[med-svn] [gdcm] 01/04: New upstream version 2.8.0

Gert Wollny gewo at moszumanska.debian.org
Wed Jul 5 09:08:11 UTC 2017


This is an automated email from the git hooks/post-receive script.

gewo pushed a commit to branch master
in repository gdcm.

commit 11474f89440ee0af9b5f83388d3d67eb29cf6b4c
Author: Gert Wollny <gewo at debian.org>
Date:   Wed Jul 5 07:25:59 2017 +0000

    New upstream version 2.8.0
---
 .clang-format                                      |    67 +
 .travis.yml                                        |     4 +-
 Applications/Cxx/gdcmdump.cxx                      |    80 +
 Applications/Cxx/gdcmscanner.cxx                   |    60 +-
 Applications/Cxx/gdcmstream.cxx                    |     6 +-
 Applications/Cxx/gdcmtar.cxx                       |     9 +-
 CMake/ExportConfiguration/CMakeLists.txt           |     2 +-
 CMake/FindJavaProperties.cmake                     |     9 +-
 CMake/FindOpenJPEG.cmake                           |    42 +-
 CMake/UseCSharp.cmake                              |    48 +-
 CMakeLists.txt                                     |    22 +-
 Examples/Cxx/CMakeLists.txt                        |    18 +-
 Examples/Cxx/DeriveSeries.cxx                      |    87 +
 Examples/Cxx/DumpGEMSMovieGroup.cxx                |     6 +-
 Examples/Cxx/DumpSiemensBase64.cxx                 |    88 +
 Examples/Cxx/Extracting_All_Resolution.cxx         |     2 +-
 Source/Common/gdcmConfigure.h.in                   |    13 +-
 Source/Common/gdcmDummyValueGenerator.cxx          |     2 +-
 Source/Common/gdcmMD5.cxx                          |   104 +-
 Source/Common/gdcmMD5.h                            |    14 +-
 .../gdcmOpenSSLCryptographicMessageSyntax.cxx      |    24 +-
 Source/Common/gdcmSwapper.txx                      |     2 +-
 Source/Common/gdcmTesting.cxx                      |     2 +-
 Source/Common/gdcmTesting.h                        |     2 +-
 Source/DataDictionary/GroupName.dic                |    72 -
 Source/DataDictionary/NIH.dic                      |    15 -
 Source/DataDictionary/Part6.xml                    |  8609 ++++++++-------
 Source/DataDictionary/Part6.xsl                    |   358 +
 Source/DataDictionary/Part6togdcm1.xsl             |    39 -
 Source/DataDictionary/SPI.dic                      |   140 -
 Source/DataDictionary/gdcm1.xsl                    |    43 -
 Source/DataDictionary/gdcm2html.xsl                |   124 -
 Source/DataDictionary/gdcm2pdf.xsl                 |   123 -
 Source/DataDictionary/gdcmPrivateDefaultDicts.cxx  |     1 +
 Source/DataDictionary/txt2xml.py                   |   396 -
 .../gdcmElement.h                                  |     2 +-
 .../gdcmMediaStorage.cxx                           |     4 +
 .../gdcmMediaStorage.h                             |     2 +
 .../gdcmReader.cxx                                 |   184 +-
 .../gdcmTransferSyntax.h                           |     2 -
 .../DataStructureAndEncodingDefinition/gdcmVM.cxx  |     4 +-
 Source/DataStructureAndEncodingDefinition/gdcmVM.h |     2 +-
 .../DataStructureAndEncodingDefinition/gdcmVR.cxx  |    44 +-
 Source/DataStructureAndEncodingDefinition/gdcmVR.h |    15 +-
 Source/InformationObjectDefinition/Part3New.xsl    |   219 +
 Source/InformationObjectDefinition/Part4.xml       |   319 +-
 Source/InformationObjectDefinition/Part4.xsl       |   257 +-
 .../gdcmTableReader.cxx                            |    24 +
 Source/MediaStorageAndFileFormat/CMakeLists.txt    |    19 +-
 .../MediaStorageAndFileFormat/gdcmAnonymizer.cxx   |     4 +-
 .../MediaStorageAndFileFormat/gdcmImageHelper.cxx  |    42 +-
 .../gdcmImageRegionReader.cxx                      |    36 +-
 .../gdcmImageRegionReader.h                        |     1 +
 .../gdcmJPEG2000Codec.cxx                          |   333 +-
 .../MediaStorageAndFileFormat/gdcmPixmapWriter.cxx |     3 -
 .../MediaStorageAndFileFormat/gdcmPixmapWriter.h   |     1 -
 Source/MediaStorageAndFileFormat/gdcmRLECodec.cxx  |    12 +-
 Source/MediaStorageAndFileFormat/gdcmSegment.cxx   |    35 +-
 Source/MediaStorageAndFileFormat/gdcmSegment.h     |    18 +-
 .../gdcmSegmentReader.cxx                          |   183 +-
 .../gdcmSegmentWriter.cxx                          |   291 +-
 Source/MediaStorageAndFileFormat/gdcmSorter.cxx    |    15 +-
 Source/MediaStorageAndFileFormat/gdcmSorter.h      |     7 +
 .../MediaStorageAndFileFormat/gdcmStringFilter.cxx |    11 -
 .../MediaStorageAndFileFormat/gdcmStringFilter.h   |     2 -
 .../gdcmSurfaceReader.cxx                          |    82 +-
 .../gdcmSurfaceWriter.cxx                          |    80 +-
 Testing/Source/Data/CMakeLists.txt                 |    13 +-
 .../Cxx/TestAttribute1.cxx                         |     4 +
 .../Cxx/TestDS.cxx                                 |   114 +-
 .../Cxx/TestElement2.cxx                           |    14 +
 .../Cxx/TestElement5.cxx                           |     2 +-
 .../Cxx/TestVR.cxx                                 |     6 +
 .../MediaStorageAndFileFormat/Cxx/TestCurve2.cxx   |     2 +-
 .../Cxx/TestImageRegionReader1.cxx                 |     2 +-
 .../Cxx/TestImageRegionReader2.cxx                 |     2 +-
 .../MediaStorageAndFileFormat/Cxx/TestOverlay3.cxx |     4 +-
 .../MediaStorageAndFileFormat/Cxx/TestPrinter1.cxx |     2 +-
 Utilities/CMakeLists.txt                           |    20 +-
 Utilities/Release/README.md                        |     2 +-
 Utilities/Release/release.sh                       |    30 +-
 Utilities/Tools/CMakeLists.txt                     |     3 -
 Utilities/Tools/upsidedown.c                       |    46 -
 Utilities/VTK/Applications/gdcm2vtk.cxx            |     2 -
 Utilities/VTK/Applications/gdcmviewer.cxx          |    18 -
 Utilities/VTK/CMakeLists.txt                       |     1 +
 Utilities/VTK/Examples/Cxx/Compute3DSpacing.cxx    |     2 -
 Utilities/VTK/Examples/Cxx/gdcmorthoplanes.cxx     |     4 -
 .../VTK/Testing/Cxx/TestvtkGDCMImageReader1.cxx    |     4 -
 .../VTK/Testing/Cxx/TestvtkGDCMImageReader2_3.cxx  |     4 -
 .../Testing/Cxx/TestvtkGDCMImageReaderIsLossy.cxx  |     4 -
 .../VTK/Testing/Cxx/TestvtkGDCMImageWriter1.cxx    |     4 -
 .../VTK/Testing/Cxx/TestvtkGDCMImageWriter2.cxx    |     4 -
 Utilities/VTK/VTK4/vtkMedicalImageProperties.cxx   |     4 -
 Utilities/VTK/VTK4/vtkMedicalImageProperties.h     |     4 -
 Utilities/VTK/VTK4/vtkStringArray.cxx              |     4 -
 Utilities/VTK/VTK4/vtkStringArray.h                |     4 -
 Utilities/VTK/vtkGDCMImageReader.cxx               |     4 -
 Utilities/VTK/vtkGDCMImageReader.h                 |     4 -
 Utilities/VTK/vtkGDCMImageReader2.cxx              |     4 -
 Utilities/VTK/vtkGDCMImageReader2.h                |     4 -
 Utilities/VTK/vtkGDCMImageWriter.cxx               |     8 -
 Utilities/VTK/vtkGDCMImageWriter.h                 |     4 -
 Utilities/VTK/vtkGDCMMedicalImageProperties.cxx    |     4 -
 Utilities/VTK/vtkGDCMMedicalImageProperties.h      |     4 -
 Utilities/VTK/vtkGDCMPolyDataReader.cxx            |     4 -
 Utilities/VTK/vtkGDCMPolyDataReader.h              |     4 -
 Utilities/VTK/vtkGDCMPolyDataWriter.cxx            |     4 -
 Utilities/VTK/vtkGDCMPolyDataWriter.h              |     4 -
 Utilities/VTK/vtkGDCMTesting.cxx                   |     4 -
 Utilities/VTK/vtkGDCMTesting.h                     |     4 -
 Utilities/VTK/vtkGDCMThreadedImageReader.cxx       |     4 -
 Utilities/VTK/vtkGDCMThreadedImageReader.h         |     4 -
 Utilities/VTK/vtkGDCMThreadedImageReader2.cxx      |     4 -
 Utilities/VTK/vtkGDCMThreadedImageReader2.h        |     4 -
 Utilities/VTK/vtkImageColorViewer.cxx              |     4 -
 Utilities/VTK/vtkImageColorViewer.h                |     4 -
 Utilities/VTK/vtkImageMapToColors16.cxx            |     4 -
 Utilities/VTK/vtkImageMapToColors16.h              |     4 -
 Utilities/VTK/vtkImageMapToWindowLevelColors2.cxx  |     4 -
 Utilities/VTK/vtkImageMapToWindowLevelColors2.h    |     4 -
 .../VTK/vtkImagePlanarComponentsToComponents.cxx   |     4 -
 .../VTK/vtkImagePlanarComponentsToComponents.h     |     5 -
 Utilities/VTK/vtkImageRGBToYBR.cxx                 |     4 -
 Utilities/VTK/vtkImageRGBToYBR.h                   |     4 -
 Utilities/VTK/vtkImageYBRToRGB.cxx                 |     4 -
 Utilities/VTK/vtkImageYBRToRGB.h                   |     4 -
 Utilities/VTK/vtkLookupTable16.cxx                 |     4 -
 Utilities/VTK/vtkLookupTable16.h                   |     4 -
 Utilities/VTK/vtkRTStructSetProperties.cxx         |     4 -
 Utilities/VTK/vtkRTStructSetProperties.h           |     4 -
 Utilities/doxygen/man/gdcmdump.xml                 |    83 +
 Utilities/gdcm_charls.h                            |     4 +-
 Utilities/gdcm_openjpeg.h                          |    18 +-
 Utilities/gdcm_openjpeg2.h                         |    41 -
 Utilities/gdcmcharls/CMakeLists.txt                |    18 +-
 Utilities/gdcmcharls/License.txt                   |    30 +-
 Utilities/gdcmcharls/README.GDCM.txt               |    30 +-
 Utilities/gdcmcharls/colortransform.h              |     3 +
 Utilities/gdcmcharls/config.h                      |     9 +-
 Utilities/gdcmcharls/context.h                     |    44 +-
 Utilities/gdcmcharls/contextrunmode.h              |    16 +-
 Utilities/gdcmcharls/decoderstrategy.h             |   542 +-
 Utilities/gdcmcharls/defaulttraits.h               |    13 +-
 Utilities/gdcmcharls/encoderstrategy.h             |   111 +-
 Utilities/gdcmcharls/header.cpp                    |   545 +-
 Utilities/gdcmcharls/header.h                      |    84 +-
 Utilities/gdcmcharls/interface.cpp                 |   270 +-
 Utilities/gdcmcharls/interface.h                   |    50 +-
 Utilities/gdcmcharls/jpegimagedatasegment.h        |    28 +
 Utilities/gdcmcharls/jpegls.cpp                    |     3 +-
 Utilities/gdcmcharls/jpegmarker.h                  |    75 +
 Utilities/gdcmcharls/jpegmarkersegment.cpp         |   120 +
 Utilities/gdcmcharls/jpegmarkersegment.h           |    40 +
 Utilities/gdcmcharls/jpegsegment.h                 |    22 +
 Utilities/gdcmcharls/jpegstreamwriter.cpp          |   107 +
 Utilities/gdcmcharls/jpegstreamwriter.h            |   114 +
 Utilities/gdcmcharls/processline.h                 |   209 +-
 Utilities/gdcmcharls/publictypes.h                 |    77 +-
 Utilities/gdcmcharls/scan.h                        |   206 +-
 Utilities/gdcmcharls/stdafx.cpp                    |     0
 Utilities/gdcmcharls/streams.h                     |   156 -
 Utilities/gdcmcharls/util.h                        |    11 +-
 Utilities/gdcmjpeg/jdcoefct.c                      |     2 +-
 Utilities/gdcmmd5/README                           |     2 -
 Utilities/gdcmmd5/README.GDCM.txt                  |    12 +
 Utilities/gdcmopenjpeg-v1/.NoDartCoverage          |     1 -
 Utilities/gdcmopenjpeg-v1/CHANGES                  |   817 --
 .../gdcmopenjpeg-v1/CMake/CTestCustom.cmake.in     |    21 -
 .../gdcmopenjpeg-v1/CMake/CheckHaveGetopt.cmake    |    15 -
 Utilities/gdcmopenjpeg-v1/CMakeLists.txt           |   387 -
 Utilities/gdcmopenjpeg-v1/CTestConfig.cmake        |     7 -
 Utilities/gdcmopenjpeg-v1/CTestCustom.cmake.in     |    21 -
 Utilities/gdcmopenjpeg-v1/INSTALL                  |   105 -
 Utilities/gdcmopenjpeg-v1/LICENSE                  |    30 -
 Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsp          |   262 -
 Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsw          |    41 -
 Utilities/gdcmopenjpeg-v1/LibOpenJPEG.sln          |    20 -
 Utilities/gdcmopenjpeg-v1/LibOpenJPEG.vcproj       |   642 --
 Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsp  |   290 -
 Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsw  |    56 -
 Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.iss  |    48 -
 Utilities/gdcmopenjpeg-v1/OPJViewer/Readme.txt     |   100 -
 .../gdcmopenjpeg-v1/OPJViewer/about/about.htm      |    36 -
 .../gdcmopenjpeg-v1/OPJViewer/about/opj_logo.png   |   Bin 6500 -> 0 bytes
 .../gdcmopenjpeg-v1/OPJViewer/buildupdate.bat      |    15 -
 .../gdcmopenjpeg-v1/OPJViewer/source/OPJAbout.cpp  |    87 -
 .../gdcmopenjpeg-v1/OPJViewer/source/OPJChild.ico  |   Bin 1078 -> 0 bytes
 .../OPJViewer/source/OPJChild16.xpm                |    28 -
 .../OPJViewer/source/OPJDialogs.cpp                |  1373 ---
 .../OPJViewer/source/OPJThreads.cpp                |  1268 ---
 .../gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.cpp |  1664 ---
 .../gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.h   |   811 --
 .../gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.ico |   Bin 1078 -> 0 bytes
 .../gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.rc  |     3 -
 .../OPJViewer/source/OPJViewer16.xpm               |    26 -
 .../gdcmopenjpeg-v1/OPJViewer/source/about_htm.h   |    54 -
 Utilities/gdcmopenjpeg-v1/OPJViewer/source/build.h |     1 -
 .../gdcmopenjpeg-v1/OPJViewer/source/icon1.xpm     |    79 -
 .../gdcmopenjpeg-v1/OPJViewer/source/icon2.xpm     |    53 -
 .../gdcmopenjpeg-v1/OPJViewer/source/icon3.xpm     |    79 -
 .../gdcmopenjpeg-v1/OPJViewer/source/icon4.xpm     |    43 -
 .../gdcmopenjpeg-v1/OPJViewer/source/icon5.xpm     |    79 -
 .../OPJViewer/source/imagjpeg2000.cpp              |  1464 ---
 .../OPJViewer/source/imagjpeg2000.h                |   177 -
 .../gdcmopenjpeg-v1/OPJViewer/source/imagmxf.cpp   |   502 -
 .../gdcmopenjpeg-v1/OPJViewer/source/imagmxf.h     |    99 -
 .../gdcmopenjpeg-v1/OPJViewer/source/license.txt   |    14 -
 .../gdcmopenjpeg-v1/OPJViewer/source/opj_logo.xpm  |   285 -
 .../OPJViewer/source/readmeafter.txt               |    34 -
 .../OPJViewer/source/readmebefore.txt              |    11 -
 .../OPJViewer/source/wxj2kparser.cpp               |  1465 ---
 .../OPJViewer/source/wxjp2parser.cpp               |  1116 --
 .../OPJ_Validate/OPJ_Param_File_v0_1.txt           |   100 -
 .../gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.c    |   244 -
 .../gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsp  |   108 -
 .../gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsw  |    29 -
 .../OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat |     8 -
 .../OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh  |    16 -
 .../OPJ_Validate/OPJ_Validate_Create_Ref.bat       |     4 -
 .../OPJ_Validate/OPJ_Validate_Create_Ref.sh        |    13 -
 Utilities/gdcmopenjpeg-v1/OPJ_Validate/README.txt  |    46 -
 .../OPJ_Validate/linux_OPJ_Param_File_v0_1.txt     |    89 -
 Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.c       |   276 -
 Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.h       |    59 -
 .../OPJ_Validate/original/README.txt               |     1 -
 Utilities/gdcmopenjpeg-v1/OpenJPEG.rc              |   109 -
 Utilities/gdcmopenjpeg-v1/README                   |     1 -
 Utilities/gdcmopenjpeg-v1/README.msvc              |    40 -
 Utilities/gdcmopenjpeg-v1/codec/CMakeLists.txt     |   102 -
 Utilities/gdcmopenjpeg-v1/codec/README             |     8 -
 Utilities/gdcmopenjpeg-v1/codec/convert.c          |  2686 -----
 Utilities/gdcmopenjpeg-v1/codec/convert.h          |    82 -
 Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.c     |  1789 ---
 Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsp   |   118 -
 Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsw   |    44 -
 Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.sln   |   Bin 1506 -> 0 bytes
 .../gdcmopenjpeg-v1/codec/image_to_j2k.vcproj      |   292 -
 Utilities/gdcmopenjpeg-v1/codec/index.c            |   391 -
 Utilities/gdcmopenjpeg-v1/codec/j2k_dump.c         |   634 --
 Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.c     |   845 --
 Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsp   |   117 -
 Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsw   |    44 -
 Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.sln   |   Bin 1506 -> 0 bytes
 .../gdcmopenjpeg-v1/codec/j2k_to_image.vcproj      |   291 -
 Utilities/gdcmopenjpeg-v1/codec/windirent.h        |   677 --
 Utilities/gdcmopenjpeg-v1/common/color.c           |   463 -
 Utilities/gdcmopenjpeg-v1/common/color.h           |    38 -
 Utilities/gdcmopenjpeg-v1/common/format_defs.h     |    48 -
 Utilities/gdcmopenjpeg-v1/common/getopt.c          |   261 -
 Utilities/gdcmopenjpeg-v1/common/getopt.h          |    29 -
 Utilities/gdcmopenjpeg-v1/doc/CMakeLists.txt       |    15 -
 Utilities/gdcmopenjpeg-v1/doc/Doxyfile.dox         |   234 -
 .../gdcmopenjpeg-v1/doc/man/man1/image_to_j2k.1    |   222 -
 Utilities/gdcmopenjpeg-v1/doc/man/man1/j2k_dump.1  |    62 -
 .../gdcmopenjpeg-v1/doc/man/man1/j2k_to_image.1    |   109 -
 .../gdcmopenjpeg-v1/doc/man/man3/libopenjpeg.3     |   337 -
 .../gdcmopenjpeg-v1/indexer_JPIP/CMakeLists.txt    |     5 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/bio.c       |   125 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.c       |   129 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.h       |    44 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.c       |    44 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.h       |    34 -
 .../gdcmopenjpeg-v1/indexer_JPIP/index_create.c    |  1219 --
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.c       |    89 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.h       |    41 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/j2k.h       |   288 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.c       |   302 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.h       |    44 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.c      |   768 --
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.h      |    42 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.c        |   465 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.h        |    72 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.c        |   389 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.h        |    46 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.c       |   285 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.h       |   137 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.c       |   170 -
 Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.h       |    80 -
 Utilities/gdcmopenjpeg-v1/jp3d/CMakeLists.txt      |    15 -
 Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.dsp       |   273 -
 Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.sln       |    21 -
 Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.vcproj    |   278 -
 Utilities/gdcmopenjpeg-v1/jp3d/LICENSE.txt         |    30 -
 Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.sln       |    21 -
 Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.vcproj    |   249 -
 Utilities/gdcmopenjpeg-v1/jp3d/README.txt          |   285 -
 .../gdcmopenjpeg-v1/jp3d/codec/CMakeLists.txt      |    47 -
 Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.c     |   997 --
 Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.h     |    51 -
 Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.c      |   109 -
 Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.h      |    14 -
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_to_volume.c    |   540 -
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.ncb     |   Bin 470016 -> 0 bytes
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.sln     |    30 -
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.suo     |   Bin 13312 -> 0 bytes
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.vcproj  |   157 -
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.ncb     |   Bin 568320 -> 0 bytes
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.sln     |    35 -
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.suo     |   Bin 21504 -> 0 bytes
 .../gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.vcproj  |   157 -
 .../gdcmopenjpeg-v1/jp3d/codec/volume_to_jp3d.c    |   906 --
 Utilities/gdcmopenjpeg-v1/jp3d/codec/windirent.h   |   676 --
 .../gdcmopenjpeg-v1/jp3d/libjp3dvm/CMakeLists.txt  |    39 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.c     |   189 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.h     |   132 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.c     |   217 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.h     |   100 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.c     |  1016 --
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.h     |   100 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.c   |   181 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.h   |    58 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/fix.h     |    62 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/int.h     |   122 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.c    |  2328 ----
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.h    |   518 -
 .../gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d_lib.c      |    76 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.c     |   131 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.h     |    97 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.c     |   548 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.h     |   201 -
 .../gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg.c      |   207 -
 .../gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg3d.h    |   713 --
 .../gdcmopenjpeg-v1/jp3d/libjp3dvm/opj_includes.h  |    81 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.c      |   630 --
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.h      |   145 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.c     |    86 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.h     |    99 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.c      |  1181 --
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.h      |   173 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.c   |  1230 ---
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.h   |   173 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.c      |   675 --
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.h      |   101 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.c     |  1738 ---
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.h     |   334 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.c     |   256 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.h     |   124 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.c  |    89 -
 Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.h  |    43 -
 .../gdcmopenjpeg-v1/jp3d/tcltk/LPI_JP3D_VM.tcl     |   114 -
 Utilities/gdcmopenjpeg-v1/jp3d/tcltk/README        |    13 -
 Utilities/gdcmopenjpeg-v1/jp3d/tcltk/Thumbs.db     |   Bin 18944 -> 0 bytes
 Utilities/gdcmopenjpeg-v1/jp3d/tcltk/decoder.tcl   |   272 -
 Utilities/gdcmopenjpeg-v1/jp3d/tcltk/encoder.tcl   |   470 -
 Utilities/gdcmopenjpeg-v1/jp3d/tcltk/logoLPI.gif   |   Bin 5212 -> 0 bytes
 Utilities/gdcmopenjpeg-v1/jpwl/CMakeLists.txt      |   107 -
 .../gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsp     |   127 -
 .../gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsw     |    44 -
 .../gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsp     |   135 -
 .../gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsw     |    44 -
 .../gdcmopenjpeg-v1/jpwl/LibOpenJPEG_JPWL.dsp      |   282 -
 Utilities/gdcmopenjpeg-v1/jpwl/README.txt          |   136 -
 Utilities/gdcmopenjpeg-v1/jpwl/crc.c               |   160 -
 Utilities/gdcmopenjpeg-v1/jpwl/crc.h               |    84 -
 Utilities/gdcmopenjpeg-v1/jpwl/jpwl.c              |  1357 ---
 Utilities/gdcmopenjpeg-v1/jpwl/jpwl.h              |   425 -
 Utilities/gdcmopenjpeg-v1/jpwl/jpwl_lib.c          |  1796 ---
 Utilities/gdcmopenjpeg-v1/jpwl/rs.c                |   594 -
 Utilities/gdcmopenjpeg-v1/jpwl/rs.h                |   111 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg.pc.in        |    11 -
 .../gdcmopenjpeg-v1/libopenjpeg/CMakeLists.txt     |    63 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.c        |   191 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.h        |    86 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/dwt.c        |   858 --
 Utilities/gdcmopenjpeg-v1/libopenjpeg/event.h      |    58 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/fix.h        |    64 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/image.c      |    89 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/image.h      |    48 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/int.h        |   119 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.c        |  2434 ----
 Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.h        |   446 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k_lib.h    |    54 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.c        |  1089 --
 Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.h        |   231 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.c        |   155 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.h        |    75 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/mct.c        |   190 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.c   |   337 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.h   |   919 --
 .../gdcmopenjpeg-v1/libopenjpeg/opj_includes.h     |   136 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/opj_malloc.h |   163 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.c         |   963 --
 Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.h         |   156 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/t1.c         |  1581 ---
 Utilities/gdcmopenjpeg-v1/libopenjpeg/t2.c         |   795 --
 Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.c        |  1516 ---
 Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.h        |   286 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.c        |   213 -
 Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.h        |   114 -
 Utilities/gdcmopenjpeg-v1/ltmain.sh                |  8750 ---------------
 Utilities/gdcmopenjpeg-v1/missing                  |   376 -
 Utilities/gdcmopenjpeg-v1/mj2/CMakeLists.txt       |    87 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsp    |   196 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsw    |    44 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.sln    |    29 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.vcproj |   354 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsp      |   195 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsw      |    44 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.sln      |    29 -
 Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.vcproj   |   353 -
 .../gdcmopenjpeg-v1/mj2/extract_j2k_from_mj2.c     |   148 -
 Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.c      |   806 --
 Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsp    |   212 -
 Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsw    |    44 -
 Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.sln    |   Bin 1508 -> 0 bytes
 Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.vcproj |   406 -
 Utilities/gdcmopenjpeg-v1/mj2/meta_out.c           |  2181 ----
 Utilities/gdcmopenjpeg-v1/mj2/meta_out.h           |    13 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2.c                |  2911 -----
 Utilities/gdcmopenjpeg-v1/mj2/mj2.h                |   391 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.c        |   329 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.h        |    45 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.c      |   250 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsp    |   159 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsw    |    44 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.sln    |    29 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.vcproj |   324 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.c    |   312 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsp  |   140 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsw  |    44 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dtd  |   425 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.h    |     9 -
 Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.sln  |    29 -
 .../gdcmopenjpeg-v1/mj2/mj2_to_metadata.vcproj     |   349 -
 .../gdcmopenjpeg-v1/mj2/mj2_to_metadata_Notes.doc  |   Bin 35328 -> 0 bytes
 Utilities/gdcmopenjpeg-v1/mj2/readme.txt           |     3 -
 Utilities/gdcmopenjpeg-v1/mj2/wrap_j2k_in_mj2.c    |   371 -
 Utilities/gdcmopenjpeg-v1/openjpeg_mangle.h.in     |   151 -
 Utilities/gdcmopenjpeg-v1/opj_config.h.in          |   104 -
 Utilities/gdcmopenjpeg-v1/opj_config.h.in.user     |    41 -
 Utilities/gdcmopenjpeg-v1/opj_configh.cmake.in     |    31 -
 Utilities/gdcmopenjpeg-v2/.NoDartCoverage          |     1 -
 .../gdcmopenjpeg-v2/CMake/CTestCustom.cmake.in     |    21 -
 .../gdcmopenjpeg-v2/CMake/FindFreeImage.cmake      |    50 -
 .../gdcmopenjpeg-v2/CMake/Free_CMakeImport.cmake   |     3 -
 .../gdcmopenjpeg-v2/CMake/OpenJPEGConfig.cmake.in  |    48 -
 .../gdcmopenjpeg-v2/CMake/mymachine_openjpeg.cmake |    50 -
 Utilities/gdcmopenjpeg-v2/CMakeLists.txt           |   195 -
 Utilities/gdcmopenjpeg-v2/CTestConfig.cmake        |     7 -
 Utilities/gdcmopenjpeg-v2/README.cmake             |     9 -
 Utilities/gdcmopenjpeg-v2/README.linux             |    33 -
 Utilities/gdcmopenjpeg-v2/README.msvc              |    36 -
 Utilities/gdcmopenjpeg-v2/README.osx               |    26 -
 Utilities/gdcmopenjpeg-v2/README.v2                |    25 -
 Utilities/gdcmopenjpeg-v2/codec/CMakeLists.txt     |    94 -
 Utilities/gdcmopenjpeg-v2/codec/Makefile           |    14 -
 Utilities/gdcmopenjpeg-v2/codec/compat/getopt.c    |   257 -
 Utilities/gdcmopenjpeg-v2/codec/compat/getopt.h    |    29 -
 Utilities/gdcmopenjpeg-v2/codec/convert.c          |  2519 -----
 Utilities/gdcmopenjpeg-v2/codec/convert.h          |    78 -
 Utilities/gdcmopenjpeg-v2/codec/dirent.h           |   677 --
 Utilities/gdcmopenjpeg-v2/codec/image_to_j2k.c     |  1797 ---
 Utilities/gdcmopenjpeg-v2/codec/index.c            |   391 -
 Utilities/gdcmopenjpeg-v2/codec/j2k_dump.c         |   495 -
 Utilities/gdcmopenjpeg-v2/codec/j2k_to_image.c     |   769 --
 Utilities/gdcmopenjpeg-v2/doc/CMakeLists.txt       |    12 -
 Utilities/gdcmopenjpeg-v2/doc/Doxyfile.dox         |   234 -
 Utilities/gdcmopenjpeg-v2/jpwl/CMakeLists.txt      |    54 -
 Utilities/gdcmopenjpeg-v2/jpwl/README.txt          |   136 -
 Utilities/gdcmopenjpeg-v2/jpwl/crc.c               |   160 -
 Utilities/gdcmopenjpeg-v2/jpwl/crc.h               |    84 -
 Utilities/gdcmopenjpeg-v2/jpwl/jpwl.c              |  1356 ---
 Utilities/gdcmopenjpeg-v2/jpwl/jpwl.h              |   424 -
 Utilities/gdcmopenjpeg-v2/jpwl/jpwl_lib.c          |  1796 ---
 Utilities/gdcmopenjpeg-v2/jpwl/rs.c                |   594 -
 Utilities/gdcmopenjpeg-v2/jpwl/rs.h                |   111 -
 .../gdcmopenjpeg-v2/libopenjpeg/CMakeLists.txt     |    92 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.c        |   189 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.h        |   125 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.c        |   825 --
 Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.h        |   358 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.c        |   873 --
 Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.h        |   118 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/event.c      |    95 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/fix.h        |    60 -
 .../gdcmopenjpeg-v2/libopenjpeg/function_list.c    |   149 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/image.c      |   174 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/int.h        |   159 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/invert.c     |   290 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.c        |  9411 ----------------
 Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.h        |   737 --
 Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k_lib.c    |    64 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.c        |  2229 ----
 Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.h        |   341 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.c        |   249 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.h        |    83 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.c        |   303 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.h        |   130 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.c        |   542 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.h        |   198 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.c   |   947 --
 Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.h   |  1072 --
 .../gdcmopenjpeg-v2/libopenjpeg/opj_configure.h    |    16 -
 .../gdcmopenjpeg-v2/libopenjpeg/opj_includes.h     |   124 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_malloc.h |   144 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/pi.c         |  2000 ----
 Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.c    |   177 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.h    |    83 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.c        |    88 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.h        |   101 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.c         |  1284 ---
 Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.h         |   156 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/t1_luts.h    |   142 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.c         |  1287 ---
 Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.h         |   120 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.c        |  2121 ----
 Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.h        |   344 -
 Utilities/gdcmopenjpeg-v2/libopenjpeg/tgt.c        |   344 -
 Utilities/gdcmopenjpeg-v2/mj2/CMakeLists.txt       |    42 -
 Utilities/gdcmopenjpeg-v2/mj2/Makefile             |    20 -
 .../gdcmopenjpeg-v2/mj2/extract_j2k_from_mj2.c     |   148 -
 Utilities/gdcmopenjpeg-v2/mj2/frames_to_mj2.c      |   806 --
 Utilities/gdcmopenjpeg-v2/mj2/meta_out.c           |  2181 ----
 Utilities/gdcmopenjpeg-v2/mj2/meta_out.h           |    12 -
 Utilities/gdcmopenjpeg-v2/mj2/mj2.c                |  2906 -----
 Utilities/gdcmopenjpeg-v2/mj2/mj2.h                |   391 -
 Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.c        |   329 -
 Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.h        |    45 -
 Utilities/gdcmopenjpeg-v2/mj2/mj2_to_frames.c      |   225 -
 Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.c    |   312 -
 Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.dtd  |   425 -
 Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.h    |     9 -
 .../gdcmopenjpeg-v2/mj2/mj2_to_metadata_Notes.doc  |   Bin 35328 -> 0 bytes
 Utilities/gdcmopenjpeg-v2/mj2/readme.txt           |     3 -
 Utilities/gdcmopenjpeg-v2/mj2/wrap_j2k_in_mj2.c    |   368 -
 Utilities/gdcmopenjpeg-v2/openjpeg_mangle.h.in     |   278 -
 Utilities/gdcmopenjpeg-v2/opj_configure.h.in       |    16 -
 .../CMakeLists.txt                                 |    27 -
 .../test2_decoder.c                                |   367 -
 .../test2_encoder.c                                |   486 -
 .../test_V2_tile_handling/CMakeLists.txt           |    24 -
 .../test_V2_tile_handling/test_decoder.c           |   247 -
 .../test_V2_tile_handling/test_encoder.c           |   301 -
 Utilities/gdcmopenjpeg/CMakeLists.txt              |   385 +
 .../license.txt => gdcmopenjpeg/LICENSE}           |    19 +-
 Utilities/gdcmopenjpeg/README.GDCM.txt             |    23 +
 Utilities/gdcmopenjpeg/cmake/CTestCustom.cmake.in  |    40 +
 .../gdcmopenjpeg/cmake/EnsureFileInclude.cmake     |    26 +
 Utilities/gdcmopenjpeg/cmake/FindCPPCHECK.cmake    |    16 +
 Utilities/gdcmopenjpeg/cmake/FindFCGI.cmake        |    20 +
 Utilities/gdcmopenjpeg/cmake/FindJPYLYZER.cmake    |    12 +
 Utilities/gdcmopenjpeg/cmake/FindKAKADU.cmake      |    24 +
 Utilities/gdcmopenjpeg/cmake/FindLCMS.cmake        |    31 +
 Utilities/gdcmopenjpeg/cmake/FindLCMS2.cmake       |    31 +
 Utilities/gdcmopenjpeg/cmake/JPIPTestDriver.cmake  |     9 +
 Utilities/gdcmopenjpeg/cmake/OpenJPEGCPack.cmake   |    72 +
 .../cmake}/OpenJPEGConfig.cmake.in                 |    14 +-
 Utilities/gdcmopenjpeg/cmake/TestFileOffsetBits.c  |    11 +
 .../gdcmopenjpeg/cmake/TestLargeFiles.c.cmake.in   |    23 +
 Utilities/gdcmopenjpeg/cmake/TestLargeFiles.cmake  |   134 +
 Utilities/gdcmopenjpeg/cmake/TestWindowsFSeek.c    |    11 +
 .../gdcmopenjpeg/cmake/openjpeg_valgrind.supp      |    39 +
 Utilities/gdcmopenjpeg/src/lib/CMakeLists.txt      |    17 +
 .../gdcmopenjpeg/src/lib/openjp2/CMakeLists.txt    |   153 +
 .../src/lib/openjp2}/bio.c                         |   116 +-
 .../src/lib/openjp2}/bio.h                         |    47 +-
 .../gdcmopenjpeg/src/lib/openjp2/cidx_manager.c    |   241 +
 .../src/lib/openjp2/cidx_manager.h}                |    50 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/cio.c       |   644 ++
 Utilities/gdcmopenjpeg/src/lib/openjp2/cio.h       |   394 +
 Utilities/gdcmopenjpeg/src/lib/openjp2/dwt.c       |   934 ++
 .../src/lib/openjp2}/dwt.h                         |    37 +-
 .../src/lib/openjp2}/event.c                       |    83 +-
 .../src/lib/openjp2}/event.h                       |    78 +-
 .../gdcmopenjpeg/src/lib/openjp2/function_list.c   |   117 +
 .../src/lib/openjp2}/function_list.h               |    69 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/image.c     |   242 +
 .../src/lib/openjp2}/image.h                       |    33 +-
 .../src/lib/openjp2/indexbox_manager.h             |   148 +
 Utilities/gdcmopenjpeg/src/lib/openjp2/invert.c    |   294 +
 .../src/lib/openjp2}/invert.h                      |    37 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.c       | 10981 +++++++++++++++++++
 Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.h       |   863 ++
 Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.c       |  3168 ++++++
 Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.h       |   483 +
 .../src/lib/openjp2/libopenjp2.pc.cmake.in         |    14 +
 Utilities/gdcmopenjpeg/src/lib/openjp2/mct.c       |   557 +
 .../src/lib/openjp2}/mct.h                         |    75 +-
 .../src/lib/openjp2}/mqc.c                         |   253 +-
 .../src/lib/openjp2}/mqc.h                         |    67 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.c  |   960 ++
 Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.h  |  1564 +++
 .../src/lib/openjp2/openjpeg_mangle.h.in           |    61 +
 .../src/lib/openjp2/opj_clock.c}                   |    20 +-
 .../src/lib/openjp2/opj_clock.h}                   |    22 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/opj_codec.h |   165 +
 .../src/lib/openjp2/opj_config.h.cmake.in          |    10 +
 .../src/lib/openjp2/opj_config_private.h.cmake.in  |    49 +
 .../gdcmopenjpeg/src/lib/openjp2/opj_includes.h    |   218 +
 .../gdcmopenjpeg/src/lib/openjp2/opj_intmath.h     |   223 +
 .../src/lib/openjp2/opj_inttypes.h}                |    40 +-
 .../gdcmopenjpeg/src/lib/openjp2/opj_malloc.c      |   239 +
 .../src/lib/openjp2/opj_malloc.h}                  |   173 +-
 .../src/lib/openjp2/opj_stdint.h}                  |   101 +-
 .../gdcmopenjpeg/src/lib/openjp2/phix_manager.c    |   193 +
 Utilities/gdcmopenjpeg/src/lib/openjp2/pi.c        |  1878 ++++
 .../src/lib/openjp2}/pi.h                          |    99 +-
 .../gdcmopenjpeg/src/lib/openjp2/ppix_manager.c    |   196 +
 .../src/lib/openjp2}/raw.c                         |    30 +-
 .../src/lib/openjp2}/raw.h                         |    36 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/t1.c        |  1767 +++
 .../src/lib/openjp2}/t1.h                          |    74 +-
 .../src/lib/openjp2}/t1_generate_luts.c            |    67 +-
 .../src/lib/openjp2}/t1_luts.h                     |    14 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/t2.c        |  1386 +++
 .../src/lib/openjp2}/t2.h                          |    87 +-
 Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.c       |  2194 ++++
 Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.h       |   369 +
 Utilities/gdcmopenjpeg/src/lib/openjp2/tgt.c       |   335 +
 .../src/lib/openjp2}/tgt.h                         |    73 +-
 .../gdcmopenjpeg/src/lib/openjp2/thix_manager.c    |   136 +
 .../gdcmopenjpeg/src/lib/openjp2/tpix_manager.c    |   185 +
 Utilities/gdcmutfcpp/README.GDCM.txt               |    12 +-
 Utilities/gdcmutfcpp/utf8.h                        |    68 +-
 Utilities/gdcmutfcpp/utf8/checked.h                |   132 +-
 Utilities/gdcmutfcpp/utf8/core.h                   |   215 +-
 Utilities/gdcmutfcpp/utf8/unchecked.h              |    48 +-
 Utilities/gdcmzlib/README.GDCM.txt                 |    14 +
 Utilities/gdcmzlib/gzio.c                          |     4 +-
 Utilities/rle/CMakeLists.txt                       |    16 -
 Utilities/rle/example.c                            |    92 -
 Utilities/rle/rle.c                                |    35 -
 Utilities/rle/rledump.c                            |    53 -
 Utilities/rle/rlelib.c                             |   162 -
 Utilities/rle/rlelib.h                             |    67 -
 Utilities/wxWidgets/CMakeLists.txt                 |    67 -
 Utilities/wxWidgets/Copyright.txt                  |    17 -
 Utilities/wxWidgets/MyDialog.cpp                   |    30 -
 Utilities/wxWidgets/MyDialog.h                     |    32 -
 Utilities/wxWidgets/main.cpp                       |    23 -
 Utilities/wxWidgets/wxGDCMFrame.cpp                |   112 -
 Utilities/wxWidgets/wxGDCMFrame.h                  |    31 -
 Utilities/wxWidgets/wxGDCMFrameBase.cpp            |    79 -
 Utilities/wxWidgets/wxGDCMFrameBase.h              |    45 -
 .../wxWidgets/wxVTKRenderWindowInteractor.cxx      |   815 --
 Utilities/wxWidgets/wxVTKRenderWindowInteractor.h  |   181 -
 Utilities/wxWidgets/wxgdcm.wxg                     |   180 -
 Wrapping/Python/docstrings.i                       |    18 +-
 Wrapping/Python/gdcmswig.i                         |     1 +
 appveyor.yml                                       |     2 +-
 641 files changed, 42095 insertions(+), 151084 deletions(-)

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..355f43f
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,67 @@
+---
+Language:        Cpp
+# BasedOnStyle:  Google
+AccessModifierOffset: -1
+AlignAfterOpenBracket: true
+AlignConsecutiveAssignments: false
+AlignEscapedNewlinesLeft: true
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Attach
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+ColumnLimit:     80
+CommentPragmas:  '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: true
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IndentCaseLabels: true
+IndentWidth:     2
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: false
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: false
+PenaltyBreakBeforeFirstCallParameter: 1
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 200
+PointerAlignment: Left
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 2
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Auto
+TabWidth:        8
+UseTab:          Never
+...
+
diff --git a/.travis.yml b/.travis.yml
index a0c1ede..8b3a54e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,11 +29,11 @@ matrix:
         - CPACK_NAME=Linux
     - compiler: gcc
       os: linux
-      addons: {apt: {packages: [default-jdk, mono-devel, swig, libcharls-dev, libvtk5-dev, libopenjpeg-dev, libexpat-dev, libz-dev, uuid-dev, python-all-dev, libpoppler-dev, xsltproc, docbook-xsl, dcmtk]}}
+      addons: {apt: {packages: [default-jdk, mono-devel, swig, libcharls-dev, libvtk5-dev, libexpat-dev, libz-dev, uuid-dev, python-all-dev, libpoppler-dev, xsltproc, docbook-xsl, dcmtk]}}
       env:
         - CFLAGS="-Wall -Wextra -m64"
         - CXXFLAGS="-Wall -Wextra -m64"
-        - CMAKE_EXTRA="-DGDCM_USE_SYSTEM_OPENSSL:BOOL=ON -DGDCM_WRAP_PYTHON:BOOL=ON -DGDCM_WRAP_CSHARP:BOOL=ON -DGDCM_WRAP_JAVA:BOOL=ON -DGDCM_WRAP_PHP:BOOL=OFF -DGDCM_USE_SYSTEM_EXPAT:BOOL=ON -DGDCM_USE_SYSTEM_JSON:BOOL=OFF -DGDCM_USE_SYSTEM_LIBXML2:BOOL=ON -DGDCM_USE_SYSTEM_OPENJPEG:BOOL=ON -DGDCM_USE_SYSTEM_POPPLER:BOOL=ON -DGDCM_USE_SYSTEM_UUID:BOOL=ON -DGDCM_USE_SYSTEM_ZLIB:BOOL=ON -DGDCM_WEAK_SWIG_CHECK:BOOL=ON -DGDCM_LEGACY_SILENT:BOOL=ON -DGDCM_BUILD_DOCBOOK_MANPAGES:BOOL=OFF"
+        - CMAKE_EXTRA="-DGDCM_USE_SYSTEM_OPENSSL:BOOL=ON -DGDCM_WRAP_PYTHON:BOOL=ON -DGDCM_WRAP_CSHARP:BOOL=ON -DGDCM_WRAP_JAVA:BOOL=ON -DGDCM_WRAP_PHP:BOOL=OFF -DGDCM_USE_SYSTEM_EXPAT:BOOL=ON -DGDCM_USE_SYSTEM_JSON:BOOL=OFF -DGDCM_USE_SYSTEM_LIBXML2:BOOL=ON -DGDCM_USE_SYSTEM_OPENJPEG:BOOL=OFF -DGDCM_USE_SYSTEM_POPPLER:BOOL=ON -DGDCM_USE_SYSTEM_UUID:BOOL=ON -DGDCM_USE_SYSTEM_ZLIB:BOOL=ON -DGDCM_WEAK_SWIG_CHECK:BOOL=ON -DGDCM_LEGACY_SILENT:BOOL=ON -DGDCM_BUILD_DOCBOOK_MANPAGES:BOOL=OFF"
         - B_NAME=system
         - CPACK_NAME=Linux
     - compiler: clang
diff --git a/Applications/Cxx/gdcmdump.cxx b/Applications/Cxx/gdcmdump.cxx
index 459c90e..41ba9e4 100644
--- a/Applications/Cxx/gdcmdump.cxx
+++ b/Applications/Cxx/gdcmdump.cxx
@@ -48,6 +48,7 @@
 #include "gdcmSequenceOfItems.h"
 #include "gdcmASN1.h"
 #include "gdcmAttribute.h"
+#include "gdcmBase64.h"
 
 #include <string>
 #include <iostream>
@@ -821,6 +822,58 @@ static int PrintPDB(const std::string & filename, bool verbose)
   return ret;
 }
 
+static int PrintCSABase64(const std::string & filename, const char * name)
+{
+  gdcm::Reader reader;
+  reader.SetFileName( filename.c_str() );
+  if( !reader.Read() )
+  {
+    std::cerr << "Failed to read: " << filename << std::endl;
+    return 1;
+  }
+  const gdcm::DataSet& ds = reader.GetFile().GetDataSet();
+
+  gdcm::CSAHeader csa;
+  const gdcm::PrivateTag &t1 = csa.GetCSAImageHeaderInfoTag();
+  if( !ds.FindDataElement( t1 ) ) return 1;
+  csa.LoadFromDataElement( ds.GetDataElement( t1 ) );
+
+  if( csa.FindCSAElementByName(name) )
+  {
+    const gdcm::CSAElement & el = csa.GetCSAElementByName(name);
+    if( el.IsEmpty() ) return 1;
+    const gdcm::ByteValue* bv = el.GetByteValue();
+    std::string str( bv->GetPointer(), bv->GetLength() );
+    str.erase(std::remove(str.begin(), str.end(), '\n'), str.end());
+    size_t dl = gdcm::Base64::GetDecodeLength( str.c_str(), str.size() );
+    std::vector<char> buf;
+    buf.resize( dl );
+    size_t dl2 = gdcm::Base64::Decode( &buf[0], buf.size(), str.c_str(), str.size() );
+    if( dl != dl2 ) return 1;
+    std::stringstream ss;
+    ss.str( std::string(&buf[0], buf.size()) );
+    gdcm::File file;
+    gdcm::DataSet &ds2 = file.GetDataSet();
+    gdcm::DataElement xde;
+    try
+    {
+      while( xde.Read<gdcm::ExplicitDataElement,gdcm::SwapperNoOp>( ss ) )
+      {
+        ds2.Insert( xde );
+      }
+      assert( ss.eof() );
+    }
+    catch(std::exception &)
+    {
+      return 1;
+    }
+    gdcm::Printer p;
+    p.SetFile( file );
+    p.Print(std::cout);
+  }
+  return 0;
+}
+
 static int PrintCSA(const std::string & filename)
 {
   gdcm::Reader reader;
@@ -934,6 +987,8 @@ static void PrintHelp()
   std::cout << "  -p --print          print value instead of simply dumping (default)." << std::endl;
   std::cout << "  -c --color          print in color." << std::endl;
   std::cout << "  -C --csa            print SIEMENS CSA Header (0029,[12]0,SIEMENS CSA HEADER)." << std::endl;
+  std::cout << "     --csa-asl        print decoded SIEMENS CSA MR_ASL (base64)." << std::endl;
+  std::cout << "     --csa-diffusion  print decoded SIEMENS CSA MRDiffusion (base64)." << std::endl;
   std::cout << "  -P --pdb            print GEMS Protocol Data Block (0025,1b,GEMS_SERS_01)." << std::endl;
   std::cout << "     --elscint        print ELSCINT Protocol Information (01f7,26,ELSCINT1)." << std::endl;
   std::cout << "     --vepro          print VEPRO Protocol Information (0055,20,VEPRO VIF 3.0 DATA)." << std::endl;
@@ -963,6 +1018,9 @@ int main (int argc, char *argv[])
   int dump = 0;
   int print = 0;
   int printcsa = 0;
+  int printcsabase64 = 0;
+  int printcsaasl = 0;
+  int printcsadiffusion = 0;
   int printpdb = 0;
   int printelscint = 0;
   int printvepro = 0;
@@ -1010,6 +1068,8 @@ int main (int argc, char *argv[])
         {"vepro", 0, &printvepro, 1},
         {"sds", 0, &printsds, 1},
         {"ct3", 0, &printct3, 1},
+        {"csa-asl", 0, &printcsaasl, 1},
+        {"csa-diffusion", 0, &printcsadiffusion, 1},
         {0, 0, 0, 0} // required
     };
     static const char short_options[] = "i:xrpdcCPAVWDEhvI";
@@ -1181,6 +1241,18 @@ int main (int argc, char *argv[])
     std::cerr << "Not handled for now" << std::endl;
     }
 
+  const char * csaname = NULL;
+  if( printcsaasl )
+  {
+    printcsabase64 = 1;
+    csaname = "MR_ASL";
+  }
+  else if( printcsadiffusion )
+  {
+    printcsabase64 = 1;
+    csaname = "MRDiffusion";
+  }
+
   // else
   int res = 0;
   if( !gdcm::System::FileExists(filename.c_str()) )
@@ -1227,6 +1299,10 @@ int main (int argc, char *argv[])
         {
         res += PrintCSA(*it);
         }
+      else if( printcsabase64 )
+        {
+        res += PrintCSABase64(*it, csaname);
+        }
       else if( dump )
         {
         res += DoOperation<gdcm::Dumper>(*it);
@@ -1274,6 +1350,10 @@ int main (int argc, char *argv[])
       {
       res += PrintCSA(filename);
       }
+    else if( printcsabase64 )
+      {
+      res += PrintCSABase64(filename, csaname);
+      }
     else if( dump )
       {
       res += DoOperation<gdcm::Dumper>(filename);
diff --git a/Applications/Cxx/gdcmscanner.cxx b/Applications/Cxx/gdcmscanner.cxx
index 6b42222..4659606 100644
--- a/Applications/Cxx/gdcmscanner.cxx
+++ b/Applications/Cxx/gdcmscanner.cxx
@@ -28,6 +28,7 @@
  */
 
 #include "gdcmScanner.h"
+#include "gdcmStrictScanner.h"
 #include "gdcmTrace.h"
 #include "gdcmVersion.h"
 #include "gdcmSimpleSubjectWatcher.h"
@@ -69,6 +70,38 @@ static void PrintHelp()
   std::cout << "  -v --version    print version." << std::endl;
 }
 
+typedef std::vector<gdcm::Tag> VectorTags;
+typedef std::vector<gdcm::PrivateTag> VectorPrivateTags;
+template < typename TScanner >
+static int DoIt(
+  gdcm::Directory const & d,
+  bool const & print ,
+    VectorTags const & tags,
+  VectorPrivateTags const & privatetags)
+{
+  gdcm::SmartPointer<TScanner> ps = new TScanner;
+  TScanner &s = *ps;
+  //gdcm::SimpleSubjectWatcher watcher(ps, "Scanner");
+  for( VectorTags::const_iterator it = tags.begin(); it != tags.end(); ++it)
+    {
+    s.AddTag( *it );
+    }
+  for( VectorPrivateTags::const_iterator it = privatetags.begin(); it != privatetags.end(); ++it)
+    {
+    s.AddPrivateTag( *it );
+    }
+  bool b = s.Scan( d.GetFilenames() );
+  if( !b )
+    {
+    std::cerr << "Scanner failed" << std::endl;
+    return 1;
+    }
+  if (print) s.Print( std::cout );
+
+  return 0;
+}
+
+
 int main(int argc, char *argv[])
 {
   int c;
@@ -77,13 +110,12 @@ int main(int argc, char *argv[])
   bool print = false;
   bool recursive = false;
   std::string dirname;
-  typedef std::vector<gdcm::Tag> VectorTags;
-  typedef std::vector<gdcm::PrivateTag> VectorPrivateTags;
   VectorTags tags;
   VectorPrivateTags privatetags;
   gdcm::Tag tag;
   gdcm::PrivateTag privatetag;
 
+  int strict = 0;
   int verbose = 0;
   int warning = 0;
   int debug = 0;
@@ -100,6 +132,7 @@ int main(int argc, char *argv[])
         {"recursive", 1, 0, 0},
         {"print", 1, 0, 0},
         {"private-tag", 1, 0, 0},
+        {"strict", 0, &strict, 1},
 
 // General options !
         {"verbose", 0, &verbose, 1},
@@ -260,24 +293,7 @@ int main(int argc, char *argv[])
   if( verbose ) d.Print( std::cout );
   std::cout << "done retrieving file list " << nfiles << " files found." <<  std::endl;
 
-  gdcm::SmartPointer<gdcm::Scanner> ps = new gdcm::Scanner;
-  gdcm::Scanner &s = *ps;
-  //gdcm::SimpleSubjectWatcher watcher(ps, "Scanner");
-  for( VectorTags::const_iterator it = tags.begin(); it != tags.end(); ++it)
-    {
-    s.AddTag( *it );
-    }
-  for( VectorPrivateTags::const_iterator it = privatetags.begin(); it != privatetags.end(); ++it)
-    {
-    s.AddPrivateTag( *it );
-    }
-  bool b = s.Scan( d.GetFilenames() );
-  if( !b )
-    {
-    std::cerr << "Scanner failed" << std::endl;
-    return 1;
-    }
-  if (print) s.Print( std::cout );
-
-  return 0;
+  if( strict )
+    return DoIt<gdcm::StrictScanner>(d,print,tags,privatetags);
+  return DoIt<gdcm::Scanner>(d,print,tags,privatetags);
 }
diff --git a/Applications/Cxx/gdcmstream.cxx b/Applications/Cxx/gdcmstream.cxx
index 8cc5baf..5e5c6da 100644
--- a/Applications/Cxx/gdcmstream.cxx
+++ b/Applications/Cxx/gdcmstream.cxx
@@ -27,10 +27,10 @@
 #include "gdcmUIDGenerator.h"
 #include "gdcmVersion.h"
 
-#ifdef OPENJPEG_MAJOR_VERSION
-#if OPENJPEG_MAJOR_VERSION == 1
+#ifdef OPENJPEG_VERSION_MAJOR
+#if OPENJPEG_VERSION_MAJOR == 1
 #include "gdcm_openjpeg.h"
-#elif OPENJPEG_MAJOR_VERSION == 2
+#elif OPENJPEG_VERSION_MAJOR == 2
 #define USE_OPJ_DEPRECATED // opj_setup_decoder
 #include "gdcm_openjpeg2.h"
 #else
diff --git a/Applications/Cxx/gdcmtar.cxx b/Applications/Cxx/gdcmtar.cxx
index 5ee1774..7ac126a 100644
--- a/Applications/Cxx/gdcmtar.cxx
+++ b/Applications/Cxx/gdcmtar.cxx
@@ -164,9 +164,12 @@ static frame_diff get_frame_diff( const char* filename )
     assert( csa.GetFormat() == gdcm::CSAHeader::SV10
       || csa.GetFormat() == gdcm::CSAHeader::NOMAGIC );
     // SIEMENS / Diffusion
-    //const CSAElement &bvalue  = csa.GetCSAElementByName( "B_value" );
-    //const CSAElement &bmatrix = csa.GetCSAElementByName( "B_matrix" );
-    //const CSAElement &dgd = csa.GetCSAElementByName( "DiffusionGradientDirection" );
+    const CSAElement &bvalue  = csa.GetCSAElementByName( "B_value" );
+    (void)bvalue;
+    const CSAElement &bmatrix = csa.GetCSAElementByName( "B_matrix" );
+    (void)bmatrix;
+    const CSAElement &dgd = csa.GetCSAElementByName( "DiffusionGradientDirection" );
+    (void)dgd;
     //assert(0);
     }
   else
diff --git a/CMake/ExportConfiguration/CMakeLists.txt b/CMake/ExportConfiguration/CMakeLists.txt
index 59d721c..6934229 100644
--- a/CMake/ExportConfiguration/CMakeLists.txt
+++ b/CMake/ExportConfiguration/CMakeLists.txt
@@ -115,7 +115,7 @@ set(targets
   gdcmjpeg12
   gdcmjpeg16
   gdcmexpat
-  gdcmopenjpeg
+  gdcmopenjp2
   gdcmcharls
   gdcmmd5
   gdcmzlib
diff --git a/CMake/FindJavaProperties.cmake b/CMake/FindJavaProperties.cmake
index 10f28cf..85ceafc 100644
--- a/CMake/FindJavaProperties.cmake
+++ b/CMake/FindJavaProperties.cmake
@@ -33,13 +33,6 @@ if(JavaProp_JAVA_HOME)
     ${JavaProp_JAVA_HOME}
     PATH
     )
-  #string(FIND "${javarealpath}" "${javahomesubdir}" res)
-  #if(-1 EQUAL ${res})
-  #  message(STATUS "Need to re-execute JavaProp")
-  #  file(REMOVE
-  #    ${CMAKE_BINARY_DIR}/GetSystemProperty.class
-  #    )
-  #endif()
   string(REGEX MATCH "${javahomesubdir}"
     outputvar
     "${javarealpath}"
@@ -81,7 +74,7 @@ if(${current_list_path}/GetSystemProperty.java IS_NEWER_THAN ${CMAKE_BINARY_DIR}
       OUTPUT_VARIABLE ${property_cmake_name}
       OUTPUT_STRIP_TRAILING_WHITESPACE
       )
-    #message("${property} : ${property_cmake_name} : ${${property_cmake_name}}")
+    #message(STATUS "${property} : ${property_cmake_name} : ${${property_cmake_name}}")
     set(JavaProp_${property_cmake_name} ${${property_cmake_name}}
       CACHE STRING "Java Prop Value for: ${property}" FORCE
       )
diff --git a/CMake/FindOpenJPEG.cmake b/CMake/FindOpenJPEG.cmake
index 5db1b5c..bdd5773 100644
--- a/CMake/FindOpenJPEG.cmake
+++ b/CMake/FindOpenJPEG.cmake
@@ -20,44 +20,16 @@
 
 # Try with pkg-config first
 find_package(PkgConfig)
-pkg_check_modules(OPENJPEG libopenjpeg1)
-if(OPENJPEG_FOUND)
-    set(OPENJPEG_MAJOR_VERSION 1)
-    set(OPENJPEG_INCLUDE_DIR ${OPENJPEG_INCLUDE_DIRS})
-    set(OPENJPEG_LIBRARIES ${OPENJPEG_LDFLAGS})
-else()
-# Try to locate a cmake config file
-find_package(OpenJPEG QUIET NO_MODULE)
-mark_as_advanced(OpenJPEG_DIR)
-
-if( NOT OpenJPEG_DIR )
-set(OPENJPEG_MAJOR_VERSION 1) # FIXME ?
-find_path(OPENJPEG_INCLUDE_DIR
-  NAMES openjpeg.h #openjpeg-1.0/openjpeg.h
-  PATHS /usr/local/include
-  /usr/local/include/openjpeg-1.0
-  /usr/include
-  /usr/include/openjpeg-1.0
-  )
-
-find_library(OPENJPEG_LIBRARY
-  NAMES openjpeg
-  )
+pkg_check_modules(OPENJPEG libopenjp2)
 
 include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(OpenJPEG DEFAULT_MSG
-  OPENJPEG_LIBRARY
-  OPENJPEG_INCLUDE_DIR
+find_package_handle_standard_args(OpenJPEG REQUIRED_VARS
+  OPENJPEG_LIBRARIES
+  OPENJPEG_INCLUDE_DIRS
+  VERSION_VAR OPENJPEG_VERSION
 )
 
-if(OPENJPEG_FOUND)
-  set(OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY})
-  set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR})
-endif()
-
 mark_as_advanced(
-  OPENJPEG_LIBRARY
-  OPENJPEG_INCLUDE_DIR
+  OPENJPEG_LIBRARIES
+  OPENJPEG_INCLUDE_DIRS
   )
-endif()
-endif()
diff --git a/CMake/UseCSharp.cmake b/CMake/UseCSharp.cmake
index ed49a44..793780e 100644
--- a/CMake/UseCSharp.cmake
+++ b/CMake/UseCSharp.cmake
@@ -54,35 +54,35 @@ endif()
 
 # CMAKE_CSHARP_COMPILER /platform and anycpu
 if(WIN32)
-# There is a subttle issue when compiling on 64bits platform using a 32bits compiler
-# See bug ID: 3510023 (BadImageFormatException: An attempt was made to load a progr)
-set(CSC_ACCEPTS_PLATFORM_FLAG 0)
-
-if(CMAKE_CSHARP_COMPILER)
-  execute_process(COMMAND "${CMAKE_CSHARP_COMPILER}" "/?" OUTPUT_VARIABLE CSC_HELP)
-  # get version (no /version, so use /help output):
-  if("${CSC_HELP}" MATCHES "Compiler version")
-    string(REGEX REPLACE ".*Compiler version ([0-9\\.]+).*" "\\1" VERSION_STRING 
-      "${CSC_HELP}")
-    message(STATUS "Comp version: ${VERSION_STRING}")
-  endif()
-  # when cmd locale is in French it displays: "/platform:<chaine>" in english: "/platform:<string>"
-  # so only regex match in /platform:
-  if("${CSC_HELP}" MATCHES "/platform:")
-    set(CSC_ACCEPTS_PLATFORM_FLAG 1)
+  # There is a subttle issue when compiling on 64bits platform using a 32bits compiler
+  # See bug ID: 3510023 (BadImageFormatException: An attempt was made to load a progr)
+  set(CSC_ACCEPTS_PLATFORM_FLAG 0)
+
+  if(CMAKE_CSHARP_COMPILER)
+    execute_process(COMMAND "${CMAKE_CSHARP_COMPILER}" "/?" OUTPUT_VARIABLE CSC_HELP)
+    # get version (no /version, so use /help output):
+    if("${CSC_HELP}" MATCHES "Compiler version")
+      string(REGEX REPLACE ".*Compiler version ([0-9\\.]+).*" "\\1" VERSION_STRING 
+        "${CSC_HELP}")
+      message(STATUS "Comp version: ${VERSION_STRING}")
+    endif()
+    # when cmd locale is in French it displays: "/platform:<chaine>" in english: "/platform:<string>"
+    # so only regex match in /platform:
+    if("${CSC_HELP}" MATCHES "/platform:")
+      set(CSC_ACCEPTS_PLATFORM_FLAG 1)
+    endif()
   endif()
-endif()
 
-if(NOT DEFINED CSC_PLATFORM_FLAG)
-  set(CSC_PLATFORM_FLAG "")
-  if(CSC_ACCEPTS_PLATFORM_FLAG)
-    set(CSC_PLATFORM_FLAG "/platform:x86")
-    if("${CMAKE_SIZEOF_VOID_P}" GREATER 4)
-      set(CSC_PLATFORM_FLAG "/platform:x64")
+  if(NOT DEFINED CSC_PLATFORM_FLAG)
+    set(CSC_PLATFORM_FLAG "")
+    if(CSC_ACCEPTS_PLATFORM_FLAG)
+      set(CSC_PLATFORM_FLAG "/platform:x86")
+      if("${CMAKE_SIZEOF_VOID_P}" GREATER 4)
+        set(CSC_PLATFORM_FLAG "/platform:x64")
+      endif()
     endif()
   endif()
 endif()
-endif()
 
 
 # Check something is found:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 96f89f6..d8be715 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,8 +34,8 @@ set(GDCM_PACKAGE_CONTACT "GDCM Developers <gdcm-developers at lists.sourceforge.net
 
 #----------------------------------------------------------------------------
 set(GDCM_MAJOR_VERSION 2)
-set(GDCM_MINOR_VERSION 6)
-set(GDCM_BUILD_VERSION 8)
+set(GDCM_MINOR_VERSION 8)
+set(GDCM_BUILD_VERSION 0)
 set(GDCM_VERSION
   "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
 # let advanced user the option to define GDCM_API_VERSION:
@@ -327,7 +327,7 @@ option(GDCM_USE_SYSTEM_PAPYRUS3 "Use system papyrus3" OFF)
 option(GDCM_USE_SYSTEM_SOCKETXX "Use system socket++" OFF)
 option(GDCM_USE_SYSTEM_LJPEG "Use system ljpeg (ijg lib)" OFF)
 option(GDCM_USE_SYSTEM_OPENJPEG "Use system openjpeg" OFF)
-option(GDCM_USE_SYSTEM_CHARLS "Use system charls" OFF)
+option(GDCM_USE_SYSTEM_CHARLS "Use system CharLS" OFF)
 mark_as_advanced(
   GDCM_USE_SYSTEM_ZLIB
   GDCM_USE_SYSTEM_OPENSSL
@@ -367,15 +367,10 @@ else()
 endif()
 
 if(GDCM_USE_SYSTEM_OPENJPEG)
-  # For some reason I cannot specify the version I want.
-  # find_package(OpenJPEG 2.0 REQUIRED)
-  # oh well we should handle both 1.0 and 2.0 anyway...
-  find_package(OpenJPEG REQUIRED)
+  find_package(OpenJPEG 2.0.0 REQUIRED)
   set(GDCM_OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARIES})
 else()
-  set(GDCM_OPENJPEG_LIBRARIES gdcmopenjpeg)
-  option(GDCM_USE_OPENJPEG_V2 "Use openjpeg v2 version (advanced users only)." OFF)
-  mark_as_advanced(GDCM_USE_OPENJPEG_V2)
+  set(GDCM_OPENJPEG_LIBRARIES gdcmopenjp2)
 endif()
 
 # Very advanced user option:
@@ -524,7 +519,6 @@ if(GDCM_STANDALONE)
   option(GDCM_WRAP_CSHARP "build csharp wrapping" OFF)
   mark_as_advanced(GDCM_WRAP_PHP)
   mark_as_advanced(GDCM_WRAP_PERL)
-  mark_as_advanced(GDCM_USE_RLE)
   mark_as_advanced(GDCM_USE_ACTIVIZ)
   option(GDCM_USE_JPEGLS "Build GDCM with JPEG-LS support" ON)
   mark_as_advanced(GDCM_USE_JPEGLS)
@@ -663,12 +657,6 @@ if(GDCM_STANDALONE)
     subdirs(Utilities/VTK)
   endif()
 endif()
-#-----------------------------------------------------------------------------
-option(GDCM_USE_WXWIDGETS "wxWidgets bridge ?" OFF)
-mark_as_advanced(GDCM_USE_WXWIDGETS)
-if(GDCM_USE_WXWIDGETS)
-  subdirs(Utilities/wxWidgets)
-endif()
 
 #-----------------------------------------------------------------------------
 if(GDCM_STANDALONE)
diff --git a/Examples/Cxx/CMakeLists.txt b/Examples/Cxx/CMakeLists.txt
index 65cec74..cc348d1 100644
--- a/Examples/Cxx/CMakeLists.txt
+++ b/Examples/Cxx/CMakeLists.txt
@@ -33,8 +33,10 @@ endif()
 
 set(EXAMPLES_SRCS
   EmptyMask
+  DumpSiemensBase64
   TemplateEmptyImage
   MakeTemplate
+  DeriveSeries
   FixOrientation
   DumpGEMSMovieGroup
   QIDO-RS
@@ -88,14 +90,12 @@ set(EXAMPLES_SRCS
   GenSeqs
   GetJPEGSamplePrecision
 )
-if(GDCM_USE_OPENJPEG_V2)
-set(EXAMPLES_SRCS
-  ${EXAMPLES_SRCS}
-  StreamImageReaderTest
-  Extracting_All_Resolution
-  Fake_Image_Using_Stream_Image_Writer
-  )
-endif()
+#set(EXAMPLES_SRCS
+#  ${EXAMPLES_SRCS}
+#  StreamImageReaderTest
+#  Extracting_All_Resolution
+#  Fake_Image_Using_Stream_Image_Writer
+#  )
 if(GDCM_USE_JPEGLS)
 set(EXAMPLES_SRCS
   ${EXAMPLES_SRCS}
@@ -138,7 +138,7 @@ endif()
 if(BUILD_SHARED_LIBS)
   set_source_files_properties(FixJAIBugJPEGLS.cxx
                               PROPERTIES
-                              COMPILE_FLAGS -DCHARLS_SHARED
+                              COMPILE_FLAGS -DCHARLS_DLL
                               )
 endif()
 
diff --git a/Examples/Cxx/DeriveSeries.cxx b/Examples/Cxx/DeriveSeries.cxx
new file mode 100644
index 0000000..8c9f15d
--- /dev/null
+++ b/Examples/Cxx/DeriveSeries.cxx
@@ -0,0 +1,87 @@
+/*=========================================================================
+
+  Program: GDCM (Grassroots DICOM). A DICOM library
+
+  Copyright (c) 2006-2011 Mathieu Malaterre
+  All rights reserved.
+  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#include "gdcmReader.h"
+#include "gdcmWriter.h"
+#include "gdcmAttribute.h"
+#include "gdcmFileDerivation.h"
+#include "gdcmUIDGenerator.h"
+
+int main(int argc, char *argv[])
+{
+  if( argc < 3 )
+  {
+    return 1;
+  }
+  const char * ref = argv[1];
+  const char * in  = argv[2];
+
+  gdcm::Reader r1;
+  r1.SetFileName( ref );
+  if( !r1.Read() ) return 1;
+
+  gdcm::Reader r2;
+  r2.SetFileName( in );
+  if( !r2.Read() ) return 1;
+
+
+  // Fix Spatial info:
+  gdcm::DataSet & ds1 = r1.GetFile().GetDataSet();
+  gdcm::File & file2 = r2.GetFile();
+  gdcm::DataSet & ds2 = file2.GetDataSet();
+  //gdcm::Attribute<0x8,0x8> img_type = { "ORIGINAL", "PRIMARY" };
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0008,0x0008) ));
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0020,0x0032) ));
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0020,0x0037) ));
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0018,0x0088) )); // Spacing between slices
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0020,0x0013) )); // Instance Number
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0018,0x5100) )); // Patient Position
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0018,0x0050) )); // Slice Thickness
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0008,0x0070) )); // Manufacturer
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0018,0x0081) )); // Echo Time
+  ds2.Replace( ds1.GetDataElement( gdcm::Tag(0x0020,0x1041) )); // Slice Location
+
+  gdcm::Attribute<0x8,0x16> sopclassuid;
+  sopclassuid.SetFromDataSet( ds1 );
+  gdcm::Attribute<0x8,0x18> sopinstanceuid;
+  sopinstanceuid.SetFromDataSet( ds1 );
+
+  // Step 2: DERIVED object
+  gdcm::FileDerivation fd;
+  fd.AddReference( sopclassuid.GetValue(), sopinstanceuid.GetValue() );
+
+  // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part16/chapter_D.html#DCM_121321
+  // CID 7202 "Source Image Purposes of Reference"
+  // DCM 121321 "Mask image for image processing operation"
+  fd.SetPurposeOfReferenceCodeSequenceCodeValue( 121321 );
+  // CID 7203 "Image Derivation"
+  // DCM 113047 "Pixel by pixel mask"
+  fd.SetDerivationCodeSequenceCodeValue( 113047 );
+  fd.SetFile( file2 );
+  // If all Code Value are ok the filter will execute properly
+  if( !fd.Derive() )
+    {
+    std::cerr << "Sorry could not derive using input info" << std::endl;
+    return 1;
+    }
+
+  gdcm::Writer w;
+  w.SetFile( r2.GetFile() );
+  w.SetFileName( "derived.dcm" );
+  if( !w.Write() )
+    {
+    return 1;
+    }
+
+  return 0;
+}
diff --git a/Examples/Cxx/DumpGEMSMovieGroup.cxx b/Examples/Cxx/DumpGEMSMovieGroup.cxx
index ebf54a1..c4de9f0 100644
--- a/Examples/Cxx/DumpGEMSMovieGroup.cxx
+++ b/Examples/Cxx/DumpGEMSMovieGroup.cxx
@@ -215,7 +215,7 @@ gdcm::SequenceOfItems *sqi_names, std::string const & indent )
 bool PrintNameValueMapping2( gdcm::PrivateTag const & privtag, const gdcm::DataSet & ds ,
   gdcm::SequenceOfItems *sqi_names, std::string const & indent )
 {
-  if( !ds.FindDataElement( privtag ) ) return 1;
+  if( !ds.FindDataElement( privtag ) ) return false;
   const gdcm::DataElement& seq_values = ds.GetDataElement( privtag );
   gdcm::SmartPointer<gdcm::SequenceOfItems> sqi = seq_values.GetValueAsSQ();
 
@@ -342,7 +342,7 @@ gdcm::SequenceOfItems *sqi_dict, std::string const & indent )
   if( !subds.FindDataElement( privtag0 ) )
     {
     assert( 0 );
-    return 1;
+    return false;
     }
   const gdcm::DataElement& seq_values10 = subds.GetDataElement( privtag0 );
   gdcm::SmartPointer<gdcm::SequenceOfItems> sqi_values10 = seq_values10.GetValueAsSQ();
@@ -367,7 +367,7 @@ gdcm::SequenceOfItems *sqi_dict, std::string const & indent )
     if( !ds10.FindDataElement( tseq_values20 ) )
       {
       assert( 0 );
-      return 1;
+      return false;
       }
     const gdcm::DataElement& seq_values20 = ds10.GetDataElement( tseq_values20 );
     gdcm::SmartPointer<gdcm::SequenceOfItems> sqi_values20 = seq_values20.GetValueAsSQ();
diff --git a/Examples/Cxx/DumpSiemensBase64.cxx b/Examples/Cxx/DumpSiemensBase64.cxx
new file mode 100644
index 0000000..1cae922
--- /dev/null
+++ b/Examples/Cxx/DumpSiemensBase64.cxx
@@ -0,0 +1,88 @@
+/*=========================================================================
+
+  Program: GDCM (Grassroots DICOM). A DICOM library
+
+  Copyright (c) 2006-2011 Mathieu Malaterre
+  All rights reserved.
+  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+/*
+ * https://groups.google.com/forum/#!msg/comp.protocols.dicom/2kZ2lLP8EcM/WzjFrtjnAgAJ
+ */
+#include "gdcmReader.h"
+#include "gdcmPrivateTag.h"
+#include "gdcmPrinter.h"
+#include "gdcmDictPrinter.h"
+#include "gdcmCSAHeader.h"
+#include "gdcmBase64.h"
+#include "gdcmExplicitDataElement.h"
+#include "gdcmSwapper.h"
+#include "gdcmPrinter.h"
+
+#include <iostream>
+#include <fstream>
+#include <vector>
+
+#include <assert.h>
+
+int main(int argc, char *argv[])
+{
+  if( argc < 2 ) return 1;
+  const char *filename = argv[1];
+  gdcm::Reader reader;
+  reader.SetFileName( filename );
+  if( !reader.Read() )
+  {
+    std::cerr << "Failed to read: " << filename << std::endl;
+    return 1;
+  }
+  const gdcm::DataSet& ds = reader.GetFile().GetDataSet();
+
+  gdcm::CSAHeader csa;
+  const gdcm::PrivateTag &t1 = csa.GetCSAImageHeaderInfoTag();
+  if( !ds.FindDataElement( t1 ) ) return 1;
+  csa.LoadFromDataElement( ds.GetDataElement( t1 ) );
+
+  //const char name[] = "MRDiffusion";
+  const char name[] = "MR_ASL";
+  if( csa.FindCSAElementByName(name) )
+  {
+    const gdcm::CSAElement & el = csa.GetCSAElementByName(name);
+    const gdcm::ByteValue* bv = el.GetByteValue();
+    std::string str( bv->GetPointer(), bv->GetLength() );
+    str.erase(std::remove(str.begin(), str.end(), '\n'), str.end());
+    size_t dl = gdcm::Base64::GetDecodeLength( str.c_str(), str.size() );
+    std::vector<char> buf;
+    buf.resize( dl );
+    size_t dl2 = gdcm::Base64::Decode( &buf[0], buf.size(), str.c_str(), str.size() );
+    (void)dl2;
+    std::stringstream ss;
+    ss.str( std::string(&buf[0], buf.size()) );
+    gdcm::File file;
+    gdcm::DataSet &ds2 = file.GetDataSet();
+    gdcm::DataElement xde;
+    try
+    {
+      while( xde.Read<gdcm::ExplicitDataElement,gdcm::SwapperNoOp>( ss ) )
+      {
+        ds2.Insert( xde );
+      }
+      assert( ss.eof() );
+    }
+    catch(std::exception &)
+    {
+      return 1;
+    }
+    gdcm::Printer p;
+    p.SetFile( file );
+    p.Print(std::cout);
+
+  }
+
+  return 0;
+}
diff --git a/Examples/Cxx/Extracting_All_Resolution.cxx b/Examples/Cxx/Extracting_All_Resolution.cxx
index d90f525..a2b0202 100644
--- a/Examples/Cxx/Extracting_All_Resolution.cxx
+++ b/Examples/Cxx/Extracting_All_Resolution.cxx
@@ -14,7 +14,6 @@
 // This work was realised during the GSOC 2011 by Manoj Alwani
 
 #include <fstream>
-#include <openjpeg.h>
 #include <stdint.h>
 #include <string.h>
 #include <assert.h>
@@ -33,6 +32,7 @@
 
 
 
+#include "gdcm_openjpeg.h"
 #include "gdcmMediaStorage.h"
 #include "gdcmWriter.h"
 #include "gdcmItem.h"
diff --git a/Source/Common/gdcmConfigure.h.in b/Source/Common/gdcmConfigure.h.in
index 41e1772..b01444a 100644
--- a/Source/Common/gdcmConfigure.h.in
+++ b/Source/Common/gdcmConfigure.h.in
@@ -56,7 +56,6 @@
 #cmakedefine GDCM_USE_SYSTEM_JSON
 #cmakedefine GDCM_USE_SYSTEM_LJPEG
 #cmakedefine GDCM_USE_SYSTEM_OPENJPEG
-#cmakedefine GDCM_USE_OPENJPEG_V2
 #cmakedefine GDCM_USE_SYSTEM_CHARLS
 #cmakedefine GDCM_USE_SYSTEM_KAKADU
 #cmakedefine GDCM_USE_SYSTEM_PVRG
@@ -64,18 +63,14 @@
 #cmakedefine GDCM_USE_SYSTEM_PAPYRUS3
 
 #ifndef GDCM_USE_SYSTEM_OPENJPEG
-#ifdef GDCM_USE_OPENJPEG_V2
-#define OPENJPEG_MAJOR_VERSION 2
-#else // GDCM_USE_OPENJPEG_V2
-#define OPENJPEG_MAJOR_VERSION 1
-#endif // GDCM_USE_OPENJPEG_V2
+#define OPENJPEG_VERSION_MAJOR 2
 #else
-#define OPENJPEG_MAJOR_VERSION @OPENJPEG_MAJOR_VERSION@
+#define OPENJPEG_VERSION_MAJOR @OPENJPEG_VERSION_MAJOR@
 #endif //GDCM_USE_SYSTEM_OPENJPEG
 
-#ifndef OPENJPEG_MAJOR_VERSION
+#ifndef OPENJPEG_VERSION_MAJOR
 #error problem with openjpeg major version
-#endif // OPENJPEG_MAJOR_VERSION
+#endif // OPENJPEG_VERSION_MAJOR
 
 #cmakedefine GDCM_USE_PVRG
 #cmakedefine GDCM_USE_KAKADU
diff --git a/Source/Common/gdcmDummyValueGenerator.cxx b/Source/Common/gdcmDummyValueGenerator.cxx
index 8e76f55..e7867ce 100644
--- a/Source/Common/gdcmDummyValueGenerator.cxx
+++ b/Source/Common/gdcmDummyValueGenerator.cxx
@@ -29,7 +29,7 @@ const char* DummyValueGenerator::Generate(const char *input)
   if( input )
     {
     // Cannot use MD5 as it has been broken multiple time (2005)
-    b = MD5::Compute(input, (unsigned long)strlen(input), digest);
+    b = MD5::Compute(input, strlen(input), digest);
     //b = SHA1::Compute(input, strlen(input), digest);
     }
 
diff --git a/Source/Common/gdcmMD5.cxx b/Source/Common/gdcmMD5.cxx
index 7ca80c6..a60d4d0 100644
--- a/Source/Common/gdcmMD5.cxx
+++ b/Source/Common/gdcmMD5.cxx
@@ -19,32 +19,14 @@
 #elif defined(GDCM_BUILD_TESTING)
 #include "gdcm_md5.h"
 #endif
+#include <fstream>
+#include <vector>
 
-#include <string.h>//memcmp
-#include <stdlib.h> // malloc
-#include <stdio.h> // fopen
-
-/*
- */
+// http://stackoverflow.com/questions/13256446/compute-md5-hash-value-by-c-winapi
 namespace gdcm
 {
 
-class MD5Internals
-{
-public:
-};
-
-MD5::MD5()
-{
-  Internals = new MD5Internals;
-}
-
-MD5::~MD5()
-{
-  delete Internals;
-}
-
-bool MD5::Compute(const char *buffer, unsigned long buf_len, char digest_str[33])
+bool MD5::Compute(const char *buffer, size_t buf_len, char digest_str[33])
 {
   if( !buffer || !buf_len )
     {
@@ -56,22 +38,23 @@ bool MD5::Compute(const char *buffer, unsigned long buf_len, char digest_str[33]
   MD5_Init(&ctx);
   MD5_Update(&ctx, buffer, buf_len);
   MD5_Final(digest, &ctx);
+  for (int di = 0; di < 16; ++di)
+    sprintf(digest_str+2*di, "%02x", digest[di]);
+  digest_str[2*16] = '\0';
+  return true;
 #elif defined(GDCM_BUILD_TESTING)
   md5_byte_t digest[16];
   md5_state_t state;
   md5_init(&state);
   md5_append(&state, (const md5_byte_t *)buffer, (int)buf_len);
   md5_finish(&state, digest);
-#else
-  unsigned char digest[16] = {};
-  return false;
-#endif
   for (int di = 0; di < 16; ++di)
-    {
     sprintf(digest_str+2*di, "%02x", digest[di]);
-    }
   digest_str[2*16] = '\0';
   return true;
+#else
+  return false;
+#endif
 }
 
 #ifdef GDCM_USE_SYSTEM_OPENSSL
@@ -79,74 +62,45 @@ static bool process_file(const char *filename, unsigned char *digest)
 {
   if( !filename || !digest ) return false;
 
-  FILE *file = fopen(filename, "rb");
-  if(!file)
-    {
-    return false;
-    }
+  std::ifstream file(filename, std::ios::binary);
+  if(!file) return false;
 
-  size_t file_size = System::FileSize(filename);
-  void *buffer = malloc(file_size);
-  if(!buffer)
-    {
-    fclose(file);
-    return false;
-    }
-  size_t read = fread(buffer, 1, file_size, file);
-  if( read != file_size ) return false;
+  const size_t file_size = System::FileSize(filename);
+  std::vector<char> v( file_size );
+
+  char *buffer = &v[0];
+  file.read(buffer, file_size);
 
   MD5_CTX ctx;
   MD5_Init(&ctx);
   MD5_Update(&ctx, buffer, file_size);
   MD5_Final(digest, &ctx);
 
-  /*printf("MD5 (\"%s\") = ", test[i]); */
-  /*for (int di = 0; di < 16; ++di)
-  {
-    printf("%02x", digest[di]);
-  }*/
-  //printf("\t%s\n", filename);
-  free(buffer);
-  fclose(file);
   return true;
 }
 #elif defined(GDCM_BUILD_TESTING)
-inline bool process_file(const char *filename, md5_byte_t *digest)
+static bool process_file(const char *filename, md5_byte_t *digest)
 {
   if( !filename || !digest ) return false;
 
-  FILE *file = fopen(filename, "rb");
-  if(!file)
-    {
-    return false;
-    }
+  std::ifstream file(filename, std::ios::binary);
+  if(!file) return false;
 
-  size_t file_size = System::FileSize(filename);
-  void *buffer = malloc(file_size);
-  if(!buffer)
-    {
-    fclose(file);
-    return false;
-    }
-  size_t read = fread(buffer, 1, file_size, file);
-  if( read != file_size ) return false;
+  const size_t file_size = System::FileSize(filename);
+  std::vector<char> v( file_size );
+
+  char *buffer = &v[0];
+  file.read(buffer, file_size);
 
   md5_state_t state;
   md5_init(&state);
   md5_append(&state, (const md5_byte_t *)buffer, (int)file_size);
   md5_finish(&state, digest);
-  /*printf("MD5 (\"%s\") = ", test[i]); */
-  /*for (int di = 0; di < 16; ++di)
-  {
-    printf("%02x", digest[di]);
-  }*/
-  //printf("\t%s\n", filename);
-  free(buffer);
-  fclose(file);
+
   return true;
 }
 #else
-inline bool process_file(const char *, unsigned char *)
+static inline bool process_file(const char *, unsigned char *)
 {
   return false;
 }
@@ -154,8 +108,6 @@ inline bool process_file(const char *, unsigned char *)
 
 bool MD5::ComputeFile(const char *filename, char digest_str[33])
 {
-  // If not file exist
-  // return false;
 #ifdef GDCM_USE_SYSTEM_OPENSSL
   unsigned char digest[16];
 #elif defined(GDCM_BUILD_TESTING)
diff --git a/Source/Common/gdcmMD5.h b/Source/Common/gdcmMD5.h
index 61abf2d..786be00 100644
--- a/Source/Common/gdcmMD5.h
+++ b/Source/Common/gdcmMD5.h
@@ -19,7 +19,6 @@
 namespace gdcm
 {
 //-----------------------------------------------------------------------------
-class MD5Internals;
 /**
  * \brief Class for MD5
  *
@@ -33,18 +32,11 @@ class MD5Internals;
 class GDCM_EXPORT MD5
 {
 public :
-  MD5();
-  ~MD5();
-
-  static bool Compute(const char *buffer, unsigned long buf_len, char digest_str[33]);
+  // Compute md5 from memory pointed by `pointer` of size `buf_len`
+  static bool Compute(const char *buffer, size_t buf_len, char digest_str[33]);
 
+  /// Compute md5 from a file `filename`
   static bool ComputeFile(const char *filename, char digest_str[33]);
-
-private:
-  MD5Internals *Internals;
-private:
-  MD5(const MD5&);  // Not implemented.
-  void operator=(const MD5&);  // Not implemented.
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
diff --git a/Source/Common/gdcmOpenSSLCryptographicMessageSyntax.cxx b/Source/Common/gdcmOpenSSLCryptographicMessageSyntax.cxx
index 97cb06d..36c0869 100644
--- a/Source/Common/gdcmOpenSSLCryptographicMessageSyntax.cxx
+++ b/Source/Common/gdcmOpenSSLCryptographicMessageSyntax.cxx
@@ -55,20 +55,20 @@ CryptographicMessageSyntax::CipherTypes OpenSSLCryptographicMessageSyntax::GetCi
 }
 
 bool OpenSSLCryptographicMessageSyntax::SetPassword(const char * pass, size_t passLen)
-  {
-    assert(pass);
+{
+  assert(pass);
 
-    if (password)
-      {
-      delete[] password;
-      }
+  if (password)
+    {
+    delete[] password;
+    }
 
-    passwordLength = passLen;
-    password = new char[passLen];
-    memcpy(password, pass, passLen);
-    
-    return true;
-  }
+  passwordLength = passLen;
+  password = new char[passLen];
+  memcpy(password, pass, passLen);
+
+  return true;
+}
 
 bool OpenSSLCryptographicMessageSyntax::Encrypt(char *output, size_t &outlen, const char *array, size_t len) const
 {
diff --git a/Source/Common/gdcmSwapper.txx b/Source/Common/gdcmSwapper.txx
index a1abfc2..34cb1d5 100644
--- a/Source/Common/gdcmSwapper.txx
+++ b/Source/Common/gdcmSwapper.txx
@@ -61,7 +61,7 @@
                       (((x) & 0xFF00) >> 8))
 # define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
                       (((x) & 0x0000FF00) << 8) | \
-                      (((x) & 0x00FF0000) << 8) | \
+                      (((x) & 0x00FF0000) >> 8) | \
                       (((x) & 0xFF000000) >> 24))
 # define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
                       (((x) & 0x000000000000FF00ULL) << 40) | \
diff --git a/Source/Common/gdcmTesting.cxx b/Source/Common/gdcmTesting.cxx
index f4c3031..5c78031 100644
--- a/Source/Common/gdcmTesting.cxx
+++ b/Source/Common/gdcmTesting.cxx
@@ -36,7 +36,7 @@ namespace gdcm
 #include "gdcmSelectedTagsOffsetDataFiles.cxx"
 #include "gdcmSelectedPrivateGroupOffsetDataFiles.cxx"
 
-bool Testing::ComputeMD5(const char *buffer, unsigned long buf_len,
+bool Testing::ComputeMD5(const char *buffer, size_t buf_len,
   char digest_str[33])
 {
   return MD5::Compute(buffer, buf_len, digest_str);
diff --git a/Source/Common/gdcmTesting.h b/Source/Common/gdcmTesting.h
index ca1a610..9d0f130 100644
--- a/Source/Common/gdcmTesting.h
+++ b/Source/Common/gdcmTesting.h
@@ -39,7 +39,7 @@ public :
   /// string will be \0 padded. (md5 are 32 bytes long)
   /// Testing is not meant to be shipped with an installed GDCM release, always
   /// prefer the gdcm::MD5 API when doing md5 computation.
-  static bool ComputeMD5(const char *buffer, unsigned long buf_len,
+  static bool ComputeMD5(const char *buffer, size_t buf_len,
     char digest_str[33]);
   static bool ComputeFileMD5(const char *filename, char digest_str[33]);
 
diff --git a/Source/DataDictionary/GroupName.dic b/Source/DataDictionary/GroupName.dic
deleted file mode 100644
index 39a2403..0000000
--- a/Source/DataDictionary/GroupName.dic
+++ /dev/null
@@ -1,72 +0,0 @@
-0000 CMD Command
-0002 META Meta Element
-0004 DIR Directory
-0004 FST File Set
-0008 ID Identifying
-0009 SPII SPI Identifying
-0010 PAT Patient
-0012 CLI Clinical Trial
-0018 ACQ Acquisition
-0019 SPIA SPI Acquisition
-0020 IMG Image
-0021 SPIIM SPI Image
-0022 OPHY Ophtalmology
-0028 IMGP Image Presentation
-0032 SDY Study
-0038 VIS Visit
-003a WAV Waveform
-0040 PRC Procedure
-0040 MOD Modality Worklist
-0042 EDOC Encapsulated Document
-0050 XAD XRay Angio Device
-0050 DEV Device Informations
-0054 NMI Nuclear Medicine
-0060 HIS Histogram
-0070 PRS Presentation State
-0072 HST Hanging Protocol
-0088 STO Storage
-0088 MED  Medicine
-0100 AUTH Authorization
-0400 DSIG Digital Signature
-1000 COT  Code Table
-1010 ZMAP Zonal Map
-2000 BFS Film Session
-2010 BFB Film Box
-2020 BIB Image Box
-2030 BAB Annotation
-2040 IOB Overlay Box
-2050 PLUT Presentation LUT
-2100 PJ   Print Job
-2110 PRINTER Printer
-2120 QUE Queue
-2130 PCT Print Content
-2200 MEDIAC Media Creation
-3002 RTI RT Image
-3004 RTD RT Dose
-3006 SSET RT StructureSet
-3008 RTT RT Treatment
-300A RTP RT Plan
-300C RTR RT Relationship
-300E RTA RT Approval
-4000 TXT Text
-4008 RES Results
-4ffe MAC MAC Parameters
-5000 CRV Curve
-5002 CRV Curve
-5004 CRV Curve
-5006 CRV Curve
-5008 CRV Curve
-500a CRV Curve
-500c CRV Curve
-500e CRV Curve
-5400 WFM Waveform Data
-6000 OLY Overlays
-6002 OLY Overlays
-6004 OLY Overlays
-6008 OLY Overlays
-600a OLY Overlays
-600c OLY Overlays
-600e OLY Overlays
-fffc GEN Generic
-7fe0 PXL Pixel Data
-ffff UNK Unknown
diff --git a/Source/DataDictionary/NIH.dic b/Source/DataDictionary/NIH.dic
deleted file mode 100644
index 038703b..0000000
--- a/Source/DataDictionary/NIH.dic
+++ /dev/null
@@ -1,15 +0,0 @@
-0018 106b UI 1 Synchronization Frame of Reference (RET)
-0028 0013 US 1 Instants (RET)
-0028 0015 US 1 UsedNbX ACR Special (RET)
-0028 0016 US 1 UsedNbY ACR Special (RET)
-0028 0017 US 1 UsedNbZ ACR Special (RET)
-0028 0018 US 1 UsedNbT ACR Special (RET)
-0028 0122 US 1 Waveform Padding Value (RET)
-0028 0199 US 1 Special Code (RET)
-003a 0002 SQ 1 Waveform Sequence (RET)
-003a 0103 CS 1 Data Value Representation (RET)
-0040 0552 SQ 1 Specimen Description Sequence (RET)
-0040 0553 ST 1 Specimen Description (RET)
-0040 09f8 SQ 1 Vital Stain Code Sequence (RET)
-0040 a16a ST 1 Bibliographics Citation (RET)
-0040 a992 ST 1 Uniform Resource Locator (RET)
diff --git a/Source/DataDictionary/Part6.xml b/Source/DataDictionary/Part6.xml
index fe0d2ba..0c446c8 100644
--- a/Source/DataDictionary/Part6.xml
+++ b/Source/DataDictionary/Part6.xml
@@ -18,3990 +18,4631 @@ Manual changes:
 1. DateTime -> Date Time (0008,002a)
 -->
 <!DOCTYPE doc [
-	 <!ENTITY part7 SYSTEM "Part7.xml">
-	 ]>
+  <!ENTITY part7 SYSTEM "Part7.xml">
+  ]>
 <dicts edition="2011">
   &part7;
-  <dict ref="6" name="Registry of DICOM data elements">
-    <entry group="0008" element="0001" keyword="LengthToEnd" vr="UL" vm="1" retired="true" name="Length to End"/>
-    <entry group="0008" element="0005" keyword="SpecificCharacterSet" vr="CS" vm="1-n" name="Specific Character Set"/>
-    <entry group="0008" element="0006" keyword="LanguageCodeSequence" vr="SQ" vm="1" name="Language Code Sequence"/>
-    <entry group="0008" element="0008" keyword="ImageType" vr="CS" vm="2-n" name="Image Type"/>
-    <entry group="0008" element="0010" keyword="RecognitionCode" vr="SH" vm="1" retired="true" name="Recognition Code"/>
-    <entry group="0008" element="0012" keyword="InstanceCreationDate" vr="DA" vm="1" name="Instance Creation Date"/>
-    <entry group="0008" element="0013" keyword="InstanceCreationTime" vr="TM" vm="1" name="Instance Creation Time"/>
-    <entry group="0008" element="0014" keyword="InstanceCreatorUID" vr="UI" vm="1" name="Instance Creator UID"/>
-    <entry group="0008" element="0016" keyword="SOPClassUID" vr="UI" vm="1" name="SOP Class UID"/>
-    <entry group="0008" element="0018" keyword="SOPInstanceUID" vr="UI" vm="1" name="SOP Instance UID"/>
-    <entry group="0008" element="001a" keyword="RelatedGeneralSOPClassUID" vr="UI" vm="1-n" name="Related General SOP Class UID"/>
-    <entry group="0008" element="001b" keyword="OriginalSpecializedSOPClassUID" vr="UI" vm="1" name="Original Specialized SOP Class UID"/>
-    <entry group="0008" element="0020" keyword="StudyDate" vr="DA" vm="1" name="Study Date"/>
-    <entry group="0008" element="0021" keyword="SeriesDate" vr="DA" vm="1" name="Series Date"/>
-    <entry group="0008" element="0022" keyword="AcquisitionDate" vr="DA" vm="1" name="Acquisition Date"/>
-    <entry group="0008" element="0023" keyword="ContentDate" vr="DA" vm="1" name="Content Date"/>
-    <entry group="0008" element="0024" keyword="OverlayDate" vr="DA" vm="1" retired="true" name="Overlay Date"/>
-    <entry group="0008" element="0025" keyword="CurveDate" vr="DA" vm="1" retired="true" name="Curve Date"/>
-    <entry group="0008" element="002a" keyword="AcquisitionDateTime" vr="DT" vm="1" name="Acquisition Date Time"/>
-    <entry group="0008" element="0030" keyword="StudyTime" vr="TM" vm="1" name="Study Time"/>
-    <entry group="0008" element="0031" keyword="SeriesTime" vr="TM" vm="1" name="Series Time"/>
-    <entry group="0008" element="0032" keyword="AcquisitionTime" vr="TM" vm="1" name="Acquisition Time"/>
-    <entry group="0008" element="0033" keyword="ContentTime" vr="TM" vm="1" name="Content Time"/>
-    <entry group="0008" element="0034" keyword="OverlayTime" vr="TM" vm="1" retired="true" name="Overlay Time"/>
-    <entry group="0008" element="0035" keyword="CurveTime" vr="TM" vm="1" retired="true" name="Curve Time"/>
-    <entry group="0008" element="0040" keyword="DataSetType" vr="US" vm="1" retired="true" name="Data Set Type"/>
-    <entry group="0008" element="0041" keyword="DataSetSubtype" vr="LO" vm="1" retired="true" name="Data Set Subtype"/>
-    <entry group="0008" element="0042" keyword="NuclearMedicineSeriesType" vr="CS" vm="1" retired="true" name="Nuclear Medicine Series Type"/>
-    <entry group="0008" element="0050" keyword="AccessionNumber" vr="SH" vm="1" name="Accession Number"/>
-    <entry group="0008" element="0051" keyword="IssuerOfAccessionNumberSequence" vr="SQ" vm="1" name="Issuer of Accession Number Sequence"/>
-    <entry group="0008" element="0052" keyword="QueryRetrieveLevel" vr="CS" vm="1" name="Query/Retrieve Level"/>
-    <entry group="0008" element="0054" keyword="RetrieveAETitle" vr="AE" vm="1-n" name="Retrieve AE Title"/>
-    <entry group="0008" element="0056" keyword="InstanceAvailability" vr="CS" vm="1" name="Instance Availability"/>
-    <entry group="0008" element="0058" keyword="FailedSOPInstanceUIDList" vr="UI" vm="1-n" name="Failed SOP Instance UID List"/>
-    <entry group="0008" element="0060" keyword="Modality" vr="CS" vm="1" name="Modality"/>
-    <entry group="0008" element="0061" keyword="ModalitiesInStudy" vr="CS" vm="1-n" name="Modalities in Study"/>
-    <entry group="0008" element="0062" keyword="SOPClassesInStudy" vr="UI" vm="1-n" name="SOP Classes in Study"/>
-    <entry group="0008" element="0064" keyword="ConversionType" vr="CS" vm="1" name="Conversion Type"/>
-    <entry group="0008" element="0068" keyword="PresentationIntentType" vr="CS" vm="1" name="Presentation Intent Type"/>
-    <entry group="0008" element="0070" keyword="Manufacturer" vr="LO" vm="1" name="Manufacturer"/>
-    <entry group="0008" element="0080" keyword="InstitutionName" vr="LO" vm="1" name="Institution Name"/>
-    <entry group="0008" element="0081" keyword="InstitutionAddress" vr="ST" vm="1" name="Institution Address"/>
-    <entry group="0008" element="0082" keyword="InstitutionCodeSequence" vr="SQ" vm="1" name="Institution Code Sequence"/>
-    <entry group="0008" element="0090" keyword="ReferringPhysicianName" vr="PN" vm="1" name="Referring Physician's Name"/>
-    <entry group="0008" element="0092" keyword="ReferringPhysicianAddress" vr="ST" vm="1" name="Referring Physician's Address"/>
-    <entry group="0008" element="0094" keyword="ReferringPhysicianTelephoneNumbers" vr="SH" vm="1-n" name="Referring Physician's Telephone Numbers"/>
-    <entry group="0008" element="0096" keyword="ReferringPhysicianIdentificationSequence" vr="SQ" vm="1" name="Referring Physician Identification Sequence"/>
-    <entry group="0008" element="0100" keyword="CodeValue" vr="SH" vm="1" name="Code Value"/>
-    <entry group="0008" element="0102" keyword="CodingSchemeDesignator" vr="SH" vm="1" name="Coding Scheme Designator"/>
-    <entry group="0008" element="0103" keyword="CodingSchemeVersion" vr="SH" vm="1" name="Coding Scheme Version"/>
-    <entry group="0008" element="0104" keyword="CodeMeaning" vr="LO" vm="1" name="Code Meaning"/>
-    <entry group="0008" element="0105" keyword="MappingResource" vr="CS" vm="1" name="Mapping Resource"/>
-    <entry group="0008" element="0106" keyword="ContextGroupVersion" vr="DT" vm="1" name="Context Group Version"/>
-    <entry group="0008" element="0107" keyword="ContextGroupLocalVersion" vr="DT" vm="1" name="Context Group Local Version"/>
-    <entry group="0008" element="010b" keyword="ContextGroupExtensionFlag" vr="CS" vm="1" name="Context Group Extension Flag"/>
-    <entry group="0008" element="010c" keyword="CodingSchemeUID" vr="UI" vm="1" name="Coding Scheme UID"/>
-    <entry group="0008" element="010d" keyword="ContextGroupExtensionCreatorUID" vr="UI" vm="1" name="Context Group Extension Creator UID"/>
-    <entry group="0008" element="010f" keyword="ContextIdentifier" vr="CS" vm="1" name="Context Identifier"/>
-    <entry group="0008" element="0110" keyword="CodingSchemeIdentificationSequence" vr="SQ" vm="1" name="Coding Scheme Identification Sequence"/>
-    <entry group="0008" element="0112" keyword="CodingSchemeRegistry" vr="LO" vm="1" name="Coding Scheme Registry"/>
-    <entry group="0008" element="0114" keyword="CodingSchemeExternalID" vr="ST" vm="1" name="Coding Scheme External ID"/>
-    <entry group="0008" element="0115" keyword="CodingSchemeName" vr="ST" vm="1" name="Coding Scheme Name"/>
-    <entry group="0008" element="0116" keyword="CodingSchemeResponsibleOrganization" vr="ST" vm="1" name="Coding Scheme Responsible Organization"/>
-    <entry group="0008" element="0117" keyword="ContextUID" vr="UI" vm="1" name="Context UID"/>
-    <entry group="0008" element="0201" keyword="TimezoneOffsetFromUTC" vr="SH" vm="1" name="Timezone Offset From UTC"/>
-    <entry group="0008" element="1000" keyword="NetworkID" vr="AE" vm="1" retired="true" name="Network ID"/>
-    <entry group="0008" element="1010" keyword="StationName" vr="SH" vm="1" name="Station Name"/>
-    <entry group="0008" element="1030" keyword="StudyDescription" vr="LO" vm="1" name="Study Description"/>
-    <entry group="0008" element="1032" keyword="ProcedureCodeSequence" vr="SQ" vm="1" name="Procedure Code Sequence"/>
-    <entry group="0008" element="103e" keyword="SeriesDescription" vr="LO" vm="1" name="Series Description"/>
-    <entry group="0008" element="103f" keyword="SeriesDescriptionCodeSequence" vr="SQ" vm="1" name="Series Description Code Sequence"/>
-    <entry group="0008" element="1040" keyword="InstitutionalDepartmentName" vr="LO" vm="1" name="Institutional Department Name"/>
-    <entry group="0008" element="1048" keyword="PhysiciansOfRecord" vr="PN" vm="1-n" name="Physician(s) of Record"/>
-    <entry group="0008" element="1049" keyword="PhysiciansOfRecordIdentificationSequence" vr="SQ" vm="1" name="Physician(s) of Record Identification Sequence"/>
-    <entry group="0008" element="1050" keyword="PerformingPhysicianName" vr="PN" vm="1-n" name="Performing Physician's Name"/>
-    <entry group="0008" element="1052" keyword="PerformingPhysicianIdentificationSequence" vr="SQ" vm="1" name="Performing Physician Identification Sequence"/>
-    <entry group="0008" element="1060" keyword="NameOfPhysiciansReadingStudy" vr="PN" vm="1-n" name="Name of Physician(s) Reading Study"/>
-    <entry group="0008" element="1062" keyword="PhysiciansReadingStudyIdentificationSequence" vr="SQ" vm="1" name="Physician(s) Reading Study Identification Sequence"/>
-    <entry group="0008" element="1070" keyword="OperatorsName" vr="PN" vm="1-n" name="Operators' Name"/>
-    <entry group="0008" element="1072" keyword="OperatorIdentificationSequence" vr="SQ" vm="1" name="Operator Identification Sequence"/>
-    <entry group="0008" element="1080" keyword="AdmittingDiagnosesDescription" vr="LO" vm="1-n" name="Admitting Diagnoses Description"/>
-    <entry group="0008" element="1084" keyword="AdmittingDiagnosesCodeSequence" vr="SQ" vm="1" name="Admitting Diagnoses Code Sequence"/>
-    <entry group="0008" element="1090" keyword="ManufacturerModelName" vr="LO" vm="1" name="Manufacturer's Model Name"/>
-    <entry group="0008" element="1100" keyword="ReferencedResultsSequence" vr="SQ" vm="1" retired="true" name="Referenced Results Sequence"/>
-    <entry group="0008" element="1110" keyword="ReferencedStudySequence" vr="SQ" vm="1" name="Referenced Study Sequence"/>
-    <entry group="0008" element="1111" keyword="ReferencedPerformedProcedureStepSequence" vr="SQ" vm="1" name="Referenced Performed Procedure Step Sequence"/>
-    <entry group="0008" element="1115" keyword="ReferencedSeriesSequence" vr="SQ" vm="1" name="Referenced Series Sequence"/>
-    <entry group="0008" element="1120" keyword="ReferencedPatientSequence" vr="SQ" vm="1" name="Referenced Patient Sequence"/>
-    <entry group="0008" element="1125" keyword="ReferencedVisitSequence" vr="SQ" vm="1" name="Referenced Visit Sequence"/>
-    <entry group="0008" element="1130" keyword="ReferencedOverlaySequence" vr="SQ" vm="1" retired="true" name="Referenced Overlay Sequence"/>
-    <entry group="0008" element="1134" keyword="ReferencedStereometricInstanceSequence" vr="SQ" vm="1" name="Referenced Stereometric Instance Sequence"/>
-    <entry group="0008" element="113a" keyword="ReferencedWaveformSequence" vr="SQ" vm="1" name="Referenced Waveform Sequence"/>
-    <entry group="0008" element="1140" keyword="ReferencedImageSequence" vr="SQ" vm="1" name="Referenced Image Sequence"/>
-    <entry group="0008" element="1145" keyword="ReferencedCurveSequence" vr="SQ" vm="1" retired="true" name="Referenced Curve Sequence"/>
-    <entry group="0008" element="114a" keyword="ReferencedInstanceSequence" vr="SQ" vm="1" name="Referenced Instance Sequence"/>
-    <entry group="0008" element="114b" keyword="ReferencedRealWorldValueMappingInstanceSequence" vr="SQ" vm="1" name="Referenced Real World Value Mapping Instance Sequence"/>
-    <entry group="0008" element="1150" keyword="ReferencedSOPClassUID" vr="UI" vm="1" name="Referenced SOP Class UID"/>
-    <entry group="0008" element="1155" keyword="ReferencedSOPInstanceUID" vr="UI" vm="1" name="Referenced SOP Instance UID"/>
-    <entry group="0008" element="115a" keyword="SOPClassesSupported" vr="UI" vm="1-n" name="SOP Classes Supported"/>
-    <entry group="0008" element="1160" keyword="ReferencedFrameNumber" vr="IS" vm="1-n" name="Referenced Frame Number"/>
-    <entry group="0008" element="1161" keyword="SimpleFrameList" vr="UL" vm="1-n" name="Simple Frame List"/>
-    <entry group="0008" element="1162" keyword="CalculatedFrameList" vr="UL" vm="3-3n" name="Calculated Frame List"/>
-    <entry group="0008" element="1163" keyword="TimeRange" vr="FD" vm="2" name="Time Range"/>
-    <entry group="0008" element="1164" keyword="FrameExtractionSequence" vr="SQ" vm="1" name="Frame Extraction Sequence"/>
-    <entry group="0008" element="1167" keyword="MultiFrameSourceSOPInstanceUID" vr="UI" vm="1" name="Multi-Frame Source SOP Instance UID"/>
-    <entry group="0008" element="1195" keyword="TransactionUID" vr="UI" vm="1" name="Transaction UID"/>
-    <entry group="0008" element="1197" keyword="FailureReason" vr="US" vm="1" name="Failure Reason"/>
-    <entry group="0008" element="1198" keyword="FailedSOPSequence" vr="SQ" vm="1" name="Failed SOP Sequence"/>
-    <entry group="0008" element="1199" keyword="ReferencedSOPSequence" vr="SQ" vm="1" name="Referenced SOP Sequence"/>
-    <entry group="0008" element="1200" keyword="StudiesContainingOtherReferencedInstancesSequence" vr="SQ" vm="1" name="Studies Containing Other Referenced Instances Sequence"/>
-    <entry group="0008" element="1250" keyword="RelatedSeriesSequence" vr="SQ" vm="1" name="Related Series Sequence"/>
-    <entry group="0008" element="2110" keyword="LossyImageCompressionRetired" vr="CS" vm="1" retired="true" name="Lossy Image Compression (Retired)"/>
-    <entry group="0008" element="2111" keyword="DerivationDescription" vr="ST" vm="1" name="Derivation Description"/>
-    <entry group="0008" element="2112" keyword="SourceImageSequence" vr="SQ" vm="1" name="Source Image Sequence"/>
-    <entry group="0008" element="2120" keyword="StageName" vr="SH" vm="1" name="Stage Name"/>
-    <entry group="0008" element="2122" keyword="StageNumber" vr="IS" vm="1" name="Stage Number"/>
-    <entry group="0008" element="2124" keyword="NumberOfStages" vr="IS" vm="1" name="Number of Stages"/>
-    <entry group="0008" element="2127" keyword="ViewName" vr="SH" vm="1" name="View Name"/>
-    <entry group="0008" element="2128" keyword="ViewNumber" vr="IS" vm="1" name="View Number"/>
-    <entry group="0008" element="2129" keyword="NumberOfEventTimers" vr="IS" vm="1" name="Number of Event Timers"/>
-    <entry group="0008" element="212a" keyword="NumberOfViewsInStage" vr="IS" vm="1" name="Number of Views in Stage"/>
-    <entry group="0008" element="2130" keyword="EventElapsedTimes" vr="DS" vm="1-n" name="Event Elapsed Time(s)"/>
-    <entry group="0008" element="2132" keyword="EventTimerNames" vr="LO" vm="1-n" name="Event Timer Name(s)"/>
-    <entry group="0008" element="2133" keyword="EventTimerSequence" vr="SQ" vm="1" name="Event Timer Sequence"/>
-    <entry group="0008" element="2134" keyword="EventTimeOffset" vr="FD" vm="1" name="Event Time Offset"/>
-    <entry group="0008" element="2135" keyword="EventCodeSequence" vr="SQ" vm="1" name="Event Code Sequence"/>
-    <entry group="0008" element="2142" keyword="StartTrim" vr="IS" vm="1" name="Start Trim"/>
-    <entry group="0008" element="2143" keyword="StopTrim" vr="IS" vm="1" name="Stop Trim"/>
-    <entry group="0008" element="2144" keyword="RecommendedDisplayFrameRate" vr="IS" vm="1" name="Recommended Display Frame Rate"/>
-    <entry group="0008" element="2200" keyword="TransducerPosition" vr="CS" vm="1" retired="true" name="Transducer Position"/>
-    <entry group="0008" element="2204" keyword="TransducerOrientation" vr="CS" vm="1" retired="true" name="Transducer Orientation"/>
-    <entry group="0008" element="2208" keyword="AnatomicStructure" vr="CS" vm="1" retired="true" name="Anatomic Structure"/>
-    <entry group="0008" element="2218" keyword="AnatomicRegionSequence" vr="SQ" vm="1" name="Anatomic Region Sequence"/>
-    <entry group="0008" element="2220" keyword="AnatomicRegionModifierSequence" vr="SQ" vm="1" name="Anatomic Region Modifier Sequence"/>
-    <entry group="0008" element="2228" keyword="PrimaryAnatomicStructureSequence" vr="SQ" vm="1" name="Primary Anatomic Structure Sequence"/>
-    <entry group="0008" element="2229" keyword="AnatomicStructureSpaceOrRegionSequence" vr="SQ" vm="1" name="Anatomic Structure, Space or Region Sequence"/>
-    <entry group="0008" element="2230" keyword="PrimaryAnatomicStructureModifierSequence" vr="SQ" vm="1" name="Primary Anatomic Structure Modifier Sequence"/>
-    <entry group="0008" element="2240" keyword="TransducerPositionSequence" vr="SQ" vm="1" retired="true" name="Transducer Position Sequence"/>
-    <entry group="0008" element="2242" keyword="TransducerPositionModifierSequence" vr="SQ" vm="1" retired="true" name="Transducer Position Modifier Sequence"/>
-    <entry group="0008" element="2244" keyword="TransducerOrientationSequence" vr="SQ" vm="1" retired="true" name="Transducer Orientation Sequence"/>
-    <entry group="0008" element="2246" keyword="TransducerOrientationModifierSequence" vr="SQ" vm="1" retired="true" name="Transducer Orientation Modifier Sequence"/>
-    <entry group="0008" element="2251" keyword="AnatomicStructureSpaceOrRegionCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Structure Space Or Region Code Sequence (Trial)"/>
-    <entry group="0008" element="2253" keyword="AnatomicPortalOfEntranceCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Portal Of Entrance Code Sequence (Trial)"/>
-    <entry group="0008" element="2255" keyword="AnatomicApproachDirectionCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Approach Direction Code Sequence (Trial)"/>
-    <entry group="0008" element="2256" keyword="AnatomicPerspectiveDescriptionTrial" vr="ST" vm="1" retired="true" name="Anatomic Perspective Description (Trial)"/>
-    <entry group="0008" element="2257" keyword="AnatomicPerspectiveCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Perspective Code Sequence (Trial)"/>
-    <entry group="0008" element="2258" keyword="AnatomicLocationOfExaminingInstrumentDescriptionTrial" vr="ST" vm="1" retired="true" name="Anatomic Location Of Examining Instrument Description (Trial)"/>
-    <entry group="0008" element="2259" keyword="AnatomicLocationOfExaminingInstrumentCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Location Of Examining Instrument Code Sequence (Trial)"/>
-    <entry group="0008" element="225a" keyword="AnatomicStructureSpaceOrRegionModifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Structure Space Or Region Modifier Code Sequence (Trial)"/>
-    <entry group="0008" element="225c" keyword="OnAxisBackgroundAnatomicStructureCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="OnAxis Background Anatomic Structure Code Sequence (Trial)"/>
-    <entry group="0008" element="3001" keyword="AlternateRepresentationSequence" vr="SQ" vm="1" name="Alternate Representation Sequence"/>
-    <entry group="0008" element="3010" keyword="IrradiationEventUID" vr="UI" vm="1" name="Irradiation Event UID"/>
-    <entry group="0008" element="4000" keyword="IdentifyingComments" vr="LT" vm="1" retired="true" name="Identifying Comments"/>
-    <entry group="0008" element="9007" keyword="FrameType" vr="CS" vm="4" name="Frame Type"/>
-    <entry group="0008" element="9092" keyword="ReferencedImageEvidenceSequence" vr="SQ" vm="1" name="Referenced Image Evidence Sequence"/>
-    <entry group="0008" element="9121" keyword="ReferencedRawDataSequence" vr="SQ" vm="1" name="Referenced Raw Data Sequence"/>
-    <entry group="0008" element="9123" keyword="CreatorVersionUID" vr="UI" vm="1" name="Creator-Version UID"/>
-    <entry group="0008" element="9124" keyword="DerivationImageSequence" vr="SQ" vm="1" name="Derivation Image Sequence"/>
-    <entry group="0008" element="9154" keyword="SourceImageEvidenceSequence" vr="SQ" vm="1" name="Source Image Evidence Sequence"/>
-    <entry group="0008" element="9205" keyword="PixelPresentation" vr="CS" vm="1" name="Pixel Presentation"/>
-    <entry group="0008" element="9206" keyword="VolumetricProperties" vr="CS" vm="1" name="Volumetric Properties"/>
-    <entry group="0008" element="9207" keyword="VolumeBasedCalculationTechnique" vr="CS" vm="1" name="Volume Based Calculation Technique"/>
-    <entry group="0008" element="9208" keyword="ComplexImageComponent" vr="CS" vm="1" name="Complex Image Component"/>
-    <entry group="0008" element="9209" keyword="AcquisitionContrast" vr="CS" vm="1" name="Acquisition Contrast"/>
-    <entry group="0008" element="9215" keyword="DerivationCodeSequence" vr="SQ" vm="1" name="Derivation Code Sequence"/>
-    <entry group="0008" element="9237" keyword="ReferencedPresentationStateSequence" vr="SQ" vm="1" name="Referenced Presentation State Sequence"/>
-    <entry group="0008" element="9410" keyword="ReferencedOtherPlaneSequence" vr="SQ" vm="1" name="Referenced Other Plane Sequence"/>
-    <entry group="0008" element="9458" keyword="FrameDisplaySequence" vr="SQ" vm="1" name="Frame Display Sequence"/>
-    <entry group="0008" element="9459" keyword="RecommendedDisplayFrameRateInFloat" vr="FL" vm="1" name="Recommended Display Frame Rate in Float"/>
-    <entry group="0008" element="9460" keyword="SkipFrameRangeFlag" vr="CS" vm="1" name="Skip Frame Range Flag"/>
-    <entry group="0010" element="0010" keyword="PatientName" vr="PN" vm="1" name="Patient's Name"/>
-    <entry group="0010" element="0020" keyword="PatientID" vr="LO" vm="1" name="Patient ID"/>
-    <entry group="0010" element="0021" keyword="IssuerOfPatientID" vr="LO" vm="1" name="Issuer of Patient ID"/>
-    <entry group="0010" element="0022" keyword="TypeOfPatientID" vr="CS" vm="1" name="Type of Patient ID"/>
-    <entry group="0010" element="0024" keyword="IssuerOfPatientIDQualifiersSequence" vr="SQ" vm="1" name="Issuer of Patient ID Qualifiers Sequence"/>
-    <entry group="0010" element="0030" keyword="PatientBirthDate" vr="DA" vm="1" name="Patient's Birth Date"/>
-    <entry group="0010" element="0032" keyword="PatientBirthTime" vr="TM" vm="1" name="Patient's Birth Time"/>
-    <entry group="0010" element="0040" keyword="PatientSex" vr="CS" vm="1" name="Patient's Sex"/>
-    <entry group="0010" element="0050" keyword="PatientInsurancePlanCodeSequence" vr="SQ" vm="1" name="Patient's Insurance Plan Code Sequence"/>
-    <entry group="0010" element="0101" keyword="PatientPrimaryLanguageCodeSequence" vr="SQ" vm="1" name="Patient's Primary Language Code Sequence"/>
-    <entry group="0010" element="0102" keyword="PatientPrimaryLanguageModifierCodeSequence" vr="SQ" vm="1" name="Patient's Primary Language Modifier Code Sequence"/>
-    <entry group="0010" element="1000" keyword="OtherPatientIDs" vr="LO" vm="1-n" name="Other Patient IDs"/>
-    <entry group="0010" element="1001" keyword="OtherPatientNames" vr="PN" vm="1-n" name="Other Patient Names"/>
-    <entry group="0010" element="1002" keyword="OtherPatientIDsSequence" vr="SQ" vm="1" name="Other Patient IDs Sequence"/>
-    <entry group="0010" element="1005" keyword="PatientBirthName" vr="PN" vm="1" name="Patient's Birth Name"/>
-    <entry group="0010" element="1010" keyword="PatientAge" vr="AS" vm="1" name="Patient's Age"/>
-    <entry group="0010" element="1020" keyword="PatientSize" vr="DS" vm="1" name="Patient's Size"/>
-    <entry group="0010" element="1021" keyword="PatientSizeCodeSequence" vr="SQ" vm="1" name="Patient's Size Code Sequence"/>
-    <entry group="0010" element="1030" keyword="PatientWeight" vr="DS" vm="1" name="Patient's Weight"/>
-    <entry group="0010" element="1040" keyword="PatientAddress" vr="LO" vm="1" name="Patient's Address"/>
-    <entry group="0010" element="1050" keyword="InsurancePlanIdentification" vr="LO" vm="1-n" retired="true" name="Insurance Plan Identification"/>
-    <entry group="0010" element="1060" keyword="PatientMotherBirthName" vr="PN" vm="1" name="Patient's Mother's Birth Name"/>
-    <entry group="0010" element="1080" keyword="MilitaryRank" vr="LO" vm="1" name="Military Rank"/>
-    <entry group="0010" element="1081" keyword="BranchOfService" vr="LO" vm="1" name="Branch of Service"/>
-    <entry group="0010" element="1090" keyword="MedicalRecordLocator" vr="LO" vm="1" name="Medical Record Locator"/>
-    <entry group="0010" element="2000" keyword="MedicalAlerts" vr="LO" vm="1-n" name="Medical Alerts"/>
-    <entry group="0010" element="2110" keyword="Allergies" vr="LO" vm="1-n" name="Allergies"/>
-    <entry group="0010" element="2150" keyword="CountryOfResidence" vr="LO" vm="1" name="Country of Residence"/>
-    <entry group="0010" element="2152" keyword="RegionOfResidence" vr="LO" vm="1" name="Region of Residence"/>
-    <entry group="0010" element="2154" keyword="PatientTelephoneNumbers" vr="SH" vm="1-n" name="Patient's Telephone Numbers"/>
-    <entry group="0010" element="2160" keyword="EthnicGroup" vr="SH" vm="1" name="Ethnic Group"/>
-    <entry group="0010" element="2180" keyword="Occupation" vr="SH" vm="1" name="Occupation"/>
-    <entry group="0010" element="21a0" keyword="SmokingStatus" vr="CS" vm="1" name="Smoking Status"/>
-    <entry group="0010" element="21b0" keyword="AdditionalPatientHistory" vr="LT" vm="1" name="Additional Patient History"/>
-    <entry group="0010" element="21c0" keyword="PregnancyStatus" vr="US" vm="1" name="Pregnancy Status"/>
-    <entry group="0010" element="21d0" keyword="LastMenstrualDate" vr="DA" vm="1" name="Last Menstrual Date"/>
-    <entry group="0010" element="21f0" keyword="PatientReligiousPreference" vr="LO" vm="1" name="Patient's Religious Preference"/>
-    <entry group="0010" element="2201" keyword="PatientSpeciesDescription" vr="LO" vm="1" name="Patient Species Description"/>
-    <entry group="0010" element="2202" keyword="PatientSpeciesCodeSequence" vr="SQ" vm="1" name="Patient Species Code Sequence"/>
-    <entry group="0010" element="2203" keyword="PatientSexNeutered" vr="CS" vm="1" name="Patient's Sex Neutered"/>
-    <entry group="0010" element="2210" keyword="AnatomicalOrientationType" vr="CS" vm="1" name="Anatomical Orientation Type"/>
-    <entry group="0010" element="2292" keyword="PatientBreedDescription" vr="LO" vm="1" name="Patient Breed Description"/>
-    <entry group="0010" element="2293" keyword="PatientBreedCodeSequence" vr="SQ" vm="1" name="Patient Breed Code Sequence"/>
-    <entry group="0010" element="2294" keyword="BreedRegistrationSequence" vr="SQ" vm="1" name="Breed Registration Sequence"/>
-    <entry group="0010" element="2295" keyword="BreedRegistrationNumber" vr="LO" vm="1" name="Breed Registration Number"/>
-    <entry group="0010" element="2296" keyword="BreedRegistryCodeSequence" vr="SQ" vm="1" name="Breed Registry Code Sequence"/>
-    <entry group="0010" element="2297" keyword="ResponsiblePerson" vr="PN" vm="1" name="Responsible Person"/>
-    <entry group="0010" element="2298" keyword="ResponsiblePersonRole" vr="CS" vm="1" name="Responsible Person Role"/>
-    <entry group="0010" element="2299" keyword="ResponsibleOrganization" vr="LO" vm="1" name="Responsible Organization"/>
-    <entry group="0010" element="4000" keyword="PatientComments" vr="LT" vm="1" name="Patient Comments"/>
-    <entry group="0010" element="9431" keyword="ExaminedBodyThickness" vr="FL" vm="1" name="Examined Body Thickness"/>
-    <entry group="0012" element="0010" keyword="ClinicalTrialSponsorName" vr="LO" vm="1" name="Clinical Trial Sponsor Name"/>
-    <entry group="0012" element="0020" keyword="ClinicalTrialProtocolID" vr="LO" vm="1" name="Clinical Trial Protocol ID"/>
-    <entry group="0012" element="0021" keyword="ClinicalTrialProtocolName" vr="LO" vm="1" name="Clinical Trial Protocol Name"/>
-    <entry group="0012" element="0030" keyword="ClinicalTrialSiteID" vr="LO" vm="1" name="Clinical Trial Site ID"/>
-    <entry group="0012" element="0031" keyword="ClinicalTrialSiteName" vr="LO" vm="1" name="Clinical Trial Site Name"/>
-    <entry group="0012" element="0040" keyword="ClinicalTrialSubjectID" vr="LO" vm="1" name="Clinical Trial Subject ID"/>
-    <entry group="0012" element="0042" keyword="ClinicalTrialSubjectReadingID" vr="LO" vm="1" name="Clinical Trial Subject Reading ID"/>
-    <entry group="0012" element="0050" keyword="ClinicalTrialTimePointID" vr="LO" vm="1" name="Clinical Trial Time Point ID"/>
-    <entry group="0012" element="0051" keyword="ClinicalTrialTimePointDescription" vr="ST" vm="1" name="Clinical Trial Time Point Description"/>
-    <entry group="0012" element="0060" keyword="ClinicalTrialCoordinatingCenterName" vr="LO" vm="1" name="Clinical Trial Coordinating Center Name"/>
-    <entry group="0012" element="0062" keyword="PatientIdentityRemoved" vr="CS" vm="1" name="Patient Identity Removed"/>
-    <entry group="0012" element="0063" keyword="DeidentificationMethod" vr="LO" vm="1-n" name="De-identification Method"/>
-    <entry group="0012" element="0064" keyword="DeidentificationMethodCodeSequence" vr="SQ" vm="1" name="De-identification Method Code Sequence"/>
-    <entry group="0012" element="0071" keyword="ClinicalTrialSeriesID" vr="LO" vm="1" name="Clinical Trial Series ID"/>
-    <entry group="0012" element="0072" keyword="ClinicalTrialSeriesDescription" vr="LO" vm="1" name="Clinical Trial Series Description"/>
-    <entry group="0012" element="0081" keyword="ClinicalTrialProtocolEthicsCommitteeName" vr="LO" vm="1" name="Clinical Trial Protocol Ethics Committee Name"/>
-    <entry group="0012" element="0082" keyword="ClinicalTrialProtocolEthicsCommitteeApprovalNumber" vr="LO" vm="1" name="Clinical Trial Protocol Ethics Committee Approval Number"/>
-    <entry group="0012" element="0083" keyword="ConsentForClinicalTrialUseSequence" vr="SQ" vm="1" name="Consent for Clinical Trial Use Sequence"/>
-    <entry group="0012" element="0084" keyword="DistributionType" vr="CS" vm="1" name="Distribution Type"/>
-    <entry group="0012" element="0085" keyword="ConsentForDistributionFlag" vr="CS" vm="1" name="Consent for Distribution Flag"/>
-    <entry group="0014" element="0023" keyword="CADFileFormat" vr="ST" vm="1-n" name="CAD File Format"/>
-    <entry group="0014" element="0024" keyword="ComponentReferenceSystem" vr="ST" vm="1-n" name="Component Reference System"/>
-    <entry group="0014" element="0025" keyword="ComponentManufacturingProcedure" vr="ST" vm="1-n" name="Component Manufacturing Procedure"/>
-    <entry group="0014" element="0028" keyword="ComponentManufacturer" vr="ST" vm="1-n" name="Component Manufacturer"/>
-    <entry group="0014" element="0030" keyword="MaterialThickness" vr="DS" vm="1-n" name="Material Thickness"/>
-    <entry group="0014" element="0032" keyword="MaterialPipeDiameter" vr="DS" vm="1-n" name="Material Pipe Diameter"/>
-    <entry group="0014" element="0034" keyword="MaterialIsolationDiameter" vr="DS" vm="1-n" name="Material Isolation Diameter"/>
-    <entry group="0014" element="0042" keyword="MaterialGrade" vr="ST" vm="1-n" name="Material Grade"/>
-    <entry group="0014" element="0044" keyword="MaterialPropertiesFileID" vr="ST" vm="1-n" name="Material Properties File ID"/>
-    <entry group="0014" element="0045" keyword="MaterialPropertiesFileFormat" vr="ST" vm="1-n" name="Material Properties File Format"/>
-    <entry group="0014" element="0046" keyword="MaterialNotes" vr="LT" vm="1" name="Material Notes"/>
-    <entry group="0014" element="0050" keyword="ComponentShape" vr="CS" vm="1" name="Component Shape"/>
-    <entry group="0014" element="0052" keyword="CurvatureType" vr="CS" vm="1" name="Curvature Type"/>
-    <entry group="0014" element="0054" keyword="OuterDiameter" vr="DS" vm="1" name="Outer Diameter"/>
-    <entry group="0014" element="0056" keyword="InnerDiameter" vr="DS" vm="1" name="Inner Diameter"/>
-    <entry group="0014" element="1010" keyword="ActualEnvironmentalConditions" vr="ST" vm="1" name="Actual Environmental Conditions"/>
-    <entry group="0014" element="1020" keyword="ExpiryDate" vr="DA" vm="1" name="Expiry Date"/>
-    <entry group="0014" element="1040" keyword="EnvironmentalConditions" vr="ST" vm="1" name="Environmental Conditions"/>
-    <entry group="0014" element="2002" keyword="EvaluatorSequence" vr="SQ" vm="1" name="Evaluator Sequence"/>
-    <entry group="0014" element="2004" keyword="EvaluatorNumber" vr="IS" vm="1" name="Evaluator Number"/>
-    <entry group="0014" element="2006" keyword="EvaluatorName" vr="PN" vm="1" name="Evaluator Name"/>
-    <entry group="0014" element="2008" keyword="EvaluationAttempt" vr="IS" vm="1" name="Evaluation Attempt"/>
-    <entry group="0014" element="2012" keyword="IndicationSequence" vr="SQ" vm="1" name="Indication Sequence"/>
-    <entry group="0014" element="2014" keyword="IndicationNumber" vr="IS" vm="1" name="Indication Number"/>
-    <entry group="0014" element="2016" keyword="IndicationLabel" vr="SH" vm="1" name="Indication Label"/>
-    <entry group="0014" element="2018" keyword="IndicationDescription" vr="ST" vm="1" name="Indication Description"/>
-    <entry group="0014" element="201a" keyword="IndicationType" vr="CS" vm="1-n" name="Indication Type"/>
-    <entry group="0014" element="201c" keyword="IndicationDisposition" vr="CS" vm="1" name="Indication Disposition"/>
-    <entry group="0014" element="201e" keyword="IndicationROISequence" vr="SQ" vm="1" name="Indication ROI Sequence"/>
-    <entry group="0014" element="2030" keyword="IndicationPhysicalPropertySequence" vr="SQ" vm="1" name="Indication Physical Property Sequence"/>
-    <entry group="0014" element="2032" keyword="PropertyLabel" vr="SH" vm="1" name="Property Label"/>
-    <entry group="0014" element="2202" keyword="CoordinateSystemNumberOfAxes" vr="IS" vm="1" name="Coordinate System Number of Axes"/>
-    <entry group="0014" element="2204" keyword="CoordinateSystemAxesSequence" vr="SQ" vm="1" name="Coordinate System Axes Sequence"/>
-    <entry group="0014" element="2206" keyword="CoordinateSystemAxisDescription" vr="ST" vm="1" name="Coordinate System Axis Description"/>
-    <entry group="0014" element="2208" keyword="CoordinateSystemDataSetMapping" vr="CS" vm="1" name="Coordinate System Data Set Mapping"/>
-    <entry group="0014" element="220a" keyword="CoordinateSystemAxisNumber" vr="IS" vm="1" name="Coordinate System Axis Number"/>
-    <entry group="0014" element="220c" keyword="CoordinateSystemAxisType" vr="CS" vm="1" name="Coordinate System Axis Type"/>
-    <entry group="0014" element="220e" keyword="CoordinateSystemAxisUnits" vr="CS" vm="1" name="Coordinate System Axis Units"/>
-    <entry group="0014" element="2210" keyword="CoordinateSystemAxisValues" vr="OB" vm="1" name="Coordinate System Axis Values"/>
-    <entry group="0014" element="2220" keyword="CoordinateSystemTransformSequence" vr="SQ" vm="1" name="Coordinate System Transform Sequence"/>
-    <entry group="0014" element="2222" keyword="TransformDescription" vr="ST" vm="1" name="Transform Description"/>
-    <entry group="0014" element="2224" keyword="TransformNumberOfAxes" vr="IS" vm="1" name="Transform Number of Axes"/>
-    <entry group="0014" element="2226" keyword="TransformOrderOfAxes" vr="IS" vm="1-n" name="Transform Order of Axes"/>
-    <entry group="0014" element="2228" keyword="TransformedAxisUnits" vr="CS" vm="1" name="Transformed Axis Units"/>
-    <entry group="0014" element="222a" keyword="CoordinateSystemTransformRotationAndScaleMatrix" vr="DS" vm="1-n" name="Coordinate System Transform Rotation and Scale Matrix"/>
-    <entry group="0014" element="222c" keyword="CoordinateSystemTransformTranslationMatrix" vr="DS" vm="1-n" name="Coordinate System Transform Translation Matrix"/>
-    <entry group="0014" element="3011" keyword="InternalDetectorFrameTime" vr="DS" vm="1" name="Internal Detector Frame Time"/>
-    <entry group="0014" element="3012" keyword="NumberOfFramesIntegrated" vr="DS" vm="1" name="Number of Frames Integrated"/>
-    <entry group="0014" element="3020" keyword="DetectorTemperatureSequence" vr="SQ" vm="1" name="Detector Temperature Sequence"/>
-    <entry group="0014" element="3022" keyword="SensorName" vr="ST" vm="1" name="Sensor Name"/>
-    <entry group="0014" element="3024" keyword="HorizontalOffsetOfSensor" vr="DS" vm="1" name="Horizontal Offset of Sensor"/>
-    <entry group="0014" element="3026" keyword="VerticalOffsetOfSensor" vr="DS" vm="1" name="Vertical Offset of Sensor"/>
-    <entry group="0014" element="3028" keyword="SensorTemperature" vr="DS" vm="1" name="Sensor Temperature"/>
-    <entry group="0014" element="3040" keyword="DarkCurrentSequence" vr="SQ" vm="1" name="Dark Current Sequence"/>
-    <entry group="0014" element="3050" keyword="DarkCurrentCounts" vr="OB_OW" vm="1" name="Dark Current Counts"/>
-    <entry group="0014" element="3060" keyword="GainCorrectionReferenceSequence" vr="SQ" vm="1" name="Gain Correction Reference Sequence"/>
-    <entry group="0014" element="3070" keyword="AirCounts" vr="OB_OW" vm="1" name="Air Counts"/>
-    <entry group="0014" element="3071" keyword="KVUsedInGainCalibration" vr="DS" vm="1" name="KV Used in Gain Calibration"/>
-    <entry group="0014" element="3072" keyword="MAUsedInGainCalibration" vr="DS" vm="1" name="MA Used in Gain Calibration"/>
-    <entry group="0014" element="3073" keyword="NumberOfFramesUsedForIntegration" vr="DS" vm="1" name="Number of Frames Used for Integration"/>
-    <entry group="0014" element="3074" keyword="FilterMaterialUsedInGainCalibration" vr="LO" vm="1" name="Filter Material Used in Gain Calibration"/>
-    <entry group="0014" element="3075" keyword="FilterThicknessUsedInGainCalibration" vr="DS" vm="1" name="Filter Thickness Used in Gain Calibration"/>
-    <entry group="0014" element="3076" keyword="DateOfGainCalibration" vr="DA" vm="1" name="Date of Gain Calibration"/>
-    <entry group="0014" element="3077" keyword="TimeOfGainCalibration" vr="TM" vm="1" name="Time of Gain Calibration"/>
-    <entry group="0014" element="3080" keyword="BadPixelImage" vr="OB" vm="1" name="Bad Pixel Image"/>
-    <entry group="0014" element="3099" keyword="CalibrationNotes" vr="LT" vm="1" name="Calibration Notes"/>
-    <entry group="0014" element="4002" keyword="PulserEquipmentSequence" vr="SQ" vm="1" name="Pulser Equipment Sequence"/>
-    <entry group="0014" element="4004" keyword="PulserType" vr="CS" vm="1" name="Pulser Type"/>
-    <entry group="0014" element="4006" keyword="PulserNotes" vr="LT" vm="1" name="Pulser Notes"/>
-    <entry group="0014" element="4008" keyword="ReceiverEquipmentSequence" vr="SQ" vm="1" name="Receiver Equipment Sequence"/>
-    <entry group="0014" element="400a" keyword="AmplifierType" vr="CS" vm="1" name="Amplifier Type"/>
-    <entry group="0014" element="400c" keyword="ReceiverNotes" vr="LT" vm="1" name="Receiver Notes"/>
-    <entry group="0014" element="400e" keyword="PreAmplifierEquipmentSequence" vr="SQ" vm="1" name="Pre-Amplifier Equipment Sequence"/>
-    <entry group="0014" element="400f" keyword="PreAmplifierNotes" vr="LT" vm="1" name="Pre-Amplifier Notes"/>
-    <entry group="0014" element="4010" keyword="TransmitTransducerSequence" vr="SQ" vm="1" name="Transmit Transducer Sequence"/>
-    <entry group="0014" element="4011" keyword="ReceiveTransducerSequence" vr="SQ" vm="1" name="Receive Transducer Sequence"/>
-    <entry group="0014" element="4012" keyword="NumberOfElements" vr="US" vm="1" name="Number of Elements"/>
-    <entry group="0014" element="4013" keyword="ElementShape" vr="CS" vm="1" name="Element Shape"/>
-    <entry group="0014" element="4014" keyword="ElementDimensionA" vr="DS" vm="1" name="Element Dimension A"/>
-    <entry group="0014" element="4015" keyword="ElementDimensionB" vr="DS" vm="1" name="Element Dimension B"/>
-    <entry group="0014" element="4016" keyword="ElementPitch" vr="DS" vm="1" name="Element Pitch"/>
-    <entry group="0014" element="4017" keyword="MeasuredBeamDimensionA" vr="DS" vm="1" name="Measured Beam Dimension A"/>
-    <entry group="0014" element="4018" keyword="MeasuredBeamDimensionB" vr="DS" vm="1" name="Measured Beam Dimension B"/>
-    <entry group="0014" element="4019" keyword="LocationOfMeasuredBeamDiameter" vr="DS" vm="1" name="Location of Measured Beam Diameter"/>
-    <entry group="0014" element="401a" keyword="NominalFrequency" vr="DS" vm="1" name="Nominal Frequency"/>
-    <entry group="0014" element="401b" keyword="MeasuredCenterFrequency" vr="DS" vm="1" name="Measured Center Frequency"/>
-    <entry group="0014" element="401c" keyword="MeasuredBandwidth" vr="DS" vm="1" name="Measured Bandwidth"/>
-    <entry group="0014" element="4020" keyword="PulserSettingsSequence" vr="SQ" vm="1" name="Pulser Settings Sequence"/>
-    <entry group="0014" element="4022" keyword="PulseWidth" vr="DS" vm="1" name="Pulse Width"/>
-    <entry group="0014" element="4024" keyword="ExcitationFrequency" vr="DS" vm="1" name="Excitation Frequency"/>
-    <entry group="0014" element="4026" keyword="ModulationType" vr="CS" vm="1" name="Modulation Type"/>
-    <entry group="0014" element="4028" keyword="Damping" vr="DS" vm="1" name="Damping"/>
-    <entry group="0014" element="4030" keyword="ReceiverSettingsSequence" vr="SQ" vm="1" name="Receiver Settings Sequence"/>
-    <entry group="0014" element="4031" keyword="AcquiredSoundpathLength" vr="DS" vm="1" name="Acquired Soundpath Length"/>
-    <entry group="0014" element="4032" keyword="AcquisitionCompressionType" vr="CS" vm="1" name="Acquisition Compression Type"/>
-    <entry group="0014" element="4033" keyword="AcquisitionSampleSize" vr="IS" vm="1" name="Acquisition Sample Size"/>
-    <entry group="0014" element="4034" keyword="RectifierSmoothing" vr="DS" vm="1" name="Rectifier Smoothing"/>
-    <entry group="0014" element="4035" keyword="DACSequence" vr="SQ" vm="1" name="DAC Sequence"/>
-    <entry group="0014" element="4036" keyword="DACType" vr="CS" vm="1" name="DAC Type"/>
-    <entry group="0014" element="4038" keyword="DACGainPoints" vr="DS" vm="1-n" name="DAC Gain Points"/>
-    <entry group="0014" element="403a" keyword="DACTimePoints" vr="DS" vm="1-n" name="DAC Time Points"/>
-    <entry group="0014" element="403c" keyword="DACAmplitude" vr="DS" vm="1-n" name="DAC Amplitude"/>
-    <entry group="0014" element="4040" keyword="PreAmplifierSettingsSequence" vr="SQ" vm="1" name="Pre-Amplifier Settings Sequence"/>
-    <entry group="0014" element="4050" keyword="TransmitTransducerSettingsSequence" vr="SQ" vm="1" name="Transmit Transducer Settings Sequence"/>
-    <entry group="0014" element="4051" keyword="ReceiveTransducerSettingsSequence" vr="SQ" vm="1" name="Receive Transducer Settings Sequence"/>
-    <entry group="0014" element="4052" keyword="IncidentAngle" vr="DS" vm="1" name="Incident Angle"/>
-    <entry group="0014" element="4054" keyword="CouplingTechnique" vr="ST" vm="1" name="Coupling Technique"/>
-    <entry group="0014" element="4056" keyword="CouplingMedium" vr="ST" vm="1" name="Coupling Medium"/>
-    <entry group="0014" element="4057" keyword="CouplingVelocity" vr="DS" vm="1" name="Coupling Velocity"/>
-    <entry group="0014" element="4058" keyword="CrystalCenterLocationX" vr="DS" vm="1" name="Crystal Center Location X"/>
-    <entry group="0014" element="4059" keyword="CrystalCenterLocationZ" vr="DS" vm="1" name="Crystal Center Location Z"/>
-    <entry group="0014" element="405a" keyword="SoundPathLength" vr="DS" vm="1" name="Sound Path Length"/>
-    <entry group="0014" element="405c" keyword="DelayLawIdentifier" vr="ST" vm="1" name="Delay Law Identifier"/>
-    <entry group="0014" element="4060" keyword="GateSettingsSequence" vr="SQ" vm="1" name="Gate Settings Sequence"/>
-    <entry group="0014" element="4062" keyword="GateThreshold" vr="DS" vm="1" name="Gate Threshold"/>
-    <entry group="0014" element="4064" keyword="VelocityOfSound" vr="DS" vm="1" name="Velocity of Sound"/>
-    <entry group="0014" element="4070" keyword="CalibrationSettingsSequence" vr="SQ" vm="1" name="Calibration Settings Sequence"/>
-    <entry group="0014" element="4072" keyword="CalibrationProcedure" vr="ST" vm="1" name="Calibration Procedure"/>
-    <entry group="0014" element="4074" keyword="ProcedureVersion" vr="SH" vm="1" name="Procedure Version"/>
-    <entry group="0014" element="4076" keyword="ProcedureCreationDate" vr="DA" vm="1" name="Procedure Creation Date"/>
-    <entry group="0014" element="4078" keyword="ProcedureExpirationDate" vr="DA" vm="1" name="Procedure Expiration Date"/>
-    <entry group="0014" element="407a" keyword="ProcedureLastModifiedDate" vr="DA" vm="1" name="Procedure Last Modified Date"/>
-    <entry group="0014" element="407c" keyword="CalibrationTime" vr="TM" vm="1-n" name="Calibration Time"/>
-    <entry group="0014" element="407e" keyword="CalibrationDate" vr="DA" vm="1-n" name="Calibration Date"/>
-    <entry group="0014" element="5002" keyword="LINACEnergy" vr="IS" vm="1" name="LINAC Energy"/>
-    <entry group="0014" element="5004" keyword="LINACOutput" vr="IS" vm="1" name="LINAC Output"/>
-    <entry group="0018" element="0010" keyword="ContrastBolusAgent" vr="LO" vm="1" name="Contrast/Bolus Agent"/>
-    <entry group="0018" element="0012" keyword="ContrastBolusAgentSequence" vr="SQ" vm="1" name="Contrast/Bolus Agent Sequence"/>
-    <entry group="0018" element="0014" keyword="ContrastBolusAdministrationRouteSequence" vr="SQ" vm="1" name="Contrast/Bolus Administration Route Sequence"/>
-    <entry group="0018" element="0015" keyword="BodyPartExamined" vr="CS" vm="1" name="Body Part Examined"/>
-    <entry group="0018" element="0020" keyword="ScanningSequence" vr="CS" vm="1-n" name="Scanning Sequence"/>
-    <entry group="0018" element="0021" keyword="SequenceVariant" vr="CS" vm="1-n" name="Sequence Variant"/>
-    <entry group="0018" element="0022" keyword="ScanOptions" vr="CS" vm="1-n" name="Scan Options"/>
-    <entry group="0018" element="0023" keyword="MRAcquisitionType" vr="CS" vm="1" name="MR Acquisition Type"/>
-    <entry group="0018" element="0024" keyword="SequenceName" vr="SH" vm="1" name="Sequence Name"/>
-    <entry group="0018" element="0025" keyword="AngioFlag" vr="CS" vm="1" name="Angio Flag"/>
-    <entry group="0018" element="0026" keyword="InterventionDrugInformationSequence" vr="SQ" vm="1" name="Intervention Drug Information Sequence"/>
-    <entry group="0018" element="0027" keyword="InterventionDrugStopTime" vr="TM" vm="1" name="Intervention Drug Stop Time"/>
-    <entry group="0018" element="0028" keyword="InterventionDrugDose" vr="DS" vm="1" name="Intervention Drug Dose"/>
-    <entry group="0018" element="0029" keyword="InterventionDrugCodeSequence" vr="SQ" vm="1" name="Intervention Drug Code Sequence"/>
-    <entry group="0018" element="002a" keyword="AdditionalDrugSequence" vr="SQ" vm="1" name="Additional Drug Sequence"/>
-    <entry group="0018" element="0030" keyword="Radionuclide" vr="LO" vm="1-n" retired="true" name="Radionuclide"/>
-    <entry group="0018" element="0031" keyword="Radiopharmaceutical" vr="LO" vm="1" name="Radiopharmaceutical"/>
-    <entry group="0018" element="0032" keyword="EnergyWindowCenterline" vr="DS" vm="1" retired="true" name="Energy Window Centerline"/>
-    <entry group="0018" element="0033" keyword="EnergyWindowTotalWidth" vr="DS" vm="1-n" retired="true" name="Energy Window Total Width"/>
-    <entry group="0018" element="0034" keyword="InterventionDrugName" vr="LO" vm="1" name="Intervention Drug Name"/>
-    <entry group="0018" element="0035" keyword="InterventionDrugStartTime" vr="TM" vm="1" name="Intervention Drug Start Time"/>
-    <entry group="0018" element="0036" keyword="InterventionSequence" vr="SQ" vm="1" name="Intervention Sequence"/>
-    <entry group="0018" element="0037" keyword="TherapyType" vr="CS" vm="1" retired="true" name="Therapy Type"/>
-    <entry group="0018" element="0038" keyword="InterventionStatus" vr="CS" vm="1" name="Intervention Status"/>
-    <entry group="0018" element="0039" keyword="TherapyDescription" vr="CS" vm="1" retired="true" name="Therapy Description"/>
-    <entry group="0018" element="003a" keyword="InterventionDescription" vr="ST" vm="1" name="Intervention Description"/>
-    <entry group="0018" element="0040" keyword="CineRate" vr="IS" vm="1" name="Cine Rate"/>
-    <entry group="0018" element="0042" keyword="InitialCineRunState" vr="CS" vm="1" name="Initial Cine Run State"/>
-    <entry group="0018" element="0050" keyword="SliceThickness" vr="DS" vm="1" name="Slice Thickness"/>
-    <entry group="0018" element="0060" keyword="KVP" vr="DS" vm="1" name="KVP">
-      <correction>kVp</correction>
-    </entry>
-    <entry group="0018" element="0070" keyword="CountsAccumulated" vr="IS" vm="1" name="Counts Accumulated"/>
-    <entry group="0018" element="0071" keyword="AcquisitionTerminationCondition" vr="CS" vm="1" name="Acquisition Termination Condition"/>
-    <entry group="0018" element="0072" keyword="EffectiveDuration" vr="DS" vm="1" name="Effective Duration"/>
-    <entry group="0018" element="0073" keyword="AcquisitionStartCondition" vr="CS" vm="1" name="Acquisition Start Condition"/>
-    <entry group="0018" element="0074" keyword="AcquisitionStartConditionData" vr="IS" vm="1" name="Acquisition Start Condition Data"/>
-    <entry group="0018" element="0075" keyword="AcquisitionTerminationConditionData" vr="IS" vm="1" name="Acquisition Termination Condition Data"/>
-    <entry group="0018" element="0080" keyword="RepetitionTime" vr="DS" vm="1" name="Repetition Time"/>
-    <entry group="0018" element="0081" keyword="EchoTime" vr="DS" vm="1" name="Echo Time"/>
-    <entry group="0018" element="0082" keyword="InversionTime" vr="DS" vm="1" name="Inversion Time"/>
-    <entry group="0018" element="0083" keyword="NumberOfAverages" vr="DS" vm="1" name="Number of Averages"/>
-    <entry group="0018" element="0084" keyword="ImagingFrequency" vr="DS" vm="1" name="Imaging Frequency"/>
-    <entry group="0018" element="0085" keyword="ImagedNucleus" vr="SH" vm="1" name="Imaged Nucleus"/>
-    <entry group="0018" element="0086" keyword="EchoNumbers" vr="IS" vm="1-n" name="Echo Number(s)"/>
-    <entry group="0018" element="0087" keyword="MagneticFieldStrength" vr="DS" vm="1" name="Magnetic Field Strength"/>
-    <entry group="0018" element="0088" keyword="SpacingBetweenSlices" vr="DS" vm="1" name="Spacing Between Slices"/>
-    <entry group="0018" element="0089" keyword="NumberOfPhaseEncodingSteps" vr="IS" vm="1" name="Number of Phase Encoding Steps"/>
-    <entry group="0018" element="0090" keyword="DataCollectionDiameter" vr="DS" vm="1" name="Data Collection Diameter"/>
-    <entry group="0018" element="0091" keyword="EchoTrainLength" vr="IS" vm="1" name="Echo Train Length"/>
-    <entry group="0018" element="0093" keyword="PercentSampling" vr="DS" vm="1" name="Percent Sampling"/>
-    <entry group="0018" element="0094" keyword="PercentPhaseFieldOfView" vr="DS" vm="1" name="Percent Phase Field of View"/>
-    <entry group="0018" element="0095" keyword="PixelBandwidth" vr="DS" vm="1" name="Pixel Bandwidth"/>
-    <entry group="0018" element="1000" keyword="DeviceSerialNumber" vr="LO" vm="1" name="Device Serial Number"/>
-    <entry group="0018" element="1002" keyword="DeviceUID" vr="UI" vm="1" name="Device UID"/>
-    <entry group="0018" element="1003" keyword="DeviceID" vr="LO" vm="1" name="Device ID"/>
-    <entry group="0018" element="1004" keyword="PlateID" vr="LO" vm="1" name="Plate ID"/>
-    <entry group="0018" element="1005" keyword="GeneratorID" vr="LO" vm="1" name="Generator ID"/>
-    <entry group="0018" element="1006" keyword="GridID" vr="LO" vm="1" name="Grid ID"/>
-    <entry group="0018" element="1007" keyword="CassetteID" vr="LO" vm="1" name="Cassette ID"/>
-    <entry group="0018" element="1008" keyword="GantryID" vr="LO" vm="1" name="Gantry ID"/>
-    <entry group="0018" element="1010" keyword="SecondaryCaptureDeviceID" vr="LO" vm="1" name="Secondary Capture Device ID"/>
-    <entry group="0018" element="1011" keyword="HardcopyCreationDeviceID" vr="LO" vm="1" retired="true" name="Hardcopy Creation Device ID"/>
-    <entry group="0018" element="1012" keyword="DateOfSecondaryCapture" vr="DA" vm="1" name="Date of Secondary Capture"/>
-    <entry group="0018" element="1014" keyword="TimeOfSecondaryCapture" vr="TM" vm="1" name="Time of Secondary Capture"/>
-    <entry group="0018" element="1016" keyword="SecondaryCaptureDeviceManufacturer" vr="LO" vm="1" name="Secondary Capture Device Manufacturer"/>
-    <entry group="0018" element="1017" keyword="HardcopyDeviceManufacturer" vr="LO" vm="1" retired="true" name="Hardcopy Device Manufacturer"/>
-    <entry group="0018" element="1018" keyword="SecondaryCaptureDeviceManufacturerModelName" vr="LO" vm="1" name="Secondary Capture Device Manufacturer's Model Name"/>
-    <entry group="0018" element="1019" keyword="SecondaryCaptureDeviceSoftwareVersions" vr="LO" vm="1-n" name="Secondary Capture Device Software Versions"/>
-    <entry group="0018" element="101a" keyword="HardcopyDeviceSoftwareVersion" vr="LO" vm="1-n" retired="true" name="Hardcopy Device Software Version"/>
-    <entry group="0018" element="101b" keyword="HardcopyDeviceManufacturerModelName" vr="LO" vm="1" retired="true" name="Hardcopy Device Manufacturer's Model Name"/>
-    <entry group="0018" element="1020" keyword="SoftwareVersions" vr="LO" vm="1-n" name="Software Version(s)"/>
-    <entry group="0018" element="1022" keyword="VideoImageFormatAcquired" vr="SH" vm="1" name="Video Image Format Acquired"/>
-    <entry group="0018" element="1023" keyword="DigitalImageFormatAcquired" vr="LO" vm="1" name="Digital Image Format Acquired"/>
-    <entry group="0018" element="1030" keyword="ProtocolName" vr="LO" vm="1" name="Protocol Name"/>
-    <entry group="0018" element="1040" keyword="ContrastBolusRoute" vr="LO" vm="1" name="Contrast/Bolus Route"/>
-    <entry group="0018" element="1041" keyword="ContrastBolusVolume" vr="DS" vm="1" name="Contrast/Bolus Volume"/>
-    <entry group="0018" element="1042" keyword="ContrastBolusStartTime" vr="TM" vm="1" name="Contrast/Bolus Start Time"/>
-    <entry group="0018" element="1043" keyword="ContrastBolusStopTime" vr="TM" vm="1" name="Contrast/Bolus Stop Time"/>
-    <entry group="0018" element="1044" keyword="ContrastBolusTotalDose" vr="DS" vm="1" name="Contrast/Bolus Total Dose"/>
-    <entry group="0018" element="1045" keyword="SyringeCounts" vr="IS" vm="1" name="Syringe Counts"/>
-    <entry group="0018" element="1046" keyword="ContrastFlowRate" vr="DS" vm="1-n" name="Contrast Flow Rate"/>
-    <entry group="0018" element="1047" keyword="ContrastFlowDuration" vr="DS" vm="1-n" name="Contrast Flow Duration"/>
-    <entry group="0018" element="1048" keyword="ContrastBolusIngredient" vr="CS" vm="1" name="Contrast/Bolus Ingredient"/>
-    <entry group="0018" element="1049" keyword="ContrastBolusIngredientConcentration" vr="DS" vm="1" name="Contrast/Bolus Ingredient Concentration"/>
-    <entry group="0018" element="1050" keyword="SpatialResolution" vr="DS" vm="1" name="Spatial Resolution"/>
-    <entry group="0018" element="1060" keyword="TriggerTime" vr="DS" vm="1" name="Trigger Time"/>
-    <entry group="0018" element="1061" keyword="TriggerSourceOrType" vr="LO" vm="1" name="Trigger Source or Type"/>
-    <entry group="0018" element="1062" keyword="NominalInterval" vr="IS" vm="1" name="Nominal Interval"/>
-    <entry group="0018" element="1063" keyword="FrameTime" vr="DS" vm="1" name="Frame Time"/>
-    <entry group="0018" element="1064" keyword="CardiacFramingType" vr="LO" vm="1" name="Cardiac Framing Type"/>
-    <entry group="0018" element="1065" keyword="FrameTimeVector" vr="DS" vm="1-n" name="Frame Time Vector"/>
-    <entry group="0018" element="1066" keyword="FrameDelay" vr="DS" vm="1" name="Frame Delay"/>
-    <entry group="0018" element="1067" keyword="ImageTriggerDelay" vr="DS" vm="1" name="Image Trigger Delay"/>
-    <entry group="0018" element="1068" keyword="MultiplexGroupTimeOffset" vr="DS" vm="1" name="Multiplex Group Time Offset"/>
-    <entry group="0018" element="1069" keyword="TriggerTimeOffset" vr="DS" vm="1" name="Trigger Time Offset"/>
-    <entry group="0018" element="106a" keyword="SynchronizationTrigger" vr="CS" vm="1" name="Synchronization Trigger"/>
-    <entry group="0018" element="106c" keyword="SynchronizationChannel" vr="US" vm="2" name="Synchronization Channel"/>
-    <entry group="0018" element="106e" keyword="TriggerSamplePosition" vr="UL" vm="1" name="Trigger Sample Position"/>
-    <entry group="0018" element="1070" keyword="RadiopharmaceuticalRoute" vr="LO" vm="1" name="Radiopharmaceutical Route"/>
-    <entry group="0018" element="1071" keyword="RadiopharmaceuticalVolume" vr="DS" vm="1" name="Radiopharmaceutical Volume"/>
-    <entry group="0018" element="1072" keyword="RadiopharmaceuticalStartTime" vr="TM" vm="1" name="Radiopharmaceutical Start Time"/>
-    <entry group="0018" element="1073" keyword="RadiopharmaceuticalStopTime" vr="TM" vm="1" name="Radiopharmaceutical Stop Time"/>
-    <entry group="0018" element="1074" keyword="RadionuclideTotalDose" vr="DS" vm="1" name="Radionuclide Total Dose"/>
-    <entry group="0018" element="1075" keyword="RadionuclideHalfLife" vr="DS" vm="1" name="Radionuclide Half Life"/>
-    <entry group="0018" element="1076" keyword="RadionuclidePositronFraction" vr="DS" vm="1" name="Radionuclide Positron Fraction"/>
-    <entry group="0018" element="1077" keyword="RadiopharmaceuticalSpecificActivity" vr="DS" vm="1" name="Radiopharmaceutical Specific Activity"/>
-    <entry group="0018" element="1078" keyword="RadiopharmaceuticalStartDateTime" vr="DT" vm="1" name="Radiopharmaceutical Start DateTime"/>
-    <entry group="0018" element="1079" keyword="RadiopharmaceuticalStopDateTime" vr="DT" vm="1" name="Radiopharmaceutical Stop DateTime"/>
-    <entry group="0018" element="1080" keyword="BeatRejectionFlag" vr="CS" vm="1" name="Beat Rejection Flag"/>
-    <entry group="0018" element="1081" keyword="LowRRValue" vr="IS" vm="1" name="Low R-R Value"/>
-    <entry group="0018" element="1082" keyword="HighRRValue" vr="IS" vm="1" name="High R-R Value"/>
-    <entry group="0018" element="1083" keyword="IntervalsAcquired" vr="IS" vm="1" name="Intervals Acquired"/>
-    <entry group="0018" element="1084" keyword="IntervalsRejected" vr="IS" vm="1" name="Intervals Rejected"/>
-    <entry group="0018" element="1085" keyword="PVCRejection" vr="LO" vm="1" name="PVC Rejection"/>
-    <entry group="0018" element="1086" keyword="SkipBeats" vr="IS" vm="1" name="Skip Beats"/>
-    <entry group="0018" element="1088" keyword="HeartRate" vr="IS" vm="1" name="Heart Rate"/>
-    <entry group="0018" element="1090" keyword="CardiacNumberOfImages" vr="IS" vm="1" name="Cardiac Number of Images"/>
-    <entry group="0018" element="1094" keyword="TriggerWindow" vr="IS" vm="1" name="Trigger Window"/>
-    <entry group="0018" element="1100" keyword="ReconstructionDiameter" vr="DS" vm="1" name="Reconstruction Diameter"/>
-    <entry group="0018" element="1110" keyword="DistanceSourceToDetector" vr="DS" vm="1" name="Distance Source to Detector"/>
-    <entry group="0018" element="1111" keyword="DistanceSourceToPatient" vr="DS" vm="1" name="Distance Source to Patient"/>
-    <entry group="0018" element="1114" keyword="EstimatedRadiographicMagnificationFactor" vr="DS" vm="1" name="Estimated Radiographic Magnification Factor"/>
-    <entry group="0018" element="1120" keyword="GantryDetectorTilt" vr="DS" vm="1" name="Gantry/Detector Tilt"/>
-    <entry group="0018" element="1121" keyword="GantryDetectorSlew" vr="DS" vm="1" name="Gantry/Detector Slew"/>
-    <entry group="0018" element="1130" keyword="TableHeight" vr="DS" vm="1" name="Table Height"/>
-    <entry group="0018" element="1131" keyword="TableTraverse" vr="DS" vm="1" name="Table Traverse"/>
-    <entry group="0018" element="1134" keyword="TableMotion" vr="CS" vm="1" name="Table Motion"/>
-    <entry group="0018" element="1135" keyword="TableVerticalIncrement" vr="DS" vm="1-n" name="Table Vertical Increment"/>
-    <entry group="0018" element="1136" keyword="TableLateralIncrement" vr="DS" vm="1-n" name="Table Lateral Increment"/>
-    <entry group="0018" element="1137" keyword="TableLongitudinalIncrement" vr="DS" vm="1-n" name="Table Longitudinal Increment"/>
-    <entry group="0018" element="1138" keyword="TableAngle" vr="DS" vm="1" name="Table Angle"/>
-    <entry group="0018" element="113a" keyword="TableType" vr="CS" vm="1" name="Table Type"/>
-    <entry group="0018" element="1140" keyword="RotationDirection" vr="CS" vm="1" name="Rotation Direction"/>
-    <entry group="0018" element="1141" keyword="AngularPosition" vr="DS" vm="1" retired="true" name="Angular Position"/>
-    <entry group="0018" element="1142" keyword="RadialPosition" vr="DS" vm="1-n" name="Radial Position"/>
-    <entry group="0018" element="1143" keyword="ScanArc" vr="DS" vm="1" name="Scan Arc"/>
-    <entry group="0018" element="1144" keyword="AngularStep" vr="DS" vm="1" name="Angular Step"/>
-    <entry group="0018" element="1145" keyword="CenterOfRotationOffset" vr="DS" vm="1" name="Center of Rotation Offset"/>
-    <entry group="0018" element="1146" keyword="RotationOffset" vr="DS" vm="1-n" retired="true" name="Rotation Offset"/>
-    <entry group="0018" element="1147" keyword="FieldOfViewShape" vr="CS" vm="1" name="Field of View Shape"/>
-    <entry group="0018" element="1149" keyword="FieldOfViewDimensions" vr="IS" vm="1-2" name="Field of View Dimension(s)"/>
-    <entry group="0018" element="1150" keyword="ExposureTime" vr="IS" vm="1" name="Exposure Time"/>
-    <entry group="0018" element="1151" keyword="XRayTubeCurrent" vr="IS" vm="1" name="X-Ray Tube Current"/>
-    <entry group="0018" element="1152" keyword="Exposure" vr="IS" vm="1" name="Exposure"/>
-    <entry group="0018" element="1153" keyword="ExposureInuAs" vr="IS" vm="1" name="Exposure in µAs"/>
-    <entry group="0018" element="1154" keyword="AveragePulseWidth" vr="DS" vm="1" name="Average Pulse Width"/>
-    <entry group="0018" element="1155" keyword="RadiationSetting" vr="CS" vm="1" name="Radiation Setting"/>
-    <entry group="0018" element="1156" keyword="RectificationType" vr="CS" vm="1" name="Rectification Type"/>
-    <entry group="0018" element="115a" keyword="RadiationMode" vr="CS" vm="1" name="Radiation Mode"/>
-    <entry group="0018" element="115e" keyword="ImageAndFluoroscopyAreaDoseProduct" vr="DS" vm="1" name="Image and Fluoroscopy Area Dose Product"/>
-    <entry group="0018" element="1160" keyword="FilterType" vr="SH" vm="1" name="Filter Type"/>
-    <entry group="0018" element="1161" keyword="TypeOfFilters" vr="LO" vm="1-n" name="Type of Filters"/>
-    <entry group="0018" element="1162" keyword="IntensifierSize" vr="DS" vm="1" name="Intensifier Size"/>
-    <entry group="0018" element="1164" keyword="ImagerPixelSpacing" vr="DS" vm="2" name="Imager Pixel Spacing"/>
-    <entry group="0018" element="1166" keyword="Grid" vr="CS" vm="1-n" name="Grid"/>
-    <entry group="0018" element="1170" keyword="GeneratorPower" vr="IS" vm="1" name="Generator Power"/>
-    <entry group="0018" element="1180" keyword="CollimatorGridName" vr="SH" vm="1" name="Collimator/grid Name"/>
-    <entry group="0018" element="1181" keyword="CollimatorType" vr="CS" vm="1" name="Collimator Type"/>
-    <entry group="0018" element="1182" keyword="FocalDistance" vr="IS" vm="1-2" name="Focal Distance"/>
-    <entry group="0018" element="1183" keyword="XFocusCenter" vr="DS" vm="1-2" name="X Focus Center"/>
-    <entry group="0018" element="1184" keyword="YFocusCenter" vr="DS" vm="1-2" name="Y Focus Center"/>
-    <entry group="0018" element="1190" keyword="FocalSpots" vr="DS" vm="1-n" name="Focal Spot(s)"/>
-    <entry group="0018" element="1191" keyword="AnodeTargetMaterial" vr="CS" vm="1" name="Anode Target Material"/>
-    <entry group="0018" element="11a0" keyword="BodyPartThickness" vr="DS" vm="1" name="Body Part Thickness"/>
-    <entry group="0018" element="11a2" keyword="CompressionForce" vr="DS" vm="1" name="Compression Force"/>
-    <entry group="0018" element="1200" keyword="DateOfLastCalibration" vr="DA" vm="1-n" name="Date of Last Calibration"/>
-    <entry group="0018" element="1201" keyword="TimeOfLastCalibration" vr="TM" vm="1-n" name="Time of Last Calibration"/>
-    <entry group="0018" element="1210" keyword="ConvolutionKernel" vr="SH" vm="1-n" name="Convolution Kernel"/>
-    <entry group="0018" element="1240" keyword="UpperLowerPixelValues" vr="IS" vm="1-n" retired="true" name="Upper/Lower Pixel Values"/>
-    <entry group="0018" element="1242" keyword="ActualFrameDuration" vr="IS" vm="1" name="Actual Frame Duration"/>
-    <entry group="0018" element="1243" keyword="CountRate" vr="IS" vm="1" name="Count Rate"/>
-    <entry group="0018" element="1244" keyword="PreferredPlaybackSequencing" vr="US" vm="1" name="Preferred Playback Sequencing"/>
-    <entry group="0018" element="1250" keyword="ReceiveCoilName" vr="SH" vm="1" name="Receive Coil Name"/>
-    <entry group="0018" element="1251" keyword="TransmitCoilName" vr="SH" vm="1" name="Transmit Coil Name"/>
-    <entry group="0018" element="1260" keyword="PlateType" vr="SH" vm="1" name="Plate Type"/>
-    <entry group="0018" element="1261" keyword="PhosphorType" vr="LO" vm="1" name="Phosphor Type"/>
-    <entry group="0018" element="1300" keyword="ScanVelocity" vr="DS" vm="1" name="Scan Velocity"/>
-    <entry group="0018" element="1301" keyword="WholeBodyTechnique" vr="CS" vm="1-n" name="Whole Body Technique"/>
-    <entry group="0018" element="1302" keyword="ScanLength" vr="IS" vm="1" name="Scan Length"/>
-    <entry group="0018" element="1310" keyword="AcquisitionMatrix" vr="US" vm="4" name="Acquisition Matrix"/>
-    <entry group="0018" element="1312" keyword="InPlanePhaseEncodingDirection" vr="CS" vm="1" name="In-plane Phase Encoding Direction"/>
-    <entry group="0018" element="1314" keyword="FlipAngle" vr="DS" vm="1" name="Flip Angle"/>
-    <entry group="0018" element="1315" keyword="VariableFlipAngleFlag" vr="CS" vm="1" name="Variable Flip Angle Flag"/>
-    <entry group="0018" element="1316" keyword="SAR" vr="DS" vm="1" name="SAR"/>
-    <entry group="0018" element="1318" keyword="dBdt" vr="DS" vm="1" name="dB/dt"/>
-    <entry group="0018" element="1400" keyword="AcquisitionDeviceProcessingDescription" vr="LO" vm="1" name="Acquisition Device Processing Description"/>
-    <entry group="0018" element="1401" keyword="AcquisitionDeviceProcessingCode" vr="LO" vm="1" name="Acquisition Device Processing Code"/>
-    <entry group="0018" element="1402" keyword="CassetteOrientation" vr="CS" vm="1" name="Cassette Orientation"/>
-    <entry group="0018" element="1403" keyword="CassetteSize" vr="CS" vm="1" name="Cassette Size"/>
-    <entry group="0018" element="1404" keyword="ExposuresOnPlate" vr="US" vm="1" name="Exposures on Plate"/>
-    <entry group="0018" element="1405" keyword="RelativeXRayExposure" vr="IS" vm="1" name="Relative X-Ray Exposure"/>
-    <entry group="0018" element="1411" keyword="ExposureIndex" vr="DS" vm="1" name="Exposure Index"/>
-    <entry group="0018" element="1412" keyword="TargetExposureIndex" vr="DS" vm="1" name="Target Exposure Index"/>
-    <entry group="0018" element="1413" keyword="DeviationIndex" vr="DS" vm="1" name="Deviation Index"/>
-    <entry group="0018" element="1450" keyword="ColumnAngulation" vr="DS" vm="1" name="Column Angulation"/>
-    <entry group="0018" element="1460" keyword="TomoLayerHeight" vr="DS" vm="1" name="Tomo Layer Height"/>
-    <entry group="0018" element="1470" keyword="TomoAngle" vr="DS" vm="1" name="Tomo Angle"/>
-    <entry group="0018" element="1480" keyword="TomoTime" vr="DS" vm="1" name="Tomo Time"/>
-    <entry group="0018" element="1490" keyword="TomoType" vr="CS" vm="1" name="Tomo Type"/>
-    <entry group="0018" element="1491" keyword="TomoClass" vr="CS" vm="1" name="Tomo Class"/>
-    <entry group="0018" element="1495" keyword="NumberOfTomosynthesisSourceImages" vr="IS" vm="1" name="Number of Tomosynthesis Source Images"/>
-    <entry group="0018" element="1500" keyword="PositionerMotion" vr="CS" vm="1" name="Positioner Motion"/>
-    <entry group="0018" element="1508" keyword="PositionerType" vr="CS" vm="1" name="Positioner Type"/>
-    <entry group="0018" element="1510" keyword="PositionerPrimaryAngle" vr="DS" vm="1" name="Positioner Primary Angle"/>
-    <entry group="0018" element="1511" keyword="PositionerSecondaryAngle" vr="DS" vm="1" name="Positioner Secondary Angle"/>
-    <entry group="0018" element="1520" keyword="PositionerPrimaryAngleIncrement" vr="DS" vm="1-n" name="Positioner Primary Angle Increment"/>
-    <entry group="0018" element="1521" keyword="PositionerSecondaryAngleIncrement" vr="DS" vm="1-n" name="Positioner Secondary Angle Increment"/>
-    <entry group="0018" element="1530" keyword="DetectorPrimaryAngle" vr="DS" vm="1" name="Detector Primary Angle"/>
-    <entry group="0018" element="1531" keyword="DetectorSecondaryAngle" vr="DS" vm="1" name="Detector Secondary Angle"/>
-    <entry group="0018" element="1600" keyword="ShutterShape" vr="CS" vm="1-3" name="Shutter Shape"/>
-    <entry group="0018" element="1602" keyword="ShutterLeftVerticalEdge" vr="IS" vm="1" name="Shutter Left Vertical Edge"/>
-    <entry group="0018" element="1604" keyword="ShutterRightVerticalEdge" vr="IS" vm="1" name="Shutter Right Vertical Edge"/>
-    <entry group="0018" element="1606" keyword="ShutterUpperHorizontalEdge" vr="IS" vm="1" name="Shutter Upper Horizontal Edge"/>
-    <entry group="0018" element="1608" keyword="ShutterLowerHorizontalEdge" vr="IS" vm="1" name="Shutter Lower Horizontal Edge"/>
-    <entry group="0018" element="1610" keyword="CenterOfCircularShutter" vr="IS" vm="2" name="Center of Circular Shutter"/>
-    <entry group="0018" element="1612" keyword="RadiusOfCircularShutter" vr="IS" vm="1" name="Radius of Circular Shutter"/>
-    <entry group="0018" element="1620" keyword="VerticesOfThePolygonalShutter" vr="IS" vm="2-2n" name="Vertices of the Polygonal Shutter"/>
-    <entry group="0018" element="1622" keyword="ShutterPresentationValue" vr="US" vm="1" name="Shutter Presentation Value"/>
-    <entry group="0018" element="1623" keyword="ShutterOverlayGroup" vr="US" vm="1" name="Shutter Overlay Group"/>
-    <entry group="0018" element="1624" keyword="ShutterPresentationColorCIELabValue" vr="US" vm="3" name="Shutter Presentation Color CIELab Value"/>
-    <entry group="0018" element="1700" keyword="CollimatorShape" vr="CS" vm="1-3" name="Collimator Shape"/>
-    <entry group="0018" element="1702" keyword="CollimatorLeftVerticalEdge" vr="IS" vm="1" name="Collimator Left Vertical Edge"/>
-    <entry group="0018" element="1704" keyword="CollimatorRightVerticalEdge" vr="IS" vm="1" name="Collimator Right Vertical Edge"/>
-    <entry group="0018" element="1706" keyword="CollimatorUpperHorizontalEdge" vr="IS" vm="1" name="Collimator Upper Horizontal Edge"/>
-    <entry group="0018" element="1708" keyword="CollimatorLowerHorizontalEdge" vr="IS" vm="1" name="Collimator Lower Horizontal Edge"/>
-    <entry group="0018" element="1710" keyword="CenterOfCircularCollimator" vr="IS" vm="2" name="Center of Circular Collimator"/>
-    <entry group="0018" element="1712" keyword="RadiusOfCircularCollimator" vr="IS" vm="1" name="Radius of Circular Collimator"/>
-    <entry group="0018" element="1720" keyword="VerticesOfThePolygonalCollimator" vr="IS" vm="2-2n" name="Vertices of the Polygonal Collimator"/>
-    <entry group="0018" element="1800" keyword="AcquisitionTimeSynchronized" vr="CS" vm="1" name="Acquisition Time Synchronized"/>
-    <entry group="0018" element="1801" keyword="TimeSource" vr="SH" vm="1" name="Time Source"/>
-    <entry group="0018" element="1802" keyword="TimeDistributionProtocol" vr="CS" vm="1" name="Time Distribution Protocol"/>
-    <entry group="0018" element="1803" keyword="NTPSourceAddress" vr="LO" vm="1" name="NTP Source Address"/>
-    <entry group="0018" element="2001" keyword="PageNumberVector" vr="IS" vm="1-n" name="Page Number Vector"/>
-    <entry group="0018" element="2002" keyword="FrameLabelVector" vr="SH" vm="1-n" name="Frame Label Vector"/>
-    <entry group="0018" element="2003" keyword="FramePrimaryAngleVector" vr="DS" vm="1-n" name="Frame Primary Angle Vector"/>
-    <entry group="0018" element="2004" keyword="FrameSecondaryAngleVector" vr="DS" vm="1-n" name="Frame Secondary Angle Vector"/>
-    <entry group="0018" element="2005" keyword="SliceLocationVector" vr="DS" vm="1-n" name="Slice Location Vector"/>
-    <entry group="0018" element="2006" keyword="DisplayWindowLabelVector" vr="SH" vm="1-n" name="Display Window Label Vector"/>
-    <entry group="0018" element="2010" keyword="NominalScannedPixelSpacing" vr="DS" vm="2" name="Nominal Scanned Pixel Spacing"/>
-    <entry group="0018" element="2020" keyword="DigitizingDeviceTransportDirection" vr="CS" vm="1" name="Digitizing Device Transport Direction"/>
-    <entry group="0018" element="2030" keyword="RotationOfScannedFilm" vr="DS" vm="1" name="Rotation of Scanned Film"/>
-    <entry group="0018" element="3100" keyword="IVUSAcquisition" vr="CS" vm="1" name="IVUS Acquisition"/>
-    <entry group="0018" element="3101" keyword="IVUSPullbackRate" vr="DS" vm="1" name="IVUS Pullback Rate"/>
-    <entry group="0018" element="3102" keyword="IVUSGatedRate" vr="DS" vm="1" name="IVUS Gated Rate"/>
-    <entry group="0018" element="3103" keyword="IVUSPullbackStartFrameNumber" vr="IS" vm="1" name="IVUS Pullback Start Frame Number"/>
-    <entry group="0018" element="3104" keyword="IVUSPullbackStopFrameNumber" vr="IS" vm="1" name="IVUS Pullback Stop Frame Number"/>
-    <entry group="0018" element="3105" keyword="LesionNumber" vr="IS" vm="1-n" name="Lesion Number"/>
-    <entry group="0018" element="4000" keyword="AcquisitionComments" vr="LT" vm="1" retired="true" name="Acquisition Comments"/>
-    <entry group="0018" element="5000" keyword="OutputPower" vr="SH" vm="1-n" name="Output Power"/>
-    <entry group="0018" element="5010" keyword="TransducerData" vr="LO" vm="1-n" name="Transducer Data"/>
-    <entry group="0018" element="5012" keyword="FocusDepth" vr="DS" vm="1" name="Focus Depth"/>
-    <entry group="0018" element="5020" keyword="ProcessingFunction" vr="LO" vm="1" name="Processing Function"/>
-    <entry group="0018" element="5021" keyword="PostprocessingFunction" vr="LO" vm="1" retired="true" name="Postprocessing Function"/>
-    <entry group="0018" element="5022" keyword="MechanicalIndex" vr="DS" vm="1" name="Mechanical Index"/>
-    <entry group="0018" element="5024" keyword="BoneThermalIndex" vr="DS" vm="1" name="Bone Thermal Index"/>
-    <entry group="0018" element="5026" keyword="CranialThermalIndex" vr="DS" vm="1" name="Cranial Thermal Index"/>
-    <entry group="0018" element="5027" keyword="SoftTissueThermalIndex" vr="DS" vm="1" name="Soft Tissue Thermal Index"/>
-    <entry group="0018" element="5028" keyword="SoftTissueFocusThermalIndex" vr="DS" vm="1" name="Soft Tissue-focus Thermal Index"/>
-    <entry group="0018" element="5029" keyword="SoftTissueSurfaceThermalIndex" vr="DS" vm="1" name="Soft Tissue-surface Thermal Index"/>
-    <entry group="0018" element="5030" keyword="DynamicRange" vr="DS" vm="1" retired="true" name="Dynamic Range"/>
-    <entry group="0018" element="5040" keyword="TotalGain" vr="DS" vm="1" retired="true" name="Total Gain"/>
-    <entry group="0018" element="5050" keyword="DepthOfScanField" vr="IS" vm="1" name="Depth of Scan Field"/>
-    <entry group="0018" element="5100" keyword="PatientPosition" vr="CS" vm="1" name="Patient Position"/>
-    <entry group="0018" element="5101" keyword="ViewPosition" vr="CS" vm="1" name="View Position"/>
-    <entry group="0018" element="5104" keyword="ProjectionEponymousNameCodeSequence" vr="SQ" vm="1" name="Projection Eponymous Name Code Sequence"/>
-    <entry group="0018" element="5210" keyword="ImageTransformationMatrix" vr="DS" vm="6" retired="true" name="Image Transformation Matrix"/>
-    <entry group="0018" element="5212" keyword="ImageTranslationVector" vr="DS" vm="3" retired="true" name="Image Translation Vector"/>
-    <entry group="0018" element="6000" keyword="Sensitivity" vr="DS" vm="1" name="Sensitivity"/>
-    <entry group="0018" element="6011" keyword="SequenceOfUltrasoundRegions" vr="SQ" vm="1" name="Sequence of Ultrasound Regions"/>
-    <entry group="0018" element="6012" keyword="RegionSpatialFormat" vr="US" vm="1" name="Region Spatial Format"/>
-    <entry group="0018" element="6014" keyword="RegionDataType" vr="US" vm="1" name="Region Data Type"/>
-    <entry group="0018" element="6016" keyword="RegionFlags" vr="UL" vm="1" name="Region Flags"/>
-    <entry group="0018" element="6018" keyword="RegionLocationMinX0" vr="UL" vm="1" name="Region Location Min X0"/>
-    <entry group="0018" element="601a" keyword="RegionLocationMinY0" vr="UL" vm="1" name="Region Location Min Y0"/>
-    <entry group="0018" element="601c" keyword="RegionLocationMaxX1" vr="UL" vm="1" name="Region Location Max X1"/>
-    <entry group="0018" element="601e" keyword="RegionLocationMaxY1" vr="UL" vm="1" name="Region Location Max Y1"/>
-    <entry group="0018" element="6020" keyword="ReferencePixelX0" vr="SL" vm="1" name="Reference Pixel X0"/>
-    <entry group="0018" element="6022" keyword="ReferencePixelY0" vr="SL" vm="1" name="Reference Pixel Y0"/>
-    <entry group="0018" element="6024" keyword="PhysicalUnitsXDirection" vr="US" vm="1" name="Physical Units X Direction"/>
-    <entry group="0018" element="6026" keyword="PhysicalUnitsYDirection" vr="US" vm="1" name="Physical Units Y Direction"/>
-    <entry group="0018" element="6028" keyword="ReferencePixelPhysicalValueX" vr="FD" vm="1" name="Reference Pixel Physical Value X"/>
-    <entry group="0018" element="602a" keyword="ReferencePixelPhysicalValueY" vr="FD" vm="1" name="Reference Pixel Physical Value Y"/>
-    <entry group="0018" element="602c" keyword="PhysicalDeltaX" vr="FD" vm="1" name="Physical Delta X"/>
-    <entry group="0018" element="602e" keyword="PhysicalDeltaY" vr="FD" vm="1" name="Physical Delta Y"/>
-    <entry group="0018" element="6030" keyword="TransducerFrequency" vr="UL" vm="1" name="Transducer Frequency"/>
-    <entry group="0018" element="6031" keyword="TransducerType" vr="CS" vm="1" name="Transducer Type"/>
-    <entry group="0018" element="6032" keyword="PulseRepetitionFrequency" vr="UL" vm="1" name="Pulse Repetition Frequency"/>
-    <entry group="0018" element="6034" keyword="DopplerCorrectionAngle" vr="FD" vm="1" name="Doppler Correction Angle"/>
-    <entry group="0018" element="6036" keyword="SteeringAngle" vr="FD" vm="1" name="Steering Angle"/>
-    <entry group="0018" element="6038" keyword="DopplerSampleVolumeXPositionRetired" vr="UL" vm="1" retired="true" name="Doppler Sample Volume X Position (Retired)"/>
-    <entry group="0018" element="6039" keyword="DopplerSampleVolumeXPosition" vr="SL" vm="1" name="Doppler Sample Volume X Position"/>
-    <entry group="0018" element="603a" keyword="DopplerSampleVolumeYPositionRetired" vr="UL" vm="1" retired="true" name="Doppler Sample Volume Y Position (Retired)"/>
-    <entry group="0018" element="603b" keyword="DopplerSampleVolumeYPosition" vr="SL" vm="1" name="Doppler Sample Volume Y Position"/>
-    <entry group="0018" element="603c" keyword="TMLinePositionX0Retired" vr="UL" vm="1" retired="true" name="TM-Line Position X0 (Retired)"/>
-    <entry group="0018" element="603d" keyword="TMLinePositionX0" vr="SL" vm="1" name="TM-Line Position X0"/>
-    <entry group="0018" element="603e" keyword="TMLinePositionY0Retired" vr="UL" vm="1" retired="true" name="TM-Line Position Y0 (Retired)"/>
-    <entry group="0018" element="603f" keyword="TMLinePositionY0" vr="SL" vm="1" name="TM-Line Position Y0"/>
-    <entry group="0018" element="6040" keyword="TMLinePositionX1Retired" vr="UL" vm="1" retired="true" name="TM-Line Position X1 (Retired)"/>
-    <entry group="0018" element="6041" keyword="TMLinePositionX1" vr="SL" vm="1" name="TM-Line Position X1"/>
-    <entry group="0018" element="6042" keyword="TMLinePositionY1Retired" vr="UL" vm="1" retired="true" name="TM-Line Position Y1 (Retired)"/>
-    <entry group="0018" element="6043" keyword="TMLinePositionY1" vr="SL" vm="1" name="TM-Line Position Y1"/>
-    <entry group="0018" element="6044" keyword="PixelComponentOrganization" vr="US" vm="1" name="Pixel Component Organization"/>
-    <entry group="0018" element="6046" keyword="PixelComponentMask" vr="UL" vm="1" name="Pixel Component Mask"/>
-    <entry group="0018" element="6048" keyword="PixelComponentRangeStart" vr="UL" vm="1" name="Pixel Component Range Start"/>
-    <entry group="0018" element="604a" keyword="PixelComponentRangeStop" vr="UL" vm="1" name="Pixel Component Range Stop"/>
-    <entry group="0018" element="604c" keyword="PixelComponentPhysicalUnits" vr="US" vm="1" name="Pixel Component Physical Units"/>
-    <entry group="0018" element="604e" keyword="PixelComponentDataType" vr="US" vm="1" name="Pixel Component Data Type"/>
-    <entry group="0018" element="6050" keyword="NumberOfTableBreakPoints" vr="UL" vm="1" name="Number of Table Break Points"/>
-    <entry group="0018" element="6052" keyword="TableOfXBreakPoints" vr="UL" vm="1-n" name="Table of X Break Points"/>
-    <entry group="0018" element="6054" keyword="TableOfYBreakPoints" vr="FD" vm="1-n" name="Table of Y Break Points"/>
-    <entry group="0018" element="6056" keyword="NumberOfTableEntries" vr="UL" vm="1" name="Number of Table Entries"/>
-    <entry group="0018" element="6058" keyword="TableOfPixelValues" vr="UL" vm="1-n" name="Table of Pixel Values"/>
-    <entry group="0018" element="605a" keyword="TableOfParameterValues" vr="FL" vm="1-n" name="Table of Parameter Values"/>
-    <entry group="0018" element="6060" keyword="RWaveTimeVector" vr="FL" vm="1-n" name="R Wave Time Vector"/>
-    <entry group="0018" element="7000" keyword="DetectorConditionsNominalFlag" vr="CS" vm="1" name="Detector Conditions Nominal Flag"/>
-    <entry group="0018" element="7001" keyword="DetectorTemperature" vr="DS" vm="1" name="Detector Temperature"/>
-    <entry group="0018" element="7004" keyword="DetectorType" vr="CS" vm="1" name="Detector Type"/>
-    <entry group="0018" element="7005" keyword="DetectorConfiguration" vr="CS" vm="1" name="Detector Configuration"/>
-    <entry group="0018" element="7006" keyword="DetectorDescription" vr="LT" vm="1" name="Detector Description"/>
-    <entry group="0018" element="7008" keyword="DetectorMode" vr="LT" vm="1" name="Detector Mode"/>
-    <entry group="0018" element="700a" keyword="DetectorID" vr="SH" vm="1" name="Detector ID"/>
-    <entry group="0018" element="700c" keyword="DateOfLastDetectorCalibration" vr="DA" vm="1" name="Date of Last Detector Calibration"/>
-    <entry group="0018" element="700e" keyword="TimeOfLastDetectorCalibration" vr="TM" vm="1" name="Time of Last Detector Calibration"/>
-    <entry group="0018" element="7010" keyword="ExposuresOnDetectorSinceLastCalibration" vr="IS" vm="1" name="Exposures on Detector Since Last Calibration"/>
-    <entry group="0018" element="7011" keyword="ExposuresOnDetectorSinceManufactured" vr="IS" vm="1" name="Exposures on Detector Since Manufactured"/>
-    <entry group="0018" element="7012" keyword="DetectorTimeSinceLastExposure" vr="DS" vm="1" name="Detector Time Since Last Exposure"/>
-    <entry group="0018" element="7014" keyword="DetectorActiveTime" vr="DS" vm="1" name="Detector Active Time"/>
-    <entry group="0018" element="7016" keyword="DetectorActivationOffsetFromExposure" vr="DS" vm="1" name="Detector Activation Offset From Exposure"/>
-    <entry group="0018" element="701a" keyword="DetectorBinning" vr="DS" vm="2" name="Detector Binning"/>
-    <entry group="0018" element="7020" keyword="DetectorElementPhysicalSize" vr="DS" vm="2" name="Detector Element Physical Size"/>
-    <entry group="0018" element="7022" keyword="DetectorElementSpacing" vr="DS" vm="2" name="Detector Element Spacing"/>
-    <entry group="0018" element="7024" keyword="DetectorActiveShape" vr="CS" vm="1" name="Detector Active Shape"/>
-    <entry group="0018" element="7026" keyword="DetectorActiveDimensions" vr="DS" vm="1-2" name="Detector Active Dimension(s)"/>
-    <entry group="0018" element="7028" keyword="DetectorActiveOrigin" vr="DS" vm="2" name="Detector Active Origin"/>
-    <entry group="0018" element="702a" keyword="DetectorManufacturerName" vr="LO" vm="1" name="Detector Manufacturer Name"/>
-    <entry group="0018" element="702b" keyword="DetectorManufacturerModelName" vr="LO" vm="1" name="Detector Manufacturer's Model Name"/>
-    <entry group="0018" element="7030" keyword="FieldOfViewOrigin" vr="DS" vm="2" name="Field of View Origin"/>
-    <entry group="0018" element="7032" keyword="FieldOfViewRotation" vr="DS" vm="1" name="Field of View Rotation"/>
-    <entry group="0018" element="7034" keyword="FieldOfViewHorizontalFlip" vr="CS" vm="1" name="Field of View Horizontal Flip"/>
-    <entry group="0018" element="7036" keyword="PixelDataAreaOriginRelativeToFOV" vr="FL" vm="2" name="Pixel Data Area Origin Relative To FOV"/>
-    <entry group="0018" element="7038" keyword="PixelDataAreaRotationAngleRelativeToFOV" vr="FL" vm="1" name="Pixel Data Area Rotation Angle Relative To FOV"/>
-    <entry group="0018" element="7040" keyword="GridAbsorbingMaterial" vr="LT" vm="1" name="Grid Absorbing Material"/>
-    <entry group="0018" element="7041" keyword="GridSpacingMaterial" vr="LT" vm="1" name="Grid Spacing Material"/>
-    <entry group="0018" element="7042" keyword="GridThickness" vr="DS" vm="1" name="Grid Thickness"/>
-    <entry group="0018" element="7044" keyword="GridPitch" vr="DS" vm="1" name="Grid Pitch"/>
-    <entry group="0018" element="7046" keyword="GridAspectRatio" vr="IS" vm="2" name="Grid Aspect Ratio"/>
-    <entry group="0018" element="7048" keyword="GridPeriod" vr="DS" vm="1" name="Grid Period"/>
-    <entry group="0018" element="704c" keyword="GridFocalDistance" vr="DS" vm="1" name="Grid Focal Distance"/>
-    <entry group="0018" element="7050" keyword="FilterMaterial" vr="CS" vm="1-n" name="Filter Material"/>
-    <entry group="0018" element="7052" keyword="FilterThicknessMinimum" vr="DS" vm="1-n" name="Filter Thickness Minimum"/>
-    <entry group="0018" element="7054" keyword="FilterThicknessMaximum" vr="DS" vm="1-n" name="Filter Thickness Maximum"/>
-    <entry group="0018" element="7056" keyword="FilterBeamPathLengthMinimum" vr="FL" vm="1-n" name="Filter Beam Path Length Minimum"/>
-    <entry group="0018" element="7058" keyword="FilterBeamPathLengthMaximum" vr="FL" vm="1-n" name="Filter Beam Path Length Maximum"/>
-    <entry group="0018" element="7060" keyword="ExposureControlMode" vr="CS" vm="1" name="Exposure Control Mode"/>
-    <entry group="0018" element="7062" keyword="ExposureControlModeDescription" vr="LT" vm="1" name="Exposure Control Mode Description"/>
-    <entry group="0018" element="7064" keyword="ExposureStatus" vr="CS" vm="1" name="Exposure Status"/>
-    <entry group="0018" element="7065" keyword="PhototimerSetting" vr="DS" vm="1" name="Phototimer Setting"/>
-    <entry group="0018" element="8150" keyword="ExposureTimeInuS" vr="DS" vm="1" name="Exposure Time in µS"/>
-    <entry group="0018" element="8151" keyword="XRayTubeCurrentInuA" vr="DS" vm="1" name="X-Ray Tube Current in µA"/>
-    <entry group="0018" element="9004" keyword="ContentQualification" vr="CS" vm="1" name="Content Qualification"/>
-    <entry group="0018" element="9005" keyword="PulseSequenceName" vr="SH" vm="1" name="Pulse Sequence Name"/>
-    <entry group="0018" element="9006" keyword="MRImagingModifierSequence" vr="SQ" vm="1" name="MR Imaging Modifier Sequence"/>
-    <entry group="0018" element="9008" keyword="EchoPulseSequence" vr="CS" vm="1" name="Echo Pulse Sequence"/>
-    <entry group="0018" element="9009" keyword="InversionRecovery" vr="CS" vm="1" name="Inversion Recovery"/>
-    <entry group="0018" element="9010" keyword="FlowCompensation" vr="CS" vm="1" name="Flow Compensation"/>
-    <entry group="0018" element="9011" keyword="MultipleSpinEcho" vr="CS" vm="1" name="Multiple Spin Echo"/>
-    <entry group="0018" element="9012" keyword="MultiPlanarExcitation" vr="CS" vm="1" name="Multi-planar Excitation"/>
-    <entry group="0018" element="9014" keyword="PhaseContrast" vr="CS" vm="1" name="Phase Contrast"/>
-    <entry group="0018" element="9015" keyword="TimeOfFlightContrast" vr="CS" vm="1" name="Time of Flight Contrast"/>
-    <entry group="0018" element="9016" keyword="Spoiling" vr="CS" vm="1" name="Spoiling"/>
-    <entry group="0018" element="9017" keyword="SteadyStatePulseSequence" vr="CS" vm="1" name="Steady State Pulse Sequence"/>
-    <entry group="0018" element="9018" keyword="EchoPlanarPulseSequence" vr="CS" vm="1" name="Echo Planar Pulse Sequence"/>
-    <entry group="0018" element="9019" keyword="TagAngleFirstAxis" vr="FD" vm="1" name="Tag Angle First Axis"/>
-    <entry group="0018" element="9020" keyword="MagnetizationTransfer" vr="CS" vm="1" name="Magnetization Transfer"/>
-    <entry group="0018" element="9021" keyword="T2Preparation" vr="CS" vm="1" name="T2 Preparation"/>
-    <entry group="0018" element="9022" keyword="BloodSignalNulling" vr="CS" vm="1" name="Blood Signal Nulling"/>
-    <entry group="0018" element="9024" keyword="SaturationRecovery" vr="CS" vm="1" name="Saturation Recovery"/>
-    <entry group="0018" element="9025" keyword="SpectrallySelectedSuppression" vr="CS" vm="1" name="Spectrally Selected Suppression"/>
-    <entry group="0018" element="9026" keyword="SpectrallySelectedExcitation" vr="CS" vm="1" name="Spectrally Selected Excitation"/>
-    <entry group="0018" element="9027" keyword="SpatialPresaturation" vr="CS" vm="1" name="Spatial Pre-saturation"/>
-    <entry group="0018" element="9028" keyword="Tagging" vr="CS" vm="1" name="Tagging"/>
-    <entry group="0018" element="9029" keyword="OversamplingPhase" vr="CS" vm="1" name="Oversampling Phase"/>
-    <entry group="0018" element="9030" keyword="TagSpacingFirstDimension" vr="FD" vm="1" name="Tag Spacing First Dimension"/>
-    <entry group="0018" element="9032" keyword="GeometryOfKSpaceTraversal" vr="CS" vm="1" name="Geometry of k-Space Traversal"/>
-    <entry group="0018" element="9033" keyword="SegmentedKSpaceTraversal" vr="CS" vm="1" name="Segmented k-Space Traversal"/>
-    <entry group="0018" element="9034" keyword="RectilinearPhaseEncodeReordering" vr="CS" vm="1" name="Rectilinear Phase Encode Reordering"/>
-    <entry group="0018" element="9035" keyword="TagThickness" vr="FD" vm="1" name="Tag Thickness"/>
-    <entry group="0018" element="9036" keyword="PartialFourierDirection" vr="CS" vm="1" name="Partial Fourier Direction"/>
-    <entry group="0018" element="9037" keyword="CardiacSynchronizationTechnique" vr="CS" vm="1" name="Cardiac Synchronization Technique"/>
-    <entry group="0018" element="9041" keyword="ReceiveCoilManufacturerName" vr="LO" vm="1" name="Receive Coil Manufacturer Name"/>
-    <entry group="0018" element="9042" keyword="MRReceiveCoilSequence" vr="SQ" vm="1" name="MR Receive Coil Sequence"/>
-    <entry group="0018" element="9043" keyword="ReceiveCoilType" vr="CS" vm="1" name="Receive Coil Type"/>
-    <entry group="0018" element="9044" keyword="QuadratureReceiveCoil" vr="CS" vm="1" name="Quadrature Receive Coil"/>
-    <entry group="0018" element="9045" keyword="MultiCoilDefinitionSequence" vr="SQ" vm="1" name="Multi-Coil Definition Sequence"/>
-    <entry group="0018" element="9046" keyword="MultiCoilConfiguration" vr="LO" vm="1" name="Multi-Coil Configuration"/>
-    <entry group="0018" element="9047" keyword="MultiCoilElementName" vr="SH" vm="1" name="Multi-Coil Element Name"/>
-    <entry group="0018" element="9048" keyword="MultiCoilElementUsed" vr="CS" vm="1" name="Multi-Coil Element Used"/>
-    <entry group="0018" element="9049" keyword="MRTransmitCoilSequence" vr="SQ" vm="1" name="MR Transmit Coil Sequence"/>
-    <entry group="0018" element="9050" keyword="TransmitCoilManufacturerName" vr="LO" vm="1" name="Transmit Coil Manufacturer Name"/>
-    <entry group="0018" element="9051" keyword="TransmitCoilType" vr="CS" vm="1" name="Transmit Coil Type"/>
-    <entry group="0018" element="9052" keyword="SpectralWidth" vr="FD" vm="1-2" name="Spectral Width"/>
-    <entry group="0018" element="9053" keyword="ChemicalShiftReference" vr="FD" vm="1-2" name="Chemical Shift Reference"/>
-    <entry group="0018" element="9054" keyword="VolumeLocalizationTechnique" vr="CS" vm="1" name="Volume Localization Technique"/>
-    <entry group="0018" element="9058" keyword="MRAcquisitionFrequencyEncodingSteps" vr="US" vm="1" name="MR Acquisition Frequency Encoding Steps"/>
-    <entry group="0018" element="9059" keyword="Decoupling" vr="CS" vm="1" name="De-coupling"/>
-    <entry group="0018" element="9060" keyword="DecoupledNucleus" vr="CS" vm="1-2" name="De-coupled Nucleus"/>
-    <entry group="0018" element="9061" keyword="DecouplingFrequency" vr="FD" vm="1-2" name="De-coupling Frequency"/>
-    <entry group="0018" element="9062" keyword="DecouplingMethod" vr="CS" vm="1" name="De-coupling Method"/>
-    <entry group="0018" element="9063" keyword="DecouplingChemicalShiftReference" vr="FD" vm="1-2" name="De-coupling Chemical Shift Reference"/>
-    <entry group="0018" element="9064" keyword="KSpaceFiltering" vr="CS" vm="1" name="k-space Filtering"/>
-    <entry group="0018" element="9065" keyword="TimeDomainFiltering" vr="CS" vm="1-2" name="Time Domain Filtering"/>
-    <entry group="0018" element="9066" keyword="NumberOfZeroFills" vr="US" vm="1-2" name="Number of Zero Fills"/>
-    <entry group="0018" element="9067" keyword="BaselineCorrection" vr="CS" vm="1" name="Baseline Correction"/>
-    <entry group="0018" element="9069" keyword="ParallelReductionFactorInPlane" vr="FD" vm="1" name="Parallel Reduction Factor In-plane"/>
-    <entry group="0018" element="9070" keyword="CardiacRRIntervalSpecified" vr="FD" vm="1" name="Cardiac R-R Interval Specified"/>
-    <entry group="0018" element="9073" keyword="AcquisitionDuration" vr="FD" vm="1" name="Acquisition Duration"/>
-    <entry group="0018" element="9074" keyword="FrameAcquisitionDateTime" vr="DT" vm="1" name="Frame Acquisition DateTime"/>
-    <entry group="0018" element="9075" keyword="DiffusionDirectionality" vr="CS" vm="1" name="Diffusion Directionality"/>
-    <entry group="0018" element="9076" keyword="DiffusionGradientDirectionSequence" vr="SQ" vm="1" name="Diffusion Gradient Direction Sequence"/>
-    <entry group="0018" element="9077" keyword="ParallelAcquisition" vr="CS" vm="1" name="Parallel Acquisition"/>
-    <entry group="0018" element="9078" keyword="ParallelAcquisitionTechnique" vr="CS" vm="1" name="Parallel Acquisition Technique"/>
-    <entry group="0018" element="9079" keyword="InversionTimes" vr="FD" vm="1-n" name="Inversion Times"/>
-    <entry group="0018" element="9080" keyword="MetaboliteMapDescription" vr="ST" vm="1" name="Metabolite Map Description"/>
-    <entry group="0018" element="9081" keyword="PartialFourier" vr="CS" vm="1" name="Partial Fourier"/>
-    <entry group="0018" element="9082" keyword="EffectiveEchoTime" vr="FD" vm="1" name="Effective Echo Time"/>
-    <entry group="0018" element="9083" keyword="MetaboliteMapCodeSequence" vr="SQ" vm="1" name="Metabolite Map Code Sequence"/>
-    <entry group="0018" element="9084" keyword="ChemicalShiftSequence" vr="SQ" vm="1" name="Chemical Shift Sequence"/>
-    <entry group="0018" element="9085" keyword="CardiacSignalSource" vr="CS" vm="1" name="Cardiac Signal Source"/>
-    <entry group="0018" element="9087" keyword="DiffusionBValue" vr="FD" vm="1" name="Diffusion b-value"/>
-    <entry group="0018" element="9089" keyword="DiffusionGradientOrientation" vr="FD" vm="3" name="Diffusion Gradient Orientation"/>
-    <entry group="0018" element="9090" keyword="VelocityEncodingDirection" vr="FD" vm="3" name="Velocity Encoding Direction"/>
-    <entry group="0018" element="9091" keyword="VelocityEncodingMinimumValue" vr="FD" vm="1" name="Velocity Encoding Minimum Value"/>
-    <entry group="0018" element="9092" keyword="VelocityEncodingAcquisitionSequence" vr="SQ" vm="1" name="Velocity Encoding Acquisition Sequence"/>
-    <entry group="0018" element="9093" keyword="NumberOfKSpaceTrajectories" vr="US" vm="1" name="Number of k-Space Trajectories"/>
-    <entry group="0018" element="9094" keyword="CoverageOfKSpace" vr="CS" vm="1" name="Coverage of k-Space"/>
-    <entry group="0018" element="9095" keyword="SpectroscopyAcquisitionPhaseRows" vr="UL" vm="1" name="Spectroscopy Acquisition Phase Rows"/>
-    <entry group="0018" element="9096" keyword="ParallelReductionFactorInPlaneRetired" vr="FD" vm="1" retired="true" name="Parallel Reduction Factor In-plane (Retired)"/>
-    <entry group="0018" element="9098" keyword="TransmitterFrequency" vr="FD" vm="1-2" name="Transmitter Frequency"/>
-    <entry group="0018" element="9100" keyword="ResonantNucleus" vr="CS" vm="1-2" name="Resonant Nucleus"/>
-    <entry group="0018" element="9101" keyword="FrequencyCorrection" vr="CS" vm="1" name="Frequency Correction"/>
-    <entry group="0018" element="9103" keyword="MRSpectroscopyFOVGeometrySequence" vr="SQ" vm="1" name="MR Spectroscopy FOV/Geometry Sequence"/>
-    <entry group="0018" element="9104" keyword="SlabThickness" vr="FD" vm="1" name="Slab Thickness"/>
-    <entry group="0018" element="9105" keyword="SlabOrientation" vr="FD" vm="3" name="Slab Orientation"/>
-    <entry group="0018" element="9106" keyword="MidSlabPosition" vr="FD" vm="3" name="Mid Slab Position"/>
-    <entry group="0018" element="9107" keyword="MRSpatialSaturationSequence" vr="SQ" vm="1" name="MR Spatial Saturation Sequence"/>
-    <entry group="0018" element="9112" keyword="MRTimingAndRelatedParametersSequence" vr="SQ" vm="1" name="MR Timing and Related Parameters Sequence"/>
-    <entry group="0018" element="9114" keyword="MREchoSequence" vr="SQ" vm="1" name="MR Echo Sequence"/>
-    <entry group="0018" element="9115" keyword="MRModifierSequence" vr="SQ" vm="1" name="MR Modifier Sequence"/>
-    <entry group="0018" element="9117" keyword="MRDiffusionSequence" vr="SQ" vm="1" name="MR Diffusion Sequence"/>
-    <entry group="0018" element="9118" keyword="CardiacSynchronizationSequence" vr="SQ" vm="1" name="Cardiac Synchronization Sequence"/>
-    <entry group="0018" element="9119" keyword="MRAveragesSequence" vr="SQ" vm="1" name="MR Averages Sequence"/>
-    <entry group="0018" element="9125" keyword="MRFOVGeometrySequence" vr="SQ" vm="1" name="MR FOV/Geometry Sequence"/>
-    <entry group="0018" element="9126" keyword="VolumeLocalizationSequence" vr="SQ" vm="1" name="Volume Localization Sequence"/>
-    <entry group="0018" element="9127" keyword="SpectroscopyAcquisitionDataColumns" vr="UL" vm="1" name="Spectroscopy Acquisition Data Columns"/>
-    <entry group="0018" element="9147" keyword="DiffusionAnisotropyType" vr="CS" vm="1" name="Diffusion Anisotropy Type"/>
-    <entry group="0018" element="9151" keyword="FrameReferenceDateTime" vr="DT" vm="1" name="Frame Reference DateTime"/>
-    <entry group="0018" element="9152" keyword="MRMetaboliteMapSequence" vr="SQ" vm="1" name="MR Metabolite Map Sequence"/>
-    <entry group="0018" element="9155" keyword="ParallelReductionFactorOutOfPlane" vr="FD" vm="1" name="Parallel Reduction Factor out-of-plane"/>
-    <entry group="0018" element="9159" keyword="SpectroscopyAcquisitionOutOfPlanePhaseSteps" vr="UL" vm="1" name="Spectroscopy Acquisition Out-of-plane Phase Steps"/>
-    <entry group="0018" element="9166" keyword="BulkMotionStatus" vr="CS" vm="1" retired="true" name="Bulk Motion Status"/>
-    <entry group="0018" element="9168" keyword="ParallelReductionFactorSecondInPlane" vr="FD" vm="1" name="Parallel Reduction Factor Second In-plane"/>
-    <entry group="0018" element="9169" keyword="CardiacBeatRejectionTechnique" vr="CS" vm="1" name="Cardiac Beat Rejection Technique"/>
-    <entry group="0018" element="9170" keyword="RespiratoryMotionCompensationTechnique" vr="CS" vm="1" name="Respiratory Motion Compensation Technique"/>
-    <entry group="0018" element="9171" keyword="RespiratorySignalSource" vr="CS" vm="1" name="Respiratory Signal Source"/>
-    <entry group="0018" element="9172" keyword="BulkMotionCompensationTechnique" vr="CS" vm="1" name="Bulk Motion Compensation Technique"/>
-    <entry group="0018" element="9173" keyword="BulkMotionSignalSource" vr="CS" vm="1" name="Bulk Motion Signal Source"/>
-    <entry group="0018" element="9174" keyword="ApplicableSafetyStandardAgency" vr="CS" vm="1" name="Applicable Safety Standard Agency"/>
-    <entry group="0018" element="9175" keyword="ApplicableSafetyStandardDescription" vr="LO" vm="1" name="Applicable Safety Standard Description"/>
-    <entry group="0018" element="9176" keyword="OperatingModeSequence" vr="SQ" vm="1" name="Operating Mode Sequence"/>
-    <entry group="0018" element="9177" keyword="OperatingModeType" vr="CS" vm="1" name="Operating Mode Type"/>
-    <entry group="0018" element="9178" keyword="OperatingMode" vr="CS" vm="1" name="Operating Mode"/>
-    <entry group="0018" element="9179" keyword="SpecificAbsorptionRateDefinition" vr="CS" vm="1" name="Specific Absorption Rate Definition"/>
-    <entry group="0018" element="9180" keyword="GradientOutputType" vr="CS" vm="1" name="Gradient Output Type"/>
-    <entry group="0018" element="9181" keyword="SpecificAbsorptionRateValue" vr="FD" vm="1" name="Specific Absorption Rate Value"/>
-    <entry group="0018" element="9182" keyword="GradientOutput" vr="FD" vm="1" name="Gradient Output"/>
-    <entry group="0018" element="9183" keyword="FlowCompensationDirection" vr="CS" vm="1" name="Flow Compensation Direction"/>
-    <entry group="0018" element="9184" keyword="TaggingDelay" vr="FD" vm="1" name="Tagging Delay"/>
-    <entry group="0018" element="9185" keyword="RespiratoryMotionCompensationTechniqueDescription" vr="ST" vm="1" name="Respiratory Motion Compensation Technique Description"/>
-    <entry group="0018" element="9186" keyword="RespiratorySignalSourceID" vr="SH" vm="1" name="Respiratory Signal Source ID"/>
-    <entry group="0018" element="9195" keyword="ChemicalShiftMinimumIntegrationLimitInHz" vr="FD" vm="1" retired="true" name="Chemical Shift Minimum Integration Limit in Hz"/>
-    <entry group="0018" element="9196" keyword="ChemicalShiftMaximumIntegrationLimitInHz" vr="FD" vm="1" retired="true" name="Chemical Shift Maximum Integration Limit in Hz"/>
-    <entry group="0018" element="9197" keyword="MRVelocityEncodingSequence" vr="SQ" vm="1" name="MR Velocity Encoding Sequence"/>
-    <entry group="0018" element="9198" keyword="FirstOrderPhaseCorrection" vr="CS" vm="1" name="First Order Phase Correction"/>
-    <entry group="0018" element="9199" keyword="WaterReferencedPhaseCorrection" vr="CS" vm="1" name="Water Referenced Phase Correction"/>
-    <entry group="0018" element="9200" keyword="MRSpectroscopyAcquisitionType" vr="CS" vm="1" name="MR Spectroscopy Acquisition Type"/>
-    <entry group="0018" element="9214" keyword="RespiratoryCyclePosition" vr="CS" vm="1" name="Respiratory Cycle Position"/>
-    <entry group="0018" element="9217" keyword="VelocityEncodingMaximumValue" vr="FD" vm="1" name="Velocity Encoding Maximum Value"/>
-    <entry group="0018" element="9218" keyword="TagSpacingSecondDimension" vr="FD" vm="1" name="Tag Spacing Second Dimension"/>
-    <entry group="0018" element="9219" keyword="TagAngleSecondAxis" vr="SS" vm="1" name="Tag Angle Second Axis"/>
-    <entry group="0018" element="9220" keyword="FrameAcquisitionDuration" vr="FD" vm="1" name="Frame Acquisition Duration"/>
-    <entry group="0018" element="9226" keyword="MRImageFrameTypeSequence" vr="SQ" vm="1" name="MR Image Frame Type Sequence"/>
-    <entry group="0018" element="9227" keyword="MRSpectroscopyFrameTypeSequence" vr="SQ" vm="1" name="MR Spectroscopy Frame Type Sequence"/>
-    <entry group="0018" element="9231" keyword="MRAcquisitionPhaseEncodingStepsInPlane" vr="US" vm="1" name="MR Acquisition Phase Encoding Steps in-plane"/>
-    <entry group="0018" element="9232" keyword="MRAcquisitionPhaseEncodingStepsOutOfPlane" vr="US" vm="1" name="MR Acquisition Phase Encoding Steps out-of-plane"/>
-    <entry group="0018" element="9234" keyword="SpectroscopyAcquisitionPhaseColumns" vr="UL" vm="1" name="Spectroscopy Acquisition Phase Columns"/>
-    <entry group="0018" element="9236" keyword="CardiacCyclePosition" vr="CS" vm="1" name="Cardiac Cycle Position"/>
-    <entry group="0018" element="9239" keyword="SpecificAbsorptionRateSequence" vr="SQ" vm="1" name="Specific Absorption Rate Sequence"/>
-    <entry group="0018" element="9240" keyword="RFEchoTrainLength" vr="US" vm="1" name="RF Echo Train Length"/>
-    <entry group="0018" element="9241" keyword="GradientEchoTrainLength" vr="US" vm="1" name="Gradient Echo Train Length"/>
-    <entry group="0018" element="9250" keyword="ArterialSpinLabelingContrast" vr="CS" vm="1" name="Arterial Spin Labeling Contrast"/>
-    <entry group="0018" element="9251" keyword="MRArterialSpinLabelingSequence" vr="SQ" vm="1" name="MR Arterial Spin Labeling Sequence"/>
-    <entry group="0018" element="9252" keyword="ASLTechniqueDescription" vr="LO" vm="1" name="ASL Technique Description"/>
-    <entry group="0018" element="9253" keyword="ASLSlabNumber" vr="US" vm="1" name="ASL Slab Number"/>
-    <entry group="0018" element="9254" keyword="ASLSlabThickness" vr="FD" vm="1" name="ASL Slab Thickness"/>
-    <entry group="0018" element="9255" keyword="ASLSlabOrientation" vr="FD" vm="3" name="ASL Slab Orientation"/>
-    <entry group="0018" element="9256" keyword="ASLMidSlabPosition" vr="FD" vm="3" name="ASL Mid Slab Position"/>
-    <entry group="0018" element="9257" keyword="ASLContext" vr="CS" vm="1" name="ASL Context"/>
-    <entry group="0018" element="9258" keyword="ASLPulseTrainDuration" vr="UL" vm="1" name="ASL Pulse Train Duration"/>
-    <entry group="0018" element="9259" keyword="ASLCrusherFlag" vr="CS" vm="1" name="ASL Crusher Flag"/>
-    <entry group="0018" element="925a" keyword="ASLCrusherFlow" vr="FD" vm="1" name="ASL Crusher Flow"/>
-    <entry group="0018" element="925b" keyword="ASLCrusherDescription" vr="LO" vm="1" name="ASL Crusher Description"/>
-    <entry group="0018" element="925c" keyword="ASLBolusCutoffFlag" vr="CS" vm="1" name="ASL Bolus Cut-off Flag"/>
-    <entry group="0018" element="925d" keyword="ASLBolusCutoffTimingSequence" vr="SQ" vm="1" name="ASL Bolus Cut-off Timing Sequence"/>
-    <entry group="0018" element="925e" keyword="ASLBolusCutoffTechnique" vr="LO" vm="1" name="ASL Bolus Cut-off Technique"/>
-    <entry group="0018" element="925f" keyword="ASLBolusCutoffDelayTime" vr="UL" vm="1" name="ASL Bolus Cut-off Delay Time"/>
-    <entry group="0018" element="9260" keyword="ASLSlabSequence" vr="SQ" vm="1" name="ASL Slab Sequence"/>
-    <entry group="0018" element="9295" keyword="ChemicalShiftMinimumIntegrationLimitInppm" vr="FD" vm="1" name="Chemical Shift Minimum Integration Limit in ppm"/>
-    <entry group="0018" element="9296" keyword="ChemicalShiftMaximumIntegrationLimitInppm" vr="FD" vm="1" name="Chemical Shift Maximum Integration Limit in ppm"/>
-    <entry group="0018" element="9301" keyword="CTAcquisitionTypeSequence" vr="SQ" vm="1" name="CT Acquisition Type Sequence"/>
-    <entry group="0018" element="9302" keyword="AcquisitionType" vr="CS" vm="1" name="Acquisition Type"/>
-    <entry group="0018" element="9303" keyword="TubeAngle" vr="FD" vm="1" name="Tube Angle"/>
-    <entry group="0018" element="9304" keyword="CTAcquisitionDetailsSequence" vr="SQ" vm="1" name="CT Acquisition Details Sequence"/>
-    <entry group="0018" element="9305" keyword="RevolutionTime" vr="FD" vm="1" name="Revolution Time"/>
-    <entry group="0018" element="9306" keyword="SingleCollimationWidth" vr="FD" vm="1" name="Single Collimation Width"/>
-    <entry group="0018" element="9307" keyword="TotalCollimationWidth" vr="FD" vm="1" name="Total Collimation Width"/>
-    <entry group="0018" element="9308" keyword="CTTableDynamicsSequence" vr="SQ" vm="1" name="CT Table Dynamics Sequence"/>
-    <entry group="0018" element="9309" keyword="TableSpeed" vr="FD" vm="1" name="Table Speed"/>
-    <entry group="0018" element="9310" keyword="TableFeedPerRotation" vr="FD" vm="1" name="Table Feed per Rotation"/>
-    <entry group="0018" element="9311" keyword="SpiralPitchFactor" vr="FD" vm="1" name="Spiral Pitch Factor"/>
-    <entry group="0018" element="9312" keyword="CTGeometrySequence" vr="SQ" vm="1" name="CT Geometry Sequence"/>
-    <entry group="0018" element="9313" keyword="DataCollectionCenterPatient" vr="FD" vm="3" name="Data Collection Center (Patient)"/>
-    <entry group="0018" element="9314" keyword="CTReconstructionSequence" vr="SQ" vm="1" name="CT Reconstruction Sequence"/>
-    <entry group="0018" element="9315" keyword="ReconstructionAlgorithm" vr="CS" vm="1" name="Reconstruction Algorithm"/>
-    <entry group="0018" element="9316" keyword="ConvolutionKernelGroup" vr="CS" vm="1" name="Convolution Kernel Group"/>
-    <entry group="0018" element="9317" keyword="ReconstructionFieldOfView" vr="FD" vm="2" name="Reconstruction Field of View"/>
-    <entry group="0018" element="9318" keyword="ReconstructionTargetCenterPatient" vr="FD" vm="3" name="Reconstruction Target Center (Patient)"/>
-    <entry group="0018" element="9319" keyword="ReconstructionAngle" vr="FD" vm="1" name="Reconstruction Angle"/>
-    <entry group="0018" element="9320" keyword="ImageFilter" vr="SH" vm="1" name="Image Filter"/>
-    <entry group="0018" element="9321" keyword="CTExposureSequence" vr="SQ" vm="1" name="CT Exposure Sequence"/>
-    <entry group="0018" element="9322" keyword="ReconstructionPixelSpacing" vr="FD" vm="2" name="Reconstruction Pixel Spacing"/>
-    <entry group="0018" element="9323" keyword="ExposureModulationType" vr="CS" vm="1" name="Exposure Modulation Type"/>
-    <entry group="0018" element="9324" keyword="EstimatedDoseSaving" vr="FD" vm="1" name="Estimated Dose Saving"/>
-    <entry group="0018" element="9325" keyword="CTXRayDetailsSequence" vr="SQ" vm="1" name="CT X-Ray Details Sequence"/>
-    <entry group="0018" element="9326" keyword="CTPositionSequence" vr="SQ" vm="1" name="CT Position Sequence"/>
-    <entry group="0018" element="9327" keyword="TablePosition" vr="FD" vm="1" name="Table Position"/>
-    <entry group="0018" element="9328" keyword="ExposureTimeInms" vr="FD" vm="1" name="Exposure Time in ms"/>
-    <entry group="0018" element="9329" keyword="CTImageFrameTypeSequence" vr="SQ" vm="1" name="CT Image Frame Type Sequence"/>
-    <entry group="0018" element="9330" keyword="XRayTubeCurrentInmA" vr="FD" vm="1" name="X-Ray Tube Current in mA"/>
-    <entry group="0018" element="9332" keyword="ExposureInmAs" vr="FD" vm="1" name="Exposure in mAs"/>
-    <entry group="0018" element="9333" keyword="ConstantVolumeFlag" vr="CS" vm="1" name="Constant Volume Flag"/>
-    <entry group="0018" element="9334" keyword="FluoroscopyFlag" vr="CS" vm="1" name="Fluoroscopy Flag"/>
-    <entry group="0018" element="9335" keyword="DistanceSourceToDataCollectionCenter" vr="FD" vm="1" name="Distance Source to Data Collection Center"/>
-    <entry group="0018" element="9337" keyword="ContrastBolusAgentNumber" vr="US" vm="1" name="Contrast/Bolus Agent Number"/>
-    <entry group="0018" element="9338" keyword="ContrastBolusIngredientCodeSequence" vr="SQ" vm="1" name="Contrast/Bolus Ingredient Code Sequence"/>
-    <entry group="0018" element="9340" keyword="ContrastAdministrationProfileSequence" vr="SQ" vm="1" name="Contrast Administration Profile Sequence"/>
-    <entry group="0018" element="9341" keyword="ContrastBolusUsageSequence" vr="SQ" vm="1" name="Contrast/Bolus Usage Sequence"/>
-    <entry group="0018" element="9342" keyword="ContrastBolusAgentAdministered" vr="CS" vm="1" name="Contrast/Bolus Agent Administered"/>
-    <entry group="0018" element="9343" keyword="ContrastBolusAgentDetected" vr="CS" vm="1" name="Contrast/Bolus Agent Detected"/>
-    <entry group="0018" element="9344" keyword="ContrastBolusAgentPhase" vr="CS" vm="1" name="Contrast/Bolus Agent Phase"/>
-    <entry group="0018" element="9345" keyword="CTDIvol" vr="FD" vm="1" name="CTDIvol"/>
-    <entry group="0018" element="9346" keyword="CTDIPhantomTypeCodeSequence" vr="SQ" vm="1" name="CTDI Phantom Type Code Sequence"/>
-    <entry group="0018" element="9351" keyword="CalciumScoringMassFactorPatient" vr="FL" vm="1" name="Calcium Scoring Mass Factor Patient"/>
-    <entry group="0018" element="9352" keyword="CalciumScoringMassFactorDevice" vr="FL" vm="3" name="Calcium Scoring Mass Factor Device"/>
-    <entry group="0018" element="9353" keyword="EnergyWeightingFactor" vr="FL" vm="1" name="Energy Weighting Factor"/>
-    <entry group="0018" element="9360" keyword="CTAdditionalXRaySourceSequence" vr="SQ" vm="1" name="CT Additional X-Ray Source Sequence"/>
-    <entry group="0018" element="9401" keyword="ProjectionPixelCalibrationSequence" vr="SQ" vm="1" name="Projection Pixel Calibration Sequence"/>
-    <entry group="0018" element="9402" keyword="DistanceSourceToIsocenter" vr="FL" vm="1" name="Distance Source to Isocenter"/>
-    <entry group="0018" element="9403" keyword="DistanceObjectToTableTop" vr="FL" vm="1" name="Distance Object to Table Top"/>
-    <entry group="0018" element="9404" keyword="ObjectPixelSpacingInCenterOfBeam" vr="FL" vm="2" name="Object Pixel Spacing in Center of Beam"/>
-    <entry group="0018" element="9405" keyword="PositionerPositionSequence" vr="SQ" vm="1" name="Positioner Position Sequence"/>
-    <entry group="0018" element="9406" keyword="TablePositionSequence" vr="SQ" vm="1" name="Table Position Sequence"/>
-    <entry group="0018" element="9407" keyword="CollimatorShapeSequence" vr="SQ" vm="1" name="Collimator Shape Sequence"/>
-    <entry group="0018" element="9410" keyword="PlanesInAcquisition" vr="CS" vm="1" name="Planes in Acquisition"/>
-    <entry group="0018" element="9412" keyword="XAXRFFrameCharacteristicsSequence" vr="SQ" vm="1" name="XA/XRF Frame Characteristics Sequence"/>
-    <entry group="0018" element="9417" keyword="FrameAcquisitionSequence" vr="SQ" vm="1" name="Frame Acquisition Sequence"/>
-    <entry group="0018" element="9420" keyword="XRayReceptorType" vr="CS" vm="1" name="X-Ray Receptor Type"/>
-    <entry group="0018" element="9423" keyword="AcquisitionProtocolName" vr="LO" vm="1" name="Acquisition Protocol Name"/>
-    <entry group="0018" element="9424" keyword="AcquisitionProtocolDescription" vr="LT" vm="1" name="Acquisition Protocol Description"/>
-    <entry group="0018" element="9425" keyword="ContrastBolusIngredientOpaque" vr="CS" vm="1" name="Contrast/Bolus Ingredient Opaque"/>
-    <entry group="0018" element="9426" keyword="DistanceReceptorPlaneToDetectorHousing" vr="FL" vm="1" name="Distance Receptor Plane to Detector Housing"/>
-    <entry group="0018" element="9427" keyword="IntensifierActiveShape" vr="CS" vm="1" name="Intensifier Active Shape"/>
-    <entry group="0018" element="9428" keyword="IntensifierActiveDimensions" vr="FL" vm="1-2" name="Intensifier Active Dimension(s)"/>
-    <entry group="0018" element="9429" keyword="PhysicalDetectorSize" vr="FL" vm="2" name="Physical Detector Size"/>
-    <entry group="0018" element="9430" keyword="PositionOfIsocenterProjection" vr="FL" vm="2" name="Position of Isocenter Projection"/>
-    <entry group="0018" element="9432" keyword="FieldOfViewSequence" vr="SQ" vm="1" name="Field of View Sequence"/>
-    <entry group="0018" element="9433" keyword="FieldOfViewDescription" vr="LO" vm="1" name="Field of View Description"/>
-    <entry group="0018" element="9434" keyword="ExposureControlSensingRegionsSequence" vr="SQ" vm="1" name="Exposure Control Sensing Regions Sequence"/>
-    <entry group="0018" element="9435" keyword="ExposureControlSensingRegionShape" vr="CS" vm="1" name="Exposure Control Sensing Region Shape"/>
-    <entry group="0018" element="9436" keyword="ExposureControlSensingRegionLeftVerticalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Left Vertical Edge"/>
-    <entry group="0018" element="9437" keyword="ExposureControlSensingRegionRightVerticalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Right Vertical Edge"/>
-    <entry group="0018" element="9438" keyword="ExposureControlSensingRegionUpperHorizontalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Upper Horizontal Edge"/>
-    <entry group="0018" element="9439" keyword="ExposureControlSensingRegionLowerHorizontalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Lower Horizontal Edge"/>
-    <entry group="0018" element="9440" keyword="CenterOfCircularExposureControlSensingRegion" vr="SS" vm="2" name="Center of Circular Exposure Control Sensing Region"/>
-    <entry group="0018" element="9441" keyword="RadiusOfCircularExposureControlSensingRegion" vr="US" vm="1" name="Radius of Circular Exposure Control Sensing Region"/>
-    <entry group="0018" element="9442" keyword="VerticesOfThePolygonalExposureControlSensingRegion" vr="SS" vm="2-n" name="Vertices of the Polygonal Exposure Control Sensing Region"/>
-    <entry group="0018" element="9445" keyword="" retired="true">
-      <description>SHALL NOT BE USED</description>
-    </entry>
-    <entry group="0018" element="9447" keyword="ColumnAngulationPatient" vr="FL" vm="1" name="Column Angulation (Patient)"/>
-    <entry group="0018" element="9449" keyword="BeamAngle" vr="FL" vm="1" name="Beam Angle"/>
-    <entry group="0018" element="9451" keyword="FrameDetectorParametersSequence" vr="SQ" vm="1" name="Frame Detector Parameters Sequence"/>
-    <entry group="0018" element="9452" keyword="CalculatedAnatomyThickness" vr="FL" vm="1" name="Calculated Anatomy Thickness"/>
-    <entry group="0018" element="9455" keyword="CalibrationSequence" vr="SQ" vm="1" name="Calibration Sequence"/>
-    <entry group="0018" element="9456" keyword="ObjectThicknessSequence" vr="SQ" vm="1" name="Object Thickness Sequence"/>
-    <entry group="0018" element="9457" keyword="PlaneIdentification" vr="CS" vm="1" name="Plane Identification"/>
-    <entry group="0018" element="9461" keyword="FieldOfViewDimensionsInFloat" vr="FL" vm="1-2" name="Field of View Dimension(s) in Float"/>
-    <entry group="0018" element="9462" keyword="IsocenterReferenceSystemSequence" vr="SQ" vm="1" name="Isocenter Reference System Sequence"/>
-    <entry group="0018" element="9463" keyword="PositionerIsocenterPrimaryAngle" vr="FL" vm="1" name="Positioner Isocenter Primary Angle"/>
-    <entry group="0018" element="9464" keyword="PositionerIsocenterSecondaryAngle" vr="FL" vm="1" name="Positioner Isocenter Secondary Angle"/>
-    <entry group="0018" element="9465" keyword="PositionerIsocenterDetectorRotationAngle" vr="FL" vm="1" name="Positioner Isocenter Detector Rotation Angle"/>
-    <entry group="0018" element="9466" keyword="TableXPositionToIsocenter" vr="FL" vm="1" name="Table X Position to Isocenter"/>
-    <entry group="0018" element="9467" keyword="TableYPositionToIsocenter" vr="FL" vm="1" name="Table Y Position to Isocenter"/>
-    <entry group="0018" element="9468" keyword="TableZPositionToIsocenter" vr="FL" vm="1" name="Table Z Position to Isocenter"/>
-    <entry group="0018" element="9469" keyword="TableHorizontalRotationAngle" vr="FL" vm="1" name="Table Horizontal Rotation Angle"/>
-    <entry group="0018" element="9470" keyword="TableHeadTiltAngle" vr="FL" vm="1" name="Table Head Tilt Angle"/>
-    <entry group="0018" element="9471" keyword="TableCradleTiltAngle" vr="FL" vm="1" name="Table Cradle Tilt Angle"/>
-    <entry group="0018" element="9472" keyword="FrameDisplayShutterSequence" vr="SQ" vm="1" name="Frame Display Shutter Sequence"/>
-    <entry group="0018" element="9473" keyword="AcquiredImageAreaDoseProduct" vr="FL" vm="1" name="Acquired Image Area Dose Product"/>
-    <entry group="0018" element="9474" keyword="CArmPositionerTabletopRelationship" vr="CS" vm="1" name="C-arm Positioner Tabletop Relationship"/>
-    <entry group="0018" element="9476" keyword="XRayGeometrySequence" vr="SQ" vm="1" name="X-Ray Geometry Sequence"/>
-    <entry group="0018" element="9477" keyword="IrradiationEventIdentificationSequence" vr="SQ" vm="1" name="Irradiation Event Identification Sequence"/>
-    <entry group="0018" element="9504" keyword="XRay3DFrameTypeSequence" vr="SQ" vm="1" name="X-Ray 3D Frame Type Sequence"/>
-    <entry group="0018" element="9506" keyword="ContributingSourcesSequence" vr="SQ" vm="1" name="Contributing Sources Sequence"/>
-    <entry group="0018" element="9507" keyword="XRay3DAcquisitionSequence" vr="SQ" vm="1" name="X-Ray 3D Acquisition Sequence"/>
-    <entry group="0018" element="9508" keyword="PrimaryPositionerScanArc" vr="FL" vm="1" name="Primary Positioner Scan Arc"/>
-    <entry group="0018" element="9509" keyword="SecondaryPositionerScanArc" vr="FL" vm="1" name="Secondary Positioner Scan Arc"/>
-    <entry group="0018" element="9510" keyword="PrimaryPositionerScanStartAngle" vr="FL" vm="1" name="Primary Positioner Scan Start Angle"/>
-    <entry group="0018" element="9511" keyword="SecondaryPositionerScanStartAngle" vr="FL" vm="1" name="Secondary Positioner Scan Start Angle"/>
-    <entry group="0018" element="9514" keyword="PrimaryPositionerIncrement" vr="FL" vm="1" name="Primary Positioner Increment"/>
-    <entry group="0018" element="9515" keyword="SecondaryPositionerIncrement" vr="FL" vm="1" name="Secondary Positioner Increment"/>
-    <entry group="0018" element="9516" keyword="StartAcquisitionDateTime" vr="DT" vm="1" name="Start Acquisition DateTime"/>
-    <entry group="0018" element="9517" keyword="EndAcquisitionDateTime" vr="DT" vm="1" name="End Acquisition DateTime"/>
-    <entry group="0018" element="9524" keyword="ApplicationName" vr="LO" vm="1" name="Application Name"/>
-    <entry group="0018" element="9525" keyword="ApplicationVersion" vr="LO" vm="1" name="Application Version"/>
-    <entry group="0018" element="9526" keyword="ApplicationManufacturer" vr="LO" vm="1" name="Application Manufacturer"/>
-    <entry group="0018" element="9527" keyword="AlgorithmType" vr="CS" vm="1" name="Algorithm Type"/>
-    <entry group="0018" element="9528" keyword="AlgorithmDescription" vr="LO" vm="1" name="Algorithm Description"/>
-    <entry group="0018" element="9530" keyword="XRay3DReconstructionSequence" vr="SQ" vm="1" name="X-Ray 3D Reconstruction Sequence"/>
-    <entry group="0018" element="9531" keyword="ReconstructionDescription" vr="LO" vm="1" name="Reconstruction Description"/>
-    <entry group="0018" element="9538" keyword="PerProjectionAcquisitionSequence" vr="SQ" vm="1" name="Per Projection Acquisition Sequence"/>
-    <entry group="0018" element="9601" keyword="DiffusionBMatrixSequence" vr="SQ" vm="1" name="Diffusion b-matrix Sequence"/>
-    <entry group="0018" element="9602" keyword="DiffusionBValueXX" vr="FD" vm="1" name="Diffusion b-value XX"/>
-    <entry group="0018" element="9603" keyword="DiffusionBValueXY" vr="FD" vm="1" name="Diffusion b-value XY"/>
-    <entry group="0018" element="9604" keyword="DiffusionBValueXZ" vr="FD" vm="1" name="Diffusion b-value XZ"/>
-    <entry group="0018" element="9605" keyword="DiffusionBValueYY" vr="FD" vm="1" name="Diffusion b-value YY"/>
-    <entry group="0018" element="9606" keyword="DiffusionBValueYZ" vr="FD" vm="1" name="Diffusion b-value YZ"/>
-    <entry group="0018" element="9607" keyword="DiffusionBValueZZ" vr="FD" vm="1" name="Diffusion b-value ZZ"/>
-    <entry group="0018" element="9701" keyword="DecayCorrectionDateTime" vr="DT" vm="1" name="Decay Correction DateTime"/>
-    <entry group="0018" element="9715" keyword="StartDensityThreshold" vr="FD" vm="1" name="Start Density Threshold"/>
-    <entry group="0018" element="9716" keyword="StartRelativeDensityDifferenceThreshold" vr="FD" vm="1" name="Start Relative Density Difference Threshold"/>
-    <entry group="0018" element="9717" keyword="StartCardiacTriggerCountThreshold" vr="FD" vm="1" name="Start Cardiac Trigger Count Threshold"/>
-    <entry group="0018" element="9718" keyword="StartRespiratoryTriggerCountThreshold" vr="FD" vm="1" name="Start Respiratory Trigger Count Threshold"/>
-    <entry group="0018" element="9719" keyword="TerminationCountsThreshold" vr="FD" vm="1" name="Termination Counts Threshold"/>
-    <entry group="0018" element="9720" keyword="TerminationDensityThreshold" vr="FD" vm="1" name="Termination Density Threshold"/>
-    <entry group="0018" element="9721" keyword="TerminationRelativeDensityThreshold" vr="FD" vm="1" name="Termination Relative Density Threshold"/>
-    <entry group="0018" element="9722" keyword="TerminationTimeThreshold" vr="FD" vm="1" name="Termination Time Threshold"/>
-    <entry group="0018" element="9723" keyword="TerminationCardiacTriggerCountThreshold" vr="FD" vm="1" name="Termination Cardiac Trigger Count Threshold"/>
-    <entry group="0018" element="9724" keyword="TerminationRespiratoryTriggerCountThreshold" vr="FD" vm="1" name="Termination Respiratory Trigger Count Threshold"/>
-    <entry group="0018" element="9725" keyword="DetectorGeometry" vr="CS" vm="1" name="Detector Geometry"/>
-    <entry group="0018" element="9726" keyword="TransverseDetectorSeparation" vr="FD" vm="1" name="Transverse Detector Separation"/>
-    <entry group="0018" element="9727" keyword="AxialDetectorDimension" vr="FD" vm="1" name="Axial Detector Dimension"/>
-    <entry group="0018" element="9729" keyword="RadiopharmaceuticalAgentNumber" vr="US" vm="1" name="Radiopharmaceutical Agent Number"/>
-    <entry group="0018" element="9732" keyword="PETFrameAcquisitionSequence" vr="SQ" vm="1" name="PET Frame Acquisition Sequence"/>
-    <entry group="0018" element="9733" keyword="PETDetectorMotionDetailsSequence" vr="SQ" vm="1" name="PET Detector Motion Details Sequence"/>
-    <entry group="0018" element="9734" keyword="PETTableDynamicsSequence" vr="SQ" vm="1" name="PET Table Dynamics Sequence"/>
-    <entry group="0018" element="9735" keyword="PETPositionSequence" vr="SQ" vm="1" name="PET Position Sequence"/>
-    <entry group="0018" element="9736" keyword="PETFrameCorrectionFactorsSequence" vr="SQ" vm="1" name="PET Frame Correction Factors Sequence"/>
-    <entry group="0018" element="9737" keyword="RadiopharmaceuticalUsageSequence" vr="SQ" vm="1" name="Radiopharmaceutical Usage Sequence"/>
-    <entry group="0018" element="9738" keyword="AttenuationCorrectionSource" vr="CS" vm="1" name="Attenuation Correction Source"/>
-    <entry group="0018" element="9739" keyword="NumberOfIterations" vr="US" vm="1" name="Number of Iterations"/>
-    <entry group="0018" element="9740" keyword="NumberOfSubsets" vr="US" vm="1" name="Number of Subsets"/>
-    <entry group="0018" element="9749" keyword="PETReconstructionSequence" vr="SQ" vm="1" name="PET Reconstruction Sequence"/>
-    <entry group="0018" element="9751" keyword="PETFrameTypeSequence" vr="SQ" vm="1" name="PET Frame Type Sequence"/>
-    <entry group="0018" element="9755" keyword="TimeOfFlightInformationUsed" vr="CS" vm="1" name="Time of Flight Information Used"/>
-    <entry group="0018" element="9756" keyword="ReconstructionType" vr="CS" vm="1" name="Reconstruction Type"/>
-    <entry group="0018" element="9758" keyword="DecayCorrected" vr="CS" vm="1" name="Decay Corrected"/>
-    <entry group="0018" element="9759" keyword="AttenuationCorrected" vr="CS" vm="1" name="Attenuation Corrected"/>
-    <entry group="0018" element="9760" keyword="ScatterCorrected" vr="CS" vm="1" name="Scatter Corrected"/>
-    <entry group="0018" element="9761" keyword="DeadTimeCorrected" vr="CS" vm="1" name="Dead Time Corrected"/>
-    <entry group="0018" element="9762" keyword="GantryMotionCorrected" vr="CS" vm="1" name="Gantry Motion Corrected"/>
-    <entry group="0018" element="9763" keyword="PatientMotionCorrected" vr="CS" vm="1" name="Patient Motion Corrected"/>
-    <entry group="0018" element="9764" keyword="CountLossNormalizationCorrected" vr="CS" vm="1" name="Count Loss Normalization Corrected"/>
-    <entry group="0018" element="9765" keyword="RandomsCorrected" vr="CS" vm="1" name="Randoms Corrected"/>
-    <entry group="0018" element="9766" keyword="NonUniformRadialSamplingCorrected" vr="CS" vm="1" name="Non-uniform Radial Sampling Corrected"/>
-    <entry group="0018" element="9767" keyword="SensitivityCalibrated" vr="CS" vm="1" name="Sensitivity Calibrated"/>
-    <entry group="0018" element="9768" keyword="DetectorNormalizationCorrection" vr="CS" vm="1" name="Detector Normalization Correction"/>
-    <entry group="0018" element="9769" keyword="IterativeReconstructionMethod" vr="CS" vm="1" name="Iterative Reconstruction Method"/>
-    <entry group="0018" element="9770" keyword="AttenuationCorrectionTemporalRelationship" vr="CS" vm="1" name="Attenuation Correction Temporal Relationship"/>
-    <entry group="0018" element="9771" keyword="PatientPhysiologicalStateSequence" vr="SQ" vm="1" name="Patient Physiological State Sequence"/>
-    <entry group="0018" element="9772" keyword="PatientPhysiologicalStateCodeSequence" vr="SQ" vm="1" name="Patient Physiological State Code Sequence"/>
-    <entry group="0018" element="9801" keyword="DepthsOfFocus" vr="FD" vm="1-n" name="Depth(s) of Focus"/>
-    <entry group="0018" element="9803" keyword="ExcludedIntervalsSequence" vr="SQ" vm="1" name="Excluded Intervals Sequence"/>
-    <entry group="0018" element="9804" keyword="ExclusionStartDatetime" vr="DT" vm="1" name="Exclusion Start Datetime"/>
-    <entry group="0018" element="9805" keyword="ExclusionDuration" vr="FD" vm="1" name="Exclusion Duration"/>
-    <entry group="0018" element="9806" keyword="USImageDescriptionSequence" vr="SQ" vm="1" name="US Image Description Sequence"/>
-    <entry group="0018" element="9807" keyword="ImageDataTypeSequence" vr="SQ" vm="1" name="Image Data Type Sequence"/>
-    <entry group="0018" element="9808" keyword="DataType" vr="CS" vm="1" name="Data Type"/>
-    <entry group="0018" element="9809" keyword="TransducerScanPatternCodeSequence" vr="SQ" vm="1" name="Transducer Scan Pattern Code Sequence"/>
-    <entry group="0018" element="980b" keyword="AliasedDataType" vr="CS" vm="1" name="Aliased Data Type"/>
-    <entry group="0018" element="980c" keyword="PositionMeasuringDeviceUsed" vr="CS" vm="1" name="Position Measuring Device Used"/>
-    <entry group="0018" element="980d" keyword="TransducerGeometryCodeSequence" vr="SQ" vm="1" name="Transducer Geometry Code Sequence"/>
-    <entry group="0018" element="980e" keyword="TransducerBeamSteeringCodeSequence" vr="SQ" vm="1" name="Transducer Beam Steering Code Sequence"/>
-    <entry group="0018" element="980f" keyword="TransducerApplicationCodeSequence" vr="SQ" vm="1" name="Transducer Application Code Sequence"/>
-    <entry group="0018" element="a001" keyword="ContributingEquipmentSequence" vr="SQ" vm="1" name="Contributing Equipment Sequence"/>
-    <entry group="0018" element="a002" keyword="ContributionDateTime" vr="DT" vm="1" name="Contribution Date Time"/>
-    <entry group="0018" element="a003" keyword="ContributionDescription" vr="ST" vm="1" name="Contribution Description"/>
-    <entry group="0020" element="000d" keyword="StudyInstanceUID" vr="UI" vm="1" name="Study Instance UID"/>
-    <entry group="0020" element="000e" keyword="SeriesInstanceUID" vr="UI" vm="1" name="Series Instance UID"/>
-    <entry group="0020" element="0010" keyword="StudyID" vr="SH" vm="1" name="Study ID"/>
-    <entry group="0020" element="0011" keyword="SeriesNumber" vr="IS" vm="1" name="Series Number"/>
-    <entry group="0020" element="0012" keyword="AcquisitionNumber" vr="IS" vm="1" name="Acquisition Number"/>
-    <entry group="0020" element="0013" keyword="InstanceNumber" vr="IS" vm="1" name="Instance Number"/>
-    <entry group="0020" element="0014" keyword="IsotopeNumber" vr="IS" vm="1" retired="true" name="Isotope Number"/>
-    <entry group="0020" element="0015" keyword="PhaseNumber" vr="IS" vm="1" retired="true" name="Phase Number"/>
-    <entry group="0020" element="0016" keyword="IntervalNumber" vr="IS" vm="1" retired="true" name="Interval Number"/>
-    <entry group="0020" element="0017" keyword="TimeSlotNumber" vr="IS" vm="1" retired="true" name="Time Slot Number"/>
-    <entry group="0020" element="0018" keyword="AngleNumber" vr="IS" vm="1" retired="true" name="Angle Number"/>
-    <entry group="0020" element="0019" keyword="ItemNumber" vr="IS" vm="1" name="Item Number"/>
-    <entry group="0020" element="0020" keyword="PatientOrientation" vr="CS" vm="2" name="Patient Orientation"/>
-    <entry group="0020" element="0022" keyword="OverlayNumber" vr="IS" vm="1" retired="true" name="Overlay Number"/>
-    <entry group="0020" element="0024" keyword="CurveNumber" vr="IS" vm="1" retired="true" name="Curve Number"/>
-    <entry group="0020" element="0026" keyword="LUTNumber" vr="IS" vm="1" retired="true" name="LUT Number"/>
-    <entry group="0020" element="0030" keyword="ImagePosition" vr="DS" vm="3" retired="true" name="Image Position"/>
-    <entry group="0020" element="0032" keyword="ImagePositionPatient" vr="DS" vm="3" name="Image Position (Patient)"/>
-    <entry group="0020" element="0035" keyword="ImageOrientation" vr="DS" vm="6" retired="true" name="Image Orientation"/>
-    <entry group="0020" element="0037" keyword="ImageOrientationPatient" vr="DS" vm="6" name="Image Orientation (Patient)"/>
-    <entry group="0020" element="0050" keyword="Location" vr="DS" vm="1" retired="true" name="Location"/>
-    <entry group="0020" element="0052" keyword="FrameOfReferenceUID" vr="UI" vm="1" name="Frame of Reference UID"/>
-    <entry group="0020" element="0060" keyword="Laterality" vr="CS" vm="1" name="Laterality"/>
-    <entry group="0020" element="0062" keyword="ImageLaterality" vr="CS" vm="1" name="Image Laterality"/>
-    <entry group="0020" element="0070" keyword="ImageGeometryType" vr="LO" vm="1" retired="true" name="Image Geometry Type"/>
-    <entry group="0020" element="0080" keyword="MaskingImage" vr="CS" vm="1-n" retired="true" name="Masking Image"/>
-    <entry group="0020" element="00aa" keyword="ReportNumber" vr="IS" vm="1" retired="true" name="Report Number"/>
-    <entry group="0020" element="0100" keyword="TemporalPositionIdentifier" vr="IS" vm="1" name="Temporal Position Identifier"/>
-    <entry group="0020" element="0105" keyword="NumberOfTemporalPositions" vr="IS" vm="1" name="Number of Temporal Positions"/>
-    <entry group="0020" element="0110" keyword="TemporalResolution" vr="DS" vm="1" name="Temporal Resolution"/>
-    <entry group="0020" element="0200" keyword="SynchronizationFrameOfReferenceUID" vr="UI" vm="1" name="Synchronization Frame of Reference UID"/>
-    <entry group="0020" element="0242" keyword="SOPInstanceUIDOfConcatenationSource" vr="UI" vm="1" name="SOP Instance UID of Concatenation Source"/>
-    <entry group="0020" element="1000" keyword="SeriesInStudy" vr="IS" vm="1" retired="true" name="Series in Study"/>
-    <entry group="0020" element="1001" keyword="AcquisitionsInSeries" vr="IS" vm="1" retired="true" name="Acquisitions in Series"/>
-    <entry group="0020" element="1002" keyword="ImagesInAcquisition" vr="IS" vm="1" name="Images in Acquisition"/>
-    <entry group="0020" element="1003" keyword="ImagesInSeries" vr="IS" vm="1" retired="true" name="Images in Series"/>
-    <entry group="0020" element="1004" keyword="AcquisitionsInStudy" vr="IS" vm="1" retired="true" name="Acquisitions in Study"/>
-    <entry group="0020" element="1005" keyword="ImagesInStudy" vr="IS" vm="1" retired="true" name="Images in Study"/>
-    <entry group="0020" element="1020" keyword="Reference" vr="LO" vm="1-n" retired="true" name="Reference"/>
-    <entry group="0020" element="1040" keyword="PositionReferenceIndicator" vr="LO" vm="1" name="Position Reference Indicator"/>
-    <entry group="0020" element="1041" keyword="SliceLocation" vr="DS" vm="1" name="Slice Location"/>
-    <entry group="0020" element="1070" keyword="OtherStudyNumbers" vr="IS" vm="1-n" retired="true" name="Other Study Numbers"/>
-    <entry group="0020" element="1200" keyword="NumberOfPatientRelatedStudies" vr="IS" vm="1" name="Number of Patient Related Studies"/>
-    <entry group="0020" element="1202" keyword="NumberOfPatientRelatedSeries" vr="IS" vm="1" name="Number of Patient Related Series"/>
-    <entry group="0020" element="1204" keyword="NumberOfPatientRelatedInstances" vr="IS" vm="1" name="Number of Patient Related Instances"/>
-    <entry group="0020" element="1206" keyword="NumberOfStudyRelatedSeries" vr="IS" vm="1" name="Number of Study Related Series"/>
-    <entry group="0020" element="1208" keyword="NumberOfStudyRelatedInstances" vr="IS" vm="1" name="Number of Study Related Instances"/>
-    <entry group="0020" element="1209" keyword="NumberOfSeriesRelatedInstances" vr="IS" vm="1" name="Number of Series Related Instances"/>
-    <entry group="0020" element="31xx" keyword="SourceImageIDs" vr="CS" vm="1-n" retired="true" name="Source Image IDs"/>
-    <entry group="0020" element="3401" keyword="ModifyingDeviceID" vr="CS" vm="1" retired="true" name="Modifying Device ID"/>
-    <entry group="0020" element="3402" keyword="ModifiedImageID" vr="CS" vm="1" retired="true" name="Modified Image ID"/>
-    <entry group="0020" element="3403" keyword="ModifiedImageDate" vr="DA" vm="1" retired="true" name="Modified Image Date"/>
-    <entry group="0020" element="3404" keyword="ModifyingDeviceManufacturer" vr="LO" vm="1" retired="true" name="Modifying Device Manufacturer"/>
-    <entry group="0020" element="3405" keyword="ModifiedImageTime" vr="TM" vm="1" retired="true" name="Modified Image Time"/>
-    <entry group="0020" element="3406" keyword="ModifiedImageDescription" vr="LO" vm="1" retired="true" name="Modified Image Description"/>
-    <entry group="0020" element="4000" keyword="ImageComments" vr="LT" vm="1" name="Image Comments"/>
-    <entry group="0020" element="5000" keyword="OriginalImageIdentification" vr="AT" vm="1-n" retired="true" name="Original Image Identification"/>
-    <entry group="0020" element="5002" keyword="OriginalImageIdentificationNomenclature" vr="LO" vm="1-n" retired="true" name="Original Image Identification Nomenclature"/>
-    <entry group="0020" element="9056" keyword="StackID" vr="SH" vm="1" name="Stack ID"/>
-    <entry group="0020" element="9057" keyword="InStackPositionNumber" vr="UL" vm="1" name="In-Stack Position Number"/>
-    <entry group="0020" element="9071" keyword="FrameAnatomySequence" vr="SQ" vm="1" name="Frame Anatomy Sequence"/>
-    <entry group="0020" element="9072" keyword="FrameLaterality" vr="CS" vm="1" name="Frame Laterality"/>
-    <entry group="0020" element="9111" keyword="FrameContentSequence" vr="SQ" vm="1" name="Frame Content Sequence"/>
-    <entry group="0020" element="9113" keyword="PlanePositionSequence" vr="SQ" vm="1" name="Plane Position Sequence"/>
-    <entry group="0020" element="9116" keyword="PlaneOrientationSequence" vr="SQ" vm="1" name="Plane Orientation Sequence"/>
-    <entry group="0020" element="9128" keyword="TemporalPositionIndex" vr="UL" vm="1" name="Temporal Position Index"/>
-    <entry group="0020" element="9153" keyword="NominalCardiacTriggerDelayTime" vr="FD" vm="1" name="Nominal Cardiac Trigger Delay Time"/>
-    <entry group="0020" element="9154" keyword="NominalCardiacTriggerTimePriorToRPeak" vr="FL" vm="1" name="Nominal Cardiac Trigger Time Prior To R-Peak"/>
-    <entry group="0020" element="9155" keyword="ActualCardiacTriggerTimePriorToRPeak" vr="FL" vm="1" name="Actual Cardiac Trigger Time Prior To R-Peak"/>
-    <entry group="0020" element="9156" keyword="FrameAcquisitionNumber" vr="US" vm="1" name="Frame Acquisition Number"/>
-    <entry group="0020" element="9157" keyword="DimensionIndexValues" vr="UL" vm="1-n" name="Dimension Index Values"/>
-    <entry group="0020" element="9158" keyword="FrameComments" vr="LT" vm="1" name="Frame Comments"/>
-    <entry group="0020" element="9161" keyword="ConcatenationUID" vr="UI" vm="1" name="Concatenation UID"/>
-    <entry group="0020" element="9162" keyword="InConcatenationNumber" vr="US" vm="1" name="In-concatenation Number"/>
-    <entry group="0020" element="9163" keyword="InConcatenationTotalNumber" vr="US" vm="1" name="In-concatenation Total Number"/>
-    <entry group="0020" element="9164" keyword="DimensionOrganizationUID" vr="UI" vm="1" name="Dimension Organization UID"/>
-    <entry group="0020" element="9165" keyword="DimensionIndexPointer" vr="AT" vm="1" name="Dimension Index Pointer"/>
-    <entry group="0020" element="9167" keyword="FunctionalGroupPointer" vr="AT" vm="1" name="Functional Group Pointer"/>
-    <entry group="0020" element="9213" keyword="DimensionIndexPrivateCreator" vr="LO" vm="1" name="Dimension Index Private Creator"/>
-    <entry group="0020" element="9221" keyword="DimensionOrganizationSequence" vr="SQ" vm="1" name="Dimension Organization Sequence"/>
-    <entry group="0020" element="9222" keyword="DimensionIndexSequence" vr="SQ" vm="1" name="Dimension Index Sequence"/>
-    <entry group="0020" element="9228" keyword="ConcatenationFrameOffsetNumber" vr="UL" vm="1" name="Concatenation Frame Offset Number"/>
-    <entry group="0020" element="9238" keyword="FunctionalGroupPrivateCreator" vr="LO" vm="1" name="Functional Group Private Creator"/>
-    <entry group="0020" element="9241" keyword="NominalPercentageOfCardiacPhase" vr="FL" vm="1" name="Nominal Percentage of Cardiac Phase"/>
-    <entry group="0020" element="9245" keyword="NominalPercentageOfRespiratoryPhase" vr="FL" vm="1" name="Nominal Percentage of Respiratory Phase"/>
-    <entry group="0020" element="9246" keyword="StartingRespiratoryAmplitude" vr="FL" vm="1" name="Starting Respiratory Amplitude"/>
-    <entry group="0020" element="9247" keyword="StartingRespiratoryPhase" vr="CS" vm="1" name="Starting Respiratory Phase"/>
-    <entry group="0020" element="9248" keyword="EndingRespiratoryAmplitude" vr="FL" vm="1" name="Ending Respiratory Amplitude"/>
-    <entry group="0020" element="9249" keyword="EndingRespiratoryPhase" vr="CS" vm="1" name="Ending Respiratory Phase"/>
-    <entry group="0020" element="9250" keyword="RespiratoryTriggerType" vr="CS" vm="1" name="Respiratory Trigger Type"/>
-    <entry group="0020" element="9251" keyword="RRIntervalTimeNominal" vr="FD" vm="1" name="R-R Interval Time Nominal"/>
-    <entry group="0020" element="9252" keyword="ActualCardiacTriggerDelayTime" vr="FD" vm="1" name="Actual Cardiac Trigger Delay Time"/>
-    <entry group="0020" element="9253" keyword="RespiratorySynchronizationSequence" vr="SQ" vm="1" name="Respiratory Synchronization Sequence"/>
-    <entry group="0020" element="9254" keyword="RespiratoryIntervalTime" vr="FD" vm="1" name="Respiratory Interval Time"/>
-    <entry group="0020" element="9255" keyword="NominalRespiratoryTriggerDelayTime" vr="FD" vm="1" name="Nominal Respiratory Trigger Delay Time"/>
-    <entry group="0020" element="9256" keyword="RespiratoryTriggerDelayThreshold" vr="FD" vm="1" name="Respiratory Trigger Delay Threshold"/>
-    <entry group="0020" element="9257" keyword="ActualRespiratoryTriggerDelayTime" vr="FD" vm="1" name="Actual Respiratory Trigger Delay Time"/>
-    <entry group="0020" element="9301" keyword="ImagePositionVolume" vr="FD" vm="3" name="Image Position (Volume)"/>
-    <entry group="0020" element="9302" keyword="ImageOrientationVolume" vr="FD" vm="6" name="Image Orientation (Volume)"/>
-    <entry group="0020" element="9307" keyword="UltrasoundAcquisitionGeometry" vr="CS" vm="1" name="Ultrasound Acquisition Geometry"/>
-    <entry group="0020" element="9308" keyword="ApexPosition" vr="FD" vm="3" name="Apex Position"/>
-    <entry group="0020" element="9309" keyword="VolumeToTransducerMappingMatrix" vr="FD" vm="16" name="Volume to Transducer Mapping Matrix"/>
-    <entry group="0020" element="930a" keyword="VolumeToTableMappingMatrix" vr="FD" vm="16" name="Volume to Table Mapping Matrix"/>
-    <entry group="0020" element="930c" keyword="PatientFrameOfReferenceSource" vr="CS" vm="1" name="Patient Frame of Reference Source"/>
-    <entry group="0020" element="930d" keyword="TemporalPositionTimeOffset" vr="FD" vm="1" name="Temporal Position Time Offset"/>
-    <entry group="0020" element="930e" keyword="PlanePositionVolumeSequence" vr="SQ" vm="1" name="Plane Position (Volume) Sequence"/>
-    <entry group="0020" element="930f" keyword="PlaneOrientationVolumeSequence" vr="SQ" vm="1" name="Plane Orientation (Volume) Sequence"/>
-    <entry group="0020" element="9310" keyword="TemporalPositionSequence" vr="SQ" vm="1" name="Temporal Position Sequence"/>
-    <entry group="0020" element="9311" keyword="DimensionOrganizationType" vr="CS" vm="1" name="Dimension Organization Type"/>
-    <entry group="0020" element="9312" keyword="VolumeFrameOfReferenceUID" vr="UI" vm="1" name="Volume Frame of Reference UID"/>
-    <entry group="0020" element="9313" keyword="TableFrameOfReferenceUID" vr="UI" vm="1" name="Table Frame of Reference UID"/>
-    <entry group="0020" element="9421" keyword="DimensionDescriptionLabel" vr="LO" vm="1" name="Dimension Description Label"/>
-    <entry group="0020" element="9450" keyword="PatientOrientationInFrameSequence" vr="SQ" vm="1" name="Patient Orientation in Frame Sequence"/>
-    <entry group="0020" element="9453" keyword="FrameLabel" vr="LO" vm="1" name="Frame Label"/>
-    <entry group="0020" element="9518" keyword="AcquisitionIndex" vr="US" vm="1-n" name="Acquisition Index"/>
-    <entry group="0020" element="9529" keyword="ContributingSOPInstancesReferenceSequence" vr="SQ" vm="1" name="Contributing SOP Instances Reference Sequence"/>
-    <entry group="0020" element="9536" keyword="ReconstructionIndex" vr="US" vm="1" name="Reconstruction Index"/>
-    <entry group="0022" element="0001" keyword="LightPathFilterPassThroughWavelength" vr="US" vm="1" name="Light Path Filter Pass-Through Wavelength"/>
-    <entry group="0022" element="0002" keyword="LightPathFilterPassBand" vr="US" vm="2" name="Light Path Filter Pass Band"/>
-    <entry group="0022" element="0003" keyword="ImagePathFilterPassThroughWavelength" vr="US" vm="1" name="Image Path Filter Pass-Through Wavelength"/>
-    <entry group="0022" element="0004" keyword="ImagePathFilterPassBand" vr="US" vm="2" name="Image Path Filter Pass Band"/>
-    <entry group="0022" element="0005" keyword="PatientEyeMovementCommanded" vr="CS" vm="1" name="Patient Eye Movement Commanded"/>
-    <entry group="0022" element="0006" keyword="PatientEyeMovementCommandCodeSequence" vr="SQ" vm="1" name="Patient Eye Movement Command Code Sequence"/>
-    <entry group="0022" element="0007" keyword="SphericalLensPower" vr="FL" vm="1" name="Spherical Lens Power"/>
-    <entry group="0022" element="0008" keyword="CylinderLensPower" vr="FL" vm="1" name="Cylinder Lens Power"/>
-    <entry group="0022" element="0009" keyword="CylinderAxis" vr="FL" vm="1" name="Cylinder Axis"/>
-    <entry group="0022" element="000a" keyword="EmmetropicMagnification" vr="FL" vm="1" name="Emmetropic Magnification"/>
-    <entry group="0022" element="000b" keyword="IntraOcularPressure" vr="FL" vm="1" name="Intra Ocular Pressure"/>
-    <entry group="0022" element="000c" keyword="HorizontalFieldOfView" vr="FL" vm="1" name="Horizontal Field of View"/>
-    <entry group="0022" element="000d" keyword="PupilDilated" vr="CS" vm="1" name="Pupil Dilated"/>
-    <entry group="0022" element="000e" keyword="DegreeOfDilation" vr="FL" vm="1" name="Degree of Dilation"/>
-    <entry group="0022" element="0010" keyword="StereoBaselineAngle" vr="FL" vm="1" name="Stereo Baseline Angle"/>
-    <entry group="0022" element="0011" keyword="StereoBaselineDisplacement" vr="FL" vm="1" name="Stereo Baseline Displacement"/>
-    <entry group="0022" element="0012" keyword="StereoHorizontalPixelOffset" vr="FL" vm="1" name="Stereo Horizontal Pixel Offset"/>
-    <entry group="0022" element="0013" keyword="StereoVerticalPixelOffset" vr="FL" vm="1" name="Stereo Vertical Pixel Offset"/>
-    <entry group="0022" element="0014" keyword="StereoRotation" vr="FL" vm="1" name="Stereo Rotation"/>
-    <entry group="0022" element="0015" keyword="AcquisitionDeviceTypeCodeSequence" vr="SQ" vm="1" name="Acquisition Device Type Code Sequence"/>
-    <entry group="0022" element="0016" keyword="IlluminationTypeCodeSequence" vr="SQ" vm="1" name="Illumination Type Code Sequence"/>
-    <entry group="0022" element="0017" keyword="LightPathFilterTypeStackCodeSequence" vr="SQ" vm="1" name="Light Path Filter Type Stack Code Sequence"/>
-    <entry group="0022" element="0018" keyword="ImagePathFilterTypeStackCodeSequence" vr="SQ" vm="1" name="Image Path Filter Type Stack Code Sequence"/>
-    <entry group="0022" element="0019" keyword="LensesCodeSequence" vr="SQ" vm="1" name="Lenses Code Sequence"/>
-    <entry group="0022" element="001a" keyword="ChannelDescriptionCodeSequence" vr="SQ" vm="1" name="Channel Description Code Sequence"/>
-    <entry group="0022" element="001b" keyword="RefractiveStateSequence" vr="SQ" vm="1" name="Refractive State Sequence"/>
-    <entry group="0022" element="001c" keyword="MydriaticAgentCodeSequence" vr="SQ" vm="1" name="Mydriatic Agent Code Sequence"/>
-    <entry group="0022" element="001d" keyword="RelativeImagePositionCodeSequence" vr="SQ" vm="1" name="Relative Image Position Code Sequence"/>
-    <entry group="0022" element="001e" keyword="CameraAngleOfView" vr="FL" vm="1" name="Camera Angle of View"/>
-    <entry group="0022" element="0020" keyword="StereoPairsSequence" vr="SQ" vm="1" name="Stereo Pairs Sequence"/>
-    <entry group="0022" element="0021" keyword="LeftImageSequence" vr="SQ" vm="1" name="Left Image Sequence"/>
-    <entry group="0022" element="0022" keyword="RightImageSequence" vr="SQ" vm="1" name="Right Image Sequence"/>
-    <entry group="0022" element="0030" keyword="AxialLengthOfTheEye" vr="FL" vm="1" name="Axial Length of the Eye"/>
-    <entry group="0022" element="0031" keyword="OphthalmicFrameLocationSequence" vr="SQ" vm="1" name="Ophthalmic Frame Location Sequence"/>
-    <entry group="0022" element="0032" keyword="ReferenceCoordinates" vr="FL" vm="2-2n" name="Reference Coordinates"/>
-    <entry group="0022" element="0035" keyword="DepthSpatialResolution" vr="FL" vm="1" name="Depth Spatial Resolution"/>
-    <entry group="0022" element="0036" keyword="MaximumDepthDistortion" vr="FL" vm="1" name="Maximum Depth Distortion"/>
-    <entry group="0022" element="0037" keyword="AlongScanSpatialResolution" vr="FL" vm="1" name="Along-scan Spatial Resolution"/>
-    <entry group="0022" element="0038" keyword="MaximumAlongScanDistortion" vr="FL" vm="1" name="Maximum Along-scan Distortion"/>
-    <entry group="0022" element="0039" keyword="OphthalmicImageOrientation" vr="CS" vm="1" name="Ophthalmic Image Orientation"/>
-    <entry group="0022" element="0041" keyword="DepthOfTransverseImage" vr="FL" vm="1" name="Depth of Transverse Image"/>
-    <entry group="0022" element="0042" keyword="MydriaticAgentConcentrationUnitsSequence" vr="SQ" vm="1" name="Mydriatic Agent Concentration Units Sequence"/>
-    <entry group="0022" element="0048" keyword="AcrossScanSpatialResolution" vr="FL" vm="1" name="Across-scan Spatial Resolution"/>
-    <entry group="0022" element="0049" keyword="MaximumAcrossScanDistortion" vr="FL" vm="1" name="Maximum Across-scan Distortion"/>
-    <entry group="0022" element="004e" keyword="MydriaticAgentConcentration" vr="DS" vm="1" name="Mydriatic Agent Concentration"/>
-    <entry group="0022" element="0055" keyword="IlluminationWaveLength" vr="FL" vm="1" name="Illumination Wave Length"/>
-    <entry group="0022" element="0056" keyword="IlluminationPower" vr="FL" vm="1" name="Illumination Power"/>
-    <entry group="0022" element="0057" keyword="IlluminationBandwidth" vr="FL" vm="1" name="Illumination Bandwidth"/>
-    <entry group="0022" element="0058" keyword="MydriaticAgentSequence" vr="SQ" vm="1" name="Mydriatic Agent Sequence"/>
-    <entry group="0022" element="1007" keyword="OphthalmicAxialMeasurementsRightEyeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Measurements Right Eye Sequence"/>
-    <entry group="0022" element="1008" keyword="OphthalmicAxialMeasurementsLeftEyeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Measurements Left Eye Sequence"/>
-    <entry group="0022" element="1009" keyword="OphthalmicAxialMeasurementsDeviceType" vr="CS" vm="1" name="Ophthalmic Axial Measurements Device Type"/>
-    <entry group="0022" element="1010" keyword="OphthalmicAxialLengthMeasurementsType" vr="CS" vm="1" name="Ophthalmic Axial Length Measurements Type"/>
-    <entry group="0022" element="1012" keyword="OphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Sequence"/>
-    <entry group="0022" element="1019" keyword="OphthalmicAxialLength" vr="FL" vm="1" name="Ophthalmic Axial Length"/>
-    <entry group="0022" element="1024" keyword="LensStatusCodeSequence" vr="SQ" vm="1" name="Lens Status Code Sequence"/>
-    <entry group="0022" element="1025" keyword="VitreousStatusCodeSequence" vr="SQ" vm="1" name="Vitreous Status Code Sequence"/>
-    <entry group="0022" element="1028" keyword="IOLFormulaCodeSequence" vr="SQ" vm="1" name="IOL Formula Code Sequence"/>
-    <entry group="0022" element="1029" keyword="IOLFormulaDetail" vr="LO" vm="1" name="IOL Formula Detail"/>
-    <entry group="0022" element="1033" keyword="KeratometerIndex" vr="FL" vm="1" name="Keratometer Index"/>
-    <entry group="0022" element="1035" keyword="SourceOfOphthalmicAxialLengthCodeSequence" vr="SQ" vm="1" name="Source of Ophthalmic Axial Length Code Sequence"/>
-    <entry group="0022" element="1037" keyword="TargetRefraction" vr="FL" vm="1" name="Target Refraction"/>
-    <entry group="0022" element="1039" keyword="RefractiveProcedureOccurred" vr="CS" vm="1" name="Refractive Procedure Occurred"/>
-    <entry group="0022" element="1040" keyword="RefractiveSurgeryTypeCodeSequence" vr="SQ" vm="1" name="Refractive Surgery Type Code Sequence"/>
-    <entry group="0022" element="1044" keyword="OphthalmicUltrasoundMethodCodeSequence" vr="SQ" vm="1" name="Ophthalmic Ultrasound Method Code Sequence"/>
-    <entry group="0022" element="1050" keyword="OphthalmicAxialLengthMeasurementsSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Sequence"/>
-    <entry group="0022" element="1053" keyword="IOLPower" vr="FL" vm="1" name="IOL Power"/>
-    <entry group="0022" element="1054" keyword="PredictedRefractiveError" vr="FL" vm="1" name="Predicted Refractive Error"/>
-    <entry group="0022" element="1059" keyword="OphthalmicAxialLengthVelocity" vr="FL" vm="1" name="Ophthalmic Axial Length Velocity"/>
-    <entry group="0022" element="1065" keyword="LensStatusDescription" vr="LO" vm="1" name="Lens Status Description"/>
-    <entry group="0022" element="1066" keyword="VitreousStatusDescription" vr="LO" vm="1" name="Vitreous Status Description"/>
-    <entry group="0022" element="1090" keyword="IOLPowerSequence" vr="SQ" vm="1" name="IOL Power Sequence"/>
-    <entry group="0022" element="1092" keyword="LensConstantSequence" vr="SQ" vm="1" name="Lens Constant Sequence"/>
-    <entry group="0022" element="1093" keyword="IOLManufacturer" vr="LO" vm="1" name="IOL Manufacturer"/>
-    <entry group="0022" element="1094" keyword="LensConstantDescription" vr="LO" vm="1" name="Lens Constant Description"/>
-    <entry group="0022" element="1095" keyword="ImplantName" vr="LO" vm="1" name="Implant Name"/>
-    <entry group="0022" element="1096" keyword="KeratometryMeasurementTypeCodeSequence" vr="SQ" vm="1" name="Keratometry Measurement Type Code Sequence"/>
-    <entry group="0022" element="1097" keyword="ImplantPartNumber" vr="LO" vm="1" name="Implant Part Number"/>
-    <entry group="0022" element="1100" keyword="ReferencedOphthalmicAxialMeasurementsSequence" vr="SQ" vm="1" name="Referenced Ophthalmic Axial Measurements Sequence"/>
-    <entry group="0022" element="1101" keyword="OphthalmicAxialLengthMeasurementsSegmentNameCodeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Segment Name Code Sequence"/>
-    <entry group="0022" element="1103" keyword="RefractiveErrorBeforeRefractiveSurgeryCodeSequence" vr="SQ" vm="1" name="Refractive Error Before Refractive Surgery Code Sequence"/>
-    <entry group="0022" element="1121" keyword="IOLPowerForExactEmmetropia" vr="FL" vm="1" name="IOL Power For Exact Emmetropia"/>
-    <entry group="0022" element="1122" keyword="IOLPowerForExactTargetRefraction" vr="FL" vm="1" name="IOL Power For Exact Target Refraction"/>
-    <entry group="0022" element="1125" keyword="AnteriorChamberDepthDefinitionCodeSequence" vr="SQ" vm="1" name="Anterior Chamber Depth Definition Code Sequence"/>
-    <entry group="0022" element="1127" keyword="LensThicknessSequence" vr="SQ" vm="1" name="Lens Thickness Sequence"/>
-    <entry group="0022" element="1128" keyword="AnteriorChamberDepthSequence" vr="SQ" vm="1" name="Anterior Chamber Depth Sequence"/>
-    <entry group="0022" element="1130" keyword="LensThickness" vr="FL" vm="1" name="Lens Thickness"/>
-    <entry group="0022" element="1131" keyword="AnteriorChamberDepth" vr="FL" vm="1" name="Anterior Chamber Depth"/>
-    <entry group="0022" element="1132" keyword="SourceOfLensThicknessDataCodeSequence" vr="SQ" vm="1" name="Source of Lens Thickness Data Code Sequence"/>
-    <entry group="0022" element="1133" keyword="SourceOfAnteriorChamberDepthDataCodeSequence" vr="SQ" vm="1" name="Source of Anterior Chamber Depth Data Code Sequence"/>
-    <entry group="0022" element="1134" keyword="SourceOfRefractiveMeasurementsSequence" vr="SQ" vm="1" name="Source of Refractive Measurements Sequence"/>
-    <entry group="0022" element="1135" keyword="SourceOfRefractiveMeasurementsCodeSequence" vr="SQ" vm="1" name="Source of Refractive Measurements Code Sequence"/>
-    <entry group="0022" element="1140" keyword="OphthalmicAxialLengthMeasurementModified" vr="CS" vm="1" name="Ophthalmic Axial Length Measurement Modified"/>
-    <entry group="0022" element="1150" keyword="OphthalmicAxialLengthDataSourceCodeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Data Source Code Sequence"/>
-    <entry group="0022" element="1153" keyword="OphthalmicAxialLengthAcquisitionMethodCodeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Acquisition Method Code Sequence"/>
-    <entry group="0022" element="1155" keyword="SignalToNoiseRatio" vr="FL" vm="1" name="Signal to Noise Ratio"/>
-    <entry group="0022" element="1159" keyword="OphthalmicAxialLengthDataSourceDescription" vr="LO" vm="1" name="Ophthalmic Axial Length Data Source Description"/>
-    <entry group="0022" element="1210" keyword="OphthalmicAxialLengthMeasurementsTotalLengthSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Total Length Sequence"/>
-    <entry group="0022" element="1211" keyword="OphthalmicAxialLengthMeasurementsSegmentalLengthSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Segmental Length Sequence"/>
-    <entry group="0022" element="1212" keyword="OphthalmicAxialLengthMeasurementsLengthSummationSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Length Summation Sequence"/>
-    <entry group="0022" element="1220" keyword="UltrasoundOphthalmicAxialLengthMeasurementsSequence" vr="SQ" vm="1" name="Ultrasound Ophthalmic Axial Length Measurements Sequence"/>
-    <entry group="0022" element="1225" keyword="OpticalOphthalmicAxialLengthMeasurementsSequence" vr="SQ" vm="1" name="Optical Ophthalmic Axial Length Measurements Sequence"/>
-    <entry group="0022" element="1230" keyword="UltrasoundSelectedOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Ultrasound Selected Ophthalmic Axial Length Sequence"/>
-    <entry group="0022" element="1250" keyword="OphthalmicAxialLengthSelectionMethodCodeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Selection Method Code Sequence"/>
-    <entry group="0022" element="1255" keyword="OpticalSelectedOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Optical Selected Ophthalmic Axial Length Sequence"/>
-    <entry group="0022" element="1257" keyword="SelectedSegmentalOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Selected Segmental Ophthalmic Axial Length Sequence"/>
-    <entry group="0022" element="1260" keyword="SelectedTotalOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Selected Total Ophthalmic Axial Length Sequence"/>
-    <entry group="0022" element="1262" keyword="OphthalmicAxialLengthQualityMetricSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Quality Metric Sequence"/>
-    <entry group="0022" element="1273" keyword="OphthalmicAxialLengthQualityMetricTypeDescription" vr="LO" vm="1" name="Ophthalmic Axial Length Quality Metric Type Description"/>
-    <entry group="0022" element="1300" keyword="IntraocularLensCalculationsRightEyeSequence" vr="SQ" vm="1" name="Intraocular Lens Calculations Right Eye Sequence"/>
-    <entry group="0022" element="1310" keyword="IntraocularLensCalculationsLeftEyeSequence" vr="SQ" vm="1" name="Intraocular Lens Calculations Left Eye Sequence"/>
-    <entry group="0022" element="1330" keyword="ReferencedOphthalmicAxialLengthMeasurementQCImageSequence" vr="SQ" vm="1" name="Referenced Ophthalmic Axial Length Measurement QC Image Sequence"/>
-    <entry group="0024" element="0010" keyword="VisualFieldHorizontalExtent" vr="FL" vm="1" name="Visual Field Horizontal Extent"/>
-    <entry group="0024" element="0011" keyword="VisualFieldVerticalExtent" vr="FL" vm="1" name="Visual Field Vertical Extent"/>
-    <entry group="0024" element="0012" keyword="VisualFieldShape" vr="CS" vm="1" name="Visual Field Shape"/>
-    <entry group="0024" element="0016" keyword="ScreeningTestModeCodeSequence" vr="SQ" vm="1" name="Screening Test Mode Code Sequence"/>
-    <entry group="0024" element="0018" keyword="MaximumStimulusLuminance" vr="FL" vm="1" name="Maximum Stimulus Luminance"/>
-    <entry group="0024" element="0020" keyword="BackgroundLuminance" vr="FL" vm="1" name="Background Luminance"/>
-    <entry group="0024" element="0021" keyword="StimulusColorCodeSequence" vr="SQ" vm="1" name="Stimulus Color Code Sequence"/>
-    <entry group="0024" element="0024" keyword="BackgroundIlluminationColorCodeSequence" vr="SQ" vm="1" name="Background Illumination Color Code Sequence"/>
-    <entry group="0024" element="0025" keyword="StimulusArea" vr="FL" vm="1" name="Stimulus Area"/>
-    <entry group="0024" element="0028" keyword="StimulusPresentationTime" vr="FL" vm="1" name="Stimulus Presentation Time"/>
-    <entry group="0024" element="0032" keyword="FixationSequence" vr="SQ" vm="1" name="Fixation Sequence"/>
-    <entry group="0024" element="0033" keyword="FixationMonitoringCodeSequence" vr="SQ" vm="1" name="Fixation Monitoring Code Sequence"/>
-    <entry group="0024" element="0034" keyword="VisualFieldCatchTrialSequence" vr="SQ" vm="1" name="Visual Field Catch Trial Sequence"/>
-    <entry group="0024" element="0035" keyword="FixationCheckedQuantity" vr="US" vm="1" name="Fixation Checked Quantity"/>
-    <entry group="0024" element="0036" keyword="PatientNotProperlyFixatedQuantity" vr="US" vm="1" name="Patient Not Properly Fixated Quantity"/>
-    <entry group="0024" element="0037" keyword="PresentedVisualStimuliDataFlag" vr="CS" vm="1" name="Presented Visual Stimuli Data Flag"/>
-    <entry group="0024" element="0038" keyword="NumberOfVisualStimuli" vr="US" vm="1" name="Number of Visual Stimuli"/>
-    <entry group="0024" element="0039" keyword="ExcessiveFixationLossesDataFlag" vr="CS" vm="1" name="Excessive Fixation Losses Data Flag"/>
-    <entry group="0024" element="0040" keyword="ExcessiveFixationLosses" vr="CS" vm="1" name="Excessive Fixation Losses"/>
-    <entry group="0024" element="0042" keyword="StimuliRetestingQuantity" vr="US" vm="1" name="Stimuli Retesting Quantity"/>
-    <entry group="0024" element="0044" keyword="CommentsOnPatientPerformanceOfVisualField" vr="LT" vm="1" name="Comments on Patient's Performance of Visual Field"/>
-    <entry group="0024" element="0045" keyword="FalseNegativesEstimateFlag" vr="CS" vm="1" name="False Negatives Estimate Flag"/>
-    <entry group="0024" element="0046" keyword="FalseNegativesEstimate" vr="FL" vm="1" name="False Negatives Estimate"/>
-    <entry group="0024" element="0048" keyword="NegativeCatchTrialsQuantity" vr="US" vm="1" name="Negative Catch Trials Quantity"/>
-    <entry group="0024" element="0050" keyword="FalseNegativesQuantity" vr="US" vm="1" name="False Negatives Quantity"/>
-    <entry group="0024" element="0051" keyword="ExcessiveFalseNegativesDataFlag" vr="CS" vm="1" name="Excessive False Negatives Data Flag"/>
-    <entry group="0024" element="0052" keyword="ExcessiveFalseNegatives" vr="CS" vm="1" name="Excessive False Negatives"/>
-    <entry group="0024" element="0053" keyword="FalsePositivesEstimateFlag" vr="CS" vm="1" name="False Positives Estimate Flag"/>
-    <entry group="0024" element="0054" keyword="FalsePositivesEstimate" vr="FL" vm="1" name="False Positives Estimate"/>
-    <entry group="0024" element="0055" keyword="CatchTrialsDataFlag" vr="CS" vm="1" name="Catch Trials Data Flag"/>
-    <entry group="0024" element="0056" keyword="PositiveCatchTrialsQuantity" vr="US" vm="1" name="Positive Catch Trials Quantity"/>
-    <entry group="0024" element="0057" keyword="TestPointNormalsDataFlag" vr="CS" vm="1" name="Test Point Normals Data Flag"/>
-    <entry group="0024" element="0058" keyword="TestPointNormalsSequence" vr="SQ" vm="1" name="Test Point Normals Sequence"/>
-    <entry group="0024" element="0059" keyword="GlobalDeviationProbabilityNormalsFlag" vr="CS" vm="1" name="Global Deviation Probability Normals Flag"/>
-    <entry group="0024" element="0060" keyword="FalsePositivesQuantity" vr="US" vm="1" name="False Positives Quantity"/>
-    <entry group="0024" element="0061" keyword="ExcessiveFalsePositivesDataFlag" vr="CS" vm="1" name="Excessive False Positives Data Flag"/>
-    <entry group="0024" element="0062" keyword="ExcessiveFalsePositives" vr="CS" vm="1" name="Excessive False Positives"/>
-    <entry group="0024" element="0063" keyword="VisualFieldTestNormalsFlag" vr="CS" vm="1" name="Visual Field Test Normals Flag"/>
-    <entry group="0024" element="0064" keyword="ResultsNormalsSequence" vr="SQ" vm="1" name="Results Normals Sequence"/>
-    <entry group="0024" element="0065" keyword="AgeCorrectedSensitivityDeviationAlgorithmSequence" vr="SQ" vm="1" name="Age Corrected Sensitivity Deviation Algorithm Sequence"/>
-    <entry group="0024" element="0066" keyword="GlobalDeviationFromNormal" vr="FL" vm="1" name="Global Deviation From Normal"/>
-    <entry group="0024" element="0067" keyword="GeneralizedDefectSensitivityDeviationAlgorithmSequence" vr="SQ" vm="1" name="Generalized Defect Sensitivity Deviation Algorithm Sequence"/>
-    <entry group="0024" element="0068" keyword="LocalizedDeviationfromNormal" vr="FL" vm="1" name="Localized Deviation from Normal"/>
-    <entry group="0024" element="0069" keyword="PatientReliabilityIndicator" vr="LO" vm="1" name="Patient Reliability Indicator"/>
-    <entry group="0024" element="0070" keyword="VisualFieldMeanSensitivity" vr="FL" vm="1" name="Visual Field Mean Sensitivity"/>
-    <entry group="0024" element="0071" keyword="GlobalDeviationProbability" vr="FL" vm="1" name="Global Deviation Probability"/>
-    <entry group="0024" element="0072" keyword="LocalDeviationProbabilityNormalsFlag" vr="CS" vm="1" name="Local Deviation Probability Normals Flag"/>
-    <entry group="0024" element="0073" keyword="LocalizedDeviationProbability" vr="FL" vm="1" name="Localized Deviation Probability"/>
-    <entry group="0024" element="0074" keyword="ShortTermFluctuationCalculated" vr="CS" vm="1" name="Short Term Fluctuation Calculated"/>
-    <entry group="0024" element="0075" keyword="ShortTermFluctuation" vr="FL" vm="1" name="Short Term Fluctuation"/>
-    <entry group="0024" element="0076" keyword="ShortTermFluctuationProbabilityCalculated" vr="CS" vm="1" name="Short Term Fluctuation Probability Calculated"/>
-    <entry group="0024" element="0077" keyword="ShortTermFluctuationProbability" vr="FL" vm="1" name="Short Term Fluctuation Probability"/>
-    <entry group="0024" element="0078" keyword="CorrectedLocalizedDeviationFromNormalCalculated" vr="CS" vm="1" name="Corrected Localized Deviation From Normal Calculated"/>
-    <entry group="0024" element="0079" keyword="CorrectedLocalizedDeviationFromNormal" vr="FL" vm="1" name="Corrected Localized Deviation From Normal"/>
-    <entry group="0024" element="0080" keyword="CorrectedLocalizedDeviationFromNormalProbabilityCalculated" vr="CS" vm="1" name="Corrected Localized Deviation From Normal Probability Calculated"/>
-    <entry group="0024" element="0081" keyword="CorrectedLocalizedDeviationFromNormalProbability" vr="FL" vm="1" name="Corrected Localized Deviation From Normal Probability"/>
-    <entry group="0024" element="0083" keyword="GlobalDeviationProbabilitySequence" vr="SQ" vm="1" name="Global Deviation Probability Sequence"/>
-    <entry group="0024" element="0085" keyword="LocalizedDeviationProbabilitySequence" vr="SQ" vm="1" name="Localized Deviation Probability Sequence"/>
-    <entry group="0024" element="0086" keyword="FovealSensitivityMeasured" vr="CS" vm="1" name="Foveal Sensitivity Measured"/>
-    <entry group="0024" element="0087" keyword="FovealSensitivity" vr="FL" vm="1" name="Foveal Sensitivity"/>
-    <entry group="0024" element="0088" keyword="VisualFieldTestDuration" vr="FL" vm="1" name="Visual Field Test Duration"/>
-    <entry group="0024" element="0089" keyword="VisualFieldTestPointSequence" vr="SQ" vm="1" name="Visual Field Test Point Sequence"/>
-    <entry group="0024" element="0090" keyword="VisualFieldTestPointXCoordinate" vr="FL" vm="1" name="Visual Field Test Point X-Coordinate"/>
-    <entry group="0024" element="0091" keyword="VisualFieldTestPointYCoordinate" vr="FL" vm="1" name="Visual Field Test Point Y-Coordinate"/>
-    <entry group="0024" element="0092" keyword="AgeCorrectedSensitivityDeviationValue" vr="FL" vm="1" name="Age Corrected Sensitivity Deviation Value"/>
-    <entry group="0024" element="0093" keyword="StimulusResults" vr="CS" vm="1" name="Stimulus Results"/>
-    <entry group="0024" element="0094" keyword="SensitivityValue" vr="FL" vm="1" name="Sensitivity Value"/>
-    <entry group="0024" element="0095" keyword="RetestStimulusSeen" vr="CS" vm="1" name="Retest Stimulus Seen"/>
-    <entry group="0024" element="0096" keyword="RetestSensitivityValue" vr="FL" vm="1" name="Retest Sensitivity Value"/>
-    <entry group="0024" element="0097" keyword="VisualFieldTestPointNormalsSequence" vr="SQ" vm="1" name="Visual Field Test Point Normals Sequence"/>
-    <entry group="0024" element="0098" keyword="QuantifiedDefect" vr="FL" vm="1" name="Quantified Defect"/>
-    <entry group="0024" element="0100" keyword="AgeCorrectedSensitivityDeviationProbabilityValue" vr="FL" vm="1" name="Age Corrected Sensitivity Deviation Probability Value"/>
-    <entry group="0024" element="0102" keyword="GeneralizedDefectCorrectedSensitivityDeviationFlag" vr="CS" vm="1" name="Generalized Defect Corrected Sensitivity Deviation Flag"/>
-    <entry group="0024" element="0103" keyword="GeneralizedDefectCorrectedSensitivityDeviationValue" vr="FL" vm="1" name="Generalized Defect Corrected Sensitivity Deviation Value"/>
-    <entry group="0024" element="0104" keyword="GeneralizedDefectCorrectedSensitivityDeviationProbabilityValue" vr="FL" vm="1" name="Generalized Defect Corrected Sensitivity Deviation Probability Value"/>
-    <entry group="0024" element="0105" keyword="MinimumSensitivityValue" vr="FL" vm="1" name="Minimum Sensitivity Value"/>
-    <entry group="0024" element="0106" keyword="BlindSpotLocalized" vr="CS" vm="1" name="Blind Spot Localized"/>
-    <entry group="0024" element="0107" keyword="BlindSpotXCoordinate" vr="FL" vm="1" name="Blind Spot X-Coordinate"/>
-    <entry group="0024" element="0108" keyword="BlindSpotYCoordinate" vr="FL" vm="1" name="Blind Spot Y-Coordinate"/>
-    <entry group="0024" element="0110" keyword="VisualAcuityMeasurementSequence" vr="SQ" vm="1" name="Visual Acuity Measurement Sequence"/>
-    <entry group="0024" element="0112" keyword="RefractiveParametersUsedOnPatientSequence" vr="SQ" vm="1" name="Refractive Parameters Used on Patient Sequence"/>
-    <entry group="0024" element="0113" keyword="MeasurementLaterality" vr="CS" vm="1" name="Measurement Laterality"/>
-    <entry group="0024" element="0114" keyword="OphthalmicPatientClinicalInformationLeftEyeSequence" vr="SQ" vm="1" name="Ophthalmic Patient Clinical Information Left Eye Sequence"/>
-    <entry group="0024" element="0115" keyword="OphthalmicPatientClinicalInformationRightEyeSequence" vr="SQ" vm="1" name="Ophthalmic Patient Clinical Information Right Eye Sequence"/>
-    <entry group="0024" element="0117" keyword="FovealPointNormativeDataFlag" vr="CS" vm="1" name="Foveal Point Normative Data Flag"/>
-    <entry group="0024" element="0118" keyword="FovealPointProbabilityValue" vr="FL" vm="1" name="Foveal Point Probability Value"/>
-    <entry group="0024" element="0120" keyword="ScreeningBaselineMeasured" vr="CS" vm="1" name="Screening Baseline Measured"/>
-    <entry group="0024" element="0122" keyword="ScreeningBaselineMeasuredSequence" vr="SQ" vm="1" name="Screening Baseline Measured Sequence"/>
-    <entry group="0024" element="0124" keyword="ScreeningBaselineType" vr="CS" vm="1" name="Screening Baseline Type"/>
-    <entry group="0024" element="0126" keyword="ScreeningBaselineValue" vr="FL" vm="1" name="Screening Baseline Value"/>
-    <entry group="0024" element="0202" keyword="AlgorithmSource" vr="LO" vm="1" name="Algorithm Source"/>
-    <entry group="0024" element="0306" keyword="DataSetName" vr="LO" vm="1" name="Data Set Name"/>
-    <entry group="0024" element="0307" keyword="DataSetVersion" vr="LO" vm="1" name="Data Set Version"/>
-    <entry group="0024" element="0308" keyword="DataSetSource" vr="LO" vm="1" name="Data Set Source"/>
-    <entry group="0024" element="0309" keyword="DataSetDescription" vr="LO" vm="1" name="Data Set Description"/>
-    <entry group="0024" element="0317" keyword="VisualFieldTestReliabilityGlobalIndexSequence" vr="SQ" vm="1" name="Visual Field Test Reliability Global Index Sequence"/>
-    <entry group="0024" element="0320" keyword="VisualFieldGlobalResultsIndexSequence" vr="SQ" vm="1" name="Visual Field Global Results Index Sequence"/>
-    <entry group="0024" element="0325" keyword="DataObservationSequence" vr="SQ" vm="1" name="Data Observation Sequence"/>
-    <entry group="0024" element="0338" keyword="IndexNormalsFlag" vr="CS" vm="1" name="Index Normals Flag"/>
-    <entry group="0024" element="0341" keyword="IndexProbability" vr="FL" vm="1" name="Index Probability"/>
-    <entry group="0024" element="0344" keyword="IndexProbabilitySequence" vr="SQ" vm="1" name="Index Probability Sequence"/>
-    <entry group="0028" element="0002" keyword="SamplesPerPixel" vr="US" vm="1" name="Samples per Pixel"/>
-    <entry group="0028" element="0003" keyword="SamplesPerPixelUsed" vr="US" vm="1" name="Samples per Pixel Used"/>
-    <entry group="0028" element="0004" keyword="PhotometricInterpretation" vr="CS" vm="1" name="Photometric Interpretation"/>
-    <entry group="0028" element="0005" keyword="ImageDimensions" vr="US" vm="1" retired="true" name="Image Dimensions"/>
-    <entry group="0028" element="0006" keyword="PlanarConfiguration" vr="US" vm="1" name="Planar Configuration"/>
-    <entry group="0028" element="0008" keyword="NumberOfFrames" vr="IS" vm="1" name="Number of Frames"/>
-    <entry group="0028" element="0009" keyword="FrameIncrementPointer" vr="AT" vm="1-n" name="Frame Increment Pointer"/>
-    <entry group="0028" element="000a" keyword="FrameDimensionPointer" vr="AT" vm="1-n" name="Frame Dimension Pointer"/>
-    <entry group="0028" element="0010" keyword="Rows" vr="US" vm="1" name="Rows"/>
-    <entry group="0028" element="0011" keyword="Columns" vr="US" vm="1" name="Columns"/>
-    <entry group="0028" element="0012" keyword="Planes" vr="US" vm="1" retired="true" name="Planes"/>
-    <entry group="0028" element="0014" keyword="UltrasoundColorDataPresent" vr="US" vm="1" name="Ultrasound Color Data Present"/>
-    <entry group="0028" element="0020" keyword="" retired="true">
-      <description>SHALL NOT BE USED</description>
-    </entry>
-    <entry group="0028" element="0030" keyword="PixelSpacing" vr="DS" vm="2" name="Pixel Spacing"/>
-    <entry group="0028" element="0031" keyword="ZoomFactor" vr="DS" vm="2" name="Zoom Factor"/>
-    <entry group="0028" element="0032" keyword="ZoomCenter" vr="DS" vm="2" name="Zoom Center"/>
-    <entry group="0028" element="0034" keyword="PixelAspectRatio" vr="IS" vm="2" name="Pixel Aspect Ratio"/>
-    <entry group="0028" element="0040" keyword="ImageFormat" vr="CS" vm="1" retired="true" name="Image Format"/>
-    <entry group="0028" element="0050" keyword="ManipulatedImage" vr="LO" vm="1-n" retired="true" name="Manipulated Image"/>
-    <entry group="0028" element="0051" keyword="CorrectedImage" vr="CS" vm="1-n" name="Corrected Image"/>
-    <entry group="0028" element="005f" keyword="CompressionRecognitionCode" vr="LO" vm="1" retired="true" name="Compression Recognition Code"/>
-    <entry group="0028" element="0060" keyword="CompressionCode" vr="CS" vm="1" retired="true" name="Compression Code"/>
-    <entry group="0028" element="0061" keyword="CompressionOriginator" vr="SH" vm="1" retired="true" name="Compression Originator"/>
-    <entry group="0028" element="0062" keyword="CompressionLabel" vr="LO" vm="1" retired="true" name="Compression Label"/>
-    <entry group="0028" element="0063" keyword="CompressionDescription" vr="SH" vm="1" retired="true" name="Compression Description"/>
-    <entry group="0028" element="0065" keyword="CompressionSequence" vr="CS" vm="1-n" retired="true" name="Compression Sequence"/>
-    <entry group="0028" element="0066" keyword="CompressionStepPointers" vr="AT" vm="1-n" retired="true" name="Compression Step Pointers"/>
-    <entry group="0028" element="0068" keyword="RepeatInterval" vr="US" vm="1" retired="true" name="Repeat Interval"/>
-    <entry group="0028" element="0069" keyword="BitsGrouped" vr="US" vm="1" retired="true" name="Bits Grouped"/>
-    <entry group="0028" element="0070" keyword="PerimeterTable" vr="US" vm="1-n" retired="true" name="Perimeter Table"/>
-    <entry group="0028" element="0071" keyword="PerimeterValue" vr="US_SS" vm="1" retired="true" name="Perimeter Value"/>
-    <entry group="0028" element="0080" keyword="PredictorRows" vr="US" vm="1" retired="true" name="Predictor Rows"/>
-    <entry group="0028" element="0081" keyword="PredictorColumns" vr="US" vm="1" retired="true" name="Predictor Columns"/>
-    <entry group="0028" element="0082" keyword="PredictorConstants" vr="US" vm="1-n" retired="true" name="Predictor Constants"/>
-    <entry group="0028" element="0090" keyword="BlockedPixels" vr="CS" vm="1" retired="true" name="Blocked Pixels"/>
-    <entry group="0028" element="0091" keyword="BlockRows" vr="US" vm="1" retired="true" name="Block Rows"/>
-    <entry group="0028" element="0092" keyword="BlockColumns" vr="US" vm="1" retired="true" name="Block Columns"/>
-    <entry group="0028" element="0093" keyword="RowOverlap" vr="US" vm="1" retired="true" name="Row Overlap"/>
-    <entry group="0028" element="0094" keyword="ColumnOverlap" vr="US" vm="1" retired="true" name="Column Overlap"/>
-    <entry group="0028" element="0100" keyword="BitsAllocated" vr="US" vm="1" name="Bits Allocated"/>
-    <entry group="0028" element="0101" keyword="BitsStored" vr="US" vm="1" name="Bits Stored"/>
-    <entry group="0028" element="0102" keyword="HighBit" vr="US" vm="1" name="High Bit"/>
-    <entry group="0028" element="0103" keyword="PixelRepresentation" vr="US" vm="1" name="Pixel Representation"/>
-    <entry group="0028" element="0104" keyword="SmallestValidPixelValue" vr="US_SS" vm="1" retired="true" name="Smallest Valid Pixel Value"/>
-    <entry group="0028" element="0105" keyword="LargestValidPixelValue" vr="US_SS" vm="1" retired="true" name="Largest Valid Pixel Value"/>
-    <entry group="0028" element="0106" keyword="SmallestImagePixelValue" vr="US_SS" vm="1" name="Smallest Image Pixel Value"/>
-    <entry group="0028" element="0107" keyword="LargestImagePixelValue" vr="US_SS" vm="1" name="Largest Image Pixel Value"/>
-    <entry group="0028" element="0108" keyword="SmallestPixelValueInSeries" vr="US_SS" vm="1" name="Smallest Pixel Value in Series"/>
-    <entry group="0028" element="0109" keyword="LargestPixelValueInSeries" vr="US_SS" vm="1" name="Largest Pixel Value in Series"/>
-    <entry group="0028" element="0110" keyword="SmallestImagePixelValueInPlane" vr="US_SS" vm="1" retired="true" name="Smallest Image Pixel Value in Plane"/>
-    <entry group="0028" element="0111" keyword="LargestImagePixelValueInPlane" vr="US_SS" vm="1" retired="true" name="Largest Image Pixel Value in Plane"/>
-    <entry group="0028" element="0120" keyword="PixelPaddingValue" vr="US_SS" vm="1" name="Pixel Padding Value"/>
-    <entry group="0028" element="0121" keyword="PixelPaddingRangeLimit" vr="US_SS" vm="1" name="Pixel Padding Range Limit"/>
-    <entry group="0028" element="0200" keyword="ImageLocation" vr="US" vm="1" retired="true" name="Image Location"/>
-    <entry group="0028" element="0300" keyword="QualityControlImage" vr="CS" vm="1" name="Quality Control Image"/>
-    <entry group="0028" element="0301" keyword="BurnedInAnnotation" vr="CS" vm="1" name="Burned In Annotation"/>
-    <entry group="0028" element="0302" keyword="RecognizableVisualFeatures" vr="CS" vm="1" name="Recognizable Visual Features"/>
-    <entry group="0028" element="0303" keyword="LongitudinalTemporalInformationModified" vr="CS" vm="1" name="Longitudinal Temporal Information Modified"/>
-    <entry group="0028" element="0304" keyword="ReferencedColorPaletteInstanceUID" vr="UI" vm="1" name="Referenced Color Palette Instance UID"/>
-    <entry group="0028" element="0400" keyword="TransformLabel" vr="LO" vm="1" retired="true" name="Transform Label"/>
-    <entry group="0028" element="0401" keyword="TransformVersionNumber" vr="LO" vm="1" retired="true" name="Transform Version Number"/>
-    <entry group="0028" element="0402" keyword="NumberOfTransformSteps" vr="US" vm="1" retired="true" name="Number of Transform Steps"/>
-    <entry group="0028" element="0403" keyword="SequenceOfCompressedData" vr="LO" vm="1-n" retired="true" name="Sequence of Compressed Data"/>
-    <entry group="0028" element="0404" keyword="DetailsOfCoefficients" vr="AT" vm="1-n" retired="true" name="Details of Coefficients"/>
-    <entry group="0028" element="04x0" keyword="RowsForNthOrderCoefficients" vr="US" vm="1" retired="true" name="Rows For Nth Order Coefficients"/>
-    <entry group="0028" element="04x1" keyword="ColumnsForNthOrderCoefficients" vr="US" vm="1" retired="true" name="Columns For Nth Order Coefficients"/>
-    <entry group="0028" element="04x2" keyword="CoefficientCoding" vr="LO" vm="1-n" retired="true" name="Coefficient Coding"/>
-    <entry group="0028" element="04x3" keyword="CoefficientCodingPointers" vr="AT" vm="1-n" retired="true" name="Coefficient Coding Pointers"/>
-    <entry group="0028" element="0700" keyword="DCTLabel" vr="LO" vm="1" retired="true" name="DCT Label"/>
-    <entry group="0028" element="0701" keyword="DataBlockDescription" vr="CS" vm="1-n" retired="true" name="Data Block Description"/>
-    <entry group="0028" element="0702" keyword="DataBlock" vr="AT" vm="1-n" retired="true" name="Data Block"/>
-    <entry group="0028" element="0710" keyword="NormalizationFactorFormat" vr="US" vm="1" retired="true" name="Normalization Factor Format"/>
-    <entry group="0028" element="0720" keyword="ZonalMapNumberFormat" vr="US" vm="1" retired="true" name="Zonal Map Number Format"/>
-    <entry group="0028" element="0721" keyword="ZonalMapLocation" vr="AT" vm="1-n" retired="true" name="Zonal Map Location"/>
-    <entry group="0028" element="0722" keyword="ZonalMapFormat" vr="US" vm="1" retired="true" name="Zonal Map Format"/>
-    <entry group="0028" element="0730" keyword="AdaptiveMapFormat" vr="US" vm="1" retired="true" name="Adaptive Map Format"/>
-    <entry group="0028" element="0740" keyword="CodeNumberFormat" vr="US" vm="1" retired="true" name="Code Number Format"/>
-    <entry group="0028" element="08x0" keyword="CodeLabel" vr="CS" vm="1-n" retired="true" name="Code Label"/>
-    <entry group="0028" element="08x2" keyword="NumberOfTables" vr="US" vm="1" retired="true" name="Number of Tables"/>
-    <entry group="0028" element="08x3" keyword="CodeTableLocation" vr="AT" vm="1-n" retired="true" name="Code Table Location"/>
-    <entry group="0028" element="08x4" keyword="BitsForCodeWord" vr="US" vm="1" retired="true" name="Bits For Code Word"/>
-    <entry group="0028" element="08x8" keyword="ImageDataLocation" vr="AT" vm="1-n" retired="true" name="Image Data Location"/>
-    <entry group="0028" element="0a02" keyword="PixelSpacingCalibrationType" vr="CS" vm="1" name="Pixel Spacing Calibration Type"/>
-    <entry group="0028" element="0a04" keyword="PixelSpacingCalibrationDescription" vr="LO" vm="1" name="Pixel Spacing Calibration Description"/>
-    <entry group="0028" element="1040" keyword="PixelIntensityRelationship" vr="CS" vm="1" name="Pixel Intensity Relationship"/>
-    <entry group="0028" element="1041" keyword="PixelIntensityRelationshipSign" vr="SS" vm="1" name="Pixel Intensity Relationship Sign"/>
-    <entry group="0028" element="1050" keyword="WindowCenter" vr="DS" vm="1-n" name="Window Center"/>
-    <entry group="0028" element="1051" keyword="WindowWidth" vr="DS" vm="1-n" name="Window Width"/>
-    <entry group="0028" element="1052" keyword="RescaleIntercept" vr="DS" vm="1" name="Rescale Intercept"/>
-    <entry group="0028" element="1053" keyword="RescaleSlope" vr="DS" vm="1" name="Rescale Slope"/>
-    <entry group="0028" element="1054" keyword="RescaleType" vr="LO" vm="1" name="Rescale Type"/>
-    <entry group="0028" element="1055" keyword="WindowCenterWidthExplanation" vr="LO" vm="1-n" name="Window Center & Width Explanation"/>
-    <entry group="0028" element="1056" keyword="VOILUTFunction" vr="CS" vm="1" name="VOI LUT Function"/>
-    <entry group="0028" element="1080" keyword="GrayScale" vr="CS" vm="1" retired="true" name="Gray Scale"/>
-    <entry group="0028" element="1090" keyword="RecommendedViewingMode" vr="CS" vm="1" name="Recommended Viewing Mode"/>
-    <entry group="0028" element="1100" keyword="GrayLookupTableDescriptor" vr="US_SS" vm="3" retired="true" name="Gray Lookup Table Descriptor"/>
-    <entry group="0028" element="1101" keyword="RedPaletteColorLookupTableDescriptor" vr="US_SS" vm="3" name="Red Palette Color Lookup Table Descriptor"/>
-    <entry group="0028" element="1102" keyword="GreenPaletteColorLookupTableDescriptor" vr="US_SS" vm="3" name="Green Palette Color Lookup Table Descriptor"/>
-    <entry group="0028" element="1103" keyword="BluePaletteColorLookupTableDescriptor" vr="US_SS" vm="3" name="Blue Palette Color Lookup Table Descriptor"/>
-    <entry group="0028" element="1104" keyword="AlphaPaletteColorLookupTableDescriptor" vr="US" vm="3" name="Alpha Palette Color Lookup Table Descriptor"/>
-    <entry group="0028" element="1111" keyword="LargeRedPaletteColorLookupTableDescriptor" vr="US_SS" vm="4" retired="true" name="Large Red Palette Color Lookup Table Descriptor"/>
-    <entry group="0028" element="1112" keyword="LargeGreenPaletteColorLookupTableDescriptor" vr="US_SS" vm="4" retired="true" name="Large Green Palette Color Lookup Table Descriptor"/>
-    <entry group="0028" element="1113" keyword="LargeBluePaletteColorLookupTableDescriptor" vr="US_SS" vm="4" retired="true" name="Large Blue Palette Color Lookup Table Descriptor"/>
-    <entry group="0028" element="1199" keyword="PaletteColorLookupTableUID" vr="UI" vm="1" name="Palette Color Lookup Table UID"/>
-    <entry group="0028" element="1200" keyword="GrayLookupTableData" vr="US_SS_OW" vm="1-n" retired="true" name="Gray Lookup Table Data"/>
-    <entry group="0028" element="1201" keyword="RedPaletteColorLookupTableData" vr="OW" vm="1" name="Red Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1202" keyword="GreenPaletteColorLookupTableData" vr="OW" vm="1" name="Green Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1203" keyword="BluePaletteColorLookupTableData" vr="OW" vm="1" name="Blue Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1204" keyword="AlphaPaletteColorLookupTableData" vr="OW" vm="1" name="Alpha Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1211" keyword="LargeRedPaletteColorLookupTableData" vr="OW" vm="1" retired="true" name="Large Red Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1212" keyword="LargeGreenPaletteColorLookupTableData" vr="OW" vm="1" retired="true" name="Large Green Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1213" keyword="LargeBluePaletteColorLookupTableData" vr="OW" vm="1" retired="true" name="Large Blue Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1214" keyword="LargePaletteColorLookupTableUID" vr="UI" vm="1" retired="true" name="Large Palette Color Lookup Table UID"/>
-    <entry group="0028" element="1221" keyword="SegmentedRedPaletteColorLookupTableData" vr="OW" vm="1" name="Segmented Red Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1222" keyword="SegmentedGreenPaletteColorLookupTableData" vr="OW" vm="1" name="Segmented Green Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1223" keyword="SegmentedBluePaletteColorLookupTableData" vr="OW" vm="1" name="Segmented Blue Palette Color Lookup Table Data"/>
-    <entry group="0028" element="1300" keyword="BreastImplantPresent" vr="CS" vm="1" name="Breast Implant Present"/>
-    <entry group="0028" element="1350" keyword="PartialView" vr="CS" vm="1" name="Partial View"/>
-    <entry group="0028" element="1351" keyword="PartialViewDescription" vr="ST" vm="1" name="Partial View Description"/>
-    <entry group="0028" element="1352" keyword="PartialViewCodeSequence" vr="SQ" vm="1" name="Partial View Code Sequence"/>
-    <entry group="0028" element="135a" keyword="SpatialLocationsPreserved" vr="CS" vm="1" name="Spatial Locations Preserved"/>
-    <entry group="0028" element="1401" keyword="DataFrameAssignmentSequence" vr="SQ" vm="1" name="Data Frame Assignment Sequence"/>
-    <entry group="0028" element="1402" keyword="DataPathAssignment" vr="CS" vm="1" name="Data Path Assignment"/>
-    <entry group="0028" element="1403" keyword="BitsMappedToColorLookupTable" vr="US" vm="1" name="Bits Mapped to Color Lookup Table"/>
-    <entry group="0028" element="1404" keyword="BlendingLUT1Sequence" vr="SQ" vm="1" name="Blending LUT 1 Sequence"/>
-    <entry group="0028" element="1405" keyword="BlendingLUT1TransferFunction" vr="CS" vm="1" name="Blending LUT 1 Transfer Function"/>
-    <entry group="0028" element="1406" keyword="BlendingWeightConstant" vr="FD" vm="1" name="Blending Weight Constant"/>
-    <entry group="0028" element="1407" keyword="BlendingLookupTableDescriptor" vr="US" vm="3" name="Blending Lookup Table Descriptor"/>
-    <entry group="0028" element="1408" keyword="BlendingLookupTableData" vr="OW" vm="1" name="Blending Lookup Table Data"/>
-    <entry group="0028" element="140b" keyword="EnhancedPaletteColorLookupTableSequence" vr="SQ" vm="1" name="Enhanced Palette Color Lookup Table Sequence"/>
-    <entry group="0028" element="140c" keyword="BlendingLUT2Sequence" vr="SQ" vm="1" name="Blending LUT 2 Sequence"/>
-    <entry group="0028" element="140d" keyword="BlendingLUT2TransferFunction" vr="CS" vm="1" name="Blending LUT 2 Transfer Function"/>
-    <entry group="0028" element="140e" keyword="DataPathID" vr="CS" vm="1" name="Data Path ID"/>
-    <entry group="0028" element="140f" keyword="RGBLUTTransferFunction" vr="CS" vm="1" name="RGB LUT Transfer Function"/>
-    <entry group="0028" element="1410" keyword="AlphaLUTTransferFunction" vr="CS" vm="1" name="Alpha LUT Transfer Function"/>
-    <entry group="0028" element="2000" keyword="ICCProfile" vr="OB" vm="1" name="ICC Profile"/>
-    <entry group="0028" element="2110" keyword="LossyImageCompression" vr="CS" vm="1" name="Lossy Image Compression"/>
-    <entry group="0028" element="2112" keyword="LossyImageCompressionRatio" vr="DS" vm="1-n" name="Lossy Image Compression Ratio"/>
-    <entry group="0028" element="2114" keyword="LossyImageCompressionMethod" vr="CS" vm="1-n" name="Lossy Image Compression Method"/>
-    <entry group="0028" element="3000" keyword="ModalityLUTSequence" vr="SQ" vm="1" name="Modality LUT Sequence"/>
-    <entry group="0028" element="3002" keyword="LUTDescriptor" vr="US_SS" vm="3" name="LUT Descriptor"/>
-    <entry group="0028" element="3003" keyword="LUTExplanation" vr="LO" vm="1" name="LUT Explanation"/>
-    <entry group="0028" element="3004" keyword="ModalityLUTType" vr="LO" vm="1" name="Modality LUT Type"/>
-    <entry group="0028" element="3006" keyword="LUTData" vr="US_SS_OW" vm="1-n" name="LUT Data"/>
-    <entry group="0028" element="3010" keyword="VOILUTSequence" vr="SQ" vm="1" name="VOI LUT Sequence"/>
-    <entry group="0028" element="3110" keyword="SoftcopyVOILUTSequence" vr="SQ" vm="1" name="Softcopy VOI LUT Sequence"/>
-    <entry group="0028" element="4000" keyword="ImagePresentationComments" vr="LT" vm="1" retired="true" name="Image Presentation Comments"/>
-    <entry group="0028" element="5000" keyword="BiPlaneAcquisitionSequence" vr="SQ" vm="1" retired="true" name="Bi-Plane Acquisition Sequence"/>
-    <entry group="0028" element="6010" keyword="RepresentativeFrameNumber" vr="US" vm="1" name="Representative Frame Number"/>
-    <entry group="0028" element="6020" keyword="FrameNumbersOfInterest" vr="US" vm="1-n" name="Frame Numbers of Interest (FOI)"/>
-    <entry group="0028" element="6022" keyword="FrameOfInterestDescription" vr="LO" vm="1-n" name="Frame of Interest Description"/>
-    <entry group="0028" element="6023" keyword="FrameOfInterestType" vr="CS" vm="1-n" name="Frame of Interest Type"/>
-    <entry group="0028" element="6030" keyword="MaskPointers" vr="US" vm="1-n" retired="true" name="Mask Pointer(s)"/>
-    <entry group="0028" element="6040" keyword="RWavePointer" vr="US" vm="1-n" name="R Wave Pointer"/>
-    <entry group="0028" element="6100" keyword="MaskSubtractionSequence" vr="SQ" vm="1" name="Mask Subtraction Sequence"/>
-    <entry group="0028" element="6101" keyword="MaskOperation" vr="CS" vm="1" name="Mask Operation"/>
-    <entry group="0028" element="6102" keyword="ApplicableFrameRange" vr="US" vm="2-2n" name="Applicable Frame Range"/>
-    <entry group="0028" element="6110" keyword="MaskFrameNumbers" vr="US" vm="1-n" name="Mask Frame Numbers"/>
-    <entry group="0028" element="6112" keyword="ContrastFrameAveraging" vr="US" vm="1" name="Contrast Frame Averaging"/>
-    <entry group="0028" element="6114" keyword="MaskSubPixelShift" vr="FL" vm="2" name="Mask Sub-pixel Shift"/>
-    <entry group="0028" element="6120" keyword="TIDOffset" vr="SS" vm="1" name="TID Offset"/>
-    <entry group="0028" element="6190" keyword="MaskOperationExplanation" vr="ST" vm="1" name="Mask Operation Explanation"/>
-    <entry group="0028" element="7fe0" keyword="PixelDataProviderURL" vr="UT" vm="1" name="Pixel Data Provider URL"/>
-    <entry group="0028" element="9001" keyword="DataPointRows" vr="UL" vm="1" name="Data Point Rows"/>
-    <entry group="0028" element="9002" keyword="DataPointColumns" vr="UL" vm="1" name="Data Point Columns"/>
-    <entry group="0028" element="9003" keyword="SignalDomainColumns" vr="CS" vm="1" name="Signal Domain Columns"/>
-    <entry group="0028" element="9099" keyword="LargestMonochromePixelValue" vr="US" vm="1" retired="true" name="Largest Monochrome Pixel Value"/>
-    <entry group="0028" element="9108" keyword="DataRepresentation" vr="CS" vm="1" name="Data Representation"/>
-    <entry group="0028" element="9110" keyword="PixelMeasuresSequence" vr="SQ" vm="1" name="Pixel Measures Sequence"/>
-    <entry group="0028" element="9132" keyword="FrameVOILUTSequence" vr="SQ" vm="1" name="Frame VOI LUT Sequence"/>
-    <entry group="0028" element="9145" keyword="PixelValueTransformationSequence" vr="SQ" vm="1" name="Pixel Value Transformation Sequence"/>
-    <entry group="0028" element="9235" keyword="SignalDomainRows" vr="CS" vm="1" name="Signal Domain Rows"/>
-    <entry group="0028" element="9411" keyword="DisplayFilterPercentage" vr="FL" vm="1" name="Display Filter Percentage"/>
-    <entry group="0028" element="9415" keyword="FramePixelShiftSequence" vr="SQ" vm="1" name="Frame Pixel Shift Sequence"/>
-    <entry group="0028" element="9416" keyword="SubtractionItemID" vr="US" vm="1" name="Subtraction Item ID"/>
-    <entry group="0028" element="9422" keyword="PixelIntensityRelationshipLUTSequence" vr="SQ" vm="1" name="Pixel Intensity Relationship LUT Sequence"/>
-    <entry group="0028" element="9443" keyword="FramePixelDataPropertiesSequence" vr="SQ" vm="1" name="Frame Pixel Data Properties Sequence"/>
-    <entry group="0028" element="9444" keyword="GeometricalProperties" vr="CS" vm="1" name="Geometrical Properties"/>
-    <entry group="0028" element="9445" keyword="GeometricMaximumDistortion" vr="FL" vm="1" name="Geometric Maximum Distortion"/>
-    <entry group="0028" element="9446" keyword="ImageProcessingApplied" vr="CS" vm="1-n" name="Image Processing Applied"/>
-    <entry group="0028" element="9454" keyword="MaskSelectionMode" vr="CS" vm="1" name="Mask Selection Mode"/>
-    <entry group="0028" element="9474" keyword="LUTFunction" vr="CS" vm="1" name="LUT Function"/>
-    <entry group="0028" element="9478" keyword="MaskVisibilityPercentage" vr="FL" vm="1" name="Mask Visibility Percentage"/>
-    <entry group="0028" element="9501" keyword="PixelShiftSequence" vr="SQ" vm="1" name="Pixel Shift Sequence"/>
-    <entry group="0028" element="9502" keyword="RegionPixelShiftSequence" vr="SQ" vm="1" name="Region Pixel Shift Sequence"/>
-    <entry group="0028" element="9503" keyword="VerticesOfTheRegion" vr="SS" vm="2-2n" name="Vertices of the Region"/>
-    <entry group="0028" element="9505" keyword="MultiFramePresentationSequence" vr="SQ" vm="1" name="Multi-frame Presentation Sequence"/>
-    <entry group="0028" element="9506" keyword="PixelShiftFrameRange" vr="US" vm="2-2n" name="Pixel Shift Frame Range"/>
-    <entry group="0028" element="9507" keyword="LUTFrameRange" vr="US" vm="2-2n" name="LUT Frame Range"/>
-    <entry group="0028" element="9520" keyword="ImageToEquipmentMappingMatrix" vr="DS" vm="16" name="Image to Equipment Mapping Matrix"/>
-    <entry group="0028" element="9537" keyword="EquipmentCoordinateSystemIdentification" vr="CS" vm="1" name="Equipment Coordinate System Identification"/>
-    <entry group="0032" element="000a" keyword="StudyStatusID" vr="CS" vm="1" retired="true" name="Study Status ID"/>
-    <entry group="0032" element="000c" keyword="StudyPriorityID" vr="CS" vm="1" retired="true" name="Study Priority ID"/>
-    <entry group="0032" element="0012" keyword="StudyIDIssuer" vr="LO" vm="1" retired="true" name="Study ID Issuer"/>
-    <entry group="0032" element="0032" keyword="StudyVerifiedDate" vr="DA" vm="1" retired="true" name="Study Verified Date"/>
-    <entry group="0032" element="0033" keyword="StudyVerifiedTime" vr="TM" vm="1" retired="true" name="Study Verified Time"/>
-    <entry group="0032" element="0034" keyword="StudyReadDate" vr="DA" vm="1" retired="true" name="Study Read Date"/>
-    <entry group="0032" element="0035" keyword="StudyReadTime" vr="TM" vm="1" retired="true" name="Study Read Time"/>
-    <entry group="0032" element="1000" keyword="ScheduledStudyStartDate" vr="DA" vm="1" retired="true" name="Scheduled Study Start Date"/>
-    <entry group="0032" element="1001" keyword="ScheduledStudyStartTime" vr="TM" vm="1" retired="true" name="Scheduled Study Start Time"/>
-    <entry group="0032" element="1010" keyword="ScheduledStudyStopDate" vr="DA" vm="1" retired="true" name="Scheduled Study Stop Date"/>
-    <entry group="0032" element="1011" keyword="ScheduledStudyStopTime" vr="TM" vm="1" retired="true" name="Scheduled Study Stop Time"/>
-    <entry group="0032" element="1020" keyword="ScheduledStudyLocation" vr="LO" vm="1" retired="true" name="Scheduled Study Location"/>
-    <entry group="0032" element="1021" keyword="ScheduledStudyLocationAETitle" vr="AE" vm="1-n" retired="true" name="Scheduled Study Location AE Title"/>
-    <entry group="0032" element="1030" keyword="ReasonForStudy" vr="LO" vm="1" retired="true" name="Reason for Study"/>
-    <entry group="0032" element="1031" keyword="RequestingPhysicianIdentificationSequence" vr="SQ" vm="1" name="Requesting Physician Identification Sequence"/>
-    <entry group="0032" element="1032" keyword="RequestingPhysician" vr="PN" vm="1" name="Requesting Physician"/>
-    <entry group="0032" element="1033" keyword="RequestingService" vr="LO" vm="1" name="Requesting Service"/>
-    <entry group="0032" element="1034" keyword="RequestingServiceCodeSequence" vr="SQ" vm="1" name="Requesting Service Code Sequence"/>
-    <entry group="0032" element="1040" keyword="StudyArrivalDate" vr="DA" vm="1" retired="true" name="Study Arrival Date"/>
-    <entry group="0032" element="1041" keyword="StudyArrivalTime" vr="TM" vm="1" retired="true" name="Study Arrival Time"/>
-    <entry group="0032" element="1050" keyword="StudyCompletionDate" vr="DA" vm="1" retired="true" name="Study Completion Date"/>
-    <entry group="0032" element="1051" keyword="StudyCompletionTime" vr="TM" vm="1" retired="true" name="Study Completion Time"/>
-    <entry group="0032" element="1055" keyword="StudyComponentStatusID" vr="CS" vm="1" retired="true" name="Study Component Status ID"/>
-    <entry group="0032" element="1060" keyword="RequestedProcedureDescription" vr="LO" vm="1" name="Requested Procedure Description"/>
-    <entry group="0032" element="1064" keyword="RequestedProcedureCodeSequence" vr="SQ" vm="1" name="Requested Procedure Code Sequence"/>
-    <entry group="0032" element="1070" keyword="RequestedContrastAgent" vr="LO" vm="1" name="Requested Contrast Agent"/>
-    <entry group="0032" element="4000" keyword="StudyComments" vr="LT" vm="1" retired="true" name="Study Comments"/>
-    <entry group="0038" element="0004" keyword="ReferencedPatientAliasSequence" vr="SQ" vm="1" name="Referenced Patient Alias Sequence"/>
-    <entry group="0038" element="0008" keyword="VisitStatusID" vr="CS" vm="1" name="Visit Status ID"/>
-    <entry group="0038" element="0010" keyword="AdmissionID" vr="LO" vm="1" name="Admission ID"/>
-    <entry group="0038" element="0011" keyword="IssuerOfAdmissionID" vr="LO" vm="1" retired="true" name="Issuer of Admission ID"/>
-    <entry group="0038" element="0014" keyword="IssuerOfAdmissionIDSequence" vr="SQ" vm="1" name="Issuer of Admission ID Sequence"/>
-    <entry group="0038" element="0016" keyword="RouteOfAdmissions" vr="LO" vm="1" name="Route of Admissions"/>
-    <entry group="0038" element="001a" keyword="ScheduledAdmissionDate" vr="DA" vm="1" retired="true" name="Scheduled Admission Date"/>
-    <entry group="0038" element="001b" keyword="ScheduledAdmissionTime" vr="TM" vm="1" retired="true" name="Scheduled Admission Time"/>
-    <entry group="0038" element="001c" keyword="ScheduledDischargeDate" vr="DA" vm="1" retired="true" name="Scheduled Discharge Date"/>
-    <entry group="0038" element="001d" keyword="ScheduledDischargeTime" vr="TM" vm="1" retired="true" name="Scheduled Discharge Time"/>
-    <entry group="0038" element="001e" keyword="ScheduledPatientInstitutionResidence" vr="LO" vm="1" retired="true" name="Scheduled Patient Institution Residence"/>
-    <entry group="0038" element="0020" keyword="AdmittingDate" vr="DA" vm="1" name="Admitting Date"/>
-    <entry group="0038" element="0021" keyword="AdmittingTime" vr="TM" vm="1" name="Admitting Time"/>
-    <entry group="0038" element="0030" keyword="DischargeDate" vr="DA" vm="1" retired="true" name="Discharge Date"/>
-    <entry group="0038" element="0032" keyword="DischargeTime" vr="TM" vm="1" retired="true" name="Discharge Time"/>
-    <entry group="0038" element="0040" keyword="DischargeDiagnosisDescription" vr="LO" vm="1" retired="true" name="Discharge Diagnosis Description"/>
-    <entry group="0038" element="0044" keyword="DischargeDiagnosisCodeSequence" vr="SQ" vm="1" retired="true" name="Discharge Diagnosis Code Sequence"/>
-    <entry group="0038" element="0050" keyword="SpecialNeeds" vr="LO" vm="1" name="Special Needs"/>
-    <entry group="0038" element="0060" keyword="ServiceEpisodeID" vr="LO" vm="1" name="Service Episode ID"/>
-    <entry group="0038" element="0061" keyword="IssuerOfServiceEpisodeID" vr="LO" vm="1" retired="true" name="Issuer of Service Episode ID"/>
-    <entry group="0038" element="0062" keyword="ServiceEpisodeDescription" vr="LO" vm="1" name="Service Episode Description"/>
-    <entry group="0038" element="0064" keyword="IssuerOfServiceEpisodeIDSequence" vr="SQ" vm="1" name="Issuer of Service Episode ID Sequence"/>
-    <entry group="0038" element="0100" keyword="PertinentDocumentsSequence" vr="SQ" vm="1" name="Pertinent Documents Sequence"/>
-    <entry group="0038" element="0300" keyword="CurrentPatientLocation" vr="LO" vm="1" name="Current Patient Location"/>
-    <entry group="0038" element="0400" keyword="PatientInstitutionResidence" vr="LO" vm="1" name="Patient's Institution Residence"/>
-    <entry group="0038" element="0500" keyword="PatientState" vr="LO" vm="1" name="Patient State"/>
-    <entry group="0038" element="0502" keyword="PatientClinicalTrialParticipationSequence" vr="SQ" vm="1" name="Patient Clinical Trial Participation Sequence"/>
-    <entry group="0038" element="4000" keyword="VisitComments" vr="LT" vm="1" name="Visit Comments"/>
-    <entry group="003a" element="0004" keyword="WaveformOriginality" vr="CS" vm="1" name="Waveform Originality"/>
-    <entry group="003a" element="0005" keyword="NumberOfWaveformChannels" vr="US" vm="1" name="Number of Waveform Channels"/>
-    <entry group="003a" element="0010" keyword="NumberOfWaveformSamples" vr="UL" vm="1" name="Number of Waveform Samples"/>
-    <entry group="003a" element="001a" keyword="SamplingFrequency" vr="DS" vm="1" name="Sampling Frequency"/>
-    <entry group="003a" element="0020" keyword="MultiplexGroupLabel" vr="SH" vm="1" name="Multiplex Group Label"/>
-    <entry group="003a" element="0200" keyword="ChannelDefinitionSequence" vr="SQ" vm="1" name="Channel Definition Sequence"/>
-    <entry group="003a" element="0202" keyword="WaveformChannelNumber" vr="IS" vm="1" name="Waveform Channel Number"/>
-    <entry group="003a" element="0203" keyword="ChannelLabel" vr="SH" vm="1" name="Channel Label"/>
-    <entry group="003a" element="0205" keyword="ChannelStatus" vr="CS" vm="1-n" name="Channel Status"/>
-    <entry group="003a" element="0208" keyword="ChannelSourceSequence" vr="SQ" vm="1" name="Channel Source Sequence"/>
-    <entry group="003a" element="0209" keyword="ChannelSourceModifiersSequence" vr="SQ" vm="1" name="Channel Source Modifiers Sequence"/>
-    <entry group="003a" element="020a" keyword="SourceWaveformSequence" vr="SQ" vm="1" name="Source Waveform Sequence"/>
-    <entry group="003a" element="020c" keyword="ChannelDerivationDescription" vr="LO" vm="1" name="Channel Derivation Description"/>
-    <entry group="003a" element="0210" keyword="ChannelSensitivity" vr="DS" vm="1" name="Channel Sensitivity"/>
-    <entry group="003a" element="0211" keyword="ChannelSensitivityUnitsSequence" vr="SQ" vm="1" name="Channel Sensitivity Units Sequence"/>
-    <entry group="003a" element="0212" keyword="ChannelSensitivityCorrectionFactor" vr="DS" vm="1" name="Channel Sensitivity Correction Factor"/>
-    <entry group="003a" element="0213" keyword="ChannelBaseline" vr="DS" vm="1" name="Channel Baseline"/>
-    <entry group="003a" element="0214" keyword="ChannelTimeSkew" vr="DS" vm="1" name="Channel Time Skew"/>
-    <entry group="003a" element="0215" keyword="ChannelSampleSkew" vr="DS" vm="1" name="Channel Sample Skew"/>
-    <entry group="003a" element="0218" keyword="ChannelOffset" vr="DS" vm="1" name="Channel Offset"/>
-    <entry group="003a" element="021a" keyword="WaveformBitsStored" vr="US" vm="1" name="Waveform Bits Stored"/>
-    <entry group="003a" element="0220" keyword="FilterLowFrequency" vr="DS" vm="1" name="Filter Low Frequency"/>
-    <entry group="003a" element="0221" keyword="FilterHighFrequency" vr="DS" vm="1" name="Filter High Frequency"/>
-    <entry group="003a" element="0222" keyword="NotchFilterFrequency" vr="DS" vm="1" name="Notch Filter Frequency"/>
-    <entry group="003a" element="0223" keyword="NotchFilterBandwidth" vr="DS" vm="1" name="Notch Filter Bandwidth"/>
-    <entry group="003a" element="0230" keyword="WaveformDataDisplayScale" vr="FL" vm="1" name="Waveform Data Display Scale"/>
-    <entry group="003a" element="0231" keyword="WaveformDisplayBackgroundCIELabValue" vr="US" vm="3" name="Waveform Display Background CIELab Value"/>
-    <entry group="003a" element="0240" keyword="WaveformPresentationGroupSequence" vr="SQ" vm="1" name="Waveform Presentation Group Sequence"/>
-    <entry group="003a" element="0241" keyword="PresentationGroupNumber" vr="US" vm="1" name="Presentation Group Number"/>
-    <entry group="003a" element="0242" keyword="ChannelDisplaySequence" vr="SQ" vm="1" name="Channel Display Sequence"/>
-    <entry group="003a" element="0244" keyword="ChannelRecommendedDisplayCIELabValue" vr="US" vm="3" name="Channel Recommended Display CIELab Value"/>
-    <entry group="003a" element="0245" keyword="ChannelPosition" vr="FL" vm="1" name="Channel Position"/>
-    <entry group="003a" element="0246" keyword="DisplayShadingFlag" vr="CS" vm="1" name="Display Shading Flag"/>
-    <entry group="003a" element="0247" keyword="FractionalChannelDisplayScale" vr="FL" vm="1" name="Fractional Channel Display Scale"/>
-    <entry group="003a" element="0248" keyword="AbsoluteChannelDisplayScale" vr="FL" vm="1" name="Absolute Channel Display Scale"/>
-    <entry group="003a" element="0300" keyword="MultiplexedAudioChannelsDescriptionCodeSequence" vr="SQ" vm="1" name="Multiplexed Audio Channels Description Code Sequence"/>
-    <entry group="003a" element="0301" keyword="ChannelIdentificationCode" vr="IS" vm="1" name="Channel Identification Code"/>
-    <entry group="003a" element="0302" keyword="ChannelMode" vr="CS" vm="1" name="Channel Mode"/>
-    <entry group="0040" element="0001" keyword="ScheduledStationAETitle" vr="AE" vm="1-n" name="Scheduled Station AE Title"/>
-    <entry group="0040" element="0002" keyword="ScheduledProcedureStepStartDate" vr="DA" vm="1" name="Scheduled Procedure Step Start Date"/>
-    <entry group="0040" element="0003" keyword="ScheduledProcedureStepStartTime" vr="TM" vm="1" name="Scheduled Procedure Step Start Time"/>
-    <entry group="0040" element="0004" keyword="ScheduledProcedureStepEndDate" vr="DA" vm="1" name="Scheduled Procedure Step End Date"/>
-    <entry group="0040" element="0005" keyword="ScheduledProcedureStepEndTime" vr="TM" vm="1" name="Scheduled Procedure Step End Time"/>
-    <entry group="0040" element="0006" keyword="ScheduledPerformingPhysicianName" vr="PN" vm="1" name="Scheduled Performing Physician's Name"/>
-    <entry group="0040" element="0007" keyword="ScheduledProcedureStepDescription" vr="LO" vm="1" name="Scheduled Procedure Step Description"/>
-    <entry group="0040" element="0008" keyword="ScheduledProtocolCodeSequence" vr="SQ" vm="1" name="Scheduled Protocol Code Sequence"/>
-    <entry group="0040" element="0009" keyword="ScheduledProcedureStepID" vr="SH" vm="1" name="Scheduled Procedure Step ID"/>
-    <entry group="0040" element="000a" keyword="StageCodeSequence" vr="SQ" vm="1" name="Stage Code Sequence"/>
-    <entry group="0040" element="000b" keyword="ScheduledPerformingPhysicianIdentificationSequence" vr="SQ" vm="1" name="Scheduled Performing Physician Identification Sequence"/>
-    <entry group="0040" element="0010" keyword="ScheduledStationName" vr="SH" vm="1-n" name="Scheduled Station Name"/>
-    <entry group="0040" element="0011" keyword="ScheduledProcedureStepLocation" vr="SH" vm="1" name="Scheduled Procedure Step Location"/>
-    <entry group="0040" element="0012" keyword="PreMedication" vr="LO" vm="1" name="Pre-Medication"/>
-    <entry group="0040" element="0020" keyword="ScheduledProcedureStepStatus" vr="CS" vm="1" name="Scheduled Procedure Step Status"/>
-    <entry group="0040" element="0026" keyword="OrderPlacerIdentifierSequence" vr="SQ" vm="1" name="Order Placer Identifier Sequence"/>
-    <entry group="0040" element="0027" keyword="OrderFillerIdentifierSequence" vr="SQ" vm="1" name="Order Filler Identifier Sequence"/>
-    <entry group="0040" element="0031" keyword="LocalNamespaceEntityID" vr="UT" vm="1" name="Local Namespace Entity ID"/>
-    <entry group="0040" element="0032" keyword="UniversalEntityID" vr="UT" vm="1" name="Universal Entity ID"/>
-    <entry group="0040" element="0033" keyword="UniversalEntityIDType" vr="CS" vm="1" name="Universal Entity ID Type"/>
-    <entry group="0040" element="0035" keyword="IdentifierTypeCode" vr="CS" vm="1" name="Identifier Type Code"/>
-    <entry group="0040" element="0036" keyword="AssigningFacilitySequence" vr="SQ" vm="1" name="Assigning Facility Sequence"/>
-    <entry group="0040" element="0039" keyword="AssigningJurisdictionCodeSequence" vr="SQ" vm="1" name="Assigning Jurisdiction Code Sequence"/>
-    <entry group="0040" element="003a" keyword="AssigningAgencyOrDepartmentCodeSequence" vr="SQ" vm="1" name="Assigning Agency or Department Code Sequence"/>
-    <entry group="0040" element="0100" keyword="ScheduledProcedureStepSequence" vr="SQ" vm="1" name="Scheduled Procedure Step Sequence"/>
-    <entry group="0040" element="0220" keyword="ReferencedNonImageCompositeSOPInstanceSequence" vr="SQ" vm="1" name="Referenced Non-Image Composite SOP Instance Sequence"/>
-    <entry group="0040" element="0241" keyword="PerformedStationAETitle" vr="AE" vm="1" name="Performed Station AE Title"/>
-    <entry group="0040" element="0242" keyword="PerformedStationName" vr="SH" vm="1" name="Performed Station Name"/>
-    <entry group="0040" element="0243" keyword="PerformedLocation" vr="SH" vm="1" name="Performed Location"/>
-    <entry group="0040" element="0244" keyword="PerformedProcedureStepStartDate" vr="DA" vm="1" name="Performed Procedure Step Start Date"/>
-    <entry group="0040" element="0245" keyword="PerformedProcedureStepStartTime" vr="TM" vm="1" name="Performed Procedure Step Start Time"/>
-    <entry group="0040" element="0250" keyword="PerformedProcedureStepEndDate" vr="DA" vm="1" name="Performed Procedure Step End Date"/>
-    <entry group="0040" element="0251" keyword="PerformedProcedureStepEndTime" vr="TM" vm="1" name="Performed Procedure Step End Time"/>
-    <entry group="0040" element="0252" keyword="PerformedProcedureStepStatus" vr="CS" vm="1" name="Performed Procedure Step Status"/>
-    <entry group="0040" element="0253" keyword="PerformedProcedureStepID" vr="SH" vm="1" name="Performed Procedure Step ID"/>
-    <entry group="0040" element="0254" keyword="PerformedProcedureStepDescription" vr="LO" vm="1" name="Performed Procedure Step Description"/>
-    <entry group="0040" element="0255" keyword="PerformedProcedureTypeDescription" vr="LO" vm="1" name="Performed Procedure Type Description"/>
-    <entry group="0040" element="0260" keyword="PerformedProtocolCodeSequence" vr="SQ" vm="1" name="Performed Protocol Code Sequence"/>
-    <entry group="0040" element="0261" keyword="PerformedProtocolType" vr="CS" vm="1" name="Performed Protocol Type"/>
-    <entry group="0040" element="0270" keyword="ScheduledStepAttributesSequence" vr="SQ" vm="1" name="Scheduled Step Attributes Sequence"/>
-    <entry group="0040" element="0275" keyword="RequestAttributesSequence" vr="SQ" vm="1" name="Request Attributes Sequence"/>
-    <entry group="0040" element="0280" keyword="CommentsOnThePerformedProcedureStep" vr="ST" vm="1" name="Comments on the Performed Procedure Step"/>
-    <entry group="0040" element="0281" keyword="PerformedProcedureStepDiscontinuationReasonCodeSequence" vr="SQ" vm="1" name="Performed Procedure Step Discontinuation Reason Code Sequence"/>
-    <entry group="0040" element="0293" keyword="QuantitySequence" vr="SQ" vm="1" name="Quantity Sequence"/>
-    <entry group="0040" element="0294" keyword="Quantity" vr="DS" vm="1" name="Quantity"/>
-    <entry group="0040" element="0295" keyword="MeasuringUnitsSequence" vr="SQ" vm="1" name="Measuring Units Sequence"/>
-    <entry group="0040" element="0296" keyword="BillingItemSequence" vr="SQ" vm="1" name="Billing Item Sequence"/>
-    <entry group="0040" element="0300" keyword="TotalTimeOfFluoroscopy" vr="US" vm="1" name="Total Time of Fluoroscopy"/>
-    <entry group="0040" element="0301" keyword="TotalNumberOfExposures" vr="US" vm="1" name="Total Number of Exposures"/>
-    <entry group="0040" element="0302" keyword="EntranceDose" vr="US" vm="1" name="Entrance Dose"/>
-    <entry group="0040" element="0303" keyword="ExposedArea" vr="US" vm="1-2" name="Exposed Area"/>
-    <entry group="0040" element="0306" keyword="DistanceSourceToEntrance" vr="DS" vm="1" name="Distance Source to Entrance"/>
-    <entry group="0040" element="0307" keyword="DistanceSourceToSupport" vr="DS" vm="1" retired="true" name="Distance Source to Support"/>
-    <entry group="0040" element="030e" keyword="ExposureDoseSequence" vr="SQ" vm="1" name="Exposure Dose Sequence"/>
-    <entry group="0040" element="0310" keyword="CommentsOnRadiationDose" vr="ST" vm="1" name="Comments on Radiation Dose"/>
-    <entry group="0040" element="0312" keyword="XRayOutput" vr="DS" vm="1" name="X-Ray Output"/>
-    <entry group="0040" element="0314" keyword="HalfValueLayer" vr="DS" vm="1" name="Half Value Layer"/>
-    <entry group="0040" element="0316" keyword="OrganDose" vr="DS" vm="1" name="Organ Dose"/>
-    <entry group="0040" element="0318" keyword="OrganExposed" vr="CS" vm="1" name="Organ Exposed"/>
-    <entry group="0040" element="0320" keyword="BillingProcedureStepSequence" vr="SQ" vm="1" name="Billing Procedure Step Sequence"/>
-    <entry group="0040" element="0321" keyword="FilmConsumptionSequence" vr="SQ" vm="1" name="Film Consumption Sequence"/>
-    <entry group="0040" element="0324" keyword="BillingSuppliesAndDevicesSequence" vr="SQ" vm="1" name="Billing Supplies and Devices Sequence"/>
-    <entry group="0040" element="0330" keyword="ReferencedProcedureStepSequence" vr="SQ" vm="1" retired="true" name="Referenced Procedure Step Sequence"/>
-    <entry group="0040" element="0340" keyword="PerformedSeriesSequence" vr="SQ" vm="1" name="Performed Series Sequence"/>
-    <entry group="0040" element="0400" keyword="CommentsOnTheScheduledProcedureStep" vr="LT" vm="1" name="Comments on the Scheduled Procedure Step"/>
-    <entry group="0040" element="0440" keyword="ProtocolContextSequence" vr="SQ" vm="1" name="Protocol Context Sequence"/>
-    <entry group="0040" element="0441" keyword="ContentItemModifierSequence" vr="SQ" vm="1" name="Content Item Modifier Sequence"/>
-    <entry group="0040" element="0500" keyword="ScheduledSpecimenSequence" vr="SQ" vm="1" name="Scheduled Specimen Sequence"/>
-    <entry group="0040" element="050a" keyword="SpecimenAccessionNumber" vr="LO" vm="1" retired="true" name="Specimen Accession Number"/>
-    <entry group="0040" element="0512" keyword="ContainerIdentifier" vr="LO" vm="1" name="Container Identifier"/>
-    <entry group="0040" element="0513" keyword="IssuerOfTheContainerIdentifierSequence" vr="SQ" vm="1" name="Issuer of the Container Identifier Sequence"/>
-    <entry group="0040" element="0515" keyword="AlternateContainerIdentifierSequence" vr="SQ" vm="1" name="Alternate Container Identifier Sequence"/>
-    <entry group="0040" element="0518" keyword="ContainerTypeCodeSequence" vr="SQ" vm="1" name="Container Type Code Sequence"/>
-    <entry group="0040" element="051a" keyword="ContainerDescription" vr="LO" vm="1" name="Container Description"/>
-    <entry group="0040" element="0520" keyword="ContainerComponentSequence" vr="SQ" vm="1" name="Container Component Sequence"/>
-    <entry group="0040" element="0550" keyword="SpecimenSequence" vr="SQ" vm="1" retired="true" name="Specimen Sequence"/>
-    <entry group="0040" element="0551" keyword="SpecimenIdentifier" vr="LO" vm="1" name="Specimen Identifier"/>
-    <entry group="0040" element="0552" keyword="SpecimenDescriptionSequenceTrial" vr="SQ" vm="1" retired="true" name="Specimen Description Sequence (Trial)"/>
-    <entry group="0040" element="0553" keyword="SpecimenDescriptionTrial" vr="ST" vm="1" retired="true" name="Specimen Description (Trial)"/>
-    <entry group="0040" element="0554" keyword="SpecimenUID" vr="UI" vm="1" name="Specimen UID"/>
-    <entry group="0040" element="0555" keyword="AcquisitionContextSequence" vr="SQ" vm="1" name="Acquisition Context Sequence"/>
-    <entry group="0040" element="0556" keyword="AcquisitionContextDescription" vr="ST" vm="1" name="Acquisition Context Description"/>
-    <entry group="0040" element="059a" keyword="SpecimenTypeCodeSequence" vr="SQ" vm="1" name="Specimen Type Code Sequence"/>
-    <entry group="0040" element="0560" keyword="SpecimenDescriptionSequence" vr="SQ" vm="1" name="Specimen Description Sequence"/>
-    <entry group="0040" element="0562" keyword="IssuerOfTheSpecimenIdentifierSequence" vr="SQ" vm="1" name="Issuer of the Specimen Identifier Sequence"/>
-    <entry group="0040" element="0600" keyword="SpecimenShortDescription" vr="LO" vm="1" name="Specimen Short Description"/>
-    <entry group="0040" element="0602" keyword="SpecimenDetailedDescription" vr="UT" vm="1" name="Specimen Detailed Description"/>
-    <entry group="0040" element="0610" keyword="SpecimenPreparationSequence" vr="SQ" vm="1" name="Specimen Preparation Sequence"/>
-    <entry group="0040" element="0612" keyword="SpecimenPreparationStepContentItemSequence" vr="SQ" vm="1" name="Specimen Preparation Step Content Item Sequence"/>
-    <entry group="0040" element="0620" keyword="SpecimenLocalizationContentItemSequence" vr="SQ" vm="1" name="Specimen Localization Content Item Sequence"/>
-    <entry group="0040" element="06fa" keyword="SlideIdentifier" vr="LO" vm="1" retired="true" name="Slide Identifier"/>
-    <entry group="0040" element="071a" keyword="ImageCenterPointCoordinatesSequence" vr="SQ" vm="1" name="Image Center Point Coordinates Sequence"/>
-    <entry group="0040" element="072a" keyword="XOffsetInSlideCoordinateSystem" vr="DS" vm="1" name="X Offset in Slide Coordinate System"/>
-    <entry group="0040" element="073a" keyword="YOffsetInSlideCoordinateSystem" vr="DS" vm="1" name="Y Offset in Slide Coordinate System"/>
-    <entry group="0040" element="074a" keyword="ZOffsetInSlideCoordinateSystem" vr="DS" vm="1" name="Z Offset in Slide Coordinate System"/>
-    <entry group="0040" element="08d8" keyword="PixelSpacingSequence" vr="SQ" vm="1" retired="true" name="Pixel Spacing Sequence"/>
-    <entry group="0040" element="08da" keyword="CoordinateSystemAxisCodeSequence" vr="SQ" vm="1" retired="true" name="Coordinate System Axis Code Sequence"/>
-    <entry group="0040" element="08ea" keyword="MeasurementUnitsCodeSequence" vr="SQ" vm="1" name="Measurement Units Code Sequence"/>
-    <entry group="0040" element="09f8" keyword="VitalStainCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Vital Stain Code Sequence (Trial)"/>
-    <entry group="0040" element="1001" keyword="RequestedProcedureID" vr="SH" vm="1" name="Requested Procedure ID"/>
-    <entry group="0040" element="1002" keyword="ReasonForTheRequestedProcedure" vr="LO" vm="1" name="Reason for the Requested Procedure"/>
-    <entry group="0040" element="1003" keyword="RequestedProcedurePriority" vr="SH" vm="1" name="Requested Procedure Priority"/>
-    <entry group="0040" element="1004" keyword="PatientTransportArrangements" vr="LO" vm="1" name="Patient Transport Arrangements"/>
-    <entry group="0040" element="1005" keyword="RequestedProcedureLocation" vr="LO" vm="1" name="Requested Procedure Location"/>
-    <entry group="0040" element="1006" keyword="PlacerOrderNumberProcedure" vr="SH" vm="1" retired="true" name="Placer Order Number / Procedure"/>
-    <entry group="0040" element="1007" keyword="FillerOrderNumberProcedure" vr="SH" vm="1" retired="true" name="Filler Order Number / Procedure"/>
-    <entry group="0040" element="1008" keyword="ConfidentialityCode" vr="LO" vm="1" name="Confidentiality Code"/>
-    <entry group="0040" element="1009" keyword="ReportingPriority" vr="SH" vm="1" name="Reporting Priority"/>
-    <entry group="0040" element="100a" keyword="ReasonForRequestedProcedureCodeSequence" vr="SQ" vm="1" name="Reason for Requested Procedure Code Sequence"/>
-    <entry group="0040" element="1010" keyword="NamesOfIntendedRecipientsOfResults" vr="PN" vm="1-n" name="Names of Intended Recipients of Results"/>
-    <entry group="0040" element="1011" keyword="IntendedRecipientsOfResultsIdentificationSequence" vr="SQ" vm="1" name="Intended Recipients of Results Identification Sequence"/>
-    <entry group="0040" element="1012" keyword="ReasonForPerformedProcedureCodeSequence" vr="SQ" vm="1" name="Reason For Performed Procedure Code Sequence"/>
-    <entry group="0040" element="1060" keyword="RequestedProcedureDescriptionTrial" vr="LO" vm="1" retired="true" name="Requested Procedure Description (Trial)"/>
-    <entry group="0040" element="1101" keyword="PersonIdentificationCodeSequence" vr="SQ" vm="1" name="Person Identification Code Sequence"/>
-    <entry group="0040" element="1102" keyword="PersonAddress" vr="ST" vm="1" name="Person's Address"/>
-    <entry group="0040" element="1103" keyword="PersonTelephoneNumbers" vr="LO" vm="1-n" name="Person's Telephone Numbers"/>
-    <entry group="0040" element="1400" keyword="RequestedProcedureComments" vr="LT" vm="1" name="Requested Procedure Comments"/>
-    <entry group="0040" element="2001" keyword="ReasonForTheImagingServiceRequest" vr="LO" vm="1" retired="true" name="Reason for the Imaging Service Request"/>
-    <entry group="0040" element="2004" keyword="IssueDateOfImagingServiceRequest" vr="DA" vm="1" name="Issue Date of Imaging Service Request"/>
-    <entry group="0040" element="2005" keyword="IssueTimeOfImagingServiceRequest" vr="TM" vm="1" name="Issue Time of Imaging Service Request"/>
-    <entry group="0040" element="2006" keyword="PlacerOrderNumberImagingServiceRequestRetired" vr="SH" vm="1" retired="true" name="Placer Order Number / Imaging Service Request (Retired)"/>
-    <entry group="0040" element="2007" keyword="FillerOrderNumberImagingServiceRequestRetired" vr="SH" vm="1" retired="true" name="Filler Order Number / Imaging Service Request (Retired)"/>
-    <entry group="0040" element="2008" keyword="OrderEnteredBy" vr="PN" vm="1" name="Order Entered By"/>
-    <entry group="0040" element="2009" keyword="OrderEntererLocation" vr="SH" vm="1" name="Order Enterer's Location"/>
-    <entry group="0040" element="2010" keyword="OrderCallbackPhoneNumber" vr="SH" vm="1" name="Order Callback Phone Number"/>
-    <entry group="0040" element="2016" keyword="PlacerOrderNumberImagingServiceRequest" vr="LO" vm="1" name="Placer Order Number / Imaging Service Request"/>
-    <entry group="0040" element="2017" keyword="FillerOrderNumberImagingServiceRequest" vr="LO" vm="1" name="Filler Order Number / Imaging Service Request"/>
-    <entry group="0040" element="2400" keyword="ImagingServiceRequestComments" vr="LT" vm="1" name="Imaging Service Request Comments"/>
-    <entry group="0040" element="3001" keyword="ConfidentialityConstraintOnPatientDataDescription" vr="LO" vm="1" name="Confidentiality Constraint on Patient Data Description"/>
-    <entry group="0040" element="4001" keyword="GeneralPurposeScheduledProcedureStepStatus" vr="CS" vm="1" name="General Purpose Scheduled Procedure Step Status"/>
-    <entry group="0040" element="4002" keyword="GeneralPurposePerformedProcedureStepStatus" vr="CS" vm="1" name="General Purpose Performed Procedure Step Status"/>
-    <entry group="0040" element="4003" keyword="GeneralPurposeScheduledProcedureStepPriority" vr="CS" vm="1" name="General Purpose Scheduled Procedure Step Priority"/>
-    <entry group="0040" element="4004" keyword="ScheduledProcessingApplicationsCodeSequence" vr="SQ" vm="1" name="Scheduled Processing Applications Code Sequence"/>
-    <entry group="0040" element="4005" keyword="ScheduledProcedureStepStartDateTime" vr="DT" vm="1" name="Scheduled Procedure Step Start DateTime"/>
-    <entry group="0040" element="4006" keyword="MultipleCopiesFlag" vr="CS" vm="1" name="Multiple Copies Flag"/>
-    <entry group="0040" element="4007" keyword="PerformedProcessingApplicationsCodeSequence" vr="SQ" vm="1" name="Performed Processing Applications Code Sequence"/>
-    <entry group="0040" element="4009" keyword="HumanPerformerCodeSequence" vr="SQ" vm="1" name="Human Performer Code Sequence"/>
-    <entry group="0040" element="4010" keyword="ScheduledProcedureStepModificationDateTime" vr="DT" vm="1" name="Scheduled Procedure Step Modification Date Time"/>
-    <entry group="0040" element="4011" keyword="ExpectedCompletionDateTime" vr="DT" vm="1" name="Expected Completion Date Time"/>
-    <entry group="0040" element="4015" keyword="ResultingGeneralPurposePerformedProcedureStepsSequence" vr="SQ" vm="1" name="Resulting General Purpose Performed Procedure Steps Sequence"/>
-    <entry group="0040" element="4016" keyword="ReferencedGeneralPurposeScheduledProcedureStepSequence" vr="SQ" vm="1" name="Referenced General Purpose Scheduled Procedure Step Sequence"/>
-    <entry group="0040" element="4018" keyword="ScheduledWorkitemCodeSequence" vr="SQ" vm="1" name="Scheduled Workitem Code Sequence"/>
-    <entry group="0040" element="4019" keyword="PerformedWorkitemCodeSequence" vr="SQ" vm="1" name="Performed Workitem Code Sequence"/>
-    <entry group="0040" element="4020" keyword="InputAvailabilityFlag" vr="CS" vm="1" name="Input Availability Flag"/>
-    <entry group="0040" element="4021" keyword="InputInformationSequence" vr="SQ" vm="1" name="Input Information Sequence"/>
-    <entry group="0040" element="4022" keyword="RelevantInformationSequence" vr="SQ" vm="1" name="Relevant Information Sequence"/>
-    <entry group="0040" element="4023" keyword="ReferencedGeneralPurposeScheduledProcedureStepTransactionUID" vr="UI" vm="1" name="Referenced General Purpose Scheduled Procedure Step Transaction UID"/>
-    <entry group="0040" element="4025" keyword="ScheduledStationNameCodeSequence" vr="SQ" vm="1" name="Scheduled Station Name Code Sequence"/>
-    <entry group="0040" element="4026" keyword="ScheduledStationClassCodeSequence" vr="SQ" vm="1" name="Scheduled Station Class Code Sequence"/>
-    <entry group="0040" element="4027" keyword="ScheduledStationGeographicLocationCodeSequence" vr="SQ" vm="1" name="Scheduled Station Geographic Location Code Sequence"/>
-    <entry group="0040" element="4028" keyword="PerformedStationNameCodeSequence" vr="SQ" vm="1" name="Performed Station Name Code Sequence"/>
-    <entry group="0040" element="4029" keyword="PerformedStationClassCodeSequence" vr="SQ" vm="1" name="Performed Station Class Code Sequence"/>
-    <entry group="0040" element="4030" keyword="PerformedStationGeographicLocationCodeSequence" vr="SQ" vm="1" name="Performed Station Geographic Location Code Sequence"/>
-    <entry group="0040" element="4031" keyword="RequestedSubsequentWorkitemCodeSequence" vr="SQ" vm="1" name="Requested Subsequent Workitem Code Sequence"/>
-    <entry group="0040" element="4032" keyword="NonDICOMOutputCodeSequence" vr="SQ" vm="1" name="Non-DICOM Output Code Sequence"/>
-    <entry group="0040" element="4033" keyword="OutputInformationSequence" vr="SQ" vm="1" name="Output Information Sequence"/>
-    <entry group="0040" element="4034" keyword="ScheduledHumanPerformersSequence" vr="SQ" vm="1" name="Scheduled Human Performers Sequence"/>
-    <entry group="0040" element="4035" keyword="ActualHumanPerformersSequence" vr="SQ" vm="1" name="Actual Human Performers Sequence"/>
-    <entry group="0040" element="4036" keyword="HumanPerformerOrganization" vr="LO" vm="1" name="Human Performer's Organization"/>
-    <entry group="0040" element="4037" keyword="HumanPerformerName" vr="PN" vm="1" name="Human Performer's Name"/>
-    <entry group="0040" element="4040" keyword="RawDataHandling" vr="CS" vm="1" name="Raw Data Handling"/>
-    <entry group="0040" element="4041" keyword="InputReadinessState" vr="CS" vm="1" name="Input Readiness State"/>
-    <entry group="0040" element="4050" keyword="PerformedProcedureStepStartDateTime" vr="DT" vm="1" name="Performed Procedure Step Start DateTime"/>
-    <entry group="0040" element="4051" keyword="PerformedProcedureStepEndDateTime" vr="DT" vm="1" name="Performed Procedure Step End DateTime"/>
-    <entry group="0040" element="4052" keyword="ProcedureStepCancellationDateTime" vr="DT" vm="1" name="Procedure Step Cancellation DateTime"/>
-    <entry group="0040" element="8302" keyword="EntranceDoseInmGy" vr="DS" vm="1" name="Entrance Dose in mGy"/>
-    <entry group="0040" element="9094" keyword="ReferencedImageRealWorldValueMappingSequence" vr="SQ" vm="1" name="Referenced Image Real World Value Mapping Sequence"/>
-    <entry group="0040" element="9096" keyword="RealWorldValueMappingSequence" vr="SQ" vm="1" name="Real World Value Mapping Sequence"/>
-    <entry group="0040" element="9098" keyword="PixelValueMappingCodeSequence" vr="SQ" vm="1" name="Pixel Value Mapping Code Sequence"/>
-    <entry group="0040" element="9210" keyword="LUTLabel" vr="SH" vm="1" name="LUT Label"/>
-    <entry group="0040" element="9211" keyword="RealWorldValueLastValueMapped" vr="US_SS" vm="1" name="Real World Value Last Value Mapped"/>
-    <entry group="0040" element="9212" keyword="RealWorldValueLUTData" vr="FD" vm="1-n" name="Real World Value LUT Data"/>
-    <entry group="0040" element="9216" keyword="RealWorldValueFirstValueMapped" vr="US_SS" vm="1" name="Real World Value First Value Mapped"/>
-    <entry group="0040" element="9224" keyword="RealWorldValueIntercept" vr="FD" vm="1" name="Real World Value Intercept"/>
-    <entry group="0040" element="9225" keyword="RealWorldValueSlope" vr="FD" vm="1" name="Real World Value Slope"/>
-    <entry group="0040" element="a007" keyword="FindingsFlagTrial" vr="CS" vm="1" retired="true" name="Findings Flag (Trial)"/>
-    <entry group="0040" element="a010" keyword="RelationshipType" vr="CS" vm="1" name="Relationship Type"/>
-    <entry group="0040" element="a020" keyword="FindingsSequenceTrial" vr="SQ" vm="1" retired="true" name="Findings Sequence (Trial)"/>
-    <entry group="0040" element="a021" keyword="FindingsGroupUIDTrial" vr="UI" vm="1" retired="true" name="Findings Group UID (Trial)"/>
-    <entry group="0040" element="a022" keyword="ReferencedFindingsGroupUIDTrial" vr="UI" vm="1" retired="true" name="Referenced Findings Group UID (Trial)"/>
-    <entry group="0040" element="a023" keyword="FindingsGroupRecordingDateTrial" vr="DA" vm="1" retired="true" name="Findings Group Recording Date (Trial)"/>
-    <entry group="0040" element="a024" keyword="FindingsGroupRecordingTimeTrial" vr="TM" vm="1" retired="true" name="Findings Group Recording Time (Trial)"/>
-    <entry group="0040" element="a026" keyword="FindingsSourceCategoryCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Findings Source Category Code Sequence (Trial)"/>
-    <entry group="0040" element="a027" keyword="VerifyingOrganization" vr="LO" vm="1" name="Verifying Organization"/>
-    <entry group="0040" element="a028" keyword="DocumentingOrganizationIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Documenting Organization Identifier Code Sequence (Trial)"/>
-    <entry group="0040" element="a030" keyword="VerificationDateTime" vr="DT" vm="1" name="Verification Date Time"/>
-    <entry group="0040" element="a032" keyword="ObservationDateTime" vr="DT" vm="1" name="Observation Date Time"/>
-    <entry group="0040" element="a040" keyword="ValueType" vr="CS" vm="1" name="Value Type"/>
-    <entry group="0040" element="a043" keyword="ConceptNameCodeSequence" vr="SQ" vm="1" name="Concept Name Code Sequence"/>
-    <entry group="0040" element="a047" keyword="MeasurementPrecisionDescriptionTrial" vr="LO" vm="1" retired="true" name="Measurement Precision Description (Trial)"/>
-    <entry group="0040" element="a050" keyword="ContinuityOfContent" vr="CS" vm="1" name="Continuity Of Content"/>
-    <entry group="0040" element="a057" keyword="UrgencyOrPriorityAlertsTrial" vr="CS" vm="1-n" retired="true" name="Urgency or Priority Alerts (Trial)"/>
-    <entry group="0040" element="a060" keyword="SequencingIndicatorTrial" vr="LO" vm="1" retired="true" name="Sequencing Indicator (Trial)"/>
-    <entry group="0040" element="a066" keyword="DocumentIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Document Identifier Code Sequence (Trial)"/>
-    <entry group="0040" element="a067" keyword="DocumentAuthorTrial" vr="PN" vm="1" retired="true" name="Document Author (Trial)"/>
-    <entry group="0040" element="a068" keyword="DocumentAuthorIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Document Author Identifier Code Sequence (Trial)"/>
-    <entry group="0040" element="a070" keyword="IdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Identifier Code Sequence (Trial)"/>
-    <entry group="0040" element="a073" keyword="VerifyingObserverSequence" vr="SQ" vm="1" name="Verifying Observer Sequence"/>
-    <entry group="0040" element="a074" keyword="ObjectBinaryIdentifierTrial" vr="OB" vm="1" retired="true" name="Object Binary Identifier (Trial)"/>
-    <entry group="0040" element="a075" keyword="VerifyingObserverName" vr="PN" vm="1" name="Verifying Observer Name"/>
-    <entry group="0040" element="a076" keyword="DocumentingObserverIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Documenting Observer Identifier Code Sequence (Trial)"/>
-    <entry group="0040" element="a078" keyword="AuthorObserverSequence" vr="SQ" vm="1" name="Author Observer Sequence"/>
-    <entry group="0040" element="a07a" keyword="ParticipantSequence" vr="SQ" vm="1" name="Participant Sequence"/>
-    <entry group="0040" element="a07c" keyword="CustodialOrganizationSequence" vr="SQ" vm="1" name="Custodial Organization Sequence"/>
-    <entry group="0040" element="a080" keyword="ParticipationType" vr="CS" vm="1" name="Participation Type"/>
-    <entry group="0040" element="a082" keyword="ParticipationDateTime" vr="DT" vm="1" name="Participation DateTime"/>
-    <entry group="0040" element="a084" keyword="ObserverType" vr="CS" vm="1" name="Observer Type"/>
-    <entry group="0040" element="a085" keyword="ProcedureIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Procedure Identifier Code Sequence (Trial)"/>
-    <entry group="0040" element="a088" keyword="VerifyingObserverIdentificationCodeSequence" vr="SQ" vm="1" name="Verifying Observer Identification Code Sequence"/>
-    <entry group="0040" element="a089" keyword="ObjectDirectoryBinaryIdentifierTrial" vr="OB" vm="1" retired="true" name="Object Directory Binary Identifier (Trial)"/>
-    <entry group="0040" element="a090" keyword="EquivalentCDADocumentSequence" vr="SQ" vm="1" retired="true" name="Equivalent CDA Document Sequence"/>
-    <entry group="0040" element="a0b0" keyword="ReferencedWaveformChannels" vr="US" vm="2-2n" name="Referenced Waveform Channels"/>
-    <entry group="0040" element="a110" keyword="DateOfDocumentOrVerbalTransactionTrial" vr="DA" vm="1" retired="true" name="Date of Document or Verbal Transaction (Trial)"/>
-    <entry group="0040" element="a112" keyword="TimeOfDocumentCreationOrVerbalTransactionTrial" vr="TM" vm="1" retired="true" name="Time of Document Creation or Verbal Transaction (Trial)"/>
-    <entry group="0040" element="a120" keyword="DateTime" vr="DT" vm="1" name="DateTime"/>
-    <entry group="0040" element="a121" keyword="Date" vr="DA" vm="1" name="Date"/>
-    <entry group="0040" element="a122" keyword="Time" vr="TM" vm="1" name="Time"/>
-    <entry group="0040" element="a123" keyword="PersonName" vr="PN" vm="1" name="Person Name"/>
-    <entry group="0040" element="a124" keyword="UID" vr="UI" vm="1" name="UID"/>
-    <entry group="0040" element="a125" keyword="ReportStatusIDTrial" vr="CS" vm="2" retired="true" name="Report Status ID (Trial)"/>
-    <entry group="0040" element="a130" keyword="TemporalRangeType" vr="CS" vm="1" name="Temporal Range Type"/>
-    <entry group="0040" element="a132" keyword="ReferencedSamplePositions" vr="UL" vm="1-n" name="Referenced Sample Positions"/>
-    <entry group="0040" element="a136" keyword="ReferencedFrameNumbers" vr="US" vm="1-n" name="Referenced Frame Numbers"/>
-    <entry group="0040" element="a138" keyword="ReferencedTimeOffsets" vr="DS" vm="1-n" name="Referenced Time Offsets"/>
-    <entry group="0040" element="a13a" keyword="ReferencedDateTime" vr="DT" vm="1-n" name="Referenced DateTime"/>
-    <entry group="0040" element="a160" keyword="TextValue" vr="UT" vm="1" name="Text Value"/>
-    <entry group="0040" element="a167" keyword="ObservationCategoryCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Observation Category Code Sequence (Trial)"/>
-    <entry group="0040" element="a168" keyword="ConceptCodeSequence" vr="SQ" vm="1" name="Concept Code Sequence"/>
-    <entry group="0040" element="a16a" keyword="BibliographicCitationTrial" vr="ST" vm="1" retired="true" name="Bibliographic Citation (Trial)"/>
-    <entry group="0040" element="a170" keyword="PurposeOfReferenceCodeSequence" vr="SQ" vm="1" name="Purpose of Reference Code Sequence"/>
-    <entry group="0040" element="a171" keyword="ObservationUIDTrial" vr="UI" vm="1" retired="true" name="Observation UID (Trial)"/>
-    <entry group="0040" element="a172" keyword="ReferencedObservationUIDTrial" vr="UI" vm="1" retired="true" name="Referenced Observation UID (Trial)"/>
-    <entry group="0040" element="a173" keyword="ReferencedObservationClassTrial" vr="CS" vm="1" retired="true" name="Referenced Observation Class (Trial)"/>
-    <entry group="0040" element="a174" keyword="ReferencedObjectObservationClassTrial" vr="CS" vm="1" retired="true" name="Referenced Object Observation Class (Trial)"/>
-    <entry group="0040" element="a180" keyword="AnnotationGroupNumber" vr="US" vm="1" name="Annotation Group Number"/>
-    <entry group="0040" element="a192" keyword="ObservationDateTrial" vr="DA" vm="1" retired="true" name="Observation Date (Trial)"/>
-    <entry group="0040" element="a193" keyword="ObservationTimeTrial" vr="TM" vm="1" retired="true" name="Observation Time (Trial)"/>
-    <entry group="0040" element="a194" keyword="MeasurementAutomationTrial" vr="CS" vm="1" retired="true" name="Measurement Automation (Trial)"/>
-    <entry group="0040" element="a195" keyword="ModifierCodeSequence" vr="SQ" vm="1" name="Modifier Code Sequence"/>
-    <entry group="0040" element="a224" keyword="IdentificationDescriptionTrial" vr="ST" vm="1" retired="true" name="Identification Description (Trial)"/>
-    <entry group="0040" element="a290" keyword="CoordinatesSetGeometricTypeTrial" vr="CS" vm="1" retired="true" name="Coordinates Set Geometric Type (Trial)"/>
-    <entry group="0040" element="a296" keyword="AlgorithmCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Algorithm Code Sequence (Trial)"/>
-    <entry group="0040" element="a297" keyword="AlgorithmDescriptionTrial" vr="ST" vm="1" retired="true" name="Algorithm Description (Trial)"/>
-    <entry group="0040" element="a29a" keyword="PixelCoordinatesSetTrial" vr="SL" vm="2-2n" retired="true" name="Pixel Coordinates Set (Trial)"/>
-    <entry group="0040" element="a300" keyword="MeasuredValueSequence" vr="SQ" vm="1" name="Measured Value Sequence"/>
-    <entry group="0040" element="a301" keyword="NumericValueQualifierCodeSequence" vr="SQ" vm="1" name="Numeric Value Qualifier Code Sequence"/>
-    <entry group="0040" element="a307" keyword="CurrentObserverTrial" vr="PN" vm="1" retired="true" name="Current Observer (Trial)"/>
-    <entry group="0040" element="a30a" keyword="NumericValue" vr="DS" vm="1-n" name="Numeric Value"/>
-    <entry group="0040" element="a313" keyword="ReferencedAccessionSequenceTrial" vr="SQ" vm="1" retired="true" name="Referenced Accession Sequence (Trial)"/>
-    <entry group="0040" element="a33a" keyword="ReportStatusCommentTrial" vr="ST" vm="1" retired="true" name="Report Status Comment (Trial)"/>
-    <entry group="0040" element="a340" keyword="ProcedureContextSequenceTrial" vr="SQ" vm="1" retired="true" name="Procedure Context Sequence (Trial)"/>
-    <entry group="0040" element="a352" keyword="VerbalSourceTrial" vr="PN" vm="1" retired="true" name="Verbal Source (Trial)"/>
-    <entry group="0040" element="a353" keyword="AddressTrial" vr="ST" vm="1" retired="true" name="Address (Trial)"/>
-    <entry group="0040" element="a354" keyword="TelephoneNumberTrial" vr="LO" vm="1" retired="true" name="Telephone Number (Trial)"/>
-    <entry group="0040" element="a358" keyword="VerbalSourceIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Verbal Source Identifier Code Sequence (Trial)"/>
-    <entry group="0040" element="a360" keyword="PredecessorDocumentsSequence" vr="SQ" vm="1" name="Predecessor Documents Sequence"/>
-    <entry group="0040" element="a370" keyword="ReferencedRequestSequence" vr="SQ" vm="1" name="Referenced Request Sequence"/>
-    <entry group="0040" element="a372" keyword="PerformedProcedureCodeSequence" vr="SQ" vm="1" name="Performed Procedure Code Sequence"/>
-    <entry group="0040" element="a375" keyword="CurrentRequestedProcedureEvidenceSequence" vr="SQ" vm="1" name="Current Requested Procedure Evidence Sequence"/>
-    <entry group="0040" element="a380" keyword="ReportDetailSequenceTrial" vr="SQ" vm="1" retired="true" name="Report Detail Sequence (Trial)"/>
-    <entry group="0040" element="a385" keyword="PertinentOtherEvidenceSequence" vr="SQ" vm="1" name="Pertinent Other Evidence Sequence"/>
-    <entry group="0040" element="a390" keyword="HL7StructuredDocumentReferenceSequence" vr="SQ" vm="1" name="HL7 Structured Document Reference Sequence"/>
-    <entry group="0040" element="a402" keyword="ObservationSubjectUIDTrial" vr="UI" vm="1" retired="true" name="Observation Subject UID (Trial)"/>
-    <entry group="0040" element="a403" keyword="ObservationSubjectClassTrial" vr="CS" vm="1" retired="true" name="Observation Subject Class (Trial)"/>
-    <entry group="0040" element="a404" keyword="ObservationSubjectTypeCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Observation Subject Type Code Sequence (Trial)"/>
-    <entry group="0040" element="a491" keyword="CompletionFlag" vr="CS" vm="1" name="Completion Flag"/>
-    <entry group="0040" element="a492" keyword="CompletionFlagDescription" vr="LO" vm="1" name="Completion Flag Description"/>
-    <entry group="0040" element="a493" keyword="VerificationFlag" vr="CS" vm="1" name="Verification Flag"/>
-    <entry group="0040" element="a494" keyword="ArchiveRequested" vr="CS" vm="1" name="Archive Requested"/>
-    <entry group="0040" element="a496" keyword="PreliminaryFlag" vr="CS" vm="1" name="Preliminary Flag"/>
-    <entry group="0040" element="a504" keyword="ContentTemplateSequence" vr="SQ" vm="1" name="Content Template Sequence"/>
-    <entry group="0040" element="a525" keyword="IdenticalDocumentsSequence" vr="SQ" vm="1" name="Identical Documents Sequence"/>
-    <entry group="0040" element="a600" keyword="ObservationSubjectContextFlagTrial" vr="CS" vm="1" retired="true" name="Observation Subject Context Flag (Trial)"/>
-    <entry group="0040" element="a601" keyword="ObserverContextFlagTrial" vr="CS" vm="1" retired="true" name="Observer Context Flag (Trial)"/>
-    <entry group="0040" element="a603" keyword="ProcedureContextFlagTrial" vr="CS" vm="1" retired="true" name="Procedure Context Flag (Trial)"/>
-    <entry group="0040" element="a730" keyword="ContentSequence" vr="SQ" vm="1" name="Content Sequence"/>
-    <entry group="0040" element="a731" keyword="RelationshipSequenceTrial" vr="SQ" vm="1" retired="true" name="Relationship Sequence (Trial)"/>
-    <entry group="0040" element="a732" keyword="RelationshipTypeCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Relationship Type Code Sequence (Trial)"/>
-    <entry group="0040" element="a744" keyword="LanguageCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Language Code Sequence (Trial)"/>
-    <entry group="0040" element="a992" keyword="UniformResourceLocatorTrial" vr="ST" vm="1" retired="true" name="Uniform Resource Locator (Trial)"/>
-    <entry group="0040" element="b020" keyword="WaveformAnnotationSequence" vr="SQ" vm="1" name="Waveform Annotation Sequence"/>
-    <entry group="0040" element="db00" keyword="TemplateIdentifier" vr="CS" vm="1" name="Template Identifier"/>
-    <entry group="0040" element="db06" keyword="TemplateVersion" vr="DT" vm="1" retired="true" name="Template Version"/>
-    <entry group="0040" element="db07" keyword="TemplateLocalVersion" vr="DT" vm="1" retired="true" name="Template Local Version"/>
-    <entry group="0040" element="db0b" keyword="TemplateExtensionFlag" vr="CS" vm="1" retired="true" name="Template Extension Flag"/>
-    <entry group="0040" element="db0c" keyword="TemplateExtensionOrganizationUID" vr="UI" vm="1" retired="true" name="Template Extension Organization UID"/>
-    <entry group="0040" element="db0d" keyword="TemplateExtensionCreatorUID" vr="UI" vm="1" retired="true" name="Template Extension Creator UID"/>
-    <entry group="0040" element="db73" keyword="ReferencedContentItemIdentifier" vr="UL" vm="1-n" name="Referenced Content Item Identifier"/>
-    <entry group="0040" element="e001" keyword="HL7InstanceIdentifier" vr="ST" vm="1" name="HL7 Instance Identifier"/>
-    <entry group="0040" element="e004" keyword="HL7DocumentEffectiveTime" vr="DT" vm="1" name="HL7 Document Effective Time"/>
-    <entry group="0040" element="e006" keyword="HL7DocumentTypeCodeSequence" vr="SQ" vm="1" name="HL7 Document Type Code Sequence"/>
-    <entry group="0040" element="e008" keyword="DocumentClassCodeSequence" vr="SQ" vm="1" name="Document Class Code Sequence"/>
-    <entry group="0040" element="e010" keyword="RetrieveURI" vr="UT" vm="1" name="Retrieve URI"/>
-    <entry group="0040" element="e011" keyword="RetrieveLocationUID" vr="UI" vm="1" name="Retrieve Location UID"/>
-    <entry group="0040" element="e020" keyword="TypeOfInstances" vr="CS" vm="1" name="Type of Instances"/>
-    <entry group="0040" element="e021" keyword="DICOMRetrievalSequence" vr="SQ" vm="1" name="DICOM Retrieval Sequence"/>
-    <entry group="0040" element="e022" keyword="DICOMMediaRetrievalSequence" vr="SQ" vm="1" name="DICOM Media Retrieval Sequence"/>
-    <entry group="0040" element="e023" keyword="WADORetrievalSequence" vr="SQ" vm="1" name="WADO Retrieval Sequence"/>
-    <entry group="0040" element="e024" keyword="XDSRetrievalSequence" vr="SQ" vm="1" name="XDS Retrieval Sequence"/>
-    <entry group="0040" element="e030" keyword="RepositoryUniqueID" vr="UI" vm="1" name="Repository Unique ID"/>
-    <entry group="0040" element="e031" keyword="HomeCommunityID" vr="UI" vm="1" name="Home Community ID"/>
-    <entry group="0042" element="0010" keyword="DocumentTitle" vr="ST" vm="1" name="Document Title"/>
-    <entry group="0042" element="0011" keyword="EncapsulatedDocument" vr="OB" vm="1" name="Encapsulated Document"/>
-    <entry group="0042" element="0012" keyword="MIMETypeOfEncapsulatedDocument" vr="LO" vm="1" name="MIME Type of Encapsulated Document"/>
-    <entry group="0042" element="0013" keyword="SourceInstanceSequence" vr="SQ" vm="1" name="Source Instance Sequence"/>
-    <entry group="0042" element="0014" keyword="ListOfMIMETypes" vr="LO" vm="1-n" name="List of MIME Types"/>
-    <entry group="0044" element="0001" keyword="ProductPackageIdentifier" vr="ST" vm="1" name="Product Package Identifier"/>
-    <entry group="0044" element="0002" keyword="SubstanceAdministrationApproval" vr="CS" vm="1" name="Substance Administration Approval"/>
-    <entry group="0044" element="0003" keyword="ApprovalStatusFurtherDescription" vr="LT" vm="1" name="Approval Status Further Description"/>
-    <entry group="0044" element="0004" keyword="ApprovalStatusDateTime" vr="DT" vm="1" name="Approval Status DateTime"/>
-    <entry group="0044" element="0007" keyword="ProductTypeCodeSequence" vr="SQ" vm="1" name="Product Type Code Sequence"/>
-    <entry group="0044" element="0008" keyword="ProductName" vr="LO" vm="1-n" name="Product Name"/>
-    <entry group="0044" element="0009" keyword="ProductDescription" vr="LT" vm="1" name="Product Description"/>
-    <entry group="0044" element="000a" keyword="ProductLotIdentifier" vr="LO" vm="1" name="Product Lot Identifier"/>
-    <entry group="0044" element="000b" keyword="ProductExpirationDateTime" vr="DT" vm="1" name="Product Expiration DateTime"/>
-    <entry group="0044" element="0010" keyword="SubstanceAdministrationDateTime" vr="DT" vm="1" name="Substance Administration DateTime"/>
-    <entry group="0044" element="0011" keyword="SubstanceAdministrationNotes" vr="LO" vm="1" name="Substance Administration Notes"/>
-    <entry group="0044" element="0012" keyword="SubstanceAdministrationDeviceID" vr="LO" vm="1" name="Substance Administration Device ID"/>
-    <entry group="0044" element="0013" keyword="ProductParameterSequence" vr="SQ" vm="1" name="Product Parameter Sequence"/>
-    <entry group="0044" element="0019" keyword="SubstanceAdministrationParameterSequence" vr="SQ" vm="1" name="Substance Administration Parameter Sequence"/>
-    <entry group="0046" element="0012" keyword="LensDescription" vr="LO" vm="1" name="Lens Description"/>
-    <entry group="0046" element="0014" keyword="RightLensSequence" vr="SQ" vm="1" name="Right Lens Sequence"/>
-    <entry group="0046" element="0015" keyword="LeftLensSequence" vr="SQ" vm="1" name="Left Lens Sequence"/>
-    <entry group="0046" element="0016" keyword="UnspecifiedLateralityLensSequence" vr="SQ" vm="1" name="Unspecified Laterality Lens Sequence"/>
-    <entry group="0046" element="0018" keyword="CylinderSequence" vr="SQ" vm="1" name="Cylinder Sequence"/>
-    <entry group="0046" element="0028" keyword="PrismSequence" vr="SQ" vm="1" name="Prism Sequence"/>
-    <entry group="0046" element="0030" keyword="HorizontalPrismPower" vr="FD" vm="1" name="Horizontal Prism Power"/>
-    <entry group="0046" element="0032" keyword="HorizontalPrismBase" vr="CS" vm="1" name="Horizontal Prism Base"/>
-    <entry group="0046" element="0034" keyword="VerticalPrismPower" vr="FD" vm="1" name="Vertical Prism Power"/>
-    <entry group="0046" element="0036" keyword="VerticalPrismBase" vr="CS" vm="1" name="Vertical Prism Base"/>
-    <entry group="0046" element="0038" keyword="LensSegmentType" vr="CS" vm="1" name="Lens Segment Type"/>
-    <entry group="0046" element="0040" keyword="OpticalTransmittance" vr="FD" vm="1" name="Optical Transmittance"/>
-    <entry group="0046" element="0042" keyword="ChannelWidth" vr="FD" vm="1" name="Channel Width"/>
-    <entry group="0046" element="0044" keyword="PupilSize" vr="FD" vm="1" name="Pupil Size"/>
-    <entry group="0046" element="0046" keyword="CornealSize" vr="FD" vm="1" name="Corneal Size"/>
-    <entry group="0046" element="0050" keyword="AutorefractionRightEyeSequence" vr="SQ" vm="1" name="Autorefraction Right Eye Sequence"/>
-    <entry group="0046" element="0052" keyword="AutorefractionLeftEyeSequence" vr="SQ" vm="1" name="Autorefraction Left Eye Sequence"/>
-    <entry group="0046" element="0060" keyword="DistancePupillaryDistance" vr="FD" vm="1" name="Distance Pupillary Distance"/>
-    <entry group="0046" element="0062" keyword="NearPupillaryDistance" vr="FD" vm="1" name="Near Pupillary Distance"/>
-    <entry group="0046" element="0063" keyword="IntermediatePupillaryDistance" vr="FD" vm="1" name="Intermediate Pupillary Distance"/>
-    <entry group="0046" element="0064" keyword="OtherPupillaryDistance" vr="FD" vm="1" name="Other Pupillary Distance"/>
-    <entry group="0046" element="0070" keyword="KeratometryRightEyeSequence" vr="SQ" vm="1" name="Keratometry Right Eye Sequence"/>
-    <entry group="0046" element="0071" keyword="KeratometryLeftEyeSequence" vr="SQ" vm="1" name="Keratometry Left Eye Sequence"/>
-    <entry group="0046" element="0074" keyword="SteepKeratometricAxisSequence" vr="SQ" vm="1" name="Steep Keratometric Axis Sequence"/>
-    <entry group="0046" element="0075" keyword="RadiusOfCurvature" vr="FD" vm="1" name="Radius of Curvature"/>
-    <entry group="0046" element="0076" keyword="KeratometricPower" vr="FD" vm="1" name="Keratometric Power"/>
-    <entry group="0046" element="0077" keyword="KeratometricAxis" vr="FD" vm="1" name="Keratometric Axis"/>
-    <entry group="0046" element="0080" keyword="FlatKeratometricAxisSequence" vr="SQ" vm="1" name="Flat Keratometric Axis Sequence"/>
-    <entry group="0046" element="0092" keyword="BackgroundColor" vr="CS" vm="1" name="Background Color"/>
-    <entry group="0046" element="0094" keyword="Optotype" vr="CS" vm="1" name="Optotype"/>
-    <entry group="0046" element="0095" keyword="OptotypePresentation" vr="CS" vm="1" name="Optotype Presentation"/>
-    <entry group="0046" element="0097" keyword="SubjectiveRefractionRightEyeSequence" vr="SQ" vm="1" name="Subjective Refraction Right Eye Sequence"/>
-    <entry group="0046" element="0098" keyword="SubjectiveRefractionLeftEyeSequence" vr="SQ" vm="1" name="Subjective Refraction Left Eye Sequence"/>
-    <entry group="0046" element="0100" keyword="AddNearSequence" vr="SQ" vm="1" name="Add Near Sequence"/>
-    <entry group="0046" element="0101" keyword="AddIntermediateSequence" vr="SQ" vm="1" name="Add Intermediate Sequence"/>
-    <entry group="0046" element="0102" keyword="AddOtherSequence" vr="SQ" vm="1" name="Add Other Sequence"/>
-    <entry group="0046" element="0104" keyword="AddPower" vr="FD" vm="1" name="Add Power"/>
-    <entry group="0046" element="0106" keyword="ViewingDistance" vr="FD" vm="1" name="Viewing Distance"/>
-    <entry group="0046" element="0121" keyword="VisualAcuityTypeCodeSequence" vr="SQ" vm="1" name="Visual Acuity Type Code Sequence"/>
-    <entry group="0046" element="0122" keyword="VisualAcuityRightEyeSequence" vr="SQ" vm="1" name="Visual Acuity Right Eye Sequence"/>
-    <entry group="0046" element="0123" keyword="VisualAcuityLeftEyeSequence" vr="SQ" vm="1" name="Visual Acuity Left Eye Sequence"/>
-    <entry group="0046" element="0124" keyword="VisualAcuityBothEyesOpenSequence" vr="SQ" vm="1" name="Visual Acuity Both Eyes Open Sequence"/>
-    <entry group="0046" element="0125" keyword="ViewingDistanceType" vr="CS" vm="1" name="Viewing Distance Type"/>
-    <entry group="0046" element="0135" keyword="VisualAcuityModifiers" vr="SS" vm="2" name="Visual Acuity Modifiers"/>
-    <entry group="0046" element="0137" keyword="DecimalVisualAcuity" vr="FD" vm="1" name="Decimal Visual Acuity"/>
-    <entry group="0046" element="0139" keyword="OptotypeDetailedDefinition" vr="LO" vm="1" name="Optotype Detailed Definition"/>
-    <entry group="0046" element="0145" keyword="ReferencedRefractiveMeasurementsSequence" vr="SQ" vm="1" name="Referenced Refractive Measurements Sequence"/>
-    <entry group="0046" element="0146" keyword="SpherePower" vr="FD" vm="1" name="Sphere Power"/>
-    <entry group="0046" element="0147" keyword="CylinderPower" vr="FD" vm="1" name="Cylinder Power"/>
-    <entry group="0048" element="0001" keyword="ImagedVolumeWidth" vr="FL" vm="1" name="Imaged Volume Width"/>
-    <entry group="0048" element="0002" keyword="ImagedVolumeHeight" vr="FL" vm="1" name="Imaged Volume Height"/>
-    <entry group="0048" element="0003" keyword="ImagedVolumeDepth" vr="FL" vm="1" name="Imaged Volume Depth"/>
-    <entry group="0048" element="0006" keyword="TotalPixelMatrixColumns" vr="UL" vm="1" name="Total Pixel Matrix Columns"/>
-    <entry group="0048" element="0007" keyword="TotalPixelMatrixRows" vr="UL" vm="1" name="Total Pixel Matrix Rows"/>
-    <entry group="0048" element="0008" keyword="TotalPixelMatrixOriginSequence" vr="SQ" vm="1" name="Total Pixel Matrix Origin Sequence"/>
-    <entry group="0048" element="0010" keyword="SpecimenLabelInImage" vr="CS" vm="1" name="Specimen Label in Image"/>
-    <entry group="0048" element="0011" keyword="FocusMethod" vr="CS" vm="1" name="Focus Method"/>
-    <entry group="0048" element="0012" keyword="ExtendedDepthOfField" vr="CS" vm="1" name="Extended Depth of Field"/>
-    <entry group="0048" element="0013" keyword="NumberOfFocalPlanes" vr="US" vm="1" name="Number of Focal Planes"/>
-    <entry group="0048" element="0014" keyword="DistanceBetweenFocalPlanes" vr="FL" vm="1" name="Distance Between Focal Planes"/>
-    <entry group="0048" element="0015" keyword="RecommendedAbsentPixelCIELabValue" vr="US" vm="3" name="Recommended Absent Pixel CIELab Value"/>
-    <entry group="0048" element="0100" keyword="IlluminatorTypeCodeSequence" vr="SQ" vm="1" name="Illuminator Type Code Sequence"/>
-    <entry group="0048" element="0102" keyword="ImageOrientationSlide" vr="DS" vm="6" name="Image Orientation (Slide)"/>
-    <entry group="0048" element="0105" keyword="OpticalPathSequence" vr="SQ" vm="1" name="Optical Path Sequence"/>
-    <entry group="0048" element="0106" keyword="OpticalPathIdentifier" vr="SH" vm="1" name="Optical Path Identifier"/>
-    <entry group="0048" element="0107" keyword="OpticalPathDescription" vr="ST" vm="1" name="Optical Path Description"/>
-    <entry group="0048" element="0108" keyword="IlluminationColorCodeSequence" vr="SQ" vm="1" name="Illumination Color Code Sequence"/>
-    <entry group="0048" element="0110" keyword="SpecimenReferenceSequence" vr="SQ" vm="1" name="Specimen Reference Sequence"/>
-    <entry group="0048" element="0111" keyword="CondenserLensPower" vr="DS" vm="1" name="Condenser Lens Power"/>
-    <entry group="0048" element="0112" keyword="ObjectiveLensPower" vr="DS" vm="1" name="Objective Lens Power"/>
-    <entry group="0048" element="0113" keyword="ObjectiveLensNumericalAperture" vr="DS" vm="1" name="Objective Lens Numerical Aperture"/>
-    <entry group="0048" element="0120" keyword="PaletteColorLookupTableSequence" vr="SQ" vm="1" name="Palette Color Lookup Table Sequence"/>
-    <entry group="0048" element="0200" keyword="ReferencedImageNavigationSequence" vr="SQ" vm="1" name="Referenced Image Navigation Sequence"/>
-    <entry group="0048" element="0201" keyword="TopLeftHandCornerOfLocalizerArea" vr="US" vm="2" name="Top Left Hand Corner of Localizer Area"/>
-    <entry group="0048" element="0202" keyword="BottomRightHandCornerOfLocalizerArea" vr="US" vm="2" name="Bottom Right Hand Corner of Localizer Area"/>
-    <entry group="0048" element="0207" keyword="OpticalPathIdentificationSequence" vr="SQ" vm="1" name="Optical Path Identification Sequence"/>
-    <entry group="0048" element="021a" keyword="PlanePositionSlideSequence" vr="SQ" vm="1" name="Plane Position (Slide) Sequence"/>
-    <entry group="0048" element="021e" keyword="ColumnPositionInTotalImagePixelMatrix" vr="SL" vm="1" name="Column Position In Total Image Pixel Matrix"/>
-    <entry group="0048" element="021f" keyword="RowPositionInTotalImagePixelMatrix" vr="SL" vm="1" name="Row Position In Total Image Pixel Matrix"/>
-    <entry group="0048" element="0301" keyword="PixelOriginInterpretation" vr="CS" vm="1" name="Pixel Origin Interpretation"/>
-    <entry group="0050" element="0004" keyword="CalibrationImage" vr="CS" vm="1" name="Calibration Image"/>
-    <entry group="0050" element="0010" keyword="DeviceSequence" vr="SQ" vm="1" name="Device Sequence"/>
-    <entry group="0050" element="0012" keyword="ContainerComponentTypeCodeSequence" vr="SQ" vm="1" name="Container Component Type Code Sequence"/>
-    <entry group="0050" element="0013" keyword="ContainerComponentThickness" vr="FD" vm="1" name="Container Component Thickness"/>
-    <entry group="0050" element="0014" keyword="DeviceLength" vr="DS" vm="1" name="Device Length"/>
-    <entry group="0050" element="0015" keyword="ContainerComponentWidth" vr="FD" vm="1" name="Container Component Width"/>
-    <entry group="0050" element="0016" keyword="DeviceDiameter" vr="DS" vm="1" name="Device Diameter"/>
-    <entry group="0050" element="0017" keyword="DeviceDiameterUnits" vr="CS" vm="1" name="Device Diameter Units"/>
-    <entry group="0050" element="0018" keyword="DeviceVolume" vr="DS" vm="1" name="Device Volume"/>
-    <entry group="0050" element="0019" keyword="InterMarkerDistance" vr="DS" vm="1" name="Inter-Marker Distance"/>
-    <entry group="0050" element="001a" keyword="ContainerComponentMaterial" vr="CS" vm="1" name="Container Component Material"/>
-    <entry group="0050" element="001b" keyword="ContainerComponentID" vr="LO" vm="1" name="Container Component ID"/>
-    <entry group="0050" element="001c" keyword="ContainerComponentLength" vr="FD" vm="1" name="Container Component Length"/>
-    <entry group="0050" element="001d" keyword="ContainerComponentDiameter" vr="FD" vm="1" name="Container Component Diameter"/>
-    <entry group="0050" element="001e" keyword="ContainerComponentDescription" vr="LO" vm="1" name="Container Component Description"/>
-    <entry group="0050" element="0020" keyword="DeviceDescription" vr="LO" vm="1" name="Device Description"/>
-    <entry group="0052" element="0001" keyword="ContrastBolusIngredientPercentByVolume" vr="FL" vm="1" name="Contrast/Bolus Ingredient Percent by Volume"/>
-    <entry group="0052" element="0002" keyword="OCTFocalDistance" vr="FD" vm="1" name="OCT Focal Distance"/>
-    <entry group="0052" element="0003" keyword="BeamSpotSize" vr="FD" vm="1" name="Beam Spot Size"/>
-    <entry group="0052" element="0004" keyword="EffectiveRefractiveIndex" vr="FD" vm="1" name="Effective Refractive Index"/>
-    <entry group="0052" element="0006" keyword="OCTAcquisitionDomain" vr="CS" vm="1" name="OCT Acquisition Domain"/>
-    <entry group="0052" element="0007" keyword="OCTOpticalCenterWavelength" vr="FD" vm="1" name="OCT Optical Center Wavelength"/>
-    <entry group="0052" element="0008" keyword="AxialResolution" vr="FD" vm="1" name="Axial Resolution"/>
-    <entry group="0052" element="0009" keyword="RangingDepth" vr="FD" vm="1" name="Ranging Depth"/>
-    <entry group="0052" element="0011" keyword="ALineRate" vr="FD" vm="1" name="A-line Rate"/>
-    <entry group="0052" element="0012" keyword="ALinesPerFrame" vr="US" vm="1" name="A-lines Per Frame"/>
-    <entry group="0052" element="0013" keyword="CatheterRotationalRate" vr="FD" vm="1" name="Catheter Rotational Rate"/>
-    <entry group="0052" element="0014" keyword="ALinePixelSpacing" vr="FD" vm="1" name="A-line Pixel Spacing"/>
-    <entry group="0052" element="0016" keyword="ModeOfPercutaneousAccessSequence" vr="SQ" vm="1" name="Mode of Percutaneous Access Sequence"/>
-    <entry group="0052" element="0025" keyword="IntravascularOCTFrameTypeSequence" vr="SQ" vm="1" name="Intravascular OCT Frame Type Sequence"/>
-    <entry group="0052" element="0026" keyword="OCTZOffsetApplied" vr="CS" vm="1" name="OCT Z Offset Applied"/>
-    <entry group="0052" element="0027" keyword="IntravascularFrameContentSequence" vr="SQ" vm="1" name="Intravascular Frame Content Sequence"/>
-    <entry group="0052" element="0028" keyword="IntravascularLongitudinalDistance" vr="FD" vm="1" name="Intravascular Longitudinal Distance"/>
-    <entry group="0052" element="0029" keyword="IntravascularOCTFrameContentSequence" vr="SQ" vm="1" name="Intravascular OCT Frame Content Sequence"/>
-    <entry group="0052" element="0030" keyword="OCTZOffsetCorrection" vr="SS" vm="1" name="OCT Z Offset Correction"/>
-    <entry group="0052" element="0031" keyword="CatheterDirectionOfRotation" vr="CS" vm="1" name="Catheter Direction of Rotation"/>
-    <entry group="0052" element="0033" keyword="SeamLineLocation" vr="FD" vm="1" name="Seam Line Location"/>
-    <entry group="0052" element="0034" keyword="FirstALineLocation" vr="FD" vm="1" name="First A-line Location"/>
-    <entry group="0052" element="0036" keyword="SeamLineIndex" vr="US" vm="1" name="Seam Line Index"/>
-    <entry group="0052" element="0038" keyword="NumberOfPaddedAlines" vr="US" vm="1" name="Number of Padded A-lines"/>
-    <entry group="0052" element="0039" keyword="InterpolationType" vr="CS" vm="1" name="Interpolation Type"/>
-    <entry group="0052" element="003a" keyword="RefractiveIndexApplied" vr="CS" vm="1" name="Refractive Index Applied"/>
-    <entry group="0054" element="0010" keyword="EnergyWindowVector" vr="US" vm="1-n" name="Energy Window Vector"/>
-    <entry group="0054" element="0011" keyword="NumberOfEnergyWindows" vr="US" vm="1" name="Number of Energy Windows"/>
-    <entry group="0054" element="0012" keyword="EnergyWindowInformationSequence" vr="SQ" vm="1" name="Energy Window Information Sequence"/>
-    <entry group="0054" element="0013" keyword="EnergyWindowRangeSequence" vr="SQ" vm="1" name="Energy Window Range Sequence"/>
-    <entry group="0054" element="0014" keyword="EnergyWindowLowerLimit" vr="DS" vm="1" name="Energy Window Lower Limit"/>
-    <entry group="0054" element="0015" keyword="EnergyWindowUpperLimit" vr="DS" vm="1" name="Energy Window Upper Limit"/>
-    <entry group="0054" element="0016" keyword="RadiopharmaceuticalInformationSequence" vr="SQ" vm="1" name="Radiopharmaceutical Information Sequence"/>
-    <entry group="0054" element="0017" keyword="ResidualSyringeCounts" vr="IS" vm="1" name="Residual Syringe Counts"/>
-    <entry group="0054" element="0018" keyword="EnergyWindowName" vr="SH" vm="1" name="Energy Window Name"/>
-    <entry group="0054" element="0020" keyword="DetectorVector" vr="US" vm="1-n" name="Detector Vector"/>
-    <entry group="0054" element="0021" keyword="NumberOfDetectors" vr="US" vm="1" name="Number of Detectors"/>
-    <entry group="0054" element="0022" keyword="DetectorInformationSequence" vr="SQ" vm="1" name="Detector Information Sequence"/>
-    <entry group="0054" element="0030" keyword="PhaseVector" vr="US" vm="1-n" name="Phase Vector"/>
-    <entry group="0054" element="0031" keyword="NumberOfPhases" vr="US" vm="1" name="Number of Phases"/>
-    <entry group="0054" element="0032" keyword="PhaseInformationSequence" vr="SQ" vm="1" name="Phase Information Sequence"/>
-    <entry group="0054" element="0033" keyword="NumberOfFramesInPhase" vr="US" vm="1" name="Number of Frames in Phase"/>
-    <entry group="0054" element="0036" keyword="PhaseDelay" vr="IS" vm="1" name="Phase Delay"/>
-    <entry group="0054" element="0038" keyword="PauseBetweenFrames" vr="IS" vm="1" name="Pause Between Frames"/>
-    <entry group="0054" element="0039" keyword="PhaseDescription" vr="CS" vm="1" name="Phase Description"/>
-    <entry group="0054" element="0050" keyword="RotationVector" vr="US" vm="1-n" name="Rotation Vector"/>
-    <entry group="0054" element="0051" keyword="NumberOfRotations" vr="US" vm="1" name="Number of Rotations"/>
-    <entry group="0054" element="0052" keyword="RotationInformationSequence" vr="SQ" vm="1" name="Rotation Information Sequence"/>
-    <entry group="0054" element="0053" keyword="NumberOfFramesInRotation" vr="US" vm="1" name="Number of Frames in Rotation"/>
-    <entry group="0054" element="0060" keyword="RRIntervalVector" vr="US" vm="1-n" name="R-R Interval Vector"/>
-    <entry group="0054" element="0061" keyword="NumberOfRRIntervals" vr="US" vm="1" name="Number of R-R Intervals"/>
-    <entry group="0054" element="0062" keyword="GatedInformationSequence" vr="SQ" vm="1" name="Gated Information Sequence"/>
-    <entry group="0054" element="0063" keyword="DataInformationSequence" vr="SQ" vm="1" name="Data Information Sequence"/>
-    <entry group="0054" element="0070" keyword="TimeSlotVector" vr="US" vm="1-n" name="Time Slot Vector"/>
-    <entry group="0054" element="0071" keyword="NumberOfTimeSlots" vr="US" vm="1" name="Number of Time Slots"/>
-    <entry group="0054" element="0072" keyword="TimeSlotInformationSequence" vr="SQ" vm="1" name="Time Slot Information Sequence"/>
-    <entry group="0054" element="0073" keyword="TimeSlotTime" vr="DS" vm="1" name="Time Slot Time"/>
-    <entry group="0054" element="0080" keyword="SliceVector" vr="US" vm="1-n" name="Slice Vector"/>
-    <entry group="0054" element="0081" keyword="NumberOfSlices" vr="US" vm="1" name="Number of Slices"/>
-    <entry group="0054" element="0090" keyword="AngularViewVector" vr="US" vm="1-n" name="Angular View Vector"/>
-    <entry group="0054" element="0100" keyword="TimeSliceVector" vr="US" vm="1-n" name="Time Slice Vector"/>
-    <entry group="0054" element="0101" keyword="NumberOfTimeSlices" vr="US" vm="1" name="Number of Time Slices"/>
-    <entry group="0054" element="0200" keyword="StartAngle" vr="DS" vm="1" name="Start Angle"/>
-    <entry group="0054" element="0202" keyword="TypeOfDetectorMotion" vr="CS" vm="1" name="Type of Detector Motion"/>
-    <entry group="0054" element="0210" keyword="TriggerVector" vr="IS" vm="1-n" name="Trigger Vector"/>
-    <entry group="0054" element="0211" keyword="NumberOfTriggersInPhase" vr="US" vm="1" name="Number of Triggers in Phase"/>
-    <entry group="0054" element="0220" keyword="ViewCodeSequence" vr="SQ" vm="1" name="View Code Sequence"/>
-    <entry group="0054" element="0222" keyword="ViewModifierCodeSequence" vr="SQ" vm="1" name="View Modifier Code Sequence"/>
-    <entry group="0054" element="0300" keyword="RadionuclideCodeSequence" vr="SQ" vm="1" name="Radionuclide Code Sequence"/>
-    <entry group="0054" element="0302" keyword="AdministrationRouteCodeSequence" vr="SQ" vm="1" name="Administration Route Code Sequence"/>
-    <entry group="0054" element="0304" keyword="RadiopharmaceuticalCodeSequence" vr="SQ" vm="1" name="Radiopharmaceutical Code Sequence"/>
-    <entry group="0054" element="0306" keyword="CalibrationDataSequence" vr="SQ" vm="1" name="Calibration Data Sequence"/>
-    <entry group="0054" element="0308" keyword="EnergyWindowNumber" vr="US" vm="1" name="Energy Window Number"/>
-    <entry group="0054" element="0400" keyword="ImageID" vr="SH" vm="1" name="Image ID"/>
-    <entry group="0054" element="0410" keyword="PatientOrientationCodeSequence" vr="SQ" vm="1" name="Patient Orientation Code Sequence"/>
-    <entry group="0054" element="0412" keyword="PatientOrientationModifierCodeSequence" vr="SQ" vm="1" name="Patient Orientation Modifier Code Sequence"/>
-    <entry group="0054" element="0414" keyword="PatientGantryRelationshipCodeSequence" vr="SQ" vm="1" name="Patient Gantry Relationship Code Sequence"/>
-    <entry group="0054" element="0500" keyword="SliceProgressionDirection" vr="CS" vm="1" name="Slice Progression Direction"/>
-    <entry group="0054" element="1000" keyword="SeriesType" vr="CS" vm="2" name="Series Type"/>
-    <entry group="0054" element="1001" keyword="Units" vr="CS" vm="1" name="Units"/>
-    <entry group="0054" element="1002" keyword="CountsSource" vr="CS" vm="1" name="Counts Source"/>
-    <entry group="0054" element="1004" keyword="ReprojectionMethod" vr="CS" vm="1" name="Reprojection Method"/>
-    <entry group="0054" element="1006" keyword="SUVType" vr="CS" vm="1" name="SUV Type"/>
-    <entry group="0054" element="1100" keyword="RandomsCorrectionMethod" vr="CS" vm="1" name="Randoms Correction Method"/>
-    <entry group="0054" element="1101" keyword="AttenuationCorrectionMethod" vr="LO" vm="1" name="Attenuation Correction Method"/>
-    <entry group="0054" element="1102" keyword="DecayCorrection" vr="CS" vm="1" name="Decay Correction"/>
-    <entry group="0054" element="1103" keyword="ReconstructionMethod" vr="LO" vm="1" name="Reconstruction Method"/>
-    <entry group="0054" element="1104" keyword="DetectorLinesOfResponseUsed" vr="LO" vm="1" name="Detector Lines of Response Used"/>
-    <entry group="0054" element="1105" keyword="ScatterCorrectionMethod" vr="LO" vm="1" name="Scatter Correction Method"/>
-    <entry group="0054" element="1200" keyword="AxialAcceptance" vr="DS" vm="1" name="Axial Acceptance"/>
-    <entry group="0054" element="1201" keyword="AxialMash" vr="IS" vm="2" name="Axial Mash"/>
-    <entry group="0054" element="1202" keyword="TransverseMash" vr="IS" vm="1" name="Transverse Mash"/>
-    <entry group="0054" element="1203" keyword="DetectorElementSize" vr="DS" vm="2" name="Detector Element Size"/>
-    <entry group="0054" element="1210" keyword="CoincidenceWindowWidth" vr="DS" vm="1" name="Coincidence Window Width"/>
-    <entry group="0054" element="1220" keyword="SecondaryCountsType" vr="CS" vm="1-n" name="Secondary Counts Type"/>
-    <entry group="0054" element="1300" keyword="FrameReferenceTime" vr="DS" vm="1" name="Frame Reference Time"/>
-    <entry group="0054" element="1310" keyword="PrimaryPromptsCountsAccumulated" vr="IS" vm="1" name="Primary (Prompts) Counts Accumulated"/>
-    <entry group="0054" element="1311" keyword="SecondaryCountsAccumulated" vr="IS" vm="1-n" name="Secondary Counts Accumulated"/>
-    <entry group="0054" element="1320" keyword="SliceSensitivityFactor" vr="DS" vm="1" name="Slice Sensitivity Factor"/>
-    <entry group="0054" element="1321" keyword="DecayFactor" vr="DS" vm="1" name="Decay Factor"/>
-    <entry group="0054" element="1322" keyword="DoseCalibrationFactor" vr="DS" vm="1" name="Dose Calibration Factor"/>
-    <entry group="0054" element="1323" keyword="ScatterFractionFactor" vr="DS" vm="1" name="Scatter Fraction Factor"/>
-    <entry group="0054" element="1324" keyword="DeadTimeFactor" vr="DS" vm="1" name="Dead Time Factor"/>
-    <entry group="0054" element="1330" keyword="ImageIndex" vr="US" vm="1" name="Image Index"/>
-    <entry group="0054" element="1400" keyword="CountsIncluded" vr="CS" vm="1-n" retired="true" name="Counts Included"/>
-    <entry group="0054" element="1401" keyword="DeadTimeCorrectionFlag" vr="CS" vm="1" retired="true" name="Dead Time Correction Flag"/>
-    <entry group="0060" element="3000" keyword="HistogramSequence" vr="SQ" vm="1" name="Histogram Sequence"/>
-    <entry group="0060" element="3002" keyword="HistogramNumberOfBins" vr="US" vm="1" name="Histogram Number of Bins"/>
-    <entry group="0060" element="3004" keyword="HistogramFirstBinValue" vr="US_SS" vm="1" name="Histogram First Bin Value"/>
-    <entry group="0060" element="3006" keyword="HistogramLastBinValue" vr="US_SS" vm="1" name="Histogram Last Bin Value"/>
-    <entry group="0060" element="3008" keyword="HistogramBinWidth" vr="US" vm="1" name="Histogram Bin Width"/>
-    <entry group="0060" element="3010" keyword="HistogramExplanation" vr="LO" vm="1" name="Histogram Explanation"/>
-    <entry group="0060" element="3020" keyword="HistogramData" vr="UL" vm="1-n" name="Histogram Data"/>
-    <entry group="0062" element="0001" keyword="SegmentationType" vr="CS" vm="1" name="Segmentation Type"/>
-    <entry group="0062" element="0002" keyword="SegmentSequence" vr="SQ" vm="1" name="Segment Sequence"/>
-    <entry group="0062" element="0003" keyword="SegmentedPropertyCategoryCodeSequence" vr="SQ" vm="1" name="Segmented Property Category Code Sequence"/>
-    <entry group="0062" element="0004" keyword="SegmentNumber" vr="US" vm="1" name="Segment Number"/>
-    <entry group="0062" element="0005" keyword="SegmentLabel" vr="LO" vm="1" name="Segment Label"/>
-    <entry group="0062" element="0006" keyword="SegmentDescription" vr="ST" vm="1" name="Segment Description"/>
-    <entry group="0062" element="0008" keyword="SegmentAlgorithmType" vr="CS" vm="1" name="Segment Algorithm Type"/>
-    <entry group="0062" element="0009" keyword="SegmentAlgorithmName" vr="LO" vm="1" name="Segment Algorithm Name"/>
-    <entry group="0062" element="000a" keyword="SegmentIdentificationSequence" vr="SQ" vm="1" name="Segment Identification Sequence"/>
-    <entry group="0062" element="000b" keyword="ReferencedSegmentNumber" vr="US" vm="1-n" name="Referenced Segment Number"/>
-    <entry group="0062" element="000c" keyword="RecommendedDisplayGrayscaleValue" vr="US" vm="1" name="Recommended Display Grayscale Value"/>
-    <entry group="0062" element="000d" keyword="RecommendedDisplayCIELabValue" vr="US" vm="3" name="Recommended Display CIELab Value"/>
-    <entry group="0062" element="000e" keyword="MaximumFractionalValue" vr="US" vm="1" name="Maximum Fractional Value"/>
-    <entry group="0062" element="000f" keyword="SegmentedPropertyTypeCodeSequence" vr="SQ" vm="1" name="Segmented Property Type Code Sequence"/>
-    <entry group="0062" element="0010" keyword="SegmentationFractionalType" vr="CS" vm="1" name="Segmentation Fractional Type"/>
-    <entry group="0064" element="0002" keyword="DeformableRegistrationSequence" vr="SQ" vm="1" name="Deformable Registration Sequence"/>
-    <entry group="0064" element="0003" keyword="SourceFrameOfReferenceUID" vr="UI" vm="1" name="Source Frame of Reference UID"/>
-    <entry group="0064" element="0005" keyword="DeformableRegistrationGridSequence" vr="SQ" vm="1" name="Deformable Registration Grid Sequence"/>
-    <entry group="0064" element="0007" keyword="GridDimensions" vr="UL" vm="3" name="Grid Dimensions"/>
-    <entry group="0064" element="0008" keyword="GridResolution" vr="FD" vm="3" name="Grid Resolution"/>
-    <entry group="0064" element="0009" keyword="VectorGridData" vr="OF" vm="1" name="Vector Grid Data"/>
-    <entry group="0064" element="000f" keyword="PreDeformationMatrixRegistrationSequence" vr="SQ" vm="1" name="Pre Deformation Matrix Registration Sequence"/>
-    <entry group="0064" element="0010" keyword="PostDeformationMatrixRegistrationSequence" vr="SQ" vm="1" name="Post Deformation Matrix Registration Sequence"/>
-    <entry group="0066" element="0001" keyword="NumberOfSurfaces" vr="UL" vm="1" name="Number of Surfaces"/>
-    <entry group="0066" element="0002" keyword="SurfaceSequence" vr="SQ" vm="1" name="Surface Sequence"/>
-    <entry group="0066" element="0003" keyword="SurfaceNumber" vr="UL" vm="1" name="Surface Number"/>
-    <entry group="0066" element="0004" keyword="SurfaceComments" vr="LT" vm="1" name="Surface Comments"/>
-    <entry group="0066" element="0009" keyword="SurfaceProcessing" vr="CS" vm="1" name="Surface Processing"/>
-    <entry group="0066" element="000a" keyword="SurfaceProcessingRatio" vr="FL" vm="1" name="Surface Processing Ratio"/>
-    <entry group="0066" element="000b" keyword="SurfaceProcessingDescription" vr="LO" vm="1" name="Surface Processing Description"/>
-    <entry group="0066" element="000c" keyword="RecommendedPresentationOpacity" vr="FL" vm="1" name="Recommended Presentation Opacity"/>
-    <entry group="0066" element="000d" keyword="RecommendedPresentationType" vr="CS" vm="1" name="Recommended Presentation Type"/>
-    <entry group="0066" element="000e" keyword="FiniteVolume" vr="CS" vm="1" name="Finite Volume"/>
-    <entry group="0066" element="0010" keyword="Manifold" vr="CS" vm="1" name="Manifold"/>
-    <entry group="0066" element="0011" keyword="SurfacePointsSequence" vr="SQ" vm="1" name="Surface Points Sequence"/>
-    <entry group="0066" element="0012" keyword="SurfacePointsNormalsSequence" vr="SQ" vm="1" name="Surface Points Normals Sequence"/>
-    <entry group="0066" element="0013" keyword="SurfaceMeshPrimitivesSequence" vr="SQ" vm="1" name="Surface Mesh Primitives Sequence"/>
-    <entry group="0066" element="0015" keyword="NumberOfSurfacePoints" vr="UL" vm="1" name="Number of Surface Points"/>
-    <entry group="0066" element="0016" keyword="PointCoordinatesData" vr="OF" vm="1" name="Point Coordinates Data"/>
-    <entry group="0066" element="0017" keyword="PointPositionAccuracy" vr="FL" vm="3" name="Point Position Accuracy"/>
-    <entry group="0066" element="0018" keyword="MeanPointDistance" vr="FL" vm="1" name="Mean Point Distance"/>
-    <entry group="0066" element="0019" keyword="MaximumPointDistance" vr="FL" vm="1" name="Maximum Point Distance"/>
-    <entry group="0066" element="001a" keyword="PointsBoundingBoxCoordinates" vr="FL" vm="6" name="Points Bounding Box Coordinates"/>
-    <entry group="0066" element="001b" keyword="AxisOfRotation" vr="FL" vm="3" name="Axis of Rotation"/>
-    <entry group="0066" element="001c" keyword="CenterOfRotation" vr="FL" vm="3" name="Center of Rotation"/>
-    <entry group="0066" element="001e" keyword="NumberOfVectors" vr="UL" vm="1" name="Number of Vectors"/>
-    <entry group="0066" element="001f" keyword="VectorDimensionality" vr="US" vm="1" name="Vector Dimensionality"/>
-    <entry group="0066" element="0020" keyword="VectorAccuracy" vr="FL" vm="1-n" name="Vector Accuracy"/>
-    <entry group="0066" element="0021" keyword="VectorCoordinateData" vr="OF" vm="1" name="Vector Coordinate Data"/>
-    <entry group="0066" element="0023" keyword="TrianglePointIndexList" vr="OW" vm="1" name="Triangle Point Index List"/>
-    <entry group="0066" element="0024" keyword="EdgePointIndexList" vr="OW" vm="1" name="Edge Point Index List"/>
-    <entry group="0066" element="0025" keyword="VertexPointIndexList" vr="OW" vm="1" name="Vertex Point Index List"/>
-    <entry group="0066" element="0026" keyword="TriangleStripSequence" vr="SQ" vm="1" name="Triangle Strip Sequence"/>
-    <entry group="0066" element="0027" keyword="TriangleFanSequence" vr="SQ" vm="1" name="Triangle Fan Sequence"/>
-    <entry group="0066" element="0028" keyword="LineSequence" vr="SQ" vm="1" name="Line Sequence"/>
-    <entry group="0066" element="0029" keyword="PrimitivePointIndexList" vr="OW" vm="1" name="Primitive Point Index List"/>
-    <entry group="0066" element="002a" keyword="SurfaceCount" vr="UL" vm="1" name="Surface Count"/>
-    <entry group="0066" element="002b" keyword="ReferencedSurfaceSequence" vr="SQ" vm="1" name="Referenced Surface Sequence"/>
-    <entry group="0066" element="002c" keyword="ReferencedSurfaceNumber" vr="UL" vm="1" name="Referenced Surface Number"/>
-    <entry group="0066" element="002d" keyword="SegmentSurfaceGenerationAlgorithmIdentificationSequence" vr="SQ" vm="1" name="Segment Surface Generation Algorithm Identification Sequence"/>
-    <entry group="0066" element="002e" keyword="SegmentSurfaceSourceInstanceSequence" vr="SQ" vm="1" name="Segment Surface Source Instance Sequence"/>
-    <entry group="0066" element="002f" keyword="AlgorithmFamilyCodeSequence" vr="SQ" vm="1" name="Algorithm Family Code Sequence"/>
-    <entry group="0066" element="0030" keyword="AlgorithmNameCodeSequence" vr="SQ" vm="1" name="Algorithm Name Code Sequence"/>
-    <entry group="0066" element="0031" keyword="AlgorithmVersion" vr="LO" vm="1" name="Algorithm Version"/>
-    <entry group="0066" element="0032" keyword="AlgorithmParameters" vr="LT" vm="1" name="Algorithm Parameters"/>
-    <entry group="0066" element="0034" keyword="FacetSequence" vr="SQ" vm="1" name="Facet Sequence"/>
-    <entry group="0066" element="0035" keyword="SurfaceProcessingAlgorithmIdentificationSequence" vr="SQ" vm="1" name="Surface Processing Algorithm Identification Sequence"/>
-    <entry group="0066" element="0036" keyword="AlgorithmName" vr="LO" vm="1" name="Algorithm Name"/>
-    <entry group="0068" element="6210" keyword="ImplantSize" vr="LO" vm="1" name="Implant Size"/>
-    <entry group="0068" element="6221" keyword="ImplantTemplateVersion" vr="LO" vm="1" name="Implant Template Version"/>
-    <entry group="0068" element="6222" keyword="ReplacedImplantTemplateSequence" vr="SQ" vm="1" name="Replaced Implant Template Sequence"/>
-    <entry group="0068" element="6223" keyword="ImplantType" vr="CS" vm="1" name="Implant Type"/>
-    <entry group="0068" element="6224" keyword="DerivationImplantTemplateSequence" vr="SQ" vm="1" name="Derivation Implant Template Sequence"/>
-    <entry group="0068" element="6225" keyword="OriginalImplantTemplateSequence" vr="SQ" vm="1" name="Original Implant Template Sequence"/>
-    <entry group="0068" element="6226" keyword="EffectiveDateTime" vr="DT" vm="1" name="Effective DateTime"/>
-    <entry group="0068" element="6230" keyword="ImplantTargetAnatomySequence" vr="SQ" vm="1" name="Implant Target Anatomy Sequence"/>
-    <entry group="0068" element="6260" keyword="InformationFromManufacturerSequence" vr="SQ" vm="1" name="Information From Manufacturer Sequence"/>
-    <entry group="0068" element="6265" keyword="NotificationFromManufacturerSequence" vr="SQ" vm="1" name="Notification From Manufacturer Sequence"/>
-    <entry group="0068" element="6270" keyword="InformationIssueDateTime" vr="DT" vm="1" name="Information Issue DateTime"/>
-    <entry group="0068" element="6280" keyword="InformationSummary" vr="ST" vm="1" name="Information Summary"/>
-    <entry group="0068" element="62a0" keyword="ImplantRegulatoryDisapprovalCodeSequence" vr="SQ" vm="1" name="Implant Regulatory Disapproval Code Sequence"/>
-    <entry group="0068" element="62a5" keyword="OverallTemplateSpatialTolerance" vr="FD" vm="1" name="Overall Template Spatial Tolerance"/>
-    <entry group="0068" element="62c0" keyword="HPGLDocumentSequence" vr="SQ" vm="1" name="HPGL Document Sequence"/>
-    <entry group="0068" element="62d0" keyword="HPGLDocumentID" vr="US" vm="1" name="HPGL Document ID"/>
-    <entry group="0068" element="62d5" keyword="HPGLDocumentLabel" vr="LO" vm="1" name="HPGL Document Label"/>
-    <entry group="0068" element="62e0" keyword="ViewOrientationCodeSequence" vr="SQ" vm="1" name="View Orientation Code Sequence"/>
-    <entry group="0068" element="62f0" keyword="ViewOrientationModifier" vr="FD" vm="9" name="View Orientation Modifier"/>
-    <entry group="0068" element="62f2" keyword="HPGLDocumentScaling" vr="FD" vm="1" name="HPGL Document Scaling"/>
-    <entry group="0068" element="6300" keyword="HPGLDocument" vr="OB" vm="1" name="HPGL Document"/>
-    <entry group="0068" element="6310" keyword="HPGLContourPenNumber" vr="US" vm="1" name="HPGL Contour Pen Number"/>
-    <entry group="0068" element="6320" keyword="HPGLPenSequence" vr="SQ" vm="1" name="HPGL Pen Sequence"/>
-    <entry group="0068" element="6330" keyword="HPGLPenNumber" vr="US" vm="1" name="HPGL Pen Number"/>
-    <entry group="0068" element="6340" keyword="HPGLPenLabel" vr="LO" vm="1" name="HPGL Pen Label"/>
-    <entry group="0068" element="6345" keyword="HPGLPenDescription" vr="ST" vm="1" name="HPGL Pen Description"/>
-    <entry group="0068" element="6346" keyword="RecommendedRotationPoint" vr="FD" vm="2" name="Recommended Rotation Point"/>
-    <entry group="0068" element="6347" keyword="BoundingRectangle" vr="FD" vm="4" name="Bounding Rectangle"/>
-    <entry group="0068" element="6350" keyword="ImplantTemplate3DModelSurfaceNumber" vr="US" vm="1-n" name="Implant Template 3D Model Surface Number"/>
-    <entry group="0068" element="6360" keyword="SurfaceModelDescriptionSequence" vr="SQ" vm="1" name="Surface Model Description Sequence"/>
-    <entry group="0068" element="6380" keyword="SurfaceModelLabel" vr="LO" vm="1" name="Surface Model Label"/>
-    <entry group="0068" element="6390" keyword="SurfaceModelScalingFactor" vr="FD" vm="1" name="Surface Model Scaling Factor"/>
-    <entry group="0068" element="63a0" keyword="MaterialsCodeSequence" vr="SQ" vm="1" name="Materials Code Sequence"/>
-    <entry group="0068" element="63a4" keyword="CoatingMaterialsCodeSequence" vr="SQ" vm="1" name="Coating Materials Code Sequence"/>
-    <entry group="0068" element="63a8" keyword="ImplantTypeCodeSequence" vr="SQ" vm="1" name="Implant Type Code Sequence"/>
-    <entry group="0068" element="63ac" keyword="FixationMethodCodeSequence" vr="SQ" vm="1" name="Fixation Method Code Sequence"/>
-    <entry group="0068" element="63b0" keyword="MatingFeatureSetsSequence" vr="SQ" vm="1" name="Mating Feature Sets Sequence"/>
-    <entry group="0068" element="63c0" keyword="MatingFeatureSetID" vr="US" vm="1" name="Mating Feature Set ID"/>
-    <entry group="0068" element="63d0" keyword="MatingFeatureSetLabel" vr="LO" vm="1" name="Mating Feature Set Label"/>
-    <entry group="0068" element="63e0" keyword="MatingFeatureSequence" vr="SQ" vm="1" name="Mating Feature Sequence"/>
-    <entry group="0068" element="63f0" keyword="MatingFeatureID" vr="US" vm="1" name="Mating Feature ID"/>
-    <entry group="0068" element="6400" keyword="MatingFeatureDegreeOfFreedomSequence" vr="SQ" vm="1" name="Mating Feature Degree of Freedom Sequence"/>
-    <entry group="0068" element="6410" keyword="DegreeOfFreedomID" vr="US" vm="1" name="Degree of Freedom ID"/>
-    <entry group="0068" element="6420" keyword="DegreeOfFreedomType" vr="CS" vm="1" name="Degree of Freedom Type"/>
-    <entry group="0068" element="6430" keyword="TwoDMatingFeatureCoordinatesSequence" vr="SQ" vm="1" name="2D Mating Feature Coordinates Sequence"/>
-    <entry group="0068" element="6440" keyword="ReferencedHPGLDocumentID" vr="US" vm="1" name="Referenced HPGL Document ID"/>
-    <entry group="0068" element="6450" keyword="TwoDMatingPoint" vr="FD" vm="2" name="2D Mating Point"/>
-    <entry group="0068" element="6460" keyword="TwoDMatingAxes" vr="FD" vm="4" name="2D Mating Axes"/>
-    <entry group="0068" element="6470" keyword="TwoDDegreeOfFreedomSequence" vr="SQ" vm="1" name="2D Degree of Freedom Sequence"/>
-    <entry group="0068" element="6490" keyword="ThreeDDegreeOfFreedomAxis" vr="FD" vm="3" name="3D Degree of Freedom Axis"/>
-    <entry group="0068" element="64a0" keyword="RangeOfFreedom" vr="FD" vm="2" name="Range of Freedom"/>
-    <entry group="0068" element="64c0" keyword="ThreeDMatingPoint" vr="FD" vm="3" name="3D Mating Point"/>
-    <entry group="0068" element="64d0" keyword="ThreeDMatingAxes" vr="FD" vm="9" name="3D Mating Axes"/>
-    <entry group="0068" element="64f0" keyword="TwoDDegreeOfFreedomAxis" vr="FD" vm="3" name="2D Degree of Freedom Axis"/>
-    <entry group="0068" element="6500" keyword="PlanningLandmarkPointSequence" vr="SQ" vm="1" name="Planning Landmark Point Sequence"/>
-    <entry group="0068" element="6510" keyword="PlanningLandmarkLineSequence" vr="SQ" vm="1" name="Planning Landmark Line Sequence"/>
-    <entry group="0068" element="6520" keyword="PlanningLandmarkPlaneSequence" vr="SQ" vm="1" name="Planning Landmark Plane Sequence"/>
-    <entry group="0068" element="6530" keyword="PlanningLandmarkID" vr="US" vm="1" name="Planning Landmark ID"/>
-    <entry group="0068" element="6540" keyword="PlanningLandmarkDescription" vr="LO" vm="1" name="Planning Landmark Description"/>
-    <entry group="0068" element="6545" keyword="PlanningLandmarkIdentificationCodeSequence" vr="SQ" vm="1" name="Planning Landmark Identification Code Sequence"/>
-    <entry group="0068" element="6550" keyword="TwoDPointCoordinatesSequence" vr="SQ" vm="1" name="2D Point Coordinates Sequence"/>
-    <entry group="0068" element="6560" keyword="TwoDPointCoordinates" vr="FD" vm="2" name="2D Point Coordinates"/>
-    <entry group="0068" element="6590" keyword="ThreeDPointCoordinates" vr="FD" vm="3" name="3D Point Coordinates"/>
-    <entry group="0068" element="65a0" keyword="TwoDLineCoordinatesSequence" vr="SQ" vm="1" name="2D Line Coordinates Sequence"/>
-    <entry group="0068" element="65b0" keyword="TwoDLineCoordinates" vr="FD" vm="4" name="2D Line Coordinates"/>
-    <entry group="0068" element="65d0" keyword="ThreeDLineCoordinates" vr="FD" vm="6" name="3D Line Coordinates"/>
-    <entry group="0068" element="65e0" keyword="TwoDPlaneCoordinatesSequence" vr="SQ" vm="1" name="2D Plane Coordinates Sequence"/>
-    <entry group="0068" element="65f0" keyword="TwoDPlaneIntersection" vr="FD" vm="4" name="2D Plane Intersection"/>
-    <entry group="0068" element="6610" keyword="ThreeDPlaneOrigin" vr="FD" vm="3" name="3D Plane Origin"/>
-    <entry group="0068" element="6620" keyword="ThreeDPlaneNormal" vr="FD" vm="3" name="3D Plane Normal"/>
-    <entry group="0070" element="0001" keyword="GraphicAnnotationSequence" vr="SQ" vm="1" name="Graphic Annotation Sequence"/>
-    <entry group="0070" element="0002" keyword="GraphicLayer" vr="CS" vm="1" name="Graphic Layer"/>
-    <entry group="0070" element="0003" keyword="BoundingBoxAnnotationUnits" vr="CS" vm="1" name="Bounding Box Annotation Units"/>
-    <entry group="0070" element="0004" keyword="AnchorPointAnnotationUnits" vr="CS" vm="1" name="Anchor Point Annotation Units"/>
-    <entry group="0070" element="0005" keyword="GraphicAnnotationUnits" vr="CS" vm="1" name="Graphic Annotation Units"/>
-    <entry group="0070" element="0006" keyword="UnformattedTextValue" vr="ST" vm="1" name="Unformatted Text Value"/>
-    <entry group="0070" element="0008" keyword="TextObjectSequence" vr="SQ" vm="1" name="Text Object Sequence"/>
-    <entry group="0070" element="0009" keyword="GraphicObjectSequence" vr="SQ" vm="1" name="Graphic Object Sequence"/>
-    <entry group="0070" element="0010" keyword="BoundingBoxTopLeftHandCorner" vr="FL" vm="2" name="Bounding Box Top Left Hand Corner"/>
-    <entry group="0070" element="0011" keyword="BoundingBoxBottomRightHandCorner" vr="FL" vm="2" name="Bounding Box Bottom Right Hand Corner"/>
-    <entry group="0070" element="0012" keyword="BoundingBoxTextHorizontalJustification" vr="CS" vm="1" name="Bounding Box Text Horizontal Justification"/>
-    <entry group="0070" element="0014" keyword="AnchorPoint" vr="FL" vm="2" name="Anchor Point"/>
-    <entry group="0070" element="0015" keyword="AnchorPointVisibility" vr="CS" vm="1" name="Anchor Point Visibility"/>
-    <entry group="0070" element="0020" keyword="GraphicDimensions" vr="US" vm="1" name="Graphic Dimensions"/>
-    <entry group="0070" element="0021" keyword="NumberOfGraphicPoints" vr="US" vm="1" name="Number of Graphic Points"/>
-    <entry group="0070" element="0022" keyword="GraphicData" vr="FL" vm="2-n" name="Graphic Data"/>
-    <entry group="0070" element="0023" keyword="GraphicType" vr="CS" vm="1" name="Graphic Type"/>
-    <entry group="0070" element="0024" keyword="GraphicFilled" vr="CS" vm="1" name="Graphic Filled"/>
-    <entry group="0070" element="0040" keyword="ImageRotationRetired" vr="IS" vm="1" retired="true" name="Image Rotation (Retired)"/>
-    <entry group="0070" element="0041" keyword="ImageHorizontalFlip" vr="CS" vm="1" name="Image Horizontal Flip"/>
-    <entry group="0070" element="0042" keyword="ImageRotation" vr="US" vm="1" name="Image Rotation"/>
-    <entry group="0070" element="0050" keyword="DisplayedAreaTopLeftHandCornerTrial" vr="US" vm="2" retired="true" name="Displayed Area Top Left Hand Corner (Trial)"/>
-    <entry group="0070" element="0051" keyword="DisplayedAreaBottomRightHandCornerTrial" vr="US" vm="2" retired="true" name="Displayed Area Bottom Right Hand Corner (Trial)"/>
-    <entry group="0070" element="0052" keyword="DisplayedAreaTopLeftHandCorner" vr="SL" vm="2" name="Displayed Area Top Left Hand Corner"/>
-    <entry group="0070" element="0053" keyword="DisplayedAreaBottomRightHandCorner" vr="SL" vm="2" name="Displayed Area Bottom Right Hand Corner"/>
-    <entry group="0070" element="005a" keyword="DisplayedAreaSelectionSequence" vr="SQ" vm="1" name="Displayed Area Selection Sequence"/>
-    <entry group="0070" element="0060" keyword="GraphicLayerSequence" vr="SQ" vm="1" name="Graphic Layer Sequence"/>
-    <entry group="0070" element="0062" keyword="GraphicLayerOrder" vr="IS" vm="1" name="Graphic Layer Order"/>
-    <entry group="0070" element="0066" keyword="GraphicLayerRecommendedDisplayGrayscaleValue" vr="US" vm="1" name="Graphic Layer Recommended Display Grayscale Value"/>
-    <entry group="0070" element="0067" keyword="GraphicLayerRecommendedDisplayRGBValue" vr="US" vm="3" retired="true" name="Graphic Layer Recommended Display RGB Value"/>
-    <entry group="0070" element="0068" keyword="GraphicLayerDescription" vr="LO" vm="1" name="Graphic Layer Description"/>
-    <entry group="0070" element="0080" keyword="ContentLabel" vr="CS" vm="1" name="Content Label"/>
-    <entry group="0070" element="0081" keyword="ContentDescription" vr="LO" vm="1" name="Content Description"/>
-    <entry group="0070" element="0082" keyword="PresentationCreationDate" vr="DA" vm="1" name="Presentation Creation Date"/>
-    <entry group="0070" element="0083" keyword="PresentationCreationTime" vr="TM" vm="1" name="Presentation Creation Time"/>
-    <entry group="0070" element="0084" keyword="ContentCreatorName" vr="PN" vm="1" name="Content Creator's Name"/>
-    <entry group="0070" element="0086" keyword="ContentCreatorIdentificationCodeSequence" vr="SQ" vm="1" name="Content Creator's Identification Code Sequence"/>
-    <entry group="0070" element="0087" keyword="AlternateContentDescriptionSequence" vr="SQ" vm="1" name="Alternate Content Description Sequence"/>
-    <entry group="0070" element="0100" keyword="PresentationSizeMode" vr="CS" vm="1" name="Presentation Size Mode"/>
-    <entry group="0070" element="0101" keyword="PresentationPixelSpacing" vr="DS" vm="2" name="Presentation Pixel Spacing"/>
-    <entry group="0070" element="0102" keyword="PresentationPixelAspectRatio" vr="IS" vm="2" name="Presentation Pixel Aspect Ratio"/>
-    <entry group="0070" element="0103" keyword="PresentationPixelMagnificationRatio" vr="FL" vm="1" name="Presentation Pixel Magnification Ratio"/>
-    <entry group="0070" element="0207" keyword="GraphicGroupLabel" vr="LO" vm="1" name="Graphic Group Label"/>
-    <entry group="0070" element="0208" keyword="GraphicGroupDescription" vr="ST" vm="1" name="Graphic Group Description"/>
-    <entry group="0070" element="0209" keyword="CompoundGraphicSequence" vr="SQ" vm="1" name="Compound Graphic Sequence"/>
-    <entry group="0070" element="0226" keyword="CompoundGraphicInstanceID" vr="UL" vm="1" name="Compound Graphic Instance ID"/>
-    <entry group="0070" element="0227" keyword="FontName" vr="LO" vm="1" name="Font Name"/>
-    <entry group="0070" element="0228" keyword="FontNameType" vr="CS" vm="1" name="Font Name Type"/>
-    <entry group="0070" element="0229" keyword="CSSFontName" vr="LO" vm="1" name="CSS Font Name"/>
-    <entry group="0070" element="0230" keyword="RotationAngle" vr="FD" vm="1" name="Rotation Angle"/>
-    <entry group="0070" element="0231" keyword="TextStyleSequence" vr="SQ" vm="1" name="Text Style Sequence"/>
-    <entry group="0070" element="0232" keyword="LineStyleSequence" vr="SQ" vm="1" name="Line Style Sequence"/>
-    <entry group="0070" element="0233" keyword="FillStyleSequence" vr="SQ" vm="1" name="Fill Style Sequence"/>
-    <entry group="0070" element="0234" keyword="GraphicGroupSequence" vr="SQ" vm="1" name="Graphic Group Sequence"/>
-    <entry group="0070" element="0241" keyword="TextColorCIELabValue" vr="US" vm="3" name="Text Color CIELab Value"/>
-    <entry group="0070" element="0242" keyword="HorizontalAlignment" vr="CS" vm="1" name="Horizontal Alignment"/>
-    <entry group="0070" element="0243" keyword="VerticalAlignment" vr="CS" vm="1" name="Vertical Alignment"/>
-    <entry group="0070" element="0244" keyword="ShadowStyle" vr="CS" vm="1" name="Shadow Style"/>
-    <entry group="0070" element="0245" keyword="ShadowOffsetX" vr="FL" vm="1" name="Shadow Offset X"/>
-    <entry group="0070" element="0246" keyword="ShadowOffsetY" vr="FL" vm="1" name="Shadow Offset Y"/>
-    <entry group="0070" element="0247" keyword="ShadowColorCIELabValue" vr="US" vm="3" name="Shadow Color CIELab Value"/>
-    <entry group="0070" element="0248" keyword="Underlined" vr="CS" vm="1" name="Underlined"/>
-    <entry group="0070" element="0249" keyword="Bold" vr="CS" vm="1" name="Bold"/>
-    <entry group="0070" element="0250" keyword="Italic" vr="CS" vm="1" name="Italic"/>
-    <entry group="0070" element="0251" keyword="PatternOnColorCIELabValue" vr="US" vm="3" name="Pattern On Color CIELab Value"/>
-    <entry group="0070" element="0252" keyword="PatternOffColorCIELabValue" vr="US" vm="3" name="Pattern Off Color CIELab Value"/>
-    <entry group="0070" element="0253" keyword="LineThickness" vr="FL" vm="1" name="Line Thickness"/>
-    <entry group="0070" element="0254" keyword="LineDashingStyle" vr="CS" vm="1" name="Line Dashing Style"/>
-    <entry group="0070" element="0255" keyword="LinePattern" vr="UL" vm="1" name="Line Pattern"/>
-    <entry group="0070" element="0256" keyword="FillPattern" vr="OB" vm="1" name="Fill Pattern"/>
-    <entry group="0070" element="0257" keyword="FillMode" vr="CS" vm="1" name="Fill Mode"/>
-    <entry group="0070" element="0258" keyword="ShadowOpacity" vr="FL" vm="1" name="Shadow Opacity"/>
-    <entry group="0070" element="0261" keyword="GapLength" vr="FL" vm="1" name="Gap Length"/>
-    <entry group="0070" element="0262" keyword="DiameterOfVisibility" vr="FL" vm="1" name="Diameter of Visibility"/>
-    <entry group="0070" element="0273" keyword="RotationPoint" vr="FL" vm="2" name="Rotation Point"/>
-    <entry group="0070" element="0274" keyword="TickAlignment" vr="CS" vm="1" name="Tick Alignment"/>
-    <entry group="0070" element="0278" keyword="ShowTickLabel" vr="CS" vm="1" name="Show Tick Label"/>
-    <entry group="0070" element="0279" keyword="TickLabelAlignment" vr="CS" vm="1" name="Tick Label Alignment"/>
-    <entry group="0070" element="0282" keyword="CompoundGraphicUnits" vr="CS" vm="1" name="Compound Graphic Units"/>
-    <entry group="0070" element="0284" keyword="PatternOnOpacity" vr="FL" vm="1" name="Pattern On Opacity"/>
-    <entry group="0070" element="0285" keyword="PatternOffOpacity" vr="FL" vm="1" name="Pattern Off Opacity"/>
-    <entry group="0070" element="0287" keyword="MajorTicksSequence" vr="SQ" vm="1" name="Major Ticks Sequence"/>
-    <entry group="0070" element="0288" keyword="TickPosition" vr="FL" vm="1" name="Tick Position"/>
-    <entry group="0070" element="0289" keyword="TickLabel" vr="SH" vm="1" name="Tick Label"/>
-    <entry group="0070" element="0294" keyword="CompoundGraphicType" vr="CS" vm="1" name="Compound Graphic Type"/>
-    <entry group="0070" element="0295" keyword="GraphicGroupID" vr="UL" vm="1" name="Graphic Group ID"/>
-    <entry group="0070" element="0306" keyword="ShapeType" vr="CS" vm="1" name="Shape Type"/>
-    <entry group="0070" element="0308" keyword="RegistrationSequence" vr="SQ" vm="1" name="Registration Sequence"/>
-    <entry group="0070" element="0309" keyword="MatrixRegistrationSequence" vr="SQ" vm="1" name="Matrix Registration Sequence"/>
-    <entry group="0070" element="030a" keyword="MatrixSequence" vr="SQ" vm="1" name="Matrix Sequence"/>
-    <entry group="0070" element="030c" keyword="FrameOfReferenceTransformationMatrixType" vr="CS" vm="1" name="Frame of Reference Transformation Matrix Type"/>
-    <entry group="0070" element="030d" keyword="RegistrationTypeCodeSequence" vr="SQ" vm="1" name="Registration Type Code Sequence"/>
-    <entry group="0070" element="030f" keyword="FiducialDescription" vr="ST" vm="1" name="Fiducial Description"/>
-    <entry group="0070" element="0310" keyword="FiducialIdentifier" vr="SH" vm="1" name="Fiducial Identifier"/>
-    <entry group="0070" element="0311" keyword="FiducialIdentifierCodeSequence" vr="SQ" vm="1" name="Fiducial Identifier Code Sequence"/>
-    <entry group="0070" element="0312" keyword="ContourUncertaintyRadius" vr="FD" vm="1" name="Contour Uncertainty Radius"/>
-    <entry group="0070" element="0314" keyword="UsedFiducialsSequence" vr="SQ" vm="1" name="Used Fiducials Sequence"/>
-    <entry group="0070" element="0318" keyword="GraphicCoordinatesDataSequence" vr="SQ" vm="1" name="Graphic Coordinates Data Sequence"/>
-    <entry group="0070" element="031a" keyword="FiducialUID" vr="UI" vm="1" name="Fiducial UID"/>
-    <entry group="0070" element="031c" keyword="FiducialSetSequence" vr="SQ" vm="1" name="Fiducial Set Sequence"/>
-    <entry group="0070" element="031e" keyword="FiducialSequence" vr="SQ" vm="1" name="Fiducial Sequence"/>
-    <entry group="0070" element="0401" keyword="GraphicLayerRecommendedDisplayCIELabValue" vr="US" vm="3" name="Graphic Layer Recommended Display CIELab Value"/>
-    <entry group="0070" element="0402" keyword="BlendingSequence" vr="SQ" vm="1" name="Blending Sequence"/>
-    <entry group="0070" element="0403" keyword="RelativeOpacity" vr="FL" vm="1" name="Relative Opacity"/>
-    <entry group="0070" element="0404" keyword="ReferencedSpatialRegistrationSequence" vr="SQ" vm="1" name="Referenced Spatial Registration Sequence"/>
-    <entry group="0070" element="0405" keyword="BlendingPosition" vr="CS" vm="1" name="Blending Position"/>
-    <entry group="0072" element="0002" keyword="HangingProtocolName" vr="SH" vm="1" name="Hanging Protocol Name"/>
-    <entry group="0072" element="0004" keyword="HangingProtocolDescription" vr="LO" vm="1" name="Hanging Protocol Description"/>
-    <entry group="0072" element="0006" keyword="HangingProtocolLevel" vr="CS" vm="1" name="Hanging Protocol Level"/>
-    <entry group="0072" element="0008" keyword="HangingProtocolCreator" vr="LO" vm="1" name="Hanging Protocol Creator"/>
-    <entry group="0072" element="000a" keyword="HangingProtocolCreationDateTime" vr="DT" vm="1" name="Hanging Protocol Creation DateTime"/>
-    <entry group="0072" element="000c" keyword="HangingProtocolDefinitionSequence" vr="SQ" vm="1" name="Hanging Protocol Definition Sequence"/>
-    <entry group="0072" element="000e" keyword="HangingProtocolUserIdentificationCodeSequence" vr="SQ" vm="1" name="Hanging Protocol User Identification Code Sequence"/>
-    <entry group="0072" element="0010" keyword="HangingProtocolUserGroupName" vr="LO" vm="1" name="Hanging Protocol User Group Name"/>
-    <entry group="0072" element="0012" keyword="SourceHangingProtocolSequence" vr="SQ" vm="1" name="Source Hanging Protocol Sequence"/>
-    <entry group="0072" element="0014" keyword="NumberOfPriorsReferenced" vr="US" vm="1" name="Number of Priors Referenced"/>
-    <entry group="0072" element="0020" keyword="ImageSetsSequence" vr="SQ" vm="1" name="Image Sets Sequence"/>
-    <entry group="0072" element="0022" keyword="ImageSetSelectorSequence" vr="SQ" vm="1" name="Image Set Selector Sequence"/>
-    <entry group="0072" element="0024" keyword="ImageSetSelectorUsageFlag" vr="CS" vm="1" name="Image Set Selector Usage Flag"/>
-    <entry group="0072" element="0026" keyword="SelectorAttribute" vr="AT" vm="1" name="Selector Attribute"/>
-    <entry group="0072" element="0028" keyword="SelectorValueNumber" vr="US" vm="1" name="Selector Value Number"/>
-    <entry group="0072" element="0030" keyword="TimeBasedImageSetsSequence" vr="SQ" vm="1" name="Time Based Image Sets Sequence"/>
-    <entry group="0072" element="0032" keyword="ImageSetNumber" vr="US" vm="1" name="Image Set Number"/>
-    <entry group="0072" element="0034" keyword="ImageSetSelectorCategory" vr="CS" vm="1" name="Image Set Selector Category"/>
-    <entry group="0072" element="0038" keyword="RelativeTime" vr="US" vm="2" name="Relative Time"/>
-    <entry group="0072" element="003a" keyword="RelativeTimeUnits" vr="CS" vm="1" name="Relative Time Units"/>
-    <entry group="0072" element="003c" keyword="AbstractPriorValue" vr="SS" vm="2" name="Abstract Prior Value"/>
-    <entry group="0072" element="003e" keyword="AbstractPriorCodeSequence" vr="SQ" vm="1" name="Abstract Prior Code Sequence"/>
-    <entry group="0072" element="0040" keyword="ImageSetLabel" vr="LO" vm="1" name="Image Set Label"/>
-    <entry group="0072" element="0050" keyword="SelectorAttributeVR" vr="CS" vm="1" name="Selector Attribute VR"/>
-    <entry group="0072" element="0052" keyword="SelectorSequencePointer" vr="AT" vm="1-n" name="Selector Sequence Pointer"/>
-    <entry group="0072" element="0054" keyword="SelectorSequencePointerPrivateCreator" vr="LO" vm="1-n" name="Selector Sequence Pointer Private Creator"/>
-    <entry group="0072" element="0056" keyword="SelectorAttributePrivateCreator" vr="LO" vm="1" name="Selector Attribute Private Creator"/>
-    <entry group="0072" element="0060" keyword="SelectorATValue" vr="AT" vm="1-n" name="Selector AT Value"/>
-    <entry group="0072" element="0062" keyword="SelectorCSValue" vr="CS" vm="1-n" name="Selector CS Value"/>
-    <entry group="0072" element="0064" keyword="SelectorISValue" vr="IS" vm="1-n" name="Selector IS Value"/>
-    <entry group="0072" element="0066" keyword="SelectorLOValue" vr="LO" vm="1-n" name="Selector LO Value"/>
-    <entry group="0072" element="0068" keyword="SelectorLTValue" vr="LT" vm="1" name="Selector LT Value"/>
-    <entry group="0072" element="006a" keyword="SelectorPNValue" vr="PN" vm="1-n" name="Selector PN Value"/>
-    <entry group="0072" element="006c" keyword="SelectorSHValue" vr="SH" vm="1-n" name="Selector SH Value"/>
-    <entry group="0072" element="006e" keyword="SelectorSTValue" vr="ST" vm="1" name="Selector ST Value"/>
-    <entry group="0072" element="0070" keyword="SelectorUTValue" vr="UT" vm="1" name="Selector UT Value"/>
-    <entry group="0072" element="0072" keyword="SelectorDSValue" vr="DS" vm="1-n" name="Selector DS Value"/>
-    <entry group="0072" element="0074" keyword="SelectorFDValue" vr="FD" vm="1-n" name="Selector FD Value"/>
-    <entry group="0072" element="0076" keyword="SelectorFLValue" vr="FL" vm="1-n" name="Selector FL Value"/>
-    <entry group="0072" element="0078" keyword="SelectorULValue" vr="UL" vm="1-n" name="Selector UL Value"/>
-    <entry group="0072" element="007a" keyword="SelectorUSValue" vr="US" vm="1-n" name="Selector US Value"/>
-    <entry group="0072" element="007c" keyword="SelectorSLValue" vr="SL" vm="1-n" name="Selector SL Value"/>
-    <entry group="0072" element="007e" keyword="SelectorSSValue" vr="SS" vm="1-n" name="Selector SS Value"/>
-    <entry group="0072" element="0080" keyword="SelectorCodeSequenceValue" vr="SQ" vm="1" name="Selector Code Sequence Value"/>
-    <entry group="0072" element="0100" keyword="NumberOfScreens" vr="US" vm="1" name="Number of Screens"/>
-    <entry group="0072" element="0102" keyword="NominalScreenDefinitionSequence" vr="SQ" vm="1" name="Nominal Screen Definition Sequence"/>
-    <entry group="0072" element="0104" keyword="NumberOfVerticalPixels" vr="US" vm="1" name="Number of Vertical Pixels"/>
-    <entry group="0072" element="0106" keyword="NumberOfHorizontalPixels" vr="US" vm="1" name="Number of Horizontal Pixels"/>
-    <entry group="0072" element="0108" keyword="DisplayEnvironmentSpatialPosition" vr="FD" vm="4" name="Display Environment Spatial Position"/>
-    <entry group="0072" element="010a" keyword="ScreenMinimumGrayscaleBitDepth" vr="US" vm="1" name="Screen Minimum Grayscale Bit Depth"/>
-    <entry group="0072" element="010c" keyword="ScreenMinimumColorBitDepth" vr="US" vm="1" name="Screen Minimum Color Bit Depth"/>
-    <entry group="0072" element="010e" keyword="ApplicationMaximumRepaintTime" vr="US" vm="1" name="Application Maximum Repaint Time"/>
-    <entry group="0072" element="0200" keyword="DisplaySetsSequence" vr="SQ" vm="1" name="Display Sets Sequence"/>
-    <entry group="0072" element="0202" keyword="DisplaySetNumber" vr="US" vm="1" name="Display Set Number"/>
-    <entry group="0072" element="0203" keyword="DisplaySetLabel" vr="LO" vm="1" name="Display Set Label"/>
-    <entry group="0072" element="0204" keyword="DisplaySetPresentationGroup" vr="US" vm="1" name="Display Set Presentation Group"/>
-    <entry group="0072" element="0206" keyword="DisplaySetPresentationGroupDescription" vr="LO" vm="1" name="Display Set Presentation Group Description"/>
-    <entry group="0072" element="0208" keyword="PartialDataDisplayHandling" vr="CS" vm="1" name="Partial Data Display Handling"/>
-    <entry group="0072" element="0210" keyword="SynchronizedScrollingSequence" vr="SQ" vm="1" name="Synchronized Scrolling Sequence"/>
-    <entry group="0072" element="0212" keyword="DisplaySetScrollingGroup" vr="US" vm="2-n" name="Display Set Scrolling Group"/>
-    <entry group="0072" element="0214" keyword="NavigationIndicatorSequence" vr="SQ" vm="1" name="Navigation Indicator Sequence"/>
-    <entry group="0072" element="0216" keyword="NavigationDisplaySet" vr="US" vm="1" name="Navigation Display Set"/>
-    <entry group="0072" element="0218" keyword="ReferenceDisplaySets" vr="US" vm="1-n" name="Reference Display Sets"/>
-    <entry group="0072" element="0300" keyword="ImageBoxesSequence" vr="SQ" vm="1" name="Image Boxes Sequence"/>
-    <entry group="0072" element="0302" keyword="ImageBoxNumber" vr="US" vm="1" name="Image Box Number"/>
-    <entry group="0072" element="0304" keyword="ImageBoxLayoutType" vr="CS" vm="1" name="Image Box Layout Type"/>
-    <entry group="0072" element="0306" keyword="ImageBoxTileHorizontalDimension" vr="US" vm="1" name="Image Box Tile Horizontal Dimension"/>
-    <entry group="0072" element="0308" keyword="ImageBoxTileVerticalDimension" vr="US" vm="1" name="Image Box Tile Vertical Dimension"/>
-    <entry group="0072" element="0310" keyword="ImageBoxScrollDirection" vr="CS" vm="1" name="Image Box Scroll Direction"/>
-    <entry group="0072" element="0312" keyword="ImageBoxSmallScrollType" vr="CS" vm="1" name="Image Box Small Scroll Type"/>
-    <entry group="0072" element="0314" keyword="ImageBoxSmallScrollAmount" vr="US" vm="1" name="Image Box Small Scroll Amount"/>
-    <entry group="0072" element="0316" keyword="ImageBoxLargeScrollType" vr="CS" vm="1" name="Image Box Large Scroll Type"/>
-    <entry group="0072" element="0318" keyword="ImageBoxLargeScrollAmount" vr="US" vm="1" name="Image Box Large Scroll Amount"/>
-    <entry group="0072" element="0320" keyword="ImageBoxOverlapPriority" vr="US" vm="1" name="Image Box Overlap Priority"/>
-    <entry group="0072" element="0330" keyword="CineRelativeToRealTime" vr="FD" vm="1" name="Cine Relative to Real-Time"/>
-    <entry group="0072" element="0400" keyword="FilterOperationsSequence" vr="SQ" vm="1" name="Filter Operations Sequence"/>
-    <entry group="0072" element="0402" keyword="FilterByCategory" vr="CS" vm="1" name="Filter-by Category"/>
-    <entry group="0072" element="0404" keyword="FilterByAttributePresence" vr="CS" vm="1" name="Filter-by Attribute Presence"/>
-    <entry group="0072" element="0406" keyword="FilterByOperator" vr="CS" vm="1" name="Filter-by Operator"/>
-    <entry group="0072" element="0420" keyword="StructuredDisplayBackgroundCIELabValue" vr="US" vm="3" name="Structured Display Background CIELab Value"/>
-    <entry group="0072" element="0421" keyword="EmptyImageBoxCIELabValue" vr="US" vm="3" name="Empty Image Box CIELab Value"/>
-    <entry group="0072" element="0422" keyword="StructuredDisplayImageBoxSequence" vr="SQ" vm="1" name="Structured Display Image Box Sequence"/>
-    <entry group="0072" element="0424" keyword="StructuredDisplayTextBoxSequence" vr="SQ" vm="1" name="Structured Display Text Box Sequence"/>
-    <entry group="0072" element="0427" keyword="ReferencedFirstFrameSequence" vr="SQ" vm="1" name="Referenced First Frame Sequence"/>
-    <entry group="0072" element="0430" keyword="ImageBoxSynchronizationSequence" vr="SQ" vm="1" name="Image Box Synchronization Sequence"/>
-    <entry group="0072" element="0432" keyword="SynchronizedImageBoxList" vr="US" vm="2-n" name="Synchronized Image Box List"/>
-    <entry group="0072" element="0434" keyword="TypeOfSynchronization" vr="CS" vm="1" name="Type of Synchronization"/>
-    <entry group="0072" element="0500" keyword="BlendingOperationType" vr="CS" vm="1" name="Blending Operation Type"/>
-    <entry group="0072" element="0510" keyword="ReformattingOperationType" vr="CS" vm="1" name="Reformatting Operation Type"/>
-    <entry group="0072" element="0512" keyword="ReformattingThickness" vr="FD" vm="1" name="Reformatting Thickness"/>
-    <entry group="0072" element="0514" keyword="ReformattingInterval" vr="FD" vm="1" name="Reformatting Interval"/>
-    <entry group="0072" element="0516" keyword="ReformattingOperationInitialViewDirection" vr="CS" vm="1" name="Reformatting Operation Initial View Direction"/>
-    <entry group="0072" element="0520" keyword="ThreeDRenderingType" vr="CS" vm="1-n" name="3D Rendering Type"/>
-    <entry group="0072" element="0600" keyword="SortingOperationsSequence" vr="SQ" vm="1" name="Sorting Operations Sequence"/>
-    <entry group="0072" element="0602" keyword="SortByCategory" vr="CS" vm="1" name="Sort-by Category"/>
-    <entry group="0072" element="0604" keyword="SortingDirection" vr="CS" vm="1" name="Sorting Direction"/>
-    <entry group="0072" element="0700" keyword="DisplaySetPatientOrientation" vr="CS" vm="2" name="Display Set Patient Orientation"/>
-    <entry group="0072" element="0702" keyword="VOIType" vr="CS" vm="1" name="VOI Type"/>
-    <entry group="0072" element="0704" keyword="PseudoColorType" vr="CS" vm="1" name="Pseudo-Color Type"/>
-    <entry group="0072" element="0705" keyword="PseudoColorPaletteInstanceReferenceSequence" vr="SQ" vm="1" name="Pseudo-Color Palette Instance Reference Sequence"/>
-    <entry group="0072" element="0706" keyword="ShowGrayscaleInverted" vr="CS" vm="1" name="Show Grayscale Inverted"/>
-    <entry group="0072" element="0710" keyword="ShowImageTrueSizeFlag" vr="CS" vm="1" name="Show Image True Size Flag"/>
-    <entry group="0072" element="0712" keyword="ShowGraphicAnnotationFlag" vr="CS" vm="1" name="Show Graphic Annotation Flag"/>
-    <entry group="0072" element="0714" keyword="ShowPatientDemographicsFlag" vr="CS" vm="1" name="Show Patient Demographics Flag"/>
-    <entry group="0072" element="0716" keyword="ShowAcquisitionTechniquesFlag" vr="CS" vm="1" name="Show Acquisition Techniques Flag"/>
-    <entry group="0072" element="0717" keyword="DisplaySetHorizontalJustification" vr="CS" vm="1" name="Display Set Horizontal Justification"/>
-    <entry group="0072" element="0718" keyword="DisplaySetVerticalJustification" vr="CS" vm="1" name="Display Set Vertical Justification"/>
-    <entry group="0074" element="0120" keyword="ContinuationStartMeterset" vr="FD" vm="1" name="Continuation Start Meterset"/>
-    <entry group="0074" element="0121" keyword="ContinuationEndMeterset" vr="FD" vm="1" name="Continuation End Meterset"/>
-    <entry group="0074" element="1000" keyword="ProcedureStepState" vr="CS" vm="1" name="Procedure Step State"/>
-    <entry group="0074" element="1002" keyword="ProcedureStepProgressInformationSequence" vr="SQ" vm="1" name="Procedure Step Progress Information Sequence"/>
-    <entry group="0074" element="1004" keyword="ProcedureStepProgress" vr="DS" vm="1" name="Procedure Step Progress"/>
-    <entry group="0074" element="1006" keyword="ProcedureStepProgressDescription" vr="ST" vm="1" name="Procedure Step Progress Description"/>
-    <entry group="0074" element="1008" keyword="ProcedureStepCommunicationsURISequence" vr="SQ" vm="1" name="Procedure Step Communications URI Sequence"/>
-    <entry group="0074" element="100a" keyword="ContactURI" vr="ST" vm="1" name="Contact URI"/>
-    <entry group="0074" element="100c" keyword="ContactDisplayName" vr="LO" vm="1" name="Contact Display Name"/>
-    <entry group="0074" element="100e" keyword="ProcedureStepDiscontinuationReasonCodeSequence" vr="SQ" vm="1" name="Procedure Step Discontinuation Reason Code Sequence"/>
-    <entry group="0074" element="1020" keyword="BeamTaskSequence" vr="SQ" vm="1" name="Beam Task Sequence"/>
-    <entry group="0074" element="1022" keyword="BeamTaskType" vr="CS" vm="1" name="Beam Task Type"/>
-    <entry group="0074" element="1024" keyword="BeamOrderIndexTrial" vr="IS" vm="1" retired="true" name="Beam Order Index (Trial)"/>
-    <entry group="0074" element="1026" keyword="TableTopVerticalAdjustedPosition" vr="FD" vm="1" name="Table Top Vertical Adjusted Position"/>
-    <entry group="0074" element="1027" keyword="TableTopLongitudinalAdjustedPosition" vr="FD" vm="1" name="Table Top Longitudinal Adjusted Position"/>
-    <entry group="0074" element="1028" keyword="TableTopLateralAdjustedPosition" vr="FD" vm="1" name="Table Top Lateral Adjusted Position"/>
-    <entry group="0074" element="102a" keyword="PatientSupportAdjustedAngle" vr="FD" vm="1" name="Patient Support Adjusted Angle"/>
-    <entry group="0074" element="102b" keyword="TableTopEccentricAdjustedAngle" vr="FD" vm="1" name="Table Top Eccentric Adjusted Angle"/>
-    <entry group="0074" element="102c" keyword="TableTopPitchAdjustedAngle" vr="FD" vm="1" name="Table Top Pitch Adjusted Angle"/>
-    <entry group="0074" element="102d" keyword="TableTopRollAdjustedAngle" vr="FD" vm="1" name="Table Top Roll Adjusted Angle"/>
-    <entry group="0074" element="1030" keyword="DeliveryVerificationImageSequence" vr="SQ" vm="1" name="Delivery Verification Image Sequence"/>
-    <entry group="0074" element="1032" keyword="VerificationImageTiming" vr="CS" vm="1" name="Verification Image Timing"/>
-    <entry group="0074" element="1034" keyword="DoubleExposureFlag" vr="CS" vm="1" name="Double Exposure Flag"/>
-    <entry group="0074" element="1036" keyword="DoubleExposureOrdering" vr="CS" vm="1" name="Double Exposure Ordering"/>
-    <entry group="0074" element="1038" keyword="DoubleExposureMetersetTrial" vr="DS" vm="1" retired="true" name="Double Exposure Meterset (Trial)"/>
-    <entry group="0074" element="103a" keyword="DoubleExposureFieldDeltaTrial" vr="DS" vm="4" retired="true" name="Double Exposure Field Delta (Trial)"/>
-    <entry group="0074" element="1040" keyword="RelatedReferenceRTImageSequence" vr="SQ" vm="1" name="Related Reference RT Image Sequence"/>
-    <entry group="0074" element="1042" keyword="GeneralMachineVerificationSequence" vr="SQ" vm="1" name="General Machine Verification Sequence"/>
-    <entry group="0074" element="1044" keyword="ConventionalMachineVerificationSequence" vr="SQ" vm="1" name="Conventional Machine Verification Sequence"/>
-    <entry group="0074" element="1046" keyword="IonMachineVerificationSequence" vr="SQ" vm="1" name="Ion Machine Verification Sequence"/>
-    <entry group="0074" element="1048" keyword="FailedAttributesSequence" vr="SQ" vm="1" name="Failed Attributes Sequence"/>
-    <entry group="0074" element="104a" keyword="OverriddenAttributesSequence" vr="SQ" vm="1" name="Overridden Attributes Sequence"/>
-    <entry group="0074" element="104c" keyword="ConventionalControlPointVerificationSequence" vr="SQ" vm="1" name="Conventional Control Point Verification Sequence"/>
-    <entry group="0074" element="104e" keyword="IonControlPointVerificationSequence" vr="SQ" vm="1" name="Ion Control Point Verification Sequence"/>
-    <entry group="0074" element="1050" keyword="AttributeOccurrenceSequence" vr="SQ" vm="1" name="Attribute Occurrence Sequence"/>
-    <entry group="0074" element="1052" keyword="AttributeOccurrencePointer" vr="AT" vm="1" name="Attribute Occurrence Pointer"/>
-    <entry group="0074" element="1054" keyword="AttributeItemSelector" vr="UL" vm="1" name="Attribute Item Selector"/>
-    <entry group="0074" element="1056" keyword="AttributeOccurrencePrivateCreator" vr="LO" vm="1" name="Attribute Occurrence Private Creator"/>
-    <entry group="0074" element="1057" keyword="SelectorSequencePointerItems" vr="IS" vm="1-n" name="Selector Sequence Pointer Items"/>
-    <entry group="0074" element="1200" keyword="ScheduledProcedureStepPriority" vr="CS" vm="1" name="Scheduled Procedure Step Priority"/>
-    <entry group="0074" element="1202" keyword="WorklistLabel" vr="LO" vm="1" name="Worklist Label"/>
-    <entry group="0074" element="1204" keyword="ProcedureStepLabel" vr="LO" vm="1" name="Procedure Step Label"/>
-    <entry group="0074" element="1210" keyword="ScheduledProcessingParametersSequence" vr="SQ" vm="1" name="Scheduled Processing Parameters Sequence"/>
-    <entry group="0074" element="1212" keyword="PerformedProcessingParametersSequence" vr="SQ" vm="1" name="Performed Processing Parameters Sequence"/>
-    <entry group="0074" element="1216" keyword="UnifiedProcedureStepPerformedProcedureSequence" vr="SQ" vm="1" name="Unified Procedure Step Performed Procedure Sequence"/>
-    <entry group="0074" element="1220" keyword="RelatedProcedureStepSequence" vr="SQ" vm="1" retired="true" name="Related Procedure Step Sequence"/>
-    <entry group="0074" element="1222" keyword="ProcedureStepRelationshipType" vr="LO" vm="1" retired="true" name="Procedure Step Relationship Type"/>
-    <entry group="0074" element="1224" keyword="ReplacedProcedureStepSequence" vr="SQ" vm="1" name="Replaced Procedure Step Sequence"/>
-    <entry group="0074" element="1230" keyword="DeletionLock" vr="LO" vm="1" name="Deletion Lock"/>
-    <entry group="0074" element="1234" keyword="ReceivingAE" vr="AE" vm="1" name="Receiving AE"/>
-    <entry group="0074" element="1236" keyword="RequestingAE" vr="AE" vm="1" name="Requesting AE"/>
-    <entry group="0074" element="1238" keyword="ReasonForCancellation" vr="LT" vm="1" name="Reason for Cancellation"/>
-    <entry group="0074" element="1242" keyword="SCPStatus" vr="CS" vm="1" name="SCP Status"/>
-    <entry group="0074" element="1244" keyword="SubscriptionListStatus" vr="CS" vm="1" name="Subscription List Status"/>
-    <entry group="0074" element="1246" keyword="UnifiedProcedureStepListStatus" vr="CS" vm="1" name="Unified Procedure Step List Status"/>
-    <entry group="0074" element="1324" keyword="BeamOrderIndex" vr="UL" vm="1" name="Beam Order Index"/>
-    <entry group="0074" element="1338" keyword="DoubleExposureMeterset" vr="FD" vm="1" name="Double Exposure Meterset"/>
-    <entry group="0074" element="133a" keyword="DoubleExposureFieldDelta" vr="FD" vm="4" name="Double Exposure Field Delta"/>
-    <entry group="0076" element="0001" keyword="ImplantAssemblyTemplateName" vr="LO" vm="1" name="Implant Assembly Template Name"/>
-    <entry group="0076" element="0003" keyword="ImplantAssemblyTemplateIssuer" vr="LO" vm="1" name="Implant Assembly Template Issuer"/>
-    <entry group="0076" element="0006" keyword="ImplantAssemblyTemplateVersion" vr="LO" vm="1" name="Implant Assembly Template Version"/>
-    <entry group="0076" element="0008" keyword="ReplacedImplantAssemblyTemplateSequence" vr="SQ" vm="1" name="Replaced Implant Assembly Template Sequence"/>
-    <entry group="0076" element="000a" keyword="ImplantAssemblyTemplateType" vr="CS" vm="1" name="Implant Assembly Template Type"/>
-    <entry group="0076" element="000c" keyword="OriginalImplantAssemblyTemplateSequence" vr="SQ" vm="1" name="Original Implant Assembly Template Sequence"/>
-    <entry group="0076" element="000e" keyword="DerivationImplantAssemblyTemplateSequence" vr="SQ" vm="1" name="Derivation Implant Assembly Template Sequence"/>
-    <entry group="0076" element="0010" keyword="ImplantAssemblyTemplateTargetAnatomySequence" vr="SQ" vm="1" name="Implant Assembly Template Target Anatomy Sequence"/>
-    <entry group="0076" element="0020" keyword="ProcedureTypeCodeSequence" vr="SQ" vm="1" name="Procedure Type Code Sequence"/>
-    <entry group="0076" element="0030" keyword="SurgicalTechnique" vr="LO" vm="1" name="Surgical Technique"/>
-    <entry group="0076" element="0032" keyword="ComponentTypesSequence" vr="SQ" vm="1" name="Component Types Sequence"/>
-    <entry group="0076" element="0034" keyword="ComponentTypeCodeSequence" vr="CS" vm="1" name="Component Type Code Sequence"/>
-    <entry group="0076" element="0036" keyword="ExclusiveComponentType" vr="CS" vm="1" name="Exclusive Component Type"/>
-    <entry group="0076" element="0038" keyword="MandatoryComponentType" vr="CS" vm="1" name="Mandatory Component Type"/>
-    <entry group="0076" element="0040" keyword="ComponentSequence" vr="SQ" vm="1" name="Component Sequence"/>
-    <entry group="0076" element="0055" keyword="ComponentID" vr="US" vm="1" name="Component ID"/>
-    <entry group="0076" element="0060" keyword="ComponentAssemblySequence" vr="SQ" vm="1" name="Component Assembly Sequence"/>
-    <entry group="0076" element="0070" keyword="Component1ReferencedID" vr="US" vm="1" name="Component 1 Referenced ID"/>
-    <entry group="0076" element="0080" keyword="Component1ReferencedMatingFeatureSetID" vr="US" vm="1" name="Component 1 Referenced Mating Feature Set ID"/>
-    <entry group="0076" element="0090" keyword="Component1ReferencedMatingFeatureID" vr="US" vm="1" name="Component 1 Referenced Mating Feature ID"/>
-    <entry group="0076" element="00a0" keyword="Component2ReferencedID" vr="US" vm="1" name="Component 2 Referenced ID"/>
-    <entry group="0076" element="00b0" keyword="Component2ReferencedMatingFeatureSetID" vr="US" vm="1" name="Component 2 Referenced Mating Feature Set ID"/>
-    <entry group="0076" element="00c0" keyword="Component2ReferencedMatingFeatureID" vr="US" vm="1" name="Component 2 Referenced Mating Feature ID"/>
-    <entry group="0078" element="0001" keyword="ImplantTemplateGroupName" vr="LO" vm="1" name="Implant Template Group Name"/>
-    <entry group="0078" element="0010" keyword="ImplantTemplateGroupDescription" vr="ST" vm="1" name="Implant Template Group Description"/>
-    <entry group="0078" element="0020" keyword="ImplantTemplateGroupIssuer" vr="LO" vm="1" name="Implant Template Group Issuer"/>
-    <entry group="0078" element="0024" keyword="ImplantTemplateGroupVersion" vr="LO" vm="1" name="Implant Template Group Version"/>
-    <entry group="0078" element="0026" keyword="ReplacedImplantTemplateGroupSequence" vr="SQ" vm="1" name="Replaced Implant Template Group Sequence"/>
-    <entry group="0078" element="0028" keyword="ImplantTemplateGroupTargetAnatomySequence" vr="SQ" vm="1" name="Implant Template Group Target Anatomy Sequence"/>
-    <entry group="0078" element="002a" keyword="ImplantTemplateGroupMembersSequence" vr="SQ" vm="1" name="Implant Template Group Members Sequence"/>
-    <entry group="0078" element="002e" keyword="ImplantTemplateGroupMemberID" vr="US" vm="1" name="Implant Template Group Member ID"/>
-    <entry group="0078" element="0050" keyword="ThreeDImplantTemplateGroupMemberMatchingPoint" vr="FD" vm="3" name="3D Implant Template Group Member Matching Point"/>
-    <entry group="0078" element="0060" keyword="ThreeDImplantTemplateGroupMemberMatchingAxes" vr="FD" vm="9" name="3D Implant Template Group Member Matching Axes"/>
-    <entry group="0078" element="0070" keyword="ImplantTemplateGroupMemberMatching2DCoordinatesSequence" vr="SQ" vm="1" name="Implant Template Group Member Matching 2D Coordinates Sequence"/>
-    <entry group="0078" element="0090" keyword="TwoDImplantTemplateGroupMemberMatchingPoint" vr="FD" vm="2" name="2D Implant Template Group Member Matching Point"/>
-    <entry group="0078" element="00a0" keyword="TwoDImplantTemplateGroupMemberMatchingAxes" vr="FD" vm="4" name="2D Implant Template Group Member Matching Axes"/>
-    <entry group="0078" element="00b0" keyword="ImplantTemplateGroupVariationDimensionSequence" vr="SQ" vm="1" name="Implant Template Group Variation Dimension Sequence"/>
-    <entry group="0078" element="00b2" keyword="ImplantTemplateGroupVariationDimensionName" vr="LO" vm="1" name="Implant Template Group Variation Dimension Name"/>
-    <entry group="0078" element="00b4" keyword="ImplantTemplateGroupVariationDimensionRankSequence" vr="SQ" vm="1" name="Implant Template Group Variation Dimension Rank Sequence"/>
-    <entry group="0078" element="00b6" keyword="ReferencedImplantTemplateGroupMemberID" vr="US" vm="1" name="Referenced Implant Template Group Member ID"/>
-    <entry group="0078" element="00b8" keyword="ImplantTemplateGroupVariationDimensionRank" vr="US" vm="1" name="Implant Template Group Variation Dimension Rank"/>
-    <entry group="0088" element="0130" keyword="StorageMediaFileSetID" vr="SH" vm="1" name="Storage Media File-set ID"/>
-    <entry group="0088" element="0140" keyword="StorageMediaFileSetUID" vr="UI" vm="1" name="Storage Media File-set UID"/>
-    <entry group="0088" element="0200" keyword="IconImageSequence" vr="SQ" vm="1" name="Icon Image Sequence"/>
-    <entry group="0088" element="0904" keyword="TopicTitle" vr="LO" vm="1" retired="true" name="Topic Title"/>
-    <entry group="0088" element="0906" keyword="TopicSubject" vr="ST" vm="1" retired="true" name="Topic Subject"/>
-    <entry group="0088" element="0910" keyword="TopicAuthor" vr="LO" vm="1" retired="true" name="Topic Author"/>
-    <entry group="0088" element="0912" keyword="TopicKeywords" vr="LO" vm="1-32" retired="true" name="Topic Keywords"/>
-    <entry group="0100" element="0410" keyword="SOPInstanceStatus" vr="CS" vm="1" name="SOP Instance Status"/>
-    <entry group="0100" element="0420" keyword="SOPAuthorizationDateTime" vr="DT" vm="1" name="SOP Authorization DateTime"/>
-    <entry group="0100" element="0424" keyword="SOPAuthorizationComment" vr="LT" vm="1" name="SOP Authorization Comment"/>
-    <entry group="0100" element="0426" keyword="AuthorizationEquipmentCertificationNumber" vr="LO" vm="1" name="Authorization Equipment Certification Number"/>
-    <entry group="0400" element="0005" keyword="MACIDNumber" vr="US" vm="1" name="MAC ID Number"/>
-    <entry group="0400" element="0010" keyword="MACCalculationTransferSyntaxUID" vr="UI" vm="1" name="MAC Calculation Transfer Syntax UID"/>
-    <entry group="0400" element="0015" keyword="MACAlgorithm" vr="CS" vm="1" name="MAC Algorithm"/>
-    <entry group="0400" element="0020" keyword="DataElementsSigned" vr="AT" vm="1-n" name="Data Elements Signed"/>
-    <entry group="0400" element="0100" keyword="DigitalSignatureUID" vr="UI" vm="1" name="Digital Signature UID"/>
-    <entry group="0400" element="0105" keyword="DigitalSignatureDateTime" vr="DT" vm="1" name="Digital Signature DateTime"/>
-    <entry group="0400" element="0110" keyword="CertificateType" vr="CS" vm="1" name="Certificate Type"/>
-    <entry group="0400" element="0115" keyword="CertificateOfSigner" vr="OB" vm="1" name="Certificate of Signer"/>
-    <entry group="0400" element="0120" keyword="Signature" vr="OB" vm="1" name="Signature"/>
-    <entry group="0400" element="0305" keyword="CertifiedTimestampType" vr="CS" vm="1" name="Certified Timestamp Type"/>
-    <entry group="0400" element="0310" keyword="CertifiedTimestamp" vr="OB" vm="1" name="Certified Timestamp"/>
-    <entry group="0400" element="0401" keyword="DigitalSignaturePurposeCodeSequence" vr="SQ" vm="1" name="Digital Signature Purpose Code Sequence"/>
-    <entry group="0400" element="0402" keyword="ReferencedDigitalSignatureSequence" vr="SQ" vm="1" name="Referenced Digital Signature Sequence"/>
-    <entry group="0400" element="0403" keyword="ReferencedSOPInstanceMACSequence" vr="SQ" vm="1" name="Referenced SOP Instance MAC Sequence"/>
-    <entry group="0400" element="0404" keyword="MAC" vr="OB" vm="1" name="MAC"/>
-    <entry group="0400" element="0500" keyword="EncryptedAttributesSequence" vr="SQ" vm="1" name="Encrypted Attributes Sequence"/>
-    <entry group="0400" element="0510" keyword="EncryptedContentTransferSyntaxUID" vr="UI" vm="1" name="Encrypted Content Transfer Syntax UID"/>
-    <entry group="0400" element="0520" keyword="EncryptedContent" vr="OB" vm="1" name="Encrypted Content"/>
-    <entry group="0400" element="0550" keyword="ModifiedAttributesSequence" vr="SQ" vm="1" name="Modified Attributes Sequence"/>
-    <entry group="0400" element="0561" keyword="OriginalAttributesSequence" vr="SQ" vm="1" name="Original Attributes Sequence"/>
-    <entry group="0400" element="0562" keyword="AttributeModificationDateTime" vr="DT" vm="1" name="Attribute Modification DateTime"/>
-    <entry group="0400" element="0563" keyword="ModifyingSystem" vr="LO" vm="1" name="Modifying System"/>
-    <entry group="0400" element="0564" keyword="SourceOfPreviousValues" vr="LO" vm="1" name="Source of Previous Values"/>
-    <entry group="0400" element="0565" keyword="ReasonForTheAttributeModification" vr="CS" vm="1" name="Reason for the Attribute Modification"/>
-    <entry group="1000" element="xxx0" keyword="EscapeTriplet" vr="US" vm="3" retired="true" name="Escape Triplet"/>
-    <entry group="1000" element="xxx1" keyword="RunLengthTriplet" vr="US" vm="3" retired="true" name="Run Length Triplet"/>
-    <entry group="1000" element="xxx2" keyword="HuffmanTableSize" vr="US" vm="1" retired="true" name="Huffman Table Size"/>
-    <entry group="1000" element="xxx3" keyword="HuffmanTableTriplet" vr="US" vm="3" retired="true" name="Huffman Table Triplet"/>
-    <entry group="1000" element="xxx4" keyword="ShiftTableSize" vr="US" vm="1" retired="true" name="Shift Table Size"/>
-    <entry group="1000" element="xxx5" keyword="ShiftTableTriplet" vr="US" vm="3" retired="true" name="Shift Table Triplet"/>
-    <entry group="1010" element="xxxx" keyword="ZonalMap" vr="US" vm="1-n" retired="true" name="Zonal Map"/>
-    <entry group="2000" element="0010" keyword="NumberOfCopies" vr="IS" vm="1" name="Number of Copies"/>
-    <entry group="2000" element="001e" keyword="PrinterConfigurationSequence" vr="SQ" vm="1" name="Printer Configuration Sequence"/>
-    <entry group="2000" element="0020" keyword="PrintPriority" vr="CS" vm="1" name="Print Priority"/>
-    <entry group="2000" element="0030" keyword="MediumType" vr="CS" vm="1" name="Medium Type"/>
-    <entry group="2000" element="0040" keyword="FilmDestination" vr="CS" vm="1" name="Film Destination"/>
-    <entry group="2000" element="0050" keyword="FilmSessionLabel" vr="LO" vm="1" name="Film Session Label"/>
-    <entry group="2000" element="0060" keyword="MemoryAllocation" vr="IS" vm="1" name="Memory Allocation"/>
-    <entry group="2000" element="0061" keyword="MaximumMemoryAllocation" vr="IS" vm="1" name="Maximum Memory Allocation"/>
-    <entry group="2000" element="0062" keyword="ColorImagePrintingFlag" vr="CS" vm="1" retired="true" name="Color Image Printing Flag"/>
-    <entry group="2000" element="0063" keyword="CollationFlag" vr="CS" vm="1" retired="true" name="Collation Flag"/>
-    <entry group="2000" element="0065" keyword="AnnotationFlag" vr="CS" vm="1" retired="true" name="Annotation Flag"/>
-    <entry group="2000" element="0067" keyword="ImageOverlayFlag" vr="CS" vm="1" retired="true" name="Image Overlay Flag"/>
-    <entry group="2000" element="0069" keyword="PresentationLUTFlag" vr="CS" vm="1" retired="true" name="Presentation LUT Flag"/>
-    <entry group="2000" element="006a" keyword="ImageBoxPresentationLUTFlag" vr="CS" vm="1" retired="true" name="Image Box Presentation LUT Flag"/>
-    <entry group="2000" element="00a0" keyword="MemoryBitDepth" vr="US" vm="1" name="Memory Bit Depth"/>
-    <entry group="2000" element="00a1" keyword="PrintingBitDepth" vr="US" vm="1" name="Printing Bit Depth"/>
-    <entry group="2000" element="00a2" keyword="MediaInstalledSequence" vr="SQ" vm="1" name="Media Installed Sequence"/>
-    <entry group="2000" element="00a4" keyword="OtherMediaAvailableSequence" vr="SQ" vm="1" name="Other Media Available Sequence"/>
-    <entry group="2000" element="00a8" keyword="SupportedImageDisplayFormatsSequence" vr="SQ" vm="1" name="Supported Image Display Formats Sequence"/>
-    <entry group="2000" element="0500" keyword="ReferencedFilmBoxSequence" vr="SQ" vm="1" name="Referenced Film Box Sequence"/>
-    <entry group="2000" element="0510" keyword="ReferencedStoredPrintSequence" vr="SQ" vm="1" retired="true" name="Referenced Stored Print Sequence"/>
-    <entry group="2010" element="0010" keyword="ImageDisplayFormat" vr="ST" vm="1" name="Image Display Format"/>
-    <entry group="2010" element="0030" keyword="AnnotationDisplayFormatID" vr="CS" vm="1" name="Annotation Display Format ID"/>
-    <entry group="2010" element="0040" keyword="FilmOrientation" vr="CS" vm="1" name="Film Orientation"/>
-    <entry group="2010" element="0050" keyword="FilmSizeID" vr="CS" vm="1" name="Film Size ID"/>
-    <entry group="2010" element="0052" keyword="PrinterResolutionID" vr="CS" vm="1" name="Printer Resolution ID"/>
-    <entry group="2010" element="0054" keyword="DefaultPrinterResolutionID" vr="CS" vm="1" name="Default Printer Resolution ID"/>
-    <entry group="2010" element="0060" keyword="MagnificationType" vr="CS" vm="1" name="Magnification Type"/>
-    <entry group="2010" element="0080" keyword="SmoothingType" vr="CS" vm="1" name="Smoothing Type"/>
-    <entry group="2010" element="00a6" keyword="DefaultMagnificationType" vr="CS" vm="1" name="Default Magnification Type"/>
-    <entry group="2010" element="00a7" keyword="OtherMagnificationTypesAvailable" vr="CS" vm="1-n" name="Other Magnification Types Available"/>
-    <entry group="2010" element="00a8" keyword="DefaultSmoothingType" vr="CS" vm="1" name="Default Smoothing Type"/>
-    <entry group="2010" element="00a9" keyword="OtherSmoothingTypesAvailable" vr="CS" vm="1-n" name="Other Smoothing Types Available"/>
-    <entry group="2010" element="0100" keyword="BorderDensity" vr="CS" vm="1" name="Border Density"/>
-    <entry group="2010" element="0110" keyword="EmptyImageDensity" vr="CS" vm="1" name="Empty Image Density"/>
-    <entry group="2010" element="0120" keyword="MinDensity" vr="US" vm="1" name="Min Density"/>
-    <entry group="2010" element="0130" keyword="MaxDensity" vr="US" vm="1" name="Max Density"/>
-    <entry group="2010" element="0140" keyword="Trim" vr="CS" vm="1" name="Trim"/>
-    <entry group="2010" element="0150" keyword="ConfigurationInformation" vr="ST" vm="1" name="Configuration Information"/>
-    <entry group="2010" element="0152" keyword="ConfigurationInformationDescription" vr="LT" vm="1" name="Configuration Information Description"/>
-    <entry group="2010" element="0154" keyword="MaximumCollatedFilms" vr="IS" vm="1" name="Maximum Collated Films"/>
-    <entry group="2010" element="015e" keyword="Illumination" vr="US" vm="1" name="Illumination"/>
-    <entry group="2010" element="0160" keyword="ReflectedAmbientLight" vr="US" vm="1" name="Reflected Ambient Light"/>
-    <entry group="2010" element="0376" keyword="PrinterPixelSpacing" vr="DS" vm="2" name="Printer Pixel Spacing"/>
-    <entry group="2010" element="0500" keyword="ReferencedFilmSessionSequence" vr="SQ" vm="1" name="Referenced Film Session Sequence"/>
-    <entry group="2010" element="0510" keyword="ReferencedImageBoxSequence" vr="SQ" vm="1" name="Referenced Image Box Sequence"/>
-    <entry group="2010" element="0520" keyword="ReferencedBasicAnnotationBoxSequence" vr="SQ" vm="1" name="Referenced Basic Annotation Box Sequence"/>
-    <entry group="2020" element="0010" keyword="ImageBoxPosition" vr="US" vm="1" name="Image Box Position"/>
-    <entry group="2020" element="0020" keyword="Polarity" vr="CS" vm="1" name="Polarity"/>
-    <entry group="2020" element="0030" keyword="RequestedImageSize" vr="DS" vm="1" name="Requested Image Size"/>
-    <entry group="2020" element="0040" keyword="RequestedDecimateCropBehavior" vr="CS" vm="1" name="Requested Decimate/Crop Behavior"/>
-    <entry group="2020" element="0050" keyword="RequestedResolutionID" vr="CS" vm="1" name="Requested Resolution ID"/>
-    <entry group="2020" element="00a0" keyword="RequestedImageSizeFlag" vr="CS" vm="1" name="Requested Image Size Flag"/>
-    <entry group="2020" element="00a2" keyword="DecimateCropResult" vr="CS" vm="1" name="Decimate/Crop Result"/>
-    <entry group="2020" element="0110" keyword="BasicGrayscaleImageSequence" vr="SQ" vm="1" name="Basic Grayscale Image Sequence"/>
-    <entry group="2020" element="0111" keyword="BasicColorImageSequence" vr="SQ" vm="1" name="Basic Color Image Sequence"/>
-    <entry group="2020" element="0130" keyword="ReferencedImageOverlayBoxSequence" vr="SQ" vm="1" retired="true" name="Referenced Image Overlay Box Sequence"/>
-    <entry group="2020" element="0140" keyword="ReferencedVOILUTBoxSequence" vr="SQ" vm="1" retired="true" name="Referenced VOI LUT Box Sequence"/>
-    <entry group="2030" element="0010" keyword="AnnotationPosition" vr="US" vm="1" name="Annotation Position"/>
-    <entry group="2030" element="0020" keyword="TextString" vr="LO" vm="1" name="Text String"/>
-    <entry group="2040" element="0010" keyword="ReferencedOverlayPlaneSequence" vr="SQ" vm="1" retired="true" name="Referenced Overlay Plane Sequence"/>
-    <entry group="2040" element="0011" keyword="ReferencedOverlayPlaneGroups" vr="US" vm="1-99" retired="true" name="Referenced Overlay Plane Groups"/>
-    <entry group="2040" element="0020" keyword="OverlayPixelDataSequence" vr="SQ" vm="1" retired="true" name="Overlay Pixel Data Sequence"/>
-    <entry group="2040" element="0060" keyword="OverlayMagnificationType" vr="CS" vm="1" retired="true" name="Overlay Magnification Type"/>
-    <entry group="2040" element="0070" keyword="OverlaySmoothingType" vr="CS" vm="1" retired="true" name="Overlay Smoothing Type"/>
-    <entry group="2040" element="0072" keyword="OverlayOrImageMagnification" vr="CS" vm="1" retired="true" name="Overlay or Image Magnification"/>
-    <entry group="2040" element="0074" keyword="MagnifyToNumberOfColumns" vr="US" vm="1" retired="true" name="Magnify to Number of Columns"/>
-    <entry group="2040" element="0080" keyword="OverlayForegroundDensity" vr="CS" vm="1" retired="true" name="Overlay Foreground Density"/>
-    <entry group="2040" element="0082" keyword="OverlayBackgroundDensity" vr="CS" vm="1" retired="true" name="Overlay Background Density"/>
-    <entry group="2040" element="0090" keyword="OverlayMode" vr="CS" vm="1" retired="true" name="Overlay Mode"/>
-    <entry group="2040" element="0100" keyword="ThresholdDensity" vr="CS" vm="1" retired="true" name="Threshold Density"/>
-    <entry group="2040" element="0500" keyword="ReferencedImageBoxSequenceRetired" vr="SQ" vm="1" retired="true" name="Referenced Image Box Sequence (Retired)"/>
-    <entry group="2050" element="0010" keyword="PresentationLUTSequence" vr="SQ" vm="1" name="Presentation LUT Sequence"/>
-    <entry group="2050" element="0020" keyword="PresentationLUTShape" vr="CS" vm="1" name="Presentation LUT Shape"/>
-    <entry group="2050" element="0500" keyword="ReferencedPresentationLUTSequence" vr="SQ" vm="1" name="Referenced Presentation LUT Sequence"/>
-    <entry group="2100" element="0010" keyword="PrintJobID" vr="SH" vm="1" retired="true" name="Print Job ID"/>
-    <entry group="2100" element="0020" keyword="ExecutionStatus" vr="CS" vm="1" name="Execution Status"/>
-    <entry group="2100" element="0030" keyword="ExecutionStatusInfo" vr="CS" vm="1" name="Execution Status Info"/>
-    <entry group="2100" element="0040" keyword="CreationDate" vr="DA" vm="1" name="Creation Date"/>
-    <entry group="2100" element="0050" keyword="CreationTime" vr="TM" vm="1" name="Creation Time"/>
-    <entry group="2100" element="0070" keyword="Originator" vr="AE" vm="1" name="Originator"/>
-    <entry group="2100" element="0140" keyword="DestinationAE" vr="AE" vm="1" retired="true" name="Destination AE"/>
-    <entry group="2100" element="0160" keyword="OwnerID" vr="SH" vm="1" name="Owner ID"/>
-    <entry group="2100" element="0170" keyword="NumberOfFilms" vr="IS" vm="1" name="Number of Films"/>
-    <entry group="2100" element="0500" keyword="ReferencedPrintJobSequencePullStoredPrint" vr="SQ" vm="1" retired="true" name="Referenced Print Job Sequence (Pull Stored Print)"/>
-    <entry group="2110" element="0010" keyword="PrinterStatus" vr="CS" vm="1" name="Printer Status"/>
-    <entry group="2110" element="0020" keyword="PrinterStatusInfo" vr="CS" vm="1" name="Printer Status Info"/>
-    <entry group="2110" element="0030" keyword="PrinterName" vr="LO" vm="1" name="Printer Name"/>
-    <entry group="2110" element="0099" keyword="PrintQueueID" vr="SH" vm="1" retired="true" name="Print Queue ID"/>
-    <entry group="2120" element="0010" keyword="QueueStatus" vr="CS" vm="1" retired="true" name="Queue Status"/>
-    <entry group="2120" element="0050" keyword="PrintJobDescriptionSequence" vr="SQ" vm="1" retired="true" name="Print Job Description Sequence"/>
-    <entry group="2120" element="0070" keyword="ReferencedPrintJobSequence" vr="SQ" vm="1" retired="true" name="Referenced Print Job Sequence"/>
-    <entry group="2130" element="0010" keyword="PrintManagementCapabilitiesSequence" vr="SQ" vm="1" retired="true" name="Print Management Capabilities Sequence"/>
-    <entry group="2130" element="0015" keyword="PrinterCharacteristicsSequence" vr="SQ" vm="1" retired="true" name="Printer Characteristics Sequence"/>
-    <entry group="2130" element="0030" keyword="FilmBoxContentSequence" vr="SQ" vm="1" retired="true" name="Film Box Content Sequence"/>
-    <entry group="2130" element="0040" keyword="ImageBoxContentSequence" vr="SQ" vm="1" retired="true" name="Image Box Content Sequence"/>
-    <entry group="2130" element="0050" keyword="AnnotationContentSequence" vr="SQ" vm="1" retired="true" name="Annotation Content Sequence"/>
-    <entry group="2130" element="0060" keyword="ImageOverlayBoxContentSequence" vr="SQ" vm="1" retired="true" name="Image Overlay Box Content Sequence"/>
-    <entry group="2130" element="0080" keyword="PresentationLUTContentSequence" vr="SQ" vm="1" retired="true" name="Presentation LUT Content Sequence"/>
-    <entry group="2130" element="00a0" keyword="ProposedStudySequence" vr="SQ" vm="1" retired="true" name="Proposed Study Sequence"/>
-    <entry group="2130" element="00c0" keyword="OriginalImageSequence" vr="SQ" vm="1" retired="true" name="Original Image Sequence"/>
-    <entry group="2200" element="0001" keyword="LabelUsingInformationExtractedFromInstances" vr="CS" vm="1" name="Label Using Information Extracted From Instances"/>
-    <entry group="2200" element="0002" keyword="LabelText" vr="UT" vm="1" name="Label Text"/>
-    <entry group="2200" element="0003" keyword="LabelStyleSelection" vr="CS" vm="1" name="Label Style Selection"/>
-    <entry group="2200" element="0004" keyword="MediaDisposition" vr="LT" vm="1" name="Media Disposition"/>
-    <entry group="2200" element="0005" keyword="BarcodeValue" vr="LT" vm="1" name="Barcode Value"/>
-    <entry group="2200" element="0006" keyword="BarcodeSymbology" vr="CS" vm="1" name="Barcode Symbology"/>
-    <entry group="2200" element="0007" keyword="AllowMediaSplitting" vr="CS" vm="1" name="Allow Media Splitting"/>
-    <entry group="2200" element="0008" keyword="IncludeNonDICOMObjects" vr="CS" vm="1" name="Include Non-DICOM Objects"/>
-    <entry group="2200" element="0009" keyword="IncludeDisplayApplication" vr="CS" vm="1" name="Include Display Application"/>
-    <entry group="2200" element="000a" keyword="PreserveCompositeInstancesAfterMediaCreation" vr="CS" vm="1" name="Preserve Composite Instances After Media Creation"/>
-    <entry group="2200" element="000b" keyword="TotalNumberOfPiecesOfMediaCreated" vr="US" vm="1" name="Total Number of Pieces of Media Created"/>
-    <entry group="2200" element="000c" keyword="RequestedMediaApplicationProfile" vr="LO" vm="1" name="Requested Media Application Profile"/>
-    <entry group="2200" element="000d" keyword="ReferencedStorageMediaSequence" vr="SQ" vm="1" name="Referenced Storage Media Sequence"/>
-    <entry group="2200" element="000e" keyword="FailureAttributes" vr="AT" vm="1-n" name="Failure Attributes"/>
-    <entry group="2200" element="000f" keyword="AllowLossyCompression" vr="CS" vm="1" name="Allow Lossy Compression"/>
-    <entry group="2200" element="0020" keyword="RequestPriority" vr="CS" vm="1" name="Request Priority"/>
-    <entry group="3002" element="0002" keyword="RTImageLabel" vr="SH" vm="1" name="RT Image Label"/>
-    <entry group="3002" element="0003" keyword="RTImageName" vr="LO" vm="1" name="RT Image Name"/>
-    <entry group="3002" element="0004" keyword="RTImageDescription" vr="ST" vm="1" name="RT Image Description"/>
-    <entry group="3002" element="000a" keyword="ReportedValuesOrigin" vr="CS" vm="1" name="Reported Values Origin"/>
-    <entry group="3002" element="000c" keyword="RTImagePlane" vr="CS" vm="1" name="RT Image Plane"/>
-    <entry group="3002" element="000d" keyword="XRayImageReceptorTranslation" vr="DS" vm="3" name="X-Ray Image Receptor Translation"/>
-    <entry group="3002" element="000e" keyword="XRayImageReceptorAngle" vr="DS" vm="1" name="X-Ray Image Receptor Angle"/>
-    <entry group="3002" element="0010" keyword="RTImageOrientation" vr="DS" vm="6" name="RT Image Orientation"/>
-    <entry group="3002" element="0011" keyword="ImagePlanePixelSpacing" vr="DS" vm="2" name="Image Plane Pixel Spacing"/>
-    <entry group="3002" element="0012" keyword="RTImagePosition" vr="DS" vm="2" name="RT Image Position"/>
-    <entry group="3002" element="0020" keyword="RadiationMachineName" vr="SH" vm="1" name="Radiation Machine Name"/>
-    <entry group="3002" element="0022" keyword="RadiationMachineSAD" vr="DS" vm="1" name="Radiation Machine SAD"/>
-    <entry group="3002" element="0024" keyword="RadiationMachineSSD" vr="DS" vm="1" name="Radiation Machine SSD"/>
-    <entry group="3002" element="0026" keyword="RTImageSID" vr="DS" vm="1" name="RT Image SID"/>
-    <entry group="3002" element="0028" keyword="SourceToReferenceObjectDistance" vr="DS" vm="1" name="Source to Reference Object Distance"/>
-    <entry group="3002" element="0029" keyword="FractionNumber" vr="IS" vm="1" name="Fraction Number"/>
-    <entry group="3002" element="0030" keyword="ExposureSequence" vr="SQ" vm="1" name="Exposure Sequence"/>
-    <entry group="3002" element="0032" keyword="MetersetExposure" vr="DS" vm="1" name="Meterset Exposure"/>
-    <entry group="3002" element="0034" keyword="DiaphragmPosition" vr="DS" vm="4" name="Diaphragm Position"/>
-    <entry group="3002" element="0040" keyword="FluenceMapSequence" vr="SQ" vm="1" name="Fluence Map Sequence"/>
-    <entry group="3002" element="0041" keyword="FluenceDataSource" vr="CS" vm="1" name="Fluence Data Source"/>
-    <entry group="3002" element="0042" keyword="FluenceDataScale" vr="DS" vm="1" name="Fluence Data Scale"/>
-    <entry group="3002" element="0050" keyword="PrimaryFluenceModeSequence" vr="SQ" vm="1" name="Primary Fluence Mode Sequence"/>
-    <entry group="3002" element="0051" keyword="FluenceMode" vr="CS" vm="1" name="Fluence Mode"/>
-    <entry group="3002" element="0052" keyword="FluenceModeID" vr="SH" vm="1" name="Fluence Mode ID"/>
-    <entry group="3004" element="0001" keyword="DVHType" vr="CS" vm="1" name="DVH Type"/>
-    <entry group="3004" element="0002" keyword="DoseUnits" vr="CS" vm="1" name="Dose Units"/>
-    <entry group="3004" element="0004" keyword="DoseType" vr="CS" vm="1" name="Dose Type"/>
-    <entry group="3004" element="0006" keyword="DoseComment" vr="LO" vm="1" name="Dose Comment"/>
-    <entry group="3004" element="0008" keyword="NormalizationPoint" vr="DS" vm="3" name="Normalization Point"/>
-    <entry group="3004" element="000a" keyword="DoseSummationType" vr="CS" vm="1" name="Dose Summation Type"/>
-    <entry group="3004" element="000c" keyword="GridFrameOffsetVector" vr="DS" vm="2-n" name="Grid Frame Offset Vector"/>
-    <entry group="3004" element="000e" keyword="DoseGridScaling" vr="DS" vm="1" name="Dose Grid Scaling"/>
-    <entry group="3004" element="0010" keyword="RTDoseROISequence" vr="SQ" vm="1" name="RT Dose ROI Sequence"/>
-    <entry group="3004" element="0012" keyword="DoseValue" vr="DS" vm="1" name="Dose Value"/>
-    <entry group="3004" element="0014" keyword="TissueHeterogeneityCorrection" vr="CS" vm="1-3" name="Tissue Heterogeneity Correction"/>
-    <entry group="3004" element="0040" keyword="DVHNormalizationPoint" vr="DS" vm="3" name="DVH Normalization Point"/>
-    <entry group="3004" element="0042" keyword="DVHNormalizationDoseValue" vr="DS" vm="1" name="DVH Normalization Dose Value"/>
-    <entry group="3004" element="0050" keyword="DVHSequence" vr="SQ" vm="1" name="DVH Sequence"/>
-    <entry group="3004" element="0052" keyword="DVHDoseScaling" vr="DS" vm="1" name="DVH Dose Scaling"/>
-    <entry group="3004" element="0054" keyword="DVHVolumeUnits" vr="CS" vm="1" name="DVH Volume Units"/>
-    <entry group="3004" element="0056" keyword="DVHNumberOfBins" vr="IS" vm="1" name="DVH Number of Bins"/>
-    <entry group="3004" element="0058" keyword="DVHData" vr="DS" vm="2-2n" name="DVH Data"/>
-    <entry group="3004" element="0060" keyword="DVHReferencedROISequence" vr="SQ" vm="1" name="DVH Referenced ROI Sequence"/>
-    <entry group="3004" element="0062" keyword="DVHROIContributionType" vr="CS" vm="1" name="DVH ROI Contribution Type"/>
-    <entry group="3004" element="0070" keyword="DVHMinimumDose" vr="DS" vm="1" name="DVH Minimum Dose"/>
-    <entry group="3004" element="0072" keyword="DVHMaximumDose" vr="DS" vm="1" name="DVH Maximum Dose"/>
-    <entry group="3004" element="0074" keyword="DVHMeanDose" vr="DS" vm="1" name="DVH Mean Dose"/>
-    <entry group="3006" element="0002" keyword="StructureSetLabel" vr="SH" vm="1" name="Structure Set Label"/>
-    <entry group="3006" element="0004" keyword="StructureSetName" vr="LO" vm="1" name="Structure Set Name"/>
-    <entry group="3006" element="0006" keyword="StructureSetDescription" vr="ST" vm="1" name="Structure Set Description"/>
-    <entry group="3006" element="0008" keyword="StructureSetDate" vr="DA" vm="1" name="Structure Set Date"/>
-    <entry group="3006" element="0009" keyword="StructureSetTime" vr="TM" vm="1" name="Structure Set Time"/>
-    <entry group="3006" element="0010" keyword="ReferencedFrameOfReferenceSequence" vr="SQ" vm="1" name="Referenced Frame of Reference Sequence"/>
-    <entry group="3006" element="0012" keyword="RTReferencedStudySequence" vr="SQ" vm="1" name="RT Referenced Study Sequence"/>
-    <entry group="3006" element="0014" keyword="RTReferencedSeriesSequence" vr="SQ" vm="1" name="RT Referenced Series Sequence"/>
-    <entry group="3006" element="0016" keyword="ContourImageSequence" vr="SQ" vm="1" name="Contour Image Sequence"/>
-    <entry group="3006" element="0020" keyword="StructureSetROISequence" vr="SQ" vm="1" name="Structure Set ROI Sequence"/>
-    <entry group="3006" element="0022" keyword="ROINumber" vr="IS" vm="1" name="ROI Number"/>
-    <entry group="3006" element="0024" keyword="ReferencedFrameOfReferenceUID" vr="UI" vm="1" name="Referenced Frame of Reference UID"/>
-    <entry group="3006" element="0026" keyword="ROIName" vr="LO" vm="1" name="ROI Name"/>
-    <entry group="3006" element="0028" keyword="ROIDescription" vr="ST" vm="1" name="ROI Description"/>
-    <entry group="3006" element="002a" keyword="ROIDisplayColor" vr="IS" vm="3" name="ROI Display Color"/>
-    <entry group="3006" element="002c" keyword="ROIVolume" vr="DS" vm="1" name="ROI Volume"/>
-    <entry group="3006" element="0030" keyword="RTRelatedROISequence" vr="SQ" vm="1" name="RT Related ROI Sequence"/>
-    <entry group="3006" element="0033" keyword="RTROIRelationship" vr="CS" vm="1" name="RT ROI Relationship"/>
-    <entry group="3006" element="0036" keyword="ROIGenerationAlgorithm" vr="CS" vm="1" name="ROI Generation Algorithm"/>
-    <entry group="3006" element="0038" keyword="ROIGenerationDescription" vr="LO" vm="1" name="ROI Generation Description"/>
-    <entry group="3006" element="0039" keyword="ROIContourSequence" vr="SQ" vm="1" name="ROI Contour Sequence"/>
-    <entry group="3006" element="0040" keyword="ContourSequence" vr="SQ" vm="1" name="Contour Sequence"/>
-    <entry group="3006" element="0042" keyword="ContourGeometricType" vr="CS" vm="1" name="Contour Geometric Type"/>
-    <entry group="3006" element="0044" keyword="ContourSlabThickness" vr="DS" vm="1" name="Contour Slab Thickness"/>
-    <entry group="3006" element="0045" keyword="ContourOffsetVector" vr="DS" vm="3" name="Contour Offset Vector"/>
-    <entry group="3006" element="0046" keyword="NumberOfContourPoints" vr="IS" vm="1" name="Number of Contour Points"/>
-    <entry group="3006" element="0048" keyword="ContourNumber" vr="IS" vm="1" name="Contour Number"/>
-    <entry group="3006" element="0049" keyword="AttachedContours" vr="IS" vm="1-n" name="Attached Contours"/>
-    <entry group="3006" element="0050" keyword="ContourData" vr="DS" vm="3-3n" name="Contour Data"/>
-    <entry group="3006" element="0080" keyword="RTROIObservationsSequence" vr="SQ" vm="1" name="RT ROI Observations Sequence"/>
-    <entry group="3006" element="0082" keyword="ObservationNumber" vr="IS" vm="1" name="Observation Number"/>
-    <entry group="3006" element="0084" keyword="ReferencedROINumber" vr="IS" vm="1" name="Referenced ROI Number"/>
-    <entry group="3006" element="0085" keyword="ROIObservationLabel" vr="SH" vm="1" name="ROI Observation Label"/>
-    <entry group="3006" element="0086" keyword="RTROIIdentificationCodeSequence" vr="SQ" vm="1" name="RT ROI Identification Code Sequence"/>
-    <entry group="3006" element="0088" keyword="ROIObservationDescription" vr="ST" vm="1" name="ROI Observation Description"/>
-    <entry group="3006" element="00a0" keyword="RelatedRTROIObservationsSequence" vr="SQ" vm="1" name="Related RT ROI Observations Sequence"/>
-    <entry group="3006" element="00a4" keyword="RTROIInterpretedType" vr="CS" vm="1" name="RT ROI Interpreted Type"/>
-    <entry group="3006" element="00a6" keyword="ROIInterpreter" vr="PN" vm="1" name="ROI Interpreter"/>
-    <entry group="3006" element="00b0" keyword="ROIPhysicalPropertiesSequence" vr="SQ" vm="1" name="ROI Physical Properties Sequence"/>
-    <entry group="3006" element="00b2" keyword="ROIPhysicalProperty" vr="CS" vm="1" name="ROI Physical Property"/>
-    <entry group="3006" element="00b4" keyword="ROIPhysicalPropertyValue" vr="DS" vm="1" name="ROI Physical Property Value"/>
-    <entry group="3006" element="00b6" keyword="ROIElementalCompositionSequence" vr="SQ" vm="1" name="ROI Elemental Composition Sequence"/>
-    <entry group="3006" element="00b7" keyword="ROIElementalCompositionAtomicNumber" vr="US" vm="1" name="ROI Elemental Composition Atomic Number"/>
-    <entry group="3006" element="00b8" keyword="ROIElementalCompositionAtomicMassFraction" vr="FL" vm="1" name="ROI Elemental Composition Atomic Mass Fraction"/>
-    <entry group="3006" element="00c0" keyword="FrameOfReferenceRelationshipSequence" vr="SQ" vm="1" name="Frame of Reference Relationship Sequence"/>
-    <entry group="3006" element="00c2" keyword="RelatedFrameOfReferenceUID" vr="UI" vm="1" name="Related Frame of Reference UID"/>
-    <entry group="3006" element="00c4" keyword="FrameOfReferenceTransformationType" vr="CS" vm="1" name="Frame of Reference Transformation Type"/>
-    <entry group="3006" element="00c6" keyword="FrameOfReferenceTransformationMatrix" vr="DS" vm="16" name="Frame of Reference Transformation Matrix"/>
-    <entry group="3006" element="00c8" keyword="FrameOfReferenceTransformationComment" vr="LO" vm="1" name="Frame of Reference Transformation Comment"/>
-    <entry group="3008" element="0010" keyword="MeasuredDoseReferenceSequence" vr="SQ" vm="1" name="Measured Dose Reference Sequence"/>
-    <entry group="3008" element="0012" keyword="MeasuredDoseDescription" vr="ST" vm="1" name="Measured Dose Description"/>
-    <entry group="3008" element="0014" keyword="MeasuredDoseType" vr="CS" vm="1" name="Measured Dose Type"/>
-    <entry group="3008" element="0016" keyword="MeasuredDoseValue" vr="DS" vm="1" name="Measured Dose Value"/>
-    <entry group="3008" element="0020" keyword="TreatmentSessionBeamSequence" vr="SQ" vm="1" name="Treatment Session Beam Sequence"/>
-    <entry group="3008" element="0021" keyword="TreatmentSessionIonBeamSequence" vr="SQ" vm="1" name="Treatment Session Ion Beam Sequence"/>
-    <entry group="3008" element="0022" keyword="CurrentFractionNumber" vr="IS" vm="1" name="Current Fraction Number"/>
-    <entry group="3008" element="0024" keyword="TreatmentControlPointDate" vr="DA" vm="1" name="Treatment Control Point Date"/>
-    <entry group="3008" element="0025" keyword="TreatmentControlPointTime" vr="TM" vm="1" name="Treatment Control Point Time"/>
-    <entry group="3008" element="002a" keyword="TreatmentTerminationStatus" vr="CS" vm="1" name="Treatment Termination Status"/>
-    <entry group="3008" element="002b" keyword="TreatmentTerminationCode" vr="SH" vm="1" name="Treatment Termination Code"/>
-    <entry group="3008" element="002c" keyword="TreatmentVerificationStatus" vr="CS" vm="1" name="Treatment Verification Status"/>
-    <entry group="3008" element="0030" keyword="ReferencedTreatmentRecordSequence" vr="SQ" vm="1" name="Referenced Treatment Record Sequence"/>
-    <entry group="3008" element="0032" keyword="SpecifiedPrimaryMeterset" vr="DS" vm="1" name="Specified Primary Meterset"/>
-    <entry group="3008" element="0033" keyword="SpecifiedSecondaryMeterset" vr="DS" vm="1" name="Specified Secondary Meterset"/>
-    <entry group="3008" element="0036" keyword="DeliveredPrimaryMeterset" vr="DS" vm="1" name="Delivered Primary Meterset"/>
-    <entry group="3008" element="0037" keyword="DeliveredSecondaryMeterset" vr="DS" vm="1" name="Delivered Secondary Meterset"/>
-    <entry group="3008" element="003a" keyword="SpecifiedTreatmentTime" vr="DS" vm="1" name="Specified Treatment Time"/>
-    <entry group="3008" element="003b" keyword="DeliveredTreatmentTime" vr="DS" vm="1" name="Delivered Treatment Time"/>
-    <entry group="3008" element="0040" keyword="ControlPointDeliverySequence" vr="SQ" vm="1" name="Control Point Delivery Sequence"/>
-    <entry group="3008" element="0041" keyword="IonControlPointDeliverySequence" vr="SQ" vm="1" name="Ion Control Point Delivery Sequence"/>
-    <entry group="3008" element="0042" keyword="SpecifiedMeterset" vr="DS" vm="1" name="Specified Meterset"/>
-    <entry group="3008" element="0044" keyword="DeliveredMeterset" vr="DS" vm="1" name="Delivered Meterset"/>
-    <entry group="3008" element="0045" keyword="MetersetRateSet" vr="FL" vm="1" name="Meterset Rate Set"/>
-    <entry group="3008" element="0046" keyword="MetersetRateDelivered" vr="FL" vm="1" name="Meterset Rate Delivered"/>
-    <entry group="3008" element="0047" keyword="ScanSpotMetersetsDelivered" vr="FL" vm="1-n" name="Scan Spot Metersets Delivered"/>
-    <entry group="3008" element="0048" keyword="DoseRateDelivered" vr="DS" vm="1" name="Dose Rate Delivered"/>
-    <entry group="3008" element="0050" keyword="TreatmentSummaryCalculatedDoseReferenceSequence" vr="SQ" vm="1" name="Treatment Summary Calculated Dose Reference Sequence"/>
-    <entry group="3008" element="0052" keyword="CumulativeDoseToDoseReference" vr="DS" vm="1" name="Cumulative Dose to Dose Reference"/>
-    <entry group="3008" element="0054" keyword="FirstTreatmentDate" vr="DA" vm="1" name="First Treatment Date"/>
-    <entry group="3008" element="0056" keyword="MostRecentTreatmentDate" vr="DA" vm="1" name="Most Recent Treatment Date"/>
-    <entry group="3008" element="005a" keyword="NumberOfFractionsDelivered" vr="IS" vm="1" name="Number of Fractions Delivered"/>
-    <entry group="3008" element="0060" keyword="OverrideSequence" vr="SQ" vm="1" name="Override Sequence"/>
-    <entry group="3008" element="0061" keyword="ParameterSequencePointer" vr="AT" vm="1" name="Parameter Sequence Pointer"/>
-    <entry group="3008" element="0062" keyword="OverrideParameterPointer" vr="AT" vm="1" name="Override Parameter Pointer"/>
-    <entry group="3008" element="0063" keyword="ParameterItemIndex" vr="IS" vm="1" name="Parameter Item Index"/>
-    <entry group="3008" element="0064" keyword="MeasuredDoseReferenceNumber" vr="IS" vm="1" name="Measured Dose Reference Number"/>
-    <entry group="3008" element="0065" keyword="ParameterPointer" vr="AT" vm="1" name="Parameter Pointer"/>
-    <entry group="3008" element="0066" keyword="OverrideReason" vr="ST" vm="1" name="Override Reason"/>
-    <entry group="3008" element="0068" keyword="CorrectedParameterSequence" vr="SQ" vm="1" name="Corrected Parameter Sequence"/>
-    <entry group="3008" element="006a" keyword="CorrectionValue" vr="FL" vm="1" name="Correction Value"/>
-    <entry group="3008" element="0070" keyword="CalculatedDoseReferenceSequence" vr="SQ" vm="1" name="Calculated Dose Reference Sequence"/>
-    <entry group="3008" element="0072" keyword="CalculatedDoseReferenceNumber" vr="IS" vm="1" name="Calculated Dose Reference Number"/>
-    <entry group="3008" element="0074" keyword="CalculatedDoseReferenceDescription" vr="ST" vm="1" name="Calculated Dose Reference Description"/>
-    <entry group="3008" element="0076" keyword="CalculatedDoseReferenceDoseValue" vr="DS" vm="1" name="Calculated Dose Reference Dose Value"/>
-    <entry group="3008" element="0078" keyword="StartMeterset" vr="DS" vm="1" name="Start Meterset"/>
-    <entry group="3008" element="007a" keyword="EndMeterset" vr="DS" vm="1" name="End Meterset"/>
-    <entry group="3008" element="0080" keyword="ReferencedMeasuredDoseReferenceSequence" vr="SQ" vm="1" name="Referenced Measured Dose Reference Sequence"/>
-    <entry group="3008" element="0082" keyword="ReferencedMeasuredDoseReferenceNumber" vr="IS" vm="1" name="Referenced Measured Dose Reference Number"/>
-    <entry group="3008" element="0090" keyword="ReferencedCalculatedDoseReferenceSequence" vr="SQ" vm="1" name="Referenced Calculated Dose Reference Sequence"/>
-    <entry group="3008" element="0092" keyword="ReferencedCalculatedDoseReferenceNumber" vr="IS" vm="1" name="Referenced Calculated Dose Reference Number"/>
-    <entry group="3008" element="00a0" keyword="BeamLimitingDeviceLeafPairsSequence" vr="SQ" vm="1" name="Beam Limiting Device Leaf Pairs Sequence"/>
-    <entry group="3008" element="00b0" keyword="RecordedWedgeSequence" vr="SQ" vm="1" name="Recorded Wedge Sequence"/>
-    <entry group="3008" element="00c0" keyword="RecordedCompensatorSequence" vr="SQ" vm="1" name="Recorded Compensator Sequence"/>
-    <entry group="3008" element="00d0" keyword="RecordedBlockSequence" vr="SQ" vm="1" name="Recorded Block Sequence"/>
-    <entry group="3008" element="00e0" keyword="TreatmentSummaryMeasuredDoseReferenceSequence" vr="SQ" vm="1" name="Treatment Summary Measured Dose Reference Sequence"/>
-    <entry group="3008" element="00f0" keyword="RecordedSnoutSequence" vr="SQ" vm="1" name="Recorded Snout Sequence"/>
-    <entry group="3008" element="00f2" keyword="RecordedRangeShifterSequence" vr="SQ" vm="1" name="Recorded Range Shifter Sequence"/>
-    <entry group="3008" element="00f4" keyword="RecordedLateralSpreadingDeviceSequence" vr="SQ" vm="1" name="Recorded Lateral Spreading Device Sequence"/>
-    <entry group="3008" element="00f6" keyword="RecordedRangeModulatorSequence" vr="SQ" vm="1" name="Recorded Range Modulator Sequence"/>
-    <entry group="3008" element="0100" keyword="RecordedSourceSequence" vr="SQ" vm="1" name="Recorded Source Sequence"/>
-    <entry group="3008" element="0105" keyword="SourceSerialNumber" vr="LO" vm="1" name="Source Serial Number"/>
-    <entry group="3008" element="0110" keyword="TreatmentSessionApplicationSetupSequence" vr="SQ" vm="1" name="Treatment Session Application Setup Sequence"/>
-    <entry group="3008" element="0116" keyword="ApplicationSetupCheck" vr="CS" vm="1" name="Application Setup Check"/>
-    <entry group="3008" element="0120" keyword="RecordedBrachyAccessoryDeviceSequence" vr="SQ" vm="1" name="Recorded Brachy Accessory Device Sequence"/>
-    <entry group="3008" element="0122" keyword="ReferencedBrachyAccessoryDeviceNumber" vr="IS" vm="1" name="Referenced Brachy Accessory Device Number"/>
-    <entry group="3008" element="0130" keyword="RecordedChannelSequence" vr="SQ" vm="1" name="Recorded Channel Sequence"/>
-    <entry group="3008" element="0132" keyword="SpecifiedChannelTotalTime" vr="DS" vm="1" name="Specified Channel Total Time"/>
-    <entry group="3008" element="0134" keyword="DeliveredChannelTotalTime" vr="DS" vm="1" name="Delivered Channel Total Time"/>
-    <entry group="3008" element="0136" keyword="SpecifiedNumberOfPulses" vr="IS" vm="1" name="Specified Number of Pulses"/>
-    <entry group="3008" element="0138" keyword="DeliveredNumberOfPulses" vr="IS" vm="1" name="Delivered Number of Pulses"/>
-    <entry group="3008" element="013a" keyword="SpecifiedPulseRepetitionInterval" vr="DS" vm="1" name="Specified Pulse Repetition Interval"/>
-    <entry group="3008" element="013c" keyword="DeliveredPulseRepetitionInterval" vr="DS" vm="1" name="Delivered Pulse Repetition Interval"/>
-    <entry group="3008" element="0140" keyword="RecordedSourceApplicatorSequence" vr="SQ" vm="1" name="Recorded Source Applicator Sequence"/>
-    <entry group="3008" element="0142" keyword="ReferencedSourceApplicatorNumber" vr="IS" vm="1" name="Referenced Source Applicator Number"/>
-    <entry group="3008" element="0150" keyword="RecordedChannelShieldSequence" vr="SQ" vm="1" name="Recorded Channel Shield Sequence"/>
-    <entry group="3008" element="0152" keyword="ReferencedChannelShieldNumber" vr="IS" vm="1" name="Referenced Channel Shield Number"/>
-    <entry group="3008" element="0160" keyword="BrachyControlPointDeliveredSequence" vr="SQ" vm="1" name="Brachy Control Point Delivered Sequence"/>
-    <entry group="3008" element="0162" keyword="SafePositionExitDate" vr="DA" vm="1" name="Safe Position Exit Date"/>
-    <entry group="3008" element="0164" keyword="SafePositionExitTime" vr="TM" vm="1" name="Safe Position Exit Time"/>
-    <entry group="3008" element="0166" keyword="SafePositionReturnDate" vr="DA" vm="1" name="Safe Position Return Date"/>
-    <entry group="3008" element="0168" keyword="SafePositionReturnTime" vr="TM" vm="1" name="Safe Position Return Time"/>
-    <entry group="3008" element="0200" keyword="CurrentTreatmentStatus" vr="CS" vm="1" name="Current Treatment Status"/>
-    <entry group="3008" element="0202" keyword="TreatmentStatusComment" vr="ST" vm="1" name="Treatment Status Comment"/>
-    <entry group="3008" element="0220" keyword="FractionGroupSummarySequence" vr="SQ" vm="1" name="Fraction Group Summary Sequence"/>
-    <entry group="3008" element="0223" keyword="ReferencedFractionNumber" vr="IS" vm="1" name="Referenced Fraction Number"/>
-    <entry group="3008" element="0224" keyword="FractionGroupType" vr="CS" vm="1" name="Fraction Group Type"/>
-    <entry group="3008" element="0230" keyword="BeamStopperPosition" vr="CS" vm="1" name="Beam Stopper Position"/>
-    <entry group="3008" element="0240" keyword="FractionStatusSummarySequence" vr="SQ" vm="1" name="Fraction Status Summary Sequence"/>
-    <entry group="3008" element="0250" keyword="TreatmentDate" vr="DA" vm="1" name="Treatment Date"/>
-    <entry group="3008" element="0251" keyword="TreatmentTime" vr="TM" vm="1" name="Treatment Time"/>
-    <entry group="300a" element="0002" keyword="RTPlanLabel" vr="SH" vm="1" name="RT Plan Label"/>
-    <entry group="300a" element="0003" keyword="RTPlanName" vr="LO" vm="1" name="RT Plan Name"/>
-    <entry group="300a" element="0004" keyword="RTPlanDescription" vr="ST" vm="1" name="RT Plan Description"/>
-    <entry group="300a" element="0006" keyword="RTPlanDate" vr="DA" vm="1" name="RT Plan Date"/>
-    <entry group="300a" element="0007" keyword="RTPlanTime" vr="TM" vm="1" name="RT Plan Time"/>
-    <entry group="300a" element="0009" keyword="TreatmentProtocols" vr="LO" vm="1-n" name="Treatment Protocols"/>
-    <entry group="300a" element="000a" keyword="PlanIntent" vr="CS" vm="1" name="Plan Intent"/>
-    <entry group="300a" element="000b" keyword="TreatmentSites" vr="LO" vm="1-n" name="Treatment Sites"/>
-    <entry group="300a" element="000c" keyword="RTPlanGeometry" vr="CS" vm="1" name="RT Plan Geometry"/>
-    <entry group="300a" element="000e" keyword="PrescriptionDescription" vr="ST" vm="1" name="Prescription Description"/>
-    <entry group="300a" element="0010" keyword="DoseReferenceSequence" vr="SQ" vm="1" name="Dose Reference Sequence"/>
-    <entry group="300a" element="0012" keyword="DoseReferenceNumber" vr="IS" vm="1" name="Dose Reference Number"/>
-    <entry group="300a" element="0013" keyword="DoseReferenceUID" vr="UI" vm="1" name="Dose Reference UID"/>
-    <entry group="300a" element="0014" keyword="DoseReferenceStructureType" vr="CS" vm="1" name="Dose Reference Structure Type"/>
-    <entry group="300a" element="0015" keyword="NominalBeamEnergyUnit" vr="CS" vm="1" name="Nominal Beam Energy Unit"/>
-    <entry group="300a" element="0016" keyword="DoseReferenceDescription" vr="LO" vm="1" name="Dose Reference Description"/>
-    <entry group="300a" element="0018" keyword="DoseReferencePointCoordinates" vr="DS" vm="3" name="Dose Reference Point Coordinates"/>
-    <entry group="300a" element="001a" keyword="NominalPriorDose" vr="DS" vm="1" name="Nominal Prior Dose"/>
-    <entry group="300a" element="0020" keyword="DoseReferenceType" vr="CS" vm="1" name="Dose Reference Type"/>
-    <entry group="300a" element="0021" keyword="ConstraintWeight" vr="DS" vm="1" name="Constraint Weight"/>
-    <entry group="300a" element="0022" keyword="DeliveryWarningDose" vr="DS" vm="1" name="Delivery Warning Dose"/>
-    <entry group="300a" element="0023" keyword="DeliveryMaximumDose" vr="DS" vm="1" name="Delivery Maximum Dose"/>
-    <entry group="300a" element="0025" keyword="TargetMinimumDose" vr="DS" vm="1" name="Target Minimum Dose"/>
-    <entry group="300a" element="0026" keyword="TargetPrescriptionDose" vr="DS" vm="1" name="Target Prescription Dose"/>
-    <entry group="300a" element="0027" keyword="TargetMaximumDose" vr="DS" vm="1" name="Target Maximum Dose"/>
-    <entry group="300a" element="0028" keyword="TargetUnderdoseVolumeFraction" vr="DS" vm="1" name="Target Underdose Volume Fraction"/>
-    <entry group="300a" element="002a" keyword="OrganAtRiskFullVolumeDose" vr="DS" vm="1" name="Organ at Risk Full-volume Dose"/>
-    <entry group="300a" element="002b" keyword="OrganAtRiskLimitDose" vr="DS" vm="1" name="Organ at Risk Limit Dose"/>
-    <entry group="300a" element="002c" keyword="OrganAtRiskMaximumDose" vr="DS" vm="1" name="Organ at Risk Maximum Dose"/>
-    <entry group="300a" element="002d" keyword="OrganAtRiskOverdoseVolumeFraction" vr="DS" vm="1" name="Organ at Risk Overdose Volume Fraction"/>
-    <entry group="300a" element="0040" keyword="ToleranceTableSequence" vr="SQ" vm="1" name="Tolerance Table Sequence"/>
-    <entry group="300a" element="0042" keyword="ToleranceTableNumber" vr="IS" vm="1" name="Tolerance Table Number"/>
-    <entry group="300a" element="0043" keyword="ToleranceTableLabel" vr="SH" vm="1" name="Tolerance Table Label"/>
-    <entry group="300a" element="0044" keyword="GantryAngleTolerance" vr="DS" vm="1" name="Gantry Angle Tolerance"/>
-    <entry group="300a" element="0046" keyword="BeamLimitingDeviceAngleTolerance" vr="DS" vm="1" name="Beam Limiting Device Angle Tolerance"/>
-    <entry group="300a" element="0048" keyword="BeamLimitingDeviceToleranceSequence" vr="SQ" vm="1" name="Beam Limiting Device Tolerance Sequence"/>
-    <entry group="300a" element="004a" keyword="BeamLimitingDevicePositionTolerance" vr="DS" vm="1" name="Beam Limiting Device Position Tolerance"/>
-    <entry group="300a" element="004b" keyword="SnoutPositionTolerance" vr="FL" vm="1" name="Snout Position Tolerance"/>
-    <entry group="300a" element="004c" keyword="PatientSupportAngleTolerance" vr="DS" vm="1" name="Patient Support Angle Tolerance"/>
-    <entry group="300a" element="004e" keyword="TableTopEccentricAngleTolerance" vr="DS" vm="1" name="Table Top Eccentric Angle Tolerance"/>
-    <entry group="300a" element="004f" keyword="TableTopPitchAngleTolerance" vr="FL" vm="1" name="Table Top Pitch Angle Tolerance"/>
-    <entry group="300a" element="0050" keyword="TableTopRollAngleTolerance" vr="FL" vm="1" name="Table Top Roll Angle Tolerance"/>
-    <entry group="300a" element="0051" keyword="TableTopVerticalPositionTolerance" vr="DS" vm="1" name="Table Top Vertical Position Tolerance"/>
-    <entry group="300a" element="0052" keyword="TableTopLongitudinalPositionTolerance" vr="DS" vm="1" name="Table Top Longitudinal Position Tolerance"/>
-    <entry group="300a" element="0053" keyword="TableTopLateralPositionTolerance" vr="DS" vm="1" name="Table Top Lateral Position Tolerance"/>
-    <entry group="300a" element="0055" keyword="RTPlanRelationship" vr="CS" vm="1" name="RT Plan Relationship"/>
-    <entry group="300a" element="0070" keyword="FractionGroupSequence" vr="SQ" vm="1" name="Fraction Group Sequence"/>
-    <entry group="300a" element="0071" keyword="FractionGroupNumber" vr="IS" vm="1" name="Fraction Group Number"/>
-    <entry group="300a" element="0072" keyword="FractionGroupDescription" vr="LO" vm="1" name="Fraction Group Description"/>
-    <entry group="300a" element="0078" keyword="NumberOfFractionsPlanned" vr="IS" vm="1" name="Number of Fractions Planned"/>
-    <entry group="300a" element="0079" keyword="NumberOfFractionPatternDigitsPerDay" vr="IS" vm="1" name="Number of Fraction Pattern Digits Per Day"/>
-    <entry group="300a" element="007a" keyword="RepeatFractionCycleLength" vr="IS" vm="1" name="Repeat Fraction Cycle Length"/>
-    <entry group="300a" element="007b" keyword="FractionPattern" vr="LT" vm="1" name="Fraction Pattern"/>
-    <entry group="300a" element="0080" keyword="NumberOfBeams" vr="IS" vm="1" name="Number of Beams"/>
-    <entry group="300a" element="0082" keyword="BeamDoseSpecificationPoint" vr="DS" vm="3" name="Beam Dose Specification Point"/>
-    <entry group="300a" element="0084" keyword="BeamDose" vr="DS" vm="1" name="Beam Dose"/>
-    <entry group="300a" element="0086" keyword="BeamMeterset" vr="DS" vm="1" name="Beam Meterset"/>
-    <entry group="300a" element="0088" keyword="BeamDosePointDepth" vr="FL" vm="1" name="Beam Dose Point Depth"/>
-    <entry group="300a" element="0089" keyword="BeamDosePointEquivalentDepth" vr="FL" vm="1" name="Beam Dose Point Equivalent Depth"/>
-    <entry group="300a" element="008a" keyword="BeamDosePointSSD" vr="FL" vm="1" name="Beam Dose Point SSD"/>
-    <entry group="300a" element="00a0" keyword="NumberOfBrachyApplicationSetups" vr="IS" vm="1" name="Number of Brachy Application Setups"/>
-    <entry group="300a" element="00a2" keyword="BrachyApplicationSetupDoseSpecificationPoint" vr="DS" vm="3" name="Brachy Application Setup Dose Specification Point"/>
-    <entry group="300a" element="00a4" keyword="BrachyApplicationSetupDose" vr="DS" vm="1" name="Brachy Application Setup Dose"/>
-    <entry group="300a" element="00b0" keyword="BeamSequence" vr="SQ" vm="1" name="Beam Sequence"/>
-    <entry group="300a" element="00b2" keyword="TreatmentMachineName" vr="SH" vm="1" name="Treatment Machine Name"/>
-    <entry group="300a" element="00b3" keyword="PrimaryDosimeterUnit" vr="CS" vm="1" name="Primary Dosimeter Unit"/>
-    <entry group="300a" element="00b4" keyword="SourceAxisDistance" vr="DS" vm="1" name="Source-Axis Distance"/>
-    <entry group="300a" element="00b6" keyword="BeamLimitingDeviceSequence" vr="SQ" vm="1" name="Beam Limiting Device Sequence"/>
-    <entry group="300a" element="00b8" keyword="RTBeamLimitingDeviceType" vr="CS" vm="1" name="RT Beam Limiting Device Type"/>
-    <entry group="300a" element="00ba" keyword="SourceToBeamLimitingDeviceDistance" vr="DS" vm="1" name="Source to Beam Limiting Device Distance"/>
-    <entry group="300a" element="00bb" keyword="IsocenterToBeamLimitingDeviceDistance" vr="FL" vm="1" name="Isocenter to Beam Limiting Device Distance"/>
-    <entry group="300a" element="00bc" keyword="NumberOfLeafJawPairs" vr="IS" vm="1" name="Number of Leaf/Jaw Pairs"/>
-    <entry group="300a" element="00be" keyword="LeafPositionBoundaries" vr="DS" vm="3-n" name="Leaf Position Boundaries"/>
-    <entry group="300a" element="00c0" keyword="BeamNumber" vr="IS" vm="1" name="Beam Number"/>
-    <entry group="300a" element="00c2" keyword="BeamName" vr="LO" vm="1" name="Beam Name"/>
-    <entry group="300a" element="00c3" keyword="BeamDescription" vr="ST" vm="1" name="Beam Description"/>
-    <entry group="300a" element="00c4" keyword="BeamType" vr="CS" vm="1" name="Beam Type"/>
-    <entry group="300a" element="00c6" keyword="RadiationType" vr="CS" vm="1" name="Radiation Type"/>
-    <entry group="300a" element="00c7" keyword="HighDoseTechniqueType" vr="CS" vm="1" name="High-Dose Technique Type"/>
-    <entry group="300a" element="00c8" keyword="ReferenceImageNumber" vr="IS" vm="1" name="Reference Image Number"/>
-    <entry group="300a" element="00ca" keyword="PlannedVerificationImageSequence" vr="SQ" vm="1" name="Planned Verification Image Sequence"/>
-    <entry group="300a" element="00cc" keyword="ImagingDeviceSpecificAcquisitionParameters" vr="LO" vm="1-n" name="Imaging Device-Specific Acquisition Parameters"/>
-    <entry group="300a" element="00ce" keyword="TreatmentDeliveryType" vr="CS" vm="1" name="Treatment Delivery Type"/>
-    <entry group="300a" element="00d0" keyword="NumberOfWedges" vr="IS" vm="1" name="Number of Wedges"/>
-    <entry group="300a" element="00d1" keyword="WedgeSequence" vr="SQ" vm="1" name="Wedge Sequence"/>
-    <entry group="300a" element="00d2" keyword="WedgeNumber" vr="IS" vm="1" name="Wedge Number"/>
-    <entry group="300a" element="00d3" keyword="WedgeType" vr="CS" vm="1" name="Wedge Type"/>
-    <entry group="300a" element="00d4" keyword="WedgeID" vr="SH" vm="1" name="Wedge ID"/>
-    <entry group="300a" element="00d5" keyword="WedgeAngle" vr="IS" vm="1" name="Wedge Angle"/>
-    <entry group="300a" element="00d6" keyword="WedgeFactor" vr="DS" vm="1" name="Wedge Factor"/>
-    <entry group="300a" element="00d7" keyword="TotalWedgeTrayWaterEquivalentThickness" vr="FL" vm="1" name="Total Wedge Tray Water-Equivalent Thickness"/>
-    <entry group="300a" element="00d8" keyword="WedgeOrientation" vr="DS" vm="1" name="Wedge Orientation"/>
-    <entry group="300a" element="00d9" keyword="IsocenterToWedgeTrayDistance" vr="FL" vm="1" name="Isocenter to Wedge Tray Distance"/>
-    <entry group="300a" element="00da" keyword="SourceToWedgeTrayDistance" vr="DS" vm="1" name="Source to Wedge Tray Distance"/>
-    <entry group="300a" element="00db" keyword="WedgeThinEdgePosition" vr="FL" vm="1" name="Wedge Thin Edge Position"/>
-    <entry group="300a" element="00dc" keyword="BolusID" vr="SH" vm="1" name="Bolus ID"/>
-    <entry group="300a" element="00dd" keyword="BolusDescription" vr="ST" vm="1" name="Bolus Description"/>
-    <entry group="300a" element="00e0" keyword="NumberOfCompensators" vr="IS" vm="1" name="Number of Compensators"/>
-    <entry group="300a" element="00e1" keyword="MaterialID" vr="SH" vm="1" name="Material ID"/>
-    <entry group="300a" element="00e2" keyword="TotalCompensatorTrayFactor" vr="DS" vm="1" name="Total Compensator Tray Factor"/>
-    <entry group="300a" element="00e3" keyword="CompensatorSequence" vr="SQ" vm="1" name="Compensator Sequence"/>
-    <entry group="300a" element="00e4" keyword="CompensatorNumber" vr="IS" vm="1" name="Compensator Number"/>
-    <entry group="300a" element="00e5" keyword="CompensatorID" vr="SH" vm="1" name="Compensator ID"/>
-    <entry group="300a" element="00e6" keyword="SourceToCompensatorTrayDistance" vr="DS" vm="1" name="Source to Compensator Tray Distance"/>
-    <entry group="300a" element="00e7" keyword="CompensatorRows" vr="IS" vm="1" name="Compensator Rows"/>
-    <entry group="300a" element="00e8" keyword="CompensatorColumns" vr="IS" vm="1" name="Compensator Columns"/>
-    <entry group="300a" element="00e9" keyword="CompensatorPixelSpacing" vr="DS" vm="2" name="Compensator Pixel Spacing"/>
-    <entry group="300a" element="00ea" keyword="CompensatorPosition" vr="DS" vm="2" name="Compensator Position"/>
-    <entry group="300a" element="00eb" keyword="CompensatorTransmissionData" vr="DS" vm="1-n" name="Compensator Transmission Data"/>
-    <entry group="300a" element="00ec" keyword="CompensatorThicknessData" vr="DS" vm="1-n" name="Compensator Thickness Data"/>
-    <entry group="300a" element="00ed" keyword="NumberOfBoli" vr="IS" vm="1" name="Number of Boli"/>
-    <entry group="300a" element="00ee" keyword="CompensatorType" vr="CS" vm="1" name="Compensator Type"/>
-    <entry group="300a" element="00f0" keyword="NumberOfBlocks" vr="IS" vm="1" name="Number of Blocks"/>
-    <entry group="300a" element="00f2" keyword="TotalBlockTrayFactor" vr="DS" vm="1" name="Total Block Tray Factor"/>
-    <entry group="300a" element="00f3" keyword="TotalBlockTrayWaterEquivalentThickness" vr="FL" vm="1" name="Total Block Tray Water-Equivalent Thickness"/>
-    <entry group="300a" element="00f4" keyword="BlockSequence" vr="SQ" vm="1" name="Block Sequence"/>
-    <entry group="300a" element="00f5" keyword="BlockTrayID" vr="SH" vm="1" name="Block Tray ID"/>
-    <entry group="300a" element="00f6" keyword="SourceToBlockTrayDistance" vr="DS" vm="1" name="Source to Block Tray Distance"/>
-    <entry group="300a" element="00f7" keyword="IsocenterToBlockTrayDistance" vr="FL" vm="1" name="Isocenter to Block Tray Distance"/>
-    <entry group="300a" element="00f8" keyword="BlockType" vr="CS" vm="1" name="Block Type"/>
-    <entry group="300a" element="00f9" keyword="AccessoryCode" vr="LO" vm="1" name="Accessory Code"/>
-    <entry group="300a" element="00fa" keyword="BlockDivergence" vr="CS" vm="1" name="Block Divergence"/>
-    <entry group="300a" element="00fb" keyword="BlockMountingPosition" vr="CS" vm="1" name="Block Mounting Position"/>
-    <entry group="300a" element="00fc" keyword="BlockNumber" vr="IS" vm="1" name="Block Number"/>
-    <entry group="300a" element="00fe" keyword="BlockName" vr="LO" vm="1" name="Block Name"/>
-    <entry group="300a" element="0100" keyword="BlockThickness" vr="DS" vm="1" name="Block Thickness"/>
-    <entry group="300a" element="0102" keyword="BlockTransmission" vr="DS" vm="1" name="Block Transmission"/>
-    <entry group="300a" element="0104" keyword="BlockNumberOfPoints" vr="IS" vm="1" name="Block Number of Points"/>
-    <entry group="300a" element="0106" keyword="BlockData" vr="DS" vm="2-2n" name="Block Data"/>
-    <entry group="300a" element="0107" keyword="ApplicatorSequence" vr="SQ" vm="1" name="Applicator Sequence"/>
-    <entry group="300a" element="0108" keyword="ApplicatorID" vr="SH" vm="1" name="Applicator ID"/>
-    <entry group="300a" element="0109" keyword="ApplicatorType" vr="CS" vm="1" name="Applicator Type"/>
-    <entry group="300a" element="010a" keyword="ApplicatorDescription" vr="LO" vm="1" name="Applicator Description"/>
-    <entry group="300a" element="010c" keyword="CumulativeDoseReferenceCoefficient" vr="DS" vm="1" name="Cumulative Dose Reference Coefficient"/>
-    <entry group="300a" element="010e" keyword="FinalCumulativeMetersetWeight" vr="DS" vm="1" name="Final Cumulative Meterset Weight"/>
-    <entry group="300a" element="0110" keyword="NumberOfControlPoints" vr="IS" vm="1" name="Number of Control Points"/>
-    <entry group="300a" element="0111" keyword="ControlPointSequence" vr="SQ" vm="1" name="Control Point Sequence"/>
-    <entry group="300a" element="0112" keyword="ControlPointIndex" vr="IS" vm="1" name="Control Point Index"/>
-    <entry group="300a" element="0114" keyword="NominalBeamEnergy" vr="DS" vm="1" name="Nominal Beam Energy"/>
-    <entry group="300a" element="0115" keyword="DoseRateSet" vr="DS" vm="1" name="Dose Rate Set"/>
-    <entry group="300a" element="0116" keyword="WedgePositionSequence" vr="SQ" vm="1" name="Wedge Position Sequence"/>
-    <entry group="300a" element="0118" keyword="WedgePosition" vr="CS" vm="1" name="Wedge Position"/>
-    <entry group="300a" element="011a" keyword="BeamLimitingDevicePositionSequence" vr="SQ" vm="1" name="Beam Limiting Device Position Sequence"/>
-    <entry group="300a" element="011c" keyword="LeafJawPositions" vr="DS" vm="2-2n" name="Leaf/Jaw Positions"/>
-    <entry group="300a" element="011e" keyword="GantryAngle" vr="DS" vm="1" name="Gantry Angle"/>
-    <entry group="300a" element="011f" keyword="GantryRotationDirection" vr="CS" vm="1" name="Gantry Rotation Direction"/>
-    <entry group="300a" element="0120" keyword="BeamLimitingDeviceAngle" vr="DS" vm="1" name="Beam Limiting Device Angle"/>
-    <entry group="300a" element="0121" keyword="BeamLimitingDeviceRotationDirection" vr="CS" vm="1" name="Beam Limiting Device Rotation Direction"/>
-    <entry group="300a" element="0122" keyword="PatientSupportAngle" vr="DS" vm="1" name="Patient Support Angle"/>
-    <entry group="300a" element="0123" keyword="PatientSupportRotationDirection" vr="CS" vm="1" name="Patient Support Rotation Direction"/>
-    <entry group="300a" element="0124" keyword="TableTopEccentricAxisDistance" vr="DS" vm="1" name="Table Top Eccentric Axis Distance"/>
-    <entry group="300a" element="0125" keyword="TableTopEccentricAngle" vr="DS" vm="1" name="Table Top Eccentric Angle"/>
-    <entry group="300a" element="0126" keyword="TableTopEccentricRotationDirection" vr="CS" vm="1" name="Table Top Eccentric Rotation Direction"/>
-    <entry group="300a" element="0128" keyword="TableTopVerticalPosition" vr="DS" vm="1" name="Table Top Vertical Position"/>
-    <entry group="300a" element="0129" keyword="TableTopLongitudinalPosition" vr="DS" vm="1" name="Table Top Longitudinal Position"/>
-    <entry group="300a" element="012a" keyword="TableTopLateralPosition" vr="DS" vm="1" name="Table Top Lateral Position"/>
-    <entry group="300a" element="012c" keyword="IsocenterPosition" vr="DS" vm="3" name="Isocenter Position"/>
-    <entry group="300a" element="012e" keyword="SurfaceEntryPoint" vr="DS" vm="3" name="Surface Entry Point"/>
-    <entry group="300a" element="0130" keyword="SourceToSurfaceDistance" vr="DS" vm="1" name="Source to Surface Distance"/>
-    <entry group="300a" element="0134" keyword="CumulativeMetersetWeight" vr="DS" vm="1" name="Cumulative Meterset Weight"/>
-    <entry group="300a" element="0140" keyword="TableTopPitchAngle" vr="FL" vm="1" name="Table Top Pitch Angle"/>
-    <entry group="300a" element="0142" keyword="TableTopPitchRotationDirection" vr="CS" vm="1" name="Table Top Pitch Rotation Direction"/>
-    <entry group="300a" element="0144" keyword="TableTopRollAngle" vr="FL" vm="1" name="Table Top Roll Angle"/>
-    <entry group="300a" element="0146" keyword="TableTopRollRotationDirection" vr="CS" vm="1" name="Table Top Roll Rotation Direction"/>
-    <entry group="300a" element="0148" keyword="HeadFixationAngle" vr="FL" vm="1" name="Head Fixation Angle"/>
-    <entry group="300a" element="014a" keyword="GantryPitchAngle" vr="FL" vm="1" name="Gantry Pitch Angle"/>
-    <entry group="300a" element="014c" keyword="GantryPitchRotationDirection" vr="CS" vm="1" name="Gantry Pitch Rotation Direction"/>
-    <entry group="300a" element="014e" keyword="GantryPitchAngleTolerance" vr="FL" vm="1" name="Gantry Pitch Angle Tolerance"/>
-    <entry group="300a" element="0180" keyword="PatientSetupSequence" vr="SQ" vm="1" name="Patient Setup Sequence"/>
-    <entry group="300a" element="0182" keyword="PatientSetupNumber" vr="IS" vm="1" name="Patient Setup Number"/>
-    <entry group="300a" element="0183" keyword="PatientSetupLabel" vr="LO" vm="1" name="Patient Setup Label"/>
-    <entry group="300a" element="0184" keyword="PatientAdditionalPosition" vr="LO" vm="1" name="Patient Additional Position"/>
-    <entry group="300a" element="0190" keyword="FixationDeviceSequence" vr="SQ" vm="1" name="Fixation Device Sequence"/>
-    <entry group="300a" element="0192" keyword="FixationDeviceType" vr="CS" vm="1" name="Fixation Device Type"/>
-    <entry group="300a" element="0194" keyword="FixationDeviceLabel" vr="SH" vm="1" name="Fixation Device Label"/>
-    <entry group="300a" element="0196" keyword="FixationDeviceDescription" vr="ST" vm="1" name="Fixation Device Description"/>
-    <entry group="300a" element="0198" keyword="FixationDevicePosition" vr="SH" vm="1" name="Fixation Device Position"/>
-    <entry group="300a" element="0199" keyword="FixationDevicePitchAngle" vr="FL" vm="1" name="Fixation Device Pitch Angle"/>
-    <entry group="300a" element="019a" keyword="FixationDeviceRollAngle" vr="FL" vm="1" name="Fixation Device Roll Angle"/>
-    <entry group="300a" element="01a0" keyword="ShieldingDeviceSequence" vr="SQ" vm="1" name="Shielding Device Sequence"/>
-    <entry group="300a" element="01a2" keyword="ShieldingDeviceType" vr="CS" vm="1" name="Shielding Device Type"/>
-    <entry group="300a" element="01a4" keyword="ShieldingDeviceLabel" vr="SH" vm="1" name="Shielding Device Label"/>
-    <entry group="300a" element="01a6" keyword="ShieldingDeviceDescription" vr="ST" vm="1" name="Shielding Device Description"/>
-    <entry group="300a" element="01a8" keyword="ShieldingDevicePosition" vr="SH" vm="1" name="Shielding Device Position"/>
-    <entry group="300a" element="01b0" keyword="SetupTechnique" vr="CS" vm="1" name="Setup Technique"/>
-    <entry group="300a" element="01b2" keyword="SetupTechniqueDescription" vr="ST" vm="1" name="Setup Technique Description"/>
-    <entry group="300a" element="01b4" keyword="SetupDeviceSequence" vr="SQ" vm="1" name="Setup Device Sequence"/>
-    <entry group="300a" element="01b6" keyword="SetupDeviceType" vr="CS" vm="1" name="Setup Device Type"/>
-    <entry group="300a" element="01b8" keyword="SetupDeviceLabel" vr="SH" vm="1" name="Setup Device Label"/>
-    <entry group="300a" element="01ba" keyword="SetupDeviceDescription" vr="ST" vm="1" name="Setup Device Description"/>
-    <entry group="300a" element="01bc" keyword="SetupDeviceParameter" vr="DS" vm="1" name="Setup Device Parameter"/>
-    <entry group="300a" element="01d0" keyword="SetupReferenceDescription" vr="ST" vm="1" name="Setup Reference Description"/>
-    <entry group="300a" element="01d2" keyword="TableTopVerticalSetupDisplacement" vr="DS" vm="1" name="Table Top Vertical Setup Displacement"/>
-    <entry group="300a" element="01d4" keyword="TableTopLongitudinalSetupDisplacement" vr="DS" vm="1" name="Table Top Longitudinal Setup Displacement"/>
-    <entry group="300a" element="01d6" keyword="TableTopLateralSetupDisplacement" vr="DS" vm="1" name="Table Top Lateral Setup Displacement"/>
-    <entry group="300a" element="0200" keyword="BrachyTreatmentTechnique" vr="CS" vm="1" name="Brachy Treatment Technique"/>
-    <entry group="300a" element="0202" keyword="BrachyTreatmentType" vr="CS" vm="1" name="Brachy Treatment Type"/>
-    <entry group="300a" element="0206" keyword="TreatmentMachineSequence" vr="SQ" vm="1" name="Treatment Machine Sequence"/>
-    <entry group="300a" element="0210" keyword="SourceSequence" vr="SQ" vm="1" name="Source Sequence"/>
-    <entry group="300a" element="0212" keyword="SourceNumber" vr="IS" vm="1" name="Source Number"/>
-    <entry group="300a" element="0214" keyword="SourceType" vr="CS" vm="1" name="Source Type"/>
-    <entry group="300a" element="0216" keyword="SourceManufacturer" vr="LO" vm="1" name="Source Manufacturer"/>
-    <entry group="300a" element="0218" keyword="ActiveSourceDiameter" vr="DS" vm="1" name="Active Source Diameter"/>
-    <entry group="300a" element="021a" keyword="ActiveSourceLength" vr="DS" vm="1" name="Active Source Length"/>
-    <entry group="300a" element="0222" keyword="SourceEncapsulationNominalThickness" vr="DS" vm="1" name="Source Encapsulation Nominal Thickness"/>
-    <entry group="300a" element="0224" keyword="SourceEncapsulationNominalTransmission" vr="DS" vm="1" name="Source Encapsulation Nominal Transmission"/>
-    <entry group="300a" element="0226" keyword="SourceIsotopeName" vr="LO" vm="1" name="Source Isotope Name"/>
-    <entry group="300a" element="0228" keyword="SourceIsotopeHalfLife" vr="DS" vm="1" name="Source Isotope Half Life"/>
-    <entry group="300a" element="0229" keyword="SourceStrengthUnits" vr="CS" vm="1" name="Source Strength Units"/>
-    <entry group="300a" element="022a" keyword="ReferenceAirKermaRate" vr="DS" vm="1" name="Reference Air Kerma Rate"/>
-    <entry group="300a" element="022b" keyword="SourceStrength" vr="DS" vm="1" name="Source Strength"/>
-    <entry group="300a" element="022c" keyword="SourceStrengthReferenceDate" vr="DA" vm="1" name="Source Strength Reference Date"/>
-    <entry group="300a" element="022e" keyword="SourceStrengthReferenceTime" vr="TM" vm="1" name="Source Strength Reference Time"/>
-    <entry group="300a" element="0230" keyword="ApplicationSetupSequence" vr="SQ" vm="1" name="Application Setup Sequence"/>
-    <entry group="300a" element="0232" keyword="ApplicationSetupType" vr="CS" vm="1" name="Application Setup Type"/>
-    <entry group="300a" element="0234" keyword="ApplicationSetupNumber" vr="IS" vm="1" name="Application Setup Number"/>
-    <entry group="300a" element="0236" keyword="ApplicationSetupName" vr="LO" vm="1" name="Application Setup Name"/>
-    <entry group="300a" element="0238" keyword="ApplicationSetupManufacturer" vr="LO" vm="1" name="Application Setup Manufacturer"/>
-    <entry group="300a" element="0240" keyword="TemplateNumber" vr="IS" vm="1" name="Template Number"/>
-    <entry group="300a" element="0242" keyword="TemplateType" vr="SH" vm="1" name="Template Type"/>
-    <entry group="300a" element="0244" keyword="TemplateName" vr="LO" vm="1" name="Template Name"/>
-    <entry group="300a" element="0250" keyword="TotalReferenceAirKerma" vr="DS" vm="1" name="Total Reference Air Kerma"/>
-    <entry group="300a" element="0260" keyword="BrachyAccessoryDeviceSequence" vr="SQ" vm="1" name="Brachy Accessory Device Sequence"/>
-    <entry group="300a" element="0262" keyword="BrachyAccessoryDeviceNumber" vr="IS" vm="1" name="Brachy Accessory Device Number"/>
-    <entry group="300a" element="0263" keyword="BrachyAccessoryDeviceID" vr="SH" vm="1" name="Brachy Accessory Device ID"/>
-    <entry group="300a" element="0264" keyword="BrachyAccessoryDeviceType" vr="CS" vm="1" name="Brachy Accessory Device Type"/>
-    <entry group="300a" element="0266" keyword="BrachyAccessoryDeviceName" vr="LO" vm="1" name="Brachy Accessory Device Name"/>
-    <entry group="300a" element="026a" keyword="BrachyAccessoryDeviceNominalThickness" vr="DS" vm="1" name="Brachy Accessory Device Nominal Thickness"/>
-    <entry group="300a" element="026c" keyword="BrachyAccessoryDeviceNominalTransmission" vr="DS" vm="1" name="Brachy Accessory Device Nominal Transmission"/>
-    <entry group="300a" element="0280" keyword="ChannelSequence" vr="SQ" vm="1" name="Channel Sequence"/>
-    <entry group="300a" element="0282" keyword="ChannelNumber" vr="IS" vm="1" name="Channel Number"/>
-    <entry group="300a" element="0284" keyword="ChannelLength" vr="DS" vm="1" name="Channel Length"/>
-    <entry group="300a" element="0286" keyword="ChannelTotalTime" vr="DS" vm="1" name="Channel Total Time"/>
-    <entry group="300a" element="0288" keyword="SourceMovementType" vr="CS" vm="1" name="Source Movement Type"/>
-    <entry group="300a" element="028a" keyword="NumberOfPulses" vr="IS" vm="1" name="Number of Pulses"/>
-    <entry group="300a" element="028c" keyword="PulseRepetitionInterval" vr="DS" vm="1" name="Pulse Repetition Interval"/>
-    <entry group="300a" element="0290" keyword="SourceApplicatorNumber" vr="IS" vm="1" name="Source Applicator Number"/>
-    <entry group="300a" element="0291" keyword="SourceApplicatorID" vr="SH" vm="1" name="Source Applicator ID"/>
-    <entry group="300a" element="0292" keyword="SourceApplicatorType" vr="CS" vm="1" name="Source Applicator Type"/>
-    <entry group="300a" element="0294" keyword="SourceApplicatorName" vr="LO" vm="1" name="Source Applicator Name"/>
-    <entry group="300a" element="0296" keyword="SourceApplicatorLength" vr="DS" vm="1" name="Source Applicator Length"/>
-    <entry group="300a" element="0298" keyword="SourceApplicatorManufacturer" vr="LO" vm="1" name="Source Applicator Manufacturer"/>
-    <entry group="300a" element="029c" keyword="SourceApplicatorWallNominalThickness" vr="DS" vm="1" name="Source Applicator Wall Nominal Thickness"/>
-    <entry group="300a" element="029e" keyword="SourceApplicatorWallNominalTransmission" vr="DS" vm="1" name="Source Applicator Wall Nominal Transmission"/>
-    <entry group="300a" element="02a0" keyword="SourceApplicatorStepSize" vr="DS" vm="1" name="Source Applicator Step Size"/>
-    <entry group="300a" element="02a2" keyword="TransferTubeNumber" vr="IS" vm="1" name="Transfer Tube Number"/>
-    <entry group="300a" element="02a4" keyword="TransferTubeLength" vr="DS" vm="1" name="Transfer Tube Length"/>
-    <entry group="300a" element="02b0" keyword="ChannelShieldSequence" vr="SQ" vm="1" name="Channel Shield Sequence"/>
-    <entry group="300a" element="02b2" keyword="ChannelShieldNumber" vr="IS" vm="1" name="Channel Shield Number"/>
-    <entry group="300a" element="02b3" keyword="ChannelShieldID" vr="SH" vm="1" name="Channel Shield ID"/>
-    <entry group="300a" element="02b4" keyword="ChannelShieldName" vr="LO" vm="1" name="Channel Shield Name"/>
-    <entry group="300a" element="02b8" keyword="ChannelShieldNominalThickness" vr="DS" vm="1" name="Channel Shield Nominal Thickness"/>
-    <entry group="300a" element="02ba" keyword="ChannelShieldNominalTransmission" vr="DS" vm="1" name="Channel Shield Nominal Transmission"/>
-    <entry group="300a" element="02c8" keyword="FinalCumulativeTimeWeight" vr="DS" vm="1" name="Final Cumulative Time Weight"/>
-    <entry group="300a" element="02d0" keyword="BrachyControlPointSequence" vr="SQ" vm="1" name="Brachy Control Point Sequence"/>
-    <entry group="300a" element="02d2" keyword="ControlPointRelativePosition" vr="DS" vm="1" name="Control Point Relative Position"/>
-    <entry group="300a" element="02d4" keyword="ControlPoint3DPosition" vr="DS" vm="3" name="Control Point 3D Position"/>
-    <entry group="300a" element="02d6" keyword="CumulativeTimeWeight" vr="DS" vm="1" name="Cumulative Time Weight"/>
-    <entry group="300a" element="02e0" keyword="CompensatorDivergence" vr="CS" vm="1" name="Compensator Divergence"/>
-    <entry group="300a" element="02e1" keyword="CompensatorMountingPosition" vr="CS" vm="1" name="Compensator Mounting Position"/>
-    <entry group="300a" element="02e2" keyword="SourceToCompensatorDistance" vr="DS" vm="1-n" name="Source to Compensator Distance"/>
-    <entry group="300a" element="02e3" keyword="TotalCompensatorTrayWaterEquivalentThickness" vr="FL" vm="1" name="Total Compensator Tray Water-Equivalent Thickness"/>
-    <entry group="300a" element="02e4" keyword="IsocenterToCompensatorTrayDistance" vr="FL" vm="1" name="Isocenter to Compensator Tray Distance"/>
-    <entry group="300a" element="02e5" keyword="CompensatorColumnOffset" vr="FL" vm="1" name="Compensator Column Offset"/>
-    <entry group="300a" element="02e6" keyword="IsocenterToCompensatorDistances" vr="FL" vm="1-n" name="Isocenter to Compensator Distances"/>
-    <entry group="300a" element="02e7" keyword="CompensatorRelativeStoppingPowerRatio" vr="FL" vm="1" name="Compensator Relative Stopping Power Ratio"/>
-    <entry group="300a" element="02e8" keyword="CompensatorMillingToolDiameter" vr="FL" vm="1" name="Compensator Milling Tool Diameter"/>
-    <entry group="300a" element="02ea" keyword="IonRangeCompensatorSequence" vr="SQ" vm="1" name="Ion Range Compensator Sequence"/>
-    <entry group="300a" element="02eb" keyword="CompensatorDescription" vr="LT" vm="1" name="Compensator Description"/>
-    <entry group="300a" element="0302" keyword="RadiationMassNumber" vr="IS" vm="1" name="Radiation Mass Number"/>
-    <entry group="300a" element="0304" keyword="RadiationAtomicNumber" vr="IS" vm="1" name="Radiation Atomic Number"/>
-    <entry group="300a" element="0306" keyword="RadiationChargeState" vr="SS" vm="1" name="Radiation Charge State"/>
-    <entry group="300a" element="0308" keyword="ScanMode" vr="CS" vm="1" name="Scan Mode"/>
-    <entry group="300a" element="030a" keyword="VirtualSourceAxisDistances" vr="FL" vm="2" name="Virtual Source-Axis Distances"/>
-    <entry group="300a" element="030c" keyword="SnoutSequence" vr="SQ" vm="1" name="Snout Sequence"/>
-    <entry group="300a" element="030d" keyword="SnoutPosition" vr="FL" vm="1" name="Snout Position"/>
-    <entry group="300a" element="030f" keyword="SnoutID" vr="SH" vm="1" name="Snout ID"/>
-    <entry group="300a" element="0312" keyword="NumberOfRangeShifters" vr="IS" vm="1" name="Number of Range Shifters"/>
-    <entry group="300a" element="0314" keyword="RangeShifterSequence" vr="SQ" vm="1" name="Range Shifter Sequence"/>
-    <entry group="300a" element="0316" keyword="RangeShifterNumber" vr="IS" vm="1" name="Range Shifter Number"/>
-    <entry group="300a" element="0318" keyword="RangeShifterID" vr="SH" vm="1" name="Range Shifter ID"/>
-    <entry group="300a" element="0320" keyword="RangeShifterType" vr="CS" vm="1" name="Range Shifter Type"/>
-    <entry group="300a" element="0322" keyword="RangeShifterDescription" vr="LO" vm="1" name="Range Shifter Description"/>
-    <entry group="300a" element="0330" keyword="NumberOfLateralSpreadingDevices" vr="IS" vm="1" name="Number of Lateral Spreading Devices"/>
-    <entry group="300a" element="0332" keyword="LateralSpreadingDeviceSequence" vr="SQ" vm="1" name="Lateral Spreading Device Sequence"/>
-    <entry group="300a" element="0334" keyword="LateralSpreadingDeviceNumber" vr="IS" vm="1" name="Lateral Spreading Device Number"/>
-    <entry group="300a" element="0336" keyword="LateralSpreadingDeviceID" vr="SH" vm="1" name="Lateral Spreading Device ID"/>
-    <entry group="300a" element="0338" keyword="LateralSpreadingDeviceType" vr="CS" vm="1" name="Lateral Spreading Device Type"/>
-    <entry group="300a" element="033a" keyword="LateralSpreadingDeviceDescription" vr="LO" vm="1" name="Lateral Spreading Device Description"/>
-    <entry group="300a" element="033c" keyword="LateralSpreadingDeviceWaterEquivalentThickness" vr="FL" vm="1" name="Lateral Spreading Device Water Equivalent Thickness"/>
-    <entry group="300a" element="0340" keyword="NumberOfRangeModulators" vr="IS" vm="1" name="Number of Range Modulators"/>
-    <entry group="300a" element="0342" keyword="RangeModulatorSequence" vr="SQ" vm="1" name="Range Modulator Sequence"/>
-    <entry group="300a" element="0344" keyword="RangeModulatorNumber" vr="IS" vm="1" name="Range Modulator Number"/>
-    <entry group="300a" element="0346" keyword="RangeModulatorID" vr="SH" vm="1" name="Range Modulator ID"/>
-    <entry group="300a" element="0348" keyword="RangeModulatorType" vr="CS" vm="1" name="Range Modulator Type"/>
-    <entry group="300a" element="034a" keyword="RangeModulatorDescription" vr="LO" vm="1" name="Range Modulator Description"/>
-    <entry group="300a" element="034c" keyword="BeamCurrentModulationID" vr="SH" vm="1" name="Beam Current Modulation ID"/>
-    <entry group="300a" element="0350" keyword="PatientSupportType" vr="CS" vm="1" name="Patient Support Type"/>
-    <entry group="300a" element="0352" keyword="PatientSupportID" vr="SH" vm="1" name="Patient Support ID"/>
-    <entry group="300a" element="0354" keyword="PatientSupportAccessoryCode" vr="LO" vm="1" name="Patient Support Accessory Code"/>
-    <entry group="300a" element="0356" keyword="FixationLightAzimuthalAngle" vr="FL" vm="1" name="Fixation Light Azimuthal Angle"/>
-    <entry group="300a" element="0358" keyword="FixationLightPolarAngle" vr="FL" vm="1" name="Fixation Light Polar Angle"/>
-    <entry group="300a" element="035a" keyword="MetersetRate" vr="FL" vm="1" name="Meterset Rate"/>
-    <entry group="300a" element="0360" keyword="RangeShifterSettingsSequence" vr="SQ" vm="1" name="Range Shifter Settings Sequence"/>
-    <entry group="300a" element="0362" keyword="RangeShifterSetting" vr="LO" vm="1" name="Range Shifter Setting"/>
-    <entry group="300a" element="0364" keyword="IsocenterToRangeShifterDistance" vr="FL" vm="1" name="Isocenter to Range Shifter Distance"/>
-    <entry group="300a" element="0366" keyword="RangeShifterWaterEquivalentThickness" vr="FL" vm="1" name="Range Shifter Water Equivalent Thickness"/>
-    <entry group="300a" element="0370" keyword="LateralSpreadingDeviceSettingsSequence" vr="SQ" vm="1" name="Lateral Spreading Device Settings Sequence"/>
-    <entry group="300a" element="0372" keyword="LateralSpreadingDeviceSetting" vr="LO" vm="1" name="Lateral Spreading Device Setting"/>
-    <entry group="300a" element="0374" keyword="IsocenterToLateralSpreadingDeviceDistance" vr="FL" vm="1" name="Isocenter to Lateral Spreading Device Distance"/>
-    <entry group="300a" element="0380" keyword="RangeModulatorSettingsSequence" vr="SQ" vm="1" name="Range Modulator Settings Sequence"/>
-    <entry group="300a" element="0382" keyword="RangeModulatorGatingStartValue" vr="FL" vm="1" name="Range Modulator Gating Start Value"/>
-    <entry group="300a" element="0384" keyword="RangeModulatorGatingStopValue" vr="FL" vm="1" name="Range Modulator Gating Stop Value"/>
-    <entry group="300a" element="0386" keyword="RangeModulatorGatingStartWaterEquivalentThickness" vr="FL" vm="1" name="Range Modulator Gating Start Water Equivalent Thickness"/>
-    <entry group="300a" element="0388" keyword="RangeModulatorGatingStopWaterEquivalentThickness" vr="FL" vm="1" name="Range Modulator Gating Stop Water Equivalent Thickness"/>
-    <entry group="300a" element="038a" keyword="IsocenterToRangeModulatorDistance" vr="FL" vm="1" name="Isocenter to Range Modulator Distance"/>
-    <entry group="300a" element="0390" keyword="ScanSpotTuneID" vr="SH" vm="1" name="Scan Spot Tune ID"/>
-    <entry group="300a" element="0392" keyword="NumberOfScanSpotPositions" vr="IS" vm="1" name="Number of Scan Spot Positions"/>
-    <entry group="300a" element="0394" keyword="ScanSpotPositionMap" vr="FL" vm="1-n" name="Scan Spot Position Map"/>
-    <entry group="300a" element="0396" keyword="ScanSpotMetersetWeights" vr="FL" vm="1-n" name="Scan Spot Meterset Weights"/>
-    <entry group="300a" element="0398" keyword="ScanningSpotSize" vr="FL" vm="2" name="Scanning Spot Size"/>
-    <entry group="300a" element="039a" keyword="NumberOfPaintings" vr="IS" vm="1" name="Number of Paintings"/>
-    <entry group="300a" element="03a0" keyword="IonToleranceTableSequence" vr="SQ" vm="1" name="Ion Tolerance Table Sequence"/>
-    <entry group="300a" element="03a2" keyword="IonBeamSequence" vr="SQ" vm="1" name="Ion Beam Sequence"/>
-    <entry group="300a" element="03a4" keyword="IonBeamLimitingDeviceSequence" vr="SQ" vm="1" name="Ion Beam Limiting Device Sequence"/>
-    <entry group="300a" element="03a6" keyword="IonBlockSequence" vr="SQ" vm="1" name="Ion Block Sequence"/>
-    <entry group="300a" element="03a8" keyword="IonControlPointSequence" vr="SQ" vm="1" name="Ion Control Point Sequence"/>
-    <entry group="300a" element="03aa" keyword="IonWedgeSequence" vr="SQ" vm="1" name="Ion Wedge Sequence"/>
-    <entry group="300a" element="03ac" keyword="IonWedgePositionSequence" vr="SQ" vm="1" name="Ion Wedge Position Sequence"/>
-    <entry group="300a" element="0401" keyword="ReferencedSetupImageSequence" vr="SQ" vm="1" name="Referenced Setup Image Sequence"/>
-    <entry group="300a" element="0402" keyword="SetupImageComment" vr="ST" vm="1" name="Setup Image Comment"/>
-    <entry group="300a" element="0410" keyword="MotionSynchronizationSequence" vr="SQ" vm="1" name="Motion Synchronization Sequence"/>
-    <entry group="300a" element="0412" keyword="ControlPointOrientation" vr="FL" vm="3" name="Control Point Orientation"/>
-    <entry group="300a" element="0420" keyword="GeneralAccessorySequence" vr="SQ" vm="1" name="General Accessory Sequence"/>
-    <entry group="300a" element="0421" keyword="GeneralAccessoryID" vr="SH" vm="1" name="General Accessory ID"/>
-    <entry group="300a" element="0422" keyword="GeneralAccessoryDescription" vr="ST" vm="1" name="General Accessory Description"/>
-    <entry group="300a" element="0423" keyword="GeneralAccessoryType" vr="CS" vm="1" name="General Accessory Type"/>
-    <entry group="300a" element="0424" keyword="GeneralAccessoryNumber" vr="IS" vm="1" name="General Accessory Number"/>
-    <entry group="300a" element="0431" keyword="ApplicatorGeometrySequence" vr="SQ" vm="1" name="Applicator Geometry Sequence"/>
-    <entry group="300a" element="0432" keyword="ApplicatorApertureShape" vr="CS" vm="1" name="Applicator Aperture Shape"/>
-    <entry group="300a" element="0433" keyword="ApplicatorOpening" vr="FL" vm="1" name="Applicator Opening"/>
-    <entry group="300a" element="0434" keyword="ApplicatorOpeningX" vr="FL" vm="1" name="Applicator Opening X"/>
-    <entry group="300a" element="0435" keyword="ApplicatorOpeningY" vr="FL" vm="1" name="Applicator Opening Y"/>
-    <entry group="300a" element="0436" keyword="SourceToApplicatorMountingPositionDistance" vr="FL" vm="1" name="Source to Applicator Mounting Position Distance"/>
-    <entry group="300c" element="0002" keyword="ReferencedRTPlanSequence" vr="SQ" vm="1" name="Referenced RT Plan Sequence"/>
-    <entry group="300c" element="0004" keyword="ReferencedBeamSequence" vr="SQ" vm="1" name="Referenced Beam Sequence"/>
-    <entry group="300c" element="0006" keyword="ReferencedBeamNumber" vr="IS" vm="1" name="Referenced Beam Number"/>
-    <entry group="300c" element="0007" keyword="ReferencedReferenceImageNumber" vr="IS" vm="1" name="Referenced Reference Image Number"/>
-    <entry group="300c" element="0008" keyword="StartCumulativeMetersetWeight" vr="DS" vm="1" name="Start Cumulative Meterset Weight"/>
-    <entry group="300c" element="0009" keyword="EndCumulativeMetersetWeight" vr="DS" vm="1" name="End Cumulative Meterset Weight"/>
-    <entry group="300c" element="000a" keyword="ReferencedBrachyApplicationSetupSequence" vr="SQ" vm="1" name="Referenced Brachy Application Setup Sequence"/>
-    <entry group="300c" element="000c" keyword="ReferencedBrachyApplicationSetupNumber" vr="IS" vm="1" name="Referenced Brachy Application Setup Number"/>
-    <entry group="300c" element="000e" keyword="ReferencedSourceNumber" vr="IS" vm="1" name="Referenced Source Number"/>
-    <entry group="300c" element="0020" keyword="ReferencedFractionGroupSequence" vr="SQ" vm="1" name="Referenced Fraction Group Sequence"/>
-    <entry group="300c" element="0022" keyword="ReferencedFractionGroupNumber" vr="IS" vm="1" name="Referenced Fraction Group Number"/>
-    <entry group="300c" element="0040" keyword="ReferencedVerificationImageSequence" vr="SQ" vm="1" name="Referenced Verification Image Sequence"/>
-    <entry group="300c" element="0042" keyword="ReferencedReferenceImageSequence" vr="SQ" vm="1" name="Referenced Reference Image Sequence"/>
-    <entry group="300c" element="0050" keyword="ReferencedDoseReferenceSequence" vr="SQ" vm="1" name="Referenced Dose Reference Sequence"/>
-    <entry group="300c" element="0051" keyword="ReferencedDoseReferenceNumber" vr="IS" vm="1" name="Referenced Dose Reference Number"/>
-    <entry group="300c" element="0055" keyword="BrachyReferencedDoseReferenceSequence" vr="SQ" vm="1" name="Brachy Referenced Dose Reference Sequence"/>
-    <entry group="300c" element="0060" keyword="ReferencedStructureSetSequence" vr="SQ" vm="1" name="Referenced Structure Set Sequence"/>
-    <entry group="300c" element="006a" keyword="ReferencedPatientSetupNumber" vr="IS" vm="1" name="Referenced Patient Setup Number"/>
-    <entry group="300c" element="0080" keyword="ReferencedDoseSequence" vr="SQ" vm="1" name="Referenced Dose Sequence"/>
-    <entry group="300c" element="00a0" keyword="ReferencedToleranceTableNumber" vr="IS" vm="1" name="Referenced Tolerance Table Number"/>
-    <entry group="300c" element="00b0" keyword="ReferencedBolusSequence" vr="SQ" vm="1" name="Referenced Bolus Sequence"/>
-    <entry group="300c" element="00c0" keyword="ReferencedWedgeNumber" vr="IS" vm="1" name="Referenced Wedge Number"/>
-    <entry group="300c" element="00d0" keyword="ReferencedCompensatorNumber" vr="IS" vm="1" name="Referenced Compensator Number"/>
-    <entry group="300c" element="00e0" keyword="ReferencedBlockNumber" vr="IS" vm="1" name="Referenced Block Number"/>
-    <entry group="300c" element="00f0" keyword="ReferencedControlPointIndex" vr="IS" vm="1" name="Referenced Control Point Index"/>
-    <entry group="300c" element="00f2" keyword="ReferencedControlPointSequence" vr="SQ" vm="1" name="Referenced Control Point Sequence"/>
-    <entry group="300c" element="00f4" keyword="ReferencedStartControlPointIndex" vr="IS" vm="1" name="Referenced Start Control Point Index"/>
-    <entry group="300c" element="00f6" keyword="ReferencedStopControlPointIndex" vr="IS" vm="1" name="Referenced Stop Control Point Index"/>
-    <entry group="300c" element="0100" keyword="ReferencedRangeShifterNumber" vr="IS" vm="1" name="Referenced Range Shifter Number"/>
-    <entry group="300c" element="0102" keyword="ReferencedLateralSpreadingDeviceNumber" vr="IS" vm="1" name="Referenced Lateral Spreading Device Number"/>
-    <entry group="300c" element="0104" keyword="ReferencedRangeModulatorNumber" vr="IS" vm="1" name="Referenced Range Modulator Number"/>
-    <entry group="300e" element="0002" keyword="ApprovalStatus" vr="CS" vm="1" name="Approval Status"/>
-    <entry group="300e" element="0004" keyword="ReviewDate" vr="DA" vm="1" name="Review Date"/>
-    <entry group="300e" element="0005" keyword="ReviewTime" vr="TM" vm="1" name="Review Time"/>
-    <entry group="300e" element="0008" keyword="ReviewerName" vr="PN" vm="1" name="Reviewer Name"/>
-    <entry group="4000" element="0010" keyword="Arbitrary" vr="LT" vm="1" retired="true" name="Arbitrary"/>
-    <entry group="4000" element="4000" keyword="TextComments" vr="LT" vm="1" retired="true" name="Text Comments"/>
-    <entry group="4008" element="0040" keyword="ResultsID" vr="SH" vm="1" retired="true" name="Results ID"/>
-    <entry group="4008" element="0042" keyword="ResultsIDIssuer" vr="LO" vm="1" retired="true" name="Results ID Issuer"/>
-    <entry group="4008" element="0050" keyword="ReferencedInterpretationSequence" vr="SQ" vm="1" retired="true" name="Referenced Interpretation Sequence"/>
-    <entry group="4008" element="00ff" keyword="ReportProductionStatusTrial" vr="CS" vm="1" retired="true" name="Report Production Status (Trial)"/>
-    <entry group="4008" element="0100" keyword="InterpretationRecordedDate" vr="DA" vm="1" retired="true" name="Interpretation Recorded Date"/>
-    <entry group="4008" element="0101" keyword="InterpretationRecordedTime" vr="TM" vm="1" retired="true" name="Interpretation Recorded Time"/>
-    <entry group="4008" element="0102" keyword="InterpretationRecorder" vr="PN" vm="1" retired="true" name="Interpretation Recorder"/>
-    <entry group="4008" element="0103" keyword="ReferenceToRecordedSound" vr="LO" vm="1" retired="true" name="Reference to Recorded Sound"/>
-    <entry group="4008" element="0108" keyword="InterpretationTranscriptionDate" vr="DA" vm="1" retired="true" name="Interpretation Transcription Date"/>
-    <entry group="4008" element="0109" keyword="InterpretationTranscriptionTime" vr="TM" vm="1" retired="true" name="Interpretation Transcription Time"/>
-    <entry group="4008" element="010a" keyword="InterpretationTranscriber" vr="PN" vm="1" retired="true" name="Interpretation Transcriber"/>
-    <entry group="4008" element="010b" keyword="InterpretationText" vr="ST" vm="1" retired="true" name="Interpretation Text"/>
-    <entry group="4008" element="010c" keyword="InterpretationAuthor" vr="PN" vm="1" retired="true" name="Interpretation Author"/>
-    <entry group="4008" element="0111" keyword="InterpretationApproverSequence" vr="SQ" vm="1" retired="true" name="Interpretation Approver Sequence"/>
-    <entry group="4008" element="0112" keyword="InterpretationApprovalDate" vr="DA" vm="1" retired="true" name="Interpretation Approval Date"/>
-    <entry group="4008" element="0113" keyword="InterpretationApprovalTime" vr="TM" vm="1" retired="true" name="Interpretation Approval Time"/>
-    <entry group="4008" element="0114" keyword="PhysicianApprovingInterpretation" vr="PN" vm="1" retired="true" name="Physician Approving Interpretation"/>
-    <entry group="4008" element="0115" keyword="InterpretationDiagnosisDescription" vr="LT" vm="1" retired="true" name="Interpretation Diagnosis Description"/>
-    <entry group="4008" element="0117" keyword="InterpretationDiagnosisCodeSequence" vr="SQ" vm="1" retired="true" name="Interpretation Diagnosis Code Sequence"/>
-    <entry group="4008" element="0118" keyword="ResultsDistributionListSequence" vr="SQ" vm="1" retired="true" name="Results Distribution List Sequence"/>
-    <entry group="4008" element="0119" keyword="DistributionName" vr="PN" vm="1" retired="true" name="Distribution Name"/>
-    <entry group="4008" element="011a" keyword="DistributionAddress" vr="LO" vm="1" retired="true" name="Distribution Address"/>
-    <entry group="4008" element="0200" keyword="InterpretationID" vr="SH" vm="1" retired="true" name="Interpretation ID"/>
-    <entry group="4008" element="0202" keyword="InterpretationIDIssuer" vr="LO" vm="1" retired="true" name="Interpretation ID Issuer"/>
-    <entry group="4008" element="0210" keyword="InterpretationTypeID" vr="CS" vm="1" retired="true" name="Interpretation Type ID"/>
-    <entry group="4008" element="0212" keyword="InterpretationStatusID" vr="CS" vm="1" retired="true" name="Interpretation Status ID"/>
-    <entry group="4008" element="0300" keyword="Impressions" vr="ST" vm="1" retired="true" name="Impressions"/>
-    <entry group="4008" element="4000" keyword="ResultsComments" vr="ST" vm="1" retired="true" name="Results Comments"/>
-    <entry group="4010" element="0001" keyword="LowEnergyDetectors" vr="CS" vm="1" name="Low Energy Detectors"/>
-    <entry group="4010" element="0002" keyword="HighEnergyDetectors" vr="CS" vm="1" name="High Energy Detectors"/>
-    <entry group="4010" element="0004" keyword="DetectorGeometrySequence" vr="SQ" vm="1" name="Detector Geometry Sequence"/>
-    <entry group="4010" element="1001" keyword="ThreatROIVoxelSequence" vr="SQ" vm="1" name="Threat ROI Voxel Sequence"/>
-    <entry group="4010" element="1004" keyword="ThreatROIBase" vr="FL" vm="3" name="Threat ROI Base"/>
-    <entry group="4010" element="1005" keyword="ThreatROIExtents" vr="FL" vm="3" name="Threat ROI Extents"/>
-    <entry group="4010" element="1006" keyword="ThreatROIBitmap" vr="OB" vm="1" name="Threat ROI Bitmap"/>
-    <entry group="4010" element="1007" keyword="RouteSegmentID" vr="SH" vm="1" name="Route Segment ID"/>
-    <entry group="4010" element="1008" keyword="GantryType" vr="CS" vm="1" name="Gantry Type"/>
-    <entry group="4010" element="1009" keyword="OOIOwnerType" vr="CS" vm="1" name="OOI Owner Type"/>
-    <entry group="4010" element="100a" keyword="RouteSegmentSequence" vr="SQ" vm="1" name="Route Segment Sequence"/>
-    <entry group="4010" element="1010" keyword="PotentialThreatObjectID" vr="US" vm="1" name="Potential Threat Object ID"/>
-    <entry group="4010" element="1011" keyword="ThreatSequence" vr="SQ" vm="1" name="Threat Sequence"/>
-    <entry group="4010" element="1012" keyword="ThreatCategory" vr="CS" vm="1" name="Threat Category"/>
-    <entry group="4010" element="1013" keyword="ThreatCategoryDescription" vr="LT" vm="1" name="Threat Category Description"/>
-    <entry group="4010" element="1014" keyword="ATDAbilityAssessment" vr="CS" vm="1" name="ATD Ability Assessment"/>
-    <entry group="4010" element="1015" keyword="ATDAssessmentFlag" vr="CS" vm="1" name="ATD Assessment Flag"/>
-    <entry group="4010" element="1016" keyword="ATDAssessmentProbability" vr="FL" vm="1" name="ATD Assessment Probability"/>
-    <entry group="4010" element="1017" keyword="Mass" vr="FL" vm="1" name="Mass"/>
-    <entry group="4010" element="1018" keyword="Density" vr="FL" vm="1" name="Density"/>
-    <entry group="4010" element="1019" keyword="ZEffective" vr="FL" vm="1" name="Z Effective"/>
-    <entry group="4010" element="101a" keyword="BoardingPassID" vr="SH" vm="1" name="Boarding Pass ID"/>
-    <entry group="4010" element="101b" keyword="CenterOfMass" vr="FL" vm="3" name="Center of Mass"/>
-    <entry group="4010" element="101c" keyword="CenterOfPTO" vr="FL" vm="3" name="Center of PTO"/>
-    <entry group="4010" element="101d" keyword="BoundingPolygon" vr="FL" vm="6-6n" name="Bounding Polygon"/>
-    <entry group="4010" element="101e" keyword="RouteSegmentStartLocationID" vr="SH" vm="1" name="Route Segment Start Location ID"/>
-    <entry group="4010" element="101f" keyword="RouteSegmentEndLocationID" vr="SH" vm="1" name="Route Segment End Location ID"/>
-    <entry group="4010" element="1020" keyword="RouteSegmentLocationIDType" vr="CS" vm="1" name="Route Segment Location ID Type"/>
-    <entry group="4010" element="1021" keyword="AbortReason" vr="CS" vm="1-n" name="Abort Reason"/>
-    <entry group="4010" element="1023" keyword="VolumeOfPTO" vr="FL" vm="1" name="Volume of PTO"/>
-    <entry group="4010" element="1024" keyword="AbortFlag" vr="CS" vm="1" name="Abort Flag"/>
-    <entry group="4010" element="1025" keyword="RouteSegmentStartTime" vr="DT" vm="1" name="Route Segment Start Time"/>
-    <entry group="4010" element="1026" keyword="RouteSegmentEndTime" vr="DT" vm="1" name="Route Segment End Time"/>
-    <entry group="4010" element="1027" keyword="TDRType" vr="CS" vm="1" name="TDR Type"/>
-    <entry group="4010" element="1028" keyword="InternationalRouteSegment" vr="CS" vm="1" name="International Route Segment"/>
-    <entry group="4010" element="1029" keyword="ThreatDetectionAlgorithmandVersion" vr="LO" vm="1-n" name="Threat Detection Algorithm and Version"/>
-    <entry group="4010" element="102a" keyword="AssignedLocation" vr="SH" vm="1" name="Assigned Location"/>
-    <entry group="4010" element="102b" keyword="AlarmDecisionTime" vr="DT" vm="1" name="Alarm Decision Time"/>
-    <entry group="4010" element="1031" keyword="AlarmDecision" vr="CS" vm="1" name="Alarm Decision"/>
-    <entry group="4010" element="1033" keyword="NumberOfTotalObjects" vr="US" vm="1" name="Number of Total Objects"/>
-    <entry group="4010" element="1034" keyword="NumberOfAlarmObjects" vr="US" vm="1" name="Number of Alarm Objects"/>
-    <entry group="4010" element="1037" keyword="PTORepresentationSequence" vr="SQ" vm="1" name="PTO Representation Sequence"/>
-    <entry group="4010" element="1038" keyword="ATDAssessmentSequence" vr="SQ" vm="1" name="ATD Assessment Sequence"/>
-    <entry group="4010" element="1039" keyword="TIPType" vr="CS" vm="1" name="TIP Type"/>
-    <entry group="4010" element="103a" keyword="DICOSVersion" vr="CS" vm="1" name="DICOS Version"/>
-    <entry group="4010" element="1041" keyword="OOIOwnerCreationTime" vr="DT" vm="1" name="OOI Owner Creation Time"/>
-    <entry group="4010" element="1042" keyword="OOIType" vr="CS" vm="1" name="OOI Type"/>
-    <entry group="4010" element="1043" keyword="OOISize" vr="FL" vm="3" name="OOI Size"/>
-    <entry group="4010" element="1044" keyword="AcquisitionStatus" vr="CS" vm="1" name="Acquisition Status"/>
-    <entry group="4010" element="1045" keyword="BasisMaterialsCodeSequence" vr="SQ" vm="1" name="Basis Materials Code Sequence"/>
-    <entry group="4010" element="1046" keyword="PhantomType" vr="CS" vm="1" name="Phantom Type"/>
-    <entry group="4010" element="1047" keyword="OOIOwnerSequence" vr="SQ" vm="1" name="OOI Owner Sequence"/>
-    <entry group="4010" element="1048" keyword="ScanType" vr="CS" vm="1" name="Scan Type"/>
-    <entry group="4010" element="1051" keyword="ItineraryID" vr="LO" vm="1" name="Itinerary ID"/>
-    <entry group="4010" element="1052" keyword="ItineraryIDType" vr="SH" vm="1" name="Itinerary ID Type"/>
-    <entry group="4010" element="1053" keyword="ItineraryIDAssigningAuthority" vr="LO" vm="1" name="Itinerary ID Assigning Authority"/>
-    <entry group="4010" element="1054" keyword="RouteID" vr="SH" vm="1" name="Route ID"/>
-    <entry group="4010" element="1055" keyword="RouteIDAssigningAuthority" vr="SH" vm="1" name="Route ID Assigning Authority"/>
-    <entry group="4010" element="1056" keyword="InboundArrivalType" vr="CS" vm="1" name="Inbound Arrival Type"/>
-    <entry group="4010" element="1058" keyword="CarrierID" vr="SH" vm="1" name="Carrier ID"/>
-    <entry group="4010" element="1059" keyword="CarrierIDAssigningAuthority" vr="CS" vm="1" name="Carrier ID Assigning Authority"/>
-    <entry group="4010" element="1060" keyword="SourceOrientation" vr="FL" vm="3" name="Source Orientation"/>
-    <entry group="4010" element="1061" keyword="SourcePosition" vr="FL" vm="3" name="Source Position"/>
-    <entry group="4010" element="1062" keyword="BeltHeight" vr="FL" vm="1" name="Belt Height"/>
-    <entry group="4010" element="1064" keyword="AlgorithmRoutingCodeSequence" vr="SQ" vm="1" name="Algorithm Routing Code Sequence"/>
-    <entry group="4010" element="1067" keyword="TransportClassification" vr="CS" vm="1" name="Transport Classification"/>
-    <entry group="4010" element="1068" keyword="OOITypeDescriptor" vr="LT" vm="1" name="OOI Type Descriptor"/>
-    <entry group="4010" element="1069" keyword="TotalProcessingTime" vr="FL" vm="1" name="Total Processing Time"/>
-    <entry group="4010" element="106c" keyword="DetectorCalibrationData" vr="OB" vm="1" name="Detector Calibration Data"/>
-    <entry group="4ffe" element="0001" keyword="MACParametersSequence" vr="SQ" vm="1" name="MAC Parameters Sequence"/>
-    <entry group="50xx" element="0005" keyword="CurveDimensions" vr="US" vm="1" retired="true" name="Curve Dimensions"/>
-    <entry group="50xx" element="0010" keyword="NumberOfPoints" vr="US" vm="1" retired="true" name="Number of Points"/>
-    <entry group="50xx" element="0020" keyword="TypeOfData" vr="CS" vm="1" retired="true" name="Type of Data"/>
-    <entry group="50xx" element="0022" keyword="CurveDescription" vr="LO" vm="1" retired="true" name="Curve Description"/>
-    <entry group="50xx" element="0030" keyword="AxisUnits" vr="SH" vm="1-n" retired="true" name="Axis Units"/>
-    <entry group="50xx" element="0040" keyword="AxisLabels" vr="SH" vm="1-n" retired="true" name="Axis Labels"/>
-    <entry group="50xx" element="0103" keyword="DataValueRepresentation" vr="US" vm="1" retired="true" name="Data Value Representation"/>
-    <entry group="50xx" element="0104" keyword="MinimumCoordinateValue" vr="US" vm="1-n" retired="true" name="Minimum Coordinate Value"/>
-    <entry group="50xx" element="0105" keyword="MaximumCoordinateValue" vr="US" vm="1-n" retired="true" name="Maximum Coordinate Value"/>
-    <entry group="50xx" element="0106" keyword="CurveRange" vr="SH" vm="1-n" retired="true" name="Curve Range"/>
-    <entry group="50xx" element="0110" keyword="CurveDataDescriptor" vr="US" vm="1-n" retired="true" name="Curve Data Descriptor"/>
-    <entry group="50xx" element="0112" keyword="CoordinateStartValue" vr="US" vm="1-n" retired="true" name="Coordinate Start Value"/>
-    <entry group="50xx" element="0114" keyword="CoordinateStepValue" vr="US" vm="1-n" retired="true" name="Coordinate Step Value"/>
-    <entry group="50xx" element="1001" keyword="CurveActivationLayer" vr="CS" vm="1" retired="true" name="Curve Activation Layer"/>
-    <entry group="50xx" element="2000" keyword="AudioType" vr="US" vm="1" retired="true" name="Audio Type"/>
-    <entry group="50xx" element="2002" keyword="AudioSampleFormat" vr="US" vm="1" retired="true" name="Audio Sample Format"/>
-    <entry group="50xx" element="2004" keyword="NumberOfChannels" vr="US" vm="1" retired="true" name="Number of Channels"/>
-    <entry group="50xx" element="2006" keyword="NumberOfSamples" vr="UL" vm="1" retired="true" name="Number of Samples"/>
-    <entry group="50xx" element="2008" keyword="SampleRate" vr="UL" vm="1" retired="true" name="Sample Rate"/>
-    <entry group="50xx" element="200a" keyword="TotalTime" vr="UL" vm="1" retired="true" name="Total Time"/>
-    <entry group="50xx" element="200c" keyword="AudioSampleData" vr="OB_OW" vm="1" retired="true" name="Audio Sample Data"/>
-    <entry group="50xx" element="200e" keyword="AudioComments" vr="LT" vm="1" retired="true" name="Audio Comments"/>
-    <entry group="50xx" element="2500" keyword="CurveLabel" vr="LO" vm="1" retired="true" name="Curve Label"/>
-    <entry group="50xx" element="2600" keyword="CurveReferencedOverlaySequence" vr="SQ" vm="1" retired="true" name="Curve Referenced Overlay Sequence"/>
-    <entry group="50xx" element="2610" keyword="CurveReferencedOverlayGroup" vr="US" vm="1" retired="true" name="Curve Referenced Overlay Group"/>
-    <entry group="50xx" element="3000" keyword="CurveData" vr="OB_OW" vm="1" retired="true" name="Curve Data"/>
-    <entry group="5200" element="9229" keyword="SharedFunctionalGroupsSequence" vr="SQ" vm="1" name="Shared Functional Groups Sequence"/>
-    <entry group="5200" element="9230" keyword="PerFrameFunctionalGroupsSequence" vr="SQ" vm="1" name="Per-frame Functional Groups Sequence"/>
-    <entry group="5400" element="0100" keyword="WaveformSequence" vr="SQ" vm="1" name="Waveform Sequence"/>
-    <entry group="5400" element="0110" keyword="ChannelMinimumValue" vr="OB_OW" vm="1" name="Channel Minimum Value"/>
-    <entry group="5400" element="0112" keyword="ChannelMaximumValue" vr="OB_OW" vm="1" name="Channel Maximum Value"/>
-    <entry group="5400" element="1004" keyword="WaveformBitsAllocated" vr="US" vm="1" name="Waveform Bits Allocated"/>
-    <entry group="5400" element="1006" keyword="WaveformSampleInterpretation" vr="CS" vm="1" name="Waveform Sample Interpretation"/>
-    <entry group="5400" element="100a" keyword="WaveformPaddingValue" vr="OB_OW" vm="1" name="Waveform Padding Value"/>
-    <entry group="5400" element="1010" keyword="WaveformData" vr="OB_OW" vm="1" name="Waveform Data"/>
-    <entry group="5600" element="0010" keyword="FirstOrderPhaseCorrectionAngle" vr="OF" vm="1" name="First Order Phase Correction Angle"/>
-    <entry group="5600" element="0020" keyword="SpectroscopyData" vr="OF" vm="1" name="Spectroscopy Data"/>
-    <entry group="60xx" element="0010" keyword="OverlayRows" vr="US" vm="1" name="Overlay Rows"/>
-    <entry group="60xx" element="0011" keyword="OverlayColumns" vr="US" vm="1" name="Overlay Columns"/>
-    <entry group="60xx" element="0012" keyword="OverlayPlanes" vr="US" vm="1" retired="true" name="Overlay Planes"/>
-    <entry group="60xx" element="0015" keyword="NumberOfFramesInOverlay" vr="IS" vm="1" name="Number of Frames in Overlay"/>
-    <entry group="60xx" element="0022" keyword="OverlayDescription" vr="LO" vm="1" name="Overlay Description"/>
-    <entry group="60xx" element="0040" keyword="OverlayType" vr="CS" vm="1" name="Overlay Type"/>
-    <entry group="60xx" element="0045" keyword="OverlaySubtype" vr="LO" vm="1" name="Overlay Subtype"/>
-    <entry group="60xx" element="0050" keyword="OverlayOrigin" vr="SS" vm="2" name="Overlay Origin"/>
-    <entry group="60xx" element="0051" keyword="ImageFrameOrigin" vr="US" vm="1" name="Image Frame Origin"/>
-    <entry group="60xx" element="0052" keyword="OverlayPlaneOrigin" vr="US" vm="1" retired="true" name="Overlay Plane Origin"/>
-    <entry group="60xx" element="0060" keyword="OverlayCompressionCode" vr="CS" vm="1" retired="true" name="Overlay Compression Code"/>
-    <entry group="60xx" element="0061" keyword="OverlayCompressionOriginator" vr="SH" vm="1" retired="true" name="Overlay Compression Originator"/>
-    <entry group="60xx" element="0062" keyword="OverlayCompressionLabel" vr="SH" vm="1" retired="true" name="Overlay Compression Label"/>
-    <entry group="60xx" element="0063" keyword="OverlayCompressionDescription" vr="CS" vm="1" retired="true" name="Overlay Compression Description"/>
-    <entry group="60xx" element="0066" keyword="OverlayCompressionStepPointers" vr="AT" vm="1-n" retired="true" name="Overlay Compression Step Pointers"/>
-    <entry group="60xx" element="0068" keyword="OverlayRepeatInterval" vr="US" vm="1" retired="true" name="Overlay Repeat Interval"/>
-    <entry group="60xx" element="0069" keyword="OverlayBitsGrouped" vr="US" vm="1" retired="true" name="Overlay Bits Grouped"/>
-    <entry group="60xx" element="0100" keyword="OverlayBitsAllocated" vr="US" vm="1" name="Overlay Bits Allocated"/>
-    <entry group="60xx" element="0102" keyword="OverlayBitPosition" vr="US" vm="1" name="Overlay Bit Position"/>
-    <entry group="60xx" element="0110" keyword="OverlayFormat" vr="CS" vm="1" retired="true" name="Overlay Format"/>
-    <entry group="60xx" element="0200" keyword="OverlayLocation" vr="US" vm="1" retired="true" name="Overlay Location"/>
-    <entry group="60xx" element="0800" keyword="OverlayCodeLabel" vr="CS" vm="1-n" retired="true" name="Overlay Code Label"/>
-    <entry group="60xx" element="0802" keyword="OverlayNumberOfTables" vr="US" vm="1" retired="true" name="Overlay Number of Tables"/>
-    <entry group="60xx" element="0803" keyword="OverlayCodeTableLocation" vr="AT" vm="1-n" retired="true" name="Overlay Code Table Location"/>
-    <entry group="60xx" element="0804" keyword="OverlayBitsForCodeWord" vr="US" vm="1" retired="true" name="Overlay Bits For Code Word"/>
-    <entry group="60xx" element="1001" keyword="OverlayActivationLayer" vr="CS" vm="1" name="Overlay Activation Layer"/>
-    <entry group="60xx" element="1100" keyword="OverlayDescriptorGray" vr="US" vm="1" retired="true" name="Overlay Descriptor - Gray"/>
-    <entry group="60xx" element="1101" keyword="OverlayDescriptorRed" vr="US" vm="1" retired="true" name="Overlay Descriptor - Red"/>
-    <entry group="60xx" element="1102" keyword="OverlayDescriptorGreen" vr="US" vm="1" retired="true" name="Overlay Descriptor - Green"/>
-    <entry group="60xx" element="1103" keyword="OverlayDescriptorBlue" vr="US" vm="1" retired="true" name="Overlay Descriptor - Blue"/>
-    <entry group="60xx" element="1200" keyword="OverlaysGray" vr="US" vm="1-n" retired="true" name="Overlays - Gray"/>
-    <entry group="60xx" element="1201" keyword="OverlaysRed" vr="US" vm="1-n" retired="true" name="Overlays - Red"/>
-    <entry group="60xx" element="1202" keyword="OverlaysGreen" vr="US" vm="1-n" retired="true" name="Overlays - Green"/>
-    <entry group="60xx" element="1203" keyword="OverlaysBlue" vr="US" vm="1-n" retired="true" name="Overlays - Blue"/>
-    <entry group="60xx" element="1301" keyword="ROIArea" vr="IS" vm="1" name="ROI Area"/>
-    <entry group="60xx" element="1302" keyword="ROIMean" vr="DS" vm="1" name="ROI Mean"/>
-    <entry group="60xx" element="1303" keyword="ROIStandardDeviation" vr="DS" vm="1" name="ROI Standard Deviation"/>
-    <entry group="60xx" element="1500" keyword="OverlayLabel" vr="LO" vm="1" name="Overlay Label"/>
-    <entry group="60xx" element="3000" keyword="OverlayData" vr="OB_OW" vm="1" name="Overlay Data"/>
-    <entry group="60xx" element="4000" keyword="OverlayComments" vr="LT" vm="1" retired="true" name="Overlay Comments"/>
-    <entry group="7fe0" element="0010" keyword="PixelData" vr="OB_OW" vm="1" name="Pixel Data"/>
-    <entry group="7fe0" element="0020" keyword="CoefficientsSDVN" vr="OW" vm="1" retired="true" name="Coefficients SDVN"/>
-    <entry group="7fe0" element="0030" keyword="CoefficientsSDHN" vr="OW" vm="1" retired="true" name="Coefficients SDHN"/>
-    <entry group="7fe0" element="0040" keyword="CoefficientsSDDN" vr="OW" vm="1" retired="true" name="Coefficients SDDN"/>
-    <entry group="7fxx" element="0010" keyword="VariablePixelData" vr="OB_OW" vm="1" retired="true" name="Variable Pixel Data"/>
-    <entry group="7fxx" element="0011" keyword="VariableNextDataGroup" vr="US" vm="1" retired="true" name="Variable Next Data Group"/>
-    <entry group="7fxx" element="0020" keyword="VariableCoefficientsSDVN" vr="OW" vm="1" retired="true" name="Variable Coefficients SDVN"/>
-    <entry group="7fxx" element="0030" keyword="VariableCoefficientsSDHN" vr="OW" vm="1" retired="true" name="Variable Coefficients SDHN"/>
-    <entry group="7fxx" element="0040" keyword="VariableCoefficientsSDDN" vr="OW" vm="1" retired="true" name="Variable Coefficients SDDN"/>
-    <entry group="fffa" element="fffa" keyword="DigitalSignaturesSequence" vr="SQ" vm="1" name="Digital Signatures Sequence"/>
-    <entry group="fffc" element="fffc" keyword="DataSetTrailingPadding" vr="OB" vm="1" name="Data Set Trailing Padding"/>
-    <entry group="fffe" element="e000" keyword="Item" vm="1" name="Item"/>
-    <entry group="fffe" element="e00d" keyword="ItemDelimitationItem" vm="1" name="Item Delimitation Item"/>
-    <entry group="fffe" element="e0dd" keyword="SequenceDelimitationItem" vm="1" name="Sequence Delimitation Item"/>
-  </dict>
-  <dict ref="7" name="Registry of DICOM File Meta Elements">
-    <entry group="0002" element="0000" keyword="FileMetaInformationGroupLength" vr="UL" vm="1" name="File Meta Information Group Length"/>
-    <entry group="0002" element="0001" keyword="FileMetaInformationVersion" vr="OB" vm="1" name="File Meta Information Version"/>
-    <entry group="0002" element="0002" keyword="MediaStorageSOPClassUID" vr="UI" vm="1" name="Media Storage SOP Class UID"/>
-    <entry group="0002" element="0003" keyword="MediaStorageSOPInstanceUID" vr="UI" vm="1" name="Media Storage SOP Instance UID"/>
-    <entry group="0002" element="0010" keyword="TransferSyntaxUID" vr="UI" vm="1" name="Transfer Syntax UID"/>
-    <entry group="0002" element="0012" keyword="ImplementationClassUID" vr="UI" vm="1" name="Implementation Class UID"/>
-    <entry group="0002" element="0013" keyword="ImplementationVersionName" vr="SH" vm="1" name="Implementation Version Name"/>
-    <entry group="0002" element="0016" keyword="SourceApplicationEntityTitle" vr="AE" vm="1" name="Source Application Entity Title"/>
-    <entry group="0002" element="0100" keyword="PrivateInformationCreatorUID" vr="UI" vm="1" name="Private Information Creator UID"/>
-    <entry group="0002" element="0102" keyword="PrivateInformation" vr="OB" vm="1" name="Private Information"/>
-  </dict>
-  <dict ref="8" name="Registry of DICOM directory structuring elements">
-    <entry group="0004" element="1130" keyword="FileSetID" vr="CS" vm="1" name="File-set ID"/>
-    <entry group="0004" element="1141" keyword="FileSetDescriptorFileID" vr="CS" vm="1-8" name="File-set Descriptor File ID"/>
-    <entry group="0004" element="1142" keyword="SpecificCharacterSetOfFileSetDescriptorFile" vr="CS" vm="1" name="Specific Character Set of File-set Descriptor File"/>
-    <entry group="0004" element="1200" keyword="OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity" vr="UL" vm="1" name="Offset of the First Directory Record of the Root Directory Entity"/>
-    <entry group="0004" element="1202" keyword="OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity" vr="UL" vm="1" name="Offset of the Last Directory Record of the Root Directory Entity"/>
-    <entry group="0004" element="1212" keyword="FileSetConsistencyFlag" vr="US" vm="1" name="File-set Consistency Flag"/>
-    <entry group="0004" element="1220" keyword="DirectoryRecordSequence" vr="SQ" vm="1" name="Directory Record Sequence"/>
-    <entry group="0004" element="1400" keyword="OffsetOfTheNextDirectoryRecord" vr="UL" vm="1" name="Offset of the Next Directory Record"/>
-    <entry group="0004" element="1410" keyword="RecordInUseFlag" vr="US" vm="1" name="Record In-use Flag"/>
-    <entry group="0004" element="1420" keyword="OffsetOfReferencedLowerLevelDirectoryEntity" vr="UL" vm="1" name="Offset of Referenced Lower-Level Directory Entity"/>
-    <entry group="0004" element="1430" keyword="DirectoryRecordType" vr="CS" vm="1" name="Directory Record Type"/>
-    <entry group="0004" element="1432" keyword="PrivateRecordUID" vr="UI" vm="1" name="Private Record UID"/>
-    <entry group="0004" element="1500" keyword="ReferencedFileID" vr="CS" vm="1-8" name="Referenced File ID"/>
-    <entry group="0004" element="1504" keyword="MRDRDirectoryRecordOffset" vr="UL" vm="1" retired="true" name="MRDR Directory Record Offset"/>
-    <entry group="0004" element="1510" keyword="ReferencedSOPClassUIDInFile" vr="UI" vm="1" name="Referenced SOP Class UID in File"/>
-    <entry group="0004" element="1511" keyword="ReferencedSOPInstanceUIDInFile" vr="UI" vm="1" name="Referenced SOP Instance UID in File"/>
-    <entry group="0004" element="1512" keyword="ReferencedTransferSyntaxUIDInFile" vr="UI" vm="1" name="Referenced Transfer Syntax UID in File"/>
-    <entry group="0004" element="151a" keyword="ReferencedRelatedGeneralSOPClassUIDInFile" vr="UI" vm="1-n" name="Referenced Related General SOP Class UID in File"/>
-    <entry group="0004" element="1600" keyword="NumberOfReferences" vr="UL" vm="1" retired="true" name="Number of References"/>
-  </dict>
-  <table ref="Table A-1" name="UID VALUES">
-    <uid value="1.2.840.10008.1.1" name="Verification SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.1.2" name="Implicit VR Little Endian: Default Transfer Syntax for DICOM" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.1" name="Explicit VR Little Endian" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.1.99" name="Deflated Explicit VR Little Endian" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.2" name="Explicit VR Big Endian" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.50" name="JPEG Baseline (Process 1): Default Transfer Syntax for Lossy JPEG 8 Bit Image Compression" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.51" name="JPEG Extended (Process 2 & 4): Default Transfer Syntax for Lossy JPEG 12 Bit Image Compression (Process 4 only)" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.52" name="JPEG Extended (Process 3 & 5)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.53" name="JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.54" name="JPEG Spectral Selection, Non-Hierarchical (Process 7 & 9)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.55" name="JPEG Full Progression, Non-Hierarchical (Process 10 & 12)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.56" name="JPEG Full Progression, Non-Hierarchical (Process 11 & 13)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.57" name="JPEG Lossless, Non-Hierarchical (Process 14)" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.58" name="JPEG Lossless, Non-Hierarchical (Process 15)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.59" name="JPEG Extended, Hierarchical (Process 16 & 18)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.60" name="JPEG Extended, Hierarchical (Process 17 & 19)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.61" name="JPEG Spectral Selection, Hierarchical (Process 20 & 22)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.62" name="JPEG Spectral Selection, Hierarchical (Process 21 & 23)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.63" name="JPEG Full Progression, Hierarchical (Process 24 & 26)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.64" name="JPEG Full Progression, Hierarchical (Process 25 & 27)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.65" name="JPEG Lossless, Hierarchical (Process 28)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.66" name="JPEG Lossless, Hierarchical (Process 29)" type="Transfer Syntax" part="PS 3.5" retired="true"/>
-    <uid value="1.2.840.10008.1.2.4.70" name="JPEG Lossless, Non-Hierarchical, First-Order Prediction (Process 14 [Selection Value 1]): Default Transfer Syntax for Lossless JPEG Image Compression" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.80" name="JPEG-LS Lossless Image Compression" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.81" name="JPEG-LS Lossy (Near-Lossless) Image Compression" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.90" name="JPEG 2000 Image Compression (Lossless Only)" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.91" name="JPEG 2000 Image Compression" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.92" name="JPEG 2000 Part 2 Multi-component Image Compression (Lossless Only)" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.93" name="JPEG 2000 Part 2 Multi-component Image Compression" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.94" name="JPIP Referenced" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.95" name="JPIP Referenced Deflate" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.100" name="MPEG2 Main Profile @ Main Level" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.101" name="MPEG2 Main Profile @ High Level" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.102" name="MPEG-4 AVC/H.264 High Profile / Level 4.1" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.4.103" name="MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.5" name="RLE Lossless" type="Transfer Syntax" part="PS 3.5" retired="false"/>
-    <uid value="1.2.840.10008.1.2.6.1" name="RFC 2557 MIME encapsulation" type="Transfer Syntax" part="PS 3.10" retired="false"/>
-    <uid value="1.2.840.10008.1.2.6.2" name="XML Encoding" type="Transfer Syntax" part="PS 3.10" retired="false"/>
-    <uid value="1.2.840.10008.1.3.10" name="Media Storage Directory Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.1" name="Talairach Brain Atlas Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.2" name="SPM2 T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.3" name="SPM2 T2 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.4" name="SPM2 PD Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.5" name="SPM2 EPI Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.6" name="SPM2 FIL T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.7" name="SPM2 PET Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.8" name="SPM2 TRANSM Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.9" name="SPM2 SPECT Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.10" name="SPM2 GRAY Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.11" name="SPM2 WHITE Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.12" name="SPM2 CSF Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.13" name="SPM2 BRAINMASK Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.14" name="SPM2 AVG305T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.15" name="SPM2 AVG152T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.16" name="SPM2 AVG152T2 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.17" name="SPM2 AVG152PD Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.1.18" name="SPM2 SINGLESUBJT1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.2.1" name="ICBM 452 T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.4.2.2" name="ICBM Single Subject MRI Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
-    <uid value="1.2.840.10008.1.5.1" name="Hot Iron Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
-    <uid value="1.2.840.10008.1.5.2" name="PET Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
-    <uid value="1.2.840.10008.1.5.3" name="Hot Metal Blue Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
-    <uid value="1.2.840.10008.1.5.4" name="PET 20 Step Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
-    <uid value="1.2.840.10008.1.9" name="Basic Study Content Notification SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.1.20.1" name="Storage Commitment Push Model SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.1.20.1.1" name="Storage Commitment Push Model SOP Instance" type="Well-known SOP Instance" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.1.20.2" name="Storage Commitment Pull Model SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.1.20.2.1" name="Storage Commitment Pull Model SOP Instance" type="Well-known SOP Instance" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.1.40" name="Procedural Event Logging SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.1.40.1" name="Procedural Event Logging SOP Instance" type="Well-known SOP Instance" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.1.42" name="Substance Administration Logging SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.1.42.1" name="Substance Administration Logging SOP Instance" type="Well-known SOP Instance" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.2.6.1" name="DICOM UID Registry" type="DICOM UIDs as a Coding Scheme" part="PS 3.6" retired="false"/>
-    <uid value="1.2.840.10008.2.16.4" name="DICOM Controlled Terminology" type="Coding Scheme" part="PS 3.16" retired="false"/>
-    <uid value="1.2.840.10008.3.1.1.1" name="DICOM Application Context Name" type="Application Context Name" part="PS 3.7" retired="false"/>
-    <uid value="1.2.840.10008.3.1.2.1.1" name="Detached Patient Management SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.1.4" name="Detached Patient Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.2.1" name="Detached Visit Management SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.3.1" name="Detached Study Management SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.3.2" name="Study Component Management SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.3.3" name="Modality Performed Procedure Step SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.3.1.2.3.4" name="Modality Performed Procedure Step Retrieve SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.3.1.2.3.5" name="Modality Performed Procedure Step Notification SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.3.1.2.5.1" name="Detached Results Management SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.5.4" name="Detached Results Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.5.5" name="Detached Study Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.3.1.2.6.1" name="Detached Interpretation Management SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.4.2" name="Storage Service Class" type="Service Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.1" name="Basic Film Session SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.2" name="Basic Film Box SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.4" name="Basic Grayscale Image Box SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.4.1" name="Basic Color Image Box SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.4.2" name="Referenced Image Box SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.9" name="Basic Grayscale Print Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.9.1" name="Referenced Grayscale Print Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.14" name="Print Job SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.15" name="Basic Annotation Box SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.16" name="Printer SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.16.376" name="Printer Configuration Retrieval SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.17" name="Printer SOP Instance" type="Well-known Printer SOP Instance" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.17.376" name="Printer Configuration Retrieval SOP Instance" type="Well-known Printer SOP Instance" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.18" name="Basic Color Print Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.18.1" name="Referenced Color Print Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.22" name="VOI LUT Box SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.23" name="Presentation LUT SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.1.24" name="Image Overlay Box SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.24.1" name="Basic Print Image Overlay Box SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.25" name="Print Queue SOP Instance" type="Well-known Print Queue SOP Instance" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.26" name="Print Queue Management SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.27" name="Stored Print Storage SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.29" name="Hardcopy Grayscale Image Storage SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.30" name="Hardcopy Color Image Storage SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.31" name="Pull Print Request SOP Class" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.32" name="Pull Stored Print Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.1.33" name="Media Creation Management SOP Class UID" type="SOP Class" part="PS3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.1" name="Computed Radiography Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.1.1" name="Digital X-Ray Image Storage - For Presentation" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.1.1.1" name="Digital X-Ray Image Storage - For Processing" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.1.2" name="Digital Mammography X-Ray Image Storage - For Presentation" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.1.2.1" name="Digital Mammography X-Ray Image Storage - For Processing" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.1.3" name="Digital Intra-oral X-Ray Image Storage - For Presentation" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.1.3.1" name="Digital Intra-oral X-Ray Image Storage - For Processing" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.2" name="CT Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.2.1" name="Enhanced CT Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.3" name="Ultrasound Multi-frame Image Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.3.1" name="Ultrasound Multi-frame Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.4" name="MR Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.4.1" name="Enhanced MR Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.4.2" name="MR Spectroscopy Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.4.3" name="Enhanced MR Color Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.5" name="Nuclear Medicine Image Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.6" name="Ultrasound Image Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.6.1" name="Ultrasound Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.6.2" name="Enhanced US Volume Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.7" name="Secondary Capture Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.7.1" name="Multi-frame Single Bit Secondary Capture Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.7.2" name="Multi-frame Grayscale Byte Secondary Capture Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.7.3" name="Multi-frame Grayscale Word Secondary Capture Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.7.4" name="Multi-frame True Color Secondary Capture Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.8" name="Standalone Overlay Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9" name="Standalone Curve Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.1" name="Waveform Storage - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.1.1" name="12-lead ECG Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.1.2" name="General ECG Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.1.3" name="Ambulatory ECG Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.2.1" name="Hemodynamic Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.3.1" name="Cardiac Electrophysiology Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.4.1" name="Basic Voice Audio Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.4.2" name="General Audio Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.5.1" name="Arterial Pulse Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.9.6.1" name="Respiratory Waveform Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.10" name="Standalone Modality LUT Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.11" name="Standalone VOI LUT Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.11.1" name="Grayscale Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.11.2" name="Color Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.11.3" name="Pseudo-Color Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.11.4" name="Blending Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.11.5" name="XA/XRF Grayscale Softcopy Presentation State Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.12.1" name="X-Ray Angiographic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.12.1.1" name="Enhanced XA Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.12.2" name="X-Ray Radiofluoroscopic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.12.2.1" name="Enhanced XRF Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.12.3" name="X-Ray Angiographic Bi-Plane Image Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.13.1.1" name="X-Ray 3D Angiographic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.13.1.2" name="X-Ray 3D Craniofacial Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.13.1.3" name="Breast Tomosynthesis Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.14.1" name="Intravascular Optical Coherence Tomography Image Storage - For Presentation" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.14.2" name="Intravascular Optical Coherence Tomography Image Storage - For Processing" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.20" name="Nuclear Medicine Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.66" name="Raw Data Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.66.1" name="Spatial Registration Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.66.2" name="Spatial Fiducials Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.66.3" name="Deformable Spatial Registration Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.66.4" name="Segmentation Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.66.5" name="Surface Segmentation Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.67" name="Real World Value Mapping Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1" name="VL Image Storage - Trial" type="" part="" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.2" name="VL Multi-frame Image Storage - Trial" type="" part="" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.1" name="VL Endoscopic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.1.1" name="Video Endoscopic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.2" name="VL Microscopic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.2.1" name="Video Microscopic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.3" name="VL Slide-Coordinates Microscopic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.4" name="VL Photographic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.4.1" name="Video Photographic Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.1" name="Ophthalmic Photography 8 Bit Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.2" name="Ophthalmic Photography 16 Bit Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.3" name="Stereometric Relationship Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.4" name="Ophthalmic Tomography Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.77.1.6" name="VL Whole Slide Microscopy Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.1" name="Lensometry Measurements Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.2" name="Autorefraction Measurements Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.3" name="Keratometry Measurements Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.4" name="Subjective Refraction Measurements Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.5" name="Visual Acuity Measurements Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.6" name="Spectacle Prescription Report Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.7" name="Ophthalmic Axial Measurements Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.78.8" name="Intraocular Lens Calculations Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.79.1" name="Macular Grid Thickness and Volume Report Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.80.1" name="Ophthalmic Visual Field Static Perimetry Measurements Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.1" name="Text SR Storage - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.2" name="Audio SR Storage - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.3" name="Detail SR Storage - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.4" name="Comprehensive SR Storage - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.11" name="Basic Text SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.22" name="Enhanced SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.33" name="Comprehensive SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.40" name="Procedure Log Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.50" name="Mammography CAD SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.59" name="Key Object Selection Document Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.65" name="Chest CAD SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.67" name="X-Ray Radiation Dose SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.69" name="Colon CAD SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.88.70" name="Implantation Plan SR Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.104.1" name="Encapsulated PDF Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.104.2" name="Encapsulated CDA Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.128" name="Positron Emission Tomography Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.129" name="Standalone PET Curve Storage" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.130" name="Enhanced PET Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.131" name="Basic Structured Display Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.1" name="RT Image Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.2" name="RT Dose Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.3" name="RT Structure Set Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.4" name="RT Beams Treatment Record Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.5" name="RT Plan Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.6" name="RT Brachy Treatment Record Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.7" name="RT Treatment Summary Record Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.8" name="RT Ion Plan Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.481.9" name="RT Ion Beams Treatment Record Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.501.1" name="DICOS CT Image Storage" type="SOP Class" part="DICOS" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.501.2.1" name="DICOS Digital X-Ray Image Storage - For Presentation" type="SOP Class" part="DICOS" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.501.2.2" name="DICOS Digital X-Ray Image Storage - For Processing" type="SOP Class" part="DICOS" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.501.3" name="DICOS Threat Detection Report Storage" type="SOP Class" part="DICOS" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.601.1" name="Eddy Current Image Storage" type="SOP Class" part="DICONDE ASTM Exxxx" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.1.601.2" name="Eddy Current Multi-frame Image Storage" type="SOP Class" part="DICONDE ASTM Exxxx" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.1.1" name="Patient Root Query/Retrieve Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.1.2" name="Patient Root Query/Retrieve Information Model - MOVE" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.1.3" name="Patient Root Query/Retrieve Information Model - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.2.1" name="Study Root Query/Retrieve Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.2.2" name="Study Root Query/Retrieve Information Model - MOVE" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.2.3" name="Study Root Query/Retrieve Information Model - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.3.1" name="Patient/Study Only Query/Retrieve Information Model - FIND" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.3.2" name="Patient/Study Only Query/Retrieve Information Model - MOVE" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.3.3" name="Patient/Study Only Query/Retrieve Information Model - GET" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.4.2" name="Composite Instance Root Retrieve - MOVE" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.4.3" name="Composite Instance Root Retrieve - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.1.2.5.3" name="Composite Instance Retrieve Without Bulk Data - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.31" name="Modality Worklist Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.32.1" name="General Purpose Worklist Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.32.2" name="General Purpose Scheduled Procedure Step SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.32.3" name="General Purpose Performed Procedure Step SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.32" name="General Purpose Worklist Management Meta SOP Class" type="Meta SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.33" name="Instance Availability Notification SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.1" name="RT Beams Delivery Instruction Storage - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.2" name="RT Conventional Machine Verification - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.3" name="RT Ion Machine Verification - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.4" name="Unified Worklist and Procedure Step Service Class - Trial" type="Service Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.4.1" name="Unified Procedure Step - Push SOP Class - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.4.2" name="Unified Procedure Step - Watch SOP Class - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.4.3" name="Unified Procedure Step - Pull SOP Class - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.4.4" name="Unified Procedure Step - Event SOP Class - Trial" type="SOP Class" part="PS 3.4" retired="true"/>
-    <uid value="1.2.840.10008.5.1.4.34.5" name="Unified Worklist and Procedure Step SOP Instance" type="Well-known SOP Instance" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.6" name="Unified Worklist and Procedure Step Service Class" type="Service Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.6.1" name="Unified Procedure Step - Push SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.6.2" name="Unified Procedure Step - Watch SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.6.3" name="Unified Procedure Step - Pull SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.6.4" name="Unified Procedure Step - Event SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.7" name="RT Beams Delivery Instruction Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.8" name="RT Conventional Machine Verification" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.34.9" name="RT Ion Machine Verification" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.37.1" name="General Relevant Patient Information Query" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.37.2" name="Breast Imaging Relevant Patient Information Query" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.37.3" name="Cardiac Relevant Patient Information Query" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.38.1" name="Hanging Protocol Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.38.2" name="Hanging Protocol Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.38.3" name="Hanging Protocol Information Model - MOVE" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.38.4" name="Hanging Protocol Information Model - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.39.1" name="Color Palette Storage" type="Transfer" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.39.2" name="Color Palette Information Model - FIND" type="Query/Retrieve" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.39.3" name="Color Palette Information Model - MOVE" type="Query/Retrieve" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.39.4" name="Color Palette Information Model - GET" type="Query/Retrieve" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.41" name="Product Characteristics Query SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.42" name="Substance Approval Query SOP Class" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.43.1" name="Generic Implant Template Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.43.2" name="Generic Implant Template Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.43.3" name="Generic Implant Template Information Model - MOVE" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.43.4" name="Generic Implant Template Information Model - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.44.1" name="Implant Assembly Template Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.44.2" name="Implant Assembly Template Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.44.3" name="Implant Assembly Template Information Model - MOVE" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.44.4" name="Implant Assembly Template Information Model - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.45.1" name="Implant Template Group Storage" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.45.2" name="Implant Template Group Information Model - FIND" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.45.3" name="Implant Template Group Information Model - MOVE" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.5.1.4.45.4" name="Implant Template Group Information Model - GET" type="SOP Class" part="PS 3.4" retired="false"/>
-    <uid value="1.2.840.10008.7.1.1" name="Native DICOM Model" type="Application Hosting Model" part="PS 3.19" retired="false"/>
-    <uid value="1.2.840.10008.7.1.2" name="Abstract Multi-Dimensional Image Model" type="Application Hosting Model" part="PS 3.19" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.1" name="dicomDeviceName" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.2" name="dicomDescription" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.3" name="dicomManufacturer" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.4" name="dicomManufacturerModelName" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.5" name="dicomSoftwareVersion" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.6" name="dicomVendorData" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.7" name="dicomAETitle" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.8" name="dicomNetworkConnectionReference" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.9" name="dicomApplicationCluster" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.10" name="dicomAssociationInitiator" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.11" name="dicomAssociationAcceptor" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.12" name="dicomHostname" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.13" name="dicomPort" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.14" name="dicomSOPClass" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.15" name="dicomTransferRole" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.16" name="dicomTransferSyntax" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.17" name="dicomPrimaryDeviceType" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.18" name="dicomRelatedDeviceReference" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.19" name="dicomPreferredCalledAETitle" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.20" name="dicomTLSCyphersuite" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.21" name="dicomAuthorizedNodeCertificateReference" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.22" name="dicomThisNodeCertificateReference" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.23" name="dicomInstalled" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.24" name="dicomStationName" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.25" name="dicomDeviceSerialNumber" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.26" name="dicomInstitutionName" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.27" name="dicomInstitutionAddress" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.28" name="dicomInstitutionDepartmentName" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.29" name="dicomIssuerOfPatientID" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.30" name="dicomPreferredCallingAETitle" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.3.31" name="dicomSupportedCharacterSet" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.1" name="dicomConfigurationRoot" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.2" name="dicomDevicesRoot" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.3" name="dicomUniqueAETitlesRegistryRoot" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.4" name="dicomDevice" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.5" name="dicomNetworkAE" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.6" name="dicomNetworkConnection" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.7" name="dicomUniqueAETitle" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.0.4.8" name="dicomTransferCapability" type="LDAP OID" part="PS 3.15" retired="false"/>
-    <uid value="1.2.840.10008.15.1.1" name="Universal Coordinated Time" type="Synchronization Frame of Reference" part="PS 3.3" retired="false"/>
-  </table>
-  <table ref="Table A-2" name="Well-known Frames of Reference">
-    <uid value="1.2.840.10008.1.4.1.1" name="Talairach Brain Atlas Frame of Reference" normative-reference="Talairach J. and Tournoux P. Co-Planar stereotactic atlas of the human brain. Stutgart: Georg Thieme Verlag, 1988."/>
-    <uid value="1.2.840.10008.1.4.1.2" name="SPM2 T1 Frame of Reference" normative-reference="SPM2 /templates/T1.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.3" name="SPM2 T2 Frame of Reference" normative-reference="SPM2 /templates/T2.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.4" name="SPM2 PD Frame of Reference" normative-reference="SPM2 /templates/PD.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.5" name="SPM2 EPI Frame of Reference" normative-reference="SPM2 /templates/EPI.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.6" name="SPM2 FIL T1 Frame of Reference" normative-reference="SPM2 /templates/filT1.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.7" name="SPM2 PET Frame of Reference" normative-reference="SPM2 /templates/PET.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.8" name="SPM2 TRANSM Frame of Reference" normative-reference="SPM2 /templates/Transm.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.9" name="SPM2 SPECT Frame of Reference" normative-reference="SPM2 /templates/SPECT.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.10" name="SPM2 GRAY Frame of Reference" normative-reference="SPM2 /apriori/gray.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.11" name="SPM2 WHITE Frame of Reference" normative-reference="SPM2 /apriori/white.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.12" name="SPM2 CSF Frame of Reference" normative-reference="SPM2 /apriori/csf.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.13" name="SPM2 BRAINMASK Frame of Reference" normative-reference="SPM2 /apriori/brainmask.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.14" name="SPM2 AVG305T1 Frame of Reference" normative-reference="SPM2 /canonical/avg305T1.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.15" name="SPM2 AVG152T1 Frame of Reference" normative-reference="SPM2 /canonical/avg152T1.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.16" name="SPM2 AVG152T2 Frame of Reference" normative-reference="SPM2 /canonical/avg152T2.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.17" name="SPM2 AVG152PD Frame of Reference" normative-reference="SPM2 /canonical/avg152PD.mnc"/>
-    <uid value="1.2.840.10008.1.4.1.18" name="SPM2 SINGLESUBJT1 Frame of Reference" normative-reference="SPM2 /canonical/single_subj_T1.mnc"/>
-    <uid value="1.2.840.10008.1.4.2.1" name="ICBM 452 T1 Frame of Reference" normative-reference="ICBM452 T1 Atlas"/>
-    <uid value="1.2.840.10008.1.4.2.2" name="ICBM Single Subject MRI Frame of Reference" normative-reference="ICBM Single Subject MRI Anatomical Template"/>
-  </table>
+<dict ref="6" name="Registry of DICOM Data Elements">
+        <entry group="0008" element="0001" keyword="LengthToEnd" vr="UL" vm="1" retired="true" name="Length to End"/>
+        <entry group="0008" element="0005" keyword="SpecificCharacterSet" vr="CS" vm="1-n" name="Specific Character Set"/>
+        <entry group="0008" element="0006" keyword="LanguageCodeSequence" vr="SQ" vm="1" name="Language Code Sequence"/>
+        <entry group="0008" element="0008" keyword="ImageType" vr="CS" vm="2-n" name="Image Type"/>
+        <entry group="0008" element="0010" keyword="RecognitionCode" vr="SH" vm="1" retired="true" name="Recognition Code"/>
+        <entry group="0008" element="0012" keyword="InstanceCreationDate" vr="DA" vm="1" name="Instance Creation Date"/>
+        <entry group="0008" element="0013" keyword="InstanceCreationTime" vr="TM" vm="1" name="Instance Creation Time"/>
+        <entry group="0008" element="0014" keyword="InstanceCreatorUID" vr="UI" vm="1" name="Instance Creator UID"/>
+        <entry group="0008" element="0015" keyword="InstanceCoercionDateTime" vr="DT" vm="1" name="Instance Coercion DateTime"/>
+        <entry group="0008" element="0016" keyword="SOPClassUID" vr="UI" vm="1" name="SOP Class UID"/>
+        <entry group="0008" element="0018" keyword="SOPInstanceUID" vr="UI" vm="1" name="SOP Instance UID"/>
+        <entry group="0008" element="001a" keyword="RelatedGeneralSOPClassUID" vr="UI" vm="1-n" name="Related General SOP Class UID"/>
+        <entry group="0008" element="001b" keyword="OriginalSpecializedSOPClassUID" vr="UI" vm="1" name="Original Specialized SOP Class UID"/>
+        <entry group="0008" element="0020" keyword="StudyDate" vr="DA" vm="1" name="Study Date"/>
+        <entry group="0008" element="0021" keyword="SeriesDate" vr="DA" vm="1" name="Series Date"/>
+        <entry group="0008" element="0022" keyword="AcquisitionDate" vr="DA" vm="1" name="Acquisition Date"/>
+        <entry group="0008" element="0023" keyword="ContentDate" vr="DA" vm="1" name="Content Date"/>
+        <entry group="0008" element="0024" keyword="OverlayDate" vr="DA" vm="1" retired="true" name="Overlay Date"/>
+        <entry group="0008" element="0025" keyword="CurveDate" vr="DA" vm="1" retired="true" name="Curve Date"/>
+        <entry group="0008" element="002a" keyword="AcquisitionDateTime" vr="DT" vm="1" name="Acquisition DateTime"/>
+        <entry group="0008" element="0030" keyword="StudyTime" vr="TM" vm="1" name="Study Time"/>
+        <entry group="0008" element="0031" keyword="SeriesTime" vr="TM" vm="1" name="Series Time"/>
+        <entry group="0008" element="0032" keyword="AcquisitionTime" vr="TM" vm="1" name="Acquisition Time"/>
+        <entry group="0008" element="0033" keyword="ContentTime" vr="TM" vm="1" name="Content Time"/>
+        <entry group="0008" element="0034" keyword="OverlayTime" vr="TM" vm="1" retired="true" name="Overlay Time"/>
+        <entry group="0008" element="0035" keyword="CurveTime" vr="TM" vm="1" retired="true" name="Curve Time"/>
+        <entry group="0008" element="0040" keyword="DataSetType" vr="US" vm="1" retired="true" name="Data Set Type"/>
+        <entry group="0008" element="0041" keyword="DataSetSubtype" vr="LO" vm="1" retired="true" name="Data Set Subtype"/>
+        <entry group="0008" element="0042" keyword="NuclearMedicineSeriesType" vr="CS" vm="1" retired="true" name="Nuclear Medicine Series Type"/>
+        <entry group="0008" element="0050" keyword="AccessionNumber" vr="SH" vm="1" name="Accession Number"/>
+        <entry group="0008" element="0051" keyword="IssuerOfAccessionNumberSequence" vr="SQ" vm="1" name="Issuer of Accession Number Sequence"/>
+        <entry group="0008" element="0052" keyword="QueryRetrieveLevel" vr="CS" vm="1" name="Query/Retrieve Level"/>
+        <entry group="0008" element="0053" keyword="QueryRetrieveView" vr="CS" vm="1" name="Query/Retrieve View"/>
+        <entry group="0008" element="0054" keyword="RetrieveAETitle" vr="AE" vm="1-n" name="Retrieve AE Title"/>
+        <entry group="0008" element="0055" keyword="StationAETitle" vr="AE" vm="1" name="Station  AE Title"/>
+        <entry group="0008" element="0056" keyword="InstanceAvailability" vr="CS" vm="1" name="Instance Availability"/>
+        <entry group="0008" element="0058" keyword="FailedSOPInstanceUIDList" vr="UI" vm="1-n" name="Failed SOP Instance UID List"/>
+        <entry group="0008" element="0060" keyword="Modality" vr="CS" vm="1" name="Modality"/>
+        <entry group="0008" element="0061" keyword="ModalitiesInStudy" vr="CS" vm="1-n" name="Modalities in Study"/>
+        <entry group="0008" element="0062" keyword="SOPClassesInStudy" vr="UI" vm="1-n" name="SOP Classes in Study"/>
+        <entry group="0008" element="0064" keyword="ConversionType" vr="CS" vm="1" name="Conversion Type"/>
+        <entry group="0008" element="0068" keyword="PresentationIntentType" vr="CS" vm="1" name="Presentation Intent Type"/>
+        <entry group="0008" element="0070" keyword="Manufacturer" vr="LO" vm="1" name="Manufacturer"/>
+        <entry group="0008" element="0080" keyword="InstitutionName" vr="LO" vm="1" name="Institution Name"/>
+        <entry group="0008" element="0081" keyword="InstitutionAddress" vr="ST" vm="1" name="Institution Address"/>
+        <entry group="0008" element="0082" keyword="InstitutionCodeSequence" vr="SQ" vm="1" name="Institution Code Sequence"/>
+        <entry group="0008" element="0090" keyword="ReferringPhysicianName" vr="PN" vm="1" name="Referring Physician's Name"/>
+        <entry group="0008" element="0092" keyword="ReferringPhysicianAddress" vr="ST" vm="1" name="Referring Physician's Address"/>
+        <entry group="0008" element="0094" keyword="ReferringPhysicianTelephoneNumbers" vr="SH" vm="1-n" name="Referring Physician's Telephone Numbers"/>
+        <entry group="0008" element="0096" keyword="ReferringPhysicianIdentificationSequence" vr="SQ" vm="1" name="Referring Physician Identification Sequence"/>
+        <entry group="0008" element="009c" keyword="ConsultingPhysicianName" vr="PN" vm="1-n" name="Consulting Physician's Name"/>
+        <entry group="0008" element="009d" keyword="ConsultingPhysicianIdentificationSequence" vr="SQ" vm="1" name="Consulting Physician Identification Sequence"/>
+        <entry group="0008" element="0100" keyword="CodeValue" vr="SH" vm="1" name="Code Value"/>
+        <entry group="0008" element="0101" keyword="ExtendedCodeValue" vr="LO" vm="1" name="Extended Code Value"/>
+        <entry group="0008" element="0102" keyword="CodingSchemeDesignator" vr="SH" vm="1" name="Coding Scheme Designator"/>
+        <entry group="0008" element="0103" keyword="CodingSchemeVersion" vr="SH" vm="1" name="Coding Scheme Version"/>
+        <entry group="0008" element="0104" keyword="CodeMeaning" vr="LO" vm="1" name="Code Meaning"/>
+        <entry group="0008" element="0105" keyword="MappingResource" vr="CS" vm="1" name="Mapping Resource"/>
+        <entry group="0008" element="0106" keyword="ContextGroupVersion" vr="DT" vm="1" name="Context Group Version"/>
+        <entry group="0008" element="0107" keyword="ContextGroupLocalVersion" vr="DT" vm="1" name="Context Group Local Version"/>
+        <entry group="0008" element="0108" keyword="ExtendedCodeMeaning" vr="LT" vm="1" name="Extended Code Meaning"/>
+        <entry group="0008" element="010b" keyword="ContextGroupExtensionFlag" vr="CS" vm="1" name="Context Group Extension Flag"/>
+        <entry group="0008" element="010c" keyword="CodingSchemeUID" vr="UI" vm="1" name="Coding Scheme UID"/>
+        <entry group="0008" element="010d" keyword="ContextGroupExtensionCreatorUID" vr="UI" vm="1" name="Context Group Extension Creator UID"/>
+        <entry group="0008" element="010f" keyword="ContextIdentifier" vr="CS" vm="1" name="Context Identifier"/>
+        <entry group="0008" element="0110" keyword="CodingSchemeIdentificationSequence" vr="SQ" vm="1" name="Coding Scheme Identification Sequence"/>
+        <entry group="0008" element="0112" keyword="CodingSchemeRegistry" vr="LO" vm="1" name="Coding Scheme Registry"/>
+        <entry group="0008" element="0114" keyword="CodingSchemeExternalID" vr="ST" vm="1" name="Coding Scheme External ID"/>
+        <entry group="0008" element="0115" keyword="CodingSchemeName" vr="ST" vm="1" name="Coding Scheme Name"/>
+        <entry group="0008" element="0116" keyword="CodingSchemeResponsibleOrganization" vr="ST" vm="1" name="Coding Scheme Responsible Organization"/>
+        <entry group="0008" element="0117" keyword="ContextUID" vr="UI" vm="1" name="Context UID"/>
+        <entry group="0008" element="0118" keyword="MappingResourceUID" vr="UI" vm="1" name="Mapping Resource UID"/>
+        <entry group="0008" element="0119" keyword="LongCodeValue" vr="UC" vm="1" name="Long Code Value"/>
+        <entry group="0008" element="0120" keyword="URNCodeValue" vr="UR" vm="1" name="URN Code Value"/>
+        <entry group="0008" element="0121" keyword="EquivalentCodeSequence" vr="SQ" vm="1" name="Equivalent Code Sequence"/>
+        <entry group="0008" element="0122" keyword="MappingResourceName" vr="LO" vm="1" name="Mapping Resource Name"/>
+        <entry group="0008" element="0123" keyword="ContextGroupIdentificationSequence" vr="SQ" vm="1" name="Context Group Identification Sequence"/>
+        <entry group="0008" element="0124" keyword="MappingResourceIdentificationSequence" vr="SQ" vm="1" name="Mapping Resource Identification Sequence"/>
+        <entry group="0008" element="0201" keyword="TimezoneOffsetFromUTC" vr="SH" vm="1" name="Timezone Offset From UTC"/>
+        <entry group="0008" element="0220" keyword="ResponsibleGroupCodeSequence" vr="SQ" vm="1" name="Responsible Group Code Sequence"/>
+        <entry group="0008" element="0221" keyword="EquipmentModality" vr="CS" vm="1" name="Equipment Modality"/>
+        <entry group="0008" element="0222" keyword="ManufacturerRelatedModelGroup" vr="LO" vm="1" name="Manufacturer's Related Model Group"/>
+        <entry group="0008" element="0300" keyword="PrivateDataElementCharacteristicsSequence" vr="SQ" vm="1" name="Private Data Element Characteristics Sequence"/>
+        <entry group="0008" element="0301" keyword="PrivateGroupReference" vr="US" vm="1" name="Private Group Reference"/>
+        <entry group="0008" element="0302" keyword="PrivateCreatorReference" vr="LO" vm="1" name="Private Creator Reference"/>
+        <entry group="0008" element="0303" keyword="BlockIdentifyingInformationStatus" vr="CS" vm="1" name="Block Identifying Information Status"/>
+        <entry group="0008" element="0304" keyword="NonidentifyingPrivateElements" vr="US" vm="1-n" name="Nonidentifying Private Elements"/>
+        <entry group="0008" element="0306" keyword="IdentifyingPrivateElements" vr="US" vm="1-n" name="Identifying Private Elements"/>
+        <entry group="0008" element="0305" keyword="DeidentificationActionSequence" vr="SQ" vm="1" name="Deidentification Action Sequence"/>
+        <entry group="0008" element="0307" keyword="DeidentificationAction" vr="CS" vm="1" name="Deidentification Action"/>
+        <entry group="0008" element="0308" keyword="PrivateDataElement" vr="US" vm="1" name="Private Data Element"/>
+        <entry group="0008" element="0309" keyword="PrivateDataElementValueMultiplicity" vr="UL" vm="1-3" name="Private Data Element Value Multiplicity"/>
+        <entry group="0008" element="030a" keyword="PrivateDataElementValueRepresentation" vr="CS" vm="1" name="Private Data Element Value Representation"/>
+        <entry group="0008" element="030b" keyword="PrivateDataElementNumberOfItems" vr="UL" vm="1-2" name="Private Data Element Number of Items"/>
+        <entry group="0008" element="030c" keyword="PrivateDataElementName" vr="UC" vm="1" name="Private Data Element Name"/>
+        <entry group="0008" element="030d" keyword="PrivateDataElementKeyword" vr="UC" vm="1" name="Private Data Element Keyword"/>
+        <entry group="0008" element="030e" keyword="PrivateDataElementDescription" vr="UT" vm="1" name="Private Data Element Description"/>
+        <entry group="0008" element="030f" keyword="PrivateDataElementEncoding" vr="UT" vm="1" name="Private Data Element Encoding"/>
+        <entry group="0008" element="0310" keyword="PrivateDataElementDefinitionSequence" vr="SQ" vm="1" name="Private Data Element Definition Sequence"/>
+        <entry group="0008" element="1000" keyword="NetworkID" vr="AE" vm="1" retired="true" name="Network ID"/>
+        <entry group="0008" element="1010" keyword="StationName" vr="SH" vm="1" name="Station Name"/>
+        <entry group="0008" element="1030" keyword="StudyDescription" vr="LO" vm="1" name="Study Description"/>
+        <entry group="0008" element="1032" keyword="ProcedureCodeSequence" vr="SQ" vm="1" name="Procedure Code Sequence"/>
+        <entry group="0008" element="103e" keyword="SeriesDescription" vr="LO" vm="1" name="Series Description"/>
+        <entry group="0008" element="103f" keyword="SeriesDescriptionCodeSequence" vr="SQ" vm="1" name="Series Description Code Sequence"/>
+        <entry group="0008" element="1040" keyword="InstitutionalDepartmentName" vr="LO" vm="1" name="Institutional Department Name"/>
+        <entry group="0008" element="1048" keyword="PhysiciansOfRecord" vr="PN" vm="1-n" name="Physician(s) of Record"/>
+        <entry group="0008" element="1049" keyword="PhysiciansOfRecordIdentificationSequence" vr="SQ" vm="1" name="Physician(s) of Record Identification Sequence"/>
+        <entry group="0008" element="1050" keyword="PerformingPhysicianName" vr="PN" vm="1-n" name="Performing Physician's Name"/>
+        <entry group="0008" element="1052" keyword="PerformingPhysicianIdentificationSequence" vr="SQ" vm="1" name="Performing Physician Identification Sequence"/>
+        <entry group="0008" element="1060" keyword="NameOfPhysiciansReadingStudy" vr="PN" vm="1-n" name="Name of Physician(s) Reading Study"/>
+        <entry group="0008" element="1062" keyword="PhysiciansReadingStudyIdentificationSequence" vr="SQ" vm="1" name="Physician(s) Reading Study Identification Sequence"/>
+        <entry group="0008" element="1070" keyword="OperatorsName" vr="PN" vm="1-n" name="Operators' Name"/>
+        <entry group="0008" element="1072" keyword="OperatorIdentificationSequence" vr="SQ" vm="1" name="Operator Identification Sequence"/>
+        <entry group="0008" element="1080" keyword="AdmittingDiagnosesDescription" vr="LO" vm="1-n" name="Admitting Diagnoses Description"/>
+        <entry group="0008" element="1084" keyword="AdmittingDiagnosesCodeSequence" vr="SQ" vm="1" name="Admitting Diagnoses Code Sequence"/>
+        <entry group="0008" element="1090" keyword="ManufacturerModelName" vr="LO" vm="1" name="Manufacturer's Model Name"/>
+        <entry group="0008" element="1100" keyword="ReferencedResultsSequence" vr="SQ" vm="1" retired="true" name="Referenced Results Sequence"/>
+        <entry group="0008" element="1110" keyword="ReferencedStudySequence" vr="SQ" vm="1" name="Referenced Study Sequence"/>
+        <entry group="0008" element="1111" keyword="ReferencedPerformedProcedureStepSequence" vr="SQ" vm="1" name="Referenced Performed Procedure Step Sequence"/>
+        <entry group="0008" element="1115" keyword="ReferencedSeriesSequence" vr="SQ" vm="1" name="Referenced Series Sequence"/>
+        <entry group="0008" element="1120" keyword="ReferencedPatientSequence" vr="SQ" vm="1" name="Referenced Patient Sequence"/>
+        <entry group="0008" element="1125" keyword="ReferencedVisitSequence" vr="SQ" vm="1" name="Referenced Visit Sequence"/>
+        <entry group="0008" element="1130" keyword="ReferencedOverlaySequence" vr="SQ" vm="1" retired="true" name="Referenced Overlay Sequence"/>
+        <entry group="0008" element="1134" keyword="ReferencedStereometricInstanceSequence" vr="SQ" vm="1" name="Referenced Stereometric Instance Sequence"/>
+        <entry group="0008" element="113a" keyword="ReferencedWaveformSequence" vr="SQ" vm="1" name="Referenced Waveform Sequence"/>
+        <entry group="0008" element="1140" keyword="ReferencedImageSequence" vr="SQ" vm="1" name="Referenced Image Sequence"/>
+        <entry group="0008" element="1145" keyword="ReferencedCurveSequence" vr="SQ" vm="1" retired="true" name="Referenced Curve Sequence"/>
+        <entry group="0008" element="114a" keyword="ReferencedInstanceSequence" vr="SQ" vm="1" name="Referenced Instance Sequence"/>
+        <entry group="0008" element="114b" keyword="ReferencedRealWorldValueMappingInstanceSequence" vr="SQ" vm="1" name="Referenced Real World Value Mapping Instance Sequence"/>
+        <entry group="0008" element="1150" keyword="ReferencedSOPClassUID" vr="UI" vm="1" name="Referenced SOP Class UID"/>
+        <entry group="0008" element="1155" keyword="ReferencedSOPInstanceUID" vr="UI" vm="1" name="Referenced SOP Instance UID"/>
+        <entry group="0008" element="115a" keyword="SOPClassesSupported" vr="UI" vm="1-n" name="SOP Classes Supported"/>
+        <entry group="0008" element="1160" keyword="ReferencedFrameNumber" vr="IS" vm="1-n" name="Referenced Frame Number"/>
+        <entry group="0008" element="1161" keyword="SimpleFrameList" vr="UL" vm="1-n" name="Simple Frame List"/>
+        <entry group="0008" element="1162" keyword="CalculatedFrameList" vr="UL" vm="3-3n" name="Calculated Frame List"/>
+        <entry group="0008" element="1163" keyword="TimeRange" vr="FD" vm="2" name="Time Range"/>
+        <entry group="0008" element="1164" keyword="FrameExtractionSequence" vr="SQ" vm="1" name="Frame Extraction Sequence"/>
+        <entry group="0008" element="1167" keyword="MultiFrameSourceSOPInstanceUID" vr="UI" vm="1" name="Multi-frame Source SOP Instance UID"/>
+        <entry group="0008" element="1190" keyword="RetrieveURL" vr="UR" vm="1" name="Retrieve URL"/>
+        <entry group="0008" element="1195" keyword="TransactionUID" vr="UI" vm="1" name="Transaction UID"/>
+        <entry group="0008" element="1196" keyword="WarningReason" vr="US" vm="1" name="Warning Reason"/>
+        <entry group="0008" element="1197" keyword="FailureReason" vr="US" vm="1" name="Failure Reason"/>
+        <entry group="0008" element="1198" keyword="FailedSOPSequence" vr="SQ" vm="1" name="Failed SOP Sequence"/>
+        <entry group="0008" element="1199" keyword="ReferencedSOPSequence" vr="SQ" vm="1" name="Referenced SOP Sequence"/>
+        <entry group="0008" element="119a" keyword="OtherFailuresSequence" vr="SQ" vm="1" name="Other Failures Sequence"/>
+        <entry group="0008" element="1200" keyword="StudiesContainingOtherReferencedInstancesSequence" vr="SQ" vm="1" name="Studies Containing Other Referenced Instances Sequence"/>
+        <entry group="0008" element="1250" keyword="RelatedSeriesSequence" vr="SQ" vm="1" name="Related Series Sequence"/>
+        <entry group="0008" element="2110" keyword="LossyImageCompressionRetired" vr="CS" vm="1" retired="true" name="Lossy Image Compression (Retired)"/>
+        <entry group="0008" element="2111" keyword="DerivationDescription" vr="ST" vm="1" name="Derivation Description"/>
+        <entry group="0008" element="2112" keyword="SourceImageSequence" vr="SQ" vm="1" name="Source Image Sequence"/>
+        <entry group="0008" element="2120" keyword="StageName" vr="SH" vm="1" name="Stage Name"/>
+        <entry group="0008" element="2122" keyword="StageNumber" vr="IS" vm="1" name="Stage Number"/>
+        <entry group="0008" element="2124" keyword="NumberOfStages" vr="IS" vm="1" name="Number of Stages"/>
+        <entry group="0008" element="2127" keyword="ViewName" vr="SH" vm="1" name="View Name"/>
+        <entry group="0008" element="2128" keyword="ViewNumber" vr="IS" vm="1" name="View Number"/>
+        <entry group="0008" element="2129" keyword="NumberOfEventTimers" vr="IS" vm="1" name="Number of Event Timers"/>
+        <entry group="0008" element="212a" keyword="NumberOfViewsInStage" vr="IS" vm="1" name="Number of Views in Stage"/>
+        <entry group="0008" element="2130" keyword="EventElapsedTimes" vr="DS" vm="1-n" name="Event Elapsed Time(s)"/>
+        <entry group="0008" element="2132" keyword="EventTimerNames" vr="LO" vm="1-n" name="Event Timer Name(s)"/>
+        <entry group="0008" element="2133" keyword="EventTimerSequence" vr="SQ" vm="1" name="Event Timer Sequence"/>
+        <entry group="0008" element="2134" keyword="EventTimeOffset" vr="FD" vm="1" name="Event Time Offset"/>
+        <entry group="0008" element="2135" keyword="EventCodeSequence" vr="SQ" vm="1" name="Event Code Sequence"/>
+        <entry group="0008" element="2142" keyword="StartTrim" vr="IS" vm="1" name="Start Trim"/>
+        <entry group="0008" element="2143" keyword="StopTrim" vr="IS" vm="1" name="Stop Trim"/>
+        <entry group="0008" element="2144" keyword="RecommendedDisplayFrameRate" vr="IS" vm="1" name="Recommended Display Frame Rate"/>
+        <entry group="0008" element="2200" keyword="TransducerPosition" vr="CS" vm="1" retired="true" name="Transducer Position"/>
+        <entry group="0008" element="2204" keyword="TransducerOrientation" vr="CS" vm="1" retired="true" name="Transducer Orientation"/>
+        <entry group="0008" element="2208" keyword="AnatomicStructure" vr="CS" vm="1" retired="true" name="Anatomic Structure"/>
+        <entry group="0008" element="2218" keyword="AnatomicRegionSequence" vr="SQ" vm="1" name="Anatomic Region Sequence"/>
+        <entry group="0008" element="2220" keyword="AnatomicRegionModifierSequence" vr="SQ" vm="1" name="Anatomic Region Modifier Sequence"/>
+        <entry group="0008" element="2228" keyword="PrimaryAnatomicStructureSequence" vr="SQ" vm="1" name="Primary Anatomic Structure Sequence"/>
+        <entry group="0008" element="2229" keyword="AnatomicStructureSpaceOrRegionSequence" vr="SQ" vm="1" name="Anatomic Structure, Space or Region Sequence"/>
+        <entry group="0008" element="2230" keyword="PrimaryAnatomicStructureModifierSequence" vr="SQ" vm="1" name="Primary Anatomic Structure Modifier Sequence"/>
+        <entry group="0008" element="2240" keyword="TransducerPositionSequence" vr="SQ" vm="1" retired="true" name="Transducer Position Sequence"/>
+        <entry group="0008" element="2242" keyword="TransducerPositionModifierSequence" vr="SQ" vm="1" retired="true" name="Transducer Position Modifier Sequence"/>
+        <entry group="0008" element="2244" keyword="TransducerOrientationSequence" vr="SQ" vm="1" retired="true" name="Transducer Orientation Sequence"/>
+        <entry group="0008" element="2246" keyword="TransducerOrientationModifierSequence" vr="SQ" vm="1" retired="true" name="Transducer Orientation Modifier Sequence"/>
+        <entry group="0008" element="2251" keyword="AnatomicStructureSpaceOrRegionCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Structure Space Or Region Code Sequence (Trial)"/>
+        <entry group="0008" element="2253" keyword="AnatomicPortalOfEntranceCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Portal Of Entrance Code Sequence (Trial)"/>
+        <entry group="0008" element="2255" keyword="AnatomicApproachDirectionCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Approach Direction Code Sequence (Trial)"/>
+        <entry group="0008" element="2256" keyword="AnatomicPerspectiveDescriptionTrial" vr="ST" vm="1" retired="true" name="Anatomic Perspective Description (Trial)"/>
+        <entry group="0008" element="2257" keyword="AnatomicPerspectiveCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Perspective Code Sequence (Trial)"/>
+        <entry group="0008" element="2258" keyword="AnatomicLocationOfExaminingInstrumentDescriptionTrial" vr="ST" vm="1" retired="true" name="Anatomic Location Of Examining Instrument Description (Trial)"/>
+        <entry group="0008" element="2259" keyword="AnatomicLocationOfExaminingInstrumentCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Location Of Examining Instrument Code Sequence (Trial)"/>
+        <entry group="0008" element="225a" keyword="AnatomicStructureSpaceOrRegionModifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Anatomic Structure Space Or Region Modifier Code Sequence (Trial)"/>
+        <entry group="0008" element="225c" keyword="OnAxisBackgroundAnatomicStructureCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="On Axis Background Anatomic Structure Code Sequence (Trial)"/>
+        <entry group="0008" element="3001" keyword="AlternateRepresentationSequence" vr="SQ" vm="1" name="Alternate Representation Sequence"/>
+        <entry group="0008" element="3010" keyword="IrradiationEventUID" vr="UI" vm="1-n" name="Irradiation Event UID"/>
+        <entry group="0008" element="3011" keyword="SourceIrradiationEventSequence" vr="SQ" vm="1" name="Source Irradiation Event Sequence"/>
+        <entry group="0008" element="3012" keyword="RadiopharmaceuticalAdministrationEventUID" vr="UI" vm="1" name="Radiopharmaceutical Administration Event UID"/>
+        <entry group="0008" element="4000" keyword="IdentifyingComments" vr="LT" vm="1" retired="true" name="Identifying Comments"/>
+        <entry group="0008" element="9007" keyword="FrameType" vr="CS" vm="4" name="Frame Type"/>
+        <entry group="0008" element="9092" keyword="ReferencedImageEvidenceSequence" vr="SQ" vm="1" name="Referenced Image Evidence Sequence"/>
+        <entry group="0008" element="9121" keyword="ReferencedRawDataSequence" vr="SQ" vm="1" name="Referenced Raw Data Sequence"/>
+        <entry group="0008" element="9123" keyword="CreatorVersionUID" vr="UI" vm="1" name="Creator-Version UID"/>
+        <entry group="0008" element="9124" keyword="DerivationImageSequence" vr="SQ" vm="1" name="Derivation Image Sequence"/>
+        <entry group="0008" element="9154" keyword="SourceImageEvidenceSequence" vr="SQ" vm="1" name="Source Image Evidence Sequence"/>
+        <entry group="0008" element="9205" keyword="PixelPresentation" vr="CS" vm="1" name="Pixel Presentation"/>
+        <entry group="0008" element="9206" keyword="VolumetricProperties" vr="CS" vm="1" name="Volumetric Properties"/>
+        <entry group="0008" element="9207" keyword="VolumeBasedCalculationTechnique" vr="CS" vm="1" name="Volume Based Calculation Technique"/>
+        <entry group="0008" element="9208" keyword="ComplexImageComponent" vr="CS" vm="1" name="Complex Image Component"/>
+        <entry group="0008" element="9209" keyword="AcquisitionContrast" vr="CS" vm="1" name="Acquisition Contrast"/>
+        <entry group="0008" element="9215" keyword="DerivationCodeSequence" vr="SQ" vm="1" name="Derivation Code Sequence"/>
+        <entry group="0008" element="9237" keyword="ReferencedPresentationStateSequence" vr="SQ" vm="1" name="Referenced Presentation State Sequence"/>
+        <entry group="0008" element="9410" keyword="ReferencedOtherPlaneSequence" vr="SQ" vm="1" name="Referenced Other Plane Sequence"/>
+        <entry group="0008" element="9458" keyword="FrameDisplaySequence" vr="SQ" vm="1" name="Frame Display Sequence"/>
+        <entry group="0008" element="9459" keyword="RecommendedDisplayFrameRateInFloat" vr="FL" vm="1" name="Recommended Display Frame Rate in Float"/>
+        <entry group="0008" element="9460" keyword="SkipFrameRangeFlag" vr="CS" vm="1" name="Skip Frame Range Flag"/>
+        <entry group="0010" element="0010" keyword="PatientName" vr="PN" vm="1" name="Patient's Name"/>
+        <entry group="0010" element="0020" keyword="PatientID" vr="LO" vm="1" name="Patient ID"/>
+        <entry group="0010" element="0021" keyword="IssuerOfPatientID" vr="LO" vm="1" name="Issuer of Patient ID"/>
+        <entry group="0010" element="0022" keyword="TypeOfPatientID" vr="CS" vm="1" name="Type of Patient ID"/>
+        <entry group="0010" element="0024" keyword="IssuerOfPatientIDQualifiersSequence" vr="SQ" vm="1" name="Issuer of Patient ID Qualifiers Sequence"/>
+        <entry group="0010" element="0026" keyword="SourcePatientGroupIdentificationSequence" vr="SQ" vm="1" name="Source Patient Group Identification Sequence"/>
+        <entry group="0010" element="0027" keyword="GroupOfPatientsIdentificationSequence" vr="SQ" vm="1" name="Group of Patients Identification Sequence"/>
+        <entry group="0010" element="0028" keyword="SubjectRelativePositionInImage" vr="US" vm="3" name="Subject Relative Position in Image"/>
+        <entry group="0010" element="0030" keyword="PatientBirthDate" vr="DA" vm="1" name="Patient's Birth Date"/>
+        <entry group="0010" element="0032" keyword="PatientBirthTime" vr="TM" vm="1" name="Patient's Birth Time"/>
+        <entry group="0010" element="0033" keyword="PatientBirthDateInAlternativeCalendar" vr="LO" vm="1" name="Patient's Birth Date in Alternative Calendar"/>
+        <entry group="0010" element="0034" keyword="PatientDeathDateInAlternativeCalendar" vr="LO" vm="1" name="Patient's Death Date in Alternative Calendar"/>
+        <entry group="0010" element="0035" keyword="PatientAlternativeCalendar" vr="CS" vm="1" name="Patient's Alternative Calendar"/>
+        <entry group="0010" element="0040" keyword="PatientSex" vr="CS" vm="1" name="Patient's Sex"/>
+        <entry group="0010" element="0050" keyword="PatientInsurancePlanCodeSequence" vr="SQ" vm="1" name="Patient's Insurance Plan Code Sequence"/>
+        <entry group="0010" element="0101" keyword="PatientPrimaryLanguageCodeSequence" vr="SQ" vm="1" name="Patient's Primary Language Code Sequence"/>
+        <entry group="0010" element="0102" keyword="PatientPrimaryLanguageModifierCodeSequence" vr="SQ" vm="1" name="Patient's Primary Language Modifier Code Sequence"/>
+        <entry group="0010" element="0200" keyword="QualityControlSubject" vr="CS" vm="1" name="Quality Control Subject"/>
+        <entry group="0010" element="0201" keyword="QualityControlSubjectTypeCodeSequence" vr="SQ" vm="1" name="Quality Control Subject Type Code Sequence"/>
+        <entry group="0010" element="0212" keyword="StrainDescription" vr="UC" vm="1" name="Strain Description"/>
+        <entry group="0010" element="0213" keyword="StrainNomenclature" vr="LO" vm="1" name="Strain Nomenclature"/>
+        <entry group="0010" element="0214" keyword="StrainStockNumber" vr="LO" vm="1" name="Strain Stock Number"/>
+        <entry group="0010" element="0215" keyword="StrainSourceRegistryCodeSequence" vr="SQ" vm="1" name="Strain Source Registry Code Sequence"/>
+        <entry group="0010" element="0216" keyword="StrainStockSequence" vr="SQ" vm="1" name="Strain Stock Sequence"/>
+        <entry group="0010" element="0217" keyword="StrainSource" vr="LO" vm="1" name="Strain Source"/>
+        <entry group="0010" element="0218" keyword="StrainAdditionalInformation" vr="UT" vm="1" name="Strain Additional Information"/>
+        <entry group="0010" element="0219" keyword="StrainCodeSequence" vr="SQ" vm="1" name="Strain Code Sequence"/>
+        <entry group="0010" element="1000" keyword="OtherPatientIDs" vr="LO" vm="1-n" name="Other Patient IDs"/>
+        <entry group="0010" element="1001" keyword="OtherPatientNames" vr="PN" vm="1-n" name="Other Patient Names"/>
+        <entry group="0010" element="1002" keyword="OtherPatientIDsSequence" vr="SQ" vm="1" name="Other Patient IDs Sequence"/>
+        <entry group="0010" element="1005" keyword="PatientBirthName" vr="PN" vm="1" name="Patient's Birth Name"/>
+        <entry group="0010" element="1010" keyword="PatientAge" vr="AS" vm="1" name="Patient's Age"/>
+        <entry group="0010" element="1020" keyword="PatientSize" vr="DS" vm="1" name="Patient's Size"/>
+        <entry group="0010" element="1021" keyword="PatientSizeCodeSequence" vr="SQ" vm="1" name="Patient's Size Code Sequence"/>
+        <entry group="0010" element="1022" keyword="PatientBodyMassIndex" vr="DS" vm="1" name="Patient's Body Mass Index"/>
+        <entry group="0010" element="1023" keyword="MeasuredAPDimension" vr="DS" vm="1" name="Measured AP Dimension"/>
+        <entry group="0010" element="1024" keyword="MeasuredLateralDimension" vr="DS" vm="1" name="Measured Lateral Dimension"/>
+        <entry group="0010" element="1030" keyword="PatientWeight" vr="DS" vm="1" name="Patient's Weight"/>
+        <entry group="0010" element="1040" keyword="PatientAddress" vr="LO" vm="1" name="Patient's Address"/>
+        <entry group="0010" element="1050" keyword="InsurancePlanIdentification" vr="LO" vm="1-n" retired="true" name="Insurance Plan Identification"/>
+        <entry group="0010" element="1060" keyword="PatientMotherBirthName" vr="PN" vm="1" name="Patient's Mother's Birth Name"/>
+        <entry group="0010" element="1080" keyword="MilitaryRank" vr="LO" vm="1" name="Military Rank"/>
+        <entry group="0010" element="1081" keyword="BranchOfService" vr="LO" vm="1" name="Branch of Service"/>
+        <entry group="0010" element="1090" keyword="MedicalRecordLocator" vr="LO" vm="1" name="Medical Record Locator"/>
+        <entry group="0010" element="1100" keyword="ReferencedPatientPhotoSequence" vr="SQ" vm="1" name="Referenced Patient Photo Sequence"/>
+        <entry group="0010" element="2000" keyword="MedicalAlerts" vr="LO" vm="1-n" name="Medical Alerts"/>
+        <entry group="0010" element="2110" keyword="Allergies" vr="LO" vm="1-n" name="Allergies"/>
+        <entry group="0010" element="2150" keyword="CountryOfResidence" vr="LO" vm="1" name="Country of Residence"/>
+        <entry group="0010" element="2152" keyword="RegionOfResidence" vr="LO" vm="1" name="Region of Residence"/>
+        <entry group="0010" element="2154" keyword="PatientTelephoneNumbers" vr="SH" vm="1-n" name="Patient's Telephone Numbers"/>
+        <entry group="0010" element="2155" keyword="PatientTelecomInformation" vr="LT" vm="1" name="Patient's Telecom Information"/>
+        <entry group="0010" element="2160" keyword="EthnicGroup" vr="SH" vm="1" name="Ethnic Group"/>
+        <entry group="0010" element="2180" keyword="Occupation" vr="SH" vm="1" name="Occupation"/>
+        <entry group="0010" element="21a0" keyword="SmokingStatus" vr="CS" vm="1" name="Smoking Status"/>
+        <entry group="0010" element="21b0" keyword="AdditionalPatientHistory" vr="LT" vm="1" name="Additional Patient History"/>
+        <entry group="0010" element="21c0" keyword="PregnancyStatus" vr="US" vm="1" name="Pregnancy Status"/>
+        <entry group="0010" element="21d0" keyword="LastMenstrualDate" vr="DA" vm="1" name="Last Menstrual Date"/>
+        <entry group="0010" element="21f0" keyword="PatientReligiousPreference" vr="LO" vm="1" name="Patient's Religious Preference"/>
+        <entry group="0010" element="2201" keyword="PatientSpeciesDescription" vr="LO" vm="1" name="Patient Species Description"/>
+        <entry group="0010" element="2202" keyword="PatientSpeciesCodeSequence" vr="SQ" vm="1" name="Patient Species Code Sequence"/>
+        <entry group="0010" element="2203" keyword="PatientSexNeutered" vr="CS" vm="1" name="Patient's Sex Neutered"/>
+        <entry group="0010" element="2210" keyword="AnatomicalOrientationType" vr="CS" vm="1" name="Anatomical Orientation Type"/>
+        <entry group="0010" element="2292" keyword="PatientBreedDescription" vr="LO" vm="1" name="Patient Breed Description"/>
+        <entry group="0010" element="2293" keyword="PatientBreedCodeSequence" vr="SQ" vm="1" name="Patient Breed Code Sequence"/>
+        <entry group="0010" element="2294" keyword="BreedRegistrationSequence" vr="SQ" vm="1" name="Breed Registration Sequence"/>
+        <entry group="0010" element="2295" keyword="BreedRegistrationNumber" vr="LO" vm="1" name="Breed Registration Number"/>
+        <entry group="0010" element="2296" keyword="BreedRegistryCodeSequence" vr="SQ" vm="1" name="Breed Registry Code Sequence"/>
+        <entry group="0010" element="2297" keyword="ResponsiblePerson" vr="PN" vm="1" name="Responsible Person"/>
+        <entry group="0010" element="2298" keyword="ResponsiblePersonRole" vr="CS" vm="1" name="Responsible Person Role"/>
+        <entry group="0010" element="2299" keyword="ResponsibleOrganization" vr="LO" vm="1" name="Responsible Organization"/>
+        <entry group="0010" element="4000" keyword="PatientComments" vr="LT" vm="1" name="Patient Comments"/>
+        <entry group="0010" element="9431" keyword="ExaminedBodyThickness" vr="FL" vm="1" name="Examined Body Thickness"/>
+        <entry group="0012" element="0010" keyword="ClinicalTrialSponsorName" vr="LO" vm="1" name="Clinical Trial Sponsor Name"/>
+        <entry group="0012" element="0020" keyword="ClinicalTrialProtocolID" vr="LO" vm="1" name="Clinical Trial Protocol ID"/>
+        <entry group="0012" element="0021" keyword="ClinicalTrialProtocolName" vr="LO" vm="1" name="Clinical Trial Protocol Name"/>
+        <entry group="0012" element="0030" keyword="ClinicalTrialSiteID" vr="LO" vm="1" name="Clinical Trial Site ID"/>
+        <entry group="0012" element="0031" keyword="ClinicalTrialSiteName" vr="LO" vm="1" name="Clinical Trial Site Name"/>
+        <entry group="0012" element="0040" keyword="ClinicalTrialSubjectID" vr="LO" vm="1" name="Clinical Trial Subject ID"/>
+        <entry group="0012" element="0042" keyword="ClinicalTrialSubjectReadingID" vr="LO" vm="1" name="Clinical Trial Subject Reading ID"/>
+        <entry group="0012" element="0050" keyword="ClinicalTrialTimePointID" vr="LO" vm="1" name="Clinical Trial Time Point ID"/>
+        <entry group="0012" element="0051" keyword="ClinicalTrialTimePointDescription" vr="ST" vm="1" name="Clinical Trial Time Point Description"/>
+        <entry group="0012" element="0060" keyword="ClinicalTrialCoordinatingCenterName" vr="LO" vm="1" name="Clinical Trial Coordinating Center Name"/>
+        <entry group="0012" element="0062" keyword="PatientIdentityRemoved" vr="CS" vm="1" name="Patient Identity Removed"/>
+        <entry group="0012" element="0063" keyword="DeidentificationMethod" vr="LO" vm="1-n" name="De-identification Method"/>
+        <entry group="0012" element="0064" keyword="DeidentificationMethodCodeSequence" vr="SQ" vm="1" name="De-identification Method Code Sequence"/>
+        <entry group="0012" element="0071" keyword="ClinicalTrialSeriesID" vr="LO" vm="1" name="Clinical Trial Series ID"/>
+        <entry group="0012" element="0072" keyword="ClinicalTrialSeriesDescription" vr="LO" vm="1" name="Clinical Trial Series Description"/>
+        <entry group="0012" element="0081" keyword="ClinicalTrialProtocolEthicsCommitteeName" vr="LO" vm="1" name="Clinical Trial Protocol Ethics Committee Name"/>
+        <entry group="0012" element="0082" keyword="ClinicalTrialProtocolEthicsCommitteeApprovalNumber" vr="LO" vm="1" name="Clinical Trial Protocol Ethics Committee Approval Number"/>
+        <entry group="0012" element="0083" keyword="ConsentForClinicalTrialUseSequence" vr="SQ" vm="1" name="Consent for Clinical Trial Use Sequence"/>
+        <entry group="0012" element="0084" keyword="DistributionType" vr="CS" vm="1" name="Distribution Type"/>
+        <entry group="0012" element="0085" keyword="ConsentForDistributionFlag" vr="CS" vm="1" name="Consent for Distribution Flag"/>
+        <entry group="0012" element="0086" keyword="EthicsCommitteeApprovalEffectivenessStartDate" vr="DA" vm="1" name="Ethics Committee Approval Effectiveness Start Date"/>
+        <entry group="0012" element="0087" keyword="EthicsCommitteeApprovalEffectivenessEndDate" vr="DA" vm="1" name="Ethics Committee Approval Effectiveness End Date"/>
+        <entry group="0014" element="0023" keyword="CADFileFormat" vr="ST" vm="1" retired="true" name="CAD File Format"/>
+        <entry group="0014" element="0024" keyword="ComponentReferenceSystem" vr="ST" vm="1" retired="true" name="Component Reference System"/>
+        <entry group="0014" element="0025" keyword="ComponentManufacturingProcedure" vr="ST" vm="1" name="Component Manufacturing Procedure"/>
+        <entry group="0014" element="0028" keyword="ComponentManufacturer" vr="ST" vm="1" name="Component Manufacturer"/>
+        <entry group="0014" element="0030" keyword="MaterialThickness" vr="DS" vm="1-n" name="Material Thickness"/>
+        <entry group="0014" element="0032" keyword="MaterialPipeDiameter" vr="DS" vm="1-n" name="Material Pipe Diameter"/>
+        <entry group="0014" element="0034" keyword="MaterialIsolationDiameter" vr="DS" vm="1-n" name="Material Isolation Diameter"/>
+        <entry group="0014" element="0042" keyword="MaterialGrade" vr="ST" vm="1" name="Material Grade"/>
+        <entry group="0014" element="0044" keyword="MaterialPropertiesDescription" vr="ST" vm="1" name="Material Properties Description"/>
+        <entry group="0014" element="0045" keyword="MaterialPropertiesFileFormatRetired" vr="ST" vm="1" retired="true" name="Material Properties File Format (Retired)"/>
+        <entry group="0014" element="0046" keyword="MaterialNotes" vr="LT" vm="1" name="Material Notes"/>
+        <entry group="0014" element="0050" keyword="ComponentShape" vr="CS" vm="1" name="Component Shape"/>
+        <entry group="0014" element="0052" keyword="CurvatureType" vr="CS" vm="1" name="Curvature Type"/>
+        <entry group="0014" element="0054" keyword="OuterDiameter" vr="DS" vm="1" name="Outer Diameter"/>
+        <entry group="0014" element="0056" keyword="InnerDiameter" vr="DS" vm="1" name="Inner Diameter"/>
+        <entry group="0014" element="0100" keyword="ComponentWelderIDs" vr="LO" vm="1-n" name="Component Welder IDs"/>
+        <entry group="0014" element="0101" keyword="SecondaryApprovalStatus" vr="CS" vm="1" name="Secondary Approval Status"/>
+        <entry group="0014" element="0102" keyword="SecondaryReviewDate" vr="DA" vm="1" name="Secondary Review Date"/>
+        <entry group="0014" element="0103" keyword="SecondaryReviewTime" vr="TM" vm="1" name="Secondary Review Time"/>
+        <entry group="0014" element="0104" keyword="SecondaryReviewerName" vr="PN" vm="1" name="Secondary Reviewer Name"/>
+        <entry group="0014" element="0105" keyword="RepairID" vr="ST" vm="1" name="Repair ID"/>
+        <entry group="0014" element="0106" keyword="MultipleComponentApprovalSequence" vr="SQ" vm="1" name="Multiple Component Approval Sequence"/>
+        <entry group="0014" element="0107" keyword="OtherApprovalStatus" vr="CS" vm="1-n" name="Other Approval Status"/>
+        <entry group="0014" element="0108" keyword="OtherSecondaryApprovalStatus" vr="CS" vm="1-n" name="Other Secondary Approval Status"/>
+        <entry group="0014" element="1010" keyword="ActualEnvironmentalConditions" vr="ST" vm="1" name="Actual Environmental Conditions"/>
+        <entry group="0014" element="1020" keyword="ExpiryDate" vr="DA" vm="1" name="Expiry Date"/>
+        <entry group="0014" element="1040" keyword="EnvironmentalConditions" vr="ST" vm="1" name="Environmental Conditions"/>
+        <entry group="0014" element="2002" keyword="EvaluatorSequence" vr="SQ" vm="1" name="Evaluator Sequence"/>
+        <entry group="0014" element="2004" keyword="EvaluatorNumber" vr="IS" vm="1" name="Evaluator Number"/>
+        <entry group="0014" element="2006" keyword="EvaluatorName" vr="PN" vm="1" name="Evaluator Name"/>
+        <entry group="0014" element="2008" keyword="EvaluationAttempt" vr="IS" vm="1" name="Evaluation Attempt"/>
+        <entry group="0014" element="2012" keyword="IndicationSequence" vr="SQ" vm="1" name="Indication Sequence"/>
+        <entry group="0014" element="2014" keyword="IndicationNumber" vr="IS" vm="1" name="Indication Number"/>
+        <entry group="0014" element="2016" keyword="IndicationLabel" vr="SH" vm="1" name="Indication Label"/>
+        <entry group="0014" element="2018" keyword="IndicationDescription" vr="ST" vm="1" name="Indication Description"/>
+        <entry group="0014" element="201a" keyword="IndicationType" vr="CS" vm="1-n" name="Indication Type"/>
+        <entry group="0014" element="201c" keyword="IndicationDisposition" vr="CS" vm="1" name="Indication Disposition"/>
+        <entry group="0014" element="201e" keyword="IndicationROISequence" vr="SQ" vm="1" name="Indication ROI Sequence"/>
+        <entry group="0014" element="2030" keyword="IndicationPhysicalPropertySequence" vr="SQ" vm="1" name="Indication Physical Property Sequence"/>
+        <entry group="0014" element="2032" keyword="PropertyLabel" vr="SH" vm="1" name="Property Label"/>
+        <entry group="0014" element="2202" keyword="CoordinateSystemNumberOfAxes" vr="IS" vm="1" name="Coordinate System Number of Axes"/>
+        <entry group="0014" element="2204" keyword="CoordinateSystemAxesSequence" vr="SQ" vm="1" name="Coordinate System Axes Sequence"/>
+        <entry group="0014" element="2206" keyword="CoordinateSystemAxisDescription" vr="ST" vm="1" name="Coordinate System Axis Description"/>
+        <entry group="0014" element="2208" keyword="CoordinateSystemDataSetMapping" vr="CS" vm="1" name="Coordinate System Data Set Mapping"/>
+        <entry group="0014" element="220a" keyword="CoordinateSystemAxisNumber" vr="IS" vm="1" name="Coordinate System Axis Number"/>
+        <entry group="0014" element="220c" keyword="CoordinateSystemAxisType" vr="CS" vm="1" name="Coordinate System Axis Type"/>
+        <entry group="0014" element="220e" keyword="CoordinateSystemAxisUnits" vr="CS" vm="1" name="Coordinate System Axis Units"/>
+        <entry group="0014" element="2210" keyword="CoordinateSystemAxisValues" vr="OB" vm="1" name="Coordinate System Axis Values"/>
+        <entry group="0014" element="2220" keyword="CoordinateSystemTransformSequence" vr="SQ" vm="1" name="Coordinate System Transform Sequence"/>
+        <entry group="0014" element="2222" keyword="TransformDescription" vr="ST" vm="1" name="Transform Description"/>
+        <entry group="0014" element="2224" keyword="TransformNumberOfAxes" vr="IS" vm="1" name="Transform Number of Axes"/>
+        <entry group="0014" element="2226" keyword="TransformOrderOfAxes" vr="IS" vm="1-n" name="Transform Order of Axes"/>
+        <entry group="0014" element="2228" keyword="TransformedAxisUnits" vr="CS" vm="1" name="Transformed Axis Units"/>
+        <entry group="0014" element="222a" keyword="CoordinateSystemTransformRotationAndScaleMatrix" vr="DS" vm="1-n" name="Coordinate System Transform Rotation and Scale Matrix"/>
+        <entry group="0014" element="222c" keyword="CoordinateSystemTransformTranslationMatrix" vr="DS" vm="1-n" name="Coordinate System Transform Translation Matrix"/>
+        <entry group="0014" element="3011" keyword="InternalDetectorFrameTime" vr="DS" vm="1" name="Internal Detector Frame Time"/>
+        <entry group="0014" element="3012" keyword="NumberOfFramesIntegrated" vr="DS" vm="1" name="Number of Frames Integrated"/>
+        <entry group="0014" element="3020" keyword="DetectorTemperatureSequence" vr="SQ" vm="1" name="Detector Temperature Sequence"/>
+        <entry group="0014" element="3022" keyword="SensorName" vr="ST" vm="1" name="Sensor Name"/>
+        <entry group="0014" element="3024" keyword="HorizontalOffsetOfSensor" vr="DS" vm="1" name="Horizontal Offset of Sensor"/>
+        <entry group="0014" element="3026" keyword="VerticalOffsetOfSensor" vr="DS" vm="1" name="Vertical Offset of Sensor"/>
+        <entry group="0014" element="3028" keyword="SensorTemperature" vr="DS" vm="1" name="Sensor Temperature"/>
+        <entry group="0014" element="3040" keyword="DarkCurrentSequence" vr="SQ" vm="1" name="Dark Current Sequence"/>
+        <entry group="0014" element="3050" keyword="DarkCurrentCounts" vr="OB_OW" vm="1" name="Dark Current Counts"/>
+        <entry group="0014" element="3060" keyword="GainCorrectionReferenceSequence" vr="SQ" vm="1" name="Gain Correction Reference Sequence"/>
+        <entry group="0014" element="3070" keyword="AirCounts" vr="OB_OW" vm="1" name="Air Counts"/>
+        <entry group="0014" element="3071" keyword="KVUsedInGainCalibration" vr="DS" vm="1" name="KV Used in Gain Calibration"/>
+        <entry group="0014" element="3072" keyword="MAUsedInGainCalibration" vr="DS" vm="1" name="MA Used in Gain Calibration"/>
+        <entry group="0014" element="3073" keyword="NumberOfFramesUsedForIntegration" vr="DS" vm="1" name="Number of Frames Used for Integration"/>
+        <entry group="0014" element="3074" keyword="FilterMaterialUsedInGainCalibration" vr="LO" vm="1" name="Filter Material Used in Gain Calibration"/>
+        <entry group="0014" element="3075" keyword="FilterThicknessUsedInGainCalibration" vr="DS" vm="1" name="Filter Thickness Used in Gain Calibration"/>
+        <entry group="0014" element="3076" keyword="DateOfGainCalibration" vr="DA" vm="1" name="Date of Gain Calibration"/>
+        <entry group="0014" element="3077" keyword="TimeOfGainCalibration" vr="TM" vm="1" name="Time of Gain Calibration"/>
+        <entry group="0014" element="3080" keyword="BadPixelImage" vr="OB" vm="1" name="Bad Pixel Image"/>
+        <entry group="0014" element="3099" keyword="CalibrationNotes" vr="LT" vm="1" name="Calibration Notes"/>
+        <entry group="0014" element="4002" keyword="PulserEquipmentSequence" vr="SQ" vm="1" name="Pulser Equipment Sequence"/>
+        <entry group="0014" element="4004" keyword="PulserType" vr="CS" vm="1" name="Pulser Type"/>
+        <entry group="0014" element="4006" keyword="PulserNotes" vr="LT" vm="1" name="Pulser Notes"/>
+        <entry group="0014" element="4008" keyword="ReceiverEquipmentSequence" vr="SQ" vm="1" name="Receiver Equipment Sequence"/>
+        <entry group="0014" element="400a" keyword="AmplifierType" vr="CS" vm="1" name="Amplifier Type"/>
+        <entry group="0014" element="400c" keyword="ReceiverNotes" vr="LT" vm="1" name="Receiver Notes"/>
+        <entry group="0014" element="400e" keyword="PreAmplifierEquipmentSequence" vr="SQ" vm="1" name="Pre-Amplifier Equipment Sequence"/>
+        <entry group="0014" element="400f" keyword="PreAmplifierNotes" vr="LT" vm="1" name="Pre-Amplifier Notes"/>
+        <entry group="0014" element="4010" keyword="TransmitTransducerSequence" vr="SQ" vm="1" name="Transmit Transducer Sequence"/>
+        <entry group="0014" element="4011" keyword="ReceiveTransducerSequence" vr="SQ" vm="1" name="Receive Transducer Sequence"/>
+        <entry group="0014" element="4012" keyword="NumberOfElements" vr="US" vm="1" name="Number of Elements"/>
+        <entry group="0014" element="4013" keyword="ElementShape" vr="CS" vm="1" name="Element Shape"/>
+        <entry group="0014" element="4014" keyword="ElementDimensionA" vr="DS" vm="1" name="Element Dimension A"/>
+        <entry group="0014" element="4015" keyword="ElementDimensionB" vr="DS" vm="1" name="Element Dimension B"/>
+        <entry group="0014" element="4016" keyword="ElementPitchA" vr="DS" vm="1" name="Element Pitch A"/>
+        <entry group="0014" element="4017" keyword="MeasuredBeamDimensionA" vr="DS" vm="1" name="Measured Beam Dimension A"/>
+        <entry group="0014" element="4018" keyword="MeasuredBeamDimensionB" vr="DS" vm="1" name="Measured Beam Dimension B"/>
+        <entry group="0014" element="4019" keyword="LocationOfMeasuredBeamDiameter" vr="DS" vm="1" name="Location of Measured Beam Diameter"/>
+        <entry group="0014" element="401a" keyword="NominalFrequency" vr="DS" vm="1" name="Nominal Frequency"/>
+        <entry group="0014" element="401b" keyword="MeasuredCenterFrequency" vr="DS" vm="1" name="Measured Center Frequency"/>
+        <entry group="0014" element="401c" keyword="MeasuredBandwidth" vr="DS" vm="1" name="Measured Bandwidth"/>
+        <entry group="0014" element="401d" keyword="ElementPitchB" vr="DS" vm="1" name="Element Pitch B"/>
+        <entry group="0014" element="4020" keyword="PulserSettingsSequence" vr="SQ" vm="1" name="Pulser Settings Sequence"/>
+        <entry group="0014" element="4022" keyword="PulseWidth" vr="DS" vm="1" name="Pulse Width"/>
+        <entry group="0014" element="4024" keyword="ExcitationFrequency" vr="DS" vm="1" name="Excitation Frequency"/>
+        <entry group="0014" element="4026" keyword="ModulationType" vr="CS" vm="1" name="Modulation Type"/>
+        <entry group="0014" element="4028" keyword="Damping" vr="DS" vm="1" name="Damping"/>
+        <entry group="0014" element="4030" keyword="ReceiverSettingsSequence" vr="SQ" vm="1" name="Receiver Settings Sequence"/>
+        <entry group="0014" element="4031" keyword="AcquiredSoundpathLength" vr="DS" vm="1" name="Acquired Soundpath Length"/>
+        <entry group="0014" element="4032" keyword="AcquisitionCompressionType" vr="CS" vm="1" name="Acquisition Compression Type"/>
+        <entry group="0014" element="4033" keyword="AcquisitionSampleSize" vr="IS" vm="1" name="Acquisition Sample Size"/>
+        <entry group="0014" element="4034" keyword="RectifierSmoothing" vr="DS" vm="1" name="Rectifier Smoothing"/>
+        <entry group="0014" element="4035" keyword="DACSequence" vr="SQ" vm="1" name="DAC Sequence"/>
+        <entry group="0014" element="4036" keyword="DACType" vr="CS" vm="1" name="DAC Type"/>
+        <entry group="0014" element="4038" keyword="DACGainPoints" vr="DS" vm="1-n" name="DAC Gain Points"/>
+        <entry group="0014" element="403a" keyword="DACTimePoints" vr="DS" vm="1-n" name="DAC Time Points"/>
+        <entry group="0014" element="403c" keyword="DACAmplitude" vr="DS" vm="1-n" name="DAC Amplitude"/>
+        <entry group="0014" element="4040" keyword="PreAmplifierSettingsSequence" vr="SQ" vm="1" name="Pre-Amplifier Settings Sequence"/>
+        <entry group="0014" element="4050" keyword="TransmitTransducerSettingsSequence" vr="SQ" vm="1" name="Transmit Transducer Settings Sequence"/>
+        <entry group="0014" element="4051" keyword="ReceiveTransducerSettingsSequence" vr="SQ" vm="1" name="Receive Transducer Settings Sequence"/>
+        <entry group="0014" element="4052" keyword="IncidentAngle" vr="DS" vm="1" name="Incident Angle"/>
+        <entry group="0014" element="4054" keyword="CouplingTechnique" vr="ST" vm="1" name="Coupling Technique"/>
+        <entry group="0014" element="4056" keyword="CouplingMedium" vr="ST" vm="1" name="Coupling Medium"/>
+        <entry group="0014" element="4057" keyword="CouplingVelocity" vr="DS" vm="1" name="Coupling Velocity"/>
+        <entry group="0014" element="4058" keyword="ProbeCenterLocationX" vr="DS" vm="1" name="Probe Center Location X"/>
+        <entry group="0014" element="4059" keyword="ProbeCenterLocationZ" vr="DS" vm="1" name="Probe Center Location Z"/>
+        <entry group="0014" element="405a" keyword="SoundPathLength" vr="DS" vm="1" name="Sound Path Length"/>
+        <entry group="0014" element="405c" keyword="DelayLawIdentifier" vr="ST" vm="1" name="Delay Law Identifier"/>
+        <entry group="0014" element="4060" keyword="GateSettingsSequence" vr="SQ" vm="1" name="Gate Settings Sequence"/>
+        <entry group="0014" element="4062" keyword="GateThreshold" vr="DS" vm="1" name="Gate Threshold"/>
+        <entry group="0014" element="4064" keyword="VelocityOfSound" vr="DS" vm="1" name="Velocity of Sound"/>
+        <entry group="0014" element="4070" keyword="CalibrationSettingsSequence" vr="SQ" vm="1" name="Calibration Settings Sequence"/>
+        <entry group="0014" element="4072" keyword="CalibrationProcedure" vr="ST" vm="1" name="Calibration Procedure"/>
+        <entry group="0014" element="4074" keyword="ProcedureVersion" vr="SH" vm="1" name="Procedure Version"/>
+        <entry group="0014" element="4076" keyword="ProcedureCreationDate" vr="DA" vm="1" name="Procedure Creation Date"/>
+        <entry group="0014" element="4078" keyword="ProcedureExpirationDate" vr="DA" vm="1" name="Procedure Expiration Date"/>
+        <entry group="0014" element="407a" keyword="ProcedureLastModifiedDate" vr="DA" vm="1" name="Procedure Last Modified Date"/>
+        <entry group="0014" element="407c" keyword="CalibrationTime" vr="TM" vm="1-n" name="Calibration Time"/>
+        <entry group="0014" element="407e" keyword="CalibrationDate" vr="DA" vm="1-n" name="Calibration Date"/>
+        <entry group="0014" element="4080" keyword="ProbeDriveEquipmentSequence" vr="SQ" vm="1" name="Probe Drive Equipment Sequence"/>
+        <entry group="0014" element="4081" keyword="DriveType" vr="CS" vm="1" name="Drive Type"/>
+        <entry group="0014" element="4082" keyword="ProbeDriveNotes" vr="LT" vm="1" name="Probe Drive Notes"/>
+        <entry group="0014" element="4083" keyword="DriveProbeSequence" vr="SQ" vm="1" name="Drive Probe Sequence"/>
+        <entry group="0014" element="4084" keyword="ProbeInductance" vr="DS" vm="1" name="Probe Inductance"/>
+        <entry group="0014" element="4085" keyword="ProbeResistance" vr="DS" vm="1" name="Probe Resistance"/>
+        <entry group="0014" element="4086" keyword="ReceiveProbeSequence" vr="SQ" vm="1" name="Receive Probe Sequence"/>
+        <entry group="0014" element="4087" keyword="ProbeDriveSettingsSequence" vr="SQ" vm="1" name="Probe Drive Settings Sequence"/>
+        <entry group="0014" element="4088" keyword="BridgeResistors" vr="DS" vm="1" name="Bridge Resistors"/>
+        <entry group="0014" element="4089" keyword="ProbeOrientationAngle" vr="DS" vm="1" name="Probe Orientation Angle"/>
+        <entry group="0014" element="408b" keyword="UserSelectedGainY" vr="DS" vm="1" name="User Selected Gain Y"/>
+        <entry group="0014" element="408c" keyword="UserSelectedPhase" vr="DS" vm="1" name="User Selected Phase"/>
+        <entry group="0014" element="408d" keyword="UserSelectedOffsetX" vr="DS" vm="1" name="User Selected Offset X"/>
+        <entry group="0014" element="408e" keyword="UserSelectedOffsetY" vr="DS" vm="1" name="User Selected Offset Y"/>
+        <entry group="0014" element="4091" keyword="ChannelSettingsSequence" vr="SQ" vm="1" name="Channel Settings Sequence"/>
+        <entry group="0014" element="4092" keyword="ChannelThreshold" vr="DS" vm="1" name="Channel Threshold"/>
+        <entry group="0014" element="409a" keyword="ScannerSettingsSequence" vr="SQ" vm="1" name="Scanner Settings Sequence"/>
+        <entry group="0014" element="409b" keyword="ScanProcedure" vr="ST" vm="1" name="Scan Procedure"/>
+        <entry group="0014" element="409c" keyword="TranslationRateX" vr="DS" vm="1" name="Translation Rate X"/>
+        <entry group="0014" element="409d" keyword="TranslationRateY" vr="DS" vm="1" name="Translation Rate Y"/>
+        <entry group="0014" element="409f" keyword="ChannelOverlap" vr="DS" vm="1" name="Channel Overlap"/>
+        <entry group="0014" element="40a0" keyword="ImageQualityIndicatorType" vr="LO" vm="1" name="Image Quality Indicator Type"/>
+        <entry group="0014" element="40a1" keyword="ImageQualityIndicatorMaterial" vr="LO" vm="1" name="Image Quality Indicator Material"/>
+        <entry group="0014" element="40a2" keyword="ImageQualityIndicatorSize" vr="LO" vm="1" name="Image Quality Indicator Size"/>
+        <entry group="0014" element="5002" keyword="LINACEnergy" vr="IS" vm="1" name="LINAC Energy"/>
+        <entry group="0014" element="5004" keyword="LINACOutput" vr="IS" vm="1" name="LINAC Output"/>
+        <entry group="0014" element="5100" keyword="ActiveAperture" vr="US" vm="1" name="Active Aperture"/>
+        <entry group="0014" element="5101" keyword="TotalAperture" vr="DS" vm="1" name="Total Aperture"/>
+        <entry group="0014" element="5102" keyword="ApertureElevation" vr="DS" vm="1" name="Aperture Elevation"/>
+        <entry group="0014" element="5103" keyword="MainLobeAngle" vr="DS" vm="1" name="Main Lobe Angle"/>
+        <entry group="0014" element="5104" keyword="MainRoofAngle" vr="DS" vm="1" name="Main Roof Angle"/>
+        <entry group="0014" element="5105" keyword="ConnectorType" vr="CS" vm="1" name="Connector Type"/>
+        <entry group="0014" element="5106" keyword="WedgeModelNumber" vr="SH" vm="1" name="Wedge Model Number"/>
+        <entry group="0014" element="5107" keyword="WedgeAngleFloat" vr="DS" vm="1" name="Wedge Angle Float"/>
+        <entry group="0014" element="5108" keyword="WedgeRoofAngle" vr="DS" vm="1" name="Wedge Roof Angle"/>
+        <entry group="0014" element="5109" keyword="WedgeElement1Position" vr="CS" vm="1" name="Wedge Element 1 Position"/>
+        <entry group="0014" element="510a" keyword="WedgeMaterialVelocity" vr="DS" vm="1" name="Wedge Material Velocity"/>
+        <entry group="0014" element="510b" keyword="WedgeMaterial" vr="SH" vm="1" name="Wedge Material"/>
+        <entry group="0014" element="510c" keyword="WedgeOffsetZ" vr="DS" vm="1" name="Wedge Offset Z"/>
+        <entry group="0014" element="510d" keyword="WedgeOriginOffsetX" vr="DS" vm="1" name="Wedge Origin Offset X"/>
+        <entry group="0014" element="510e" keyword="WedgeTimeDelay" vr="DS" vm="1" name="Wedge Time Delay"/>
+        <entry group="0014" element="510f" keyword="WedgeName" vr="SH" vm="1" name="Wedge Name"/>
+        <entry group="0014" element="5110" keyword="WedgeManufacturerName" vr="SH" vm="1" name="Wedge Manufacturer Name"/>
+        <entry group="0014" element="5111" keyword="WedgeDescription" vr="LO" vm="1" name="Wedge Description"/>
+        <entry group="0014" element="5112" keyword="NominalBeamAngle" vr="DS" vm="1" name="Nominal Beam Angle"/>
+        <entry group="0014" element="5113" keyword="WedgeOffsetX" vr="DS" vm="1" name="Wedge Offset X"/>
+        <entry group="0014" element="5114" keyword="WedgeOffsetY" vr="DS" vm="1" name="Wedge Offset Y"/>
+        <entry group="0014" element="5115" keyword="WedgeTotalLength" vr="DS" vm="1" name="Wedge Total Length"/>
+        <entry group="0014" element="5116" keyword="WedgeInContactLength" vr="DS" vm="1" name="Wedge In Contact Length"/>
+        <entry group="0014" element="5117" keyword="WedgeFrontGap" vr="DS" vm="1" name="Wedge Front Gap"/>
+        <entry group="0014" element="5118" keyword="WedgeTotalHeight" vr="DS" vm="1" name="Wedge Total Height"/>
+        <entry group="0014" element="5119" keyword="WedgeFrontHeight" vr="DS" vm="1" name="Wedge Front Height"/>
+        <entry group="0014" element="511a" keyword="WedgeRearHeight" vr="DS" vm="1" name="Wedge Rear Height"/>
+        <entry group="0014" element="511b" keyword="WedgeTotalWidth" vr="DS" vm="1" name="Wedge Total Width"/>
+        <entry group="0014" element="511c" keyword="WedgeInContactWidth" vr="DS" vm="1" name="Wedge In Contact Width"/>
+        <entry group="0014" element="511d" keyword="WedgeChamferHeight" vr="DS" vm="1" name="Wedge Chamfer Height"/>
+        <entry group="0014" element="511e" keyword="WedgeCurve" vr="CS" vm="1" name="Wedge Curve"/>
+        <entry group="0014" element="511f" keyword="RadiusAlongWedge" vr="DS" vm="1" name="Radius Along the Wedge"/>
+        <entry group="0018" element="0010" keyword="ContrastBolusAgent" vr="LO" vm="1" name="Contrast/Bolus Agent"/>
+        <entry group="0018" element="0012" keyword="ContrastBolusAgentSequence" vr="SQ" vm="1" name="Contrast/Bolus Agent Sequence"/>
+        <entry group="0018" element="0013" keyword="ContrastBolusT1Relaxivity" vr="FL" vm="1" name="Contrast/Bolus T1 Relaxivity"/>
+        <entry group="0018" element="0014" keyword="ContrastBolusAdministrationRouteSequence" vr="SQ" vm="1" name="Contrast/Bolus Administration Route Sequence"/>
+        <entry group="0018" element="0015" keyword="BodyPartExamined" vr="CS" vm="1" name="Body Part Examined"/>
+        <entry group="0018" element="0020" keyword="ScanningSequence" vr="CS" vm="1-n" name="Scanning Sequence"/>
+        <entry group="0018" element="0021" keyword="SequenceVariant" vr="CS" vm="1-n" name="Sequence Variant"/>
+        <entry group="0018" element="0022" keyword="ScanOptions" vr="CS" vm="1-n" name="Scan Options"/>
+        <entry group="0018" element="0023" keyword="MRAcquisitionType" vr="CS" vm="1" name="MR Acquisition Type"/>
+        <entry group="0018" element="0024" keyword="SequenceName" vr="SH" vm="1" name="Sequence Name"/>
+        <entry group="0018" element="0025" keyword="AngioFlag" vr="CS" vm="1" name="Angio Flag"/>
+        <entry group="0018" element="0026" keyword="InterventionDrugInformationSequence" vr="SQ" vm="1" name="Intervention Drug Information Sequence"/>
+        <entry group="0018" element="0027" keyword="InterventionDrugStopTime" vr="TM" vm="1" name="Intervention Drug Stop Time"/>
+        <entry group="0018" element="0028" keyword="InterventionDrugDose" vr="DS" vm="1" name="Intervention Drug Dose"/>
+        <entry group="0018" element="0029" keyword="InterventionDrugCodeSequence" vr="SQ" vm="1" name="Intervention Drug Code Sequence"/>
+        <entry group="0018" element="002a" keyword="AdditionalDrugSequence" vr="SQ" vm="1" name="Additional Drug Sequence"/>
+        <entry group="0018" element="0030" keyword="Radionuclide" vr="LO" vm="1-n" retired="true" name="Radionuclide"/>
+        <entry group="0018" element="0031" keyword="Radiopharmaceutical" vr="LO" vm="1" name="Radiopharmaceutical"/>
+        <entry group="0018" element="0032" keyword="EnergyWindowCenterline" vr="DS" vm="1" retired="true" name="Energy Window Centerline"/>
+        <entry group="0018" element="0033" keyword="EnergyWindowTotalWidth" vr="DS" vm="1-n" retired="true" name="Energy Window Total Width"/>
+        <entry group="0018" element="0034" keyword="InterventionDrugName" vr="LO" vm="1" name="Intervention Drug Name"/>
+        <entry group="0018" element="0035" keyword="InterventionDrugStartTime" vr="TM" vm="1" name="Intervention Drug Start Time"/>
+        <entry group="0018" element="0036" keyword="InterventionSequence" vr="SQ" vm="1" name="Intervention Sequence"/>
+        <entry group="0018" element="0037" keyword="TherapyType" vr="CS" vm="1" retired="true" name="Therapy Type"/>
+        <entry group="0018" element="0038" keyword="InterventionStatus" vr="CS" vm="1" name="Intervention Status"/>
+        <entry group="0018" element="0039" keyword="TherapyDescription" vr="CS" vm="1" retired="true" name="Therapy Description"/>
+        <entry group="0018" element="003a" keyword="InterventionDescription" vr="ST" vm="1" name="Intervention Description"/>
+        <entry group="0018" element="0040" keyword="CineRate" vr="IS" vm="1" name="Cine Rate"/>
+        <entry group="0018" element="0042" keyword="InitialCineRunState" vr="CS" vm="1" name="Initial Cine Run State"/>
+        <entry group="0018" element="0050" keyword="SliceThickness" vr="DS" vm="1" name="Slice Thickness"/>
+        <entry group="0018" element="0060" keyword="KVP" vr="DS" vm="1" name="KVP"/>
+        <entry group="0018" element="0061" vr="DS" vm="1" retired="true"/>
+        <entry group="0018" element="0070" keyword="CountsAccumulated" vr="IS" vm="1" name="Counts Accumulated"/>
+        <entry group="0018" element="0071" keyword="AcquisitionTerminationCondition" vr="CS" vm="1" name="Acquisition Termination Condition"/>
+        <entry group="0018" element="0072" keyword="EffectiveDuration" vr="DS" vm="1" name="Effective Duration"/>
+        <entry group="0018" element="0073" keyword="AcquisitionStartCondition" vr="CS" vm="1" name="Acquisition Start Condition"/>
+        <entry group="0018" element="0074" keyword="AcquisitionStartConditionData" vr="IS" vm="1" name="Acquisition Start Condition Data"/>
+        <entry group="0018" element="0075" keyword="AcquisitionTerminationConditionData" vr="IS" vm="1" name="Acquisition Termination Condition Data"/>
+        <entry group="0018" element="0080" keyword="RepetitionTime" vr="DS" vm="1" name="Repetition Time"/>
+        <entry group="0018" element="0081" keyword="EchoTime" vr="DS" vm="1" name="Echo Time"/>
+        <entry group="0018" element="0082" keyword="InversionTime" vr="DS" vm="1" name="Inversion Time"/>
+        <entry group="0018" element="0083" keyword="NumberOfAverages" vr="DS" vm="1" name="Number of Averages"/>
+        <entry group="0018" element="0084" keyword="ImagingFrequency" vr="DS" vm="1" name="Imaging Frequency"/>
+        <entry group="0018" element="0085" keyword="ImagedNucleus" vr="SH" vm="1" name="Imaged Nucleus"/>
+        <entry group="0018" element="0086" keyword="EchoNumbers" vr="IS" vm="1-n" name="Echo Number(s)"/>
+        <entry group="0018" element="0087" keyword="MagneticFieldStrength" vr="DS" vm="1" name="Magnetic Field Strength"/>
+        <entry group="0018" element="0088" keyword="SpacingBetweenSlices" vr="DS" vm="1" name="Spacing Between Slices"/>
+        <entry group="0018" element="0089" keyword="NumberOfPhaseEncodingSteps" vr="IS" vm="1" name="Number of Phase Encoding Steps"/>
+        <entry group="0018" element="0090" keyword="DataCollectionDiameter" vr="DS" vm="1" name="Data Collection Diameter"/>
+        <entry group="0018" element="0091" keyword="EchoTrainLength" vr="IS" vm="1" name="Echo Train Length"/>
+        <entry group="0018" element="0093" keyword="PercentSampling" vr="DS" vm="1" name="Percent Sampling"/>
+        <entry group="0018" element="0094" keyword="PercentPhaseFieldOfView" vr="DS" vm="1" name="Percent Phase Field of View"/>
+        <entry group="0018" element="0095" keyword="PixelBandwidth" vr="DS" vm="1" name="Pixel Bandwidth"/>
+        <entry group="0018" element="1000" keyword="DeviceSerialNumber" vr="LO" vm="1" name="Device Serial Number"/>
+        <entry group="0018" element="1002" keyword="DeviceUID" vr="UI" vm="1" name="Device UID"/>
+        <entry group="0018" element="1003" keyword="DeviceID" vr="LO" vm="1" name="Device ID"/>
+        <entry group="0018" element="1004" keyword="PlateID" vr="LO" vm="1" name="Plate ID"/>
+        <entry group="0018" element="1005" keyword="GeneratorID" vr="LO" vm="1" name="Generator ID"/>
+        <entry group="0018" element="1006" keyword="GridID" vr="LO" vm="1" name="Grid ID"/>
+        <entry group="0018" element="1007" keyword="CassetteID" vr="LO" vm="1" name="Cassette ID"/>
+        <entry group="0018" element="1008" keyword="GantryID" vr="LO" vm="1" name="Gantry ID"/>
+        <entry group="0018" element="1009" keyword="UniqueDeviceIdentifier" vr="UT" vm="1" name="Unique Device Identifier"/>
+        <entry group="0018" element="100a" keyword="UDISequence" vr="SQ" vm="1" name="UDI Sequence"/>
+        <entry group="0018" element="1010" keyword="SecondaryCaptureDeviceID" vr="LO" vm="1" name="Secondary Capture Device ID"/>
+        <entry group="0018" element="1011" keyword="HardcopyCreationDeviceID" vr="LO" vm="1" retired="true" name="Hardcopy Creation Device ID"/>
+        <entry group="0018" element="1012" keyword="DateOfSecondaryCapture" vr="DA" vm="1" name="Date of Secondary Capture"/>
+        <entry group="0018" element="1014" keyword="TimeOfSecondaryCapture" vr="TM" vm="1" name="Time of Secondary Capture"/>
+        <entry group="0018" element="1016" keyword="SecondaryCaptureDeviceManufacturer" vr="LO" vm="1" name="Secondary Capture Device Manufacturer"/>
+        <entry group="0018" element="1017" keyword="HardcopyDeviceManufacturer" vr="LO" vm="1" retired="true" name="Hardcopy Device Manufacturer"/>
+        <entry group="0018" element="1018" keyword="SecondaryCaptureDeviceManufacturerModelName" vr="LO" vm="1" name="Secondary Capture Device Manufacturer's Model Name"/>
+        <entry group="0018" element="1019" keyword="SecondaryCaptureDeviceSoftwareVersions" vr="LO" vm="1-n" name="Secondary Capture Device Software Versions"/>
+        <entry group="0018" element="101a" keyword="HardcopyDeviceSoftwareVersion" vr="LO" vm="1-n" retired="true" name="Hardcopy Device Software Version"/>
+        <entry group="0018" element="101b" keyword="HardcopyDeviceManufacturerModelName" vr="LO" vm="1" retired="true" name="Hardcopy Device Manufacturer's Model Name"/>
+        <entry group="0018" element="1020" keyword="SoftwareVersions" vr="LO" vm="1-n" name="Software Version(s)"/>
+        <entry group="0018" element="1022" keyword="VideoImageFormatAcquired" vr="SH" vm="1" name="Video Image Format Acquired"/>
+        <entry group="0018" element="1023" keyword="DigitalImageFormatAcquired" vr="LO" vm="1" name="Digital Image Format Acquired"/>
+        <entry group="0018" element="1030" keyword="ProtocolName" vr="LO" vm="1" name="Protocol Name"/>
+        <entry group="0018" element="1040" keyword="ContrastBolusRoute" vr="LO" vm="1" name="Contrast/Bolus Route"/>
+        <entry group="0018" element="1041" keyword="ContrastBolusVolume" vr="DS" vm="1" name="Contrast/Bolus Volume"/>
+        <entry group="0018" element="1042" keyword="ContrastBolusStartTime" vr="TM" vm="1" name="Contrast/Bolus Start Time"/>
+        <entry group="0018" element="1043" keyword="ContrastBolusStopTime" vr="TM" vm="1" name="Contrast/Bolus Stop Time"/>
+        <entry group="0018" element="1044" keyword="ContrastBolusTotalDose" vr="DS" vm="1" name="Contrast/Bolus Total Dose"/>
+        <entry group="0018" element="1045" keyword="SyringeCounts" vr="IS" vm="1" name="Syringe Counts"/>
+        <entry group="0018" element="1046" keyword="ContrastFlowRate" vr="DS" vm="1-n" name="Contrast Flow Rate"/>
+        <entry group="0018" element="1047" keyword="ContrastFlowDuration" vr="DS" vm="1-n" name="Contrast Flow Duration"/>
+        <entry group="0018" element="1048" keyword="ContrastBolusIngredient" vr="CS" vm="1" name="Contrast/Bolus Ingredient"/>
+        <entry group="0018" element="1049" keyword="ContrastBolusIngredientConcentration" vr="DS" vm="1" name="Contrast/Bolus Ingredient Concentration"/>
+        <entry group="0018" element="1050" keyword="SpatialResolution" vr="DS" vm="1" name="Spatial Resolution"/>
+        <entry group="0018" element="1060" keyword="TriggerTime" vr="DS" vm="1" name="Trigger Time"/>
+        <entry group="0018" element="1061" keyword="TriggerSourceOrType" vr="LO" vm="1" name="Trigger Source or Type"/>
+        <entry group="0018" element="1062" keyword="NominalInterval" vr="IS" vm="1" name="Nominal Interval"/>
+        <entry group="0018" element="1063" keyword="FrameTime" vr="DS" vm="1" name="Frame Time"/>
+        <entry group="0018" element="1064" keyword="CardiacFramingType" vr="LO" vm="1" name="Cardiac Framing Type"/>
+        <entry group="0018" element="1065" keyword="FrameTimeVector" vr="DS" vm="1-n" name="Frame Time Vector"/>
+        <entry group="0018" element="1066" keyword="FrameDelay" vr="DS" vm="1" name="Frame Delay"/>
+        <entry group="0018" element="1067" keyword="ImageTriggerDelay" vr="DS" vm="1" name="Image Trigger Delay"/>
+        <entry group="0018" element="1068" keyword="MultiplexGroupTimeOffset" vr="DS" vm="1" name="Multiplex Group Time Offset"/>
+        <entry group="0018" element="1069" keyword="TriggerTimeOffset" vr="DS" vm="1" name="Trigger Time Offset"/>
+        <entry group="0018" element="106a" keyword="SynchronizationTrigger" vr="CS" vm="1" name="Synchronization Trigger"/>
+        <entry group="0018" element="106c" keyword="SynchronizationChannel" vr="US" vm="2" name="Synchronization Channel"/>
+        <entry group="0018" element="106e" keyword="TriggerSamplePosition" vr="UL" vm="1" name="Trigger Sample Position"/>
+        <entry group="0018" element="1070" keyword="RadiopharmaceuticalRoute" vr="LO" vm="1" name="Radiopharmaceutical Route"/>
+        <entry group="0018" element="1071" keyword="RadiopharmaceuticalVolume" vr="DS" vm="1" name="Radiopharmaceutical Volume"/>
+        <entry group="0018" element="1072" keyword="RadiopharmaceuticalStartTime" vr="TM" vm="1" name="Radiopharmaceutical Start Time"/>
+        <entry group="0018" element="1073" keyword="RadiopharmaceuticalStopTime" vr="TM" vm="1" name="Radiopharmaceutical Stop Time"/>
+        <entry group="0018" element="1074" keyword="RadionuclideTotalDose" vr="DS" vm="1" name="Radionuclide Total Dose"/>
+        <entry group="0018" element="1075" keyword="RadionuclideHalfLife" vr="DS" vm="1" name="Radionuclide Half Life"/>
+        <entry group="0018" element="1076" keyword="RadionuclidePositronFraction" vr="DS" vm="1" name="Radionuclide Positron Fraction"/>
+        <entry group="0018" element="1077" keyword="RadiopharmaceuticalSpecificActivity" vr="DS" vm="1" name="Radiopharmaceutical Specific Activity"/>
+        <entry group="0018" element="1078" keyword="RadiopharmaceuticalStartDateTime" vr="DT" vm="1" name="Radiopharmaceutical Start DateTime"/>
+        <entry group="0018" element="1079" keyword="RadiopharmaceuticalStopDateTime" vr="DT" vm="1" name="Radiopharmaceutical Stop DateTime"/>
+        <entry group="0018" element="1080" keyword="BeatRejectionFlag" vr="CS" vm="1" name="Beat Rejection Flag"/>
+        <entry group="0018" element="1081" keyword="LowRRValue" vr="IS" vm="1" name="Low R-R Value"/>
+        <entry group="0018" element="1082" keyword="HighRRValue" vr="IS" vm="1" name="High R-R Value"/>
+        <entry group="0018" element="1083" keyword="IntervalsAcquired" vr="IS" vm="1" name="Intervals Acquired"/>
+        <entry group="0018" element="1084" keyword="IntervalsRejected" vr="IS" vm="1" name="Intervals Rejected"/>
+        <entry group="0018" element="1085" keyword="PVCRejection" vr="LO" vm="1" name="PVC Rejection"/>
+        <entry group="0018" element="1086" keyword="SkipBeats" vr="IS" vm="1" name="Skip Beats"/>
+        <entry group="0018" element="1088" keyword="HeartRate" vr="IS" vm="1" name="Heart Rate"/>
+        <entry group="0018" element="1090" keyword="CardiacNumberOfImages" vr="IS" vm="1" name="Cardiac Number of Images"/>
+        <entry group="0018" element="1094" keyword="TriggerWindow" vr="IS" vm="1" name="Trigger Window"/>
+        <entry group="0018" element="1100" keyword="ReconstructionDiameter" vr="DS" vm="1" name="Reconstruction Diameter"/>
+        <entry group="0018" element="1110" keyword="DistanceSourceToDetector" vr="DS" vm="1" name="Distance Source to Detector"/>
+        <entry group="0018" element="1111" keyword="DistanceSourceToPatient" vr="DS" vm="1" name="Distance Source to Patient"/>
+        <entry group="0018" element="1114" keyword="EstimatedRadiographicMagnificationFactor" vr="DS" vm="1" name="Estimated Radiographic Magnification Factor"/>
+        <entry group="0018" element="1120" keyword="GantryDetectorTilt" vr="DS" vm="1" name="Gantry/Detector Tilt"/>
+        <entry group="0018" element="1121" keyword="GantryDetectorSlew" vr="DS" vm="1" name="Gantry/Detector Slew"/>
+        <entry group="0018" element="1130" keyword="TableHeight" vr="DS" vm="1" name="Table Height"/>
+        <entry group="0018" element="1131" keyword="TableTraverse" vr="DS" vm="1" name="Table Traverse"/>
+        <entry group="0018" element="1134" keyword="TableMotion" vr="CS" vm="1" name="Table Motion"/>
+        <entry group="0018" element="1135" keyword="TableVerticalIncrement" vr="DS" vm="1-n" name="Table Vertical Increment"/>
+        <entry group="0018" element="1136" keyword="TableLateralIncrement" vr="DS" vm="1-n" name="Table Lateral Increment"/>
+        <entry group="0018" element="1137" keyword="TableLongitudinalIncrement" vr="DS" vm="1-n" name="Table Longitudinal Increment"/>
+        <entry group="0018" element="1138" keyword="TableAngle" vr="DS" vm="1" name="Table Angle"/>
+        <entry group="0018" element="113a" keyword="TableType" vr="CS" vm="1" name="Table Type"/>
+        <entry group="0018" element="1140" keyword="RotationDirection" vr="CS" vm="1" name="Rotation Direction"/>
+        <entry group="0018" element="1141" keyword="AngularPosition" vr="DS" vm="1" retired="true" name="Angular Position"/>
+        <entry group="0018" element="1142" keyword="RadialPosition" vr="DS" vm="1-n" name="Radial Position"/>
+        <entry group="0018" element="1143" keyword="ScanArc" vr="DS" vm="1" name="Scan Arc"/>
+        <entry group="0018" element="1144" keyword="AngularStep" vr="DS" vm="1" name="Angular Step"/>
+        <entry group="0018" element="1145" keyword="CenterOfRotationOffset" vr="DS" vm="1" name="Center of Rotation Offset"/>
+        <entry group="0018" element="1146" keyword="RotationOffset" vr="DS" vm="1-n" retired="true" name="Rotation Offset"/>
+        <entry group="0018" element="1147" keyword="FieldOfViewShape" vr="CS" vm="1" name="Field of View Shape"/>
+        <entry group="0018" element="1149" keyword="FieldOfViewDimensions" vr="IS" vm="1-2" name="Field of View Dimension(s)"/>
+        <entry group="0018" element="1150" keyword="ExposureTime" vr="IS" vm="1" name="Exposure Time"/>
+        <entry group="0018" element="1151" keyword="XRayTubeCurrent" vr="IS" vm="1" name="X-Ray Tube Current"/>
+        <entry group="0018" element="1152" keyword="Exposure" vr="IS" vm="1" name="Exposure"/>
+        <entry group="0018" element="1153" keyword="ExposureInuAs" vr="IS" vm="1" name="Exposure in µAs"/>
+        <entry group="0018" element="1154" keyword="AveragePulseWidth" vr="DS" vm="1" name="Average Pulse Width"/>
+        <entry group="0018" element="1155" keyword="RadiationSetting" vr="CS" vm="1" name="Radiation Setting"/>
+        <entry group="0018" element="1156" keyword="RectificationType" vr="CS" vm="1" name="Rectification Type"/>
+        <entry group="0018" element="115a" keyword="RadiationMode" vr="CS" vm="1" name="Radiation Mode"/>
+        <entry group="0018" element="115e" keyword="ImageAndFluoroscopyAreaDoseProduct" vr="DS" vm="1" name="Image and Fluoroscopy Area Dose Product"/>
+        <entry group="0018" element="1160" keyword="FilterType" vr="SH" vm="1" name="Filter Type"/>
+        <entry group="0018" element="1161" keyword="TypeOfFilters" vr="LO" vm="1-n" name="Type of Filters"/>
+        <entry group="0018" element="1162" keyword="IntensifierSize" vr="DS" vm="1" name="Intensifier Size"/>
+        <entry group="0018" element="1164" keyword="ImagerPixelSpacing" vr="DS" vm="2" name="Imager Pixel Spacing"/>
+        <entry group="0018" element="1166" keyword="Grid" vr="CS" vm="1-n" name="Grid"/>
+        <entry group="0018" element="1170" keyword="GeneratorPower" vr="IS" vm="1" name="Generator Power"/>
+        <entry group="0018" element="1180" keyword="CollimatorGridName" vr="SH" vm="1" name="Collimator/grid Name"/>
+        <entry group="0018" element="1181" keyword="CollimatorType" vr="CS" vm="1" name="Collimator Type"/>
+        <entry group="0018" element="1182" keyword="FocalDistance" vr="IS" vm="1-2" name="Focal Distance"/>
+        <entry group="0018" element="1183" keyword="XFocusCenter" vr="DS" vm="1-2" name="X Focus Center"/>
+        <entry group="0018" element="1184" keyword="YFocusCenter" vr="DS" vm="1-2" name="Y Focus Center"/>
+        <entry group="0018" element="1190" keyword="FocalSpots" vr="DS" vm="1-n" name="Focal Spot(s)"/>
+        <entry group="0018" element="1191" keyword="AnodeTargetMaterial" vr="CS" vm="1" name="Anode Target Material"/>
+        <entry group="0018" element="11a0" keyword="BodyPartThickness" vr="DS" vm="1" name="Body Part Thickness"/>
+        <entry group="0018" element="11a2" keyword="CompressionForce" vr="DS" vm="1" name="Compression Force"/>
+        <entry group="0018" element="11a4" keyword="PaddleDescription" vr="LO" vm="1" name="Paddle Description"/>
+        <entry group="0018" element="1200" keyword="DateOfLastCalibration" vr="DA" vm="1-n" name="Date of Last Calibration"/>
+        <entry group="0018" element="1201" keyword="TimeOfLastCalibration" vr="TM" vm="1-n" name="Time of Last Calibration"/>
+        <entry group="0018" element="1202" keyword="DateTimeOfLastCalibration" vr="DT" vm="1" name="DateTime of Last Calibration"/>
+        <entry group="0018" element="1210" keyword="ConvolutionKernel" vr="SH" vm="1-n" name="Convolution Kernel"/>
+        <entry group="0018" element="1240" keyword="UpperLowerPixelValues" vr="IS" vm="1-n" retired="true" name="Upper/Lower Pixel Values"/>
+        <entry group="0018" element="1242" keyword="ActualFrameDuration" vr="IS" vm="1" name="Actual Frame Duration"/>
+        <entry group="0018" element="1243" keyword="CountRate" vr="IS" vm="1" name="Count Rate"/>
+        <entry group="0018" element="1244" keyword="PreferredPlaybackSequencing" vr="US" vm="1" name="Preferred Playback Sequencing"/>
+        <entry group="0018" element="1250" keyword="ReceiveCoilName" vr="SH" vm="1" name="Receive Coil Name"/>
+        <entry group="0018" element="1251" keyword="TransmitCoilName" vr="SH" vm="1" name="Transmit Coil Name"/>
+        <entry group="0018" element="1260" keyword="PlateType" vr="SH" vm="1" name="Plate Type"/>
+        <entry group="0018" element="1261" keyword="PhosphorType" vr="LO" vm="1" name="Phosphor Type"/>
+        <entry group="0018" element="1271" keyword="WaterEquivalentDiameter" vr="FD" vm="1" name="Water Equivalent Diameter"/>
+        <entry group="0018" element="1272" keyword="WaterEquivalentDiameterCalculationMethodCodeSequence" vr="SQ" vm="1" name="Water Equivalent Diameter Calculation Method Code Sequence"/>
+        <entry group="0018" element="1300" keyword="ScanVelocity" vr="DS" vm="1" name="Scan Velocity"/>
+        <entry group="0018" element="1301" keyword="WholeBodyTechnique" vr="CS" vm="1-n" name="Whole Body Technique"/>
+        <entry group="0018" element="1302" keyword="ScanLength" vr="IS" vm="1" name="Scan Length"/>
+        <entry group="0018" element="1310" keyword="AcquisitionMatrix" vr="US" vm="4" name="Acquisition Matrix"/>
+        <entry group="0018" element="1312" keyword="InPlanePhaseEncodingDirection" vr="CS" vm="1" name="In-plane Phase Encoding Direction"/>
+        <entry group="0018" element="1314" keyword="FlipAngle" vr="DS" vm="1" name="Flip Angle"/>
+        <entry group="0018" element="1315" keyword="VariableFlipAngleFlag" vr="CS" vm="1" name="Variable Flip Angle Flag"/>
+        <entry group="0018" element="1316" keyword="SAR" vr="DS" vm="1" name="SAR"/>
+        <entry group="0018" element="1318" keyword="dBdt" vr="DS" vm="1" name="dB/dt"/>
+        <entry group="0018" element="1320" keyword="B1rms" vr="FL" vm="1" name="B1rms"/>
+        <entry group="0018" element="1400" keyword="AcquisitionDeviceProcessingDescription" vr="LO" vm="1" name="Acquisition Device Processing Description"/>
+        <entry group="0018" element="1401" keyword="AcquisitionDeviceProcessingCode" vr="LO" vm="1" name="Acquisition Device Processing Code"/>
+        <entry group="0018" element="1402" keyword="CassetteOrientation" vr="CS" vm="1" name="Cassette Orientation"/>
+        <entry group="0018" element="1403" keyword="CassetteSize" vr="CS" vm="1" name="Cassette Size"/>
+        <entry group="0018" element="1404" keyword="ExposuresOnPlate" vr="US" vm="1" name="Exposures on Plate"/>
+        <entry group="0018" element="1405" keyword="RelativeXRayExposure" vr="IS" vm="1" name="Relative X-Ray Exposure"/>
+        <entry group="0018" element="1411" keyword="ExposureIndex" vr="DS" vm="1" name="Exposure Index"/>
+        <entry group="0018" element="1412" keyword="TargetExposureIndex" vr="DS" vm="1" name="Target Exposure Index"/>
+        <entry group="0018" element="1413" keyword="DeviationIndex" vr="DS" vm="1" name="Deviation Index"/>
+        <entry group="0018" element="1450" keyword="ColumnAngulation" vr="DS" vm="1" name="Column Angulation"/>
+        <entry group="0018" element="1460" keyword="TomoLayerHeight" vr="DS" vm="1" name="Tomo Layer Height"/>
+        <entry group="0018" element="1470" keyword="TomoAngle" vr="DS" vm="1" name="Tomo Angle"/>
+        <entry group="0018" element="1480" keyword="TomoTime" vr="DS" vm="1" name="Tomo Time"/>
+        <entry group="0018" element="1490" keyword="TomoType" vr="CS" vm="1" name="Tomo Type"/>
+        <entry group="0018" element="1491" keyword="TomoClass" vr="CS" vm="1" name="Tomo Class"/>
+        <entry group="0018" element="1495" keyword="NumberOfTomosynthesisSourceImages" vr="IS" vm="1" name="Number of Tomosynthesis Source Images"/>
+        <entry group="0018" element="1500" keyword="PositionerMotion" vr="CS" vm="1" name="Positioner Motion"/>
+        <entry group="0018" element="1508" keyword="PositionerType" vr="CS" vm="1" name="Positioner Type"/>
+        <entry group="0018" element="1510" keyword="PositionerPrimaryAngle" vr="DS" vm="1" name="Positioner Primary Angle"/>
+        <entry group="0018" element="1511" keyword="PositionerSecondaryAngle" vr="DS" vm="1" name="Positioner Secondary Angle"/>
+        <entry group="0018" element="1520" keyword="PositionerPrimaryAngleIncrement" vr="DS" vm="1-n" name="Positioner Primary Angle Increment"/>
+        <entry group="0018" element="1521" keyword="PositionerSecondaryAngleIncrement" vr="DS" vm="1-n" name="Positioner Secondary Angle Increment"/>
+        <entry group="0018" element="1530" keyword="DetectorPrimaryAngle" vr="DS" vm="1" name="Detector Primary Angle"/>
+        <entry group="0018" element="1531" keyword="DetectorSecondaryAngle" vr="DS" vm="1" name="Detector Secondary Angle"/>
+        <entry group="0018" element="1600" keyword="ShutterShape" vr="CS" vm="1-3" name="Shutter Shape"/>
+        <entry group="0018" element="1602" keyword="ShutterLeftVerticalEdge" vr="IS" vm="1" name="Shutter Left Vertical Edge"/>
+        <entry group="0018" element="1604" keyword="ShutterRightVerticalEdge" vr="IS" vm="1" name="Shutter Right Vertical Edge"/>
+        <entry group="0018" element="1606" keyword="ShutterUpperHorizontalEdge" vr="IS" vm="1" name="Shutter Upper Horizontal Edge"/>
+        <entry group="0018" element="1608" keyword="ShutterLowerHorizontalEdge" vr="IS" vm="1" name="Shutter Lower Horizontal Edge"/>
+        <entry group="0018" element="1610" keyword="CenterOfCircularShutter" vr="IS" vm="2" name="Center of Circular Shutter"/>
+        <entry group="0018" element="1612" keyword="RadiusOfCircularShutter" vr="IS" vm="1" name="Radius of Circular Shutter"/>
+        <entry group="0018" element="1620" keyword="VerticesOfThePolygonalShutter" vr="IS" vm="2-2n" name="Vertices of the Polygonal Shutter"/>
+        <entry group="0018" element="1622" keyword="ShutterPresentationValue" vr="US" vm="1" name="Shutter Presentation Value"/>
+        <entry group="0018" element="1623" keyword="ShutterOverlayGroup" vr="US" vm="1" name="Shutter Overlay Group"/>
+        <entry group="0018" element="1624" keyword="ShutterPresentationColorCIELabValue" vr="US" vm="3" name="Shutter Presentation Color CIELab Value"/>
+        <entry group="0018" element="1700" keyword="CollimatorShape" vr="CS" vm="1-3" name="Collimator Shape"/>
+        <entry group="0018" element="1702" keyword="CollimatorLeftVerticalEdge" vr="IS" vm="1" name="Collimator Left Vertical Edge"/>
+        <entry group="0018" element="1704" keyword="CollimatorRightVerticalEdge" vr="IS" vm="1" name="Collimator Right Vertical Edge"/>
+        <entry group="0018" element="1706" keyword="CollimatorUpperHorizontalEdge" vr="IS" vm="1" name="Collimator Upper Horizontal Edge"/>
+        <entry group="0018" element="1708" keyword="CollimatorLowerHorizontalEdge" vr="IS" vm="1" name="Collimator Lower Horizontal Edge"/>
+        <entry group="0018" element="1710" keyword="CenterOfCircularCollimator" vr="IS" vm="2" name="Center of Circular Collimator"/>
+        <entry group="0018" element="1712" keyword="RadiusOfCircularCollimator" vr="IS" vm="1" name="Radius of Circular Collimator"/>
+        <entry group="0018" element="1720" keyword="VerticesOfThePolygonalCollimator" vr="IS" vm="2-2n" name="Vertices of the Polygonal Collimator"/>
+        <entry group="0018" element="1800" keyword="AcquisitionTimeSynchronized" vr="CS" vm="1" name="Acquisition Time Synchronized"/>
+        <entry group="0018" element="1801" keyword="TimeSource" vr="SH" vm="1" name="Time Source"/>
+        <entry group="0018" element="1802" keyword="TimeDistributionProtocol" vr="CS" vm="1" name="Time Distribution Protocol"/>
+        <entry group="0018" element="1803" keyword="NTPSourceAddress" vr="LO" vm="1" name="NTP Source Address"/>
+        <entry group="0018" element="2001" keyword="PageNumberVector" vr="IS" vm="1-n" name="Page Number Vector"/>
+        <entry group="0018" element="2002" keyword="FrameLabelVector" vr="SH" vm="1-n" name="Frame Label Vector"/>
+        <entry group="0018" element="2003" keyword="FramePrimaryAngleVector" vr="DS" vm="1-n" name="Frame Primary Angle Vector"/>
+        <entry group="0018" element="2004" keyword="FrameSecondaryAngleVector" vr="DS" vm="1-n" name="Frame Secondary Angle Vector"/>
+        <entry group="0018" element="2005" keyword="SliceLocationVector" vr="DS" vm="1-n" name="Slice Location Vector"/>
+        <entry group="0018" element="2006" keyword="DisplayWindowLabelVector" vr="SH" vm="1-n" name="Display Window Label Vector"/>
+        <entry group="0018" element="2010" keyword="NominalScannedPixelSpacing" vr="DS" vm="2" name="Nominal Scanned Pixel Spacing"/>
+        <entry group="0018" element="2020" keyword="DigitizingDeviceTransportDirection" vr="CS" vm="1" name="Digitizing Device Transport Direction"/>
+        <entry group="0018" element="2030" keyword="RotationOfScannedFilm" vr="DS" vm="1" name="Rotation of Scanned Film"/>
+        <entry group="0018" element="2041" keyword="BiopsyTargetSequence" vr="SQ" vm="1" name="Biopsy Target Sequence"/>
+        <entry group="0018" element="2042" keyword="TargetUID" vr="UI" vm="1" name="Target UID"/>
+        <entry group="0018" element="2043" keyword="LocalizingCursorPosition" vr="FL" vm="2" name="Localizing Cursor Position"/>
+        <entry group="0018" element="2044" keyword="CalculatedTargetPosition" vr="FL" vm="3" name="Calculated Target Position"/>
+        <entry group="0018" element="2045" keyword="TargetLabel" vr="SH" vm="1" name="Target Label"/>
+        <entry group="0018" element="2046" keyword="DisplayedZValue" vr="FL" vm="1" name="Displayed Z Value"/>
+        <entry group="0018" element="3100" keyword="IVUSAcquisition" vr="CS" vm="1" name="IVUS Acquisition"/>
+        <entry group="0018" element="3101" keyword="IVUSPullbackRate" vr="DS" vm="1" name="IVUS Pullback Rate"/>
+        <entry group="0018" element="3102" keyword="IVUSGatedRate" vr="DS" vm="1" name="IVUS Gated Rate"/>
+        <entry group="0018" element="3103" keyword="IVUSPullbackStartFrameNumber" vr="IS" vm="1" name="IVUS Pullback Start Frame Number"/>
+        <entry group="0018" element="3104" keyword="IVUSPullbackStopFrameNumber" vr="IS" vm="1" name="IVUS Pullback Stop Frame Number"/>
+        <entry group="0018" element="3105" keyword="LesionNumber" vr="IS" vm="1-n" name="Lesion Number"/>
+        <entry group="0018" element="4000" keyword="AcquisitionComments" vr="LT" vm="1" retired="true" name="Acquisition Comments"/>
+        <entry group="0018" element="5000" keyword="OutputPower" vr="SH" vm="1-n" name="Output Power"/>
+        <entry group="0018" element="5010" keyword="TransducerData" vr="LO" vm="1-n" name="Transducer Data"/>
+        <entry group="0018" element="5012" keyword="FocusDepth" vr="DS" vm="1" name="Focus Depth"/>
+        <entry group="0018" element="5020" keyword="ProcessingFunction" vr="LO" vm="1" name="Processing Function"/>
+        <entry group="0018" element="5021" keyword="PostprocessingFunction" vr="LO" vm="1" retired="true" name="Postprocessing Function"/>
+        <entry group="0018" element="5022" keyword="MechanicalIndex" vr="DS" vm="1" name="Mechanical Index"/>
+        <entry group="0018" element="5024" keyword="BoneThermalIndex" vr="DS" vm="1" name="Bone Thermal Index"/>
+        <entry group="0018" element="5026" keyword="CranialThermalIndex" vr="DS" vm="1" name="Cranial Thermal Index"/>
+        <entry group="0018" element="5027" keyword="SoftTissueThermalIndex" vr="DS" vm="1" name="Soft Tissue Thermal Index"/>
+        <entry group="0018" element="5028" keyword="SoftTissueFocusThermalIndex" vr="DS" vm="1" name="Soft Tissue-focus Thermal Index"/>
+        <entry group="0018" element="5029" keyword="SoftTissueSurfaceThermalIndex" vr="DS" vm="1" name="Soft Tissue-surface Thermal Index"/>
+        <entry group="0018" element="5030" keyword="DynamicRange" vr="DS" vm="1" retired="true" name="Dynamic Range"/>
+        <entry group="0018" element="5040" keyword="TotalGain" vr="DS" vm="1" retired="true" name="Total Gain"/>
+        <entry group="0018" element="5050" keyword="DepthOfScanField" vr="IS" vm="1" name="Depth of Scan Field"/>
+        <entry group="0018" element="5100" keyword="PatientPosition" vr="CS" vm="1" name="Patient Position"/>
+        <entry group="0018" element="5101" keyword="ViewPosition" vr="CS" vm="1" name="View Position"/>
+        <entry group="0018" element="5104" keyword="ProjectionEponymousNameCodeSequence" vr="SQ" vm="1" name="Projection Eponymous Name Code Sequence"/>
+        <entry group="0018" element="5210" keyword="ImageTransformationMatrix" vr="DS" vm="6" retired="true" name="Image Transformation Matrix"/>
+        <entry group="0018" element="5212" keyword="ImageTranslationVector" vr="DS" vm="3" retired="true" name="Image Translation Vector"/>
+        <entry group="0018" element="6000" keyword="Sensitivity" vr="DS" vm="1" name="Sensitivity"/>
+        <entry group="0018" element="6011" keyword="SequenceOfUltrasoundRegions" vr="SQ" vm="1" name="Sequence of Ultrasound Regions"/>
+        <entry group="0018" element="6012" keyword="RegionSpatialFormat" vr="US" vm="1" name="Region Spatial Format"/>
+        <entry group="0018" element="6014" keyword="RegionDataType" vr="US" vm="1" name="Region Data Type"/>
+        <entry group="0018" element="6016" keyword="RegionFlags" vr="UL" vm="1" name="Region Flags"/>
+        <entry group="0018" element="6018" keyword="RegionLocationMinX0" vr="UL" vm="1" name="Region Location Min X0"/>
+        <entry group="0018" element="601a" keyword="RegionLocationMinY0" vr="UL" vm="1" name="Region Location Min Y0"/>
+        <entry group="0018" element="601c" keyword="RegionLocationMaxX1" vr="UL" vm="1" name="Region Location Max X1"/>
+        <entry group="0018" element="601e" keyword="RegionLocationMaxY1" vr="UL" vm="1" name="Region Location Max Y1"/>
+        <entry group="0018" element="6020" keyword="ReferencePixelX0" vr="SL" vm="1" name="Reference Pixel X0"/>
+        <entry group="0018" element="6022" keyword="ReferencePixelY0" vr="SL" vm="1" name="Reference Pixel Y0"/>
+        <entry group="0018" element="6024" keyword="PhysicalUnitsXDirection" vr="US" vm="1" name="Physical Units X Direction"/>
+        <entry group="0018" element="6026" keyword="PhysicalUnitsYDirection" vr="US" vm="1" name="Physical Units Y Direction"/>
+        <entry group="0018" element="6028" keyword="ReferencePixelPhysicalValueX" vr="FD" vm="1" name="Reference Pixel Physical Value X"/>
+        <entry group="0018" element="602a" keyword="ReferencePixelPhysicalValueY" vr="FD" vm="1" name="Reference Pixel Physical Value Y"/>
+        <entry group="0018" element="602c" keyword="PhysicalDeltaX" vr="FD" vm="1" name="Physical Delta X"/>
+        <entry group="0018" element="602e" keyword="PhysicalDeltaY" vr="FD" vm="1" name="Physical Delta Y"/>
+        <entry group="0018" element="6030" keyword="TransducerFrequency" vr="UL" vm="1" name="Transducer Frequency"/>
+        <entry group="0018" element="6031" keyword="TransducerType" vr="CS" vm="1" name="Transducer Type"/>
+        <entry group="0018" element="6032" keyword="PulseRepetitionFrequency" vr="UL" vm="1" name="Pulse Repetition Frequency"/>
+        <entry group="0018" element="6034" keyword="DopplerCorrectionAngle" vr="FD" vm="1" name="Doppler Correction Angle"/>
+        <entry group="0018" element="6036" keyword="SteeringAngle" vr="FD" vm="1" name="Steering Angle"/>
+        <entry group="0018" element="6038" keyword="DopplerSampleVolumeXPositionRetired" vr="UL" vm="1" retired="true" name="Doppler Sample Volume X Position (Retired)"/>
+        <entry group="0018" element="6039" keyword="DopplerSampleVolumeXPosition" vr="SL" vm="1" name="Doppler Sample Volume X Position"/>
+        <entry group="0018" element="603a" keyword="DopplerSampleVolumeYPositionRetired" vr="UL" vm="1" retired="true" name="Doppler Sample Volume Y Position (Retired)"/>
+        <entry group="0018" element="603b" keyword="DopplerSampleVolumeYPosition" vr="SL" vm="1" name="Doppler Sample Volume Y Position"/>
+        <entry group="0018" element="603c" keyword="TMLinePositionX0Retired" vr="UL" vm="1" retired="true" name="TM-Line Position X0 (Retired)"/>
+        <entry group="0018" element="603d" keyword="TMLinePositionX0" vr="SL" vm="1" name="TM-Line Position X0"/>
+        <entry group="0018" element="603e" keyword="TMLinePositionY0Retired" vr="UL" vm="1" retired="true" name="TM-Line Position Y0 (Retired)"/>
+        <entry group="0018" element="603f" keyword="TMLinePositionY0" vr="SL" vm="1" name="TM-Line Position Y0"/>
+        <entry group="0018" element="6040" keyword="TMLinePositionX1Retired" vr="UL" vm="1" retired="true" name="TM-Line Position X1 (Retired)"/>
+        <entry group="0018" element="6041" keyword="TMLinePositionX1" vr="SL" vm="1" name="TM-Line Position X1"/>
+        <entry group="0018" element="6042" keyword="TMLinePositionY1Retired" vr="UL" vm="1" retired="true" name="TM-Line Position Y1 (Retired)"/>
+        <entry group="0018" element="6043" keyword="TMLinePositionY1" vr="SL" vm="1" name="TM-Line Position Y1"/>
+        <entry group="0018" element="6044" keyword="PixelComponentOrganization" vr="US" vm="1" name="Pixel Component Organization"/>
+        <entry group="0018" element="6046" keyword="PixelComponentMask" vr="UL" vm="1" name="Pixel Component Mask"/>
+        <entry group="0018" element="6048" keyword="PixelComponentRangeStart" vr="UL" vm="1" name="Pixel Component Range Start"/>
+        <entry group="0018" element="604a" keyword="PixelComponentRangeStop" vr="UL" vm="1" name="Pixel Component Range Stop"/>
+        <entry group="0018" element="604c" keyword="PixelComponentPhysicalUnits" vr="US" vm="1" name="Pixel Component Physical Units"/>
+        <entry group="0018" element="604e" keyword="PixelComponentDataType" vr="US" vm="1" name="Pixel Component Data Type"/>
+        <entry group="0018" element="6050" keyword="NumberOfTableBreakPoints" vr="UL" vm="1" name="Number of Table Break Points"/>
+        <entry group="0018" element="6052" keyword="TableOfXBreakPoints" vr="UL" vm="1-n" name="Table of X Break Points"/>
+        <entry group="0018" element="6054" keyword="TableOfYBreakPoints" vr="FD" vm="1-n" name="Table of Y Break Points"/>
+        <entry group="0018" element="6056" keyword="NumberOfTableEntries" vr="UL" vm="1" name="Number of Table Entries"/>
+        <entry group="0018" element="6058" keyword="TableOfPixelValues" vr="UL" vm="1-n" name="Table of Pixel Values"/>
+        <entry group="0018" element="605a" keyword="TableOfParameterValues" vr="FL" vm="1-n" name="Table of Parameter Values"/>
+        <entry group="0018" element="6060" keyword="RWaveTimeVector" vr="FL" vm="1-n" name="R Wave Time Vector"/>
+        <entry group="0018" element="7000" keyword="DetectorConditionsNominalFlag" vr="CS" vm="1" name="Detector Conditions Nominal Flag"/>
+        <entry group="0018" element="7001" keyword="DetectorTemperature" vr="DS" vm="1" name="Detector Temperature"/>
+        <entry group="0018" element="7004" keyword="DetectorType" vr="CS" vm="1" name="Detector Type"/>
+        <entry group="0018" element="7005" keyword="DetectorConfiguration" vr="CS" vm="1" name="Detector Configuration"/>
+        <entry group="0018" element="7006" keyword="DetectorDescription" vr="LT" vm="1" name="Detector Description"/>
+        <entry group="0018" element="7008" keyword="DetectorMode" vr="LT" vm="1" name="Detector Mode"/>
+        <entry group="0018" element="700a" keyword="DetectorID" vr="SH" vm="1" name="Detector ID"/>
+        <entry group="0018" element="700c" keyword="DateOfLastDetectorCalibration" vr="DA" vm="1" name="Date of Last Detector Calibration"/>
+        <entry group="0018" element="700e" keyword="TimeOfLastDetectorCalibration" vr="TM" vm="1" name="Time of Last Detector Calibration"/>
+        <entry group="0018" element="7010" keyword="ExposuresOnDetectorSinceLastCalibration" vr="IS" vm="1" name="Exposures on Detector Since Last Calibration"/>
+        <entry group="0018" element="7011" keyword="ExposuresOnDetectorSinceManufactured" vr="IS" vm="1" name="Exposures on Detector Since Manufactured"/>
+        <entry group="0018" element="7012" keyword="DetectorTimeSinceLastExposure" vr="DS" vm="1" name="Detector Time Since Last Exposure"/>
+        <entry group="0018" element="7014" keyword="DetectorActiveTime" vr="DS" vm="1" name="Detector Active Time"/>
+        <entry group="0018" element="7016" keyword="DetectorActivationOffsetFromExposure" vr="DS" vm="1" name="Detector Activation Offset From Exposure"/>
+        <entry group="0018" element="701a" keyword="DetectorBinning" vr="DS" vm="2" name="Detector Binning"/>
+        <entry group="0018" element="7020" keyword="DetectorElementPhysicalSize" vr="DS" vm="2" name="Detector Element Physical Size"/>
+        <entry group="0018" element="7022" keyword="DetectorElementSpacing" vr="DS" vm="2" name="Detector Element Spacing"/>
+        <entry group="0018" element="7024" keyword="DetectorActiveShape" vr="CS" vm="1" name="Detector Active Shape"/>
+        <entry group="0018" element="7026" keyword="DetectorActiveDimensions" vr="DS" vm="1-2" name="Detector Active Dimension(s)"/>
+        <entry group="0018" element="7028" keyword="DetectorActiveOrigin" vr="DS" vm="2" name="Detector Active Origin"/>
+        <entry group="0018" element="702a" keyword="DetectorManufacturerName" vr="LO" vm="1" name="Detector Manufacturer Name"/>
+        <entry group="0018" element="702b" keyword="DetectorManufacturerModelName" vr="LO" vm="1" name="Detector Manufacturer's Model Name"/>
+        <entry group="0018" element="7030" keyword="FieldOfViewOrigin" vr="DS" vm="2" name="Field of View Origin"/>
+        <entry group="0018" element="7032" keyword="FieldOfViewRotation" vr="DS" vm="1" name="Field of View Rotation"/>
+        <entry group="0018" element="7034" keyword="FieldOfViewHorizontalFlip" vr="CS" vm="1" name="Field of View Horizontal Flip"/>
+        <entry group="0018" element="7036" keyword="PixelDataAreaOriginRelativeToFOV" vr="FL" vm="2" name="Pixel Data Area Origin Relative To FOV"/>
+        <entry group="0018" element="7038" keyword="PixelDataAreaRotationAngleRelativeToFOV" vr="FL" vm="1" name="Pixel Data Area Rotation Angle Relative To FOV"/>
+        <entry group="0018" element="7040" keyword="GridAbsorbingMaterial" vr="LT" vm="1" name="Grid Absorbing Material"/>
+        <entry group="0018" element="7041" keyword="GridSpacingMaterial" vr="LT" vm="1" name="Grid Spacing Material"/>
+        <entry group="0018" element="7042" keyword="GridThickness" vr="DS" vm="1" name="Grid Thickness"/>
+        <entry group="0018" element="7044" keyword="GridPitch" vr="DS" vm="1" name="Grid Pitch"/>
+        <entry group="0018" element="7046" keyword="GridAspectRatio" vr="IS" vm="2" name="Grid Aspect Ratio"/>
+        <entry group="0018" element="7048" keyword="GridPeriod" vr="DS" vm="1" name="Grid Period"/>
+        <entry group="0018" element="704c" keyword="GridFocalDistance" vr="DS" vm="1" name="Grid Focal Distance"/>
+        <entry group="0018" element="7050" keyword="FilterMaterial" vr="CS" vm="1-n" name="Filter Material"/>
+        <entry group="0018" element="7052" keyword="FilterThicknessMinimum" vr="DS" vm="1-n" name="Filter Thickness Minimum"/>
+        <entry group="0018" element="7054" keyword="FilterThicknessMaximum" vr="DS" vm="1-n" name="Filter Thickness Maximum"/>
+        <entry group="0018" element="7056" keyword="FilterBeamPathLengthMinimum" vr="FL" vm="1-n" name="Filter Beam Path Length Minimum"/>
+        <entry group="0018" element="7058" keyword="FilterBeamPathLengthMaximum" vr="FL" vm="1-n" name="Filter Beam Path Length Maximum"/>
+        <entry group="0018" element="7060" keyword="ExposureControlMode" vr="CS" vm="1" name="Exposure Control Mode"/>
+        <entry group="0018" element="7062" keyword="ExposureControlModeDescription" vr="LT" vm="1" name="Exposure Control Mode Description"/>
+        <entry group="0018" element="7064" keyword="ExposureStatus" vr="CS" vm="1" name="Exposure Status"/>
+        <entry group="0018" element="7065" keyword="PhototimerSetting" vr="DS" vm="1" name="Phototimer Setting"/>
+        <entry group="0018" element="8150" keyword="ExposureTimeInuS" vr="DS" vm="1" name="Exposure Time in µS"/>
+        <entry group="0018" element="8151" keyword="XRayTubeCurrentInuA" vr="DS" vm="1" name="X-Ray Tube Current in µA"/>
+        <entry group="0018" element="9004" keyword="ContentQualification" vr="CS" vm="1" name="Content Qualification"/>
+        <entry group="0018" element="9005" keyword="PulseSequenceName" vr="SH" vm="1" name="Pulse Sequence Name"/>
+        <entry group="0018" element="9006" keyword="MRImagingModifierSequence" vr="SQ" vm="1" name="MR Imaging Modifier Sequence"/>
+        <entry group="0018" element="9008" keyword="EchoPulseSequence" vr="CS" vm="1" name="Echo Pulse Sequence"/>
+        <entry group="0018" element="9009" keyword="InversionRecovery" vr="CS" vm="1" name="Inversion Recovery"/>
+        <entry group="0018" element="9010" keyword="FlowCompensation" vr="CS" vm="1" name="Flow Compensation"/>
+        <entry group="0018" element="9011" keyword="MultipleSpinEcho" vr="CS" vm="1" name="Multiple Spin Echo"/>
+        <entry group="0018" element="9012" keyword="MultiPlanarExcitation" vr="CS" vm="1" name="Multi-planar Excitation"/>
+        <entry group="0018" element="9014" keyword="PhaseContrast" vr="CS" vm="1" name="Phase Contrast"/>
+        <entry group="0018" element="9015" keyword="TimeOfFlightContrast" vr="CS" vm="1" name="Time of Flight Contrast"/>
+        <entry group="0018" element="9016" keyword="Spoiling" vr="CS" vm="1" name="Spoiling"/>
+        <entry group="0018" element="9017" keyword="SteadyStatePulseSequence" vr="CS" vm="1" name="Steady State Pulse Sequence"/>
+        <entry group="0018" element="9018" keyword="EchoPlanarPulseSequence" vr="CS" vm="1" name="Echo Planar Pulse Sequence"/>
+        <entry group="0018" element="9019" keyword="TagAngleFirstAxis" vr="FD" vm="1" name="Tag Angle First Axis"/>
+        <entry group="0018" element="9020" keyword="MagnetizationTransfer" vr="CS" vm="1" name="Magnetization Transfer"/>
+        <entry group="0018" element="9021" keyword="T2Preparation" vr="CS" vm="1" name="T2 Preparation"/>
+        <entry group="0018" element="9022" keyword="BloodSignalNulling" vr="CS" vm="1" name="Blood Signal Nulling"/>
+        <entry group="0018" element="9024" keyword="SaturationRecovery" vr="CS" vm="1" name="Saturation Recovery"/>
+        <entry group="0018" element="9025" keyword="SpectrallySelectedSuppression" vr="CS" vm="1" name="Spectrally Selected Suppression"/>
+        <entry group="0018" element="9026" keyword="SpectrallySelectedExcitation" vr="CS" vm="1" name="Spectrally Selected Excitation"/>
+        <entry group="0018" element="9027" keyword="SpatialPresaturation" vr="CS" vm="1" name="Spatial Pre-saturation"/>
+        <entry group="0018" element="9028" keyword="Tagging" vr="CS" vm="1" name="Tagging"/>
+        <entry group="0018" element="9029" keyword="OversamplingPhase" vr="CS" vm="1" name="Oversampling Phase"/>
+        <entry group="0018" element="9030" keyword="TagSpacingFirstDimension" vr="FD" vm="1" name="Tag Spacing First Dimension"/>
+        <entry group="0018" element="9032" keyword="GeometryOfKSpaceTraversal" vr="CS" vm="1" name="Geometry of k-Space Traversal"/>
+        <entry group="0018" element="9033" keyword="SegmentedKSpaceTraversal" vr="CS" vm="1" name="Segmented k-Space Traversal"/>
+        <entry group="0018" element="9034" keyword="RectilinearPhaseEncodeReordering" vr="CS" vm="1" name="Rectilinear Phase Encode Reordering"/>
+        <entry group="0018" element="9035" keyword="TagThickness" vr="FD" vm="1" name="Tag Thickness"/>
+        <entry group="0018" element="9036" keyword="PartialFourierDirection" vr="CS" vm="1" name="Partial Fourier Direction"/>
+        <entry group="0018" element="9037" keyword="CardiacSynchronizationTechnique" vr="CS" vm="1" name="Cardiac Synchronization Technique"/>
+        <entry group="0018" element="9041" keyword="ReceiveCoilManufacturerName" vr="LO" vm="1" name="Receive Coil Manufacturer Name"/>
+        <entry group="0018" element="9042" keyword="MRReceiveCoilSequence" vr="SQ" vm="1" name="MR Receive Coil Sequence"/>
+        <entry group="0018" element="9043" keyword="ReceiveCoilType" vr="CS" vm="1" name="Receive Coil Type"/>
+        <entry group="0018" element="9044" keyword="QuadratureReceiveCoil" vr="CS" vm="1" name="Quadrature Receive Coil"/>
+        <entry group="0018" element="9045" keyword="MultiCoilDefinitionSequence" vr="SQ" vm="1" name="Multi-Coil Definition Sequence"/>
+        <entry group="0018" element="9046" keyword="MultiCoilConfiguration" vr="LO" vm="1" name="Multi-Coil Configuration"/>
+        <entry group="0018" element="9047" keyword="MultiCoilElementName" vr="SH" vm="1" name="Multi-Coil Element Name"/>
+        <entry group="0018" element="9048" keyword="MultiCoilElementUsed" vr="CS" vm="1" name="Multi-Coil Element Used"/>
+        <entry group="0018" element="9049" keyword="MRTransmitCoilSequence" vr="SQ" vm="1" name="MR Transmit Coil Sequence"/>
+        <entry group="0018" element="9050" keyword="TransmitCoilManufacturerName" vr="LO" vm="1" name="Transmit Coil Manufacturer Name"/>
+        <entry group="0018" element="9051" keyword="TransmitCoilType" vr="CS" vm="1" name="Transmit Coil Type"/>
+        <entry group="0018" element="9052" keyword="SpectralWidth" vr="FD" vm="1-2" name="Spectral Width"/>
+        <entry group="0018" element="9053" keyword="ChemicalShiftReference" vr="FD" vm="1-2" name="Chemical Shift Reference"/>
+        <entry group="0018" element="9054" keyword="VolumeLocalizationTechnique" vr="CS" vm="1" name="Volume Localization Technique"/>
+        <entry group="0018" element="9058" keyword="MRAcquisitionFrequencyEncodingSteps" vr="US" vm="1" name="MR Acquisition Frequency Encoding Steps"/>
+        <entry group="0018" element="9059" keyword="Decoupling" vr="CS" vm="1" name="De-coupling"/>
+        <entry group="0018" element="9060" keyword="DecoupledNucleus" vr="CS" vm="1-2" name="De-coupled Nucleus"/>
+        <entry group="0018" element="9061" keyword="DecouplingFrequency" vr="FD" vm="1-2" name="De-coupling Frequency"/>
+        <entry group="0018" element="9062" keyword="DecouplingMethod" vr="CS" vm="1" name="De-coupling Method"/>
+        <entry group="0018" element="9063" keyword="DecouplingChemicalShiftReference" vr="FD" vm="1-2" name="De-coupling Chemical Shift Reference"/>
+        <entry group="0018" element="9064" keyword="KSpaceFiltering" vr="CS" vm="1" name="k-space Filtering"/>
+        <entry group="0018" element="9065" keyword="TimeDomainFiltering" vr="CS" vm="1-2" name="Time Domain Filtering"/>
+        <entry group="0018" element="9066" keyword="NumberOfZeroFills" vr="US" vm="1-2" name="Number of Zero Fills"/>
+        <entry group="0018" element="9067" keyword="BaselineCorrection" vr="CS" vm="1" name="Baseline Correction"/>
+        <entry group="0018" element="9069" keyword="ParallelReductionFactorInPlane" vr="FD" vm="1" name="Parallel Reduction Factor In-plane"/>
+        <entry group="0018" element="9070" keyword="CardiacRRIntervalSpecified" vr="FD" vm="1" name="Cardiac R-R Interval Specified"/>
+        <entry group="0018" element="9073" keyword="AcquisitionDuration" vr="FD" vm="1" name="Acquisition Duration"/>
+        <entry group="0018" element="9074" keyword="FrameAcquisitionDateTime" vr="DT" vm="1" name="Frame Acquisition DateTime"/>
+        <entry group="0018" element="9075" keyword="DiffusionDirectionality" vr="CS" vm="1" name="Diffusion Directionality"/>
+        <entry group="0018" element="9076" keyword="DiffusionGradientDirectionSequence" vr="SQ" vm="1" name="Diffusion Gradient Direction Sequence"/>
+        <entry group="0018" element="9077" keyword="ParallelAcquisition" vr="CS" vm="1" name="Parallel Acquisition"/>
+        <entry group="0018" element="9078" keyword="ParallelAcquisitionTechnique" vr="CS" vm="1" name="Parallel Acquisition Technique"/>
+        <entry group="0018" element="9079" keyword="InversionTimes" vr="FD" vm="1-n" name="Inversion Times"/>
+        <entry group="0018" element="9080" keyword="MetaboliteMapDescription" vr="ST" vm="1" name="Metabolite Map Description"/>
+        <entry group="0018" element="9081" keyword="PartialFourier" vr="CS" vm="1" name="Partial Fourier"/>
+        <entry group="0018" element="9082" keyword="EffectiveEchoTime" vr="FD" vm="1" name="Effective Echo Time"/>
+        <entry group="0018" element="9083" keyword="MetaboliteMapCodeSequence" vr="SQ" vm="1" name="Metabolite Map Code Sequence"/>
+        <entry group="0018" element="9084" keyword="ChemicalShiftSequence" vr="SQ" vm="1" name="Chemical Shift Sequence"/>
+        <entry group="0018" element="9085" keyword="CardiacSignalSource" vr="CS" vm="1" name="Cardiac Signal Source"/>
+        <entry group="0018" element="9087" keyword="DiffusionBValue" vr="FD" vm="1" name="Diffusion b-value"/>
+        <entry group="0018" element="9089" keyword="DiffusionGradientOrientation" vr="FD" vm="3" name="Diffusion Gradient Orientation"/>
+        <entry group="0018" element="9090" keyword="VelocityEncodingDirection" vr="FD" vm="3" name="Velocity Encoding Direction"/>
+        <entry group="0018" element="9091" keyword="VelocityEncodingMinimumValue" vr="FD" vm="1" name="Velocity Encoding Minimum Value"/>
+        <entry group="0018" element="9092" keyword="VelocityEncodingAcquisitionSequence" vr="SQ" vm="1" name="Velocity Encoding Acquisition Sequence"/>
+        <entry group="0018" element="9093" keyword="NumberOfKSpaceTrajectories" vr="US" vm="1" name="Number of k-Space Trajectories"/>
+        <entry group="0018" element="9094" keyword="CoverageOfKSpace" vr="CS" vm="1" name="Coverage of k-Space"/>
+        <entry group="0018" element="9095" keyword="SpectroscopyAcquisitionPhaseRows" vr="UL" vm="1" name="Spectroscopy Acquisition Phase Rows"/>
+        <entry group="0018" element="9096" keyword="ParallelReductionFactorInPlaneRetired" vr="FD" vm="1" retired="true" name="Parallel Reduction Factor In-plane (Retired)"/>
+        <entry group="0018" element="9098" keyword="TransmitterFrequency" vr="FD" vm="1-2" name="Transmitter Frequency"/>
+        <entry group="0018" element="9100" keyword="ResonantNucleus" vr="CS" vm="1-2" name="Resonant Nucleus"/>
+        <entry group="0018" element="9101" keyword="FrequencyCorrection" vr="CS" vm="1" name="Frequency Correction"/>
+        <entry group="0018" element="9103" keyword="MRSpectroscopyFOVGeometrySequence" vr="SQ" vm="1" name="MR Spectroscopy FOV/Geometry Sequence"/>
+        <entry group="0018" element="9104" keyword="SlabThickness" vr="FD" vm="1" name="Slab Thickness"/>
+        <entry group="0018" element="9105" keyword="SlabOrientation" vr="FD" vm="3" name="Slab Orientation"/>
+        <entry group="0018" element="9106" keyword="MidSlabPosition" vr="FD" vm="3" name="Mid Slab Position"/>
+        <entry group="0018" element="9107" keyword="MRSpatialSaturationSequence" vr="SQ" vm="1" name="MR Spatial Saturation Sequence"/>
+        <entry group="0018" element="9112" keyword="MRTimingAndRelatedParametersSequence" vr="SQ" vm="1" name="MR Timing and Related Parameters Sequence"/>
+        <entry group="0018" element="9114" keyword="MREchoSequence" vr="SQ" vm="1" name="MR Echo Sequence"/>
+        <entry group="0018" element="9115" keyword="MRModifierSequence" vr="SQ" vm="1" name="MR Modifier Sequence"/>
+        <entry group="0018" element="9117" keyword="MRDiffusionSequence" vr="SQ" vm="1" name="MR Diffusion Sequence"/>
+        <entry group="0018" element="9118" keyword="CardiacSynchronizationSequence" vr="SQ" vm="1" name="Cardiac Synchronization Sequence"/>
+        <entry group="0018" element="9119" keyword="MRAveragesSequence" vr="SQ" vm="1" name="MR Averages Sequence"/>
+        <entry group="0018" element="9125" keyword="MRFOVGeometrySequence" vr="SQ" vm="1" name="MR FOV/Geometry Sequence"/>
+        <entry group="0018" element="9126" keyword="VolumeLocalizationSequence" vr="SQ" vm="1" name="Volume Localization Sequence"/>
+        <entry group="0018" element="9127" keyword="SpectroscopyAcquisitionDataColumns" vr="UL" vm="1" name="Spectroscopy Acquisition Data Columns"/>
+        <entry group="0018" element="9147" keyword="DiffusionAnisotropyType" vr="CS" vm="1" name="Diffusion Anisotropy Type"/>
+        <entry group="0018" element="9151" keyword="FrameReferenceDateTime" vr="DT" vm="1" name="Frame Reference DateTime"/>
+        <entry group="0018" element="9152" keyword="MRMetaboliteMapSequence" vr="SQ" vm="1" name="MR Metabolite Map Sequence"/>
+        <entry group="0018" element="9155" keyword="ParallelReductionFactorOutOfPlane" vr="FD" vm="1" name="Parallel Reduction Factor out-of-plane"/>
+        <entry group="0018" element="9159" keyword="SpectroscopyAcquisitionOutOfPlanePhaseSteps" vr="UL" vm="1" name="Spectroscopy Acquisition Out-of-plane Phase Steps"/>
+        <entry group="0018" element="9166" keyword="BulkMotionStatus" vr="CS" vm="1" retired="true" name="Bulk Motion Status"/>
+        <entry group="0018" element="9168" keyword="ParallelReductionFactorSecondInPlane" vr="FD" vm="1" name="Parallel Reduction Factor Second In-plane"/>
+        <entry group="0018" element="9169" keyword="CardiacBeatRejectionTechnique" vr="CS" vm="1" name="Cardiac Beat Rejection Technique"/>
+        <entry group="0018" element="9170" keyword="RespiratoryMotionCompensationTechnique" vr="CS" vm="1" name="Respiratory Motion Compensation Technique"/>
+        <entry group="0018" element="9171" keyword="RespiratorySignalSource" vr="CS" vm="1" name="Respiratory Signal Source"/>
+        <entry group="0018" element="9172" keyword="BulkMotionCompensationTechnique" vr="CS" vm="1" name="Bulk Motion Compensation Technique"/>
+        <entry group="0018" element="9173" keyword="BulkMotionSignalSource" vr="CS" vm="1" name="Bulk Motion Signal Source"/>
+        <entry group="0018" element="9174" keyword="ApplicableSafetyStandardAgency" vr="CS" vm="1" name="Applicable Safety Standard Agency"/>
+        <entry group="0018" element="9175" keyword="ApplicableSafetyStandardDescription" vr="LO" vm="1" name="Applicable Safety Standard Description"/>
+        <entry group="0018" element="9176" keyword="OperatingModeSequence" vr="SQ" vm="1" name="Operating Mode Sequence"/>
+        <entry group="0018" element="9177" keyword="OperatingModeType" vr="CS" vm="1" name="Operating Mode Type"/>
+        <entry group="0018" element="9178" keyword="OperatingMode" vr="CS" vm="1" name="Operating Mode"/>
+        <entry group="0018" element="9179" keyword="SpecificAbsorptionRateDefinition" vr="CS" vm="1" name="Specific Absorption Rate Definition"/>
+        <entry group="0018" element="9180" keyword="GradientOutputType" vr="CS" vm="1" name="Gradient Output Type"/>
+        <entry group="0018" element="9181" keyword="SpecificAbsorptionRateValue" vr="FD" vm="1" name="Specific Absorption Rate Value"/>
+        <entry group="0018" element="9182" keyword="GradientOutput" vr="FD" vm="1" name="Gradient Output"/>
+        <entry group="0018" element="9183" keyword="FlowCompensationDirection" vr="CS" vm="1" name="Flow Compensation Direction"/>
+        <entry group="0018" element="9184" keyword="TaggingDelay" vr="FD" vm="1" name="Tagging Delay"/>
+        <entry group="0018" element="9185" keyword="RespiratoryMotionCompensationTechniqueDescription" vr="ST" vm="1" name="Respiratory Motion Compensation Technique Description"/>
+        <entry group="0018" element="9186" keyword="RespiratorySignalSourceID" vr="SH" vm="1" name="Respiratory Signal Source ID"/>
+        <entry group="0018" element="9195" keyword="ChemicalShiftMinimumIntegrationLimitInHz" vr="FD" vm="1" retired="true" name="Chemical Shift Minimum Integration Limit in Hz"/>
+        <entry group="0018" element="9196" keyword="ChemicalShiftMaximumIntegrationLimitInHz" vr="FD" vm="1" retired="true" name="Chemical Shift Maximum Integration Limit in Hz"/>
+        <entry group="0018" element="9197" keyword="MRVelocityEncodingSequence" vr="SQ" vm="1" name="MR Velocity Encoding Sequence"/>
+        <entry group="0018" element="9198" keyword="FirstOrderPhaseCorrection" vr="CS" vm="1" name="First Order Phase Correction"/>
+        <entry group="0018" element="9199" keyword="WaterReferencedPhaseCorrection" vr="CS" vm="1" name="Water Referenced Phase Correction"/>
+        <entry group="0018" element="9200" keyword="MRSpectroscopyAcquisitionType" vr="CS" vm="1" name="MR Spectroscopy Acquisition Type"/>
+        <entry group="0018" element="9214" keyword="RespiratoryCyclePosition" vr="CS" vm="1" name="Respiratory Cycle Position"/>
+        <entry group="0018" element="9217" keyword="VelocityEncodingMaximumValue" vr="FD" vm="1" name="Velocity Encoding Maximum Value"/>
+        <entry group="0018" element="9218" keyword="TagSpacingSecondDimension" vr="FD" vm="1" name="Tag Spacing Second Dimension"/>
+        <entry group="0018" element="9219" keyword="TagAngleSecondAxis" vr="SS" vm="1" name="Tag Angle Second Axis"/>
+        <entry group="0018" element="9220" keyword="FrameAcquisitionDuration" vr="FD" vm="1" name="Frame Acquisition Duration"/>
+        <entry group="0018" element="9226" keyword="MRImageFrameTypeSequence" vr="SQ" vm="1" name="MR Image Frame Type Sequence"/>
+        <entry group="0018" element="9227" keyword="MRSpectroscopyFrameTypeSequence" vr="SQ" vm="1" name="MR Spectroscopy Frame Type Sequence"/>
+        <entry group="0018" element="9231" keyword="MRAcquisitionPhaseEncodingStepsInPlane" vr="US" vm="1" name="MR Acquisition Phase Encoding Steps in-plane"/>
+        <entry group="0018" element="9232" keyword="MRAcquisitionPhaseEncodingStepsOutOfPlane" vr="US" vm="1" name="MR Acquisition Phase Encoding Steps out-of-plane"/>
+        <entry group="0018" element="9234" keyword="SpectroscopyAcquisitionPhaseColumns" vr="UL" vm="1" name="Spectroscopy Acquisition Phase Columns"/>
+        <entry group="0018" element="9236" keyword="CardiacCyclePosition" vr="CS" vm="1" name="Cardiac Cycle Position"/>
+        <entry group="0018" element="9239" keyword="SpecificAbsorptionRateSequence" vr="SQ" vm="1" name="Specific Absorption Rate Sequence"/>
+        <entry group="0018" element="9240" keyword="RFEchoTrainLength" vr="US" vm="1" name="RF Echo Train Length"/>
+        <entry group="0018" element="9241" keyword="GradientEchoTrainLength" vr="US" vm="1" name="Gradient Echo Train Length"/>
+        <entry group="0018" element="9250" keyword="ArterialSpinLabelingContrast" vr="CS" vm="1" name="Arterial Spin Labeling Contrast"/>
+        <entry group="0018" element="9251" keyword="MRArterialSpinLabelingSequence" vr="SQ" vm="1" name="MR Arterial Spin Labeling Sequence"/>
+        <entry group="0018" element="9252" keyword="ASLTechniqueDescription" vr="LO" vm="1" name="ASL Technique Description"/>
+        <entry group="0018" element="9253" keyword="ASLSlabNumber" vr="US" vm="1" name="ASL Slab Number"/>
+        <entry group="0018" element="9254" keyword="ASLSlabThickness" vr="FD" vm="1" name="ASL Slab Thickness"/>
+        <entry group="0018" element="9255" keyword="ASLSlabOrientation" vr="FD" vm="3" name="ASL Slab Orientation"/>
+        <entry group="0018" element="9256" keyword="ASLMidSlabPosition" vr="FD" vm="3" name="ASL Mid Slab Position"/>
+        <entry group="0018" element="9257" keyword="ASLContext" vr="CS" vm="1" name="ASL Context"/>
+        <entry group="0018" element="9258" keyword="ASLPulseTrainDuration" vr="UL" vm="1" name="ASL Pulse Train Duration"/>
+        <entry group="0018" element="9259" keyword="ASLCrusherFlag" vr="CS" vm="1" name="ASL Crusher Flag"/>
+        <entry group="0018" element="925a" keyword="ASLCrusherFlowLimit" vr="FD" vm="1" name="ASL Crusher Flow Limit"/>
+        <entry group="0018" element="925b" keyword="ASLCrusherDescription" vr="LO" vm="1" name="ASL Crusher Description"/>
+        <entry group="0018" element="925c" keyword="ASLBolusCutoffFlag" vr="CS" vm="1" name="ASL Bolus Cut-off Flag"/>
+        <entry group="0018" element="925d" keyword="ASLBolusCutoffTimingSequence" vr="SQ" vm="1" name="ASL Bolus Cut-off Timing Sequence"/>
+        <entry group="0018" element="925e" keyword="ASLBolusCutoffTechnique" vr="LO" vm="1" name="ASL Bolus Cut-off Technique"/>
+        <entry group="0018" element="925f" keyword="ASLBolusCutoffDelayTime" vr="UL" vm="1" name="ASL Bolus Cut-off Delay Time"/>
+        <entry group="0018" element="9260" keyword="ASLSlabSequence" vr="SQ" vm="1" name="ASL Slab Sequence"/>
+        <entry group="0018" element="9295" keyword="ChemicalShiftMinimumIntegrationLimitInppm" vr="FD" vm="1" name="Chemical Shift Minimum Integration Limit in ppm"/>
+        <entry group="0018" element="9296" keyword="ChemicalShiftMaximumIntegrationLimitInppm" vr="FD" vm="1" name="Chemical Shift Maximum Integration Limit in ppm"/>
+        <entry group="0018" element="9297" keyword="WaterReferenceAcquisition" vr="CS" vm="1" name="Water Reference Acquisition"/>
+        <entry group="0018" element="9298" keyword="EchoPeakPosition" vr="IS" vm="1" name="Echo Peak Position"/>
+        <entry group="0018" element="9301" keyword="CTAcquisitionTypeSequence" vr="SQ" vm="1" name="CT Acquisition Type Sequence"/>
+        <entry group="0018" element="9302" keyword="AcquisitionType" vr="CS" vm="1" name="Acquisition Type"/>
+        <entry group="0018" element="9303" keyword="TubeAngle" vr="FD" vm="1" name="Tube Angle"/>
+        <entry group="0018" element="9304" keyword="CTAcquisitionDetailsSequence" vr="SQ" vm="1" name="CT Acquisition Details Sequence"/>
+        <entry group="0018" element="9305" keyword="RevolutionTime" vr="FD" vm="1" name="Revolution Time"/>
+        <entry group="0018" element="9306" keyword="SingleCollimationWidth" vr="FD" vm="1" name="Single Collimation Width"/>
+        <entry group="0018" element="9307" keyword="TotalCollimationWidth" vr="FD" vm="1" name="Total Collimation Width"/>
+        <entry group="0018" element="9308" keyword="CTTableDynamicsSequence" vr="SQ" vm="1" name="CT Table Dynamics Sequence"/>
+        <entry group="0018" element="9309" keyword="TableSpeed" vr="FD" vm="1" name="Table Speed"/>
+        <entry group="0018" element="9310" keyword="TableFeedPerRotation" vr="FD" vm="1" name="Table Feed per Rotation"/>
+        <entry group="0018" element="9311" keyword="SpiralPitchFactor" vr="FD" vm="1" name="Spiral Pitch Factor"/>
+        <entry group="0018" element="9312" keyword="CTGeometrySequence" vr="SQ" vm="1" name="CT Geometry Sequence"/>
+        <entry group="0018" element="9313" keyword="DataCollectionCenterPatient" vr="FD" vm="3" name="Data Collection Center (Patient)"/>
+        <entry group="0018" element="9314" keyword="CTReconstructionSequence" vr="SQ" vm="1" name="CT Reconstruction Sequence"/>
+        <entry group="0018" element="9315" keyword="ReconstructionAlgorithm" vr="CS" vm="1" name="Reconstruction Algorithm"/>
+        <entry group="0018" element="9316" keyword="ConvolutionKernelGroup" vr="CS" vm="1" name="Convolution Kernel Group"/>
+        <entry group="0018" element="9317" keyword="ReconstructionFieldOfView" vr="FD" vm="2" name="Reconstruction Field of View"/>
+        <entry group="0018" element="9318" keyword="ReconstructionTargetCenterPatient" vr="FD" vm="3" name="Reconstruction Target Center (Patient)"/>
+        <entry group="0018" element="9319" keyword="ReconstructionAngle" vr="FD" vm="1" name="Reconstruction Angle"/>
+        <entry group="0018" element="9320" keyword="ImageFilter" vr="SH" vm="1" name="Image Filter"/>
+        <entry group="0018" element="9321" keyword="CTExposureSequence" vr="SQ" vm="1" name="CT Exposure Sequence"/>
+        <entry group="0018" element="9322" keyword="ReconstructionPixelSpacing" vr="FD" vm="2" name="Reconstruction Pixel Spacing"/>
+        <entry group="0018" element="9323" keyword="ExposureModulationType" vr="CS" vm="1-n" name="Exposure Modulation Type"/>
+        <entry group="0018" element="9324" keyword="EstimatedDoseSaving" vr="FD" vm="1" name="Estimated Dose Saving"/>
+        <entry group="0018" element="9325" keyword="CTXRayDetailsSequence" vr="SQ" vm="1" name="CT X-Ray Details Sequence"/>
+        <entry group="0018" element="9326" keyword="CTPositionSequence" vr="SQ" vm="1" name="CT Position Sequence"/>
+        <entry group="0018" element="9327" keyword="TablePosition" vr="FD" vm="1" name="Table Position"/>
+        <entry group="0018" element="9328" keyword="ExposureTimeInms" vr="FD" vm="1" name="Exposure Time in ms"/>
+        <entry group="0018" element="9329" keyword="CTImageFrameTypeSequence" vr="SQ" vm="1" name="CT Image Frame Type Sequence"/>
+        <entry group="0018" element="9330" keyword="XRayTubeCurrentInmA" vr="FD" vm="1" name="X-Ray Tube Current in mA"/>
+        <entry group="0018" element="9332" keyword="ExposureInmAs" vr="FD" vm="1" name="Exposure in mAs"/>
+        <entry group="0018" element="9333" keyword="ConstantVolumeFlag" vr="CS" vm="1" name="Constant Volume Flag"/>
+        <entry group="0018" element="9334" keyword="FluoroscopyFlag" vr="CS" vm="1" name="Fluoroscopy Flag"/>
+        <entry group="0018" element="9335" keyword="DistanceSourceToDataCollectionCenter" vr="FD" vm="1" name="Distance Source to Data Collection Center"/>
+        <entry group="0018" element="9337" keyword="ContrastBolusAgentNumber" vr="US" vm="1" name="Contrast/Bolus Agent Number"/>
+        <entry group="0018" element="9338" keyword="ContrastBolusIngredientCodeSequence" vr="SQ" vm="1" name="Contrast/Bolus Ingredient Code Sequence"/>
+        <entry group="0018" element="9340" keyword="ContrastAdministrationProfileSequence" vr="SQ" vm="1" name="Contrast Administration Profile Sequence"/>
+        <entry group="0018" element="9341" keyword="ContrastBolusUsageSequence" vr="SQ" vm="1" name="Contrast/Bolus Usage Sequence"/>
+        <entry group="0018" element="9342" keyword="ContrastBolusAgentAdministered" vr="CS" vm="1" name="Contrast/Bolus Agent Administered"/>
+        <entry group="0018" element="9343" keyword="ContrastBolusAgentDetected" vr="CS" vm="1" name="Contrast/Bolus Agent Detected"/>
+        <entry group="0018" element="9344" keyword="ContrastBolusAgentPhase" vr="CS" vm="1" name="Contrast/Bolus Agent Phase"/>
+        <entry group="0018" element="9345" keyword="CTDIvol" vr="FD" vm="1" name="CTDIvol"/>
+        <entry group="0018" element="9346" keyword="CTDIPhantomTypeCodeSequence" vr="SQ" vm="1" name="CTDI Phantom Type Code Sequence"/>
+        <entry group="0018" element="9351" keyword="CalciumScoringMassFactorPatient" vr="FL" vm="1" name="Calcium Scoring Mass Factor Patient"/>
+        <entry group="0018" element="9352" keyword="CalciumScoringMassFactorDevice" vr="FL" vm="3" name="Calcium Scoring Mass Factor Device"/>
+        <entry group="0018" element="9353" keyword="EnergyWeightingFactor" vr="FL" vm="1" name="Energy Weighting Factor"/>
+        <entry group="0018" element="9360" keyword="CTAdditionalXRaySourceSequence" vr="SQ" vm="1" name="CT Additional X-Ray Source Sequence"/>
+        <entry group="0018" element="9401" keyword="ProjectionPixelCalibrationSequence" vr="SQ" vm="1" name="Projection Pixel Calibration Sequence"/>
+        <entry group="0018" element="9402" keyword="DistanceSourceToIsocenter" vr="FL" vm="1" name="Distance Source to Isocenter"/>
+        <entry group="0018" element="9403" keyword="DistanceObjectToTableTop" vr="FL" vm="1" name="Distance Object to Table Top"/>
+        <entry group="0018" element="9404" keyword="ObjectPixelSpacingInCenterOfBeam" vr="FL" vm="2" name="Object Pixel Spacing in Center of Beam"/>
+        <entry group="0018" element="9405" keyword="PositionerPositionSequence" vr="SQ" vm="1" name="Positioner Position Sequence"/>
+        <entry group="0018" element="9406" keyword="TablePositionSequence" vr="SQ" vm="1" name="Table Position Sequence"/>
+        <entry group="0018" element="9407" keyword="CollimatorShapeSequence" vr="SQ" vm="1" name="Collimator Shape Sequence"/>
+        <entry group="0018" element="9410" keyword="PlanesInAcquisition" vr="CS" vm="1" name="Planes in Acquisition"/>
+        <entry group="0018" element="9412" keyword="XAXRFFrameCharacteristicsSequence" vr="SQ" vm="1" name="XA/XRF Frame Characteristics Sequence"/>
+        <entry group="0018" element="9417" keyword="FrameAcquisitionSequence" vr="SQ" vm="1" name="Frame Acquisition Sequence"/>
+        <entry group="0018" element="9420" keyword="XRayReceptorType" vr="CS" vm="1" name="X-Ray Receptor Type"/>
+        <entry group="0018" element="9423" keyword="AcquisitionProtocolName" vr="LO" vm="1" name="Acquisition Protocol Name"/>
+        <entry group="0018" element="9424" keyword="AcquisitionProtocolDescription" vr="LT" vm="1" name="Acquisition Protocol Description"/>
+        <entry group="0018" element="9425" keyword="ContrastBolusIngredientOpaque" vr="CS" vm="1" name="Contrast/Bolus Ingredient Opaque"/>
+        <entry group="0018" element="9426" keyword="DistanceReceptorPlaneToDetectorHousing" vr="FL" vm="1" name="Distance Receptor Plane to Detector Housing"/>
+        <entry group="0018" element="9427" keyword="IntensifierActiveShape" vr="CS" vm="1" name="Intensifier Active Shape"/>
+        <entry group="0018" element="9428" keyword="IntensifierActiveDimensions" vr="FL" vm="1-2" name="Intensifier Active Dimension(s)"/>
+        <entry group="0018" element="9429" keyword="PhysicalDetectorSize" vr="FL" vm="2" name="Physical Detector Size"/>
+        <entry group="0018" element="9430" keyword="PositionOfIsocenterProjection" vr="FL" vm="2" name="Position of Isocenter Projection"/>
+        <entry group="0018" element="9432" keyword="FieldOfViewSequence" vr="SQ" vm="1" name="Field of View Sequence"/>
+        <entry group="0018" element="9433" keyword="FieldOfViewDescription" vr="LO" vm="1" name="Field of View Description"/>
+        <entry group="0018" element="9434" keyword="ExposureControlSensingRegionsSequence" vr="SQ" vm="1" name="Exposure Control Sensing Regions Sequence"/>
+        <entry group="0018" element="9435" keyword="ExposureControlSensingRegionShape" vr="CS" vm="1" name="Exposure Control Sensing Region Shape"/>
+        <entry group="0018" element="9436" keyword="ExposureControlSensingRegionLeftVerticalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Left Vertical Edge"/>
+        <entry group="0018" element="9437" keyword="ExposureControlSensingRegionRightVerticalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Right Vertical Edge"/>
+        <entry group="0018" element="9438" keyword="ExposureControlSensingRegionUpperHorizontalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Upper Horizontal Edge"/>
+        <entry group="0018" element="9439" keyword="ExposureControlSensingRegionLowerHorizontalEdge" vr="SS" vm="1" name="Exposure Control Sensing Region Lower Horizontal Edge"/>
+        <entry group="0018" element="9440" keyword="CenterOfCircularExposureControlSensingRegion" vr="SS" vm="2" name="Center of Circular Exposure Control Sensing Region"/>
+        <entry group="0018" element="9441" keyword="RadiusOfCircularExposureControlSensingRegion" vr="US" vm="1" name="Radius of Circular Exposure Control Sensing Region"/>
+        <entry group="0018" element="9442" keyword="VerticesOfThePolygonalExposureControlSensingRegion" vr="SS" vm="2-n" name="Vertices of the Polygonal Exposure Control Sensing Region"/>
+        <entry group="0018" element="9445" retired="true"/>
+        <entry group="0018" element="9447" keyword="ColumnAngulationPatient" vr="FL" vm="1" name="Column Angulation (Patient)"/>
+        <entry group="0018" element="9449" keyword="BeamAngle" vr="FL" vm="1" name="Beam Angle"/>
+        <entry group="0018" element="9451" keyword="FrameDetectorParametersSequence" vr="SQ" vm="1" name="Frame Detector Parameters Sequence"/>
+        <entry group="0018" element="9452" keyword="CalculatedAnatomyThickness" vr="FL" vm="1" name="Calculated Anatomy Thickness"/>
+        <entry group="0018" element="9455" keyword="CalibrationSequence" vr="SQ" vm="1" name="Calibration Sequence"/>
+        <entry group="0018" element="9456" keyword="ObjectThicknessSequence" vr="SQ" vm="1" name="Object Thickness Sequence"/>
+        <entry group="0018" element="9457" keyword="PlaneIdentification" vr="CS" vm="1" name="Plane Identification"/>
+        <entry group="0018" element="9461" keyword="FieldOfViewDimensionsInFloat" vr="FL" vm="1-2" name="Field of View Dimension(s) in Float"/>
+        <entry group="0018" element="9462" keyword="IsocenterReferenceSystemSequence" vr="SQ" vm="1" name="Isocenter Reference System Sequence"/>
+        <entry group="0018" element="9463" keyword="PositionerIsocenterPrimaryAngle" vr="FL" vm="1" name="Positioner Isocenter Primary Angle"/>
+        <entry group="0018" element="9464" keyword="PositionerIsocenterSecondaryAngle" vr="FL" vm="1" name="Positioner Isocenter Secondary Angle"/>
+        <entry group="0018" element="9465" keyword="PositionerIsocenterDetectorRotationAngle" vr="FL" vm="1" name="Positioner Isocenter Detector Rotation Angle"/>
+        <entry group="0018" element="9466" keyword="TableXPositionToIsocenter" vr="FL" vm="1" name="Table X Position to Isocenter"/>
+        <entry group="0018" element="9467" keyword="TableYPositionToIsocenter" vr="FL" vm="1" name="Table Y Position to Isocenter"/>
+        <entry group="0018" element="9468" keyword="TableZPositionToIsocenter" vr="FL" vm="1" name="Table Z Position to Isocenter"/>
+        <entry group="0018" element="9469" keyword="TableHorizontalRotationAngle" vr="FL" vm="1" name="Table Horizontal Rotation Angle"/>
+        <entry group="0018" element="9470" keyword="TableHeadTiltAngle" vr="FL" vm="1" name="Table Head Tilt Angle"/>
+        <entry group="0018" element="9471" keyword="TableCradleTiltAngle" vr="FL" vm="1" name="Table Cradle Tilt Angle"/>
+        <entry group="0018" element="9472" keyword="FrameDisplayShutterSequence" vr="SQ" vm="1" name="Frame Display Shutter Sequence"/>
+        <entry group="0018" element="9473" keyword="AcquiredImageAreaDoseProduct" vr="FL" vm="1" name="Acquired Image Area Dose Product"/>
+        <entry group="0018" element="9474" keyword="CArmPositionerTabletopRelationship" vr="CS" vm="1" name="C-arm Positioner Tabletop Relationship"/>
+        <entry group="0018" element="9476" keyword="XRayGeometrySequence" vr="SQ" vm="1" name="X-Ray Geometry Sequence"/>
+        <entry group="0018" element="9477" keyword="IrradiationEventIdentificationSequence" vr="SQ" vm="1" name="Irradiation Event Identification Sequence"/>
+        <entry group="0018" element="9504" keyword="XRay3DFrameTypeSequence" vr="SQ" vm="1" name="X-Ray 3D Frame Type Sequence"/>
+        <entry group="0018" element="9506" keyword="ContributingSourcesSequence" vr="SQ" vm="1" name="Contributing Sources Sequence"/>
+        <entry group="0018" element="9507" keyword="XRay3DAcquisitionSequence" vr="SQ" vm="1" name="X-Ray 3D Acquisition Sequence"/>
+        <entry group="0018" element="9508" keyword="PrimaryPositionerScanArc" vr="FL" vm="1" name="Primary Positioner Scan Arc"/>
+        <entry group="0018" element="9509" keyword="SecondaryPositionerScanArc" vr="FL" vm="1" name="Secondary Positioner Scan Arc"/>
+        <entry group="0018" element="9510" keyword="PrimaryPositionerScanStartAngle" vr="FL" vm="1" name="Primary Positioner Scan Start Angle"/>
+        <entry group="0018" element="9511" keyword="SecondaryPositionerScanStartAngle" vr="FL" vm="1" name="Secondary Positioner Scan Start Angle"/>
+        <entry group="0018" element="9514" keyword="PrimaryPositionerIncrement" vr="FL" vm="1" name="Primary Positioner Increment"/>
+        <entry group="0018" element="9515" keyword="SecondaryPositionerIncrement" vr="FL" vm="1" name="Secondary Positioner Increment"/>
+        <entry group="0018" element="9516" keyword="StartAcquisitionDateTime" vr="DT" vm="1" name="Start Acquisition DateTime"/>
+        <entry group="0018" element="9517" keyword="EndAcquisitionDateTime" vr="DT" vm="1" name="End Acquisition DateTime"/>
+        <entry group="0018" element="9518" keyword="PrimaryPositionerIncrementSign" vr="SS" vm="1" name="Primary Positioner Increment Sign"/>
+        <entry group="0018" element="9519" keyword="SecondaryPositionerIncrementSign" vr="SS" vm="1" name="Secondary Positioner Increment Sign"/>
+        <entry group="0018" element="9524" keyword="ApplicationName" vr="LO" vm="1" name="Application Name"/>
+        <entry group="0018" element="9525" keyword="ApplicationVersion" vr="LO" vm="1" name="Application Version"/>
+        <entry group="0018" element="9526" keyword="ApplicationManufacturer" vr="LO" vm="1" name="Application Manufacturer"/>
+        <entry group="0018" element="9527" keyword="AlgorithmType" vr="CS" vm="1" name="Algorithm Type"/>
+        <entry group="0018" element="9528" keyword="AlgorithmDescription" vr="LO" vm="1" name="Algorithm Description"/>
+        <entry group="0018" element="9530" keyword="XRay3DReconstructionSequence" vr="SQ" vm="1" name="X-Ray 3D Reconstruction Sequence"/>
+        <entry group="0018" element="9531" keyword="ReconstructionDescription" vr="LO" vm="1" name="Reconstruction Description"/>
+        <entry group="0018" element="9538" keyword="PerProjectionAcquisitionSequence" vr="SQ" vm="1" name="Per Projection Acquisition Sequence"/>
+        <entry group="0018" element="9541" keyword="DetectorPositionSequence" vr="SQ" vm="1" name="Detector Position Sequence"/>
+        <entry group="0018" element="9542" keyword="XRayAcquisitionDoseSequence" vr="SQ" vm="1" name="X-Ray Acquisition Dose Sequence"/>
+        <entry group="0018" element="9543" keyword="XRaySourceIsocenterPrimaryAngle" vr="FD" vm="1" name="X-Ray Source Isocenter Primary Angle"/>
+        <entry group="0018" element="9544" keyword="XRaySourceIsocenterSecondaryAngle" vr="FD" vm="1" name="X-Ray Source Isocenter Secondary Angle"/>
+        <entry group="0018" element="9545" keyword="BreastSupportIsocenterPrimaryAngle" vr="FD" vm="1" name="Breast Support Isocenter Primary Angle"/>
+        <entry group="0018" element="9546" keyword="BreastSupportIsocenterSecondaryAngle" vr="FD" vm="1" name="Breast Support Isocenter Secondary Angle"/>
+        <entry group="0018" element="9547" keyword="BreastSupportXPositionToIsocenter" vr="FD" vm="1" name="Breast Support X Position to Isocenter"/>
+        <entry group="0018" element="9548" keyword="BreastSupportYPositionToIsocenter" vr="FD" vm="1" name="Breast Support Y Position to Isocenter"/>
+        <entry group="0018" element="9549" keyword="BreastSupportZPositionToIsocenter" vr="FD" vm="1" name="Breast Support Z Position to Isocenter"/>
+        <entry group="0018" element="9550" keyword="DetectorIsocenterPrimaryAngle" vr="FD" vm="1" name="Detector Isocenter Primary Angle"/>
+        <entry group="0018" element="9551" keyword="DetectorIsocenterSecondaryAngle" vr="FD" vm="1" name="Detector Isocenter Secondary Angle"/>
+        <entry group="0018" element="9552" keyword="DetectorXPositionToIsocenter" vr="FD" vm="1" name="Detector X Position to Isocenter"/>
+        <entry group="0018" element="9553" keyword="DetectorYPositionToIsocenter" vr="FD" vm="1" name="Detector Y Position to Isocenter"/>
+        <entry group="0018" element="9554" keyword="DetectorZPositionToIsocenter" vr="FD" vm="1" name="Detector Z Position to Isocenter"/>
+        <entry group="0018" element="9555" keyword="XRayGridSequence" vr="SQ" vm="1" name="X-Ray Grid Sequence"/>
+        <entry group="0018" element="9556" keyword="XRayFilterSequence" vr="SQ" vm="1" name="X-Ray Filter Sequence"/>
+        <entry group="0018" element="9557" keyword="DetectorActiveAreaTLHCPosition" vr="FD" vm="3" name="Detector Active Area TLHC Position"/>
+        <entry group="0018" element="9558" keyword="DetectorActiveAreaOrientation" vr="FD" vm="6" name="Detector Active Area Orientation"/>
+        <entry group="0018" element="9559" keyword="PositionerPrimaryAngleDirection" vr="CS" vm="1" name="Positioner Primary Angle Direction"/>
+        <entry group="0018" element="9601" keyword="DiffusionBMatrixSequence" vr="SQ" vm="1" name="Diffusion b-matrix Sequence"/>
+        <entry group="0018" element="9602" keyword="DiffusionBValueXX" vr="FD" vm="1" name="Diffusion b-value XX"/>
+        <entry group="0018" element="9603" keyword="DiffusionBValueXY" vr="FD" vm="1" name="Diffusion b-value XY"/>
+        <entry group="0018" element="9604" keyword="DiffusionBValueXZ" vr="FD" vm="1" name="Diffusion b-value XZ"/>
+        <entry group="0018" element="9605" keyword="DiffusionBValueYY" vr="FD" vm="1" name="Diffusion b-value YY"/>
+        <entry group="0018" element="9606" keyword="DiffusionBValueYZ" vr="FD" vm="1" name="Diffusion b-value YZ"/>
+        <entry group="0018" element="9607" keyword="DiffusionBValueZZ" vr="FD" vm="1" name="Diffusion b-value ZZ"/>
+        <entry group="0018" element="9621" keyword="FunctionalMRSequence" vr="SQ" vm="1" name="Functional MR Sequence"/>
+        <entry group="0018" element="9622" keyword="FunctionalSettlingPhaseFramesPresent" vr="CS" vm="1" name="Functional Settling Phase Frames Present"/>
+        <entry group="0018" element="9623" keyword="FunctionalSyncPulse" vr="DT" vm="1" name="Functional Sync Pulse"/>
+        <entry group="0018" element="9624" keyword="SettlingPhaseFrame" vr="CS" vm="1" name="Settling Phase Frame"/>
+        <entry group="0018" element="9701" keyword="DecayCorrectionDateTime" vr="DT" vm="1" name="Decay Correction DateTime"/>
+        <entry group="0018" element="9715" keyword="StartDensityThreshold" vr="FD" vm="1" name="Start Density Threshold"/>
+        <entry group="0018" element="9716" keyword="StartRelativeDensityDifferenceThreshold" vr="FD" vm="1" name="Start Relative Density Difference Threshold"/>
+        <entry group="0018" element="9717" keyword="StartCardiacTriggerCountThreshold" vr="FD" vm="1" name="Start Cardiac Trigger Count Threshold"/>
+        <entry group="0018" element="9718" keyword="StartRespiratoryTriggerCountThreshold" vr="FD" vm="1" name="Start Respiratory Trigger Count Threshold"/>
+        <entry group="0018" element="9719" keyword="TerminationCountsThreshold" vr="FD" vm="1" name="Termination Counts Threshold"/>
+        <entry group="0018" element="9720" keyword="TerminationDensityThreshold" vr="FD" vm="1" name="Termination Density Threshold"/>
+        <entry group="0018" element="9721" keyword="TerminationRelativeDensityThreshold" vr="FD" vm="1" name="Termination Relative Density Threshold"/>
+        <entry group="0018" element="9722" keyword="TerminationTimeThreshold" vr="FD" vm="1" name="Termination Time Threshold"/>
+        <entry group="0018" element="9723" keyword="TerminationCardiacTriggerCountThreshold" vr="FD" vm="1" name="Termination Cardiac Trigger Count Threshold"/>
+        <entry group="0018" element="9724" keyword="TerminationRespiratoryTriggerCountThreshold" vr="FD" vm="1" name="Termination Respiratory Trigger Count Threshold"/>
+        <entry group="0018" element="9725" keyword="DetectorGeometry" vr="CS" vm="1" name="Detector Geometry"/>
+        <entry group="0018" element="9726" keyword="TransverseDetectorSeparation" vr="FD" vm="1" name="Transverse Detector Separation"/>
+        <entry group="0018" element="9727" keyword="AxialDetectorDimension" vr="FD" vm="1" name="Axial Detector Dimension"/>
+        <entry group="0018" element="9729" keyword="RadiopharmaceuticalAgentNumber" vr="US" vm="1" name="Radiopharmaceutical Agent Number"/>
+        <entry group="0018" element="9732" keyword="PETFrameAcquisitionSequence" vr="SQ" vm="1" name="PET Frame Acquisition Sequence"/>
+        <entry group="0018" element="9733" keyword="PETDetectorMotionDetailsSequence" vr="SQ" vm="1" name="PET Detector Motion Details Sequence"/>
+        <entry group="0018" element="9734" keyword="PETTableDynamicsSequence" vr="SQ" vm="1" name="PET Table Dynamics Sequence"/>
+        <entry group="0018" element="9735" keyword="PETPositionSequence" vr="SQ" vm="1" name="PET Position Sequence"/>
+        <entry group="0018" element="9736" keyword="PETFrameCorrectionFactorsSequence" vr="SQ" vm="1" name="PET Frame Correction Factors Sequence"/>
+        <entry group="0018" element="9737" keyword="RadiopharmaceuticalUsageSequence" vr="SQ" vm="1" name="Radiopharmaceutical Usage Sequence"/>
+        <entry group="0018" element="9738" keyword="AttenuationCorrectionSource" vr="CS" vm="1" name="Attenuation Correction Source"/>
+        <entry group="0018" element="9739" keyword="NumberOfIterations" vr="US" vm="1" name="Number of Iterations"/>
+        <entry group="0018" element="9740" keyword="NumberOfSubsets" vr="US" vm="1" name="Number of Subsets"/>
+        <entry group="0018" element="9749" keyword="PETReconstructionSequence" vr="SQ" vm="1" name="PET Reconstruction Sequence"/>
+        <entry group="0018" element="9751" keyword="PETFrameTypeSequence" vr="SQ" vm="1" name="PET Frame Type Sequence"/>
+        <entry group="0018" element="9755" keyword="TimeOfFlightInformationUsed" vr="CS" vm="1" name="Time of Flight Information Used"/>
+        <entry group="0018" element="9756" keyword="ReconstructionType" vr="CS" vm="1" name="Reconstruction Type"/>
+        <entry group="0018" element="9758" keyword="DecayCorrected" vr="CS" vm="1" name="Decay Corrected"/>
+        <entry group="0018" element="9759" keyword="AttenuationCorrected" vr="CS" vm="1" name="Attenuation Corrected"/>
+        <entry group="0018" element="9760" keyword="ScatterCorrected" vr="CS" vm="1" name="Scatter Corrected"/>
+        <entry group="0018" element="9761" keyword="DeadTimeCorrected" vr="CS" vm="1" name="Dead Time Corrected"/>
+        <entry group="0018" element="9762" keyword="GantryMotionCorrected" vr="CS" vm="1" name="Gantry Motion Corrected"/>
+        <entry group="0018" element="9763" keyword="PatientMotionCorrected" vr="CS" vm="1" name="Patient Motion Corrected"/>
+        <entry group="0018" element="9764" keyword="CountLossNormalizationCorrected" vr="CS" vm="1" name="Count Loss Normalization Corrected"/>
+        <entry group="0018" element="9765" keyword="RandomsCorrected" vr="CS" vm="1" name="Randoms Corrected"/>
+        <entry group="0018" element="9766" keyword="NonUniformRadialSamplingCorrected" vr="CS" vm="1" name="Non-uniform Radial Sampling Corrected"/>
+        <entry group="0018" element="9767" keyword="SensitivityCalibrated" vr="CS" vm="1" name="Sensitivity Calibrated"/>
+        <entry group="0018" element="9768" keyword="DetectorNormalizationCorrection" vr="CS" vm="1" name="Detector Normalization Correction"/>
+        <entry group="0018" element="9769" keyword="IterativeReconstructionMethod" vr="CS" vm="1" name="Iterative Reconstruction Method"/>
+        <entry group="0018" element="9770" keyword="AttenuationCorrectionTemporalRelationship" vr="CS" vm="1" name="Attenuation Correction Temporal Relationship"/>
+        <entry group="0018" element="9771" keyword="PatientPhysiologicalStateSequence" vr="SQ" vm="1" name="Patient Physiological State Sequence"/>
+        <entry group="0018" element="9772" keyword="PatientPhysiologicalStateCodeSequence" vr="SQ" vm="1" name="Patient Physiological State Code Sequence"/>
+        <entry group="0018" element="9801" keyword="DepthsOfFocus" vr="FD" vm="1-n" name="Depth(s) of Focus"/>
+        <entry group="0018" element="9803" keyword="ExcludedIntervalsSequence" vr="SQ" vm="1" name="Excluded Intervals Sequence"/>
+        <entry group="0018" element="9804" keyword="ExclusionStartDateTime" vr="DT" vm="1" name="Exclusion Start DateTime"/>
+        <entry group="0018" element="9805" keyword="ExclusionDuration" vr="FD" vm="1" name="Exclusion Duration"/>
+        <entry group="0018" element="9806" keyword="USImageDescriptionSequence" vr="SQ" vm="1" name="US Image Description Sequence"/>
+        <entry group="0018" element="9807" keyword="ImageDataTypeSequence" vr="SQ" vm="1" name="Image Data Type Sequence"/>
+        <entry group="0018" element="9808" keyword="DataType" vr="CS" vm="1" name="Data Type"/>
+        <entry group="0018" element="9809" keyword="TransducerScanPatternCodeSequence" vr="SQ" vm="1" name="Transducer Scan Pattern Code Sequence"/>
+        <entry group="0018" element="980b" keyword="AliasedDataType" vr="CS" vm="1" name="Aliased Data Type"/>
+        <entry group="0018" element="980c" keyword="PositionMeasuringDeviceUsed" vr="CS" vm="1" name="Position Measuring Device Used"/>
+        <entry group="0018" element="980d" keyword="TransducerGeometryCodeSequence" vr="SQ" vm="1" name="Transducer Geometry Code Sequence"/>
+        <entry group="0018" element="980e" keyword="TransducerBeamSteeringCodeSequence" vr="SQ" vm="1" name="Transducer Beam Steering Code Sequence"/>
+        <entry group="0018" element="980f" keyword="TransducerApplicationCodeSequence" vr="SQ" vm="1" name="Transducer Application Code Sequence"/>
+        <entry group="0018" element="9810" keyword="ZeroVelocityPixelValue" vr="US_SS" vm="1" name="Zero Velocity Pixel Value"/>
+        <entry group="0018" element="9900" keyword="ReferenceLocationLabel" vr="LO" vm="1" name="Reference Location Label"/>
+        <entry group="0018" element="9901" keyword="ReferenceLocationDescription" vr="UT" vm="1" name="Reference Location Description"/>
+        <entry group="0018" element="9902" keyword="ReferenceBasisCodeSequence" vr="SQ" vm="1" name="Reference Basis Code Sequence"/>
+        <entry group="0018" element="9903" keyword="ReferenceGeometryCodeSequence" vr="SQ" vm="1" name="Reference Geometry Code Sequence"/>
+        <entry group="0018" element="9904" keyword="OffsetDistance" vr="DS" vm="1" name="Offset Distance"/>
+        <entry group="0018" element="9905" keyword="OffsetDirection" vr="CS" vm="1" name="Offset Direction"/>
+        <entry group="0018" element="9906" keyword="PotentialScheduledProtocolCodeSequence" vr="SQ" vm="1" name="Potential Scheduled Protocol Code Sequence"/>
+        <entry group="0018" element="9907" keyword="PotentialRequestedProcedureCodeSequence" vr="SQ" vm="1" name="Potential Requested Procedure Code Sequence"/>
+        <entry group="0018" element="9908" keyword="PotentialReasonsForProcedure" vr="UC" vm="1-n" name="Potential Reasons for Procedure"/>
+        <entry group="0018" element="9909" keyword="PotentialReasonsForProcedureCodeSequence" vr="SQ" vm="1" name="Potential Reasons for Procedure Code Sequence"/>
+        <entry group="0018" element="990a" keyword="PotentialDiagnosticTasks" vr="UC" vm="1-n" name="Potential Diagnostic Tasks"/>
+        <entry group="0018" element="990b" keyword="ContraindicationsCodeSequence" vr="SQ" vm="1" name="Contraindications Code Sequence"/>
+        <entry group="0018" element="990c" keyword="ReferencedDefinedProtocolSequence" vr="SQ" vm="1" name="Referenced Defined Protocol Sequence"/>
+        <entry group="0018" element="990d" keyword="ReferencedPerformedProtocolSequence" vr="SQ" vm="1" name="Referenced Performed Protocol Sequence"/>
+        <entry group="0018" element="990e" keyword="PredecessorProtocolSequence" vr="SQ" vm="1" name="Predecessor Protocol Sequence"/>
+        <entry group="0018" element="990f" keyword="ProtocolPlanningInformation" vr="UT" vm="1" name="Protocol Planning Information"/>
+        <entry group="0018" element="9910" keyword="ProtocolDesignRationale" vr="UT" vm="1" name="Protocol Design Rationale"/>
+        <entry group="0018" element="9911" keyword="PatientSpecificationSequence" vr="SQ" vm="1" name="Patient Specification Sequence"/>
+        <entry group="0018" element="9912" keyword="ModelSpecificationSequence" vr="SQ" vm="1" name="Model Specification Sequence"/>
+        <entry group="0018" element="9913" keyword="ParametersSpecificationSequence" vr="SQ" vm="1" name="Parameters Specification Sequence"/>
+        <entry group="0018" element="9914" keyword="InstructionSequence" vr="SQ" vm="1" name="Instruction Sequence"/>
+        <entry group="0018" element="9915" keyword="InstructionIndex" vr="US" vm="1" name="Instruction Index"/>
+        <entry group="0018" element="9916" keyword="InstructionText" vr="LO" vm="1" name="Instruction Text"/>
+        <entry group="0018" element="9917" keyword="InstructionDescription" vr="UT" vm="1" name="Instruction Description"/>
+        <entry group="0018" element="9918" keyword="InstructionPerformedFlag" vr="CS" vm="1" name="Instruction Performed Flag"/>
+        <entry group="0018" element="9919" keyword="InstructionPerformedDateTime" vr="DT" vm="1" name="Instruction Performed DateTime"/>
+        <entry group="0018" element="991a" keyword="InstructionPerformanceComment" vr="UT" vm="1" name="Instruction Performance Comment"/>
+        <entry group="0018" element="991b" keyword="PatientPositioningInstructionSequence" vr="SQ" vm="1" name="Patient Positioning Instruction Sequence"/>
+        <entry group="0018" element="991c" keyword="PositioningMethodCodeSequence" vr="SQ" vm="1" name="Positioning Method Code Sequence"/>
+        <entry group="0018" element="991d" keyword="PositioningLandmarkSequence" vr="SQ" vm="1" name="Positioning Landmark Sequence"/>
+        <entry group="0018" element="991e" keyword="TargetFrameOfReferenceUID" vr="UI" vm="1" name="Target Frame of Reference UID"/>
+        <entry group="0018" element="991f" keyword="AcquisitionProtocolElementSpecificationSequence" vr="SQ" vm="1" name="Acquisition Protocol Element Specification Sequence"/>
+        <entry group="0018" element="9920" keyword="AcquisitionProtocolElementSequence" vr="SQ" vm="1" name="Acquisition Protocol Element Sequence"/>
+        <entry group="0018" element="9921" keyword="ProtocolElementNumber" vr="US" vm="1" name="Protocol Element Number"/>
+        <entry group="0018" element="9922" keyword="ProtocolElementName" vr="LO" vm="1" name="Protocol Element Name"/>
+        <entry group="0018" element="9923" keyword="ProtocolElementCharacteristicsSummary" vr="UT" vm="1" name="Protocol Element Characteristics Summary"/>
+        <entry group="0018" element="9924" keyword="ProtocolElementPurpose" vr="UT" vm="1" name="Protocol Element Purpose"/>
+        <entry group="0018" element="9930" keyword="AcquisitionMotion" vr="CS" vm="1" name="Acquisition Motion"/>
+        <entry group="0018" element="9931" keyword="AcquisitionStartLocationSequence" vr="SQ" vm="1" name="Acquisition Start Location Sequence"/>
+        <entry group="0018" element="9932" keyword="AcquisitionEndLocationSequence" vr="SQ" vm="1" name="Acquisition End Location Sequence"/>
+        <entry group="0018" element="9933" keyword="ReconstructionProtocolElementSpecificationSequence" vr="SQ" vm="1" name="Reconstruction Protocol Element Specification Sequence"/>
+        <entry group="0018" element="9934" keyword="ReconstructionProtocolElementSequence" vr="SQ" vm="1" name="Reconstruction Protocol Element Sequence"/>
+        <entry group="0018" element="9935" keyword="StorageProtocolElementSpecificationSequence" vr="SQ" vm="1" name="Storage Protocol Element Specification Sequence"/>
+        <entry group="0018" element="9936" keyword="StorageProtocolElementSequence" vr="SQ" vm="1" name="Storage Protocol Element Sequence"/>
+        <entry group="0018" element="9937" keyword="RequestedSeriesDescription" vr="LO" vm="1" name="Requested Series Description"/>
+        <entry group="0018" element="9938" keyword="SourceAcquisitionProtocolElementNumber" vr="US" vm="1-n" name="Source Acquisition Protocol Element Number"/>
+        <entry group="0018" element="9939" keyword="SourceAcquisitionBeamNumber" vr="US" vm="1-n" name="Source Acquisition Beam Number"/>
+        <entry group="0018" element="993a" keyword="SourceReconstructionProtocolElementNumber" vr="US" vm="1-n" name="Source Reconstruction Protocol Element Number"/>
+        <entry group="0018" element="993b" keyword="ReconstructionStartLocationSequence" vr="SQ" vm="1" name="Reconstruction Start Location Sequence"/>
+        <entry group="0018" element="993c" keyword="ReconstructionEndLocationSequence" vr="SQ" vm="1" name="Reconstruction End Location Sequence"/>
+        <entry group="0018" element="993d" keyword="ReconstructionAlgorithmSequence" vr="SQ" vm="1" name="Reconstruction Algorithm Sequence"/>
+        <entry group="0018" element="993e" keyword="ReconstructionTargetCenterLocationSequence" vr="SQ" vm="1" name="Reconstruction Target Center Location Sequence"/>
+        <entry group="0018" element="9941" keyword="ImageFilterDescription" vr="UT" vm="1" name="Image Filter Description"/>
+        <entry group="0018" element="9942" keyword="CTDIvolNotificationTrigger" vr="FD" vm="1" name="CTDIvol Notification Trigger"/>
+        <entry group="0018" element="9943" keyword="DLPNotificationTrigger" vr="FD" vm="1" name="DLP Notification Trigger"/>
+        <entry group="0018" element="9944" keyword="AutoKVPSelectionType" vr="CS" vm="1" name="Auto KVP Selection Type"/>
+        <entry group="0018" element="9945" keyword="AutoKVPUpperBound" vr="FD" vm="1" name="Auto KVP Upper Bound"/>
+        <entry group="0018" element="9946" keyword="AutoKVPLowerBound" vr="FD" vm="1" name="Auto KVP Lower Bound"/>
+        <entry group="0018" element="9947" keyword="ProtocolDefinedPatientPosition" vr="CS" vm="1" name="Protocol Defined Patient Position"/>
+        <entry group="0018" element="a001" keyword="ContributingEquipmentSequence" vr="SQ" vm="1" name="Contributing Equipment Sequence"/>
+        <entry group="0018" element="a002" keyword="ContributionDateTime" vr="DT" vm="1" name="Contribution DateTime"/>
+        <entry group="0018" element="a003" keyword="ContributionDescription" vr="ST" vm="1" name="Contribution Description"/>
+        <entry group="0020" element="000d" keyword="StudyInstanceUID" vr="UI" vm="1" name="Study Instance UID"/>
+        <entry group="0020" element="000e" keyword="SeriesInstanceUID" vr="UI" vm="1" name="Series Instance UID"/>
+        <entry group="0020" element="0010" keyword="StudyID" vr="SH" vm="1" name="Study ID"/>
+        <entry group="0020" element="0011" keyword="SeriesNumber" vr="IS" vm="1" name="Series Number"/>
+        <entry group="0020" element="0012" keyword="AcquisitionNumber" vr="IS" vm="1" name="Acquisition Number"/>
+        <entry group="0020" element="0013" keyword="InstanceNumber" vr="IS" vm="1" name="Instance Number"/>
+        <entry group="0020" element="0014" keyword="IsotopeNumber" vr="IS" vm="1" retired="true" name="Isotope Number"/>
+        <entry group="0020" element="0015" keyword="PhaseNumber" vr="IS" vm="1" retired="true" name="Phase Number"/>
+        <entry group="0020" element="0016" keyword="IntervalNumber" vr="IS" vm="1" retired="true" name="Interval Number"/>
+        <entry group="0020" element="0017" keyword="TimeSlotNumber" vr="IS" vm="1" retired="true" name="Time Slot Number"/>
+        <entry group="0020" element="0018" keyword="AngleNumber" vr="IS" vm="1" retired="true" name="Angle Number"/>
+        <entry group="0020" element="0019" keyword="ItemNumber" vr="IS" vm="1" name="Item Number"/>
+        <entry group="0020" element="0020" keyword="PatientOrientation" vr="CS" vm="2" name="Patient Orientation"/>
+        <entry group="0020" element="0022" keyword="OverlayNumber" vr="IS" vm="1" retired="true" name="Overlay Number"/>
+        <entry group="0020" element="0024" keyword="CurveNumber" vr="IS" vm="1" retired="true" name="Curve Number"/>
+        <entry group="0020" element="0026" keyword="LUTNumber" vr="IS" vm="1" retired="true" name="LUT Number"/>
+        <entry group="0020" element="0030" keyword="ImagePosition" vr="DS" vm="3" retired="true" name="Image Position"/>
+        <entry group="0020" element="0032" keyword="ImagePositionPatient" vr="DS" vm="3" name="Image Position (Patient)"/>
+        <entry group="0020" element="0035" keyword="ImageOrientation" vr="DS" vm="6" retired="true" name="Image Orientation"/>
+        <entry group="0020" element="0037" keyword="ImageOrientationPatient" vr="DS" vm="6" name="Image Orientation (Patient)"/>
+        <entry group="0020" element="0050" keyword="Location" vr="DS" vm="1" retired="true" name="Location"/>
+        <entry group="0020" element="0052" keyword="FrameOfReferenceUID" vr="UI" vm="1" name="Frame of Reference UID"/>
+        <entry group="0020" element="0060" keyword="Laterality" vr="CS" vm="1" name="Laterality"/>
+        <entry group="0020" element="0062" keyword="ImageLaterality" vr="CS" vm="1" name="Image Laterality"/>
+        <entry group="0020" element="0070" keyword="ImageGeometryType" vr="LO" vm="1" retired="true" name="Image Geometry Type"/>
+        <entry group="0020" element="0080" keyword="MaskingImage" vr="CS" vm="1-n" retired="true" name="Masking Image"/>
+        <entry group="0020" element="00aa" keyword="ReportNumber" vr="IS" vm="1" retired="true" name="Report Number"/>
+        <entry group="0020" element="0100" keyword="TemporalPositionIdentifier" vr="IS" vm="1" name="Temporal Position Identifier"/>
+        <entry group="0020" element="0105" keyword="NumberOfTemporalPositions" vr="IS" vm="1" name="Number of Temporal Positions"/>
+        <entry group="0020" element="0110" keyword="TemporalResolution" vr="DS" vm="1" name="Temporal Resolution"/>
+        <entry group="0020" element="0200" keyword="SynchronizationFrameOfReferenceUID" vr="UI" vm="1" name="Synchronization Frame of Reference UID"/>
+        <entry group="0020" element="0242" keyword="SOPInstanceUIDOfConcatenationSource" vr="UI" vm="1" name="SOP Instance UID of Concatenation Source"/>
+        <entry group="0020" element="1000" keyword="SeriesInStudy" vr="IS" vm="1" retired="true" name="Series in Study"/>
+        <entry group="0020" element="1001" keyword="AcquisitionsInSeries" vr="IS" vm="1" retired="true" name="Acquisitions in Series"/>
+        <entry group="0020" element="1002" keyword="ImagesInAcquisition" vr="IS" vm="1" name="Images in Acquisition"/>
+        <entry group="0020" element="1003" keyword="ImagesInSeries" vr="IS" vm="1" retired="true" name="Images in Series"/>
+        <entry group="0020" element="1004" keyword="AcquisitionsInStudy" vr="IS" vm="1" retired="true" name="Acquisitions in Study"/>
+        <entry group="0020" element="1005" keyword="ImagesInStudy" vr="IS" vm="1" retired="true" name="Images in Study"/>
+        <entry group="0020" element="1020" keyword="Reference" vr="LO" vm="1-n" retired="true" name="Reference"/>
+        <entry group="0020" element="103f" keyword="TargetPositionReferenceIndicator" vr="LO" vm="1" name="Target Position Reference Indicator"/>
+        <entry group="0020" element="1040" keyword="PositionReferenceIndicator" vr="LO" vm="1" name="Position Reference Indicator"/>
+        <entry group="0020" element="1041" keyword="SliceLocation" vr="DS" vm="1" name="Slice Location"/>
+        <entry group="0020" element="1070" keyword="OtherStudyNumbers" vr="IS" vm="1-n" retired="true" name="Other Study Numbers"/>
+        <entry group="0020" element="1200" keyword="NumberOfPatientRelatedStudies" vr="IS" vm="1" name="Number of Patient Related Studies"/>
+        <entry group="0020" element="1202" keyword="NumberOfPatientRelatedSeries" vr="IS" vm="1" name="Number of Patient Related Series"/>
+        <entry group="0020" element="1204" keyword="NumberOfPatientRelatedInstances" vr="IS" vm="1" name="Number of Patient Related Instances"/>
+        <entry group="0020" element="1206" keyword="NumberOfStudyRelatedSeries" vr="IS" vm="1" name="Number of Study Related Series"/>
+        <entry group="0020" element="1208" keyword="NumberOfStudyRelatedInstances" vr="IS" vm="1" name="Number of Study Related Instances"/>
+        <entry group="0020" element="1209" keyword="NumberOfSeriesRelatedInstances" vr="IS" vm="1" name="Number of Series Related Instances"/>
+        <entry group="0020" element="31xx" keyword="SourceImageIDs" vr="CS" vm="1-n" retired="true" name="Source Image IDs"/>
+        <entry group="0020" element="3401" keyword="ModifyingDeviceID" vr="CS" vm="1" retired="true" name="Modifying Device ID"/>
+        <entry group="0020" element="3402" keyword="ModifiedImageID" vr="CS" vm="1" retired="true" name="Modified Image ID"/>
+        <entry group="0020" element="3403" keyword="ModifiedImageDate" vr="DA" vm="1" retired="true" name="Modified Image Date"/>
+        <entry group="0020" element="3404" keyword="ModifyingDeviceManufacturer" vr="LO" vm="1" retired="true" name="Modifying Device Manufacturer"/>
+        <entry group="0020" element="3405" keyword="ModifiedImageTime" vr="TM" vm="1" retired="true" name="Modified Image Time"/>
+        <entry group="0020" element="3406" keyword="ModifiedImageDescription" vr="LO" vm="1" retired="true" name="Modified Image Description"/>
+        <entry group="0020" element="4000" keyword="ImageComments" vr="LT" vm="1" name="Image Comments"/>
+        <entry group="0020" element="5000" keyword="OriginalImageIdentification" vr="AT" vm="1-n" retired="true" name="Original Image Identification"/>
+        <entry group="0020" element="5002" keyword="OriginalImageIdentificationNomenclature" vr="LO" vm="1-n" retired="true" name="Original Image Identification Nomenclature"/>
+        <entry group="0020" element="9056" keyword="StackID" vr="SH" vm="1" name="Stack ID"/>
+        <entry group="0020" element="9057" keyword="InStackPositionNumber" vr="UL" vm="1" name="In-Stack Position Number"/>
+        <entry group="0020" element="9071" keyword="FrameAnatomySequence" vr="SQ" vm="1" name="Frame Anatomy Sequence"/>
+        <entry group="0020" element="9072" keyword="FrameLaterality" vr="CS" vm="1" name="Frame Laterality"/>
+        <entry group="0020" element="9111" keyword="FrameContentSequence" vr="SQ" vm="1" name="Frame Content Sequence"/>
+        <entry group="0020" element="9113" keyword="PlanePositionSequence" vr="SQ" vm="1" name="Plane Position Sequence"/>
+        <entry group="0020" element="9116" keyword="PlaneOrientationSequence" vr="SQ" vm="1" name="Plane Orientation Sequence"/>
+        <entry group="0020" element="9128" keyword="TemporalPositionIndex" vr="UL" vm="1" name="Temporal Position Index"/>
+        <entry group="0020" element="9153" keyword="NominalCardiacTriggerDelayTime" vr="FD" vm="1" name="Nominal Cardiac Trigger Delay Time"/>
+        <entry group="0020" element="9154" keyword="NominalCardiacTriggerTimePriorToRPeak" vr="FL" vm="1" name="Nominal Cardiac Trigger Time Prior To R-Peak"/>
+        <entry group="0020" element="9155" keyword="ActualCardiacTriggerTimePriorToRPeak" vr="FL" vm="1" name="Actual Cardiac Trigger Time Prior To R-Peak"/>
+        <entry group="0020" element="9156" keyword="FrameAcquisitionNumber" vr="US" vm="1" name="Frame Acquisition Number"/>
+        <entry group="0020" element="9157" keyword="DimensionIndexValues" vr="UL" vm="1-n" name="Dimension Index Values"/>
+        <entry group="0020" element="9158" keyword="FrameComments" vr="LT" vm="1" name="Frame Comments"/>
+        <entry group="0020" element="9161" keyword="ConcatenationUID" vr="UI" vm="1" name="Concatenation UID"/>
+        <entry group="0020" element="9162" keyword="InConcatenationNumber" vr="US" vm="1" name="In-concatenation Number"/>
+        <entry group="0020" element="9163" keyword="InConcatenationTotalNumber" vr="US" vm="1" name="In-concatenation Total Number"/>
+        <entry group="0020" element="9164" keyword="DimensionOrganizationUID" vr="UI" vm="1" name="Dimension Organization UID"/>
+        <entry group="0020" element="9165" keyword="DimensionIndexPointer" vr="AT" vm="1" name="Dimension Index Pointer"/>
+        <entry group="0020" element="9167" keyword="FunctionalGroupPointer" vr="AT" vm="1" name="Functional Group Pointer"/>
+        <entry group="0020" element="9170" keyword="UnassignedSharedConvertedAttributesSequence" vr="SQ" vm="1" name="Unassigned Shared Converted Attributes Sequence"/>
+        <entry group="0020" element="9171" keyword="UnassignedPerFrameConvertedAttributesSequence" vr="SQ" vm="1" name="Unassigned Per-Frame Converted Attributes Sequence"/>
+        <entry group="0020" element="9172" keyword="ConversionSourceAttributesSequence" vr="SQ" vm="1" name="Conversion Source Attributes Sequence"/>
+        <entry group="0020" element="9213" keyword="DimensionIndexPrivateCreator" vr="LO" vm="1" name="Dimension Index Private Creator"/>
+        <entry group="0020" element="9221" keyword="DimensionOrganizationSequence" vr="SQ" vm="1" name="Dimension Organization Sequence"/>
+        <entry group="0020" element="9222" keyword="DimensionIndexSequence" vr="SQ" vm="1" name="Dimension Index Sequence"/>
+        <entry group="0020" element="9228" keyword="ConcatenationFrameOffsetNumber" vr="UL" vm="1" name="Concatenation Frame Offset Number"/>
+        <entry group="0020" element="9238" keyword="FunctionalGroupPrivateCreator" vr="LO" vm="1" name="Functional Group Private Creator"/>
+        <entry group="0020" element="9241" keyword="NominalPercentageOfCardiacPhase" vr="FL" vm="1" name="Nominal Percentage of Cardiac Phase"/>
+        <entry group="0020" element="9245" keyword="NominalPercentageOfRespiratoryPhase" vr="FL" vm="1" name="Nominal Percentage of Respiratory Phase"/>
+        <entry group="0020" element="9246" keyword="StartingRespiratoryAmplitude" vr="FL" vm="1" name="Starting Respiratory Amplitude"/>
+        <entry group="0020" element="9247" keyword="StartingRespiratoryPhase" vr="CS" vm="1" name="Starting Respiratory Phase"/>
+        <entry group="0020" element="9248" keyword="EndingRespiratoryAmplitude" vr="FL" vm="1" name="Ending Respiratory Amplitude"/>
+        <entry group="0020" element="9249" keyword="EndingRespiratoryPhase" vr="CS" vm="1" name="Ending Respiratory Phase"/>
+        <entry group="0020" element="9250" keyword="RespiratoryTriggerType" vr="CS" vm="1" name="Respiratory Trigger Type"/>
+        <entry group="0020" element="9251" keyword="RRIntervalTimeNominal" vr="FD" vm="1" name="R-R Interval Time Nominal"/>
+        <entry group="0020" element="9252" keyword="ActualCardiacTriggerDelayTime" vr="FD" vm="1" name="Actual Cardiac Trigger Delay Time"/>
+        <entry group="0020" element="9253" keyword="RespiratorySynchronizationSequence" vr="SQ" vm="1" name="Respiratory Synchronization Sequence"/>
+        <entry group="0020" element="9254" keyword="RespiratoryIntervalTime" vr="FD" vm="1" name="Respiratory Interval Time"/>
+        <entry group="0020" element="9255" keyword="NominalRespiratoryTriggerDelayTime" vr="FD" vm="1" name="Nominal Respiratory Trigger Delay Time"/>
+        <entry group="0020" element="9256" keyword="RespiratoryTriggerDelayThreshold" vr="FD" vm="1" name="Respiratory Trigger Delay Threshold"/>
+        <entry group="0020" element="9257" keyword="ActualRespiratoryTriggerDelayTime" vr="FD" vm="1" name="Actual Respiratory Trigger Delay Time"/>
+        <entry group="0020" element="9301" keyword="ImagePositionVolume" vr="FD" vm="3" name="Image Position (Volume)"/>
+        <entry group="0020" element="9302" keyword="ImageOrientationVolume" vr="FD" vm="6" name="Image Orientation (Volume)"/>
+        <entry group="0020" element="9307" keyword="UltrasoundAcquisitionGeometry" vr="CS" vm="1" name="Ultrasound Acquisition Geometry"/>
+        <entry group="0020" element="9308" keyword="ApexPosition" vr="FD" vm="3" name="Apex Position"/>
+        <entry group="0020" element="9309" keyword="VolumeToTransducerMappingMatrix" vr="FD" vm="16" name="Volume to Transducer Mapping Matrix"/>
+        <entry group="0020" element="930a" keyword="VolumeToTableMappingMatrix" vr="FD" vm="16" name="Volume to Table Mapping Matrix"/>
+        <entry group="0020" element="930b" keyword="VolumeToTransducerRelationship" vr="CS" vm="1" name="Volume to Transducer Relationship"/>
+        <entry group="0020" element="930c" keyword="PatientFrameOfReferenceSource" vr="CS" vm="1" name="Patient Frame of Reference Source"/>
+        <entry group="0020" element="930d" keyword="TemporalPositionTimeOffset" vr="FD" vm="1" name="Temporal Position Time Offset"/>
+        <entry group="0020" element="930e" keyword="PlanePositionVolumeSequence" vr="SQ" vm="1" name="Plane Position (Volume) Sequence"/>
+        <entry group="0020" element="930f" keyword="PlaneOrientationVolumeSequence" vr="SQ" vm="1" name="Plane Orientation (Volume) Sequence"/>
+        <entry group="0020" element="9310" keyword="TemporalPositionSequence" vr="SQ" vm="1" name="Temporal Position Sequence"/>
+        <entry group="0020" element="9311" keyword="DimensionOrganizationType" vr="CS" vm="1" name="Dimension Organization Type"/>
+        <entry group="0020" element="9312" keyword="VolumeFrameOfReferenceUID" vr="UI" vm="1" name="Volume Frame of Reference UID"/>
+        <entry group="0020" element="9313" keyword="TableFrameOfReferenceUID" vr="UI" vm="1" name="Table Frame of Reference UID"/>
+        <entry group="0020" element="9421" keyword="DimensionDescriptionLabel" vr="LO" vm="1" name="Dimension Description Label"/>
+        <entry group="0020" element="9450" keyword="PatientOrientationInFrameSequence" vr="SQ" vm="1" name="Patient Orientation in Frame Sequence"/>
+        <entry group="0020" element="9453" keyword="FrameLabel" vr="LO" vm="1" name="Frame Label"/>
+        <entry group="0020" element="9518" keyword="AcquisitionIndex" vr="US" vm="1-n" name="Acquisition Index"/>
+        <entry group="0020" element="9529" keyword="ContributingSOPInstancesReferenceSequence" vr="SQ" vm="1" name="Contributing SOP Instances Reference Sequence"/>
+        <entry group="0020" element="9536" keyword="ReconstructionIndex" vr="US" vm="1" name="Reconstruction Index"/>
+        <entry group="0022" element="0001" keyword="LightPathFilterPassThroughWavelength" vr="US" vm="1" name="Light Path Filter Pass-Through Wavelength"/>
+        <entry group="0022" element="0002" keyword="LightPathFilterPassBand" vr="US" vm="2" name="Light Path Filter Pass Band"/>
+        <entry group="0022" element="0003" keyword="ImagePathFilterPassThroughWavelength" vr="US" vm="1" name="Image Path Filter Pass-Through Wavelength"/>
+        <entry group="0022" element="0004" keyword="ImagePathFilterPassBand" vr="US" vm="2" name="Image Path Filter Pass Band"/>
+        <entry group="0022" element="0005" keyword="PatientEyeMovementCommanded" vr="CS" vm="1" name="Patient Eye Movement Commanded"/>
+        <entry group="0022" element="0006" keyword="PatientEyeMovementCommandCodeSequence" vr="SQ" vm="1" name="Patient Eye Movement Command Code Sequence"/>
+        <entry group="0022" element="0007" keyword="SphericalLensPower" vr="FL" vm="1" name="Spherical Lens Power"/>
+        <entry group="0022" element="0008" keyword="CylinderLensPower" vr="FL" vm="1" name="Cylinder Lens Power"/>
+        <entry group="0022" element="0009" keyword="CylinderAxis" vr="FL" vm="1" name="Cylinder Axis"/>
+        <entry group="0022" element="000a" keyword="EmmetropicMagnification" vr="FL" vm="1" name="Emmetropic Magnification"/>
+        <entry group="0022" element="000b" keyword="IntraOcularPressure" vr="FL" vm="1" name="Intra Ocular Pressure"/>
+        <entry group="0022" element="000c" keyword="HorizontalFieldOfView" vr="FL" vm="1" name="Horizontal Field of View"/>
+        <entry group="0022" element="000d" keyword="PupilDilated" vr="CS" vm="1" name="Pupil Dilated"/>
+        <entry group="0022" element="000e" keyword="DegreeOfDilation" vr="FL" vm="1" name="Degree of Dilation"/>
+        <entry group="0022" element="0010" keyword="StereoBaselineAngle" vr="FL" vm="1" name="Stereo Baseline Angle"/>
+        <entry group="0022" element="0011" keyword="StereoBaselineDisplacement" vr="FL" vm="1" name="Stereo Baseline Displacement"/>
+        <entry group="0022" element="0012" keyword="StereoHorizontalPixelOffset" vr="FL" vm="1" name="Stereo Horizontal Pixel Offset"/>
+        <entry group="0022" element="0013" keyword="StereoVerticalPixelOffset" vr="FL" vm="1" name="Stereo Vertical Pixel Offset"/>
+        <entry group="0022" element="0014" keyword="StereoRotation" vr="FL" vm="1" name="Stereo Rotation"/>
+        <entry group="0022" element="0015" keyword="AcquisitionDeviceTypeCodeSequence" vr="SQ" vm="1" name="Acquisition Device Type Code Sequence"/>
+        <entry group="0022" element="0016" keyword="IlluminationTypeCodeSequence" vr="SQ" vm="1" name="Illumination Type Code Sequence"/>
+        <entry group="0022" element="0017" keyword="LightPathFilterTypeStackCodeSequence" vr="SQ" vm="1" name="Light Path Filter Type Stack Code Sequence"/>
+        <entry group="0022" element="0018" keyword="ImagePathFilterTypeStackCodeSequence" vr="SQ" vm="1" name="Image Path Filter Type Stack Code Sequence"/>
+        <entry group="0022" element="0019" keyword="LensesCodeSequence" vr="SQ" vm="1" name="Lenses Code Sequence"/>
+        <entry group="0022" element="001a" keyword="ChannelDescriptionCodeSequence" vr="SQ" vm="1" name="Channel Description Code Sequence"/>
+        <entry group="0022" element="001b" keyword="RefractiveStateSequence" vr="SQ" vm="1" name="Refractive State Sequence"/>
+        <entry group="0022" element="001c" keyword="MydriaticAgentCodeSequence" vr="SQ" vm="1" name="Mydriatic Agent Code Sequence"/>
+        <entry group="0022" element="001d" keyword="RelativeImagePositionCodeSequence" vr="SQ" vm="1" name="Relative Image Position Code Sequence"/>
+        <entry group="0022" element="001e" keyword="CameraAngleOfView" vr="FL" vm="1" name="Camera Angle of View"/>
+        <entry group="0022" element="0020" keyword="StereoPairsSequence" vr="SQ" vm="1" name="Stereo Pairs Sequence"/>
+        <entry group="0022" element="0021" keyword="LeftImageSequence" vr="SQ" vm="1" name="Left Image Sequence"/>
+        <entry group="0022" element="0022" keyword="RightImageSequence" vr="SQ" vm="1" name="Right Image Sequence"/>
+        <entry group="0022" element="0028" keyword="StereoPairsPresent" vr="CS" vm="1" name="Stereo Pairs Present"/>
+        <entry group="0022" element="0030" keyword="AxialLengthOfTheEye" vr="FL" vm="1" name="Axial Length of the Eye"/>
+        <entry group="0022" element="0031" keyword="OphthalmicFrameLocationSequence" vr="SQ" vm="1" name="Ophthalmic Frame Location Sequence"/>
+        <entry group="0022" element="0032" keyword="ReferenceCoordinates" vr="FL" vm="2-2n" name="Reference Coordinates"/>
+        <entry group="0022" element="0035" keyword="DepthSpatialResolution" vr="FL" vm="1" name="Depth Spatial Resolution"/>
+        <entry group="0022" element="0036" keyword="MaximumDepthDistortion" vr="FL" vm="1" name="Maximum Depth Distortion"/>
+        <entry group="0022" element="0037" keyword="AlongScanSpatialResolution" vr="FL" vm="1" name="Along-scan Spatial Resolution"/>
+        <entry group="0022" element="0038" keyword="MaximumAlongScanDistortion" vr="FL" vm="1" name="Maximum Along-scan Distortion"/>
+        <entry group="0022" element="0039" keyword="OphthalmicImageOrientation" vr="CS" vm="1" name="Ophthalmic Image Orientation"/>
+        <entry group="0022" element="0041" keyword="DepthOfTransverseImage" vr="FL" vm="1" name="Depth of Transverse Image"/>
+        <entry group="0022" element="0042" keyword="MydriaticAgentConcentrationUnitsSequence" vr="SQ" vm="1" name="Mydriatic Agent Concentration Units Sequence"/>
+        <entry group="0022" element="0048" keyword="AcrossScanSpatialResolution" vr="FL" vm="1" name="Across-scan Spatial Resolution"/>
+        <entry group="0022" element="0049" keyword="MaximumAcrossScanDistortion" vr="FL" vm="1" name="Maximum Across-scan Distortion"/>
+        <entry group="0022" element="004e" keyword="MydriaticAgentConcentration" vr="DS" vm="1" name="Mydriatic Agent Concentration"/>
+        <entry group="0022" element="0055" keyword="IlluminationWaveLength" vr="FL" vm="1" name="Illumination Wave Length"/>
+        <entry group="0022" element="0056" keyword="IlluminationPower" vr="FL" vm="1" name="Illumination Power"/>
+        <entry group="0022" element="0057" keyword="IlluminationBandwidth" vr="FL" vm="1" name="Illumination Bandwidth"/>
+        <entry group="0022" element="0058" keyword="MydriaticAgentSequence" vr="SQ" vm="1" name="Mydriatic Agent Sequence"/>
+        <entry group="0022" element="1007" keyword="OphthalmicAxialMeasurementsRightEyeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Measurements Right Eye Sequence"/>
+        <entry group="0022" element="1008" keyword="OphthalmicAxialMeasurementsLeftEyeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Measurements Left Eye Sequence"/>
+        <entry group="0022" element="1009" keyword="OphthalmicAxialMeasurementsDeviceType" vr="CS" vm="1" name="Ophthalmic Axial Measurements Device Type"/>
+        <entry group="0022" element="1010" keyword="OphthalmicAxialLengthMeasurementsType" vr="CS" vm="1" name="Ophthalmic Axial Length Measurements Type"/>
+        <entry group="0022" element="1012" keyword="OphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Sequence"/>
+        <entry group="0022" element="1019" keyword="OphthalmicAxialLength" vr="FL" vm="1" name="Ophthalmic Axial Length"/>
+        <entry group="0022" element="1024" keyword="LensStatusCodeSequence" vr="SQ" vm="1" name="Lens Status Code Sequence"/>
+        <entry group="0022" element="1025" keyword="VitreousStatusCodeSequence" vr="SQ" vm="1" name="Vitreous Status Code Sequence"/>
+        <entry group="0022" element="1028" keyword="IOLFormulaCodeSequence" vr="SQ" vm="1" name="IOL Formula Code Sequence"/>
+        <entry group="0022" element="1029" keyword="IOLFormulaDetail" vr="LO" vm="1" name="IOL Formula Detail"/>
+        <entry group="0022" element="1033" keyword="KeratometerIndex" vr="FL" vm="1" name="Keratometer Index"/>
+        <entry group="0022" element="1035" keyword="SourceOfOphthalmicAxialLengthCodeSequence" vr="SQ" vm="1" name="Source of Ophthalmic Axial Length Code Sequence"/>
+        <entry group="0022" element="1037" keyword="TargetRefraction" vr="FL" vm="1" name="Target Refraction"/>
+        <entry group="0022" element="1039" keyword="RefractiveProcedureOccurred" vr="CS" vm="1" name="Refractive Procedure Occurred"/>
+        <entry group="0022" element="1040" keyword="RefractiveSurgeryTypeCodeSequence" vr="SQ" vm="1" name="Refractive Surgery Type Code Sequence"/>
+        <entry group="0022" element="1044" keyword="OphthalmicUltrasoundMethodCodeSequence" vr="SQ" vm="1" name="Ophthalmic Ultrasound Method Code Sequence"/>
+        <entry group="0022" element="1050" keyword="OphthalmicAxialLengthMeasurementsSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Sequence"/>
+        <entry group="0022" element="1053" keyword="IOLPower" vr="FL" vm="1" name="IOL Power"/>
+        <entry group="0022" element="1054" keyword="PredictedRefractiveError" vr="FL" vm="1" name="Predicted Refractive Error"/>
+        <entry group="0022" element="1059" keyword="OphthalmicAxialLengthVelocity" vr="FL" vm="1" name="Ophthalmic Axial Length Velocity"/>
+        <entry group="0022" element="1065" keyword="LensStatusDescription" vr="LO" vm="1" name="Lens Status Description"/>
+        <entry group="0022" element="1066" keyword="VitreousStatusDescription" vr="LO" vm="1" name="Vitreous Status Description"/>
+        <entry group="0022" element="1090" keyword="IOLPowerSequence" vr="SQ" vm="1" name="IOL Power Sequence"/>
+        <entry group="0022" element="1092" keyword="LensConstantSequence" vr="SQ" vm="1" name="Lens Constant Sequence"/>
+        <entry group="0022" element="1093" keyword="IOLManufacturer" vr="LO" vm="1" name="IOL Manufacturer"/>
+        <entry group="0022" element="1094" keyword="LensConstantDescription" vr="LO" vm="1" retired="true" name="Lens Constant Description"/>
+        <entry group="0022" element="1095" keyword="ImplantName" vr="LO" vm="1" name="Implant Name"/>
+        <entry group="0022" element="1096" keyword="KeratometryMeasurementTypeCodeSequence" vr="SQ" vm="1" name="Keratometry Measurement Type Code Sequence"/>
+        <entry group="0022" element="1097" keyword="ImplantPartNumber" vr="LO" vm="1" name="Implant Part Number"/>
+        <entry group="0022" element="1100" keyword="ReferencedOphthalmicAxialMeasurementsSequence" vr="SQ" vm="1" name="Referenced Ophthalmic Axial Measurements Sequence"/>
+        <entry group="0022" element="1101" keyword="OphthalmicAxialLengthMeasurementsSegmentNameCodeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Segment Name Code Sequence"/>
+        <entry group="0022" element="1103" keyword="RefractiveErrorBeforeRefractiveSurgeryCodeSequence" vr="SQ" vm="1" name="Refractive Error Before Refractive Surgery Code Sequence"/>
+        <entry group="0022" element="1121" keyword="IOLPowerForExactEmmetropia" vr="FL" vm="1" name="IOL Power For Exact Emmetropia"/>
+        <entry group="0022" element="1122" keyword="IOLPowerForExactTargetRefraction" vr="FL" vm="1" name="IOL Power For Exact Target Refraction"/>
+        <entry group="0022" element="1125" keyword="AnteriorChamberDepthDefinitionCodeSequence" vr="SQ" vm="1" name="Anterior Chamber Depth Definition Code Sequence"/>
+        <entry group="0022" element="1127" keyword="LensThicknessSequence" vr="SQ" vm="1" name="Lens Thickness Sequence"/>
+        <entry group="0022" element="1128" keyword="AnteriorChamberDepthSequence" vr="SQ" vm="1" name="Anterior Chamber Depth Sequence"/>
+        <entry group="0022" element="1130" keyword="LensThickness" vr="FL" vm="1" name="Lens Thickness"/>
+        <entry group="0022" element="1131" keyword="AnteriorChamberDepth" vr="FL" vm="1" name="Anterior Chamber Depth"/>
+        <entry group="0022" element="1132" keyword="SourceOfLensThicknessDataCodeSequence" vr="SQ" vm="1" name="Source of Lens Thickness Data Code Sequence"/>
+        <entry group="0022" element="1133" keyword="SourceOfAnteriorChamberDepthDataCodeSequence" vr="SQ" vm="1" name="Source of Anterior Chamber Depth Data Code Sequence"/>
+        <entry group="0022" element="1134" keyword="SourceOfRefractiveMeasurementsSequence" vr="SQ" vm="1" name="Source of Refractive Measurements Sequence"/>
+        <entry group="0022" element="1135" keyword="SourceOfRefractiveMeasurementsCodeSequence" vr="SQ" vm="1" name="Source of Refractive Measurements Code Sequence"/>
+        <entry group="0022" element="1140" keyword="OphthalmicAxialLengthMeasurementModified" vr="CS" vm="1" name="Ophthalmic Axial Length Measurement Modified"/>
+        <entry group="0022" element="1150" keyword="OphthalmicAxialLengthDataSourceCodeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Data Source Code Sequence"/>
+        <entry group="0022" element="1153" keyword="OphthalmicAxialLengthAcquisitionMethodCodeSequence" vr="SQ" vm="1" retired="true" name="Ophthalmic Axial Length Acquisition Method Code Sequence"/>
+        <entry group="0022" element="1155" keyword="SignalToNoiseRatio" vr="FL" vm="1" name="Signal to Noise Ratio"/>
+        <entry group="0022" element="1159" keyword="OphthalmicAxialLengthDataSourceDescription" vr="LO" vm="1" name="Ophthalmic Axial Length Data Source Description"/>
+        <entry group="0022" element="1210" keyword="OphthalmicAxialLengthMeasurementsTotalLengthSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Total Length Sequence"/>
+        <entry group="0022" element="1211" keyword="OphthalmicAxialLengthMeasurementsSegmentalLengthSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Segmental Length Sequence"/>
+        <entry group="0022" element="1212" keyword="OphthalmicAxialLengthMeasurementsLengthSummationSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Measurements Length Summation Sequence"/>
+        <entry group="0022" element="1220" keyword="UltrasoundOphthalmicAxialLengthMeasurementsSequence" vr="SQ" vm="1" name="Ultrasound Ophthalmic Axial Length Measurements Sequence"/>
+        <entry group="0022" element="1225" keyword="OpticalOphthalmicAxialLengthMeasurementsSequence" vr="SQ" vm="1" name="Optical Ophthalmic Axial Length Measurements Sequence"/>
+        <entry group="0022" element="1230" keyword="UltrasoundSelectedOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Ultrasound Selected Ophthalmic Axial Length Sequence"/>
+        <entry group="0022" element="1250" keyword="OphthalmicAxialLengthSelectionMethodCodeSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Selection Method Code Sequence"/>
+        <entry group="0022" element="1255" keyword="OpticalSelectedOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Optical Selected Ophthalmic Axial Length Sequence"/>
+        <entry group="0022" element="1257" keyword="SelectedSegmentalOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Selected Segmental Ophthalmic Axial Length Sequence"/>
+        <entry group="0022" element="1260" keyword="SelectedTotalOphthalmicAxialLengthSequence" vr="SQ" vm="1" name="Selected Total Ophthalmic Axial Length Sequence"/>
+        <entry group="0022" element="1262" keyword="OphthalmicAxialLengthQualityMetricSequence" vr="SQ" vm="1" name="Ophthalmic Axial Length Quality Metric Sequence"/>
+        <entry group="0022" element="1265" keyword="OphthalmicAxialLengthQualityMetricTypeCodeSequence" vr="SQ" vm="1" retired="true" name="Ophthalmic Axial Length Quality Metric Type Code Sequence"/>
+        <entry group="0022" element="1273" keyword="OphthalmicAxialLengthQualityMetricTypeDescription" vr="LO" vm="1" retired="true" name="Ophthalmic Axial Length Quality Metric Type Description"/>
+        <entry group="0022" element="1300" keyword="IntraocularLensCalculationsRightEyeSequence" vr="SQ" vm="1" name="Intraocular Lens Calculations Right Eye Sequence"/>
+        <entry group="0022" element="1310" keyword="IntraocularLensCalculationsLeftEyeSequence" vr="SQ" vm="1" name="Intraocular Lens Calculations Left Eye Sequence"/>
+        <entry group="0022" element="1330" keyword="ReferencedOphthalmicAxialLengthMeasurementQCImageSequence" vr="SQ" vm="1" name="Referenced Ophthalmic Axial Length Measurement QC Image Sequence"/>
+        <entry group="0022" element="1415" keyword="OphthalmicMappingDeviceType" vr="CS" vm="1" name="Ophthalmic Mapping Device Type"/>
+        <entry group="0022" element="1420" keyword="AcquisitionMethodCodeSequence" vr="SQ" vm="1" name="Acquisition Method Code Sequence"/>
+        <entry group="0022" element="1423" keyword="AcquisitionMethodAlgorithmSequence" vr="SQ" vm="1" name="Acquisition Method Algorithm Sequence"/>
+        <entry group="0022" element="1436" keyword="OphthalmicThicknessMapTypeCodeSequence" vr="SQ" vm="1" name="Ophthalmic Thickness Map Type Code Sequence"/>
+        <entry group="0022" element="1443" keyword="OphthalmicThicknessMappingNormalsSequence" vr="SQ" vm="1" name="Ophthalmic Thickness Mapping Normals Sequence"/>
+        <entry group="0022" element="1445" keyword="RetinalThicknessDefinitionCodeSequence" vr="SQ" vm="1" name="Retinal Thickness Definition Code Sequence"/>
+        <entry group="0022" element="1450" keyword="PixelValueMappingToCodedConceptSequence" vr="SQ" vm="1" name="Pixel Value Mapping to Coded Concept Sequence"/>
+        <entry group="0022" element="1452" keyword="MappedPixelValue" vr="US_SS" vm="1" name="Mapped Pixel Value"/>
+        <entry group="0022" element="1454" keyword="PixelValueMappingExplanation" vr="LO" vm="1" name="Pixel Value Mapping Explanation"/>
+        <entry group="0022" element="1458" keyword="OphthalmicThicknessMapQualityThresholdSequence" vr="SQ" vm="1" name="Ophthalmic Thickness Map Quality Threshold Sequence"/>
+        <entry group="0022" element="1460" keyword="OphthalmicThicknessMapThresholdQualityRating" vr="FL" vm="1" name="Ophthalmic Thickness Map Threshold Quality Rating"/>
+        <entry group="0022" element="1463" keyword="AnatomicStructureReferencePoint" vr="FL" vm="2" name="Anatomic Structure Reference Point"/>
+        <entry group="0022" element="1465" keyword="RegistrationToLocalizerSequence" vr="SQ" vm="1" name="Registration to Localizer Sequence"/>
+        <entry group="0022" element="1466" keyword="RegisteredLocalizerUnits" vr="CS" vm="1" name="Registered Localizer Units"/>
+        <entry group="0022" element="1467" keyword="RegisteredLocalizerTopLeftHandCorner" vr="FL" vm="2" name="Registered Localizer Top Left Hand Corner"/>
+        <entry group="0022" element="1468" keyword="RegisteredLocalizerBottomRightHandCorner" vr="FL" vm="2" name="Registered Localizer Bottom Right Hand Corner"/>
+        <entry group="0022" element="1470" keyword="OphthalmicThicknessMapQualityRatingSequence" vr="SQ" vm="1" name="Ophthalmic Thickness Map Quality Rating Sequence"/>
+        <entry group="0022" element="1472" keyword="RelevantOPTAttributesSequence" vr="SQ" vm="1" name="Relevant OPT Attributes Sequence"/>
+        <entry group="0022" element="1512" keyword="TransformationMethodCodeSequence" vr="SQ" vm="1" name="Transformation Method Code Sequence"/>
+        <entry group="0022" element="1513" keyword="TransformationAlgorithmSequence" vr="SQ" vm="1" name="Transformation Algorithm Sequence"/>
+        <entry group="0022" element="1515" keyword="OphthalmicAxialLengthMethod" vr="CS" vm="1" name="Ophthalmic Axial Length Method"/>
+        <entry group="0022" element="1517" keyword="OphthalmicFOV" vr="FL" vm="1" name="Ophthalmic FOV"/>
+        <entry group="0022" element="1518" keyword="TwoDimensionalToThreeDimensionalMapSequence" vr="SQ" vm="1" name="Two Dimensional to Three Dimensional Map Sequence"/>
+        <entry group="0022" element="1525" keyword="WideFieldOphthalmicPhotographyQualityRatingSequence" vr="SQ" vm="1" name="Wide Field Ophthalmic Photography Quality Rating Sequence"/>
+        <entry group="0022" element="1526" keyword="WideFieldOphthalmicPhotographyQualityThresholdSequence" vr="SQ" vm="1" name="Wide Field Ophthalmic Photography Quality Threshold Sequence"/>
+        <entry group="0022" element="1527" keyword="WideFieldOphthalmicPhotographyThresholdQualityRating" vr="FL" vm="1" name="Wide Field Ophthalmic Photography Threshold Quality Rating"/>
+        <entry group="0022" element="1528" keyword="XCoordinatesCenterPixelViewAngle" vr="FL" vm="1" name="X Coordinates Center Pixel View Angle"/>
+        <entry group="0022" element="1529" keyword="YCoordinatesCenterPixelViewAngle" vr="FL" vm="1" name="Y Coordinates Center Pixel View Angle"/>
+        <entry group="0022" element="1530" keyword="NumberOfMapPoints" vr="UL" vm="1" name="Number of Map Points"/>
+        <entry group="0022" element="1531" keyword="TwoDimensionalToThreeDimensionalMapData" vr="OF" vm="1" name="Two Dimensional to Three Dimensional Map Data"/>
+        <entry group="0024" element="0010" keyword="VisualFieldHorizontalExtent" vr="FL" vm="1" name="Visual Field Horizontal Extent"/>
+        <entry group="0024" element="0011" keyword="VisualFieldVerticalExtent" vr="FL" vm="1" name="Visual Field Vertical Extent"/>
+        <entry group="0024" element="0012" keyword="VisualFieldShape" vr="CS" vm="1" name="Visual Field Shape"/>
+        <entry group="0024" element="0016" keyword="ScreeningTestModeCodeSequence" vr="SQ" vm="1" name="Screening Test Mode Code Sequence"/>
+        <entry group="0024" element="0018" keyword="MaximumStimulusLuminance" vr="FL" vm="1" name="Maximum Stimulus Luminance"/>
+        <entry group="0024" element="0020" keyword="BackgroundLuminance" vr="FL" vm="1" name="Background Luminance"/>
+        <entry group="0024" element="0021" keyword="StimulusColorCodeSequence" vr="SQ" vm="1" name="Stimulus Color Code Sequence"/>
+        <entry group="0024" element="0024" keyword="BackgroundIlluminationColorCodeSequence" vr="SQ" vm="1" name="Background Illumination Color Code Sequence"/>
+        <entry group="0024" element="0025" keyword="StimulusArea" vr="FL" vm="1" name="Stimulus Area"/>
+        <entry group="0024" element="0028" keyword="StimulusPresentationTime" vr="FL" vm="1" name="Stimulus Presentation Time"/>
+        <entry group="0024" element="0032" keyword="FixationSequence" vr="SQ" vm="1" name="Fixation Sequence"/>
+        <entry group="0024" element="0033" keyword="FixationMonitoringCodeSequence" vr="SQ" vm="1" name="Fixation Monitoring Code Sequence"/>
+        <entry group="0024" element="0034" keyword="VisualFieldCatchTrialSequence" vr="SQ" vm="1" name="Visual Field Catch Trial Sequence"/>
+        <entry group="0024" element="0035" keyword="FixationCheckedQuantity" vr="US" vm="1" name="Fixation Checked Quantity"/>
+        <entry group="0024" element="0036" keyword="PatientNotProperlyFixatedQuantity" vr="US" vm="1" name="Patient Not Properly Fixated Quantity"/>
+        <entry group="0024" element="0037" keyword="PresentedVisualStimuliDataFlag" vr="CS" vm="1" name="Presented Visual Stimuli Data Flag"/>
+        <entry group="0024" element="0038" keyword="NumberOfVisualStimuli" vr="US" vm="1" name="Number of Visual Stimuli"/>
+        <entry group="0024" element="0039" keyword="ExcessiveFixationLossesDataFlag" vr="CS" vm="1" name="Excessive Fixation Losses Data Flag"/>
+        <entry group="0024" element="0040" keyword="ExcessiveFixationLosses" vr="CS" vm="1" name="Excessive Fixation Losses"/>
+        <entry group="0024" element="0042" keyword="StimuliRetestingQuantity" vr="US" vm="1" name="Stimuli Retesting Quantity"/>
+        <entry group="0024" element="0044" keyword="CommentsOnPatientPerformanceOfVisualField" vr="LT" vm="1" name="Comments on Patient's Performance of Visual Field"/>
+        <entry group="0024" element="0045" keyword="FalseNegativesEstimateFlag" vr="CS" vm="1" name="False Negatives Estimate Flag"/>
+        <entry group="0024" element="0046" keyword="FalseNegativesEstimate" vr="FL" vm="1" name="False Negatives Estimate"/>
+        <entry group="0024" element="0048" keyword="NegativeCatchTrialsQuantity" vr="US" vm="1" name="Negative Catch Trials Quantity"/>
+        <entry group="0024" element="0050" keyword="FalseNegativesQuantity" vr="US" vm="1" name="False Negatives Quantity"/>
+        <entry group="0024" element="0051" keyword="ExcessiveFalseNegativesDataFlag" vr="CS" vm="1" name="Excessive False Negatives Data Flag"/>
+        <entry group="0024" element="0052" keyword="ExcessiveFalseNegatives" vr="CS" vm="1" name="Excessive False Negatives"/>
+        <entry group="0024" element="0053" keyword="FalsePositivesEstimateFlag" vr="CS" vm="1" name="False Positives Estimate Flag"/>
+        <entry group="0024" element="0054" keyword="FalsePositivesEstimate" vr="FL" vm="1" name="False Positives Estimate"/>
+        <entry group="0024" element="0055" keyword="CatchTrialsDataFlag" vr="CS" vm="1" name="Catch Trials Data Flag"/>
+        <entry group="0024" element="0056" keyword="PositiveCatchTrialsQuantity" vr="US" vm="1" name="Positive Catch Trials Quantity"/>
+        <entry group="0024" element="0057" keyword="TestPointNormalsDataFlag" vr="CS" vm="1" name="Test Point Normals Data Flag"/>
+        <entry group="0024" element="0058" keyword="TestPointNormalsSequence" vr="SQ" vm="1" name="Test Point Normals Sequence"/>
+        <entry group="0024" element="0059" keyword="GlobalDeviationProbabilityNormalsFlag" vr="CS" vm="1" name="Global Deviation Probability Normals Flag"/>
+        <entry group="0024" element="0060" keyword="FalsePositivesQuantity" vr="US" vm="1" name="False Positives Quantity"/>
+        <entry group="0024" element="0061" keyword="ExcessiveFalsePositivesDataFlag" vr="CS" vm="1" name="Excessive False Positives Data Flag"/>
+        <entry group="0024" element="0062" keyword="ExcessiveFalsePositives" vr="CS" vm="1" name="Excessive False Positives"/>
+        <entry group="0024" element="0063" keyword="VisualFieldTestNormalsFlag" vr="CS" vm="1" name="Visual Field Test Normals Flag"/>
+        <entry group="0024" element="0064" keyword="ResultsNormalsSequence" vr="SQ" vm="1" name="Results Normals Sequence"/>
+        <entry group="0024" element="0065" keyword="AgeCorrectedSensitivityDeviationAlgorithmSequence" vr="SQ" vm="1" name="Age Corrected Sensitivity Deviation Algorithm Sequence"/>
+        <entry group="0024" element="0066" keyword="GlobalDeviationFromNormal" vr="FL" vm="1" name="Global Deviation From Normal"/>
+        <entry group="0024" element="0067" keyword="GeneralizedDefectSensitivityDeviationAlgorithmSequence" vr="SQ" vm="1" name="Generalized Defect Sensitivity Deviation Algorithm Sequence"/>
+        <entry group="0024" element="0068" keyword="LocalizedDeviationFromNormal" vr="FL" vm="1" name="Localized Deviation From Normal"/>
+        <entry group="0024" element="0069" keyword="PatientReliabilityIndicator" vr="LO" vm="1" name="Patient Reliability Indicator"/>
+        <entry group="0024" element="0070" keyword="VisualFieldMeanSensitivity" vr="FL" vm="1" name="Visual Field Mean Sensitivity"/>
+        <entry group="0024" element="0071" keyword="GlobalDeviationProbability" vr="FL" vm="1" name="Global Deviation Probability"/>
+        <entry group="0024" element="0072" keyword="LocalDeviationProbabilityNormalsFlag" vr="CS" vm="1" name="Local Deviation Probability Normals Flag"/>
+        <entry group="0024" element="0073" keyword="LocalizedDeviationProbability" vr="FL" vm="1" name="Localized Deviation Probability"/>
+        <entry group="0024" element="0074" keyword="ShortTermFluctuationCalculated" vr="CS" vm="1" name="Short Term Fluctuation Calculated"/>
+        <entry group="0024" element="0075" keyword="ShortTermFluctuation" vr="FL" vm="1" name="Short Term Fluctuation"/>
+        <entry group="0024" element="0076" keyword="ShortTermFluctuationProbabilityCalculated" vr="CS" vm="1" name="Short Term Fluctuation Probability Calculated"/>
+        <entry group="0024" element="0077" keyword="ShortTermFluctuationProbability" vr="FL" vm="1" name="Short Term Fluctuation Probability"/>
+        <entry group="0024" element="0078" keyword="CorrectedLocalizedDeviationFromNormalCalculated" vr="CS" vm="1" name="Corrected Localized Deviation From Normal Calculated"/>
+        <entry group="0024" element="0079" keyword="CorrectedLocalizedDeviationFromNormal" vr="FL" vm="1" name="Corrected Localized Deviation From Normal"/>
+        <entry group="0024" element="0080" keyword="CorrectedLocalizedDeviationFromNormalProbabilityCalculated" vr="CS" vm="1" name="Corrected Localized Deviation From Normal Probability Calculated"/>
+        <entry group="0024" element="0081" keyword="CorrectedLocalizedDeviationFromNormalProbability" vr="FL" vm="1" name="Corrected Localized Deviation From Normal Probability"/>
+        <entry group="0024" element="0083" keyword="GlobalDeviationProbabilitySequence" vr="SQ" vm="1" name="Global Deviation Probability Sequence"/>
+        <entry group="0024" element="0085" keyword="LocalizedDeviationProbabilitySequence" vr="SQ" vm="1" name="Localized Deviation Probability Sequence"/>
+        <entry group="0024" element="0086" keyword="FovealSensitivityMeasured" vr="CS" vm="1" name="Foveal Sensitivity Measured"/>
+        <entry group="0024" element="0087" keyword="FovealSensitivity" vr="FL" vm="1" name="Foveal Sensitivity"/>
+        <entry group="0024" element="0088" keyword="VisualFieldTestDuration" vr="FL" vm="1" name="Visual Field Test Duration"/>
+        <entry group="0024" element="0089" keyword="VisualFieldTestPointSequence" vr="SQ" vm="1" name="Visual Field Test Point Sequence"/>
+        <entry group="0024" element="0090" keyword="VisualFieldTestPointXCoordinate" vr="FL" vm="1" name="Visual Field Test Point X-Coordinate"/>
+        <entry group="0024" element="0091" keyword="VisualFieldTestPointYCoordinate" vr="FL" vm="1" name="Visual Field Test Point Y-Coordinate"/>
+        <entry group="0024" element="0092" keyword="AgeCorrectedSensitivityDeviationValue" vr="FL" vm="1" name="Age Corrected Sensitivity Deviation Value"/>
+        <entry group="0024" element="0093" keyword="StimulusResults" vr="CS" vm="1" name="Stimulus Results"/>
+        <entry group="0024" element="0094" keyword="SensitivityValue" vr="FL" vm="1" name="Sensitivity Value"/>
+        <entry group="0024" element="0095" keyword="RetestStimulusSeen" vr="CS" vm="1" name="Retest Stimulus Seen"/>
+        <entry group="0024" element="0096" keyword="RetestSensitivityValue" vr="FL" vm="1" name="Retest Sensitivity Value"/>
+        <entry group="0024" element="0097" keyword="VisualFieldTestPointNormalsSequence" vr="SQ" vm="1" name="Visual Field Test Point Normals Sequence"/>
+        <entry group="0024" element="0098" keyword="QuantifiedDefect" vr="FL" vm="1" name="Quantified Defect"/>
+        <entry group="0024" element="0100" keyword="AgeCorrectedSensitivityDeviationProbabilityValue" vr="FL" vm="1" name="Age Corrected Sensitivity Deviation Probability Value"/>
+        <entry group="0024" element="0102" keyword="GeneralizedDefectCorrectedSensitivityDeviationFlag" vr="CS" vm="1" name="Generalized Defect Corrected Sensitivity Deviation Flag"/>
+        <entry group="0024" element="0103" keyword="GeneralizedDefectCorrectedSensitivityDeviationValue" vr="FL" vm="1" name="Generalized Defect Corrected Sensitivity Deviation Value"/>
+        <entry group="0024" element="0104" keyword="GeneralizedDefectCorrectedSensitivityDeviationProbabilityValue" vr="FL" vm="1" name="Generalized Defect Corrected Sensitivity Deviation Probability Value"/>
+        <entry group="0024" element="0105" keyword="MinimumSensitivityValue" vr="FL" vm="1" name="Minimum Sensitivity Value"/>
+        <entry group="0024" element="0106" keyword="BlindSpotLocalized" vr="CS" vm="1" name="Blind Spot Localized"/>
+        <entry group="0024" element="0107" keyword="BlindSpotXCoordinate" vr="FL" vm="1" name="Blind Spot X-Coordinate"/>
+        <entry group="0024" element="0108" keyword="BlindSpotYCoordinate" vr="FL" vm="1" name="Blind Spot Y-Coordinate"/>
+        <entry group="0024" element="0110" keyword="VisualAcuityMeasurementSequence" vr="SQ" vm="1" name="Visual Acuity Measurement Sequence"/>
+        <entry group="0024" element="0112" keyword="RefractiveParametersUsedOnPatientSequence" vr="SQ" vm="1" name="Refractive Parameters Used on Patient Sequence"/>
+        <entry group="0024" element="0113" keyword="MeasurementLaterality" vr="CS" vm="1" name="Measurement Laterality"/>
+        <entry group="0024" element="0114" keyword="OphthalmicPatientClinicalInformationLeftEyeSequence" vr="SQ" vm="1" name="Ophthalmic Patient Clinical Information Left Eye Sequence"/>
+        <entry group="0024" element="0115" keyword="OphthalmicPatientClinicalInformationRightEyeSequence" vr="SQ" vm="1" name="Ophthalmic Patient Clinical Information Right Eye Sequence"/>
+        <entry group="0024" element="0117" keyword="FovealPointNormativeDataFlag" vr="CS" vm="1" name="Foveal Point Normative Data Flag"/>
+        <entry group="0024" element="0118" keyword="FovealPointProbabilityValue" vr="FL" vm="1" name="Foveal Point Probability Value"/>
+        <entry group="0024" element="0120" keyword="ScreeningBaselineMeasured" vr="CS" vm="1" name="Screening Baseline Measured"/>
+        <entry group="0024" element="0122" keyword="ScreeningBaselineMeasuredSequence" vr="SQ" vm="1" name="Screening Baseline Measured Sequence"/>
+        <entry group="0024" element="0124" keyword="ScreeningBaselineType" vr="CS" vm="1" name="Screening Baseline Type"/>
+        <entry group="0024" element="0126" keyword="ScreeningBaselineValue" vr="FL" vm="1" name="Screening Baseline Value"/>
+        <entry group="0024" element="0202" keyword="AlgorithmSource" vr="LO" vm="1" name="Algorithm Source"/>
+        <entry group="0024" element="0306" keyword="DataSetName" vr="LO" vm="1" name="Data Set Name"/>
+        <entry group="0024" element="0307" keyword="DataSetVersion" vr="LO" vm="1" name="Data Set Version"/>
+        <entry group="0024" element="0308" keyword="DataSetSource" vr="LO" vm="1" name="Data Set Source"/>
+        <entry group="0024" element="0309" keyword="DataSetDescription" vr="LO" vm="1" name="Data Set Description"/>
+        <entry group="0024" element="0317" keyword="VisualFieldTestReliabilityGlobalIndexSequence" vr="SQ" vm="1" name="Visual Field Test Reliability Global Index Sequence"/>
+        <entry group="0024" element="0320" keyword="VisualFieldGlobalResultsIndexSequence" vr="SQ" vm="1" name="Visual Field Global Results Index Sequence"/>
+        <entry group="0024" element="0325" keyword="DataObservationSequence" vr="SQ" vm="1" name="Data Observation Sequence"/>
+        <entry group="0024" element="0338" keyword="IndexNormalsFlag" vr="CS" vm="1" name="Index Normals Flag"/>
+        <entry group="0024" element="0341" keyword="IndexProbability" vr="FL" vm="1" name="Index Probability"/>
+        <entry group="0024" element="0344" keyword="IndexProbabilitySequence" vr="SQ" vm="1" name="Index Probability Sequence"/>
+        <entry group="0028" element="0002" keyword="SamplesPerPixel" vr="US" vm="1" name="Samples per Pixel"/>
+        <entry group="0028" element="0003" keyword="SamplesPerPixelUsed" vr="US" vm="1" name="Samples per Pixel Used"/>
+        <entry group="0028" element="0004" keyword="PhotometricInterpretation" vr="CS" vm="1" name="Photometric Interpretation"/>
+        <entry group="0028" element="0005" keyword="ImageDimensions" vr="US" vm="1" retired="true" name="Image Dimensions"/>
+        <entry group="0028" element="0006" keyword="PlanarConfiguration" vr="US" vm="1" name="Planar Configuration"/>
+        <entry group="0028" element="0008" keyword="NumberOfFrames" vr="IS" vm="1" name="Number of Frames"/>
+        <entry group="0028" element="0009" keyword="FrameIncrementPointer" vr="AT" vm="1-n" name="Frame Increment Pointer"/>
+        <entry group="0028" element="000a" keyword="FrameDimensionPointer" vr="AT" vm="1-n" name="Frame Dimension Pointer"/>
+        <entry group="0028" element="0010" keyword="Rows" vr="US" vm="1" name="Rows"/>
+        <entry group="0028" element="0011" keyword="Columns" vr="US" vm="1" name="Columns"/>
+        <entry group="0028" element="0012" keyword="Planes" vr="US" vm="1" retired="true" name="Planes"/>
+        <entry group="0028" element="0014" keyword="UltrasoundColorDataPresent" vr="US" vm="1" name="Ultrasound Color Data Present"/>
+        <entry group="0028" element="0020" retired="true"/>
+        <entry group="0028" element="0030" keyword="PixelSpacing" vr="DS" vm="2" name="Pixel Spacing"/>
+        <entry group="0028" element="0031" keyword="ZoomFactor" vr="DS" vm="2" name="Zoom Factor"/>
+        <entry group="0028" element="0032" keyword="ZoomCenter" vr="DS" vm="2" name="Zoom Center"/>
+        <entry group="0028" element="0034" keyword="PixelAspectRatio" vr="IS" vm="2" name="Pixel Aspect Ratio"/>
+        <entry group="0028" element="0040" keyword="ImageFormat" vr="CS" vm="1" retired="true" name="Image Format"/>
+        <entry group="0028" element="0050" keyword="ManipulatedImage" vr="LO" vm="1-n" retired="true" name="Manipulated Image"/>
+        <entry group="0028" element="0051" keyword="CorrectedImage" vr="CS" vm="1-n" name="Corrected Image"/>
+        <entry group="0028" element="005f" keyword="CompressionRecognitionCode" vr="LO" vm="1" retired="true" name="Compression Recognition Code"/>
+        <entry group="0028" element="0060" keyword="CompressionCode" vr="CS" vm="1" retired="true" name="Compression Code"/>
+        <entry group="0028" element="0061" keyword="CompressionOriginator" vr="SH" vm="1" retired="true" name="Compression Originator"/>
+        <entry group="0028" element="0062" keyword="CompressionLabel" vr="LO" vm="1" retired="true" name="Compression Label"/>
+        <entry group="0028" element="0063" keyword="CompressionDescription" vr="SH" vm="1" retired="true" name="Compression Description"/>
+        <entry group="0028" element="0065" keyword="CompressionSequence" vr="CS" vm="1-n" retired="true" name="Compression Sequence"/>
+        <entry group="0028" element="0066" keyword="CompressionStepPointers" vr="AT" vm="1-n" retired="true" name="Compression Step Pointers"/>
+        <entry group="0028" element="0068" keyword="RepeatInterval" vr="US" vm="1" retired="true" name="Repeat Interval"/>
+        <entry group="0028" element="0069" keyword="BitsGrouped" vr="US" vm="1" retired="true" name="Bits Grouped"/>
+        <entry group="0028" element="0070" keyword="PerimeterTable" vr="US" vm="1-n" retired="true" name="Perimeter Table"/>
+        <entry group="0028" element="0071" keyword="PerimeterValue" vr="US_SS" vm="1" retired="true" name="Perimeter Value"/>
+        <entry group="0028" element="0080" keyword="PredictorRows" vr="US" vm="1" retired="true" name="Predictor Rows"/>
+        <entry group="0028" element="0081" keyword="PredictorColumns" vr="US" vm="1" retired="true" name="Predictor Columns"/>
+        <entry group="0028" element="0082" keyword="PredictorConstants" vr="US" vm="1-n" retired="true" name="Predictor Constants"/>
+        <entry group="0028" element="0090" keyword="BlockedPixels" vr="CS" vm="1" retired="true" name="Blocked Pixels"/>
+        <entry group="0028" element="0091" keyword="BlockRows" vr="US" vm="1" retired="true" name="Block Rows"/>
+        <entry group="0028" element="0092" keyword="BlockColumns" vr="US" vm="1" retired="true" name="Block Columns"/>
+        <entry group="0028" element="0093" keyword="RowOverlap" vr="US" vm="1" retired="true" name="Row Overlap"/>
+        <entry group="0028" element="0094" keyword="ColumnOverlap" vr="US" vm="1" retired="true" name="Column Overlap"/>
+        <entry group="0028" element="0100" keyword="BitsAllocated" vr="US" vm="1" name="Bits Allocated"/>
+        <entry group="0028" element="0101" keyword="BitsStored" vr="US" vm="1" name="Bits Stored"/>
+        <entry group="0028" element="0102" keyword="HighBit" vr="US" vm="1" name="High Bit"/>
+        <entry group="0028" element="0103" keyword="PixelRepresentation" vr="US" vm="1" name="Pixel Representation"/>
+        <entry group="0028" element="0104" keyword="SmallestValidPixelValue" vr="US_SS" vm="1" retired="true" name="Smallest Valid Pixel Value"/>
+        <entry group="0028" element="0105" keyword="LargestValidPixelValue" vr="US_SS" vm="1" retired="true" name="Largest Valid Pixel Value"/>
+        <entry group="0028" element="0106" keyword="SmallestImagePixelValue" vr="US_SS" vm="1" name="Smallest Image Pixel Value"/>
+        <entry group="0028" element="0107" keyword="LargestImagePixelValue" vr="US_SS" vm="1" name="Largest Image Pixel Value"/>
+        <entry group="0028" element="0108" keyword="SmallestPixelValueInSeries" vr="US_SS" vm="1" name="Smallest Pixel Value in Series"/>
+        <entry group="0028" element="0109" keyword="LargestPixelValueInSeries" vr="US_SS" vm="1" name="Largest Pixel Value in Series"/>
+        <entry group="0028" element="0110" keyword="SmallestImagePixelValueInPlane" vr="US_SS" vm="1" retired="true" name="Smallest Image Pixel Value in Plane"/>
+        <entry group="0028" element="0111" keyword="LargestImagePixelValueInPlane" vr="US_SS" vm="1" retired="true" name="Largest Image Pixel Value in Plane"/>
+        <entry group="0028" element="0120" keyword="PixelPaddingValue" vr="US_SS" vm="1" name="Pixel Padding Value"/>
+        <entry group="0028" element="0121" keyword="PixelPaddingRangeLimit" vr="US_SS" vm="1" name="Pixel Padding Range Limit"/>
+        <entry group="0028" element="0122" keyword="FloatPixelPaddingValue" vr="FL" vm="1" name="Float Pixel Padding Value"/>
+        <entry group="0028" element="0123" keyword="DoubleFloatPixelPaddingValue" vr="FD" vm="1" name="Double Float Pixel Padding Value"/>
+        <entry group="0028" element="0124" keyword="FloatPixelPaddingRangeLimit" vr="FL" vm="1" name="Float Pixel Padding Range Limit"/>
+        <entry group="0028" element="0125" keyword="DoubleFloatPixelPaddingRangeLimit" vr="FD" vm="1" name="Double Float Pixel Padding Range Limit"/>
+        <entry group="0028" element="0200" keyword="ImageLocation" vr="US" vm="1" retired="true" name="Image Location"/>
+        <entry group="0028" element="0300" keyword="QualityControlImage" vr="CS" vm="1" name="Quality Control Image"/>
+        <entry group="0028" element="0301" keyword="BurnedInAnnotation" vr="CS" vm="1" name="Burned In Annotation"/>
+        <entry group="0028" element="0302" keyword="RecognizableVisualFeatures" vr="CS" vm="1" name="Recognizable Visual Features"/>
+        <entry group="0028" element="0303" keyword="LongitudinalTemporalInformationModified" vr="CS" vm="1" name="Longitudinal Temporal Information Modified"/>
+        <entry group="0028" element="0304" keyword="ReferencedColorPaletteInstanceUID" vr="UI" vm="1" name="Referenced Color Palette Instance UID"/>
+        <entry group="0028" element="0400" keyword="TransformLabel" vr="LO" vm="1" retired="true" name="Transform Label"/>
+        <entry group="0028" element="0401" keyword="TransformVersionNumber" vr="LO" vm="1" retired="true" name="Transform Version Number"/>
+        <entry group="0028" element="0402" keyword="NumberOfTransformSteps" vr="US" vm="1" retired="true" name="Number of Transform Steps"/>
+        <entry group="0028" element="0403" keyword="SequenceOfCompressedData" vr="LO" vm="1-n" retired="true" name="Sequence of Compressed Data"/>
+        <entry group="0028" element="0404" keyword="DetailsOfCoefficients" vr="AT" vm="1-n" retired="true" name="Details of Coefficients"/>
+        <entry group="0028" element="04x0" keyword="RowsForNthOrderCoefficients" vr="US" vm="1" retired="true" name="Rows For Nth Order Coefficients"/>
+        <entry group="0028" element="04x1" keyword="ColumnsForNthOrderCoefficients" vr="US" vm="1" retired="true" name="Columns For Nth Order Coefficients"/>
+        <entry group="0028" element="04x2" keyword="CoefficientCoding" vr="LO" vm="1-n" retired="true" name="Coefficient Coding"/>
+        <entry group="0028" element="04x3" keyword="CoefficientCodingPointers" vr="AT" vm="1-n" retired="true" name="Coefficient Coding Pointers"/>
+        <entry group="0028" element="0700" keyword="DCTLabel" vr="LO" vm="1" retired="true" name="DCT Label"/>
+        <entry group="0028" element="0701" keyword="DataBlockDescription" vr="CS" vm="1-n" retired="true" name="Data Block Description"/>
+        <entry group="0028" element="0702" keyword="DataBlock" vr="AT" vm="1-n" retired="true" name="Data Block"/>
+        <entry group="0028" element="0710" keyword="NormalizationFactorFormat" vr="US" vm="1" retired="true" name="Normalization Factor Format"/>
+        <entry group="0028" element="0720" keyword="ZonalMapNumberFormat" vr="US" vm="1" retired="true" name="Zonal Map Number Format"/>
+        <entry group="0028" element="0721" keyword="ZonalMapLocation" vr="AT" vm="1-n" retired="true" name="Zonal Map Location"/>
+        <entry group="0028" element="0722" keyword="ZonalMapFormat" vr="US" vm="1" retired="true" name="Zonal Map Format"/>
+        <entry group="0028" element="0730" keyword="AdaptiveMapFormat" vr="US" vm="1" retired="true" name="Adaptive Map Format"/>
+        <entry group="0028" element="0740" keyword="CodeNumberFormat" vr="US" vm="1" retired="true" name="Code Number Format"/>
+        <entry group="0028" element="08x0" keyword="CodeLabel" vr="CS" vm="1-n" retired="true" name="Code Label"/>
+        <entry group="0028" element="08x2" keyword="NumberOfTables" vr="US" vm="1" retired="true" name="Number of Tables"/>
+        <entry group="0028" element="08x3" keyword="CodeTableLocation" vr="AT" vm="1-n" retired="true" name="Code Table Location"/>
+        <entry group="0028" element="08x4" keyword="BitsForCodeWord" vr="US" vm="1" retired="true" name="Bits For Code Word"/>
+        <entry group="0028" element="08x8" keyword="ImageDataLocation" vr="AT" vm="1-n" retired="true" name="Image Data Location"/>
+        <entry group="0028" element="0a02" keyword="PixelSpacingCalibrationType" vr="CS" vm="1" name="Pixel Spacing Calibration Type"/>
+        <entry group="0028" element="0a04" keyword="PixelSpacingCalibrationDescription" vr="LO" vm="1" name="Pixel Spacing Calibration Description"/>
+        <entry group="0028" element="1040" keyword="PixelIntensityRelationship" vr="CS" vm="1" name="Pixel Intensity Relationship"/>
+        <entry group="0028" element="1041" keyword="PixelIntensityRelationshipSign" vr="SS" vm="1" name="Pixel Intensity Relationship Sign"/>
+        <entry group="0028" element="1050" keyword="WindowCenter" vr="DS" vm="1-n" name="Window Center"/>
+        <entry group="0028" element="1051" keyword="WindowWidth" vr="DS" vm="1-n" name="Window Width"/>
+        <entry group="0028" element="1052" keyword="RescaleIntercept" vr="DS" vm="1" name="Rescale Intercept"/>
+        <entry group="0028" element="1053" keyword="RescaleSlope" vr="DS" vm="1" name="Rescale Slope"/>
+        <entry group="0028" element="1054" keyword="RescaleType" vr="LO" vm="1" name="Rescale Type"/>
+        <entry group="0028" element="1055" keyword="WindowCenterWidthExplanation" vr="LO" vm="1-n" name="Window Center & Width Explanation"/>
+        <entry group="0028" element="1056" keyword="VOILUTFunction" vr="CS" vm="1" name="VOI LUT Function"/>
+        <entry group="0028" element="1080" keyword="GrayScale" vr="CS" vm="1" retired="true" name="Gray Scale"/>
+        <entry group="0028" element="1090" keyword="RecommendedViewingMode" vr="CS" vm="1" name="Recommended Viewing Mode"/>
+        <entry group="0028" element="1100" keyword="GrayLookupTableDescriptor" vr="US_SS" vm="3" retired="true" name="Gray Lookup Table Descriptor"/>
+        <entry group="0028" element="1101" keyword="RedPaletteColorLookupTableDescriptor" vr="US_SS" vm="3" name="Red Palette Color Lookup Table Descriptor"/>
+        <entry group="0028" element="1102" keyword="GreenPaletteColorLookupTableDescriptor" vr="US_SS" vm="3" name="Green Palette Color Lookup Table Descriptor"/>
+        <entry group="0028" element="1103" keyword="BluePaletteColorLookupTableDescriptor" vr="US_SS" vm="3" name="Blue Palette Color Lookup Table Descriptor"/>
+        <entry group="0028" element="1104" keyword="AlphaPaletteColorLookupTableDescriptor" vr="US" vm="3" name="Alpha Palette Color Lookup Table Descriptor"/>
+        <entry group="0028" element="1111" keyword="LargeRedPaletteColorLookupTableDescriptor" vr="US_SS" vm="4" retired="true" name="Large Red Palette Color Lookup Table Descriptor"/>
+        <entry group="0028" element="1112" keyword="LargeGreenPaletteColorLookupTableDescriptor" vr="US_SS" vm="4" retired="true" name="Large Green Palette Color Lookup Table Descriptor"/>
+        <entry group="0028" element="1113" keyword="LargeBluePaletteColorLookupTableDescriptor" vr="US_SS" vm="4" retired="true" name="Large Blue Palette Color Lookup Table Descriptor"/>
+        <entry group="0028" element="1199" keyword="PaletteColorLookupTableUID" vr="UI" vm="1" name="Palette Color Lookup Table UID"/>
+        <entry group="0028" element="1200" keyword="GrayLookupTableData" vr="US_SS_OW" vm="1-n" retired="true" name="Gray Lookup Table Data"/>
+        <entry group="0028" element="1201" keyword="RedPaletteColorLookupTableData" vr="OW" vm="1" name="Red Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1202" keyword="GreenPaletteColorLookupTableData" vr="OW" vm="1" name="Green Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1203" keyword="BluePaletteColorLookupTableData" vr="OW" vm="1" name="Blue Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1204" keyword="AlphaPaletteColorLookupTableData" vr="OW" vm="1" name="Alpha Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1211" keyword="LargeRedPaletteColorLookupTableData" vr="OW" vm="1" retired="true" name="Large Red Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1212" keyword="LargeGreenPaletteColorLookupTableData" vr="OW" vm="1" retired="true" name="Large Green Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1213" keyword="LargeBluePaletteColorLookupTableData" vr="OW" vm="1" retired="true" name="Large Blue Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1214" keyword="LargePaletteColorLookupTableUID" vr="UI" vm="1" retired="true" name="Large Palette Color Lookup Table UID"/>
+        <entry group="0028" element="1221" keyword="SegmentedRedPaletteColorLookupTableData" vr="OW" vm="1" name="Segmented Red Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1222" keyword="SegmentedGreenPaletteColorLookupTableData" vr="OW" vm="1" name="Segmented Green Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1223" keyword="SegmentedBluePaletteColorLookupTableData" vr="OW" vm="1" name="Segmented Blue Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1224" keyword="SegmentedAlphaPaletteColorLookupTableData" vr="OW" vm="1" name="Segmented Alpha Palette Color Lookup Table Data"/>
+        <entry group="0028" element="1230" keyword="StoredValueColorRangeSequence" vr="SQ" vm="1" name="Stored Value Color Range Sequence"/>
+        <entry group="0028" element="1231" keyword="MinimumStoredValueMapped" vr="FD" vm="1" name="Minimum Stored Value Mapped"/>
+        <entry group="0028" element="1232" keyword="MaximumStoredValueMapped" vr="FD" vm="1" name="Maximum Stored Value Mapped"/>
+        <entry group="0028" element="1300" keyword="BreastImplantPresent" vr="CS" vm="1" name="Breast Implant Present"/>
+        <entry group="0028" element="1350" keyword="PartialView" vr="CS" vm="1" name="Partial View"/>
+        <entry group="0028" element="1351" keyword="PartialViewDescription" vr="ST" vm="1" name="Partial View Description"/>
+        <entry group="0028" element="1352" keyword="PartialViewCodeSequence" vr="SQ" vm="1" name="Partial View Code Sequence"/>
+        <entry group="0028" element="135a" keyword="SpatialLocationsPreserved" vr="CS" vm="1" name="Spatial Locations Preserved"/>
+        <entry group="0028" element="1401" keyword="DataFrameAssignmentSequence" vr="SQ" vm="1" name="Data Frame Assignment Sequence"/>
+        <entry group="0028" element="1402" keyword="DataPathAssignment" vr="CS" vm="1" name="Data Path Assignment"/>
+        <entry group="0028" element="1403" keyword="BitsMappedToColorLookupTable" vr="US" vm="1" name="Bits Mapped to Color Lookup Table"/>
+        <entry group="0028" element="1404" keyword="BlendingLUT1Sequence" vr="SQ" vm="1" name="Blending LUT 1 Sequence"/>
+        <entry group="0028" element="1405" keyword="BlendingLUT1TransferFunction" vr="CS" vm="1" name="Blending LUT 1 Transfer Function"/>
+        <entry group="0028" element="1406" keyword="BlendingWeightConstant" vr="FD" vm="1" name="Blending Weight Constant"/>
+        <entry group="0028" element="1407" keyword="BlendingLookupTableDescriptor" vr="US" vm="3" name="Blending Lookup Table Descriptor"/>
+        <entry group="0028" element="1408" keyword="BlendingLookupTableData" vr="OW" vm="1" name="Blending Lookup Table Data"/>
+        <entry group="0028" element="140b" keyword="EnhancedPaletteColorLookupTableSequence" vr="SQ" vm="1" name="Enhanced Palette Color Lookup Table Sequence"/>
+        <entry group="0028" element="140c" keyword="BlendingLUT2Sequence" vr="SQ" vm="1" name="Blending LUT 2 Sequence"/>
+        <entry group="0028" element="140d" keyword="BlendingLUT2TransferFunction" vr="CS" vm="1" name="Blending LUT 2 Transfer Function"/>
+        <entry group="0028" element="140e" keyword="DataPathID" vr="CS" vm="1" name="Data Path ID"/>
+        <entry group="0028" element="140f" keyword="RGBLUTTransferFunction" vr="CS" vm="1" name="RGB LUT Transfer Function"/>
+        <entry group="0028" element="1410" keyword="AlphaLUTTransferFunction" vr="CS" vm="1" name="Alpha LUT Transfer Function"/>
+        <entry group="0028" element="2000" keyword="ICCProfile" vr="OB" vm="1" name="ICC Profile"/>
+        <entry group="0028" element="2002" keyword="ColorSpace" vr="CS" vm="1" name="Color Space"/>
+        <entry group="0028" element="2110" keyword="LossyImageCompression" vr="CS" vm="1" name="Lossy Image Compression"/>
+        <entry group="0028" element="2112" keyword="LossyImageCompressionRatio" vr="DS" vm="1-n" name="Lossy Image Compression Ratio"/>
+        <entry group="0028" element="2114" keyword="LossyImageCompressionMethod" vr="CS" vm="1-n" name="Lossy Image Compression Method"/>
+        <entry group="0028" element="3000" keyword="ModalityLUTSequence" vr="SQ" vm="1" name="Modality LUT Sequence"/>
+        <entry group="0028" element="3002" keyword="LUTDescriptor" vr="US_SS" vm="3" name="LUT Descriptor"/>
+        <entry group="0028" element="3003" keyword="LUTExplanation" vr="LO" vm="1" name="LUT Explanation"/>
+        <entry group="0028" element="3004" keyword="ModalityLUTType" vr="LO" vm="1" name="Modality LUT Type"/>
+        <entry group="0028" element="3006" keyword="LUTData" vr="US_OW" vm="1-n" name="LUT Data"/>
+        <entry group="0028" element="3010" keyword="VOILUTSequence" vr="SQ" vm="1" name="VOI LUT Sequence"/>
+        <entry group="0028" element="3110" keyword="SoftcopyVOILUTSequence" vr="SQ" vm="1" name="Softcopy VOI LUT Sequence"/>
+        <entry group="0028" element="4000" keyword="ImagePresentationComments" vr="LT" vm="1" retired="true" name="Image Presentation Comments"/>
+        <entry group="0028" element="5000" keyword="BiPlaneAcquisitionSequence" vr="SQ" vm="1" retired="true" name="Bi-Plane Acquisition Sequence"/>
+        <entry group="0028" element="6010" keyword="RepresentativeFrameNumber" vr="US" vm="1" name="Representative Frame Number"/>
+        <entry group="0028" element="6020" keyword="FrameNumbersOfInterest" vr="US" vm="1-n" name="Frame Numbers of Interest (FOI)"/>
+        <entry group="0028" element="6022" keyword="FrameOfInterestDescription" vr="LO" vm="1-n" name="Frame of Interest Description"/>
+        <entry group="0028" element="6023" keyword="FrameOfInterestType" vr="CS" vm="1-n" name="Frame of Interest Type"/>
+        <entry group="0028" element="6030" keyword="MaskPointers" vr="US" vm="1-n" retired="true" name="Mask Pointer(s)"/>
+        <entry group="0028" element="6040" keyword="RWavePointer" vr="US" vm="1-n" name="R Wave Pointer"/>
+        <entry group="0028" element="6100" keyword="MaskSubtractionSequence" vr="SQ" vm="1" name="Mask Subtraction Sequence"/>
+        <entry group="0028" element="6101" keyword="MaskOperation" vr="CS" vm="1" name="Mask Operation"/>
+        <entry group="0028" element="6102" keyword="ApplicableFrameRange" vr="US" vm="2-2n" name="Applicable Frame Range"/>
+        <entry group="0028" element="6110" keyword="MaskFrameNumbers" vr="US" vm="1-n" name="Mask Frame Numbers"/>
+        <entry group="0028" element="6112" keyword="ContrastFrameAveraging" vr="US" vm="1" name="Contrast Frame Averaging"/>
+        <entry group="0028" element="6114" keyword="MaskSubPixelShift" vr="FL" vm="2" name="Mask Sub-pixel Shift"/>
+        <entry group="0028" element="6120" keyword="TIDOffset" vr="SS" vm="1" name="TID Offset"/>
+        <entry group="0028" element="6190" keyword="MaskOperationExplanation" vr="ST" vm="1" name="Mask Operation Explanation"/>
+        <entry group="0028" element="7000" keyword="EquipmentAdministratorSequence" vr="SQ" vm="1" name="Equipment Administrator Sequence"/>
+        <entry group="0028" element="7001" keyword="NumberOfDisplaySubsystems" vr="US" vm="1" name="Number of Display Subsystems"/>
+        <entry group="0028" element="7002" keyword="CurrentConfigurationID" vr="US" vm="1" name="Current Configuration ID"/>
+        <entry group="0028" element="7003" keyword="DisplaySubsystemID" vr="US" vm="1" name="Display Subsystem ID"/>
+        <entry group="0028" element="7004" keyword="DisplaySubsystemName" vr="SH" vm="1" name="Display Subsystem Name"/>
+        <entry group="0028" element="7005" keyword="DisplaySubsystemDescription" vr="LO" vm="1" name="Display Subsystem Description"/>
+        <entry group="0028" element="7006" keyword="SystemStatus" vr="CS" vm="1" name="System Status"/>
+        <entry group="0028" element="7007" keyword="SystemStatusComment" vr="LO" vm="1" name="System Status Comment"/>
+        <entry group="0028" element="7008" keyword="TargetLuminanceCharacteristicsSequence" vr="SQ" vm="1" name="Target Luminance Characteristics Sequence"/>
+        <entry group="0028" element="7009" keyword="LuminanceCharacteristicsID" vr="US" vm="1" name="Luminance Characteristics ID"/>
+        <entry group="0028" element="700a" keyword="DisplaySubsystemConfigurationSequence" vr="SQ" vm="1" name="Display Subsystem Configuration Sequence"/>
+        <entry group="0028" element="700b" keyword="ConfigurationID" vr="US" vm="1" name="Configuration ID"/>
+        <entry group="0028" element="700c" keyword="ConfigurationName" vr="SH" vm="1" name="Configuration Name"/>
+        <entry group="0028" element="700d" keyword="ConfigurationDescription" vr="LO" vm="1" name="Configuration Description"/>
+        <entry group="0028" element="700e" keyword="ReferencedTargetLuminanceCharacteristicsID" vr="US" vm="1" name="Referenced Target Luminance Characteristics ID"/>
+        <entry group="0028" element="700f" keyword="QAResultsSequence" vr="SQ" vm="1" name="QA Results Sequence"/>
+        <entry group="0028" element="7010" keyword="DisplaySubsystemQAResultsSequence" vr="SQ" vm="1" name="Display Subsystem QA Results Sequence"/>
+        <entry group="0028" element="7011" keyword="ConfigurationQAResultsSequence" vr="SQ" vm="1" name="Configuration QA Results Sequence"/>
+        <entry group="0028" element="7012" keyword="MeasurementEquipmentSequence" vr="SQ" vm="1" name="Measurement Equipment Sequence"/>
+        <entry group="0028" element="7013" keyword="MeasurementFunctions" vr="CS" vm="1-n" name="Measurement Functions"/>
+        <entry group="0028" element="7014" keyword="MeasurementEquipmentType" vr="CS" vm="1" name="Measurement Equipment Type"/>
+        <entry group="0028" element="7015" keyword="VisualEvaluationResultSequence" vr="SQ" vm="1" name="Visual Evaluation Result Sequence"/>
+        <entry group="0028" element="7016" keyword="DisplayCalibrationResultSequence" vr="SQ" vm="1" name="Display Calibration Result Sequence"/>
+        <entry group="0028" element="7017" keyword="DDLValue" vr="US" vm="1" name="DDL Value"/>
+        <entry group="0028" element="7018" keyword="CIExyWhitePoint" vr="FL" vm="2" name="CIExy White Point"/>
+        <entry group="0028" element="7019" keyword="DisplayFunctionType" vr="CS" vm="1" name="Display Function Type"/>
+        <entry group="0028" element="701a" keyword="GammaValue" vr="FL" vm="1" name="Gamma Value"/>
+        <entry group="0028" element="701b" keyword="NumberOfLuminancePoints" vr="US" vm="1" name="Number of Luminance Points"/>
+        <entry group="0028" element="701c" keyword="LuminanceResponseSequence" vr="SQ" vm="1" name="Luminance Response Sequence"/>
+        <entry group="0028" element="701d" keyword="TargetMinimumLuminance" vr="FL" vm="1" name="Target Minimum Luminance"/>
+        <entry group="0028" element="701e" keyword="TargetMaximumLuminance" vr="FL" vm="1" name="Target Maximum Luminance"/>
+        <entry group="0028" element="701f" keyword="LuminanceValue" vr="FL" vm="1" name="Luminance Value"/>
+        <entry group="0028" element="7020" keyword="LuminanceResponseDescription" vr="LO" vm="1" name="Luminance Response Description"/>
+        <entry group="0028" element="7021" keyword="WhitePointFlag" vr="CS" vm="1" name="White Point Flag"/>
+        <entry group="0028" element="7022" keyword="DisplayDeviceTypeCodeSequence" vr="SQ" vm="1" name="Display Device Type Code Sequence"/>
+        <entry group="0028" element="7023" keyword="DisplaySubsystemSequence" vr="SQ" vm="1" name="Display Subsystem Sequence"/>
+        <entry group="0028" element="7024" keyword="LuminanceResultSequence" vr="SQ" vm="1" name="Luminance Result Sequence"/>
+        <entry group="0028" element="7025" keyword="AmbientLightValueSource" vr="CS" vm="1" name="Ambient Light Value Source"/>
+        <entry group="0028" element="7026" keyword="MeasuredCharacteristics" vr="CS" vm="1-n" name="Measured Characteristics"/>
+        <entry group="0028" element="7027" keyword="LuminanceUniformityResultSequence" vr="SQ" vm="1" name="Luminance Uniformity Result Sequence"/>
+        <entry group="0028" element="7028" keyword="VisualEvaluationTestSequence" vr="SQ" vm="1" name="Visual Evaluation Test Sequence"/>
+        <entry group="0028" element="7029" keyword="TestResult" vr="CS" vm="1" name="Test Result"/>
+        <entry group="0028" element="702a" keyword="TestResultComment" vr="LO" vm="1" name="Test Result Comment"/>
+        <entry group="0028" element="702b" keyword="TestImageValidation" vr="CS" vm="1" name="Test Image Validation"/>
+        <entry group="0028" element="702c" keyword="TestPatternCodeSequence" vr="SQ" vm="1" name="Test Pattern Code Sequence"/>
+        <entry group="0028" element="702d" keyword="MeasurementPatternCodeSequence" vr="SQ" vm="1" name="Measurement Pattern Code Sequence"/>
+        <entry group="0028" element="702e" keyword="VisualEvaluationMethodCodeSequence" vr="SQ" vm="1" name="Visual Evaluation Method Code Sequence"/>
+        <entry group="0028" element="7fe0" keyword="PixelDataProviderURL" vr="UR" vm="1" name="Pixel Data Provider URL"/>
+        <entry group="0028" element="9001" keyword="DataPointRows" vr="UL" vm="1" name="Data Point Rows"/>
+        <entry group="0028" element="9002" keyword="DataPointColumns" vr="UL" vm="1" name="Data Point Columns"/>
+        <entry group="0028" element="9003" keyword="SignalDomainColumns" vr="CS" vm="1" name="Signal Domain Columns"/>
+        <entry group="0028" element="9099" keyword="LargestMonochromePixelValue" vr="US" vm="1" retired="true" name="Largest Monochrome Pixel Value"/>
+        <entry group="0028" element="9108" keyword="DataRepresentation" vr="CS" vm="1" name="Data Representation"/>
+        <entry group="0028" element="9110" keyword="PixelMeasuresSequence" vr="SQ" vm="1" name="Pixel Measures Sequence"/>
+        <entry group="0028" element="9132" keyword="FrameVOILUTSequence" vr="SQ" vm="1" name="Frame VOI LUT Sequence"/>
+        <entry group="0028" element="9145" keyword="PixelValueTransformationSequence" vr="SQ" vm="1" name="Pixel Value Transformation Sequence"/>
+        <entry group="0028" element="9235" keyword="SignalDomainRows" vr="CS" vm="1" name="Signal Domain Rows"/>
+        <entry group="0028" element="9411" keyword="DisplayFilterPercentage" vr="FL" vm="1" name="Display Filter Percentage"/>
+        <entry group="0028" element="9415" keyword="FramePixelShiftSequence" vr="SQ" vm="1" name="Frame Pixel Shift Sequence"/>
+        <entry group="0028" element="9416" keyword="SubtractionItemID" vr="US" vm="1" name="Subtraction Item ID"/>
+        <entry group="0028" element="9422" keyword="PixelIntensityRelationshipLUTSequence" vr="SQ" vm="1" name="Pixel Intensity Relationship LUT Sequence"/>
+        <entry group="0028" element="9443" keyword="FramePixelDataPropertiesSequence" vr="SQ" vm="1" name="Frame Pixel Data Properties Sequence"/>
+        <entry group="0028" element="9444" keyword="GeometricalProperties" vr="CS" vm="1" name="Geometrical Properties"/>
+        <entry group="0028" element="9445" keyword="GeometricMaximumDistortion" vr="FL" vm="1" name="Geometric Maximum Distortion"/>
+        <entry group="0028" element="9446" keyword="ImageProcessingApplied" vr="CS" vm="1-n" name="Image Processing Applied"/>
+        <entry group="0028" element="9454" keyword="MaskSelectionMode" vr="CS" vm="1" name="Mask Selection Mode"/>
+        <entry group="0028" element="9474" keyword="LUTFunction" vr="CS" vm="1" name="LUT Function"/>
+        <entry group="0028" element="9478" keyword="MaskVisibilityPercentage" vr="FL" vm="1" name="Mask Visibility Percentage"/>
+        <entry group="0028" element="9501" keyword="PixelShiftSequence" vr="SQ" vm="1" name="Pixel Shift Sequence"/>
+        <entry group="0028" element="9502" keyword="RegionPixelShiftSequence" vr="SQ" vm="1" name="Region Pixel Shift Sequence"/>
+        <entry group="0028" element="9503" keyword="VerticesOfTheRegion" vr="SS" vm="2-2n" name="Vertices of the Region"/>
+        <entry group="0028" element="9505" keyword="MultiFramePresentationSequence" vr="SQ" vm="1" name="Multi-frame Presentation Sequence"/>
+        <entry group="0028" element="9506" keyword="PixelShiftFrameRange" vr="US" vm="2-2n" name="Pixel Shift Frame Range"/>
+        <entry group="0028" element="9507" keyword="LUTFrameRange" vr="US" vm="2-2n" name="LUT Frame Range"/>
+        <entry group="0028" element="9520" keyword="ImageToEquipmentMappingMatrix" vr="DS" vm="16" name="Image to Equipment Mapping Matrix"/>
+        <entry group="0028" element="9537" keyword="EquipmentCoordinateSystemIdentification" vr="CS" vm="1" name="Equipment Coordinate System Identification"/>
+        <entry group="0032" element="000a" keyword="StudyStatusID" vr="CS" vm="1" retired="true" name="Study Status ID"/>
+        <entry group="0032" element="000c" keyword="StudyPriorityID" vr="CS" vm="1" retired="true" name="Study Priority ID"/>
+        <entry group="0032" element="0012" keyword="StudyIDIssuer" vr="LO" vm="1" retired="true" name="Study ID Issuer"/>
+        <entry group="0032" element="0032" keyword="StudyVerifiedDate" vr="DA" vm="1" retired="true" name="Study Verified Date"/>
+        <entry group="0032" element="0033" keyword="StudyVerifiedTime" vr="TM" vm="1" retired="true" name="Study Verified Time"/>
+        <entry group="0032" element="0034" keyword="StudyReadDate" vr="DA" vm="1" retired="true" name="Study Read Date"/>
+        <entry group="0032" element="0035" keyword="StudyReadTime" vr="TM" vm="1" retired="true" name="Study Read Time"/>
+        <entry group="0032" element="1000" keyword="ScheduledStudyStartDate" vr="DA" vm="1" retired="true" name="Scheduled Study Start Date"/>
+        <entry group="0032" element="1001" keyword="ScheduledStudyStartTime" vr="TM" vm="1" retired="true" name="Scheduled Study Start Time"/>
+        <entry group="0032" element="1010" keyword="ScheduledStudyStopDate" vr="DA" vm="1" retired="true" name="Scheduled Study Stop Date"/>
+        <entry group="0032" element="1011" keyword="ScheduledStudyStopTime" vr="TM" vm="1" retired="true" name="Scheduled Study Stop Time"/>
+        <entry group="0032" element="1020" keyword="ScheduledStudyLocation" vr="LO" vm="1" retired="true" name="Scheduled Study Location"/>
+        <entry group="0032" element="1021" keyword="ScheduledStudyLocationAETitle" vr="AE" vm="1-n" retired="true" name="Scheduled Study Location AE Title"/>
+        <entry group="0032" element="1030" keyword="ReasonForStudy" vr="LO" vm="1" retired="true" name="Reason for Study"/>
+        <entry group="0032" element="1031" keyword="RequestingPhysicianIdentificationSequence" vr="SQ" vm="1" name="Requesting Physician Identification Sequence"/>
+        <entry group="0032" element="1032" keyword="RequestingPhysician" vr="PN" vm="1" name="Requesting Physician"/>
+        <entry group="0032" element="1033" keyword="RequestingService" vr="LO" vm="1" name="Requesting Service"/>
+        <entry group="0032" element="1034" keyword="RequestingServiceCodeSequence" vr="SQ" vm="1" name="Requesting Service Code Sequence"/>
+        <entry group="0032" element="1040" keyword="StudyArrivalDate" vr="DA" vm="1" retired="true" name="Study Arrival Date"/>
+        <entry group="0032" element="1041" keyword="StudyArrivalTime" vr="TM" vm="1" retired="true" name="Study Arrival Time"/>
+        <entry group="0032" element="1050" keyword="StudyCompletionDate" vr="DA" vm="1" retired="true" name="Study Completion Date"/>
+        <entry group="0032" element="1051" keyword="StudyCompletionTime" vr="TM" vm="1" retired="true" name="Study Completion Time"/>
+        <entry group="0032" element="1055" keyword="StudyComponentStatusID" vr="CS" vm="1" retired="true" name="Study Component Status ID"/>
+        <entry group="0032" element="1060" keyword="RequestedProcedureDescription" vr="LO" vm="1" name="Requested Procedure Description"/>
+        <entry group="0032" element="1064" keyword="RequestedProcedureCodeSequence" vr="SQ" vm="1" name="Requested Procedure Code Sequence"/>
+        <entry group="0032" element="1070" keyword="RequestedContrastAgent" vr="LO" vm="1" name="Requested Contrast Agent"/>
+        <entry group="0032" element="4000" keyword="StudyComments" vr="LT" vm="1" retired="true" name="Study Comments"/>
+        <entry group="0038" element="0004" keyword="ReferencedPatientAliasSequence" vr="SQ" vm="1" name="Referenced Patient Alias Sequence"/>
+        <entry group="0038" element="0008" keyword="VisitStatusID" vr="CS" vm="1" name="Visit Status ID"/>
+        <entry group="0038" element="0010" keyword="AdmissionID" vr="LO" vm="1" name="Admission ID"/>
+        <entry group="0038" element="0011" keyword="IssuerOfAdmissionID" vr="LO" vm="1" retired="true" name="Issuer of Admission ID"/>
+        <entry group="0038" element="0014" keyword="IssuerOfAdmissionIDSequence" vr="SQ" vm="1" name="Issuer of Admission ID Sequence"/>
+        <entry group="0038" element="0016" keyword="RouteOfAdmissions" vr="LO" vm="1" name="Route of Admissions"/>
+        <entry group="0038" element="001a" keyword="ScheduledAdmissionDate" vr="DA" vm="1" retired="true" name="Scheduled Admission Date"/>
+        <entry group="0038" element="001b" keyword="ScheduledAdmissionTime" vr="TM" vm="1" retired="true" name="Scheduled Admission Time"/>
+        <entry group="0038" element="001c" keyword="ScheduledDischargeDate" vr="DA" vm="1" retired="true" name="Scheduled Discharge Date"/>
+        <entry group="0038" element="001d" keyword="ScheduledDischargeTime" vr="TM" vm="1" retired="true" name="Scheduled Discharge Time"/>
+        <entry group="0038" element="001e" keyword="ScheduledPatientInstitutionResidence" vr="LO" vm="1" retired="true" name="Scheduled Patient Institution Residence"/>
+        <entry group="0038" element="0020" keyword="AdmittingDate" vr="DA" vm="1" name="Admitting Date"/>
+        <entry group="0038" element="0021" keyword="AdmittingTime" vr="TM" vm="1" name="Admitting Time"/>
+        <entry group="0038" element="0030" keyword="DischargeDate" vr="DA" vm="1" retired="true" name="Discharge Date"/>
+        <entry group="0038" element="0032" keyword="DischargeTime" vr="TM" vm="1" retired="true" name="Discharge Time"/>
+        <entry group="0038" element="0040" keyword="DischargeDiagnosisDescription" vr="LO" vm="1" retired="true" name="Discharge Diagnosis Description"/>
+        <entry group="0038" element="0044" keyword="DischargeDiagnosisCodeSequence" vr="SQ" vm="1" retired="true" name="Discharge Diagnosis Code Sequence"/>
+        <entry group="0038" element="0050" keyword="SpecialNeeds" vr="LO" vm="1" name="Special Needs"/>
+        <entry group="0038" element="0060" keyword="ServiceEpisodeID" vr="LO" vm="1" name="Service Episode ID"/>
+        <entry group="0038" element="0061" keyword="IssuerOfServiceEpisodeID" vr="LO" vm="1" retired="true" name="Issuer of Service Episode ID"/>
+        <entry group="0038" element="0062" keyword="ServiceEpisodeDescription" vr="LO" vm="1" name="Service Episode Description"/>
+        <entry group="0038" element="0064" keyword="IssuerOfServiceEpisodeIDSequence" vr="SQ" vm="1" name="Issuer of Service Episode ID Sequence"/>
+        <entry group="0038" element="0100" keyword="PertinentDocumentsSequence" vr="SQ" vm="1" name="Pertinent Documents Sequence"/>
+        <entry group="0038" element="0101" keyword="PertinentResourcesSequence" vr="SQ" vm="1" name="Pertinent Resources Sequence"/>
+        <entry group="0038" element="0102" keyword="ResourceDescription" vr="LO" vm="1" name="Resource Description"/>
+        <entry group="0038" element="0300" keyword="CurrentPatientLocation" vr="LO" vm="1" name="Current Patient Location"/>
+        <entry group="0038" element="0400" keyword="PatientInstitutionResidence" vr="LO" vm="1" name="Patient's Institution Residence"/>
+        <entry group="0038" element="0500" keyword="PatientState" vr="LO" vm="1" name="Patient State"/>
+        <entry group="0038" element="0502" keyword="PatientClinicalTrialParticipationSequence" vr="SQ" vm="1" name="Patient Clinical Trial Participation Sequence"/>
+        <entry group="0038" element="4000" keyword="VisitComments" vr="LT" vm="1" name="Visit Comments"/>
+        <entry group="003a" element="0004" keyword="WaveformOriginality" vr="CS" vm="1" name="Waveform Originality"/>
+        <entry group="003a" element="0005" keyword="NumberOfWaveformChannels" vr="US" vm="1" name="Number of Waveform Channels"/>
+        <entry group="003a" element="0010" keyword="NumberOfWaveformSamples" vr="UL" vm="1" name="Number of Waveform Samples"/>
+        <entry group="003a" element="001a" keyword="SamplingFrequency" vr="DS" vm="1" name="Sampling Frequency"/>
+        <entry group="003a" element="0020" keyword="MultiplexGroupLabel" vr="SH" vm="1" name="Multiplex Group Label"/>
+        <entry group="003a" element="0200" keyword="ChannelDefinitionSequence" vr="SQ" vm="1" name="Channel Definition Sequence"/>
+        <entry group="003a" element="0202" keyword="WaveformChannelNumber" vr="IS" vm="1" name="Waveform Channel Number"/>
+        <entry group="003a" element="0203" keyword="ChannelLabel" vr="SH" vm="1" name="Channel Label"/>
+        <entry group="003a" element="0205" keyword="ChannelStatus" vr="CS" vm="1-n" name="Channel Status"/>
+        <entry group="003a" element="0208" keyword="ChannelSourceSequence" vr="SQ" vm="1" name="Channel Source Sequence"/>
+        <entry group="003a" element="0209" keyword="ChannelSourceModifiersSequence" vr="SQ" vm="1" name="Channel Source Modifiers Sequence"/>
+        <entry group="003a" element="020a" keyword="SourceWaveformSequence" vr="SQ" vm="1" name="Source Waveform Sequence"/>
+        <entry group="003a" element="020c" keyword="ChannelDerivationDescription" vr="LO" vm="1" name="Channel Derivation Description"/>
+        <entry group="003a" element="0210" keyword="ChannelSensitivity" vr="DS" vm="1" name="Channel Sensitivity"/>
+        <entry group="003a" element="0211" keyword="ChannelSensitivityUnitsSequence" vr="SQ" vm="1" name="Channel Sensitivity Units Sequence"/>
+        <entry group="003a" element="0212" keyword="ChannelSensitivityCorrectionFactor" vr="DS" vm="1" name="Channel Sensitivity Correction Factor"/>
+        <entry group="003a" element="0213" keyword="ChannelBaseline" vr="DS" vm="1" name="Channel Baseline"/>
+        <entry group="003a" element="0214" keyword="ChannelTimeSkew" vr="DS" vm="1" name="Channel Time Skew"/>
+        <entry group="003a" element="0215" keyword="ChannelSampleSkew" vr="DS" vm="1" name="Channel Sample Skew"/>
+        <entry group="003a" element="0218" keyword="ChannelOffset" vr="DS" vm="1" name="Channel Offset"/>
+        <entry group="003a" element="021a" keyword="WaveformBitsStored" vr="US" vm="1" name="Waveform Bits Stored"/>
+        <entry group="003a" element="0220" keyword="FilterLowFrequency" vr="DS" vm="1" name="Filter Low Frequency"/>
+        <entry group="003a" element="0221" keyword="FilterHighFrequency" vr="DS" vm="1" name="Filter High Frequency"/>
+        <entry group="003a" element="0222" keyword="NotchFilterFrequency" vr="DS" vm="1" name="Notch Filter Frequency"/>
+        <entry group="003a" element="0223" keyword="NotchFilterBandwidth" vr="DS" vm="1" name="Notch Filter Bandwidth"/>
+        <entry group="003a" element="0230" keyword="WaveformDataDisplayScale" vr="FL" vm="1" name="Waveform Data Display Scale"/>
+        <entry group="003a" element="0231" keyword="WaveformDisplayBackgroundCIELabValue" vr="US" vm="3" name="Waveform Display Background CIELab Value"/>
+        <entry group="003a" element="0240" keyword="WaveformPresentationGroupSequence" vr="SQ" vm="1" name="Waveform Presentation Group Sequence"/>
+        <entry group="003a" element="0241" keyword="PresentationGroupNumber" vr="US" vm="1" name="Presentation Group Number"/>
+        <entry group="003a" element="0242" keyword="ChannelDisplaySequence" vr="SQ" vm="1" name="Channel Display Sequence"/>
+        <entry group="003a" element="0244" keyword="ChannelRecommendedDisplayCIELabValue" vr="US" vm="3" name="Channel Recommended Display CIELab Value"/>
+        <entry group="003a" element="0245" keyword="ChannelPosition" vr="FL" vm="1" name="Channel Position"/>
+        <entry group="003a" element="0246" keyword="DisplayShadingFlag" vr="CS" vm="1" name="Display Shading Flag"/>
+        <entry group="003a" element="0247" keyword="FractionalChannelDisplayScale" vr="FL" vm="1" name="Fractional Channel Display Scale"/>
+        <entry group="003a" element="0248" keyword="AbsoluteChannelDisplayScale" vr="FL" vm="1" name="Absolute Channel Display Scale"/>
+        <entry group="003a" element="0300" keyword="MultiplexedAudioChannelsDescriptionCodeSequence" vr="SQ" vm="1" name="Multiplexed Audio Channels Description Code Sequence"/>
+        <entry group="003a" element="0301" keyword="ChannelIdentificationCode" vr="IS" vm="1" name="Channel Identification Code"/>
+        <entry group="003a" element="0302" keyword="ChannelMode" vr="CS" vm="1" name="Channel Mode"/>
+        <entry group="0040" element="0001" keyword="ScheduledStationAETitle" vr="AE" vm="1-n" name="Scheduled Station AE Title"/>
+        <entry group="0040" element="0002" keyword="ScheduledProcedureStepStartDate" vr="DA" vm="1" name="Scheduled Procedure Step Start Date"/>
+        <entry group="0040" element="0003" keyword="ScheduledProcedureStepStartTime" vr="TM" vm="1" name="Scheduled Procedure Step Start Time"/>
+        <entry group="0040" element="0004" keyword="ScheduledProcedureStepEndDate" vr="DA" vm="1" name="Scheduled Procedure Step End Date"/>
+        <entry group="0040" element="0005" keyword="ScheduledProcedureStepEndTime" vr="TM" vm="1" name="Scheduled Procedure Step End Time"/>
+        <entry group="0040" element="0006" keyword="ScheduledPerformingPhysicianName" vr="PN" vm="1" name="Scheduled Performing Physician's Name"/>
+        <entry group="0040" element="0007" keyword="ScheduledProcedureStepDescription" vr="LO" vm="1" name="Scheduled Procedure Step Description"/>
+        <entry group="0040" element="0008" keyword="ScheduledProtocolCodeSequence" vr="SQ" vm="1" name="Scheduled Protocol Code Sequence"/>
+        <entry group="0040" element="0009" keyword="ScheduledProcedureStepID" vr="SH" vm="1" name="Scheduled Procedure Step ID"/>
+        <entry group="0040" element="000a" keyword="StageCodeSequence" vr="SQ" vm="1" name="Stage Code Sequence"/>
+        <entry group="0040" element="000b" keyword="ScheduledPerformingPhysicianIdentificationSequence" vr="SQ" vm="1" name="Scheduled Performing Physician Identification Sequence"/>
+        <entry group="0040" element="0010" keyword="ScheduledStationName" vr="SH" vm="1-n" name="Scheduled Station Name"/>
+        <entry group="0040" element="0011" keyword="ScheduledProcedureStepLocation" vr="SH" vm="1" name="Scheduled Procedure Step Location"/>
+        <entry group="0040" element="0012" keyword="PreMedication" vr="LO" vm="1" name="Pre-Medication"/>
+        <entry group="0040" element="0020" keyword="ScheduledProcedureStepStatus" vr="CS" vm="1" name="Scheduled Procedure Step Status"/>
+        <entry group="0040" element="0026" keyword="OrderPlacerIdentifierSequence" vr="SQ" vm="1" name="Order Placer Identifier Sequence"/>
+        <entry group="0040" element="0027" keyword="OrderFillerIdentifierSequence" vr="SQ" vm="1" name="Order Filler Identifier Sequence"/>
+        <entry group="0040" element="0031" keyword="LocalNamespaceEntityID" vr="UT" vm="1" name="Local Namespace Entity ID"/>
+        <entry group="0040" element="0032" keyword="UniversalEntityID" vr="UT" vm="1" name="Universal Entity ID"/>
+        <entry group="0040" element="0033" keyword="UniversalEntityIDType" vr="CS" vm="1" name="Universal Entity ID Type"/>
+        <entry group="0040" element="0035" keyword="IdentifierTypeCode" vr="CS" vm="1" name="Identifier Type Code"/>
+        <entry group="0040" element="0036" keyword="AssigningFacilitySequence" vr="SQ" vm="1" name="Assigning Facility Sequence"/>
+        <entry group="0040" element="0039" keyword="AssigningJurisdictionCodeSequence" vr="SQ" vm="1" name="Assigning Jurisdiction Code Sequence"/>
+        <entry group="0040" element="003a" keyword="AssigningAgencyOrDepartmentCodeSequence" vr="SQ" vm="1" name="Assigning Agency or Department Code Sequence"/>
+        <entry group="0040" element="0100" keyword="ScheduledProcedureStepSequence" vr="SQ" vm="1" name="Scheduled Procedure Step Sequence"/>
+        <entry group="0040" element="0220" keyword="ReferencedNonImageCompositeSOPInstanceSequence" vr="SQ" vm="1" name="Referenced Non-Image Composite SOP Instance Sequence"/>
+        <entry group="0040" element="0241" keyword="PerformedStationAETitle" vr="AE" vm="1" name="Performed Station AE Title"/>
+        <entry group="0040" element="0242" keyword="PerformedStationName" vr="SH" vm="1" name="Performed Station Name"/>
+        <entry group="0040" element="0243" keyword="PerformedLocation" vr="SH" vm="1" name="Performed Location"/>
+        <entry group="0040" element="0244" keyword="PerformedProcedureStepStartDate" vr="DA" vm="1" name="Performed Procedure Step Start Date"/>
+        <entry group="0040" element="0245" keyword="PerformedProcedureStepStartTime" vr="TM" vm="1" name="Performed Procedure Step Start Time"/>
+        <entry group="0040" element="0250" keyword="PerformedProcedureStepEndDate" vr="DA" vm="1" name="Performed Procedure Step End Date"/>
+        <entry group="0040" element="0251" keyword="PerformedProcedureStepEndTime" vr="TM" vm="1" name="Performed Procedure Step End Time"/>
+        <entry group="0040" element="0252" keyword="PerformedProcedureStepStatus" vr="CS" vm="1" name="Performed Procedure Step Status"/>
+        <entry group="0040" element="0253" keyword="PerformedProcedureStepID" vr="SH" vm="1" name="Performed Procedure Step ID"/>
+        <entry group="0040" element="0254" keyword="PerformedProcedureStepDescription" vr="LO" vm="1" name="Performed Procedure Step Description"/>
+        <entry group="0040" element="0255" keyword="PerformedProcedureTypeDescription" vr="LO" vm="1" name="Performed Procedure Type Description"/>
+        <entry group="0040" element="0260" keyword="PerformedProtocolCodeSequence" vr="SQ" vm="1" name="Performed Protocol Code Sequence"/>
+        <entry group="0040" element="0261" keyword="PerformedProtocolType" vr="CS" vm="1" name="Performed Protocol Type"/>
+        <entry group="0040" element="0270" keyword="ScheduledStepAttributesSequence" vr="SQ" vm="1" name="Scheduled Step Attributes Sequence"/>
+        <entry group="0040" element="0275" keyword="RequestAttributesSequence" vr="SQ" vm="1" name="Request Attributes Sequence"/>
+        <entry group="0040" element="0280" keyword="CommentsOnThePerformedProcedureStep" vr="ST" vm="1" name="Comments on the Performed Procedure Step"/>
+        <entry group="0040" element="0281" keyword="PerformedProcedureStepDiscontinuationReasonCodeSequence" vr="SQ" vm="1" name="Performed Procedure Step Discontinuation Reason Code Sequence"/>
+        <entry group="0040" element="0293" keyword="QuantitySequence" vr="SQ" vm="1" name="Quantity Sequence"/>
+        <entry group="0040" element="0294" keyword="Quantity" vr="DS" vm="1" name="Quantity"/>
+        <entry group="0040" element="0295" keyword="MeasuringUnitsSequence" vr="SQ" vm="1" name="Measuring Units Sequence"/>
+        <entry group="0040" element="0296" keyword="BillingItemSequence" vr="SQ" vm="1" name="Billing Item Sequence"/>
+        <entry group="0040" element="0300" keyword="TotalTimeOfFluoroscopy" vr="US" vm="1" name="Total Time of Fluoroscopy"/>
+        <entry group="0040" element="0301" keyword="TotalNumberOfExposures" vr="US" vm="1" name="Total Number of Exposures"/>
+        <entry group="0040" element="0302" keyword="EntranceDose" vr="US" vm="1" name="Entrance Dose"/>
+        <entry group="0040" element="0303" keyword="ExposedArea" vr="US" vm="1-2" name="Exposed Area"/>
+        <entry group="0040" element="0306" keyword="DistanceSourceToEntrance" vr="DS" vm="1" name="Distance Source to Entrance"/>
+        <entry group="0040" element="0307" keyword="DistanceSourceToSupport" vr="DS" vm="1" retired="true" name="Distance Source to Support"/>
+        <entry group="0040" element="030e" keyword="ExposureDoseSequence" vr="SQ" vm="1" name="Exposure Dose Sequence"/>
+        <entry group="0040" element="0310" keyword="CommentsOnRadiationDose" vr="ST" vm="1" name="Comments on Radiation Dose"/>
+        <entry group="0040" element="0312" keyword="XRayOutput" vr="DS" vm="1" name="X-Ray Output"/>
+        <entry group="0040" element="0314" keyword="HalfValueLayer" vr="DS" vm="1" name="Half Value Layer"/>
+        <entry group="0040" element="0316" keyword="OrganDose" vr="DS" vm="1" name="Organ Dose"/>
+        <entry group="0040" element="0318" keyword="OrganExposed" vr="CS" vm="1" name="Organ Exposed"/>
+        <entry group="0040" element="0320" keyword="BillingProcedureStepSequence" vr="SQ" vm="1" name="Billing Procedure Step Sequence"/>
+        <entry group="0040" element="0321" keyword="FilmConsumptionSequence" vr="SQ" vm="1" name="Film Consumption Sequence"/>
+        <entry group="0040" element="0324" keyword="BillingSuppliesAndDevicesSequence" vr="SQ" vm="1" name="Billing Supplies and Devices Sequence"/>
+        <entry group="0040" element="0330" keyword="ReferencedProcedureStepSequence" vr="SQ" vm="1" retired="true" name="Referenced Procedure Step Sequence"/>
+        <entry group="0040" element="0340" keyword="PerformedSeriesSequence" vr="SQ" vm="1" name="Performed Series Sequence"/>
+        <entry group="0040" element="0400" keyword="CommentsOnTheScheduledProcedureStep" vr="LT" vm="1" name="Comments on the Scheduled Procedure Step"/>
+        <entry group="0040" element="0440" keyword="ProtocolContextSequence" vr="SQ" vm="1" name="Protocol Context Sequence"/>
+        <entry group="0040" element="0441" keyword="ContentItemModifierSequence" vr="SQ" vm="1" name="Content Item Modifier Sequence"/>
+        <entry group="0040" element="0500" keyword="ScheduledSpecimenSequence" vr="SQ" vm="1" name="Scheduled Specimen Sequence"/>
+        <entry group="0040" element="050a" keyword="SpecimenAccessionNumber" vr="LO" vm="1" retired="true" name="Specimen Accession Number"/>
+        <entry group="0040" element="0512" keyword="ContainerIdentifier" vr="LO" vm="1" name="Container Identifier"/>
+        <entry group="0040" element="0513" keyword="IssuerOfTheContainerIdentifierSequence" vr="SQ" vm="1" name="Issuer of the Container Identifier Sequence"/>
+        <entry group="0040" element="0515" keyword="AlternateContainerIdentifierSequence" vr="SQ" vm="1" name="Alternate Container Identifier Sequence"/>
+        <entry group="0040" element="0518" keyword="ContainerTypeCodeSequence" vr="SQ" vm="1" name="Container Type Code Sequence"/>
+        <entry group="0040" element="051a" keyword="ContainerDescription" vr="LO" vm="1" name="Container Description"/>
+        <entry group="0040" element="0520" keyword="ContainerComponentSequence" vr="SQ" vm="1" name="Container Component Sequence"/>
+        <entry group="0040" element="0550" keyword="SpecimenSequence" vr="SQ" vm="1" retired="true" name="Specimen Sequence"/>
+        <entry group="0040" element="0551" keyword="SpecimenIdentifier" vr="LO" vm="1" name="Specimen Identifier"/>
+        <entry group="0040" element="0552" keyword="SpecimenDescriptionSequenceTrial" vr="SQ" vm="1" retired="true" name="Specimen Description Sequence (Trial)"/>
+        <entry group="0040" element="0553" keyword="SpecimenDescriptionTrial" vr="ST" vm="1" retired="true" name="Specimen Description (Trial)"/>
+        <entry group="0040" element="0554" keyword="SpecimenUID" vr="UI" vm="1" name="Specimen UID"/>
+        <entry group="0040" element="0555" keyword="AcquisitionContextSequence" vr="SQ" vm="1" name="Acquisition Context Sequence"/>
+        <entry group="0040" element="0556" keyword="AcquisitionContextDescription" vr="ST" vm="1" name="Acquisition Context Description"/>
+        <entry group="0040" element="059a" keyword="SpecimenTypeCodeSequence" vr="SQ" vm="1" name="Specimen Type Code Sequence"/>
+        <entry group="0040" element="0560" keyword="SpecimenDescriptionSequence" vr="SQ" vm="1" name="Specimen Description Sequence"/>
+        <entry group="0040" element="0562" keyword="IssuerOfTheSpecimenIdentifierSequence" vr="SQ" vm="1" name="Issuer of the Specimen Identifier Sequence"/>
+        <entry group="0040" element="0600" keyword="SpecimenShortDescription" vr="LO" vm="1" name="Specimen Short Description"/>
+        <entry group="0040" element="0602" keyword="SpecimenDetailedDescription" vr="UT" vm="1" name="Specimen Detailed Description"/>
+        <entry group="0040" element="0610" keyword="SpecimenPreparationSequence" vr="SQ" vm="1" name="Specimen Preparation Sequence"/>
+        <entry group="0040" element="0612" keyword="SpecimenPreparationStepContentItemSequence" vr="SQ" vm="1" name="Specimen Preparation Step Content Item Sequence"/>
+        <entry group="0040" element="0620" keyword="SpecimenLocalizationContentItemSequence" vr="SQ" vm="1" name="Specimen Localization Content Item Sequence"/>
+        <entry group="0040" element="06fa" keyword="SlideIdentifier" vr="LO" vm="1" retired="true" name="Slide Identifier"/>
+        <entry group="0040" element="071a" keyword="ImageCenterPointCoordinatesSequence" vr="SQ" vm="1" name="Image Center Point Coordinates Sequence"/>
+        <entry group="0040" element="072a" keyword="XOffsetInSlideCoordinateSystem" vr="DS" vm="1" name="X Offset in Slide Coordinate System"/>
+        <entry group="0040" element="073a" keyword="YOffsetInSlideCoordinateSystem" vr="DS" vm="1" name="Y Offset in Slide Coordinate System"/>
+        <entry group="0040" element="074a" keyword="ZOffsetInSlideCoordinateSystem" vr="DS" vm="1" name="Z Offset in Slide Coordinate System"/>
+        <entry group="0040" element="08d8" keyword="PixelSpacingSequence" vr="SQ" vm="1" retired="true" name="Pixel Spacing Sequence"/>
+        <entry group="0040" element="08da" keyword="CoordinateSystemAxisCodeSequence" vr="SQ" vm="1" retired="true" name="Coordinate System Axis Code Sequence"/>
+        <entry group="0040" element="08ea" keyword="MeasurementUnitsCodeSequence" vr="SQ" vm="1" name="Measurement Units Code Sequence"/>
+        <entry group="0040" element="09f8" keyword="VitalStainCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Vital Stain Code Sequence (Trial)"/>
+        <entry group="0040" element="1001" keyword="RequestedProcedureID" vr="SH" vm="1" name="Requested Procedure ID"/>
+        <entry group="0040" element="1002" keyword="ReasonForTheRequestedProcedure" vr="LO" vm="1" name="Reason for the Requested Procedure"/>
+        <entry group="0040" element="1003" keyword="RequestedProcedurePriority" vr="SH" vm="1" name="Requested Procedure Priority"/>
+        <entry group="0040" element="1004" keyword="PatientTransportArrangements" vr="LO" vm="1" name="Patient Transport Arrangements"/>
+        <entry group="0040" element="1005" keyword="RequestedProcedureLocation" vr="LO" vm="1" name="Requested Procedure Location"/>
+        <entry group="0040" element="1006" keyword="PlacerOrderNumberProcedure" vr="SH" vm="1" retired="true" name="Placer Order Number / Procedure"/>
+        <entry group="0040" element="1007" keyword="FillerOrderNumberProcedure" vr="SH" vm="1" retired="true" name="Filler Order Number / Procedure"/>
+        <entry group="0040" element="1008" keyword="ConfidentialityCode" vr="LO" vm="1" name="Confidentiality Code"/>
+        <entry group="0040" element="1009" keyword="ReportingPriority" vr="SH" vm="1" name="Reporting Priority"/>
+        <entry group="0040" element="100a" keyword="ReasonForRequestedProcedureCodeSequence" vr="SQ" vm="1" name="Reason for Requested Procedure Code Sequence"/>
+        <entry group="0040" element="1010" keyword="NamesOfIntendedRecipientsOfResults" vr="PN" vm="1-n" name="Names of Intended Recipients of Results"/>
+        <entry group="0040" element="1011" keyword="IntendedRecipientsOfResultsIdentificationSequence" vr="SQ" vm="1" name="Intended Recipients of Results Identification Sequence"/>
+        <entry group="0040" element="1012" keyword="ReasonForPerformedProcedureCodeSequence" vr="SQ" vm="1" name="Reason For Performed Procedure Code Sequence"/>
+        <entry group="0040" element="1060" keyword="RequestedProcedureDescriptionTrial" vr="LO" vm="1" retired="true" name="Requested Procedure Description (Trial)"/>
+        <entry group="0040" element="1101" keyword="PersonIdentificationCodeSequence" vr="SQ" vm="1" name="Person Identification Code Sequence"/>
+        <entry group="0040" element="1102" keyword="PersonAddress" vr="ST" vm="1" name="Person's Address"/>
+        <entry group="0040" element="1103" keyword="PersonTelephoneNumbers" vr="LO" vm="1-n" name="Person's Telephone Numbers"/>
+        <entry group="0040" element="1104" keyword="PersonTelecomInformation" vr="LT" vm="1" name="Person's Telecom Information"/>
+        <entry group="0040" element="1400" keyword="RequestedProcedureComments" vr="LT" vm="1" name="Requested Procedure Comments"/>
+        <entry group="0040" element="2001" keyword="ReasonForTheImagingServiceRequest" vr="LO" vm="1" retired="true" name="Reason for the Imaging Service Request"/>
+        <entry group="0040" element="2004" keyword="IssueDateOfImagingServiceRequest" vr="DA" vm="1" name="Issue Date of Imaging Service Request"/>
+        <entry group="0040" element="2005" keyword="IssueTimeOfImagingServiceRequest" vr="TM" vm="1" name="Issue Time of Imaging Service Request"/>
+        <entry group="0040" element="2006" keyword="PlacerOrderNumberImagingServiceRequestRetired" vr="SH" vm="1" retired="true" name="Placer Order Number / Imaging Service Request (Retired)"/>
+        <entry group="0040" element="2007" keyword="FillerOrderNumberImagingServiceRequestRetired" vr="SH" vm="1" retired="true" name="Filler Order Number / Imaging Service Request (Retired)"/>
+        <entry group="0040" element="2008" keyword="OrderEnteredBy" vr="PN" vm="1" name="Order Entered By"/>
+        <entry group="0040" element="2009" keyword="OrderEntererLocation" vr="SH" vm="1" name="Order Enterer's Location"/>
+        <entry group="0040" element="2010" keyword="OrderCallbackPhoneNumber" vr="SH" vm="1" name="Order Callback Phone Number"/>
+        <entry group="0040" element="2011" keyword="OrderCallbackTelecomInformation" vr="LT" vm="1" name="Order Callback Telecom Information"/>
+        <entry group="0040" element="2016" keyword="PlacerOrderNumberImagingServiceRequest" vr="LO" vm="1" name="Placer Order Number / Imaging Service Request"/>
+        <entry group="0040" element="2017" keyword="FillerOrderNumberImagingServiceRequest" vr="LO" vm="1" name="Filler Order Number / Imaging Service Request"/>
+        <entry group="0040" element="2400" keyword="ImagingServiceRequestComments" vr="LT" vm="1" name="Imaging Service Request Comments"/>
+        <entry group="0040" element="3001" keyword="ConfidentialityConstraintOnPatientDataDescription" vr="LO" vm="1" name="Confidentiality Constraint on Patient Data Description"/>
+        <entry group="0040" element="4001" keyword="GeneralPurposeScheduledProcedureStepStatus" vr="CS" vm="1" retired="true" name="General Purpose Scheduled Procedure Step Status"/>
+        <entry group="0040" element="4002" keyword="GeneralPurposePerformedProcedureStepStatus" vr="CS" vm="1" retired="true" name="General Purpose Performed Procedure Step Status"/>
+        <entry group="0040" element="4003" keyword="GeneralPurposeScheduledProcedureStepPriority" vr="CS" vm="1" retired="true" name="General Purpose Scheduled Procedure Step Priority"/>
+        <entry group="0040" element="4004" keyword="ScheduledProcessingApplicationsCodeSequence" vr="SQ" vm="1" retired="true" name="Scheduled Processing Applications Code Sequence"/>
+        <entry group="0040" element="4005" keyword="ScheduledProcedureStepStartDateTime" vr="DT" vm="1" name="Scheduled Procedure Step Start DateTime"/>
+        <entry group="0040" element="4006" keyword="MultipleCopiesFlag" vr="CS" vm="1" retired="true" name="Multiple Copies Flag"/>
+        <entry group="0040" element="4007" keyword="PerformedProcessingApplicationsCodeSequence" vr="SQ" vm="1" name="Performed Processing Applications Code Sequence"/>
+        <entry group="0040" element="4009" keyword="HumanPerformerCodeSequence" vr="SQ" vm="1" name="Human Performer Code Sequence"/>
+        <entry group="0040" element="4010" keyword="ScheduledProcedureStepModificationDateTime" vr="DT" vm="1" name="Scheduled Procedure Step Modification DateTime"/>
+        <entry group="0040" element="4011" keyword="ExpectedCompletionDateTime" vr="DT" vm="1" name="Expected Completion DateTime"/>
+        <entry group="0040" element="4015" keyword="ResultingGeneralPurposePerformedProcedureStepsSequence" vr="SQ" vm="1" retired="true" name="Resulting General Purpose Performed Procedure Steps Sequence"/>
+        <entry group="0040" element="4016" keyword="ReferencedGeneralPurposeScheduledProcedureStepSequence" vr="SQ" vm="1" retired="true" name="Referenced General Purpose Scheduled Procedure Step Sequence"/>
+        <entry group="0040" element="4018" keyword="ScheduledWorkitemCodeSequence" vr="SQ" vm="1" name="Scheduled Workitem Code Sequence"/>
+        <entry group="0040" element="4019" keyword="PerformedWorkitemCodeSequence" vr="SQ" vm="1" name="Performed Workitem Code Sequence"/>
+        <entry group="0040" element="4020" keyword="InputAvailabilityFlag" vr="CS" vm="1" name="Input Availability Flag"/>
+        <entry group="0040" element="4021" keyword="InputInformationSequence" vr="SQ" vm="1" name="Input Information Sequence"/>
+        <entry group="0040" element="4022" keyword="RelevantInformationSequence" vr="SQ" vm="1" retired="true" name="Relevant Information Sequence"/>
+        <entry group="0040" element="4023" keyword="ReferencedGeneralPurposeScheduledProcedureStepTransactionUID" vr="UI" vm="1" retired="true" name="Referenced General Purpose Scheduled Procedure Step Transaction UID"/>
+        <entry group="0040" element="4025" keyword="ScheduledStationNameCodeSequence" vr="SQ" vm="1" name="Scheduled Station Name Code Sequence"/>
+        <entry group="0040" element="4026" keyword="ScheduledStationClassCodeSequence" vr="SQ" vm="1" name="Scheduled Station Class Code Sequence"/>
+        <entry group="0040" element="4027" keyword="ScheduledStationGeographicLocationCodeSequence" vr="SQ" vm="1" name="Scheduled Station Geographic Location Code Sequence"/>
+        <entry group="0040" element="4028" keyword="PerformedStationNameCodeSequence" vr="SQ" vm="1" name="Performed Station Name Code Sequence"/>
+        <entry group="0040" element="4029" keyword="PerformedStationClassCodeSequence" vr="SQ" vm="1" name="Performed Station Class Code Sequence"/>
+        <entry group="0040" element="4030" keyword="PerformedStationGeographicLocationCodeSequence" vr="SQ" vm="1" name="Performed Station Geographic Location Code Sequence"/>
+        <entry group="0040" element="4031" keyword="RequestedSubsequentWorkitemCodeSequence" vr="SQ" vm="1" retired="true" name="Requested Subsequent Workitem Code Sequence"/>
+        <entry group="0040" element="4032" keyword="NonDICOMOutputCodeSequence" vr="SQ" vm="1" retired="true" name="Non-DICOM Output Code Sequence"/>
+        <entry group="0040" element="4033" keyword="OutputInformationSequence" vr="SQ" vm="1" name="Output Information Sequence"/>
+        <entry group="0040" element="4034" keyword="ScheduledHumanPerformersSequence" vr="SQ" vm="1" name="Scheduled Human Performers Sequence"/>
+        <entry group="0040" element="4035" keyword="ActualHumanPerformersSequence" vr="SQ" vm="1" name="Actual Human Performers Sequence"/>
+        <entry group="0040" element="4036" keyword="HumanPerformerOrganization" vr="LO" vm="1" name="Human Performer's Organization"/>
+        <entry group="0040" element="4037" keyword="HumanPerformerName" vr="PN" vm="1" name="Human Performer's Name"/>
+        <entry group="0040" element="4040" keyword="RawDataHandling" vr="CS" vm="1" name="Raw Data Handling"/>
+        <entry group="0040" element="4041" keyword="InputReadinessState" vr="CS" vm="1" name="Input Readiness State"/>
+        <entry group="0040" element="4050" keyword="PerformedProcedureStepStartDateTime" vr="DT" vm="1" name="Performed Procedure Step Start DateTime"/>
+        <entry group="0040" element="4051" keyword="PerformedProcedureStepEndDateTime" vr="DT" vm="1" name="Performed Procedure Step End DateTime"/>
+        <entry group="0040" element="4052" keyword="ProcedureStepCancellationDateTime" vr="DT" vm="1" name="Procedure Step Cancellation DateTime"/>
+        <entry group="0040" element="4070" keyword="OutputDestinationSequence" vr="SQ" vm="1" name="Output Destination Sequence"/>
+        <entry group="0040" element="4071" keyword="DICOMStorageSequence" vr="SQ" vm="1" name="DICOM Storage Sequence"/>
+        <entry group="0040" element="4072" keyword="STOWRSStorageSequence" vr="SQ" vm="1" name="STOW-RS Storage Sequence"/>
+        <entry group="0040" element="4073" keyword="StorageURL" vr="UR" vm="1" name="Storage URL"/>
+        <entry group="0040" element="4074" keyword="XDSStorageSequence" vr="SQ" vm="1" name="XDS Storage Sequence"/>
+        <entry group="0040" element="8302" keyword="EntranceDoseInmGy" vr="DS" vm="1" name="Entrance Dose in mGy"/>
+        <entry group="0040" element="9092" keyword="ParametricMapFrameTypeSequence" vr="SQ" vm="1" name="Parametric Map Frame Type Sequence"/>
+        <entry group="0040" element="9094" keyword="ReferencedImageRealWorldValueMappingSequence" vr="SQ" vm="1" name="Referenced Image Real World Value Mapping Sequence"/>
+        <entry group="0040" element="9096" keyword="RealWorldValueMappingSequence" vr="SQ" vm="1" name="Real World Value Mapping Sequence"/>
+        <entry group="0040" element="9098" keyword="PixelValueMappingCodeSequence" vr="SQ" vm="1" name="Pixel Value Mapping Code Sequence"/>
+        <entry group="0040" element="9210" keyword="LUTLabel" vr="SH" vm="1" name="LUT Label"/>
+        <entry group="0040" element="9211" keyword="RealWorldValueLastValueMapped" vr="US_SS" vm="1" name="Real World Value Last Value Mapped"/>
+        <entry group="0040" element="9212" keyword="RealWorldValueLUTData" vr="FD" vm="1-n" name="Real World Value LUT Data"/>
+        <entry group="0040" element="9213" keyword="DoubleFloatRealWorldValueLastValueMapped" vr="FD" vm="1" name="Double Float Real World Value Last Value Mapped"/>
+        <entry group="0040" element="9214" keyword="DoubleFloatRealWorldValueFirstValueMapped" vr="FD" vm="1" name="Double Float Real World Value First Value Mapped"/>
+        <entry group="0040" element="9216" keyword="RealWorldValueFirstValueMapped" vr="US_SS" vm="1" name="Real World Value First Value Mapped"/>
+        <entry group="0040" element="9220" keyword="QuantityDefinitionSequence" vr="SQ" vm="1" name="Quantity Definition Sequence"/>
+
+        <entry group="0040" element="9224" keyword="RealWorldValueIntercept" vr="FD" vm="1" name="Real World Value Intercept"/>
+        <entry group="0040" element="9225" keyword="RealWorldValueSlope" vr="FD" vm="1" name="Real World Value Slope"/>
+        <entry group="0040" element="a007" keyword="FindingsFlagTrial" vr="CS" vm="1" retired="true" name="Findings Flag (Trial)"/>
+        <entry group="0040" element="a010" keyword="RelationshipType" vr="CS" vm="1" name="Relationship Type"/>
+        <entry group="0040" element="a020" keyword="FindingsSequenceTrial" vr="SQ" vm="1" retired="true" name="Findings Sequence (Trial)"/>
+        <entry group="0040" element="a021" keyword="FindingsGroupUIDTrial" vr="UI" vm="1" retired="true" name="Findings Group UID (Trial)"/>
+        <entry group="0040" element="a022" keyword="ReferencedFindingsGroupUIDTrial" vr="UI" vm="1" retired="true" name="Referenced Findings Group UID (Trial)"/>
+        <entry group="0040" element="a023" keyword="FindingsGroupRecordingDateTrial" vr="DA" vm="1" retired="true" name="Findings Group Recording Date (Trial)"/>
+        <entry group="0040" element="a024" keyword="FindingsGroupRecordingTimeTrial" vr="TM" vm="1" retired="true" name="Findings Group Recording Time (Trial)"/>
+        <entry group="0040" element="a026" keyword="FindingsSourceCategoryCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Findings Source Category Code Sequence (Trial)"/>
+        <entry group="0040" element="a027" keyword="VerifyingOrganization" vr="LO" vm="1" name="Verifying Organization"/>
+        <entry group="0040" element="a028" keyword="DocumentingOrganizationIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Documenting Organization Identifier Code Sequence (Trial)"/>
+        <entry group="0040" element="a030" keyword="VerificationDateTime" vr="DT" vm="1" name="Verification DateTime"/>
+        <entry group="0040" element="a032" keyword="ObservationDateTime" vr="DT" vm="1" name="Observation DateTime"/>
+        <entry group="0040" element="a040" keyword="ValueType" vr="CS" vm="1" name="Value Type"/>
+        <entry group="0040" element="a043" keyword="ConceptNameCodeSequence" vr="SQ" vm="1" name="Concept Name Code Sequence"/>
+        <entry group="0040" element="a047" keyword="MeasurementPrecisionDescriptionTrial" vr="LO" vm="1" retired="true" name="Measurement Precision Description (Trial)"/>
+        <entry group="0040" element="a050" keyword="ContinuityOfContent" vr="CS" vm="1" name="Continuity Of Content"/>
+        <entry group="0040" element="a057" keyword="UrgencyOrPriorityAlertsTrial" vr="CS" vm="1-n" retired="true" name="Urgency or Priority Alerts (Trial)"/>
+        <entry group="0040" element="a060" keyword="SequencingIndicatorTrial" vr="LO" vm="1" retired="true" name="Sequencing Indicator (Trial)"/>
+        <entry group="0040" element="a066" keyword="DocumentIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Document Identifier Code Sequence (Trial)"/>
+        <entry group="0040" element="a067" keyword="DocumentAuthorTrial" vr="PN" vm="1" retired="true" name="Document Author (Trial)"/>
+        <entry group="0040" element="a068" keyword="DocumentAuthorIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Document Author Identifier Code Sequence (Trial)"/>
+        <entry group="0040" element="a070" keyword="IdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Identifier Code Sequence (Trial)"/>
+        <entry group="0040" element="a073" keyword="VerifyingObserverSequence" vr="SQ" vm="1" name="Verifying Observer Sequence"/>
+        <entry group="0040" element="a074" keyword="ObjectBinaryIdentifierTrial" vr="OB" vm="1" retired="true" name="Object Binary Identifier (Trial)"/>
+        <entry group="0040" element="a075" keyword="VerifyingObserverName" vr="PN" vm="1" name="Verifying Observer Name"/>
+        <entry group="0040" element="a076" keyword="DocumentingObserverIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Documenting Observer Identifier Code Sequence (Trial)"/>
+        <entry group="0040" element="a078" keyword="AuthorObserverSequence" vr="SQ" vm="1" name="Author Observer Sequence"/>
+        <entry group="0040" element="a07a" keyword="ParticipantSequence" vr="SQ" vm="1" name="Participant Sequence"/>
+        <entry group="0040" element="a07c" keyword="CustodialOrganizationSequence" vr="SQ" vm="1" name="Custodial Organization Sequence"/>
+        <entry group="0040" element="a080" keyword="ParticipationType" vr="CS" vm="1" name="Participation Type"/>
+        <entry group="0040" element="a082" keyword="ParticipationDateTime" vr="DT" vm="1" name="Participation DateTime"/>
+        <entry group="0040" element="a084" keyword="ObserverType" vr="CS" vm="1" name="Observer Type"/>
+        <entry group="0040" element="a085" keyword="ProcedureIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Procedure Identifier Code Sequence (Trial)"/>
+        <entry group="0040" element="a088" keyword="VerifyingObserverIdentificationCodeSequence" vr="SQ" vm="1" name="Verifying Observer Identification Code Sequence"/>
+        <entry group="0040" element="a089" keyword="ObjectDirectoryBinaryIdentifierTrial" vr="OB" vm="1" retired="true" name="Object Directory Binary Identifier (Trial)"/>
+        <entry group="0040" element="a090" keyword="EquivalentCDADocumentSequence" vr="SQ" vm="1" retired="true" name="Equivalent CDA Document Sequence"/>
+        <entry group="0040" element="a0b0" keyword="ReferencedWaveformChannels" vr="US" vm="2-2n" name="Referenced Waveform Channels"/>
+        <entry group="0040" element="a110" keyword="DateOfDocumentOrVerbalTransactionTrial" vr="DA" vm="1" retired="true" name="Date of Document or Verbal Transaction (Trial)"/>
+        <entry group="0040" element="a112" keyword="TimeOfDocumentCreationOrVerbalTransactionTrial" vr="TM" vm="1" retired="true" name="Time of Document Creation or Verbal Transaction (Trial)"/>
+        <entry group="0040" element="a120" keyword="DateTime" vr="DT" vm="1" name="DateTime"/>
+        <entry group="0040" element="a121" keyword="Date" vr="DA" vm="1" name="Date"/>
+        <entry group="0040" element="a122" keyword="Time" vr="TM" vm="1" name="Time"/>
+        <entry group="0040" element="a123" keyword="PersonName" vr="PN" vm="1" name="Person Name"/>
+        <entry group="0040" element="a124" keyword="UID" vr="UI" vm="1" name="UID"/>
+        <entry group="0040" element="a125" keyword="ReportStatusIDTrial" vr="CS" vm="2" retired="true" name="Report Status ID (Trial)"/>
+        <entry group="0040" element="a130" keyword="TemporalRangeType" vr="CS" vm="1" name="Temporal Range Type"/>
+        <entry group="0040" element="a132" keyword="ReferencedSamplePositions" vr="UL" vm="1-n" name="Referenced Sample Positions"/>
+        <entry group="0040" element="a136" keyword="ReferencedFrameNumbers" vr="US" vm="1-n" name="Referenced Frame Numbers"/>
+        <entry group="0040" element="a138" keyword="ReferencedTimeOffsets" vr="DS" vm="1-n" name="Referenced Time Offsets"/>
+        <entry group="0040" element="a13a" keyword="ReferencedDateTime" vr="DT" vm="1-n" name="Referenced DateTime"/>
+        <entry group="0040" element="a160" keyword="TextValue" vr="UT" vm="1" name="Text Value"/>
+        <entry group="0040" element="a161" keyword="FloatingPointValue" vr="FD" vm="1-n" name="Floating Point Value"/>
+        <entry group="0040" element="a162" keyword="RationalNumeratorValue" vr="SL" vm="1-n" name="Rational Numerator Value"/>
+        <entry group="0040" element="a163" keyword="RationalDenominatorValue" vr="UL" vm="1-n" name="Rational Denominator Value"/>
+        <entry group="0040" element="a167" keyword="ObservationCategoryCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Observation Category Code Sequence (Trial)"/>
+        <entry group="0040" element="a168" keyword="ConceptCodeSequence" vr="SQ" vm="1" name="Concept Code Sequence"/>
+        <entry group="0040" element="a16a" keyword="BibliographicCitationTrial" vr="ST" vm="1" retired="true" name="Bibliographic Citation (Trial)"/>
+        <entry group="0040" element="a170" keyword="PurposeOfReferenceCodeSequence" vr="SQ" vm="1" name="Purpose of Reference Code Sequence"/>
+        <entry group="0040" element="a171" keyword="ObservationUID" vr="UI" vm="1" name="Observation UID"/>
+        <entry group="0040" element="a172" keyword="ReferencedObservationUIDTrial" vr="UI" vm="1" retired="true" name="Referenced Observation UID (Trial)"/>
+        <entry group="0040" element="a173" keyword="ReferencedObservationClassTrial" vr="CS" vm="1" retired="true" name="Referenced Observation Class (Trial)"/>
+        <entry group="0040" element="a174" keyword="ReferencedObjectObservationClassTrial" vr="CS" vm="1" retired="true" name="Referenced Object Observation Class (Trial)"/>
+        <entry group="0040" element="a180" keyword="AnnotationGroupNumber" vr="US" vm="1" name="Annotation Group Number"/>
+        <entry group="0040" element="a192" keyword="ObservationDateTrial" vr="DA" vm="1" retired="true" name="Observation Date (Trial)"/>
+        <entry group="0040" element="a193" keyword="ObservationTimeTrial" vr="TM" vm="1" retired="true" name="Observation Time (Trial)"/>
+        <entry group="0040" element="a194" keyword="MeasurementAutomationTrial" vr="CS" vm="1" retired="true" name="Measurement Automation (Trial)"/>
+        <entry group="0040" element="a195" keyword="ModifierCodeSequence" vr="SQ" vm="1" name="Modifier Code Sequence"/>
+        <entry group="0040" element="a224" keyword="IdentificationDescriptionTrial" vr="ST" vm="1" retired="true" name="Identification Description (Trial)"/>
+        <entry group="0040" element="a290" keyword="CoordinatesSetGeometricTypeTrial" vr="CS" vm="1" retired="true" name="Coordinates Set Geometric Type (Trial)"/>
+        <entry group="0040" element="a296" keyword="AlgorithmCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Algorithm Code Sequence (Trial)"/>
+        <entry group="0040" element="a297" keyword="AlgorithmDescriptionTrial" vr="ST" vm="1" retired="true" name="Algorithm Description (Trial)"/>
+        <entry group="0040" element="a29a" keyword="PixelCoordinatesSetTrial" vr="SL" vm="2-2n" retired="true" name="Pixel Coordinates Set (Trial)"/>
+        <entry group="0040" element="a300" keyword="MeasuredValueSequence" vr="SQ" vm="1" name="Measured Value Sequence"/>
+        <entry group="0040" element="a301" keyword="NumericValueQualifierCodeSequence" vr="SQ" vm="1" name="Numeric Value Qualifier Code Sequence"/>
+        <entry group="0040" element="a307" keyword="CurrentObserverTrial" vr="PN" vm="1" retired="true" name="Current Observer (Trial)"/>
+        <entry group="0040" element="a30a" keyword="NumericValue" vr="DS" vm="1-n" name="Numeric Value"/>
+        <entry group="0040" element="a313" keyword="ReferencedAccessionSequenceTrial" vr="SQ" vm="1" retired="true" name="Referenced Accession Sequence (Trial)"/>
+        <entry group="0040" element="a33a" keyword="ReportStatusCommentTrial" vr="ST" vm="1" retired="true" name="Report Status Comment (Trial)"/>
+        <entry group="0040" element="a340" keyword="ProcedureContextSequenceTrial" vr="SQ" vm="1" retired="true" name="Procedure Context Sequence (Trial)"/>
+        <entry group="0040" element="a352" keyword="VerbalSourceTrial" vr="PN" vm="1" retired="true" name="Verbal Source (Trial)"/>
+        <entry group="0040" element="a353" keyword="AddressTrial" vr="ST" vm="1" retired="true" name="Address (Trial)"/>
+        <entry group="0040" element="a354" keyword="TelephoneNumberTrial" vr="LO" vm="1" retired="true" name="Telephone Number (Trial)"/>
+        <entry group="0040" element="a358" keyword="VerbalSourceIdentifierCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Verbal Source Identifier Code Sequence (Trial)"/>
+        <entry group="0040" element="a360" keyword="PredecessorDocumentsSequence" vr="SQ" vm="1" name="Predecessor Documents Sequence"/>
+        <entry group="0040" element="a370" keyword="ReferencedRequestSequence" vr="SQ" vm="1" name="Referenced Request Sequence"/>
+        <entry group="0040" element="a372" keyword="PerformedProcedureCodeSequence" vr="SQ" vm="1" name="Performed Procedure Code Sequence"/>
+        <entry group="0040" element="a375" keyword="CurrentRequestedProcedureEvidenceSequence" vr="SQ" vm="1" name="Current Requested Procedure Evidence Sequence"/>
+        <entry group="0040" element="a380" keyword="ReportDetailSequenceTrial" vr="SQ" vm="1" retired="true" name="Report Detail Sequence (Trial)"/>
+        <entry group="0040" element="a385" keyword="PertinentOtherEvidenceSequence" vr="SQ" vm="1" name="Pertinent Other Evidence Sequence"/>
+        <entry group="0040" element="a390" keyword="HL7StructuredDocumentReferenceSequence" vr="SQ" vm="1" name="HL7 Structured Document Reference Sequence"/>
+        <entry group="0040" element="a402" keyword="ObservationSubjectUIDTrial" vr="UI" vm="1" retired="true" name="Observation Subject UID (Trial)"/>
+        <entry group="0040" element="a403" keyword="ObservationSubjectClassTrial" vr="CS" vm="1" retired="true" name="Observation Subject Class (Trial)"/>
+        <entry group="0040" element="a404" keyword="ObservationSubjectTypeCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Observation Subject Type Code Sequence (Trial)"/>
+        <entry group="0040" element="a491" keyword="CompletionFlag" vr="CS" vm="1" name="Completion Flag"/>
+        <entry group="0040" element="a492" keyword="CompletionFlagDescription" vr="LO" vm="1" name="Completion Flag Description"/>
+        <entry group="0040" element="a493" keyword="VerificationFlag" vr="CS" vm="1" name="Verification Flag"/>
+        <entry group="0040" element="a494" keyword="ArchiveRequested" vr="CS" vm="1" name="Archive Requested"/>
+        <entry group="0040" element="a496" keyword="PreliminaryFlag" vr="CS" vm="1" name="Preliminary Flag"/>
+        <entry group="0040" element="a504" keyword="ContentTemplateSequence" vr="SQ" vm="1" name="Content Template Sequence"/>
+        <entry group="0040" element="a525" keyword="IdenticalDocumentsSequence" vr="SQ" vm="1" name="Identical Documents Sequence"/>
+        <entry group="0040" element="a600" keyword="ObservationSubjectContextFlagTrial" vr="CS" vm="1" retired="true" name="Observation Subject Context Flag (Trial)"/>
+        <entry group="0040" element="a601" keyword="ObserverContextFlagTrial" vr="CS" vm="1" retired="true" name="Observer Context Flag (Trial)"/>
+        <entry group="0040" element="a603" keyword="ProcedureContextFlagTrial" vr="CS" vm="1" retired="true" name="Procedure Context Flag (Trial)"/>
+        <entry group="0040" element="a730" keyword="ContentSequence" vr="SQ" vm="1" name="Content Sequence"/>
+        <entry group="0040" element="a731" keyword="RelationshipSequenceTrial" vr="SQ" vm="1" retired="true" name="Relationship Sequence (Trial)"/>
+        <entry group="0040" element="a732" keyword="RelationshipTypeCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Relationship Type Code Sequence (Trial)"/>
+        <entry group="0040" element="a744" keyword="LanguageCodeSequenceTrial" vr="SQ" vm="1" retired="true" name="Language Code Sequence (Trial)"/>
+        <entry group="0040" element="a992" keyword="UniformResourceLocatorTrial" vr="ST" vm="1" retired="true" name="Uniform Resource Locator (Trial)"/>
+        <entry group="0040" element="b020" keyword="WaveformAnnotationSequence" vr="SQ" vm="1" name="Waveform Annotation Sequence"/>
+        <entry group="0040" element="db00" keyword="TemplateIdentifier" vr="CS" vm="1" name="Template Identifier"/>
+        <entry group="0040" element="db06" keyword="TemplateVersion" vr="DT" vm="1" retired="true" name="Template Version"/>
+        <entry group="0040" element="db07" keyword="TemplateLocalVersion" vr="DT" vm="1" retired="true" name="Template Local Version"/>
+        <entry group="0040" element="db0b" keyword="TemplateExtensionFlag" vr="CS" vm="1" retired="true" name="Template Extension Flag"/>
+        <entry group="0040" element="db0c" keyword="TemplateExtensionOrganizationUID" vr="UI" vm="1" retired="true" name="Template Extension Organization UID"/>
+        <entry group="0040" element="db0d" keyword="TemplateExtensionCreatorUID" vr="UI" vm="1" retired="true" name="Template Extension Creator UID"/>
+        <entry group="0040" element="db73" keyword="ReferencedContentItemIdentifier" vr="UL" vm="1-n" name="Referenced Content Item Identifier"/>
+        <entry group="0040" element="e001" keyword="HL7InstanceIdentifier" vr="ST" vm="1" name="HL7 Instance Identifier"/>
+        <entry group="0040" element="e004" keyword="HL7DocumentEffectiveTime" vr="DT" vm="1" name="HL7 Document Effective Time"/>
+        <entry group="0040" element="e006" keyword="HL7DocumentTypeCodeSequence" vr="SQ" vm="1" name="HL7 Document Type Code Sequence"/>
+        <entry group="0040" element="e008" keyword="DocumentClassCodeSequence" vr="SQ" vm="1" name="Document Class Code Sequence"/>
+        <entry group="0040" element="e010" keyword="RetrieveURI" vr="UR" vm="1" name="Retrieve URI"/>
+        <entry group="0040" element="e011" keyword="RetrieveLocationUID" vr="UI" vm="1" name="Retrieve Location UID"/>
+        <entry group="0040" element="e020" keyword="TypeOfInstances" vr="CS" vm="1" name="Type of Instances"/>
+        <entry group="0040" element="e021" keyword="DICOMRetrievalSequence" vr="SQ" vm="1" name="DICOM Retrieval Sequence"/>
+        <entry group="0040" element="e022" keyword="DICOMMediaRetrievalSequence" vr="SQ" vm="1" name="DICOM Media Retrieval Sequence"/>
+        <entry group="0040" element="e023" keyword="WADORetrievalSequence" vr="SQ" vm="1" name="WADO Retrieval Sequence"/>
+        <entry group="0040" element="e024" keyword="XDSRetrievalSequence" vr="SQ" vm="1" name="XDS Retrieval Sequence"/>
+        <entry group="0040" element="e025" keyword="WADORSRetrievalSequence" vr="SQ" vm="1" name="WADO-RS Retrieval Sequence"/>
+        <entry group="0040" element="e030" keyword="RepositoryUniqueID" vr="UI" vm="1" name="Repository Unique ID"/>
+        <entry group="0040" element="e031" keyword="HomeCommunityID" vr="UI" vm="1" name="Home Community ID"/>
+        <entry group="0042" element="0010" keyword="DocumentTitle" vr="ST" vm="1" name="Document Title"/>
+        <entry group="0042" element="0011" keyword="EncapsulatedDocument" vr="OB" vm="1" name="Encapsulated Document"/>
+        <entry group="0042" element="0012" keyword="MIMETypeOfEncapsulatedDocument" vr="LO" vm="1" name="MIME Type of Encapsulated Document"/>
+        <entry group="0042" element="0013" keyword="SourceInstanceSequence" vr="SQ" vm="1" name="Source Instance Sequence"/>
+        <entry group="0042" element="0014" keyword="ListOfMIMETypes" vr="LO" vm="1-n" name="List of MIME Types"/>
+        <entry group="0044" element="0001" keyword="ProductPackageIdentifier" vr="ST" vm="1" name="Product Package Identifier"/>
+        <entry group="0044" element="0002" keyword="SubstanceAdministrationApproval" vr="CS" vm="1" name="Substance Administration Approval"/>
+        <entry group="0044" element="0003" keyword="ApprovalStatusFurtherDescription" vr="LT" vm="1" name="Approval Status Further Description"/>
+        <entry group="0044" element="0004" keyword="ApprovalStatusDateTime" vr="DT" vm="1" name="Approval Status DateTime"/>
+        <entry group="0044" element="0007" keyword="ProductTypeCodeSequence" vr="SQ" vm="1" name="Product Type Code Sequence"/>
+        <entry group="0044" element="0008" keyword="ProductName" vr="LO" vm="1-n" name="Product Name"/>
+        <entry group="0044" element="0009" keyword="ProductDescription" vr="LT" vm="1" name="Product Description"/>
+        <entry group="0044" element="000a" keyword="ProductLotIdentifier" vr="LO" vm="1" name="Product Lot Identifier"/>
+        <entry group="0044" element="000b" keyword="ProductExpirationDateTime" vr="DT" vm="1" name="Product Expiration DateTime"/>
+        <entry group="0044" element="0010" keyword="SubstanceAdministrationDateTime" vr="DT" vm="1" name="Substance Administration DateTime"/>
+        <entry group="0044" element="0011" keyword="SubstanceAdministrationNotes" vr="LO" vm="1" name="Substance Administration Notes"/>
+        <entry group="0044" element="0012" keyword="SubstanceAdministrationDeviceID" vr="LO" vm="1" name="Substance Administration Device ID"/>
+        <entry group="0044" element="0013" keyword="ProductParameterSequence" vr="SQ" vm="1" name="Product Parameter Sequence"/>
+        <entry group="0044" element="0019" keyword="SubstanceAdministrationParameterSequence" vr="SQ" vm="1" name="Substance Administration Parameter Sequence"/>
+        <entry group="0046" element="0012" keyword="LensDescription" vr="LO" vm="1" name="Lens Description"/>
+        <entry group="0046" element="0014" keyword="RightLensSequence" vr="SQ" vm="1" name="Right Lens Sequence"/>
+        <entry group="0046" element="0015" keyword="LeftLensSequence" vr="SQ" vm="1" name="Left Lens Sequence"/>
+        <entry group="0046" element="0016" keyword="UnspecifiedLateralityLensSequence" vr="SQ" vm="1" name="Unspecified Laterality Lens Sequence"/>
+        <entry group="0046" element="0018" keyword="CylinderSequence" vr="SQ" vm="1" name="Cylinder Sequence"/>
+        <entry group="0046" element="0028" keyword="PrismSequence" vr="SQ" vm="1" name="Prism Sequence"/>
+        <entry group="0046" element="0030" keyword="HorizontalPrismPower" vr="FD" vm="1" name="Horizontal Prism Power"/>
+        <entry group="0046" element="0032" keyword="HorizontalPrismBase" vr="CS" vm="1" name="Horizontal Prism Base"/>
+        <entry group="0046" element="0034" keyword="VerticalPrismPower" vr="FD" vm="1" name="Vertical Prism Power"/>
+        <entry group="0046" element="0036" keyword="VerticalPrismBase" vr="CS" vm="1" name="Vertical Prism Base"/>
+        <entry group="0046" element="0038" keyword="LensSegmentType" vr="CS" vm="1" name="Lens Segment Type"/>
+        <entry group="0046" element="0040" keyword="OpticalTransmittance" vr="FD" vm="1" name="Optical Transmittance"/>
+        <entry group="0046" element="0042" keyword="ChannelWidth" vr="FD" vm="1" name="Channel Width"/>
+        <entry group="0046" element="0044" keyword="PupilSize" vr="FD" vm="1" name="Pupil Size"/>
+        <entry group="0046" element="0046" keyword="CornealSize" vr="FD" vm="1" name="Corneal Size"/>
+        <entry group="0046" element="0050" keyword="AutorefractionRightEyeSequence" vr="SQ" vm="1" name="Autorefraction Right Eye Sequence"/>
+        <entry group="0046" element="0052" keyword="AutorefractionLeftEyeSequence" vr="SQ" vm="1" name="Autorefraction Left Eye Sequence"/>
+        <entry group="0046" element="0060" keyword="DistancePupillaryDistance" vr="FD" vm="1" name="Distance Pupillary Distance"/>
+        <entry group="0046" element="0062" keyword="NearPupillaryDistance" vr="FD" vm="1" name="Near Pupillary Distance"/>
+        <entry group="0046" element="0063" keyword="IntermediatePupillaryDistance" vr="FD" vm="1" name="Intermediate Pupillary Distance"/>
+        <entry group="0046" element="0064" keyword="OtherPupillaryDistance" vr="FD" vm="1" name="Other Pupillary Distance"/>
+        <entry group="0046" element="0070" keyword="KeratometryRightEyeSequence" vr="SQ" vm="1" name="Keratometry Right Eye Sequence"/>
+        <entry group="0046" element="0071" keyword="KeratometryLeftEyeSequence" vr="SQ" vm="1" name="Keratometry Left Eye Sequence"/>
+        <entry group="0046" element="0074" keyword="SteepKeratometricAxisSequence" vr="SQ" vm="1" name="Steep Keratometric Axis Sequence"/>
+        <entry group="0046" element="0075" keyword="RadiusOfCurvature" vr="FD" vm="1" name="Radius of Curvature"/>
+        <entry group="0046" element="0076" keyword="KeratometricPower" vr="FD" vm="1" name="Keratometric Power"/>
+        <entry group="0046" element="0077" keyword="KeratometricAxis" vr="FD" vm="1" name="Keratometric Axis"/>
+        <entry group="0046" element="0080" keyword="FlatKeratometricAxisSequence" vr="SQ" vm="1" name="Flat Keratometric Axis Sequence"/>
+        <entry group="0046" element="0092" keyword="BackgroundColor" vr="CS" vm="1" name="Background Color"/>
+        <entry group="0046" element="0094" keyword="Optotype" vr="CS" vm="1" name="Optotype"/>
+        <entry group="0046" element="0095" keyword="OptotypePresentation" vr="CS" vm="1" name="Optotype Presentation"/>
+        <entry group="0046" element="0097" keyword="SubjectiveRefractionRightEyeSequence" vr="SQ" vm="1" name="Subjective Refraction Right Eye Sequence"/>
+        <entry group="0046" element="0098" keyword="SubjectiveRefractionLeftEyeSequence" vr="SQ" vm="1" name="Subjective Refraction Left Eye Sequence"/>
+        <entry group="0046" element="0100" keyword="AddNearSequence" vr="SQ" vm="1" name="Add Near Sequence"/>
+        <entry group="0046" element="0101" keyword="AddIntermediateSequence" vr="SQ" vm="1" name="Add Intermediate Sequence"/>
+        <entry group="0046" element="0102" keyword="AddOtherSequence" vr="SQ" vm="1" name="Add Other Sequence"/>
+        <entry group="0046" element="0104" keyword="AddPower" vr="FD" vm="1" name="Add Power"/>
+        <entry group="0046" element="0106" keyword="ViewingDistance" vr="FD" vm="1" name="Viewing Distance"/>
+        <entry group="0046" element="0121" keyword="VisualAcuityTypeCodeSequence" vr="SQ" vm="1" name="Visual Acuity Type Code Sequence"/>
+        <entry group="0046" element="0122" keyword="VisualAcuityRightEyeSequence" vr="SQ" vm="1" name="Visual Acuity Right Eye Sequence"/>
+        <entry group="0046" element="0123" keyword="VisualAcuityLeftEyeSequence" vr="SQ" vm="1" name="Visual Acuity Left Eye Sequence"/>
+        <entry group="0046" element="0124" keyword="VisualAcuityBothEyesOpenSequence" vr="SQ" vm="1" name="Visual Acuity Both Eyes Open Sequence"/>
+        <entry group="0046" element="0125" keyword="ViewingDistanceType" vr="CS" vm="1" name="Viewing Distance Type"/>
+        <entry group="0046" element="0135" keyword="VisualAcuityModifiers" vr="SS" vm="2" name="Visual Acuity Modifiers"/>
+        <entry group="0046" element="0137" keyword="DecimalVisualAcuity" vr="FD" vm="1" name="Decimal Visual Acuity"/>
+        <entry group="0046" element="0139" keyword="OptotypeDetailedDefinition" vr="LO" vm="1" name="Optotype Detailed Definition"/>
+        <entry group="0046" element="0145" keyword="ReferencedRefractiveMeasurementsSequence" vr="SQ" vm="1" name="Referenced Refractive Measurements Sequence"/>
+        <entry group="0046" element="0146" keyword="SpherePower" vr="FD" vm="1" name="Sphere Power"/>
+        <entry group="0046" element="0147" keyword="CylinderPower" vr="FD" vm="1" name="Cylinder Power"/>
+        <entry group="0046" element="0201" keyword="CornealTopographySurface" vr="CS" vm="1" name="Corneal Topography Surface"/>
+        <entry group="0046" element="0202" keyword="CornealVertexLocation" vr="FL" vm="2" name="Corneal Vertex Location"/>
+        <entry group="0046" element="0203" keyword="PupilCentroidXCoordinate" vr="FL" vm="1" name="Pupil Centroid X-Coordinate"/>
+        <entry group="0046" element="0204" keyword="PupilCentroidYCoordinate" vr="FL" vm="1" name="Pupil Centroid Y-Coordinate"/>
+        <entry group="0046" element="0205" keyword="EquivalentPupilRadius" vr="FL" vm="1" name="Equivalent Pupil Radius"/>
+        <entry group="0046" element="0207" keyword="CornealTopographyMapTypeCodeSequence" vr="SQ" vm="1" name="Corneal Topography Map Type Code Sequence"/>
+        <entry group="0046" element="0208" keyword="VerticesOfTheOutlineOfPupil" vr="IS" vm="2-2n" name="Vertices of the Outline of Pupil"/>
+        <entry group="0046" element="0210" keyword="CornealTopographyMappingNormalsSequence" vr="SQ" vm="1" name="Corneal Topography Mapping Normals Sequence"/>
+        <entry group="0046" element="0211" keyword="MaximumCornealCurvatureSequence" vr="SQ" vm="1" name="Maximum Corneal Curvature Sequence"/>
+        <entry group="0046" element="0212" keyword="MaximumCornealCurvature" vr="FL" vm="1" name="Maximum Corneal Curvature"/>
+        <entry group="0046" element="0213" keyword="MaximumCornealCurvatureLocation" vr="FL" vm="2" name="Maximum Corneal Curvature Location"/>
+        <entry group="0046" element="0215" keyword="MinimumKeratometricSequence" vr="SQ" vm="1" name="Minimum Keratometric Sequence"/>
+        <entry group="0046" element="0218" keyword="SimulatedKeratometricCylinderSequence" vr="SQ" vm="1" name="Simulated Keratometric Cylinder Sequence"/>
+        <entry group="0046" element="0220" keyword="AverageCornealPower" vr="FL" vm="1" name="Average Corneal Power"/>
+        <entry group="0046" element="0224" keyword="CornealISValue" vr="FL" vm="1" name="Corneal I-S Value"/>
+        <entry group="0046" element="0227" keyword="AnalyzedArea" vr="FL" vm="1" name="Analyzed Area"/>
+        <entry group="0046" element="0230" keyword="SurfaceRegularityIndex" vr="FL" vm="1" name="Surface Regularity Index"/>
+        <entry group="0046" element="0232" keyword="SurfaceAsymmetryIndex" vr="FL" vm="1" name="Surface Asymmetry Index"/>
+        <entry group="0046" element="0234" keyword="CornealEccentricityIndex" vr="FL" vm="1" name="Corneal Eccentricity Index"/>
+        <entry group="0046" element="0236" keyword="KeratoconusPredictionIndex" vr="FL" vm="1" name="Keratoconus Prediction Index"/>
+        <entry group="0046" element="0238" keyword="DecimalPotentialVisualAcuity" vr="FL" vm="1" name="Decimal Potential Visual Acuity"/>
+        <entry group="0046" element="0242" keyword="CornealTopographyMapQualityEvaluation" vr="CS" vm="1" name="Corneal Topography Map Quality Evaluation"/>
+        <entry group="0046" element="0244" keyword="SourceImageCornealProcessedDataSequence" vr="SQ" vm="1" name="Source Image Corneal Processed Data Sequence"/>
+        <entry group="0046" element="0247" keyword="CornealPointLocation" vr="FL" vm="3" name="Corneal Point Location"/>
+        <entry group="0046" element="0248" keyword="CornealPointEstimated" vr="CS" vm="1" name="Corneal Point Estimated"/>
+        <entry group="0046" element="0249" keyword="AxialPower" vr="FL" vm="1" name="Axial Power"/>
+        <entry group="0046" element="0250" keyword="TangentialPower" vr="FL" vm="1" name="Tangential Power"/>
+        <entry group="0046" element="0251" keyword="RefractivePower" vr="FL" vm="1" name="Refractive Power"/>
+        <entry group="0046" element="0252" keyword="RelativeElevation" vr="FL" vm="1" name="Relative Elevation"/>
+        <entry group="0046" element="0253" keyword="CornealWavefront" vr="FL" vm="1" name="Corneal Wavefront"/>
+        <entry group="0048" element="0001" keyword="ImagedVolumeWidth" vr="FL" vm="1" name="Imaged Volume Width"/>
+        <entry group="0048" element="0002" keyword="ImagedVolumeHeight" vr="FL" vm="1" name="Imaged Volume Height"/>
+        <entry group="0048" element="0003" keyword="ImagedVolumeDepth" vr="FL" vm="1" name="Imaged Volume Depth"/>
+        <entry group="0048" element="0006" keyword="TotalPixelMatrixColumns" vr="UL" vm="1" name="Total Pixel Matrix Columns"/>
+        <entry group="0048" element="0007" keyword="TotalPixelMatrixRows" vr="UL" vm="1" name="Total Pixel Matrix Rows"/>
+        <entry group="0048" element="0008" keyword="TotalPixelMatrixOriginSequence" vr="SQ" vm="1" name="Total Pixel Matrix Origin Sequence"/>
+        <entry group="0048" element="0010" keyword="SpecimenLabelInImage" vr="CS" vm="1" name="Specimen Label in Image"/>
+        <entry group="0048" element="0011" keyword="FocusMethod" vr="CS" vm="1" name="Focus Method"/>
+        <entry group="0048" element="0012" keyword="ExtendedDepthOfField" vr="CS" vm="1" name="Extended Depth of Field"/>
+        <entry group="0048" element="0013" keyword="NumberOfFocalPlanes" vr="US" vm="1" name="Number of Focal Planes"/>
+        <entry group="0048" element="0014" keyword="DistanceBetweenFocalPlanes" vr="FL" vm="1" name="Distance Between Focal Planes"/>
+        <entry group="0048" element="0015" keyword="RecommendedAbsentPixelCIELabValue" vr="US" vm="3" name="Recommended Absent Pixel CIELab Value"/>
+        <entry group="0048" element="0100" keyword="IlluminatorTypeCodeSequence" vr="SQ" vm="1" name="Illuminator Type Code Sequence"/>
+        <entry group="0048" element="0102" keyword="ImageOrientationSlide" vr="DS" vm="6" name="Image Orientation (Slide)"/>
+        <entry group="0048" element="0105" keyword="OpticalPathSequence" vr="SQ" vm="1" name="Optical Path Sequence"/>
+        <entry group="0048" element="0106" keyword="OpticalPathIdentifier" vr="SH" vm="1" name="Optical Path Identifier"/>
+        <entry group="0048" element="0107" keyword="OpticalPathDescription" vr="ST" vm="1" name="Optical Path Description"/>
+        <entry group="0048" element="0108" keyword="IlluminationColorCodeSequence" vr="SQ" vm="1" name="Illumination Color Code Sequence"/>
+        <entry group="0048" element="0110" keyword="SpecimenReferenceSequence" vr="SQ" vm="1" name="Specimen Reference Sequence"/>
+        <entry group="0048" element="0111" keyword="CondenserLensPower" vr="DS" vm="1" name="Condenser Lens Power"/>
+        <entry group="0048" element="0112" keyword="ObjectiveLensPower" vr="DS" vm="1" name="Objective Lens Power"/>
+        <entry group="0048" element="0113" keyword="ObjectiveLensNumericalAperture" vr="DS" vm="1" name="Objective Lens Numerical Aperture"/>
+        <entry group="0048" element="0120" keyword="PaletteColorLookupTableSequence" vr="SQ" vm="1" name="Palette Color Lookup Table Sequence"/>
+        <entry group="0048" element="0200" keyword="ReferencedImageNavigationSequence" vr="SQ" vm="1" name="Referenced Image Navigation Sequence"/>
+        <entry group="0048" element="0201" keyword="TopLeftHandCornerOfLocalizerArea" vr="US" vm="2" name="Top Left Hand Corner of Localizer Area"/>
+        <entry group="0048" element="0202" keyword="BottomRightHandCornerOfLocalizerArea" vr="US" vm="2" name="Bottom Right Hand Corner of Localizer Area"/>
+        <entry group="0048" element="0207" keyword="OpticalPathIdentificationSequence" vr="SQ" vm="1" name="Optical Path Identification Sequence"/>
+        <entry group="0048" element="021a" keyword="PlanePositionSlideSequence" vr="SQ" vm="1" name="Plane Position (Slide) Sequence"/>
+        <entry group="0048" element="021e" keyword="ColumnPositionInTotalImagePixelMatrix" vr="SL" vm="1" name="Column Position In Total Image Pixel Matrix"/>
+        <entry group="0048" element="021f" keyword="RowPositionInTotalImagePixelMatrix" vr="SL" vm="1" name="Row Position In Total Image Pixel Matrix"/>
+        <entry group="0048" element="0301" keyword="PixelOriginInterpretation" vr="CS" vm="1" name="Pixel Origin Interpretation"/>
+        <entry group="0050" element="0004" keyword="CalibrationImage" vr="CS" vm="1" name="Calibration Image"/>
+        <entry group="0050" element="0010" keyword="DeviceSequence" vr="SQ" vm="1" name="Device Sequence"/>
+        <entry group="0050" element="0012" keyword="ContainerComponentTypeCodeSequence" vr="SQ" vm="1" name="Container Component Type Code Sequence"/>
+        <entry group="0050" element="0013" keyword="ContainerComponentThickness" vr="FD" vm="1" name="Container Component Thickness"/>
+        <entry group="0050" element="0014" keyword="DeviceLength" vr="DS" vm="1" name="Device Length"/>
+        <entry group="0050" element="0015" keyword="ContainerComponentWidth" vr="FD" vm="1" name="Container Component Width"/>
+        <entry group="0050" element="0016" keyword="DeviceDiameter" vr="DS" vm="1" name="Device Diameter"/>
+        <entry group="0050" element="0017" keyword="DeviceDiameterUnits" vr="CS" vm="1" name="Device Diameter Units"/>
+        <entry group="0050" element="0018" keyword="DeviceVolume" vr="DS" vm="1" name="Device Volume"/>
+        <entry group="0050" element="0019" keyword="InterMarkerDistance" vr="DS" vm="1" name="Inter-Marker Distance"/>
+        <entry group="0050" element="001a" keyword="ContainerComponentMaterial" vr="CS" vm="1" name="Container Component Material"/>
+        <entry group="0050" element="001b" keyword="ContainerComponentID" vr="LO" vm="1" name="Container Component ID"/>
+        <entry group="0050" element="001c" keyword="ContainerComponentLength" vr="FD" vm="1" name="Container Component Length"/>
+        <entry group="0050" element="001d" keyword="ContainerComponentDiameter" vr="FD" vm="1" name="Container Component Diameter"/>
+        <entry group="0050" element="001e" keyword="ContainerComponentDescription" vr="LO" vm="1" name="Container Component Description"/>
+        <entry group="0050" element="0020" keyword="DeviceDescription" vr="LO" vm="1" name="Device Description"/>
+        <entry group="0052" element="0001" keyword="ContrastBolusIngredientPercentByVolume" vr="FL" vm="1" name="Contrast/Bolus Ingredient Percent by Volume"/>
+        <entry group="0052" element="0002" keyword="OCTFocalDistance" vr="FD" vm="1" name="OCT Focal Distance"/>
+        <entry group="0052" element="0003" keyword="BeamSpotSize" vr="FD" vm="1" name="Beam Spot Size"/>
+        <entry group="0052" element="0004" keyword="EffectiveRefractiveIndex" vr="FD" vm="1" name="Effective Refractive Index"/>
+        <entry group="0052" element="0006" keyword="OCTAcquisitionDomain" vr="CS" vm="1" name="OCT Acquisition Domain"/>
+        <entry group="0052" element="0007" keyword="OCTOpticalCenterWavelength" vr="FD" vm="1" name="OCT Optical Center Wavelength"/>
+        <entry group="0052" element="0008" keyword="AxialResolution" vr="FD" vm="1" name="Axial Resolution"/>
+        <entry group="0052" element="0009" keyword="RangingDepth" vr="FD" vm="1" name="Ranging Depth"/>
+        <entry group="0052" element="0011" keyword="ALineRate" vr="FD" vm="1" name="A-line Rate"/>
+        <entry group="0052" element="0012" keyword="ALinesPerFrame" vr="US" vm="1" name="A-lines Per Frame"/>
+        <entry group="0052" element="0013" keyword="CatheterRotationalRate" vr="FD" vm="1" name="Catheter Rotational Rate"/>
+        <entry group="0052" element="0014" keyword="ALinePixelSpacing" vr="FD" vm="1" name="A-line Pixel Spacing"/>
+        <entry group="0052" element="0016" keyword="ModeOfPercutaneousAccessSequence" vr="SQ" vm="1" name="Mode of Percutaneous Access Sequence"/>
+        <entry group="0052" element="0025" keyword="IntravascularOCTFrameTypeSequence" vr="SQ" vm="1" name="Intravascular OCT Frame Type Sequence"/>
+        <entry group="0052" element="0026" keyword="OCTZOffsetApplied" vr="CS" vm="1" name="OCT Z Offset Applied"/>
+        <entry group="0052" element="0027" keyword="IntravascularFrameContentSequence" vr="SQ" vm="1" name="Intravascular Frame Content Sequence"/>
+        <entry group="0052" element="0028" keyword="IntravascularLongitudinalDistance" vr="FD" vm="1" name="Intravascular Longitudinal Distance"/>
+        <entry group="0052" element="0029" keyword="IntravascularOCTFrameContentSequence" vr="SQ" vm="1" name="Intravascular OCT Frame Content Sequence"/>
+        <entry group="0052" element="0030" keyword="OCTZOffsetCorrection" vr="SS" vm="1" name="OCT Z Offset Correction"/>
+        <entry group="0052" element="0031" keyword="CatheterDirectionOfRotation" vr="CS" vm="1" name="Catheter Direction of Rotation"/>
+        <entry group="0052" element="0033" keyword="SeamLineLocation" vr="FD" vm="1" name="Seam Line Location"/>
+        <entry group="0052" element="0034" keyword="FirstALineLocation" vr="FD" vm="1" name="First A-line Location"/>
+        <entry group="0052" element="0036" keyword="SeamLineIndex" vr="US" vm="1" name="Seam Line Index"/>
+        <entry group="0052" element="0038" keyword="NumberOfPaddedALines" vr="US" vm="1" name="Number of Padded A-lines"/>
+        <entry group="0052" element="0039" keyword="InterpolationType" vr="CS" vm="1" name="Interpolation Type"/>
+        <entry group="0052" element="003a" keyword="RefractiveIndexApplied" vr="CS" vm="1" name="Refractive Index Applied"/>
+        <entry group="0054" element="0010" keyword="EnergyWindowVector" vr="US" vm="1-n" name="Energy Window Vector"/>
+        <entry group="0054" element="0011" keyword="NumberOfEnergyWindows" vr="US" vm="1" name="Number of Energy Windows"/>
+        <entry group="0054" element="0012" keyword="EnergyWindowInformationSequence" vr="SQ" vm="1" name="Energy Window Information Sequence"/>
+        <entry group="0054" element="0013" keyword="EnergyWindowRangeSequence" vr="SQ" vm="1" name="Energy Window Range Sequence"/>
+        <entry group="0054" element="0014" keyword="EnergyWindowLowerLimit" vr="DS" vm="1" name="Energy Window Lower Limit"/>
+        <entry group="0054" element="0015" keyword="EnergyWindowUpperLimit" vr="DS" vm="1" name="Energy Window Upper Limit"/>
+        <entry group="0054" element="0016" keyword="RadiopharmaceuticalInformationSequence" vr="SQ" vm="1" name="Radiopharmaceutical Information Sequence"/>
+        <entry group="0054" element="0017" keyword="ResidualSyringeCounts" vr="IS" vm="1" name="Residual Syringe Counts"/>
+        <entry group="0054" element="0018" keyword="EnergyWindowName" vr="SH" vm="1" name="Energy Window Name"/>
+        <entry group="0054" element="0020" keyword="DetectorVector" vr="US" vm="1-n" name="Detector Vector"/>
+        <entry group="0054" element="0021" keyword="NumberOfDetectors" vr="US" vm="1" name="Number of Detectors"/>
+        <entry group="0054" element="0022" keyword="DetectorInformationSequence" vr="SQ" vm="1" name="Detector Information Sequence"/>
+        <entry group="0054" element="0030" keyword="PhaseVector" vr="US" vm="1-n" name="Phase Vector"/>
+        <entry group="0054" element="0031" keyword="NumberOfPhases" vr="US" vm="1" name="Number of Phases"/>
+        <entry group="0054" element="0032" keyword="PhaseInformationSequence" vr="SQ" vm="1" name="Phase Information Sequence"/>
+        <entry group="0054" element="0033" keyword="NumberOfFramesInPhase" vr="US" vm="1" name="Number of Frames in Phase"/>
+        <entry group="0054" element="0036" keyword="PhaseDelay" vr="IS" vm="1" name="Phase Delay"/>
+        <entry group="0054" element="0038" keyword="PauseBetweenFrames" vr="IS" vm="1" name="Pause Between Frames"/>
+        <entry group="0054" element="0039" keyword="PhaseDescription" vr="CS" vm="1" name="Phase Description"/>
+        <entry group="0054" element="0050" keyword="RotationVector" vr="US" vm="1-n" name="Rotation Vector"/>
+        <entry group="0054" element="0051" keyword="NumberOfRotations" vr="US" vm="1" name="Number of Rotations"/>
+        <entry group="0054" element="0052" keyword="RotationInformationSequence" vr="SQ" vm="1" name="Rotation Information Sequence"/>
+        <entry group="0054" element="0053" keyword="NumberOfFramesInRotation" vr="US" vm="1" name="Number of Frames in Rotation"/>
+        <entry group="0054" element="0060" keyword="RRIntervalVector" vr="US" vm="1-n" name="R-R Interval Vector"/>
+        <entry group="0054" element="0061" keyword="NumberOfRRIntervals" vr="US" vm="1" name="Number of R-R Intervals"/>
+        <entry group="0054" element="0062" keyword="GatedInformationSequence" vr="SQ" vm="1" name="Gated Information Sequence"/>
+        <entry group="0054" element="0063" keyword="DataInformationSequence" vr="SQ" vm="1" name="Data Information Sequence"/>
+        <entry group="0054" element="0070" keyword="TimeSlotVector" vr="US" vm="1-n" name="Time Slot Vector"/>
+        <entry group="0054" element="0071" keyword="NumberOfTimeSlots" vr="US" vm="1" name="Number of Time Slots"/>
+        <entry group="0054" element="0072" keyword="TimeSlotInformationSequence" vr="SQ" vm="1" name="Time Slot Information Sequence"/>
+        <entry group="0054" element="0073" keyword="TimeSlotTime" vr="DS" vm="1" name="Time Slot Time"/>
+        <entry group="0054" element="0080" keyword="SliceVector" vr="US" vm="1-n" name="Slice Vector"/>
+        <entry group="0054" element="0081" keyword="NumberOfSlices" vr="US" vm="1" name="Number of Slices"/>
+        <entry group="0054" element="0090" keyword="AngularViewVector" vr="US" vm="1-n" name="Angular View Vector"/>
+        <entry group="0054" element="0100" keyword="TimeSliceVector" vr="US" vm="1-n" name="Time Slice Vector"/>
+        <entry group="0054" element="0101" keyword="NumberOfTimeSlices" vr="US" vm="1" name="Number of Time Slices"/>
+        <entry group="0054" element="0200" keyword="StartAngle" vr="DS" vm="1" name="Start Angle"/>
+        <entry group="0054" element="0202" keyword="TypeOfDetectorMotion" vr="CS" vm="1" name="Type of Detector Motion"/>
+        <entry group="0054" element="0210" keyword="TriggerVector" vr="IS" vm="1-n" name="Trigger Vector"/>
+        <entry group="0054" element="0211" keyword="NumberOfTriggersInPhase" vr="US" vm="1" name="Number of Triggers in Phase"/>
+        <entry group="0054" element="0220" keyword="ViewCodeSequence" vr="SQ" vm="1" name="View Code Sequence"/>
+        <entry group="0054" element="0222" keyword="ViewModifierCodeSequence" vr="SQ" vm="1" name="View Modifier Code Sequence"/>
+        <entry group="0054" element="0300" keyword="RadionuclideCodeSequence" vr="SQ" vm="1" name="Radionuclide Code Sequence"/>
+        <entry group="0054" element="0302" keyword="AdministrationRouteCodeSequence" vr="SQ" vm="1" name="Administration Route Code Sequence"/>
+        <entry group="0054" element="0304" keyword="RadiopharmaceuticalCodeSequence" vr="SQ" vm="1" name="Radiopharmaceutical Code Sequence"/>
+        <entry group="0054" element="0306" keyword="CalibrationDataSequence" vr="SQ" vm="1" name="Calibration Data Sequence"/>
+        <entry group="0054" element="0308" keyword="EnergyWindowNumber" vr="US" vm="1" name="Energy Window Number"/>
+        <entry group="0054" element="0400" keyword="ImageID" vr="SH" vm="1" name="Image ID"/>
+        <entry group="0054" element="0410" keyword="PatientOrientationCodeSequence" vr="SQ" vm="1" name="Patient Orientation Code Sequence"/>
+        <entry group="0054" element="0412" keyword="PatientOrientationModifierCodeSequence" vr="SQ" vm="1" name="Patient Orientation Modifier Code Sequence"/>
+        <entry group="0054" element="0414" keyword="PatientGantryRelationshipCodeSequence" vr="SQ" vm="1" name="Patient Gantry Relationship Code Sequence"/>
+        <entry group="0054" element="0500" keyword="SliceProgressionDirection" vr="CS" vm="1" name="Slice Progression Direction"/>
+        <entry group="0054" element="0501" keyword="ScanProgressionDirection" vr="CS" vm="1" name="Scan Progression Direction"/>
+        <entry group="0054" element="1000" keyword="SeriesType" vr="CS" vm="2" name="Series Type"/>
+        <entry group="0054" element="1001" keyword="Units" vr="CS" vm="1" name="Units"/>
+        <entry group="0054" element="1002" keyword="CountsSource" vr="CS" vm="1" name="Counts Source"/>
+        <entry group="0054" element="1004" keyword="ReprojectionMethod" vr="CS" vm="1" name="Reprojection Method"/>
+        <entry group="0054" element="1006" keyword="SUVType" vr="CS" vm="1" name="SUV Type"/>
+        <entry group="0054" element="1100" keyword="RandomsCorrectionMethod" vr="CS" vm="1" name="Randoms Correction Method"/>
+        <entry group="0054" element="1101" keyword="AttenuationCorrectionMethod" vr="LO" vm="1" name="Attenuation Correction Method"/>
+        <entry group="0054" element="1102" keyword="DecayCorrection" vr="CS" vm="1" name="Decay Correction"/>
+        <entry group="0054" element="1103" keyword="ReconstructionMethod" vr="LO" vm="1" name="Reconstruction Method"/>
+        <entry group="0054" element="1104" keyword="DetectorLinesOfResponseUsed" vr="LO" vm="1" name="Detector Lines of Response Used"/>
+        <entry group="0054" element="1105" keyword="ScatterCorrectionMethod" vr="LO" vm="1" name="Scatter Correction Method"/>
+        <entry group="0054" element="1200" keyword="AxialAcceptance" vr="DS" vm="1" name="Axial Acceptance"/>
+        <entry group="0054" element="1201" keyword="AxialMash" vr="IS" vm="2" name="Axial Mash"/>
+        <entry group="0054" element="1202" keyword="TransverseMash" vr="IS" vm="1" name="Transverse Mash"/>
+        <entry group="0054" element="1203" keyword="DetectorElementSize" vr="DS" vm="2" name="Detector Element Size"/>
+        <entry group="0054" element="1210" keyword="CoincidenceWindowWidth" vr="DS" vm="1" name="Coincidence Window Width"/>
+        <entry group="0054" element="1220" keyword="SecondaryCountsType" vr="CS" vm="1-n" name="Secondary Counts Type"/>
+        <entry group="0054" element="1300" keyword="FrameReferenceTime" vr="DS" vm="1" name="Frame Reference Time"/>
+        <entry group="0054" element="1310" keyword="PrimaryPromptsCountsAccumulated" vr="IS" vm="1" name="Primary (Prompts) Counts Accumulated"/>
+        <entry group="0054" element="1311" keyword="SecondaryCountsAccumulated" vr="IS" vm="1-n" name="Secondary Counts Accumulated"/>
+        <entry group="0054" element="1320" keyword="SliceSensitivityFactor" vr="DS" vm="1" name="Slice Sensitivity Factor"/>
+        <entry group="0054" element="1321" keyword="DecayFactor" vr="DS" vm="1" name="Decay Factor"/>
+        <entry group="0054" element="1322" keyword="DoseCalibrationFactor" vr="DS" vm="1" name="Dose Calibration Factor"/>
+        <entry group="0054" element="1323" keyword="ScatterFractionFactor" vr="DS" vm="1" name="Scatter Fraction Factor"/>
+        <entry group="0054" element="1324" keyword="DeadTimeFactor" vr="DS" vm="1" name="Dead Time Factor"/>
+        <entry group="0054" element="1330" keyword="ImageIndex" vr="US" vm="1" name="Image Index"/>
+        <entry group="0054" element="1400" keyword="CountsIncluded" vr="CS" vm="1-n" retired="true" name="Counts Included"/>
+        <entry group="0054" element="1401" keyword="DeadTimeCorrectionFlag" vr="CS" vm="1" retired="true" name="Dead Time Correction Flag"/>
+        <entry group="0060" element="3000" keyword="HistogramSequence" vr="SQ" vm="1" name="Histogram Sequence"/>
+        <entry group="0060" element="3002" keyword="HistogramNumberOfBins" vr="US" vm="1" name="Histogram Number of Bins"/>
+        <entry group="0060" element="3004" keyword="HistogramFirstBinValue" vr="US_SS" vm="1" name="Histogram First Bin Value"/>
+        <entry group="0060" element="3006" keyword="HistogramLastBinValue" vr="US_SS" vm="1" name="Histogram Last Bin Value"/>
+        <entry group="0060" element="3008" keyword="HistogramBinWidth" vr="US" vm="1" name="Histogram Bin Width"/>
+        <entry group="0060" element="3010" keyword="HistogramExplanation" vr="LO" vm="1" name="Histogram Explanation"/>
+        <entry group="0060" element="3020" keyword="HistogramData" vr="UL" vm="1-n" name="Histogram Data"/>
+        <entry group="0062" element="0001" keyword="SegmentationType" vr="CS" vm="1" name="Segmentation Type"/>
+        <entry group="0062" element="0002" keyword="SegmentSequence" vr="SQ" vm="1" name="Segment Sequence"/>
+        <entry group="0062" element="0003" keyword="SegmentedPropertyCategoryCodeSequence" vr="SQ" vm="1" name="Segmented Property Category Code Sequence"/>
+        <entry group="0062" element="0004" keyword="SegmentNumber" vr="US" vm="1" name="Segment Number"/>
+        <entry group="0062" element="0005" keyword="SegmentLabel" vr="LO" vm="1" name="Segment Label"/>
+        <entry group="0062" element="0006" keyword="SegmentDescription" vr="ST" vm="1" name="Segment Description"/>
+        <entry group="0062" element="0007" keyword="SegmentationAlgorithmIdentificationSequence" vr="SQ" vm="1" name="Segmentation Algorithm Identification Sequence"/>
+        <entry group="0062" element="0008" keyword="SegmentAlgorithmType" vr="CS" vm="1" name="Segment Algorithm Type"/>
+        <entry group="0062" element="0009" keyword="SegmentAlgorithmName" vr="LO" vm="1" name="Segment Algorithm Name"/>
+        <entry group="0062" element="000a" keyword="SegmentIdentificationSequence" vr="SQ" vm="1" name="Segment Identification Sequence"/>
+        <entry group="0062" element="000b" keyword="ReferencedSegmentNumber" vr="US" vm="1-n" name="Referenced Segment Number"/>
+        <entry group="0062" element="000c" keyword="RecommendedDisplayGrayscaleValue" vr="US" vm="1" name="Recommended Display Grayscale Value"/>
+        <entry group="0062" element="000d" keyword="RecommendedDisplayCIELabValue" vr="US" vm="3" name="Recommended Display CIELab Value"/>
+        <entry group="0062" element="000e" keyword="MaximumFractionalValue" vr="US" vm="1" name="Maximum Fractional Value"/>
+        <entry group="0062" element="000f" keyword="SegmentedPropertyTypeCodeSequence" vr="SQ" vm="1" name="Segmented Property Type Code Sequence"/>
+        <entry group="0062" element="0010" keyword="SegmentationFractionalType" vr="CS" vm="1" name="Segmentation Fractional Type"/>
+        <entry group="0062" element="0011" keyword="SegmentedPropertyTypeModifierCodeSequence" vr="SQ" vm="1" name="Segmented Property Type Modifier Code Sequence"/>
+        <entry group="0062" element="0012" keyword="UsedSegmentsSequence" vr="SQ" vm="1" name="Used Segments Sequence"/>
+        <entry group="0062" element="0020" keyword="TrackingID" vr="UT" vm="1" name="Tracking ID"/>
+        <entry group="0062" element="0021" keyword="TrackingUID" vr="UI" vm="1" name="Tracking UID"/>
+        <entry group="0064" element="0002" keyword="DeformableRegistrationSequence" vr="SQ" vm="1" name="Deformable Registration Sequence"/>
+        <entry group="0064" element="0003" keyword="SourceFrameOfReferenceUID" vr="UI" vm="1" name="Source Frame of Reference UID"/>
+        <entry group="0064" element="0005" keyword="DeformableRegistrationGridSequence" vr="SQ" vm="1" name="Deformable Registration Grid Sequence"/>
+        <entry group="0064" element="0007" keyword="GridDimensions" vr="UL" vm="3" name="Grid Dimensions"/>
+        <entry group="0064" element="0008" keyword="GridResolution" vr="FD" vm="3" name="Grid Resolution"/>
+        <entry group="0064" element="0009" keyword="VectorGridData" vr="OF" vm="1" name="Vector Grid Data"/>
+        <entry group="0064" element="000f" keyword="PreDeformationMatrixRegistrationSequence" vr="SQ" vm="1" name="Pre Deformation Matrix Registration Sequence"/>
+        <entry group="0064" element="0010" keyword="PostDeformationMatrixRegistrationSequence" vr="SQ" vm="1" name="Post Deformation Matrix Registration Sequence"/>
+        <entry group="0066" element="0001" keyword="NumberOfSurfaces" vr="UL" vm="1" name="Number of Surfaces"/>
+        <entry group="0066" element="0002" keyword="SurfaceSequence" vr="SQ" vm="1" name="Surface Sequence"/>
+        <entry group="0066" element="0003" keyword="SurfaceNumber" vr="UL" vm="1" name="Surface Number"/>
+        <entry group="0066" element="0004" keyword="SurfaceComments" vr="LT" vm="1" name="Surface Comments"/>
+        <entry group="0066" element="0009" keyword="SurfaceProcessing" vr="CS" vm="1" name="Surface Processing"/>
+        <entry group="0066" element="000a" keyword="SurfaceProcessingRatio" vr="FL" vm="1" name="Surface Processing Ratio"/>
+        <entry group="0066" element="000b" keyword="SurfaceProcessingDescription" vr="LO" vm="1" name="Surface Processing Description"/>
+        <entry group="0066" element="000c" keyword="RecommendedPresentationOpacity" vr="FL" vm="1" name="Recommended Presentation Opacity"/>
+        <entry group="0066" element="000d" keyword="RecommendedPresentationType" vr="CS" vm="1" name="Recommended Presentation Type"/>
+        <entry group="0066" element="000e" keyword="FiniteVolume" vr="CS" vm="1" name="Finite Volume"/>
+        <entry group="0066" element="0010" keyword="Manifold" vr="CS" vm="1" name="Manifold"/>
+        <entry group="0066" element="0011" keyword="SurfacePointsSequence" vr="SQ" vm="1" name="Surface Points Sequence"/>
+        <entry group="0066" element="0012" keyword="SurfacePointsNormalsSequence" vr="SQ" vm="1" name="Surface Points Normals Sequence"/>
+        <entry group="0066" element="0013" keyword="SurfaceMeshPrimitivesSequence" vr="SQ" vm="1" name="Surface Mesh Primitives Sequence"/>
+        <entry group="0066" element="0015" keyword="NumberOfSurfacePoints" vr="UL" vm="1" name="Number of Surface Points"/>
+        <entry group="0066" element="0016" keyword="PointCoordinatesData" vr="OF" vm="1" name="Point Coordinates Data"/>
+        <entry group="0066" element="0017" keyword="PointPositionAccuracy" vr="FL" vm="3" name="Point Position Accuracy"/>
+        <entry group="0066" element="0018" keyword="MeanPointDistance" vr="FL" vm="1" name="Mean Point Distance"/>
+        <entry group="0066" element="0019" keyword="MaximumPointDistance" vr="FL" vm="1" name="Maximum Point Distance"/>
+        <entry group="0066" element="001a" keyword="PointsBoundingBoxCoordinates" vr="FL" vm="6" name="Points Bounding Box Coordinates"/>
+        <entry group="0066" element="001b" keyword="AxisOfRotation" vr="FL" vm="3" name="Axis of Rotation"/>
+        <entry group="0066" element="001c" keyword="CenterOfRotation" vr="FL" vm="3" name="Center of Rotation"/>
+        <entry group="0066" element="001e" keyword="NumberOfVectors" vr="UL" vm="1" name="Number of Vectors"/>
+        <entry group="0066" element="001f" keyword="VectorDimensionality" vr="US" vm="1" name="Vector Dimensionality"/>
+        <entry group="0066" element="0020" keyword="VectorAccuracy" vr="FL" vm="1-n" name="Vector Accuracy"/>
+        <entry group="0066" element="0021" keyword="VectorCoordinateData" vr="OF" vm="1" name="Vector Coordinate Data"/>
+        <entry group="0066" element="0023" keyword="TrianglePointIndexList" vr="OW" vm="1" retired="true" name="Triangle Point Index List"/>
+        <entry group="0066" element="0024" keyword="EdgePointIndexList" vr="OW" vm="1" retired="true" name="Edge Point Index List"/>
+        <entry group="0066" element="0025" keyword="VertexPointIndexList" vr="OW" vm="1" retired="true" name="Vertex Point Index List"/>
+        <entry group="0066" element="0026" keyword="TriangleStripSequence" vr="SQ" vm="1" name="Triangle Strip Sequence"/>
+        <entry group="0066" element="0027" keyword="TriangleFanSequence" vr="SQ" vm="1" name="Triangle Fan Sequence"/>
+        <entry group="0066" element="0028" keyword="LineSequence" vr="SQ" vm="1" name="Line Sequence"/>
+        <entry group="0066" element="0029" keyword="PrimitivePointIndexList" vr="OW" vm="1" retired="true" name="Primitive Point Index List"/>
+        <entry group="0066" element="002a" keyword="SurfaceCount" vr="UL" vm="1" name="Surface Count"/>
+        <entry group="0066" element="002b" keyword="ReferencedSurfaceSequence" vr="SQ" vm="1" name="Referenced Surface Sequence"/>
+        <entry group="0066" element="002c" keyword="ReferencedSurfaceNumber" vr="UL" vm="1" name="Referenced Surface Number"/>
+        <entry group="0066" element="002d" keyword="SegmentSurfaceGenerationAlgorithmIdentificationSequence" vr="SQ" vm="1" name="Segment Surface Generation Algorithm Identification Sequence"/>
+        <entry group="0066" element="002e" keyword="SegmentSurfaceSourceInstanceSequence" vr="SQ" vm="1" name="Segment Surface Source Instance Sequence"/>
+        <entry group="0066" element="002f" keyword="AlgorithmFamilyCodeSequence" vr="SQ" vm="1" name="Algorithm Family Code Sequence"/>
+        <entry group="0066" element="0030" keyword="AlgorithmNameCodeSequence" vr="SQ" vm="1" name="Algorithm Name Code Sequence"/>
+        <entry group="0066" element="0031" keyword="AlgorithmVersion" vr="LO" vm="1" name="Algorithm Version"/>
+        <entry group="0066" element="0032" keyword="AlgorithmParameters" vr="LT" vm="1" name="Algorithm Parameters"/>
+        <entry group="0066" element="0034" keyword="FacetSequence" vr="SQ" vm="1" name="Facet Sequence"/>
+        <entry group="0066" element="0035" keyword="SurfaceProcessingAlgorithmIdentificationSequence" vr="SQ" vm="1" name="Surface Processing Algorithm Identification Sequence"/>
+        <entry group="0066" element="0036" keyword="AlgorithmName" vr="LO" vm="1" name="Algorithm Name"/>
+        <entry group="0066" element="0037" keyword="RecommendedPointRadius" vr="FL" vm="1" name="Recommended Point Radius"/>
+        <entry group="0066" element="0038" keyword="RecommendedLineThickness" vr="FL" vm="1" name="Recommended Line Thickness"/>
+        <entry group="0066" element="0040" keyword="LongPrimitivePointIndexList" vr="OL" vm="1" name="Long Primitive Point Index List"/>
+        <entry group="0066" element="0041" keyword="LongTrianglePointIndexList" vr="OL" vm="1" name="Long Triangle Point Index List"/>
+        <entry group="0066" element="0042" keyword="LongEdgePointIndexList" vr="OL" vm="1" name="Long Edge Point Index List"/>
+        <entry group="0066" element="0043" keyword="LongVertexPointIndexList" vr="OL" vm="1" name="Long Vertex Point Index List"/>
+        <entry group="0066" element="0101" keyword="TrackSetSequence" vr="SQ" vm="1" name="Track Set Sequence"/>
+        <entry group="0066" element="0102" keyword="TrackSequence" vr="SQ" vm="1" name="Track Sequence"/>
+        <entry group="0066" element="0103" keyword="RecommendedDisplayCIELabValueList" vr="OW" vm="1" name="Recommended Display CIELab Value List"/>
+        <entry group="0066" element="0104" keyword="TrackingAlgorithmIdentificationSequence" vr="SQ" vm="1" name="Tracking Algorithm Identification Sequence"/>
+        <entry group="0066" element="0105" keyword="TrackSetNumber" vr="UL" vm="1" name="Track Set Number"/>
+        <entry group="0066" element="0106" keyword="TrackSetLabel" vr="LO" vm="1" name="Track Set Label"/>
+        <entry group="0066" element="0107" keyword="TrackSetDescription" vr="UT" vm="1" name="Track Set Description"/>
+        <entry group="0066" element="0108" keyword="TrackSetAnatomicalTypeCodeSequence" vr="SQ" vm="1" name="Track Set Anatomical Type Code Sequence"/>
+        <entry group="0066" element="0121" keyword="MeasurementsSequence" vr="SQ" vm="1" name="Measurements Sequence"/>
+        <entry group="0066" element="0124" keyword="TrackSetStatisticsSequence" vr="SQ" vm="1" name="Track Set Statistics Sequence"/>
+        <entry group="0066" element="0125" keyword="FloatingPointValues" vr="OF" vm="1" name="Floating Point Values"/>
+        <entry group="0066" element="0129" keyword="TrackPointIndexList" vr="OL" vm="1" name="Track Point Index List"/>
+        <entry group="0066" element="0130" keyword="TrackStatisticsSequence" vr="SQ" vm="1" name="Track Statistics Sequence"/>
+        <entry group="0066" element="0132" keyword="MeasurementValuesSequence" vr="SQ" vm="1" name="Measurement Values Sequence"/>
+        <entry group="0066" element="0133" keyword="DiffusionAcquisitionCodeSequence" vr="SQ" vm="1" name="Diffusion Acquisition Code Sequence"/>
+        <entry group="0066" element="0134" keyword="DiffusionModelCodeSequence" vr="SQ" vm="1" name="Diffusion Model Code Sequence"/>
+        <entry group="0068" element="6210" keyword="ImplantSize" vr="LO" vm="1" name="Implant Size"/>
+        <entry group="0068" element="6221" keyword="ImplantTemplateVersion" vr="LO" vm="1" name="Implant Template Version"/>
+        <entry group="0068" element="6222" keyword="ReplacedImplantTemplateSequence" vr="SQ" vm="1" name="Replaced Implant Template Sequence"/>
+        <entry group="0068" element="6223" keyword="ImplantType" vr="CS" vm="1" name="Implant Type"/>
+        <entry group="0068" element="6224" keyword="DerivationImplantTemplateSequence" vr="SQ" vm="1" name="Derivation Implant Template Sequence"/>
+        <entry group="0068" element="6225" keyword="OriginalImplantTemplateSequence" vr="SQ" vm="1" name="Original Implant Template Sequence"/>
+        <entry group="0068" element="6226" keyword="EffectiveDateTime" vr="DT" vm="1" name="Effective DateTime"/>
+        <entry group="0068" element="6230" keyword="ImplantTargetAnatomySequence" vr="SQ" vm="1" name="Implant Target Anatomy Sequence"/>
+        <entry group="0068" element="6260" keyword="InformationFromManufacturerSequence" vr="SQ" vm="1" name="Information From Manufacturer Sequence"/>
+        <entry group="0068" element="6265" keyword="NotificationFromManufacturerSequence" vr="SQ" vm="1" name="Notification From Manufacturer Sequence"/>
+        <entry group="0068" element="6270" keyword="InformationIssueDateTime" vr="DT" vm="1" name="Information Issue DateTime"/>
+        <entry group="0068" element="6280" keyword="InformationSummary" vr="ST" vm="1" name="Information Summary"/>
+        <entry group="0068" element="62a0" keyword="ImplantRegulatoryDisapprovalCodeSequence" vr="SQ" vm="1" name="Implant Regulatory Disapproval Code Sequence"/>
+        <entry group="0068" element="62a5" keyword="OverallTemplateSpatialTolerance" vr="FD" vm="1" name="Overall Template Spatial Tolerance"/>
+        <entry group="0068" element="62c0" keyword="HPGLDocumentSequence" vr="SQ" vm="1" name="HPGL Document Sequence"/>
+        <entry group="0068" element="62d0" keyword="HPGLDocumentID" vr="US" vm="1" name="HPGL Document ID"/>
+        <entry group="0068" element="62d5" keyword="HPGLDocumentLabel" vr="LO" vm="1" name="HPGL Document Label"/>
+        <entry group="0068" element="62e0" keyword="ViewOrientationCodeSequence" vr="SQ" vm="1" name="View Orientation Code Sequence"/>
+        <entry group="0068" element="62f0" keyword="ViewOrientationModifier" vr="FD" vm="9" name="View Orientation Modifier"/>
+        <entry group="0068" element="62f2" keyword="HPGLDocumentScaling" vr="FD" vm="1" name="HPGL Document Scaling"/>
+        <entry group="0068" element="6300" keyword="HPGLDocument" vr="OB" vm="1" name="HPGL Document"/>
+        <entry group="0068" element="6310" keyword="HPGLContourPenNumber" vr="US" vm="1" name="HPGL Contour Pen Number"/>
+        <entry group="0068" element="6320" keyword="HPGLPenSequence" vr="SQ" vm="1" name="HPGL Pen Sequence"/>
+        <entry group="0068" element="6330" keyword="HPGLPenNumber" vr="US" vm="1" name="HPGL Pen Number"/>
+        <entry group="0068" element="6340" keyword="HPGLPenLabel" vr="LO" vm="1" name="HPGL Pen Label"/>
+        <entry group="0068" element="6345" keyword="HPGLPenDescription" vr="ST" vm="1" name="HPGL Pen Description"/>
+        <entry group="0068" element="6346" keyword="RecommendedRotationPoint" vr="FD" vm="2" name="Recommended Rotation Point"/>
+        <entry group="0068" element="6347" keyword="BoundingRectangle" vr="FD" vm="4" name="Bounding Rectangle"/>
+        <entry group="0068" element="6350" keyword="ImplantTemplate3DModelSurfaceNumber" vr="US" vm="1-n" name="Implant Template 3D Model Surface Number"/>
+        <entry group="0068" element="6360" keyword="SurfaceModelDescriptionSequence" vr="SQ" vm="1" name="Surface Model Description Sequence"/>
+        <entry group="0068" element="6380" keyword="SurfaceModelLabel" vr="LO" vm="1" name="Surface Model Label"/>
+        <entry group="0068" element="6390" keyword="SurfaceModelScalingFactor" vr="FD" vm="1" name="Surface Model Scaling Factor"/>
+        <entry group="0068" element="63a0" keyword="MaterialsCodeSequence" vr="SQ" vm="1" name="Materials Code Sequence"/>
+        <entry group="0068" element="63a4" keyword="CoatingMaterialsCodeSequence" vr="SQ" vm="1" name="Coating Materials Code Sequence"/>
+        <entry group="0068" element="63a8" keyword="ImplantTypeCodeSequence" vr="SQ" vm="1" name="Implant Type Code Sequence"/>
+        <entry group="0068" element="63ac" keyword="FixationMethodCodeSequence" vr="SQ" vm="1" name="Fixation Method Code Sequence"/>
+        <entry group="0068" element="63b0" keyword="MatingFeatureSetsSequence" vr="SQ" vm="1" name="Mating Feature Sets Sequence"/>
+        <entry group="0068" element="63c0" keyword="MatingFeatureSetID" vr="US" vm="1" name="Mating Feature Set ID"/>
+        <entry group="0068" element="63d0" keyword="MatingFeatureSetLabel" vr="LO" vm="1" name="Mating Feature Set Label"/>
+        <entry group="0068" element="63e0" keyword="MatingFeatureSequence" vr="SQ" vm="1" name="Mating Feature Sequence"/>
+        <entry group="0068" element="63f0" keyword="MatingFeatureID" vr="US" vm="1" name="Mating Feature ID"/>
+        <entry group="0068" element="6400" keyword="MatingFeatureDegreeOfFreedomSequence" vr="SQ" vm="1" name="Mating Feature Degree of Freedom Sequence"/>
+        <entry group="0068" element="6410" keyword="DegreeOfFreedomID" vr="US" vm="1" name="Degree of Freedom ID"/>
+        <entry group="0068" element="6420" keyword="DegreeOfFreedomType" vr="CS" vm="1" name="Degree of Freedom Type"/>
+        <entry group="0068" element="6430" keyword="TwoDMatingFeatureCoordinatesSequence" vr="SQ" vm="1" name="2D Mating Feature Coordinates Sequence"/>
+        <entry group="0068" element="6440" keyword="ReferencedHPGLDocumentID" vr="US" vm="1" name="Referenced HPGL Document ID"/>
+        <entry group="0068" element="6450" keyword="TwoDMatingPoint" vr="FD" vm="2" name="2D Mating Point"/>
+        <entry group="0068" element="6460" keyword="TwoDMatingAxes" vr="FD" vm="4" name="2D Mating Axes"/>
+        <entry group="0068" element="6470" keyword="TwoDDegreeOfFreedomSequence" vr="SQ" vm="1" name="2D Degree of Freedom Sequence"/>
+        <entry group="0068" element="6490" keyword="ThreeDDegreeOfFreedomAxis" vr="FD" vm="3" name="3D Degree of Freedom Axis"/>
+        <entry group="0068" element="64a0" keyword="RangeOfFreedom" vr="FD" vm="2" name="Range of Freedom"/>
+        <entry group="0068" element="64c0" keyword="ThreeDMatingPoint" vr="FD" vm="3" name="3D Mating Point"/>
+        <entry group="0068" element="64d0" keyword="ThreeDMatingAxes" vr="FD" vm="9" name="3D Mating Axes"/>
+        <entry group="0068" element="64f0" keyword="TwoDDegreeOfFreedomAxis" vr="FD" vm="3" name="2D Degree of Freedom Axis"/>
+        <entry group="0068" element="6500" keyword="PlanningLandmarkPointSequence" vr="SQ" vm="1" name="Planning Landmark Point Sequence"/>
+        <entry group="0068" element="6510" keyword="PlanningLandmarkLineSequence" vr="SQ" vm="1" name="Planning Landmark Line Sequence"/>
+        <entry group="0068" element="6520" keyword="PlanningLandmarkPlaneSequence" vr="SQ" vm="1" name="Planning Landmark Plane Sequence"/>
+        <entry group="0068" element="6530" keyword="PlanningLandmarkID" vr="US" vm="1" name="Planning Landmark ID"/>
+        <entry group="0068" element="6540" keyword="PlanningLandmarkDescription" vr="LO" vm="1" name="Planning Landmark Description"/>
+        <entry group="0068" element="6545" keyword="PlanningLandmarkIdentificationCodeSequence" vr="SQ" vm="1" name="Planning Landmark Identification Code Sequence"/>
+        <entry group="0068" element="6550" keyword="TwoDPointCoordinatesSequence" vr="SQ" vm="1" name="2D Point Coordinates Sequence"/>
+        <entry group="0068" element="6560" keyword="TwoDPointCoordinates" vr="FD" vm="2" name="2D Point Coordinates"/>
+        <entry group="0068" element="6590" keyword="ThreeDPointCoordinates" vr="FD" vm="3" name="3D Point Coordinates"/>
+        <entry group="0068" element="65a0" keyword="TwoDLineCoordinatesSequence" vr="SQ" vm="1" name="2D Line Coordinates Sequence"/>
+        <entry group="0068" element="65b0" keyword="TwoDLineCoordinates" vr="FD" vm="4" name="2D Line Coordinates"/>
+        <entry group="0068" element="65d0" keyword="ThreeDLineCoordinates" vr="FD" vm="6" name="3D Line Coordinates"/>
+        <entry group="0068" element="65e0" keyword="TwoDPlaneCoordinatesSequence" vr="SQ" vm="1" name="2D Plane Coordinates Sequence"/>
+        <entry group="0068" element="65f0" keyword="TwoDPlaneIntersection" vr="FD" vm="4" name="2D Plane Intersection"/>
+        <entry group="0068" element="6610" keyword="ThreeDPlaneOrigin" vr="FD" vm="3" name="3D Plane Origin"/>
+        <entry group="0068" element="6620" keyword="ThreeDPlaneNormal" vr="FD" vm="3" name="3D Plane Normal"/>
+        <entry group="0070" element="0001" keyword="GraphicAnnotationSequence" vr="SQ" vm="1" name="Graphic Annotation Sequence"/>
+        <entry group="0070" element="0002" keyword="GraphicLayer" vr="CS" vm="1" name="Graphic Layer"/>
+        <entry group="0070" element="0003" keyword="BoundingBoxAnnotationUnits" vr="CS" vm="1" name="Bounding Box Annotation Units"/>
+        <entry group="0070" element="0004" keyword="AnchorPointAnnotationUnits" vr="CS" vm="1" name="Anchor Point Annotation Units"/>
+        <entry group="0070" element="0005" keyword="GraphicAnnotationUnits" vr="CS" vm="1" name="Graphic Annotation Units"/>
+        <entry group="0070" element="0006" keyword="UnformattedTextValue" vr="ST" vm="1" name="Unformatted Text Value"/>
+        <entry group="0070" element="0008" keyword="TextObjectSequence" vr="SQ" vm="1" name="Text Object Sequence"/>
+        <entry group="0070" element="0009" keyword="GraphicObjectSequence" vr="SQ" vm="1" name="Graphic Object Sequence"/>
+        <entry group="0070" element="0010" keyword="BoundingBoxTopLeftHandCorner" vr="FL" vm="2" name="Bounding Box Top Left Hand Corner"/>
+        <entry group="0070" element="0011" keyword="BoundingBoxBottomRightHandCorner" vr="FL" vm="2" name="Bounding Box Bottom Right Hand Corner"/>
+        <entry group="0070" element="0012" keyword="BoundingBoxTextHorizontalJustification" vr="CS" vm="1" name="Bounding Box Text Horizontal Justification"/>
+        <entry group="0070" element="0014" keyword="AnchorPoint" vr="FL" vm="2" name="Anchor Point"/>
+        <entry group="0070" element="0015" keyword="AnchorPointVisibility" vr="CS" vm="1" name="Anchor Point Visibility"/>
+        <entry group="0070" element="0020" keyword="GraphicDimensions" vr="US" vm="1" name="Graphic Dimensions"/>
+        <entry group="0070" element="0021" keyword="NumberOfGraphicPoints" vr="US" vm="1" name="Number of Graphic Points"/>
+        <entry group="0070" element="0022" keyword="GraphicData" vr="FL" vm="2-n" name="Graphic Data"/>
+        <entry group="0070" element="0023" keyword="GraphicType" vr="CS" vm="1" name="Graphic Type"/>
+        <entry group="0070" element="0024" keyword="GraphicFilled" vr="CS" vm="1" name="Graphic Filled"/>
+        <entry group="0070" element="0040" keyword="ImageRotationRetired" vr="IS" vm="1" retired="true" name="Image Rotation (Retired)"/>
+        <entry group="0070" element="0041" keyword="ImageHorizontalFlip" vr="CS" vm="1" name="Image Horizontal Flip"/>
+        <entry group="0070" element="0042" keyword="ImageRotation" vr="US" vm="1" name="Image Rotation"/>
+        <entry group="0070" element="0050" keyword="DisplayedAreaTopLeftHandCornerTrial" vr="US" vm="2" retired="true" name="Displayed Area Top Left Hand Corner (Trial)"/>
+        <entry group="0070" element="0051" keyword="DisplayedAreaBottomRightHandCornerTrial" vr="US" vm="2" retired="true" name="Displayed Area Bottom Right Hand Corner (Trial)"/>
+        <entry group="0070" element="0052" keyword="DisplayedAreaTopLeftHandCorner" vr="SL" vm="2" name="Displayed Area Top Left Hand Corner"/>
+        <entry group="0070" element="0053" keyword="DisplayedAreaBottomRightHandCorner" vr="SL" vm="2" name="Displayed Area Bottom Right Hand Corner"/>
+        <entry group="0070" element="005a" keyword="DisplayedAreaSelectionSequence" vr="SQ" vm="1" name="Displayed Area Selection Sequence"/>
+        <entry group="0070" element="0060" keyword="GraphicLayerSequence" vr="SQ" vm="1" name="Graphic Layer Sequence"/>
+        <entry group="0070" element="0062" keyword="GraphicLayerOrder" vr="IS" vm="1" name="Graphic Layer Order"/>
+        <entry group="0070" element="0066" keyword="GraphicLayerRecommendedDisplayGrayscaleValue" vr="US" vm="1" name="Graphic Layer Recommended Display Grayscale Value"/>
+        <entry group="0070" element="0067" keyword="GraphicLayerRecommendedDisplayRGBValue" vr="US" vm="3" retired="true" name="Graphic Layer Recommended Display RGB Value"/>
+        <entry group="0070" element="0068" keyword="GraphicLayerDescription" vr="LO" vm="1" name="Graphic Layer Description"/>
+        <entry group="0070" element="0080" keyword="ContentLabel" vr="CS" vm="1" name="Content Label"/>
+        <entry group="0070" element="0081" keyword="ContentDescription" vr="LO" vm="1" name="Content Description"/>
+        <entry group="0070" element="0082" keyword="PresentationCreationDate" vr="DA" vm="1" name="Presentation Creation Date"/>
+        <entry group="0070" element="0083" keyword="PresentationCreationTime" vr="TM" vm="1" name="Presentation Creation Time"/>
+        <entry group="0070" element="0084" keyword="ContentCreatorName" vr="PN" vm="1" name="Content Creator's Name"/>
+        <entry group="0070" element="0086" keyword="ContentCreatorIdentificationCodeSequence" vr="SQ" vm="1" name="Content Creator's Identification Code Sequence"/>
+        <entry group="0070" element="0087" keyword="AlternateContentDescriptionSequence" vr="SQ" vm="1" name="Alternate Content Description Sequence"/>
+        <entry group="0070" element="0100" keyword="PresentationSizeMode" vr="CS" vm="1" name="Presentation Size Mode"/>
+        <entry group="0070" element="0101" keyword="PresentationPixelSpacing" vr="DS" vm="2" name="Presentation Pixel Spacing"/>
+        <entry group="0070" element="0102" keyword="PresentationPixelAspectRatio" vr="IS" vm="2" name="Presentation Pixel Aspect Ratio"/>
+        <entry group="0070" element="0103" keyword="PresentationPixelMagnificationRatio" vr="FL" vm="1" name="Presentation Pixel Magnification Ratio"/>
+        <entry group="0070" element="0207" keyword="GraphicGroupLabel" vr="LO" vm="1" name="Graphic Group Label"/>
+        <entry group="0070" element="0208" keyword="GraphicGroupDescription" vr="ST" vm="1" name="Graphic Group Description"/>
+        <entry group="0070" element="0209" keyword="CompoundGraphicSequence" vr="SQ" vm="1" name="Compound Graphic Sequence"/>
+        <entry group="0070" element="0226" keyword="CompoundGraphicInstanceID" vr="UL" vm="1" name="Compound Graphic Instance ID"/>
+        <entry group="0070" element="0227" keyword="FontName" vr="LO" vm="1" name="Font Name"/>
+        <entry group="0070" element="0228" keyword="FontNameType" vr="CS" vm="1" name="Font Name Type"/>
+        <entry group="0070" element="0229" keyword="CSSFontName" vr="LO" vm="1" name="CSS Font Name"/>
+        <entry group="0070" element="0230" keyword="RotationAngle" vr="FD" vm="1" name="Rotation Angle"/>
+        <entry group="0070" element="0231" keyword="TextStyleSequence" vr="SQ" vm="1" name="Text Style Sequence"/>
+        <entry group="0070" element="0232" keyword="LineStyleSequence" vr="SQ" vm="1" name="Line Style Sequence"/>
+        <entry group="0070" element="0233" keyword="FillStyleSequence" vr="SQ" vm="1" name="Fill Style Sequence"/>
+        <entry group="0070" element="0234" keyword="GraphicGroupSequence" vr="SQ" vm="1" name="Graphic Group Sequence"/>
+        <entry group="0070" element="0241" keyword="TextColorCIELabValue" vr="US" vm="3" name="Text Color CIELab Value"/>
+        <entry group="0070" element="0242" keyword="HorizontalAlignment" vr="CS" vm="1" name="Horizontal Alignment"/>
+        <entry group="0070" element="0243" keyword="VerticalAlignment" vr="CS" vm="1" name="Vertical Alignment"/>
+        <entry group="0070" element="0244" keyword="ShadowStyle" vr="CS" vm="1" name="Shadow Style"/>
+        <entry group="0070" element="0245" keyword="ShadowOffsetX" vr="FL" vm="1" name="Shadow Offset X"/>
+        <entry group="0070" element="0246" keyword="ShadowOffsetY" vr="FL" vm="1" name="Shadow Offset Y"/>
+        <entry group="0070" element="0247" keyword="ShadowColorCIELabValue" vr="US" vm="3" name="Shadow Color CIELab Value"/>
+        <entry group="0070" element="0248" keyword="Underlined" vr="CS" vm="1" name="Underlined"/>
+        <entry group="0070" element="0249" keyword="Bold" vr="CS" vm="1" name="Bold"/>
+        <entry group="0070" element="0250" keyword="Italic" vr="CS" vm="1" name="Italic"/>
+        <entry group="0070" element="0251" keyword="PatternOnColorCIELabValue" vr="US" vm="3" name="Pattern On Color CIELab Value"/>
+        <entry group="0070" element="0252" keyword="PatternOffColorCIELabValue" vr="US" vm="3" name="Pattern Off Color CIELab Value"/>
+        <entry group="0070" element="0253" keyword="LineThickness" vr="FL" vm="1" name="Line Thickness"/>
+        <entry group="0070" element="0254" keyword="LineDashingStyle" vr="CS" vm="1" name="Line Dashing Style"/>
+        <entry group="0070" element="0255" keyword="LinePattern" vr="UL" vm="1" name="Line Pattern"/>
+        <entry group="0070" element="0256" keyword="FillPattern" vr="OB" vm="1" name="Fill Pattern"/>
+        <entry group="0070" element="0257" keyword="FillMode" vr="CS" vm="1" name="Fill Mode"/>
+        <entry group="0070" element="0258" keyword="ShadowOpacity" vr="FL" vm="1" name="Shadow Opacity"/>
+        <entry group="0070" element="0261" keyword="GapLength" vr="FL" vm="1" name="Gap Length"/>
+        <entry group="0070" element="0262" keyword="DiameterOfVisibility" vr="FL" vm="1" name="Diameter of Visibility"/>
+        <entry group="0070" element="0273" keyword="RotationPoint" vr="FL" vm="2" name="Rotation Point"/>
+        <entry group="0070" element="0274" keyword="TickAlignment" vr="CS" vm="1" name="Tick Alignment"/>
+        <entry group="0070" element="0278" keyword="ShowTickLabel" vr="CS" vm="1" name="Show Tick Label"/>
+        <entry group="0070" element="0279" keyword="TickLabelAlignment" vr="CS" vm="1" name="Tick Label Alignment"/>
+        <entry group="0070" element="0282" keyword="CompoundGraphicUnits" vr="CS" vm="1" name="Compound Graphic Units"/>
+        <entry group="0070" element="0284" keyword="PatternOnOpacity" vr="FL" vm="1" name="Pattern On Opacity"/>
+        <entry group="0070" element="0285" keyword="PatternOffOpacity" vr="FL" vm="1" name="Pattern Off Opacity"/>
+        <entry group="0070" element="0287" keyword="MajorTicksSequence" vr="SQ" vm="1" name="Major Ticks Sequence"/>
+        <entry group="0070" element="0288" keyword="TickPosition" vr="FL" vm="1" name="Tick Position"/>
+        <entry group="0070" element="0289" keyword="TickLabel" vr="SH" vm="1" name="Tick Label"/>
+        <entry group="0070" element="0294" keyword="CompoundGraphicType" vr="CS" vm="1" name="Compound Graphic Type"/>
+        <entry group="0070" element="0295" keyword="GraphicGroupID" vr="UL" vm="1" name="Graphic Group ID"/>
+        <entry group="0070" element="0306" keyword="ShapeType" vr="CS" vm="1" name="Shape Type"/>
+        <entry group="0070" element="0308" keyword="RegistrationSequence" vr="SQ" vm="1" name="Registration Sequence"/>
+        <entry group="0070" element="0309" keyword="MatrixRegistrationSequence" vr="SQ" vm="1" name="Matrix Registration Sequence"/>
+        <entry group="0070" element="030a" keyword="MatrixSequence" vr="SQ" vm="1" name="Matrix Sequence"/>
+        <entry group="0070" element="030b" keyword="FrameOfReferenceToDisplayedCoordinateSystemTransformationMatrix" vr="FD" vm="16" name="Frame of Reference to Displayed Coordinate System Transformation Matrix"/>
+        <entry group="0070" element="030c" keyword="FrameOfReferenceTransformationMatrixType" vr="CS" vm="1" name="Frame of Reference Transformation Matrix Type"/>
+        <entry group="0070" element="030d" keyword="RegistrationTypeCodeSequence" vr="SQ" vm="1" name="Registration Type Code Sequence"/>
+        <entry group="0070" element="030f" keyword="FiducialDescription" vr="ST" vm="1" name="Fiducial Description"/>
+        <entry group="0070" element="0310" keyword="FiducialIdentifier" vr="SH" vm="1" name="Fiducial Identifier"/>
+        <entry group="0070" element="0311" keyword="FiducialIdentifierCodeSequence" vr="SQ" vm="1" name="Fiducial Identifier Code Sequence"/>
+        <entry group="0070" element="0312" keyword="ContourUncertaintyRadius" vr="FD" vm="1" name="Contour Uncertainty Radius"/>
+        <entry group="0070" element="0314" keyword="UsedFiducialsSequence" vr="SQ" vm="1" name="Used Fiducials Sequence"/>
+        <entry group="0070" element="0318" keyword="GraphicCoordinatesDataSequence" vr="SQ" vm="1" name="Graphic Coordinates Data Sequence"/>
+        <entry group="0070" element="031a" keyword="FiducialUID" vr="UI" vm="1" name="Fiducial UID"/>
+        <entry group="0070" element="031c" keyword="FiducialSetSequence" vr="SQ" vm="1" name="Fiducial Set Sequence"/>
+        <entry group="0070" element="031e" keyword="FiducialSequence" vr="SQ" vm="1" name="Fiducial Sequence"/>
+        <entry group="0070" element="031f" keyword="FiducialsPropertyCategoryCodeSequence" vr="SQ" vm="1" name="Fiducials Property Category Code Sequence"/>
+        <entry group="0070" element="0401" keyword="GraphicLayerRecommendedDisplayCIELabValue" vr="US" vm="3" name="Graphic Layer Recommended Display CIELab Value"/>
+        <entry group="0070" element="0402" keyword="BlendingSequence" vr="SQ" vm="1" name="Blending Sequence"/>
+        <entry group="0070" element="0403" keyword="RelativeOpacity" vr="FL" vm="1" name="Relative Opacity"/>
+        <entry group="0070" element="0404" keyword="ReferencedSpatialRegistrationSequence" vr="SQ" vm="1" name="Referenced Spatial Registration Sequence"/>
+        <entry group="0070" element="0405" keyword="BlendingPosition" vr="CS" vm="1" name="Blending Position"/>
+        <entry group="0070" element="1101" keyword="PresentationDisplayCollectionUID" vr="UI" vm="1" name="Presentation Display Collection UID"/>
+        <entry group="0070" element="1102" keyword="PresentationSequenceCollectionUID" vr="UI" vm="1" name="Presentation Sequence Collection UID"/>
+        <entry group="0070" element="1103" keyword="PresentationSequencePositionIndex" vr="US" vm="1" name="Presentation Sequence Position Index"/>
+        <entry group="0070" element="1104" keyword="RenderedImageReferenceSequence" vr="SQ" vm="1" name="Rendered Image Reference Sequence"/>
+        <entry group="0070" element="1201" keyword="VolumetricPresentationStateInputSequence" vr="SQ" vm="1" name="Volumetric Presentation State Input Sequence"/>
+        <entry group="0070" element="1202" keyword="PresentationInputType" vr="CS" vm="1" name="Presentation Input Type"/>
+        <entry group="0070" element="1203" keyword="InputSequencePositionIndex" vr="US" vm="1" name="Input Sequence Position Index"/>
+        <entry group="0070" element="1204" keyword="Crop" vr="CS" vm="1" name="Crop"/>
+        <entry group="0070" element="1205" keyword="CroppingSpecificationIndex" vr="US" vm="1-n" name="Cropping Specification Index"/>
+        <entry group="0070" element="1206" keyword="CompositingMethod" vr="CS" vm="1" name="Compositing Method"/>
+        <entry group="0070" element="1207" keyword="VolumetricPresentationInputNumber" vr="US" vm="1" name="Volumetric Presentation Input Number"/>
+        <entry group="0070" element="1208" keyword="ImageVolumeGeometry" vr="CS" vm="1" name="Image Volume Geometry"/>
+        <entry group="0070" element="1301" keyword="VolumeCroppingSequence" vr="SQ" vm="1" name="Volume Cropping Sequence"/>
+        <entry group="0070" element="1302" keyword="VolumeCroppingMethod" vr="CS" vm="1" name="Volume Cropping Method"/>
+        <entry group="0070" element="1303" keyword="BoundingBoxCrop" vr="FD" vm="6" name="Bounding Box Crop"/>
+        <entry group="0070" element="1304" keyword="ObliqueCroppingPlaneSequence" vr="SQ" vm="1" name="Oblique Cropping Plane Sequence"/>
+        <entry group="0070" element="1305" keyword="Plane" vr="FD" vm="4" name="Plane"/>
+        <entry group="0070" element="1306" keyword="PlaneNormal" vr="FD" vm="3" name="Plane Normal"/>
+        <entry group="0070" element="1309" keyword="CroppingSpecificationNumber" vr="US" vm="1" name="Cropping Specification Number"/>
+        <entry group="0070" element="1501" keyword="MultiPlanarReconstructionStyle" vr="CS" vm="1" name="Multi-Planar Reconstruction Style"/>
+        <entry group="0070" element="1502" keyword="MPRThicknessType" vr="CS" vm="1" name="MPR Thickness Type"/>
+        <entry group="0070" element="1503" keyword="MPRSlabThickness" vr="FD" vm="1" name="MPR Slab Thickness"/>
+        <entry group="0070" element="1505" keyword="MPRTopLeftHandCorner" vr="FD" vm="3" name="MPR Top Left Hand Corner"/>
+        <entry group="0070" element="1507" keyword="MPRViewWidthDirection" vr="FD" vm="3" name="MPR View Width Direction"/>
+        <entry group="0070" element="1508" keyword="MPRViewWidth" vr="FD" vm="1" name="MPR View Width"/>
+        <entry group="0070" element="150c" keyword="NumberOfVolumetricCurvePoints" vr="UL" vm="1" name="Number of Volumetric Curve Points"/>
+        <entry group="0070" element="150d" keyword="VolumetricCurvePoints" vr="OD" vm="1" name="Volumetric Curve Points"/>
+        <entry group="0070" element="1511" keyword="MPRViewHeightDirection" vr="FD" vm="3" name="MPR View Height Direction"/>
+        <entry group="0070" element="1512" keyword="MPRViewHeight" vr="FD" vm="1" name="MPR View Height"/>
+        <entry group="0070" element="1801" keyword="PresentationStateClassificationComponentSequence" vr="SQ" vm="1" name="Presentation State Classification Component Sequence"/>
+        <entry group="0070" element="1802" keyword="ComponentType" vr="CS" vm="1" name="Component Type"/>
+        <entry group="0070" element="1803" keyword="ComponentInputSequence" vr="SQ" vm="1" name="Component Input Sequence"/>
+        <entry group="0070" element="1804" keyword="VolumetricPresentationInputIndex" vr="US" vm="1" name="Volumetric Presentation Input Index"/>
+        <entry group="0070" element="1805" keyword="PresentationStateCompositorComponentSequence" vr="SQ" vm="1" name="Presentation State Compositor Component Sequence"/>
+        <entry group="0070" element="1806" keyword="WeightingTransferFunctionSequence" vr="SQ" vm="1" name="Weighting Transfer Function Sequence"/>
+        <entry group="0070" element="1807" keyword="WeightingLookupTableDescriptor" vr="US" vm="3" name="Weighting Lookup Table Descriptor"/>
+        <entry group="0070" element="1808" keyword="WeightingLookupTableData" vr="OB" vm="1" name="Weighting Lookup Table Data"/>
+        <entry group="0070" element="1901" keyword="VolumetricAnnotationSequence" vr="SQ" vm="1" name="Volumetric Annotation Sequence"/>
+        <entry group="0070" element="1903" keyword="ReferencedStructuredContextSequence" vr="SQ" vm="1" name="Referenced Structured Context Sequence"/>
+        <entry group="0070" element="1904" keyword="ReferencedContentItem" vr="UI" vm="1" name="Referenced Content Item"/>
+        <entry group="0070" element="1905" keyword="VolumetricPresentationInputAnnotationSequence" vr="SQ" vm="1" name="Volumetric Presentation Input Annotation Sequence"/>
+        <entry group="0070" element="1907" keyword="AnnotationClipping" vr="CS" vm="1" name="Annotation Clipping"/>
+        <entry group="0070" element="1a01" keyword="PresentationAnimationStyle" vr="CS" vm="1" name="Presentation Animation Style"/>
+        <entry group="0070" element="1a03" keyword="RecommendedAnimationRate" vr="FD" vm="1" name="Recommended Animation Rate"/>
+        <entry group="0070" element="1a04" keyword="AnimationCurveSequence" vr="SQ" vm="1" name="Animation Curve Sequence"/>
+        <entry group="0070" element="1a05" keyword="AnimationStepSize" vr="FD" vm="1" name="Animation Step Size"/>
+        <entry group="0072" element="0002" keyword="HangingProtocolName" vr="SH" vm="1" name="Hanging Protocol Name"/>
+        <entry group="0072" element="0004" keyword="HangingProtocolDescription" vr="LO" vm="1" name="Hanging Protocol Description"/>
+        <entry group="0072" element="0006" keyword="HangingProtocolLevel" vr="CS" vm="1" name="Hanging Protocol Level"/>
+        <entry group="0072" element="0008" keyword="HangingProtocolCreator" vr="LO" vm="1" name="Hanging Protocol Creator"/>
+        <entry group="0072" element="000a" keyword="HangingProtocolCreationDateTime" vr="DT" vm="1" name="Hanging Protocol Creation DateTime"/>
+        <entry group="0072" element="000c" keyword="HangingProtocolDefinitionSequence" vr="SQ" vm="1" name="Hanging Protocol Definition Sequence"/>
+        <entry group="0072" element="000e" keyword="HangingProtocolUserIdentificationCodeSequence" vr="SQ" vm="1" name="Hanging Protocol User Identification Code Sequence"/>
+        <entry group="0072" element="0010" keyword="HangingProtocolUserGroupName" vr="LO" vm="1" name="Hanging Protocol User Group Name"/>
+        <entry group="0072" element="0012" keyword="SourceHangingProtocolSequence" vr="SQ" vm="1" name="Source Hanging Protocol Sequence"/>
+        <entry group="0072" element="0014" keyword="NumberOfPriorsReferenced" vr="US" vm="1" name="Number of Priors Referenced"/>
+        <entry group="0072" element="0020" keyword="ImageSetsSequence" vr="SQ" vm="1" name="Image Sets Sequence"/>
+        <entry group="0072" element="0022" keyword="ImageSetSelectorSequence" vr="SQ" vm="1" name="Image Set Selector Sequence"/>
+        <entry group="0072" element="0024" keyword="ImageSetSelectorUsageFlag" vr="CS" vm="1" name="Image Set Selector Usage Flag"/>
+        <entry group="0072" element="0026" keyword="SelectorAttribute" vr="AT" vm="1" name="Selector Attribute"/>
+        <entry group="0072" element="0028" keyword="SelectorValueNumber" vr="US" vm="1" name="Selector Value Number"/>
+        <entry group="0072" element="0030" keyword="TimeBasedImageSetsSequence" vr="SQ" vm="1" name="Time Based Image Sets Sequence"/>
+        <entry group="0072" element="0032" keyword="ImageSetNumber" vr="US" vm="1" name="Image Set Number"/>
+        <entry group="0072" element="0034" keyword="ImageSetSelectorCategory" vr="CS" vm="1" name="Image Set Selector Category"/>
+        <entry group="0072" element="0038" keyword="RelativeTime" vr="US" vm="2" name="Relative Time"/>
+        <entry group="0072" element="003a" keyword="RelativeTimeUnits" vr="CS" vm="1" name="Relative Time Units"/>
+        <entry group="0072" element="003c" keyword="AbstractPriorValue" vr="SS" vm="2" name="Abstract Prior Value"/>
+        <entry group="0072" element="003e" keyword="AbstractPriorCodeSequence" vr="SQ" vm="1" name="Abstract Prior Code Sequence"/>
+        <entry group="0072" element="0040" keyword="ImageSetLabel" vr="LO" vm="1" name="Image Set Label"/>
+        <entry group="0072" element="0050" keyword="SelectorAttributeVR" vr="CS" vm="1" name="Selector Attribute VR"/>
+        <entry group="0072" element="0052" keyword="SelectorSequencePointer" vr="AT" vm="1-n" name="Selector Sequence Pointer"/>
+        <entry group="0072" element="0054" keyword="SelectorSequencePointerPrivateCreator" vr="LO" vm="1-n" name="Selector Sequence Pointer Private Creator"/>
+        <entry group="0072" element="0056" keyword="SelectorAttributePrivateCreator" vr="LO" vm="1" name="Selector Attribute Private Creator"/>
+        <entry group="0072" element="005e" keyword="SelectorAEValue" vr="AE" vm="1-n" name="Selector AE Value"/>
+        <entry group="0072" element="005f" keyword="SelectorASValue" vr="AS" vm="1-n" name="Selector AS Value"/>
+        <entry group="0072" element="0060" keyword="SelectorATValue" vr="AT" vm="1-n" name="Selector AT Value"/>
+        <entry group="0072" element="0061" keyword="SelectorDAValue" vr="DA" vm="1-n" name="Selector DA Value"/>
+        <entry group="0072" element="0062" keyword="SelectorCSValue" vr="CS" vm="1-n" name="Selector CS Value"/>
+        <entry group="0072" element="0063" keyword="SelectorDTValue" vr="DT" vm="1-n" name="Selector DT Value"/>
+        <entry group="0072" element="0064" keyword="SelectorISValue" vr="IS" vm="1-n" name="Selector IS Value"/>
+        <entry group="0072" element="0065" keyword="SelectorOBValue" vr="OB" vm="1" name="Selector OB Value"/>
+        <entry group="0072" element="0066" keyword="SelectorLOValue" vr="LO" vm="1-n" name="Selector LO Value"/>
+        <entry group="0072" element="0067" keyword="SelectorOFValue" vr="OF" vm="1" name="Selector OF Value"/>
+        <entry group="0072" element="0068" keyword="SelectorLTValue" vr="LT" vm="1" name="Selector LT Value"/>
+        <entry group="0072" element="0069" keyword="SelectorOWValue" vr="OW" vm="1" name="Selector OW Value"/>
+        <entry group="0072" element="006a" keyword="SelectorPNValue" vr="PN" vm="1-n" name="Selector PN Value"/>
+        <entry group="0072" element="006b" keyword="SelectorTMValue" vr="TM" vm="1-n" name="Selector TM Value"/>
+        <entry group="0072" element="006c" keyword="SelectorSHValue" vr="SH" vm="1-n" name="Selector SH Value"/>
+        <entry group="0072" element="006d" keyword="SelectorUNValue" vr="UN" vm="1" name="Selector UN Value"/>
+        <entry group="0072" element="006e" keyword="SelectorSTValue" vr="ST" vm="1" name="Selector ST Value"/>
+        <entry group="0072" element="006f" keyword="SelectorUCValue" vr="UC" vm="1-n" name="Selector UC Value"/>
+        <entry group="0072" element="0070" keyword="SelectorUTValue" vr="UT" vm="1" name="Selector UT Value"/>
+        <entry group="0072" element="0071" keyword="SelectorURValue" vr="UR" vm="1" name="Selector UR Value"/>
+        <entry group="0072" element="0072" keyword="SelectorDSValue" vr="DS" vm="1-n" name="Selector DS Value"/>
+        <entry group="0072" element="0073" keyword="SelectorODValue" vr="OD" vm="1" name="Selector OD Value"/>
+        <entry group="0072" element="0074" keyword="SelectorFDValue" vr="FD" vm="1-n" name="Selector FD Value"/>
+        <entry group="0072" element="0075" keyword="SelectorOLValue" vr="OL" vm="1" name="Selector OL Value"/>
+        <entry group="0072" element="0076" keyword="SelectorFLValue" vr="FL" vm="1-n" name="Selector FL Value"/>
+        <entry group="0072" element="0078" keyword="SelectorULValue" vr="UL" vm="1-n" name="Selector UL Value"/>
+        <entry group="0072" element="007a" keyword="SelectorUSValue" vr="US" vm="1-n" name="Selector US Value"/>
+        <entry group="0072" element="007c" keyword="SelectorSLValue" vr="SL" vm="1-n" name="Selector SL Value"/>
+        <entry group="0072" element="007e" keyword="SelectorSSValue" vr="SS" vm="1-n" name="Selector SS Value"/>
+        <entry group="0072" element="007f" keyword="SelectorUIValue" vr="UI" vm="1-n" name="Selector UI Value"/>
+        <entry group="0072" element="0080" keyword="SelectorCodeSequenceValue" vr="SQ" vm="1" name="Selector Code Sequence Value"/>
+        <entry group="0072" element="0100" keyword="NumberOfScreens" vr="US" vm="1" name="Number of Screens"/>
+        <entry group="0072" element="0102" keyword="NominalScreenDefinitionSequence" vr="SQ" vm="1" name="Nominal Screen Definition Sequence"/>
+        <entry group="0072" element="0104" keyword="NumberOfVerticalPixels" vr="US" vm="1" name="Number of Vertical Pixels"/>
+        <entry group="0072" element="0106" keyword="NumberOfHorizontalPixels" vr="US" vm="1" name="Number of Horizontal Pixels"/>
+        <entry group="0072" element="0108" keyword="DisplayEnvironmentSpatialPosition" vr="FD" vm="4" name="Display Environment Spatial Position"/>
+        <entry group="0072" element="010a" keyword="ScreenMinimumGrayscaleBitDepth" vr="US" vm="1" name="Screen Minimum Grayscale Bit Depth"/>
+        <entry group="0072" element="010c" keyword="ScreenMinimumColorBitDepth" vr="US" vm="1" name="Screen Minimum Color Bit Depth"/>
+        <entry group="0072" element="010e" keyword="ApplicationMaximumRepaintTime" vr="US" vm="1" name="Application Maximum Repaint Time"/>
+        <entry group="0072" element="0200" keyword="DisplaySetsSequence" vr="SQ" vm="1" name="Display Sets Sequence"/>
+        <entry group="0072" element="0202" keyword="DisplaySetNumber" vr="US" vm="1" name="Display Set Number"/>
+        <entry group="0072" element="0203" keyword="DisplaySetLabel" vr="LO" vm="1" name="Display Set Label"/>
+        <entry group="0072" element="0204" keyword="DisplaySetPresentationGroup" vr="US" vm="1" name="Display Set Presentation Group"/>
+        <entry group="0072" element="0206" keyword="DisplaySetPresentationGroupDescription" vr="LO" vm="1" name="Display Set Presentation Group Description"/>
+        <entry group="0072" element="0208" keyword="PartialDataDisplayHandling" vr="CS" vm="1" name="Partial Data Display Handling"/>
+        <entry group="0072" element="0210" keyword="SynchronizedScrollingSequence" vr="SQ" vm="1" name="Synchronized Scrolling Sequence"/>
+        <entry group="0072" element="0212" keyword="DisplaySetScrollingGroup" vr="US" vm="2-n" name="Display Set Scrolling Group"/>
+        <entry group="0072" element="0214" keyword="NavigationIndicatorSequence" vr="SQ" vm="1" name="Navigation Indicator Sequence"/>
+        <entry group="0072" element="0216" keyword="NavigationDisplaySet" vr="US" vm="1" name="Navigation Display Set"/>
+        <entry group="0072" element="0218" keyword="ReferenceDisplaySets" vr="US" vm="1-n" name="Reference Display Sets"/>
+        <entry group="0072" element="0300" keyword="ImageBoxesSequence" vr="SQ" vm="1" name="Image Boxes Sequence"/>
+        <entry group="0072" element="0302" keyword="ImageBoxNumber" vr="US" vm="1" name="Image Box Number"/>
+        <entry group="0072" element="0304" keyword="ImageBoxLayoutType" vr="CS" vm="1" name="Image Box Layout Type"/>
+        <entry group="0072" element="0306" keyword="ImageBoxTileHorizontalDimension" vr="US" vm="1" name="Image Box Tile Horizontal Dimension"/>
+        <entry group="0072" element="0308" keyword="ImageBoxTileVerticalDimension" vr="US" vm="1" name="Image Box Tile Vertical Dimension"/>
+        <entry group="0072" element="0310" keyword="ImageBoxScrollDirection" vr="CS" vm="1" name="Image Box Scroll Direction"/>
+        <entry group="0072" element="0312" keyword="ImageBoxSmallScrollType" vr="CS" vm="1" name="Image Box Small Scroll Type"/>
+        <entry group="0072" element="0314" keyword="ImageBoxSmallScrollAmount" vr="US" vm="1" name="Image Box Small Scroll Amount"/>
+        <entry group="0072" element="0316" keyword="ImageBoxLargeScrollType" vr="CS" vm="1" name="Image Box Large Scroll Type"/>
+        <entry group="0072" element="0318" keyword="ImageBoxLargeScrollAmount" vr="US" vm="1" name="Image Box Large Scroll Amount"/>
+        <entry group="0072" element="0320" keyword="ImageBoxOverlapPriority" vr="US" vm="1" name="Image Box Overlap Priority"/>
+        <entry group="0072" element="0330" keyword="CineRelativeToRealTime" vr="FD" vm="1" name="Cine Relative to Real-Time"/>
+        <entry group="0072" element="0400" keyword="FilterOperationsSequence" vr="SQ" vm="1" name="Filter Operations Sequence"/>
+        <entry group="0072" element="0402" keyword="FilterByCategory" vr="CS" vm="1" name="Filter-by Category"/>
+        <entry group="0072" element="0404" keyword="FilterByAttributePresence" vr="CS" vm="1" name="Filter-by Attribute Presence"/>
+        <entry group="0072" element="0406" keyword="FilterByOperator" vr="CS" vm="1" name="Filter-by Operator"/>
+        <entry group="0072" element="0420" keyword="StructuredDisplayBackgroundCIELabValue" vr="US" vm="3" name="Structured Display Background CIELab Value"/>
+        <entry group="0072" element="0421" keyword="EmptyImageBoxCIELabValue" vr="US" vm="3" name="Empty Image Box CIELab Value"/>
+        <entry group="0072" element="0422" keyword="StructuredDisplayImageBoxSequence" vr="SQ" vm="1" name="Structured Display Image Box Sequence"/>
+        <entry group="0072" element="0424" keyword="StructuredDisplayTextBoxSequence" vr="SQ" vm="1" name="Structured Display Text Box Sequence"/>
+        <entry group="0072" element="0427" keyword="ReferencedFirstFrameSequence" vr="SQ" vm="1" name="Referenced First Frame Sequence"/>
+        <entry group="0072" element="0430" keyword="ImageBoxSynchronizationSequence" vr="SQ" vm="1" name="Image Box Synchronization Sequence"/>
+        <entry group="0072" element="0432" keyword="SynchronizedImageBoxList" vr="US" vm="2-n" name="Synchronized Image Box List"/>
+        <entry group="0072" element="0434" keyword="TypeOfSynchronization" vr="CS" vm="1" name="Type of Synchronization"/>
+        <entry group="0072" element="0500" keyword="BlendingOperationType" vr="CS" vm="1" name="Blending Operation Type"/>
+        <entry group="0072" element="0510" keyword="ReformattingOperationType" vr="CS" vm="1" name="Reformatting Operation Type"/>
+        <entry group="0072" element="0512" keyword="ReformattingThickness" vr="FD" vm="1" name="Reformatting Thickness"/>
+        <entry group="0072" element="0514" keyword="ReformattingInterval" vr="FD" vm="1" name="Reformatting Interval"/>
+        <entry group="0072" element="0516" keyword="ReformattingOperationInitialViewDirection" vr="CS" vm="1" name="Reformatting Operation Initial View Direction"/>
+        <entry group="0072" element="0520" keyword="ThreeDRenderingType" vr="CS" vm="1-n" name="3D Rendering Type"/>
+        <entry group="0072" element="0600" keyword="SortingOperationsSequence" vr="SQ" vm="1" name="Sorting Operations Sequence"/>
+        <entry group="0072" element="0602" keyword="SortByCategory" vr="CS" vm="1" name="Sort-by Category"/>
+        <entry group="0072" element="0604" keyword="SortingDirection" vr="CS" vm="1" name="Sorting Direction"/>
+        <entry group="0072" element="0700" keyword="DisplaySetPatientOrientation" vr="CS" vm="2" name="Display Set Patient Orientation"/>
+        <entry group="0072" element="0702" keyword="VOIType" vr="CS" vm="1" name="VOI Type"/>
+        <entry group="0072" element="0704" keyword="PseudoColorType" vr="CS" vm="1" name="Pseudo-Color Type"/>
+        <entry group="0072" element="0705" keyword="PseudoColorPaletteInstanceReferenceSequence" vr="SQ" vm="1" name="Pseudo-Color Palette Instance Reference Sequence"/>
+        <entry group="0072" element="0706" keyword="ShowGrayscaleInverted" vr="CS" vm="1" name="Show Grayscale Inverted"/>
+        <entry group="0072" element="0710" keyword="ShowImageTrueSizeFlag" vr="CS" vm="1" name="Show Image True Size Flag"/>
+        <entry group="0072" element="0712" keyword="ShowGraphicAnnotationFlag" vr="CS" vm="1" name="Show Graphic Annotation Flag"/>
+        <entry group="0072" element="0714" keyword="ShowPatientDemographicsFlag" vr="CS" vm="1" name="Show Patient Demographics Flag"/>
+        <entry group="0072" element="0716" keyword="ShowAcquisitionTechniquesFlag" vr="CS" vm="1" name="Show Acquisition Techniques Flag"/>
+        <entry group="0072" element="0717" keyword="DisplaySetHorizontalJustification" vr="CS" vm="1" name="Display Set Horizontal Justification"/>
+        <entry group="0072" element="0718" keyword="DisplaySetVerticalJustification" vr="CS" vm="1" name="Display Set Vertical Justification"/>
+        <entry group="0074" element="0120" keyword="ContinuationStartMeterset" vr="FD" vm="1" name="Continuation Start Meterset"/>
+        <entry group="0074" element="0121" keyword="ContinuationEndMeterset" vr="FD" vm="1" name="Continuation End Meterset"/>
+        <entry group="0074" element="1000" keyword="ProcedureStepState" vr="CS" vm="1" name="Procedure Step State"/>
+        <entry group="0074" element="1002" keyword="ProcedureStepProgressInformationSequence" vr="SQ" vm="1" name="Procedure Step Progress Information Sequence"/>
+        <entry group="0074" element="1004" keyword="ProcedureStepProgress" vr="DS" vm="1" name="Procedure Step Progress"/>
+        <entry group="0074" element="1006" keyword="ProcedureStepProgressDescription" vr="ST" vm="1" name="Procedure Step Progress Description"/>
+        <entry group="0074" element="1008" keyword="ProcedureStepCommunicationsURISequence" vr="SQ" vm="1" name="Procedure Step Communications URI Sequence"/>
+        <entry group="0074" element="100a" keyword="ContactURI" vr="UR" vm="1" name="Contact URI"/>
+        <entry group="0074" element="100c" keyword="ContactDisplayName" vr="LO" vm="1" name="Contact Display Name"/>
+        <entry group="0074" element="100e" keyword="ProcedureStepDiscontinuationReasonCodeSequence" vr="SQ" vm="1" name="Procedure Step Discontinuation Reason Code Sequence"/>
+        <entry group="0074" element="1020" keyword="BeamTaskSequence" vr="SQ" vm="1" name="Beam Task Sequence"/>
+        <entry group="0074" element="1022" keyword="BeamTaskType" vr="CS" vm="1" name="Beam Task Type"/>
+        <entry group="0074" element="1024" keyword="BeamOrderIndexTrial" vr="IS" vm="1" retired="true" name="Beam Order Index (Trial)"/>
+        <entry group="0074" element="1025" keyword="AutosequenceFlag" vr="CS" vm="1" name="Autosequence Flag"/>
+        <entry group="0074" element="1026" keyword="TableTopVerticalAdjustedPosition" vr="FD" vm="1" name="Table Top Vertical Adjusted Position"/>
+        <entry group="0074" element="1027" keyword="TableTopLongitudinalAdjustedPosition" vr="FD" vm="1" name="Table Top Longitudinal Adjusted Position"/>
+        <entry group="0074" element="1028" keyword="TableTopLateralAdjustedPosition" vr="FD" vm="1" name="Table Top Lateral Adjusted Position"/>
+        <entry group="0074" element="102a" keyword="PatientSupportAdjustedAngle" vr="FD" vm="1" name="Patient Support Adjusted Angle"/>
+        <entry group="0074" element="102b" keyword="TableTopEccentricAdjustedAngle" vr="FD" vm="1" name="Table Top Eccentric Adjusted Angle"/>
+        <entry group="0074" element="102c" keyword="TableTopPitchAdjustedAngle" vr="FD" vm="1" name="Table Top Pitch Adjusted Angle"/>
+        <entry group="0074" element="102d" keyword="TableTopRollAdjustedAngle" vr="FD" vm="1" name="Table Top Roll Adjusted Angle"/>
+        <entry group="0074" element="1030" keyword="DeliveryVerificationImageSequence" vr="SQ" vm="1" name="Delivery Verification Image Sequence"/>
+        <entry group="0074" element="1032" keyword="VerificationImageTiming" vr="CS" vm="1" name="Verification Image Timing"/>
+        <entry group="0074" element="1034" keyword="DoubleExposureFlag" vr="CS" vm="1" name="Double Exposure Flag"/>
+        <entry group="0074" element="1036" keyword="DoubleExposureOrdering" vr="CS" vm="1" name="Double Exposure Ordering"/>
+        <entry group="0074" element="1038" keyword="DoubleExposureMetersetTrial" vr="DS" vm="1" retired="true" name="Double Exposure Meterset (Trial)"/>
+        <entry group="0074" element="103a" keyword="DoubleExposureFieldDeltaTrial" vr="DS" vm="4" retired="true" name="Double Exposure Field Delta (Trial)"/>
+        <entry group="0074" element="1040" keyword="RelatedReferenceRTImageSequence" vr="SQ" vm="1" name="Related Reference RT Image Sequence"/>
+        <entry group="0074" element="1042" keyword="GeneralMachineVerificationSequence" vr="SQ" vm="1" name="General Machine Verification Sequence"/>
+        <entry group="0074" element="1044" keyword="ConventionalMachineVerificationSequence" vr="SQ" vm="1" name="Conventional Machine Verification Sequence"/>
+        <entry group="0074" element="1046" keyword="IonMachineVerificationSequence" vr="SQ" vm="1" name="Ion Machine Verification Sequence"/>
+        <entry group="0074" element="1048" keyword="FailedAttributesSequence" vr="SQ" vm="1" name="Failed Attributes Sequence"/>
+        <entry group="0074" element="104a" keyword="OverriddenAttributesSequence" vr="SQ" vm="1" name="Overridden Attributes Sequence"/>
+        <entry group="0074" element="104c" keyword="ConventionalControlPointVerificationSequence" vr="SQ" vm="1" name="Conventional Control Point Verification Sequence"/>
+        <entry group="0074" element="104e" keyword="IonControlPointVerificationSequence" vr="SQ" vm="1" name="Ion Control Point Verification Sequence"/>
+        <entry group="0074" element="1050" keyword="AttributeOccurrenceSequence" vr="SQ" vm="1" name="Attribute Occurrence Sequence"/>
+        <entry group="0074" element="1052" keyword="AttributeOccurrencePointer" vr="AT" vm="1" name="Attribute Occurrence Pointer"/>
+        <entry group="0074" element="1054" keyword="AttributeItemSelector" vr="UL" vm="1" name="Attribute Item Selector"/>
+        <entry group="0074" element="1056" keyword="AttributeOccurrencePrivateCreator" vr="LO" vm="1" name="Attribute Occurrence Private Creator"/>
+        <entry group="0074" element="1057" keyword="SelectorSequencePointerItems" vr="IS" vm="1-n" name="Selector Sequence Pointer Items"/>
+        <entry group="0074" element="1200" keyword="ScheduledProcedureStepPriority" vr="CS" vm="1" name="Scheduled Procedure Step Priority"/>
+        <entry group="0074" element="1202" keyword="WorklistLabel" vr="LO" vm="1" name="Worklist Label"/>
+        <entry group="0074" element="1204" keyword="ProcedureStepLabel" vr="LO" vm="1" name="Procedure Step Label"/>
+        <entry group="0074" element="1210" keyword="ScheduledProcessingParametersSequence" vr="SQ" vm="1" name="Scheduled Processing Parameters Sequence"/>
+        <entry group="0074" element="1212" keyword="PerformedProcessingParametersSequence" vr="SQ" vm="1" name="Performed Processing Parameters Sequence"/>
+        <entry group="0074" element="1216" keyword="UnifiedProcedureStepPerformedProcedureSequence" vr="SQ" vm="1" name="Unified Procedure Step Performed Procedure Sequence"/>
+        <entry group="0074" element="1220" keyword="RelatedProcedureStepSequence" vr="SQ" vm="1" retired="true" name="Related Procedure Step Sequence"/>
+        <entry group="0074" element="1222" keyword="ProcedureStepRelationshipType" vr="LO" vm="1" retired="true" name="Procedure Step Relationship Type"/>
+        <entry group="0074" element="1224" keyword="ReplacedProcedureStepSequence" vr="SQ" vm="1" name="Replaced Procedure Step Sequence"/>
+        <entry group="0074" element="1230" keyword="DeletionLock" vr="LO" vm="1" name="Deletion Lock"/>
+        <entry group="0074" element="1234" keyword="ReceivingAE" vr="AE" vm="1" name="Receiving AE"/>
+        <entry group="0074" element="1236" keyword="RequestingAE" vr="AE" vm="1" name="Requesting AE"/>
+        <entry group="0074" element="1238" keyword="ReasonForCancellation" vr="LT" vm="1" name="Reason for Cancellation"/>
+        <entry group="0074" element="1242" keyword="SCPStatus" vr="CS" vm="1" name="SCP Status"/>
+        <entry group="0074" element="1244" keyword="SubscriptionListStatus" vr="CS" vm="1" name="Subscription List Status"/>
+        <entry group="0074" element="1246" keyword="UnifiedProcedureStepListStatus" vr="CS" vm="1" name="Unified Procedure Step List Status"/>
+        <entry group="0074" element="1324" keyword="BeamOrderIndex" vr="UL" vm="1" name="Beam Order Index"/>
+        <entry group="0074" element="1338" keyword="DoubleExposureMeterset" vr="FD" vm="1" name="Double Exposure Meterset"/>
+        <entry group="0074" element="133a" keyword="DoubleExposureFieldDelta" vr="FD" vm="4" name="Double Exposure Field Delta"/>
+        <entry group="0074" element="1401" keyword="BrachyTaskSequence" vr="SQ" vm="1" name="Brachy Task Sequence"/>
+        <entry group="0074" element="1402" keyword="ContinuationStartTotalReferenceAirKerma" vr="DS" vm="1" name="Continuation Start Total Reference Air Kerma"/>
+        <entry group="0074" element="1403" keyword="ContinuationEndTotalReferenceAirKerma" vr="DS" vm="1" name="Continuation End Total Reference Air Kerma"/>
+        <entry group="0074" element="1404" keyword="ContinuationPulseNumber" vr="IS" vm="1" name="Continuation Pulse Number"/>
+        <entry group="0074" element="1405" keyword="ChannelDeliveryOrderSequence" vr="SQ" vm="1" name="Channel Delivery Order Sequence"/>
+        <entry group="0074" element="1406" keyword="ReferencedChannelNumber" vr="IS" vm="1" name="Referenced Channel Number"/>
+        <entry group="0074" element="1407" keyword="StartCumulativeTimeWeight" vr="DS" vm="1" name="Start Cumulative Time Weight"/>
+        <entry group="0074" element="1408" keyword="EndCumulativeTimeWeight" vr="DS" vm="1" name="End Cumulative Time Weight"/>
+        <entry group="0074" element="1409" keyword="OmittedChannelSequence" vr="SQ" vm="1" name="Omitted Channel Sequence"/>
+        <entry group="0074" element="140a" keyword="ReasonForChannelOmission" vr="CS" vm="1" name="Reason for Channel Omission"/>
+        <entry group="0074" element="140b" keyword="ReasonForChannelOmissionDescription" vr="LO" vm="1" name="Reason for Channel Omission Description"/>
+        <entry group="0074" element="140c" keyword="ChannelDeliveryOrderIndex" vr="IS" vm="1" name="Channel Delivery Order Index"/>
+        <entry group="0074" element="140d" keyword="ChannelDeliveryContinuationSequence" vr="SQ" vm="1" name="Channel Delivery Continuation Sequence"/>
+        <entry group="0074" element="140e" keyword="OmittedApplicationSetupSequence" vr="SQ" vm="1" name="Omitted Application Setup Sequence"/>
+        <entry group="0076" element="0001" keyword="ImplantAssemblyTemplateName" vr="LO" vm="1" name="Implant Assembly Template Name"/>
+        <entry group="0076" element="0003" keyword="ImplantAssemblyTemplateIssuer" vr="LO" vm="1" name="Implant Assembly Template Issuer"/>
+        <entry group="0076" element="0006" keyword="ImplantAssemblyTemplateVersion" vr="LO" vm="1" name="Implant Assembly Template Version"/>
+        <entry group="0076" element="0008" keyword="ReplacedImplantAssemblyTemplateSequence" vr="SQ" vm="1" name="Replaced Implant Assembly Template Sequence"/>
+        <entry group="0076" element="000a" keyword="ImplantAssemblyTemplateType" vr="CS" vm="1" name="Implant Assembly Template Type"/>
+        <entry group="0076" element="000c" keyword="OriginalImplantAssemblyTemplateSequence" vr="SQ" vm="1" name="Original Implant Assembly Template Sequence"/>
+        <entry group="0076" element="000e" keyword="DerivationImplantAssemblyTemplateSequence" vr="SQ" vm="1" name="Derivation Implant Assembly Template Sequence"/>
+        <entry group="0076" element="0010" keyword="ImplantAssemblyTemplateTargetAnatomySequence" vr="SQ" vm="1" name="Implant Assembly Template Target Anatomy Sequence"/>
+        <entry group="0076" element="0020" keyword="ProcedureTypeCodeSequence" vr="SQ" vm="1" name="Procedure Type Code Sequence"/>
+        <entry group="0076" element="0030" keyword="SurgicalTechnique" vr="LO" vm="1" name="Surgical Technique"/>
+        <entry group="0076" element="0032" keyword="ComponentTypesSequence" vr="SQ" vm="1" name="Component Types Sequence"/>
+        <entry group="0076" element="0034" keyword="ComponentTypeCodeSequence" vr="CS" vm="1" name="Component Type Code Sequence"/>
+        <entry group="0076" element="0036" keyword="ExclusiveComponentType" vr="CS" vm="1" name="Exclusive Component Type"/>
+        <entry group="0076" element="0038" keyword="MandatoryComponentType" vr="CS" vm="1" name="Mandatory Component Type"/>
+        <entry group="0076" element="0040" keyword="ComponentSequence" vr="SQ" vm="1" name="Component Sequence"/>
+        <entry group="0076" element="0055" keyword="ComponentID" vr="US" vm="1" name="Component ID"/>
+        <entry group="0076" element="0060" keyword="ComponentAssemblySequence" vr="SQ" vm="1" name="Component Assembly Sequence"/>
+        <entry group="0076" element="0070" keyword="Component1ReferencedID" vr="US" vm="1" name="Component 1 Referenced ID"/>
+        <entry group="0076" element="0080" keyword="Component1ReferencedMatingFeatureSetID" vr="US" vm="1" name="Component 1 Referenced Mating Feature Set ID"/>
+        <entry group="0076" element="0090" keyword="Component1ReferencedMatingFeatureID" vr="US" vm="1" name="Component 1 Referenced Mating Feature ID"/>
+        <entry group="0076" element="00a0" keyword="Component2ReferencedID" vr="US" vm="1" name="Component 2 Referenced ID"/>
+        <entry group="0076" element="00b0" keyword="Component2ReferencedMatingFeatureSetID" vr="US" vm="1" name="Component 2 Referenced Mating Feature Set ID"/>
+        <entry group="0076" element="00c0" keyword="Component2ReferencedMatingFeatureID" vr="US" vm="1" name="Component 2 Referenced Mating Feature ID"/>
+        <entry group="0078" element="0001" keyword="ImplantTemplateGroupName" vr="LO" vm="1" name="Implant Template Group Name"/>
+        <entry group="0078" element="0010" keyword="ImplantTemplateGroupDescription" vr="ST" vm="1" name="Implant Template Group Description"/>
+        <entry group="0078" element="0020" keyword="ImplantTemplateGroupIssuer" vr="LO" vm="1" name="Implant Template Group Issuer"/>
+        <entry group="0078" element="0024" keyword="ImplantTemplateGroupVersion" vr="LO" vm="1" name="Implant Template Group Version"/>
+        <entry group="0078" element="0026" keyword="ReplacedImplantTemplateGroupSequence" vr="SQ" vm="1" name="Replaced Implant Template Group Sequence"/>
+        <entry group="0078" element="0028" keyword="ImplantTemplateGroupTargetAnatomySequence" vr="SQ" vm="1" name="Implant Template Group Target Anatomy Sequence"/>
+        <entry group="0078" element="002a" keyword="ImplantTemplateGroupMembersSequence" vr="SQ" vm="1" name="Implant Template Group Members Sequence"/>
+        <entry group="0078" element="002e" keyword="ImplantTemplateGroupMemberID" vr="US" vm="1" name="Implant Template Group Member ID"/>
+        <entry group="0078" element="0050" keyword="ThreeDImplantTemplateGroupMemberMatchingPoint" vr="FD" vm="3" name="3D Implant Template Group Member Matching Point"/>
+        <entry group="0078" element="0060" keyword="ThreeDImplantTemplateGroupMemberMatchingAxes" vr="FD" vm="9" name="3D Implant Template Group Member Matching Axes"/>
+        <entry group="0078" element="0070" keyword="ImplantTemplateGroupMemberMatching2DCoordinatesSequence" vr="SQ" vm="1" name="Implant Template Group Member Matching 2D Coordinates Sequence"/>
+        <entry group="0078" element="0090" keyword="TwoDImplantTemplateGroupMemberMatchingPoint" vr="FD" vm="2" name="2D Implant Template Group Member Matching Point"/>
+        <entry group="0078" element="00a0" keyword="TwoDImplantTemplateGroupMemberMatchingAxes" vr="FD" vm="4" name="2D Implant Template Group Member Matching Axes"/>
+        <entry group="0078" element="00b0" keyword="ImplantTemplateGroupVariationDimensionSequence" vr="SQ" vm="1" name="Implant Template Group Variation Dimension Sequence"/>
+        <entry group="0078" element="00b2" keyword="ImplantTemplateGroupVariationDimensionName" vr="LO" vm="1" name="Implant Template Group Variation Dimension Name"/>
+        <entry group="0078" element="00b4" keyword="ImplantTemplateGroupVariationDimensionRankSequence" vr="SQ" vm="1" name="Implant Template Group Variation Dimension Rank Sequence"/>
+        <entry group="0078" element="00b6" keyword="ReferencedImplantTemplateGroupMemberID" vr="US" vm="1" name="Referenced Implant Template Group Member ID"/>
+        <entry group="0078" element="00b8" keyword="ImplantTemplateGroupVariationDimensionRank" vr="US" vm="1" name="Implant Template Group Variation Dimension Rank"/>
+        <entry group="0080" element="0001" keyword="SurfaceScanAcquisitionTypeCodeSequence" vr="SQ" vm="1" name="Surface Scan Acquisition Type Code Sequence"/>
+        <entry group="0080" element="0002" keyword="SurfaceScanModeCodeSequence" vr="SQ" vm="1" name="Surface Scan Mode Code Sequence"/>
+        <entry group="0080" element="0003" keyword="RegistrationMethodCodeSequence" vr="SQ" vm="1" name="Registration Method Code Sequence"/>
+        <entry group="0080" element="0004" keyword="ShotDurationTime" vr="FD" vm="1" name="Shot Duration Time"/>
+        <entry group="0080" element="0005" keyword="ShotOffsetTime" vr="FD" vm="1" name="Shot Offset Time"/>
+        <entry group="0080" element="0006" keyword="SurfacePointPresentationValueData" vr="US" vm="1-n" name="Surface Point Presentation Value Data"/>
+        <entry group="0080" element="0007" keyword="SurfacePointColorCIELabValueData" vr="US" vm="3-3n" name="Surface Point Color CIELab Value Data"/>
+        <entry group="0080" element="0008" keyword="UVMappingSequence" vr="SQ" vm="1" name="UV Mapping Sequence"/>
+        <entry group="0080" element="0009" keyword="TextureLabel" vr="SH" vm="1" name="Texture Label"/>
+        <entry group="0080" element="0010" keyword="UValueData" vr="OF" vm="1-n" name="U Value Data"/>
+        <entry group="0080" element="0011" keyword="VValueData" vr="OF" vm="1-n" name="V Value Data"/>
+        <entry group="0080" element="0012" keyword="ReferencedTextureSequence" vr="SQ" vm="1" name="Referenced Texture Sequence"/>
+        <entry group="0080" element="0013" keyword="ReferencedSurfaceDataSequence" vr="SQ" vm="1" name="Referenced Surface Data Sequence"/>
+              <entry group="0082" element="0001" keyword="AssessmentSummary" vr="CS" vm="1" name="Assessment Summary"/>
+      <entry group="0082" element="0003" keyword="AssessmentSummaryDescription" vr="UT" vm="1" name="Assessment Summary Description"/>
+      <entry group="0082" element="0004" keyword="AssessedSOPInstanceSequence" vr="SQ" vm="1" name="Assessed SOP Instance Sequence"/>
+      <entry group="0082" element="0005" keyword="ReferencedComparisonSOPInstanceSequence" vr="SQ" vm="1" name="Referenced Comparison SOP Instance Sequence"/>
+      <entry group="0082" element="0006" keyword="NumberOfAssessmentObservations" vr="UL" vm="1" name="Number of Assessment Observations"/>
+      <entry group="0082" element="0007" keyword="AssessmentObservationsSequence" vr="SQ" vm="1" name="Assessment Observations Sequence"/>
+      <entry group="0082" element="0008" keyword="ObservationSignificance" vr="CS" vm="1" name="Observation Significance"/>
+      <entry group="0082" element="000a" keyword="ObservationDescription" vr="UT" vm="1" name="Observation Description"/>
+      <entry group="0082" element="000c" keyword="StructuredContraintObservationSequence" vr="SQ" vm="1" name="Structured Constraint Observation Sequence"/>
+      <entry group="0082" element="0010" keyword="AssessedAttributeValueSequence" vr="SQ" vm="1" name="Assessed Attribute Value Sequence"/>
+      <entry group="0082" element="0016" keyword="AssessmentSetID" vr="LO" vm="1" name="Assessment Set ID"/>
+      <entry group="0082" element="0017" keyword="AssessmentRequesterSequence" vr="SQ" vm="1" name="Assessment Requester Sequence"/>
+      <entry group="0082" element="0018" keyword="SelectorAttributeName" vr="LO" vm="1" name="Selector Attribute Name"/>
+      <entry group="0082" element="0019" keyword="SelectorAttributeKeyword" vr="LO" vm="1" name="Selector Attribute Keyword"/>
+      <entry group="0082" element="0021" keyword="AssessmentTypeCodeSequence" vr="SQ" vm="1" name="Assessment Type Code Sequence"/>
+      <entry group="0082" element="0022" keyword="ObservationBasisCodeSequence" vr="SQ" vm="1" name="Observation Basis Code Sequence"/>
+      <entry group="0082" element="0023" keyword="AssessmentLabel" vr="LO" vm="1" name="Assessment Label"/>
+      <entry group="0082" element="0032" keyword="ConstraintType" vr="CS" vm="1" name="Constraint Type"/>
+      <entry group="0082" element="0033" keyword="SpecificationSelectionGuidance" vr="UT" vm="1" name="Specification Selection Guidance"/>
+      <entry group="0082" element="0034" keyword="ConstraintValueSequence" vr="SQ" vm="1" name="Constraint Value Sequence"/>
+      <entry group="0082" element="0035" keyword="RecommendedDefaultValueSequence" vr="SQ" vm="1" name="Recommended Default Value Sequence"/>
+      <entry group="0082" element="0036" keyword="ConstraintViolationSignificance" vr="CS" vm="1" name="Constraint Violation Significance"/>
+      <entry group="0082" element="0037" keyword="ConstraintViolationCondition" vr="UT" vm="1" name="Constraint Violation Condition"/>
+        <entry group="0082" element="0038" keyword="ModifiableConstraintFlag" vr="CS" vm="1" name="Modifiable Constraint Flag"/>
+        <entry group="0088" element="0130" keyword="StorageMediaFileSetID" vr="SH" vm="1" name="Storage Media File-set ID"/>
+        <entry group="0088" element="0140" keyword="StorageMediaFileSetUID" vr="UI" vm="1" name="Storage Media File-set UID"/>
+        <entry group="0088" element="0200" keyword="IconImageSequence" vr="SQ" vm="1" name="Icon Image Sequence"/>
+        <entry group="0088" element="0904" keyword="TopicTitle" vr="LO" vm="1" retired="true" name="Topic Title"/>
+        <entry group="0088" element="0906" keyword="TopicSubject" vr="ST" vm="1" retired="true" name="Topic Subject"/>
+        <entry group="0088" element="0910" keyword="TopicAuthor" vr="LO" vm="1" retired="true" name="Topic Author"/>
+        <entry group="0088" element="0912" keyword="TopicKeywords" vr="LO" vm="1-32" retired="true" name="Topic Keywords"/>
+        <entry group="0100" element="0410" keyword="SOPInstanceStatus" vr="CS" vm="1" name="SOP Instance Status"/>
+        <entry group="0100" element="0420" keyword="SOPAuthorizationDateTime" vr="DT" vm="1" name="SOP Authorization DateTime"/>
+        <entry group="0100" element="0424" keyword="SOPAuthorizationComment" vr="LT" vm="1" name="SOP Authorization Comment"/>
+        <entry group="0100" element="0426" keyword="AuthorizationEquipmentCertificationNumber" vr="LO" vm="1" name="Authorization Equipment Certification Number"/>
+        <entry group="0400" element="0005" keyword="MACIDNumber" vr="US" vm="1" name="MAC ID Number"/>
+        <entry group="0400" element="0010" keyword="MACCalculationTransferSyntaxUID" vr="UI" vm="1" name="MAC Calculation Transfer Syntax UID"/>
+        <entry group="0400" element="0015" keyword="MACAlgorithm" vr="CS" vm="1" name="MAC Algorithm"/>
+        <entry group="0400" element="0020" keyword="DataElementsSigned" vr="AT" vm="1-n" name="Data Elements Signed"/>
+        <entry group="0400" element="0100" keyword="DigitalSignatureUID" vr="UI" vm="1" name="Digital Signature UID"/>
+        <entry group="0400" element="0105" keyword="DigitalSignatureDateTime" vr="DT" vm="1" name="Digital Signature DateTime"/>
+        <entry group="0400" element="0110" keyword="CertificateType" vr="CS" vm="1" name="Certificate Type"/>
+        <entry group="0400" element="0115" keyword="CertificateOfSigner" vr="OB" vm="1" name="Certificate of Signer"/>
+        <entry group="0400" element="0120" keyword="Signature" vr="OB" vm="1" name="Signature"/>
+        <entry group="0400" element="0305" keyword="CertifiedTimestampType" vr="CS" vm="1" name="Certified Timestamp Type"/>
+        <entry group="0400" element="0310" keyword="CertifiedTimestamp" vr="OB" vm="1" name="Certified Timestamp"/>
+        <entry group="0400" element="0315" vr="FL" vm="1" retired="true"/>
+        <entry group="0400" element="0401" keyword="DigitalSignaturePurposeCodeSequence" vr="SQ" vm="1" name="Digital Signature Purpose Code Sequence"/>
+        <entry group="0400" element="0402" keyword="ReferencedDigitalSignatureSequence" vr="SQ" vm="1" name="Referenced Digital Signature Sequence"/>
+        <entry group="0400" element="0403" keyword="ReferencedSOPInstanceMACSequence" vr="SQ" vm="1" name="Referenced SOP Instance MAC Sequence"/>
+        <entry group="0400" element="0404" keyword="MAC" vr="OB" vm="1" name="MAC"/>
+        <entry group="0400" element="0500" keyword="EncryptedAttributesSequence" vr="SQ" vm="1" name="Encrypted Attributes Sequence"/>
+        <entry group="0400" element="0510" keyword="EncryptedContentTransferSyntaxUID" vr="UI" vm="1" name="Encrypted Content Transfer Syntax UID"/>
+        <entry group="0400" element="0520" keyword="EncryptedContent" vr="OB" vm="1" name="Encrypted Content"/>
+        <entry group="0400" element="0550" keyword="ModifiedAttributesSequence" vr="SQ" vm="1" name="Modified Attributes Sequence"/>
+        <entry group="0400" element="0561" keyword="OriginalAttributesSequence" vr="SQ" vm="1" name="Original Attributes Sequence"/>
+        <entry group="0400" element="0562" keyword="AttributeModificationDateTime" vr="DT" vm="1" name="Attribute Modification DateTime"/>
+        <entry group="0400" element="0563" keyword="ModifyingSystem" vr="LO" vm="1" name="Modifying System"/>
+        <entry group="0400" element="0564" keyword="SourceOfPreviousValues" vr="LO" vm="1" name="Source of Previous Values"/>
+        <entry group="0400" element="0565" keyword="ReasonForTheAttributeModification" vr="CS" vm="1" name="Reason for the Attribute Modification"/>
+        <entry group="1000" element="xxx0" keyword="EscapeTriplet" vr="US" vm="3" retired="true" name="Escape Triplet"/>
+        <entry group="1000" element="xxx1" keyword="RunLengthTriplet" vr="US" vm="3" retired="true" name="Run Length Triplet"/>
+        <entry group="1000" element="xxx2" keyword="HuffmanTableSize" vr="US" vm="1" retired="true" name="Huffman Table Size"/>
+        <entry group="1000" element="xxx3" keyword="HuffmanTableTriplet" vr="US" vm="3" retired="true" name="Huffman Table Triplet"/>
+        <entry group="1000" element="xxx4" keyword="ShiftTableSize" vr="US" vm="1" retired="true" name="Shift Table Size"/>
+        <entry group="1000" element="xxx5" keyword="ShiftTableTriplet" vr="US" vm="3" retired="true" name="Shift Table Triplet"/>
+        <entry group="1010" element="xxxx" keyword="ZonalMap" vr="US" vm="1-n" retired="true" name="Zonal Map"/>
+        <entry group="2000" element="0010" keyword="NumberOfCopies" vr="IS" vm="1" name="Number of Copies"/>
+        <entry group="2000" element="001e" keyword="PrinterConfigurationSequence" vr="SQ" vm="1" name="Printer Configuration Sequence"/>
+        <entry group="2000" element="0020" keyword="PrintPriority" vr="CS" vm="1" name="Print Priority"/>
+        <entry group="2000" element="0030" keyword="MediumType" vr="CS" vm="1" name="Medium Type"/>
+        <entry group="2000" element="0040" keyword="FilmDestination" vr="CS" vm="1" name="Film Destination"/>
+        <entry group="2000" element="0050" keyword="FilmSessionLabel" vr="LO" vm="1" name="Film Session Label"/>
+        <entry group="2000" element="0060" keyword="MemoryAllocation" vr="IS" vm="1" name="Memory Allocation"/>
+        <entry group="2000" element="0061" keyword="MaximumMemoryAllocation" vr="IS" vm="1" name="Maximum Memory Allocation"/>
+        <entry group="2000" element="0062" keyword="ColorImagePrintingFlag" vr="CS" vm="1" retired="true" name="Color Image Printing Flag"/>
+        <entry group="2000" element="0063" keyword="CollationFlag" vr="CS" vm="1" retired="true" name="Collation Flag"/>
+        <entry group="2000" element="0065" keyword="AnnotationFlag" vr="CS" vm="1" retired="true" name="Annotation Flag"/>
+        <entry group="2000" element="0067" keyword="ImageOverlayFlag" vr="CS" vm="1" retired="true" name="Image Overlay Flag"/>
+        <entry group="2000" element="0069" keyword="PresentationLUTFlag" vr="CS" vm="1" retired="true" name="Presentation LUT Flag"/>
+        <entry group="2000" element="006a" keyword="ImageBoxPresentationLUTFlag" vr="CS" vm="1" retired="true" name="Image Box Presentation LUT Flag"/>
+        <entry group="2000" element="00a0" keyword="MemoryBitDepth" vr="US" vm="1" name="Memory Bit Depth"/>
+        <entry group="2000" element="00a1" keyword="PrintingBitDepth" vr="US" vm="1" name="Printing Bit Depth"/>
+        <entry group="2000" element="00a2" keyword="MediaInstalledSequence" vr="SQ" vm="1" name="Media Installed Sequence"/>
+        <entry group="2000" element="00a4" keyword="OtherMediaAvailableSequence" vr="SQ" vm="1" name="Other Media Available Sequence"/>
+        <entry group="2000" element="00a8" keyword="SupportedImageDisplayFormatsSequence" vr="SQ" vm="1" name="Supported Image Display Formats Sequence"/>
+        <entry group="2000" element="0500" keyword="ReferencedFilmBoxSequence" vr="SQ" vm="1" name="Referenced Film Box Sequence"/>
+        <entry group="2000" element="0510" keyword="ReferencedStoredPrintSequence" vr="SQ" vm="1" retired="true" name="Referenced Stored Print Sequence"/>
+        <entry group="2010" element="0010" keyword="ImageDisplayFormat" vr="ST" vm="1" name="Image Display Format"/>
+        <entry group="2010" element="0030" keyword="AnnotationDisplayFormatID" vr="CS" vm="1" name="Annotation Display Format ID"/>
+        <entry group="2010" element="0040" keyword="FilmOrientation" vr="CS" vm="1" name="Film Orientation"/>
+        <entry group="2010" element="0050" keyword="FilmSizeID" vr="CS" vm="1" name="Film Size ID"/>
+        <entry group="2010" element="0052" keyword="PrinterResolutionID" vr="CS" vm="1" name="Printer Resolution ID"/>
+        <entry group="2010" element="0054" keyword="DefaultPrinterResolutionID" vr="CS" vm="1" name="Default Printer Resolution ID"/>
+        <entry group="2010" element="0060" keyword="MagnificationType" vr="CS" vm="1" name="Magnification Type"/>
+        <entry group="2010" element="0080" keyword="SmoothingType" vr="CS" vm="1" name="Smoothing Type"/>
+        <entry group="2010" element="00a6" keyword="DefaultMagnificationType" vr="CS" vm="1" name="Default Magnification Type"/>
+        <entry group="2010" element="00a7" keyword="OtherMagnificationTypesAvailable" vr="CS" vm="1-n" name="Other Magnification Types Available"/>
+        <entry group="2010" element="00a8" keyword="DefaultSmoothingType" vr="CS" vm="1" name="Default Smoothing Type"/>
+        <entry group="2010" element="00a9" keyword="OtherSmoothingTypesAvailable" vr="CS" vm="1-n" name="Other Smoothing Types Available"/>
+        <entry group="2010" element="0100" keyword="BorderDensity" vr="CS" vm="1" name="Border Density"/>
+        <entry group="2010" element="0110" keyword="EmptyImageDensity" vr="CS" vm="1" name="Empty Image Density"/>
+        <entry group="2010" element="0120" keyword="MinDensity" vr="US" vm="1" name="Min Density"/>
+        <entry group="2010" element="0130" keyword="MaxDensity" vr="US" vm="1" name="Max Density"/>
+        <entry group="2010" element="0140" keyword="Trim" vr="CS" vm="1" name="Trim"/>
+        <entry group="2010" element="0150" keyword="ConfigurationInformation" vr="ST" vm="1" name="Configuration Information"/>
+        <entry group="2010" element="0152" keyword="ConfigurationInformationDescription" vr="LT" vm="1" name="Configuration Information Description"/>
+        <entry group="2010" element="0154" keyword="MaximumCollatedFilms" vr="IS" vm="1" name="Maximum Collated Films"/>
+        <entry group="2010" element="015e" keyword="Illumination" vr="US" vm="1" name="Illumination"/>
+        <entry group="2010" element="0160" keyword="ReflectedAmbientLight" vr="US" vm="1" name="Reflected Ambient Light"/>
+        <entry group="2010" element="0376" keyword="PrinterPixelSpacing" vr="DS" vm="2" name="Printer Pixel Spacing"/>
+        <entry group="2010" element="0500" keyword="ReferencedFilmSessionSequence" vr="SQ" vm="1" name="Referenced Film Session Sequence"/>
+        <entry group="2010" element="0510" keyword="ReferencedImageBoxSequence" vr="SQ" vm="1" name="Referenced Image Box Sequence"/>
+        <entry group="2010" element="0520" keyword="ReferencedBasicAnnotationBoxSequence" vr="SQ" vm="1" name="Referenced Basic Annotation Box Sequence"/>
+        <entry group="2020" element="0010" keyword="ImageBoxPosition" vr="US" vm="1" name="Image Box Position"/>
+        <entry group="2020" element="0020" keyword="Polarity" vr="CS" vm="1" name="Polarity"/>
+        <entry group="2020" element="0030" keyword="RequestedImageSize" vr="DS" vm="1" name="Requested Image Size"/>
+        <entry group="2020" element="0040" keyword="RequestedDecimateCropBehavior" vr="CS" vm="1" name="Requested Decimate/Crop Behavior"/>
+        <entry group="2020" element="0050" keyword="RequestedResolutionID" vr="CS" vm="1" name="Requested Resolution ID"/>
+        <entry group="2020" element="00a0" keyword="RequestedImageSizeFlag" vr="CS" vm="1" name="Requested Image Size Flag"/>
+        <entry group="2020" element="00a2" keyword="DecimateCropResult" vr="CS" vm="1" name="Decimate/Crop Result"/>
+        <entry group="2020" element="0110" keyword="BasicGrayscaleImageSequence" vr="SQ" vm="1" name="Basic Grayscale Image Sequence"/>
+        <entry group="2020" element="0111" keyword="BasicColorImageSequence" vr="SQ" vm="1" name="Basic Color Image Sequence"/>
+        <entry group="2020" element="0130" keyword="ReferencedImageOverlayBoxSequence" vr="SQ" vm="1" retired="true" name="Referenced Image Overlay Box Sequence"/>
+        <entry group="2020" element="0140" keyword="ReferencedVOILUTBoxSequence" vr="SQ" vm="1" retired="true" name="Referenced VOI LUT Box Sequence"/>
+        <entry group="2030" element="0010" keyword="AnnotationPosition" vr="US" vm="1" name="Annotation Position"/>
+        <entry group="2030" element="0020" keyword="TextString" vr="LO" vm="1" name="Text String"/>
+        <entry group="2040" element="0010" keyword="ReferencedOverlayPlaneSequence" vr="SQ" vm="1" retired="true" name="Referenced Overlay Plane Sequence"/>
+        <entry group="2040" element="0011" keyword="ReferencedOverlayPlaneGroups" vr="US" vm="1-99" retired="true" name="Referenced Overlay Plane Groups"/>
+        <entry group="2040" element="0020" keyword="OverlayPixelDataSequence" vr="SQ" vm="1" retired="true" name="Overlay Pixel Data Sequence"/>
+        <entry group="2040" element="0060" keyword="OverlayMagnificationType" vr="CS" vm="1" retired="true" name="Overlay Magnification Type"/>
+        <entry group="2040" element="0070" keyword="OverlaySmoothingType" vr="CS" vm="1" retired="true" name="Overlay Smoothing Type"/>
+        <entry group="2040" element="0072" keyword="OverlayOrImageMagnification" vr="CS" vm="1" retired="true" name="Overlay or Image Magnification"/>
+        <entry group="2040" element="0074" keyword="MagnifyToNumberOfColumns" vr="US" vm="1" retired="true" name="Magnify to Number of Columns"/>
+        <entry group="2040" element="0080" keyword="OverlayForegroundDensity" vr="CS" vm="1" retired="true" name="Overlay Foreground Density"/>
+        <entry group="2040" element="0082" keyword="OverlayBackgroundDensity" vr="CS" vm="1" retired="true" name="Overlay Background Density"/>
+        <entry group="2040" element="0090" keyword="OverlayMode" vr="CS" vm="1" retired="true" name="Overlay Mode"/>
+        <entry group="2040" element="0100" keyword="ThresholdDensity" vr="CS" vm="1" retired="true" name="Threshold Density"/>
+        <entry group="2040" element="0500" keyword="ReferencedImageBoxSequenceRetired" vr="SQ" vm="1" retired="true" name="Referenced Image Box Sequence (Retired)"/>
+        <entry group="2050" element="0010" keyword="PresentationLUTSequence" vr="SQ" vm="1" name="Presentation LUT Sequence"/>
+        <entry group="2050" element="0020" keyword="PresentationLUTShape" vr="CS" vm="1" name="Presentation LUT Shape"/>
+        <entry group="2050" element="0500" keyword="ReferencedPresentationLUTSequence" vr="SQ" vm="1" name="Referenced Presentation LUT Sequence"/>
+        <entry group="2100" element="0010" keyword="PrintJobID" vr="SH" vm="1" retired="true" name="Print Job ID"/>
+        <entry group="2100" element="0020" keyword="ExecutionStatus" vr="CS" vm="1" name="Execution Status"/>
+        <entry group="2100" element="0030" keyword="ExecutionStatusInfo" vr="CS" vm="1" name="Execution Status Info"/>
+        <entry group="2100" element="0040" keyword="CreationDate" vr="DA" vm="1" name="Creation Date"/>
+        <entry group="2100" element="0050" keyword="CreationTime" vr="TM" vm="1" name="Creation Time"/>
+        <entry group="2100" element="0070" keyword="Originator" vr="AE" vm="1" name="Originator"/>
+        <entry group="2100" element="0140" keyword="DestinationAE" vr="AE" vm="1" name="Destination AE"/>
+        <entry group="2100" element="0160" keyword="OwnerID" vr="SH" vm="1" name="Owner ID"/>
+        <entry group="2100" element="0170" keyword="NumberOfFilms" vr="IS" vm="1" name="Number of Films"/>
+        <entry group="2100" element="0500" keyword="ReferencedPrintJobSequencePullStoredPrint" vr="SQ" vm="1" retired="true" name="Referenced Print Job Sequence (Pull Stored Print)"/>
+        <entry group="2110" element="0010" keyword="PrinterStatus" vr="CS" vm="1" name="Printer Status"/>
+        <entry group="2110" element="0020" keyword="PrinterStatusInfo" vr="CS" vm="1" name="Printer Status Info"/>
+        <entry group="2110" element="0030" keyword="PrinterName" vr="LO" vm="1" name="Printer Name"/>
+        <entry group="2110" element="0099" keyword="PrintQueueID" vr="SH" vm="1" retired="true" name="Print Queue ID"/>
+        <entry group="2120" element="0010" keyword="QueueStatus" vr="CS" vm="1" retired="true" name="Queue Status"/>
+        <entry group="2120" element="0050" keyword="PrintJobDescriptionSequence" vr="SQ" vm="1" retired="true" name="Print Job Description Sequence"/>
+        <entry group="2120" element="0070" keyword="ReferencedPrintJobSequence" vr="SQ" vm="1" retired="true" name="Referenced Print Job Sequence"/>
+        <entry group="2130" element="0010" keyword="PrintManagementCapabilitiesSequence" vr="SQ" vm="1" retired="true" name="Print Management Capabilities Sequence"/>
+        <entry group="2130" element="0015" keyword="PrinterCharacteristicsSequence" vr="SQ" vm="1" retired="true" name="Printer Characteristics Sequence"/>
+        <entry group="2130" element="0030" keyword="FilmBoxContentSequence" vr="SQ" vm="1" retired="true" name="Film Box Content Sequence"/>
+        <entry group="2130" element="0040" keyword="ImageBoxContentSequence" vr="SQ" vm="1" retired="true" name="Image Box Content Sequence"/>
+        <entry group="2130" element="0050" keyword="AnnotationContentSequence" vr="SQ" vm="1" retired="true" name="Annotation Content Sequence"/>
+        <entry group="2130" element="0060" keyword="ImageOverlayBoxContentSequence" vr="SQ" vm="1" retired="true" name="Image Overlay Box Content Sequence"/>
+        <entry group="2130" element="0080" keyword="PresentationLUTContentSequence" vr="SQ" vm="1" retired="true" name="Presentation LUT Content Sequence"/>
+        <entry group="2130" element="00a0" keyword="ProposedStudySequence" vr="SQ" vm="1" retired="true" name="Proposed Study Sequence"/>
+        <entry group="2130" element="00c0" keyword="OriginalImageSequence" vr="SQ" vm="1" retired="true" name="Original Image Sequence"/>
+        <entry group="2200" element="0001" keyword="LabelUsingInformationExtractedFromInstances" vr="CS" vm="1" name="Label Using Information Extracted From Instances"/>
+        <entry group="2200" element="0002" keyword="LabelText" vr="UT" vm="1" name="Label Text"/>
+        <entry group="2200" element="0003" keyword="LabelStyleSelection" vr="CS" vm="1" name="Label Style Selection"/>
+        <entry group="2200" element="0004" keyword="MediaDisposition" vr="LT" vm="1" name="Media Disposition"/>
+        <entry group="2200" element="0005" keyword="BarcodeValue" vr="LT" vm="1" name="Barcode Value"/>
+        <entry group="2200" element="0006" keyword="BarcodeSymbology" vr="CS" vm="1" name="Barcode Symbology"/>
+        <entry group="2200" element="0007" keyword="AllowMediaSplitting" vr="CS" vm="1" name="Allow Media Splitting"/>
+        <entry group="2200" element="0008" keyword="IncludeNonDICOMObjects" vr="CS" vm="1" name="Include Non-DICOM Objects"/>
+        <entry group="2200" element="0009" keyword="IncludeDisplayApplication" vr="CS" vm="1" name="Include Display Application"/>
+        <entry group="2200" element="000a" keyword="PreserveCompositeInstancesAfterMediaCreation" vr="CS" vm="1" name="Preserve Composite Instances After Media Creation"/>
+        <entry group="2200" element="000b" keyword="TotalNumberOfPiecesOfMediaCreated" vr="US" vm="1" name="Total Number of Pieces of Media Created"/>
+        <entry group="2200" element="000c" keyword="RequestedMediaApplicationProfile" vr="LO" vm="1" name="Requested Media Application Profile"/>
+        <entry group="2200" element="000d" keyword="ReferencedStorageMediaSequence" vr="SQ" vm="1" name="Referenced Storage Media Sequence"/>
+        <entry group="2200" element="000e" keyword="FailureAttributes" vr="AT" vm="1-n" name="Failure Attributes"/>
+        <entry group="2200" element="000f" keyword="AllowLossyCompression" vr="CS" vm="1" name="Allow Lossy Compression"/>
+        <entry group="2200" element="0020" keyword="RequestPriority" vr="CS" vm="1" name="Request Priority"/>
+        <entry group="3002" element="0002" keyword="RTImageLabel" vr="SH" vm="1" name="RT Image Label"/>
+        <entry group="3002" element="0003" keyword="RTImageName" vr="LO" vm="1" name="RT Image Name"/>
+        <entry group="3002" element="0004" keyword="RTImageDescription" vr="ST" vm="1" name="RT Image Description"/>
+        <entry group="3002" element="000a" keyword="ReportedValuesOrigin" vr="CS" vm="1" name="Reported Values Origin"/>
+        <entry group="3002" element="000c" keyword="RTImagePlane" vr="CS" vm="1" name="RT Image Plane"/>
+        <entry group="3002" element="000d" keyword="XRayImageReceptorTranslation" vr="DS" vm="3" name="X-Ray Image Receptor Translation"/>
+        <entry group="3002" element="000e" keyword="XRayImageReceptorAngle" vr="DS" vm="1" name="X-Ray Image Receptor Angle"/>
+        <entry group="3002" element="0010" keyword="RTImageOrientation" vr="DS" vm="6" name="RT Image Orientation"/>
+        <entry group="3002" element="0011" keyword="ImagePlanePixelSpacing" vr="DS" vm="2" name="Image Plane Pixel Spacing"/>
+        <entry group="3002" element="0012" keyword="RTImagePosition" vr="DS" vm="2" name="RT Image Position"/>
+        <entry group="3002" element="0020" keyword="RadiationMachineName" vr="SH" vm="1" name="Radiation Machine Name"/>
+        <entry group="3002" element="0022" keyword="RadiationMachineSAD" vr="DS" vm="1" name="Radiation Machine SAD"/>
+        <entry group="3002" element="0024" keyword="RadiationMachineSSD" vr="DS" vm="1" name="Radiation Machine SSD"/>
+        <entry group="3002" element="0026" keyword="RTImageSID" vr="DS" vm="1" name="RT Image SID"/>
+        <entry group="3002" element="0028" keyword="SourceToReferenceObjectDistance" vr="DS" vm="1" name="Source to Reference Object Distance"/>
+        <entry group="3002" element="0029" keyword="FractionNumber" vr="IS" vm="1" name="Fraction Number"/>
+        <entry group="3002" element="0030" keyword="ExposureSequence" vr="SQ" vm="1" name="Exposure Sequence"/>
+        <entry group="3002" element="0032" keyword="MetersetExposure" vr="DS" vm="1" name="Meterset Exposure"/>
+        <entry group="3002" element="0034" keyword="DiaphragmPosition" vr="DS" vm="4" name="Diaphragm Position"/>
+        <entry group="3002" element="0040" keyword="FluenceMapSequence" vr="SQ" vm="1" name="Fluence Map Sequence"/>
+        <entry group="3002" element="0041" keyword="FluenceDataSource" vr="CS" vm="1" name="Fluence Data Source"/>
+        <entry group="3002" element="0042" keyword="FluenceDataScale" vr="DS" vm="1" name="Fluence Data Scale"/>
+        <entry group="3002" element="0050" keyword="PrimaryFluenceModeSequence" vr="SQ" vm="1" name="Primary Fluence Mode Sequence"/>
+        <entry group="3002" element="0051" keyword="FluenceMode" vr="CS" vm="1" name="Fluence Mode"/>
+        <entry group="3002" element="0052" keyword="FluenceModeID" vr="SH" vm="1" name="Fluence Mode ID"/>
+        <entry group="3004" element="0001" keyword="DVHType" vr="CS" vm="1" name="DVH Type"/>
+        <entry group="3004" element="0002" keyword="DoseUnits" vr="CS" vm="1" name="Dose Units"/>
+        <entry group="3004" element="0004" keyword="DoseType" vr="CS" vm="1" name="Dose Type"/>
+        <entry group="3004" element="0005" keyword="SpatialTransformOfDose" vr="CS" vm="1" name="Spatial Transform of Dose"/>
+        <entry group="3004" element="0006" keyword="DoseComment" vr="LO" vm="1" name="Dose Comment"/>
+        <entry group="3004" element="0008" keyword="NormalizationPoint" vr="DS" vm="3" name="Normalization Point"/>
+        <entry group="3004" element="000a" keyword="DoseSummationType" vr="CS" vm="1" name="Dose Summation Type"/>
+        <entry group="3004" element="000c" keyword="GridFrameOffsetVector" vr="DS" vm="2-n" name="Grid Frame Offset Vector"/>
+        <entry group="3004" element="000e" keyword="DoseGridScaling" vr="DS" vm="1" name="Dose Grid Scaling"/>
+        <entry group="3004" element="0010" keyword="RTDoseROISequence" vr="SQ" vm="1" name="RT Dose ROI Sequence"/>
+        <entry group="3004" element="0012" keyword="DoseValue" vr="DS" vm="1" name="Dose Value"/>
+        <entry group="3004" element="0014" keyword="TissueHeterogeneityCorrection" vr="CS" vm="1-3" name="Tissue Heterogeneity Correction"/>
+        <entry group="3004" element="0040" keyword="DVHNormalizationPoint" vr="DS" vm="3" name="DVH Normalization Point"/>
+        <entry group="3004" element="0042" keyword="DVHNormalizationDoseValue" vr="DS" vm="1" name="DVH Normalization Dose Value"/>
+        <entry group="3004" element="0050" keyword="DVHSequence" vr="SQ" vm="1" name="DVH Sequence"/>
+        <entry group="3004" element="0052" keyword="DVHDoseScaling" vr="DS" vm="1" name="DVH Dose Scaling"/>
+        <entry group="3004" element="0054" keyword="DVHVolumeUnits" vr="CS" vm="1" name="DVH Volume Units"/>
+        <entry group="3004" element="0056" keyword="DVHNumberOfBins" vr="IS" vm="1" name="DVH Number of Bins"/>
+        <entry group="3004" element="0058" keyword="DVHData" vr="DS" vm="2-2n" name="DVH Data"/>
+        <entry group="3004" element="0060" keyword="DVHReferencedROISequence" vr="SQ" vm="1" name="DVH Referenced ROI Sequence"/>
+        <entry group="3004" element="0062" keyword="DVHROIContributionType" vr="CS" vm="1" name="DVH ROI Contribution Type"/>
+        <entry group="3004" element="0070" keyword="DVHMinimumDose" vr="DS" vm="1" name="DVH Minimum Dose"/>
+        <entry group="3004" element="0072" keyword="DVHMaximumDose" vr="DS" vm="1" name="DVH Maximum Dose"/>
+        <entry group="3004" element="0074" keyword="DVHMeanDose" vr="DS" vm="1" name="DVH Mean Dose"/>
+        <entry group="3006" element="0002" keyword="StructureSetLabel" vr="SH" vm="1" name="Structure Set Label"/>
+        <entry group="3006" element="0004" keyword="StructureSetName" vr="LO" vm="1" name="Structure Set Name"/>
+        <entry group="3006" element="0006" keyword="StructureSetDescription" vr="ST" vm="1" name="Structure Set Description"/>
+        <entry group="3006" element="0008" keyword="StructureSetDate" vr="DA" vm="1" name="Structure Set Date"/>
+        <entry group="3006" element="0009" keyword="StructureSetTime" vr="TM" vm="1" name="Structure Set Time"/>
+        <entry group="3006" element="0010" keyword="ReferencedFrameOfReferenceSequence" vr="SQ" vm="1" name="Referenced Frame of Reference Sequence"/>
+        <entry group="3006" element="0012" keyword="RTReferencedStudySequence" vr="SQ" vm="1" name="RT Referenced Study Sequence"/>
+        <entry group="3006" element="0014" keyword="RTReferencedSeriesSequence" vr="SQ" vm="1" name="RT Referenced Series Sequence"/>
+        <entry group="3006" element="0016" keyword="ContourImageSequence" vr="SQ" vm="1" name="Contour Image Sequence"/>
+        <entry group="3006" element="0018" keyword="PredecessorStructureSetSequence" vr="SQ" vm="1" name="Predecessor Structure Set Sequence"/>
+        <entry group="3006" element="0020" keyword="StructureSetROISequence" vr="SQ" vm="1" name="Structure Set ROI Sequence"/>
+        <entry group="3006" element="0022" keyword="ROINumber" vr="IS" vm="1" name="ROI Number"/>
+        <entry group="3006" element="0024" keyword="ReferencedFrameOfReferenceUID" vr="UI" vm="1" name="Referenced Frame of Reference UID"/>
+        <entry group="3006" element="0026" keyword="ROIName" vr="LO" vm="1" name="ROI Name"/>
+        <entry group="3006" element="0028" keyword="ROIDescription" vr="ST" vm="1" name="ROI Description"/>
+        <entry group="3006" element="002a" keyword="ROIDisplayColor" vr="IS" vm="3" name="ROI Display Color"/>
+        <entry group="3006" element="002c" keyword="ROIVolume" vr="DS" vm="1" name="ROI Volume"/>
+        <entry group="3006" element="0030" keyword="RTRelatedROISequence" vr="SQ" vm="1" name="RT Related ROI Sequence"/>
+        <entry group="3006" element="0033" keyword="RTROIRelationship" vr="CS" vm="1" name="RT ROI Relationship"/>
+        <entry group="3006" element="0036" keyword="ROIGenerationAlgorithm" vr="CS" vm="1" name="ROI Generation Algorithm"/>
+        <entry group="3006" element="0038" keyword="ROIGenerationDescription" vr="LO" vm="1" name="ROI Generation Description"/>
+        <entry group="3006" element="0039" keyword="ROIContourSequence" vr="SQ" vm="1" name="ROI Contour Sequence"/>
+        <entry group="3006" element="0040" keyword="ContourSequence" vr="SQ" vm="1" name="Contour Sequence"/>
+        <entry group="3006" element="0042" keyword="ContourGeometricType" vr="CS" vm="1" name="Contour Geometric Type"/>
+        <entry group="3006" element="0044" keyword="ContourSlabThickness" vr="DS" vm="1" name="Contour Slab Thickness"/>
+        <entry group="3006" element="0045" keyword="ContourOffsetVector" vr="DS" vm="3" name="Contour Offset Vector"/>
+        <entry group="3006" element="0046" keyword="NumberOfContourPoints" vr="IS" vm="1" name="Number of Contour Points"/>
+        <entry group="3006" element="0048" keyword="ContourNumber" vr="IS" vm="1" name="Contour Number"/>
+        <entry group="3006" element="0049" keyword="AttachedContours" vr="IS" vm="1-n" name="Attached Contours"/>
+        <entry group="3006" element="0050" keyword="ContourData" vr="DS" vm="3-3n" name="Contour Data"/>
+        <entry group="3006" element="0080" keyword="RTROIObservationsSequence" vr="SQ" vm="1" name="RT ROI Observations Sequence"/>
+        <entry group="3006" element="0082" keyword="ObservationNumber" vr="IS" vm="1" name="Observation Number"/>
+        <entry group="3006" element="0084" keyword="ReferencedROINumber" vr="IS" vm="1" name="Referenced ROI Number"/>
+        <entry group="3006" element="0085" keyword="ROIObservationLabel" vr="SH" vm="1" name="ROI Observation Label"/>
+        <entry group="3006" element="0086" keyword="RTROIIdentificationCodeSequence" vr="SQ" vm="1" name="RT ROI Identification Code Sequence"/>
+        <entry group="3006" element="0088" keyword="ROIObservationDescription" vr="ST" vm="1" name="ROI Observation Description"/>
+        <entry group="3006" element="00a0" keyword="RelatedRTROIObservationsSequence" vr="SQ" vm="1" name="Related RT ROI Observations Sequence"/>
+        <entry group="3006" element="00a4" keyword="RTROIInterpretedType" vr="CS" vm="1" name="RT ROI Interpreted Type"/>
+        <entry group="3006" element="00a6" keyword="ROIInterpreter" vr="PN" vm="1" name="ROI Interpreter"/>
+        <entry group="3006" element="00b0" keyword="ROIPhysicalPropertiesSequence" vr="SQ" vm="1" name="ROI Physical Properties Sequence"/>
+        <entry group="3006" element="00b2" keyword="ROIPhysicalProperty" vr="CS" vm="1" name="ROI Physical Property"/>
+        <entry group="3006" element="00b4" keyword="ROIPhysicalPropertyValue" vr="DS" vm="1" name="ROI Physical Property Value"/>
+        <entry group="3006" element="00b6" keyword="ROIElementalCompositionSequence" vr="SQ" vm="1" name="ROI Elemental Composition Sequence"/>
+        <entry group="3006" element="00b7" keyword="ROIElementalCompositionAtomicNumber" vr="US" vm="1" name="ROI Elemental Composition Atomic Number"/>
+        <entry group="3006" element="00b8" keyword="ROIElementalCompositionAtomicMassFraction" vr="FL" vm="1" name="ROI Elemental Composition Atomic Mass Fraction"/>
+        <entry group="3006" element="00b9" keyword="AdditionalRTROIIdentificationCodeSequence" vr="SQ" vm="1" retired="true" name="Additional RT ROI Identification Code Sequence"/>
+        <entry group="3006" element="00c0" keyword="FrameOfReferenceRelationshipSequence" vr="SQ" vm="1" retired="true" name="Frame of Reference Relationship Sequence"/>
+        <entry group="3006" element="00c2" keyword="RelatedFrameOfReferenceUID" vr="UI" vm="1" retired="true" name="Related Frame of Reference UID"/>
+        <entry group="3006" element="00c4" keyword="FrameOfReferenceTransformationType" vr="CS" vm="1" retired="true" name="Frame of Reference Transformation Type"/>
+        <entry group="3006" element="00c6" keyword="FrameOfReferenceTransformationMatrix" vr="DS" vm="16" name="Frame of Reference Transformation Matrix"/>
+        <entry group="3006" element="00c8" keyword="FrameOfReferenceTransformationComment" vr="LO" vm="1" name="Frame of Reference Transformation Comment"/>
+        <entry group="3008" element="0010" keyword="MeasuredDoseReferenceSequence" vr="SQ" vm="1" name="Measured Dose Reference Sequence"/>
+        <entry group="3008" element="0012" keyword="MeasuredDoseDescription" vr="ST" vm="1" name="Measured Dose Description"/>
+        <entry group="3008" element="0014" keyword="MeasuredDoseType" vr="CS" vm="1" name="Measured Dose Type"/>
+        <entry group="3008" element="0016" keyword="MeasuredDoseValue" vr="DS" vm="1" name="Measured Dose Value"/>
+        <entry group="3008" element="0020" keyword="TreatmentSessionBeamSequence" vr="SQ" vm="1" name="Treatment Session Beam Sequence"/>
+        <entry group="3008" element="0021" keyword="TreatmentSessionIonBeamSequence" vr="SQ" vm="1" name="Treatment Session Ion Beam Sequence"/>
+        <entry group="3008" element="0022" keyword="CurrentFractionNumber" vr="IS" vm="1" name="Current Fraction Number"/>
+        <entry group="3008" element="0024" keyword="TreatmentControlPointDate" vr="DA" vm="1" name="Treatment Control Point Date"/>
+        <entry group="3008" element="0025" keyword="TreatmentControlPointTime" vr="TM" vm="1" name="Treatment Control Point Time"/>
+        <entry group="3008" element="002a" keyword="TreatmentTerminationStatus" vr="CS" vm="1" name="Treatment Termination Status"/>
+        <entry group="3008" element="002b" keyword="TreatmentTerminationCode" vr="SH" vm="1" name="Treatment Termination Code"/>
+        <entry group="3008" element="002c" keyword="TreatmentVerificationStatus" vr="CS" vm="1" name="Treatment Verification Status"/>
+        <entry group="3008" element="0030" keyword="ReferencedTreatmentRecordSequence" vr="SQ" vm="1" name="Referenced Treatment Record Sequence"/>
+        <entry group="3008" element="0032" keyword="SpecifiedPrimaryMeterset" vr="DS" vm="1" name="Specified Primary Meterset"/>
+        <entry group="3008" element="0033" keyword="SpecifiedSecondaryMeterset" vr="DS" vm="1" name="Specified Secondary Meterset"/>
+        <entry group="3008" element="0036" keyword="DeliveredPrimaryMeterset" vr="DS" vm="1" name="Delivered Primary Meterset"/>
+        <entry group="3008" element="0037" keyword="DeliveredSecondaryMeterset" vr="DS" vm="1" name="Delivered Secondary Meterset"/>
+        <entry group="3008" element="003a" keyword="SpecifiedTreatmentTime" vr="DS" vm="1" name="Specified Treatment Time"/>
+        <entry group="3008" element="003b" keyword="DeliveredTreatmentTime" vr="DS" vm="1" name="Delivered Treatment Time"/>
+        <entry group="3008" element="0040" keyword="ControlPointDeliverySequence" vr="SQ" vm="1" name="Control Point Delivery Sequence"/>
+        <entry group="3008" element="0041" keyword="IonControlPointDeliverySequence" vr="SQ" vm="1" name="Ion Control Point Delivery Sequence"/>
+        <entry group="3008" element="0042" keyword="SpecifiedMeterset" vr="DS" vm="1" name="Specified Meterset"/>
+        <entry group="3008" element="0044" keyword="DeliveredMeterset" vr="DS" vm="1" name="Delivered Meterset"/>
+        <entry group="3008" element="0045" keyword="MetersetRateSet" vr="FL" vm="1" name="Meterset Rate Set"/>
+        <entry group="3008" element="0046" keyword="MetersetRateDelivered" vr="FL" vm="1" name="Meterset Rate Delivered"/>
+        <entry group="3008" element="0047" keyword="ScanSpotMetersetsDelivered" vr="FL" vm="1-n" name="Scan Spot Metersets Delivered"/>
+        <entry group="3008" element="0048" keyword="DoseRateDelivered" vr="DS" vm="1" name="Dose Rate Delivered"/>
+        <entry group="3008" element="0050" keyword="TreatmentSummaryCalculatedDoseReferenceSequence" vr="SQ" vm="1" name="Treatment Summary Calculated Dose Reference Sequence"/>
+        <entry group="3008" element="0052" keyword="CumulativeDoseToDoseReference" vr="DS" vm="1" name="Cumulative Dose to Dose Reference"/>
+        <entry group="3008" element="0054" keyword="FirstTreatmentDate" vr="DA" vm="1" name="First Treatment Date"/>
+        <entry group="3008" element="0056" keyword="MostRecentTreatmentDate" vr="DA" vm="1" name="Most Recent Treatment Date"/>
+        <entry group="3008" element="005a" keyword="NumberOfFractionsDelivered" vr="IS" vm="1" name="Number of Fractions Delivered"/>
+        <entry group="3008" element="0060" keyword="OverrideSequence" vr="SQ" vm="1" name="Override Sequence"/>
+        <entry group="3008" element="0061" keyword="ParameterSequencePointer" vr="AT" vm="1" name="Parameter Sequence Pointer"/>
+        <entry group="3008" element="0062" keyword="OverrideParameterPointer" vr="AT" vm="1" name="Override Parameter Pointer"/>
+        <entry group="3008" element="0063" keyword="ParameterItemIndex" vr="IS" vm="1" name="Parameter Item Index"/>
+        <entry group="3008" element="0064" keyword="MeasuredDoseReferenceNumber" vr="IS" vm="1" name="Measured Dose Reference Number"/>
+        <entry group="3008" element="0065" keyword="ParameterPointer" vr="AT" vm="1" name="Parameter Pointer"/>
+        <entry group="3008" element="0066" keyword="OverrideReason" vr="ST" vm="1" name="Override Reason"/>
+        <entry group="3008" element="0067" keyword="ParameterValueNumber" vr="US" vm="1" name="Parameter Value Number"/>
+        <entry group="3008" element="0068" keyword="CorrectedParameterSequence" vr="SQ" vm="1" name="Corrected Parameter Sequence"/>
+        <entry group="3008" element="006a" keyword="CorrectionValue" vr="FL" vm="1" name="Correction Value"/>
+        <entry group="3008" element="0070" keyword="CalculatedDoseReferenceSequence" vr="SQ" vm="1" name="Calculated Dose Reference Sequence"/>
+        <entry group="3008" element="0072" keyword="CalculatedDoseReferenceNumber" vr="IS" vm="1" name="Calculated Dose Reference Number"/>
+        <entry group="3008" element="0074" keyword="CalculatedDoseReferenceDescription" vr="ST" vm="1" name="Calculated Dose Reference Description"/>
+        <entry group="3008" element="0076" keyword="CalculatedDoseReferenceDoseValue" vr="DS" vm="1" name="Calculated Dose Reference Dose Value"/>
+        <entry group="3008" element="0078" keyword="StartMeterset" vr="DS" vm="1" name="Start Meterset"/>
+        <entry group="3008" element="007a" keyword="EndMeterset" vr="DS" vm="1" name="End Meterset"/>
+        <entry group="3008" element="0080" keyword="ReferencedMeasuredDoseReferenceSequence" vr="SQ" vm="1" name="Referenced Measured Dose Reference Sequence"/>
+        <entry group="3008" element="0082" keyword="ReferencedMeasuredDoseReferenceNumber" vr="IS" vm="1" name="Referenced Measured Dose Reference Number"/>
+        <entry group="3008" element="0090" keyword="ReferencedCalculatedDoseReferenceSequence" vr="SQ" vm="1" name="Referenced Calculated Dose Reference Sequence"/>
+        <entry group="3008" element="0092" keyword="ReferencedCalculatedDoseReferenceNumber" vr="IS" vm="1" name="Referenced Calculated Dose Reference Number"/>
+        <entry group="3008" element="00a0" keyword="BeamLimitingDeviceLeafPairsSequence" vr="SQ" vm="1" name="Beam Limiting Device Leaf Pairs Sequence"/>
+        <entry group="3008" element="00b0" keyword="RecordedWedgeSequence" vr="SQ" vm="1" name="Recorded Wedge Sequence"/>
+        <entry group="3008" element="00c0" keyword="RecordedCompensatorSequence" vr="SQ" vm="1" name="Recorded Compensator Sequence"/>
+        <entry group="3008" element="00d0" keyword="RecordedBlockSequence" vr="SQ" vm="1" name="Recorded Block Sequence"/>
+        <entry group="3008" element="00e0" keyword="TreatmentSummaryMeasuredDoseReferenceSequence" vr="SQ" vm="1" name="Treatment Summary Measured Dose Reference Sequence"/>
+        <entry group="3008" element="00f0" keyword="RecordedSnoutSequence" vr="SQ" vm="1" name="Recorded Snout Sequence"/>
+        <entry group="3008" element="00f2" keyword="RecordedRangeShifterSequence" vr="SQ" vm="1" name="Recorded Range Shifter Sequence"/>
+        <entry group="3008" element="00f4" keyword="RecordedLateralSpreadingDeviceSequence" vr="SQ" vm="1" name="Recorded Lateral Spreading Device Sequence"/>
+        <entry group="3008" element="00f6" keyword="RecordedRangeModulatorSequence" vr="SQ" vm="1" name="Recorded Range Modulator Sequence"/>
+        <entry group="3008" element="0100" keyword="RecordedSourceSequence" vr="SQ" vm="1" name="Recorded Source Sequence"/>
+        <entry group="3008" element="0105" keyword="SourceSerialNumber" vr="LO" vm="1" name="Source Serial Number"/>
+        <entry group="3008" element="0110" keyword="TreatmentSessionApplicationSetupSequence" vr="SQ" vm="1" name="Treatment Session Application Setup Sequence"/>
+        <entry group="3008" element="0116" keyword="ApplicationSetupCheck" vr="CS" vm="1" name="Application Setup Check"/>
+        <entry group="3008" element="0120" keyword="RecordedBrachyAccessoryDeviceSequence" vr="SQ" vm="1" name="Recorded Brachy Accessory Device Sequence"/>
+        <entry group="3008" element="0122" keyword="ReferencedBrachyAccessoryDeviceNumber" vr="IS" vm="1" name="Referenced Brachy Accessory Device Number"/>
+        <entry group="3008" element="0130" keyword="RecordedChannelSequence" vr="SQ" vm="1" name="Recorded Channel Sequence"/>
+        <entry group="3008" element="0132" keyword="SpecifiedChannelTotalTime" vr="DS" vm="1" name="Specified Channel Total Time"/>
+        <entry group="3008" element="0134" keyword="DeliveredChannelTotalTime" vr="DS" vm="1" name="Delivered Channel Total Time"/>
+        <entry group="3008" element="0136" keyword="SpecifiedNumberOfPulses" vr="IS" vm="1" name="Specified Number of Pulses"/>
+        <entry group="3008" element="0138" keyword="DeliveredNumberOfPulses" vr="IS" vm="1" name="Delivered Number of Pulses"/>
+        <entry group="3008" element="013a" keyword="SpecifiedPulseRepetitionInterval" vr="DS" vm="1" name="Specified Pulse Repetition Interval"/>
+        <entry group="3008" element="013c" keyword="DeliveredPulseRepetitionInterval" vr="DS" vm="1" name="Delivered Pulse Repetition Interval"/>
+        <entry group="3008" element="0140" keyword="RecordedSourceApplicatorSequence" vr="SQ" vm="1" name="Recorded Source Applicator Sequence"/>
+        <entry group="3008" element="0142" keyword="ReferencedSourceApplicatorNumber" vr="IS" vm="1" name="Referenced Source Applicator Number"/>
+        <entry group="3008" element="0150" keyword="RecordedChannelShieldSequence" vr="SQ" vm="1" name="Recorded Channel Shield Sequence"/>
+        <entry group="3008" element="0152" keyword="ReferencedChannelShieldNumber" vr="IS" vm="1" name="Referenced Channel Shield Number"/>
+        <entry group="3008" element="0160" keyword="BrachyControlPointDeliveredSequence" vr="SQ" vm="1" name="Brachy Control Point Delivered Sequence"/>
+        <entry group="3008" element="0162" keyword="SafePositionExitDate" vr="DA" vm="1" name="Safe Position Exit Date"/>
+        <entry group="3008" element="0164" keyword="SafePositionExitTime" vr="TM" vm="1" name="Safe Position Exit Time"/>
+        <entry group="3008" element="0166" keyword="SafePositionReturnDate" vr="DA" vm="1" name="Safe Position Return Date"/>
+        <entry group="3008" element="0168" keyword="SafePositionReturnTime" vr="TM" vm="1" name="Safe Position Return Time"/>
+        <entry group="3008" element="0171" keyword="PulseSpecificBrachyControlPointDeliveredSequence" vr="SQ" vm="1" name="Pulse Specific Brachy Control Point Delivered Sequence"/>
+        <entry group="3008" element="0172" keyword="PulseNumber" vr="US" vm="1" name="Pulse Number"/>
+        <entry group="3008" element="0173" keyword="BrachyPulseControlPointDeliveredSequence" vr="SQ" vm="1" name="Brachy Pulse Control Point Delivered Sequence"/>
+        <entry group="3008" element="0200" keyword="CurrentTreatmentStatus" vr="CS" vm="1" name="Current Treatment Status"/>
+        <entry group="3008" element="0202" keyword="TreatmentStatusComment" vr="ST" vm="1" name="Treatment Status Comment"/>
+        <entry group="3008" element="0220" keyword="FractionGroupSummarySequence" vr="SQ" vm="1" name="Fraction Group Summary Sequence"/>
+        <entry group="3008" element="0223" keyword="ReferencedFractionNumber" vr="IS" vm="1" name="Referenced Fraction Number"/>
+        <entry group="3008" element="0224" keyword="FractionGroupType" vr="CS" vm="1" name="Fraction Group Type"/>
+        <entry group="3008" element="0230" keyword="BeamStopperPosition" vr="CS" vm="1" name="Beam Stopper Position"/>
+        <entry group="3008" element="0240" keyword="FractionStatusSummarySequence" vr="SQ" vm="1" name="Fraction Status Summary Sequence"/>
+        <entry group="3008" element="0250" keyword="TreatmentDate" vr="DA" vm="1" name="Treatment Date"/>
+        <entry group="3008" element="0251" keyword="TreatmentTime" vr="TM" vm="1" name="Treatment Time"/>
+        <entry group="300a" element="0002" keyword="RTPlanLabel" vr="SH" vm="1" name="RT Plan Label"/>
+        <entry group="300a" element="0003" keyword="RTPlanName" vr="LO" vm="1" name="RT Plan Name"/>
+        <entry group="300a" element="0004" keyword="RTPlanDescription" vr="ST" vm="1" name="RT Plan Description"/>
+        <entry group="300a" element="0006" keyword="RTPlanDate" vr="DA" vm="1" name="RT Plan Date"/>
+        <entry group="300a" element="0007" keyword="RTPlanTime" vr="TM" vm="1" name="RT Plan Time"/>
+        <entry group="300a" element="0009" keyword="TreatmentProtocols" vr="LO" vm="1-n" name="Treatment Protocols"/>
+        <entry group="300a" element="000a" keyword="PlanIntent" vr="CS" vm="1" name="Plan Intent"/>
+        <entry group="300a" element="000b" keyword="TreatmentSites" vr="LO" vm="1-n" name="Treatment Sites"/>
+        <entry group="300a" element="000c" keyword="RTPlanGeometry" vr="CS" vm="1" name="RT Plan Geometry"/>
+        <entry group="300a" element="000e" keyword="PrescriptionDescription" vr="ST" vm="1" name="Prescription Description"/>
+        <entry group="300a" element="0010" keyword="DoseReferenceSequence" vr="SQ" vm="1" name="Dose Reference Sequence"/>
+        <entry group="300a" element="0012" keyword="DoseReferenceNumber" vr="IS" vm="1" name="Dose Reference Number"/>
+        <entry group="300a" element="0013" keyword="DoseReferenceUID" vr="UI" vm="1" name="Dose Reference UID"/>
+        <entry group="300a" element="0014" keyword="DoseReferenceStructureType" vr="CS" vm="1" name="Dose Reference Structure Type"/>
+        <entry group="300a" element="0015" keyword="NominalBeamEnergyUnit" vr="CS" vm="1" name="Nominal Beam Energy Unit"/>
+        <entry group="300a" element="0016" keyword="DoseReferenceDescription" vr="LO" vm="1" name="Dose Reference Description"/>
+        <entry group="300a" element="0018" keyword="DoseReferencePointCoordinates" vr="DS" vm="3" name="Dose Reference Point Coordinates"/>
+        <entry group="300a" element="001a" keyword="NominalPriorDose" vr="DS" vm="1" name="Nominal Prior Dose"/>
+        <entry group="300a" element="0020" keyword="DoseReferenceType" vr="CS" vm="1" name="Dose Reference Type"/>
+        <entry group="300a" element="0021" keyword="ConstraintWeight" vr="DS" vm="1" name="Constraint Weight"/>
+        <entry group="300a" element="0022" keyword="DeliveryWarningDose" vr="DS" vm="1" name="Delivery Warning Dose"/>
+        <entry group="300a" element="0023" keyword="DeliveryMaximumDose" vr="DS" vm="1" name="Delivery Maximum Dose"/>
+        <entry group="300a" element="0025" keyword="TargetMinimumDose" vr="DS" vm="1" name="Target Minimum Dose"/>
+        <entry group="300a" element="0026" keyword="TargetPrescriptionDose" vr="DS" vm="1" name="Target Prescription Dose"/>
+        <entry group="300a" element="0027" keyword="TargetMaximumDose" vr="DS" vm="1" name="Target Maximum Dose"/>
+        <entry group="300a" element="0028" keyword="TargetUnderdoseVolumeFraction" vr="DS" vm="1" name="Target Underdose Volume Fraction"/>
+        <entry group="300a" element="002a" keyword="OrganAtRiskFullVolumeDose" vr="DS" vm="1" name="Organ at Risk Full-volume Dose"/>
+        <entry group="300a" element="002b" keyword="OrganAtRiskLimitDose" vr="DS" vm="1" name="Organ at Risk Limit Dose"/>
+        <entry group="300a" element="002c" keyword="OrganAtRiskMaximumDose" vr="DS" vm="1" name="Organ at Risk Maximum Dose"/>
+        <entry group="300a" element="002d" keyword="OrganAtRiskOverdoseVolumeFraction" vr="DS" vm="1" name="Organ at Risk Overdose Volume Fraction"/>
+        <entry group="300a" element="0040" keyword="ToleranceTableSequence" vr="SQ" vm="1" name="Tolerance Table Sequence"/>
+        <entry group="300a" element="0042" keyword="ToleranceTableNumber" vr="IS" vm="1" name="Tolerance Table Number"/>
+        <entry group="300a" element="0043" keyword="ToleranceTableLabel" vr="SH" vm="1" name="Tolerance Table Label"/>
+        <entry group="300a" element="0044" keyword="GantryAngleTolerance" vr="DS" vm="1" name="Gantry Angle Tolerance"/>
+        <entry group="300a" element="0046" keyword="BeamLimitingDeviceAngleTolerance" vr="DS" vm="1" name="Beam Limiting Device Angle Tolerance"/>
+        <entry group="300a" element="0048" keyword="BeamLimitingDeviceToleranceSequence" vr="SQ" vm="1" name="Beam Limiting Device Tolerance Sequence"/>
+        <entry group="300a" element="004a" keyword="BeamLimitingDevicePositionTolerance" vr="DS" vm="1" name="Beam Limiting Device Position Tolerance"/>
+        <entry group="300a" element="004b" keyword="SnoutPositionTolerance" vr="FL" vm="1" name="Snout Position Tolerance"/>
+        <entry group="300a" element="004c" keyword="PatientSupportAngleTolerance" vr="DS" vm="1" name="Patient Support Angle Tolerance"/>
+        <entry group="300a" element="004e" keyword="TableTopEccentricAngleTolerance" vr="DS" vm="1" name="Table Top Eccentric Angle Tolerance"/>
+        <entry group="300a" element="004f" keyword="TableTopPitchAngleTolerance" vr="FL" vm="1" name="Table Top Pitch Angle Tolerance"/>
+        <entry group="300a" element="0050" keyword="TableTopRollAngleTolerance" vr="FL" vm="1" name="Table Top Roll Angle Tolerance"/>
+        <entry group="300a" element="0051" keyword="TableTopVerticalPositionTolerance" vr="DS" vm="1" name="Table Top Vertical Position Tolerance"/>
+        <entry group="300a" element="0052" keyword="TableTopLongitudinalPositionTolerance" vr="DS" vm="1" name="Table Top Longitudinal Position Tolerance"/>
+        <entry group="300a" element="0053" keyword="TableTopLateralPositionTolerance" vr="DS" vm="1" name="Table Top Lateral Position Tolerance"/>
+        <entry group="300a" element="0055" keyword="RTPlanRelationship" vr="CS" vm="1" name="RT Plan Relationship"/>
+        <entry group="300a" element="0070" keyword="FractionGroupSequence" vr="SQ" vm="1" name="Fraction Group Sequence"/>
+        <entry group="300a" element="0071" keyword="FractionGroupNumber" vr="IS" vm="1" name="Fraction Group Number"/>
+        <entry group="300a" element="0072" keyword="FractionGroupDescription" vr="LO" vm="1" name="Fraction Group Description"/>
+        <entry group="300a" element="0078" keyword="NumberOfFractionsPlanned" vr="IS" vm="1" name="Number of Fractions Planned"/>
+        <entry group="300a" element="0079" keyword="NumberOfFractionPatternDigitsPerDay" vr="IS" vm="1" name="Number of Fraction Pattern Digits Per Day"/>
+        <entry group="300a" element="007a" keyword="RepeatFractionCycleLength" vr="IS" vm="1" name="Repeat Fraction Cycle Length"/>
+        <entry group="300a" element="007b" keyword="FractionPattern" vr="LT" vm="1" name="Fraction Pattern"/>
+        <entry group="300a" element="0080" keyword="NumberOfBeams" vr="IS" vm="1" name="Number of Beams"/>
+        <entry group="300a" element="0082" keyword="BeamDoseSpecificationPoint" vr="DS" vm="3" name="Beam Dose Specification Point"/>
+        <entry group="300a" element="0084" keyword="BeamDose" vr="DS" vm="1" name="Beam Dose"/>
+        <entry group="300a" element="0086" keyword="BeamMeterset" vr="DS" vm="1" name="Beam Meterset"/>
+        <entry group="300a" element="0088" keyword="BeamDosePointDepth" vr="FL" vm="1" retired="true" name="Beam Dose Point Depth"/>
+        <entry group="300a" element="0089" keyword="BeamDosePointEquivalentDepth" vr="FL" vm="1" retired="true" name="Beam Dose Point Equivalent Depth"/>
+        <entry group="300a" element="008a" keyword="BeamDosePointSSD" vr="FL" vm="1" retired="true" name="Beam Dose Point SSD"/>
+        <entry group="300a" element="008b" keyword="BeamDoseMeaning" vr="CS" vm="1" name="Beam Dose Meaning"/>
+        <entry group="300a" element="008c" keyword="BeamDoseVerificationControlPointSequence" vr="SQ" vm="1" name="Beam Dose Verification Control Point Sequence"/>
+        <entry group="300a" element="008d" keyword="AverageBeamDosePointDepth" vr="FL" vm="1" name="Average Beam Dose Point Depth"/>
+        <entry group="300a" element="008e" keyword="AverageBeamDosePointEquivalentDepth" vr="FL" vm="1" name="Average Beam Dose Point Equivalent Depth"/>
+        <entry group="300a" element="008f" keyword="AverageBeamDosePointSSD" vr="FL" vm="1" name="Average Beam Dose Point SSD"/>
+        <entry group="300a" element="0090" keyword="BeamDoseType" vr="CS" vm="1" name="Beam Dose Type"/>
+        <entry group="300a" element="0091" keyword="AlternateBeamDose" vr="DS" vm="1" name="Alternate Beam Dose"/>
+        <entry group="300a" element="0092" keyword="AlternateBeamDoseType" vr="CS" vm="1" name="Alternate Beam Dose Type"/>
+        <entry group="300a" element="00a0" keyword="NumberOfBrachyApplicationSetups" vr="IS" vm="1" name="Number of Brachy Application Setups"/>
+        <entry group="300a" element="00a2" keyword="BrachyApplicationSetupDoseSpecificationPoint" vr="DS" vm="3" name="Brachy Application Setup Dose Specification Point"/>
+        <entry group="300a" element="00a4" keyword="BrachyApplicationSetupDose" vr="DS" vm="1" name="Brachy Application Setup Dose"/>
+        <entry group="300a" element="00b0" keyword="BeamSequence" vr="SQ" vm="1" name="Beam Sequence"/>
+        <entry group="300a" element="00b2" keyword="TreatmentMachineName" vr="SH" vm="1" name="Treatment Machine Name"/>
+        <entry group="300a" element="00b3" keyword="PrimaryDosimeterUnit" vr="CS" vm="1" name="Primary Dosimeter Unit"/>
+        <entry group="300a" element="00b4" keyword="SourceAxisDistance" vr="DS" vm="1" name="Source-Axis Distance"/>
+        <entry group="300a" element="00b6" keyword="BeamLimitingDeviceSequence" vr="SQ" vm="1" name="Beam Limiting Device Sequence"/>
+        <entry group="300a" element="00b8" keyword="RTBeamLimitingDeviceType" vr="CS" vm="1" name="RT Beam Limiting Device Type"/>
+        <entry group="300a" element="00ba" keyword="SourceToBeamLimitingDeviceDistance" vr="DS" vm="1" name="Source to Beam Limiting Device Distance"/>
+        <entry group="300a" element="00bb" keyword="IsocenterToBeamLimitingDeviceDistance" vr="FL" vm="1" name="Isocenter to Beam Limiting Device Distance"/>
+        <entry group="300a" element="00bc" keyword="NumberOfLeafJawPairs" vr="IS" vm="1" name="Number of Leaf/Jaw Pairs"/>
+        <entry group="300a" element="00be" keyword="LeafPositionBoundaries" vr="DS" vm="3-n" name="Leaf Position Boundaries"/>
+        <entry group="300a" element="00c0" keyword="BeamNumber" vr="IS" vm="1" name="Beam Number"/>
+        <entry group="300a" element="00c2" keyword="BeamName" vr="LO" vm="1" name="Beam Name"/>
+        <entry group="300a" element="00c3" keyword="BeamDescription" vr="ST" vm="1" name="Beam Description"/>
+        <entry group="300a" element="00c4" keyword="BeamType" vr="CS" vm="1" name="Beam Type"/>
+        <entry group="300a" element="00c5" keyword="BeamDeliveryDurationLimit" vr="FD" vm="1" name="Beam Delivery Duration Limit"/>
+        <entry group="300a" element="00c6" keyword="RadiationType" vr="CS" vm="1" name="Radiation Type"/>
+        <entry group="300a" element="00c7" keyword="HighDoseTechniqueType" vr="CS" vm="1" name="High-Dose Technique Type"/>
+        <entry group="300a" element="00c8" keyword="ReferenceImageNumber" vr="IS" vm="1" name="Reference Image Number"/>
+        <entry group="300a" element="00ca" keyword="PlannedVerificationImageSequence" vr="SQ" vm="1" name="Planned Verification Image Sequence"/>
+        <entry group="300a" element="00cc" keyword="ImagingDeviceSpecificAcquisitionParameters" vr="LO" vm="1-n" name="Imaging Device-Specific Acquisition Parameters"/>
+        <entry group="300a" element="00ce" keyword="TreatmentDeliveryType" vr="CS" vm="1" name="Treatment Delivery Type"/>
+        <entry group="300a" element="00d0" keyword="NumberOfWedges" vr="IS" vm="1" name="Number of Wedges"/>
+        <entry group="300a" element="00d1" keyword="WedgeSequence" vr="SQ" vm="1" name="Wedge Sequence"/>
+        <entry group="300a" element="00d2" keyword="WedgeNumber" vr="IS" vm="1" name="Wedge Number"/>
+        <entry group="300a" element="00d3" keyword="WedgeType" vr="CS" vm="1" name="Wedge Type"/>
+        <entry group="300a" element="00d4" keyword="WedgeID" vr="SH" vm="1" name="Wedge ID"/>
+        <entry group="300a" element="00d5" keyword="WedgeAngle" vr="IS" vm="1" name="Wedge Angle"/>
+        <entry group="300a" element="00d6" keyword="WedgeFactor" vr="DS" vm="1" name="Wedge Factor"/>
+        <entry group="300a" element="00d7" keyword="TotalWedgeTrayWaterEquivalentThickness" vr="FL" vm="1" name="Total Wedge Tray Water-Equivalent Thickness"/>
+        <entry group="300a" element="00d8" keyword="WedgeOrientation" vr="DS" vm="1" name="Wedge Orientation"/>
+        <entry group="300a" element="00d9" keyword="IsocenterToWedgeTrayDistance" vr="FL" vm="1" name="Isocenter to Wedge Tray Distance"/>
+        <entry group="300a" element="00da" keyword="SourceToWedgeTrayDistance" vr="DS" vm="1" name="Source to Wedge Tray Distance"/>
+        <entry group="300a" element="00db" keyword="WedgeThinEdgePosition" vr="FL" vm="1" name="Wedge Thin Edge Position"/>
+        <entry group="300a" element="00dc" keyword="BolusID" vr="SH" vm="1" name="Bolus ID"/>
+        <entry group="300a" element="00dd" keyword="BolusDescription" vr="ST" vm="1" name="Bolus Description"/>
+        <entry group="300a" element="00de" keyword="EffectiveWedgeAngle" vr="DS" vm="1" name="Effective Wedge Angle"/>
+        <entry group="300a" element="00e0" keyword="NumberOfCompensators" vr="IS" vm="1" name="Number of Compensators"/>
+        <entry group="300a" element="00e1" keyword="MaterialID" vr="SH" vm="1" name="Material ID"/>
+        <entry group="300a" element="00e2" keyword="TotalCompensatorTrayFactor" vr="DS" vm="1" name="Total Compensator Tray Factor"/>
+        <entry group="300a" element="00e3" keyword="CompensatorSequence" vr="SQ" vm="1" name="Compensator Sequence"/>
+        <entry group="300a" element="00e4" keyword="CompensatorNumber" vr="IS" vm="1" name="Compensator Number"/>
+        <entry group="300a" element="00e5" keyword="CompensatorID" vr="SH" vm="1" name="Compensator ID"/>
+        <entry group="300a" element="00e6" keyword="SourceToCompensatorTrayDistance" vr="DS" vm="1" name="Source to Compensator Tray Distance"/>
+        <entry group="300a" element="00e7" keyword="CompensatorRows" vr="IS" vm="1" name="Compensator Rows"/>
+        <entry group="300a" element="00e8" keyword="CompensatorColumns" vr="IS" vm="1" name="Compensator Columns"/>
+        <entry group="300a" element="00e9" keyword="CompensatorPixelSpacing" vr="DS" vm="2" name="Compensator Pixel Spacing"/>
+        <entry group="300a" element="00ea" keyword="CompensatorPosition" vr="DS" vm="2" name="Compensator Position"/>
+        <entry group="300a" element="00eb" keyword="CompensatorTransmissionData" vr="DS" vm="1-n" name="Compensator Transmission Data"/>
+        <entry group="300a" element="00ec" keyword="CompensatorThicknessData" vr="DS" vm="1-n" name="Compensator Thickness Data"/>
+        <entry group="300a" element="00ed" keyword="NumberOfBoli" vr="IS" vm="1" name="Number of Boli"/>
+        <entry group="300a" element="00ee" keyword="CompensatorType" vr="CS" vm="1" name="Compensator Type"/>
+        <entry group="300a" element="00ef" keyword="CompensatorTrayID" vr="SH" vm="1" name="Compensator Tray ID"/>
+        <entry group="300a" element="00f0" keyword="NumberOfBlocks" vr="IS" vm="1" name="Number of Blocks"/>
+        <entry group="300a" element="00f2" keyword="TotalBlockTrayFactor" vr="DS" vm="1" name="Total Block Tray Factor"/>
+        <entry group="300a" element="00f3" keyword="TotalBlockTrayWaterEquivalentThickness" vr="FL" vm="1" name="Total Block Tray Water-Equivalent Thickness"/>
+        <entry group="300a" element="00f4" keyword="BlockSequence" vr="SQ" vm="1" name="Block Sequence"/>
+        <entry group="300a" element="00f5" keyword="BlockTrayID" vr="SH" vm="1" name="Block Tray ID"/>
+        <entry group="300a" element="00f6" keyword="SourceToBlockTrayDistance" vr="DS" vm="1" name="Source to Block Tray Distance"/>
+        <entry group="300a" element="00f7" keyword="IsocenterToBlockTrayDistance" vr="FL" vm="1" name="Isocenter to Block Tray Distance"/>
+        <entry group="300a" element="00f8" keyword="BlockType" vr="CS" vm="1" name="Block Type"/>
+        <entry group="300a" element="00f9" keyword="AccessoryCode" vr="LO" vm="1" name="Accessory Code"/>
+        <entry group="300a" element="00fa" keyword="BlockDivergence" vr="CS" vm="1" name="Block Divergence"/>
+        <entry group="300a" element="00fb" keyword="BlockMountingPosition" vr="CS" vm="1" name="Block Mounting Position"/>
+        <entry group="300a" element="00fc" keyword="BlockNumber" vr="IS" vm="1" name="Block Number"/>
+        <entry group="300a" element="00fe" keyword="BlockName" vr="LO" vm="1" name="Block Name"/>
+        <entry group="300a" element="0100" keyword="BlockThickness" vr="DS" vm="1" name="Block Thickness"/>
+        <entry group="300a" element="0102" keyword="BlockTransmission" vr="DS" vm="1" name="Block Transmission"/>
+        <entry group="300a" element="0104" keyword="BlockNumberOfPoints" vr="IS" vm="1" name="Block Number of Points"/>
+        <entry group="300a" element="0106" keyword="BlockData" vr="DS" vm="2-2n" name="Block Data"/>
+        <entry group="300a" element="0107" keyword="ApplicatorSequence" vr="SQ" vm="1" name="Applicator Sequence"/>
+        <entry group="300a" element="0108" keyword="ApplicatorID" vr="SH" vm="1" name="Applicator ID"/>
+        <entry group="300a" element="0109" keyword="ApplicatorType" vr="CS" vm="1" name="Applicator Type"/>
+        <entry group="300a" element="010a" keyword="ApplicatorDescription" vr="LO" vm="1" name="Applicator Description"/>
+        <entry group="300a" element="010c" keyword="CumulativeDoseReferenceCoefficient" vr="DS" vm="1" name="Cumulative Dose Reference Coefficient"/>
+        <entry group="300a" element="010e" keyword="FinalCumulativeMetersetWeight" vr="DS" vm="1" name="Final Cumulative Meterset Weight"/>
+        <entry group="300a" element="0110" keyword="NumberOfControlPoints" vr="IS" vm="1" name="Number of Control Points"/>
+        <entry group="300a" element="0111" keyword="ControlPointSequence" vr="SQ" vm="1" name="Control Point Sequence"/>
+        <entry group="300a" element="0112" keyword="ControlPointIndex" vr="IS" vm="1" name="Control Point Index"/>
+        <entry group="300a" element="0114" keyword="NominalBeamEnergy" vr="DS" vm="1" name="Nominal Beam Energy"/>
+        <entry group="300a" element="0115" keyword="DoseRateSet" vr="DS" vm="1" name="Dose Rate Set"/>
+        <entry group="300a" element="0116" keyword="WedgePositionSequence" vr="SQ" vm="1" name="Wedge Position Sequence"/>
+        <entry group="300a" element="0118" keyword="WedgePosition" vr="CS" vm="1" name="Wedge Position"/>
+        <entry group="300a" element="011a" keyword="BeamLimitingDevicePositionSequence" vr="SQ" vm="1" name="Beam Limiting Device Position Sequence"/>
+        <entry group="300a" element="011c" keyword="LeafJawPositions" vr="DS" vm="2-2n" name="Leaf/Jaw Positions"/>
+        <entry group="300a" element="011e" keyword="GantryAngle" vr="DS" vm="1" name="Gantry Angle"/>
+        <entry group="300a" element="011f" keyword="GantryRotationDirection" vr="CS" vm="1" name="Gantry Rotation Direction"/>
+        <entry group="300a" element="0120" keyword="BeamLimitingDeviceAngle" vr="DS" vm="1" name="Beam Limiting Device Angle"/>
+        <entry group="300a" element="0121" keyword="BeamLimitingDeviceRotationDirection" vr="CS" vm="1" name="Beam Limiting Device Rotation Direction"/>
+        <entry group="300a" element="0122" keyword="PatientSupportAngle" vr="DS" vm="1" name="Patient Support Angle"/>
+        <entry group="300a" element="0123" keyword="PatientSupportRotationDirection" vr="CS" vm="1" name="Patient Support Rotation Direction"/>
+        <entry group="300a" element="0124" keyword="TableTopEccentricAxisDistance" vr="DS" vm="1" name="Table Top Eccentric Axis Distance"/>
+        <entry group="300a" element="0125" keyword="TableTopEccentricAngle" vr="DS" vm="1" name="Table Top Eccentric Angle"/>
+        <entry group="300a" element="0126" keyword="TableTopEccentricRotationDirection" vr="CS" vm="1" name="Table Top Eccentric Rotation Direction"/>
+        <entry group="300a" element="0128" keyword="TableTopVerticalPosition" vr="DS" vm="1" name="Table Top Vertical Position"/>
+        <entry group="300a" element="0129" keyword="TableTopLongitudinalPosition" vr="DS" vm="1" name="Table Top Longitudinal Position"/>
+        <entry group="300a" element="012a" keyword="TableTopLateralPosition" vr="DS" vm="1" name="Table Top Lateral Position"/>
+        <entry group="300a" element="012c" keyword="IsocenterPosition" vr="DS" vm="3" name="Isocenter Position"/>
+        <entry group="300a" element="012e" keyword="SurfaceEntryPoint" vr="DS" vm="3" name="Surface Entry Point"/>
+        <entry group="300a" element="0130" keyword="SourceToSurfaceDistance" vr="DS" vm="1" name="Source to Surface Distance"/>
+        <entry group="300a" element="0131" keyword="AverageBeamDosePointSourceToExternalContourDistance" vr="FL" vm="1" name="Average Beam Dose Point Source to External Contour Distance"/>
+        <entry group="300a" element="0132" keyword="SourceToExternalContourDistance" vr="FL" vm="1" name="Source to External Contour Distance"/>
+        <entry group="300a" element="0133" keyword="ExternalContourEntryPoint" vr="FL" vm="3" name="External Contour Entry Point"/>
+        <entry group="300a" element="0134" keyword="CumulativeMetersetWeight" vr="DS" vm="1" name="Cumulative Meterset Weight"/>
+        <entry group="300a" element="0140" keyword="TableTopPitchAngle" vr="FL" vm="1" name="Table Top Pitch Angle"/>
+        <entry group="300a" element="0142" keyword="TableTopPitchRotationDirection" vr="CS" vm="1" name="Table Top Pitch Rotation Direction"/>
+        <entry group="300a" element="0144" keyword="TableTopRollAngle" vr="FL" vm="1" name="Table Top Roll Angle"/>
+        <entry group="300a" element="0146" keyword="TableTopRollRotationDirection" vr="CS" vm="1" name="Table Top Roll Rotation Direction"/>
+        <entry group="300a" element="0148" keyword="HeadFixationAngle" vr="FL" vm="1" name="Head Fixation Angle"/>
+        <entry group="300a" element="014a" keyword="GantryPitchAngle" vr="FL" vm="1" name="Gantry Pitch Angle"/>
+        <entry group="300a" element="014c" keyword="GantryPitchRotationDirection" vr="CS" vm="1" name="Gantry Pitch Rotation Direction"/>
+        <entry group="300a" element="014e" keyword="GantryPitchAngleTolerance" vr="FL" vm="1" name="Gantry Pitch Angle Tolerance"/>
+        <entry group="300a" element="0150" keyword="FixationEye" vr="CS" vm="1" name="Fixation Eye"/>
+        <entry group="300a" element="0151" keyword="ChairHeadFramePosition" vr="DS" vm="1" name="Chair Head Frame Position"/>
+        <entry group="300a" element="0152" keyword="HeadFixationAngleTolerance" vr="DS" vm="1" name="Head Fixation Angle Tolerance"/>
+        <entry group="300a" element="0153" keyword="ChairHeadFramePositionTolerance" vr="DS" vm="1" name="Chair Head Frame Position Tolerance"/>
+        <entry group="300a" element="0154" keyword="FixationLightAzimuthalAngleTolerance" vr="DS" vm="1" name="Fixation Light Azimuthal Angle Tolerance"/>
+        <entry group="300a" element="0155" keyword="FixationLightPolarAngleTolerance" vr="DS" vm="1" name="Fixation Light Polar Angle Tolerance"/>
+        <entry group="300a" element="0180" keyword="PatientSetupSequence" vr="SQ" vm="1" name="Patient Setup Sequence"/>
+        <entry group="300a" element="0182" keyword="PatientSetupNumber" vr="IS" vm="1" name="Patient Setup Number"/>
+        <entry group="300a" element="0183" keyword="PatientSetupLabel" vr="LO" vm="1" name="Patient Setup Label"/>
+        <entry group="300a" element="0184" keyword="PatientAdditionalPosition" vr="LO" vm="1" name="Patient Additional Position"/>
+        <entry group="300a" element="0190" keyword="FixationDeviceSequence" vr="SQ" vm="1" name="Fixation Device Sequence"/>
+        <entry group="300a" element="0192" keyword="FixationDeviceType" vr="CS" vm="1" name="Fixation Device Type"/>
+        <entry group="300a" element="0194" keyword="FixationDeviceLabel" vr="SH" vm="1" name="Fixation Device Label"/>
+        <entry group="300a" element="0196" keyword="FixationDeviceDescription" vr="ST" vm="1" name="Fixation Device Description"/>
+        <entry group="300a" element="0198" keyword="FixationDevicePosition" vr="SH" vm="1" name="Fixation Device Position"/>
+        <entry group="300a" element="0199" keyword="FixationDevicePitchAngle" vr="FL" vm="1" name="Fixation Device Pitch Angle"/>
+        <entry group="300a" element="019a" keyword="FixationDeviceRollAngle" vr="FL" vm="1" name="Fixation Device Roll Angle"/>
+        <entry group="300a" element="01a0" keyword="ShieldingDeviceSequence" vr="SQ" vm="1" name="Shielding Device Sequence"/>
+        <entry group="300a" element="01a2" keyword="ShieldingDeviceType" vr="CS" vm="1" name="Shielding Device Type"/>
+        <entry group="300a" element="01a4" keyword="ShieldingDeviceLabel" vr="SH" vm="1" name="Shielding Device Label"/>
+        <entry group="300a" element="01a6" keyword="ShieldingDeviceDescription" vr="ST" vm="1" name="Shielding Device Description"/>
+        <entry group="300a" element="01a8" keyword="ShieldingDevicePosition" vr="SH" vm="1" name="Shielding Device Position"/>
+        <entry group="300a" element="01b0" keyword="SetupTechnique" vr="CS" vm="1" name="Setup Technique"/>
+        <entry group="300a" element="01b2" keyword="SetupTechniqueDescription" vr="ST" vm="1" name="Setup Technique Description"/>
+        <entry group="300a" element="01b4" keyword="SetupDeviceSequence" vr="SQ" vm="1" name="Setup Device Sequence"/>
+        <entry group="300a" element="01b6" keyword="SetupDeviceType" vr="CS" vm="1" name="Setup Device Type"/>
+        <entry group="300a" element="01b8" keyword="SetupDeviceLabel" vr="SH" vm="1" name="Setup Device Label"/>
+        <entry group="300a" element="01ba" keyword="SetupDeviceDescription" vr="ST" vm="1" name="Setup Device Description"/>
+        <entry group="300a" element="01bc" keyword="SetupDeviceParameter" vr="DS" vm="1" name="Setup Device Parameter"/>
+        <entry group="300a" element="01d0" keyword="SetupReferenceDescription" vr="ST" vm="1" name="Setup Reference Description"/>
+        <entry group="300a" element="01d2" keyword="TableTopVerticalSetupDisplacement" vr="DS" vm="1" name="Table Top Vertical Setup Displacement"/>
+        <entry group="300a" element="01d4" keyword="TableTopLongitudinalSetupDisplacement" vr="DS" vm="1" name="Table Top Longitudinal Setup Displacement"/>
+        <entry group="300a" element="01d6" keyword="TableTopLateralSetupDisplacement" vr="DS" vm="1" name="Table Top Lateral Setup Displacement"/>
+        <entry group="300a" element="0200" keyword="BrachyTreatmentTechnique" vr="CS" vm="1" name="Brachy Treatment Technique"/>
+        <entry group="300a" element="0202" keyword="BrachyTreatmentType" vr="CS" vm="1" name="Brachy Treatment Type"/>
+        <entry group="300a" element="0206" keyword="TreatmentMachineSequence" vr="SQ" vm="1" name="Treatment Machine Sequence"/>
+        <entry group="300a" element="0210" keyword="SourceSequence" vr="SQ" vm="1" name="Source Sequence"/>
+        <entry group="300a" element="0212" keyword="SourceNumber" vr="IS" vm="1" name="Source Number"/>
+        <entry group="300a" element="0214" keyword="SourceType" vr="CS" vm="1" name="Source Type"/>
+        <entry group="300a" element="0216" keyword="SourceManufacturer" vr="LO" vm="1" name="Source Manufacturer"/>
+        <entry group="300a" element="0218" keyword="ActiveSourceDiameter" vr="DS" vm="1" name="Active Source Diameter"/>
+        <entry group="300a" element="021a" keyword="ActiveSourceLength" vr="DS" vm="1" name="Active Source Length"/>
+        <entry group="300a" element="021b" keyword="SourceModelID" vr="SH" vm="1" name="Source Model ID"/>
+        <entry group="300a" element="021c" keyword="SourceDescription" vr="LO" vm="1" name="Source Description"/>
+        <entry group="300a" element="0222" keyword="SourceEncapsulationNominalThickness" vr="DS" vm="1" name="Source Encapsulation Nominal Thickness"/>
+        <entry group="300a" element="0224" keyword="SourceEncapsulationNominalTransmission" vr="DS" vm="1" name="Source Encapsulation Nominal Transmission"/>
+        <entry group="300a" element="0226" keyword="SourceIsotopeName" vr="LO" vm="1" name="Source Isotope Name"/>
+        <entry group="300a" element="0228" keyword="SourceIsotopeHalfLife" vr="DS" vm="1" name="Source Isotope Half Life"/>
+        <entry group="300a" element="0229" keyword="SourceStrengthUnits" vr="CS" vm="1" name="Source Strength Units"/>
+        <entry group="300a" element="022a" keyword="ReferenceAirKermaRate" vr="DS" vm="1" name="Reference Air Kerma Rate"/>
+        <entry group="300a" element="022b" keyword="SourceStrength" vr="DS" vm="1" name="Source Strength"/>
+        <entry group="300a" element="022c" keyword="SourceStrengthReferenceDate" vr="DA" vm="1" name="Source Strength Reference Date"/>
+        <entry group="300a" element="022e" keyword="SourceStrengthReferenceTime" vr="TM" vm="1" name="Source Strength Reference Time"/>
+        <entry group="300a" element="0230" keyword="ApplicationSetupSequence" vr="SQ" vm="1" name="Application Setup Sequence"/>
+        <entry group="300a" element="0232" keyword="ApplicationSetupType" vr="CS" vm="1" name="Application Setup Type"/>
+        <entry group="300a" element="0234" keyword="ApplicationSetupNumber" vr="IS" vm="1" name="Application Setup Number"/>
+        <entry group="300a" element="0236" keyword="ApplicationSetupName" vr="LO" vm="1" name="Application Setup Name"/>
+        <entry group="300a" element="0238" keyword="ApplicationSetupManufacturer" vr="LO" vm="1" name="Application Setup Manufacturer"/>
+        <entry group="300a" element="0240" keyword="TemplateNumber" vr="IS" vm="1" name="Template Number"/>
+        <entry group="300a" element="0242" keyword="TemplateType" vr="SH" vm="1" name="Template Type"/>
+        <entry group="300a" element="0244" keyword="TemplateName" vr="LO" vm="1" name="Template Name"/>
+        <entry group="300a" element="0250" keyword="TotalReferenceAirKerma" vr="DS" vm="1" name="Total Reference Air Kerma"/>
+        <entry group="300a" element="0260" keyword="BrachyAccessoryDeviceSequence" vr="SQ" vm="1" name="Brachy Accessory Device Sequence"/>
+        <entry group="300a" element="0262" keyword="BrachyAccessoryDeviceNumber" vr="IS" vm="1" name="Brachy Accessory Device Number"/>
+        <entry group="300a" element="0263" keyword="BrachyAccessoryDeviceID" vr="SH" vm="1" name="Brachy Accessory Device ID"/>
+        <entry group="300a" element="0264" keyword="BrachyAccessoryDeviceType" vr="CS" vm="1" name="Brachy Accessory Device Type"/>
+        <entry group="300a" element="0266" keyword="BrachyAccessoryDeviceName" vr="LO" vm="1" name="Brachy Accessory Device Name"/>
+        <entry group="300a" element="026a" keyword="BrachyAccessoryDeviceNominalThickness" vr="DS" vm="1" name="Brachy Accessory Device Nominal Thickness"/>
+        <entry group="300a" element="026c" keyword="BrachyAccessoryDeviceNominalTransmission" vr="DS" vm="1" name="Brachy Accessory Device Nominal Transmission"/>
+        <entry group="300a" element="0280" keyword="ChannelSequence" vr="SQ" vm="1" name="Channel Sequence"/>
+        <entry group="300a" element="0282" keyword="ChannelNumber" vr="IS" vm="1" name="Channel Number"/>
+        <entry group="300a" element="0284" keyword="ChannelLength" vr="DS" vm="1" name="Channel Length"/>
+        <entry group="300a" element="0286" keyword="ChannelTotalTime" vr="DS" vm="1" name="Channel Total Time"/>
+        <entry group="300a" element="0288" keyword="SourceMovementType" vr="CS" vm="1" name="Source Movement Type"/>
+        <entry group="300a" element="028a" keyword="NumberOfPulses" vr="IS" vm="1" name="Number of Pulses"/>
+        <entry group="300a" element="028c" keyword="PulseRepetitionInterval" vr="DS" vm="1" name="Pulse Repetition Interval"/>
+        <entry group="300a" element="0290" keyword="SourceApplicatorNumber" vr="IS" vm="1" name="Source Applicator Number"/>
+        <entry group="300a" element="0291" keyword="SourceApplicatorID" vr="SH" vm="1" name="Source Applicator ID"/>
+        <entry group="300a" element="0292" keyword="SourceApplicatorType" vr="CS" vm="1" name="Source Applicator Type"/>
+        <entry group="300a" element="0294" keyword="SourceApplicatorName" vr="LO" vm="1" name="Source Applicator Name"/>
+        <entry group="300a" element="0296" keyword="SourceApplicatorLength" vr="DS" vm="1" name="Source Applicator Length"/>
+        <entry group="300a" element="0298" keyword="SourceApplicatorManufacturer" vr="LO" vm="1" name="Source Applicator Manufacturer"/>
+        <entry group="300a" element="029c" keyword="SourceApplicatorWallNominalThickness" vr="DS" vm="1" name="Source Applicator Wall Nominal Thickness"/>
+        <entry group="300a" element="029e" keyword="SourceApplicatorWallNominalTransmission" vr="DS" vm="1" name="Source Applicator Wall Nominal Transmission"/>
+        <entry group="300a" element="02a0" keyword="SourceApplicatorStepSize" vr="DS" vm="1" name="Source Applicator Step Size"/>
+        <entry group="300a" element="02a2" keyword="TransferTubeNumber" vr="IS" vm="1" name="Transfer Tube Number"/>
+        <entry group="300a" element="02a4" keyword="TransferTubeLength" vr="DS" vm="1" name="Transfer Tube Length"/>
+        <entry group="300a" element="02b0" keyword="ChannelShieldSequence" vr="SQ" vm="1" name="Channel Shield Sequence"/>
+        <entry group="300a" element="02b2" keyword="ChannelShieldNumber" vr="IS" vm="1" name="Channel Shield Number"/>
+        <entry group="300a" element="02b3" keyword="ChannelShieldID" vr="SH" vm="1" name="Channel Shield ID"/>
+        <entry group="300a" element="02b4" keyword="ChannelShieldName" vr="LO" vm="1" name="Channel Shield Name"/>
+        <entry group="300a" element="02b8" keyword="ChannelShieldNominalThickness" vr="DS" vm="1" name="Channel Shield Nominal Thickness"/>
+        <entry group="300a" element="02ba" keyword="ChannelShieldNominalTransmission" vr="DS" vm="1" name="Channel Shield Nominal Transmission"/>
+        <entry group="300a" element="02c8" keyword="FinalCumulativeTimeWeight" vr="DS" vm="1" name="Final Cumulative Time Weight"/>
+        <entry group="300a" element="02d0" keyword="BrachyControlPointSequence" vr="SQ" vm="1" name="Brachy Control Point Sequence"/>
+        <entry group="300a" element="02d2" keyword="ControlPointRelativePosition" vr="DS" vm="1" name="Control Point Relative Position"/>
+        <entry group="300a" element="02d4" keyword="ControlPoint3DPosition" vr="DS" vm="3" name="Control Point 3D Position"/>
+        <entry group="300a" element="02d6" keyword="CumulativeTimeWeight" vr="DS" vm="1" name="Cumulative Time Weight"/>
+        <entry group="300a" element="02e0" keyword="CompensatorDivergence" vr="CS" vm="1" name="Compensator Divergence"/>
+        <entry group="300a" element="02e1" keyword="CompensatorMountingPosition" vr="CS" vm="1" name="Compensator Mounting Position"/>
+        <entry group="300a" element="02e2" keyword="SourceToCompensatorDistance" vr="DS" vm="1-n" name="Source to Compensator Distance"/>
+        <entry group="300a" element="02e3" keyword="TotalCompensatorTrayWaterEquivalentThickness" vr="FL" vm="1" name="Total Compensator Tray Water-Equivalent Thickness"/>
+        <entry group="300a" element="02e4" keyword="IsocenterToCompensatorTrayDistance" vr="FL" vm="1" name="Isocenter to Compensator Tray Distance"/>
+        <entry group="300a" element="02e5" keyword="CompensatorColumnOffset" vr="FL" vm="1" name="Compensator Column Offset"/>
+        <entry group="300a" element="02e6" keyword="IsocenterToCompensatorDistances" vr="FL" vm="1-n" name="Isocenter to Compensator Distances"/>
+        <entry group="300a" element="02e7" keyword="CompensatorRelativeStoppingPowerRatio" vr="FL" vm="1" name="Compensator Relative Stopping Power Ratio"/>
+        <entry group="300a" element="02e8" keyword="CompensatorMillingToolDiameter" vr="FL" vm="1" name="Compensator Milling Tool Diameter"/>
+        <entry group="300a" element="02ea" keyword="IonRangeCompensatorSequence" vr="SQ" vm="1" name="Ion Range Compensator Sequence"/>
+        <entry group="300a" element="02eb" keyword="CompensatorDescription" vr="LT" vm="1" name="Compensator Description"/>
+        <entry group="300a" element="0302" keyword="RadiationMassNumber" vr="IS" vm="1" name="Radiation Mass Number"/>
+        <entry group="300a" element="0304" keyword="RadiationAtomicNumber" vr="IS" vm="1" name="Radiation Atomic Number"/>
+        <entry group="300a" element="0306" keyword="RadiationChargeState" vr="SS" vm="1" name="Radiation Charge State"/>
+        <entry group="300a" element="0308" keyword="ScanMode" vr="CS" vm="1" name="Scan Mode"/>
+        <entry group="300a" element="0309" keyword="ModulatedScanModeType" vr="CS" vm="1" name="Modulated Scan Mode Type"/>
+        <entry group="300a" element="030a" keyword="VirtualSourceAxisDistances" vr="FL" vm="2" name="Virtual Source-Axis Distances"/>
+        <entry group="300a" element="030c" keyword="SnoutSequence" vr="SQ" vm="1" name="Snout Sequence"/>
+        <entry group="300a" element="030d" keyword="SnoutPosition" vr="FL" vm="1" name="Snout Position"/>
+        <entry group="300a" element="030f" keyword="SnoutID" vr="SH" vm="1" name="Snout ID"/>
+        <entry group="300a" element="0312" keyword="NumberOfRangeShifters" vr="IS" vm="1" name="Number of Range Shifters"/>
+        <entry group="300a" element="0314" keyword="RangeShifterSequence" vr="SQ" vm="1" name="Range Shifter Sequence"/>
+        <entry group="300a" element="0316" keyword="RangeShifterNumber" vr="IS" vm="1" name="Range Shifter Number"/>
+        <entry group="300a" element="0318" keyword="RangeShifterID" vr="SH" vm="1" name="Range Shifter ID"/>
+        <entry group="300a" element="0320" keyword="RangeShifterType" vr="CS" vm="1" name="Range Shifter Type"/>
+        <entry group="300a" element="0322" keyword="RangeShifterDescription" vr="LO" vm="1" name="Range Shifter Description"/>
+        <entry group="300a" element="0330" keyword="NumberOfLateralSpreadingDevices" vr="IS" vm="1" name="Number of Lateral Spreading Devices"/>
+        <entry group="300a" element="0332" keyword="LateralSpreadingDeviceSequence" vr="SQ" vm="1" name="Lateral Spreading Device Sequence"/>
+        <entry group="300a" element="0334" keyword="LateralSpreadingDeviceNumber" vr="IS" vm="1" name="Lateral Spreading Device Number"/>
+        <entry group="300a" element="0336" keyword="LateralSpreadingDeviceID" vr="SH" vm="1" name="Lateral Spreading Device ID"/>
+        <entry group="300a" element="0338" keyword="LateralSpreadingDeviceType" vr="CS" vm="1" name="Lateral Spreading Device Type"/>
+        <entry group="300a" element="033a" keyword="LateralSpreadingDeviceDescription" vr="LO" vm="1" name="Lateral Spreading Device Description"/>
+        <entry group="300a" element="033c" keyword="LateralSpreadingDeviceWaterEquivalentThickness" vr="FL" vm="1" name="Lateral Spreading Device Water Equivalent Thickness"/>
+        <entry group="300a" element="0340" keyword="NumberOfRangeModulators" vr="IS" vm="1" name="Number of Range Modulators"/>
+        <entry group="300a" element="0342" keyword="RangeModulatorSequence" vr="SQ" vm="1" name="Range Modulator Sequence"/>
+        <entry group="300a" element="0344" keyword="RangeModulatorNumber" vr="IS" vm="1" name="Range Modulator Number"/>
+        <entry group="300a" element="0346" keyword="RangeModulatorID" vr="SH" vm="1" name="Range Modulator ID"/>
+        <entry group="300a" element="0348" keyword="RangeModulatorType" vr="CS" vm="1" name="Range Modulator Type"/>
+        <entry group="300a" element="034a" keyword="RangeModulatorDescription" vr="LO" vm="1" name="Range Modulator Description"/>
+        <entry group="300a" element="034c" keyword="BeamCurrentModulationID" vr="SH" vm="1" name="Beam Current Modulation ID"/>
+        <entry group="300a" element="0350" keyword="PatientSupportType" vr="CS" vm="1" name="Patient Support Type"/>
+        <entry group="300a" element="0352" keyword="PatientSupportID" vr="SH" vm="1" name="Patient Support ID"/>
+        <entry group="300a" element="0354" keyword="PatientSupportAccessoryCode" vr="LO" vm="1" name="Patient Support Accessory Code"/>
+        <entry group="300a" element="0355" keyword="TrayAccessoryCode" vr="LO" vm="1" name="Tray Accessory Code"/>
+        <entry group="300a" element="0356" keyword="FixationLightAzimuthalAngle" vr="FL" vm="1" name="Fixation Light Azimuthal Angle"/>
+        <entry group="300a" element="0358" keyword="FixationLightPolarAngle" vr="FL" vm="1" name="Fixation Light Polar Angle"/>
+        <entry group="300a" element="035a" keyword="MetersetRate" vr="FL" vm="1" name="Meterset Rate"/>
+        <entry group="300a" element="0360" keyword="RangeShifterSettingsSequence" vr="SQ" vm="1" name="Range Shifter Settings Sequence"/>
+        <entry group="300a" element="0362" keyword="RangeShifterSetting" vr="LO" vm="1" name="Range Shifter Setting"/>
+        <entry group="300a" element="0364" keyword="IsocenterToRangeShifterDistance" vr="FL" vm="1" name="Isocenter to Range Shifter Distance"/>
+        <entry group="300a" element="0366" keyword="RangeShifterWaterEquivalentThickness" vr="FL" vm="1" name="Range Shifter Water Equivalent Thickness"/>
+        <entry group="300a" element="0370" keyword="LateralSpreadingDeviceSettingsSequence" vr="SQ" vm="1" name="Lateral Spreading Device Settings Sequence"/>
+        <entry group="300a" element="0372" keyword="LateralSpreadingDeviceSetting" vr="LO" vm="1" name="Lateral Spreading Device Setting"/>
+        <entry group="300a" element="0374" keyword="IsocenterToLateralSpreadingDeviceDistance" vr="FL" vm="1" name="Isocenter to Lateral Spreading Device Distance"/>
+        <entry group="300a" element="0380" keyword="RangeModulatorSettingsSequence" vr="SQ" vm="1" name="Range Modulator Settings Sequence"/>
+        <entry group="300a" element="0382" keyword="RangeModulatorGatingStartValue" vr="FL" vm="1" name="Range Modulator Gating Start Value"/>
+        <entry group="300a" element="0384" keyword="RangeModulatorGatingStopValue" vr="FL" vm="1" name="Range Modulator Gating Stop Value"/>
+        <entry group="300a" element="0386" keyword="RangeModulatorGatingStartWaterEquivalentThickness" vr="FL" vm="1" name="Range Modulator Gating Start Water Equivalent Thickness"/>
+        <entry group="300a" element="0388" keyword="RangeModulatorGatingStopWaterEquivalentThickness" vr="FL" vm="1" name="Range Modulator Gating Stop Water Equivalent Thickness"/>
+        <entry group="300a" element="038a" keyword="IsocenterToRangeModulatorDistance" vr="FL" vm="1" name="Isocenter to Range Modulator Distance"/>
+        <entry group="300a" element="038f" keyword="ScanSpotTimeOffset" vr="FL" vm="1-n" name="Scan Spot Time Offset"/>
+        <entry group="300a" element="0390" keyword="ScanSpotTuneID" vr="SH" vm="1" name="Scan Spot Tune ID"/>
+        <entry group="300a" element="0391" keyword="ScanSpotPrescribedIndices" vr="IS" vm="1-n" name="Scan Spot Prescribed Indices"/>
+        <entry group="300a" element="0392" keyword="NumberOfScanSpotPositions" vr="IS" vm="1" name="Number of Scan Spot Positions"/>
+        <entry group="300a" element="0393" keyword="ScanSpotReordered" vr="CS" vm="1" name="Scan Spot Reordered"/>
+        <entry group="300a" element="0394" keyword="ScanSpotPositionMap" vr="FL" vm="1-n" name="Scan Spot Position Map"/>
+        <entry group="300a" element="0395" keyword="ScanSpotReorderingAllowed" vr="CS" vm="1" name="Scan Spot Reordering Allowed"/>
+        <entry group="300a" element="0396" keyword="ScanSpotMetersetWeights" vr="FL" vm="1-n" name="Scan Spot Meterset Weights"/>
+        <entry group="300a" element="0398" keyword="ScanningSpotSize" vr="FL" vm="2" name="Scanning Spot Size"/>
+        <entry group="300a" element="039a" keyword="NumberOfPaintings" vr="IS" vm="1" name="Number of Paintings"/>
+        <entry group="300a" element="03a0" keyword="IonToleranceTableSequence" vr="SQ" vm="1" name="Ion Tolerance Table Sequence"/>
+        <entry group="300a" element="03a2" keyword="IonBeamSequence" vr="SQ" vm="1" name="Ion Beam Sequence"/>
+        <entry group="300a" element="03a4" keyword="IonBeamLimitingDeviceSequence" vr="SQ" vm="1" name="Ion Beam Limiting Device Sequence"/>
+        <entry group="300a" element="03a6" keyword="IonBlockSequence" vr="SQ" vm="1" name="Ion Block Sequence"/>
+        <entry group="300a" element="03a8" keyword="IonControlPointSequence" vr="SQ" vm="1" name="Ion Control Point Sequence"/>
+        <entry group="300a" element="03aa" keyword="IonWedgeSequence" vr="SQ" vm="1" name="Ion Wedge Sequence"/>
+        <entry group="300a" element="03ac" keyword="IonWedgePositionSequence" vr="SQ" vm="1" name="Ion Wedge Position Sequence"/>
+        <entry group="300a" element="0401" keyword="ReferencedSetupImageSequence" vr="SQ" vm="1" name="Referenced Setup Image Sequence"/>
+        <entry group="300a" element="0402" keyword="SetupImageComment" vr="ST" vm="1" name="Setup Image Comment"/>
+        <entry group="300a" element="0410" keyword="MotionSynchronizationSequence" vr="SQ" vm="1" name="Motion Synchronization Sequence"/>
+        <entry group="300a" element="0412" keyword="ControlPointOrientation" vr="FL" vm="3" name="Control Point Orientation"/>
+        <entry group="300a" element="0420" keyword="GeneralAccessorySequence" vr="SQ" vm="1" name="General Accessory Sequence"/>
+        <entry group="300a" element="0421" keyword="GeneralAccessoryID" vr="SH" vm="1" name="General Accessory ID"/>
+        <entry group="300a" element="0422" keyword="GeneralAccessoryDescription" vr="ST" vm="1" name="General Accessory Description"/>
+        <entry group="300a" element="0423" keyword="GeneralAccessoryType" vr="CS" vm="1" name="General Accessory Type"/>
+        <entry group="300a" element="0424" keyword="GeneralAccessoryNumber" vr="IS" vm="1" name="General Accessory Number"/>
+        <entry group="300a" element="0425" keyword="SourceToGeneralAccessoryDistance" vr="FL" vm="1" name="Source to General Accessory Distance"/>
+        <entry group="300a" element="0431" keyword="ApplicatorGeometrySequence" vr="SQ" vm="1" name="Applicator Geometry Sequence"/>
+        <entry group="300a" element="0432" keyword="ApplicatorApertureShape" vr="CS" vm="1" name="Applicator Aperture Shape"/>
+        <entry group="300a" element="0433" keyword="ApplicatorOpening" vr="FL" vm="1" name="Applicator Opening"/>
+        <entry group="300a" element="0434" keyword="ApplicatorOpeningX" vr="FL" vm="1" name="Applicator Opening X"/>
+        <entry group="300a" element="0435" keyword="ApplicatorOpeningY" vr="FL" vm="1" name="Applicator Opening Y"/>
+        <entry group="300a" element="0436" keyword="SourceToApplicatorMountingPositionDistance" vr="FL" vm="1" name="Source to Applicator Mounting Position Distance"/>
+        <entry group="300a" element="0440" keyword="NumberOfBlockSlabItems" vr="IS" vm="1" name="Number of Block Slab Items"/>
+        <entry group="300a" element="0441" keyword="BlockSlabSequence" vr="SQ" vm="1" name="Block Slab Sequence"/>
+        <entry group="300a" element="0442" keyword="BlockSlabThickness" vr="DS" vm="1" name="Block Slab Thickness"/>
+        <entry group="300a" element="0443" keyword="BlockSlabNumber" vr="US" vm="1" name="Block Slab Number"/>
+        <entry group="300a" element="0450" keyword="DeviceMotionControlSequence" vr="SQ" vm="1" name="Device Motion Control Sequence"/>
+        <entry group="300a" element="0451" keyword="DeviceMotionExecutionMode" vr="CS" vm="1" name="Device Motion Execution Mode"/>
+        <entry group="300a" element="0452" keyword="DeviceMotionObservationMode" vr="CS" vm="1" name="Device Motion Observation Mode"/>
+        <entry group="300a" element="0453" keyword="DeviceMotionParameterCodeSequence" vr="SQ" vm="1" name="Device Motion Parameter Code Sequence"/> 
+        <entry group="300a" element="0501" keyword="DistalDepthFraction" vr="FL" vm="1" name="Distal Depth Fraction"/>
+        <entry group="300a" element="0502" keyword="DistalDepth" vr="FL" vm="1" name="Distal Depth"/>
+        <entry group="300a" element="0503" keyword="NominalRangeModulationFractions" vr="FL" vm="2" name="Nominal Range Modulation Fractions"/>
+        <entry group="300a" element="0504" keyword="NominalRangeModulatedRegionDepths" vr="FL" vm="2" name="Nominal Range Modulated Region Depths"/>
+        <entry group="300a" element="0505" keyword="DepthDoseParametersSequence" vr="SQ" vm="1" name="Depth Dose Parameters Sequence"/>
+        <entry group="300a" element="0506" keyword="DeliveredDepthDoseParametersSequence" vr="SQ" vm="1" name="Delivered Depth Dose Parameters Sequence"/>
+        <entry group="300a" element="0507" keyword="DeliveredDistalDepthFraction" vr="FL" vm="1" name="Delivered Distal Depth Fraction"/>
+        <entry group="300a" element="0508" keyword="DeliveredDistalDepth" vr="FL" vm="1" name="Delivered Distal Depth"/>
+        <entry group="300a" element="0509" keyword="DeliveredNominalRangeModulationFractions" vr="FL" vm="2" name="Delivered Nominal Range Modulation Fractions"/>
+        <entry group="300a" element="0510" keyword="DeliveredNominalRangeModulatedRegionDepths" vr="FL" vm="2" name="Delivered Nominal Range Modulated Region Depths"/>
+        <entry group="300a" element="0511" keyword="DeliveredReferenceDoseDefinition" vr="CS" vm="1" name="Delivered Reference Dose Definition"/>
+        <entry group="300a" element="0512" keyword="ReferenceDoseDefinition" vr="CS" vm="1" name="Reference Dose Definition"/>
+        <entry group="300c" element="0002" keyword="ReferencedRTPlanSequence" vr="SQ" vm="1" name="Referenced RT Plan Sequence"/>
+        <entry group="300c" element="0004" keyword="ReferencedBeamSequence" vr="SQ" vm="1" name="Referenced Beam Sequence"/>
+        <entry group="300c" element="0006" keyword="ReferencedBeamNumber" vr="IS" vm="1" name="Referenced Beam Number"/>
+        <entry group="300c" element="0007" keyword="ReferencedReferenceImageNumber" vr="IS" vm="1" name="Referenced Reference Image Number"/>
+        <entry group="300c" element="0008" keyword="StartCumulativeMetersetWeight" vr="DS" vm="1" name="Start Cumulative Meterset Weight"/>
+        <entry group="300c" element="0009" keyword="EndCumulativeMetersetWeight" vr="DS" vm="1" name="End Cumulative Meterset Weight"/>
+        <entry group="300c" element="000a" keyword="ReferencedBrachyApplicationSetupSequence" vr="SQ" vm="1" name="Referenced Brachy Application Setup Sequence"/>
+        <entry group="300c" element="000c" keyword="ReferencedBrachyApplicationSetupNumber" vr="IS" vm="1" name="Referenced Brachy Application Setup Number"/>
+        <entry group="300c" element="000e" keyword="ReferencedSourceNumber" vr="IS" vm="1" name="Referenced Source Number"/>
+        <entry group="300c" element="0020" keyword="ReferencedFractionGroupSequence" vr="SQ" vm="1" name="Referenced Fraction Group Sequence"/>
+        <entry group="300c" element="0022" keyword="ReferencedFractionGroupNumber" vr="IS" vm="1" name="Referenced Fraction Group Number"/>
+        <entry group="300c" element="0040" keyword="ReferencedVerificationImageSequence" vr="SQ" vm="1" name="Referenced Verification Image Sequence"/>
+        <entry group="300c" element="0042" keyword="ReferencedReferenceImageSequence" vr="SQ" vm="1" name="Referenced Reference Image Sequence"/>
+        <entry group="300c" element="0050" keyword="ReferencedDoseReferenceSequence" vr="SQ" vm="1" name="Referenced Dose Reference Sequence"/>
+        <entry group="300c" element="0051" keyword="ReferencedDoseReferenceNumber" vr="IS" vm="1" name="Referenced Dose Reference Number"/>
+        <entry group="300c" element="0055" keyword="BrachyReferencedDoseReferenceSequence" vr="SQ" vm="1" name="Brachy Referenced Dose Reference Sequence"/>
+        <entry group="300c" element="0060" keyword="ReferencedStructureSetSequence" vr="SQ" vm="1" name="Referenced Structure Set Sequence"/>
+        <entry group="300c" element="006a" keyword="ReferencedPatientSetupNumber" vr="IS" vm="1" name="Referenced Patient Setup Number"/>
+        <entry group="300c" element="0080" keyword="ReferencedDoseSequence" vr="SQ" vm="1" name="Referenced Dose Sequence"/>
+        <entry group="300c" element="00a0" keyword="ReferencedToleranceTableNumber" vr="IS" vm="1" name="Referenced Tolerance Table Number"/>
+        <entry group="300c" element="00b0" keyword="ReferencedBolusSequence" vr="SQ" vm="1" name="Referenced Bolus Sequence"/>
+        <entry group="300c" element="00c0" keyword="ReferencedWedgeNumber" vr="IS" vm="1" name="Referenced Wedge Number"/>
+        <entry group="300c" element="00d0" keyword="ReferencedCompensatorNumber" vr="IS" vm="1" name="Referenced Compensator Number"/>
+        <entry group="300c" element="00e0" keyword="ReferencedBlockNumber" vr="IS" vm="1" name="Referenced Block Number"/>
+        <entry group="300c" element="00f0" keyword="ReferencedControlPointIndex" vr="IS" vm="1" name="Referenced Control Point Index"/>
+        <entry group="300c" element="00f2" keyword="ReferencedControlPointSequence" vr="SQ" vm="1" name="Referenced Control Point Sequence"/>
+        <entry group="300c" element="00f4" keyword="ReferencedStartControlPointIndex" vr="IS" vm="1" name="Referenced Start Control Point Index"/>
+        <entry group="300c" element="00f6" keyword="ReferencedStopControlPointIndex" vr="IS" vm="1" name="Referenced Stop Control Point Index"/>
+        <entry group="300c" element="0100" keyword="ReferencedRangeShifterNumber" vr="IS" vm="1" name="Referenced Range Shifter Number"/>
+        <entry group="300c" element="0102" keyword="ReferencedLateralSpreadingDeviceNumber" vr="IS" vm="1" name="Referenced Lateral Spreading Device Number"/>
+        <entry group="300c" element="0104" keyword="ReferencedRangeModulatorNumber" vr="IS" vm="1" name="Referenced Range Modulator Number"/>
+        <entry group="300c" element="0111" keyword="OmittedBeamTaskSequence" vr="SQ" vm="1" name="Omitted Beam Task Sequence"/>
+        <entry group="300c" element="0112" keyword="ReasonForOmission" vr="CS" vm="1" name="Reason for Omission"/>
+        <entry group="300c" element="0113" keyword="ReasonForOmissionDescription" vr="LO" vm="1" name="Reason for Omission Description"/>
+        <entry group="300e" element="0002" keyword="ApprovalStatus" vr="CS" vm="1" name="Approval Status"/>
+        <entry group="300e" element="0004" keyword="ReviewDate" vr="DA" vm="1" name="Review Date"/>
+        <entry group="300e" element="0005" keyword="ReviewTime" vr="TM" vm="1" name="Review Time"/>
+        <entry group="300e" element="0008" keyword="ReviewerName" vr="PN" vm="1" name="Reviewer Name"/>
+        <entry group="4000" element="0010" keyword="Arbitrary" vr="LT" vm="1" retired="true" name="Arbitrary"/>
+        <entry group="4000" element="4000" keyword="TextComments" vr="LT" vm="1" retired="true" name="Text Comments"/>
+        <entry group="4008" element="0040" keyword="ResultsID" vr="SH" vm="1" retired="true" name="Results ID"/>
+        <entry group="4008" element="0042" keyword="ResultsIDIssuer" vr="LO" vm="1" retired="true" name="Results ID Issuer"/>
+        <entry group="4008" element="0050" keyword="ReferencedInterpretationSequence" vr="SQ" vm="1" retired="true" name="Referenced Interpretation Sequence"/>
+        <entry group="4008" element="00ff" keyword="ReportProductionStatusTrial" vr="CS" vm="1" retired="true" name="Report Production Status (Trial)"/>
+        <entry group="4008" element="0100" keyword="InterpretationRecordedDate" vr="DA" vm="1" retired="true" name="Interpretation Recorded Date"/>
+        <entry group="4008" element="0101" keyword="InterpretationRecordedTime" vr="TM" vm="1" retired="true" name="Interpretation Recorded Time"/>
+        <entry group="4008" element="0102" keyword="InterpretationRecorder" vr="PN" vm="1" retired="true" name="Interpretation Recorder"/>
+        <entry group="4008" element="0103" keyword="ReferenceToRecordedSound" vr="LO" vm="1" retired="true" name="Reference to Recorded Sound"/>
+        <entry group="4008" element="0108" keyword="InterpretationTranscriptionDate" vr="DA" vm="1" retired="true" name="Interpretation Transcription Date"/>
+        <entry group="4008" element="0109" keyword="InterpretationTranscriptionTime" vr="TM" vm="1" retired="true" name="Interpretation Transcription Time"/>
+        <entry group="4008" element="010a" keyword="InterpretationTranscriber" vr="PN" vm="1" retired="true" name="Interpretation Transcriber"/>
+        <entry group="4008" element="010b" keyword="InterpretationText" vr="ST" vm="1" retired="true" name="Interpretation Text"/>
+        <entry group="4008" element="010c" keyword="InterpretationAuthor" vr="PN" vm="1" retired="true" name="Interpretation Author"/>
+        <entry group="4008" element="0111" keyword="InterpretationApproverSequence" vr="SQ" vm="1" retired="true" name="Interpretation Approver Sequence"/>
+        <entry group="4008" element="0112" keyword="InterpretationApprovalDate" vr="DA" vm="1" retired="true" name="Interpretation Approval Date"/>
+        <entry group="4008" element="0113" keyword="InterpretationApprovalTime" vr="TM" vm="1" retired="true" name="Interpretation Approval Time"/>
+        <entry group="4008" element="0114" keyword="PhysicianApprovingInterpretation" vr="PN" vm="1" retired="true" name="Physician Approving Interpretation"/>
+        <entry group="4008" element="0115" keyword="InterpretationDiagnosisDescription" vr="LT" vm="1" retired="true" name="Interpretation Diagnosis Description"/>
+        <entry group="4008" element="0117" keyword="InterpretationDiagnosisCodeSequence" vr="SQ" vm="1" retired="true" name="Interpretation Diagnosis Code Sequence"/>
+        <entry group="4008" element="0118" keyword="ResultsDistributionListSequence" vr="SQ" vm="1" retired="true" name="Results Distribution List Sequence"/>
+        <entry group="4008" element="0119" keyword="DistributionName" vr="PN" vm="1" retired="true" name="Distribution Name"/>
+        <entry group="4008" element="011a" keyword="DistributionAddress" vr="LO" vm="1" retired="true" name="Distribution Address"/>
+        <entry group="4008" element="0200" keyword="InterpretationID" vr="SH" vm="1" retired="true" name="Interpretation ID"/>
+        <entry group="4008" element="0202" keyword="InterpretationIDIssuer" vr="LO" vm="1" retired="true" name="Interpretation ID Issuer"/>
+        <entry group="4008" element="0210" keyword="InterpretationTypeID" vr="CS" vm="1" retired="true" name="Interpretation Type ID"/>
+        <entry group="4008" element="0212" keyword="InterpretationStatusID" vr="CS" vm="1" retired="true" name="Interpretation Status ID"/>
+        <entry group="4008" element="0300" keyword="Impressions" vr="ST" vm="1" retired="true" name="Impressions"/>
+        <entry group="4008" element="4000" keyword="ResultsComments" vr="ST" vm="1" retired="true" name="Results Comments"/>
+        <entry group="4010" element="0001" keyword="LowEnergyDetectors" vr="CS" vm="1" name="Low Energy Detectors"/>
+        <entry group="4010" element="0002" keyword="HighEnergyDetectors" vr="CS" vm="1" name="High Energy Detectors"/>
+        <entry group="4010" element="0004" keyword="DetectorGeometrySequence" vr="SQ" vm="1" name="Detector Geometry Sequence"/>
+        <entry group="4010" element="1001" keyword="ThreatROIVoxelSequence" vr="SQ" vm="1" name="Threat ROI Voxel Sequence"/>
+        <entry group="4010" element="1004" keyword="ThreatROIBase" vr="FL" vm="3" name="Threat ROI Base"/>
+        <entry group="4010" element="1005" keyword="ThreatROIExtents" vr="FL" vm="3" name="Threat ROI Extents"/>
+        <entry group="4010" element="1006" keyword="ThreatROIBitmap" vr="OB" vm="1" name="Threat ROI Bitmap"/>
+        <entry group="4010" element="1007" keyword="RouteSegmentID" vr="SH" vm="1" name="Route Segment ID"/>
+        <entry group="4010" element="1008" keyword="GantryType" vr="CS" vm="1" name="Gantry Type"/>
+        <entry group="4010" element="1009" keyword="OOIOwnerType" vr="CS" vm="1" name="OOI Owner Type"/>
+        <entry group="4010" element="100a" keyword="RouteSegmentSequence" vr="SQ" vm="1" name="Route Segment Sequence"/>
+        <entry group="4010" element="1010" keyword="PotentialThreatObjectID" vr="US" vm="1" name="Potential Threat Object ID"/>
+        <entry group="4010" element="1011" keyword="ThreatSequence" vr="SQ" vm="1" name="Threat Sequence"/>
+        <entry group="4010" element="1012" keyword="ThreatCategory" vr="CS" vm="1" name="Threat Category"/>
+        <entry group="4010" element="1013" keyword="ThreatCategoryDescription" vr="LT" vm="1" name="Threat Category Description"/>
+        <entry group="4010" element="1014" keyword="ATDAbilityAssessment" vr="CS" vm="1" name="ATD Ability Assessment"/>
+        <entry group="4010" element="1015" keyword="ATDAssessmentFlag" vr="CS" vm="1" name="ATD Assessment Flag"/>
+        <entry group="4010" element="1016" keyword="ATDAssessmentProbability" vr="FL" vm="1" name="ATD Assessment Probability"/>
+        <entry group="4010" element="1017" keyword="Mass" vr="FL" vm="1" name="Mass"/>
+        <entry group="4010" element="1018" keyword="Density" vr="FL" vm="1" name="Density"/>
+        <entry group="4010" element="1019" keyword="ZEffective" vr="FL" vm="1" name="Z Effective"/>
+        <entry group="4010" element="101a" keyword="BoardingPassID" vr="SH" vm="1" name="Boarding Pass ID"/>
+        <entry group="4010" element="101b" keyword="CenterOfMass" vr="FL" vm="3" name="Center of Mass"/>
+        <entry group="4010" element="101c" keyword="CenterOfPTO" vr="FL" vm="3" name="Center of PTO"/>
+        <entry group="4010" element="101d" keyword="BoundingPolygon" vr="FL" vm="6-n" name="Bounding Polygon"/>
+        <entry group="4010" element="101e" keyword="RouteSegmentStartLocationID" vr="SH" vm="1" name="Route Segment Start Location ID"/>
+        <entry group="4010" element="101f" keyword="RouteSegmentEndLocationID" vr="SH" vm="1" name="Route Segment End Location ID"/>
+        <entry group="4010" element="1020" keyword="RouteSegmentLocationIDType" vr="CS" vm="1" name="Route Segment Location ID Type"/>
+        <entry group="4010" element="1021" keyword="AbortReason" vr="CS" vm="1-n" name="Abort Reason"/>
+        <entry group="4010" element="1023" keyword="VolumeOfPTO" vr="FL" vm="1" name="Volume of PTO"/>
+        <entry group="4010" element="1024" keyword="AbortFlag" vr="CS" vm="1" name="Abort Flag"/>
+        <entry group="4010" element="1025" keyword="RouteSegmentStartTime" vr="DT" vm="1" name="Route Segment Start Time"/>
+        <entry group="4010" element="1026" keyword="RouteSegmentEndTime" vr="DT" vm="1" name="Route Segment End Time"/>
+        <entry group="4010" element="1027" keyword="TDRType" vr="CS" vm="1" name="TDR Type"/>
+        <entry group="4010" element="1028" keyword="InternationalRouteSegment" vr="CS" vm="1" name="International Route Segment"/>
+        <entry group="4010" element="1029" keyword="ThreatDetectionAlgorithmandVersion" vr="LO" vm="1-n" name="Threat Detection Algorithm and Version"/>
+        <entry group="4010" element="102a" keyword="AssignedLocation" vr="SH" vm="1" name="Assigned Location"/>
+        <entry group="4010" element="102b" keyword="AlarmDecisionTime" vr="DT" vm="1" name="Alarm Decision Time"/>
+        <entry group="4010" element="1031" keyword="AlarmDecision" vr="CS" vm="1" name="Alarm Decision"/>
+        <entry group="4010" element="1033" keyword="NumberOfTotalObjects" vr="US" vm="1" name="Number of Total Objects"/>
+        <entry group="4010" element="1034" keyword="NumberOfAlarmObjects" vr="US" vm="1" name="Number of Alarm Objects"/>
+        <entry group="4010" element="1037" keyword="PTORepresentationSequence" vr="SQ" vm="1" name="PTO Representation Sequence"/>
+        <entry group="4010" element="1038" keyword="ATDAssessmentSequence" vr="SQ" vm="1" name="ATD Assessment Sequence"/>
+        <entry group="4010" element="1039" keyword="TIPType" vr="CS" vm="1" name="TIP Type"/>
+        <entry group="4010" element="103a" keyword="DICOSVersion" vr="CS" vm="1" name="DICOS Version"/>
+        <entry group="4010" element="1041" keyword="OOIOwnerCreationTime" vr="DT" vm="1" name="OOI Owner Creation Time"/>
+        <entry group="4010" element="1042" keyword="OOIType" vr="CS" vm="1" name="OOI Type"/>
+        <entry group="4010" element="1043" keyword="OOISize" vr="FL" vm="3" name="OOI Size"/>
+        <entry group="4010" element="1044" keyword="AcquisitionStatus" vr="CS" vm="1" name="Acquisition Status"/>
+        <entry group="4010" element="1045" keyword="BasisMaterialsCodeSequence" vr="SQ" vm="1" name="Basis Materials Code Sequence"/>
+        <entry group="4010" element="1046" keyword="PhantomType" vr="CS" vm="1" name="Phantom Type"/>
+        <entry group="4010" element="1047" keyword="OOIOwnerSequence" vr="SQ" vm="1" name="OOI Owner Sequence"/>
+        <entry group="4010" element="1048" keyword="ScanType" vr="CS" vm="1" name="Scan Type"/>
+        <entry group="4010" element="1051" keyword="ItineraryID" vr="LO" vm="1" name="Itinerary ID"/>
+        <entry group="4010" element="1052" keyword="ItineraryIDType" vr="SH" vm="1" name="Itinerary ID Type"/>
+        <entry group="4010" element="1053" keyword="ItineraryIDAssigningAuthority" vr="LO" vm="1" name="Itinerary ID Assigning Authority"/>
+        <entry group="4010" element="1054" keyword="RouteID" vr="SH" vm="1" name="Route ID"/>
+        <entry group="4010" element="1055" keyword="RouteIDAssigningAuthority" vr="SH" vm="1" name="Route ID Assigning Authority"/>
+        <entry group="4010" element="1056" keyword="InboundArrivalType" vr="CS" vm="1" name="Inbound Arrival Type"/>
+        <entry group="4010" element="1058" keyword="CarrierID" vr="SH" vm="1" name="Carrier ID"/>
+        <entry group="4010" element="1059" keyword="CarrierIDAssigningAuthority" vr="CS" vm="1" name="Carrier ID Assigning Authority"/>
+        <entry group="4010" element="1060" keyword="SourceOrientation" vr="FL" vm="3" name="Source Orientation"/>
+        <entry group="4010" element="1061" keyword="SourcePosition" vr="FL" vm="3" name="Source Position"/>
+        <entry group="4010" element="1062" keyword="BeltHeight" vr="FL" vm="1" name="Belt Height"/>
+        <entry group="4010" element="1064" keyword="AlgorithmRoutingCodeSequence" vr="SQ" vm="1" name="Algorithm Routing Code Sequence"/>
+        <entry group="4010" element="1067" keyword="TransportClassification" vr="CS" vm="1" name="Transport Classification"/>
+        <entry group="4010" element="1068" keyword="OOITypeDescriptor" vr="LT" vm="1" name="OOI Type Descriptor"/>
+        <entry group="4010" element="1069" keyword="TotalProcessingTime" vr="FL" vm="1" name="Total Processing Time"/>
+        <entry group="4010" element="106c" keyword="DetectorCalibrationData" vr="OB" vm="1" name="Detector Calibration Data"/>
+        <entry group="4010" element="106d" keyword="AdditionalScreeningPerformed" vr="CS" vm="1" name="Additional Screening Performed"/>
+        <entry group="4010" element="106e" keyword="AdditionalInspectionSelectionCriteria" vr="CS" vm="1" name="Additional Inspection Selection Criteria"/>
+        <entry group="4010" element="106f" keyword="AdditionalInspectionMethodSequence" vr="SQ" vm="1" name="Additional Inspection Method Sequence"/>
+        <entry group="4010" element="1070" keyword="AITDeviceType" vr="CS" vm="1" name="AIT Device Type"/>
+        <entry group="4010" element="1071" keyword="QRMeasurementsSequence" vr="SQ" vm="1" name="QR Measurements Sequence"/>
+        <entry group="4010" element="1072" keyword="TargetMaterialSequence" vr="SQ" vm="1" name="Target Material Sequence"/>
+        <entry group="4010" element="1073" keyword="SNRThreshold" vr="FD" vm="1" name="SNR Threshold"/>
+        <entry group="4010" element="1075" keyword="ImageScaleRepresentation" vr="DS" vm="1" name="Image Scale Representation"/>
+        <entry group="4010" element="1076" keyword="ReferencedPTOSequence" vr="SQ" vm="1" name="Referenced PTO Sequence"/>
+        <entry group="4010" element="1077" keyword="ReferencedTDRInstanceSequence" vr="SQ" vm="1" name="Referenced TDR Instance Sequence"/>
+        <entry group="4010" element="1078" keyword="PTOLocationDescription" vr="ST" vm="1" name="PTO Location Description"/>
+        <entry group="4010" element="1079" keyword="AnomalyLocatorIndicatorSequence" vr="SQ" vm="1" name="Anomaly Locator Indicator Sequence"/>
+        <entry group="4010" element="107a" keyword="AnomalyLocatorIndicator" vr="FL" vm="3" name="Anomaly Locator Indicator"/>
+        <entry group="4010" element="107b" keyword="PTORegionSequence" vr="SQ" vm="1" name="PTO Region Sequence"/>
+        <entry group="4010" element="107c" keyword="InspectionSelectionCriteria" vr="CS" vm="1" name="Inspection Selection Criteria"/>
+        <entry group="4010" element="107d" keyword="SecondaryInspectionMethodSequence" vr="SQ" vm="1" name="Secondary Inspection Method Sequence"/>
+        <entry group="4010" element="107e" keyword="PRCSToRCSOrientation" vr="DS" vm="6" name="PRCS to RCS Orientation"/>
+        <entry group="4ffe" element="0001" keyword="MACParametersSequence" vr="SQ" vm="1" name="MAC Parameters Sequence"/>
+        <entry group="50xx" element="0005" keyword="CurveDimensions" vr="US" vm="1" retired="true" name="Curve Dimensions"/>
+        <entry group="50xx" element="0010" keyword="NumberOfPoints" vr="US" vm="1" retired="true" name="Number of Points"/>
+        <entry group="50xx" element="0020" keyword="TypeOfData" vr="CS" vm="1" retired="true" name="Type of Data"/>
+        <entry group="50xx" element="0022" keyword="CurveDescription" vr="LO" vm="1" retired="true" name="Curve Description"/>
+        <entry group="50xx" element="0030" keyword="AxisUnits" vr="SH" vm="1-n" retired="true" name="Axis Units"/>
+        <entry group="50xx" element="0040" keyword="AxisLabels" vr="SH" vm="1-n" retired="true" name="Axis Labels"/>
+        <entry group="50xx" element="0103" keyword="DataValueRepresentation" vr="US" vm="1" retired="true" name="Data Value Representation"/>
+        <entry group="50xx" element="0104" keyword="MinimumCoordinateValue" vr="US" vm="1-n" retired="true" name="Minimum Coordinate Value"/>
+        <entry group="50xx" element="0105" keyword="MaximumCoordinateValue" vr="US" vm="1-n" retired="true" name="Maximum Coordinate Value"/>
+        <entry group="50xx" element="0106" keyword="CurveRange" vr="SH" vm="1-n" retired="true" name="Curve Range"/>
+        <entry group="50xx" element="0110" keyword="CurveDataDescriptor" vr="US" vm="1-n" retired="true" name="Curve Data Descriptor"/>
+        <entry group="50xx" element="0112" keyword="CoordinateStartValue" vr="US" vm="1-n" retired="true" name="Coordinate Start Value"/>
+        <entry group="50xx" element="0114" keyword="CoordinateStepValue" vr="US" vm="1-n" retired="true" name="Coordinate Step Value"/>
+        <entry group="50xx" element="1001" keyword="CurveActivationLayer" vr="CS" vm="1" retired="true" name="Curve Activation Layer"/>
+        <entry group="50xx" element="2000" keyword="AudioType" vr="US" vm="1" retired="true" name="Audio Type"/>
+        <entry group="50xx" element="2002" keyword="AudioSampleFormat" vr="US" vm="1" retired="true" name="Audio Sample Format"/>
+        <entry group="50xx" element="2004" keyword="NumberOfChannels" vr="US" vm="1" retired="true" name="Number of Channels"/>
+        <entry group="50xx" element="2006" keyword="NumberOfSamples" vr="UL" vm="1" retired="true" name="Number of Samples"/>
+        <entry group="50xx" element="2008" keyword="SampleRate" vr="UL" vm="1" retired="true" name="Sample Rate"/>
+        <entry group="50xx" element="200a" keyword="TotalTime" vr="UL" vm="1" retired="true" name="Total Time"/>
+        <entry group="50xx" element="200c" keyword="AudioSampleData" vr="OB_OW" vm="1" retired="true" name="Audio Sample Data"/>
+        <entry group="50xx" element="200e" keyword="AudioComments" vr="LT" vm="1" retired="true" name="Audio Comments"/>
+        <entry group="50xx" element="2500" keyword="CurveLabel" vr="LO" vm="1" retired="true" name="Curve Label"/>
+        <entry group="50xx" element="2600" keyword="CurveReferencedOverlaySequence" vr="SQ" vm="1" retired="true" name="Curve Referenced Overlay Sequence"/>
+        <entry group="50xx" element="2610" keyword="CurveReferencedOverlayGroup" vr="US" vm="1" retired="true" name="Curve Referenced Overlay Group"/>
+        <entry group="50xx" element="3000" keyword="CurveData" vr="OB_OW" vm="1" retired="true" name="Curve Data"/>
+        <entry group="5200" element="9229" keyword="SharedFunctionalGroupsSequence" vr="SQ" vm="1" name="Shared Functional Groups Sequence"/>
+        <entry group="5200" element="9230" keyword="PerFrameFunctionalGroupsSequence" vr="SQ" vm="1" name="Per-frame Functional Groups Sequence"/>
+        <entry group="5400" element="0100" keyword="WaveformSequence" vr="SQ" vm="1" name="Waveform Sequence"/>
+        <entry group="5400" element="0110" keyword="ChannelMinimumValue" vr="OB_OW" vm="1" name="Channel Minimum Value"/>
+        <entry group="5400" element="0112" keyword="ChannelMaximumValue" vr="OB_OW" vm="1" name="Channel Maximum Value"/>
+        <entry group="5400" element="1004" keyword="WaveformBitsAllocated" vr="US" vm="1" name="Waveform Bits Allocated"/>
+        <entry group="5400" element="1006" keyword="WaveformSampleInterpretation" vr="CS" vm="1" name="Waveform Sample Interpretation"/>
+        <entry group="5400" element="100a" keyword="WaveformPaddingValue" vr="OB_OW" vm="1" name="Waveform Padding Value"/>
+        <entry group="5400" element="1010" keyword="WaveformData" vr="OB_OW" vm="1" name="Waveform Data"/>
+        <entry group="5600" element="0010" keyword="FirstOrderPhaseCorrectionAngle" vr="OF" vm="1" name="First Order Phase Correction Angle"/>
+        <entry group="5600" element="0020" keyword="SpectroscopyData" vr="OF" vm="1" name="Spectroscopy Data"/>
+        <entry group="60xx" element="0010" keyword="OverlayRows" vr="US" vm="1" name="Overlay Rows"/>
+        <entry group="60xx" element="0011" keyword="OverlayColumns" vr="US" vm="1" name="Overlay Columns"/>
+        <entry group="60xx" element="0012" keyword="OverlayPlanes" vr="US" vm="1" retired="true" name="Overlay Planes"/>
+        <entry group="60xx" element="0015" keyword="NumberOfFramesInOverlay" vr="IS" vm="1" name="Number of Frames in Overlay"/>
+        <entry group="60xx" element="0022" keyword="OverlayDescription" vr="LO" vm="1" name="Overlay Description"/>
+        <entry group="60xx" element="0040" keyword="OverlayType" vr="CS" vm="1" name="Overlay Type"/>
+        <entry group="60xx" element="0045" keyword="OverlaySubtype" vr="LO" vm="1" name="Overlay Subtype"/>
+        <entry group="60xx" element="0050" keyword="OverlayOrigin" vr="SS" vm="2" name="Overlay Origin"/>
+        <entry group="60xx" element="0051" keyword="ImageFrameOrigin" vr="US" vm="1" name="Image Frame Origin"/>
+        <entry group="60xx" element="0052" keyword="OverlayPlaneOrigin" vr="US" vm="1" retired="true" name="Overlay Plane Origin"/>
+        <entry group="60xx" element="0060" keyword="OverlayCompressionCode" vr="CS" vm="1" retired="true" name="Overlay Compression Code"/>
+        <entry group="60xx" element="0061" keyword="OverlayCompressionOriginator" vr="SH" vm="1" retired="true" name="Overlay Compression Originator"/>
+        <entry group="60xx" element="0062" keyword="OverlayCompressionLabel" vr="SH" vm="1" retired="true" name="Overlay Compression Label"/>
+        <entry group="60xx" element="0063" keyword="OverlayCompressionDescription" vr="CS" vm="1" retired="true" name="Overlay Compression Description"/>
+        <entry group="60xx" element="0066" keyword="OverlayCompressionStepPointers" vr="AT" vm="1-n" retired="true" name="Overlay Compression Step Pointers"/>
+        <entry group="60xx" element="0068" keyword="OverlayRepeatInterval" vr="US" vm="1" retired="true" name="Overlay Repeat Interval"/>
+        <entry group="60xx" element="0069" keyword="OverlayBitsGrouped" vr="US" vm="1" retired="true" name="Overlay Bits Grouped"/>
+        <entry group="60xx" element="0100" keyword="OverlayBitsAllocated" vr="US" vm="1" name="Overlay Bits Allocated"/>
+        <entry group="60xx" element="0102" keyword="OverlayBitPosition" vr="US" vm="1" name="Overlay Bit Position"/>
+        <entry group="60xx" element="0110" keyword="OverlayFormat" vr="CS" vm="1" retired="true" name="Overlay Format"/>
+        <entry group="60xx" element="0200" keyword="OverlayLocation" vr="US" vm="1" retired="true" name="Overlay Location"/>
+        <entry group="60xx" element="0800" keyword="OverlayCodeLabel" vr="CS" vm="1-n" retired="true" name="Overlay Code Label"/>
+        <entry group="60xx" element="0802" keyword="OverlayNumberOfTables" vr="US" vm="1" retired="true" name="Overlay Number of Tables"/>
+        <entry group="60xx" element="0803" keyword="OverlayCodeTableLocation" vr="AT" vm="1-n" retired="true" name="Overlay Code Table Location"/>
+        <entry group="60xx" element="0804" keyword="OverlayBitsForCodeWord" vr="US" vm="1" retired="true" name="Overlay Bits For Code Word"/>
+        <entry group="60xx" element="1001" keyword="OverlayActivationLayer" vr="CS" vm="1" name="Overlay Activation Layer"/>
+        <entry group="60xx" element="1100" keyword="OverlayDescriptorGray" vr="US" vm="1" retired="true" name="Overlay Descriptor - Gray"/>
+        <entry group="60xx" element="1101" keyword="OverlayDescriptorRed" vr="US" vm="1" retired="true" name="Overlay Descriptor - Red"/>
+        <entry group="60xx" element="1102" keyword="OverlayDescriptorGreen" vr="US" vm="1" retired="true" name="Overlay Descriptor - Green"/>
+        <entry group="60xx" element="1103" keyword="OverlayDescriptorBlue" vr="US" vm="1" retired="true" name="Overlay Descriptor - Blue"/>
+        <entry group="60xx" element="1200" keyword="OverlaysGray" vr="US" vm="1-n" retired="true" name="Overlays - Gray"/>
+        <entry group="60xx" element="1201" keyword="OverlaysRed" vr="US" vm="1-n" retired="true" name="Overlays - Red"/>
+        <entry group="60xx" element="1202" keyword="OverlaysGreen" vr="US" vm="1-n" retired="true" name="Overlays - Green"/>
+        <entry group="60xx" element="1203" keyword="OverlaysBlue" vr="US" vm="1-n" retired="true" name="Overlays - Blue"/>
+        <entry group="60xx" element="1301" keyword="ROIArea" vr="IS" vm="1" name="ROI Area"/>
+        <entry group="60xx" element="1302" keyword="ROIMean" vr="DS" vm="1" name="ROI Mean"/>
+        <entry group="60xx" element="1303" keyword="ROIStandardDeviation" vr="DS" vm="1" name="ROI Standard Deviation"/>
+        <entry group="60xx" element="1500" keyword="OverlayLabel" vr="LO" vm="1" name="Overlay Label"/>
+        <entry group="60xx" element="3000" keyword="OverlayData" vr="OB_OW" vm="1" name="Overlay Data"/>
+        <entry group="60xx" element="4000" keyword="OverlayComments" vr="LT" vm="1" retired="true" name="Overlay Comments"/>
+        <entry group="7fe0" element="0008" keyword="FloatPixelData" vr="OF" vm="1" name="Float Pixel Data"/>
+        <entry group="7fe0" element="0009" keyword="DoubleFloatPixelData" vr="OD" vm="1" name="Double Float Pixel Data"/>
+        <entry group="7fe0" element="0010" keyword="PixelData" vr="OB_OW" vm="1" name="Pixel Data"/>
+        <entry group="7fe0" element="0020" keyword="CoefficientsSDVN" vr="OW" vm="1" retired="true" name="Coefficients SDVN"/>
+        <entry group="7fe0" element="0030" keyword="CoefficientsSDHN" vr="OW" vm="1" retired="true" name="Coefficients SDHN"/>
+        <entry group="7fe0" element="0040" keyword="CoefficientsSDDN" vr="OW" vm="1" retired="true" name="Coefficients SDDN"/>
+        <entry group="7fxx" element="0010" keyword="VariablePixelData" vr="OB_OW" vm="1" retired="true" name="Variable Pixel Data"/>
+        <entry group="7fxx" element="0011" keyword="VariableNextDataGroup" vr="US" vm="1" retired="true" name="Variable Next Data Group"/>
+        <entry group="7fxx" element="0020" keyword="VariableCoefficientsSDVN" vr="OW" vm="1" retired="true" name="Variable Coefficients SDVN"/>
+        <entry group="7fxx" element="0030" keyword="VariableCoefficientsSDHN" vr="OW" vm="1" retired="true" name="Variable Coefficients SDHN"/>
+        <entry group="7fxx" element="0040" keyword="VariableCoefficientsSDDN" vr="OW" vm="1" retired="true" name="Variable Coefficients SDDN"/>
+        <entry group="fffa" element="fffa" keyword="DigitalSignaturesSequence" vr="SQ" vm="1" name="Digital Signatures Sequence"/>
+        <entry group="fffc" element="fffc" keyword="DataSetTrailingPadding" vr="OB" vm="1" name="Data Set Trailing Padding"/>
+        <entry group="fffe" element="e000" keyword="Item" vr="" vm="1" name="Item"/>
+        <entry group="fffe" element="e00d" keyword="ItemDelimitationItem" vr="" vm="1" name="Item Delimitation Item"/>
+        <entry group="fffe" element="e0dd" keyword="SequenceDelimitationItem" vr="" vm="1" name="Sequence Delimitation Item"/>
+      </dict>
+<dict ref="7" name="Registry of DICOM File Meta Elements">
+        <entry group="0002" element="0000" keyword="FileMetaInformationGroupLength" vr="UL" vm="1" name="File Meta Information Group Length"/>
+        <entry group="0002" element="0001" keyword="FileMetaInformationVersion" vr="OB" vm="1" name="File Meta Information Version"/>
+        <entry group="0002" element="0002" keyword="MediaStorageSOPClassUID" vr="UI" vm="1" name="Media Storage SOP Class UID"/>
+        <entry group="0002" element="0003" keyword="MediaStorageSOPInstanceUID" vr="UI" vm="1" name="Media Storage SOP Instance UID"/>
+        <entry group="0002" element="0010" keyword="TransferSyntaxUID" vr="UI" vm="1" name="Transfer Syntax UID"/>
+        <entry group="0002" element="0012" keyword="ImplementationClassUID" vr="UI" vm="1" name="Implementation Class UID"/>
+        <entry group="0002" element="0013" keyword="ImplementationVersionName" vr="SH" vm="1" name="Implementation Version Name"/>
+        <entry group="0002" element="0016" keyword="SourceApplicationEntityTitle" vr="AE" vm="1" name="Source Application Entity Title"/>
+        <entry group="0002" element="0017" keyword="SendingApplicationEntityTitle" vr="AE" vm="1" name="Sending Application Entity Title"/>
+        <entry group="0002" element="0018" keyword="ReceivingApplicationEntityTitle" vr="AE" vm="1" name="Receiving Application Entity Title"/>
+        <entry group="0002" element="0100" keyword="PrivateInformationCreatorUID" vr="UI" vm="1" name="Private Information Creator UID"/>
+        <entry group="0002" element="0102" keyword="PrivateInformation" vr="OB" vm="1" name="Private Information"/>
+      </dict>
+<dict ref="8" name="Registry of DICOM Directory Structuring Elements">
+        <entry group="0004" element="1130" keyword="FileSetID" vr="CS" vm="1" name="File-set ID"/>
+        <entry group="0004" element="1141" keyword="FileSetDescriptorFileID" vr="CS" vm="1-8" name="File-set Descriptor File ID"/>
+        <entry group="0004" element="1142" keyword="SpecificCharacterSetOfFileSetDescriptorFile" vr="CS" vm="1" name="Specific Character Set of File-set Descriptor File"/>
+        <entry group="0004" element="1200" keyword="OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity" vr="UL" vm="1" name="Offset of the First Directory Record of the Root Directory Entity"/>
+        <entry group="0004" element="1202" keyword="OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity" vr="UL" vm="1" name="Offset of the Last Directory Record of the Root Directory Entity"/>
+        <entry group="0004" element="1212" keyword="FileSetConsistencyFlag" vr="US" vm="1" name="File-set Consistency Flag"/>
+        <entry group="0004" element="1220" keyword="DirectoryRecordSequence" vr="SQ" vm="1" name="Directory Record Sequence"/>
+        <entry group="0004" element="1400" keyword="OffsetOfTheNextDirectoryRecord" vr="UL" vm="1" name="Offset of the Next Directory Record"/>
+        <entry group="0004" element="1410" keyword="RecordInUseFlag" vr="US" vm="1" name="Record In-use Flag"/>
+        <entry group="0004" element="1420" keyword="OffsetOfReferencedLowerLevelDirectoryEntity" vr="UL" vm="1" name="Offset of Referenced Lower-Level Directory Entity"/>
+        <entry group="0004" element="1430" keyword="DirectoryRecordType" vr="CS" vm="1" name="Directory Record Type"/>
+        <entry group="0004" element="1432" keyword="PrivateRecordUID" vr="UI" vm="1" name="Private Record UID"/>
+        <entry group="0004" element="1500" keyword="ReferencedFileID" vr="CS" vm="1-8" name="Referenced File ID"/>
+        <entry group="0004" element="1504" keyword="MRDRDirectoryRecordOffset" vr="UL" vm="1" retired="true" name="MRDR Directory Record Offset"/>
+        <entry group="0004" element="1510" keyword="ReferencedSOPClassUIDInFile" vr="UI" vm="1" name="Referenced SOP Class UID in File"/>
+        <entry group="0004" element="1511" keyword="ReferencedSOPInstanceUIDInFile" vr="UI" vm="1" name="Referenced SOP Instance UID in File"/>
+        <entry group="0004" element="1512" keyword="ReferencedTransferSyntaxUIDInFile" vr="UI" vm="1" name="Referenced Transfer Syntax UID in File"/>
+        <entry group="0004" element="151a" keyword="ReferencedRelatedGeneralSOPClassUIDInFile" vr="UI" vm="1-n" name="Referenced Related General SOP Class UID in File"/>
+        <entry group="0004" element="1600" keyword="NumberOfReferences" vr="UL" vm="1" retired="true" name="Number of References"/>
+      </dict>
+<table ref="Table A-1" name="UID Values">
+        <uid value="1.2.840.10008.1.1" name="Verification SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.1.2" name="Implicit VR Little Endian: Default Transfer Syntax for DICOM" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.1" name="Explicit VR Little Endian" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.1.99" name="Deflated Explicit VR Little Endian" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.2" name="Explicit VR Big Endian" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.50" name="JPEG Baseline (Process 1): Default Transfer Syntax for Lossy JPEG 8 Bit Image Compression" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.51" name="JPEG Extended (Process 2 & 4): Default Transfer Syntax for Lossy JPEG 12 Bit Image Compression (Process 4 only)" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.52" name="JPEG Extended (Process 3 & 5)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.53" name="JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.54" name="JPEG Spectral Selection, Non-Hierarchical (Process 7 & 9)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.55" name="JPEG Full Progression, Non-Hierarchical (Process 10 & 12)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.56" name="JPEG Full Progression, Non-Hierarchical (Process 11 & 13)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.57" name="JPEG Lossless, Non-Hierarchical (Process 14)" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.58" name="JPEG Lossless, Non-Hierarchical (Process 15)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.59" name="JPEG Extended, Hierarchical (Process 16 & 18)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.60" name="JPEG Extended, Hierarchical (Process 17 & 19)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.61" name="JPEG Spectral Selection, Hierarchical (Process 20 & 22)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.62" name="JPEG Spectral Selection, Hierarchical (Process 21 & 23)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.63" name="JPEG Full Progression, Hierarchical (Process 24 & 26)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.64" name="JPEG Full Progression, Hierarchical (Process 25 & 27)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.65" name="JPEG Lossless, Hierarchical (Process 28)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.66" name="JPEG Lossless, Hierarchical (Process 29)" type="Transfer Syntax" part="PS3.5" retired="true"/>
+        <uid value="1.2.840.10008.1.2.4.70" name="JPEG Lossless, Non-Hierarchical, First-Order Prediction (Process 14 [Selection Value 1]): Default Transfer Syntax for Lossless JPEG Image Compression" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.80" name="JPEG-LS Lossless Image Compression" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.81" name="JPEG-LS Lossy (Near-Lossless) Image Compression" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.90" name="JPEG 2000 Image Compression (Lossless Only)" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.91" name="JPEG 2000 Image Compression" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.92" name="JPEG 2000 Part 2 Multi-component Image Compression (Lossless Only)" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.93" name="JPEG 2000 Part 2 Multi-component Image Compression" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.94" name="JPIP Referenced" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.95" name="JPIP Referenced Deflate" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.100" name="MPEG2 Main Profile / Main Level" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.101" name="MPEG2 Main Profile / High Level" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.102" name="MPEG-4 AVC/H.264 High Profile / Level 4.1" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.103" name="MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.104" name="MPEG-4 AVC/H.264 High Profile / Level 4.2 For 2D Video" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.105" name="MPEG-4 AVC/H.264 High Profile / Level 4.2 For 3D Video" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.106" name="MPEG-4 AVC/H.264 Stereo High Profile / Level 4.2" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.107" name="HEVC/H.265 Main Profile / Level 5.1" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.4.108" name="HEVC/H.265 Main 10 Profile / Level 5.1" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.5" name="RLE Lossless" type="Transfer Syntax" part="PS3.5" retired="false"/>
+        <uid value="1.2.840.10008.1.2.6.1" name="RFC 2557 MIME encapsulation" type="Transfer Syntax" part="PS3.10" retired="false"/>
+        <uid value="1.2.840.10008.1.2.6.2" name="XML Encoding" type="Transfer Syntax" part="PS3.10" retired="false"/>
+        <uid value="1.2.840.10008.1.3.10" name="Media Storage Directory Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.1" name="Talairach Brain Atlas Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.2" name="SPM2 T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.3" name="SPM2 T2 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.4" name="SPM2 PD Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.5" name="SPM2 EPI Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.6" name="SPM2 FIL T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.7" name="SPM2 PET Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.8" name="SPM2 TRANSM Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.9" name="SPM2 SPECT Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.10" name="SPM2 GRAY Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.11" name="SPM2 WHITE Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.12" name="SPM2 CSF Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.13" name="SPM2 BRAINMASK Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.14" name="SPM2 AVG305T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.15" name="SPM2 AVG152T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.16" name="SPM2 AVG152T2 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.17" name="SPM2 AVG152PD Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.1.18" name="SPM2 SINGLESUBJT1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.2.1" name="ICBM 452 T1 Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.4.2.2" name="ICBM Single Subject MRI Frame of Reference" type="Well-known frame of reference" part="" retired="false"/>
+        <uid value="1.2.840.10008.1.5.1" name="Hot Iron Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.1.5.2" name="PET Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.1.5.3" name="Hot Metal Blue Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.1.5.4" name="PET 20 Step Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.1.5.5" name="Spring Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>        <uid value="1.2.840.10008.1.5.6" name="Summer Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.1.5.7" name="Fall Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.1.5.8" name="Winter Color Palette SOP Instance" type="Well-known SOP Instance" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.1.9" name="Basic Study Content Notification SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.1.20" name="Papyrus 3 Implicit VR Little Endian" type="Transfer Syntax" part="" retired="true"/>
+        <uid value="1.2.840.10008.1.20.1" name="Storage Commitment Push Model SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.1.20.1.1" name="Storage Commitment Push Model SOP Instance" type="Well-known SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.1.20.2" name="Storage Commitment Pull Model SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.1.20.2.1" name="Storage Commitment Pull Model SOP Instance" type="Well-known SOP Instance" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.1.40" name="Procedural Event Logging SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.1.40.1" name="Procedural Event Logging SOP Instance" type="Well-known SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.1.42" name="Substance Administration Logging SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.1.42.1" name="Substance Administration Logging SOP Instance" type="Well-known SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.2.6.1" name="DICOM UID Registry" type="DICOM UIDs as a Coding Scheme" part="PS 3.6" retired="false"/>
+        <uid value="1.2.840.10008.2.16.4" name="DICOM Controlled Terminology" type="Coding Scheme" part="PS3.16" retired="false"/>
+        <uid value="1.2.840.10008.2.16.5" name="Adult Mouse Anatomy Ontology" type="Coding Scheme" part="PS3.16" retired="false"/>
+        <uid value="1.2.840.10008.2.16.6" name="Uberon Ontology" type="Coding Scheme" part="PS3.16" retired="false"/>
+        <uid value="1.2.840.10008.2.16.7" name="Integrated Taxonomic Information System (ITIS) Taxonomic Serial Number (TSN)" type="Coding Scheme" part="PS3.16" retired="false"/>
+        <uid value="1.2.840.10008.2.16.8" name="Mouse Genome Initiative (MGI)" type="Coding Scheme" part="PS3.16" retired="false"/>
+        <uid value="1.2.840.10008.2.16.9" name="PubChem Compound CID" type="Coding Scheme" part="PS3.16" retired="false"/>
+        <uid value="1.2.840.10008.3.1.1.1" name="DICOM Application Context Name" type="Application Context Name" part="PS3.7" retired="false"/>
+        <uid value="1.2.840.10008.3.1.2.1.1" name="Detached Patient Management SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.1.4" name="Detached Patient Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.2.1" name="Detached Visit Management SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.3.1" name="Detached Study Management SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.3.2" name="Study Component Management SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.3.3" name="Modality Performed Procedure Step SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.3.1.2.3.4" name="Modality Performed Procedure Step Retrieve SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.3.1.2.3.5" name="Modality Performed Procedure Step Notification SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.3.1.2.5.1" name="Detached Results Management SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.5.4" name="Detached Results Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.5.5" name="Detached Study Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.3.1.2.6.1" name="Detached Interpretation Management SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.4.2" name="Storage Service Class" type="Service Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.1" name="Basic Film Session SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.2" name="Basic Film Box SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.4" name="Basic Grayscale Image Box SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.4.1" name="Basic Color Image Box SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.4.2" name="Referenced Image Box SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.9" name="Basic Grayscale Print Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.9.1" name="Referenced Grayscale Print Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.14" name="Print Job SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.15" name="Basic Annotation Box SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.16" name="Printer SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.16.376" name="Printer Configuration Retrieval SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.17" name="Printer SOP Instance" type="Well-known Printer SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.17.376" name="Printer Configuration Retrieval SOP Instance" type="Well-known Printer SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.18" name="Basic Color Print Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.18.1" name="Referenced Color Print Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.22" name="VOI LUT Box SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.23" name="Presentation LUT SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.24" name="Image Overlay Box SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.24.1" name="Basic Print Image Overlay Box SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.25" name="Print Queue SOP Instance" type="Well-known Print Queue SOP Instance" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.26" name="Print Queue Management SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.27" name="Stored Print Storage SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.29" name="Hardcopy Grayscale Image Storage SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.30" name="Hardcopy Color Image Storage SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.31" name="Pull Print Request SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.32" name="Pull Stored Print Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.1.33" name="Media Creation Management SOP Class UID" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.40" name="Display System SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.1.40.1" name="Display System SOP Instance" type="Well-known SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.1" name="Computed Radiography Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.1.1" name="Digital X-Ray Image Storage - For Presentation" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.1.1.1" name="Digital X-Ray Image Storage - For Processing" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.1.2" name="Digital Mammography X-Ray Image Storage - For Presentation" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.1.2.1" name="Digital Mammography X-Ray Image Storage - For Processing" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.1.3" name="Digital Intra-Oral X-Ray Image Storage - For Presentation" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.1.3.1" name="Digital Intra-Oral X-Ray Image Storage - For Processing" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.2" name="CT Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.2.1" name="Enhanced CT Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.2.2" name="Legacy Converted Enhanced CT Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.3" name="Ultrasound Multi-frame Image Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.3.1" name="Ultrasound Multi-frame Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.4" name="MR Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.4.1" name="Enhanced MR Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.4.2" name="MR Spectroscopy Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.4.3" name="Enhanced MR Color Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.4.4" name="Legacy Converted Enhanced MR Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.5" name="Nuclear Medicine Image Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.6" name="Ultrasound Image Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.6.1" name="Ultrasound Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.6.2" name="Enhanced US Volume Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.7" name="Secondary Capture Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.7.1" name="Multi-frame Single Bit Secondary Capture Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.7.2" name="Multi-frame Grayscale Byte Secondary Capture Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.7.3" name="Multi-frame Grayscale Word Secondary Capture Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.7.4" name="Multi-frame True Color Secondary Capture Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.8" name="Standalone Overlay Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9" name="Standalone Curve Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.1" name="Waveform Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.1.1" name="12-lead ECG Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.1.2" name="General ECG Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.1.3" name="Ambulatory ECG Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.2.1" name="Hemodynamic Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.3.1" name="Cardiac Electrophysiology Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.4.1" name="Basic Voice Audio Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.4.2" name="General Audio Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.5.1" name="Arterial Pulse Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.9.6.1" name="Respiratory Waveform Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.10" name="Standalone Modality LUT Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11" name="Standalone VOI LUT Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11.1" name="Grayscale Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11.2" name="Color Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11.3" name="Pseudo-Color Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11.4" name="Blending Softcopy Presentation State Storage SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11.5" name="XA/XRF Grayscale Softcopy Presentation State Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11.6" name="Grayscale Planar MPR Volumetric Presentation State Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.11.7" name="Compositing Planar MPR Volumetric Presentation State Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.12.1" name="X-Ray Angiographic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.12.1.1" name="Enhanced XA Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.12.2" name="X-Ray Radiofluoroscopic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.12.2.1" name="Enhanced XRF Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.12.3" name="X-Ray Angiographic Bi-Plane Image Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.12.77" name="" type="SOP Class" part="" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.13.1.1" name="X-Ray 3D Angiographic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.13.1.2" name="X-Ray 3D Craniofacial Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.13.1.3" name="Breast Tomosynthesis Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        
+        <uid value="1.2.840.10008.5.1.4.1.1.13.1.4" name="Breast Projection X-Ray Image Storage - For Presentation" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.13.1.5" name="Breast Projection X-Ray Image Storage - For Processing" type="SOP Class" part="PS3.4" retired="false"/>
+        
+        
+        <uid value="1.2.840.10008.5.1.4.1.1.14.1" name="Intravascular Optical Coherence Tomography Image Storage - For Presentation" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.14.2" name="Intravascular Optical Coherence Tomography Image Storage - For Processing" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.20" name="Nuclear Medicine Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.30" name="Parametric Map Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.40" name="" type="SOP Class" part="" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.66" name="Raw Data Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.66.1" name="Spatial Registration Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.66.2" name="Spatial Fiducials Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.66.3" name="Deformable Spatial Registration Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.66.4" name="Segmentation Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.66.5" name="Surface Segmentation Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.66.6" name="Tractography Results Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.67" name="Real World Value Mapping Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.68.1" name="Surface Scan Mesh Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.68.2" name="Surface Scan Point Cloud Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1" name="VL Image Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.2" name="VL Multi-frame Image Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.1" name="VL Endoscopic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.1.1" name="Video Endoscopic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.2" name="VL Microscopic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.2.1" name="Video Microscopic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.3" name="VL Slide-Coordinates Microscopic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.4" name="VL Photographic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.4.1" name="Video Photographic Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.1" name="Ophthalmic Photography 8 Bit Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.2" name="Ophthalmic Photography 16 Bit Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.3" name="Stereometric Relationship Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.4" name="Ophthalmic Tomography Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.5" name="Wide Field Ophthalmic Photography Stereographic Projection Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.5.6" name="Wide Field Ophthalmic Photography 3D Coordinates Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.77.1.6" name="VL Whole Slide Microscopy Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.1" name="Lensometry Measurements Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.2" name="Autorefraction Measurements Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.3" name="Keratometry Measurements Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.4" name="Subjective Refraction Measurements Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.5" name="Visual Acuity Measurements Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.6" name="Spectacle Prescription Report Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.7" name="Ophthalmic Axial Measurements Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.78.8" name="Intraocular Lens Calculations Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.79.1" name="Macular Grid Thickness and Volume Report Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.80.1" name="Ophthalmic Visual Field Static Perimetry Measurements Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.81.1" name="Ophthalmic Thickness Map Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.82.1" name="Corneal Topography Map Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.1" name="Text SR Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.2" name="Audio SR Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.3" name="Detail SR Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.4" name="Comprehensive SR Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.11" name="Basic Text SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.22" name="Enhanced SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.33" name="Comprehensive SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.34" name="Comprehensive 3D SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.35" name="Extensible SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.40" name="Procedure Log Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.50" name="Mammography CAD SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.59" name="Key Object Selection Document Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.65" name="Chest CAD SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.67" name="X-Ray Radiation Dose SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.68" name="Radiopharmaceutical Radiation Dose SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.69" name="Colon CAD SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.70" name="Implantation Plan SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.71" name="Acquisition Context SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.88.72" name="Simplified Adult Echo SR Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.90.1" name="Content Assessment Results Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.104.1" name="Encapsulated PDF Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.104.2" name="Encapsulated CDA Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.128" name="Positron Emission Tomography Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.128.1" name="Legacy Converted Enhanced PET Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.129" name="Standalone PET Curve Storage" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.130" name="Enhanced PET Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.131" name="Basic Structured Display Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.200.1" name="CT Defined Procedure Protocol Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.200.2" name="CT Performed Procedure Protocol Storage" type="SOP Class" part="PS3.4" retired="false"/>     
+        <uid value="1.2.840.10008.5.1.4.1.1.481.1" name="RT Image Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.2" name="RT Dose Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.3" name="RT Structure Set Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.4" name="RT Beams Treatment Record Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.5" name="RT Plan Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.6" name="RT Brachy Treatment Record Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.7" name="RT Treatment Summary Record Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.8" name="RT Ion Plan Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.481.9" name="RT Ion Beams Treatment Record Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.501.1" name="DICOS CT Image Storage" type="SOP Class" part="DICOS" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.501.2.1" name="DICOS Digital X-Ray Image Storage - For Presentation" type="SOP Class" part="DICOS" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.501.2.2" name="DICOS Digital X-Ray Image Storage - For Processing" type="SOP Class" part="DICOS" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.501.3" name="DICOS Threat Detection Report Storage" type="SOP Class" part="DICOS" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.501.4" name="DICOS 2D AIT Storage" type="SOP Class" part="DICOS" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.501.5" name="DICOS 3D AIT Storage" type="SOP Class" part="DICOS" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.501.6" name="DICOS Quadrupole Resonance (QR) Storage" type="SOP Class" part="DICOS" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.601.1" name="Eddy Current Image Storage" type="SOP Class" part="DICONDE ASTM E2934" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.1.601.2" name="Eddy Current Multi-frame Image Storage" type="SOP Class" part="DICONDE ASTM E2934" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.1.1" name="Patient Root Query/Retrieve Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.1.2" name="Patient Root Query/Retrieve Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.1.3" name="Patient Root Query/Retrieve Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.2.1" name="Study Root Query/Retrieve Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.2.2" name="Study Root Query/Retrieve Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.2.3" name="Study Root Query/Retrieve Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.3.1" name="Patient/Study Only Query/Retrieve Information Model - FIND" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.3.2" name="Patient/Study Only Query/Retrieve Information Model - MOVE" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.3.3" name="Patient/Study Only Query/Retrieve Information Model - GET" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.4.2" name="Composite Instance Root Retrieve - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.4.3" name="Composite Instance Root Retrieve - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.1.2.5.3" name="Composite Instance Retrieve Without Bulk Data - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.20.1" name="Defined Procedure Protocol Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.20.2" name="Defined Procedure Protocol Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.20.3" name="Defined Procedure Protocol Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.31" name="Modality Worklist Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.32" name="General Purpose Worklist Management Meta SOP Class" type="Meta SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.32.1" name="General Purpose Worklist Information Model - FIND" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.32.2" name="General Purpose Scheduled Procedure Step SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.32.3" name="General Purpose Performed Procedure Step SOP Class" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.33" name="Instance Availability Notification SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.1" name="RT Beams Delivery Instruction Storage - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.2" name="RT Conventional Machine Verification - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.3" name="RT Ion Machine Verification - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.4" name="Unified Worklist and Procedure Step Service Class - Trial" type="Service Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.4.1" name="Unified Procedure Step - Push SOP Class - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.4.2" name="Unified Procedure Step - Watch SOP Class - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.4.3" name="Unified Procedure Step - Pull SOP Class - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.4.4" name="Unified Procedure Step - Event SOP Class - Trial" type="SOP Class" part="PS3.4" retired="true"/>
+        <uid value="1.2.840.10008.5.1.4.34.5" name="UPS Global Subscription SOP Instance" type="Well-known SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.5.1" name="UPS Filtered Global Subscription SOP Instance" type="Well-known SOP Instance" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.6" name="Unified Worklist and Procedure Step Service Class" type="Service Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.6.1" name="Unified Procedure Step - Push SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.6.2" name="Unified Procedure Step - Watch SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.6.3" name="Unified Procedure Step - Pull SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.6.4" name="Unified Procedure Step - Event SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.7" name="RT Beams Delivery Instruction Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.8" name="RT Conventional Machine Verification" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.9" name="RT Ion Machine Verification" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.34.10" name="RT Brachy Application Setup Delivery Instruction Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.37.1" name="General Relevant Patient Information Query" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.37.2" name="Breast Imaging Relevant Patient Information Query" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.37.3" name="Cardiac Relevant Patient Information Query" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.38.1" name="Hanging Protocol Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.38.2" name="Hanging Protocol Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.38.3" name="Hanging Protocol Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.38.4" name="Hanging Protocol Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.39.1" name="Color Palette Storage" type="Transfer" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.39.2" name="Color Palette Query/Retrieve Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.39.3" name="Color Palette Query/Retrieve Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.39.4" name="Color Palette Query/Retrieve Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.41" name="Product Characteristics Query SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.42" name="Substance Approval Query SOP Class" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.43.1" name="Generic Implant Template Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.43.2" name="Generic Implant Template Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.43.3" name="Generic Implant Template Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.43.4" name="Generic Implant Template Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.44.1" name="Implant Assembly Template Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.44.2" name="Implant Assembly Template Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.44.3" name="Implant Assembly Template Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.44.4" name="Implant Assembly Template Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.45.1" name="Implant Template Group Storage" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.45.2" name="Implant Template Group Information Model - FIND" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.45.3" name="Implant Template Group Information Model - MOVE" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.5.1.4.45.4" name="Implant Template Group Information Model - GET" type="SOP Class" part="PS3.4" retired="false"/>
+        <uid value="1.2.840.10008.7.1.1" name="Native DICOM Model" type="Application Hosting Model" part="PS3.19" retired="false"/>
+        <uid value="1.2.840.10008.7.1.2" name="Abstract Multi-Dimensional Image Model" type="Application Hosting Model" part="PS3.19" retired="false"/>
+        <uid value="1.2.840.10008.8.1.1" name="DICOM Content Mapping Resource" type="Mapping Resource" part="PS3.16" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.1" name="dicomDeviceName" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.2" name="dicomDescription" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.3" name="dicomManufacturer" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.4" name="dicomManufacturerModelName" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.5" name="dicomSoftwareVersion" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.6" name="dicomVendorData" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.7" name="dicomAETitle" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.8" name="dicomNetworkConnectionReference" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.9" name="dicomApplicationCluster" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.10" name="dicomAssociationInitiator" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.11" name="dicomAssociationAcceptor" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.12" name="dicomHostname" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.13" name="dicomPort" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.14" name="dicomSOPClass" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.15" name="dicomTransferRole" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.16" name="dicomTransferSyntax" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.17" name="dicomPrimaryDeviceType" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.18" name="dicomRelatedDeviceReference" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.19" name="dicomPreferredCalledAETitle" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.20" name="dicomTLSCyphersuite" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.21" name="dicomAuthorizedNodeCertificateReference" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.22" name="dicomThisNodeCertificateReference" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.23" name="dicomInstalled" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.24" name="dicomStationName" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.25" name="dicomDeviceSerialNumber" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.26" name="dicomInstitutionName" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.27" name="dicomInstitutionAddress" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.28" name="dicomInstitutionDepartmentName" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.29" name="dicomIssuerOfPatientID" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.30" name="dicomPreferredCallingAETitle" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.3.31" name="dicomSupportedCharacterSet" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.1" name="dicomConfigurationRoot" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.2" name="dicomDevicesRoot" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.3" name="dicomUniqueAETitlesRegistryRoot" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.4" name="dicomDevice" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.5" name="dicomNetworkAE" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.6" name="dicomNetworkConnection" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.7" name="dicomUniqueAETitle" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.0.4.8" name="dicomTransferCapability" type="LDAP OID" part="PS3.15" retired="false"/>
+        <uid value="1.2.840.10008.15.1.1" name="Universal Coordinated Time" type="Synchronization Frame of Reference" part="PS3.3" retired="false"/>
+      </table>
+<table ref="Table A-2" name="Well-known Frames of Reference">
+        <uid value="1.2.840.10008.1.4.1.1" name="Talairach Brain Atlas Frame of Reference" normative-reference="Talairach J. and Tournoux P. Co-Planar stereotactic atlas of the human brain. Stutgart: Georg Thieme Verlag, 1988."/>
+        <uid value="1.2.840.10008.1.4.1.2" name="SPM2 T1 Frame of Reference" normative-reference="SPM2 /templates/T1.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.3" name="SPM2 T2 Frame of Reference" normative-reference="SPM2 /templates/T2.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.4" name="SPM2 PD Frame of Reference" normative-reference="SPM2 /templates/PD.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.5" name="SPM2 EPI Frame of Reference" normative-reference="SPM2 /templates/EPI.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.6" name="SPM2 FIL T1 Frame of Reference" normative-reference="SPM2 /templates/filT1.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.7" name="SPM2 PET Frame of Reference" normative-reference="SPM2 /templates/PET.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.8" name="SPM2 TRANSM Frame of Reference" normative-reference="SPM2 /templates/Transm.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.9" name="SPM2 SPECT Frame of Reference" normative-reference="SPM2 /templates/SPECT.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.10" name="SPM2 GRAY Frame of Reference" normative-reference="SPM2 /apriori/gray.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.11" name="SPM2 WHITE Frame of Reference" normative-reference="SPM2 /apriori/white.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.12" name="SPM2 CSF Frame of Reference" normative-reference="SPM2 /apriori/csf.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.13" name="SPM2 BRAINMASK Frame of Reference" normative-reference="SPM2 /apriori/brainmask.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.14" name="SPM2 AVG305T1 Frame of Reference" normative-reference="SPM2 /canonical/avg305T1.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.15" name="SPM2 AVG152T1 Frame of Reference" normative-reference="SPM2 /canonical/avg152T1.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.16" name="SPM2 AVG152T2 Frame of Reference" normative-reference="SPM2 /canonical/avg152T2.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.17" name="SPM2 AVG152PD Frame of Reference" normative-reference="SPM2 /canonical/avg152PD.mnc"/>
+        <uid value="1.2.840.10008.1.4.1.18" name="SPM2 SINGLESUBJT1 Frame of Reference" normative-reference="SPM2 /canonical/single_subj_T1.mnc"/>
+        <uid value="1.2.840.10008.1.4.2.1" name="ICBM 452 T1 Frame of Reference" normative-reference="ICBM452 T1 Atlas"/>
+        <uid value="1.2.840.10008.1.4.2.2" name="ICBM Single Subject MRI Frame of Reference" normative-reference="ICBM Single Subject MRI Anatomical Template"/>
+      </table>
 </dicts>
diff --git a/Source/DataDictionary/Part6.xsl b/Source/DataDictionary/Part6.xsl
new file mode 100644
index 0000000..618b269
--- /dev/null
+++ b/Source/DataDictionary/Part6.xsl
@@ -0,0 +1,358 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0" xmlns:dk="http://docbook.org/ns/docbook" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="dk">
+<!--
+  Program: GDCM (Grassroots DICOM). A DICOM library
+
+  Copyright (c) 2006-2011 Mathieu Malaterre
+  All rights reserved.
+  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+-->
+<!--
+<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" doctype-system="../dtds/docbookx.dtd" doctype-public="-//OASIS//DTD DocBook XML//EN"/>
+-->
+<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8" indent="no" />
+
+<xsl:template match="/">
+    <xsl:comment>
+  Program: GDCM (Grassroots DICOM). A DICOM library
+
+  Copyright (c) 2006-2011 Mathieu Malaterre
+  All rights reserved.
+  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+</xsl:comment>
+<xsl:text>
+</xsl:text>
+<xsl:comment>
+This file was automatically created from a docbook version of PS 3.6-2011, which was then process by Part67.xsl
+
+Manual changes:
+
+1. DateTime -> Date Time (0008,002a)
+</xsl:comment>
+<xsl:text disable-output-escaping="yes">
+<!DOCTYPE doc [
+  <!ENTITY part7 SYSTEM "Part7.xml">
+  ]>
+</xsl:text>
+<dicts edition="2011">
+<xsl:text disable-output-escaping="yes">
+  &part7;
+</xsl:text>
+  <xsl:apply-templates select="*/*/dk:table[@xml:id='table_6-1']" mode="m1"/>
+  <xsl:apply-templates select="*/*/dk:table[@xml:id='table_7-1']" mode="m1"/>
+  <xsl:apply-templates select="*/*/dk:table[@xml:id='table_8-1']" mode="m1"/>
+  <xsl:apply-templates select="*/*/dk:table[@xml:id='table_A-1']" mode="m3"/>
+  <xsl:apply-templates select="*/*/dk:table[@xml:id='table_A-2']" mode="m4"/>
+<!--
+  <xsl:apply-templates select="*/*/*/*/*/dk:table[@xml:id='table_9.3-1']" mode="m2"/>
+-->
+<xsl:text>
+</xsl:text>
+</dicts>
+</xsl:template>
+
+<xsl:template match="dk:tr" mode="m4">
+  <xsl:variable name="value" select="translate(dk:td[1]/dk:para[not(dk:emphasis)] | dk:td[1]/dk:para/dk:emphasis,'&#x200B;','')"/>
+  <xsl:variable name="nameStr0" select="dk:td[2]/dk:para/dk:emphasis | dk:td[2]/dk:para[not(dk:emphasis)]"/>
+  <xsl:variable name="nameStr" select="translate($nameStr0,'&#x200B;','')"/>
+  <xsl:variable name="name">
+      <xsl:choose>
+        <xsl:when test="contains($nameStr,'(Retired)')">
+            <xsl:value-of select="normalize-space(substring-before($nameStr,'(Retired)'))"/>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="normalize-space($nameStr)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type" select="dk:td[3]/dk:para[not(dk:emphasis)] | dk:td[3]/dk:para/dk:emphasis"/>
+  <xsl:variable name="part">
+      <xsl:choose>
+        <xsl:when test="dk:td[4]/dk:para[not(dk:emphasis)]/dk:olink/@targetdoc | dk:td[4]/dk:para/dk:emphasis/dk:olink/@targetdoc">
+            <xsl:value-of select="dk:td[4]/dk:para[not(dk:emphasis)]/dk:olink/@targetdoc | dk:td[4]/dk:para/dk:emphasis/dk:olink/@targetdoc"/>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="dk:td[4]/dk:para[not(dk:emphasis)]/text() | dk:td[4]/dk:para/dk:emphasis/text()"/>
+        </xsl:otherwise>
+      </xsl:choose>
+
+  </xsl:variable>
+  <xsl:variable name="retired">
+      <xsl:choose>
+        <xsl:when test="contains($nameStr,'(Retired)')">
+            <xsl:value-of select="'true'"/>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="'false'"/>
+        </xsl:otherwise>
+      </xsl:choose>
+  </xsl:variable>
+  <xsl:if test="$value != ''">
+  <uid value="{$value}" name="{$name}" normative-reference="{$type}"/>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="dk:tr" mode="m3">
+  <xsl:variable name="value" select="translate(dk:td[1]/dk:para[not(dk:emphasis)] | dk:td[1]/dk:para/dk:emphasis,'&#x200B;','')"/>
+  <xsl:variable name="nameStr0" select="dk:td[2]/dk:para/dk:emphasis | dk:td[2]/dk:para[not(dk:emphasis)]"/>
+  <xsl:variable name="nameStr" select="translate($nameStr0,'&#x200B;','')"/>
+  <xsl:variable name="name">
+      <xsl:choose>
+        <xsl:when test="contains($nameStr,'(Retired)')">
+            <xsl:value-of select="normalize-space(substring-before($nameStr,'(Retired)'))"/>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="normalize-space($nameStr)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type" select="dk:td[3]/dk:para[not(dk:emphasis)] | dk:td[3]/dk:para/dk:emphasis"/>
+<!--
+  <xsl:variable name="part1" select="dk:td[4]/dk:para[not(dk:emphasis)]/dk:olink/@targetdoc | dk:td[4]/dk:para/dk:emphasis/dk:olink/@targetdoc"/>
+  <xsl:variable name="part2" select="dk:td[4]/dk:para[not(dk:emphasis)]/text() | dk:td[4]/dk:para/dk:emphasis/text()"/>
+-->
+  <xsl:variable name="part">
+      <xsl:choose>
+        <xsl:when test="dk:td[4]/dk:para[not(dk:emphasis)]/dk:olink/@targetdoc | dk:td[4]/dk:para/dk:emphasis/dk:olink/@targetdoc">
+            <xsl:value-of select="dk:td[4]/dk:para[not(dk:emphasis)]/dk:olink/@targetdoc | dk:td[4]/dk:para/dk:emphasis/dk:olink/@targetdoc"/>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="dk:td[4]/dk:para[not(dk:emphasis)]/text() | dk:td[4]/dk:para/dk:emphasis/text()"/>
+        </xsl:otherwise>
+      </xsl:choose>
+
+  </xsl:variable>
+  <xsl:variable name="retired">
+      <xsl:choose>
+        <xsl:when test="contains($nameStr,'(Retired)')">
+            <xsl:value-of select="'true'"/>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="'false'"/>
+        </xsl:otherwise>
+      </xsl:choose>
+  </xsl:variable>
+  <xsl:if test="$value != ''">
+  <uid value="{$value}" name="{$name}" type="{$type}" part="{$part}" retired="{$retired}"/>
+  </xsl:if>
+</xsl:template>
+
+
+<xsl:template match="dk:tr" mode="m2">
+  <xsl:variable name="name" select="dk:td[1]/dk:para/text()"/>
+  <xsl:variable name="tag" select="translate(dk:td[2]/dk:para/text(),'ABCDEF','abcdef')"/>
+  <xsl:variable name="group" select="substring-after(substring-before($tag,','), '(')"/>
+  <xsl:variable name="element" select="substring-after(substring-before($tag,')'), ',')"/>
+  <xsl:variable name="keyword" select="translate(dk:td[3]/dk:para/text(),'&#x200B;','')"/>
+  <xsl:variable name="vr" select="dk:td[3]/dk:para/text()"/>
+  <xsl:variable name="vm" select="dk:td[4]/dk:para/text()"/>
+  <entry group="{$group}" element="{$element}" keyword="{$keyword}" vr="{$vr}" vm="{$vm}" retired="false" name="{$name}"/>
+</xsl:template>
+
+<xsl:template match="dk:tr" mode="m1">
+  <xsl:variable name="tagUpper">
+<!--
+ select="translate(dk:td[1]/dk:para/text(),'ABCDEF','abcdef')"/>
+-->
+    <xsl:apply-templates select="dk:td[1]/dk:para/dk:emphasis | dk:td[1]/dk:para[not(dk:emphasis)]"/>
+  </xsl:variable>
+  <xsl:variable name="tagLower" select="translate($tagUpper,'ABCDEF','abcdef')"/>
+  <xsl:variable name="group" select="substring-after(substring-before($tagLower,','), '(')"/>
+  <xsl:variable name="element" select="substring-after(substring-before($tagLower,')'), ',')"/>
+  <xsl:variable name="name">
+    <xsl:apply-templates select="dk:td[2]/dk:para/dk:emphasis | dk:td[2]/dk:para[not(dk:emphasis)]"/>
+  </xsl:variable>
+  <xsl:variable name="keyword" >
+    <xsl:variable name="temp" >
+      <xsl:apply-templates select="dk:td[3]/dk:para/dk:emphasis | dk:td[3]/dk:para[not(dk:emphasis)]"/>
+    </xsl:variable>
+    <xsl:value-of select="translate($temp,'&#x200B;','')"/>
+  </xsl:variable>
+  <xsl:variable name="vr">
+    <xsl:apply-templates select="dk:td[4]/dk:para/dk:emphasis | dk:td[4]/dk:para[not(dk:emphasis)]"/>
+  </xsl:variable>
+  <xsl:variable name="vm">
+    <xsl:apply-templates select="dk:td[5]/dk:para/dk:emphasis | dk:td[5]/dk:para[not(dk:emphasis)]"/>
+  </xsl:variable>
+  <xsl:variable name="retString">
+    <xsl:apply-templates select="dk:td[6]/dk:para/dk:emphasis | dk:td[6]/dk:para[not(dk:emphasis)]"/>
+  </xsl:variable>
+  <!--
+  (0018,9445) -> RET - See Note (should be the only attribute without known vr/vm, with 0028,0020)
+  -->
+  <xsl:variable name="ret" select="$retString = 'RET' or starts-with($retString, 'RET')"/>
+  <xsl:if test="$group != ''">
+  <entry group="{$group}" element="{$element}">
+    <xsl:if test="$keyword != ''">
+    <xsl:attribute name="keyword"><xsl:value-of select="$keyword"/></xsl:attribute>
+    </xsl:if>
+    <xsl:if test="$vr != ''">
+    <xsl:attribute name="vr">
+        <xsl:call-template name="process-vr">
+          <xsl:with-param name="text" select="normalize-space($vr)"/>
+        </xsl:call-template>
+    </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="$vm != ''">
+    <xsl:attribute name="vm">
+        <xsl:call-template name="process-vm">
+          <xsl:with-param name="text" select="normalize-space($vm)"/>
+        </xsl:call-template>
+    </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="$ret">
+    <xsl:attribute name="retired"><xsl:value-of select="$ret"/></xsl:attribute>
+    </xsl:if>
+    <xsl:if test="$name != ''">
+    <xsl:attribute name="name"><xsl:value-of select="translate($name,'&#x200B;','')"/></xsl:attribute>
+    </xsl:if>
+  </entry>
+  </xsl:if>
+</xsl:template>
+
+<!-- remove thread -->
+<xsl:template match="dk:thead"/>
+
+<!--
+<xsl:template match="dk:para">
+   <xsl:apply-templates select="./node()"/>
+</xsl:template>
+
+<xsl:template match="dk:emphasis">
+   <xsl:value-of select="./text()"/>
+</xsl:template>
+-->
+
+<xsl:template match="dk:tbody">
+   <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<xsl:template match="dk:caption" mode="m1"/>
+<xsl:template match="dk:caption" mode="m2"/>
+<xsl:template match="dk:caption" mode="m3"/>
+<xsl:template match="dk:caption" mode="m4"/>
+
+<xsl:template match="dk:table[@xml:id='table_6-1']" mode="m1">
+  <xsl:variable name="caption" select="dk:caption"/>
+  <dict ref="6" name="{$caption}">
+   <xsl:apply-templates select="*" mode="m1"/>
+</dict>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_7-1']" mode="m1">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <dict ref="7" name="{$caption}">
+   <xsl:apply-templates select="*" mode="m1"/>
+</dict>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_8-1']" mode="m1">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <dict ref="8" name="{$caption}">
+   <xsl:apply-templates select="*" mode="m1"/>
+</dict>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_A-1']" mode="m3">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <table ref="Table A-1" name="{$caption}">
+   <xsl:apply-templates select="*" mode="m3"/>
+</table>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_A-2']" mode="m4">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <table ref="Table A-2" name="{$caption}">
+   <xsl:apply-templates select="*" mode="m4"/>
+</table>
+</xsl:template>
+
+<!--
+<xsl:template match="@*|node()">
+  <xsl:copy>
+   <xsl:apply-templates select="@*|node()" />
+  </xsl:copy>
+</xsl:template>
+-->
+
+<!-- http://stackoverflow.com/questions/5268182/how-to-remove-namespaces-from-xml-using-xslt -->
+    <!-- template to copy elements -->
+    <xsl:template match="*">
+        <xsl:element name="{local-name()}">
+            <xsl:apply-templates select="@* | node()"/>
+        </xsl:element>
+    </xsl:template>
+
+    <!-- template to copy attributes -->
+    <xsl:template match="@*">
+        <xsl:attribute name="{local-name()}">
+            <xsl:value-of select="."/>
+        </xsl:attribute>
+    </xsl:template>
+
+    <!-- template to copy the rest of the nodes -->
+    <xsl:template match="comment() | text() | processing-instruction()">
+        <xsl:copy/>
+    </xsl:template>
+
+
+<!--
+  template to process VR from PDF representation into GDCM representation
+-->
+  <xsl:template name="process-vr">
+    <xsl:param name="text"/>
+    <xsl:choose>
+      <xsl:when test="$text='See Note'">
+        <xsl:value-of select="''"/>
+      </xsl:when>
+      <xsl:when test="$text='US or OW'">
+        <xsl:value-of select="'US_OW'"/>
+      </xsl:when>
+      <xsl:when test="$text='US or SS or OW'">
+        <xsl:value-of select="'US_SS_OW'"/>
+      </xsl:when>
+      <xsl:when test="$text='US or SSor OW'">
+        <xsl:value-of select="'US_SS_OW'"/>
+      </xsl:when>
+      <xsl:when test="$text='US or SS'">
+        <xsl:value-of select="'US_SS'"/>
+      </xsl:when>
+      <xsl:when test="$text='OW or OB'">
+        <xsl:value-of select="'OB_OW'"/>
+      </xsl:when>
+      <xsl:when test="$text='OB or OW'">
+        <xsl:value-of select="'OB_OW'"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$text"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  <xsl:template name="process-vm">
+    <xsl:param name="text"/>
+    <xsl:choose>
+      <xsl:when test="$text='1-n or 1'">
+        <xsl:value-of select="'1-n'"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$text"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+</xsl:stylesheet>
diff --git a/Source/DataDictionary/Part6togdcm1.xsl b/Source/DataDictionary/Part6togdcm1.xsl
deleted file mode 100644
index 92eb5f4..0000000
--- a/Source/DataDictionary/Part6togdcm1.xsl
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="text" indent="yes"/>
-<!-- XSL to convert XML GDCM2 data dictionay into the old
-     GDCM1 data dictionary -->
-<!--
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
--->
-<!-- The main template that loop over all dict/entry -->
-  <xsl:template match="/">
-    <xsl:for-each select="dicts/dict/entry">
-      <xsl:sort select="@group"/>
-      <xsl:sort select="@element"/>
-      <xsl:value-of select="translate(@group,'x','0')"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="translate(@element,'x','0')"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="@vr"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="@vm"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="description"/>
-      <!--<xsl:if test="@retired = "true"">-->
-      <xsl:if test="@retired != "false"">
-        <xsl:text> (RET)</xsl:text>
-      </xsl:if>
-      <xsl:text>
-</xsl:text>
-    </xsl:for-each>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/Source/DataDictionary/SPI.dic b/Source/DataDictionary/SPI.dic
deleted file mode 100644
index c190aca..0000000
--- a/Source/DataDictionary/SPI.dic
+++ /dev/null
@@ -1,140 +0,0 @@
-0009 0010 LO 1 Private Creator
-0009 0011 LO 1 Private Creator
-0009 0012 LO 1 Private Creator
-0009 0013 LO 1 Private Creator
-0009 0015 LO 1 UID
-0009 0020 LO 1 Private Creator
-0009 0030 LO 1 Private Creator
-0009 0031 SH 1 Unknown (SIENET)
-0009 0040 US 1 Data Object Type
-0009 0041 SH 1 Data Object Subtype
-0009 1010 LO 1 Comments
-0009 1015 LO 1 SPI Image UID
-0009 1040 US 1 Data Object Type
-0009 1041 LO 1 Data Object Subtype
-0009 1110 LO 1 Recognition Code
-0009 1130 US 1 Byte Offset Of Original Header
-0009 1131 US 1 Length Of Original Header
-0009 1140 US 1 Byte Offset Of Pixelmatrix
-0009 1141 UL 1 Length Of Pixelmatrix In Bytes
-0009 1210 CS 1 Storage Mode
-0009 1212 UL 1 Evaluation Mask Image
-0009 1213 UN 1 TODO
-0009 1214 UN 1 TODO
-0009 1226 DA 1 Last Move Date
-0009 1227 TM 1 Last Move Time
-0009 1310 LO 1 Generator Identification Label
-0009 1311 LO 1 Gantry Identification Label
-0009 1314 LO 1 DAS Identification Label
-0009 1315 LO 1 SMI Identification Label
-0009 1316 LO 1 CPU Identification Label
-0009 1320 SH 1 Header Version
-0009 2010 LO 1 Private Creator
-0009 2030 CS 1 Unknown (IMA)
-0009 2031 SH 1 Unknown (TOPO)
-0009 2032 SH 1 Unknown (NONE)
-0009 2040 LO 1 Unknown (TOPO)
-0009 2042 LO 1 Unknown (2.9)
-0009 2050 DA 1 Unknown
-0009 2051 TM 1 Unknown (093757.981000)
-0009 3172 LO 1 Unknown 001S00OT002001082217540946
-0009 3175 LO 1 Unknown 001S60CT012001082209470996
-0011 0010 LO 1 Organ
-0011 0011 LO 1 PrivateCreator
-0011 0015 LO 1 Allergy Indication
-0011 0020 LO 1 Pregnancy
-0011 1010 LO 1 Organ
-0011 1110 DA 1 Registration Date
-0011 1111 TM 1 Registration Time
-0011 1123 DS 1 Used Patient Weight
-0019 0010 LO 1 PrivateCreator
-0019 0012 LO 1 PrivateCreator
-0019 0014 LO 1 PrivateCreator
-0019 0015 LO 1 PrivateCreator
-0019 1010 IS 1 Net Frequency
-0019 1020 CS 1 Measurement Mode
-0019 1030 CS 1 Calculation Mode
-0019 1050 IS 1 Noise Level
-0019 1060 IS 1 Number of Data Bytes
-0019 1210 DS 1 Total Measurement Time Nominal
-0019 1211 DS 1 Total Measurement Time Current
-0019 1212 DS 1 Start Delay Time
-0019 1213 DS 1 Dwell Time
-0019 1214 IS 1 Number of Phases
-0019 1216 UL 2 Sequence Control Mask
-0019 1218 UL 1 Measurement Status Mask
-0019 1220 IS 1 Number of Fourier Lines Nominal
-0019 1221 IS 1 Number of Fourier Lines Current
-0019 1226 IS 1 Number of Fourier Lines after Zero
-0019 1228 IS 1 First Measured Fourier Line
-0019 1230 IS 1 Acquisition Columns
-0019 1231 IS 1 Reconstruction Columns
-0019 1240 IS 1 Array Coil Element Number
-0019 1241 UL 1 Array Coil Element Select Mask
-0019 1242 UL 1 Array Coil Element Data Mask
-0019 1245 IS 1 Array Coil ADC Pair Number
-0019 1246 UL 1 Array Coil Combination Mask
-0019 1250 IS 1 Number of Averages Current
-0019 1260 DS 1 Flip Angle
-0019 1270 IS 1 Number of Prescans
-0019 1281 CS 1 Filter Type for Raw Data
-0019 1283 CS 1 Filter Type for Image Data
-0019 1285 CS 1 Filter Type for Phase Correction
-0019 1287 CS 1 Normalization Filter Type for Image Data
-0019 1290 IS 1 Number of Saturation Regions
-0019 1294 DS 1 Image Rotation Angle
-0019 1296 UL 3 Coil ID Mask
-0019 1297 UL 2 Coil Class Mask
-0019 1298 DS 3 Coil Position
-0019 1412 DS 1 Magnetic Field Strength
-0019 1414 DS 1 ADC Voltage
-0019 1416 DS 1 ADC Offset
-0019 1420 DS 1 Transmitter Amplitude
-0019 1421 IS 1 Number of Transmitter Amplitudes
-0019 1422 DS 1 Transmitter Attenuator
-0019 1424 DS 1 Transmitter Calibration
-0019 1426 DS 1 Transmitter Reference
-0019 1450 DS 1 Receiver Total Gain
-0019 1451 DS 1 Receiver Amplifier Gain
-0019 1452 DS 1 Receiver Preamplifier Gain
-0019 1454 DS 1 Receiver Cable Attenuation
-0019 1455 DS 1 Receiver Reference Gain
-0019 1456 DS 1 Receiver Filter Frequency
-0019 1460 DS 1 Reconstruction Scale Factor
-0019 1462 DS 1 Reference Scale Factor
-0019 1470 DS 1 Phase Gradient Amplitude
-0019 1471 DS 1 Readout Gradient Amplitude
-0019 1472 DS 1 Selection Gradient Amplitude
-0019 1480 DS 1 Gradient Delay Time
-0019 1482 DS 1 Total Gradient Delay Time
-0019 1490 LO 1 Sensitivity Correction Label
-0019 14a0 IS 1 RF Watchdog Mask
-0019 14a2 DS 1 RF Power Error Indicator
-0019 14a5 DS 1 Specific Absorption Rate Whole Body
-0019 14a6 DS 1 Specific Energy Dose
-0019 14b0 UL 1 Adjustment Status Mask
-0019 14d1 DS 1 Flow Sensitivity
-0019 14d2 CS 1 Calculation Submode
-0019 14d3 DS 1 Field of View Ratio
-0019 14d4 IS 1 Base Raw Matrix Size
-0019 14d5 IS 1 2D Oversampling Lines
-0019 14d6 IS 1 3D Phase Oversampling Partitions
-0019 14d7 IS 1 Echo Line Position
-0019 14d8 IS 1 Echo Column Position
-0019 14d9 IS 1 Lines Per Segment
-0019 14da CS 1 Phase Coding Direction
-0019 1510 LO 1 Parameter File Name
-0019 1511 LO 1 Sequence File Name
-0019 1512 LO 1 Sequence File Owner
-0019 1513 LO 1 Sequence Description
-0021 0010 LO 1 PrivateCreator
-0021 1010 DS 1 Zoom
-0021 1011 DS 1 Target
-0021 1020 US 1 ROI Mask
-0029 0060 LO 1 Compression Algorithm
-7001 0010 LO 1 PrivateCreator
-7001 1010 LO 1 Dummy
-7003 0010 LO 1 PrivateCreator
-7003 1010 LO 1 Header
-7005 0010 LO 1 PrivateCreator
-7005 1010 LO 1 Dummy
diff --git a/Source/DataDictionary/gdcm1.xsl b/Source/DataDictionary/gdcm1.xsl
deleted file mode 100644
index ef7e96c..0000000
--- a/Source/DataDictionary/gdcm1.xsl
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="text" indent="yes"/>
-<!-- XSL to convert XML GDCM2 data dictionay into the old
-     GDCM1 data dictionary -->
-<!--
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
--->
-<!-- The main template that loop over all dict/entry -->
-  <xsl:template match="/">
-    <xsl:for-each select="dict/entry">
-      <xsl:sort select="@group"/>
-      <xsl:sort select="@element"/>
-      <xsl:if test="@element = '0000'">
-      <xsl:text>
-</xsl:text>
-</xsl:if>
-      <xsl:value-of select="translate(@group,'x','0')"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="translate(@element,'x','0')"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="@vr"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="@vm"/>
-      <xsl:text> </xsl:text>
-      <xsl:value-of select="@name"/>
-      <!--<xsl:if test="@retired = "true"">-->
-      <xsl:if test="@retired != "false"">
-        <xsl:text> (RET)</xsl:text>
-      </xsl:if>
-      <xsl:text>
-</xsl:text>
-    </xsl:for-each>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/Source/DataDictionary/gdcm2html.xsl b/Source/DataDictionary/gdcm2html.xsl
deleted file mode 100644
index 5e718e5..0000000
--- a/Source/DataDictionary/gdcm2html.xsl
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="html"
-  media-type="text/html" encoding="UTF-8"
-indent="no" omit-xml-declaration="yes" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
-<!--xsl:stylesheet xmlns:xsl=
-"http://www.w3.org/1999/XSL/Transform"
-xmlns=
-"http://www.w3.org/TR/xhtml1/strict"
-version="1.0">
-<xsl:output method="xml" indent="yes"
-encoding="iso-8859-1"/-->
-
-<!-- XSL to convert XML GDCM2 data dictionay into HTML form -->
-<!--
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
--->
-  <xsl:template match="/">
-    <xsl:variable name="has_owner" select="dict/entry/@owner"/>
-    <xsl:variable name="has_retired" select="dict/entry/@retired"/>
-    <html>
-    <head>
-    <title>
-    DICOM DICTIONARY
-    </title>
-      <style type="text/css">
-tr.normal
-   {
-   font-style:normal;
-   }
-tr.italic
-   {
-   font-style:italic;
-   }
-</style>
-
-    </head>
-      <body>
-        <table border="1">
-          <tr bgcolor="#d6d6d6">
-<!--rgb(214,214,214) -->
-            <th>Tag</th>
-            <th>VR</th>
-            <th>VM</th>
-            <th>Description</th>
-            <th>Version</th>
-            <xsl:choose>
-              <xsl:when test="$has_owner">
-                <th>Owner</th>
-              </xsl:when>
-              <xsl:when test="$has_retired">
-                <th>Retired</th>
-              </xsl:when>
-              <xsl:otherwise>
-                <th>bla</th>
-              </xsl:otherwise>
-            </xsl:choose>
-          </tr>
-<!-- The main template that loop over all dict/entry -->
-          <xsl:for-each select="dict/entry">
-            <xsl:variable name="my_italic" value="@retired != 'false'"/>
-            <xsl:variable name="my_class">
-              <xsl:choose>
-<!--xsl:when test="$has_owner">
-              <xsl:text>normal</xsl:text>
-              </xsl:when-->
-<!--xsl:when test="$has_retired"-->
-                <xsl:when test="@retired !='false'">
-              italic
-              </xsl:when>
-                <xsl:otherwise>
-              normal
-              </xsl:otherwise>
-              </xsl:choose>
-            </xsl:variable>
-            <tr class="{$my_class}">
-              <td>
-<!--xsl:if test="@retired != 'false'"><i></xsl:if-->
-                <xsl:text>(</xsl:text>
-                <xsl:value-of select="@group"/>
-                <xsl:text>,</xsl:text>
-                <xsl:value-of select="@element"/>
-                <xsl:text>)</xsl:text>
-<!--xsl:if test="$my_italic"></i></xsl:if-->
-              </td>
-              <td>
-                <xsl:value-of select="@vr"/>
-              </td>
-              <td>
-                <xsl:value-of select="@vm"/>
-              </td>
-              <td>
-                <xsl:value-of select="description"/>
-              </td>
-              <td>
-                <xsl:value-of select="@version"/>
-              </td>
-              <td>
-                <xsl:choose>
-                  <xsl:when test="$has_owner">
-                    <xsl:value-of select="@owner"/>
-                  </xsl:when>
-                  <xsl:when test="$has_retired">
-                    <xsl:if test="@retired != 'false'">
-                      <xsl:text> (RET)</xsl:text>
-                    </xsl:if>
-                  </xsl:when>
-                </xsl:choose>
-              </td>
-            </tr>
-          </xsl:for-each>
-        </table>
-      </body>
-    </html>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/Source/DataDictionary/gdcm2pdf.xsl b/Source/DataDictionary/gdcm2pdf.xsl
deleted file mode 100644
index c252701..0000000
--- a/Source/DataDictionary/gdcm2pdf.xsl
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:java="http://xml.apache.org/xslt/java" version="1.1" exclude-result-prefixes="java">
-  <xsl:output method="pdf"/>
-<!-- fop -xml GDCM2.xml -xsl gdcm2pdf.xsl GDCM2.pdf -->
-<!--
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
--->
-  <xsl:template match="/">
-    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">
-      <fo:layout-master-set>
-        <fo:simple-page-master master-name="A4-L" page-height="297mm" page-width="210mm" margin-top="10mm" margin-bottom="10mm" margin-left="10mm" margin-right="10mm">
-<!--
-    * <fo:region-body> defines the body region
-    * <fo:region-before> defines the top region (header)
-    * <fo:region-after> defines the bottom region (footer)
-    * <fo:region-start> defines the left region (left sidebar)
-    * <fo:region-end> defines the right region (right sidebar)
--->
-          <fo:region-body margin="10mm"/>
-          <fo:region-before extent="10mm"/>
-          <fo:region-after extent="10mm"/>
-          <fo:region-start extent="10mm"/>
-          <fo:region-end extent="10mm"/>
-        </fo:simple-page-master>
-      </fo:layout-master-set>
-      <fo:page-sequence master-reference="A4-L">
-        <fo:static-content flow-name="xsl-region-before" font-size="10pt">
-          <fo:block text-align="justify">
-            PS 3.6-2007<fo:block><xsl:text>
-</xsl:text></fo:block>Page <fo:page-number/>
-          </fo:block>
-        </fo:static-content>
-        <fo:static-content flow-name="xsl-region-after" font-size="10pt">
-          <fo:block text-align="center">
-          - Standard -
-          </fo:block>
-        </fo:static-content>
-        <fo:flow flow-name="xsl-region-body">
-          <fo:block>
-            <fo:table table-layout="fixed" border-color="rgb(0,0,0)" border-width="1pt">
-              <fo:table-column column-width="30mm"/><!--Tag-->
-              <fo:table-column column-width="90mm"/><!--Name-->
-              <fo:table-column column-width="7.5mm"/><!--VR-->
-              <fo:table-column column-width="10mm"/><!--VM-->
-              <fo:table-column column-width="15mm"/><!--Retired?-->
-              <fo:table-header background-color="rgb(214,214,214)" font-size="10pt" font-weight="bold" text-align="justify">
-                <fo:table-row text-align="justify" font-size="10pt">
-                  <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                    <fo:block>Tag</fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                    <fo:block>Name</fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                    <fo:block>VR</fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                    <fo:block>VM</fo:block>
-                  </fo:table-cell>
-                  <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                    <fo:block>Retired</fo:block>
-                  </fo:table-cell>
-                </fo:table-row>
-              </fo:table-header>
-              <fo:table-body>
-<!-- http://www.topxml.com/xsl/articles/caseconvert/ -->
-                <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
-                <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
-                <xsl:for-each select="dict/entry">
-                  <xsl:variable name="my_font_style" select="italic"/>
-<!--xsl:if test="@retired != 'false'">italic</xsl:if>
-                    </xsl:variable-->
-<!--fo:table-row text-align="center" font-size="10pt" font-style="{$my_font_style}"-->
-                  <fo:table-row text-align="justify" font-size="10pt">
-                    <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                      <fo:block vertical-align="middle">
-                        <xsl:text>(</xsl:text>
-                        <xsl:value-of select="translate(@group,$lcletters,$ucletters)"/>
-                        <xsl:text>,</xsl:text>
-                        <xsl:value-of select="translate(@element,$lcletters,$ucletters)"/>
-                        <xsl:text>)</xsl:text>
-                      </fo:block>
-                    </fo:table-cell>
-                    <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                      <fo:block vertical-align="middle">
-                        <xsl:value-of select="description"/>
-                      </fo:block>
-                    </fo:table-cell>
-                    <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                      <fo:block vertical-align="middle">
-                          <xsl:value-of select="@vr"/>
-                      </fo:block>
-                    </fo:table-cell>
-                    <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                      <fo:block vertical-align="middle">
-                          <xsl:value-of select="@vm"/>
-                      </fo:block>
-                    </fo:table-cell>
-                    <fo:table-cell border-color="rgb(0,0,0)" border-width="1pt">
-                      <fo:block vertical-align="middle">
-                        <xsl:if test="@retired != 'false'">
-                          <xsl:text>RET</xsl:text>
-                        </xsl:if>
-                      </fo:block>
-                    </fo:table-cell>
-                  </fo:table-row>
-                </xsl:for-each>
-              </fo:table-body>
-            </fo:table>
-          </fo:block>
-        </fo:flow>
-      </fo:page-sequence>
-    </fo:root>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/Source/DataDictionary/gdcmPrivateDefaultDicts.cxx b/Source/DataDictionary/gdcmPrivateDefaultDicts.cxx
index 78b4b0c..b1e46df 100644
--- a/Source/DataDictionary/gdcmPrivateDefaultDicts.cxx
+++ b/Source/DataDictionary/gdcmPrivateDefaultDicts.cxx
@@ -7369,6 +7369,7 @@ static const DICT_ENTRY DICOMV3DataDict [] = {
   {0x0039,0x0000,"SIEMENS MED NM",VR::LT,VM::VM1,"Toshiba CBF activity results",false },
   {0x0041,0x0001,"SIEMENS MED NM",VR::SL,VM::VM1,"?",false },
   {0x0041,0x0002,"SIEMENS MED NM",VR::SL,VM::VM1,"?",false },
+  {0x0041,0x0003,"SIEMENS MED NM",VR::FL,VM::VM1,"?",false },
   {0x0041,0x0005,"SIEMENS MED NM",VR::FD,VM::VM1_n,"?",false },
   {0x0041,0x0006,"SIEMENS MED NM",VR::FD,VM::VM1_n,"?",false },
   {0x0041,0x0007,"SIEMENS MED NM",VR::FD,VM::VM1_n,"?",false },
diff --git a/Source/DataDictionary/txt2xml.py b/Source/DataDictionary/txt2xml.py
deleted file mode 100755
index 4c9f045..0000000
--- a/Source/DataDictionary/txt2xml.py
+++ /dev/null
@@ -1,396 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import re,os
-
-"""
-GEMS
-This parser parse a table formatted like this:
-Attribute Name Tag VR VM
-"""
-class TextParser:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt  = re.compile("^\s*([A-Za-z0-9&{}=+ ��%;#()./,_:<>-]+)\s+\(?([0-9A-Fa-fn]+),\s?([0-9A-Fa-fyxX]+)\)?\s+([A-Z][A-Z])\s+([0-9Nn-]+)\s*$")
-      patt1 = re.compile("^\s*([A-Za-z0-9&{}=+ ;%#\[\]()./,_:<>-]+)\s+\(?([0-9A-Fa-f]+),\s?([0-9A-Fa-fyxX]+)\)?\s+([1-3C]+)\s+([A-Z][A-Z])\s+([0-9Nn-]+)\s*$")
-      patt2 = re.compile( "^\s*([Table ]*[A-Z1-9.:-]+)\s+([A-Za-z -]+)\s+\(([A-Z0-9_]+)\)\s*$")
-      #patt3 = re.compile( '^\s*Private Creator Identification\s*\((["A-Za-z0-9() ./])\)\s*$' )
-      patt3 = re.compile( '^\s*Private Creator Identification\s*\("?(.*)"?\)\)?\s*$' )
-      patt4 = re.compile( '^\s*Private Creator Identification\s*([A-Z0-9_]+)\s*$' )
-      m = patt.match(line)
-      m1 = patt1.match(line)
-      m2 = patt2.match(line)
-      m3 = patt3.match(line)
-      m4 = patt4.match(line)
-      #print line
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" name=\"%s\"/>"%(m.group(2),m.group(3),m.group(4),m.group(5),m.group(1).rstrip())
-        #dicom = m.group(1) + ' ' + m.group(2) + ' ' + m.group(3) + ' ' + m.group(4)
-        #print dicom
-        outLines.append( dicom )
-      elif m1:
-        # <entry group="0001" element="0001" vr="LO" vm="1" type="1C"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" type=\"%s\" name=\"%s\"/>"%(m1.group(2),m1.group(3),m1.group(5),m1.group(6),m1.group(4),m1.group(1).rstrip())
-        #dicom = m.group(1) + ' ' + m.group(2) + ' ' + m.group(3) + ' ' + m.group(4)
-        #print dicom
-        outLines.append( dicom )
-      elif m2:
-        # <dict edition="2007" url="http://??" ref="Table A-16" name="Private Creator Identification - Xeleris" owner="GEMS_GENIE_1">
-        s = "</dict><dict ref=\"%s\" name=\"%s\" owner=\"%s\">"%(m2.group(1),m2.group(2).rstrip(),m2.group(3))
-        s += '\n'
-        outLines.append( s )
-      elif m3:
-        s = "</dict><dict ref=\"%s\" name=\"%s\" owner=\"%s\">"%("??","??",m3.group(1))
-        s += '\n'
-        outLines.append( s )
-      elif m4:
-        s = "</dict><dict ref=\"%s\" name=\"%s\" owner=\"%s\">"%("??","??",m4.group(1))
-        s += '\n'
-        outLines.append( s )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-GEMS
-This parser parse a table formatted like this:
-Grp Elm VR VM Type Definition
-"""
-class TextParser2:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^\s*([0-9A-Z]+)\s+([0-9A-Zx]+)\s+([A-Z][A-Z])\s+([1-9SNn-]+)\s+([1-9])\s+([A-Za-z0-9 ()._,/#>-]+)\s*$")
-      patt2 = re.compile( "^\s*([A-Z1-9.-]+)\s*([A-Za-z -]+)\s*$")
-      m = patt.match(line)
-      m2 = patt2.match(line)
-      #print line
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" type=\"%s\" name=\"%s\"/>"%(m.group(1),m.group(2),m.group(3),m.group(4),m.group(5),m.group(6).rstrip())
-        #dicom = m.group(1) + ' ' + m.group(2) + ' ' + m.group(3) + ' ' + m.group(4)
-        #print dicom
-        outLines.append( dicom )
-      elif m2:
-        # <dict edition="2007" url="http://??" ref="Table A-16" name="Private Creator Identification - Xeleris" owner="GEMS_GENIE_1">
-        s = "<dict ref=\"%s\" name=\"%s\" owner=\"%s\">"%(m2.group(1),m2.group(2).rstrip(),"")
-        s += '\n'
-        outLines.append( s )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-SIEMENS:
-This parser parse a table formatted like this:
-Tag Private Owner Code Name VR VM
-"""
-class TextParser3:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^\s*\(([0-9A-Z]+),([0-9A-Zx]+)\)\s+([A-Za-z0-9./:_ -]+)\s+\|\s+([A-Za-z0-9 ()._,/#>-]+)\s+([A-Z][A-Z]_?O?W?)\s+([0-9n-]+)\s*$")
-      patt2 = re.compile( "^\s*([A-Z1-9.-]+)\s*([A-Za-z -]+)\s*$")
-      m = patt.match(line)
-      m2 = patt2.match(line)
-      #print line
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" owner=\"%s\" name=\"%s\"/>"%(m.group(1),m.group(2),m.group(5),m.group(6),m.group(3).rstrip(),m.group(4).rstrip())
-        #dicom = m.group(1) + ' ' + m.group(2) + ' ' + m.group(3) + ' ' + m.group(4)
-        #print dicom
-        outLines.append( dicom )
-      elif m2:
-        # <dict edition="2007" url="http://??" ref="Table A-16" name="Private Creator Identification - Xeleris" owner="GEMS_GENIE_1">
-        s = "<dict ref=\"%s\" name=\"%s\" owner=\"%s\">"%(m2.group(1),m2.group(2).rstrip(),"")
-        s += '\n'
-        outLines.append( s )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-PHILIPS: (see mr91.pdf)
-  Diffusion B-Factor                            2001,xx03   VR = FL, VM = 1 Dimension: s/mm2
-                                                            Indicates the Diffusion coefficient.
-"""
-class TextParser4:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^\s*([A-Za-z0-9> -]+)\s+([0-9]+),([0-9A-Fx]+)\s+VR = ([A-Z][A-Z]), VM = ([0-9n-]+)\s+(.*)\s*$")
-      patt1 = re.compile("^\s*([A-Za-z0-9()> -]+)\s+([0-9]+),([0-9A-Fx]+)\s+Value Representation = ([A-Z][A-Z]), Multiplicity = ([0-9n-]+)(.*)\s*$")
-      patt2 = re.compile("^\s*[STUDYSERIES]+\s+\(([0-9]+),([0-9]+)\)\s+([A-Za-z ]+)\s*$")
-      m = patt.match(line)
-      m1 = patt1.match(line)
-      m2 = patt2.match(line)
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" name=\"%s\"/>"%(m.group(2),m.group(3),m.group(4),m.group(5),m.group(1).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      elif m1:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" name=\"%s\"/>"%(m1.group(2),m1.group(3),m1.group(4),m1.group(5),m1.group(1).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      elif m2:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" name=\"%s\" />"%(m2.group(1),m2.group(2),m2.group(3).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-PHILIPS: (see 453567994381_B.pdf)
-                  7053,0010       LO     Private Creator Data element                                                       1
-"""
-class TextParser5:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^([\s>]*)([0-9]+),([0-9A-Fx]+)\s+([A-Z][A-Z])\s+([A-Za-z0-9.?(,)> -]+)\s+([0-9n-]+)\s*$")
-      m = patt.match(line)
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" name=\"%s%s\"/>\n"%(m.group(2),m.group(3),m.group(4),m.group(6),m.group(1).lstrip(),m.group(5).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-PHILIPS: (see 9605_0132RevC.pdf)
-                                     Attribute                           Tag          Type       VR        VM
-                              ADAC Header Signature                   0019, 0010        3        LO         2
-"""
-class TextParser6:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^\s*([A-Za-z0-9 #()./,_:>-]+)\s+([0-9A-Z]+),\s?([0-9A-ZxX]+)\s+([1-3C]+)\s+([A-Z][A-Z])\s+([0-9Nn-]+)\s*$")
-      m = patt.match(line)
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" type=\"%s\" name=\"%s\" />"%(m.group(2),m.group(3),m.group(5),m.group(6),m.group(4),m.group(1).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-PHILIPS: (see MR_System_R1_5_dcs.pdf
-                 Number of PC Directions                    2001,1016      SS       2, USER      -
-"""
-class TextParser7:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^\s*([A-Za-z0-9'./> -]+)\s+\(?([0-9A-F]+),([0-9A-FxXY]+)\)?\s+([A-Z][A-Z])\s+([1-3C]+)?,?.*\s*$")
-      m = patt.match(line)
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" type=\"%s\" name=\"%s\" />"%(m.group(2),m.group(3),m.group(4),m.group(5),m.group(1).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-AGFA
-IMPAX object document         (0029,xx00)          OB               1                  Mitra Object Document 1.0
-"""
-class TextParser8:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^\s*([A-Za-z0-9()> -]+)\s+\(([0-9]+),([0-9A-Fx]+)\)\s+([A-Z][A-Z])\s+([1-9n-]+)\s+([A-Za-z_0-9. ]+)\s*$")
-      m = patt.match(line)
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" owner=\"%s\" name=\"%s\" />"%(m.group(2),m.group(3),m.group(4),m.group(5),m.group(6),m.group(1).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-SIEMENS
-Parse a diction.pfl file
-Pixel Overflow Flag 1 Pixel Overflow,7FE3,SIEMENS MED NM,1B,SS,1
-"""
-class TextParser9:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^([A-Z0-9a-z()=/:%. -]+),([0-9A-F]+),([A-Za-z0-9. -]+),([0-9A-F][0-9A-F]),([A-Z][A-Z]),([1-9N-]+)$")
-      patt1 = re.compile("^[^,]+,([0-9A-F]+),.*$")
-      m = patt.match(line)
-      m1 = patt1.match(line)
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" vm=\"%s\" owner=\"%s\" name=\"%s\" />"%(m.group(2),m.group(4),m.group(5),m.group(6),m.group(3),m.group(1).rstrip())
-        #print dicom
-        outLines.append( dicom )
-      else:
-        #print line
-        n = eval( '0x' + m1.group(1) )
-        #print m1.group(1)
-        if( not (n % 2 == 0) ):
-          print n
-          print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-Storage.pdf
-Attribute Name                 Group     Byte    Type      VR       Attribute Description
-"""
-class TextParser10:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      patt = re.compile("^\s*([A-Z.a-z -]+[1-2]?)\s+([0-9A-Z]+)\s+([0-9A-Zx]+)\s+([1-3])\s+([A-Z][A-Z])\s+.*$")
-      m = patt.match(line)
-      #print line
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry group=\"%s\" element=\"%s\" vr=\"%s\" type=\"%s\">"%(m.group(2),m.group(3),m.group(5),m.group(4))
-        #dicom = m.group(1) + ' ' + m.group(2) + ' ' + m.group(3) + ' ' + m.group(4)
-        #print dicom
-        dicom += '\n'
-        dicom += "<description>%s</description>\n</entry>\n"%m.group(1).rstrip()
-        outLines.append( dicom )
-      else:
-        print line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-"""
-S2000_1.5_DCS_public.pdf
-Attribute Name                 (Group,Element)    Type      Attribute Description
-"""
-class TextParser11:
-  def __init__(self, inputfilename, outputfilename):
-    self._InputFilename = ''
-    self._OutputFilename = ''
-  def Parse(self):
-    infile = file(inputfilename, 'r')
-    outLines = []
-    for line in infile.readlines():
-      #patt = re.compile("^\s*([A-Za-z ]+)\s+\(([0-9A-F]+),([0-9A-F]+)\)\s+([1-3])\s+([A-Za-z0-9=,. ])\s*$")
-      patt = re.compile("^\s*([A-Za-z0-9 '/-]+)\s+\(([0-9]+),([0-9A-Fa-fx]+)\)\s+([1-3])\s+.*$")
-      m = patt.match(line)
-      #print line
-      if m:
-        # <entry group="0001" element="0001" vr="LO" vm="1" owner="Private Creator"/>
-        dicom = "<entry name=\"%s\" group=\"%s\" element=\"%s\" type=\"%s\">"%(m.group(1).rstrip(),m.group(2),m.group(3),m.group(4))
-        #dicom = m.group(1) + ' ' + m.group(2) + ' ' + m.group(3) + ' ' + m.group(4)
-        #print dicom
-        dicom += '\n'
-        #dicom += "<description>%s</description>\n</entry>\n"%
-        outLines.append( dicom )
-      else:
-        print "no:",line
-      #print self.Reformat(line)
-      #outLines.append( self.Reformat(line) + '\n' )
-    outfile = file(outputfilename, 'w')
-    outfile.writelines( outLines )
-    outfile.close()
-
-if __name__ == "__main__":
-  argc = len(os.sys.argv )
-  if ( argc < 3 ):
-    print "Sorry, wrong list of args"
-    os.sys.exit(1) #error
-
-  inputfilename = os.sys.argv[1]
-  outputfilename = os.sys.argv[2]
-  tp = TextParser(inputfilename,outputfilename);
-  tp.Parse()
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmElement.h b/Source/DataStructureAndEncodingDefinition/gdcmElement.h
index d4ace85..d39e542 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmElement.h
+++ b/Source/DataStructureAndEncodingDefinition/gdcmElement.h
@@ -719,7 +719,7 @@ class Element<TVR, VM::VM1_2> : public Element<TVR, VM::VM1_n>
 public:
   typedef Element<TVR, VM::VM1_n> Parent;
   void SetLength(int len) {
-    if( len != 1 || len != 2 ) return;
+    if( len != 1 && len != 2 ) return;
     Parent::SetLength(len);
   }
 };
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.cxx b/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.cxx
index 0c5be6d..3a08a94 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.cxx
+++ b/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.cxx
@@ -138,6 +138,8 @@ static const char *MSStrings[] = {
   "1.2.840.10008.5.1.4.1.1.130", // Enhanced PET Image Storage
   "1.2.840.10008.5.1.4.1.1.77.1.4.1", // Video Photographic Image Storage
   "1.2.840.10008.5.1.4.1.1.13.1.2", // XRay3DCraniofacialImageStorage
+  "1.2.840.10008.5.1.4.1.1.14.1", // IVOCTForPresentation,
+  "1.2.840.10008.5.1.4.1.1.14.2", // IVCOTForProcessing,
   0
 };
 
@@ -318,6 +320,8 @@ static const MSModalityType MSModalityTypes[] = {
   {"PT", 3, 0},//PETImageStorage,
   {"XC", 3, 0},// VideoPhotographicImageStorage
   {"DX", 3, 0},// XRay3DCraniofacialImageStorage
+  {"IVOCT", 3, 0},// IVOCTForPresentation,
+  {"IVOCT", 3, 0},// IVCOTForProcessing,
 
   {NULL, 0, 0} //MS_END
 };
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.h b/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.h
index a59e4af..e555462 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.h
+++ b/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.h
@@ -131,6 +131,8 @@ public:
     EnhancedPETImageStorage,
     VideoPhotographicImageStorage,
     XRay3DCraniofacialImageStorage,
+    IVOCTForPresentation,
+    IVOCTForProcessing,
     MS_END
   } MSType; // Media Storage Type
 
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmReader.cxx b/Source/DataStructureAndEncodingDefinition/gdcmReader.cxx
index b46ff8e..5c5edf7 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmReader.cxx
+++ b/Source/DataStructureAndEncodingDefinition/gdcmReader.cxx
@@ -420,17 +420,11 @@ bool Reader::InternalReadCommon(const T_Caller &caller)
       throw Exception( "Meta Header issue" );
       }
 
-  //std::cerr << ts.GetNegociatedType() << std::endl;
-  //std::cerr << TransferSyntax::GetTSString(ts) << std::endl;
   // Special case where the dataset was compressed using the deflate
   // algorithm
   if( ts == TransferSyntax::DeflatedExplicitVRLittleEndian )
     {
-#if 0
-  std::ofstream out( "/tmp/deflate.raw", std::ios::binary );
-  out << is.rdbuf();
-  out.close();
-#endif
+
     zlib_stream::zip_istream gzis( is );
     // FIXME: we also know in this case that we are dealing with Explicit:
     assert( ts.GetNegociatedType() == TransferSyntax::Explicit );
@@ -639,30 +633,6 @@ bool Reader::InternalReadCommon(const T_Caller &caller)
             // ExplicitImplicitDataElement class instead.
             // Simply rethrow the exception for now.
             throw;
-#if 0
-            is.clear();
-            if( haspreamble )
-              {
-              is.seekg(128+4, std::ios::beg);
-              }
-            else
-              {
-              is.seekg(0, std::ios::beg);
-              }
-            if( hasmetaheader )
-              {
-              // FIXME: we are reading twice the same meta-header, we succedeed the first time...
-              // We should be able to seek to proper place instead of re-reading
-              FileMetaInformation header;
-              header.Read(is);
-              }
-
-            // Explicit/Implicit
-            gdcmWarningMacro( "Attempt to read file with explicit/implicit" );
-            F->GetDataSet().Clear(); // remove garbage from 1st attempt...
-            //F->GetDataSet().template Read<UNExplicitImplicitDataElement,SwapperNoOp>(is);
-            caller.template ReadCommon<UNExplicitImplicitDataElement,SwapperNoOp>(is);
-#endif
             }
           }
         }
@@ -734,11 +704,6 @@ bool Reader::InternalReadCommon(const T_Caller &caller)
     gdcmWarningMacro( "Unknown exception" );
     success = false;
     }
-  //  if( !success )
-  //    {
-  //    F->GetHeader().Clear();
-  //    F->GetDataSet().Clear();
-  //    }
 
   // FIXME : call this function twice...
   if (Ifstream && Ifstream->is_open())
@@ -768,8 +733,8 @@ bool Reader::CanRead() const
 {
   // fastpath
   std::istream &is = *Stream;
-  assert( is.good() );
-  assert( is.tellg() == std::streampos(0) );
+  if( is.bad() ) return false;
+  if( is.tellg() != std::streampos(0) ) return false;
     {
     is.seekg( 128, std::ios::beg ); // we ignore return value as we test is.good()
     char b[4];
@@ -784,8 +749,6 @@ bool Reader::CanRead() const
   bool bigendian = false;
   bool explicitvr = false;
   is.clear();
-  //is.seekg(0, std::ios::end);
-  //std::streampos filelen = is.tellg();
   is.seekg(0, std::ios::beg);
 
   char b[8];
@@ -847,137 +810,6 @@ bool Reader::CanRead() const
       nts = TransferSyntax::Implicit;
     }
 
-#if 0
-  is.clear();
-  is.seekg(0, std::ios::end);
-  std::streampos filelen = is.tellg();
-  is.seekg(0, std::ios::beg);
-  Tag t;
-  VL gl; // group length
-  if( bigendian )
-    {
-    if( !t.Read<SwapperDoOp>(is) )
-      {
-      is.clear();
-      is.seekg(0, std::ios::beg);
-      return false;
-      }
-    }
-  else
-    {
-    if( !t.Read<SwapperNoOp>(is) )
-      {
-      is.clear();
-      is.seekg(0, std::ios::beg);
-      return false;
-      }
-    }
-  if( t.GetGroup() % 2 == 0 )
-    {
-    switch( t.GetGroup() )
-      {
-    case 0x0002:
-    //case 0x0004: // DICOMDIR is for media, thus FMI is compulsory
-    case 0x0008:
-      sc = SwapCode::LittleEndian;
-      break;
-    //case 0x0200: // FMI is Explicit VR Little Endian...
-    case 0x0800:
-      sc = SwapCode::BigEndian;
-      break;
-    default:
-      ;
-      }
-    if( sc != SwapCode::Unknown )
-      {
-      // Purposely not Re-use ReadVR since we can read VR_END
-      char vr_str[3];
-      is.read(vr_str, 2);
-      vr_str[2] = '\0';
-      // Cannot use GetVRTypeFromFile since is assert ...
-      VR::VRType vr = VR::GetVRType(vr_str);
-      if( vr != VR::VR_END )
-        {
-        nts = TransferSyntax::Explicit;
-        }
-      else
-        {
-        assert( !(VR::IsSwap(vr_str)));
-        is.seekg(-2, std::ios::cur); // Seek back
-        gl.Read<SwapperNoOp>(is);
-
-        if( t.GetElement() == 0x0000 )
-          {
-          switch(gl)
-            {
-          case 0x00000004 :
-            assert( sc == SwapCode::LittleEndian);    // 1234
-            sc = SwapCode::LittleEndian;    // 1234
-            break;
-          case 0x04000000 :
-            assert( sc == SwapCode::BigEndian);    // 1234
-            sc = SwapCode::BigEndian;       // 4321
-            break;
-          case 0x00040000 :
-            sc = SwapCode::BadLittleEndian; // 3412
-            gdcmWarningMacro( "Bad Little Endian" );
-            break;
-          case 0x00000400 :
-            sc = SwapCode::BadBigEndian;    // 2143
-            gdcmWarningMacro( "Bad Big Endian" );
-            break;
-          default:
-            ;
-            }
-          }
-        if( gl && gl < filelen )
-          nts = TransferSyntax::Implicit;
-        }
-      }
-    }
-  else
-    {
-    // US-IRAD-NoPreambleStartWith0003.dcm
-    gdcmDebugMacro( "Start with a private tag creator" );
-    if( t.GetGroup() > 0x0002 && t.GetGroup() < 0x8 )
-      {
-      switch( t.GetElement() )
-        {
-      case 0x0010:
-        sc = SwapCode::LittleEndian;
-        break;
-      default:
-        ;
-        }
-      }
-    if( sc != SwapCode::Unknown )
-      {
-      // Purposely not Re-use ReadVR since we can read VR_END
-      char vr_str[3];
-      is.read(vr_str, 2);
-      vr_str[2] = '\0';
-      // Cannot use GetVRTypeFromFile since is assert ...
-      VR::VRType vr = VR::GetVRType(vr_str);
-      if( vr != VR::VR_END )
-        {
-        nts = TransferSyntax::Explicit;
-        }
-      else
-        {
-        assert( !(VR::IsSwap(vr_str)));
-        is.seekg(-2, std::ios::cur); // Seek back
-        gl.Read<SwapperNoOp>(is);
-        if( t.GetElement() == 0x0000 )
-          {
-          assert( gl == 0x4 || gl == 0x04000000 );
-          }
-        if( gl && gl < filelen )
-          nts = TransferSyntax::Implicit;
-        }
-      }
-    }
-
-#endif
   // reset in all other cases:
   is.clear();
   is.seekg(0, std::ios::beg);
@@ -988,16 +820,6 @@ bool Reader::CanRead() const
   if( nts == TransferSyntax::Explicit && sc == SwapCode::LittleEndian ) return true;
   if( nts == TransferSyntax::Explicit && sc == SwapCode::BigEndian ) return true;
 
-//  assert( nts == TransferSyntax::Unknown );
-//  if( sc != SwapCode::Unknown )
-//    {
-//    gdcm::Reader r;
-//    r.SetStream( is );
-//    is.clear();
-//    is.seekg(0, std::ios::beg);
-//    return r.Read();
-//    }
-
   return false;
 }
 
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmTransferSyntax.h b/Source/DataStructureAndEncodingDefinition/gdcmTransferSyntax.h
index 4e0272e..51fcdf9 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmTransferSyntax.h
+++ b/Source/DataStructureAndEncodingDefinition/gdcmTransferSyntax.h
@@ -80,9 +80,7 @@ public:
     RLELossless,
     MPEG2MainProfile,
     ImplicitVRBigEndianACRNEMA,
-#ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
     WeirdPapryus,
-#endif
     CT_private_ELE,
     JPIPReferenced,
     MPEG2MainProfileHighLevel,
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmVM.cxx b/Source/DataStructureAndEncodingDefinition/gdcmVM.cxx
index d46bbfd..815f068 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmVM.cxx
+++ b/Source/DataStructureAndEncodingDefinition/gdcmVM.cxx
@@ -348,9 +348,9 @@ VM::VMType VM::GetVMTypeFromLength(unsigned int length, unsigned int size)
     }
 }
 
-unsigned int VM::GetNumberOfElementsFromArray(const char *array, unsigned int length)
+size_t VM::GetNumberOfElementsFromArray(const char *array, size_t length)
 {
-  unsigned int c=0;
+  size_t c=0;
   if( !length || !array ) return 0;
   const char *parray = array;
   const char *end = array + length;
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmVM.h b/Source/DataStructureAndEncodingDefinition/gdcmVM.h
index b63531a..3d1ce49 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmVM.h
+++ b/Source/DataStructureAndEncodingDefinition/gdcmVM.h
@@ -126,7 +126,7 @@ public:
 
   ///
   static VMType GetVMTypeFromLength(unsigned int length, unsigned int size);
-  static unsigned int GetNumberOfElementsFromArray(const char *array, unsigned int length);
+  static size_t GetNumberOfElementsFromArray(const char *array, size_t length);
 
   VM(VMType type = VM0):VMField(type) {}
   operator VMType () const { return VMField; }
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmVR.cxx b/Source/DataStructureAndEncodingDefinition/gdcmVR.cxx
index 824801e..45acc77 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmVR.cxx
+++ b/Source/DataStructureAndEncodingDefinition/gdcmVR.cxx
@@ -48,9 +48,11 @@ static const char *VRStrings[] = {
   "UN",        // 25
   "US",        // 26
   "UT",        // 27
-  "OB or OW",  // 28
-  "US or SS",  // 29
-  "US or SS or OW", //30
+  "OD",        // 28
+  "OL",        // 29
+  "OB or OW",  // 30
+  "US or SS",  // 31
+  "US or SS or OW", //32
   0
 };
 
@@ -82,7 +84,9 @@ static VR::VRType VRValue[] = {
     VR::UL ,
     VR::UN ,
     VR::US ,
-    VR::UT
+    VR::UT ,
+    VR::OD ,
+    VR::OL ,
 };
 
 bool VR::IsVRFile() const
@@ -103,7 +107,9 @@ bool VR::IsVRFile() const
   case VR::LO:
   case VR::LT:
   case VR::OB:
+  case VR::OD:
   case VR::OF:
+  case VR::OL:
   case VR::OW:
   case VR::PN:
   case VR::SH:
@@ -169,9 +175,15 @@ unsigned int VR::GetSizeof() const
   case VR::OB:
     size = sizeof(VRToType<VR::OB>::Type);
     break;
+  case VR::OD:
+    size = sizeof(VRToType<VR::OD>::Type);
+    break;
   case VR::OF:
     size = sizeof(VRToType<VR::OF>::Type);
     break;
+  case VR::OL:
+    size = sizeof(VRToType<VR::OL>::Type);
+    break;
   case VR::OW:
     size = sizeof(VRToType<VR::OW>::Type);
     break;
@@ -232,16 +244,16 @@ int VR::GetIndex(VRType vr)
     l = 0;
     break;
   case OB_OW:
-    l =  28;
+    l =  30;
     break;
   case US_SS:
-    l =  29;
+    l =  31;
     break;
   case US_SS_OW:
-    l =  30;
+    l =  32;
     break;
   case VR_END:
-    l = 31;
+    l = 33;
     break;
   default:
       {
@@ -264,7 +276,7 @@ const char *VR::GetVRStringFromFile(VRType vr)
 {
 #if 1
   static const int N = sizeof(VRValue) / sizeof(VRType);
-  assert( N == 28 );
+  assert( N == 30 );
   static VRType *start = VRValue;
   static VRType *end   = VRValue+N;
   const VRType *p =
@@ -299,7 +311,7 @@ VR::VRType VR::GetVRTypeFromFile(const char *vr)
  */
 #if 1
   static const int N = sizeof(VRValue) / sizeof(VRType);
-  assert( N == 28 );
+  assert( N == 30 );
   static const char **start = VRStrings+1;
   static const char **end   = VRStrings+N;
   //std::cerr << "VR=" << vr << std::endl;
@@ -356,16 +368,16 @@ VR::VRType VR::GetVRType(const char *vr)
       case 0:
         r = INVALID;
         break;
-      case 28:
+      case 30:
         r = OB_OW;
         break;
-      case 29:
+      case 31:
         r = US_SS;
         break;
-      case 30:
+      case 32:
         r = US_SS_OW;
         break;
-      case 31:
+      case 33:
         r = VR_END; assert(0);
         break;
       default:
@@ -386,7 +398,7 @@ bool VR::IsValid(const char *vr)
     // Use lazy evaluation instead of strncmp
     if (ref[0] == vr[0] && ref[1] == vr[1] )
       {
-      assert( i < 28 ); // FIXME
+      assert( i < 30 ); // FIXME
       return true;
       }
     }
@@ -429,7 +441,9 @@ VRTemplateCase(IS,rep) \
 VRTemplateCase(LO,rep) \
 VRTemplateCase(LT,rep) \
 VRTemplateCase(OB,rep) \
+VRTemplateCase(OD,rep) \
 VRTemplateCase(OF,rep) \
+VRTemplateCase(OL,rep) \
 VRTemplateCase(OW,rep) \
 VRTemplateCase(PN,rep) \
 VRTemplateCase(SH,rep) \
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmVR.h b/Source/DataStructureAndEncodingDefinition/gdcmVR.h
index 04d6fcc..0a17c24 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmVR.h
+++ b/Source/DataStructureAndEncodingDefinition/gdcmVR.h
@@ -72,6 +72,7 @@ public:
     OB = 4096,
     OD = 134217728, // 2^27
     OF = 8192,
+    OL = 268435456, // 2^28
     OW = 16384,
     PN = 32768,
     SH = 65536,
@@ -90,15 +91,15 @@ public:
     US_SS_OW = US | SS | OW,
     // The following do not have a VRString equivalent (ie cannot be found in PS 3.6)
     VL16 = AE | AS | AT | CS | DA | DS | DT | FD | FL | IS | LO | LT | PN | SH | SL | SS | ST | TM | UI | UL | US, // if( VR & VL16 ) => VR has its VL coded over 16bits
-    VL32 = OB | OW | OD | OF | SQ | UN | UT, // if( VR & VL32 ) => VR has its VL coded over 32bits
+    VL32 = OB | OW | OD | OF | OL | SQ | UN | UT, // if( VR & VL32 ) => VR has its VL coded over 32bits
     VRASCII = AE | AS | CS | DA | DS | DT | IS | LO | LT | PN | SH | ST | TM | UI | UT,
-    VRBINARY = AT | FL | FD | OB | OD | OF | OW | SL | SQ | SS | UL | UN | US, // FIXME: UN ?
+    VRBINARY = AT | FL | FD | OB | OD | OF | OL | OW | SL | SQ | SS | UL | UN | US, // FIXME: UN ?
     // PS 3.5:
-    // Data Elements with a VR of SQ, OD, OF, OW, OB or UN shall always have a Value Multiplicity of one.
+    // Data Elements with a VR of SQ, OD, OF, OL, OW, OB or UN shall always have a Value Multiplicity of one.
     // GDCM is adding a couple more: AS, LT, ST, UT
-    VR_VM1 = AS | LT | ST | UT | SQ | OF | OD | OW | OB | UN, // All those VR have a VM1
+    VR_VM1 = AS | LT | ST | UT | SQ | OF | OL | OD | OW | OB | UN, // All those VR have a VM1
     VRALL = VRASCII | VRBINARY,
-    VR_END = UT+1  // Invalid VR, need to be max(VRType)+1
+    VR_END = OL+1  // Invalid VR, need to be max(VRType)+1
   } VRType;
 
   static const char *GetVRString(VRType vr);
@@ -281,7 +282,9 @@ TYPETOENCODING(IS,VRASCII ,int32_t)
 TYPETOENCODING(LO,VRASCII ,LOComp)
 TYPETOENCODING(LT,VRASCII ,LTComp)
 TYPETOENCODING(OB,VRBINARY,uint8_t)
+TYPETOENCODING(OD,VRBINARY,double)
 TYPETOENCODING(OF,VRBINARY,float)
+TYPETOENCODING(OL,VRBINARY,uint32_t)
 TYPETOENCODING(OW,VRBINARY,uint16_t)
 TYPETOENCODING(PN,VRASCII ,PNComp)
 TYPETOENCODING(SH,VRASCII ,SHComp)
@@ -317,7 +320,9 @@ inline unsigned int VR::GetSize() const
     VRTypeTemplateCase(LO)
     VRTypeTemplateCase(LT)
     VRTypeTemplateCase(OB)
+    VRTypeTemplateCase(OD)
     VRTypeTemplateCase(OF)
+    VRTypeTemplateCase(OL)
     VRTypeTemplateCase(OW)
     VRTypeTemplateCase(PN)
     VRTypeTemplateCase(SH)
diff --git a/Source/InformationObjectDefinition/Part3New.xsl b/Source/InformationObjectDefinition/Part3New.xsl
new file mode 100644
index 0000000..316b5ea
--- /dev/null
+++ b/Source/InformationObjectDefinition/Part3New.xsl
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0" xmlns:dk="http://docbook.org/ns/docbook" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="dk">
+<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8" indent="no" />
+
+<xsl:template match="text()" />
+
+<xsl:template match="/">
+<xsl:comment> to produce output use:
+$ xsltproc ma2html.xsl ModuleAttributes.xml
+    </xsl:comment>
+    <xsl:comment>
+  Program: GDCM (Grassroots DICOM). A DICOM library
+
+  Copyright (c) 2006-2011 Mathieu Malaterre
+  All rights reserved.
+  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+</xsl:comment>
+<tables edition="2008">
+   <xsl:apply-templates />
+</tables>
+</xsl:template>
+
+<xsl:template match="dk:caption" mode="module"/>
+<xsl:template match="dk:caption" mode="macro"/>
+<xsl:template match="dk:caption" mode="iod"/>
+<xsl:template match="dk:caption" mode="iod3"/>
+
+<xsl:template match="dk:table">
+  <xsl:variable name="caption" select="dk:caption"/>
+  <xsl:choose>
+  <xsl:when test="contains($caption,'Macro') and not(contains($caption,'Without The Use'))">
+  <macro table="{@label}" name="{$caption}">
+   <xsl:apply-templates mode="macro"/>
+  </macro>
+  </xsl:when>
+  <xsl:when test="contains($caption,'Module') and not(contains($caption,'IOD'))">
+  <module table="{@label}" name="{$caption}">
+   <xsl:apply-templates mode="module"/>
+  </module>
+  </xsl:when>
+  <xsl:when test="contains($caption,'IOD Modules') and count(dk:thead/dk:tr/dk:th) = 4">
+  <iod table="{@label}" name="{$caption}">
+   <xsl:apply-templates mode="iod"/>
+  </iod>
+  </xsl:when>
+  <xsl:when test="contains($caption,'IOD Modules') and count(dk:thead/dk:tr/dk:th) = 3">
+  <iod table="{@label}" name="{$caption}">
+   <xsl:apply-templates mode="iod3"/>
+  </iod>
+  </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="dk:thead/dk:tr" mode="macro"/>
+<xsl:template match="dk:tbody/dk:tr" mode="macro">
+  <xsl:variable name="num_nodes" select="count(*)"/>
+<!-- counting the number of element avoid issue with: BASIC CODED ENTRY ATTRIBUTES as seen in Table 8.8-1a -->
+  <xsl:if test="$num_nodes = 4">
+  <xsl:variable name="name" select="dk:td[1]/dk:para"/>
+  <xsl:variable name="tag" select="dk:td[2]/dk:para"/> <!-- keep upper case for now -->
+  <xsl:variable name="group" select="substring-after(substring-before($tag,','), '(')"/>
+  <xsl:variable name="element" select="substring-after(substring-before($tag,')'), ',')"/>
+  <xsl:variable name="type" select="dk:td[3]/dk:para"/>
+  <xsl:variable name="description">
+<!--
+    <xsl:apply-templates select="dk:td[4]/*" mode="module"/>
+-->
+    <xsl:for-each select="dk:td[4]/*">
+      <xsl:apply-templates select="node()" mode="module"/>
+      <xsl:if test="position() != last()">
+        <xsl:text> </xsl:text>
+      </xsl:if>
+    </xsl:for-each>
+  </xsl:variable>
+  <entry group="{$group}" element="{$element}" name="{$name}" type="{$type}">
+     <description><xsl:value-of select="$description"/></description>
+  </entry>
+  </xsl:if>
+  <!-- yes a macro can also reference another macro -->
+  <xsl:if test="$num_nodes = 2">
+  <xsl:variable name="ref">
+    <xsl:apply-templates select="dk:td[1]/dk:para/dk:emphasis" mode="module"/>
+  </xsl:variable>
+  <xsl:variable name="description" >
+    <xsl:apply-templates select="dk:td[2]/dk:para[not(dk:emphasis)] | dk:td[2]/dk:para/dk:emphasis" mode="module"/>
+  </xsl:variable>
+  <include ref="{$ref}">
+    <xsl:if test="$description != ''">
+      <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
+    </xsl:if>
+  </include>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="dk:thead/dk:tr" mode="module"/>
+<xsl:template match="dk:tbody/dk:tr" mode="module">
+  <xsl:variable name="num_nodes" select="count(*)"/>
+  <xsl:if test="$num_nodes = 4">
+  <xsl:variable name="name" select="dk:td[1]/dk:para"/>
+  <xsl:variable name="tag" select="dk:td[2]/dk:para"/> <!-- keep upper case for now -->
+  <xsl:variable name="group" select="substring-after(substring-before($tag,','), '(')"/>
+  <xsl:variable name="element" select="substring-after(substring-before($tag,')'), ',')"/>
+  <xsl:variable name="type" select="dk:td[3]/dk:para"/>
+  <xsl:variable name="description">
+    <xsl:apply-templates select="dk:td[4]/dk:para" mode="module"/>
+  </xsl:variable>
+  <entry group="{$group}" element="{$element}" name="{$name}" type="{$type}">
+     <description><xsl:value-of select="$description"/></description>
+  </entry>
+  </xsl:if>
+  <xsl:if test="$num_nodes = 2">
+  <xsl:variable name="ref">
+    <xsl:apply-templates select="dk:td[1]/dk:para/dk:emphasis" mode="module"/>
+  </xsl:variable>
+  <xsl:variable name="description" select="dk:td[2]/dk:para/dk:emphasis"/>
+  <include ref="{$ref}" description="{$description}"/>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="dk:variablelist" mode="module">
+<!--
+  <xsl:value-of select="dk:title"/>
+-->
+  <xsl:apply-templates mode="module"/>
+</xsl:template>
+
+<xsl:template match="dk:varlistentry" mode="module">
+  <xsl:value-of select="dk:term"/>
+</xsl:template>
+
+<xsl:key name="tables" match="dk:table" use="@xml:id" />
+
+<xsl:template match="dk:xref" mode="module">
+  <xsl:text>'</xsl:text>
+  <xsl:value-of select="key('tables', @linkend)/dk:caption" />
+  <xsl:text>' Table </xsl:text>
+  <xsl:value-of select="translate(@linkend,'table_','')"/>
+</xsl:template>
+
+<xsl:template match="dk:olink" mode="module">
+  <xsl:value-of select="translate(@targetptr,'sect_','')"/>
+</xsl:template>
+
+<xsl:template match="dk:thead/dk:tr" mode="iod"/>
+<xsl:template match="dk:tbody/dk:tr" mode="iod">
+  <xsl:variable name="num_nodes" select="count(*)"/>
+  <xsl:variable name="offset" select="$num_nodes - 3"/>
+  <xsl:variable name="ie">
+     <xsl:if test="$offset = 1">
+       <xsl:value-of select="dk:td[1]/dk:para"/>
+     </xsl:if>
+     <xsl:if test="$offset = 0">
+<!--
+       <xsl:value-of select="preceding::dk:td[4]/dk:para"/>
+       <xsl:value-of select="(preceding-sibling::*/dk:td[@rowspan != 1])[1]/dk:para"/>
+-->
+       <xsl:value-of select="preceding-sibling::dk:tr[count(dk:td) = 4 and dk:td[@rowspan != 1]][1]/dk:td[1]/dk:para"/>
+     </xsl:if>
+  </xsl:variable>
+  <xsl:variable name="module" select="dk:td[1 + $offset]/dk:para"/>
+  <xsl:variable name="reference" select="dk:td[2 + $offset]/dk:para/dk:xref/@linkend"/>
+  <xsl:variable name="ref" select="translate($reference,'sect_','')"/>
+<!--
+  <xsl:variable name="usage" select="dk:td[3 + $offset]/dk:para"/>
+-->
+  <xsl:variable name="usage">
+    <!-- the following is a hack since we only want to execute when two para and no trailing dot is found: -->
+    <xsl:for-each select="dk:td[3 + $offset]/*">
+      <xsl:apply-templates select="node()" mode="iod"/>
+      <xsl:if test="position() != last()">
+        <xsl:text>.</xsl:text>
+      </xsl:if>
+    </xsl:for-each>
+  </xsl:variable>
+  <entry ie="{$ie}" name="{$module}" ref="{$ref}" usage="{$usage}"/>
+</xsl:template>
+
+<xsl:template match="dk:thead/dk:tr" mode="iod3"/>
+<xsl:template match="dk:tbody/dk:tr" mode="iod3">
+  <xsl:variable name="module" select="dk:td[1]/dk:para"/>
+  <xsl:variable name="reference" select="dk:td[2]/dk:para/dk:xref/@linkend"/>
+  <xsl:variable name="ref" select="translate($reference,'sect_','')"/>
+  <xsl:variable name="description" select="dk:td[3]/dk:para"/>
+  <entry name="{$module}" ref="{$ref}">
+    <xsl:if test="$description != ''">
+    <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
+    </xsl:if>
+  </entry>
+</xsl:template>
+
+<xsl:template match="dk:para" mode="iod">
+  <xsl:apply-templates mode="iod"/>
+</xsl:template>
+
+<xsl:key name="sections" match="dk:section" use="@xml:id" />
+<xsl:template match="dk:xref" mode="iod">
+<!--
+  <xsl:message><xsl:text>bla</xsl:text></xsl:message>
+-->
+<!--
+  <xsl:value-of select="key('sections', @linkend)/dk:title" />
+-->
+  <xsl:text>Section </xsl:text>
+  <xsl:value-of select="translate(@linkend,'sect_','')"/>
+</xsl:template>
+
+<!--
+<xsl:template match="@*|node()">
+  <xsl:copy>
+   <xsl:apply-templates select="@*|node()" />
+  </xsl:copy>
+</xsl:template>
+-->
+
+</xsl:stylesheet>
diff --git a/Source/InformationObjectDefinition/Part4.xml b/Source/InformationObjectDefinition/Part4.xml
index 1605753..d8ea2cd 100644
--- a/Source/InformationObjectDefinition/Part4.xml
+++ b/Source/InformationObjectDefinition/Part4.xml
@@ -13,103 +13,158 @@
 <sop-classes>
   <standard-and-related-general-sop-classes>
     <mapping sop-class-name="12-lead ECG Waveform Storage" sop-class-uid="General ECG Waveform Storage" iod=""/>
-    <mapping sop-class-name="Digital Mammography Image Storage - For Presentation" sop-class-uid="Digital X-Ray Image Storage - For Presentation" iod=""/>
-    <mapping sop-class-name="Digital Mammography Image Storage - For Processing" sop-class-uid="Digital X-Ray Image Storage - For Processing" iod=""/>
-    <mapping sop-class-name="Digital Intra-oral X-Ray Image Storage - For Presentation" sop-class-uid="Digital X-Ray Image Storage - For Presentation" iod=""/>
-    <mapping sop-class-name="Digital Intra-oral X-Ray Image Storage - For Processing" sop-class-uid="Digital X-Ray Image Storage - For Processing" iod=""/>
+    <mapping sop-class-name="Digital Mammography X-Ray Image Storage - For Presentation" sop-class-uid="Digital X-Ray Image Storage - For Presentation" iod=""/>
+    <mapping sop-class-name="Digital Mammography X-Ray Image Storage - For Processing" sop-class-uid="Digital X-Ray Image Storage - For Processing" iod=""/>
+    <mapping sop-class-name="Digital Intra-Oral X-Ray Image Storage - For Presentation" sop-class-uid="Digital X-Ray Image Storage - For Presentation" iod=""/>
+    <mapping sop-class-name="Digital Intra-Oral X-Ray Image Storage - For Processing" sop-class-uid="Digital X-Ray Image Storage - For Processing" iod=""/>
     <mapping sop-class-name="Basic Text SR" sop-class-uid="Enhanced SR" iod=""/>
     <mapping sop-class-name="Comprehensive SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
     <mapping sop-class-name="Enhanced SR" sop-class-uid="Comprehensive SR" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive SR" sop-class-uid="Comprehensive 3D SR" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="Extensible SR" iod=""/>
     <mapping sop-class-name="Procedure Log" sop-class-uid="Enhanced SR" iod=""/>
     <mapping sop-class-name="Comprehensive SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Simplified Adult Echo SR" sop-class-uid="Enhanced SR" iod=""/>
+    <mapping sop-class-name="Comprehensive SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
     <mapping sop-class-name="X-Ray Radiation Dose SR" sop-class-uid="Enhanced SR" iod=""/>
     <mapping sop-class-name="Comprehensive SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Radiopharmaceutical Radiation Dose SR" sop-class-uid="Enhanced SR" iod=""/>
+    <mapping sop-class-name="Comprehensive SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Acquisition Context SR" sop-class-uid="Enhanced SR (see note)" iod=""/>
+    <mapping sop-class-name="Comprehensive SR (see note)" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR" sop-class-uid="" iod=""/>
+    <mapping sop-class-name="Extensible SR" sop-class-uid="" iod=""/>
     <mapping sop-class-name="Spectacle Prescription Report" sop-class-uid="Enhanced SR" iod=""/>
     <mapping sop-class-name="Macular Grid Thickness and Volume Report" sop-class-uid="Enhanced SR" iod=""/>
+    <mapping sop-class-name="Enhanced CT Image Storage" sop-class-uid="Legacy Converted Enhanced CT Image Storage" iod=""/>
+    <mapping sop-class-name="Enhanced MR Image Storage" sop-class-uid="Legacy Converted Enhanced MR Image Storage" iod=""/>
+    <mapping sop-class-name="Enhanced PET Image Storage" sop-class-uid="Legacy Converted Enhanced PET Image Storage" iod=""/>
   </standard-and-related-general-sop-classes>
   <standard-sop-classes>
     <mapping sop-class-name="Computed Radiography Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.1" iod=""/>
     <mapping sop-class-name="Digital X-Ray Image Storage - For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.1" iod="DX IOD (see B.5.1.1)"/>
     <mapping sop-class-name="Digital X-Ray Image Storage - For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.1.1" iod="DX IOD (see B.5.1.1)"/>
-    <mapping sop-class-name="Digital Mammography Image Storage - For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.2" iod="Digital Mammography IOD (see B.5.1.2)"/>
-    <mapping sop-class-name="Digital Mammography Image Storage - For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.2.1" iod="Digital Mammography IOD (see B.5.1.2)"/>
-    <mapping sop-class-name="Digital Intra-oral X-Ray Image Storage - For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.3" iod="Digital Intra-oral X-Ray IOD (see B.5.1.3)"/>
-    <mapping sop-class-name="Digital Intra-oral X-Ray Image Storage - For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.3.1" iod="Digital Intra-oral X-Ray IOD (see B.5.1.3)"/>
+    <mapping sop-class-name="Digital Mammography X-Ray Image Storage - For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.2" iod="Digital Mammography IOD (see B.5.1.2)"/>
+    <mapping sop-class-name="Digital Mammography X-Ray Image Storage - For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.2.1" iod="Digital Mammography IOD (see B.5.1.2)"/>
+    <mapping sop-class-name="Digital Intra-Oral X-Ray Image Storage - For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.3" iod="Digital Intra-oral X-Ray IOD (see B.5.1.3)"/>
+    <mapping sop-class-name="Digital Intra-Oral X-Ray Image Storage - For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.3.1" iod="Digital Intra-oral X-Ray IOD (see B.5.1.3)"/>
     <mapping sop-class-name="CT Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.2" iod=""/>
     <mapping sop-class-name="Enhanced CT Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.2.1" iod="Enhanced CT Image (see B.5.1.7)"/>
+    <mapping sop-class-name="Legacy Converted Enhanced CT Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.2.2" iod="(see B.5.1.7)"/>
     <mapping sop-class-name="Ultrasound Multi-frame Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.3.1" iod=""/>
     <mapping sop-class-name="MR Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4" iod=""/>
-    <mapping sop-class-name="Enhanced MR Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.1" iod="Enhanced MR Image  (see B.5.1.6)"/>
+    <mapping sop-class-name="Enhanced MR Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.1" iod="Enhanced MR Image (see B.5.1.6)"/>
     <mapping sop-class-name="MR Spectroscopy Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.2" iod="MR Spectroscopy"/>
     <mapping sop-class-name="Enhanced MR Color Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.3" iod="Enhanced MR Color Image"/>
+    <mapping sop-class-name="Legacy Converted Enhanced MR Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.4" iod="(see B.5.1.6)"/>
     <mapping sop-class-name="Ultrasound Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.6.1" iod=""/>
-    <mapping sop-class-name="Enhanced US Volume Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.6.2" iod="Enhanced US Volume"/>
+    <mapping sop-class-name="Enhanced US Volume Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.6.2" iod="Enhanced US Volume"/>
     <mapping sop-class-name="Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7" iod=""/>
-    <mapping sop-class-name="Multi-frame Single Bit Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.1" iod="Multi-frame Single Bit Secondary Capture Image"/>
-    <mapping sop-class-name="Multi-frame Grayscale Byte Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.2" iod="Multi-frame Grayscale Byte Secondary Capture Image"/>
-    <mapping sop-class-name="Multi-frame Grayscale Word Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.3" iod="Multi-frame Grayscale Word Secondary Capture Image"/>
-    <mapping sop-class-name="Multi-frame True Color Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.4" iod="Multi-frame True Color Secondary Capture Image"/>
-    <mapping sop-class-name="12-lead ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.1" iod="12-lead ECG Waveform "/>
-    <mapping sop-class-name="General ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.2" iod="General ECG Waveform "/>
-    <mapping sop-class-name="Ambulatory ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.3" iod="Ambulatory ECG Waveform"/>
-    <mapping sop-class-name="Hemodynamic Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.2.1" iod="Hemodynamic Waveform"/>
-    <mapping sop-class-name="Cardiac Electrophysiology Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.3.1" iod="Cardiac Electrophysiology Waveform"/>
-    <mapping sop-class-name="Basic Voice Audio Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.4.1" iod="Basic Voice Audio Waveform"/>
-    <mapping sop-class-name="General Audio Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.4.2" iod="General Audio Waveform"/>
-    <mapping sop-class-name="Arterial Pulse Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.5.1" iod="Arterial Pulse Waveform"/>
-    <mapping sop-class-name="Respiratory Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.6.1" iod="Respiratory Waveform"/>
-    <mapping sop-class-name="Grayscale Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.1" iod="Grayscale Softcopy Presentation State Storage"/>
-    <mapping sop-class-name="Color Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.2" iod="Color Softcopy Presentation State"/>
-    <mapping sop-class-name="Pseudo-Color Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.3" iod="Pseudo-Color Softcopy Presentation State"/>
-    <mapping sop-class-name="Blending Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.4" iod="Blending Softcopy Presentation State"/>
-    <mapping sop-class-name="XA/XRF Grayscale Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.5" iod="XA/XRF Grayscale Softcopy Presentation State"/>
+    <mapping sop-class-name="Multi-frame Single Bit Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.1" iod=""/>
+    <mapping sop-class-name="Multi-frame Grayscale Byte Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.2" iod=""/>
+    <mapping sop-class-name="Multi-frame Grayscale Word Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.3" iod=""/>
+    <mapping sop-class-name="Multi-frame True Color Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.4" iod=""/>
+    <mapping sop-class-name="12-lead ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.1" iod=""/>
+    <mapping sop-class-name="General ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.2" iod=""/>
+    <mapping sop-class-name="Ambulatory ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.3" iod=""/>
+    <mapping sop-class-name="Hemodynamic Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.2.1" iod=""/>
+    <mapping sop-class-name="Cardiac Electrophysiology Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.3.1" iod=""/>
+    <mapping sop-class-name="Basic Voice Audio Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.4.1" iod=""/>
+    <mapping sop-class-name="General Audio Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.4.2" iod=""/>
+    <mapping sop-class-name="Arterial Pulse Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.5.1" iod=""/>
+    <mapping sop-class-name="Respiratory Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.6.1" iod=""/>
+    <mapping sop-class-name="Grayscale Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.1" iod=""/>
+    <mapping sop-class-name="Color Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.2" iod=""/>
+    <mapping sop-class-name="Pseudo-Color Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.3" iod=""/>
+    <mapping sop-class-name="Blending Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.4" iod=""/>
+    <mapping sop-class-name="XA/XRF Grayscale Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.5" iod=""/>
+    <mapping sop-class-name="Grayscale Planar MPR Volumetric Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.6" iod=""/>
+    <mapping sop-class-name="Compositing Planar MPR Volumetric Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.7" iod=""/>
     <mapping sop-class-name="X-Ray Angiographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.1" iod=""/>
-    <mapping sop-class-name="Enhanced XA Image Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.12.1.1" iod=""/>
-    <mapping sop-class-name="X-Ray Radiofluoroscopic  Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.2" iod=""/>
-    <mapping sop-class-name="Enhanced XRF Image Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.12.2.1" iod=""/>
-    <mapping sop-class-name="X-Ray 3D Angiographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.1" iod="X-Ray 3D Angiographic Image"/>
-    <mapping sop-class-name="X-Ray 3D Craniofacial Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.2" iod="X-Ray 3D Craniofacial Image"/>
-    <mapping sop-class-name="Breast Tomosynthesis Image Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.3" iod="Breast Tomosynthesis Image"/>
+    <mapping sop-class-name="Enhanced XA Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.1.1" iod=""/>
+    <mapping sop-class-name="X-Ray Radiofluoroscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.2" iod=""/>
+    <mapping sop-class-name="Enhanced XRF Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.2.1" iod=""/>
+    <mapping sop-class-name="X-Ray 3D Angiographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.1" iod=""/>
+    <mapping sop-class-name="X-Ray 3D Craniofacial Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.2" iod=""/>
+    <mapping sop-class-name="Breast Tomosynthesis Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.3" iod=""/>
+    <mapping sop-class-name="Breast Projection X-Ray Image Storage - For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.4" iod=""/>
+    <mapping sop-class-name="Breast Projection X-Ray Image Storage - For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.5" iod=""/>
+    <mapping sop-class-name="Intravascular Optical Coherence Tomography Image Storage - For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.14.1" iod="(see B.5.1.13)"/>
+    <mapping sop-class-name="Intravascular Optical Coherence Tomography Image Storage - For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.14.2" iod="(see B.5.1.13)"/>
     <mapping sop-class-name="Nuclear Medicine Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.20" iod=""/>
-    <mapping sop-class-name="Raw Data Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66" iod="Raw Data"/>
-    <mapping sop-class-name="Spatial Registration Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.1" iod="Spatial Registration "/>
-    <mapping sop-class-name="Spatial Fiducials Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.2" iod="Spatial Fiducials "/>
-    <mapping sop-class-name="Deformable Spatial Registration Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.3" iod="Deformable Spatial Registration"/>
-    <mapping sop-class-name="Segmentation Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.4" iod="Segmentation"/>
-    <mapping sop-class-name="Surface Segmentation Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.5" iod="Surface Segmentation"/>
-    <mapping sop-class-name="Real World Value Mapping Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.67" iod="Real World Value Mapping"/>
-    <mapping sop-class-name="VL Endoscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.1" iod="VL Endoscopic Image"/>
-    <mapping sop-class-name="Video Endoscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.1.1" iod="Video Endoscopic Image"/>
-    <mapping sop-class-name="VL Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.2" iod="VL Microscopic Image"/>
-    <mapping sop-class-name="Video Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.2.1" iod="Video Microscopic Image"/>
-    <mapping sop-class-name="VL Slide-Coordinates Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.3" iod="VL Slide-Coordinates Microscopic Image"/>
-    <mapping sop-class-name="VL Photographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.4" iod="VL Photographic Image"/>
-    <mapping sop-class-name="Video Photographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.4.1" iod="Video Photographic Image"/>
-    <mapping sop-class-name="Ophthalmic Photography 8 Bit Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.1" iod="Ophthalmic Photography 8 Bit Image"/>
-    <mapping sop-class-name="Ophthalmic Photography 16 Bit Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.2" iod="Ophthalmic Photography 16 Bit Image"/>
-    <mapping sop-class-name="Stereometric Relationship Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.3" iod="Stereometric Relationship"/>
-    <mapping sop-class-name="Ophthalmic Tomography  Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.4" iod="Ophthalmic Tomography Image"/>
-    <mapping sop-class-name="Lensometry Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.1" iod="Lensometry Measurements"/>
-    <mapping sop-class-name="Autorefraction Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.2" iod="Autorefraction Measurements"/>
-    <mapping sop-class-name="Keratometry Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.3" iod="Keratometry Measurements"/>
-    <mapping sop-class-name="Subjective Refraction Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.4" iod="Subjective Refraction Measurements"/>
-    <mapping sop-class-name="Visual Acuity Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.5" iod="Visual Acuity Measurements"/>
-    <mapping sop-class-name="Spectacle Prescription Report Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.6" iod="Spectacle Prescription Report"/>
-    <mapping sop-class-name="Macular Grid Thickness and Volume Report" sop-class-uid="1.2.840.10008.5.1.4.1.1.79.1" iod="Macular Grid Thickness and Volume Report"/>
-    <mapping sop-class-name="Basic Text SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.11" iod="Basic Text SR"/>
-    <mapping sop-class-name="Enhanced SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.22" iod="Enhanced SR"/>
-    <mapping sop-class-name="Comprehensive SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.33" iod="Comprehensive SR"/>
-    <mapping sop-class-name="Procedure Log" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.40" iod="Procedure Log"/>
-    <mapping sop-class-name="Mammography CAD SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.50" iod="Mammography CAD SR IOD"/>
-    <mapping sop-class-name="Key Object Selection " sop-class-uid="1.2.840.10008.5.1.4.1.1.88.59" iod="Key Object Selection Document"/>
-    <mapping sop-class-name="Chest CAD SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.65" iod="Chest CAD SR IOD"/>
-    <mapping sop-class-name="X-Ray Radiation Dose SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.67" iod="X-Ray Radiation Dose SR"/>
-    <mapping sop-class-name="Colon CAD SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.69" iod="Colon CAD SR IOD"/>
-    <mapping sop-class-name="Encapsulated PDF Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.104.1" iod="Encapsulated PDF IOD"/>
-    <mapping sop-class-name="Encapsulated CDA Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.104.2" iod="Encapsulated CDA IOD"/>
+    <mapping sop-class-name="Parametric Map Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.30" iod=""/>
+    <mapping sop-class-name="Raw Data Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66" iod=""/>
+    <mapping sop-class-name="Spatial Registration Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.1" iod=""/>
+    <mapping sop-class-name="Spatial Fiducials Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.2" iod=""/>
+    <mapping sop-class-name="Deformable Spatial Registration Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.3" iod=""/>
+    <mapping sop-class-name="Segmentation Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.4" iod=""/>
+    <mapping sop-class-name="Surface Segmentation Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.5" iod=""/>
+    <mapping sop-class-name="Tractography Results Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.6" iod=""/>
+    <mapping sop-class-name="Real World Value Mapping Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.67" iod=""/>
+    <mapping sop-class-name="Surface Scan Mesh Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.68.1" iod=""/>
+    <mapping sop-class-name="Surface Scan Point Cloud Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.68.2" iod=""/>
+    <mapping sop-class-name="VL Endoscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.1" iod=""/>
+    <mapping sop-class-name="Video Endoscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.1.1" iod=""/>
+    <mapping sop-class-name="VL Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.2" iod=""/>
+    <mapping sop-class-name="Video Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.2.1" iod=""/>
+    <mapping sop-class-name="VL Slide-Coordinates Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.3" iod=""/>
+    <mapping sop-class-name="VL Photographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.4" iod=""/>
+    <mapping sop-class-name="Video Photographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.4.1" iod=""/>
+    <mapping sop-class-name="Ophthalmic Photography 8 Bit Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.1" iod=""/>
+    <mapping sop-class-name="Ophthalmic Photography 16 Bit Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.2" iod=""/>
+    <mapping sop-class-name="Stereometric Relationship Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.3" iod=""/>
+    <mapping sop-class-name="Ophthalmic Tomography Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.4" iod=""/>
+    <mapping sop-class-name="Wide Field Ophthalmic Photography Stereographic Projection Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.5" iod=""/>
+    <mapping sop-class-name="Wide Field Ophthalmic Photography 3D Coordinates Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.6" iod=""/>
+    <mapping sop-class-name="VL Whole Slide Microscopy Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.6" iod=""/>
+    <mapping sop-class-name="Lensometry Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.1" iod=""/>
+    <mapping sop-class-name="Autorefraction Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.2" iod=""/>
+    <mapping sop-class-name="Keratometry Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.3" iod=""/>
+    <mapping sop-class-name="Subjective Refraction Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.4" iod=""/>
+    <mapping sop-class-name="Visual Acuity Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.5" iod=""/>
+    <mapping sop-class-name="Spectacle Prescription Report Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.6" iod=""/>
+    <mapping sop-class-name="Ophthalmic Axial Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.7" iod=""/>
+    <mapping sop-class-name="Intraocular Lens Calculations Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.8" iod=""/>
+    <mapping sop-class-name="Macular Grid Thickness and Volume Report" sop-class-uid="1.2.840.10008.5.1.4.1.1.79.1" iod=""/>
+    <mapping sop-class-name="Ophthalmic Visual Field Static Perimetry Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.80.1" iod=""/>
+    <mapping sop-class-name="Ophthalmic Thickness Map Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.81.1" iod=""/>
+    <mapping sop-class-name="Corneal Topography Map Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.82.1" iod=""/>
+    <mapping sop-class-name="Basic Text SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.11" iod=""/>
+    <mapping sop-class-name="Enhanced SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.22" iod=""/>
+    <mapping sop-class-name="Comprehensive SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.33" iod=""/>
+    <mapping sop-class-name="Comprehensive 3D SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.34" iod=""/>
+    <mapping sop-class-name="Extensible SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.35" iod=""/>
+    <mapping sop-class-name="Procedure Log Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.40" iod=""/>
+    <mapping sop-class-name="Mammography CAD SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.50" iod=""/>
+    <mapping sop-class-name="Key Object Selection Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.59" iod=""/>
+    <mapping sop-class-name="Chest CAD SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.65" iod=""/>
+    <mapping sop-class-name="X-Ray Radiation Dose SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.67" iod=""/>
+    <mapping sop-class-name="Radiopharmaceutical Radiation Dose SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.68" iod=""/>
+    <mapping sop-class-name="Colon CAD SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.69" iod=""/>
+    <mapping sop-class-name="Implantation Plan SR Document Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.70" iod=""/>
+    <mapping sop-class-name="Acquisition Context SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.71" iod=""/>
+    <mapping sop-class-name="Simplified Adult Echo SR Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.72" iod=""/>
+    <mapping sop-class-name="Content Assessment Results Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.90.1" iod=""/>
+    <mapping sop-class-name="Encapsulated PDF Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.104.1" iod=""/>
+    <mapping sop-class-name="Encapsulated CDA Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.104.2" iod=""/>
     <mapping sop-class-name="Positron Emission Tomography Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.128" iod=""/>
-    <mapping sop-class-name="Enhanced PET Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.130" iod="Enhanced PET Image"/>
-    <mapping sop-class-name="Basic Structured Display Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.131" iod="Basic Structured Display IOD"/>
+    <mapping sop-class-name="Enhanced PET Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.130" iod="(see B.5.1.16)"/>
+    <mapping sop-class-name="Legacy Converted Enhanced PET Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.128.1" iod=""/>
+    <mapping sop-class-name="Basic Structured Display Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.131" iod=""/>
+    <mapping sop-class-name="CT Performed Procedure Protocol Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.200.2" iod=""/>
     <mapping sop-class-name="RT Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.1" iod=""/>
     <mapping sop-class-name="RT Dose Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.2" iod=""/>
     <mapping sop-class-name="RT Structure Set Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.3" iod=""/>
@@ -117,103 +172,31 @@
     <mapping sop-class-name="RT Plan Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.5" iod=""/>
     <mapping sop-class-name="RT Brachy Treatment Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.6" iod=""/>
     <mapping sop-class-name="RT Treatment Summary Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.7" iod=""/>
-    <mapping sop-class-name="RT Ion Plan Storage  " sop-class-uid="1.2.840.10008.5.1.4.1.1.481.8" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Ion Beams Treatment Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.9" iod="IOD defined in PS 3.3"/>
+    <mapping sop-class-name="RT Ion Plan Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.8" iod=""/>
+    <mapping sop-class-name="RT Ion Beams Treatment Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.9" iod=""/>
+    <mapping sop-class-name="RT Beams Delivery Instruction Storage" sop-class-uid="1.2.840.10008.5.1.4.34.7" iod=""/>
+    <mapping sop-class-name="RT Brachy Application Setup Delivery Instruction Storage" sop-class-uid="1.2.840.10008.5.1.4.34.10" iod=""/>
   </standard-sop-classes>
+  <retired-standard-sop-classes>
+    <mapping sop-class-name="Nuclear Medicine Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.5" iod=""/>
+    <mapping sop-class-name="Ultrasound Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.6" iod=""/>
+    <mapping sop-class-name="Ultrasound Multi-frame Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.3" iod=""/>
+    <mapping sop-class-name="X-Ray Angiographic Bi-plane Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.3" iod=""/>
+  </retired-standard-sop-classes>
+  <modality-specific-sop-class-conversions>
+    <mapping sop-class-name="CT Image Storage" sop-class-uid="Enhanced CT Image Storage" iod=""/>
+    <mapping sop-class-name="MR Image Storage" sop-class-uid="Enhanced MR Image Storage" iod=""/>
+    <mapping sop-class-name="PET Image Storage" sop-class-uid="Enhanced PET Image Storage" iod=""/>
+  </modality-specific-sop-class-conversions>
   <media-storage-standard-sop-classes>
-    <mapping sop-class-name="Media Storage Directory Storage" sop-class-uid="1.2.840.10008.1.3.10" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Computed Radiography Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Digital X-Ray Image Storage – For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.1" iod="DX IOD"/>
-    <mapping sop-class-name="Digital X-Ray Image Storage – For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.1.1" iod="DX IOD"/>
-    <mapping sop-class-name="Digital Mammography Image Storage – For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.2" iod="Digital Mammography IOD"/>
-    <mapping sop-class-name="Digital Mammography Image Storage – For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.2.1" iod="Digital Mammography IOD"/>
-    <mapping sop-class-name="Digital Intra-oral X-Ray Image Storage – For Presentation" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.3" iod="Digital Intra-oral X-Ray IOD"/>
-    <mapping sop-class-name="Digital Intra-oral X-Ray Image Storage – For Processing" sop-class-uid="1.2.840.10008.5.1.4.1.1.1.3.1" iod="Digital Intra-oral X-Ray IOD"/>
-    <mapping sop-class-name="CT Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.2" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Enhanced CT Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.2.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Ultrasound Multi-frame Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.3.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="MR Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Enhanced MR Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="MR Spectroscopy Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.2" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Enhanced MR Color Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.4.3" iod="Enhanced MR Color Image"/>
-    <mapping sop-class-name="Ultrasound Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.6.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Enhanced US Volume Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.6.2" iod="Enhanced US Volume"/>
-    <mapping sop-class-name="Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Multi-frame Single Bit Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.1" iod="Multi-frame Single Bit Secondary Capture Image"/>
-    <mapping sop-class-name="Multi-frame Grayscale Byte Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.2" iod="Multi-frame Grayscale Byte Secondary Capture Image"/>
-    <mapping sop-class-name="Multi-frame Grayscale Word Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.3" iod="Multi-frame Grayscale Word Secondary Capture Image"/>
-    <mapping sop-class-name="Multi-frame True Color Secondary Capture Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.7.4" iod="Multi-frame True Color Secondary Capture Image"/>
-    <mapping sop-class-name="12-lead ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.1" iod="12-lead ECG Waveform "/>
-    <mapping sop-class-name="General ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.2" iod="General ECG Waveform "/>
-    <mapping sop-class-name="Ambulatory ECG Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.1.3" iod="Ambulatory ECG Waveform"/>
-    <mapping sop-class-name="Hemodynamic Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.2.1" iod="Hemodynamic Waveform"/>
-    <mapping sop-class-name="Cardiac Electrophysiology Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.3.1" iod="Cardiac Electrophysiology Waveform"/>
-    <mapping sop-class-name="Basic Voice Audio Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.4.1" iod="Basic Voice Audio Waveform"/>
-    <mapping sop-class-name="General Audio Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.4.2" iod="General Audio Waveform"/>
-    <mapping sop-class-name="Arterial Pulse Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.5.1" iod="Arterial Pulse Waveform"/>
-    <mapping sop-class-name="Respiratory Waveform Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.9.6.1" iod="Respiratory Waveform"/>
-    <mapping sop-class-name="Grayscale Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.1" iod="Grayscale Softcopy Presentation State Storage"/>
-    <mapping sop-class-name="Color Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.2" iod="Color Softcopy Presentation State"/>
-    <mapping sop-class-name="Pseudo-Color Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.3" iod="Pseudo-Color Softcopy Presentation State"/>
-    <mapping sop-class-name="Blending Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.4" iod="Blending Softcopy Presentation State"/>
-    <mapping sop-class-name="XA/XRF Grayscale Softcopy Presentation State Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.11.5" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="X-Ray Angiographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Enhanced XA Image Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.12.1.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="X-Ray Radiofluoroscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.2" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Enhanced XRF Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.12.2.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="X-Ray 3D Angiographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.1" iod="X-Ray 3D Angiographic Image"/>
-    <mapping sop-class-name="X-Ray 3D Craniofacial Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.2" iod="X-Ray 3D Craniofacial Image"/>
-    <mapping sop-class-name="Breast Tomosynthesis Image Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.13.1.3" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Nuclear Medicine Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.20" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Raw Data Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Spatial Registration Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.1" iod="Spatial Registration "/>
-    <mapping sop-class-name="Spatial Fiducials Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.2" iod="Spatial Fiducials "/>
-    <mapping sop-class-name="Deformable Spatial Registration Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.3" iod="Deformable Spatial Registration"/>
-    <mapping sop-class-name="Segmentation Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.4" iod="Segmentation"/>
-    <mapping sop-class-name="Surface Segmentation Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.66.5" iod="Surface Segmentation"/>
-    <mapping sop-class-name="Real World Value Mapping Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.67" iod="Real World Value Mapping"/>
-    <mapping sop-class-name="VL Endoscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.1" iod="VL Endoscopic Image"/>
-    <mapping sop-class-name="Video Endoscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.1.1" iod="Video Endoscopic Image"/>
-    <mapping sop-class-name="VL Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.2" iod="VL Microscopic Image"/>
-    <mapping sop-class-name="Video Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.2.1" iod="Video Microscopic Image"/>
-    <mapping sop-class-name="VL Slide-Coordinates Microscopic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.3" iod="VL Slide-Coordinates Microscopic Image"/>
-    <mapping sop-class-name="VL Photographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.4" iod="VL Photographic Image"/>
-    <mapping sop-class-name="Video Photographic Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.4.1" iod="Video Photographic Image"/>
-    <mapping sop-class-name="Ophthalmic Photography 8 Bit Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.1" iod="Ophthalmic Photography 8 Bit Image"/>
-    <mapping sop-class-name="Ophthalmic Photography 16 Bit Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.2" iod="Ophthalmic Photography 16 Bit Image"/>
-    <mapping sop-class-name="Stereometric Relationship Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.3" iod="Stereometric Relationship"/>
-    <mapping sop-class-name="Ophthalmic Tomography  Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.77.1.5.4" iod="Ophthalmic Tomography Image"/>
-    <mapping sop-class-name="Lensometry Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.1" iod="Lensometry Measurements"/>
-    <mapping sop-class-name="Autorefraction Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.2" iod="Autorefraction Measurements"/>
-    <mapping sop-class-name="Keratometry Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.3" iod="Keratometry Measurements"/>
-    <mapping sop-class-name="Subjective Refraction Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.4" iod="Subjective Refraction Measurements"/>
-    <mapping sop-class-name="Visual Acuity Storage Measurements Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.5" iod="Visual Acuity Measurements"/>
-    <mapping sop-class-name="Spectacle Prescription  Report Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.78.6" iod="Spectacle Prescription Report"/>
-    <mapping sop-class-name="Macular Grid Thickness and Volume Report" sop-class-uid="1.2.840.10008.5.1.4.1.1.79.1" iod="Macular Grid Thickness and Volume Report"/>
-    <mapping sop-class-name="Basic Text SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.11" iod="Basic Text SR"/>
-    <mapping sop-class-name="Enhanced SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.22" iod="Enhanced SR"/>
-    <mapping sop-class-name="Comprehensive SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.33" iod="Comprehensive SR"/>
-    <mapping sop-class-name="Procedure Log" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.40" iod="Procedure Log"/>
-    <mapping sop-class-name="Mammography CAD SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.50" iod="Mammography CAD SR IOD"/>
-    <mapping sop-class-name="Key Object Selection Document" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.59" iod="Key Object Selection Document"/>
-    <mapping sop-class-name="Chest CAD SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.65" iod="Chest CAD SR IOD"/>
-    <mapping sop-class-name="X-Ray Radiation Dose SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.67" iod="X-Ray Radiation Dose SR"/>
-    <mapping sop-class-name="Colon CAD SR" sop-class-uid="1.2.840.10008.5.1.4.1.1.88.69" iod="Colon CAD SR IOD"/>
-    <mapping sop-class-name="Encapsulated PDF Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.104.1" iod="Encapsulated PDF IOD"/>
-    <mapping sop-class-name="Encapsulated CDA Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.104.2" iod="Encapsulated CDA IOD"/>
-    <mapping sop-class-name="Positron Emission Tomography Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.128" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Enhanced PET Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.130" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Basic Structured Display Storage " sop-class-uid="1.2.840.10008.5.1.4.1.1.131" iod="Basic Structured Display IOD"/>
-    <mapping sop-class-name="RT Image Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.1" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Dose Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.2" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Structure Set Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.3" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Beams Treatment Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.4" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Plan Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.5" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Brachy Treatment Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.6" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Treatment Summary Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.7" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Ion Plan Storage  " sop-class-uid="1.2.840.10008.5.1.4.1.1.481.8" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="RT Ion Beams Treatment Record Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.481.9" iod="IOD defined in PS 3.3"/>
-    <mapping sop-class-name="Hanging Protocol Storage" sop-class-uid="1.2.840.10008.5.1.4.38.1" iod="Hanging Protocol IOD"/>
-    <mapping sop-class-name="Color Palette Storage" sop-class-uid="1.2.840.10008.5.1.4.39.1" iod="Color Palette IOD"/>
+    <mapping sop-class-name="Media Storage Directory Storage" sop-class-uid="1.2.840.10008.1.3.10" iod=""/>
   </media-storage-standard-sop-classes>
+  <standard-sop-classes2>
+    <mapping sop-class-name="Hanging Protocol Storage" sop-class-uid="1.2.840.10008.5.1.4.38.1" iod=""/>
+    <mapping sop-class-name="Color Palette Storage" sop-class-uid="1.2.840.10008.5.1.4.39.1" iod=""/>
+    <mapping sop-class-name="Generic Implant Template Storage" sop-class-uid="1.2.840.10008.5.1.4.43.1" iod=""/>
+    <mapping sop-class-name="Implant Assembly Template Storage" sop-class-uid="1.2.840.10008.5.1.4.44.1" iod=""/>
+    <mapping sop-class-name="Implant Template Group Storage" sop-class-uid="1.2.840.10008.5.1.4.45.1" iod=""/>
+    <mapping sop-class-name="CT Defined Procedure Protocol Storage" sop-class-uid="1.2.840.10008.5.1.4.1.1.200.1" iod=""/>
+  </standard-sop-classes2>
 </sop-classes>
diff --git a/Source/InformationObjectDefinition/Part4.xsl b/Source/InformationObjectDefinition/Part4.xsl
index 5c72494..88a32b2 100644
--- a/Source/InformationObjectDefinition/Part4.xsl
+++ b/Source/InformationObjectDefinition/Part4.xsl
@@ -1,87 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-  <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
-<!--
-  Program: GDCM (Grassroots DICOM). A DICOM library
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0" xmlns:dk="http://docbook.org/ns/docbook" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="dk">
+<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8" indent="no" />
 
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+<!--
+<xsl:template match="/">
+<xsl:text>
+</xsl:text>
 
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
--->
-<!-- how to run:
-$ xsltproc ../trunk/Source/InformationObjectDefinition/Part4.xsl ./standard/2008/08_04pu.xml
+  <xsl:apply-templates select="*/*/*/*/*/dk:table[@xml:id='table_B.3-3']" />
+  <xsl:apply-templates select="*/*/*/dk:table[@xml:id='table_B.5-1']" />
+  <xsl:apply-templates select="*/*/*/dk:table[@xml:id='table_I.4-1']" />
+</xsl:template>
 -->
 <xsl:template match="text()" />
-  <xsl:template match="informaltable">
-	  <!--xsl:if test="tgroup/tbody/row/entry/para = 'SOP Class Name'"-->
-	  <!--xsl:if test="tgroup/tbody/row/entry/para = 'SOP Class UID'"-->
-	  <xsl:if test="tgroup/tbody/row/entry/para = 'Related General SOP Class Name'">
-    <standard-and-related-general-sop-classes>
-      <xsl:apply-templates/>
-    </standard-and-related-general-sop-classes>
-	  </xsl:if>
-	  <xsl:if test="tgroup/tbody/row/entry/para = 'IOD Specification'">
-    <media-storage-standard-sop-classes>
-      <xsl:apply-templates/>
-    </media-storage-standard-sop-classes>
-	  </xsl:if>
-	  <xsl:if test="tgroup/tbody/row/entry/para = 'IOD Specification(defined in PS 3.3)'">
-    <standard-sop-classes>
-      <xsl:apply-templates/>
-    </standard-sop-classes>
-	  </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="para">
-    <!--xsl:apply-templates/-->
-  </xsl:template>
-
-  <xsl:template match="tgroup">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="tbody">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="article">
-    <xsl:variable name="section-number" select="'Table B.5-1STANDARD SOP CLASSES'"/>
-    <xsl:variable name="section-anchor" select="para[starts-with(normalize-space(.),$section-number)]"/>
-    <xsl:message><xsl:value-of select="$section-anchor"/></xsl:message>
-	    <!--xsl:apply-templates select="article/sect1/sect2/informaltable"/-->
-	    <!--xsl:apply-templates select="informaltable"/-->
-	    <!--xsl:apply-templates select="sect1/sect2/informaltable"/-->
-	    <!--xsl:apply-templates select="article/informaltable"/-->
-    <sop-classes>
-	    <xsl:apply-templates select="informaltable"/>
-    </sop-classes>
-  </xsl:template>
-
-  <xsl:template match="row">
-    <!--xsl:apply-templates/-->
-    <xsl:variable name="classname" select="entry[1]/para"/>
-    <xsl:variable name="classuid" select="entry[2]/para"/>
-    <xsl:variable name="iod" select="entry[3]/para"/>
-    <xsl:if test="$classname != 'SOP Class Name'">
-    <mapping sop-class-name="{$classname}" sop-class-uid="{normalize-space($classuid)}" iod="{$iod}" />
-    </xsl:if>
-  </xsl:template>
-
-  <!--
-  <xsl:template match="entry">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="para">
-    <xsl:value-of select="."/>
-  </xsl:template>
-  -->
-
-  <xsl:template match="/">
+
+<!--
+<xsl:template match="@*|node()">
+  <xsl:copy>
+   <xsl:apply-templates select="@*|node()" />
+  </xsl:copy>
+</xsl:template>
+-->
+<xsl:template match="dk:caption" />
+
+<xsl:template match="dk:book" >
     <xsl:comment>
   Program: GDCM (Grassroots DICOM). A DICOM library
 
@@ -93,6 +35,157 @@ $ xsltproc ../trunk/Source/InformationObjectDefinition/Part4.xsl ./standard/2008
      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
      PURPOSE.  See the above copyright notice for more information.
 </xsl:comment>
-     <xsl:apply-templates select="article"/>
- </xsl:template>
+
+  <sop-classes>
+   <xsl:apply-templates />
+</sop-classes>
+</xsl:template>
+
+<!-- skip those table -->
+<!--
+<xsl:template match="dk:table[@xml:id='table_B.2-1']"/>
+<xsl:template match="dk:table[@xml:id='table_B.3-1']"/>
+<xsl:template match="dk:table[@xml:id='table_B.3-2']"/>
+<xsl:template match="dk:table[@xml:id='table_B.4-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.1.2-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.3-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.4-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.4-2']"/>
+<xsl:template match="dk:table[@xml:id='table_C.4-3']"/>
+<xsl:template match="dk:table[@xml:id='table_C.5-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.5-2']"/>
+<xsl:template match="dk:table[@xml:id='table_C.5-3']"/>
+<xsl:template match="dk:table[@xml:id='table_C.5-4']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6.1-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6-2']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6-3']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6-4']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6.1.3-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6.2-1']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6-5']"/>
+<xsl:template match="dk:table[@xml:id='table_C.6.2.3-1']"/>
+<xsl:template match="dk:table[@xml:id='table_F.1-3']"/>
+<xsl:template match="dk:table[@xml:id='table_F.1-4']"/>
+<xsl:template match="dk:table[@xml:id='table_F.7.1-1']"/>
+<xsl:template match="dk:table[@xml:id='table_F.7.2-1']"/>
+<xsl:template match="dk:table[@xml:id='table_F.7.2-2']"/>
+-->
+<xsl:template match="dk:table"/>
+
+<!-- do not skip the following tables -->
+<xsl:template match="dk:table[@xml:id='table_B.3-3']">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <standard-and-related-general-sop-classes>
+   <xsl:apply-templates />
+  </standard-and-related-general-sop-classes>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_B.5-1']">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <standard-sop-classes>
+   <xsl:apply-templates />
+  </standard-sop-classes>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_B.6-1']">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <retired-standard-sop-classes>
+   <xsl:apply-templates />
+  </retired-standard-sop-classes>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_C.3.5-1']">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+  <modality-specific-sop-class-conversions>
+   <xsl:apply-templates />
+  </modality-specific-sop-class-conversions>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_I.4-1']">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+    <media-storage-standard-sop-classes>
+   <xsl:apply-templates />
+    </media-storage-standard-sop-classes>
+</xsl:template>
+
+<xsl:template match="dk:table[@xml:id='table_GG.3-1']">
+  <xsl:variable name="caption" select="dk:caption"/>
+<xsl:text>
+</xsl:text>
+    <standard-sop-classes2>
+   <xsl:apply-templates />
+    </standard-sop-classes2>
+</xsl:template>
+
+
+<xsl:template match="dk:tr" >
+  <xsl:variable name="sopclassname" select="dk:td[1]/dk:para/text()"/>
+  <xsl:variable name="classuid" select="translate(dk:td[2]/dk:para/text(),'&#x200B;','')"/>
+<!--
+  <xsl:variable name="iod" select="dk:td[3]/dk:para/dk:emphasis | dk:td[3]/dk:para[not(dk:emphasis)]"/>
+-->
+  <xsl:variable name="iodtext" select="dk:td[3]/dk:para[1]/dk:olink/@targetptr"/>
+  <xsl:variable name="iodlink" select="dk:td[3]/dk:para[2]/dk:xref/@linkend"/>
+<!--
+<xsl:choose>
+-->
+  <xsl:variable name="iod" >
+    <xsl:choose>
+    <xsl:when test="$iodtext = 'sect_A.26'">
+       <xsl:text>DX IOD </xsl:text>
+    </xsl:when>
+    <xsl:when test="$iodtext = 'sect_A.27'">
+       <xsl:text>Digital Mammography IOD </xsl:text>
+    </xsl:when>
+    <xsl:when test="$iodtext = 'sect_A.28'">
+       <xsl:text>Digital Intra-oral X-Ray IOD </xsl:text>
+    </xsl:when>
+    <xsl:when test="$iodtext = 'sect_A.38.1'">
+       <xsl:text>Enhanced CT Image </xsl:text>
+    </xsl:when>
+    <xsl:when test="$iodtext = 'sect_A.36.2'">
+       <xsl:text>Enhanced MR Image </xsl:text>
+    </xsl:when>
+    <xsl:when test="$iodtext = 'sect_A.36.3'">
+       <xsl:text>MR Spectroscopy</xsl:text>
+    </xsl:when>
+    <xsl:when test="$iodtext = 'sect_A.36.4'">
+       <xsl:text>Enhanced MR Color Image</xsl:text>
+    </xsl:when>
+    <xsl:when test="$iodtext = 'sect_A.59'">
+       <xsl:text>Enhanced US Volume</xsl:text>
+    </xsl:when>
+<!--
+    <xsl:otherwise>
+       <xsl:value-of select="'BLA'"/>
+    </xsl:otherwise>
+-->
+    </xsl:choose>
+    <xsl:if test="$iodlink!= ''">
+<xsl:value-of select="concat(translate($iodlink,'sect_','(see '),')')"/>
+  </xsl:if>
+  </xsl:variable>
+<!--
+    </xsl:when>
+    <xsl:otherwise>
+  <xsl:variable name="iod"/>
+    </xsl:otherwise>
+</xsl:choose>
+-->
+    <xsl:if test="$sopclassname != ''">
+  <mapping sop-class-name="{$sopclassname}" sop-class-uid="{$classuid}" iod="{$iod}"/>
+</xsl:if>
+</xsl:template>
+
 </xsl:stylesheet>
diff --git a/Source/InformationObjectDefinition/gdcmTableReader.cxx b/Source/InformationObjectDefinition/gdcmTableReader.cxx
index da642f6..2766be8 100644
--- a/Source/InformationObjectDefinition/gdcmTableReader.cxx
+++ b/Source/InformationObjectDefinition/gdcmTableReader.cxx
@@ -386,6 +386,18 @@ void TableReader::StartElement(const char *name, const char **atts)
     {
     // TODO !
     }
+  else if ( strcmp(name,"retired-standard-sop-classes") == 0 )
+    {
+    // TODO !
+    }
+  else if ( strcmp(name,"modality-specific-sop-class-conversions") == 0 )
+    {
+    // TODO !
+    }
+  else if ( strcmp(name,"standard-sop-classes2") == 0 )
+    {
+    // TODO !
+    }
   else
     {
     assert(0);
@@ -508,6 +520,18 @@ void TableReader::EndElement(const char *name)
     {
     // TODO !
     }
+  else if ( strcmp(name,"retired-standard-sop-classes") == 0 )
+    {
+    // TODO !
+    }
+  else if ( strcmp(name,"modality-specific-sop-class-conversions") == 0 )
+    {
+    // TODO !
+    }
+  else if ( strcmp(name,"standard-sop-classes2") == 0 )
+    {
+    // TODO !
+    }
   else if( strcmp(name, "include" ) == 0 )
     {
     if( ParsingModule )
diff --git a/Source/MediaStorageAndFileFormat/CMakeLists.txt b/Source/MediaStorageAndFileFormat/CMakeLists.txt
index c531eb8..c408a17 100644
--- a/Source/MediaStorageAndFileFormat/CMakeLists.txt
+++ b/Source/MediaStorageAndFileFormat/CMakeLists.txt
@@ -92,16 +92,8 @@ set(MSFF_SRCS
   gdcmSurfaceReader.cxx
   gdcmSurfaceHelper.cxx
   gdcmSegmentHelper.cxx
+  gdcmJPEG2000Codec.cxx
   )
-if(OPENJPEG_VERSION VERSION_LESS 2.0)
-  list(APPEND MSFF_SRCS
-    gdcmJPEG2000Codec.cxx
-  )
-else ()
-  list(APPEND MSFF_SRCS
-    gdcmOpenJPEG2Codec.cxx
-  )
-endif()
 
   list(APPEND MSFF_SRCS
     ${GDCM_SOURCE_DIR}/Utilities/gdcmrle/rle.cxx
@@ -123,7 +115,7 @@ if(NOT BUILD_SHARED_LIBS)
 else()
   set_source_files_properties(gdcmJPEGLSCodec.cxx
                               PROPERTIES
-                              COMPILE_FLAGS -DCHARLS_SHARED
+                              COMPILE_FLAGS -DCHARLS_DLL
                               )
 endif()
 
@@ -159,15 +151,10 @@ if(GDCM_USE_SYSTEM_OPENJPEG)
 else()
   include_directories(
   "${GDCM_BINARY_DIR}/Utilities/gdcmopenjpeg"
+  "${GDCM_BINARY_DIR}/Utilities/gdcmopenjpeg/src/lib/openjp2"
     )
-if(GDCM_USE_OPENJPEG_V2)
-  INCLUDE_DIRECTORIES(
-  "${GDCM_BINARY_DIR}/Utilities/gdcmopenjpeg-v2"
-    )
-endif()
 endif()
 if(GDCM_USE_SYSTEM_LJPEG)
-  #message(${LJPEG_INCLUDE_DIRS} )
   include_directories(${LJPEG_INCLUDE_DIRS} )
 endif()
 if(NOT GDCM_USE_SYSTEM_ZLIB)
diff --git a/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx b/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx
index 353e40d..bcb23fe 100644
--- a/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx
@@ -124,7 +124,7 @@ bool Anonymizer::Replace( Tag const &t, const char *value, VL const & vl )
   DataSet &ds = F->GetDataSet();
   // Let's do the private tag:
   bool ret = false;
-  if ( t.IsPrivate() )
+  if ( t.IsPrivate() && !t.IsPrivateCreator() )
     {
     // Only one operation is allowed: making a private tag empty ...
     if ( vl == 0 )
@@ -162,7 +162,7 @@ bool Anonymizer::Replace( Tag const &t, const char *value, VL const & vl )
   else
     {
     // Ok this is a public element
-    assert( t.IsPublic() );
+    assert( t.IsPublic() || t.IsPrivateCreator() );
     const DictEntry &dictentry = dicts.GetDictEntry(t);
     if ( dictentry.GetVR() == VR::INVALID
       || dictentry.GetVR() == VR::UN
diff --git a/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx b/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx
index bd4ece5..85940f7 100644
--- a/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx
@@ -426,7 +426,9 @@ std::vector<double> ImageHelper::GetOriginValue(File const & f)
    || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
    || ms == MediaStorage::XRay3DAngiographicImageStorage
    || ms == MediaStorage::XRay3DCraniofacialImageStorage
-   || ms == MediaStorage::SegmentationStorage )
+   || ms == MediaStorage::SegmentationStorage
+   || ms == MediaStorage::IVOCTForProcessing
+   || ms == MediaStorage::IVOCTForPresentation)
     {
     const Tag t1(0x5200,0x9229);
     const Tag t2(0x5200,0x9230);
@@ -548,7 +550,9 @@ std::vector<double> ImageHelper::GetDirectionCosinesValue(File const & f)
    || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
    || ms == MediaStorage::XRay3DAngiographicImageStorage
    || ms == MediaStorage::XRay3DCraniofacialImageStorage
-   || ms == MediaStorage::SegmentationStorage )
+   || ms == MediaStorage::SegmentationStorage
+   || ms == MediaStorage::IVOCTForPresentation
+   || ms == MediaStorage::IVOCTForProcessing )
     {
     const Tag t1(0x5200,0x9229);
     const Tag t2(0x5200,0x9230);
@@ -860,7 +864,9 @@ void ImageHelper::SetDimensionsValue(File& f, const Pixmap & img)
    || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
    || ms == MediaStorage::XRay3DAngiographicImageStorage
    || ms == MediaStorage::XRay3DCraniofacialImageStorage
-   || ms == MediaStorage::SegmentationStorage )
+   || ms == MediaStorage::SegmentationStorage
+   || ms == MediaStorage::IVOCTForProcessing
+   || ms == MediaStorage::IVOCTForPresentation )
     {
       const Tag tfgs(0x5200,0x9230);
       if( ds.FindDataElement( tfgs ) )
@@ -1041,6 +1047,8 @@ Tag ImageHelper::GetSpacingTagFromMediaStorage(MediaStorage const &ms)
   case MediaStorage::PhilipsPrivateMRSyntheticImageStorage:
   case MediaStorage::VLPhotographicImageStorage: // VL Image IOD
   case MediaStorage::VLMicroscopicImageStorage:
+  case MediaStorage::IVOCTForProcessing:
+  case MediaStorage::IVOCTForPresentation:
     // (0028,0030) DS [2.0\2.0]                                #   8, 2 PixelSpacing
     t = Tag(0x0028,0x0030);
     break;
@@ -1192,7 +1200,9 @@ std::vector<double> ImageHelper::GetSpacingValue(File const & f)
     || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
     || ms == MediaStorage::XRay3DAngiographicImageStorage
     || ms == MediaStorage::XRay3DCraniofacialImageStorage
-    || ms == MediaStorage::SegmentationStorage )
+    || ms == MediaStorage::SegmentationStorage
+    || ms == MediaStorage::IVOCTForProcessing
+    || ms == MediaStorage::IVOCTForPresentation)
     {
     // <entry group="5200" element="9230" vr="SQ" vm="1" name="Per-frame Functional Groups Sequence"/>
     const Tag t1(0x5200,0x9229);
@@ -1462,7 +1472,9 @@ void ImageHelper::SetSpacingValue(DataSet & ds, const std::vector<double> & spac
    || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
    || ms == MediaStorage::XRay3DAngiographicImageStorage
    || ms == MediaStorage::XRay3DCraniofacialImageStorage
-   || ms == MediaStorage::SegmentationStorage )
+   || ms == MediaStorage::SegmentationStorage
+   || ms == MediaStorage::IVOCTForPresentation
+   || ms == MediaStorage::IVOCTForProcessing )
     {
 /*
     (0028,9110) SQ (Sequence with undefined length #=1)     # u/l, 1 PixelMeasuresSequence
@@ -1775,7 +1787,9 @@ void ImageHelper::SetOriginValue(DataSet & ds, const Image & image)
    && ms != MediaStorage::XRay3DCraniofacialImageStorage
    && ms != MediaStorage::EnhancedMRImageStorage
    && ms != MediaStorage::EnhancedPETImageStorage
-   && ms != MediaStorage::EnhancedCTImageStorage )
+   && ms != MediaStorage::EnhancedCTImageStorage
+   && ms != MediaStorage::IVOCTForPresentation
+   && ms != MediaStorage::IVOCTForProcessing )
     {
     // FIXME: should I remove the ipp tag ???
     return;
@@ -1788,7 +1802,9 @@ void ImageHelper::SetOriginValue(DataSet & ds, const Image & image)
    || ms == MediaStorage::XRay3DCraniofacialImageStorage
    || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
    || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
-   || ms == MediaStorage::SegmentationStorage )
+   || ms == MediaStorage::SegmentationStorage
+   || ms == MediaStorage::IVOCTForPresentation
+   || ms == MediaStorage::IVOCTForProcessing )
     {
 /*
     (0020,9113) SQ (Sequence with undefined length #=1)     # u/l, 1 PlanePositionSequence
@@ -1900,7 +1916,9 @@ void ImageHelper::SetDirectionCosinesValue(DataSet & ds, const std::vector<doubl
    && ms != MediaStorage::XRay3DCraniofacialImageStorage
    && ms != MediaStorage::EnhancedMRImageStorage
    && ms != MediaStorage::EnhancedPETImageStorage
-   && ms != MediaStorage::EnhancedCTImageStorage )
+   && ms != MediaStorage::EnhancedCTImageStorage
+   && ms != MediaStorage::IVOCTForPresentation
+   && ms != MediaStorage::IVOCTForProcessing )
     {
     // FIXME: should I remove the iop tag ???
     return;
@@ -1932,7 +1950,9 @@ void ImageHelper::SetDirectionCosinesValue(DataSet & ds, const std::vector<doubl
    || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
    || ms == MediaStorage::XRay3DAngiographicImageStorage
    || ms == MediaStorage::XRay3DCraniofacialImageStorage
-   || ms == MediaStorage::SegmentationStorage )
+   || ms == MediaStorage::SegmentationStorage
+   || ms == MediaStorage::IVOCTForPresentation
+   || ms == MediaStorage::IVOCTForProcessing )
     {
 /*
     (0020,9116) SQ (Sequence with undefined length #=1)     # u/l, 1 PlaneOrientationSequence
@@ -2043,7 +2063,9 @@ void ImageHelper::SetRescaleInterceptSlopeValue(File & f, const Image & img)
    && ms != MediaStorage::EnhancedPETImageStorage
    && ms != MediaStorage::XRay3DAngiographicImageStorage
    && ms != MediaStorage::XRay3DCraniofacialImageStorage
-   && ms != MediaStorage::SegmentationStorage )
+   && ms != MediaStorage::SegmentationStorage
+   && ms != MediaStorage::IVOCTForPresentation
+   && ms != MediaStorage::IVOCTForProcessing )
     {
     if( img.GetIntercept() != 0. || img.GetSlope() != 1. )
       {
diff --git a/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.cxx b/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.cxx
index 9ad6d91..494004b 100644
--- a/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.cxx
@@ -205,6 +205,22 @@ bool ImageRegionReader::ReadInformation()
   return true;
 }
 
+BoxRegion ImageRegionReader::ComputeBoundingBox()
+{
+  BoxRegion boundingbox;
+  if( Internals->GetRegion() )
+    boundingbox = this->Internals->GetRegion()->ComputeBoundingBox();
+  else
+    {
+    std::vector<unsigned int> dims = ImageHelper::GetDimensionsValue(GetFile());
+    boundingbox.SetDomain(
+      0, dims[0] - 1,
+      0, dims[1] - 1,
+      0, dims[2] - 1 );
+    }
+  return boundingbox;
+}
+
 bool ImageRegionReader::ReadRAWIntoBuffer(char *buffer, size_t buflen)
 {
   (void)buflen;
@@ -228,7 +244,7 @@ bool ImageRegionReader::ReadRAWIntoBuffer(char *buffer, size_t buflen)
   theCodec.SetDimensions(ImageHelper::GetDimensionsValue(GetFile()));
   std::istream* theStream = GetStreamPtr();
 
-  const BoxRegion &boundingbox = this->Internals->GetRegion()->ComputeBoundingBox();
+  BoxRegion boundingbox = ComputeBoundingBox();
   unsigned int xmin = boundingbox.GetXMin();
   unsigned int xmax = boundingbox.GetXMax();
   unsigned int ymin = boundingbox.GetYMin();
@@ -301,7 +317,7 @@ bool ImageRegionReader::ReadRLEIntoBuffer(char *buffer, size_t buflen)
     theCodec.SetNumberOfDimensions( 3 );
 
   std::istream* theStream = GetStreamPtr();
-  const BoxRegion &boundingbox = this->Internals->GetRegion()->ComputeBoundingBox();
+  BoxRegion boundingbox = ComputeBoundingBox();
   unsigned int xmin = boundingbox.GetXMin();
   unsigned int xmax = boundingbox.GetXMax();
   unsigned int ymin = boundingbox.GetYMin();
@@ -350,7 +366,7 @@ bool ImageRegionReader::ReadJPEG2000IntoBuffer(char *buffer, size_t buflen)
     theCodec.SetNumberOfDimensions( 3 );
 
   std::istream* theStream = GetStreamPtr();
-  const BoxRegion &boundingbox = this->Internals->GetRegion()->ComputeBoundingBox();
+  BoxRegion boundingbox = ComputeBoundingBox();
   unsigned int xmin = boundingbox.GetXMin();
   unsigned int xmax = boundingbox.GetXMax();
   unsigned int ymin = boundingbox.GetYMin();
@@ -400,17 +416,7 @@ bool ImageRegionReader::ReadJPEGIntoBuffer(char *buffer, size_t buflen)
   theCodec.SetPixelFormat( ImageHelper::GetPixelFormatValue(GetFile()) );
 
   std::istream* theStream = GetStreamPtr();
-  BoxRegion boundingbox;
-  if( Internals->GetRegion() )
-    boundingbox = this->Internals->GetRegion()->ComputeBoundingBox();
-  else
-  {
-    std::vector<unsigned int> dims = ImageHelper::GetDimensionsValue(GetFile());
-    boundingbox.SetDomain(
-      0, dims[0] - 1,
-      0, dims[1] - 1,
-      0, dims[2] - 1 );
-  }
+  BoxRegion boundingbox = ComputeBoundingBox();
   unsigned int xmin = boundingbox.GetXMin();
   unsigned int xmax = boundingbox.GetXMax();
   unsigned int ymin = boundingbox.GetYMin();
@@ -459,7 +465,7 @@ bool ImageRegionReader::ReadJPEGLSIntoBuffer(char *buffer, size_t buflen)
     theCodec.SetNumberOfDimensions( 3 );
 
   std::istream* theStream = GetStreamPtr();
-  const BoxRegion &boundingbox = this->Internals->GetRegion()->ComputeBoundingBox();
+  BoxRegion boundingbox = ComputeBoundingBox();
   unsigned int xmin = boundingbox.GetXMin();
   unsigned int xmax = boundingbox.GetXMax();
   unsigned int ymin = boundingbox.GetYMin();
diff --git a/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.h b/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.h
index 09f01d7..2f7d9f0 100644
--- a/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.h
+++ b/Source/MediaStorageAndFileFormat/gdcmImageRegionReader.h
@@ -59,6 +59,7 @@ protected:
   bool Read();
 
 private:
+  BoxRegion ComputeBoundingBox();
   bool ReadRAWIntoBuffer(char *buffer, size_t buflen);
   bool ReadRLEIntoBuffer(char *buffer, size_t buflen);
   bool ReadJPEG2000IntoBuffer(char *buffer, size_t buflen);
diff --git a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
index bff163a..66f4a61 100644
--- a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
@@ -25,24 +25,11 @@
 #define snprintf _snprintf
 #endif
 
-#ifdef OPENJPEG_MAJOR_VERSION
-#if OPENJPEG_MAJOR_VERSION == 1
 #include "gdcm_openjpeg.h"
-#elif OPENJPEG_MAJOR_VERSION == 2
-#define USE_OPJ_DEPRECATED // opj_setup_decoder
-#include "gdcm_openjpeg2.h"
-#else
-#error should not happen
-#endif
-#else
-#error should not happen
-#endif
 
 namespace gdcm
 {
 
-#if OPENJPEG_MAJOR_VERSION == 1
-#else
 /* Part 1  Table A.2 List of markers and marker segments */
 typedef enum {
   FF30 = 0xFF30,
@@ -233,15 +220,14 @@ static bool parsejp2_imp( const char * const stream, const size_t file_size, boo
         len64 = (size_t)(file_size - start + 8);
         }
       assert( len64 >= 8 );
-      return parsej2k_imp( cur, len64 - 8, lossless, mct );
+      return parsej2k_imp( cur, (size_t)(len64 - 8), lossless, mct );
       }
-      const size_t lenmarker = len64 - 8;
+      const size_t lenmarker = (size_t)(len64 - 8);
       cur += lenmarker;
     }
 
   return false;
 }
-#endif
 
 
 /**
@@ -270,13 +256,6 @@ void info_callback(const char *msg, void *) {
 #define JP2_CFMT 1
 #define JPT_CFMT 2
 
-#if OPENJPEG_MAJOR_VERSION == 1
-#define MJ2_CFMT 3
-#define PXM_DFMT 0
-#define PGX_DFMT 1
-#define BMP_DFMT 2
-#define YUV_DFMT 3
-#elif OPENJPEG_MAJOR_VERSION == 2
 #define PXM_DFMT 10
 #define PGX_DFMT 11
 #define BMP_DFMT 12
@@ -289,9 +268,7 @@ void info_callback(const char *msg, void *) {
 #define CODEC_J2K OPJ_CODEC_J2K
 #define CLRSPC_GRAY OPJ_CLRSPC_GRAY
 #define CLRSPC_SRGB OPJ_CLRSPC_SRGB
-#endif // OPENJPEG_MAJOR_VERSION == 1
 
-#if OPENJPEG_MAJOR_VERSION == 2
 struct myfile
 {
   char *mem;
@@ -301,19 +278,7 @@ struct myfile
 
 void gdcm_error_callback(const char* msg, void* )
 {
-#if 0
-  if( strcmp( msg, "Cannot read data with no size known, giving up\n" ) == 0 )
-    {
-    OPJ_UINT32 **s = (OPJ_UINT32**)f;
-    *s[1] = *s[0];
-    gdcmWarningMacro( "Recovering from odd J2K file" );
-    assert(0);
-    }
-  else
-#endif
-    {
-    fprintf( stderr, "%s", msg );
-    }
+  fprintf( stderr, "%s", msg );
 }
 
 
@@ -415,7 +380,6 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_memory_stream (myfile* p_mem,OPJ_SI
   return l_stream;
 }
 
-#endif // OPENJPEG_MAJOR_VERSION == 2
 
 /*
  * Divide an integer by a power of 2 and round upwards.
@@ -620,10 +584,6 @@ static inline bool check_comp_valid(opj_image_t *image)
     {
         opj_image_comp_t *comp1 = &image->comps[1];
         opj_image_comp_t *comp2 = &image->comps[2];
-#if OPENJPEG_MAJOR_VERSION == 1
-        if (comp->bpp != comp1->bpp) invalid = true;
-        if (comp->bpp != comp2->bpp) invalid = true;
-#endif // OPENJPEG_MAJOR_VERSION == 1
         if (comp->prec != comp1->prec) invalid = true;
         if (comp->prec != comp2->prec) invalid = true;
         if (comp->sgnd != comp1->sgnd) invalid = true;
@@ -639,14 +599,8 @@ static inline bool check_comp_valid(opj_image_t *image)
 std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffer, size_t buf_size)
 {
   opj_dparameters_t parameters;  /* decompression parameters */
-#if OPENJPEG_MAJOR_VERSION == 1
-  opj_event_mgr_t event_mgr;    /* event manager */
-  opj_dinfo_t* dinfo;  /* handle to a decompressor */
-  opj_cio_t *cio;
-#elif OPENJPEG_MAJOR_VERSION == 2
   opj_codec_t* dinfo = NULL;  /* handle to a decompressor */
   opj_stream_t *cio = NULL;
-#endif // OPENJPEG_MAJOR_VERSION == 1
   opj_image_t *image = NULL;
 
   unsigned char *src = (unsigned char*)dummy_buffer;
@@ -665,25 +619,9 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
   // what if 0xd9 is never found ?
   assert( file_length > 0 && src[file_length-1] == 0xd9 );
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  /* configure the event callbacks (not required) */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = info_callback;
-#endif // OPENJPEG_MAJOR_VERSION == 1
-
   /* set decoding parameters to default values */
   opj_set_default_decoder_parameters(&parameters);
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  // default blindly copied
-  parameters.cp_layer=0;
-  parameters.cp_reduce=0;
-  //   parameters.decod_format=-1;
-  //   parameters.cod_format=-1;
-#endif
-
   const char jp2magic[] = "\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A";
   if( memcmp( src, jp2magic, sizeof(jp2magic) ) == 0 )
     {
@@ -718,25 +656,6 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
     }
 
   int reversible;
-#if OPENJPEG_MAJOR_VERSION == 1
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL);
-
-  /* setup the decoder decoding parameters using user parameters */
-  opj_setup_decoder(dinfo, &parameters);
-
-  /* open a byte stream */
-  cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-  /* decode the stream and fill the image structure */
-  image = opj_decode(dinfo, cio);
-  if(!image) {
-    opj_destroy_decompress(dinfo);
-    opj_cio_close(cio);
-    gdcmErrorMacro( "opj_decode failed" );
-    return std::make_pair<char*,size_t>(0,0);
-  }
-#elif OPENJPEG_MAJOR_VERSION == 2
   myfile mysrc;
   myfile *fsrc = &mysrc;
   fsrc->mem = fsrc->cur = (char*)src;
@@ -767,23 +686,10 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
   OPJ_INT32 l_tile_x0,l_tile_y0;
   OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
 #endif
-#if 0
-  bResult = opj_read_header(
-    dinfo,
-    &image,
-    &l_tile_x0,
-    &l_tile_y0,
-    &l_tile_width,
-    &l_tile_height,
-    &l_nb_tiles_x,
-    &l_nb_tiles_y,
-    cio);
-#else
   bResult = opj_read_header(
     cio,
     dinfo,
     &image);
-#endif
   if( !bResult )
     {
     opj_destroy_codec(dinfo);
@@ -814,7 +720,6 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
     gdcmErrorMacro( "opj_decode failed" );
     return std::make_pair<char*,size_t>(0,0);
     }
-#endif // OPENJPEG_MAJOR_VERSION == 1
 
 #if 0
   if( image->color_space )
@@ -836,27 +741,6 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
     }
 #endif
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  opj_j2k_t* j2k = NULL;
-  opj_jp2_t* jp2 = NULL;
-
-  switch(parameters.decod_format)
-    {
-  case J2K_CFMT:
-    j2k = (opj_j2k_t*)dinfo->j2k_handle;
-    assert( j2k );
-    reversible = j2k->cp->tcps->tccps->qmfbid;
-    break;
-  case JP2_CFMT:
-    jp2 = (opj_jp2_t*)dinfo->jp2_handle;
-    assert( jp2 );
-    reversible = jp2->j2k->cp->tcps->tccps->qmfbid;
-    break;
-  default:
-    gdcmErrorMacro( "Impossible happen" );
-    return std::make_pair<char*,size_t>(0,0);
-    }
-#else
   bool b = false;
   bool lossless;
   bool mct;
@@ -869,37 +753,19 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
   if( b ) {
     reversible = lossless;
   }
-#endif // OPENJPEG_MAJOR_VERSION == 1
   LossyFlag = !reversible;
 
-#if 0
-#ifndef GDCM_USE_SYSTEM_OPENJPEG
-  if( j2k )
-    j2k_dump_cp(stdout, image, j2k->cp);
-  if( jp2 )
-    j2k_dump_cp(stdout, image, jp2->j2k->cp);
-#endif
-#endif
-
   assert( image->numcomps == this->GetPixelFormat().GetSamplesPerPixel() );
   assert( image->numcomps == this->GetPhotometricInterpretation().GetSamplesPerPixel() );
-#if OPENJPEG_MAJOR_VERSION == 1
-#else
   if( this->GetPhotometricInterpretation() == PhotometricInterpretation::RGB )
     assert( !mct );
   else if( this->GetPhotometricInterpretation() == PhotometricInterpretation::YBR_RCT )
-    assert( !mct );
+    assert( mct );
   else
     assert( !mct );
-#endif
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  /* close the byte stream */
-  opj_cio_close(cio);
-#elif OPENJPEG_MAJOR_VERSION == 2
   /* close the byte stream */
   opj_stream_destroy(cio);
-#endif // OPENJPEG_MAJOR_VERSION == 1
 
   // Copy buffer
   unsigned long len = Dimensions[0]*Dimensions[1] * (PF.GetBitsAllocated() / 8) * image->numcomps;
@@ -920,13 +786,6 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
     // -> prec = 12, bpp = 0, sgnd = 0
     //assert( wr == Dimensions[0] );
     //assert( hr == Dimensions[1] );
-#if OPENJPEG_MAJOR_VERSION == 1
-    if( comp->bpp == PF.GetBitsAllocated() )
-      {
-      gdcmWarningMacro( "BPP = " << comp->bpp << " vs BitsAllocated = " << PF.GetBitsAllocated() );
-      }
-#endif // OPENJPEG_MAJOR_VERSION == 1
-
     if( comp->sgnd != PF.GetPixelRepresentation() )
       {
       PF.SetPixelRepresentation( (uint16_t)comp->sgnd );
@@ -983,18 +842,11 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
       }
     }
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  /* free remaining structures */
-  if(dinfo) {
-    opj_destroy_decompress(dinfo);
-  }
-#elif OPENJPEG_MAJOR_VERSION == 2
   /* free remaining structures */
   if (dinfo)
     {
     opj_destroy_codec(dinfo);
     }
-#endif // OPENJPEG_MAJOR_VERSION == 1
 
   /* free image data structure */
   opj_image_destroy(image);
@@ -1150,8 +1002,9 @@ opj_image_t* rawtoimage(char *inputbuffer, opj_cparameters_t *parameters,
       rawtoimage_fill<uint32_t>((uint32_t*)inputbuffer,w,h,numcomps,image,pc);
       }
     }
-  else
+  else // dead branch ?
     {
+    opj_image_destroy(image);
     return NULL;
     }
 
@@ -1188,23 +1041,9 @@ bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t &
   bool bSuccess;
   //bool delete_comment = true;
   opj_cparameters_t parameters;  /* compression parameters */
-#if OPENJPEG_MAJOR_VERSION == 1
-  opj_event_mgr_t event_mgr;    /* event manager */
-#endif // OPENJPEG_MAJOR_VERSION == 1
   opj_image_t *image = NULL;
   //quality = 100;
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  /*
-  configure the event callbacks (not required)
-  setting of each callback is optionnal
-   */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = info_callback;
-#endif // OPENJPEG_MAJOR_VERSION == 1
-
   /* set encoding parameters to default values */
   //memset(&parameters, 0, sizeof(parameters));
   //opj_set_default_encoder_parameters(&parameters);
@@ -1227,16 +1066,10 @@ bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t &
     }
 
   if(parameters.cp_comment == NULL) {
-#if OPENJPEG_MAJOR_VERSION == 1
-    const char comment[] = "Created by GDCM/OpenJPEG version 1.4.0";
-    parameters.cp_comment = (char*)malloc(strlen(comment) + 1);
-    strcpy(parameters.cp_comment, comment);
-#else
     const char comment[] = "Created by GDCM/OpenJPEG version %s";
     const char * vers = opj_version();
     parameters.cp_comment = (char*)malloc(strlen(comment) + 10);
     snprintf( parameters.cp_comment, strlen(comment) + 10, comment, vers );
-#endif
     /* no need to delete parameters.cp_comment on exit */
     //delete_comment = false;
   }
@@ -1280,31 +1113,6 @@ bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t &
   /* ---------------------------- */
   parameters.cod_format = J2K_CFMT; /* J2K format output */
   size_t codestream_length;
-#if OPENJPEG_MAJOR_VERSION == 1
-  opj_cio_t *cio = NULL;
-
-  /* get a J2K compressor handle */
-  opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
-
-  /* setup the encoder parameters using the current image and using user parameters */
-  opj_setup_encoder(cinfo, &parameters, image);
-
-  /* open a byte stream for writing */
-  /* allocate memory for all tiles */
-  cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
-
-  /* encode the image */
-  bSuccess = opj_encode(cinfo, cio, image, parameters.index);
-  if (!bSuccess) {
-    opj_cio_close(cio);
-    fprintf(stderr, "failed to encode image\n");
-    return false;
-  }
-  codestream_length = cio_tell(cio);
-#elif OPENJPEG_MAJOR_VERSION == 2
   opj_codec_t* cinfo = 00;
   opj_stream_t *cio = 00;
 
@@ -1331,7 +1139,7 @@ bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t &
   /*if (*indexfilename)          // If need to extract codestream information
     bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
     else*/
-  bSuccess = opj_start_compress(cinfo,image,cio);
+  bSuccess = opj_start_compress(cinfo,image,cio) ? true : false;
   bSuccess = bSuccess && opj_encode(cinfo, cio);
   bSuccess = bSuccess && opj_end_compress(cinfo, cio);
 
@@ -1341,7 +1149,6 @@ bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t &
     return false;
     }
   codestream_length = mysrc.len;
-#endif // OPENJPEG_MAJOR_VERSION == 1
 
   /* write the buffer to disk */
   //f = fopen(parameters.outfile, "wb");
@@ -1364,19 +1171,6 @@ bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t &
 #endif
 
   bool success = false;
-#if OPENJPEG_MAJOR_VERSION == 1
-  if( codestream_length <= outlen )
-    {
-    success = true;
-    memcpy(outdata, (char*)(cio->buffer), codestream_length);
-    }
-
-  /* close and free the byte stream */
-  opj_cio_close(cio);
-
-  /* free remaining compression structures */
-  opj_destroy_compress(cinfo);
-#elif OPENJPEG_MAJOR_VERSION == 2
   if( codestream_length <= outlen )
     {
     success = true;
@@ -1389,7 +1183,6 @@ bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t &
 
   /* free remaining compression structures */
   opj_destroy_codec(cinfo);
-#endif // OPENJPEG_MAJOR_VERSION == 1
   complen = codestream_length;
 
   /* free user parameters structure */
@@ -1459,37 +1252,15 @@ bool JPEG2000Codec::GetHeaderInfo(std::istream &is, TransferSyntax &ts)
 bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, TransferSyntax &ts)
 {
   opj_dparameters_t parameters;  /* decompression parameters */
-#if OPENJPEG_MAJOR_VERSION == 1
-  opj_event_mgr_t event_mgr;    /* event manager */
-  opj_dinfo_t* dinfo;  /* handle to a decompressor */
-  opj_cio_t *cio;
-#elif OPENJPEG_MAJOR_VERSION == 2
   opj_codec_t* dinfo = NULL;  /* handle to a decompressor */
   opj_stream_t *cio = NULL;
-#endif // OPENJPEG_MAJOR_VERSION == 1
   opj_image_t *image = NULL;
   unsigned char *src = (unsigned char*)dummy_buffer;
   size_t file_length = buf_size;
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  /* configure the event callbacks (not required) */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = info_callback;
-#endif // OPENJPEG_MAJOR_VERSION == 1
-
   /* set decoding parameters to default values */
   opj_set_default_decoder_parameters(&parameters);
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  // default blindly copied
-  parameters.cp_layer=0;
-  parameters.cp_reduce=0;
-  //   parameters.decod_format=-1;
-  //   parameters.cod_format=-1;
-#endif
-
   const char jp2magic[] = "\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A";
   if( memcmp( src, jp2magic, sizeof(jp2magic) ) == 0 )
     {
@@ -1522,25 +1293,6 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
     return false;
     }
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL);
-
-  /* setup the decoder decoding parameters using user parameters */
-  opj_setup_decoder(dinfo, &parameters);
-
-  /* open a byte stream */
-  cio = opj_cio_open((opj_common_ptr)dinfo, src, (int)file_length);
-
-  /* decode the stream and fill the image structure */
-  image = opj_decode(dinfo, cio);
-  if(!image) {
-    opj_destroy_decompress(dinfo);
-    opj_cio_close(cio);
-    gdcmErrorMacro( "opj_decode failed" );
-    return false;
-  }
-#elif OPENJPEG_MAJOR_VERSION == 2
   myfile mysrc;
   myfile *fsrc = &mysrc;
   fsrc->mem = fsrc->cur = (char*)src;
@@ -1558,23 +1310,10 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
   OPJ_INT32 l_tile_x0,l_tile_y0;
   OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
 #endif
-#if 0
-  bResult = opj_read_header(
-    dinfo,
-    &image,
-    &l_tile_x0,
-    &l_tile_y0,
-    &l_tile_width,
-    &l_tile_height,
-    &l_nb_tiles_x,
-    &l_nb_tiles_y,
-    cio);
-#else
   bResult = opj_read_header(
     cio,
     dinfo,
-    &image);
-#endif
+    &image) ? true : false;
   if(!bResult)
   {
   opj_stream_destroy(cio);
@@ -1590,33 +1329,9 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
   //  gdcmErrorMacro( "opj_decode failed" );
   //  return false;
   //  }
-#endif // OPENJPEG_MAJOR_VERSION == 1
 
   int reversible;
   int mct = 0;
-#if OPENJPEG_MAJOR_VERSION == 1
-  opj_j2k_t* j2k = NULL;
-  opj_jp2_t* jp2 = NULL;
-
-  switch(parameters.decod_format)
-    {
-  case J2K_CFMT:
-    j2k = (opj_j2k_t*)dinfo->j2k_handle;
-    assert( j2k );
-    reversible = j2k->cp->tcps->tccps->qmfbid;
-    mct = j2k->cp->tcps->mct;
-    break;
-  case JP2_CFMT:
-    jp2 = (opj_jp2_t*)dinfo->jp2_handle;
-    assert( jp2 );
-    reversible = jp2->j2k->cp->tcps->tccps->qmfbid;
-    mct = jp2->j2k->cp->tcps->mct;
-    break;
-  default:
-    gdcmErrorMacro( "Impossible happen" );
-    return false;
-    }
-#else
 #if 0
   reversible = opj_get_reversible(dinfo, &parameters );
   assert( reversible == 0 || reversible == 1 );
@@ -1637,18 +1352,8 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
     mct = mctb;
   }
 #endif
-#endif // OPENJPEG_MAJOR_VERSION == 1
   LossyFlag = !reversible;
 
-#if 0
-#ifndef GDCM_USE_SYSTEM_OPENJPEG
-  if( j2k )
-    j2k_dump_cp(stdout, image, j2k->cp);
-  if( jp2 )
-    j2k_dump_cp(stdout, image, jp2->j2k->cp);
-#endif
-#endif
-
   int compno = 0;
   opj_image_comp_t *comp = &image->comps[compno];
 
@@ -1663,23 +1368,14 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
 
   if( comp->prec <= 8 )
     {
-#if OPENJPEG_MAJOR_VERSION == 1
-    if( comp->bpp ) assert( comp->bpp == 8 );
-#endif // OPENJPEG_MAJOR_VERSION == 1
     this->PF = PixelFormat( PixelFormat::UINT8 );
     }
   else if( comp->prec <= 16 )
     {
-#if OPENJPEG_MAJOR_VERSION == 1
-    if( comp->bpp ) assert( comp->bpp == 16 );
-#endif // OPENJPEG_MAJOR_VERSION == 1
     this->PF = PixelFormat( PixelFormat::UINT16 );
     }
   else if( comp->prec <= 32 )
     {
-#if OPENJPEG_MAJOR_VERSION == 1
-    if( comp->bpp ) assert( comp->bpp == 32 );
-#endif // OPENJPEG_MAJOR_VERSION == 1
     this->PF = PixelFormat( PixelFormat::UINT32 );
     }
   else
@@ -1797,18 +1493,6 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
     assert( this->GetPhotometricInterpretation().IsLossless() );
     }
 
-#if OPENJPEG_MAJOR_VERSION == 1
-  /* close the byte stream */
-  opj_cio_close(cio);
-
-  /* free the memory containing the code-stream */
-  //delete[] src;  //FIXME
-
-  /* free remaining structures */
-  if(dinfo) {
-    opj_destroy_decompress(dinfo);
-  }
-#elif OPENJPEG_MAJOR_VERSION == 2
   /* close the byte stream */
   opj_stream_destroy(cio);
   /* free remaining structures */
@@ -1816,7 +1500,6 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
     {
     opj_destroy_codec(dinfo);
     }
-#endif // OPENJPEG_MAJOR_VERSION == 1
 
   /* free image data structure */
   opj_image_destroy(image);
diff --git a/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx b/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx
index 201e8da..3773f33 100644
--- a/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx
@@ -230,9 +230,6 @@ Attribute<0x0028,0x0004> piat;
     }
 }
 
-// TODO: remove me
-bool PrepareWrite(){ return false; }
-
 bool PixmapWriter::PrepareWrite( MediaStorage const & ref_ms )
 {
   File& file = GetFile();
diff --git a/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.h b/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.h
index 642895c..5ec1bf5 100644
--- a/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.h
+++ b/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.h
@@ -55,7 +55,6 @@ public:
 
 protected:
   void DoIconImage(DataSet & ds, Pixmap const & image);
-  bool PrepareWrite();
   bool PrepareWrite( MediaStorage const & refms );
 
   SmartPointer<Pixmap> PixelData;
diff --git a/Source/MediaStorageAndFileFormat/gdcmRLECodec.cxx b/Source/MediaStorageAndFileFormat/gdcmRLECodec.cxx
index 5b4d328..86f688f 100644
--- a/Source/MediaStorageAndFileFormat/gdcmRLECodec.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmRLECodec.cxx
@@ -530,18 +530,10 @@ bool RLECodec::Code(DataElement const &in, DataElement &out)
     frag.SetByteValue( &str[0], strSize );
     sq->AddFragment( frag );
     }
-
   out.SetValue( *sq );
 
-  if( buffer /*GetPixelFormat().GetBitsAllocated() > 8*/ )
-    {
-    //RequestPaddedCompositePixelCode = true;
-    delete[] buffer;
-    }
-  if ( bufferrgb /*GetPhotometricInterpretation() == PhotometricInterpretation::RGB*/ )
-    {
-    delete[] bufferrgb;
-    }
+  delete[] buffer;
+  delete[] bufferrgb;
 
   return true;
 }
diff --git a/Source/MediaStorageAndFileFormat/gdcmSegment.cxx b/Source/MediaStorageAndFileFormat/gdcmSegment.cxx
index 6898538..5a8a756 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSegment.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmSegment.cxx
@@ -20,8 +20,9 @@ namespace gdcm
 {
 
 static const char * ALGOTypeStrings[] = {
-  "MANUAL",
   "AUTOMATIC",
+  "SEMIAUTOMATIC",
+  "MANUAL",
 
   0
 };
@@ -71,8 +72,10 @@ Segment::Segment():
   SegmentLabel(""),
   SegmentDescription(""),
   AnatomicRegion(),
+  AnatomicRegionModifiers(),
   PropertyCategory(),
   PropertyType(),
+  PropertyTypeModifiers(),
   SegmentAlgorithmType(ALGOType_END),
   SegmentAlgorithmName(""),
   SurfaceCount(0),
@@ -131,6 +134,21 @@ void Segment::SetAnatomicRegion(SegmentHelper::BasicCodedEntry const & BSE)
   AnatomicRegion.CM   = BSE.CM;
 }
 
+Segment::BasicCodedEntryVector const & Segment::GetAnatomicRegionModifiers() const
+{
+  return AnatomicRegionModifiers;
+}
+
+Segment::BasicCodedEntryVector & Segment::GetAnatomicRegionModifiers()
+{
+  return AnatomicRegionModifiers;
+}
+
+void Segment::SetAnatomicRegionModifiers(BasicCodedEntryVector const & BSEV)
+{
+    AnatomicRegionModifiers = BSEV;
+}
+
 SegmentHelper::BasicCodedEntry const & Segment::GetPropertyCategory() const
 {
   return PropertyCategory;
@@ -165,6 +183,21 @@ void Segment::SetPropertyType(SegmentHelper::BasicCodedEntry const & BSE)
   PropertyType.CM   = BSE.CM;
 }
 
+Segment::BasicCodedEntryVector const & Segment::GetPropertyTypeModifiers() const
+{
+  return PropertyTypeModifiers;
+}
+
+Segment::BasicCodedEntryVector & Segment::GetPropertyTypeModifiers()
+{
+  return PropertyTypeModifiers;
+}
+
+void Segment::SetPropertyTypeModifiers(BasicCodedEntryVector const & BSEV)
+{
+    PropertyTypeModifiers = BSEV;
+}
+
 Segment::ALGOType Segment::GetSegmentAlgorithmType() const
 {
   return SegmentAlgorithmType;
diff --git a/Source/MediaStorageAndFileFormat/gdcmSegment.h b/Source/MediaStorageAndFileFormat/gdcmSegment.h
index 78acfe4..88b132e 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSegment.h
+++ b/Source/MediaStorageAndFileFormat/gdcmSegment.h
@@ -35,10 +35,12 @@ class GDCM_EXPORT Segment : public Object
 public:
 
   typedef std::vector< SmartPointer< Surface > > SurfaceVector;
+  typedef std::vector< SegmentHelper::BasicCodedEntry > BasicCodedEntryVector;
 
   typedef enum {
-    MANUAL = 0,
-    AUTOMATIC,
+    AUTOMATIC = 0,
+    SEMIAUTOMATIC,
+    MANUAL,
     ALGOType_END
   } ALGOType;
 
@@ -64,6 +66,10 @@ public:
   SegmentHelper::BasicCodedEntry & GetAnatomicRegion();
   void SetAnatomicRegion(SegmentHelper::BasicCodedEntry const & BSE);
 
+  BasicCodedEntryVector const & GetAnatomicRegionModifiers() const;
+  BasicCodedEntryVector & GetAnatomicRegionModifiers();
+  void SetAnatomicRegionModifiers(BasicCodedEntryVector const & BSEV);
+
   SegmentHelper::BasicCodedEntry const & GetPropertyCategory() const;
   SegmentHelper::BasicCodedEntry & GetPropertyCategory();
   void SetPropertyCategory(SegmentHelper::BasicCodedEntry const & BSE);
@@ -72,6 +78,10 @@ public:
   SegmentHelper::BasicCodedEntry & GetPropertyType();
   void SetPropertyType(SegmentHelper::BasicCodedEntry const & BSE);
 
+  BasicCodedEntryVector const & GetPropertyTypeModifiers() const;
+  BasicCodedEntryVector & GetPropertyTypeModifiers();
+  void SetPropertyTypeModifiers(BasicCodedEntryVector const & BSEV);
+
   ALGOType GetSegmentAlgorithmType() const;
   void SetSegmentAlgorithmType(ALGOType type);
   void SetSegmentAlgorithmType(const char * typeStr);
@@ -101,10 +111,14 @@ protected :
 
   // General Anatomic Region
   SegmentHelper::BasicCodedEntry AnatomicRegion;
+  // General Anatomic Region Modifier
+  BasicCodedEntryVector AnatomicRegionModifiers;
   // Property Category Code
   SegmentHelper::BasicCodedEntry PropertyCategory;
   // Property Type Code
   SegmentHelper::BasicCodedEntry PropertyType;
+  // Property Type Modifier Code
+  BasicCodedEntryVector PropertyTypeModifiers;
 
   //0062 0008 CS 1 Segment Algorithm Type
   ALGOType        SegmentAlgorithmType;
diff --git a/Source/MediaStorageAndFileFormat/gdcmSegmentReader.cxx b/Source/MediaStorageAndFileFormat/gdcmSegmentReader.cxx
index c985dd3..d352bac 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSegmentReader.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmSegmentReader.cxx
@@ -145,6 +145,51 @@ bool SegmentReader::ReadSegments()
   return res;
 }
 
+
+Segment::BasicCodedEntryVector readCodeSequenceMacroAttributes(const Tag & tag, const DataSet & dataset)
+{
+  Segment::BasicCodedEntryVector result;
+
+  if(dataset.FindDataElement(tag))
+  {
+    SmartPointer<SequenceOfItems> sequence = dataset.GetDataElement(tag).GetValueAsSQ();
+
+    SequenceOfItems::Iterator it = sequence->Begin();
+    for(; it != sequence->End(); ++it)
+    {
+      const Item & item = *it;
+      const DataSet & itemDataSet = item.GetNestedDataSet();
+
+      SegmentHelper::BasicCodedEntry entry;
+
+      // Code Value (Type 1C)
+      Attribute<0x0008, 0x0100> codeValueAttribute;
+      codeValueAttribute.SetFromDataSet(itemDataSet);
+      entry.CV = codeValueAttribute.GetValue();
+
+      // Coding Scheme Designator (Type 1C)
+      Attribute<0x0008, 0x0102> codingSchemeDesignatorAttribute;
+      codingSchemeDesignatorAttribute.SetFromDataSet(itemDataSet);
+      entry.CSD = codingSchemeDesignatorAttribute.GetValue();
+
+      // Coding Scheme Version (Type 1C)
+      Attribute<0x0008, 0x0103> codingSchemeVersionAttribute;
+      codingSchemeVersionAttribute.SetFromDataSet(itemDataSet);
+      entry.CSV = codingSchemeVersionAttribute.GetValue();
+
+      // Code Meaning (Type 1)
+      Attribute<0x0008, 0x0104> codeMeaningAttribute;
+      codeMeaningAttribute.SetFromDataSet(itemDataSet);
+      entry.CM = codeMeaningAttribute.GetValue();
+
+      result.push_back(entry);
+    }
+  }
+
+  return result;
+}
+
+
 bool SegmentReader::ReadSegment(const Item & segmentItem, const unsigned int idx)
 {
   SmartPointer< Segment > segment   = new Segment;
@@ -188,104 +233,80 @@ bool SegmentReader::ReadSegment(const Item & segmentItem, const unsigned int idx
   segment->SetSurfaceCount( surfaceCount );
 
   // Check if there is a Surface Segmentation Module
-  if (surfaceCount > 0
-   || rootDs.FindDataElement( Tag(0x0066, 0x0002) ))
+  if (surfaceCount > 0 || rootDs.FindDataElement(Tag(0x0066, 0x0002)))
   {
-    //*****   GENERAL ANATOMY MANDATORY MACRO ATTRIBUTES   *****//
-    // Anatomic Region Sequence (0008,2218) Type 1
-    if( segmentDS.FindDataElement( Tag(0x0008, 0x2218) ) )
+
+    //Basic Coded Entries in each sequences
+    Segment::BasicCodedEntryVector basicCodedEntries;
+
+    // Anatomic Region Sequence (Type 3)
+    basicCodedEntries = readCodeSequenceMacroAttributes(Tag(0x0008, 0x2218), segmentDS);
+    if(!basicCodedEntries.empty())
     {
-      SmartPointer<SequenceOfItems> anatRegSQ = segmentDS.GetDataElement( Tag(0x0008, 0x2218) ).GetValueAsSQ();
+      segment->SetAnatomicRegion(basicCodedEntries[0]);
+      // Only a single Item is permitted in this Sequence
+      if(basicCodedEntries.size() > 1)
+      {
+        gdcmWarningMacro("Only a single Item is permitted in Anatomic Region Sequence, other items will be ignored");
+      }
+
+      SmartPointer<SequenceOfItems> sequence = segmentDS.GetDataElement(Tag(0x0008, 0x2218)).GetValueAsSQ();
+      Item& item = sequence->GetItem(1);
+      DataSet& itemDataSet = item.GetNestedDataSet();
 
-      if (anatRegSQ->GetNumberOfItems() > 0)  // Only one item is a type 1
+      // Anatomic Region Modifier Sequence (Type 3)
+      basicCodedEntries = readCodeSequenceMacroAttributes(Tag(0x0008, 0x2220), itemDataSet);
+      if(!basicCodedEntries.empty())
       {
-        const Item &    anatRegItem = anatRegSQ->GetItem(1);
-        const DataSet & anatRegDS   = anatRegItem.GetNestedDataSet();
-
-        //*****   CODE SEQUENCE MACRO ATTRIBUTES   *****//
-        SegmentHelper::BasicCodedEntry & anatReg = segment->GetAnatomicRegion();
-
-        // Code Value (Type 1)
-        Attribute<0x0008, 0x0100> codeValueAt;
-        codeValueAt.SetFromDataSet( anatRegDS );
-        anatReg.CV = codeValueAt.GetValue();
-
-        // Coding Scheme (Type 1)
-        Attribute<0x0008, 0x0102> codingSchemeAt;
-        codingSchemeAt.SetFromDataSet( anatRegDS );
-        anatReg.CSD = codingSchemeAt.GetValue();
-
-        // Code Meaning (Type 1)
-        Attribute<0x0008, 0x0104> codeMeaningAt;
-        codeMeaningAt.SetFromDataSet( anatRegDS );
-        anatReg.CM = codeMeaningAt.GetValue();
+          segment->SetAnatomicRegionModifiers(basicCodedEntries);
       }
     }
-    // else assert? return false? gdcmWarning?
 
-    //*****   Segmented Property Category Code Sequence   *****//
-    // Segmented Property Category Code Sequence (0062,0003) Type 1
-    if( segmentDS.FindDataElement( Tag(0x0062, 0x0003) ) )
-    {
-      SmartPointer<SequenceOfItems> propCatSQ = segmentDS.GetDataElement( Tag(0x0062, 0x0003) ).GetValueAsSQ();
 
-      if (propCatSQ->GetNumberOfItems() > 0)  // Only one item is a type 1
+    // Segmented Property Category Code Sequence (Type 1)
+    basicCodedEntries = readCodeSequenceMacroAttributes(Tag(0x0062, 0x0003), segmentDS);
+    if(!basicCodedEntries.empty())
+    {
+      segment->SetPropertyCategory(basicCodedEntries[0]);
+      // Only a single Item shall be included in this Sequence
+      if(basicCodedEntries.size() > 1)
       {
-        const Item &    propCatItem = propCatSQ->GetItem(1);
-        const DataSet & propCatDS   = propCatItem.GetNestedDataSet();
-
-        //*****   CODE SEQUENCE MACRO ATTRIBUTES   *****//
-        SegmentHelper::BasicCodedEntry & propCat = segment->GetPropertyCategory();
-
-        // Code Value (Type 1)
-        Attribute<0x0008, 0x0100> codeValueAt;
-        codeValueAt.SetFromDataSet( propCatDS );
-        propCat.CV = codeValueAt.GetValue();
-
-        // Coding Scheme (Type 1)
-        Attribute<0x0008, 0x0102> codingSchemeAt;
-        codingSchemeAt.SetFromDataSet( propCatDS );
-        propCat.CSD = codingSchemeAt.GetValue();
-
-        // Code Meaning (Type 1)
-        Attribute<0x0008, 0x0104> codeMeaningAt;
-        codeMeaningAt.SetFromDataSet( propCatDS );
-        propCat.CM = codeMeaningAt.GetValue();
+        gdcmWarningMacro("Only a single Item shall be included in Segmented Property Category Code Sequence, other items will be ignored");
       }
     }
-    // else assert? return false? gdcmWarning?
+    else
+    {
+        gdcmWarningMacro("No Item have been found in Segmented Property Category Code Sequence.");
+    }
 
-    //*****   Segmented Property Type Code Sequence   *****//
-    // Segmented Property Type Code Sequence (0062,000F) Type 1
-    if( segmentDS.FindDataElement( Tag(0x0062, 0x000F) ) )
+    // Segmented Property Type Code Sequence (Type 1)
+    basicCodedEntries = readCodeSequenceMacroAttributes(Tag(0x0062, 0x000F), segmentDS);
+    if(!basicCodedEntries.empty())
     {
-      SmartPointer<SequenceOfItems> propTypSQ = segmentDS.GetDataElement( Tag(0x0062, 0x000F) ).GetValueAsSQ();
+      segment->SetPropertyType(basicCodedEntries[0]);
+      // Only a single Item shall be included in this Sequence
+      if(basicCodedEntries.size() > 1)
+      {
+        gdcmWarningMacro("Only a single Item shall be included in Segmented Property Type Code Sequence, other items will be ignored");
+      }
 
-      if (propTypSQ->GetNumberOfItems() > 0)  // Only one item is a type 1
+      SmartPointer<SequenceOfItems> sequence = segmentDS.GetDataElement(Tag(0x0062, 0x000F)).GetValueAsSQ();
+      Item& item = sequence->GetItem(1);
+      DataSet& itemDataSet = item.GetNestedDataSet();
+
+      // Segmented Property Type Modifier Sequence (Type 3)
+      basicCodedEntries = readCodeSequenceMacroAttributes(Tag(0x0062, 0x0011), itemDataSet);
+      if(!basicCodedEntries.empty())
       {
-        const Item &    propTypItem = propTypSQ->GetItem(1);
-        const DataSet & propTypDS   = propTypItem.GetNestedDataSet();
-
-        //*****   CODE SEQUENCE MACRO ATTRIBUTES   *****//
-        SegmentHelper::BasicCodedEntry & propTyp = segment->GetPropertyType();
-
-        // Code Value (Type 1)
-        Attribute<0x0008, 0x0100> codeValueAt;
-        codeValueAt.SetFromDataSet( propTypDS );
-        propTyp.CV = codeValueAt.GetValue();
-
-        // Coding Scheme (Type 1)
-        Attribute<0x0008, 0x0102> codingSchemeAt;
-        codingSchemeAt.SetFromDataSet( propTypDS );
-        propTyp.CSD = codingSchemeAt.GetValue();
-
-        // Code Meaning (Type 1)
-        Attribute<0x0008, 0x0104> codeMeaningAt;
-        codeMeaningAt.SetFromDataSet( propTypDS );
-        propTyp.CM = codeMeaningAt.GetValue();
+          segment->SetPropertyTypeModifiers(basicCodedEntries);
       }
     }
-    // else assert? return false? gdcmWarning?
+    else
+    {
+        gdcmWarningMacro("No Item have been found in Segmented Property Type Code Sequence.");
+    }
+
+
 
     // Referenced Surface Sequence
     const Tag refSurfaceSQTag(0x0066, 0x002B);
diff --git a/Source/MediaStorageAndFileFormat/gdcmSegmentWriter.cxx b/Source/MediaStorageAndFileFormat/gdcmSegmentWriter.cxx
index 84b83db..89bfbc7 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSegmentWriter.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmSegmentWriter.cxx
@@ -61,6 +61,84 @@ void SegmentWriter::SetSegments(SegmentVector & segments)
   Segments = segments;
 }
 
+
+void writeCodeSequenceMacroAttributes(const SegmentHelper::BasicCodedEntry & entry,
+                                      const Tag & tag,
+                                      DataSet & dataset,
+                                      bool severalItemsAllowed)
+{
+  SmartPointer<SequenceOfItems> sequence;
+
+  // If the sequence does not exist, we create it
+  if(!dataset.FindDataElement(tag))
+  {
+    sequence = new SequenceOfItems();
+    DataElement dataElement( tag );
+    dataElement.SetVR( VR::SQ );
+    dataElement.SetValue(*sequence);
+    dataElement.SetVLToUndefined();
+    dataset.Insert(dataElement);
+  }
+
+  // Retrieve the sequence from the dataset
+  sequence = dataset.GetDataElement(tag).GetValueAsSQ();
+
+  // Check if an item is already present in the sequence
+  if (!severalItemsAllowed && sequence->GetNumberOfItems() > 0)
+  {
+    // Obviously the user has already added an item to the sequence
+    // Let's assume the user knows what he does
+    return;
+  }
+
+  // Fill the Sequence
+  sequence->SetLengthToUndefined();
+
+  Item item;
+  item.SetVLToUndefined();
+  DataSet & itemDataSet = item.GetNestedDataSet();
+
+  // Code Sequence Macro Attributes
+  {
+    // Code Value (Type 1C)
+    Attribute<0x0008, 0x0100> codeValueAttribute;
+    codeValueAttribute.SetValue(entry.CV);
+    itemDataSet.Replace(codeValueAttribute.GetAsDataElement());
+
+    // Coding Scheme Designator (Type 1C)
+    Attribute<0x0008, 0x0102> codingSchemeDesignatorAttribute;
+    codingSchemeDesignatorAttribute.SetValue(entry.CSD);
+    itemDataSet.Replace(codingSchemeDesignatorAttribute.GetAsDataElement());
+
+    // Coding Scheme Version (Type 1C)
+    if(!entry.CSV.empty())
+    {
+      Attribute<0x0008, 0x0103> codingSchemeVersionAttribute;
+      codingSchemeVersionAttribute.SetValue(entry.CSV);
+      itemDataSet.Replace(codingSchemeVersionAttribute.GetAsDataElement());
+    }
+
+    // Code Meaning (Type 1)
+    Attribute<0x0008, 0x0104> codeMeaningAttribute;
+    codeMeaningAttribute.SetValue(entry.CM);
+    itemDataSet.Replace(codeMeaningAttribute.GetAsDataElement());
+  }
+
+  sequence->AddItem(item);
+
+}
+
+void writeCodeSequenceMacroAttributes(const Segment::BasicCodedEntryVector & entries,
+                                      const Tag & tag,
+                                      DataSet & dataset)
+{
+  Segment::BasicCodedEntryVector::const_iterator it = entries.begin();
+  for(; it != entries.end(); ++it)
+  {
+    writeCodeSequenceMacroAttributes(*it, tag, dataset, true);
+  }
+}
+
 bool SegmentWriter::PrepareWrite()
 {
   File &      file    = GetFile();
@@ -80,23 +158,23 @@ bool SegmentWriter::PrepareWrite()
   segmentsSQ = ds.GetDataElement( Tag(0x0062, 0x0002) ).GetValueAsSQ();
   segmentsSQ->SetLengthToUndefined();
 
-{
-  // Fill the Segment Sequence
-  const unsigned int              numberOfSegments  = this->GetNumberOfSegments();
-  assert( numberOfSegments );
-  const size_t nbItems           = segmentsSQ->GetNumberOfItems();
-  if (nbItems < numberOfSegments)
   {
-    const size_t diff           = numberOfSegments - nbItems;
-    const size_t nbOfItemToMake = (diff > 0?diff:0);
-    for(unsigned int i = 1; i <= nbOfItemToMake; ++i)
+    // Fill the Segment Sequence
+    const unsigned int              numberOfSegments  = this->GetNumberOfSegments();
+    assert( numberOfSegments );
+    const size_t nbItems           = segmentsSQ->GetNumberOfItems();
+    if (nbItems < numberOfSegments)
     {
-      Item item;
-      item.SetVLToUndefined();
-      segmentsSQ->AddItem(item);
+      const size_t diff           = numberOfSegments - nbItems;
+      const size_t nbOfItemToMake = (diff > 0?diff:0);
+      for(unsigned int i = 1; i <= nbOfItemToMake; ++i)
+      {
+        Item item;
+        item.SetVLToUndefined();
+        segmentsSQ->AddItem(item);
+      }
     }
   }
-}
   // else Should I remove items?
 
   std::vector< SmartPointer< Segment > >::const_iterator  it0            = Segments.begin();
@@ -149,173 +227,64 @@ bool SegmentWriter::PrepareWrite()
     }
     else
     {
-    Attribute<0x0062, 0x0008> segmentAlgorithmTypeAt;
-    segmentAlgorithmTypeAt.SetValue( segmentAlgorithmType );
-    segmentDS.Replace( segmentAlgorithmTypeAt.GetAsDataElement() );
+      Attribute<0x0062, 0x0008> segmentAlgorithmTypeAt;
+      segmentAlgorithmTypeAt.SetValue( segmentAlgorithmType );
+      segmentDS.Replace( segmentAlgorithmTypeAt.GetAsDataElement() );
     }
 
-    //*****   GENERAL ANATOMY MANDATORY MACRO ATTRIBUTES   *****//
+
+    // General Anatomy Optional Macro Attributes
     {
-      const SegmentHelper::BasicCodedEntry & anatReg = segment->GetAnatomicRegion();
-      if (anatReg.IsEmpty())
+      // Anatomic Region Sequence (Type 3) - Only a single Item allowed
+      const SegmentHelper::BasicCodedEntry & anatomicRegion = segment->GetAnatomicRegion();
+      if(!anatomicRegion.IsEmpty())
       {
-        gdcmWarningMacro("Anatomic region not specified or incomplete");
-      }
+        writeCodeSequenceMacroAttributes(anatomicRegion, Tag(0x0008, 0x2218), segmentDS, false);
 
-      // Anatomic Region Sequence (0008,2218) Type 1
-      SmartPointer<SequenceOfItems> anatRegSQ;
-      const Tag anatRegSQTag(0x0008, 0x2218);
-      if( !segmentDS.FindDataElement( anatRegSQTag ) )
-      {
-        anatRegSQ = new SequenceOfItems;
-        DataElement detmp( anatRegSQTag );
-        detmp.SetVR( VR::SQ );
-        detmp.SetValue( *anatRegSQ );
-        detmp.SetVLToUndefined();
-        segmentDS.Insert( detmp );
-      }
-      anatRegSQ = segmentDS.GetDataElement( anatRegSQTag ).GetValueAsSQ();
-      anatRegSQ->SetLengthToUndefined();
+        // Anatomic Region Modifier Sequence (Type 3)
+        const Segment::BasicCodedEntryVector & anatomicRegionModifiers = segment->GetAnatomicRegionModifiers();
+        if(!anatomicRegionModifiers.empty())
+        {
+          SmartPointer<SequenceOfItems> sequence = segmentDS.GetDataElement(Tag(0x0008, 0x2218)).GetValueAsSQ();
+          Item& item = sequence->GetItem(1);
+          DataSet& itemDataSet = item.GetNestedDataSet();
 
-      // Fill the Anatomic Region Sequence
-      const size_t nbItems = anatRegSQ->GetNumberOfItems();
-      if (nbItems < 1)  // Only one item is a type 1
-      {
-        Item item;
-        item.SetVLToUndefined();
-        anatRegSQ->AddItem(item);
+          writeCodeSequenceMacroAttributes(anatomicRegionModifiers, Tag(0x0008, 0x2220), itemDataSet);
+        }
       }
 
-      Item &    anatRegItem = anatRegSQ->GetItem(1);
-      DataSet & anatRegDS   = anatRegItem.GetNestedDataSet();
-
-      //*****   CODE SEQUENCE MACRO ATTRIBUTES   *****//
-      {
-        // Code Value (Type 1)
-        Attribute<0x0008, 0x0100> codeValueAt;
-        codeValueAt.SetValue( anatReg.CV );
-        anatRegDS.Replace( codeValueAt.GetAsDataElement() );
-
-        // Coding Scheme (Type 1)
-        Attribute<0x0008, 0x0102> codingSchemeAt;
-        codingSchemeAt.SetValue( anatReg.CSD );
-        anatRegDS.Replace( codingSchemeAt.GetAsDataElement() );
-
-        // Code Meaning (Type 1)
-        Attribute<0x0008, 0x0104> codeMeaningAt;
-        codeMeaningAt.SetValue( anatReg.CM );
-        anatRegDS.Replace( codeMeaningAt.GetAsDataElement() );
-      }
     }
 
-    //*****   Segmented Property Category Code Sequence   *****//
+    // Segmented Property Category Code Sequence (Type 1) - Only a single Item allowed
+    const SegmentHelper::BasicCodedEntry & propertyCategory = segment->GetPropertyCategory();
+    if(propertyCategory.IsEmpty())
     {
-      const SegmentHelper::BasicCodedEntry & propCat = segment->GetPropertyCategory();
-      if (propCat.IsEmpty())
-      {
-        gdcmWarningMacro("Segmented property category not specified or incomplete");
-      }
-
-      // Segmented Property Category Code Sequence (0062,0003) Type 1
-      SmartPointer<SequenceOfItems> propCatSQ;
-      const Tag propCatSQTag(0x0062, 0x0003);
-      if( !segmentDS.FindDataElement( propCatSQTag ) )
-      {
-        propCatSQ = new SequenceOfItems;
-        DataElement detmp( propCatSQTag );
-        detmp.SetVR( VR::SQ );
-        detmp.SetValue( *propCatSQ );
-        detmp.SetVLToUndefined();
-        segmentDS.Insert( detmp );
-      }
-      propCatSQ = segmentDS.GetDataElement( propCatSQTag ).GetValueAsSQ();
-      propCatSQ->SetLengthToUndefined();
-
-      // Fill the Segmented Property Category Code Sequence
-      const size_t nbItems = propCatSQ->GetNumberOfItems();
-      if (nbItems < 1)  // Only one item is a type 1
-      {
-        Item item;
-        item.SetVLToUndefined();
-        propCatSQ->AddItem(item);
-      }
-
-      Item &    propCatItem = propCatSQ->GetItem(1);
-      DataSet & propCatDS   = propCatItem.GetNestedDataSet();
-
-      //*****   CODE SEQUENCE MACRO ATTRIBUTES   *****//
-      {
-        // Code Value (Type 1)
-        Attribute<0x0008, 0x0100> codeValueAt;
-        codeValueAt.SetValue( propCat.CV );
-        propCatDS.Replace( codeValueAt.GetAsDataElement() );
-
-        // Coding Scheme (Type 1)
-        Attribute<0x0008, 0x0102> codingSchemeAt;
-        codingSchemeAt.SetValue( propCat.CSD );
-        propCatDS.Replace( codingSchemeAt.GetAsDataElement() );
-
-        // Code Meaning (Type 1)
-        Attribute<0x0008, 0x0104> codeMeaningAt;
-        codeMeaningAt.SetValue( propCat.CM );
-        propCatDS.Replace( codeMeaningAt.GetAsDataElement() );
-      }
+      gdcmWarningMacro("The property category is not specified or incomplete");
     }
+    writeCodeSequenceMacroAttributes(propertyCategory, Tag(0x0062, 0x0003), segmentDS, false);
 
-    //*****   Segmented Property Type Code Sequence   *****//
-    {
-      const SegmentHelper::BasicCodedEntry & propType = segment->GetPropertyType();
-      if (propType.IsEmpty())
-      {
-        gdcmWarningMacro("Segmented property type not specified or incomplete");
-      }
 
-      // Segmented Property Type Code Sequence (0062,000F) Type 1
-      SmartPointer<SequenceOfItems> propTypeSQ;
-      const Tag propTypeSQTag(0x0062, 0x000F);
-      if( !segmentDS.FindDataElement( propTypeSQTag ) )
-      {
-        propTypeSQ = new SequenceOfItems;
-        DataElement detmp( propTypeSQTag );
-        detmp.SetVR( VR::SQ );
-        detmp.SetValue( *propTypeSQ );
-        detmp.SetVLToUndefined();
-        segmentDS.Insert( detmp );
-      }
-      propTypeSQ = segmentDS.GetDataElement( propTypeSQTag ).GetValueAsSQ();
-      propTypeSQ->SetLengthToUndefined();
+    // Segmented Property Type Code Sequence (Type 1) - Only a single Item allowed
+    const SegmentHelper::BasicCodedEntry & propertyType = segment->GetPropertyType();
+    if(propertyType.IsEmpty())
+    {
+      gdcmWarningMacro("The property type is not specified or incomplete");
+    }
+    writeCodeSequenceMacroAttributes(propertyType, Tag(0x0062, 0x000F), segmentDS, false);
 
-      // Fill the Segmented Property Type Code Sequence
-      const size_t nbItems = propTypeSQ->GetNumberOfItems();
-      if (nbItems < 1)  // Only one item is a type 1
-      {
-        Item item;
-        item.SetVLToUndefined();
-        propTypeSQ->AddItem(item);
-      }
 
-      Item &    propTypeItem = propTypeSQ->GetItem(1);
-      DataSet & propTypeDS   = propTypeItem.GetNestedDataSet();
+    // Segmented Property Type Modifier Code Sequence (Type 3)
+    const Segment::BasicCodedEntryVector & propertyTypeModifiers = segment->GetPropertyTypeModifiers();
+    if(!propertyTypeModifiers.empty())
+    {
+      SmartPointer<SequenceOfItems> sequence = segmentDS.GetDataElement(Tag(0x0062, 0x000F)).GetValueAsSQ();
+      Item& item = sequence->GetItem(1);
+      DataSet& itemDataSet = item.GetNestedDataSet();
 
-      //*****   CODE SEQUENCE MACRO ATTRIBUTES   *****//
-      {
-        // Code Value (Type 1)
-        Attribute<0x0008, 0x0100> codeValueAt;
-        codeValueAt.SetValue( propType.CV );
-        propTypeDS.Replace( codeValueAt.GetAsDataElement() );
-
-        // Coding Scheme (Type 1)
-        Attribute<0x0008, 0x0102> codingSchemeAt;
-        codingSchemeAt.SetValue( propType.CSD );
-        propTypeDS.Replace( codingSchemeAt.GetAsDataElement() );
-
-        // Code Meaning (Type 1)
-        Attribute<0x0008, 0x0104> codeMeaningAt;
-        codeMeaningAt.SetValue( propType.CM );
-        propTypeDS.Replace( codeMeaningAt.GetAsDataElement() );
-      }
+      writeCodeSequenceMacroAttributes(propertyTypeModifiers, Tag(0x0062, 0x0011), itemDataSet);
     }
 
+
     //*****   Surface segmentation    *****//
     const unsigned long surfaceCount = segment->GetSurfaceCount();
     if (surfaceCount > 0)
diff --git a/Source/MediaStorageAndFileFormat/gdcmSorter.cxx b/Source/MediaStorageAndFileFormat/gdcmSorter.cxx
index 6577f5f..55c0f09 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSorter.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmSorter.cxx
@@ -19,6 +19,7 @@
 
 #include <map>
 #include <algorithm>
+#include <set>
 
 namespace gdcm
 {
@@ -26,13 +27,18 @@ namespace gdcm
 Sorter::Sorter()
 {
   SortFunc = NULL;
+  TagsToRead = std::set<Tag>();
 }
 
-
 Sorter::~Sorter()
 {
 }
 
+void Sorter::SetTagsToRead( std::set<Tag> const & tags )
+{
+  TagsToRead = tags;
+}
+
 void Sorter::SetSortFunction( SortFunction f )
 {
   SortFunc = f;
@@ -83,7 +89,9 @@ bool Sorter::StableSort(std::vector<std::string> const & filenames)
     Reader reader;
     reader.SetFileName( it->c_str() );
     SmartPointer<FileWithName> &f = *it2;
-    if( reader.Read() )
+
+    bool readWasSuccessful = TagsToRead.empty() ? reader.Read() : reader.ReadSelectedTags(TagsToRead);
+    if (readWasSuccessful)
       {
       f = new FileWithName( reader.GetFile() );
       f->filename = *it;
@@ -125,7 +133,8 @@ bool Sorter::Sort(std::vector<std::string> const & filenames)
     Reader reader;
     reader.SetFileName( it->c_str() );
     SmartPointer<FileWithName> &f = *it2;
-    if( reader.Read() )
+    bool readWasSuccessful = TagsToRead.empty() ? reader.Read() : reader.ReadSelectedTags(TagsToRead);
+    if (readWasSuccessful)
       {
       f = new FileWithName( reader.GetFile() );
       f->filename = *it;
diff --git a/Source/MediaStorageAndFileFormat/gdcmSorter.h b/Source/MediaStorageAndFileFormat/gdcmSorter.h
index 42f3d82..f06b5a8 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSorter.h
+++ b/Source/MediaStorageAndFileFormat/gdcmSorter.h
@@ -20,6 +20,7 @@
 #include <vector>
 #include <string>
 #include <map>
+#include <set>
 
 namespace gdcm
 {
@@ -55,6 +56,11 @@ public:
   /// UNSUPPORTED FOR NOW
   bool AddSelect( Tag const &tag, const char *value );
 
+  /// Specify a set of tags to be read in during the sort procedure.
+  /// By default this set is empty, in which case the entire image,
+  /// including pixel data, is read in.
+  void SetTagsToRead( std::set<Tag> const & tags );
+
   /// Set the sort function which compares one dataset to the other
   typedef bool (*SortFunction)(DataSet const &, DataSet const &);
   void SetSortFunction( SortFunction f );
@@ -66,6 +72,7 @@ protected:
   typedef std::map<Tag,std::string> SelectionMap;
   std::map<Tag,std::string> Selection;
   SortFunction SortFunc;
+  std::set<Tag> TagsToRead;
 };
 //-----------------------------------------------------------------------------
 inline std::ostream& operator<<(std::ostream &os, const Sorter &s)
diff --git a/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx b/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx
index 6efce54..8e9c505 100644
--- a/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmStringFilter.cxx
@@ -470,17 +470,6 @@ std::pair<std::string, std::string> StringFilter::ToStringPairInternal(const Dat
   return ret;
 }
 
-#if !defined(GDCM_LEGACY_REMOVE)
-std::string StringFilter::FromString(const Tag&t, const char * value, VL const & vl)
-{
-  (void)t;
-  (void)value;
-  (void)vl;
-  assert(0 && "TODO");
-  return "";
-}
-#endif
-
 #define FromStringFilterCase(type) \
   case VR::type: \
       { \
diff --git a/Source/MediaStorageAndFileFormat/gdcmStringFilter.h b/Source/MediaStorageAndFileFormat/gdcmStringFilter.h
index 3c70834..2531fc7 100644
--- a/Source/MediaStorageAndFileFormat/gdcmStringFilter.h
+++ b/Source/MediaStorageAndFileFormat/gdcmStringFilter.h
@@ -54,8 +54,6 @@ public:
   /// Directly from a Tag:
   std::pair<std::string, std::string> ToStringPair(const Tag& t) const;
 
-  GDCM_LEGACY(std::string FromString(const Tag&t, const char * value, VL const & vl))
-
   /// Convert to string the char array defined by the pair (value,len)
   std::string FromString(const Tag&t, const char * value, size_t len);
 
diff --git a/Source/MediaStorageAndFileFormat/gdcmSurfaceReader.cxx b/Source/MediaStorageAndFileFormat/gdcmSurfaceReader.cxx
index bc0ffec..9c022dc 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSurfaceReader.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmSurfaceReader.cxx
@@ -300,45 +300,90 @@ bool SurfaceReader::ReadSurface(const Item & surfaceItem, const unsigned long id
   DataSet &                     surfacePrimitivesDS = surfacePrimitivesSQ->GetItem(1).GetNestedDataSet();
   Tag                           typedTag;
 
-  if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0023) ))
+  // Long Triangle Point Index List
+  if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0041) ))
+  {
+    typedTag = Tag(0x0066, 0x0041);
+    meshPrimitive->SetPrimitiveType( MeshPrimitive::TRIANGLE );
+  }
+  // Long Edge Point Index List
+  else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0042)) )
+  {
+    typedTag = Tag(0x0066, 0x0042);
+    meshPrimitive->SetPrimitiveType( MeshPrimitive::EDGE );
+  }
+  // Long Vertex Point Index List
+  else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0043)) )
+  {
+    typedTag = Tag(0x0066, 0x0043);
+    meshPrimitive->SetPrimitiveType( MeshPrimitive::VERTEX );
+  }
+  // RETIRED Triangle Point Index List
+  else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0023) ))
   {
     typedTag = Tag(0x0066, 0x0023);
     meshPrimitive->SetPrimitiveType( MeshPrimitive::TRIANGLE );
+    gdcmErrorMacro("Retrieving primitive data from retired tag 'Triangle Point Index List' (0066,0023)");
   }
+  // RETIRED Edge Point Index List
   else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0024)) )
   {
     typedTag = Tag(0x0066, 0x0024);
     meshPrimitive->SetPrimitiveType( MeshPrimitive::EDGE );
+    gdcmErrorMacro("Retrieving primitive data from retired tag 'Edge Point Index List' (0066,0024)");
   }
+  // RETIRED Vertex Point Index List
   else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0025)) )
   {
     typedTag = Tag(0x0066, 0x0025);
     meshPrimitive->SetPrimitiveType( MeshPrimitive::VERTEX );
+    gdcmErrorMacro("Retrieving primitive data from retired tag 'Vertex Point Index List' (0066,0025)");
   }
   else
   {
     SmartPointer< SequenceOfItems > typedSQ;
-    if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0026) ))
+
+    if (surfacePrimitivesDS.FindDataElement(Tag(0x0066, 0x0026)))
     {
-      typedSQ = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0026) ).GetValueAsSQ();
-      meshPrimitive->SetPrimitiveType( MeshPrimitive::TRIANGLE_STRIP );
+      SmartPointer< SequenceOfItems > sequence = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0026) ).GetValueAsSQ();
+      if(sequence->GetNumberOfItems() > 0)
+      {
+        typedSQ = sequence;
+        meshPrimitive->SetPrimitiveType( MeshPrimitive::TRIANGLE_STRIP );
+      }
     }
-    else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0027)) )
+
+    if(!typedSQ && surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0027)) )
     {
-      typedSQ = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0027) ).GetValueAsSQ();
-      meshPrimitive->SetPrimitiveType( MeshPrimitive::TRIANGLE_FAN );
+      SmartPointer< SequenceOfItems > sequence = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0027) ).GetValueAsSQ();
+      if(sequence->GetNumberOfItems() > 0)
+      {
+        typedSQ = sequence;
+        meshPrimitive->SetPrimitiveType( MeshPrimitive::TRIANGLE_FAN );
+      }
     }
-    else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0028)) )
+
+    if (!typedSQ && surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0028)) )
     {
-      typedSQ = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0028) ).GetValueAsSQ();
-      meshPrimitive->SetPrimitiveType( MeshPrimitive::LINE );
+      SmartPointer< SequenceOfItems > sequence = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0028) ).GetValueAsSQ();
+      if(sequence->GetNumberOfItems() > 0)
+      {
+        typedSQ = sequence;
+        meshPrimitive->SetPrimitiveType( MeshPrimitive::LINE );
+      }
     }
-    else if (surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0034)) )
+
+    if (!typedSQ && surfacePrimitivesDS.FindDataElement( Tag(0x0066, 0x0034)) )
     {
-      typedSQ = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0034) ).GetValueAsSQ();
-      meshPrimitive->SetPrimitiveType( MeshPrimitive::FACET );
+      SmartPointer< SequenceOfItems > sequence = surfacePrimitivesDS.GetDataElement( Tag(0x0066, 0x0034) ).GetValueAsSQ();
+      if(sequence->GetNumberOfItems() > 0)
+      {
+        typedSQ = sequence;
+        meshPrimitive->SetPrimitiveType( MeshPrimitive::FACET );
+      }
     }
-    else
+
+    if(!typedSQ)
     {
       gdcmErrorMacro( "Unknown surface mesh primitives type" );
        return false;
@@ -355,9 +400,16 @@ bool SurfaceReader::ReadSurface(const Item & surfaceItem, const unsigned long id
       for (; it != itEnd; it++)
       {
         const DataSet & typedPrimitivesDS = it->GetNestedDataSet();
-        if ( typedPrimitivesDS.FindDataElement( Tag(0x0066, 0x0029)) )
+        // Primitive Sequence
+        if ( typedPrimitivesDS.FindDataElement( Tag(0x0066, 0x0040)) )
+        {
+          meshPrimitive->AddPrimitiveData( typedPrimitivesDS.GetDataElement( Tag(0x0066, 0x0040)) );
+        }
+        // RETIRED Primitive Sequence
+        else if ( typedPrimitivesDS.FindDataElement( Tag(0x0066, 0x0029)) )
         {
           meshPrimitive->AddPrimitiveData( typedPrimitivesDS.GetDataElement( Tag(0x0066, 0x0029)) );
+          gdcmErrorMacro("Retrieving primitive data from retired tag 'Primitive Point Index List' (0066,0029)");
         }
         else
         {
diff --git a/Source/MediaStorageAndFileFormat/gdcmSurfaceWriter.cxx b/Source/MediaStorageAndFileFormat/gdcmSurfaceWriter.cxx
index 2ed8f30..ae515f9 100644
--- a/Source/MediaStorageAndFileFormat/gdcmSurfaceWriter.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmSurfaceWriter.cxx
@@ -92,20 +92,20 @@ bool SurfaceWriter::PrepareWrite()
   surfacesSQ->SetLengthToUndefined();
 
   // Fill the Surface Sequence
-{
-  const size_t nbItems    = surfacesSQ->GetNumberOfItems();
-  if (nbItems < nbSurfaces)
   {
-    const size_t diff           = nbSurfaces - nbItems;
-    const size_t nbOfItemToMake = (diff > 0?diff:0);
-    for(unsigned int i = 1; i <= nbOfItemToMake; ++i)
+    const size_t nbItems    = surfacesSQ->GetNumberOfItems();
+    if (nbItems < nbSurfaces)
     {
-      Item item;
-      item.SetVLToUndefined();
-      surfacesSQ->AddItem(item);
+      const size_t diff           = nbSurfaces - nbItems;
+      const size_t nbOfItemToMake = (diff > 0?diff:0);
+      for(unsigned int i = 1; i <= nbOfItemToMake; ++i)
+      {
+        Item item;
+        item.SetVLToUndefined();
+        surfacesSQ->AddItem(item);
+      }
     }
   }
-}
   // else Should I remove items?
 
   std::vector< SmartPointer< Segment > >                  segments  = this->GetSegments();
@@ -208,7 +208,7 @@ bool SurfaceWriter::PrepareWrite()
             const SegmentHelper::BasicCodedEntry & processingAlgo = surface->GetProcessingAlgorithm();
             if (processingAlgo.IsEmpty())
             {
-              gdcmWarningMacro("Surface provessing algorithm family not specified or incomplete");
+              gdcmWarningMacro("Surface processing algorithm family not specified or incomplete");
             }
 
             SmartPointer<SequenceOfItems> algoFamilyCodeSQ;
@@ -385,7 +385,7 @@ bool SurfaceWriter::PrepareWrite()
       //        Two exemples :
       //        (0066,0013) SQ (Sequence with undefined length #=1)     # u/l, 1 Surface Mesh Primitives Sequence
       //          (fffe,e000) na (Item with undefined length #=1)         # u/l, 1 Item
-      //            (0066,0016) OW                                         #  0, 1 Edge Point Index List
+      //            (0066,0042) OL                                         #  0, 1 Long Edge Point Index List
       //          (fffe,e00d) na (ItemDelimitationItem)                   #   0, 0 ItemDelimitationItem
       //        (fffe,e0dd) na (SequenceDelimitationItem)               #   0, 0 SequenceDelimitationItem
       //
@@ -395,11 +395,11 @@ bool SurfaceWriter::PrepareWrite()
       //          (fffe,e000) na (Item with undefined length #=1)         # u/l, 1 Item
       //            (0066,0026) SQ (Sequence with undefined length #=1)     # u/l, 1 // Triangle Strip Sequence
       //              (fffe,e000) na (Item with undefined length #=1)         # u/l, 1 Item
-      //                (0066,0029) OW                                         #  0, 1 // Primitive Point Index List
+      //                (0066,0040) OL                                         #  0, 1 // Long Primitive Point Index List
       //              (fffe,e00d) na (ItemDelimitationItem)                   #   0, 0 ItemDelimitationItem
       //                                            ...
       //              (fffe,e000) na (Item with undefined length #=1)         # u/l, 1 Item
-      //                (0066,0029) OW                                         #  0, 1 // Primitive Point Index List
+      //                (0066,0040) OL                                         #  0, 1 // Long Primitive Point Index List
       //              (fffe,e00d) na (ItemDelimitationItem)                   #   0, 0 ItemDelimitationItem
       //            (fffe,e0dd) na (SequenceDelimitationItem)               #   0, 0 SequenceDelimitationItem
       //          (fffe,e00d) na (ItemDelimitationItem)                   #   0, 0 ItemDelimitationItem
@@ -441,23 +441,23 @@ bool SurfaceWriter::PrepareWrite()
         switch (primitiveType)
         {
         case MeshPrimitive::VERTEX:
-          // Vertex Point Index List
-          typedPrimitiveTag.SetElement(0x0025);
+          // Long Vertex Point Index List
+          typedPrimitiveTag.SetElement(0x0043);
           break;
         case MeshPrimitive::EDGE:
-          // Edge Point Index List
-          typedPrimitiveTag.SetElement(0x0024);
+          // Long Edge Point Index List
+          typedPrimitiveTag.SetElement(0x0042);
           break;
         case MeshPrimitive::TRIANGLE:
-          // Triangle Point Index List
-          typedPrimitiveTag.SetElement(0x0023);
+          // Long Triangle Point Index List
+          typedPrimitiveTag.SetElement(0x0041);
           break;
         case MeshPrimitive::TRIANGLE_STRIP:
         case MeshPrimitive::TRIANGLE_FAN:
         case MeshPrimitive::LINE:
         case MeshPrimitive::FACET:
-          // Primitive Point Index List
-          typedPrimitiveTag.SetElement(0x0029);
+          // Long Primitive Point Index List
+          typedPrimitiveTag.SetElement(0x0040);
           insertInSQ = true;
           break;
         default:
@@ -554,7 +554,7 @@ bool SurfaceWriter::PrepareWrite()
             typedPointIndexListDE.SetVL( pointIndexListVL );
 
             if ( ts.IsExplicit() )
-              typedPointIndexListDE.SetVR( VR::OW );
+              typedPointIndexListDE.SetVR( VR::OL );
 
             pointIndexListDS.Replace( typedPointIndexListDE );
           }
@@ -579,41 +579,41 @@ bool SurfaceWriter::PrepareWrite()
           typedPointIndexListDE.SetVL( pointIndexListVL );
 
           if ( ts.IsExplicit() )
-            typedPointIndexListDE.SetVR( VR::OW );
+            typedPointIndexListDE.SetVR( VR::OL );
 
           pointIndexListDS0.Replace( typedPointIndexListDE );
         }
 
         //*****   Add empty values in unused but required tags (Type 2)   *****//
 
-        DataElement emptyOWDE;
-        emptyOWDE.SetVLToUndefined();
-        emptyOWDE.SetVR( VR::OW );
+        DataElement emptyOLDE;
+        emptyOLDE.SetVLToUndefined();
+        emptyOLDE.SetVR( VR::OL );
         SmartPointer<ByteValue> emptyValueOW = new ByteValue;
-        emptyOWDE.SetValue(*emptyValueOW);
+        emptyOLDE.SetValue(*emptyValueOW);
 
-        // Vertex Point Index List ( Type 2 )
-        Tag vertexPointIndexListTag(0x0066, 0x0025);
+        // Long Vertex Point Index List ( Type 2 )
+        Tag vertexPointIndexListTag(0x0066, 0x0043);
         if( !surfaceMeshPrimitivesDS.FindDataElement( vertexPointIndexListTag ) )
         {
-          emptyOWDE.SetTag( vertexPointIndexListTag );
-          surfaceMeshPrimitivesDS.Insert( emptyOWDE );
+          emptyOLDE.SetTag( vertexPointIndexListTag );
+          surfaceMeshPrimitivesDS.Insert( emptyOLDE );
         }
 
-        // Edge Point Index List ( Type 2 )
-        Tag edgePointIndexListTag(0x0066, 0x0024);
+        // Long Edge Point Index List ( Type 2 )
+        Tag edgePointIndexListTag(0x0066, 0x0042);
         if( !surfaceMeshPrimitivesDS.FindDataElement( edgePointIndexListTag ) )
         {
-          emptyOWDE.SetTag( edgePointIndexListTag );
-          surfaceMeshPrimitivesDS.Insert( emptyOWDE );
+          emptyOLDE.SetTag( edgePointIndexListTag );
+          surfaceMeshPrimitivesDS.Insert( emptyOLDE );
         }
 
-        // Triangle Point Index List ( Type 2 )
-        Tag trianglePointIndexListTag(0x0066, 0x0023);
+        // Long Triangle Point Index List ( Type 2 )
+        Tag trianglePointIndexListTag(0x0066, 0x0041);
         if( !surfaceMeshPrimitivesDS.FindDataElement( trianglePointIndexListTag ) )
         {
-          emptyOWDE.SetTag( trianglePointIndexListTag );
-          surfaceMeshPrimitivesDS.Insert( emptyOWDE );
+          emptyOLDE.SetTag( trianglePointIndexListTag );
+          surfaceMeshPrimitivesDS.Insert( emptyOLDE );
         }
 
         DataElement emptySQDE;
diff --git a/Testing/Source/Data/CMakeLists.txt b/Testing/Source/Data/CMakeLists.txt
index 575b312..7d61b16 100644
--- a/Testing/Source/Data/CMakeLists.txt
+++ b/Testing/Source/Data/CMakeLists.txt
@@ -66,20 +66,9 @@ set(BLACK_LIST_READER
   lena512_rot90.j2k.dcm
 # Remove this one for now:
   LengthOfItemLarger.dcm
-# Need CharLS 1.1
+# https://github.com/team-charls/charls/issues/16
   JPEG_LS_InvalidEscapeSequence_COM_padding.dcm
-# something wrong with OPJ 1.4
-  JPEGLS_CharLS_10742.dcm
 )
-if(GDCM_USE_SYSTEM_OPENJPEG)
-  if(OPENJPEG_MAJOR_VERSION EQUAL 1)
-    set(BLACK_LIST_READER
-      ${BLACK_LIST_READER}
-      # openjpeg system on travis buildd seems broken
-      TOSHIBA_J2K_OpenJPEGv2Regression.dcm
-    )
-  endif()
-endif()
 if(NOT GDCM_USE_PVRG)
   set(BLACK_LIST_READER
     # The following should really fails according to JPEG spec, IJG is failing and even when forcing
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx
index 77b905a..b679fb0 100644
--- a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestAttribute1.cxx
@@ -180,6 +180,7 @@ int TestAttributeIS()
 int TestAttributeLO() { return 0; }
 int TestAttributeLT() { return 0; }
 int TestAttributeOB() { return 0; }
+int TestAttributeOD() { return 0; }
 int TestAttributeOF()
 {
   gdcm::DataSet ds;
@@ -199,6 +200,7 @@ int TestAttributeOF()
 
   return 0;
 }
+int TestAttributeOL() { return 0; }
 int TestAttributeOW() { return 0; }
 int TestAttributePN() { return 0; }
 int TestAttributeSH() { return 0; }
@@ -230,7 +232,9 @@ int TestAttribute1(int , char *[])
   numerrors += TestAttributeLO();
   numerrors += TestAttributeLT();
   numerrors += TestAttributeOB();
+  numerrors += TestAttributeOD();
   numerrors += TestAttributeOF();
+  numerrors += TestAttributeOL();
   numerrors += TestAttributeOW();
   numerrors += TestAttributePN();
   numerrors += TestAttributeSH();
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestDS.cxx b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestDS.cxx
index 433a35d..3f58d0b 100644
--- a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestDS.cxx
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestDS.cxx
@@ -94,67 +94,67 @@ std::string to_string ( Float data ) {
     */
 
     if ( in << std::dec << std::setprecision((int)digits) << data )
-        return ( in.str() );
+        return in.str();
     else
         throw "Impossible Conversion"; // should not happen ...
 }
 
 
 
-bool checkerror(double d, std::string s)
+static bool checkerror(double d, std::string s)
 {
-	double theConverted = atof(s.c_str());
-    double error = fabs(d - theConverted);
+  double theConverted = atof(s.c_str());
+  double error = fabs(d - theConverted);
 
-    int Log = (int)log10(fabs(d));
-    int eo = ( Log - 14 );
+  int Log = (int)log10(fabs(d));
+  int eo = ( Log - 14 );
 
-    if ( Log <= -1 && Log >= -4 )
-        eo = -13;
+  if ( Log <= -1 && Log >= -4 )
+    eo = -13;
 #ifdef ALWAYS_3_DIGITS_IN_EXPONENT
-    else if ( Log >= 15 )
-        eo = ( Log - 9);
+  else if ( Log >= 15 )
+    eo = ( Log - 9);
 #else
-    else if ( Log >= 99 )
-        eo = ( Log - 9 );
-    else if ( Log >= 15 )
-        eo = ( Log - 10);
+  else if ( Log >= 99 )
+    eo = ( Log - 9 );
+  else if ( Log >= 15 )
+    eo = ( Log - 10);
 #endif
 
-    if (d<0)
-        eo += 1;
+  if (d<0)
+    eo += 1;
 
 
-    //if (error > pow(10., eo) )
-	//pow will underflow at 10^-308, so errors lower than -308 will appear to be
-	//larger than pow(10., eo), because the 'pow' result will be 0 in vs2010
-	if (log10(error) > eo)
-    {
-        std::cout << "ERROR: Absoulte Error is too large (error = " << error << ", should be < " << pow(10., eo) << ")" << std::endl;
-        return true;
-    }
-//    else if (error != 0.0) std::cout << "OK (error = " << error << ", is < " << pow(10, eo) << ")" << std::endl;
+  //if (error > pow(10., eo) )
+  //pow will underflow at 10^-308, so errors lower than -308 will appear to be
+  //larger than pow(10., eo), because the 'pow' result will be 0 in vs2010
+  if (log10(error) > eo)
+  {
+    std::cout << "ERROR: Absoulte Error is too large (error = " << error << ", should be < " << pow(10., eo) << ")" << std::endl;
+    return true;
+  }
+  //    else if (error != 0.0) std::cout << "OK (error = " << error << ", is < " << pow(10, eo) << ")" << std::endl;
 
-    return false;
+  return false;
 }
 
-bool checkerror(double d, std::string s, bool se)
+static bool checkerror(double d, std::string s, bool se)
 {
-    double error = fabs(d - atof( s.c_str() ));
-    bool has_error = (error != 0);
-
-    if (has_error)
-    {
-       std::cout << "\tError is: " << error;
-    }
-    std::cout << std::endl;
-
-    if( has_error != se )
-    {
-        std::cout << "ERROR: has_error = " << has_error << " (should be " << se << ")" << std::endl;
-        return true;
-    }
-    return checkerror(d,s);
+  double error = fabs(d - atof( s.c_str() ));
+  bool has_error = (error != 0);
+
+  if (has_error)
+  {
+    std::cout << "\tError is: " << error;
+  }
+  std::cout << std::endl;
+
+  if( has_error != se )
+  {
+    std::cout << "ERROR: has_error = " << has_error << " (should be " << se << ")" << std::endl;
+    return true;
+  }
+  return checkerror(d,s);
 }
 
 
@@ -165,26 +165,26 @@ bool checkerror(double d, std::string s, bool se)
  sz = size expected
  se = true if there should be an error
 */
-bool singleTestDS(double d, int sz, bool se = false)
+static bool singleTestDS(double d, int sz, bool se = false)
 {
-    bool fail = false;
-    std::cout << "           -|----------------|-" << std::endl;
-    std::string s = to_string<double>( d );
-    std::cout << "  Result:    " << s << std::flush;
+  bool fail = false;
+  std::cout << "           -|----------------|-" << std::endl;
+  std::string s = to_string<double>( d );
+  std::cout << "  Result:    " << s << std::flush;
 
-    if ( checkerror(d, s, se) )
-        fail = true;
+  if ( checkerror(d, s, se) )
+    fail = true;
 
-    assert(sz >= 0);
-    if( s.size() != (unsigned int)sz )
-    {
-        std::cout << "ERROR: Size = " << s.size() << " (should be " << sz << ")" << std::endl;
-        fail = true;
-    }
+  assert(sz >= 0);
+  if( s.size() != (unsigned int)sz )
+  {
+    std::cout << "ERROR: Size = " << s.size() << " (should be " << sz << ")" << std::endl;
+    fail = true;
+  }
 
-    std::cout << std::endl;
+  std::cout << std::endl;
 
-    return fail;
+  return fail;
 }
 
 
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement2.cxx b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement2.cxx
index 84a7fb5..cf541d3 100644
--- a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement2.cxx
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement2.cxx
@@ -36,5 +36,19 @@ int TestElement2(int, char *[])
   t.Print( std::cout );
   std::cout << std::endl;
 
+  gdcm::Element<gdcm::VR::US, gdcm::VM::VM1_2> ref2; // = {{1}};
+  ref2.SetLength(2);
+  ref2.SetValue(1);
+  ref2.Print(std::cout);
+  std::cout << std::endl;
+
+  gdcm::Element<gdcm::VR::US, gdcm::VM::VM1_2> ref3; // = {{1}};
+  ref3.SetLength(4);
+  ref3.SetValue(0,1);
+  ref3.SetValue(1,2);
+  ref3.Print(std::cout);
+  std::cout << std::endl;
+
+
   return 0;
 }
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement5.cxx b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement5.cxx
index 11ffc2d..7819660 100644
--- a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement5.cxx
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestElement5.cxx
@@ -23,7 +23,7 @@ int TestLO()
   const size_t lenstr = strlen(str);
   std::stringstream ss;
   ss.str( str );
-  unsigned int count = gdcm::VM::GetNumberOfElementsFromArray(str, (unsigned int)lenstr);
+  size_t count = gdcm::VM::GetNumberOfElementsFromArray(str, lenstr);
   gdcm::VR vr = gdcm::VR::LO;
   //gdcm::VM vm = gdcm::VM::VM2;
   //gdcm::VR vr = gdcm::VR::DS;
diff --git a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestVR.cxx b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestVR.cxx
index 06419cd..8930a7b 100644
--- a/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestVR.cxx
+++ b/Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestVR.cxx
@@ -124,6 +124,12 @@ int TestValue()
   vr = gdcm::VR::UT; // = 67108864,
   if( (int)vr != (1 << k++) )
     return 1;
+  vr = gdcm::VR::OD; // = 134217728,
+  if( (int)vr != (1 << k++) )
+    return 1;
+  vr = gdcm::VR::OL; // = 268435456,
+  if( (int)vr != (1 << k++) )
+    return 1;
 
   return 0;
 }
diff --git a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestCurve2.cxx b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestCurve2.cxx
index 9ba7894..7d72976 100644
--- a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestCurve2.cxx
+++ b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestCurve2.cxx
@@ -135,7 +135,7 @@ static int TestCurve2Read(const char* filename, bool verbose = false)
       const char *buffer = (char*)&points[0];
       size_t len = sizeof(float) * 3 * npts;
       const char *ref = info[idx].datamd5;
-      gdcm::Testing::ComputeMD5(buffer, (unsigned long)len, digest);
+      gdcm::Testing::ComputeMD5(buffer, len, digest);
       if( verbose )
         {
         std::cout << "ref=" << ref << std::endl;
diff --git a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader1.cxx b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader1.cxx
index 9182915..f0d8807 100644
--- a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader1.cxx
+++ b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader1.cxx
@@ -82,7 +82,7 @@ static int TestImageRegionRead(const char* filename, bool verbose = false)
   const char *ref = gdcm::Testing::GetMD5FromFile(filename);
 
   char digest[33];
-  gdcm::Testing::ComputeMD5(buffer, (unsigned long)len, digest);
+  gdcm::Testing::ComputeMD5(buffer, len, digest);
   if( verbose )
     {
     std::cout << "ref=" << ref << std::endl;
diff --git a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader2.cxx b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader2.cxx
index 5a135bb..fef2235 100644
--- a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader2.cxx
+++ b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestImageRegionReader2.cxx
@@ -88,7 +88,7 @@ static int TestImageRegionRead(const char* filename, bool verbose = false)
     of.write( buffer, len );
     of.close();
 #endif
-  gdcm::Testing::ComputeMD5(buffer, (unsigned long)len, digest);
+  gdcm::Testing::ComputeMD5(buffer, len, digest);
   if( verbose )
     {
     std::cout << "ref=" << ref << std::endl;
diff --git a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestOverlay3.cxx b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestOverlay3.cxx
index 26c115d..fad5467 100644
--- a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestOverlay3.cxx
+++ b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestOverlay3.cxx
@@ -77,7 +77,7 @@ static int TestReadOverlay(const char* filename, bool verbose = false)
         ++ret;
         }
       char digest1[33];
-      if( !gdcm::Testing::ComputeMD5(&overlay[0], (unsigned long) len, digest1) )
+      if( !gdcm::Testing::ComputeMD5(&overlay[0], len, digest1) )
         {
         std::cerr << "ComputeMD5: Problem with Overlay: #" << ovidx << std::endl;
         ++ret;
@@ -93,7 +93,7 @@ static int TestReadOverlay(const char* filename, bool verbose = false)
         ++ret;
         }
       char digest2[33];
-      if( !gdcm::Testing::ComputeMD5(soverlay2.c_str(), (unsigned long)soverlay2.size(), digest2) )
+      if( !gdcm::Testing::ComputeMD5(soverlay2.c_str(), soverlay2.size(), digest2) )
         {
         std::cerr << "ComputeMD5: Problem with Overlay: #" << ovidx << std::endl;
         ++ret;
diff --git a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestPrinter1.cxx b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestPrinter1.cxx
index bad3457..07b8862 100644
--- a/Testing/Source/MediaStorageAndFileFormat/Cxx/TestPrinter1.cxx
+++ b/Testing/Source/MediaStorageAndFileFormat/Cxx/TestPrinter1.cxx
@@ -281,7 +281,7 @@ int TestPrint(const char *filename, bool verbose= false)
       }
     }
   char digest[33];
-  gdcm::Testing::ComputeMD5(&buf[0], (unsigned long)buf.size(), digest);
+  gdcm::Testing::ComputeMD5(&buf[0], buf.size(), digest);
 
   unsigned int i = 0;
   const char *p = printmd5[i][1];
diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt
index 514bf51..ab685cb 100644
--- a/Utilities/CMakeLists.txt
+++ b/Utilities/CMakeLists.txt
@@ -22,22 +22,15 @@ if(NOT GDCM_USE_SYSTEM_EXPAT)
 endif()
 
 # Do openjpeg (jpeg2000 implementation)
-if(GDCM_USE_OPENJPEG_V2)
-  APPEND_COPYRIGHT(${CMAKE_CURRENT_SOURCE_DIR}/gdcmopenjpeg-v2/license.txt)
-else()
-  APPEND_COPYRIGHT(${CMAKE_CURRENT_SOURCE_DIR}/gdcmopenjpeg-v1/LICENSE)
-endif()
+APPEND_COPYRIGHT(${CMAKE_CURRENT_SOURCE_DIR}/gdcmopenjpeg/LICENSE)
 if(NOT GDCM_USE_SYSTEM_OPENJPEG)
   set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
   set(OPENJPEG_INSTALL_NO_LIBRARIES ${GDCM_INSTALL_NO_LIBRARIES})
   set(OPENJPEG_INSTALL_BIN_DIR      ${GDCM_INSTALL_BIN_DIR})
   set(OPENJPEG_INSTALL_LIB_DIR      ${GDCM_INSTALL_LIB_DIR})
   set(OPENJPEG_INSTALL_INCLUDE_DIR  ${GDCM_INSTALL_INCLUDE_DIR}/gdcmopenjpeg)
-  if(GDCM_USE_OPENJPEG_V2)
-    subdirs(gdcmopenjpeg-v2)
-  else()
-    subdirs(gdcmopenjpeg-v1)
-  endif()
+  subdirs(gdcmopenjpeg)
+  mark_as_advanced(BUILD_JPIP BUILD_JPWL BUILD_CODEC BUILD_DOC BUILD_MJ2 BUILD_PKGCONFIG_FILES BUILD_SHARED_LIBS BUILD_THIRDPARTY OPJ_DATA_ROOT OPJ_DISABLE_TPSOT_FIX)
 endif()
 
 # Do jpegls (JPEG-LS aka near lossless implementation)
@@ -106,16 +99,9 @@ if(GDCM_USE_PVRG)
   endif()
 endif()
 
-if(GDCM_USE_RLE)
-  subdirs(rle)
-endif()
-
 # Do C99
 APPEND_COPYRIGHT(${CMAKE_CURRENT_SOURCE_DIR}/C99/COPYING)
 
-# Do wxVTK
-APPEND_COPYRIGHT(${CMAKE_CURRENT_SOURCE_DIR}/wxWidgets/Copyright.txt)
-
 #if(NOT GDCM_INSTALL_NO_DEVELOPMENT)
 ##  file(GLOB header_files "*.h" "*.txx")
 #  install(FILES
diff --git a/Utilities/Release/README.md b/Utilities/Release/README.md
index 24f4747..debdb4e 100644
--- a/Utilities/Release/README.md
+++ b/Utilities/Release/README.md
@@ -3,7 +3,7 @@ GDCM binaries have moved !
 
 They are now automatically uploaded to github:
 
-[github release](https://github.com/malaterre/GDCM/releases)
+[github release](https://github.com/malaterre/GDCM/releases/tag/vVERSION)
 
 They are build using travis and appveyor automatically
 
diff --git a/Utilities/Release/release.sh b/Utilities/Release/release.sh
index ab92df1..0fda69f 100755
--- a/Utilities/Release/release.sh
+++ b/Utilities/Release/release.sh
@@ -18,8 +18,8 @@ date
 echo ""
 
 major=2
-minor=4
-patch=5
+minor=6
+patch=8
 dirversion="$major.$minor"
 version="$major.$minor.$patch"
 version2="$major-$minor-$patch"
@@ -115,32 +115,40 @@ cpack -G TBZ2 --config CPackSourceConfig.cmake
 check_exit_value $? "cpack did not return properly" || exit 1
 
 # Let's start doing the VTK documentation then:
-cmake -DGDCM_VTK_DOCUMENTATION:BOOL=ON -DGDCM_USE_VTK:BOOL=ON -DVTK_DIR:PATH=/home/mathieu/Kitware/VTK5.10.1-gcc .
+#cmake -DGDCM_VTK_DOCUMENTATION:BOOL=ON -DGDCM_USE_VTK:BOOL=ON -DVTK_DIR:PATH=/home/mathieu/tmp/vtk-5.10.1+dfsg/Build .
+cmake -DGDCM_VTK_DOCUMENTATION:BOOL=ON -DGDCM_USE_VTK:BOOL=ON -DVTK_DIR:PATH=/home/mathieu/tmp/vtk6-6.2.0+dfsg1/debian/build .
 check_exit_value $? "cmake did not return properly" || exit 1
 #make -j4
 make rebuild_cache
 make vtkgdcmDoxygenDoc
 check_exit_value $? "vtkgdcmDoxygenDoc did not return properly" || exit 1
 
+# https://sourceforge.net/p/forge/documentation/File%20Management/#rsync-over-ssh
 # Warning need to create /manually/ the subfolder:
-# https://sourceforge.net/project/admin/explorer.php?group_id=137895
 # https://sourceforge.net/projects/gdcm/files/gdcm%202.x/#folder-create
 
 # Update default version:
 #https://sourceforge.net/p/forge/documentation/Using%20the%20Release%20API/
-exit 1
-rsync -e ssh GDCM-$version-Linux-x86_64.tar.gz          "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
-check_exit_value $? "rsync did not return properly" || exit 1
-rsync -e ssh GDCM-$version-Linux-x86_64.tar.bz2         "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
-check_exit_value $? "rsync did not return properly" || exit 1
-rsync -e ssh gdcm-$version.zip                          "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
-check_exit_value $? "rsync did not return properly" || exit 1
+#rsync -e ssh GDCM-$version-Linux-x86_64.tar.gz          "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
+#check_exit_value $? "rsync did not return properly" || exit 1
+#rsync -e ssh GDCM-$version-Linux-x86_64.tar.bz2         "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
+#check_exit_value $? "rsync did not return properly" || exit 1
+#rsync -e ssh gdcm-$version.zip                          "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
+#check_exit_value $? "rsync did not return properly" || exit 1
 rsync -e ssh gdcm-$version.tar.gz                       "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
 check_exit_value $? "rsync did not return properly" || exit 1
+
+def_prop="default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others"
+def_path="https://sourceforge.net/projects/gdcm/files/gdcm%202.x/GDCM%20$version/gdcm-$version.tar.gz"
+curl -k -H "Accept: application/json" -X PUT -d $def_prop -d "api_key=$SFAPIKEY" $def_path
+
 rsync -e ssh gdcm-$version.tar.bz2                      "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
 check_exit_value $? "rsync did not return properly" || exit 1
 rsync -e ssh Utilities/doxygen/gdcm-$version-doc.tar.gz "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
 check_exit_value $? "rsync did not return properly" || exit 1
+sed "s/vVERSION/v$version/" $basedir/gdcm/Utilities/Release/README.md > $basedir/README.md
+rsync -e ssh $basedir/README.md "malat,gdcm at frs.sourceforge.net:/home/frs/project/g/gd/gdcm/gdcm\ 2.x/GDCM\ $version"
+check_exit_value $? "rsync did not return properly" || exit 1
 
 rsync -a -r Utilities/doxygen/html malat,gdcm at web.sourceforge.net:htdocs/$dirversion
 check_exit_value $? "rsync recursive html did not return properly" || exit 1
diff --git a/Utilities/Tools/CMakeLists.txt b/Utilities/Tools/CMakeLists.txt
deleted file mode 100644
index 0c8d7f4..0000000
--- a/Utilities/Tools/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-project(TOOLS)
-
-add_executable(upsidedown upsidedown.c)
diff --git a/Utilities/Tools/upsidedown.c b/Utilities/Tools/upsidedown.c
deleted file mode 100644
index 66f1a9d..0000000
--- a/Utilities/Tools/upsidedown.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*=========================================================================
-
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-
-#include <stdio.h>
-#include <assert.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[])
-{
-  const unsigned int x = 420;
-  const unsigned int y = 608;
-  const unsigned int bit = 1;
-  char *buffer = malloc(x*y*bit);
-  int i = 1;
-  size_t len;
-  const char *filename, *outfilename;
-  FILE *in, *out;
-  if( argc < 3 )
-    return 1;
-  filename = argv[1];
-  outfilename = argv[2];
-  in = fopen(filename, "rb" );
-  out = fopen(outfilename, "wb" );
-  len = fread(buffer,1,bit*x*y,in);
-  assert( len == x*y*bit );
-
-  for(i = y; i > 0; --i)
-    {
-    fwrite(buffer+bit*x*(i-1),1,bit*x,out);
-    }
-  fclose(in);
-  fclose(out);
-  free(buffer);
-  return 0;
-}
diff --git a/Utilities/VTK/Applications/gdcm2vtk.cxx b/Utilities/VTK/Applications/gdcm2vtk.cxx
index a651242..3ccb59f 100644
--- a/Utilities/VTK/Applications/gdcm2vtk.cxx
+++ b/Utilities/VTK/Applications/gdcm2vtk.cxx
@@ -64,11 +64,9 @@
 
 #include <getopt.h>
 
-#if VTK_MAJOR_VERSION >= 6
 #ifndef vtkFloatingPointType
 #define vtkFloatingPointType double
 #endif
-#endif
 
 void PrintVersion()
 {
diff --git a/Utilities/VTK/Applications/gdcmviewer.cxx b/Utilities/VTK/Applications/gdcmviewer.cxx
index ae89ade..c2d8c3c 100644
--- a/Utilities/VTK/Applications/gdcmviewer.cxx
+++ b/Utilities/VTK/Applications/gdcmviewer.cxx
@@ -89,11 +89,9 @@ class vtkAngleWidget;
 #include <getopt.h>
 #include <assert.h>
 
-#if VTK_MAJOR_VERSION >= 6
 #ifndef vtkFloatingPointType
 #define vtkFloatingPointType double
 #endif
-#endif
 
 //----------------------------------------------------------------------------
 // vtkImageViewer2 new interface wants SetSlice, but vtkImageViewer does not have
@@ -102,11 +100,7 @@ class vtkAngleWidget;
 class vtkGDCMImageViewer : public vtkImageViewer
 {
 public:
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMImageViewer,vtkImageViewer);
-#else
   vtkTypeMacro(vtkGDCMImageViewer,vtkImageViewer);
-#endif
 
   static vtkGDCMImageViewer *New()
     {
@@ -129,11 +123,7 @@ public:
   double GetOverlayVisibility() { return 0; }
   void SetOverlayVisibility(double vis) {(void)vis;}
 };
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMImageViewer, "$Revision: 1.30 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMImageViewer, "$Revision: 1.30 $")
-#endif
 vtkInstantiatorNewMacro(vtkGDCMImageViewer)
 
 #if VTK_MAJOR_VERSION >= 5
@@ -141,11 +131,7 @@ vtkInstantiatorNewMacro(vtkGDCMImageViewer)
 class vtkImageColorViewer : public vtkImageViewer2
 {
 public:
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkImageColorViewer,vtkImageViewer2);
-#else
   vtkTypeMacro(vtkImageColorViewer,vtkImageViewer2);
-#endif
 
   static vtkImageColorViewer *New()
     {
@@ -183,11 +169,7 @@ public:
 private:
   vtkImageActor                   *OverlayImageActor;
 };
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkImageColorViewer, "$Revision: 1.30 $")
-#else
 //vtkCxxRevisionMacro(vtkImageColorViewer, "$Revision: 1.30 $")
-#endif
 vtkInstantiatorNewMacro(vtkImageColorViewer)
 #endif
 
diff --git a/Utilities/VTK/CMakeLists.txt b/Utilities/VTK/CMakeLists.txt
index 8363e1e..92e691c 100644
--- a/Utilities/VTK/CMakeLists.txt
+++ b/Utilities/VTK/CMakeLists.txt
@@ -78,6 +78,7 @@ else()
     vtkRenderingCore
     vtkRenderingFreeType
     vtkRenderingFreeTypeOpenGL
+    vtkFiltersParallelDIY2
   )
   if(("${VTK_MAJOR_VERSION}" EQUAL 6) OR ("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL"))
     list(APPEND vtkgdcm_COND_LIBS vtkRenderingOpenGL)
diff --git a/Utilities/VTK/Examples/Cxx/Compute3DSpacing.cxx b/Utilities/VTK/Examples/Cxx/Compute3DSpacing.cxx
index bb16596..cd6065d 100644
--- a/Utilities/VTK/Examples/Cxx/Compute3DSpacing.cxx
+++ b/Utilities/VTK/Examples/Cxx/Compute3DSpacing.cxx
@@ -16,12 +16,10 @@
 #include "vtkStringArray.h"
 #include "gdcmIPPSorter.h"
 
-#if VTK_MAJOR_VERSION >= 6
 #ifndef vtkFloatingPointType
 #define vtkFloatingPointType double
 #endif
 
-#endif
 /*
  * Simple example to check computation of spacing within vtkGDCMImageReader2
  * This is a direct implementation of:
diff --git a/Utilities/VTK/Examples/Cxx/gdcmorthoplanes.cxx b/Utilities/VTK/Examples/Cxx/gdcmorthoplanes.cxx
index 4a6d504..1b4217d 100644
--- a/Utilities/VTK/Examples/Cxx/gdcmorthoplanes.cxx
+++ b/Utilities/VTK/Examples/Cxx/gdcmorthoplanes.cxx
@@ -51,12 +51,8 @@
 #include "gdcmIPPSorter.h"
 
 #ifndef vtkFloatingPointType
-#if VTK_MAJOR_VERSION < 6
-#define vtkFloatingPointType float
-#else
 #define vtkFloatingPointType double
 #endif
-#endif
 
 //----------------------------------------------------------------------------
 class vtkOrthoPlanesCallback : public vtkCommand
diff --git a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader1.cxx b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader1.cxx
index 92b7578..2f49c04 100644
--- a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader1.cxx
+++ b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader1.cxx
@@ -26,12 +26,8 @@
 #include "gdcmFilenameGenerator.h"
 
 #ifndef vtkFloatingPointType
-#if VTK_MAJOR_VERSION < 6
-#define vtkFloatingPointType float
-#else
 #define vtkFloatingPointType double
 #endif
-#endif
 /*
  * Test to show the pipeline for
  * IPPSorter -> vtkGDCMImageReader -> vtkImageChangeInformation
diff --git a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader2_3.cxx b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader2_3.cxx
index 35366a2..e3ab435 100644
--- a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader2_3.cxx
+++ b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReader2_3.cxx
@@ -26,12 +26,8 @@
 #include "gdcmFilenameGenerator.h"
 
 #ifndef vtkFloatingPointType
-#if VTK_MAJOR_VERSION < 6
-#define vtkFloatingPointType float
-#else
 #define vtkFloatingPointType double
 #endif
-#endif
 /*
  * Test to show the pipeline for
  * IPPSorter -> vtkGDCMImageReader2 -> vtkImageChangeInformation
diff --git a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReaderIsLossy.cxx b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReaderIsLossy.cxx
index 3abe7df..224a86a 100644
--- a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReaderIsLossy.cxx
+++ b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageReaderIsLossy.cxx
@@ -24,12 +24,8 @@
 #include "gdcmImageReader.h"
 
 #ifndef vtkFloatingPointType
-#if VTK_MAJOR_VERSION < 6
-#define vtkFloatingPointType float
-#else
 #define vtkFloatingPointType double
 #endif
-#endif
 
 int TestvtkGDCMImageReaderIsLossyFunc(const char *filename, bool verbose = false)
 {
diff --git a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter1.cxx b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter1.cxx
index ef1126f..9828b53 100644
--- a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter1.cxx
+++ b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter1.cxx
@@ -25,12 +25,8 @@
 #include "gdcmImageReader.h"
 
 #ifndef vtkFloatingPointType
-#if VTK_MAJOR_VERSION < 6
-#define vtkFloatingPointType float
-#else
 #define vtkFloatingPointType double
 #endif
-#endif
 
 int TestvtkGDCMImageWrite(const char *filename, bool verbose = false)
 {
diff --git a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter2.cxx b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter2.cxx
index fa7271c..0e372c5 100644
--- a/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter2.cxx
+++ b/Utilities/VTK/Testing/Cxx/TestvtkGDCMImageWriter2.cxx
@@ -29,12 +29,8 @@
 #include <iostream>
 
 #ifndef vtkFloatingPointType
-#if VTK_MAJOR_VERSION < 6
-#define vtkFloatingPointType float
-#else
 #define vtkFloatingPointType double
 #endif
-#endif
 
 int TestvtkGDCMImageWrite2(const char *filename, bool verbose = false)
 {
diff --git a/Utilities/VTK/VTK4/vtkMedicalImageProperties.cxx b/Utilities/VTK/VTK4/vtkMedicalImageProperties.cxx
index 3d5dfc3..0903242 100644
--- a/Utilities/VTK/VTK4/vtkMedicalImageProperties.cxx
+++ b/Utilities/VTK/VTK4/vtkMedicalImageProperties.cxx
@@ -39,11 +39,7 @@
 #include <assert.h>
 
 //----------------------------------------------------------------------------
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkMedicalImageProperties, "1.21")
-#else
 //vtkCxxRevisionMacro(vtkMedicalImageProperties, "1.21")
-#endif
 vtkStandardNewMacro(vtkMedicalImageProperties)
 
 static const char *vtkMedicalImagePropertiesOrientationString[] = {
diff --git a/Utilities/VTK/VTK4/vtkMedicalImageProperties.h b/Utilities/VTK/VTK4/vtkMedicalImageProperties.h
index ab91ff6..38322e9 100644
--- a/Utilities/VTK/VTK4/vtkMedicalImageProperties.h
+++ b/Utilities/VTK/VTK4/vtkMedicalImageProperties.h
@@ -51,11 +51,7 @@ class VTK_IO_EXPORT vtkMedicalImageProperties : public vtkObject
 {
 public:
   static vtkMedicalImageProperties *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkMedicalImageProperties,vtkObject);
-#else
   vtkTypeMacro(vtkMedicalImageProperties,vtkObject);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/VTK4/vtkStringArray.cxx b/Utilities/VTK/VTK4/vtkStringArray.cxx
index 5058609..5b5c7c8 100644
--- a/Utilities/VTK/VTK4/vtkStringArray.cxx
+++ b/Utilities/VTK/VTK4/vtkStringArray.cxx
@@ -18,11 +18,7 @@
 #include <vector>
 #include <string>
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkStringArray, "$Revision: 1.1 $")
-#else
 //vtkCxxRevisionMacro(vtkStringArray, "$Revision: 1.1 $")
-#endif
 vtkStandardNewMacro(vtkStringArray)
 
 struct vtkStringArrayInternals
diff --git a/Utilities/VTK/VTK4/vtkStringArray.h b/Utilities/VTK/VTK4/vtkStringArray.h
index 3e8bed2..848ac7f 100644
--- a/Utilities/VTK/VTK4/vtkStringArray.h
+++ b/Utilities/VTK/VTK4/vtkStringArray.h
@@ -34,11 +34,7 @@ class VTK_EXPORT vtkStringArray : public vtkObject
 {
 public:
   static vtkStringArray *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkStringArray,vtkObject);
-#else
   vtkTypeMacro(vtkStringArray,vtkObject);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
 //BTX
diff --git a/Utilities/VTK/vtkGDCMImageReader.cxx b/Utilities/VTK/vtkGDCMImageReader.cxx
index 30e85c6..3f96217 100644
--- a/Utilities/VTK/vtkGDCMImageReader.cxx
+++ b/Utilities/VTK/vtkGDCMImageReader.cxx
@@ -51,11 +51,7 @@
 
 #include <sstream>
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMImageReader, "$Revision: 1.1 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMImageReader, "$Revision: 1.1 $")
-#endif
 vtkStandardNewMacro(vtkGDCMImageReader)
 
 static inline bool vtkGDCMImageReader_IsCharTypeSigned()
diff --git a/Utilities/VTK/vtkGDCMImageReader.h b/Utilities/VTK/vtkGDCMImageReader.h
index eb4aeac..731b053 100644
--- a/Utilities/VTK/vtkGDCMImageReader.h
+++ b/Utilities/VTK/vtkGDCMImageReader.h
@@ -103,11 +103,7 @@ class VTK_EXPORT vtkGDCMImageReader : public vtkMedicalImageReader2
 {
 public:
   static vtkGDCMImageReader *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMImageReader,vtkMedicalImageReader2);
-#else
   vtkTypeMacro(vtkGDCMImageReader,vtkMedicalImageReader2);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description: is the given file name a DICOM file containing an image ?
diff --git a/Utilities/VTK/vtkGDCMImageReader2.cxx b/Utilities/VTK/vtkGDCMImageReader2.cxx
index 5b3195c..80bf550 100644
--- a/Utilities/VTK/vtkGDCMImageReader2.cxx
+++ b/Utilities/VTK/vtkGDCMImageReader2.cxx
@@ -49,11 +49,7 @@
 
 #include <sstream>
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMImageReader2, "$Revision: 1.1 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMImageReader2, "$Revision: 1.1 $")
-#endif
 vtkStandardNewMacro(vtkGDCMImageReader2)
 
 static inline bool vtkGDCMImageReader2_IsCharTypeSigned()
diff --git a/Utilities/VTK/vtkGDCMImageReader2.h b/Utilities/VTK/vtkGDCMImageReader2.h
index 9389b42..92e69d1 100644
--- a/Utilities/VTK/vtkGDCMImageReader2.h
+++ b/Utilities/VTK/vtkGDCMImageReader2.h
@@ -95,11 +95,7 @@ class VTK_EXPORT vtkGDCMImageReader2 : public vtkMedicalImageReader2
 {
 public:
   static vtkGDCMImageReader2 *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMImageReader2,vtkMedicalImageReader2);
-#else
   vtkTypeMacro(vtkGDCMImageReader2,vtkMedicalImageReader2);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description: is the given file name a DICOM file containing an image ?
diff --git a/Utilities/VTK/vtkGDCMImageWriter.cxx b/Utilities/VTK/vtkGDCMImageWriter.cxx
index 3439cd7..ad3444e 100644
--- a/Utilities/VTK/vtkGDCMImageWriter.cxx
+++ b/Utilities/VTK/vtkGDCMImageWriter.cxx
@@ -47,11 +47,7 @@
 
 #include <limits>
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMImageWriter, "$Revision: 1.1 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMImageWriter, "$Revision: 1.1 $")
-#endif
 vtkStandardNewMacro(vtkGDCMImageWriter)
 
 //vtkCxxSetObjectMacro(vtkGDCMImageWriter,LookupTable,vtkLookupTable)
@@ -70,12 +66,8 @@ inline bool vtkGDCMImageWriter_IsCharTypeSigned()
 }
 
 #ifndef vtkFloatingPointType
-#if VTK_MAJOR_VERSION < 6
-#define vtkFloatingPointType float
-#else
 #define vtkFloatingPointType double
 #endif
-#endif
 
 //----------------------------------------------------------------------------
 vtkGDCMImageWriter::vtkGDCMImageWriter()
diff --git a/Utilities/VTK/vtkGDCMImageWriter.h b/Utilities/VTK/vtkGDCMImageWriter.h
index 2d012fa..6e3981d 100644
--- a/Utilities/VTK/vtkGDCMImageWriter.h
+++ b/Utilities/VTK/vtkGDCMImageWriter.h
@@ -48,11 +48,7 @@ class VTK_EXPORT vtkGDCMImageWriter : public vtkImageWriter
 {
 public:
   static vtkGDCMImageWriter *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMImageWriter,vtkImageWriter);
-#else
   vtkTypeMacro(vtkGDCMImageWriter,vtkImageWriter);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkGDCMMedicalImageProperties.cxx b/Utilities/VTK/vtkGDCMMedicalImageProperties.cxx
index d4e91eb..b3c3bdc 100644
--- a/Utilities/VTK/vtkGDCMMedicalImageProperties.cxx
+++ b/Utilities/VTK/vtkGDCMMedicalImageProperties.cxx
@@ -17,11 +17,7 @@
 #include "gdcmFile.h"
 
 //----------------------------------------------------------------------------
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMMedicalImageProperties, "1.21")
-#else
 //vtkCxxRevisionMacro(vtkGDCMMedicalImageProperties, "1.21")
-#endif
 vtkStandardNewMacro(vtkGDCMMedicalImageProperties)
 
 class vtkGDCMMedicalImagePropertiesInternals
diff --git a/Utilities/VTK/vtkGDCMMedicalImageProperties.h b/Utilities/VTK/vtkGDCMMedicalImageProperties.h
index 3c82cbd..7c05874 100644
--- a/Utilities/VTK/vtkGDCMMedicalImageProperties.h
+++ b/Utilities/VTK/vtkGDCMMedicalImageProperties.h
@@ -34,11 +34,7 @@ class VTK_EXPORT vtkGDCMMedicalImageProperties : public vtkMedicalImagePropertie
 {
 public:
   static vtkGDCMMedicalImageProperties *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMMedicalImageProperties,vtkMedicalImageProperties);
-#else
   vtkTypeMacro(vtkGDCMMedicalImageProperties,vtkMedicalImageProperties);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkGDCMPolyDataReader.cxx b/Utilities/VTK/vtkGDCMPolyDataReader.cxx
index e1221dd..7ebd455 100644
--- a/Utilities/VTK/vtkGDCMPolyDataReader.cxx
+++ b/Utilities/VTK/vtkGDCMPolyDataReader.cxx
@@ -30,11 +30,7 @@
 #include "gdcmSequenceOfItems.h"
 #include "gdcmDirectoryHelper.h"
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMPolyDataReader, "$Revision: 1.74 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMPolyDataReader, "$Revision: 1.74 $")
-#endif
 vtkStandardNewMacro(vtkGDCMPolyDataReader)
 
 //----------------------------------------------------------------------------
diff --git a/Utilities/VTK/vtkGDCMPolyDataReader.h b/Utilities/VTK/vtkGDCMPolyDataReader.h
index e6df72f..abec5ee 100644
--- a/Utilities/VTK/vtkGDCMPolyDataReader.h
+++ b/Utilities/VTK/vtkGDCMPolyDataReader.h
@@ -39,11 +39,7 @@ class VTK_EXPORT vtkGDCMPolyDataReader : public vtkPolyDataAlgorithm
 {
 public:
   static vtkGDCMPolyDataReader *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMPolyDataReader,vtkPolyDataAlgorithm);
-#else
   vtkTypeMacro(vtkGDCMPolyDataReader,vtkPolyDataAlgorithm);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkGDCMPolyDataWriter.cxx b/Utilities/VTK/vtkGDCMPolyDataWriter.cxx
index e4216d8..e2c661c 100644
--- a/Utilities/VTK/vtkGDCMPolyDataWriter.cxx
+++ b/Utilities/VTK/vtkGDCMPolyDataWriter.cxx
@@ -40,11 +40,7 @@
 #include "gdcmAttribute.h"
 #include "gdcmDirectoryHelper.h"
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMPolyDataWriter, "$Revision: 1.74 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMPolyDataWriter, "$Revision: 1.74 $")
-#endif
 vtkStandardNewMacro(vtkGDCMPolyDataWriter)
 vtkCxxSetObjectMacro(vtkGDCMPolyDataWriter,MedicalImageProperties,vtkMedicalImageProperties)
 vtkCxxSetObjectMacro(vtkGDCMPolyDataWriter,RTStructSetProperties,vtkRTStructSetProperties)
diff --git a/Utilities/VTK/vtkGDCMPolyDataWriter.h b/Utilities/VTK/vtkGDCMPolyDataWriter.h
index f34cb37..afbc9f1 100644
--- a/Utilities/VTK/vtkGDCMPolyDataWriter.h
+++ b/Utilities/VTK/vtkGDCMPolyDataWriter.h
@@ -39,11 +39,7 @@ class VTK_EXPORT vtkGDCMPolyDataWriter : public vtkPolyDataWriter
 {
 public:
   static vtkGDCMPolyDataWriter *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMPolyDataWriter,vtkPolyDataWriter);
-#else
   vtkTypeMacro(vtkGDCMPolyDataWriter,vtkPolyDataWriter);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkGDCMTesting.cxx b/Utilities/VTK/vtkGDCMTesting.cxx
index 7af3879..7f6c015 100644
--- a/Utilities/VTK/vtkGDCMTesting.cxx
+++ b/Utilities/VTK/vtkGDCMTesting.cxx
@@ -18,11 +18,7 @@
 #include "gdcmTesting.h"
 #include "gdcmFilename.h"
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMTesting, "$Revision: 1.31 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMTesting, "$Revision: 1.31 $")
-#endif
 vtkStandardNewMacro(vtkGDCMTesting)
 
 // DICOM Filename, MHD MD5, RAW MD5
diff --git a/Utilities/VTK/vtkGDCMTesting.h b/Utilities/VTK/vtkGDCMTesting.h
index 52ecbb6..a011b17 100644
--- a/Utilities/VTK/vtkGDCMTesting.h
+++ b/Utilities/VTK/vtkGDCMTesting.h
@@ -27,11 +27,7 @@ class VTK_EXPORT vtkGDCMTesting : public vtkObject
 {
 public:
   static vtkGDCMTesting *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMTesting,vtkObject);
-#else
   vtkTypeMacro(vtkGDCMTesting,vtkObject);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   static const char *GetVTKDataRoot();
diff --git a/Utilities/VTK/vtkGDCMThreadedImageReader.cxx b/Utilities/VTK/vtkGDCMThreadedImageReader.cxx
index 5cda558..eb75839 100644
--- a/Utilities/VTK/vtkGDCMThreadedImageReader.cxx
+++ b/Utilities/VTK/vtkGDCMThreadedImageReader.cxx
@@ -43,11 +43,7 @@
 #include <sys/sysctl.h>
 #endif
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMThreadedImageReader, "$Revision: 1.1 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMThreadedImageReader, "$Revision: 1.1 $")
-#endif
 vtkStandardNewMacro(vtkGDCMThreadedImageReader)
 
 // Output Ports are as follow:
diff --git a/Utilities/VTK/vtkGDCMThreadedImageReader.h b/Utilities/VTK/vtkGDCMThreadedImageReader.h
index a72aeff..9210d1f 100644
--- a/Utilities/VTK/vtkGDCMThreadedImageReader.h
+++ b/Utilities/VTK/vtkGDCMThreadedImageReader.h
@@ -43,11 +43,7 @@ class VTK_EXPORT vtkGDCMThreadedImageReader : public vtkGDCMImageReader
 {
 public:
   static vtkGDCMThreadedImageReader *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMThreadedImageReader,vtkGDCMImageReader);
-#else
   vtkTypeMacro(vtkGDCMThreadedImageReader,vtkGDCMImageReader);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkGDCMThreadedImageReader2.cxx b/Utilities/VTK/vtkGDCMThreadedImageReader2.cxx
index 189b4f1..6df2ea2 100644
--- a/Utilities/VTK/vtkGDCMThreadedImageReader2.cxx
+++ b/Utilities/VTK/vtkGDCMThreadedImageReader2.cxx
@@ -25,11 +25,7 @@
 
 #include <assert.h>
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkGDCMThreadedImageReader2, "$Revision: 1.1 $")
-#else
 //vtkCxxRevisionMacro(vtkGDCMThreadedImageReader2, "$Revision: 1.1 $")
-#endif
 vtkStandardNewMacro(vtkGDCMThreadedImageReader2)
 vtkCxxSetObjectMacro(vtkGDCMThreadedImageReader2,FileNames,vtkStringArray)
 
diff --git a/Utilities/VTK/vtkGDCMThreadedImageReader2.h b/Utilities/VTK/vtkGDCMThreadedImageReader2.h
index fe14f2a..8b6473d 100644
--- a/Utilities/VTK/vtkGDCMThreadedImageReader2.h
+++ b/Utilities/VTK/vtkGDCMThreadedImageReader2.h
@@ -50,11 +50,7 @@ class VTK_EXPORT vtkGDCMThreadedImageReader2 : public vtkThreadedImageAlgorithm
 {
 public:
   static vtkGDCMThreadedImageReader2 *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkGDCMThreadedImageReader2,vtkThreadedImageAlgorithm);
-#else
   vtkTypeMacro(vtkGDCMThreadedImageReader2,vtkThreadedImageAlgorithm);
-#endif
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
   vtkGetMacro(FileLowerLeft,int);
diff --git a/Utilities/VTK/vtkImageColorViewer.cxx b/Utilities/VTK/vtkImageColorViewer.cxx
index fbbe3b9..3d6df39 100644
--- a/Utilities/VTK/vtkImageColorViewer.cxx
+++ b/Utilities/VTK/vtkImageColorViewer.cxx
@@ -49,11 +49,7 @@
 #include "vtkInformation.h"
 #endif
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkImageColorViewer, "$Revision: 1.3 $")
-#else
 //vtkCxxRevisionMacro(vtkImageColorViewer, "$Revision: 1.3 $")
-#endif
 vtkStandardNewMacro(vtkImageColorViewer)
 
 //----------------------------------------------------------------------------
diff --git a/Utilities/VTK/vtkImageColorViewer.h b/Utilities/VTK/vtkImageColorViewer.h
index e0b05fb..7673dba 100644
--- a/Utilities/VTK/vtkImageColorViewer.h
+++ b/Utilities/VTK/vtkImageColorViewer.h
@@ -71,11 +71,7 @@ class VTK_EXPORT vtkImageColorViewer : public vtkObject
 {
 public:
   static vtkImageColorViewer *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkImageColorViewer,vtkObject);
-#else
   vtkTypeMacro(vtkImageColorViewer,vtkObject);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkImageMapToColors16.cxx b/Utilities/VTK/vtkImageMapToColors16.cxx
index c172a40..96c805a 100644
--- a/Utilities/VTK/vtkImageMapToColors16.cxx
+++ b/Utilities/VTK/vtkImageMapToColors16.cxx
@@ -37,11 +37,7 @@
 #include "vtkScalarsToColors.h"
 #include "vtkPointData.h"
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkImageMapToColors16, "$Revision: 1.30 $")
-#else
 //vtkCxxRevisionMacro(vtkImageMapToColors16, "$Revision: 1.30 $")
-#endif
 vtkStandardNewMacro(vtkImageMapToColors16)
 vtkCxxSetObjectMacro(vtkImageMapToColors16,LookupTable,vtkScalarsToColors)
 
diff --git a/Utilities/VTK/vtkImageMapToColors16.h b/Utilities/VTK/vtkImageMapToColors16.h
index 70b76ec..cf35dc0 100644
--- a/Utilities/VTK/vtkImageMapToColors16.h
+++ b/Utilities/VTK/vtkImageMapToColors16.h
@@ -50,11 +50,7 @@ class VTK_EXPORT vtkImageMapToColors16 : public vtkThreadedImageAlgorithm
 {
 public:
   static vtkImageMapToColors16 *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkImageMapToColors16,vtkThreadedImageAlgorithm);
-#else
   vtkTypeMacro(vtkImageMapToColors16,vtkThreadedImageAlgorithm);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkImageMapToWindowLevelColors2.cxx b/Utilities/VTK/vtkImageMapToWindowLevelColors2.cxx
index 1a355fa..337583a 100644
--- a/Utilities/VTK/vtkImageMapToWindowLevelColors2.cxx
+++ b/Utilities/VTK/vtkImageMapToWindowLevelColors2.cxx
@@ -37,11 +37,7 @@
 #include "vtkScalarsToColors.h"
 #include "vtkPointData.h"
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkImageMapToWindowLevelColors2, "$Revision: 1.3 $")
-#else
 //vtkCxxRevisionMacro(vtkImageMapToWindowLevelColors2, "$Revision: 1.3 $")
-#endif
 vtkStandardNewMacro(vtkImageMapToWindowLevelColors2)
 
 // Constructor sets default values
diff --git a/Utilities/VTK/vtkImageMapToWindowLevelColors2.h b/Utilities/VTK/vtkImageMapToWindowLevelColors2.h
index 54bf2fb..1ea8dde 100644
--- a/Utilities/VTK/vtkImageMapToWindowLevelColors2.h
+++ b/Utilities/VTK/vtkImageMapToWindowLevelColors2.h
@@ -49,11 +49,7 @@ class VTK_EXPORT vtkImageMapToWindowLevelColors2 : public vtkImageMapToColors
 {
 public:
   static vtkImageMapToWindowLevelColors2 *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkImageMapToWindowLevelColors2,vtkImageMapToColors);
-#else
   vtkTypeMacro(vtkImageMapToWindowLevelColors2,vtkImageMapToColors);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/VTK/vtkImagePlanarComponentsToComponents.cxx b/Utilities/VTK/vtkImagePlanarComponentsToComponents.cxx
index 78d5a7c..af0e544 100644
--- a/Utilities/VTK/vtkImagePlanarComponentsToComponents.cxx
+++ b/Utilities/VTK/vtkImagePlanarComponentsToComponents.cxx
@@ -41,11 +41,7 @@
 
 #include <assert.h>
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkImagePlanarComponentsToComponents, "$Revision: 1.31 $")
-#else
 //vtkCxxRevisionMacro(vtkImagePlanarComponentsToComponents, "$Revision: 1.31 $")
-#endif
 vtkStandardNewMacro(vtkImagePlanarComponentsToComponents)
 
 //----------------------------------------------------------------------------
diff --git a/Utilities/VTK/vtkImagePlanarComponentsToComponents.h b/Utilities/VTK/vtkImagePlanarComponentsToComponents.h
index 79188f9..d378549 100644
--- a/Utilities/VTK/vtkImagePlanarComponentsToComponents.h
+++ b/Utilities/VTK/vtkImagePlanarComponentsToComponents.h
@@ -49,13 +49,8 @@ class VTK_EXPORT vtkImagePlanarComponentsToComponents : public vtkImageAlgorithm
 {
 public:
   static vtkImagePlanarComponentsToComponents *New();
-#if VTK_MAJOR_VERSION < 6
-  //vtkTypeRevisionMacro(vtkImagePlanarComponentsToComponents,vtkThreadedImageAlgorithm);
-  vtkTypeRevisionMacro(vtkImagePlanarComponentsToComponents,vtkImageAlgorithm);
-#else
   //vtkTypeMacro(vtkImagePlanarComponentsToComponents,vtkThreadedImageAlgorithm);
   vtkTypeMacro(vtkImagePlanarComponentsToComponents,vtkImageAlgorithm);
-#endif
 
   void PrintSelf(ostream& os, vtkIndent indent);
 
diff --git a/Utilities/VTK/vtkImageRGBToYBR.cxx b/Utilities/VTK/vtkImageRGBToYBR.cxx
index e0c4bd4..3b2a400 100644
--- a/Utilities/VTK/vtkImageRGBToYBR.cxx
+++ b/Utilities/VTK/vtkImageRGBToYBR.cxx
@@ -34,11 +34,7 @@
 #include "vtkMath.h"
 #include "vtkObjectFactory.h"
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkImageRGBToYBR, "$Revision: 1.31 $")
-#else
 //vtkCxxRevisionMacro(vtkImageRGBToYBR, "$Revision: 1.31 $")
-#endif
 vtkStandardNewMacro(vtkImageRGBToYBR)
 
 //----------------------------------------------------------------------------
diff --git a/Utilities/VTK/vtkImageRGBToYBR.h b/Utilities/VTK/vtkImageRGBToYBR.h
index 8efd906..7bcec29 100644
--- a/Utilities/VTK/vtkImageRGBToYBR.h
+++ b/Utilities/VTK/vtkImageRGBToYBR.h
@@ -45,11 +45,7 @@ class VTK_EXPORT vtkImageRGBToYBR : public vtkThreadedImageAlgorithm
 {
 public:
   static vtkImageRGBToYBR *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkImageRGBToYBR,vtkThreadedImageAlgorithm);
-#else
   vtkTypeMacro(vtkImageRGBToYBR,vtkThreadedImageAlgorithm);
-#endif
 
   void PrintSelf(ostream& os, vtkIndent indent);
 
diff --git a/Utilities/VTK/vtkImageYBRToRGB.cxx b/Utilities/VTK/vtkImageYBRToRGB.cxx
index afe9635..60aad2c 100644
--- a/Utilities/VTK/vtkImageYBRToRGB.cxx
+++ b/Utilities/VTK/vtkImageYBRToRGB.cxx
@@ -34,11 +34,7 @@
 #include "vtkMath.h"
 #include "vtkObjectFactory.h"
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkImageYBRToRGB, "$Revision: 1.31 $")
-#else
 //vtkCxxRevisionMacro(vtkImageYBRToRGB, "$Revision: 1.31 $")
-#endif
 vtkStandardNewMacro(vtkImageYBRToRGB)
 
 //----------------------------------------------------------------------------
diff --git a/Utilities/VTK/vtkImageYBRToRGB.h b/Utilities/VTK/vtkImageYBRToRGB.h
index ba7ee14..8c7e14f 100644
--- a/Utilities/VTK/vtkImageYBRToRGB.h
+++ b/Utilities/VTK/vtkImageYBRToRGB.h
@@ -45,11 +45,7 @@ class VTK_EXPORT vtkImageYBRToRGB : public vtkThreadedImageAlgorithm
 {
 public:
   static vtkImageYBRToRGB *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkImageYBRToRGB,vtkThreadedImageAlgorithm);
-#else
   vtkTypeMacro(vtkImageYBRToRGB,vtkThreadedImageAlgorithm);
-#endif
 
   void PrintSelf(ostream& os, vtkIndent indent);
 
diff --git a/Utilities/VTK/vtkLookupTable16.cxx b/Utilities/VTK/vtkLookupTable16.cxx
index eff3364..45be3be 100644
--- a/Utilities/VTK/vtkLookupTable16.cxx
+++ b/Utilities/VTK/vtkLookupTable16.cxx
@@ -32,11 +32,7 @@
 
 #include <cassert>
 
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkLookupTable16, "$Revision: 1.107 $")
-#else
 //vtkCxxRevisionMacro(vtkLookupTable16, "$Revision: 1.107 $")
-#endif
 vtkStandardNewMacro(vtkLookupTable16)
 
 vtkLookupTable16::vtkLookupTable16(int sze, int ext)
diff --git a/Utilities/VTK/vtkLookupTable16.h b/Utilities/VTK/vtkLookupTable16.h
index 4cb9d9e..2ddd2f4 100644
--- a/Utilities/VTK/vtkLookupTable16.h
+++ b/Utilities/VTK/vtkLookupTable16.h
@@ -46,11 +46,7 @@ class VTK_EXPORT vtkLookupTable16 : public vtkLookupTable
 public:
   static vtkLookupTable16 *New();
 
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkLookupTable16,vtkLookupTable);
-#else
   vtkTypeMacro(vtkLookupTable16,vtkLookupTable);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   void Build();
diff --git a/Utilities/VTK/vtkRTStructSetProperties.cxx b/Utilities/VTK/vtkRTStructSetProperties.cxx
index 8edf234..6310b60 100644
--- a/Utilities/VTK/vtkRTStructSetProperties.cxx
+++ b/Utilities/VTK/vtkRTStructSetProperties.cxx
@@ -28,11 +28,7 @@
 #include <assert.h>
 
 //----------------------------------------------------------------------------
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(vtkRTStructSetProperties, "1.21")
-#else
 //vtkCxxRevisionMacro(vtkRTStructSetProperties, "1.21")
-#endif
 vtkStandardNewMacro(vtkRTStructSetProperties)
 
 
diff --git a/Utilities/VTK/vtkRTStructSetProperties.h b/Utilities/VTK/vtkRTStructSetProperties.h
index 334d851..0beb5ef 100644
--- a/Utilities/VTK/vtkRTStructSetProperties.h
+++ b/Utilities/VTK/vtkRTStructSetProperties.h
@@ -28,11 +28,7 @@ class VTK_EXPORT vtkRTStructSetProperties : public vtkObject
 {
 public:
   static vtkRTStructSetProperties *New();
-#if VTK_MAJOR_VERSION < 6
-  vtkTypeRevisionMacro(vtkRTStructSetProperties,vtkObject);
-#else
   vtkTypeMacro(vtkRTStructSetProperties,vtkObject);
-#endif
   void PrintSelf(ostream& os, vtkIndent indent);
 
   // Description:
diff --git a/Utilities/doxygen/man/gdcmdump.xml b/Utilities/doxygen/man/gdcmdump.xml
index 9a8223c..a3ff2de 100644
--- a/Utilities/doxygen/man/gdcmdump.xml
+++ b/Utilities/doxygen/man/gdcmdump.xml
@@ -51,6 +51,8 @@ dcm_directory   DICOM input directory
   -p --print          print value instead of simply dumping (default).
   -c --color          print in color.
   -C --csa            print SIEMENS CSA Header (0029,[12]0,SIEMENS CSA HEADER).
+     --csa-asl        print decoded SIEMENS CSA MR_ASL (base64).
+     --csa-diffusion  print decoded SIEMENS CSA MRDiffusion (base64).
   -P --pdb            print GEMS Protocol Data Block (0025,1b,GEMS_SERS_01).
      --elscint        print ELSCINT Protocol Information (01f7,26,ELSCINT1).
      --vepro          print VEPRO Protocol Information (0055,20,VEPRO VIF 3.0 DATA).
@@ -181,6 +183,87 @@ Image shadow data (0029,xx10)
 ...
 </literallayout></para>
 </refsection>
+<refsection xml:id="gdcmdump_1siemens_csaasl">
+<title>SIEMENS CSA Header: MR_ASL</title>
+
+<para>Using this option it is possible to dump a decoded (base64) version of MR_ASL contained in the CSA header.</para>
+
+<para>Eg.:</para>
+
+<para><literallayout>$ gdcmdump --csa-asl ASL.dcm
+</literallayout></para>
+
+<para><literallayout>
+(0018,9251) SQ (Sequence with undefined length)                   # u/l,1 MR Arterial Spin Labeling Sequence 
+  (fffe,e000) na (Item with undefined length) 
+    (0018,9252) LO [2D pulsed ASL (EP2D)]                         # 20,1 ASL Technique Description 
+    (0018,9257) CS [LABEL ]                                       # 6,1 ASL Context 
+    (0018,9259) CS [NO]                                           # 2,1 ASL Crusher Flag 
+    (0018,925c) CS [YES ]                                         # 4,1 ASL Bolus Cut-off Flag 
+    (0018,925d) SQ (Sequence with undefined length)               # u/l,1 ASL Bolus Cut-off Timing Sequence 
+      (fffe,e000) na (Item with undefined length) 
+        (0018,925e) LO [Q2TIPS]                                   # 6,1 ASL Bolus Cut-off Technique 
+        (0018,925f) IS (UL) [1990]                                # 4,1 ASL Bolus Cut-off Delay Time 
+      (fffe,e00d) 
+    (fffe,e0dd) 
+    (0018,9260) SQ (Sequence with undefined length)               # u/l,1 ASL Slab Sequence 
+      (fffe,e000) na (Item with undefined length) 
+        (0018,9253) US 1                                          # 2,1 ASL Slab Number 
+        (0018,9254) FD 109.5                                      # 8,1 ASL Slab Thickness 
+        (0018,9255) FD 0\0\1                                      # 24,3 ASL Slab Orientation 
+        (0018,9256) FD 0\-23.9333\-70.9189                        # 24,3 ASL Mid Slab Position 
+        (0018,9258) IS (UL) [10]                                  # 2,1 ASL Pulse Train Duration 
+      (fffe,e00d) 
+    (fffe,e0dd) 
+  (fffe,e00d) 
+(fffe,e0dd) 
+</literallayout></para>
+<para>This is completely equivalent to doing (by hand):</para>
+<para><literallayout>
+$ gdcmdump --csa asl.dcm | grep -A 6 MR_ASL 
+98 - 'MR_ASL' VM 1, VR UT, SyngoDT 27, NoOfItems 6, Data 'GABRklNRAAD//////v8A4P////8YAFKSTE8UADJEIHB1bHNlZCBBU0wgKEVQMkQpGABXkkNT 
+BgBMQUJFTCAYAGCSU1EAAP/////+/wDg/////xgAU5JVUwIAAQAYAFSSRkQIAAAAAAAAYFtA 
+GABVkkZEGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8YAFaSRkQYAAAAAAAAAAAAAAAAYOvu 
+N8AAAACAzrpRwBgAWJJJUwIAMTD+/w3gAAAAAP7/3eAAAAAAGABZkkNTAgBOTxgAXJJDUwQA 
+WUVTIBgAXZJTUQAA//////7/AOD/////GABekkxPBgBRMlRJUFMYAF+SSVMEADE5OTD+/w3g 
+AAAAAP7/3eAAAAAA/v8N4AAAAAD+/93gAAAAAA== 
+' 
+$  echo 'GABRklNRAAD//////v8A4P////8YAFKSTE8UADJEIHB1bHNlZCBBU0wgKEVQMkQpGABXkkNT 
+BgBMQUJFTCAYAGCSU1EAAP/////+/wDg/////xgAU5JVUwIAAQAYAFSSRkQIAAAAAAAAYFtA 
+GABVkkZEGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8YAFaSRkQYAAAAAAAAAAAAAAAAYOvu 
+N8AAAACAzrpRwBgAWJJJUwIAMTD+/w3gAAAAAP7/3eAAAAAAGABZkkNTAgBOTxgAXJJDUwQA 
+WUVTIBgAXZJTUQAA//////7/AOD/////GABekkxPBgBRMlRJUFMYAF+SSVMEADE5OTD+/w3g 
+AAAAAP7/3eAAAAAA/v8N4AAAAAD+/93gAAAAAA== 
+' | base64 -d > asl.dcm
+$ dcmdump -f asl.dcm
+</literallayout></para>
+<para>One should pay attention that currently two attributes (0018,925f) and (0018,9258) are using a VR that is different from what the DICOM standard specifies.</para>
+</refsection>
+<refsection xml:id="gdcmdump_1siemens_csadiffusion">
+<title>SIEMENS CSA Header: MRDiffusion</title>
+
+<para>Using this option it is possible to dump a decoded (base64) version of MRDiffusion contained in the CSA header.</para>
+
+<para>Eg.:</para>
+
+<para><literallayout>$ gdcmdump --csa-diffusion DIFFUSION.dcm
+</literallayout></para>
+
+<para><literallayout># Dicom-File-Format
+
+# Dicom-Meta-Information-Header
+# Used TransferSyntax: 
+
+# Dicom-Data-Set
+# Used TransferSyntax: Unknown Transfer Syntax
+(0018,9117) SQ (Sequence with undefined length)                   # u/l,1 MR Diffusion Sequence
+  (fffe,e000) na (Item with undefined length)
+    (0018,9075) CS [ISOTROPIC ]                                   # 10,1 Diffusion Directionality
+    (0018,9087) FD 0                                              # 8,1 Diffusion b-value
+  (fffe,e00d)
+(fffe,e0dd)
+</literallayout></para>
+</refsection>
 <refsection xml:id="gdcmdump_1gems_pdb">
 <title>GEMS Protocol Data Block</title>
 
diff --git a/Utilities/gdcm_charls.h b/Utilities/gdcm_charls.h
index ba36b60..33f66d8 100644
--- a/Utilities/gdcm_charls.h
+++ b/Utilities/gdcm_charls.h
@@ -17,14 +17,13 @@
 /* Use the charls library configured for gdcm.  */
 #include "gdcmTypes.h"
 #ifdef GDCM_USE_SYSTEM_CHARLS
-// It is expected that 1.0 API is used (JlsParameters instead of JlsParamaters)
+// It is expected that version 1.1.0 is used
 # include <CharLS/header.h>
 # include <CharLS/interface.h>
 # include <CharLS/util.h>
 # include <CharLS/defaulttraits.h>
 # include <CharLS/losslesstraits.h>
 # include <CharLS/colortransform.h>
-//# include <CharLS/streams.h>
 # include <CharLS/processline.h>
 #else
 #include "gdcmcharls/header.h"
@@ -33,7 +32,6 @@
 #include "gdcmcharls/defaulttraits.h"
 #include "gdcmcharls/losslesstraits.h"
 #include "gdcmcharls/colortransform.h"
-#include "gdcmcharls/streams.h"
 #include "gdcmcharls/processline.h"
 #endif
 
diff --git a/Utilities/gdcm_openjpeg.h b/Utilities/gdcm_openjpeg.h
index 4c96910..7b1dfc7 100644
--- a/Utilities/gdcm_openjpeg.h
+++ b/Utilities/gdcm_openjpeg.h
@@ -18,24 +18,8 @@
 #include "gdcmTypes.h"
 #ifdef GDCM_USE_SYSTEM_OPENJPEG
 #include <openjpeg.h>
-// MM:
-// See openjpeg issue #3:
-// http://code.google.com/p/openjpeg/issues/detail?id=3
-//#include <j2k.h>
-//#include <jp2.h>
-
-// Instead duplicate header (I know this is bad)
-extern "C" {
-#include "gdcm_j2k.h"
-#include "gdcm_jp2.h"
-}
-
 #else
-extern "C" {
-#include <gdcmopenjpeg-v1/libopenjpeg/openjpeg.h>
-#include <gdcmopenjpeg-v1/libopenjpeg/j2k.h>
-#include <gdcmopenjpeg-v1/libopenjpeg/jp2.h>
-}
+#include <gdcmopenjpeg/src/lib/openjp2/openjpeg.h>
 #endif
 
 #endif
diff --git a/Utilities/gdcm_openjpeg2.h b/Utilities/gdcm_openjpeg2.h
deleted file mode 100644
index 79830dc..0000000
--- a/Utilities/gdcm_openjpeg2.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*=========================================================================
-
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-#ifndef GDCM_OPENJPEG2_H
-#define GDCM_OPENJPEG2_H
-
-/* Use the openjpeg library configured for gdcm.  */
-#include "gdcmTypes.h"
-#ifdef GDCM_USE_SYSTEM_OPENJPEG
-#include <openjpeg.h>
-// MM:
-// See openjpeg issue #3:
-// http://code.google.com/p/openjpeg/issues/detail?id=3
-//#include <j2k.h>
-//#include <jp2.h>
-
-// Instead duplicate header (I know this is bad)
-extern "C" {
-//#include "gdcm_j2k.h"
-//#include "gdcm_jp2.h"
-}
-
-#else
-extern "C" {
-#include <gdcmopenjpeg-v2/libopenjpeg/openjpeg.h>
-#include <gdcmopenjpeg-v2/libopenjpeg/j2k.h>
-#include <gdcmopenjpeg-v2/libopenjpeg/jp2.h>
-}
-#endif
-
-#endif
diff --git a/Utilities/gdcmcharls/CMakeLists.txt b/Utilities/gdcmcharls/CMakeLists.txt
index 04af594..6131345 100644
--- a/Utilities/gdcmcharls/CMakeLists.txt
+++ b/Utilities/gdcmcharls/CMakeLists.txt
@@ -12,7 +12,7 @@ project(${CHARLS_NAMESPACE} CXX)
 #-----------------------------------------------------------------------------
 # CHARLS version number
 set(CHARLS_MAJOR_VERSION 1)
-set(CHARLS_MINOR_VERSION 0)
+set(CHARLS_MINOR_VERSION 1)
 set(CHARLS_BUILD_VERSION 0)
 set(CHARLS_VERSION
       "${CHARLS_MAJOR_VERSION}.${CHARLS_MINOR_VERSION}.${CHARLS_BUILD_VERSION}")
@@ -52,14 +52,19 @@ endif()
 
 if(WIN32)
   if(BUILD_SHARED_LIBS)
-    add_definitions(-DCHARLS_SHARED)
+    add_definitions(-DCHARLS_DLL)
+  else()
+    add_definitions(-DCHARLS_STATIC)
   endif()
 endif()
 
 add_library(${CHARLS_LIBRARY_NAME} header.cpp  interface.cpp  jpegls.cpp
-  stdafx.cpp
+  jpegmarkersegment.cpp  jpegstreamwriter.cpp
   )
-set_target_properties(${CHARLS_LIBRARY_NAME} PROPERTIES ${GDCM_LIBRARY_PROPERTIES})
+set_target_properties( ${CHARLS_LIBRARY_NAME} PROPERTIES
+                              VERSION ${CHARLS_MAJOR_VERSION}.${CHARLS_MINOR_VERSION}
+                              SOVERSION ${CHARLS_MAJOR_VERSION})
+
 
 # Install library
 if(NOT CHARLS_INSTALL_NO_LIBRARIES)
@@ -85,8 +90,3 @@ if(NOT CHARLS_INSTALL_NO_DEVELOPMENT)
     DESTINATION ${CHARLS_INSTALL_INCLUDE_DIR} COMPONENT Headers
   )
 endif()
-#add_executable(charlstest test/test.cpp test/time.cpp)
-#target_link_libraries (charlstest CharLS)
-
-#include(CTest)
-#add_test(charlstest charlstest)
diff --git a/Utilities/gdcmcharls/License.txt b/Utilities/gdcmcharls/License.txt
index 6b7036e..87acfa2 100644
--- a/Utilities/gdcmcharls/License.txt
+++ b/Utilities/gdcmcharls/License.txt
@@ -1,27 +1,27 @@
 Copyright (c) 2007-2010, Jan de Vaan
 All rights reserved.
 
-Redistribution and use in source and binary forms, with or without
+Redistribution and use in source and binary forms, with or without 
 modification, are permitted provided that the following conditions are met:
 
-* Redistributions of source code must retain the above copyright notice, this
+* Redistributions of source code must retain the above copyright notice, this 
   list of conditions and the following disclaimer.
 
-* Redistributions in binary form must reproduce the above copyright notice,
-  this list of conditions and the following disclaimer in the documentation
+* Redistributions in binary form must reproduce the above copyright notice, 
+  this list of conditions and the following disclaimer in the documentation 
   and/or other materials provided with the distribution.
 
-* Neither the name of my employer, nor the names of its contributors may be
-  used to endorse or promote products derived from this software without
+* Neither the name of my employer, nor the names of its contributors may be 
+  used to endorse or promote products derived from this software without 
   specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
diff --git a/Utilities/gdcmcharls/README.GDCM.txt b/Utilities/gdcmcharls/README.GDCM.txt
index 5226fda..237da4e 100644
--- a/Utilities/gdcmcharls/README.GDCM.txt
+++ b/Utilities/gdcmcharls/README.GDCM.txt
@@ -1,19 +1,29 @@
-This directory contains a subset of the CharLS project (http://charls.codeplex.com/)
+This directory contains a subset of the CharLS project (https://github.com/team-charls/charls)
 
-It was retrieved on Wed Sep 23 18:30:14 CEST 2009
+It was retrieved on Thu Sep 15 09:35:25 CEST 2016
 URL:
-http://charls.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32643
-This is the 1.0 Beta Release
+https://github.com/team-charls/charls/archive/1.1.0.tar.gz
+This is the 1.1.0 Release
 
 Project Description
-An optimized implementation of the JPEG-LS standard for lossless and near-lossless image compression. JPEG-LS is a low-complexity standard that matches JPEG 2000 compression ratios. In terms of speed, CharLS outperforms open source and commercial JPEG LS implementations.
+An optimized implementation of the JPEG-LS standard for lossless and
+near-lossless image compression. JPEG-LS is a low-complexity standard that
+matches JPEG 2000 compression ratios. In terms of speed, CharLS outperforms
+open source and commercial JPEG LS implementations.
 
 About JPEG-LS
-JPEG-LS (ISO-14495-1/ITU-T.87) is a standard derived from the Hewlett Packard LOCO algorithm. JPEG LS has low complexity (meaning fast compression) and high compression ratios, similar to JPEG 2000. JPEG-LS is more similar to the old Lossless JPEG than to JPEG 2000, but interestingly the two different techniques result in vastly different performance characteristics.
+JPEG-LS (ISO-14495-1/ITU-T.87) is a standard derived from the Hewlett Packard
+LOCO algorithm. JPEG LS has low complexity (meaning fast compression) and high
+compression ratios, similar to JPEG 2000. JPEG-LS is more similar to the old
+Lossless JPEG than to JPEG 2000, but interestingly the two different techniques
+result in vastly different performance characteristics.
 Wikipedia on lossless JPEG and JPEG-LS: http://en.wikipedia.org/wiki/Lossless_JPEG
 
 Legal
-The code in this project is available through a BSD style license, allowing use of the code in commercial closed source applications if you wish. All the code in this project is written from scratch, and not based on other JPEG-LS implementations.
+The code in this project is available through a BSD style license, allowing use
+of the code in commercial closed source applications if you wish. All the code
+in this project is written from scratch, and not based on other JPEG-LS
+implementations.
 
 
 We only include enough of distribution to build the charls library.
@@ -22,7 +32,5 @@ We only include enough of distribution to build the charls library.
 Modifications
 -------------
 
-- remove tests/* subdirs
-- remove *.vcproj/*.sln M$ Visual Studio specific files (use cmake in all cases)
-- apply dos2unix to all files
-- remove trailing comma (,) in enum {}
+- only include the src/ subdir
+- keep our original cmakelists.txt
diff --git a/Utilities/gdcmcharls/colortransform.h b/Utilities/gdcmcharls/colortransform.h
index 548e993..06e31d3 100644
--- a/Utilities/gdcmcharls/colortransform.h
+++ b/Utilities/gdcmcharls/colortransform.h
@@ -9,6 +9,9 @@
 // They are invoked in processline.h to convert between decoded values and the internal line buffers. 
 // Color transforms work best for computer generated images. 
 //
+#ifdef _MSC_VER
+#pragma warning (disable: 4127)
+#endif
 
 template<class sample>
 struct TransformNoneImpl
diff --git a/Utilities/gdcmcharls/config.h b/Utilities/gdcmcharls/config.h
index ce7b42b..ccb1ac4 100644
--- a/Utilities/gdcmcharls/config.h
+++ b/Utilities/gdcmcharls/config.h
@@ -1,6 +1,6 @@
-// 
-// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
-// 
+/* 
+ (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
+*/ 
 
 
 #ifndef CHARLS_CONFIG
@@ -29,8 +29,7 @@ typedef long long int64_t;
 typedef unsigned long long uint64_t;
 #endif
 
-// Typedef used by Charls for the default integral type. 
-// charls will work correctly with 64 or 32 bit. 
+/* Typedef used by Charls for the default integral type.  charls will work correctly with 64 or 32 bit. */
 typedef long LONG;
 
 enum constants
diff --git a/Utilities/gdcmcharls/context.h b/Utilities/gdcmcharls/context.h
index e018d1a..71c089e 100644
--- a/Utilities/gdcmcharls/context.h
+++ b/Utilities/gdcmcharls/context.h
@@ -8,6 +8,7 @@
 
 #include <cstdlib>
 
+
 //
 // JlsContext: a JPEG-LS context with it's current statistics.
 //
@@ -44,8 +45,8 @@ public:
 		ASSERT(N != 0);
 
 		// For performance work on copies of A,B,N (compiler will use registers).
-		int b = B + errorValue * (2 * NEAR + 1); 
 		int a = A + std::abs(errorValue);
+		int b = B + errorValue * (2 * NEAR + 1); 
 		int n = N;
 
 		ASSERT(a < 65536 * 256);
@@ -58,8 +59,10 @@ public:
 			n = n >> 1;
 		}
 
+		A = a;		
 		n = n + 1;
-		
+		N = (short)n;
+
 		if (b + n <= 0) 
 		{
 			b = b + n;
@@ -67,7 +70,7 @@ public:
 			{
 				b = -n + 1;
 			}
-			C = _tableC[C - 1];
+			C = C - (C > -128);
 		} 
 		else  if (b > 0) 
 		{
@@ -76,11 +79,10 @@ public:
 			{
 				b = 0;
 			}
-			C = _tableC[C + 1];
+			C = C + (C < 127);
 		}
-		A = a;
 		B = b;
-		N = (short)n;
+		
 		ASSERT(N != 0);
 	}
 
@@ -90,7 +92,14 @@ public:
 	{
 		LONG Ntest	= N;
 		LONG Atest	= A;
-		LONG k = 0;
+
+		if (Ntest >= Atest) return 0;
+		if (Ntest << 1 >= Atest) return 1;
+		if (Ntest << 2 >= Atest) return 2;
+		if (Ntest << 3 >= Atest) return 3;
+		if (Ntest << 4 >= Atest) return 4;
+
+		LONG k = 5;
 		for(; (Ntest << k) < Atest; k++) 
 		{ 
 			ASSERT(k <= 32); 
@@ -98,26 +107,7 @@ public:
 		return k;
 	}
 
-	static signed char* CreateTableC()
-	{
-		static std::vector<signed char> rgtableC;
-		
-		rgtableC.reserve(256 + 2);
-
-		rgtableC.push_back(-128);	
-		for (int i = -128; i < 128; i++)
-		{
-			rgtableC.push_back(char(i));	
-		}
-		rgtableC.push_back(127);	
-		
-		signed char* pZero = &rgtableC[128 + 1];	
-		ASSERT(pZero[0] == 0);
-		return pZero;
-	}
-private:
-
-	static signed char* _tableC;
+	
 };
 
 #endif
diff --git a/Utilities/gdcmcharls/contextrunmode.h b/Utilities/gdcmcharls/contextrunmode.h
index 0eac1e0..5154a4b 100644
--- a/Utilities/gdcmcharls/contextrunmode.h
+++ b/Utilities/gdcmcharls/contextrunmode.h
@@ -64,7 +64,7 @@ struct CContextRunMode
 	{
 		bool map = temp & 1;
 
-		LONG errvalabs = (temp + map) / 2;
+		LONG errvalabs = (temp + LONG(map)) / 2;
 
 		if ((k != 0 || (2 * Nn >= N)) == map)
 		{
@@ -80,19 +80,19 @@ struct CContextRunMode
 	bool ComputeMap(LONG Errval, LONG k) const
 	{
 		if ((k == 0) && (Errval > 0) && (2 * Nn < N))
-			return 1;
+			return true;
 
-		else if ((Errval < 0) && (2 * Nn >= N))
-			return 1;		 
+		if ((Errval < 0) && (2 * Nn >= N))
+			return true;		 
 
-		else if ((Errval < 0) && (k != 0))
-			return 1;
+		if ((Errval < 0) && (k != 0))
+			return true;
 
-		return 0;
+		return false;
 	}
 
 
-	inlinehint LONG ComputeMapNegativeE(LONG k) const
+	inlinehint bool ComputeMapNegativeE(LONG k) const
 	{
 		return  k != 0 || (2 * Nn >= N );
 	}
diff --git a/Utilities/gdcmcharls/decoderstrategy.h b/Utilities/gdcmcharls/decoderstrategy.h
index 0481782..9488b62 100644
--- a/Utilities/gdcmcharls/decoderstrategy.h
+++ b/Utilities/gdcmcharls/decoderstrategy.h
@@ -5,274 +5,314 @@
 #ifndef CHARLS_DECODERSTATEGY
 #define CHARLS_DECODERSTATEGY
 
-#include "streams.h"
+#include "jpegmarker.h"
 #include "processline.h"
 #include "config.h"
 #include "util.h"
 
 // Implements encoding to stream of bits. In encoding mode JpegLsCodec inherits from EncoderStrategy
 
-
-
 class DecoderStrategy
 {
 public:
 	DecoderStrategy(const JlsParameters& info) :
-		  _info(info),
-	      _processLine(0),
-		  _readCache(0),
-		  _validBits(0),
-		  _position(0)
-	  {
-	  }
-
-	  virtual ~DecoderStrategy()
-	  {
-	  }
-
-	  virtual void SetPresets(const JlsCustomParameters& presets) = 0;
-	  virtual size_t DecodeScan(void* outputData, const JlsRect& size, const void* compressedData, size_t byteCount, bool bCheck) = 0;
-
-	  void Init(BYTE* compressedBytes, size_t byteCount)
-	  {
-		  _validBits = 0;
-		  _readCache = 0;
-		  _position = compressedBytes;
-		  _endPosition = compressedBytes + byteCount;
-		  _nextFFPosition = FindNextFF();
-		  MakeValid();
-	  }
-
-	  inlinehint void Skip(LONG length)
-	  {
-		  _validBits -= length;
-		  _readCache = _readCache << length; 
-	  }
-
-	
-	  void OnLineBegin(LONG /*cpixel*/, void* /*ptypeBuffer*/, LONG /*pixelStride*/) 
-	  {}
-
-
-	  void OnLineEnd(LONG pixelCount, const void* ptypeBuffer, LONG pixelStride)
-	  {
-	  		_processLine->NewLineDecoded(ptypeBuffer, pixelCount, pixelStride);
-	  }
-
-	  void EndScan()
-	  {
-		  if ((*_position) != 0xFF)
-		  {
-			  ReadBit();
-
-			  if ((*_position) != 0xFF)
-				throw JlsException(TooMuchCompressedData);
-		  }
-
-		  if (_readCache != 0)
-		     throw JlsException(TooMuchCompressedData);
-	  }
-
-
-	  inlinehint bool OptimizedRead()
-	  {
-		  // Easy & fast: if there is no 0xFF byte in sight, we can read without bitstuffing
-		  if (_position < _nextFFPosition - (sizeof(bufType)-1))
-		  {
-			  _readCache		 |= FromBigEndian<sizeof(bufType)>::Read(_position) >> _validBits;
-			  int bytesToRead = (bufferbits - _validBits) >> 3;
-			  _position += bytesToRead;
-			  _validBits += bytesToRead * 8;
-			  ASSERT(_validBits >= bufferbits - 8);
-			  return true;
-		  }
-		  return false;
-	  }
-
-	  typedef size_t bufType;
-
-	  enum { 
-		  bufferbits = sizeof( bufType ) * 8
-	  };
-		
-	  void MakeValid()
-	  {
-		  ASSERT(_validBits <=bufferbits - 8);
-
-		  if (OptimizedRead())
-			  return;
-
-		  do
-		  {
-			  if (_position >= _endPosition)
-			  {
-				  if (_validBits <= 0)
-					  throw JlsException(InvalidCompressedData);
-
-				  return;
-			  }
-
-			  bufType valnew	  = _position[0];
-			  
-			  if (valnew == 0xFF)		
-			  {
-				  // JPEG bitstream rule: no FF may be followed by 0x80 or higher	    			 
-				 if (_position == _endPosition - 1 || (_position[1] & 0x80) != 0)
-				 {
-					 if (_validBits <= 0)
-					 	throw JlsException(InvalidCompressedData);
-					 
-					 return;
-			     }
-			  }
-
-			  _readCache		 |= valnew << (bufferbits - 8  - _validBits);
-			  _position   += 1;				
-			  _validBits		 += 8; 
-
-			  if (valnew == 0xFF)		
-			  {
-				  _validBits--;		
-			  }
-		  }
-		  while (_validBits < bufferbits - 8);
-
-		  _nextFFPosition = FindNextFF();
-		  return;
-
-	  }
-
-
-	  BYTE* FindNextFF()
-	  {
-		  BYTE* pbyteNextFF = _position;
-
-		  while (pbyteNextFF < _endPosition)
-	      {
-			  if (*pbyteNextFF == 0xFF) 
-			  {				  
-				  break;
-			  }
-    		  pbyteNextFF++;
-		  }
-		  
-
-		  return pbyteNextFF;
-	  }
-
-
-	  BYTE* GetCurBytePos() const
-	  {
-		  LONG  validBits = _validBits;
-		  BYTE* compressedBytes = _position;
-
-		  for (;;)
-		  {
-			  LONG cbitLast = compressedBytes[-1] == 0xFF ? 7 : 8;
-
-			  if (validBits < cbitLast )
-				  return compressedBytes;
-
-			  validBits -= cbitLast; 
-			  compressedBytes--;
-		  }	
-	  }
-
-
-	  inlinehint LONG ReadValue(LONG length)
-	  {
-		  if (_validBits < length)
-		  {
-			  MakeValid();
-			  if (_validBits < length)
-				  throw JlsException(InvalidCompressedData);
-		  }
-		
-		  ASSERT(length != 0 && length <= _validBits);
-		  ASSERT(length < 32);
-		  LONG result = LONG(_readCache >> (bufferbits - length));
-		  Skip(length);		
-		  return result;
-	  }
-
-
-	  inlinehint LONG PeekByte()
-	  { 
-		  if (_validBits < 8)
-		  {
-			  MakeValid();
-		  }
-
-		  return _readCache >> (bufferbits - 8); 
-	  }
-
-
-
-	  inlinehint bool ReadBit()
-	  {
-		  if (_validBits <= 0)
-		  {
-			  MakeValid();
-		  }
-
-		  bool bSet = (_readCache & (bufType(1) << (bufferbits - 1))) != 0;
-		  Skip(1);
-		  return bSet;
-	  }
-
-
-
-	  inlinehint LONG Peek0Bits()
-	  {
-		  if (_validBits < 16)
-		  {
-			  MakeValid();
-		  }
-		  bufType valTest = _readCache;
-
-		  for (LONG count = 0; count < 16; count++)
-		  {
-			  if ((valTest & (bufType(1) << (bufferbits - 1))) != 0)
-				  return count;
-
-			  valTest <<= 1;
-		  }
-		  return -1;
-	  }
-
+		_info(info),
+		_byteStream(NULL),
+		_readCache(0),
+		_validBits(0),
+		_position(NULL),
+		_nextFFPosition(NULL),
+		_endPosition(NULL)
+	{
+	}
+
+	virtual ~DecoderStrategy()
+	{
+	}
+
+	virtual ProcessLine* CreateProcess(ByteStreamInfo rawStreamInfo) = 0;
+
+	virtual void SetPresets(const JlsCustomParameters& presets) = 0;
+	virtual void DecodeScan(std::auto_ptr<ProcessLine> outputData, const JlsRect& size, ByteStreamInfo* compressedData, bool bCheck) = 0;
+
+	void Init(ByteStreamInfo* compressedStream)
+	{
+		_validBits = 0;
+		_readCache = 0;
+
+		if (compressedStream->rawStream != NULL)
+		{
+			_buffer.resize(40000);
+			_position = (BYTE*)&_buffer[0];
+			_endPosition = _position;
+			_byteStream = compressedStream->rawStream;
+			AddBytesFromStream();
+		}
+		else
+		{
+			_byteStream = NULL;
+			_position = compressedStream->rawData;
+			_endPosition = _position + compressedStream->count;
+		}
+
+		_nextFFPosition = FindNextFF();
+		MakeValid();
+	}
+
+	void AddBytesFromStream()
+	{
+		if (_byteStream == NULL || _byteStream->sgetc() == std::char_traits<char>::eof())
+			return;
+
+		size_t count = _endPosition - _position; 
+
+		if (count > 64)
+			return;
+
+		for (size_t i = 0; i < count; ++i)
+		{
+			_buffer[i] = _position[i];
+		}
+		size_t offset = &_buffer[0] - _position;
+
+		_position += offset;
+		_endPosition += offset;
+		_nextFFPosition += offset;
+
+		std::streamsize readbytes = _byteStream->sgetn((char*)_endPosition, _buffer.size() - count);
+		_endPosition += readbytes;
+	}
+
+	inlinehint void Skip(LONG length)
+	{
+		_validBits -= length;
+		_readCache = _readCache << length; 
+	}
+
+
+	void OnLineBegin(LONG /*cpixel*/, void* /*ptypeBuffer*/, LONG /*pixelStride*/) 
+	{
+	}
+
+
+	void OnLineEnd(LONG pixelCount, const void* ptypeBuffer, LONG pixelStride)
+	{
+		_processLine->NewLineDecoded(ptypeBuffer, pixelCount, pixelStride);
+	}
+
+	void EndScan()
+	{
+		if ((*_position) != 0xFF)
+		{
+			ReadBit();
+
+			if ((*_position) != 0xFF)
+			throw JlsException(TooMuchCompressedData);
+		}
+
+		if (_readCache != 0)
+			throw JlsException(TooMuchCompressedData);
+	}
+
+
+	inlinehint bool OptimizedRead()
+	{
+		// Easy & fast: if there is no 0xFF byte in sight, we can read without bitstuffing
+		if (_position < _nextFFPosition - (sizeof(bufType)-1))
+		{
+			_readCache |= FromBigEndian<sizeof(bufType)>::Read(_position) >> _validBits;
+			int bytesToRead = (bufferbits - _validBits) >> 3;
+			_position += bytesToRead;
+			_validBits += bytesToRead * 8;
+			ASSERT(_validBits >= bufferbits - 8);
+			return true;
+		}
+		return false;
+	}
+
+	typedef size_t bufType;
+
+	enum { 
+		bufferbits = sizeof( bufType ) * 8
+	};
+
+	void MakeValid()
+	{
+		ASSERT(_validBits <=bufferbits - 8);
+
+		if (OptimizedRead())
+			return;
+
+		AddBytesFromStream();
+
+		do
+		{
+			if (_position >= _endPosition)
+			{
+				if (_validBits <= 0)
+					throw JlsException(InvalidCompressedData);
+
+				return;
+			}
+
+			bufType valnew	  = _position[0];
+
+			if (valnew == 0xFF)
+			{
+				// JPEG bitstream rule: no FF may be followed by 0x80 or higher
+				if (_position == _endPosition - 1 || (_position[1] & 0x80) != 0)
+				{
+					if (_validBits <= 0)
+					throw JlsException(InvalidCompressedData);
+
+					return;
+				}
+			}
+
+			_readCache	|= valnew << (bufferbits - 8 - _validBits);
+			_position		+= 1;
+			_validBits	+= 8;
+
+			if (valnew == 0xFF)
+			{
+				_validBits--;
+			}
+		}
+		while (_validBits < bufferbits - 8);
+
+		_nextFFPosition = FindNextFF();
+		return;
+	}
+
+
+	BYTE* FindNextFF()
+	{
+		BYTE* pbyteNextFF = _position;
+
+		while (pbyteNextFF < _endPosition)
+		{
+			if (*pbyteNextFF == 0xFF) 
+				break;
+
+			pbyteNextFF++;
+		}
+
+		return pbyteNextFF;
+	}
+
+
+	BYTE* GetCurBytePos() const
+	{
+		LONG validBits = _validBits;
+		BYTE* compressedBytes = _position;
+
+		for (;;)
+		{
+			LONG cbitLast = compressedBytes[-1] == 0xFF ? 7 : 8;
+
+			if (validBits < cbitLast )
+				return compressedBytes;
+
+			validBits -= cbitLast; 
+			compressedBytes--;
+		}
+	}
+
+
+	inlinehint LONG ReadValue(LONG length)
+	{
+		if (_validBits < length)
+		{
+			MakeValid();
+			if (_validBits < length)
+				throw JlsException(InvalidCompressedData);
+		}
+
+		ASSERT(length != 0 && length <= _validBits);
+		ASSERT(length < 32);
+		LONG result = LONG(_readCache >> (bufferbits - length));
+		Skip(length);
+		return result;
+	}
+
+
+	inlinehint LONG PeekByte()
+	{
+		if (_validBits < 8)
+		{
+			MakeValid();
+		}
+
+		return _readCache >> (bufferbits - 8); 
+	}
+
+
+	inlinehint bool ReadBit()
+	{
+		if (_validBits <= 0)
+		{
+			MakeValid();
+		}
+
+		bool bSet = (_readCache & (bufType(1) << (bufferbits - 1))) != 0;
+		Skip(1);
+		return bSet;
+	}
+
+
+	inlinehint LONG Peek0Bits()
+	{
+		if (_validBits < 16)
+		{
+			MakeValid();
+		}
+		bufType valTest = _readCache;
+
+		for (LONG count = 0; count < 16; count++)
+		{
+			if ((valTest & (bufType(1) << (bufferbits - 1))) != 0)
+				return count;
+
+			valTest <<= 1;
+		}
+		return -1;
+	}
+
 
-
-	  inlinehint LONG ReadHighbits()
-	  {
-		  LONG count = Peek0Bits();
-		  if (count >= 0)
-		  {
-			  Skip(count + 1);
-			  return count;
-		  }
-		  Skip(15);
-
-		  for (LONG highbits = 15; ; highbits++)
-		  { 
-			  if (ReadBit())
-				  return highbits;
-		  }                 	
-	  }
-
-
-	  LONG ReadLongValue(LONG length)
-	  {
-		  if (length <= 24)
-			  return ReadValue(length);
-
-		  return (ReadValue(length - 24) << 24) + ReadValue(24);
-	  }
+	inlinehint LONG ReadHighbits()
+	{
+		LONG count = Peek0Bits();
+		if (count >= 0)
+		{
+			Skip(count + 1);
+			return count;
+		}
+		Skip(15);
+
+		for (LONG highbits = 15; ; highbits++)
+		{ 
+			if (ReadBit())
+				return highbits;
+		}
+	}
+
+
+	LONG ReadLongValue(LONG length)
+	{
+		if (length <= 24)
+			return ReadValue(length);
+
+		return (ReadValue(length - 24) << 24) + ReadValue(24);
+	}
 
 protected:
 	JlsParameters _info;
 	std::auto_ptr<ProcessLine> _processLine;
 
 private:
+	std::vector<BYTE> _buffer;
+	std::basic_streambuf<char>* _byteStream;
+
 	// decoding
 	bufType _readCache;
 	LONG _validBits;
diff --git a/Utilities/gdcmcharls/defaulttraits.h b/Utilities/gdcmcharls/defaulttraits.h
index 3a21cd1..2456429 100644
--- a/Utilities/gdcmcharls/defaulttraits.h
+++ b/Utilities/gdcmcharls/defaulttraits.h
@@ -6,8 +6,6 @@
 #ifndef CHARLS_DEFAULTTRAITS
 #define CHARLS_DEFAULTTRAITS
 
-#include <cstdlib>
-
 // Default traits that support all JPEG LS parameters: custom limit, near, maxval (not power of 2)
 
 // This traits class is used to initialize a coder/decoder.
@@ -15,6 +13,8 @@
 // This is to allow the traits class to replace the default implementation here with optimized specific implementations.
 // This is done for lossless coding/decoding: see losslesstraits.h 
 
+#include <cstdlib>
+
 template <class sample, class pixel>
 struct DefaultTraitsT 
 {
@@ -55,8 +55,7 @@ public:
 	
 	inlinehint LONG ComputeErrVal(LONG e) const
 	{
-		LONG q = Quantize(e);
-		return ModRange(q);
+	 	return ModRange(Quantize(e));
 	}
 	
 	inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal)
@@ -69,9 +68,9 @@ public:
 
 	bool IsNear(Triplet<SAMPLE> lhs, Triplet<SAMPLE> rhs) const
 	{
-		return abs(lhs.v1-rhs.v1) <=NEAR && 
-			abs(lhs.v2-rhs.v2) <=NEAR && 
-			abs(lhs.v3-rhs.v3) <=NEAR; 
+		return std::abs(lhs.v1 - rhs.v1) <= NEAR && 
+		       std::abs(lhs.v2 - rhs.v2) <= NEAR && 
+		       std::abs(lhs.v3 - rhs.v3) <= NEAR;
 	}
 
 	inlinehint LONG CorrectPrediction(LONG Pxc) const
diff --git a/Utilities/gdcmcharls/encoderstrategy.h b/Utilities/gdcmcharls/encoderstrategy.h
index 545d662..1c8cb45 100644
--- a/Utilities/gdcmcharls/encoderstrategy.h
+++ b/Utilities/gdcmcharls/encoderstrategy.h
@@ -15,14 +15,14 @@ class EncoderStrategy
 
 public:
 	explicit EncoderStrategy(const JlsParameters& info) :
-		 _qdecoder(0),
 		 _info(info),
-		 _processLine(0),
- 		 valcurrent(0),
+		 valcurrent(0),
 		 bitpos(0),
+		 _compressedLength(0),
+		 _position(0),
 		 _isFFWritten(false),
-		 _bytesWritten(0)
-		
+		 _bytesWritten(0),
+		 _compressedStream(NULL)
 	{
 	}
 
@@ -31,7 +31,7 @@ public:
 	}
 
 	LONG PeekByte();
-	
+
 	void OnLineBegin(LONG cpixel, void* ptypeBuffer, LONG pixelStride)
 	{
 		_processLine->NewLineRequested(ptypeBuffer, cpixel, pixelStride);
@@ -39,23 +39,36 @@ public:
 
 	void OnLineEnd(LONG /*cpixel*/, void* /*ptypeBuffer*/, LONG /*pixelStride*/) { }
 
-    virtual void SetPresets(const JlsCustomParameters& presets) = 0;
-		
-	virtual size_t EncodeScan(const void* pvoid, void* pvoidOut, size_t byteCount, void* pvoidCompare) = 0;
+	virtual void SetPresets(const JlsCustomParameters& presets) = 0;
+
+	virtual size_t EncodeScan(std::auto_ptr<ProcessLine> rawData, ByteStreamInfo* compressedData, void* pvoidCompare) = 0;
+
+	virtual ProcessLine* CreateProcess(ByteStreamInfo rawStreamInfo) = 0;
 
 protected:
 
-	void Init(BYTE* compressedBytes, size_t byteCount)
+	void Init(ByteStreamInfo* compressedStream)
 	{
 		bitpos = 32;
 		valcurrent = 0;
-		_position = compressedBytes;
-   		_compressedLength = byteCount;
+
+		if (compressedStream->rawStream == NULL)
+		{
+			_position = compressedStream->rawData;
+			_compressedLength = compressedStream->count;
+		}
+		else
+		{
+			_compressedStream = compressedStream->rawStream;
+			_buffer.resize(4000);
+			_position = (BYTE*)&_buffer[0];
+			_compressedLength = _buffer.size();
+		}
 	}
 
 
 	void AppendToBitStream(LONG value, LONG length)
-	{	
+	{
 		ASSERT(length < 32 && length >= 0);
 
 		ASSERT((_qdecoder.get() == NULL) || (length == 0 && value == 0) ||( _qdecoder->ReadLongValue(length) == value));
@@ -63,7 +76,7 @@ protected:
 #ifndef NDEBUG
 		if (length < 32)
 		{
-			int mask = (1u << (length)) - 1;
+			int mask = (1 << (length)) - 1;
 			ASSERT((value | mask) == mask);
 		}
 #endif
@@ -74,19 +87,19 @@ protected:
 			valcurrent = valcurrent | (value << bitpos);
 			return;
 		}
+
 		valcurrent |= value >> -bitpos;
 		Flush();
-	        
-		// A second flush may be required if extra marker-detect bits were needed and not all bits could be written.
-		if (bitpos < 0)
-		{
-			valcurrent |= value >> -bitpos;
-			Flush();
-		}
 
-		ASSERT(bitpos >=0);
-		valcurrent |= value << bitpos;	
+		// A second flush may be required if extra marker-detect bits were needed and not all bits could be written.
+		if (bitpos < 0)
+		{
+			valcurrent |= value >> -bitpos;
+			Flush();
+		}
 
+		ASSERT(bitpos >=0);
+		valcurrent |= value << bitpos;
 	}
 
 	void EndScan()
@@ -98,13 +111,38 @@ protected:
 			AppendToBitStream(0, (bitpos - 1) % 8);
 		else
 			AppendToBitStream(0, bitpos % 8);
-		
+
 		Flush();
 		ASSERT(bitpos == 0x20);
+
+		if (_compressedStream != NULL)
+		{
+			OverFlow();
+		}
+	}
+
+	void OverFlow()
+	{
+		if (_compressedStream == NULL)
+			throw JlsException(CompressedBufferTooSmall);
+
+		size_t bytesCount = _position-(BYTE*)&_buffer[0];
+		size_t bytesWritten = (size_t)_compressedStream->sputn((char*)&_buffer[0], _position - (BYTE*)&_buffer[0]);
+
+		if (bytesWritten != bytesCount)
+			throw JlsException(CompressedBufferTooSmall);
+
+		_position = (BYTE*)&_buffer[0];
+		_compressedLength = _buffer.size();
 	}
 
 	void Flush()
 	{
+		if (_compressedLength < 4)
+		{
+			OverFlow();
+		}
+
 		for (LONG i = 0; i < 4; ++i)
 		{
 			if (bitpos >= 32)
@@ -114,32 +152,28 @@ protected:
 			{
 				// JPEG-LS requirement (T.87, A.1) to detect markers: after a xFF value a single 0 bit needs to be inserted.
 				*_position = BYTE(valcurrent >> 25);
-				valcurrent = valcurrent << 7;			
-				bitpos += 7;	
-				_isFFWritten = false;
+				valcurrent = valcurrent << 7;
+				bitpos += 7;
 			}
 			else
 			{
 				*_position = BYTE(valcurrent >> 24);
-				valcurrent = valcurrent << 8;			
-				bitpos += 8;			
-				_isFFWritten = *_position == 0xFF;			
+				valcurrent = valcurrent << 8;
+				bitpos += 8;
 			}
-			
+
+			_isFFWritten = *_position == 0xFF;
 			_position++;
 			_compressedLength--;
 			_bytesWritten++;
-
 		}
-		
 	}
 
 	size_t GetLength() 
-	{ 
+	{
 		return _bytesWritten - (bitpos -32)/8; 
 	}
 
-
 	inlinehint void AppendOnesToBitStream(LONG length)
 	{
 		AppendToBitStream((1 << length) - 1, length);	
@@ -151,17 +185,20 @@ protected:
 protected:
 	JlsParameters _info;
 	std::auto_ptr<ProcessLine> _processLine;
-private:
 
+private:
 	unsigned int valcurrent;
 	LONG bitpos;
 	size_t _compressedLength;
-	
+
+
 	// encoding
 	BYTE* _position;
 	bool _isFFWritten;
 	size_t _bytesWritten;
 
+	std::vector<BYTE> _buffer;
+	std::basic_streambuf<char>* _compressedStream;
 };
 
 #endif
diff --git a/Utilities/gdcmcharls/header.cpp b/Utilities/gdcmcharls/header.cpp
index 92026a3..9ddedc8 100644
--- a/Utilities/gdcmcharls/header.cpp
+++ b/Utilities/gdcmcharls/header.cpp
@@ -5,7 +5,10 @@
 #include "config.h"
 #include "util.h"
 #include "header.h"
-#include "streams.h"
+#include "jpegmarker.h"
+#include "jpegstreamwriter.h"
+#include "jpegmarkersegment.h"
+#include "jpegimagedatasegment.h"
 #include "decoderstrategy.h"
 #include "encoderstrategy.h"
 #include <memory>
@@ -15,27 +18,6 @@
 BYTE jfifID[] = {'J','F','I','F','\0'};
 
 
-bool IsDefault(const JlsCustomParameters* pcustom)
-{
-	if (pcustom->MAXVAL != 0)
-		return false;
-
-	if (pcustom->T1 != 0)
-		return false;
-
-	if (pcustom->T2 != 0)
-		return false;
-
-	if (pcustom->T3 != 0)
-		return false;
-
-	if (pcustom->RESET != 0)
-		return false;
-
-	return true;
-}
-
-
 LONG CLAMP(LONG i, LONG j, LONG MAXVAL)
 {
 	if (i > MAXVAL || i < j)
@@ -62,14 +44,11 @@ JlsCustomParameters ComputeDefault(LONG MAXVAL, LONG NEAR)
 
 JLS_ERROR CheckParameterCoherent(const JlsParameters* pparams)
 {
-	if (pparams->bitspersample < 6 || pparams->bitspersample > 16)
+	if (pparams->bitspersample < 2 || pparams->bitspersample > 16)
 		return ParameterValueNotSupported;
 
 	if (pparams->ilv < 0 || pparams->ilv > 2)
-		throw JlsException(InvalidCompressedData);
-
-	if (pparams->bitspersample < 6 || pparams->bitspersample > 16)
-		return ParameterValueNotSupported;
+		return InvalidCompressedData;
 
 	switch (pparams->components)
 	{
@@ -82,160 +61,54 @@ JLS_ERROR CheckParameterCoherent(const JlsParameters* pparams)
 	}
 }
 
-//
-// JpegMarkerSegment
-//
-class JpegMarkerSegment : public JpegSegment
-{
-public:
-	JpegMarkerSegment(BYTE marker, std::vector<BYTE> vecbyte)
-	{
-		_marker = marker;
-		std::swap(_vecbyte, vecbyte);
-	}
-
-	virtual void Write(JLSOutputStream* pstream)
-	{
-		pstream->WriteByte(0xFF);
-		pstream->WriteByte(_marker);
-		pstream->WriteWord(USHORT(_vecbyte.size() + 2));
-		pstream->WriteBytes(_vecbyte);		
-	}
-
-	BYTE _marker;
-	std::vector<BYTE> _vecbyte;
-};
-
-
-//
-// push_back()
-//
-void push_back(std::vector<BYTE>& vec, USHORT value)
-{
-	vec.push_back(BYTE(value / 0x100));
-	vec.push_back(BYTE(value % 0x100));
-}				   
-
-
-//
-// CreateMarkerStartOfFrame()
-//
-JpegSegment* CreateMarkerStartOfFrame(Size size, LONG bitsPerSample, LONG ccomp)
-{
-
-	std::vector<BYTE> vec;
-	vec.push_back(static_cast<BYTE>(bitsPerSample));
-	push_back(vec, static_cast<USHORT>(size.cy));
-	push_back(vec, static_cast<USHORT>(size.cx));
-	
-	// components
-	vec.push_back(static_cast<BYTE>(ccomp));
-	for (BYTE component = 0; component < ccomp; component++)
-	{
-		// rescaling
-		vec.push_back(component + 1);
-		vec.push_back(0x11); 
-		//"Tq1" reserved, 0
-		vec.push_back(0);		
-	}
-
-	return new JpegMarkerSegment(JPEG_SOF, vec);
-}
-
 
-
-
-//
-// ctor()
-//
-JLSOutputStream::JLSOutputStream() :
-	_bCompare(false),
-	_pdata(NULL),
-	_cbyteOffset(0),
-	_cbyteLength(0),
-	_icompLast(0)
+void JpegImageDataSegment::Serialize(JpegStreamWriter& streamWriter)
 {
+	JlsParameters info = _info;
+	info.components = _ccompScan;
+	std::auto_ptr<EncoderStrategy> qcodec = JlsCodecFactory<EncoderStrategy>().GetCodec(info, _info.custom);
+	ProcessLine* processLine = qcodec->CreateProcess(_rawStreamInfo);
+	ByteStreamInfo compressedData = streamWriter.OutputStream();
+	size_t cbyteWritten = qcodec->EncodeScan(std::auto_ptr<ProcessLine>(processLine), &compressedData, streamWriter._bCompare ? streamWriter.GetPos() : NULL);
+	streamWriter.Seek(cbyteWritten);
 }
 
 
-
-//
-// dtor()
-//
-JLSOutputStream::~JLSOutputStream()
+int ReadScanHeader(BYTE* compressedBytes)
 {
-	for (size_t i = 0; i < _segments.size(); ++i)
-	{
-		delete _segments[i];
-	}
-	_segments.empty();
-}
-
-
+	BYTE rgbyte[20];
+	size_t readBytes = 0;
+	::memcpy(rgbyte, compressedBytes, 4);
+	readBytes += 4;
 
+	size_t cbyteScanheader = rgbyte[3] - 2;
 
-//
-// Init()
-//
-void JLSOutputStream::Init(Size size, LONG bitsPerSample, LONG ccomp)
-{
-		_segments.push_back(CreateMarkerStartOfFrame(size, bitsPerSample, ccomp));
-}
-
+	if (cbyteScanheader > sizeof(rgbyte))
+		throw JlsException(InvalidCompressedData);
 
-void JLSOutputStream::AddColorTransform(int i)
-{
-	std::vector<BYTE> rgbyteXform;
-	rgbyteXform.push_back('m');
-	rgbyteXform.push_back('r');
-	rgbyteXform.push_back('f');
-	rgbyteXform.push_back('x');
-	rgbyteXform.push_back((BYTE)i);
-			
-	_segments.push_back(new JpegMarkerSegment(JPEG_APP8, rgbyteXform));	
+	::memcpy(rgbyte, compressedBytes, cbyteScanheader);
+	readBytes += cbyteScanheader;
+	return (int) readBytes;
 }
 
 
-//
-// Write()
-//
-size_t JLSOutputStream::Write(BYTE* pdata, size_t cbyteLength)
+void Assert(bool valid)
 {
-	_pdata = pdata;
-	_cbyteLength = cbyteLength;
-
-	WriteByte(0xFF);
-	WriteByte(JPEG_SOI);
-	
-	for (size_t i = 0; i < _segments.size(); ++i)
-	{
-		_segments[i]->Write(this);
-	}
-
-	//_bCompare = false;
-
-	WriteByte(0xFF);
-	WriteByte(JPEG_EOI);
-
-	return _cbyteOffset;
+	if (!valid)
+		throw JlsException(InvalidCompressedData);
 }
 
 
-
-JLSInputStream::JLSInputStream(const BYTE* pdata, size_t cbyteLength) :
-		_pdata(pdata),
-		_cbyteOffset(0),
-		_cbyteLength(cbyteLength),
+JpegMarkerReader::JpegMarkerReader(ByteStreamInfo byteStreamInfo) :
+		_byteStream(byteStreamInfo),
 		_bCompare(false),
 		_info(),
 		_rect()
 {
 }
 
-//
-// Read()
-//
-void JLSInputStream::Read(void* pvoid, size_t cbyteAvailable)
+
+void JpegMarkerReader::Read(ByteStreamInfo rawPixels)
 {
 	ReadHeader();
 
@@ -243,43 +116,37 @@ void JLSInputStream::Read(void* pvoid, size_t cbyteAvailable)
 	if (error != OK)
 		throw JlsException(error);
 
-	ReadPixels(pvoid, cbyteAvailable);
-}
-
-
-
-
-
-//
-// ReadPixels()
-//
-void JLSInputStream::ReadPixels(void* pvoid, size_t cbyteAvailable)
-{
-
 	if (_rect.Width <= 0)
 	{
 		_rect.Width = _info.width;
 		_rect.Height = _info.height;
 	}
 
-	int64_t cbytePlane = (int64_t)(_rect.Width) * _rect.Height * ((_info.bitspersample + 7)/8);
+	int64_t bytesPerPlane = (int64_t)(_rect.Width) * _rect.Height * ((_info.bitspersample + 7)/8);
 
-	if (int64_t(cbyteAvailable) < cbytePlane * _info.components)
+	if (rawPixels.rawData != NULL && int64_t(rawPixels.count) < bytesPerPlane * _info.components)
 		throw JlsException(UncompressedBufferTooSmall);
- 	
-	int scancount = _info.ilv == ILV_NONE ? _info.components : 1;
 
-	BYTE* pbyte = (BYTE*)pvoid;
-	for (LONG scan = 0; scan < scancount; ++scan)
+	int componentIndex = 0;
+	
+	while (componentIndex < _info.components)
 	{
-		ReadScan(pbyte);
-		pbyte += cbytePlane;
-	}	
+		ReadStartOfScan(componentIndex == 0);
+
+		std::auto_ptr<DecoderStrategy> qcodec = JlsCodecFactory<DecoderStrategy>().GetCodec(_info, _info.custom);	
+		ProcessLine* processLine = qcodec->CreateProcess(rawPixels);
+		qcodec->DecodeScan(std::auto_ptr<ProcessLine>(processLine), _rect, &_byteStream, _bCompare); 
+		SkipBytes(&rawPixels, (size_t)bytesPerPlane);		
+
+		if (_info.ilv != ILV_NONE)
+			return;
+
+		componentIndex += 1;
+	}
 }
 
-// ReadNBytes()
-//
-void JLSInputStream::ReadNBytes(std::vector<char>& dst, int byteCount)
+
+void JpegMarkerReader::ReadNBytes(std::vector<char>& dst, int byteCount)
 {
 	for (int i = 0; i < byteCount; ++i)
 	{
@@ -288,103 +155,73 @@ void JLSInputStream::ReadNBytes(std::vector<char>& dst, int byteCount)
 }
 
 
-//
-// ReadHeader()
-//
-void JLSInputStream::ReadHeader()
+void JpegMarkerReader::ReadHeader()
 {
 	if (ReadByte() != 0xFF)
-		throw JlsException(InvalidCompressedData);
+		throw JlsException(MissingJpegMarkerStart);
 
 	if (ReadByte() != JPEG_SOI)
 		throw JlsException(InvalidCompressedData);
-	
+
 	for (;;)
 	{
 		if (ReadByte() != 0xFF)
-			throw JlsException(InvalidCompressedData);
+			throw JlsException(MissingJpegMarkerStart);
 
 		BYTE marker = (BYTE)ReadByte();
 
-		size_t cbyteStart = _cbyteOffset;
-		LONG cbyteMarker = ReadWord();
-
-		switch (marker)
-		{
-			case JPEG_SOS: ReadStartOfScan();  break;
-			case JPEG_SOF: ReadStartOfFrame(); break;
-			case JPEG_COM: ReadComment();	   break;
-			case JPEG_LSE: ReadPresetParameters();	break;
-			case JPEG_APP0: ReadJfif(); break;
-			case JPEG_APP7: ReadColorSpace(); break;
-			case JPEG_APP8: ReadColorXForm(); break;			
-			// Other tags not supported (among which DNL DRI)
-			default: 		throw JlsException(ImageTypeNotSupported);
-		}
-
 		if (marker == JPEG_SOS)
-		{				
-			_cbyteOffset = cbyteStart - 2;
 			return;
-		}
-		_cbyteOffset = cbyteStart + cbyteMarker;
-	}
-}
 
+		LONG cbyteMarker = ReadWord();
 
-JpegMarkerSegment* EncodeStartOfScan(const JlsParameters* pparams, LONG icomponent)
-{
-	BYTE itable		= 0;
-	
-	std::vector<BYTE> rgbyte;
+		int bytesRead = ReadMarker(marker) + 2;
 
-	if (icomponent < 0)
-	{
-		rgbyte.push_back((BYTE)pparams->components);
-		for (LONG icomponent_ = 0; icomponent_ < pparams->components; ++icomponent_ )
+		int paddingToRead = cbyteMarker - bytesRead;
+
+		if (paddingToRead < 0)
+			throw JlsException(InvalidCompressedData);
+
+		for (int i = 0; i < paddingToRead; ++i)
 		{
-			rgbyte.push_back(BYTE(icomponent_ + 1));
-			rgbyte.push_back(itable);
+			ReadByte();
 		}
 	}
-	else
-	{
-		rgbyte.push_back(1);
-		rgbyte.push_back((BYTE)icomponent);
-		rgbyte.push_back(itable);	
-	}
-
-	rgbyte.push_back(BYTE(pparams->allowedlossyerror));
-	rgbyte.push_back(BYTE(pparams->ilv));
-	rgbyte.push_back(0); // transform
-
-	return new JpegMarkerSegment(JPEG_SOS, rgbyte);
 }
 
 
-
-JpegMarkerSegment* CreateLSE(const JlsCustomParameters* pcustom)
+int JpegMarkerReader::ReadMarker(BYTE marker)
 {
-	std::vector<BYTE> rgbyte;
-
-	rgbyte.push_back(1);
-	push_back(rgbyte, (USHORT)pcustom->MAXVAL);
-	push_back(rgbyte, (USHORT)pcustom->T1);
-	push_back(rgbyte, (USHORT)pcustom->T2);
-	push_back(rgbyte, (USHORT)pcustom->T3);
-	push_back(rgbyte, (USHORT)pcustom->RESET);
-	
-	return new JpegMarkerSegment(JPEG_LSE, rgbyte);
+	switch (marker)
+	{
+		case JPEG_SOF_55: return ReadStartOfFrame();
+		case JPEG_COM: return ReadComment();
+		case JPEG_LSE: return ReadPresetParameters();
+		case JPEG_APP0: return 0;
+		case JPEG_APP7: return ReadColorSpace();
+		case JPEG_APP8: return ReadColorXForm();
+		case JPEG_SOF_0:
+		case JPEG_SOF_1:
+		case JPEG_SOF_2:
+		case JPEG_SOF_3:
+		case JPEG_SOF_5:
+		case JPEG_SOF_6:
+		case JPEG_SOF_7:
+		case JPEG_SOF_9:
+		case JPEG_SOF_10:
+		case JPEG_SOF_11:
+			throw JlsException(UnsupportedEncoding);
+
+		// Other tags not supported (among which DNL DRI)
+		default: throw JlsException(UnknownJpegMarker);
+	}
 }
 
-//
-// ReadPresetParameters()
-//
-void JLSInputStream::ReadPresetParameters()
+
+int JpegMarkerReader::ReadPresetParameters()
 {
 	LONG type = ReadByte();
 
-
 	switch (type)
 	{
 	case 1:
@@ -394,28 +231,38 @@ void JLSInputStream::ReadPresetParameters()
 			_info.custom.T2 = ReadWord();
 			_info.custom.T3 = ReadWord();
 			_info.custom.RESET = ReadWord();
-			return;
+			return 11;
 		}
 	}
 
-	
+	return 1;
 }
 
 
-//
-// ReadStartOfScan()
-//
-void JLSInputStream::ReadStartOfScan()
+void JpegMarkerReader::ReadStartOfScan(bool firstComponent)
 {
-	LONG ccomp = ReadByte();
-	for (LONG i = 0; i < ccomp; ++i)
+	if (!firstComponent)
+	{
+		Assert(ReadByte() == 0xFF);
+		Assert(ReadByte() == JPEG_SOS);
+	}
+	int length = ReadByte(); //length
+	length = length * 256 + ReadByte();
+	
+	LONG componentCount = ReadByte();
+	if (componentCount != 1 && componentCount != _info.components)
+		throw JlsException(ParameterValueNotSupported);
+
+	for (LONG i = 0; i < componentCount; ++i)
 	{
 		ReadByte();
 		ReadByte();
 	}
 	_info.allowedlossyerror = ReadByte();
 	_info.ilv = interleavemode(ReadByte());
-	
+	Assert(ILV_NONE <= _info.ilv && _info.ilv <= ILV_SAMPLE);
+	Assert(ReadByte() == 0);
+
 	if(_info.bytesperline == 0)
 	{
 		int width = _rect.Width != 0 ? _rect.Width : _info.width;
@@ -425,17 +272,13 @@ void JLSInputStream::ReadStartOfScan()
 }
 
 
-//
-// ReadComment()
-//
-void JLSInputStream::ReadComment()
-{}
+int JpegMarkerReader::ReadComment()
+{
+	return 0;
+}
 
 
-//
-// ReadJfif()
-//
-void JLSInputStream::ReadJfif()
+void JpegMarkerReader::ReadJfif()
 {
 	for(int i = 0; i < (int)sizeof(jfifID); i++)
 	{
@@ -448,7 +291,7 @@ void JLSInputStream::ReadJfif()
 	_info.jfif.units = ReadByte();
 	_info.jfif.XDensity = ReadWord();
 	_info.jfif.YDensity = ReadWord();
-	
+
 	// thumbnail
 	_info.jfif.Xthumb = ReadByte();
 	_info.jfif.Ythumb = ReadByte();
@@ -459,43 +302,8 @@ void JLSInputStream::ReadJfif()
 	}
 }
 
-//
-// CreateJFIF()
-//
-JpegMarkerSegment* CreateJFIF(const JfifParameters* jfif)
-{
-	std::vector<BYTE> rgbyte;
-	for(int i = 0; i < (int)sizeof(jfifID); i++)
-	{
-		rgbyte.push_back(jfifID[i]);
-	}
-
-	push_back(rgbyte, (USHORT)jfif->Ver);
 
-	rgbyte.push_back(jfif->units);	
-	push_back(rgbyte, (USHORT)jfif->XDensity);
-	push_back(rgbyte, (USHORT)jfif->YDensity);
-
-	// thumbnail
-	rgbyte.push_back((BYTE)jfif->Xthumb);
-	rgbyte.push_back((BYTE)jfif->Ythumb);
-	if(jfif->Xthumb > 0) 
-	{
-		if(jfif->pdataThumbnail)
-			throw JlsException(InvalidJlsParameters);
-
-		rgbyte.insert(rgbyte.end(), (BYTE*)jfif->pdataThumbnail, (BYTE*)jfif->pdataThumbnail+3*jfif->Xthumb*jfif->Ythumb
-		);
-	}
-	
-	return new JpegMarkerSegment(JPEG_APP0, rgbyte);
-}
-
-
-//
-// ReadStartOfFrame()
-//
-void JLSInputStream::ReadStartOfFrame()
+int JpegMarkerReader::ReadStartOfFrame()
 {
 	_info.bitspersample = ReadByte();
 	int cline = ReadWord();
@@ -503,111 +311,47 @@ void JLSInputStream::ReadStartOfFrame()
 	_info.width = ccol;
 	_info.height = cline;
 	_info.components= ReadByte();
+	return 6;
 }
 
 
-//
-// ReadByte()
-//
-BYTE JLSInputStream::ReadByte()
-{  
-    if (_cbyteOffset >= _cbyteLength)
-	throw JlsException(InvalidCompressedData);
-
-    return _pdata[_cbyteOffset++]; 
-}
-
-
-//
-// ReadWord()
-//
-int JLSInputStream::ReadWord()
+BYTE JpegMarkerReader::ReadByte()
 {
-	int i = ReadByte() * 256;
-	return i + ReadByte();
-}
+	if (_byteStream.rawStream != NULL)
+		return (BYTE)_byteStream.rawStream->sbumpc();
 
+	if (_byteStream.count <= 0)
+		throw JlsException(InvalidCompressedData);
 
-void JLSInputStream::ReadScan(void* pvout) 
-{
-	std::auto_ptr<DecoderStrategy> qcodec = JlsCodecFactory<DecoderStrategy>().GetCodec(_info, _info.custom);
+	BYTE value = _byteStream.rawData[0]; 
 	
-	_cbyteOffset += qcodec->DecodeScan(pvout, _rect, _pdata + _cbyteOffset, _cbyteLength - _cbyteOffset, _bCompare); 
+	SkipBytes(&_byteStream, 1);
+
+	return value;
 }
 
 
-class JpegImageDataSegment: public JpegSegment
+int JpegMarkerReader::ReadWord()
 {
-public:
-	JpegImageDataSegment(const void* pvoidRaw, const JlsParameters& info, LONG icompStart, int ccompScan)  :
-		_ccompScan(ccompScan),
-		_icompStart(icompStart),
-		_pvoidRaw(pvoidRaw),
-		_info(info)
-	{
-	}
-
-	void Write(JLSOutputStream* pstream)
-	{		
-		JlsParameters info = _info;
-		info.components = _ccompScan;	
-		std::auto_ptr<EncoderStrategy> qcodec =JlsCodecFactory<EncoderStrategy>().GetCodec(info, _info.custom);
-		size_t cbyteWritten = qcodec->EncodeScan((BYTE*)_pvoidRaw, pstream->GetPos(), pstream->GetLength(), pstream->_bCompare ? pstream->GetPos() : NULL); 
-		pstream->Seek(cbyteWritten);
-	}
-
-
-	int _ccompScan;
-	LONG _icompStart;
-	const void* _pvoidRaw;
-	JlsParameters _info;
-};
+	int i = ReadByte() * 256;
+	return i + ReadByte();
+}
 
 
-void JLSOutputStream::AddScan(const void* compareData, const JlsParameters* pparams)
+int JpegMarkerReader::ReadColorSpace()
 {
-	if (pparams->jfif.Ver)
-	{
-		_segments.push_back(CreateJFIF(&pparams->jfif));
-	}
-	if (!IsDefault(&pparams->custom))
-	{
-		_segments.push_back(CreateLSE(&pparams->custom));		
-	}
-	else if (pparams->bitspersample > 12)
-	{
-		JlsCustomParameters preset = ComputeDefault((1 << pparams->bitspersample) - 1, pparams->allowedlossyerror);
-        _segments.push_back(CreateLSE(&preset));
-	}
-
-	_icompLast += 1;
-	_segments.push_back(EncodeStartOfScan(pparams,pparams->ilv == ILV_NONE ? _icompLast : -1));
-
-	//Size size = Size(pparams->width, pparams->height);
-	int ccomp = pparams->ilv == ILV_NONE ? 1 : pparams->components;
-		_segments.push_back(new JpegImageDataSegment(compareData, *pparams, _icompLast, ccomp));
+	return 0;
 }
 
 
-//
-// ReadColorSpace()
-//
-void JLSInputStream::ReadColorSpace()
-{}
-
-
-
-//
-// ReadColorXForm()
-//
-void JLSInputStream::ReadColorXForm()
+int JpegMarkerReader::ReadColorXForm()
 {
 	std::vector<char> sourceTag;
 	ReadNBytes(sourceTag, 4);
 
 	if(strncmp(&sourceTag[0],"mrfx", 4) != 0)
-		return;
-	
+		return 4;
+
 	int xform = ReadByte();
 	switch(xform) 
 	{
@@ -616,7 +360,7 @@ void JLSInputStream::ReadColorXForm()
 		case COLORXFORM_HP2:
 		case COLORXFORM_HP3:
 			_info.colorTransform = xform;
-			return;
+			return 5;
 		case COLORXFORM_RGB_AS_YUV_LOSSY:
 		case COLORXFORM_MATRIX:
 			throw JlsException(ImageTypeNotSupported);
@@ -625,3 +369,20 @@ void JLSInputStream::ReadColorXForm()
 	}
 }
 
+
+ByteStreamInfo FromStream(std::basic_streambuf<char>* stream)
+{
+	ByteStreamInfo info = ByteStreamInfo();
+	info.rawStream = stream;	
+	return info;
+}
+
+
+void SkipBytes(ByteStreamInfo* streamInfo, size_t count)
+{
+	if (streamInfo->rawData == NULL)
+		return;
+
+	streamInfo->rawData += count;
+	streamInfo->count -= count;
+}
diff --git a/Utilities/gdcmcharls/header.h b/Utilities/gdcmcharls/header.h
index 034325c..9aed4bb 100644
--- a/Utilities/gdcmcharls/header.h
+++ b/Utilities/gdcmcharls/header.h
@@ -6,57 +6,77 @@
 #ifndef CHARLS_HEADER
 #define CHARLS_HEADER
 
-#include "streams.h"
-
-#define JPEG_SOI  0xD8
-#define JPEG_EOI  0xD9
-#define JPEG_SOS  0xDA
-
-#define JPEG_SOF  0xF7
-#define JPEG_LSE  0xF8
-#define JPEG_DNL  0xDC
-#define JPEG_DRI  0xDD
-#define JPEG_RSTm  0xD0
-#define JPEG_COM  0xFE
-#define JPEG_APP0 0xE0 // JFIF
-#define JPEG_APP7 0xE7 // colorspace
-#define JPEG_APP8 0xE8 // colorXForm
+#include "jpegmarker.h"
+#include "encoderstrategy.h"
+
+// JPEG Marker codes have the pattern 0xFFaa. The valid 'aa' options are defined by several ITU / IEC standards.
+// 0x00, 0x01, 0xFE, 0xC0-0xDF are defined in ITU T.81/IEC 10918-1
+// 0xF0 - 0xF6 are defined in ITU T.84/IEC 10918-3 JPEG extensions
+// 0xF7 - 0xF8 are defined in ITU T.87/IEC 14495-1 JPEG LS
+// 0x4F - 0x6F, 0x90 - 0x93 are defined in JPEG 2000 IEC 15444-1
+
+#define JPEG_SOI    0xD8 // Start Of Image
+#define JPEG_EOI    0xD9 // End Of Image
+#define JPEG_SOS    0xDA // Start Of Scan
+
+// The following markers are defined in ITU T.81 | ISO IEC 10918-1.
+#define JPEG_SOF_0  0xC0 // Start Of Frame (Baseline jpeg)
+#define JPEG_SOF_1  0xC1 // Start Of Frame (Extended sequential, huffman)
+#define JPEG_SOF_2  0xC2 // Start Of Frame (progressive, huffman)
+#define JPEG_SOF_3  0xC3 // Start Of Frame (lossless, huffman)
+#define JPEG_SOF_5  0xC5 // Start Of Frame (differential sequential, huffman)
+#define JPEG_SOF_6  0xC6 // Start Of Frame (differential progressive, huffman)
+#define JPEG_SOF_7  0xC7 // Start Of Frame (differential lossless, huffman)
+#define JPEG_JPG    0xC8 // Reserved for JPEG extension
+#define JPEG_SOF_9  0xC9 // Start Of Frame (extended sequential, arithmetic)
+#define JPEG_SOF_10 0xCA // Start Of Frame (progressive, arithmetic)
+#define JPEG_SOF_11 0xCB // Start Of Frame (lossless, arithmetic)
+
+#define JPEG_SOF_55 0xF7 // Start Of Frame (JPEG-LS encoded)
+#define JPEG_LSE    0xF8 // JPEG-LS extended parameters
+#define JPEG_DNL    0xDC
+#define JPEG_DRI    0xDD
+#define JPEG_RSTm   0xD0
+#define JPEG_COM    0xFE
+#define JPEG_APP0   0xE0 // Application data 0: used for JFIF header.
+#define JPEG_APP7   0xE7 // Application data 7: colorspace
+#define JPEG_APP8   0xE8 // Application data 8: colorXForm
 
 
 
 // Default bin sizes for JPEG-LS statistical modeling. Can be overriden at compression time, however this is rarely done.
-const int BASIC_T1		= 3;
-const int BASIC_T2		= 7;
-const int BASIC_T3		= 21;
+const int BASIC_T1 = 3;
+const int BASIC_T2 = 7;
+const int BASIC_T3 = 21;
 
-const LONG BASIC_RESET	= 64;
+const LONG BASIC_RESET = 64;
 
-class JLSOutputStream;
+class JpegMarkerWriter;
 
 
 template<class STRATEGY>
 class JlsCodecFactory 
 {
-public:	
+public:
 	std::auto_ptr<STRATEGY> GetCodec(const JlsParameters& info, const JlsCustomParameters&);
 private:
 	STRATEGY* GetCodecImpl(const JlsParameters& info);
 };
 
+
+#if defined(__clang__)
+# define CHARLS_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
+# define CHARLS_USE_EXTERN_TEMPLATES (CHARLS_CLANG_VERSION >= 209)
+#endif
+
+#if CHARLS_USE_EXTERN_TEMPLATES
+extern template class JlsCodecFactory<EncoderStrategy>;
+extern template class JlsCodecFactory<DecoderStrategy>;
+#endif
+
 JLS_ERROR CheckParameterCoherent(const JlsParameters* pparams);
 
 JlsCustomParameters ComputeDefault(LONG MAXVAL, LONG NEAR);
 
-//
-// JpegSegment
-//
-class JpegSegment
-{
-protected:
-	JpegSegment() {}
-public:
-	virtual ~JpegSegment() {}
-	virtual void Write(JLSOutputStream* pstream) = 0;
-};
 
 #endif
diff --git a/Utilities/gdcmcharls/interface.cpp b/Utilities/gdcmcharls/interface.cpp
index ca4e1e9..2c661dd 100644
--- a/Utilities/gdcmcharls/interface.cpp
+++ b/Utilities/gdcmcharls/interface.cpp
@@ -1,31 +1,29 @@
-// 
-// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
-// 
+//
+// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
+//
 
 
-//implement correct linkage for win32 dlls
-//#if defined(_WIN32)
-//#define CHARLS_IMEXPORT(returntype) __declspec(dllexport) returntype __stdcall
-//#endif
+// Implement correct linkage for win32 dlls
+#if defined(WIN32) && defined(CHARLS_DLL)
+#define CHARLS_IMEXPORT(returntype) __declspec(dllexport) returntype __stdcall
+#else
+#define CHARLS_IMEXPORT(returntype) returntype
+#endif
 
 #include "config.h"
 #include "util.h"
 #include "interface.h"
 #include "header.h"
+#include "jpegstreamwriter.h"
+#include <sstream>
 
 
-JLS_ERROR CheckInput(const void* compressedData, size_t compressedLength, const void* uncompressedData, size_t uncompressedLength, const JlsParameters* pparams)
+static JLS_ERROR CheckInput(ByteStreamInfo uncompressedStream, const JlsParameters* pparams)
 {
 	if (pparams == NULL)
 		return InvalidJlsParameters;
 
-	if (compressedLength == 0)
-		return InvalidJlsParameters;
-
-	if (compressedData == NULL)
-		return InvalidJlsParameters;
-
-	if (uncompressedData == NULL)
+	if (uncompressedStream.rawStream == NULL && uncompressedStream.rawData == NULL)
 		return InvalidJlsParameters;
 
 	if (pparams->width < 1 || pparams->width > 65535)
@@ -34,173 +32,203 @@ JLS_ERROR CheckInput(const void* compressedData, size_t compressedLength, const
 	if (pparams->height < 1 || pparams->height > 65535)
 		return ParameterValueNotSupported;
 
-	int bytesperline = pparams->bytesperline < 0 ? -pparams->bytesperline : pparams->bytesperline;
-
-	if (uncompressedLength < size_t(bytesperline * pparams->height))
+	if (uncompressedStream.rawData != NULL)
+	{
+		if (uncompressedStream.count < size_t(pparams->height * pparams->width * pparams->components * (pparams->bitspersample > 8 ? 2 : 1)))
+			return UncompressedBufferTooSmall;
+	}
+	else if (uncompressedStream.rawStream == NULL)
 		return InvalidJlsParameters;
 
 	return CheckParameterCoherent(pparams);
 }
 
 
-
-extern "C"
+CHARLS_IMEXPORT(JLS_ERROR) JpegLsEncodeStream(ByteStreamInfo compressedStreamInfo, size_t* pcbyteWritten, ByteStreamInfo rawStreamInfo, struct JlsParameters* pparams)
 {
+	if (pcbyteWritten == NULL)
+		return InvalidJlsParameters;
 
-CHARLS_IMEXPORT(JLS_ERROR) JpegLsEncode(void* compressedData, size_t compressedLength, size_t* pcbyteWritten, const void* uncompressedData, size_t uncompressedLength, struct JlsParameters* pparams)
-{
-	JlsParameters info = *pparams;
-	if(info.bytesperline == 0)
+	JLS_ERROR parameterError = CheckInput(rawStreamInfo, pparams);
+	if (parameterError != OK)
+		return parameterError;
+
+	try
 	{
-		info.bytesperline = info.width * ((info.bitspersample + 7)/8);
-		if (info.ilv != ILV_NONE)
+		JlsParameters info = *pparams;
+		if (info.bytesperline == 0)
 		{
-			info.bytesperline *= info.components;
+			info.bytesperline = info.width * ((info.bitspersample + 7)/8);
+			if (info.ilv != ILV_NONE)
+			{
+				info.bytesperline *= info.components;
+			}
 		}
-	}
-	
-	JLS_ERROR parameterError = CheckInput(compressedData, compressedLength, uncompressedData, uncompressedLength, &info);
 
-	if (parameterError != OK)
-		return parameterError;
+		Size size = Size(info.width, info.height);
 
-	if (pcbyteWritten == NULL)
-		return InvalidJlsParameters;
+		JpegStreamWriter writer(info.jfif, size, info.bitspersample, info.components);
 
-	Size size = Size(info.width, info.height);
-	JLSOutputStream stream;
-	
-	stream.Init(size, info.bitspersample, info.components);
-	
-	if (info.colorTransform != 0)
-	{
-		stream.AddColorTransform(info.colorTransform);
-	}
+		if (info.colorTransform != 0)
+		{
+			writer.AddColorTransform(info.colorTransform);
+		}
 
-	if (info.ilv == ILV_NONE)
-	{
-		LONG cbyteComp = size.cx*size.cy*((info.bitspersample +7)/8);
-		for (LONG component = 0; component < info.components; ++component)
+		if (info.ilv == ILV_NONE)
+		{
+			LONG cbyteComp = size.cx*size.cy*((info.bitspersample +7)/8);
+			for (LONG component = 0; component < info.components; ++component)
+			{
+				writer.AddScan(rawStreamInfo, &info);
+				SkipBytes(&rawStreamInfo, cbyteComp);
+			}
+		}
+		else
 		{
-			const BYTE* compareData = static_cast<const BYTE*>(uncompressedData) + component*cbyteComp;
-			stream.AddScan(compareData, &info);
+			writer.AddScan(rawStreamInfo, &info);
 		}
+	
+		writer.Write(compressedStreamInfo);
+		*pcbyteWritten = writer.GetBytesWritten();
+		return OK;
 	}
-	else 
+	catch (const JlsException& e)
 	{
-		stream.AddScan(uncompressedData, &info);
+		return e._error;
 	}
-
-	
-	stream.Write((BYTE*)compressedData, compressedLength);
-	
-	*pcbyteWritten = stream.GetBytesWritten();	
-	return OK;
 }
 
-CHARLS_IMEXPORT(JLS_ERROR) JpegLsDecode(void* uncompressedData, size_t uncompressedLength, const void* compressedData, size_t compressedLength, JlsParameters* info)
+
+CHARLS_IMEXPORT(JLS_ERROR) JpegLsDecodeStream(ByteStreamInfo rawStream, ByteStreamInfo compressedStream, JlsParameters* info)
 {
-	JLSInputStream reader((BYTE*)compressedData, compressedLength);
+	JpegMarkerReader reader(compressedStream);
 
-	if(info != NULL)
+	if (info != NULL)
 	{
-	 	reader.SetInfo(info);
+		reader.SetInfo(info);
 	}
 
 	try
 	{
-		reader.Read(uncompressedData, uncompressedLength);
+		reader.Read(rawStream);
 		return OK;
 	}
-	catch (JlsException& e)
+	catch (const JlsException& e)
 	{
 		return e._error;
 	}
 }
 
 
-CHARLS_IMEXPORT(JLS_ERROR) JpegLsDecodeRect(void* uncompressedData, size_t uncompressedLength, const void* compressedData, size_t compressedLength, JlsRect roi, JlsParameters* info)
+CHARLS_IMEXPORT(JLS_ERROR) JpegLsReadHeaderStream(ByteStreamInfo rawStreamInfo, JlsParameters* pparams)
 {
-	JLSInputStream reader((BYTE*)compressedData, compressedLength);
-
-	if(info != NULL)
-	{
-	 	reader.SetInfo(info);
-	}
-
-	reader.SetRect(roi);
-
 	try
 	{
-		reader.Read(uncompressedData, uncompressedLength);
+		JpegMarkerReader reader(rawStreamInfo);
+		reader.ReadHeader();
+		reader.ReadStartOfScan(true);
+		JlsParameters info = reader.GetMetadata();
+		*pparams = info;
 		return OK;
 	}
-	catch (JlsException& e)
+	catch (const JlsException& e)
 	{
 		return e._error;
 	}
 }
 
-
-CHARLS_IMEXPORT(JLS_ERROR) JpegLsVerifyEncode(const void* uncompressedData, size_t uncompressedLength, const void* compressedData, size_t compressedLength)
+extern "C"
 {
-	JlsParameters info = JlsParameters();
-
-	JLS_ERROR error = JpegLsReadHeader(compressedData, compressedLength, &info);
-	if (error != OK)
-		return error;
+	CHARLS_IMEXPORT(JLS_ERROR) JpegLsEncode(void* compressedData, size_t compressedLength, size_t* pcbyteWritten, const void* uncompressedData, size_t uncompressedLength, struct JlsParameters* pparams)
+	{
+		ByteStreamInfo rawStreamInfo = FromByteArray(uncompressedData, uncompressedLength);
+		ByteStreamInfo compressedStreamInfo = FromByteArray(compressedData, compressedLength);
 
-	error = CheckInput(compressedData, compressedLength, uncompressedData, uncompressedLength, &info);
+		return JpegLsEncodeStream(compressedStreamInfo, pcbyteWritten, rawStreamInfo, pparams);
+	}
 
-	if (error != OK)
-		return error;
-	
-	Size size = Size(info.width, info.height);
-	
-	JLSOutputStream stream;
-	
-	stream.Init(size, info.bitspersample, info.components);
 
-	if (info.ilv == ILV_NONE)
+	CHARLS_IMEXPORT(JLS_ERROR) JpegLsDecode(void* uncompressedData, size_t uncompressedLength, const void* compressedData, size_t compressedLength, JlsParameters* info)
 	{
-		LONG cbyteComp = size.cx*size.cy*((info.bitspersample +7)/8);
-		for (LONG component = 0; component < info.components; ++component)
-		{
-			const BYTE* compareData = static_cast<const BYTE*>(uncompressedData) + component*cbyteComp;
-			stream.AddScan(compareData, &info);
-		}
+		ByteStreamInfo compressedStream = FromByteArray(compressedData, compressedLength);
+		ByteStreamInfo rawStreamInfo = FromByteArray(uncompressedData, uncompressedLength);
+
+		return JpegLsDecodeStream(rawStreamInfo, compressedStream, info);
 	}
-	else 
+
+	
+	CHARLS_IMEXPORT(JLS_ERROR) JpegLsReadHeader(const void* compressedData, size_t compressedLength, JlsParameters* pparams)
 	{
-		stream.AddScan(uncompressedData, &info);
+		return JpegLsReadHeaderStream(FromByteArray(compressedData, compressedLength), pparams);
 	}
 
-	std::vector<BYTE> rgbyteCompressed(compressedLength + 16);
-	
-	memcpy(&rgbyteCompressed[0], compressedData, compressedLength);
-	
-	stream.EnableCompare(true);
-	stream.Write(&rgbyteCompressed[0], compressedLength);
-	
-	return OK;
-}
 
- 
-CHARLS_IMEXPORT(JLS_ERROR) JpegLsReadHeader(const void* compressedData, size_t compressedLength, JlsParameters* pparams)
-{
-	try
+	CHARLS_IMEXPORT(JLS_ERROR) JpegLsVerifyEncode(const void* uncompressedData, size_t uncompressedLength, const void* compressedData, size_t compressedLength)
 	{
-		JLSInputStream reader((BYTE*)compressedData, compressedLength);
-		reader.ReadHeader();	
-		JlsParameters info = reader.GetMetadata();
-		*pparams = info;	
+		JlsParameters info = JlsParameters();
+
+		JLS_ERROR error = JpegLsReadHeader(compressedData, compressedLength, &info);
+		if (error != OK)
+			return error;
+
+		ByteStreamInfo rawStreamInfo = FromByteArray(uncompressedData, uncompressedLength);
+
+		error = CheckInput(rawStreamInfo, &info);
+
+		if (error != OK)
+			return error;
+
+		Size size = Size(info.width, info.height);
+
+		JpegStreamWriter writer(info.jfif, size, info.bitspersample, info.components);
+
+		if (info.ilv == ILV_NONE)
+		{
+			LONG fieldLength = size.cx*size.cy*((info.bitspersample +7)/8);
+			for (LONG component = 0; component < info.components; ++component)
+			{
+				writer.AddScan(rawStreamInfo, &info);
+				SkipBytes(&rawStreamInfo, fieldLength);
+			}
+		}
+		else
+		{
+			writer.AddScan(rawStreamInfo, &info);
+		}
+
+		std::vector<BYTE> rgbyteCompressed(compressedLength + 16);
+
+		memcpy(&rgbyteCompressed[0], compressedData, compressedLength);
+
+		writer.EnableCompare(true);
+		writer.Write(FromByteArray(&rgbyteCompressed[0], rgbyteCompressed.size()));
+
 		return OK;
 	}
-	catch (JlsException& e)
+
+
+	CHARLS_IMEXPORT(JLS_ERROR) JpegLsDecodeRect(void* uncompressedData, size_t uncompressedLength, const void* compressedData, size_t compressedLength, JlsRect roi, JlsParameters* info)
 	{
-		return e._error;
-	}
+		ByteStreamInfo compressedStream = FromByteArray(compressedData, compressedLength);
+		JpegMarkerReader reader(compressedStream);
 
-}
+		ByteStreamInfo rawStreamInfo = FromByteArray(uncompressedData, uncompressedLength);
+
+		if (info != NULL)
+		{
+			reader.SetInfo(info);
+		}
+
+		reader.SetRect(roi);
 
+		try
+		{
+			reader.Read(rawStreamInfo);
+			return OK;
+		}
+		catch (const JlsException& e)
+		{
+			return e._error;
+		}
+	}
 }
diff --git a/Utilities/gdcmcharls/interface.h b/Utilities/gdcmcharls/interface.h
index 680a7c0..db40bff 100644
--- a/Utilities/gdcmcharls/interface.h
+++ b/Utilities/gdcmcharls/interface.h
@@ -1,6 +1,6 @@
-// 
-// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
-// 
+/* 
+ (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
+*/ 
 
 
 #ifndef JLS_INTERFACE
@@ -8,45 +8,59 @@
 
 #include "publictypes.h"
 
-#if defined(_WIN32) && defined(CHARLS_SHARED)
-#ifdef gdcmcharls_EXPORTS
-#define CHARLS_IMEXPORT(returntype) __declspec(dllexport) returntype __stdcall
-#else
-#define CHARLS_IMEXPORT(returntype) __declspec(dllimport) returntype __stdcall
+/* non-windows (static linking) */
+#if !defined(CHARLS_IMEXPORT) && !defined(_WIN32)
+#  define CHARLS_IMEXPORT(returntype) returntype
 #endif
-#else
-#if __GNUC__ >= 4
-#define CHARLS_IMEXPORT(returntype) __attribute__ ((visibility ("default"))) returntype
-#else
-#define CHARLS_IMEXPORT(returntype) returntype
+
+/* windows static linking */
+#if !defined(CHARLS_IMEXPORT) && defined(CHARLS_STATIC)
+#  define CHARLS_IMEXPORT(returntype) returntype
+#endif
+
+/* windows dll */
+#if !defined(CHARLS_IMEXPORT) && defined(CHARLS_DLL)
+#  define CHARLS_IMEXPORT(returntype) __declspec(dllimport) returntype __stdcall
+#endif
+
+#if !defined(CHARLS_IMEXPORT)
+#error Please #define CHARLS_STATIC or CHARLS_DLL before including "interface.h" to indicate if CharLS is built as a static library or as a dll. 
 #endif
-#endif /* _WIN32 */
 
 
 #ifdef __cplusplus
+
+#include <iostream>
+
 extern "C" 
 {
+
 #endif
-  CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsEncode(void* compressedData, size_t compressedLength, size_t* pcbyteWritten, 
-	    const void* uncompressedData, size_t uncompressedLength, struct JlsParameters* pparams);
+  CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsEncode(void* compressedData, size_t compressedLength, size_t* byteCountWritten, 
+	    const void* uncompressedData, size_t uncompressedLength, struct JlsParameters* info);
 
   CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsDecode(void* uncompressedData, size_t uncompressedLength, 
 		const void* compressedData, size_t compressedLength, 
 		struct JlsParameters* info);
 
-
   CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsDecodeRect(void* uncompressedData, size_t uncompressedLength, 
 		const void* compressedData, size_t compressedLength, 
 		struct JlsRect rect, struct JlsParameters* info);
 
   CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsReadHeader(const void* compressedData, size_t compressedLength, 
-		struct JlsParameters* pparams);
+		struct JlsParameters* info);
 
   CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsVerifyEncode(const void* uncompressedData, size_t uncompressedLength, 
 		const void* compressedData, size_t compressedLength);
 
+  
 #ifdef __cplusplus
+
 }
+	CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsEncodeStream(ByteStreamInfo rawStream, size_t* bytesWritten, ByteStreamInfo inputStream, struct JlsParameters* info);
+	CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsDecodeStream(ByteStreamInfo output, ByteStreamInfo input, struct JlsParameters* info);
+	CHARLS_IMEXPORT(enum JLS_ERROR) JpegLsReadHeaderStream(ByteStreamInfo input, struct JlsParameters* info);
+
 #endif
 
 #endif
diff --git a/Utilities/gdcmcharls/jpegimagedatasegment.h b/Utilities/gdcmcharls/jpegimagedatasegment.h
new file mode 100644
index 0000000..65f0361
--- /dev/null
+++ b/Utilities/gdcmcharls/jpegimagedatasegment.h
@@ -0,0 +1,28 @@
+//
+// (C) CharLS Team 2014, all rights reserved. See the accompanying "License.txt" for licensed use. 
+//
+
+#pragma once
+
+#include "util.h"
+#include "jpegsegment.h"
+#include "jpegstreamwriter.h"
+#include <vector>
+
+class JpegImageDataSegment : public JpegSegment
+{
+public:
+	JpegImageDataSegment(ByteStreamInfo rawStream, const JlsParameters& info, int ccompScan) :
+		_ccompScan(ccompScan),
+		_rawStreamInfo(rawStream),
+		_info(info)
+	{
+	}
+
+	void Serialize(JpegStreamWriter& streamWriter);
+
+private:
+	int _ccompScan;
+	ByteStreamInfo _rawStreamInfo;
+	JlsParameters _info;
+};
diff --git a/Utilities/gdcmcharls/jpegls.cpp b/Utilities/gdcmcharls/jpegls.cpp
index 6a6bcf4..42c1df8 100644
--- a/Utilities/gdcmcharls/jpegls.cpp
+++ b/Utilities/gdcmcharls/jpegls.cpp
@@ -4,7 +4,7 @@
 
 #include "config.h"
 #include "util.h"
-#include "streams.h"
+#include "jpegmarker.h"
 #include "header.h"
                
 
@@ -21,7 +21,6 @@
 #include "lookuptable.h"
 
 
-signed char* JlsContext::_tableC = CreateTableC();
 
 // As defined in the JPEG-LS standard 
 
diff --git a/Utilities/gdcmcharls/jpegmarker.h b/Utilities/gdcmcharls/jpegmarker.h
new file mode 100644
index 0000000..7547597
--- /dev/null
+++ b/Utilities/gdcmcharls/jpegmarker.h
@@ -0,0 +1,75 @@
+// 
+// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
+// 
+#ifndef CHARLS_JPEGMARKER
+#define CHARLS_JPEGMARKER
+
+#include <memory>
+#include <vector>
+#include "util.h"
+
+
+// This file defines JPEG-LS markers: The header and the actual pixel data. Header markers have fixed length, the pixeldata not.
+
+
+class JpegSegment;
+
+
+
+ByteStreamInfo FromByteArray(const void* bytes, size_t count);
+ByteStreamInfo FromStream(std::basic_streambuf<char>* stream);
+void SkipBytes(ByteStreamInfo* streamInfo, size_t count);
+
+
+
+//
+// JpegMarkerReader: minimal implementation to read JPEG markers
+//
+class JpegMarkerReader
+{
+public:
+	JpegMarkerReader(ByteStreamInfo byteStreamInfo);
+
+	const JlsParameters& GetMetadata() const
+		{ return _info; } 
+
+	const JlsCustomParameters& GetCustomPreset() const
+	{ return _info.custom; } 
+
+	void Read(ByteStreamInfo info);
+	void ReadHeader();
+
+	void EnableCompare(bool bCompare)
+		{ _bCompare = bCompare;	}
+
+	void SetInfo(JlsParameters* info) { _info = *info; }
+
+	void SetRect(JlsRect rect) { _rect = rect; }
+
+	void ReadStartOfScan(bool firstComponent);
+	BYTE ReadByte();
+
+private:
+	void ReadScan(ByteStreamInfo rawPixels);	
+	int ReadPresetParameters();
+	int ReadComment();
+	int ReadStartOfFrame();
+	int ReadWord();
+	void ReadNBytes(std::vector<char>& dst, int byteCount);
+	int ReadMarker(BYTE marker);
+
+	// JFIF
+	void ReadJfif();
+	// Color Transform Application Markers & Code Stream (HP extension)
+	int ReadColorSpace();
+	int ReadColorXForm();
+
+private:
+	ByteStreamInfo _byteStream;
+	bool _bCompare;
+	JlsParameters _info;
+	JlsRect _rect;
+};
+
+
+#endif
diff --git a/Utilities/gdcmcharls/jpegmarkersegment.cpp b/Utilities/gdcmcharls/jpegmarkersegment.cpp
new file mode 100644
index 0000000..900b7b1
--- /dev/null
+++ b/Utilities/gdcmcharls/jpegmarkersegment.cpp
@@ -0,0 +1,120 @@
+//
+// (C) CharLS Team 2014, all rights reserved. See the accompanying "License.txt" for licensed use. 
+//
+
+#include "jpegmarkersegment.h"
+#include "header.h"
+#include "util.h"
+#include <vector>
+
+
+JpegMarkerSegment* JpegMarkerSegment::CreateStartOfFrameMarker(Size size, LONG bitsPerSample, LONG ccomp)
+{
+	std::vector<BYTE> vec;
+	vec.push_back(static_cast<BYTE>(bitsPerSample));
+	push_back(vec, static_cast<USHORT>(size.cy));
+	push_back(vec, static_cast<USHORT>(size.cx));
+
+	// components
+	vec.push_back(static_cast<BYTE>(ccomp));
+	for (BYTE component = 0; component < ccomp; component++)
+	{
+		// rescaling
+		vec.push_back(component + 1);
+		vec.push_back(0x11);
+		//"Tq1" reserved, 0
+		vec.push_back(0);
+	}
+
+	return new JpegMarkerSegment(JPEG_SOF_55, vec);
+}
+
+
+JpegMarkerSegment* JpegMarkerSegment::CreateJpegFileInterchangeFormatMarker(const JfifParameters& jfifParameters)
+{
+	BYTE jfifID [] = { 'J', 'F', 'I', 'F', '\0' };
+
+	std::vector<BYTE> rgbyte;
+	for (int i = 0; i < (int)sizeof(jfifID); i++)
+	{
+		rgbyte.push_back(jfifID[i]);
+	}
+
+	push_back(rgbyte, (USHORT) jfifParameters.Ver);
+
+	rgbyte.push_back(jfifParameters.units);
+	push_back(rgbyte, (USHORT) jfifParameters.XDensity);
+	push_back(rgbyte, (USHORT) jfifParameters.YDensity);
+
+	// thumbnail
+	rgbyte.push_back((BYTE) jfifParameters.Xthumb);
+	rgbyte.push_back((BYTE) jfifParameters.Ythumb);
+	if (jfifParameters.Xthumb > 0)
+	{
+		if (jfifParameters.pdataThumbnail)
+			throw JlsException(InvalidJlsParameters);
+
+		rgbyte.insert(rgbyte.end(), (BYTE*) jfifParameters.pdataThumbnail, (BYTE*) jfifParameters.pdataThumbnail + 3 * jfifParameters.Xthumb * jfifParameters.Ythumb);
+	}
+
+	return new JpegMarkerSegment(JPEG_APP0, rgbyte);
+}
+
+
+JpegMarkerSegment* JpegMarkerSegment::CreateJpegLSExtendedParametersMarker(const JlsCustomParameters& customParameters)
+{
+	std::vector<BYTE> rgbyte;
+
+	rgbyte.push_back(1);
+	push_back(rgbyte, (USHORT) customParameters.MAXVAL);
+	push_back(rgbyte, (USHORT) customParameters.T1);
+	push_back(rgbyte, (USHORT) customParameters.T2);
+	push_back(rgbyte, (USHORT) customParameters.T3);
+	push_back(rgbyte, (USHORT) customParameters.RESET);
+
+	return new JpegMarkerSegment(JPEG_LSE, rgbyte);
+}
+
+
+JpegMarkerSegment* JpegMarkerSegment::CreateColorTransformMarker(int i)
+{
+	std::vector<BYTE> rgbyteXform;
+
+	rgbyteXform.push_back('m');
+	rgbyteXform.push_back('r');
+	rgbyteXform.push_back('f');
+	rgbyteXform.push_back('x');
+	rgbyteXform.push_back((BYTE) i);
+
+	return new JpegMarkerSegment(JPEG_APP8, rgbyteXform);
+}
+
+
+JpegMarkerSegment* JpegMarkerSegment::CreateStartOfScanMarker(const JlsParameters* pparams, LONG icomponent)
+{
+	BYTE itable = 0;
+
+	std::vector<BYTE> rgbyte;
+
+	if (icomponent < 0)
+	{
+		rgbyte.push_back((BYTE) pparams->components);
+		for (LONG i = 0; i < pparams->components; ++i)
+		{
+			rgbyte.push_back(BYTE(i + 1));
+			rgbyte.push_back(itable);
+		}
+	}
+	else
+	{
+		rgbyte.push_back(1);
+		rgbyte.push_back((BYTE) icomponent);
+		rgbyte.push_back(itable);
+	}
+
+	rgbyte.push_back(BYTE(pparams->allowedlossyerror));
+	rgbyte.push_back(BYTE(pparams->ilv));
+	rgbyte.push_back(0); // transform
+
+	return new JpegMarkerSegment(JPEG_SOS, rgbyte);
+}
diff --git a/Utilities/gdcmcharls/jpegmarkersegment.h b/Utilities/gdcmcharls/jpegmarkersegment.h
new file mode 100644
index 0000000..6e914ef
--- /dev/null
+++ b/Utilities/gdcmcharls/jpegmarkersegment.h
@@ -0,0 +1,40 @@
+//
+// (C) CharLS Team 2014, all rights reserved. See the accompanying "License.txt" for licensed use. 
+//
+
+#pragma once
+
+#include "util.h"
+#include "jpegsegment.h"
+#include "jpegstreamwriter.h"
+#include <vector>
+
+
+class JpegMarkerSegment : public JpegSegment
+{
+public:
+	JpegMarkerSegment(BYTE marker, std::vector<BYTE> vecbyte)
+	{
+		_marker = marker;
+		std::swap(_vecbyte, vecbyte);
+	}
+
+	virtual void Serialize(JpegStreamWriter& streamWriter)
+	{
+		streamWriter.WriteByte(0xFF);
+		streamWriter.WriteByte(_marker);
+		streamWriter.WriteWord(USHORT(_vecbyte.size() + 2));
+		streamWriter.WriteBytes(_vecbyte);
+	}
+
+	static JpegMarkerSegment* CreateStartOfFrameMarker(Size size, LONG bitsPerSample, LONG ccomp);
+	static JpegMarkerSegment* CreateJpegFileInterchangeFormatMarker(const JfifParameters& jfif);
+	static JpegMarkerSegment* CreateJpegLSExtendedParametersMarker(const JlsCustomParameters& pcustom);
+	static JpegMarkerSegment* CreateColorTransformMarker(int i);
+	static JpegMarkerSegment* CreateStartOfScanMarker(const JlsParameters* pparams, LONG icomponent);
+
+private:
+	BYTE _marker;
+	std::vector<BYTE> _vecbyte;
+};
+
diff --git a/Utilities/gdcmcharls/jpegsegment.h b/Utilities/gdcmcharls/jpegsegment.h
new file mode 100644
index 0000000..7806a9b
--- /dev/null
+++ b/Utilities/gdcmcharls/jpegsegment.h
@@ -0,0 +1,22 @@
+//
+// (C) CharLS Team 2014, all rights reserved. See the accompanying "License.txt" for licensed use. 
+//
+
+#ifndef CHARLS_JPEGSEGMENT
+#define CHARLS_JPEGSEGMENT
+
+class JpegStreamWriter;
+
+//
+// Purpose: base class for segments that can be written to JPEG streams.
+//
+class JpegSegment
+{
+protected:
+	JpegSegment() {}
+public:
+	virtual ~JpegSegment() {}
+	virtual void Serialize(JpegStreamWriter& streamWriter) = 0;
+};
+
+#endif
diff --git a/Utilities/gdcmcharls/jpegstreamwriter.cpp b/Utilities/gdcmcharls/jpegstreamwriter.cpp
new file mode 100644
index 0000000..4d89882
--- /dev/null
+++ b/Utilities/gdcmcharls/jpegstreamwriter.cpp
@@ -0,0 +1,107 @@
+//
+// (C) CharLS Team 2014, all rights reserved. See the accompanying "License.txt" for licensed use. 
+//
+
+
+#include "jpegstreamwriter.h"
+#include "jpegmarkersegment.h"
+#include "jpegimagedatasegment.h"
+#include "header.h"
+#include "util.h"
+#include <vector>
+
+
+namespace
+{
+	bool IsDefault(const JlsCustomParameters* pcustom)
+	{
+		if (pcustom->MAXVAL != 0)
+			return false;
+
+		if (pcustom->T1 != 0)
+			return false;
+
+		if (pcustom->T2 != 0)
+			return false;
+
+		if (pcustom->T3 != 0)
+			return false;
+
+		if (pcustom->RESET != 0)
+			return false;
+
+		return true;
+	}
+}
+
+
+JpegStreamWriter::JpegStreamWriter(const JfifParameters& jfifParameters, Size size, LONG bitsPerSample, LONG ccomp) :
+_bCompare(false),
+_data(),
+_byteOffset(0),
+_lastCompenentIndex(0)
+{
+	if (jfifParameters.Ver)
+	{
+		AddSegment(JpegMarkerSegment::CreateJpegFileInterchangeFormatMarker(jfifParameters));
+	}
+
+	AddSegment(JpegMarkerSegment::CreateStartOfFrameMarker(size, bitsPerSample, ccomp));
+}
+
+
+JpegStreamWriter::~JpegStreamWriter()
+{
+	for (size_t i = 0; i < _segments.size(); ++i)
+	{
+		delete _segments[i];
+	}
+}
+
+
+void JpegStreamWriter::AddColorTransform(int i)
+{
+	AddSegment(JpegMarkerSegment::CreateColorTransformMarker(i));
+}
+
+
+size_t JpegStreamWriter::Write(ByteStreamInfo info)
+{
+	_data = info;
+
+	WriteByte(0xFF);
+	WriteByte(JPEG_SOI);
+
+	for (size_t i = 0; i < _segments.size(); ++i)
+	{
+		_segments[i]->Serialize(*this);
+	}
+
+	//_bCompare = false;
+
+	WriteByte(0xFF);
+	WriteByte(JPEG_EOI);
+
+	return _byteOffset;
+}
+
+
+void JpegStreamWriter::AddScan(ByteStreamInfo info, const JlsParameters* pparams)
+{
+	if (!IsDefault(&pparams->custom))
+	{
+		AddSegment(JpegMarkerSegment::CreateJpegLSExtendedParametersMarker(pparams->custom));
+	}
+	else if (pparams->bitspersample > 12)
+	{
+		JlsCustomParameters preset = ComputeDefault((1 << pparams->bitspersample) - 1, pparams->allowedlossyerror);
+		AddSegment(JpegMarkerSegment::CreateJpegLSExtendedParametersMarker(preset));
+	}
+
+	_lastCompenentIndex += 1;
+	AddSegment(JpegMarkerSegment::CreateStartOfScanMarker(pparams, pparams->ilv == ILV_NONE ? _lastCompenentIndex : -1));
+
+	int ccomp = pparams->ilv == ILV_NONE ? 1 : pparams->components;
+
+	AddSegment(new JpegImageDataSegment(info, *pparams, ccomp));
+}
diff --git a/Utilities/gdcmcharls/jpegstreamwriter.h b/Utilities/gdcmcharls/jpegstreamwriter.h
new file mode 100644
index 0000000..d0ebd49
--- /dev/null
+++ b/Utilities/gdcmcharls/jpegstreamwriter.h
@@ -0,0 +1,114 @@
+//
+// (C) CharLS Team 2014, all rights reserved. See the accompanying "License.txt" for licensed use. 
+//
+
+#ifndef CHARLS_JPEGSTREAMWRITER
+#define CHARLS_JPEGSTREAMWRITER
+
+#include "util.h"
+#include "jpegsegment.h"
+#include <vector>
+
+
+//
+// Purpose: 'Writer'class that can generate JPEG-LS file streams.
+//
+class JpegStreamWriter
+{
+	friend class JpegMarkerSegment;
+	friend class JpegImageDataSegment;
+
+public:
+	JpegStreamWriter(const JfifParameters& jfifParameters, Size size, LONG bitsPerSample, LONG ccomp);
+	virtual ~JpegStreamWriter();
+
+	void AddSegment(JpegSegment* segment)
+	{
+		_segments.push_back(segment);
+	}
+
+	void AddScan(ByteStreamInfo info, const JlsParameters* pparams);
+
+	void AddLSE(const JlsCustomParameters* pcustom);
+
+	void AddColorTransform(int i);
+
+	size_t GetBytesWritten()
+	{
+		return _byteOffset;
+	}
+
+	size_t GetLength()
+	{
+		return _data.count - _byteOffset;
+	}
+
+	size_t Write(ByteStreamInfo info);
+
+	void EnableCompare(bool bCompare)
+	{
+		_bCompare = bCompare;
+	}
+
+private:
+	BYTE* GetPos() const
+	{
+		return _data.rawData + _byteOffset;
+	}
+
+	ByteStreamInfo OutputStream() const
+	{
+		ByteStreamInfo data = _data;
+		data.count -= _byteOffset;
+		data.rawData += _byteOffset;
+		return data;
+	}
+
+	void WriteByte(BYTE val)
+	{
+		ASSERT(!_bCompare || _data.rawData[_byteOffset] == val);
+
+		if (_data.rawStream != NULL)
+		{
+			_data.rawStream->sputc(val);
+		}
+		else
+		{
+			if (_byteOffset >= _data.count)
+				throw JlsException(CompressedBufferTooSmall);
+
+			_data.rawData[_byteOffset++] = val;
+		}
+	}
+
+	void WriteBytes(const std::vector<BYTE>& rgbyte)
+	{
+		for (size_t i = 0; i < rgbyte.size(); ++i)
+		{
+			WriteByte(rgbyte[i]);
+		}
+	}
+
+	void WriteWord(USHORT val)
+	{
+		WriteByte(BYTE(val / 0x100));
+		WriteByte(BYTE(val % 0x100));
+	}
+
+	void Seek(size_t byteCount)
+	{
+		if (_data.rawStream != NULL)
+			return;
+
+		_byteOffset += byteCount;
+	}
+
+private:
+	bool _bCompare;
+	ByteStreamInfo _data;
+	size_t _byteOffset;
+	LONG _lastCompenentIndex;
+	std::vector<JpegSegment*> _segments;
+};
+
+#endif
diff --git a/Utilities/gdcmcharls/processline.h b/Utilities/gdcmcharls/processline.h
index e9b7e6f..ab96b2e 100644
--- a/Utilities/gdcmcharls/processline.h
+++ b/Utilities/gdcmcharls/processline.h
@@ -5,6 +5,12 @@
 #define CHARLS_PROCESSLINE
 
 #include "colortransform.h"
+#include <iostream>
+#include <vector>
+
+#ifdef _MSC_VER 
+#pragma warning(disable: 4996) // disable 'function': was declared deprecated also 'std::<function name>': Function call with parameters that may be unsafe
+#endif
 
 //
 // This file defines the ProcessLine base class, its derivitives and helper functions.
@@ -19,41 +25,107 @@ class ProcessLine
 {
 public:
 	virtual ~ProcessLine() {}
-	virtual void NewLineDecoded(const void* pSrc, int pixelCount, int bytesperline) = 0;
-	virtual void NewLineRequested(void* pSrc, int pixelCount, int bytesperline) = 0;
+	virtual void NewLineDecoded(const void* pSrc, int pixelCount, int sourceStride) = 0;
+	virtual void NewLineRequested(void* pDest, int pixelCount, int destStride) = 0;
 };
 
 
 class PostProcesSingleComponent : public ProcessLine
 {
 public:
-	PostProcesSingleComponent(void* pbyteOutput, const JlsParameters& info, int bytesPerPixel) :
-		_pbyteOutput((BYTE*)pbyteOutput), 
+	PostProcesSingleComponent(void* rawData, const JlsParameters& info, int bytesPerPixel) :
+		_rawData((BYTE*)rawData), 
 		_bytesPerPixel(bytesPerPixel),
 		_bytesPerLine(info.bytesperline)
 	{
 	}
 
-	void NewLineRequested(void* pDst, int pixelCount, int /*byteStride*/)
+	void NewLineRequested(void* dest, int pixelCount, int /*byteStride*/)
 	{
-		::memcpy(pDst, _pbyteOutput, pixelCount * _bytesPerPixel);
-		_pbyteOutput += _bytesPerLine;
+		::memcpy(dest, _rawData, pixelCount * _bytesPerPixel);
+		_rawData += _bytesPerLine;
 	}
 
-	void NewLineDecoded(const void* pSrc, int pixelCount, int /*byteStride*/)
+	void NewLineDecoded(const void* pSrc, int pixelCount, int /*sourceStride*/)
 	{
-		::memcpy(_pbyteOutput, pSrc, pixelCount * _bytesPerPixel);
-		_pbyteOutput += _bytesPerLine;		
+		::memcpy(_rawData, pSrc, pixelCount * _bytesPerPixel);
+		_rawData += _bytesPerLine;
 	}
 
 private:
-	BYTE* _pbyteOutput;
+	BYTE* _rawData;
 	int _bytesPerPixel;
 	int _bytesPerLine;
 };
 
 
-template<class TRANSFORM, class SAMPLE> 
+inline void ByteSwap(unsigned char* data, int count)
+{
+	if (count & 1)
+		throw JlsException(InvalidJlsParameters);
+
+	unsigned int* data32 = (unsigned int*)data;
+	for(int i = 0; i < count/4; i++)
+	{
+		unsigned int value = data32[i];
+		data32[i] = ((value >> 8) & 0x00FF00FF) | ((value & 0x00FF00FF) << 8);
+	}
+
+	if ((count % 4) != 0)
+	{
+		std::swap(data[count-2], data[count-1]);
+	}
+}
+
+class PostProcesSingleStream : public ProcessLine
+{
+public:
+	PostProcesSingleStream(std::basic_streambuf<char>* rawData, const JlsParameters& info, int bytesPerPixel) :
+		_rawData(rawData), 
+		_bytesPerPixel(bytesPerPixel),
+		_bytesPerLine(info.bytesperline)
+	{
+	}
+
+	void NewLineRequested(void* dest, int pixelCount, int /*destStride*/)
+	{
+		size_t bytesToRead = pixelCount * _bytesPerPixel;
+		while (bytesToRead != 0)
+		{
+			std::streamsize bytesRead = _rawData->sgetn((char*)dest, bytesToRead);
+			if (bytesRead == 0)
+				throw JlsException(UncompressedBufferTooSmall);
+
+			bytesToRead = (size_t)(bytesToRead - bytesRead);
+		}
+
+		if (_bytesPerPixel == 2 )
+		{
+			ByteSwap((unsigned char*)dest, 2 * pixelCount);
+		}
+
+		if (_bytesPerLine - pixelCount * _bytesPerPixel > 0)
+		{
+			_rawData->pubseekoff(std::streamoff(_bytesPerLine - bytesToRead), std::ios_base::cur);
+		}
+	}
+
+	void NewLineDecoded(const void* pSrc, int pixelCount, int /*sourceStride*/)
+	{
+		int bytesToWrite = pixelCount * _bytesPerPixel;
+		std::streamsize bytesWritten = _rawData->sputn((const char*)pSrc, bytesToWrite);
+		if (bytesWritten != bytesToWrite)
+			throw JlsException(UncompressedBufferTooSmall);
+	}
+
+private:
+	std::basic_streambuf<char>* _rawData;
+	int _bytesPerPixel;
+	int _bytesPerLine;
+};
+
+
+template<class TRANSFORM, class SAMPLE>
 void TransformLineToQuad(const SAMPLE* ptypeInput, LONG pixelStrideIn, Quad<SAMPLE>* pbyteBuffer, LONG pixelStride, TRANSFORM& transform)
 {
 	int cpixel = MIN(pixelStride, pixelStrideIn);
@@ -87,20 +159,20 @@ void TransformQuadToLine(const Quad<SAMPLE>* pbyteInput, LONG pixelStrideIn, SAM
 }
 
 
-template<class SAMPLE> 
+template<class SAMPLE>
 void TransformRgbToBgr(SAMPLE* pDest, int samplesPerPixel, int pixelCount)
 {
 	for (int i = 0; i < pixelCount; ++i)
 	{
-		std::swap(pDest[0], pDest[2]);		
+		std::swap(pDest[0], pDest[2]);
 		pDest += samplesPerPixel;
 	}
 }
 
 
-template<class TRANSFORM, class SAMPLE> 
-void TransformLine(Triplet<SAMPLE>* pDest, const Triplet<SAMPLE>* pSrc, int pixelCount, TRANSFORM& transform) 
-{	
+template<class TRANSFORM, class SAMPLE>
+void TransformLine(Triplet<SAMPLE>* pDest, const Triplet<SAMPLE>* pSrc, int pixelCount, TRANSFORM& transform)
+{
 	for (int i = 0; i < pixelCount; ++i)
 	{
 		pDest[i] = transform(pSrc[i].v1, pSrc[i].v2, pSrc[i].v3);
@@ -121,7 +193,7 @@ void TransformLineToTriplet(const SAMPLE* ptypeInput, LONG pixelStrideIn, Triple
 }
 
 
-template<class TRANSFORM, class SAMPLE> 
+template<class TRANSFORM, class SAMPLE>
 void TransformTripletToLine(const Triplet<SAMPLE>* pbyteInput, LONG pixelStrideIn, SAMPLE* ptypeBuffer, LONG pixelStride, TRANSFORM& transform)
 {
 	int cpixel = MIN(pixelStride, pixelStrideIn);
@@ -139,85 +211,134 @@ void TransformTripletToLine(const Triplet<SAMPLE>* pbyteInput, LONG pixelStrideI
 }
 
 
-template<class TRANSFORM> 
+template<class TRANSFORM>
 class ProcessTransformed : public ProcessLine
 {
 	typedef typename TRANSFORM::SAMPLE SAMPLE;
 
-	ProcessTransformed(const ProcessTransformed&);
 public:
-	ProcessTransformed(void* pbyteOutput, const JlsParameters& info, TRANSFORM transform) :
-		_pbyteOutput((BYTE*)pbyteOutput),
+	ProcessTransformed(ByteStreamInfo rawStream, const JlsParameters& info, TRANSFORM transform) :
 		_info(info),
-		_templine(info.width *  info.components),
+		_templine(info.width * info.components),
+		_buffer(info.width * info.components * sizeof(SAMPLE)),
 		_transform(transform),
-		_inverseTransform(transform)
+		_inverseTransform(transform),
+		_rawPixels(rawStream)
 	{
-//		ASSERT(_info.components == sizeof(TRIPLET)/sizeof(TRIPLET::SAMPLE));
 	}
 
+	void NewLineRequested(void* dest, int pixelCount, int destStride)
+	{
+		if (_rawPixels.rawStream == NULL)
+		{
+			Transform(_rawPixels.rawData, dest, pixelCount, destStride);
+			_rawPixels.rawData += _info.bytesperline;
+			return;
+		}
+
+		Transform(_rawPixels.rawStream, dest, pixelCount, destStride);
+	}
+
+	void Transform(std::basic_streambuf<char>* rawStream, void* dest, int pixelCount, int destStride)
+	{
+		std::streamsize bytesToRead = pixelCount * _info.components * sizeof(SAMPLE);
+		while(bytesToRead != 0)
+		{
+			std::streamsize read = rawStream->sgetn((char*)&_buffer[0], bytesToRead);
+			if (read == 0)
+				throw new JlsException(UncompressedBufferTooSmall);
+
+			bytesToRead -= read;
+		}
+		if (sizeof(SAMPLE) == 2 && _info.colorTransform == XFORM_BIGENDIAN)
+		{
+			ByteSwap(&_buffer[0], _info.components * sizeof(SAMPLE) * pixelCount);
+		}
+		Transform(&_buffer[0], dest, pixelCount, destStride);
+	}
 
-	void NewLineRequested(void* pDst, int pixelCount, int stride)
+	void Transform(const void* source, void* dest, int pixelCount, int destStride)
 	{
-		SAMPLE* pLine = (SAMPLE*)_pbyteOutput;
 		if (_info.outputBgr)
 		{
-			pLine = &_templine[0]; 
-			memcpy(pLine, _pbyteOutput, sizeof(Triplet<SAMPLE>)*pixelCount);
-			TransformRgbToBgr(pLine, _info.components, pixelCount);
+			memcpy(&_templine[0], source, sizeof(Triplet<SAMPLE>)*pixelCount);
+			TransformRgbToBgr((SAMPLE*)&_templine[0], _info.components, pixelCount);
+			source = &_templine[0];
 		}
 
 		if (_info.components == 3)
 		{
 			if (_info.ilv == ILV_SAMPLE)
 			{
-				TransformLine((Triplet<SAMPLE>*)pDst, (const Triplet<SAMPLE>*)pLine, pixelCount, _transform);
+				TransformLine((Triplet<SAMPLE>*)dest, (const Triplet<SAMPLE>*)source, pixelCount, _transform);
 			}
 			else
 			{
-				TransformTripletToLine((const Triplet<SAMPLE>*)pLine, pixelCount, (SAMPLE*)pDst, stride, _transform);
+				TransformTripletToLine((const Triplet<SAMPLE>*)source, pixelCount, (SAMPLE*)dest, destStride, _transform);
 			}
 		}
 		else if (_info.components == 4 && _info.ilv == ILV_LINE)
 		{
-			TransformQuadToLine((const Quad<SAMPLE>*)pLine, pixelCount, (SAMPLE*)pDst, stride, _transform);
+			TransformQuadToLine((const Quad<SAMPLE>*)source, pixelCount, (SAMPLE*)dest, destStride, _transform);
 		}
-		_pbyteOutput += _info.bytesperline;
 	}
 
 
-	void NewLineDecoded(const void* pSrc, int pixelCount, int byteStride)
+	void DecodeTransform(const void* pSrc, void* rawData, int pixelCount, int byteStride)
 	{
 		if (_info.components == 3)
-		{	
+		{
 			if (_info.ilv == ILV_SAMPLE)
 			{
-				TransformLine((Triplet<SAMPLE>*)_pbyteOutput, (const Triplet<SAMPLE>*)pSrc, pixelCount, _inverseTransform);
+				TransformLine((Triplet<SAMPLE>*)rawData, (const Triplet<SAMPLE>*)pSrc, pixelCount, _inverseTransform);
 			}
 			else
 			{
-				TransformLineToTriplet((const SAMPLE*)pSrc, byteStride, (Triplet<SAMPLE>*)_pbyteOutput, pixelCount, _inverseTransform);
+				TransformLineToTriplet((const SAMPLE*)pSrc, byteStride, (Triplet<SAMPLE>*)rawData, pixelCount, _inverseTransform);
 			}
 		}
 		else if (_info.components == 4 && _info.ilv == ILV_LINE)
 		{
-			TransformLineToQuad((const SAMPLE*)pSrc, byteStride, (Quad<SAMPLE>*)_pbyteOutput, pixelCount, _inverseTransform);
+			TransformLineToQuad((const SAMPLE*)pSrc, byteStride, (Quad<SAMPLE>*)rawData, pixelCount, _inverseTransform);
 		}
 
 		if (_info.outputBgr)
 		{
-			TransformRgbToBgr(_pbyteOutput, _info.components, pixelCount);
+			TransformRgbToBgr((SAMPLE*)rawData, _info.components, pixelCount);
+		}
+	}
+
+	void NewLineDecoded(const void* pSrc, int pixelCount, int sourceStride)
+	{
+		if (_rawPixels.rawStream != NULL)
+		{
+			std::streamsize bytesToWrite = pixelCount * _info.components * sizeof(SAMPLE);
+			DecodeTransform(pSrc, &_buffer[0], pixelCount, sourceStride);
+
+			if (sizeof(SAMPLE) == 2 && _info.colorTransform == XFORM_BIGENDIAN)
+			{
+				ByteSwap(&_buffer[0], _info.components * sizeof(SAMPLE) * pixelCount);
+			}
+
+			std::streamsize bytesWritten = _rawPixels.rawStream->sputn((char*)&_buffer[0], bytesToWrite);
+			if (bytesWritten != bytesToWrite)
+				throw JlsException(UncompressedBufferTooSmall);
+		}
+		else
+		{
+			DecodeTransform(pSrc, _rawPixels.rawData, pixelCount, sourceStride);
+			_rawPixels.rawData += _info.bytesperline;
 		}
-		_pbyteOutput += _info.bytesperline;		
 	}
 
 
 private:
-	BYTE* _pbyteOutput;
-	const JlsParameters& _info;	
+	const JlsParameters& _info;
 	std::vector<SAMPLE> _templine;
-	TRANSFORM _transform;	
+	std::vector<BYTE> _buffer;
+	TRANSFORM _transform;
 	typename TRANSFORM::INVERSE _inverseTransform;
+	ByteStreamInfo _rawPixels;
 };
 
 
diff --git a/Utilities/gdcmcharls/publictypes.h b/Utilities/gdcmcharls/publictypes.h
index 612738c..80e3ba6 100644
--- a/Utilities/gdcmcharls/publictypes.h
+++ b/Utilities/gdcmcharls/publictypes.h
@@ -1,11 +1,16 @@
-// 
-// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
-// 
+/* 
+  (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
+*/ 
 #ifndef CHARLS_PUBLICTYPES
 #define CHARLS_PUBLICTYPES
 
 #include "config.h"
 
+#ifdef __cplusplus
+#include <iostream>
+#include <cstddef>
+#endif
+
 enum JLS_ERROR
 {
 	OK = 0,
@@ -13,11 +18,14 @@ enum JLS_ERROR
 	ParameterValueNotSupported,
 	UncompressedBufferTooSmall,
 	CompressedBufferTooSmall,
-	InvalidCompressedData,
+	InvalidCompressedData,           // This error is returned when the encoded bit stream contains a general structural problem.
 	TooMuchCompressedData,
-	ImageTypeNotSupported,
+	ImageTypeNotSupported,           // This error is returned when the bit stream is encoded with an option that is not supported by this implementation.
 	UnsupportedBitDepthForTransform,
-	UnsupportedColorTransform
+	UnsupportedColorTransform,
+	UnsupportedEncoding,             // This error is returned when an encoded frame is found that is not encoded with the JPEG-LS algorithm.
+	UnknownJpegMarker,               // This error is returned when an unknown JPEG marker code is detected in the encoded bit stream.
+	MissingJpegMarkerStart           // This error is returned when the algorithm expect a 0xFF code (indicates start of a JPEG marker) but none was found.
 };
 
 
@@ -29,6 +37,7 @@ enum interleavemode
 };
 
 
+
 struct JlsCustomParameters
 {
 	int MAXVAL;
@@ -54,7 +63,7 @@ struct JfifParameters
 	int   YDensity;
 	short Xthumb;
 	short Ythumb;
-	void* pdataThumbnail; // user must set buffer which size is Xthumb*Ythumb*3(RGB) before JpegLsDecode()
+	void* pdataThumbnail; /* user must set buffer which size is Xthumb*Ythumb*3(RGB) before JpegLsDecode() */
 };
 
 
@@ -63,7 +72,7 @@ struct JlsParameters
 	int width;
 	int height;
 	int bitspersample;
-	int bytesperline;	// for [source (at encoding)][decoded (at decoding)] pixel image in user buffer
+	int bytesperline;	/* for [source (at encoding)][decoded (at decoding)] pixel image in user buffer */
 	int components;
 	int allowedlossyerror;
 	enum interleavemode ilv;
@@ -73,4 +82,56 @@ struct JlsParameters
 	struct JfifParameters jfif;
 };
 
+
+
+enum JPEGLS_ColorXForm
+{
+	// default (RGB)
+	COLORXFORM_NONE = 0,
+
+	// Color transforms as defined by HP
+	// Not part of the JPEG-LS standard in any way, provided for compatibility with existing streams.	
+	COLORXFORM_HP1,
+	COLORXFORM_HP2,
+	COLORXFORM_HP3,
+
+	// Defined by HP but not supported by CharLS
+	COLORXFORM_RGB_AS_YUV_LOSSY,
+	COLORXFORM_MATRIX,
+	XFORM_BIGENDIAN = 1 << 29,
+	XFORM_LITTLEENDIAN = 1 << 30
+};
+
+
+#ifdef __cplusplus
+
+// 
+// ByteStreamInfo & FromByteArray helper function
+//
+// ByteStreamInfo describes the stream: either set rawStream to a valid stream, or rawData/count, not both.
+// it's possible to decode to memorystreams, but using rawData will always be faster.
+//
+// Example use: 
+//     ByteStreamInfo streamInfo = { fileStream.rdbuf() };
+// or 
+//     ByteStreamInfo streamInfo = FromByteArray( bytePtr, byteCount);
+//
+struct ByteStreamInfo
+{
+	std::basic_streambuf<char>* rawStream;
+	BYTE* rawData;
+	std::size_t count;
+};
+
+
+inline ByteStreamInfo FromByteArray(const void* bytes, std::size_t count)
+{
+	ByteStreamInfo info = ByteStreamInfo();
+	info.rawData = (BYTE*)bytes;
+	info.count = count;
+	return info;
+}
+
+#endif
+
 #endif
diff --git a/Utilities/gdcmcharls/scan.h b/Utilities/gdcmcharls/scan.h
index e3d30ec..2c445e6 100644
--- a/Utilities/gdcmcharls/scan.h
+++ b/Utilities/gdcmcharls/scan.h
@@ -8,7 +8,7 @@
 #include "lookuptable.h"
 #include <cstdlib>
 
-// This file contains the code for handling a "scan". Usually an image is encoded as a single scan. 
+// This file contains the code for handling a "scan". Usually an image is encoded as a single scan.
 
 
 #ifdef _MSC_VER
@@ -25,7 +25,7 @@ extern std::vector<signed char> rgquant16Ll;
 // Apply 
 //
 inlinehint LONG ApplySign(LONG i, LONG sign)
-{ return (sign ^ i) - sign; }									
+{ return (sign ^ i) - sign; }
 
 
 
@@ -66,7 +66,7 @@ inlinehint LONG GetPredictedValue(LONG Ra, LONG Rb, LONG Rc)
 	if ((sgn ^ (Rc - Ra)) < 0)
 	{
 		return Rb;
-	} 
+	}
 	else if ((sgn ^ (Rb - Rc)) < 0)
 	{
 		return Ra;
@@ -114,7 +114,7 @@ public:
 	  JlsCodec(const TRAITS& inTraits, const JlsParameters& info) : STRATEGY(info), 
 	  traits(inTraits),
 		  _rect(),
-		  _width(0),
+		  _width(info.width),
 		  T1(0),
 		  T2(0),
 		  T3(0),
@@ -188,22 +188,22 @@ public:
 
 	  void DoLine(SAMPLE* pdummy);
 	  void DoLine(Triplet<SAMPLE>* pdummy);
-	  void DoScan(BYTE* compressedBytes, size_t compressedLength);         
+	  void DoScan();
 
 public:
-	ProcessLine* CreateProcess(void* pvoidOut);
+	ProcessLine* CreateProcess(ByteStreamInfo rawStreamInfo);
 	void InitDefault();
 	void InitParams(LONG t1, LONG t2, LONG t3, LONG nReset);
 
-	size_t  EncodeScan(const void* rawData, void* pvoidOut, size_t compressedLength, void* pvoidCompare);
-	size_t  DecodeScan(void* rawData, const JlsRect& size, const void* compressedData, size_t compressedLength, bool bCompare);
+	size_t  EncodeScan(std::auto_ptr<ProcessLine> rawData, ByteStreamInfo* compressedData, void* pvoidCompare);
+	void DecodeScan(std::auto_ptr<ProcessLine> rawData, const JlsRect& size, ByteStreamInfo* compressedData, bool bCompare);
 
 protected:
 	// codec parameters 
 	TRAITS traits;
 	JlsRect _rect;
 	int _width;
-	LONG T1;	
+	LONG T1;
 	LONG T2;
 	LONG T3; 
 
@@ -214,7 +214,6 @@ protected:
 	PIXEL* _previousLine; // previous line ptr
 	PIXEL* _currentLine; // current line ptr
 
-
 	// quantization lookup table
 	signed char* _pquant;
 	std::vector<signed char> _rgquant;
@@ -228,7 +227,7 @@ protected:
 
 template<class TRAITS, class STRATEGY>
 typename TRAITS::SAMPLE JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, LONG, LONG pred, DecoderStrategy*)
-{		
+{
 	LONG sign		= BitWiseSign(Qs);
 	JlsContext& ctx	= _contexts[ApplySign(Qs, sign)];
 	LONG k			= ctx.GetGolomb();	
@@ -247,8 +246,11 @@ typename TRAITS::SAMPLE JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, LONG, LONG
 		ErrVal = UnMapErrVal(DecodeValue(k, traits.LIMIT, traits.qbpp)); 
 		if (std::abs(ErrVal) > 65535)
 			throw JlsException(InvalidCompressedData);
-	}	
-	ErrVal = ErrVal ^ ((traits.NEAR == 0) ? ctx.GetErrorCorrection(k) : 0);
+	}
+	if (k == 0)
+	{
+		ErrVal = ErrVal ^ ctx.GetErrorCorrection(traits.NEAR);
+	}
 	ctx.UpdateVariables(ErrVal, traits.NEAR, traits.RESET);	
 	ErrVal = ApplySign(ErrVal, sign);
 	return traits.ComputeReconstructedSample(Px, ErrVal); 
@@ -261,7 +263,7 @@ typename TRAITS::SAMPLE JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, LONG x, LO
 	LONG sign		= BitWiseSign(Qs);
 	JlsContext& ctx	= _contexts[ApplySign(Qs, sign)];
 	LONG k			= ctx.GetGolomb();
-	LONG Px			= traits.CorrectPrediction(pred + ApplySign(ctx.C, sign));	
+	LONG Px			= traits.CorrectPrediction(pred + ApplySign(ctx.C, sign));
 
 	LONG ErrVal		= traits.ComputeErrVal(ApplySign(x - Px, sign));
 
@@ -340,7 +342,7 @@ inlinehint void JlsCodec<TRAITS,STRATEGY>::EncodeMappedValue(LONG k, LONG mapped
 		if (highbits + 1 > 31)
 		{
 			STRATEGY::AppendToBitStream(0, highbits / 2);
-			highbits = highbits - highbits / 2;													
+			highbits = highbits - highbits / 2;
 		}
 		STRATEGY::AppendToBitStream(1, highbits + 1);
 		STRATEGY::AppendToBitStream((mappedError & ((1 << k) - 1)), k);
@@ -350,48 +352,54 @@ inlinehint void JlsCodec<TRAITS,STRATEGY>::EncodeMappedValue(LONG k, LONG mapped
 	if (limit - traits.qbpp > 31)
 	{
 		STRATEGY::AppendToBitStream(0, 31);
-		STRATEGY::AppendToBitStream(1, limit - traits.qbpp - 31);			
+		STRATEGY::AppendToBitStream(1, limit - traits.qbpp - 31);
 	}
 	else
 	{
-		STRATEGY::AppendToBitStream(1, limit - traits.qbpp);			
+		STRATEGY::AppendToBitStream(1, limit - traits.qbpp);
 	}
 	STRATEGY::AppendToBitStream((mappedError - 1) & ((1 << traits.qbpp) - 1), traits.qbpp);
 }
 
 
+// Disable the Microsoft Static Analyzer warning: Potential comparison of a constant with another constant. (false warning, triggered by template construction)
+#ifdef _PREFAST_
+#pragma warning(push)
+#pragma warning(disable:6326)
+#endif
+
 // Sets up a lookup table to "Quantize" sample difference.
 
 template<class TRAITS, class STRATEGY>
 void JlsCodec<TRAITS,STRATEGY>::InitQuantizationLUT()
 {
-	// for lossless mode with default parameters, we have precomputed te luts for bitcounts 8,10,12 and 16 
+	// for lossless mode with default parameters, we have precomputed the luts for bitcounts 8,10,12 and 16.
 	if (traits.NEAR == 0 && traits.MAXVAL == (1 << traits.bpp) - 1)
 	{
 		JlsCustomParameters presets = ComputeDefault(traits.MAXVAL, traits.NEAR);
 		if (presets.T1 == T1 && presets.T2 == T2 && presets.T3 == T3)
 		{
-			if (traits.bpp == 8) 
+			if (traits.bpp == 8)
 			{
-				_pquant = &rgquant8Ll[rgquant8Ll.size() / 2 ]; 
+				_pquant = &rgquant8Ll[rgquant8Ll.size() / 2 ];
 				return;
 			}
-			if (traits.bpp == 10) 
+			if (traits.bpp == 10)
 			{
-				_pquant = &rgquant10Ll[rgquant10Ll.size() / 2 ]; 
+				_pquant = &rgquant10Ll[rgquant10Ll.size() / 2 ];
 				return;
-			}			
-			if (traits.bpp == 12) 
+			}
+			if (traits.bpp == 12)
 			{
-				_pquant = &rgquant12Ll[rgquant12Ll.size() / 2 ]; 
+				_pquant = &rgquant12Ll[rgquant12Ll.size() / 2 ];
 				return;
-			}			
-			if (traits.bpp == 16) 
+			}
+			if (traits.bpp == 16)
 			{
-				_pquant = &rgquant16Ll[rgquant16Ll.size() / 2 ]; 
+				_pquant = &rgquant16Ll[rgquant16Ll.size() / 2 ];
 				return;
-			}			
-		}	
+			}
+		}
 	}
 
 	LONG RANGE = 1 << traits.bpp;
@@ -405,6 +413,9 @@ void JlsCodec<TRAITS,STRATEGY>::InitQuantizationLUT()
 	}
 }
 
+#ifdef _PREFAST_
+#pragma warning(pop)
+#endif
 
 template<class TRAITS, class STRATEGY>
 signed char JlsCodec<TRAITS,STRATEGY>::QuantizeGratientOrg(LONG Di)
@@ -429,20 +440,19 @@ template<class TRAITS, class STRATEGY>
 LONG JlsCodec<TRAITS,STRATEGY>::DecodeRIError(CContextRunMode& ctx)
 {
 	LONG k = ctx.GetGolomb();
-	LONG EMErrval = DecodeValue(k, traits.LIMIT - J[_RUNindex]-1, traits.qbpp);	
+	LONG EMErrval = DecodeValue(k, traits.LIMIT - J[_RUNindex]-1, traits.qbpp);
 	LONG Errval = ctx.ComputeErrVal(EMErrval + ctx._nRItype, k);
 	ctx.UpdateVariables(Errval, EMErrval);
 	return Errval;
 }
 
 
-
 template<class TRAITS, class STRATEGY>
 void JlsCodec<TRAITS,STRATEGY>::EncodeRIError(CContextRunMode& ctx, LONG Errval)
 {
 	LONG k			= ctx.GetGolomb();
 	bool map		= ctx.ComputeMap(Errval, k);
-	LONG EMErrval	= 2 * std::abs(Errval) - ctx._nRItype - map;	
+	LONG EMErrval	= 2 * std::abs(Errval) - ctx._nRItype - LONG(map);
 
 	ASSERT(Errval == ctx.ComputeErrVal(EMErrval + ctx._nRItype, k));
 	EncodeMappedValue(k, EMErrval, traits.LIMIT-J[_RUNindex]-1);
@@ -476,25 +486,23 @@ Triplet<typename TRAITS::SAMPLE> JlsCodec<TRAITS,STRATEGY>::EncodeRIPixel(Triple
 	LONG errval3	= traits.ComputeErrVal(Sign(Rb.v3 - Ra.v3) * (x.v3 - Rb.v3));
 	EncodeRIError(_contextRunmode[0], errval3);
 
-
 	return Triplet<SAMPLE>(traits.ComputeReconstructedSample(Rb.v1, errval1 * Sign(Rb.v1  - Ra.v1)),
 		traits.ComputeReconstructedSample(Rb.v2, errval2 * Sign(Rb.v2  - Ra.v2)),
 		traits.ComputeReconstructedSample(Rb.v3, errval3 * Sign(Rb.v3  - Ra.v3)));
 }
 
 
-
 template<class TRAITS, class STRATEGY>
 typename TRAITS::SAMPLE JlsCodec<TRAITS,STRATEGY>::DecodeRIPixel(LONG Ra, LONG Rb)
 {
 	if (std::abs(Ra - Rb) <= traits.NEAR)
 	{
-		LONG ErrVal		= DecodeRIError(_contextRunmode[1]);
+		LONG ErrVal = DecodeRIError(_contextRunmode[1]);
 		return static_cast<SAMPLE>(traits.ComputeReconstructedSample(Ra, ErrVal));
 	}
 	else
 	{
-		LONG ErrVal		= DecodeRIError(_contextRunmode[0]);
+		LONG ErrVal = DecodeRIError(_contextRunmode[0]);
 		return static_cast<SAMPLE>(traits.ComputeReconstructedSample(Rb, ErrVal * Sign(Rb - Ra)));
 	}
 }
@@ -563,7 +571,6 @@ LONG JlsCodec<TRAITS,STRATEGY>::DecodeRunPixels(PIXEL Ra, PIXEL* startPos, LONG
 			break;
 	}
 
-
 	if (index != cpixelMac)
 	{
 		// incomplete run 	
@@ -576,7 +583,7 @@ LONG JlsCodec<TRAITS,STRATEGY>::DecodeRunPixels(PIXEL Ra, PIXEL* startPos, LONG
 	for (LONG i = 0; i < index; ++i)
 	{
 		startPos[i] = Ra;
-	}	
+	}
 
 	return index;
 }
@@ -641,7 +648,7 @@ void JlsCodec<TRAITS,STRATEGY>::DoLine(SAMPLE*)
 	LONG Rd = _previousLine[index];
 
 	while(index < _width)
-	{	
+	{
 		LONG Ra = _currentLine[index -1];
 		LONG Rc = Rb;
 		Rb = Rd;
@@ -651,15 +658,15 @@ void JlsCodec<TRAITS,STRATEGY>::DoLine(SAMPLE*)
 
 		if (Qs != 0)
 		{
-			_currentLine[index] = DoRegular(Qs, _currentLine[index], GetPredictedValue(Ra, Rb, Rc), (STRATEGY*)(NULL));
+			_currentLine[index] = DoRegular(Qs, _currentLine[index], GetPredictedValue(Ra, Rb, Rc), static_cast<STRATEGY*>(NULL));
 			index++;
 		}
 		else
 		{
-			index += DoRunMode(index, (STRATEGY*)(NULL));
+			index += DoRunMode(index, static_cast<STRATEGY*>(NULL));
 			Rb = _previousLine[index-1];
-			Rd = _previousLine[index];	
-		}				
+			Rd = _previousLine[index];
+		}
 	}
 }
 
@@ -684,17 +691,17 @@ void JlsCodec<TRAITS,STRATEGY>::DoLine(Triplet<SAMPLE>*)
 		
 		if (Qs1 == 0 && Qs2 == 0 && Qs3 == 0)
 		{
-			index += DoRunMode(index, (STRATEGY*)(NULL));
+			index += DoRunMode(index, static_cast<STRATEGY*>(NULL));
 		}
 		else
 		{
 			Triplet<SAMPLE> Rx;
-			Rx.v1 = DoRegular(Qs1, _currentLine[index].v1, GetPredictedValue(Ra.v1, Rb.v1, Rc.v1), (STRATEGY*)(NULL));
-			Rx.v2 = DoRegular(Qs2, _currentLine[index].v2, GetPredictedValue(Ra.v2, Rb.v2, Rc.v2), (STRATEGY*)(NULL));
-			Rx.v3 = DoRegular(Qs3, _currentLine[index].v3, GetPredictedValue(Ra.v3, Rb.v3, Rc.v3), (STRATEGY*)(NULL));
+			Rx.v1 = DoRegular(Qs1, _currentLine[index].v1, GetPredictedValue(Ra.v1, Rb.v1, Rc.v1), static_cast<STRATEGY*>(NULL));
+			Rx.v2 = DoRegular(Qs2, _currentLine[index].v2, GetPredictedValue(Ra.v2, Rb.v2, Rc.v2), static_cast<STRATEGY*>(NULL));
+			Rx.v3 = DoRegular(Qs3, _currentLine[index].v3, GetPredictedValue(Ra.v3, Rb.v3, Rc.v3), static_cast<STRATEGY*>(NULL));
 			_currentLine[index] = Rx;
 			index++;
-		}	
+		}
 	}
 }
 
@@ -705,22 +712,18 @@ void JlsCodec<TRAITS,STRATEGY>::DoLine(Triplet<SAMPLE>*)
 // In ILV_NONE mode, DoScan is called for each component 
 
 template<class TRAITS, class STRATEGY>
-void JlsCodec<TRAITS,STRATEGY>::DoScan(BYTE* compressedBytes, size_t compressedLength)
-{		
-	_width = Info().width;
-
-	STRATEGY::Init(compressedBytes, compressedLength);
-
+void JlsCodec<TRAITS,STRATEGY>::DoScan()
+{
 	LONG pixelstride = _width + 4;
 	int components = Info().ilv == ILV_LINE ? Info().components : 1;
 
 	std::vector<PIXEL> vectmp(2 * components * pixelstride);
 	std::vector<LONG> rgRUNindex(components);
-	
+
 	for (LONG line = 0; line < Info().height; ++line)
 	{
-		_previousLine			= &vectmp[1];	
-		_currentLine			= &vectmp[1 + components * pixelstride];	
+		_previousLine = &vectmp[1];
+		_currentLine = &vectmp[1 + components * pixelstride];
 		if ((line & 1) == 1)
 		{
 			std::swap(_previousLine, _currentLine);
@@ -731,17 +734,17 @@ void JlsCodec<TRAITS,STRATEGY>::DoScan(BYTE* compressedBytes, size_t compressedL
 		for (int component = 0; component < components; ++component)
 		{
 			_RUNindex = rgRUNindex[component];
-		
+
 			// initialize edge pixels used for prediction
 			_previousLine[_width]	= _previousLine[_width - 1];
 			_currentLine[-1]		= _previousLine[0];
 			DoLine((PIXEL*) NULL); // dummy arg for overload resolution
-	
+
 			rgRUNindex[component] = _RUNindex;
 			_previousLine += pixelstride;
 			_currentLine += pixelstride;
 		}
-		
+
 		if (_rect.Y <= line && line < _rect.Y + _rect.Height)
 		{
 			STRATEGY::OnLineEnd(_rect.Width, _currentLine + _rect.X - (components * pixelstride), pixelstride);
@@ -755,32 +758,38 @@ void JlsCodec<TRAITS,STRATEGY>::DoScan(BYTE* compressedBytes, size_t compressedL
 // Factory function for ProcessLine objects to copy/transform unencoded pixels to/from our scanline buffers.
 
 template<class TRAITS, class STRATEGY>
-ProcessLine* JlsCodec<TRAITS,STRATEGY>::CreateProcess(void* pvoidOut)
+ProcessLine* JlsCodec<TRAITS,STRATEGY>::CreateProcess(ByteStreamInfo info)
 {
 	if (!IsInterleaved())
-		return new PostProcesSingleComponent(pvoidOut, Info(), sizeof(typename TRAITS::PIXEL));
+	{
+		return info.rawData != NULL ?
+			static_cast<ProcessLine*>(new PostProcesSingleComponent(info.rawData, Info(), sizeof(typename TRAITS::PIXEL))) :
+			static_cast<ProcessLine*>(new PostProcesSingleStream(info.rawStream, Info(), sizeof(typename TRAITS::PIXEL)));
+	}
+
+	int transform = Info().colorTransform & 0xFF;
 
-	if (Info().colorTransform == 0)
-		return new ProcessTransformed<TransformNone<typename TRAITS::SAMPLE> >(pvoidOut, Info(), TransformNone<SAMPLE>()); 
+	if (transform == 0)
+		return new ProcessTransformed<TransformNone<typename TRAITS::SAMPLE> >(info, Info(), TransformNone<SAMPLE>()); 
 
 	if (Info().bitspersample == sizeof(SAMPLE)*8)
 	{
-		switch(Info().colorTransform)
+		switch(transform)
 		{
-			case COLORXFORM_HP1 : return new ProcessTransformed<TransformHp1<SAMPLE> >(pvoidOut, Info(), TransformHp1<SAMPLE>()); break;
-			case COLORXFORM_HP2 : return new ProcessTransformed<TransformHp2<SAMPLE> >(pvoidOut, Info(), TransformHp2<SAMPLE>()); break;
-			case COLORXFORM_HP3 : return new ProcessTransformed<TransformHp3<SAMPLE> >(pvoidOut, Info(), TransformHp3<SAMPLE>()); break;
+			case COLORXFORM_HP1 : return new ProcessTransformed<TransformHp1<SAMPLE> >(info, Info(), TransformHp1<SAMPLE>());
+			case COLORXFORM_HP2 : return new ProcessTransformed<TransformHp2<SAMPLE> >(info, Info(), TransformHp2<SAMPLE>());
+			case COLORXFORM_HP3 : return new ProcessTransformed<TransformHp3<SAMPLE> >(info, Info(), TransformHp3<SAMPLE>());
 			default: throw JlsException(UnsupportedColorTransform);
 		}
-	} 
+	}
 	else if (Info().bitspersample > 8)
 	{
 		int shift = 16 - Info().bitspersample;
-		switch(Info().colorTransform)
+		switch(transform)
 		{
-			case COLORXFORM_HP1 : return new ProcessTransformed<TransformShifted<TransformHp1<USHORT> > >(pvoidOut, Info(), TransformShifted<TransformHp1<USHORT> >(shift)); break;
-			case COLORXFORM_HP2 : return new ProcessTransformed<TransformShifted<TransformHp2<USHORT> > >(pvoidOut, Info(), TransformShifted<TransformHp2<USHORT> >(shift)); break;
-			case COLORXFORM_HP3 : return new ProcessTransformed<TransformShifted<TransformHp3<USHORT> > >(pvoidOut, Info(), TransformShifted<TransformHp3<USHORT> >(shift)); break;
+			case COLORXFORM_HP1 : return new ProcessTransformed<TransformShifted<TransformHp1<USHORT> > >(info, Info(), TransformShifted<TransformHp1<USHORT> >(shift));
+			case COLORXFORM_HP2 : return new ProcessTransformed<TransformShifted<TransformHp2<USHORT> > >(info, Info(), TransformShifted<TransformHp2<USHORT> >(shift));
+			case COLORXFORM_HP3 : return new ProcessTransformed<TransformShifted<TransformHp3<USHORT> > >(info, Info(), TransformShifted<TransformHp3<USHORT> >(shift));
 			default: throw JlsException(UnsupportedColorTransform);
 		}
 	}
@@ -788,61 +797,46 @@ ProcessLine* JlsCodec<TRAITS,STRATEGY>::CreateProcess(void* pvoidOut)
 }
 
 
-
 // Setup codec for encoding and calls DoScan
 
 template<class TRAITS, class STRATEGY>
-size_t JlsCodec<TRAITS,STRATEGY>::EncodeScan(const void* rawData, void* compressedData, size_t compressedLength, void* pvoidCompare)
+size_t JlsCodec<TRAITS,STRATEGY>::EncodeScan(std::auto_ptr<ProcessLine> processLine, ByteStreamInfo* compressedData, void* pvoidCompare)
 {
-	STRATEGY::_processLine = std::auto_ptr<ProcessLine>(CreateProcess(const_cast<void*>(rawData)));
-	
-	BYTE* compressedBytes = static_cast<BYTE*>(compressedData);
+	STRATEGY::_processLine = processLine;
 
+	ByteStreamInfo info = { NULL, (BYTE*)pvoidCompare, compressedData->count };
 	if (pvoidCompare != NULL)
 	{
-		STRATEGY::_qdecoder = std::auto_ptr<DecoderStrategy>(new JlsCodec<TRAITS,DecoderStrategy>(traits, Info()));		
-		STRATEGY::_qdecoder->Init((BYTE*)pvoidCompare, compressedLength); 
+		STRATEGY::_qdecoder.reset(new JlsCodec<TRAITS,DecoderStrategy>(traits, Info()));
+		STRATEGY::_qdecoder->Init(&info);
 	}
 
-	DoScan(compressedBytes, compressedLength);
-	
-	return	STRATEGY::GetLength();
+	STRATEGY::Init(compressedData);
+
+	DoScan();
 
+	return STRATEGY::GetLength();
 }
 
 // Setup codec for decoding and calls DoScan
 
+
 template<class TRAITS, class STRATEGY>
-size_t JlsCodec<TRAITS,STRATEGY>::DecodeScan(void* rawData, const JlsRect& rect, const void* compressedData, size_t compressedLength, bool bCompare)
+void JlsCodec<TRAITS,STRATEGY>::DecodeScan(std::auto_ptr<ProcessLine> processLine, const JlsRect& rect, ByteStreamInfo* compressedData, bool bCompare)
 {
-	STRATEGY::_processLine = std::auto_ptr<ProcessLine>(CreateProcess(rawData));
+	STRATEGY::_processLine = processLine;
 
-	BYTE* compressedBytes	= const_cast<BYTE*>(static_cast<const BYTE*>(compressedData));
+	BYTE* compressedBytes	= const_cast<BYTE*>(static_cast<const BYTE*>(compressedData->rawData));
 	_bCompare = bCompare;
-
-	BYTE rgbyte[20];
-
-	size_t readBytes = 0;
-	::memcpy(rgbyte, compressedBytes, 4);
-	readBytes += 4;
-
-	size_t cbyteScanheader = rgbyte[3] - 2;
-
-	if (cbyteScanheader > sizeof(rgbyte))
-		throw JlsException(InvalidCompressedData);
-
-	::memcpy(rgbyte, compressedBytes, cbyteScanheader);
-	readBytes += cbyteScanheader;
-
 	_rect = rect;
 
-	DoScan(compressedBytes + readBytes, compressedLength - readBytes);
-	
-	return STRATEGY::GetCurBytePos() - compressedBytes;
+	STRATEGY::Init(compressedData);
+	DoScan();
+	SkipBytes(compressedData, STRATEGY::GetCurBytePos() - compressedBytes);
 }
 
-// Initialize the codec data structures. Depends on JPEG-LS parameters like T1-T3.
 
+// Initialize the codec data structures. Depends on JPEG-LS parameters like T1-T3.
 template<class TRAITS, class STRATEGY>
 void JlsCodec<TRAITS,STRATEGY>::InitParams(LONG t1, LONG t2, LONG t3, LONG nReset)
 {
diff --git a/Utilities/gdcmcharls/stdafx.cpp b/Utilities/gdcmcharls/stdafx.cpp
deleted file mode 100644
index e69de29..0000000
diff --git a/Utilities/gdcmcharls/streams.h b/Utilities/gdcmcharls/streams.h
deleted file mode 100644
index ee8dbd3..0000000
--- a/Utilities/gdcmcharls/streams.h
+++ /dev/null
@@ -1,156 +0,0 @@
-// 
-// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use. 
-// 
-#ifndef CHARLS_STREAMS
-#define CHARLS_STREAMS
-
-#include <memory>
-#include <vector>
-#include "util.h"
-
-
-
-// This file defines JPEG-LS streams: The header and the actual pixel data. Header markers have fixed length, the pixeldata not. 
-
-
-
-class JpegSegment;
-
-enum JPEGLS_ColorXForm
-{
-	// default (RGB)
-	COLORXFORM_NONE = 0,	
-
-	// Color transforms as defined by HP
-	COLORXFORM_HP1,
-	COLORXFORM_HP2,
-	COLORXFORM_HP3,
-
-	// Defined by HP but not supported by CharLS
-	COLORXFORM_RGB_AS_YUV_LOSSY,
-	COLORXFORM_MATRIX
-};
-	
-//
-// JLSOutputStream: minimal implementation to write JPEG header streams
-//
-class JLSOutputStream
-{
-	friend class JpegMarkerSegment;
-	friend class JpegImageDataSegment;
-
-public:
-	JLSOutputStream();
-	virtual ~JLSOutputStream();
-
-	void Init(Size size, LONG bitsPerSample, LONG ccomp);
-	void AddScan(const void* compareData, const JlsParameters* pparams);
-	void AddLSE(const JlsCustomParameters* pcustom);
-	void AddColorTransform(int i);
-	size_t GetBytesWritten()
-		{ return _cbyteOffset; }
-
-	size_t GetLength()
-		{ return _cbyteLength - _cbyteOffset; }
-
-	size_t Write(BYTE* pdata, size_t cbyteLength);
-	
-	void EnableCompare(bool bCompare) 
-	{ _bCompare = bCompare; }
-private:
-	BYTE* GetPos() const
-		{ return _pdata + _cbyteOffset; }
-
-	void WriteByte(BYTE val)
-	{ 
-		ASSERT(!_bCompare || _pdata[_cbyteOffset] == val);
-		
-		_pdata[_cbyteOffset++] = val; 
-	}
-
-	void WriteBytes(const std::vector<BYTE>& rgbyte)
-	{
-		for (size_t i = 0; i < rgbyte.size(); ++i)
-		{
-			WriteByte(rgbyte[i]);
-		}		
-	}
-
-	void WriteWord(USHORT val)
-	{
-		WriteByte(BYTE(val / 0x100));
-		WriteByte(BYTE(val % 0x100));
-	}
-
-
-    void Seek(size_t byteCount)
-		{ _cbyteOffset += byteCount; }
-
-	bool _bCompare;
-
-private:
-	BYTE* _pdata;
-	size_t _cbyteOffset;
-	size_t _cbyteLength;
-	LONG _icompLast;
-	std::vector<JpegSegment*> _segments;
-};
-
-
-//
-// JLSInputStream: minimal implementation to read JPEG header streams
-//
-class JLSInputStream
-{
-public:
-	JLSInputStream(const BYTE* pdata, size_t cbyteLength);
-
-	size_t GetBytesRead()
-		{ return _cbyteOffset; }
-
-	const JlsParameters& GetMetadata() const
-		{ return _info; } 
-
-	const JlsCustomParameters& GetCustomPreset() const
-	{ return _info.custom; } 
-
-	void Read(void* pvoid, size_t cbyteAvailable);
-	void ReadHeader();
-	
-	void EnableCompare(bool bCompare)
-		{ _bCompare = bCompare;	}
-
-	void SetInfo(JlsParameters* info) { _info = *info; }
-
-	void SetRect(JlsRect rect) { _rect = rect; }
-
-private:
-	void ReadPixels(void* pvoid, size_t cbyteAvailable);
-	void ReadScan(void*);	
-	void ReadStartOfScan();
-	void ReadPresetParameters();
-	void ReadComment();
-	void ReadStartOfFrame();
-	BYTE ReadByte();
-	int ReadWord();
-	void ReadNBytes(std::vector<char>& dst, int byteCount);
-
-	// JFIF
-	void ReadJfif();
-	// Color Transform Application Markers & Code Stream (HP extension)
-	void ReadColorSpace();
-	void ReadColorXForm();
-	
-private:
-	const BYTE* _pdata;
-	size_t _cbyteOffset;
-	size_t _cbyteLength;
-	bool _bCompare;
-	JlsParameters _info;
-	JlsRect _rect;
-};
-
-
-
-
-#endif
diff --git a/Utilities/gdcmcharls/util.h b/Utilities/gdcmcharls/util.h
index 892cc47..5d491cb 100644
--- a/Utilities/gdcmcharls/util.h
+++ b/Utilities/gdcmcharls/util.h
@@ -6,10 +6,10 @@
 #ifndef CHARLS_UTIL
 #define CHARLS_UTIL
 
+#include "publictypes.h"
 #include <stdlib.h>
 #include <string.h>
-#include "publictypes.h"
-
+#include <vector>
 
 #ifndef MAX
 #define MAX(a,b)            (((a) > (b)) ? (a) : (b))
@@ -20,6 +20,13 @@
 #endif
 
 
+inline void push_back(std::vector<BYTE>& vec, USHORT value)
+{
+	vec.push_back(BYTE(value / 0x100));
+	vec.push_back(BYTE(value % 0x100));
+}
+
+
 inline LONG log_2(LONG n)
 {
 	LONG x = 0;
diff --git a/Utilities/gdcmjpeg/jdcoefct.c b/Utilities/gdcmjpeg/jdcoefct.c
index 2e5ec11..db3187d 100644
--- a/Utilities/gdcmjpeg/jdcoefct.c
+++ b/Utilities/gdcmjpeg/jdcoefct.c
@@ -418,7 +418,7 @@ smoothing_ok (j_decompress_ptr cinfo)
   int * coef_bits;
   int * coef_bits_latch;
 
-  if (! cinfo->process == JPROC_PROGRESSIVE || cinfo->coef_bits == NULL)
+  if ( cinfo->process != JPROC_PROGRESSIVE || cinfo->coef_bits == NULL)
     return FALSE;
 
   /* Allocate latch area if not already done */
diff --git a/Utilities/gdcmmd5/README b/Utilities/gdcmmd5/README
deleted file mode 100644
index 5e1e40b..0000000
--- a/Utilities/gdcmmd5/README
+++ /dev/null
@@ -1,2 +0,0 @@
-md5 lib from:
-http://sourceforge.net/projects/libmd5-rfc/
diff --git a/Utilities/gdcmmd5/README.GDCM.txt b/Utilities/gdcmmd5/README.GDCM.txt
new file mode 100644
index 0000000..d7d4162
--- /dev/null
+++ b/Utilities/gdcmmd5/README.GDCM.txt
@@ -0,0 +1,12 @@
+md5 lib from:
+http://sourceforge.net/projects/libmd5-rfc/
+
+Various local modifications were made.
+
+Source:
+http://downloads.sourceforge.net/project/libmd5-rfc/libmd5-rfc/2002-04-13/md5.tar.gz
+
+SHA 256 checksum:
+81ea60e5694b61153a9ba1b8eac31cef90a922336e26a66000a55559163153f2
+
+The project seems to be dead as of 2016.
diff --git a/Utilities/gdcmopenjpeg-v1/.NoDartCoverage b/Utilities/gdcmopenjpeg-v1/.NoDartCoverage
deleted file mode 100644
index 3c99729..0000000
--- a/Utilities/gdcmopenjpeg-v1/.NoDartCoverage
+++ /dev/null
@@ -1 +0,0 @@
-# do not do coverage in this directory
diff --git a/Utilities/gdcmopenjpeg-v1/CHANGES b/Utilities/gdcmopenjpeg-v1/CHANGES
deleted file mode 100644
index 18a1c98..0000000
--- a/Utilities/gdcmopenjpeg-v1/CHANGES
+++ /dev/null
@@ -1,817 +0,0 @@
-What's New for OpenJPEG
-
-* : fixed
-- : removed
-! : changed
-+ : added
-
-January 2, 2011
-* [antonin] bug fixes to enable cmake compilation on WIN32 platform
-			- fixed getopt bug in jpwl/CMakeLists.txt
-			- added png, zlib and lcms win32 libraries to libs directory
-			- updated libs/libtiff library
-			- moved j2k_dump_{image,cp} to j2k_dump.c to remain consistent with API interface
-			- changed mj2 cmake compilation method: as long as mj2 binaries do not strictly use the API interface, libopenjpeg source files are directly included in mj2 executables compilation.
-! [antonin] small update to xcode project
-
-December 14, 2010
-! [szukw000] adapted Makefile.am/Makefile.nix to build
-             choice: shared xor static
-
-December 11, 2010
-* [antonin] fixed flags when building jp3d with MinGW
-
-December 10, 2010
-! [szukw000] changed build choice in configure.ac/Makefile.am/Makefile.nix:
-             shared xor static
-
-December 9, 2010
-! [antonin] removed LCMS dependency in jp3d/libjp3dvm/CMakeLists.txt
-! [antonin] updated xcode project
-! [antonin] renamed jp3d/libjp3dvm/openjpeg.h => jp3d/libjp3dvm/openjpeg3d.h
-- [antonin] removed "codec/compat/" directory
-* [szukw000] updated Makefile.in
-! [szukw000] removed LCMS dependencies from Makefile.am/Makefile.nix
-
-December 8, 2010 
-  (thanks to Winfried for his help)
-* [antonin] changed remaining "WIN32" to "_WIN32"
-! [antonin] libopenjpeg has no more dependency on LCMS lib. Everything concerning color (icc profile, conversion to rgb, etc) has been put outside libopenjpeg and is used in j2k_to_image.c and mj2_to_frames.c.
-- [antonin] removed 'opj_convert{.c,.h}'
-+ [antonin] added a directory 'common/' that contains 'getopt{.c,.h}' (previously in 'codec/compat').
-+ [antonin] added files 'color{.c,.h}' in 'common/' that define the code for icc profile management and sycc_to_rgb conversion
-+ [antonin] added 'common/format_defs.h' that contains common definitions used in image_to_j2k, j2k_to_image, j2k_dump.
-
-December 5, 2010
-! [antonin] revert to previous behaviour for cmake: builds (and links) dynamically by default. Static build only if -DBUILD_SHARED_LIBS is set to OFF.
-* [antonin] added a definition in getopt.h and an initial value in convert.c
-
-December 3, 2010
-* [antonin] workaround for name clash when building static and dynamic on WIN32 (see http://www.vtk.org/Bug/view.php?id=10190 for description) 
-
-November 28, 2010
-* [antonin] fixed a bug in codec/convert.c that prevented to build executables with WIN32 compiler (thanks winfried)
-! [antonin] changed cmake behaviour: executables are now always statically linked. When -DBUIL_SHARED_LIBS option is ON (the default), the shared versions of the libraries are also built (but executables remain linked against the static libraries).
-
-November 25, 2010
-* [antonin] fix compilation and DLL creation of libopenjpeg with MSYS/MinGW (from vincent.torri, see issue 47 on googlecode)
-
-November 22, 2010
-! [antonin] xcode : changed to native architecture build by default
-* [antonin] reverted 'include "../opj_config.h"' to 'include "opj_config.h"'
-
-November 17, 2010
-! [antonin] install man pages by default. install CHANGES and LICENSE
-! [antonin] minor changes in cmake files (from winfried)
-
-November 16, 2010
-! [antonin] minor changes in cmake flags
-
-November 15, 2010
-! [antonin] xcode project rewrite.
-! [antonin] changed imagetopng() function to correctly deal with non-standard bit-depths. Add png support for win32. (from winfried)
-* [antonin] minor changes in header inclusions
-* [antonin] complete rewrite of opj_convert.c with correct values (from winfried)
-
-November 11, 2010
-- [antonin] removed call to dirent.h in jp3d;
-
-October 28, 2010
-* [ben.boeckel] Set the soname and soversion on the jpwl library with CMake
-+ [ben.boeckel] Install jpwl binaries with CMake
-
-October 26, 2010
-* [ben.boeckel] Install symlinks to versioned directory headers when using CMake
-+ [ben.boeckel] Set the library version on jp3d when using CMake
-
-October 25, 2010
-* [ben.boeckel] Fix jp3d version
-
-October 24, 2010
-* [antonin] Fixed doxygen data inside source code (from winfried)
-
-October 22, 2010
-* [ben.boeckel] Don't install jp3d and libopenjpeg headers to the same place
-
-October 22, 2010
-* [ben.boeckel] Install man pages when using CMake
-
-October 22, 2010
-! [ben.boeckel] Default to building shared libraries
-
-October 22, 2010
-* [antonin] Patch to support the MSVC Win 64 builds (from szekerest)
-
-October 22, 2010
-* [antonin] Currently the Visual Studio builds are broken in the SVN. Attached a patch to fix this issue (from szekerest)
-
-October 22, 2010
-* [szukw000] replaced 'cp -d' with 'cp -P' for MacOSX
-
-October 22, 2010
-* [szukw000] 'jpwl/Makefile.am': added CFLAGS for bin_PROGRAMS
-
-October 22, 2010
-+ [szukw000] added 'libopenjpeg.pc.in'
-! [szukw000] changed 'configure.ac' to create 'libopenjpeg.pc'
-! [szukw000] changed 'Makefile.am' to [un]install 'libopenjpeg.pc'
-! [szukw000] changed 'doc/Makefile.am' : 'uninstall-hook' added
-
-October 20, 2010 
-* [antonin] fixed help display (patch from winfried)
-
-October 20, 2010 
-* [antonin] 
-    fixed paths to png and tiff in CMakeLists.txt (patch from winfried)
-    fixed link to lcms library (patch from winfried)
-
-October 18, 2010 
-* [antonin] fixed options and help display (patch from winfried) 
-
-October 18, 2010
-! [szukw000]
-	doc/Makefile.am 
-	doc/Makefile.nix
-	jp3d/Makefile.nix
-	jpwl/Makefile.nix
-	Makefile.nix
-	config.nix
-
-October 17, 2010
-! [szukw000]
-	configure.ac : 'enable_shared' YES by default
-	doc/Makefile.am :
-		'all-local' and 'install-data-hook' added
-		'with_doxygen' conditional added
-	Makefile.am : 'doc' directory no longer substituted in SUBDIRS
-
-	to link binaries statically: '-static' added to:
-		codec/Makefile.am
-		mj2/Makefile.am
-		jpwl/Makefile.am
-		jp3d/codec/Makefile.am
-
-	mj2/Makefile.am : 'with_libjpwl' removed
-	mj2/Makefile.nix : 'with_libjpwl' removed
-
-	config.nix : 'WITH_JPWL', 'WITH_JP3D' added
-	doc/Makefile.nix : 'clean', 'install', 'uninstall' added
-	Makefile.nix : 'WITH_JPWL', 'WITH_JP3D' added
-
-	INSTALL : topic 3) changed regarding the changes in 'config.nix'
-
-October 13, 2010
-! [szukw000] 
-	configure.ac
-	bootstrap.sh
-
-	'with_libjpwl' removed from:
-		libopenjpeg/Makefile.am
-		codec/Makefile.am
-		codec/Makefile.nix
-		Makefile.nix
-
-October 10, 2010
-* [antonin] Patch from winfried
-
-				1. The jp3d/libjp3dvm/Makefile.am has been changed:
-
-				Installing: /usr/local/TEST_CONFIG/include/openjpeg3d-1.3/
-				Installing: /usr/local/TEST_CONFIG/include/openjpeg3d-1.3/openjpeg3d.h
-
-				PREFIX/include:
-
-					 23  openjpeg.h -> openjpeg-1.4/openjpeg.h
-					 27  openjpeg3d.h -> openjpeg3d-1.3/openjpeg3d.h
-
-				28773  openjpeg-1.4/openjpeg.h
-				22158  openjpeg3d-1.3/openjpeg3d.h
-					
-				2. The jp3d/Makefile.nix has been changed respectivly.
-					
-				3. The mj2/Makefile.nix contained a wrong path to 'compat/'
-					
-				4. opj_config.h.in.user contained a comment within a comment.
-					
-				5. 'autoreconf' reported that AC_PROG_RANLIB is no longer
-					necessary in 'configure.ac'.
-
-October 08, 2010
-* [antonin] fixed a bug in mj2.c that prevented extract_j2k_from_mj2 to build properly. Patch from winfried.
-
-October 04, 2010
-+ [antonin] Added files to let people build openjpeg with 'configure' tools
-+ [antonin] Added makefiles to let people manually build openjpeg on *nix platforms
-- [antonin] Removed obsolete Makefiles
-! [antonin] Renamed dirent.h to windirent.h
-! [antonin] Made optional the PNG, TIFF, and LCMS support in CMake files
-+ [antonin] Added opj_config* files to configure openjpeg before building it (opj_config.h generated by 'configure', cmake, or manually by the user) 
-! [antonin] Renamed this file from ChangeLog to CHANGES
-! [antonin] Renamed 'License.txt' to 'LICENSE'
-! [antonin] Updated README files
-+ [antonin] Added INSTALL and LICENSE files
-+ [antonin] Added man pages
-
-June 22, 2010
-+ [MM] Apply patch from w. szukalski (sent to list)
-+ [MM] Also dump the image info as well as cp info.
-
-June 21, 2010
-+ [MM] Added a j2k_dump to simply dump the parameter of a J2K file
-
-May 26, 2010
-+ [antonin] Added CTestConfig.cmake to the root directory to incorporate the testing dashboard.
-+ [antonin] MACOSX : Added a "build all" target to the XCode project file.
-
-April 16, 2010
-* [antonin] MACOSX : Fixed the XCode project file to link with the PNG library. Library and header should be located in /usr/local/lib/ and /usr/local/include/, respectively. Check http://ethan.tira-thompson.org/Mac_OS_X_Ports.html if it is not the case on your mac.
-
-April 8, 2010
-* [FOD] Fixed issue 6 on google code. Variable "pi" not freed or pointed-to in function "pi_create_encode". Thanks to Kent Mein for reporting this.
-* [FOD] Fixed problem with Borland C++ Builder (Borland C do not have lrintf). Thanks Marek Mauder for this fix.
-* [FOD] Fixed pi.c bug (issue 15 on google code). Thanks to Anton Lionel for catching this.
-* [FOD] Fixed MJ2 codec bugs (issues 23-24 on google code). Thanks to Winfried for these patches
-* [FOD] Fixed JP3D codec file format analyzer. Thanks to Kristóf Ralovich for this patch.
-! [FOD] Significant optimizations of MCT, DWT, MQ and T1 modules by Peter Wimmer (thanks Peter)
-
-March 26, 2010
-+ [FOD] Added support for "jpc" codestreams which are equivalent to "j2c" codestreams. Thanks to Winfried for this patch
-* [FOD] Added support for PNG image format [Not yet functional under WIN32]. Thanks to Winfried for this patch.	See details here http://code.google.com/p/openjpeg/issues/detail?id=16
-
-March 24, 2010
-* [FOD] Code improvements using 'g++-4.4.0' to trace the code. Thanks to Winfried for this patch.		
-
-March 7, 2010
-* [FOD] Fixed small compatibility issues with win32 in codec (moved include <strings.h>)
-
-March 5, 2010
-! [FOD] Updated makefiles for v1.4 and v2.0
-+ [FOD] First import of OPJ_Validate tool
-
-February 18, 2010
-* [FOD] JP3D Module. Fixed issue when computing the number of elements in an array that leads to crash (thanks Kristof). Updated JP3D makefiles.
-
-January 20, 2010
-! [FOD] Created a new constant in openjpeg.h to differentiate the case when the colorspace is not supported by the library and when it is not specified in the codestream. Suggested by Matteo Italia.
-
-November 5, 2009
-* [antonin] fixed MCT check bug in t1_getwmsedec. See http://groups.google.com/group/openjpeg/browse_thread/thread/d9d96dd4ec3e7443 for info.
-
-November 5, 2009
-* [antonin] fixed "tiffio" header inclusion to use user version on Win32 system only (otherwise assume its existence in system headers).
-
-September 10, 2009
-* [antonin] fixed minor bugs which were triggering warnings at compilation (different signedness, wrong pointer type, etc)
-
-September 8, 2009
-* [antonin] openjpeg.c : fixed initialization of parameters->cp_disto_alloc/fixed_quality/fixed_alloc/tcp_numlayers because they were preventing to use the -q and -f options.
-
-August 31, 2009
-* [antonin] JavaOpenJpegDecoder.c : fixed a signed/unsigned behaviour when returning form C to JAVA
-
-August 21, 2008
-* [antonin] found a bug in tcd.c that was preventing to find the correct threshold in tcd_rateallocate.c for high-precision images. Applied a temporary patch but a better solution should be found.
-
-August 21, 2008
-* [antonin] fixed a bug in image_to_j2k.c that was preventing the 'r' option to work properly (everything was compressed lossless regardless of the specified rate).
-
-August 8, 2008
-! [FOD] Modified the way raw images with more that 8bpp are read and written
-
-July 9, 2008
-+ [Parvatha] Added the default lossless parameter to opj_set_default_encoder_parameters in openjpeg.c.
-
-June 12, 2008
-* [antonin] fixed a bug in dirent.h that prevented codec on Linux Alpha Systems to compile correctly. Thanks to RobinC.
-
-May 22, 2008
-* [antonin] fixed a bug in j2k.c (j2k_write_sod) that allowed to get negative rates, thanks zhong1985624 for pointing this.
-
-May 22, 2008
-* [antonin] additional test to avoid crash due to invalid image size, patch by Christopher Layne
-
-May 20, 2008
-* [antonin] memory leak fixed in openjpeg.c (opj_destroy_cstr_info()), patch by Carsten Juttner
-
-March 12, 2008
-+ [GB] help line for the -F option in j2k_to_image
-
-March 4, 2008
-! [FOD] Changed Java files copyright in JavaOpenJPEG module
-
-February 28, 2008
-* [FOD] Fixed openjpeg.c for proper initialization of codec context structures (dinfo in opj_create_compress() 
-		and opj_create_decompress(). Bug fix suggested by Andrey V. Kiselev
-* [FOD] Clean up of opj_aligned_malloc(), to just forgo the use of posix_memalign(), 
-		as apparently memalign() is what is working better for everyone. Patch by Callum.
-
-February 28, 2008
-- [FOD] Removed the J2KViewer module, which has been replaced by OPJViewer
-* [FOD] Fixed the error handling of j2k_decode in jp2.c, thanks to Robin Cornelius
-
-February 11, 2008
-* [GB] Minor style modifications to comply with c99 compiler flag; removed Microsoft-specific "union-in-struct" syntax; Re-enabled cstr_info struct creation when -W switch is specified
-! [GB] Changed a number of things in opjviewer (e.g., decoding thread does not execute GUI calls anymore), to have it running under linux --> it is better than before, but still crashes
-
-February 5, 2008
-! [Parvatha] In convert.c, corrected imagetobmp() conversion for grayscale. In tcd.c, corrected Rate modification in
-  tcd_init_encode(). Thanks to Jeremy Furtek and Jérôme Fimes.
-
-January 31, 2008
-! [GB] In opjviewer, unification of JPEG 2000 family handlers (*.jp2, *.mj2, *.j2k) in a single file
-
-January 22, 2008
-! [FOD] In image.c, changed the opj_image_create0() memory allocation from malloc() to calloc() in order
-		to avoid segfaults when freeing the memory allocated for the coding of bad images.
-		Thanks to Christopher Layne for this improvement. 
-
-January 17, 2008
-+ [antonin] Initial commit of Xcode project directory (XCode 2.5 for macosx)
-			available targets : libopenjpeg (stat and dyn), image_to_j2k, j2k_to_image
-
-January 16, 2008
-* [antonin] fixed opj_malloc.h for macosx (bugfix provided by janpeder, thanks)
-
-January 11, 2008
-+ [FOD] Added missing files to JavaOpenJPEG project (files from Patrick Piscaglia)
-
-January 4, 2008
-* [Parvatha] Patch by Callum Lerwick. Fixed bug during encoding using tile option in tcd.c
-
-----------------------
-December 21, 2007
-VERSION 1.3.0 RELEASED
-----------------------
-
-December 21, 2007
-* [FOD] Bug fixed by David Bruken. Fixed memory allocation issue in opj_malloc.h
-! [FOD] Possible errors in pi_create_encode handled
-
-December 19, 2007
-* [Antonin] changed variables names alpha, beta, gamma, delta in dwt.c to avoid re-declarations on Macosx
-! [Parvatha] In pi.c, removed the Recursive function pi_check_next_level() and modified the code.
-* [FOD] Fixed allocation problem in pi.c
-
-December 19, 2007
-+ [FOD] In mqc.h, changed MQC_NUMCTXS from 32 to 19 as there are only 19 possible contexts
-
-December 10, 2007
-+ [FOD] First import of JAVAOpenJPEG, a Java wrapper of OpenJPEG, developed by Patrick Piscaglia of Telemis (www.telemis.com). 
-		Thank you Patrick for this new module !
-
-November 29, 2007
-! [GB] Added index.h and index.c in VC6 projects; wrapped index.h in the C++ preprocessor; modified OPJViewer project and some files.
-
-November 14, 2007
-+ [FOD] Created the file index.c in the codec directory. This file handles the creation of index files, 
-		at encoding and decoding. 
-* [FOD] Fixed bugs during the creation of the index (PCRL progression order)
-* [FOD] Fixed the maximum number of resolutions a user can discard while decoding.
-		Added an error state in J2K_STATE (j2k.c)
-
-November 14, 2007
-! [FOD] - First Patch by Callum Lerwick. Instead of reinventing realloc, j2k_read_sod now just uses opj_realloc in j2k.c
-		- Second Patch by Callum Lerwick. This patch rearranges the largest memory allocations so they're allocated as 
-		late as possible, and freed as soon as possible. This cuts memory usage by about half on two large test images.
-		- Third Patch by Callum Lerwick. The opj_tcd_cblk array is one of the largest allocations, because it
-		contains a bunch of static buffers. This also makes it a major source of cache thrashing. This patch allocates 
-		the buffers from the heap, and dynamically sizes them in the decoder. I have not yet managed to dynamically size 
-		them in the encoder, getting the decoder to do it was tricky enough... I also split opj_tcd_cblk_t into separate 
-		encode and decode versions. A lot of fields were not used by both, so this cuts its size even further.
-
-* [FOD] Avoided ABI breakage
-
-November 13, 2007
-! [FOD] Patch by Dzonatas and Callum Lerwick.
-        Fp/vectorization patch which basically converts most of the irreversible decode codepath to floating point,
-        eliminating a few rounds of int/fp conversion, resulting in a vast performance improvement,
-	and an increase in accuracy.
-
-November 8, 2007
-! [FOD] In t1.c, small change to avoid calling twice t1_getwmsedec()
-        Patches from Callum Lewick:
-		- Basic gcc optimization flags in cmake and makefile match.
-		- Fixed some spelling errors in dwt.c.
-
-November 5, 2007
-*+ [GB] Fixed a bug which prevented JPWL from working on multi-tiled images; added some more fields in the interface info structures 
-(keep a list of markers, save start packet number for each tile)
-
-October 23, 2007
-* [GB] Improved success for the linux build; OPJViewer shows all the COM contents
- 
-October 18, 2007
-* [FOD] Changed the ROI parameter in the image_to_j2k codec to make it correspond to the documentation (i.e. -ROI c=0,U=25)
-* [FOD] Patch from Callum Lewick. Memset patch. 
-		The main idea of the patch is that currently opj_malloc clears all allocations, which unnecessarily
-		dirties up the cache and eats bandwidth. This patch makes it no longer do so, and I've painstakingly determined which allocations actually need
-		to be cleared and changed them to use opj_calloc() instead. I previously tried to just get rid of the opj_*alloc wrappers but that
-		idea was nixed, so this time I'm trying it with macros. I also put in a gcc pragma that helps enforce their use. Which got messy.  :)  It caught a
-		few places they weren't used but it also revealed that the mj2 tools are not very cleanly separated from the library. It includes all the
-		internal headers, but it wasn't using the malloc wrappers. I figured the binaries should be "external" and have minimal knowledge of the
-		internals of the library. I patched them to not include opj_includes.h, and include only the internal headers they actually need. However,
-		they're using the opj_clock() function, which is in with the malloc wrappers. So I decided to move the malloc wrappers to their own header. 
-		But mj2.c seems to want to be "internal", so I patched it to use the wrappers. Note that this patch changes the semantics of opj_malloc, it no longer
-		clears the memory it allocates. If you need it to be cleared, you must use opj_calloc instead, or memset it yourself. It is also somewhat
-		invasive, please test it extensively. I've been pounding on it all summer with my test suite, Second Life, and valgrind, and it checks out clean.
-
-October 12, 2007
-* [FOD] Changed the way the image structure is allocated when the decoding parameters include some resolutions to discard. 
-        This should have a significant impact for the decoding of huge images when some resolutions are discarder (-r parameter)
-        Warning: The output image size is now reduced when discarding resolutions !
-
-October 10, 2007
-* [FOD] Patch from Callum Lewick. Clean up of j2klib.h for the aligned malloc stuff. 
-        It makes it work right with mingw, as _mm_malloc() isn't a macro, attempts to pave the way to using cmake 
-        to check for this stuff and combines a patch from Dana Fagerstrom at Sun that makes it use memalign() on Solaris
-        convert.c: Changed some error comments for TIFF images
-
-September 27, 2007
-* [FOD] Patch from Callum Lewick. Fixed dwt.c where an alignment in buffer was problematic under x86_64.
-
-September 25, 2007
-* [Mathieu Malaterre] BUG: Fix previous patch from Callum Lerwick. I have no
-    clue what CMAKE_INSTALL_LIBDIR refers too. Bump up cmake 2.2 restriction to
-    cmake 2.4 because of previous patch (not backward compatible). Properly set the SOVERSION in a cross plateform way (yes WIN32 is a platform)
-
-September 19, 2007
-* [Parvatha] Fixed issues with generation of SOP marker. 
-
-September 18, 2007
-* [Parvatha] Fixed issues with Reading and Writing TIF images in convert.c to avoid segmentation fault. 
-* [Parvatha] Fixed issues relating to using user specified rates for CINEMA option for multiple images.
-
-September 17, 2007
-* [FOD] Fixed issues with cstr_info when codestream has components with different number of resolutions. 
-! [FOD] OpenJPEG library interface modified to retain compatibility with version 1.2 
-
-September 12, 2007
-* [FOD] Patch from Callum Lerwick.
-		Fixed the library linking so it links with the soversion properly set. 
-		Fixes up the install targets so that it interacts properly with RPM. 
-		Install target for MJ2. Sets some necessary and useful CFLAGS if gcc is in use.		
-* [FOD] Updated the MJ2 codec to be compatible with the recent changes in the OpenJPEG library
-
-September 11, 2007
-* [GB] JPWL encoding is finalized correctly into the JP2 file format; added an additional structure in opj_codestream_info, to keep a record of the written markers
-
-September 8, 2007
-* [GB] Adapted the JPWL and OPJViewer code to new interface; fixed a samll bug in JPWL which created large EPBs even when null protection was specified
-
-September 7, 2007
-+ [FOD] Indexes can now be generated when decoding J2K codestreams.
-* [Mathieu Malaterre] Upon failure, properly return error code (!=0).
-* [Mathieu Malaterre] CMake: Add cmake code to do testing if user has properly setup a testimages directory
-
-September 6, 2007
-+ [Mathieu Malaterre] CMake: start compiling mj2, jpwl and jp3d
-+ [Mathieu Malaterre] CMake: output all executable/libs into one single directory
-+ [Mathieu Malaterre] CMake: start compiling index_create
-+ [Mathieu Malaterre] OpenJPEG.rc update copyright year
-+ [Mathieu Malaterre] CMake: add Java j2kviewer but do not compile it using cmake since cmake has too poor support for Java. Should create a custom command running ant instead.
-+ [Mathieu Malaterre] CMake: Add doxygen output
-+ [GB] One more field in the codestream_info struct for recording the number of packets per tile part; JPWL now distributes the EPBs in all the tile part headers
-+ [Mathieu Malaterre] CMake: Add very simple tests (simply run command line with no option)
-* [Mathieu Malaterre] Fix unitialized read in img_fol (we may need a smarter initialize than memset)
-
-September 4, 2007
-+ [GB] Added some fields in the codestream_info structure: they are used to record the position of single tile parts. 
-		Changed also the write_index function in the codec, to reflect the presence of this new information.
-
-September 3, 2007
-+ [GB] Added the knowledge of JPSEC SEC and INSEC markers (you have to compile the JPWL project). Management of these markers is limited to skipping them without crashing: 
-		no real security function at this stage. Deprecated USE_JPSEC will be removed next
-
-August 31, 2007
-* [GB] Fixed save capabilities in OPJViewer due to recent code upgrade
-
-August 30, 2007
-* [FOD] Changed the OpenJPEG library interface to enable users to access information regarding the codestream (also called codestream index).
-		This index is usefull for all applications requiring to have a scalable acces to the codestream (like JPIP applications, ...)
-        Currently, this information is only available when encoding an image.       
-+ [FOD] Added the information regarding the end of packet position in the index        
-
-August 28, 2007
-* [FOD] Fixed wrong destructors called in openjpeg.c
-* [FOD] Fixed bug in j2k_decode_jpt_stream
-
-August 24, 2007
-* [Parvatha] The end of main header is calculated after TLM and POC marker for Dcinema.
-
-August 21, 2007
-+ [FOD] Added support for Visual Studio 2005
-* [FOD] Robustified MJ2 codecs
-* [Parvatha] Solved problems with codec reading from image file directory when filename had more than one "." in name
-* [Callum Lerwick] Minor cleanup patch, that gets rid of a bunch of "old style declaration" warnings from Intel's compiler
-* [Callum Lerwick] Aligned malloc using Intel's _mm_malloc(). Cleanup on the t1 memory allocation, getting rid of some leftover debug code
-* [Callum Lerwick] Memory leaks fixed
-* [Callum Lerwick] Reworks of t1_updateflags to get rid of the shift operation
-* [Callum Lerwick] mqc_setcurctx moved to the header to allow it to be inlined into the t1.
-* [Callum Lerwick] Consolidated some calls to mqc_setcurctx.
-* [Callum Lerwick] Cleaned up t1_generate_luts to output the proper types.
-* [Callum Lerwick] Replaced the large ctxno_mag lookup table with a small bit of inline-able branchless code
-* [Callum Lerwick] Moved the orient flipping into the ctxno_zc table.
-
-August 20, 2007
-+ [FOD] Added support for the TGA file format in the codec
-
-August 08, 2007
-* [Parvatha] Fixed the DCinema filesize allocation. It now includes the SOT marker size
-
-August 02, 2007
-+ [GB] Added a basic saving capability to OPJViewer
-
-July 18, 2007
-! [FOD] Updated libtiff library version to 3.8.2 (for WIN32)
-* [FOD] Updated BMP and PxM truncation when decoding J2K files with more than 8 bits
-
-July 17, 2007
-* [FOD] Fixed raw option for images with more than three components
-
-July 17, 2007
-+ [FOD] Added support for RAW images. This module has been developped by the University of Perugia team. Thanks to them ! [image_to_j2k.c j2k_to_image.c convert.c convert.h]
-
-July 13, 2007
-! [FOD] Modified the memory allocation for codestreams containing multiple tiles. The memory is now allocated for each tile indenpendently, 
-		leading to an important decrease of the virtual memory needed. [j2k.c tcd.h tcd.c]
-! [FOD] Modified old comments about the ability to decode mega-images and comments about the disk size necessary to do this. [image_to_j2k.c and frames_to_mj2.c]
-* [FOD] Added 2000 bytes for the memory allocation in cio.c for the minimum size of headers (useful in case of very small images) [cio.c]
-
-July 12, 2007
-* [GB] fixed a bug in JPWL module, which prevented to exploit the full error correction capability of RS codes (e.g. it gave up at 5 errors, 
-		even if 6 were correctable); defined a JPWL_MAXIMUM_EPB_ROOM for better customization of the maximum dimension of EPBs (the dimension 
-		is pre-calculated on an hypothesis, if it goes beyond 65535 there will be problems, thus we give a little less than the max, let's say 65450)
-
-July 8, 2007
-* [ANTONIN] fixed the size of the memory allocation in cio.c (confusion between bits and bytes)
-
-June 21, 2007
-* [FOD] Output image color space set when decoding a JP2 file in jp2.c
-+ [GB] Previous, home, and next frame buttons for exploring MJ2 files in OPJViewer
-
-June 18, 2007
-* [GB] Reload image doesn't crash in OPJViewer; more settings saved to registry
- 
-June 16, 2007
-+ [GB] Possibility to disable parsing in OPJViewer; also, saves common settings to the registry
-
-June 15, 2007
-* [FOD] Fixed the generation of index files 
-
-
-----------------------
-MAY 4, 2007
-VERSION 1.2.0 RELEASED
-----------------------
-
-May 4, 2007
-* [FOD] Bugs corrected in decoding of command line (getopt.c), in the handling of 16 bit files (t1.c and tcd.c) and the calculation of elapsed time for multiple tiles parts (tcd.c and tdc.h).
-
-June 2, 2007
-+ [GB] OPJViewer opens now BMP, PNG, GIF, PNM, TIFF (with wxWidgets internals); added an encoder settings tab, for future integration with "save file as..." in JPEG 2000 format
-
-May 31, 2007
-* [FOD] Fixed the handling of 16bit TIFF files for cinema compression. Modified "convert.c"
-* [FOD] Fixed the parameters used for cinema compression (9-7 transform used instead of 5-3). Modified "image_to_j2k.c"
-
-May 24, 2007
-* [FOD] Bug fixed by Sylvain Munaut. Change in the reading of the POC marker. Since COD/COC can be anywhere in the header, the decoder cannot always know while decoding the POC marker 
-		the value of numlayers and numresolution.
-
-May 23, 2007
-! [FOD] Patch suggested by Callum Lerwick <seg at haxxed.com>: "This makes the t1 data arrays dynamic, which greatly reduces cache thrashing. Also, some minor cleanup to prevent unnecessary casts"
-
-May 22, 2007
-! [FOD] Patch suggested by Callum Lerwick <seg at haxxed.com>: "Some formatting cleanups, 
-		so that the long function definitions and calls fit on screen. Use of prefix increment which is theoretically faster, in practice any sane compiler can optimize a postfix 
-		increment but its best not to count on such things. Consolidation of some redundant calculations in the inner loops, which becomes very useful in the future autovectorize patch."
-! [FOD] Patch suggested by Callum Lerwick <seg at haxxed.com>: "This changes the flag code in t1 to use a flag_t type, which can then be changed to reduce RAM usage. It is now typedef to a short."
-! [FOD] Patch suggested by Callum Lerwick <seg at haxxed.com>: "This patch makes the t1 LUTs static. I actually intend this as a prelude to possibly eliminating some or all of the LUTs entirely."
-
-May 11, 2007
-- [FOD]	JP3D library Binaries removed from SVN.
-! [FOD] MJ2 codec updated from LibOpenJPEG version 0.97 to LibOpenJPEG version 1. Hence, the MJ2 codec will now take advantage of all the improvements and optimizations done on the LibOpenJPEG library.
-! [FOD] Possibility to choose to apply MCT (multiple component transform) enabled, and new decoding_limit: DECODE_ALL_BUT_PACKETS (openjpeg.h)
-
-April 26, 2007
-+ [gdcm] Add basic steps on how to use CMake for building examples (README.cmake)
-
-April 25, 2007
-+ [FOD] Modification of the openjpeg.h file to avoid and ABI break with v1.1, removed the dangerous #IFDEF JPWL and added tcp_mct in cparameters.
-
-April 23, 2007
-+ [GB] Enable/disable image decoding in OPJViewer
-
-April 12,2007
-* [Parvatha] Fixed Error in tiftoimage(). Modification in convert.c.
-
-April 10,2007
-+ [Parvatha] Accepting "j2c"  as format for Encoding and Decoding. Modification in image_to_j2k.c.
-* [Parvatha] Modified imagetotif() to read images with signed data. Modification in convert.c.
-
-April 5, 2007
-! [FOD] fix.h optimized. Thanks a lot to Dzonatas <dzonatas at dzonux.net> !
-! [FOD] dwt.c optimized. Thanks a lot to Dzonatas <dzonatas at dzonux.net> !
-! [FOD] t1.c optimized. Thanks a lot to Callum Lerwick <seg at haxxed.com>  !
-
-April 4,2007
-+ [Parvatha] Digital cinema compliance for 4K chosen by "-cinema4K" option. Modification in image_to_j2k.c.
-+ [Parvatha] Bit rate limitation for each color component. Modification in image_to_j2k.c, t2.c.
-* [Parvatha] Modified and tested Progression order change "-POC" option. Modification in image_to_j2k.c, j2k.c, pi.c.
-+ [Parvatha] Function j2k_check_poc_val() to check for possible loss of packets in case of wrong POC declaration. Modification in j2k.c.
-+ [Parvatha] Structure T2_MODE. This tells if the t2_encode_packets() is called during Threshold calculation or in Final pass. Modification in j2k.h, tcd.c
-
-March 30, 2007
-* [GB] OPJViewer should now work under Linux, at least with not big j2k files. Tested under Suse 10.1 64 bit.
-
-March 29, 2007
-* [Parvatha] Enable accepting file names with `-´ symbol .Modification getopt.c
-* [Parvatha] Rsiz profile name generation to be STD_RSIZ for profiles which are not DCI compliant.Modification in image_to_j2k.c
-! [Parvatha] renamed convert_progression_order to j2k_convert_progression_order. Modification j2k.c
-* [Parvatha] Calculation of number of tile part in each tile in j2k_calculate_tp. Modification j2k.c
-! [Parvatha] j2k_setup_encoder to set bit rate limitation for digital cinema compliance with quality option. Modification in j2k.c
-* [Parvatha] Equation to check multiple tile precincts. Modification pi.c
-! [Parvatha] array size generation of pi->include in pi_initialise_encode().Modification in pi.c
-* [Parvatha] modification in pi_create_encode for tile part generation.Modification in pi.c
-+ [Parvatha] In tcd_rateallocate a variable stable_threshold which holds the valid threshold value. 
-			 This is used to avoid error in case of a wrong threshold value in the last iteration. Modification in tcd.c.
-
-March 28, 2007
-* [FOD] Fixed an historical bug in t1.c that leaded to the inclusion of useless 0xFF in the codestream. Thanks to Sylvain, Pascal and Parvatha !
-
-March 27, 2007
-+ [GB] Improved parsing in OPJViewer, as well some minor aesthetic modifications; support for image rendering with bit depths lower than 8 bits; 
-		can display an arbitrary frame of an MJ2 file (only in B/W, though); can reload a file; better resizing capabilities
-* [GB] Following to Hervé's suggestions, all the exit() calls, added by JPWL strict checking in t2.c and j2k.c, 
-		have been substituted with (object free'ing + opj_evt_message(EVT_ERROR) + return)
-+ [GB] Added linking to TIFF library in the JPWL VC6 workspaces
-
-March 23, 2007
-* [antonin] Fixed Makefile.osx and changed Readme.osx accordingly
-
-March 21, 2007
-* [Parvatha] Fixed j2k_prog_order_list[]. Modifications in j2k.c.
-* [Parvatha] Fixed t1_decode_cblks. Modifications in t1.c.
-
-March 20, 2007
-+ [Parvatha] Added feature for generation of tile parts. Modifications in image_to_j2k.c, openjpeg.c, j2k.c, pi.c
-+ [Parvatha] Added function j2k_write_tlm(),to generate TLM marker for a Digital cinema compliant codestream. Modifications in j2k.c.
-
-March 14, 2007
-* [FOD] Fixed linux makefile, with help from David Fries and Guido
-
-March 7, 2007
-+ [Parvatha] Added option for Digital cinema profile compliant codestream. This can be chosen by "-cinema2K" or "-cinema4K" for a 2K and 4K compliance respectively. The feature for tileparts has not been implemented in this version. Modification in image_to_j2k.c
-+ [Parvatha] Added the Digital Cinema profiles (CINEMA2K and CINEMA4K) to the list of profiles recognized in the codestream SIZ marker segment. Modification in openjpeg.h,j2k.c
-+ [Parvatha] Added feature for constant quality within bitrate defined in Digital cinema standards. Modification in tcd.c
-! [Parvatha] Modified the method of generation of buffer length. Modification in cio.c
- 
-
-March 1, 2007
-* [FOD] Modified codec projects (*.dsp) and makefile to include the tiff library (modified codec/image_to_j2k.dsp codec/j2k_to_image.dsp and codec/makefile)
-+ [GB] Zoom capability and decoder settings dialog in OPJViewer; modified JPWL library .dsp project in order to create a library with embedded JPWL functions
-
-February 28, 2007
-+ [Parvatha] Enabled compression of TIF image format to j2k by tifftoimage() and decompression of codestream to TIF image format using imagetotif(). Modifications in image_to_j2k.c, j2k_to_image.c, convert.c, convert.h
-* [antonin] fixed a bug in context numerotation that prevented the RESET switch to work correctly : mqc_reset_enc in mqc.c
-* [Fod] Corrected codec Makefile by adding the compilation of "compat/getopt.c" 
-
-February 27, 2007
-* [Parvatha] Made get_file_format function more robust. Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
-
-February 26, 2007
-+ [Parvatha] Option to read images from a Folder whose path is specified in the Input parameters by "-ImgDir" along with output decod format specified by "-OutFor" . Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
-+ [Parvatha] Enabling use of multi character input parameters in the codec. Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
-
-----------------------
-February 23, 2007
-VERSION 1.1.1 RELEASED
-----------------------
-
-February 23, 2007
-* [GB] Fixed a copy-and-paste type assignment error (bool instead of int) in the JPWL section of decoder parameters structure in openjpeg.h; minor type-casting in jpwl_lib.c. 
-		As a result, now OPJViewer should run correctly when built against the most current SVN trunk of LibOpenJPEG.lib
-+ [GB] Linux makefile for the JPWL module; newlines at end of JPWL files
-
-February 22, 2007
-+ [FOD] Added the OPJViewer Module (/OPJViewer), developed by Giuseppe Baruffa of the university of Perugia
-
-February 21, 2007
-+ [FOD] Algorithmic optimizations in t1.c, thanks to Guido J. !
-
-February 19, 2007
-+ [FOD] Added OPJ_LIMIT_DECODING enabling us to limit the decoding to main header (modified openjpeg.c, openjpeg.h, j2k.c and j2k.h)
-
-February 13, 2007
-! [FOD] David Fries suggestions. In image_to_j2k and j2k_to_image, strncpy() functions: instead of specifying the path size macro, let the compiler read the length out of the array entry.
-! [FOD] David Fries suggestions. Makefile modified. -fPIC flag used for 64-bit compilation. Move operation (rather than copy) for the dist library creation, and -p flag added.
-
-January 31, 2007
-! [FOD] Extra tokens at the end of #endif directive corrected in openjpeg.c, j2k.c and image_to_j2k.c -> no more warnings in linux compilation
-! [FOD] Linux Makefile added for the codec
-
-January 30, 2007
-! [FOD] Use of OPJ_PATH_LEN (defined as 4096) to be the maximum allowed size for filenames instead of MAX_PATH which is not always defined. This caused some programs using OpenJPEG to crash. Modifications in openjpeg.h j2k_to_image.c and image_to_j2k.c
-! [FOD] Correction of the syntax usage in MJ2_codec/mj2_to_frames.c
-
-January 23, 2007
-! [FOD] Modification in the context numbers, to reflect what has been specified in standard, in libopenjpeg/t1.h
-
-December 07, 2006
-+ [Giuseppe Baruffa] Antonin verified that the MacOS build suffered from a missing definition of the "min" macro; I've added this definition (properly #ifndef'ed) into both jpwl.h and rs.h
-
-December 05, 2006
-* [Giuseppe Baruffa] Better fix of the TPH EPBs bug in JPWL module
-* [GB] Fixed the UEP bug in JPWL module; now, during a UEP specification, RS protection or CRC check can be switched off for selected range of packets, and consequently reswitched on without confusing the decoder
-+ [GB] Added some lines in the help of JPWL_image_to_j2k, specifying that when using error protection on data packets, this must be paired with header protection, i.e. there cannot be packet protection without header protection
-
-December 04, 2006
-
-+ [Francois-Olivier Devaux] New tag: version1.0 (includes codec and libopenjpeg directories)
-Total update of JPWL module
-    - [FOD] removed directories jpwl/decoder, jpwl/encoder, jpwl/decoder_02, jpwl/encoder_02
-    + [FOD] added in JPWL directory crc.h, jpwl.h, rs.h, crc.c, jpwl.c, jpwl_lib.c, rs.c, JPWL_image_to_j2k.dsp, JPWL_j2k_to_image.dsp, LibOpenJPEG_JPWL.dsp, JPWL_image_to_j2k.dsw, JPWL_j2k_to_image.dsw
-    ! [FOD] Modifications of libopenjpeg to integrate JPWL module (in libopenjpeg directory): j2k.c, j2k.h, openjpeg.c, openjpeg.h, opj_includes.g, t2.c
-    ! [FOD] Modification of codec to integrate JPWL module (in codec directory): image_to_j2k.c, j2k_to_image.c
-* [FOD] Corrected incorrect fprintf() formatting in codec/convert.c
-* [FOD] Code optimization usinq vsprintf() command in libopenjpeg/event.c
-* [Giuseppe Baruffa] Fixed a bug in TPH EPBs parameters: now, "last in current header" information is correctly signaled
-
-October 31, 2006
-* [Antonin] fixed a bug in the computation of the mantissa (mu)
-+ [Antonin] added the ability to specify the rate as "float" (before : integer)
-
-August 18, 2006
-* [Antonin] fixed a bug in j2k_to_image.c, that prevented the -l option to work correctly.
-
-August 4, 2006
-* [Antonin] fixed a bug in pi.c, line 473, that appeared when more than 100 precincts were generated in a resolution level.
-
-July 28, 2006
-+ [Antonin Descampe] added a readme in /mj2 to warn people that it only works with opj0.97
-
-July 21, 2006
-* [Mathieu Malaterre] Install exe and lib and include correctly
-* [Mathieu Malaterre] Fixed mem leaks and greyscale bmp
-* [Mathieu Malaterre] Fix pgx name length + random memory access
-! [Mathieu Malaterre] API is now const
-
-March 19, 2006
-* [Antonin] fixed a bug in t1.c that prevented in some cases a true lossless compression (thanks to Don Mimlitch for reporting this bug)
-
-February 12, 2006
-- [Herve Drolon] removed unneeded working variables in opj_tcd_t
-
-February 04, 2006
-* [galt] fixed a bug in codec/convert.c::imagetobmp
-
-February 01, 2006
-! [Herve Drolon] changed function definitions of INT and FIX modules to 'inline'
-+ [Herve Drolon] added a VERSION resource to the DLL version of OpenJPEG
-
-January 31, 2006
-* [Mathieu Malaterre] Fix compilation using default openjpeg.dsw
-* [Herve Drolon] fixed various minor warnings occuring under icc9 and bcc32
-- [Mathieu Malaterre] Remove all references to OPJ_EXPORT, no declspec in header file anymore
-+ [Mathieu Malaterre] Add a def.in file which is a template for Module Definition
-+ [Herve Drolon] added MSVC project and compiler directives to build a 'standard' WIN32 DLL
-! [Mathieu Malaterre] Update CMake to match the new shared lib system (no more def file)
-
-January 27, 2006
-* [Antonin Descampe] fixed a two initialization problems in t1.c and tcd.c
-
-January 26, 2006
-* [Herve Drolon] fixed various minor warnings occuring under gcc
-* [__david__] fixed a segfault in codec/image_to_j2k.c & codec/j2k_to_image.c
-* [__david__] fixed help option in codec/j2k_to_image & codec/image_to_j2k
-
-January 25, 2006
-! [Mathieu Malaterre] Sync with ITK repository, also add ref to doxygen
-! [Mathieu Malaterre] Add a lot of comments on the CMake build system
-! [Mathieu Malaterre] Fix MINGW32 and BORLAND compilation problems.
-
-January 25, 2006
-* [Antonin Descampe] fixed a problem in convert.c when multiple comments
-+ [Antonin Descampe] added cmake files to the project
-! [Antonin Descampe] fix.c : replaced "WIN32" by "_MSC_VER" for int64
-+ [Antonin Descampe] added "OPJ_EXPORT" in openjpeg.h to generate shared lib with win32
-! [Antonin Descampe] removed all CtrlM from files
-
-January 24, 2006
-! [Antonin Descampe] event.c : replaced "WIN32" by "_MSC_VER" for i2a
-
-January 20, 2006
-* [Antonin Descampe] fixed various minor warnings with gdcm patches
-
-January 19, 2006
-* [Herve Drolon] fixed a bug in jp2_read_ihdr (need to allocate jp2->comps)
-
-January 18, 2006
-* [Herve Drolon] changed the name of j2k_realloc to opj_realloc
-* [Herve Drolon] fixed a bug in opj_cio_open when saving 48-bit images (wrong buffer size calculation)
-
-December 8, 2005
-* [Antonin Descampe] fixed a bug when specifying a rate '-r' => no distortion info was available in the index
-* [Antonin Descampe] fixed a bug in t1_getwmsedec (stepsize was divided by 8192)
-
-December 5, 2005 - 1.1.0
diff --git a/Utilities/gdcmopenjpeg-v1/CMake/CTestCustom.cmake.in b/Utilities/gdcmopenjpeg-v1/CMake/CTestCustom.cmake.in
deleted file mode 100644
index 9aaafcc..0000000
--- a/Utilities/gdcmopenjpeg-v1/CMake/CTestCustom.cmake.in
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# For further details regarding this file, 
-# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
-#
-
-set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS   50)
-set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 50)
-
-set(CTEST_CUSTOM_COVERAGE_EXCLUDE
- ${CTEST_CUSTOM_COVERAGE_EXCLUDE}
-
- # Exclude files from the Testing directories
- ".*/Testing/.*"
- )
-
-set(CTEST_CUSTOM_WARNING_EXCEPTION
-  ${CTEST_CUSTOM_WARNING_EXCEPTION}
-  
-  # Suppress warning caused by intentional messages about deprecation
-  ".*warning,.* is deprecated"
-)
diff --git a/Utilities/gdcmopenjpeg-v1/CMake/CheckHaveGetopt.cmake b/Utilities/gdcmopenjpeg-v1/CMake/CheckHaveGetopt.cmake
deleted file mode 100644
index 61fca03..0000000
--- a/Utilities/gdcmopenjpeg-v1/CMake/CheckHaveGetopt.cmake
+++ /dev/null
@@ -1,15 +0,0 @@
-# Check if getopt is present:
-include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-set(DONT_HAVE_GETOPT 1)
-if(UNIX) #I am pretty sure only *nix sys have this anyway
-  CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
-  # Seems like we need the contrary:
-  if(CMAKE_HAVE_GETOPT_H)
-    set(DONT_HAVE_GETOPT 0)
-  endif()
-endif()
-
-if(DONT_HAVE_GETOPT)
-  add_definitions(-DDONT_HAVE_GETOPT)
-endif()
-
diff --git a/Utilities/gdcmopenjpeg-v1/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/CMakeLists.txt
deleted file mode 100644
index 13fd741..0000000
--- a/Utilities/gdcmopenjpeg-v1/CMakeLists.txt
+++ /dev/null
@@ -1,387 +0,0 @@
-# Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
-# Written by Mathieu Malaterre
-
-# This CMake project will by default create a library called openjpeg
-# But if you want to use this project within your own (CMake) project
-# you will eventually like to prefix the library to avoid linking confusion
-# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
-# e.g.:
-# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
-cmake_minimum_required(VERSION 2.8.7)
-if(POLICY CMP0022)
-  cmake_policy(SET CMP0022 OLD)
-endif()
-
-if(NOT OPENJPEG_NAMESPACE)
-  set(OPENJPEG_NAMESPACE "OPENJPEG")
-  set(OPENJPEG_STANDALONE 1)
-endif()
-# In all cases:
-string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
-
-project(${OPENJPEG_NAMESPACE} C)
-
-# Do full dependency headers.
-include_regular_expression("^.*$")
-
-#-----------------------------------------------------------------------------
-# OPENJPEG version number, useful for packaging and doxygen doc:
-set(OPENJPEG_VERSION_MAJOR 1)
-set(OPENJPEG_VERSION_MINOR 4)
-set(OPENJPEG_VERSION_BUILD 0)
-set(OPENJPEG_VERSION
-  "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
-set(PACKAGE_VERSION
-  "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
-# This setting of SOVERSION assumes that any API change
-# will increment either the minor or major version number of openjpeg
-set(OPENJPEG_LIBRARY_PROPERTIES
-  VERSION   "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
-  SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
-)
-# You will also need to define a value for the following variables:
-# OPENJPEG_INSTALL_BIN_DIR          - binary dir (executables)
-# OPENJPEG_INSTALL_LIB_DIR          - library dir (libs)
-# OPENJPEG_INSTALL_DATA_DIR         - share dir (say, examples, data, etc)
-# OPENJPEG_INSTALL_INCLUDE_DIR      - include dir (headers)
-
-
-# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
-# warnings
-if(WIN32)
-  if(NOT BORLAND)
-    if(NOT CYGWIN)
-      if(NOT MINGW)
-        if(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
-          add_definitions(
-            -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
-            -D_CRT_IS_WCTYPE_NO_DEPRECATE
-            -D_CRT_MANAGED_FP_NO_DEPRECATE
-            -D_CRT_NONSTDC_NO_DEPRECATE
-            -D_CRT_SECURE_NO_DEPRECATE
-            -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
-            -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
-            -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
-            -D_CRT_VCCLRIT_NO_DEPRECATE
-            -D_SCL_SECURE_NO_DEPRECATE
-            )
-        endif()
-      endif()
-    endif()
-  endif()
-endif()
-
-
-# --------------------------------------------------------------------------
-# Install directories
-
-string(TOLOWER ${PROJECT_NAME} projectname)
-set(subdir "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
-
-if(NOT OPENJPEG_INSTALL_BIN_DIR)
-  set(OPENJPEG_INSTALL_BIN_DIR "bin")
-endif()
-
-if(NOT OPENJPEG_INSTALL_LIB_DIR)
-  set(OPENJPEG_INSTALL_LIB_DIR "lib")
-endif()
-
-if(NOT OPENJPEG_INSTALL_DATA_DIR)
-  set(OPENJPEG_INSTALL_DATA_DIR "share/${subdir}")
-endif()
-
-if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
-  set(OPENJPEG_INSTALL_INCLUDE_DIR "include/")
-endif()
-
-if(NOT OPENJPEG_INSTALL_MAN_DIR)
-  set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
-endif()
-
-if(NOT OPENJPEG_INSTALL_DOC_DIR)
-  set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${subdir}")
-endif()
-
-if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
-  set(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${subdir}
-    CACHE INTERNAL "")
-endif()
-
-#-----------------------------------------------------------------------------
-# Test for some required system information.
-include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
-
-#-----------------------------------------------------------------------------
-# Test for getopt being available in this system
-include (${PROJECT_SOURCE_DIR}/CMake/CheckHaveGetopt.cmake )
-
-#-----------------------------------------------------------------------------
-# Setup file for setting custom ctest vars
-configure_file(
-  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CTestCustom.cmake.in
-  ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
-  @ONLY
-  )
-
-#-----------------------------------------------------------------------------
-# OpenJPEG build configuration options.
-#option(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
-
-#-----------------------------------------------------------------------------
-
-
-# configure name mangling to allow multiple libraries to coexist
-# peacefully
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
-set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
-               ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
-               @ONLY)
-endif()
-
-if(NOT OPENJPEG_INSTALL_NO_DEVELOPMENT)
-  install(FILES
-      ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
-    DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
-  )
-endif()
-
-#-----------------------------------------------------------------------------
-# Always build the library
-include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-subdirs(libopenjpeg)
-
-#-----------------------------------------------------------------------------
-# Build CODEC executables ?
-#option(OPJ_BUILD_CODEC "Build the CODEC executables" OFF)
-if(OPJ_BUILD_CODEC)
-  subdirs(codec)
-endif()
-
-#-----------------------------------------------------------------------------
-# Build MJ2 executables ?
-#option(BUILD_MJ2 "Build the MJ2 executables." OFF)
-if(BUILD_MJ2)
-  subdirs(mj2)
-endif()
-
-#-----------------------------------------------------------------------------
-# Build JPWL executables ?
-#option(BUILD_JPWL "Build the JPWL executables" OFF)
-if(BUILD_JPWL)
-  subdirs(jpwl)
-endif()
-
-#-----------------------------------------------------------------------------
-# Build JP3D executables ?
-#option(BUILD_JP3D "Build the JP3D executables" OFF)
-if(BUILD_JP3D)
-  subdirs(jp3d)
-endif()
-
-#-----------------------------------------------------------------------------
-# Build INDEXER_JPIP executables ?
-#option(BUILD_INDEXER_JPIP "Build the INDEXER_JPIP executables" OFF)
-if(BUILD_INDEXER_JPIP AND NOT UNIX)
-  subdirs(indexer_JPIP)
-endif()
-
-#-----------------------------------------------------------------------------
-# Build DOCUMENTATION ?
-#option(BUILD_DOC "Build the doxygen documentation" OFF)
-if(BUILD_DOC)
-  subdirs(doc)
-endif()
-
-#-----------------------------------------------------------------------------
-# For openjpeg team if they ever want CDash+CMake
-option(BUILD_TESTING "Build the tests." OFF)
-if(BUILD_TESTING)
-  enable_testing()
-  include(CTest)
-endif()
-
-# Adding test with dataset from:
-# http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
-# -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
-# http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
-#-----------------------------------------------------------------------------
-# Adding JPEG2000_CONFORMANCE_DATA_ROOT
-find_path(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
-  ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
-  $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
-)
-mark_as_advanced(JPEG2000_CONFORMANCE_DATA_ROOT)
-
-#-----------------------------------------------------------------------------
-# Compiler specific flags:
-if(CMAKE_COMPILER_IS_GNUCC)
-  # For all builds, make sure openjpeg is std99 compliant:
-  # set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
-  # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
-  #set(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
-endif()
-
-# install CHANGES and LICENSE
-#install(
-#  FILES       CHANGES
-#              LICENSE
-#  DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
-#
-#if(UNIX OR CYGWIN)
-#  set(CMAKE_INCLUDE_PATH /usr/include /usr/local/include /opt/include
-#	/opt/local/include /usr/include/libpng /usr/include/libpng14
-#	/usr/include/libpng12 /usr/local/include/libpng
-#	/usr/local/include/libpng14 /usr/local/include/libpng12
-#	/opt/include/libpng /opt/include/libpng14 /opt/include/libpng12
-#	/opt/local/include/libpng /opt/local/include/libpng14
-#	/opt/local/include/libpng12 )
-#  set(CMAKE_LIBRARY_PATH /usr/lib /usr/local/lib /opt/lib /opt/local/lib)
-#elseif(WIN32)
-#  set(CMAKE_INCLUDE_PATH ${OPENJPEG_SOURCE_DIR}/libs/libtiff
-#	${OPENJPEG_SOURCE_DIR}/libs/png ${OPENJPEG_SOURCE_DIR}/libs/lcms2
-#	C:/WINDOWS/system32/user )
-#  set(CMAKE_LIBRARY_PATH ${OPENJPEG_SOURCE_DIR}/libs/libtiff
-#        ${OPENJPEG_SOURCE_DIR}/libs/png ${OPENJPEG_SOURCE_DIR}/libs/lcms2
-#	C:/WINDOWS/system32/user )
-#endif()
-#
-include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-CHECK_INCLUDE_FILE("strings.h"       HAVE_STRINGS_H)
-CHECK_INCLUDE_FILE("inttypes.h"      HAVE_INTTYPES_H)
-CHECK_INCLUDE_FILE("memory.h"        HAVE_MEMORY_H)
-CHECK_INCLUDE_FILE("stdint.h"        HAVE_STDINT_H)
-CHECK_INCLUDE_FILE("stdlib.h"        HAVE_STDLIB_H)
-CHECK_INCLUDE_FILE("string.h"        HAVE_STRING_H)
-CHECK_INCLUDE_FILE("sys/stat.h"      HAVE_SYS_STAT_H)
-CHECK_INCLUDE_FILE("sys/types.h"     HAVE_SYS_TYPES_H)
-CHECK_INCLUDE_FILE("unistd.h"        HAVE_UNISTD_H)
-
-#find_file(HAVE_STRINGS_H_FOUND strings.h)
-#if(NOT HAVE_STRINGS_H_FOUND STREQUAL "HAVE_STRINGS_H_FOUND-NOTFOUND")
-#  find_file(HAVE_STRINGS_H strings.h)
-#  set(HAS_STRINGS_H 1)
-#endif()
-#find_file(HAVE_INTTYPES_H_FOUND inttypes.h)
-#if(NOT HAVE_INTTYPES_H_FOUND STREQUAL "HAVE_INTTYPES_H_FOUND-NOTFOUND")
-#  find_file(HAVE_INTTYPES_H inttypes.h)
-#  set(HAS_INTTYPES_H 1)
-#endif()
-#find_file(HAVE_MEMORY_H_FOUND memory.h)
-#if(NOT HAVE_MEMORY_H_FOUND STREQUAL "HAVE_MEMORY_H_FOUND-NOTFOUND")
-#  find_file(HAVE_MEMORY_H memory.h)
-#  set(HAS_MEMORY_H 1)
-#endif()
-#find_file(HAVE_STDINT_H_FOUND stdint.h)
-#if(NOT HAVE_STDINT_H_FOUND STREQUAL "HAVE_STDINT_H_FOUND-NOTFOUND")
-#  find_file(HAVE_STDINT_H stdint.h)
-#  set(HAS_STDINT_H 1)
-#endif()
-#find_file(HAVE_STDLIB_H_FOUND stdlib.h)
-#if(NOT HAVE_STDLIB_H_FOUND STREQUAL "HAVE_STDLIB_H_FOUND-NOTFOUND")
-#  find_file(HAVE_STDLIB_H stdlib.h)
-#  set(HAS_STDLIB_H 1)
-#endif()
-#find_file(HAVE_STRING_H_FOUND string.h)
-#if(NOT HAVE_STRING_H_FOUND STREQUAL "HAVE_STRING_H_FOUND-NOTFOUND")
-#  find_file(HAVE_STRING_H string.h)
-#  set(HAS_STRING_H 1)
-#endif()
-#find_file(HAVE_SYS_STAT_H_FOUND sys/stat.h)
-#if(NOT HAVE_SYS_STAT_H_FOUND STREQUAL "HAVE_SYS_STAT_H_FOUND-NOTFOUND")
-#  find_file(HAVE_SYS_STAT_H sys/stat.h)
-#  set(HAS_SYS_STAT_H 1)
-#endif()
-#find_file(HAVE_SYS_TYPES_H_FOUND sys/types.h)
-#if(NOT HAVE_SYS_TYPES_H_FOUND STREQUAL "HAVE_SYS_TYPES_H_FOUND-NOTFOUND")
-#  find_file(HAVE_SYS_TYPES_H sys/types.h)
-#  set(HAS_SYS_TYPES_H 1)
-#endif()
-#find_file(HAVE_UNISTD_H_FOUND unistd.h)
-#if(NOT HAVE_UNISTD_H_FOUND STREQUAL "HAVE_UNISTD_H_FOUND-NOTFOUND")
-#  find_file(HAVE_UNISTD_H unistd.h)
-#  set(HAS_UNISTD_H 1)
-#endif()
-#
-# Does the system have png library installed ?
-#
-#find_package(PNG)
-#
-if(PNG_FOUND)
-  set(HAVE_PNG_H 1)
-  set(HAVE_LIBPNG 1)
-endif()
-#
-# Does the system have tiff library installed ?
-# 
-#find_package(TIFF)
-#
-if(TIFF_FOUND)
-  set(HAVE_TIFF_H 1)
-  set(HAVE_LIBTIFF 1)
-endif()
-#
-#
-# Does the system have lcms library installed ?
-#
-set(LCMS_LIB "")
-#find_file(LCMS2_HEADER_FOUND lcms2.h)
-#
-if(LCMS2_HEADER_FOUND STREQUAL "LCMS2_HEADER_FOUND-NOTFOUND")
- set(LCMS2_HEADER_FOUND "")
-endif()
-if(LCMS2_HEADER_FOUND)
- find_path(LCMS_INCLUDE_DIR  lcms2.h)
- if(UNIX OR CYGWIN)
-   find_library(HAVE_LIBLCMS2 lcms2)
- else()
-   find_library(HAVE_LIBLCMS2 lcms2_static.lib)
- endif() 
- if(HAVE_LIBLCMS2 STREQUAL "HAVE_LIBLCMS2-NOTFOUND")
-  set(HAVE_LIBLCMS2 "")
- endif()
- if(HAVE_LIBLCMS2)
-  set(LCMS_LIB "${HAVE_LIBLCMS2}")
-  set(HAVE_LCMS2_LIB 1)
-  set(HAVE_LCMS2_H 1)
- endif()
-endif()
-#if(NOT LCMS2_HEADER_FOUND)
-# find_file(LCMS1_HEADER_FOUND lcms.h)
-# if(LCMS1_HEADER_FOUND STREQUAL "LCMS1_HEADER_FOUND-NOTFOUND")
-#  set(LCMS1_HEADER_FOUND "")
-# endif()
-# if(LCMS1_HEADER_FOUND)
-#  find_path(LCMS_INCLUDE_DIR  lcms.h)
-#  find_library(HAVE_LIBLCMS1 lcms)
-#  if(HAVE_LIBLCMS1 STREQUAL "HAVE_LIBLCMS1-NOTFOUND")
-#   set(HAVE_LIBLCMS1 "")
-#  endif()
-#  if(HAVE_LIBLCMS1)
-#   set(LCMS_LIB "${HAVE_LIBLCMS1}")
-#   set(HAVE_LCMS1_LIB 1)
-#   set(HAVE_LCMS1_H 1)
-#  endif()
-# endif()
-#endif()
-#
-# generate opj_config.h
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/opj_configh.cmake.in"
-  "${CMAKE_CURRENT_BINARY_DIR}/opj_config.h"
-  @ONLY 
-)
-#mark_as_advanced( HAVE_INTTYPES_H_FOUND HAVE_LIBLCMS2 HAVE_MEMORY_H
-#  HAVE_MEMORY_H_FOUND     HAVE_STDINT_H_FOUND     HAVE_STDLIB_H_FOUND
-#  HAVE_STRINGS_H          HAVE_STRINGS_H_FOUND    HAVE_STRING_H
-#  HAVE_STRING_H_FOUND     HAVE_SYS_STAT_H         HAVE_SYS_STAT_H_FOUND
-#  HAVE_SYS_TYPES_H_FOUND  HAVE_UNISTD_H_FOUND     LCMS2_HEADER_FOUND
-#  LCMS_INCLUDE_DIR        OPJ_BUILD_CODEC         )
-# install all targets referenced as OPENJPEGTargets
-#install(EXPORT ${GDCM_TARGETS_NAME} DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
-#configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
-#  ${CMAKE_CURRENT_BINARY_DIR}/OpenJPEGConfig.cmake
-#  @ONLY
-#)
-#install( FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenJPEGConfig.cmake
-#  DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
-#)
diff --git a/Utilities/gdcmopenjpeg-v1/CTestConfig.cmake b/Utilities/gdcmopenjpeg-v1/CTestConfig.cmake
deleted file mode 100644
index 6d3866e..0000000
--- a/Utilities/gdcmopenjpeg-v1/CTestConfig.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-set(CTEST_PROJECT_NAME "OPENJPEG")
-set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC")
-
-set(CTEST_DROP_METHOD "http")
-set(CTEST_DROP_SITE "my.cdash.org")
-set(CTEST_DROP_LOCATION "/submit.php?project=OPENJPEG")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Utilities/gdcmopenjpeg-v1/CTestCustom.cmake.in b/Utilities/gdcmopenjpeg-v1/CTestCustom.cmake.in
deleted file mode 100644
index 9aaafcc..0000000
--- a/Utilities/gdcmopenjpeg-v1/CTestCustom.cmake.in
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# For further details regarding this file, 
-# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
-#
-
-set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS   50)
-set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 50)
-
-set(CTEST_CUSTOM_COVERAGE_EXCLUDE
- ${CTEST_CUSTOM_COVERAGE_EXCLUDE}
-
- # Exclude files from the Testing directories
- ".*/Testing/.*"
- )
-
-set(CTEST_CUSTOM_WARNING_EXCEPTION
-  ${CTEST_CUSTOM_WARNING_EXCEPTION}
-  
-  # Suppress warning caused by intentional messages about deprecation
-  ".*warning,.* is deprecated"
-)
diff --git a/Utilities/gdcmopenjpeg-v1/INSTALL b/Utilities/gdcmopenjpeg-v1/INSTALL
deleted file mode 100644
index f205256..0000000
--- a/Utilities/gdcmopenjpeg-v1/INSTALL
+++ /dev/null
@@ -1,105 +0,0 @@
-
-How to build and install openjpeg binaries
-==========================================
-
-UNIX/LINUX similar systems
---------------------------
-
-1) Using configure tools
-
-You can simply type
-  ./configure [--prefix=/path]
-  make
-
-If you are root:
-  make install
-  make clean
-  make distclean
-
-else:
-  sudo make install
-  make clean
-  make distclean
-
-Binaries are located in the 'bin' directory.
-
-If 'configure' does not work on your system please
-call './bootstrap.sh'.
-
-If 'configure' does not find a library or header file,
-or to see available configure options, please try 
-'./configure --help'.
-
-Note: if Doxygen is found on your system, a target 'docs'
-will automatically be created in 'doc/Makefile'. To build
-the documentation (it will create an 'html' directory):
-  cd doc
-	make docs
-
-2) Using cmake (see www.cmake.org)
-
-Type:
-  cmake .
-  make
-
-If you are root:
-  make install
-  make clean
-
-else:
-  sudo make install
-  make clean
-
-Binaries are located in the 'bin' directory.
-
-Main available cmake flags:
-* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path'
-* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
-  Note: when using this option, static libraries are not built and executables are dynamically linked.
-* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
-* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
-* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
-* To build the JP3D executables and JP3D library: '-DBUILD_JP3D:bool=on' (default: 'OFF')
-* [WIN32 ONLY] To build the INDEXER_JPIP executable: '-DBUILD_INDEXER_JPIP:bool=on' (default: 'OFF')
-* To build the doxygen documentation: '-DBUILD_DOC:bool=on' (default: 'OFF')
-* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
-    cmake . -DBUILD_TESTING:BOOL=ON -DJPEG2000_CONFORMANCE_DATA_ROOT:PATH=/path/to/your/JPEG2000/test/files
-    make
-    make Experimental
-  Note : JPEG2000 test files are available here : http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
-
-3) Manually using Makefile.nix:
-- Manually edit the config.nix file
-- Manually create an opj_config.h file from opj_config.h.in.user
-  and edit this opj_config.h
-- Then : (if 'WITH_JPWL' and/or 'WITH_JP3D' are defined in config.nix)
-    make -f Makefile.nix all
-    make -f Makefile.nix install
-    make -f Makefile.nix clean
-    make -f Makefile.nix uninstall
-- If neither 'WITH_JPWL' nor 'WITH_JP3D' is defined in config.nix
-  and you want to clean/compile/install/uninstall JPWL/JP3D:
-  call the respective target in the respective directory.
-
-MACOSX
-------
-
-The same building procedures as above will soon be available for MACOSX.
-The xcode project file has also to be updated.
-Right now, the CMake procedure is the only one working. Please refer to instructions above.
-If it does not work, try adding the following flag to the cmake command : 
-  '-DCMAKE_OSX_ARCHITECTURES:STRING=i386'
-
-WINDOWS
--------
-
-If you're using cygwin, the same procedures as for Unix should work. Otherwise:
-
-1) Using cmake to generate project files
-
-Use the cmake procedure above with the '-G <generator-name>' flag to generate the project
-files for the IDE you are using. Type 'cmake --help' for available generators on your platform.
-
-2) Using the provided project files
-
-These files are obsolete and will be updated soon.
diff --git a/Utilities/gdcmopenjpeg-v1/LICENSE b/Utilities/gdcmopenjpeg-v1/LICENSE
deleted file mode 100644
index d1e5b6a..0000000
--- a/Utilities/gdcmopenjpeg-v1/LICENSE
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsp b/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsp
deleted file mode 100644
index 3f1766e..0000000
--- a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsp
+++ /dev/null
@@ -1,262 +0,0 @@
-# Microsoft Developer Studio Project File - Name="LibOpenJPEG" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=LibOpenJPEG - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "LibOpenJPEG.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "LibOpenJPEG.mak" CFG="LibOpenJPEG - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "LibOpenJPEG - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "LibOpenJPEG - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "LibOpenJPEG - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x40c /d "NDEBUG"
-# ADD RSC /l 0x40c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=if not exist dist mkdir dist	copy Release\LibOpenJPEG.lib dist	copy libopenjpeg\openjpeg.h dist
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "LibOpenJPEG - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x40c /d "_DEBUG"
-# ADD RSC /l 0x40c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"Debug\LibOpenJPEGd.lib"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=if not exist dist mkdir dist	copy Debug\LibOpenJPEGd.lib dist	copy libopenjpeg\openjpeg.h dist
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "LibOpenJPEG - Win32 Release"
-# Name "LibOpenJPEG - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=libopenjpeg\bio.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\cio.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\dwt.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\event.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\image.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\j2k.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\j2k_lib.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\jp2.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\jpt.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\mct.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\mqc.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\openjpeg.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\pi.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\raw.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\t1.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\t2.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\tcd.c
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\tgt.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=libopenjpeg\bio.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\cio.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\dwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\event.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\fix.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\image.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\int.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\j2k.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\j2k_lib.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\jp2.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\jpt.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\mct.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\mqc.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\openjpeg.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\opj_includes.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\pi.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\raw.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\t1.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\t1_luts.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\t2.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\tcd.h
-# End Source File
-# Begin Source File
-
-SOURCE=libopenjpeg\tgt.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsw b/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsw
deleted file mode 100644
index fdff9ae..0000000
--- a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.dsw
+++ /dev/null
@@ -1,41 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "DllOpenJPEG"=.\DllOpenJPEG.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "LibOpenJPEG"=.\LibOpenJPEG.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.sln b/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.sln
deleted file mode 100644
index f088d7a..0000000
--- a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOpenJPEG", "LibOpenJPEG.vcproj", "{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Debug|Win32.ActiveCfg = Debug|Win32
-		{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Debug|Win32.Build.0 = Debug|Win32
-		{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Release|Win32.ActiveCfg = Release|Win32
-		{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.vcproj b/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.vcproj
deleted file mode 100644
index 8d217d1..0000000
--- a/Utilities/gdcmopenjpeg-v1/LibOpenJPEG.vcproj
+++ /dev/null
@@ -1,642 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="LibOpenJPEG"
-	ProjectGUID="{4F27AA53-4181-4A1A-8238-3931B0A41048}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="2"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				WholeProgramOptimization="false"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/LibOpenJPEG.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1036"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile=".\Release\LibOpenJPEG.lib"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/LibOpenJPEG.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="if not exist dist mkdir dist&#x0D;&#x0A;copy Release\LibOpenJPEG.lib dist&#x0D;&#x0A;copy libopenjpeg\openjpeg.h dist&#x0D;&#x0A;"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				InlineFunctionExpansion="0"
-				EnableIntrinsicFunctions="false"
-				FavorSizeOrSpeed="1"
-				WholeProgramOptimization="false"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\Debug/LibOpenJPEG.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1036"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="Debug\LibOpenJPEGd.lib"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Debug/LibOpenJPEG.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="if not exist dist mkdir dist&#x0D;&#x0A;copy Debug\LibOpenJPEGd.lib dist&#x0D;&#x0A;copy libopenjpeg\openjpeg.h dist&#x0D;&#x0A;"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-			>
-			<File
-				RelativePath="libopenjpeg\bio.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\cio.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\dwt.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\event.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\image.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\j2k.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\j2k_lib.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\jp2.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\jpt.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\mct.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\mqc.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\openjpeg.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\pi.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\raw.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\t1.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\t2.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\tcd.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="libopenjpeg\tgt.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl"
-			>
-			<File
-				RelativePath="libopenjpeg\bio.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\cio.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\dwt.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\event.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\fix.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\image.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\int.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\j2k.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\j2k_lib.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\jp2.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\jpt.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\mct.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\mqc.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\openjpeg.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\opj_includes.h"
-				>
-			</File>
-			<File
-				RelativePath=".\libopenjpeg\opj_malloc.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\pi.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\raw.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\t1.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\t1_luts.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\t2.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\tcd.h"
-				>
-			</File>
-			<File
-				RelativePath="libopenjpeg\tgt.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsp b/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsp
deleted file mode 100644
index 4939f64..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsp
+++ /dev/null
@@ -1,290 +0,0 @@
-# Microsoft Developer Studio Project File - Name="OPJViewer" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=OPJVIEWER - WIN32 RELEASE
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "OPJViewer.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "OPJViewer.mak" CFG="OPJVIEWER - WIN32 RELEASE"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "OPJViewer - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "OPJViewer - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "OPJViewer - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "$(WXWIN28)\lib\vc_lib\msw" /I "$(WXWIN28)\include" /I ".." /I "..\libopenjpeg" /I "$(MXFLIB)" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /D "OPJ_HTMLABOUT" /D "OPJ_MANYFORMATS" /D "OPJ_INICONFIG" /FR /FD /Zm200 /c
-# ADD BASE RSC /l 0x410 /d "NDEBUG"
-# ADD RSC /l 0x409 /i "$(WXWIN28)\include" /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlib.lib wxregex.lib wxpng.lib wxjpeg.lib wxbase28.lib wxmsw28_core.lib wxmsw28_html.lib wxmsw28_adv.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib LibOpenJPEG_JPWL.lib mxflib.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libcmt.lib [...]
-# SUBTRACT LINK32 /pdb:none /nodefaultlib
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Update build number
-PostBuild_Cmds=buildupdate.bat
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "OPJViewer - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "OPJViewer___Win32_Debug"
-# PROP BASE Intermediate_Dir "OPJViewer___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "$(WXWIN28)\INCLUDE" /I "$(WXWIN28)\lib\vc_lib\msw" /I "$(WXWIN28)\include" /I ".." /I "..\libopenjpeg" /I "$(MXFLIB)" /D "_DEBUG" /D "__WXDEBUG__" /D WXDEBUG=1 /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /D "OPJ_INICONFIG" /D "OPJ_MANYFORMATS" /D "USE_JPSEC" /FR /FD /GZ /Zm200 /c
-# ADD BASE RSC /l 0x410 /d "_DEBUG"
-# ADD RSC /l 0x410 /i "$(WXWIN28)\include" /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlibd.lib wxregexd.lib wxpngd.lib wxjpegd.lib wxtiffd.lib wxbase28d.lib wxmsw28d_core.lib wxmsw28d_html.lib wxmsw28d_adv.lib LibOpenJPEG_JPWLd.lib mxflib.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /pdbtype:sept /libpath:"$(WXWIN28)\lib\vc_lib" /libpath:"..\jpwl\D [...]
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF 
-
-# Begin Target
-
-# Name "OPJViewer - Win32 Release"
-# Name "OPJViewer - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\source\imagjpeg2000.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\imagmxf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\index.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJAbout.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJDialogs.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJThreads.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJViewer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wxj2kparser.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wxjp2parser.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\source\about_htm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\build.h
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\imagjpeg2000.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\imagmxf.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\index.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJViewer.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\source\wx\msw\blank.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\bullseye.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\cdrom.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\computer.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\cross.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\drive.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\file1.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\floppy.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\folder1.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\folder2.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\hand.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\icon1.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\icon2.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\icon3.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\icon4.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\icon5.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\magnif1.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\opj_logo.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJChild.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJChild16.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJViewer.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJViewer.rc
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\OPJViewer16.xpm
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\pbrush.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\pencil.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\pntleft.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\pntright.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\removble.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\rightarr.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\roller.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\source\wx\msw\std.ico
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsw b/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsw
deleted file mode 100644
index 772043d..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.dsw
+++ /dev/null
@@ -1,56 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "LibOpenJPEG_JPWL"=..\jpwl\LibOpenJPEG_JPWL.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "OPJViewer"=.\OPJViewer.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG_JPWL
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "mxflib"="..\..\..\..\mxflib-1.0.0\build\msvc\mxflib.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.iss b/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.iss
deleted file mode 100644
index d4cfadb..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/OPJViewer.iss
+++ /dev/null
@@ -1,48 +0,0 @@
-; Script generated by the Inno Setup Script Wizard.
-; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
-
-[Setup]
-AppName=OPJViewer
-AppVerName=OPJViewer 0.4 beta
-AppPublisher=OpenJPEG
-AppPublisherURL=http://www.openjpeg.org
-AppSupportURL=http://www.openjpeg.org
-AppUpdatesURL=http://www.openjpeg.org
-DefaultDirName={pf}\OPJViewer
-DefaultGroupName=OPJViewer
-OutputDir=setup
-OutputBaseFilename=OPJViewer04beta_setup
-Compression=lzma
-SolidCompression=true
-InfoBeforeFile=source\readmebefore.txt
-InfoAfterFile=source\readmeafter.txt
-LicenseFile=source\license.txt
-VersionInfoVersion=0.4.0.0
-VersionInfoCompany=OpenJPEG
-VersionInfoDescription=JPEG 2000 viewer
-ShowLanguageDialog=yes
-SetupIconFile=source\OPJViewer.ico
-
-[Languages]
-Name: english; MessagesFile: compiler:Default.isl
-
-[Tasks]
-Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
-
-[Files]
-Source: Release\OPJViewer.exe; DestDir: {app}; Flags: ignoreversion
-;Source: about\about.htm; DestDir: {app}/about; Flags: ignoreversion
-;Source: about\opj_logo.png; DestDir: {app}/about; Flags: ignoreversion
-; NOTE: Don't use "Flags: ignoreversion" on any shared system files
-
-[Icons]
-Name: {group}\OPJViewer; Filename: {app}\OPJViewer.exe; WorkingDir: {app}; IconIndex: 0
-Name: {group}\{cm:UninstallProgram,OPJViewer}; Filename: {uninstallexe}
-Name: {userdesktop}\OPJViewer; Filename: {app}\OPJViewer.exe; Tasks: desktopicon; WorkingDir: {app}; IconIndex: 0
-
-[Run]
-Filename: {app}\OPJViewer.exe; Description: {cm:LaunchProgram,OPJViewer}; Flags: nowait postinstall skipifsilent; WorkingDir: {app}
-
-[Registry]
-Root: HKCU; Subkey: Software\OpenJPEG; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages: 
-Root: HKCU; Subkey: Software\OpenJPEG\OPJViewer; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages: 
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/Readme.txt b/Utilities/gdcmopenjpeg-v1/OPJViewer/Readme.txt
deleted file mode 100644
index 7eb3e46..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/Readme.txt
+++ /dev/null
@@ -1,100 +0,0 @@
-===============================================================================
-	JPEG2000 Visualization Software - OPJViewer
-
-		Version 0.4 beta
-===============================================================================
-
-
-1. Scope
-=============
-
-This document describes the installation and use of the OPJViewer in the framework of OpenJPEG library.
-
-This implementation has been developed using the OpenJPEG library as decoding engine and wxWidgets 2.8 as GUI engine.
-
-If you find some bugs or if you have problems using the viewer, please send an e-mail to jpwl at diei.unipg.it
-
-2. Installing the viewer
-==========================
-
-There are two options available, at the moment:
-
-a) compile from source code
-b) download a precompiled binary.
-
-In order to use option a), it is mandatory to have compiled and built the LibOpenJPEG_JPWL library and the wxWidgets 2.8 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries).
-
-2.1. Compiling the source code in Windows
--------------------------------------------
-
-The steps required to compile the viewer under windows are:
-
-a) Download at least the libopenjpeg, jpwl, and opjviewer folders from the SVN trunk.
-b) Open the OPJViewer.dsw workspace with Visual C++ 6 and activate the "OPJViewer - Win32 Release" configuration.
-c) In the configuration settings, go to the C++ tab and modify the wxWidgets paths in order to reflect your wx* install configuration (Preprocessor -> Additional include directories): simply update each instance of the two wx paths, do not remove or add them.
-d) In the configuration settings, go to the Link tab and modify the wxWidgets path in order to reflect your wx* install configuration (Input -> Additional library path): simply update the wx path.
-e) In the configuration settings, go to the Resources tab and modify the wxWidgets path in order to reflect your wx* install configuration (Additional resource include directories): simply update the wx path.
-f) Build!
-g) Run!
-h) (OPTIONAL) Prepare an installer by compiling the InnoSetup script OPJViewer.iss (you need to download InnoSetup from http://www.jrsoftware.org/isinfo.php).
-
-2.1.1 Additional libraries
-----------------------------
-
-Since we are also working on the Digital Cinema JPEG 2000, we are integrating the viewer with the MXF library, which is used to prepare the DCPs for digital movies. You can enable its linking in the code by specifying the USE_MXF preprocessor directive but, remember, the integration is at a very early stage.
-
-2.2. Compiling the source code in Unix-like systems
------------------------------------------------------
-
-The porting is possible and under way.
-
-
-3. General information on the viewer
-====================================
-
-This viewer is conceived to open and display information and image content of J2K, JP2, and MJ2 files.
-The viewer application interface is divided into three main panels:
-- a browsing pane;
-- a viewing pane;
-- a log/peek pane.
-
-The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
-
-filename
-|
-|_ #000: Marker/Box short name (Hex code)
-|  |
-|  |_ *** Marker/Box long name ***
-|  |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
-|  |_ Additional info, depending on the marker/box type
-|  |_ ...
-|
-|_ #001: Marker/Box short name (Hex code)
-|  |
-|  |_ ...
-|
-...
-
-
-The viewing pane will display the decoded image contained in the JPEG 2000 file.
-It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
-
-
-The log/peek pane is shared among two different subpanels:
-
-- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
-- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section. 
-
-
-4. Known bugs and limitations
-===============================
-
-4.1. Bugs
------------
-
-* 
-
-4.2. Limitations
-------------------
-
-* For mj2 files, rendering is only in B/W
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/about/about.htm b/Utilities/gdcmopenjpeg-v1/OPJViewer/about/about.htm
deleted file mode 100644
index fec6028..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/about/about.htm
+++ /dev/null
@@ -1,36 +0,0 @@
-<html>
-<body bgcolor="#FFFFFF">
-<table cellspacing=7 cellpadding=1 border=0 width="100%">
-<tr>
-<td rowspan=3 valign=top align=center width=70>
-<img src="opj_logo.png"><br><br>
-</td>
-<td align=center>
-<font size=+2 color="#000000"><b>OPJViewer v0.2 alpha</b></font><br>
-<font size=+0 color="#000000"><b>A JPEG 2000 image viewer</b></font>
-</td>
-</tr>
-<tr height=3 valign=center>
-<td valign=center  bgcolor=#cc3300></td>
-</tr>
-<tr>
-<td align=justify>
-<center><font size=+0 color="#000000"><a href="http://www.openjpeg.org/">OpenJPEG</a></font></center>
-<font size=-1 color="#000000">The OpenJPEG library is an open-source JPEG 2000 codec written in C language.
-In addition to the basic codec, various other features are under development,
-among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool
-useful for the JPIP protocol, JPWL-tools for error-resilience, ...</font>
-</td>
-</tr>
-<tr>
-<td colspan=2 bgcolor="#CC3300" height=3 valign=center></td>
-</tr>
-<tr>
-<td colspan=2>
-<font size=-2 color="#444444">OpenJPEG is © 2002-2007 <a href="http://www.tele.ucl.ac.be/">TELE</a> - <a href="http://www.uclouvain.be/">Universit� Catholique de Louvain</a></font><br>
-<font size=-2 color="#444444">OPJViewer is also © 2005-2007 <a href="http://dsplab.diei.unipg.it/">DSPLab</a> - <a href="http://www.unipg.it/">Universit� degli studi di Perugia</a></font>
-</td>
-</tr>
-</table>
-</body>
-</html>
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/about/opj_logo.png b/Utilities/gdcmopenjpeg-v1/OPJViewer/about/opj_logo.png
deleted file mode 100644
index 0f43840..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/OPJViewer/about/opj_logo.png and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/buildupdate.bat b/Utilities/gdcmopenjpeg-v1/OPJViewer/buildupdate.bat
deleted file mode 100644
index 0aae1c1..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/buildupdate.bat
+++ /dev/null
@@ -1,15 +0,0 @@
-::== buildupdate.bat
- at echo off
-setLocal EnableDelayedExpansion
-
-for /f "tokens=2,* delims=^(^) " %%a in ('find /v "" ^< .\source\build.h') do (
-rem echo %%a
-set /A M = %%a + 1
-echo Build %%a done^!
-echo wxT^("!M!"^) > buildtemp283746825t347
-)
-
-if exist buildtemp283746825t347 move /Y buildtemp283746825t347 .\source\build.h
-if exist buildtemp283746825t347 del /F /Q buildtemp283746825t347
-
-::==
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJAbout.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJAbout.cpp
deleted file mode 100644
index ecc5f45..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJAbout.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifdef USE_MXF
-#include "mxflib/mxflib.h"
-#endif // USE_MXF
-
-#include "OPJViewer.h"
-
-// about window for the frame
-void OPJFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
-{
-#ifdef OPJ_HTMLABOUT
-#include "about_htm.h"
-#include "opj_logo.xpm"
-
-    wxBoxSizer *topsizer;
-    wxHtmlWindow *html;
-    wxDialog dlg(this, wxID_ANY, wxString(_("About")));
-
-    wxMemoryFSHandler::AddFile(wxT("opj_logo.xpm"), wxBitmap(opj_logo), wxBITMAP_TYPE_XPM);
-
-    topsizer = new wxBoxSizer(wxVERTICAL);
-
-    html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(320, 250), wxHW_SCROLLBAR_NEVER);
-    html->SetBorders(0);
-    //html->LoadPage(wxT("about/about.htm"));
-	//html->SetPage("<html><body>Hello, world!</body></html>");
-	html->SetPage(htmlaboutpage);
-    html->SetSize(html->GetInternalRepresentation()->GetWidth(),
-                    html->GetInternalRepresentation()->GetHeight());
-
-    topsizer->Add(html, 1, wxALL, 10);
-
-    topsizer->Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
-
-    wxButton *bu1 = new wxButton(&dlg, wxID_OK, wxT("OK"));
-    bu1->SetDefault();
-
-    topsizer->Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
-
-    dlg.SetSizer(topsizer);
-    topsizer->Fit(&dlg);
-
-    dlg.ShowModal();
-
-#else
-
-	wxMessageBox(wxString::Format(OPJ_APPLICATION_TITLEBAR
-								  wxT("\n\n")
-								  wxT("Built with %s and OpenJPEG ")
-								  wxT(OPENJPEG_VERSION)
-								  wxT("\non ") wxT(__DATE__) wxT(", ") wxT(__TIME__)
-								  wxT("\nRunning under %s\n\n")
-								  OPJ_APPLICATION_COPYRIGHT,
-								  wxVERSION_STRING,
-								  wxGetOsDescription().c_str()),
-				 wxT("About ") OPJ_APPLICATION_NAME,
-				 wxOK | wxICON_INFORMATION,
-				 this
-				 );
-
-#endif
-
-}
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJChild.ico b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJChild.ico
deleted file mode 100644
index 7a12718..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJChild.ico and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJChild16.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJChild16.xpm
deleted file mode 100644
index 48e8796..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJChild16.xpm
+++ /dev/null
@@ -1,28 +0,0 @@
-/* XPM */
-static char *OPJChild16[] = {
-/* columns rows colors chars-per-pixel */
-"16 16 6 1",
-"  c black",
-". c #008000",
-"X c red",
-"o c #800080",
-"O c gray100",
-"+ c None",
-/* pixels */
-"++++++++++++++++",
-"+OOOOOOOOOOOOOO+",
-"+OooooooooooooO+",
-"+OooooooooooooO+",
-"+OooOOOOOOOOOoO+",
-"+OooO.......OoO+",
-"+OooO.......OoO+",
-"+OooO..OOO..OoO+",
-"+OooO..OXO..OoO+",
-"+OooO..OOO..OoO+",
-"+OooO.......OoO+",
-"+OooO.......OoO+",
-"+OooOOOOOOOOOoO+",
-"+OooooooooooooO+",
-"+OOOOOOOOOOOOOO+",
-"++++++++++++++++"
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJDialogs.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJDialogs.cpp
deleted file mode 100644
index ed68ef3..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJDialogs.cpp
+++ /dev/null
@@ -1,1373 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "OPJViewer.h"
-
-// ----------------------------------------------------------------------------
-// OPJDecoderDialog
-// ----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(OPJDecoderDialog, wxPropertySheetDialog)
-
-BEGIN_EVENT_TABLE(OPJDecoderDialog, wxPropertySheetDialog)
-	EVT_CHECKBOX(OPJDECO_ENABLEDECO, OPJDecoderDialog::OnEnableDeco)
-#ifdef USE_JPWL
-	EVT_CHECKBOX(OPJDECO_ENABLEJPWL, OPJDecoderDialog::OnEnableJPWL)
-#endif // USE_JPWL
-END_EVENT_TABLE()
-
-OPJDecoderDialog::OPJDecoderDialog(wxWindow* win, int dialogType)
-{
-	SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
-
-	Create(win, wxID_ANY, wxT("Decoder settings"),
-		wxDefaultPosition, wxDefaultSize,
-		wxDEFAULT_DIALOG_STYLE| (int) wxPlatform::IfNot(wxOS_WINDOWS_CE, wxRESIZE_BORDER)
-		);
-
-	CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP));
-
-	m_settingsNotebook = GetBookCtrl();
-
-	wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook);
-	wxPanel* jpeg2000Settings = CreatePart1SettingsPage(m_settingsNotebook);
-	if (!wxGetApp().m_enabledeco)
-		jpeg2000Settings->Enable(false);
-	wxPanel* mjpeg2000Settings = CreatePart3SettingsPage(m_settingsNotebook);
-	if (!wxGetApp().m_enabledeco)
-		mjpeg2000Settings->Enable(false);
-#ifdef USE_JPWL
-	wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook);
-	if (!wxGetApp().m_enabledeco)
-		jpwlSettings->Enable(false);
-#endif // USE_JPWL
-
-	m_settingsNotebook->AddPage(mainSettings, wxT("Display"), false);
-	m_settingsNotebook->AddPage(jpeg2000Settings, wxT("JPEG 2000"), false);
-	m_settingsNotebook->AddPage(mjpeg2000Settings, wxT("MJPEG 2000"), false);
-#ifdef USE_JPWL
-	m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false);
-#endif // USE_JPWL
-
-	LayoutDialog();
-}
-
-OPJDecoderDialog::~OPJDecoderDialog()
-{
-}
-
-wxPanel* OPJDecoderDialog::CreateMainSettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-		// sub top sizer
-		wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL);
-
-		// add decoding enabling check box
-		subtopSizer->Add(
-			m_enabledecoCheck = new wxCheckBox(panel, OPJDECO_ENABLEDECO, wxT("Enable decoding"), wxDefaultPosition, wxDefaultSize),
-			0, wxGROW | wxALL, 5);
-		m_enabledecoCheck->SetValue(wxGetApp().m_enabledeco);
-
-		// add parsing enabling check box
-		subtopSizer->Add(
-			m_enableparseCheck = new wxCheckBox(panel, OPJDECO_ENABLEPARSE, wxT("Enable parsing"), wxDefaultPosition, wxDefaultSize),
-			0, wxGROW | wxALL, 5);
-		m_enableparseCheck->SetValue(wxGetApp().m_enableparse);
-
-			// resize settings, column
-			wxString choices[] = {wxT("Don't resize"), wxT("Low quality"), wxT("High quality")};
-			m_resizeBox = new wxRadioBox(panel, OPJDECO_RESMETHOD,
-				wxT("Resize method"),
-				wxDefaultPosition, wxDefaultSize,
-				WXSIZEOF(choices),
-				choices,
-				1,
-				wxRA_SPECIFY_ROWS);
-			m_resizeBox->SetSelection(wxGetApp().m_resizemethod + 1);
-
-		subtopSizer->Add(m_resizeBox, 0, wxGROW | wxALL, 5);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-
-wxPanel* OPJDecoderDialog::CreatePart3SettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-	// add some space
-	//topSizer->AddSpacer(5);
-
-		// sub top sizer
-		wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL);
-
-			// frame settings, column
-			wxStaticBox* frameBox = new wxStaticBox(panel, wxID_ANY, wxT("Frame"));
-			wxBoxSizer* frameSizer = new wxStaticBoxSizer(frameBox, wxVERTICAL);
-
-				// selected frame number, row
-				wxBoxSizer* framenumSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				framenumSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Displayed frame:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
-
-				// add some horizontal space
-				framenumSizer->Add(5, 5, 1, wxALL, 0);
-
-				// add the value control
-				framenumSizer->Add(
-					m_framenumCtrl = new wxSpinCtrl(panel, OPJDECO_FRAMENUM,
-								wxString::Format(wxT("%d"), wxGetApp().m_framenum),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								1, 100000, wxGetApp().m_framenum),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
-
-			frameSizer->Add(framenumSizer, 0, wxGROW | wxALL, 5);
-
-		subtopSizer->Add(frameSizer, 0, wxGROW | wxALL, 5);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-
-wxPanel* OPJDecoderDialog::CreatePart1SettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-	// add some space
-	//topSizer->AddSpacer(5);
-
-		// sub top sizer
-		wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL);
-
-			// resolutions settings, column
-			wxStaticBox* resolutionBox = new wxStaticBox(panel, wxID_ANY, wxT("Resolutions"));
-			wxBoxSizer* resolutionSizer = new wxStaticBoxSizer(resolutionBox, wxVERTICAL);
-
-				// reduce factor sizer, row
-				wxBoxSizer* reduceSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				reduceSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Reduce factor:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
-
-				// add some horizontal space
-				reduceSizer->Add(5, 5, 1, wxALL, 0);
-
-				// add the value control
-				reduceSizer->Add(
-					m_reduceCtrl = new wxSpinCtrl(panel, OPJDECO_REDUCEFACTOR,
-					wxString::Format(wxT("%d"), wxGetApp().m_reducefactor),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								0, 10000, wxGetApp().m_reducefactor),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
-
-			resolutionSizer->Add(reduceSizer, 0, wxGROW | wxALL, 5);
-
-		subtopSizer->Add(resolutionSizer, 0, wxGROW | wxALL, 5);
-
-			// quality layer settings, column
-			wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers"));
-			wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL);
-
-				// quality layers sizer, row
-				wxBoxSizer* qualitySizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				qualitySizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Quality layers:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
-
-				// add some horizontal space
-				qualitySizer->Add(5, 5, 1, wxALL, 0);
-
-				// add the value control
-				qualitySizer->Add(
-					m_layerCtrl = new wxSpinCtrl(panel, OPJDECO_QUALITYLAYERS,
-								wxString::Format(wxT("%d"), wxGetApp().m_qualitylayers),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								0, 100000, wxGetApp().m_qualitylayers),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
-
-			layerSizer->Add(qualitySizer, 0, wxGROW | wxALL, 5);
-
-		subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 5);
-
-			// component settings, column
-			wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components"));
-			wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL);
-
-				// quality layers sizer, row
-				wxBoxSizer* numcompsSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				numcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component displayed:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
-
-				// add some horizontal space
-				numcompsSizer->Add(5, 5, 1, wxALL, 0);
-
-				// add the value control
-				numcompsSizer->Add(
-					m_numcompsCtrl = new wxSpinCtrl(panel, OPJDECO_NUMCOMPS,
-								wxString::Format(wxT("%d"), wxGetApp().m_components),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								0, 100000, wxGetApp().m_components),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
-				m_numcompsCtrl->Enable(true);
-
-			compoSizer->Add(numcompsSizer, 0, wxGROW | wxALL, 5);
-
-		subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-
-#ifdef USE_JPWL
-wxPanel* OPJDecoderDialog::CreatePart11SettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-	// add some space
-	//topSizer->AddSpacer(5);
-
-		// sub top sizer
-		wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL);
-
-		// add JPWL enabling check box
-		subtopSizer->Add(
-			m_enablejpwlCheck = new wxCheckBox(panel, OPJDECO_ENABLEJPWL, wxT("Enable JPWL"), wxDefaultPosition, wxDefaultSize),
-			0, wxGROW | wxALL, 5);
-		m_enablejpwlCheck->SetValue(wxGetApp().m_enablejpwl);
-
-			// component settings, column
-			wxStaticBox* compoBox = new wxStaticBox(panel, wxID_ANY, wxT("Components"));
-			wxBoxSizer* compoSizer = new wxStaticBoxSizer(compoBox, wxVERTICAL);
-
-				// expected components sizer, row
-				wxBoxSizer* expcompsSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				expcompsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Expected comps.:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
-
-				// add some horizontal space
-				expcompsSizer->Add(5, 5, 1, wxALL, 0);
-
-				// add the value control
-				expcompsSizer->Add(
-					m_expcompsCtrl = new wxSpinCtrl(panel, OPJDECO_EXPCOMPS,
-								wxString::Format(wxT("%d"), wxGetApp().m_expcomps),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								1, 100000, wxGetApp().m_expcomps),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
-				m_expcompsCtrl->Enable(wxGetApp().m_enablejpwl);
-
-			compoSizer->Add(expcompsSizer, 0, wxGROW | wxALL, 5);
-
-		subtopSizer->Add(compoSizer, 0, wxGROW | wxALL, 5);
-
-			// tiles settings, column
-			wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles"));
-			wxBoxSizer* tileSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL);
-
-				// maximum tiles sizer, row
-				wxBoxSizer* maxtileSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				maxtileSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Max. no. of tiles:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
-
-				// add some horizontal space
-				maxtileSizer->Add(5, 5, 1, wxALL, 0);
-
-				// add the value control
-				maxtileSizer->Add(
-					m_maxtilesCtrl = new wxSpinCtrl(panel, OPJDECO_MAXTILES,
-								wxString::Format(wxT("%d"), wxGetApp().m_maxtiles),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								1, 100000, wxGetApp().m_maxtiles),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
-				m_maxtilesCtrl->Enable(wxGetApp().m_enablejpwl);
-
-			tileSizer->Add(maxtileSizer, 0, wxGROW | wxALL, 5);
-
-		subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 5);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-
-void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event)
-{
-	size_t pp;
-
-	if (event.IsChecked()) {
-		wxLogMessage(wxT("Decoding enabled"));
-		m_resizeBox->Enable(true);
-		// enable all tabs except ourselves
-		for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) {
-			if (m_settingsNotebook->GetPageText(pp) != wxT("Display"))
-				m_settingsNotebook->GetPage(pp)->Enable(true);
-		}
-	} else {
-		wxLogMessage(wxT("Decoding disabled"));
-		m_resizeBox->Enable(false);
-		// disable all tabs except ourselves
-		for (pp = 0; pp < m_settingsNotebook->GetPageCount(); pp++) {
-			if (m_settingsNotebook->GetPageText(pp) != wxT("Display"))
-				m_settingsNotebook->GetPage(pp)->Enable(false);
-		}
-	}
-
-}
-
-void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event)
-{
-	if (event.IsChecked()) {
-		wxLogMessage(wxT("JPWL enabled"));
-		m_expcompsCtrl->Enable(true);
-		m_maxtilesCtrl->Enable(true);
-	} else {
-		wxLogMessage(wxT("JPWL disabled"));
-		m_expcompsCtrl->Enable(false);
-		m_maxtilesCtrl->Enable(false);
-	}
-
-}
-
-#endif // USE_JPWL
-
-
-
-
-// ----------------------------------------------------------------------------
-// OPJEncoderDialog
-// ----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(OPJEncoderDialog, wxPropertySheetDialog)
-
-BEGIN_EVENT_TABLE(OPJEncoderDialog, wxPropertySheetDialog)
-	EVT_CHECKBOX(OPJENCO_ENABLECOMM, OPJEncoderDialog::OnEnableComm)
-	EVT_CHECKBOX(OPJENCO_ENABLEINDEX, OPJEncoderDialog::OnEnableIdx)
-	EVT_CHECKBOX(OPJENCO_ENABLEPOC, OPJEncoderDialog::OnEnablePoc)
-	EVT_RADIOBUTTON(OPJENCO_RATERADIO, OPJEncoderDialog::OnRadioQualityRate)
-	EVT_RADIOBUTTON(OPJENCO_QUALITYRADIO, OPJEncoderDialog::OnRadioQualityRate)
-#ifdef USE_JPWL
-	EVT_CHECKBOX(OPJENCO_ENABLEJPWL, OPJEncoderDialog::OnEnableJPWL)
-	EVT_CHOICE(OPJENCO_HPROT, OPJEncoderDialog::OnHprotSelect)
-	EVT_CHOICE(OPJENCO_PPROT, OPJEncoderDialog::OnPprotSelect)
-	EVT_CHOICE(OPJENCO_SENSI, OPJEncoderDialog::OnSensiSelect)
-#endif // USE_JPWL
-END_EVENT_TABLE()
-
-OPJEncoderDialog::OPJEncoderDialog(wxWindow* win, int dialogType)
-{
-	SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
-
-	Create(win, wxID_ANY, wxT("Encoder settings"),
-		wxDefaultPosition, wxDefaultSize,
-		wxDEFAULT_DIALOG_STYLE| (int) wxPlatform::IfNot(wxOS_WINDOWS_CE, wxRESIZE_BORDER)
-		);
-
-	CreateButtons(wxOK | wxCANCEL | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, wxHELP));
-
-	m_settingsNotebook = GetBookCtrl();
-
-	wxPanel* jpeg2000_1Settings = CreatePart1_1SettingsPage(m_settingsNotebook);
-	wxPanel* jpeg2000_2Settings = CreatePart1_2SettingsPage(m_settingsNotebook);
-	wxPanel* mainSettings = CreateMainSettingsPage(m_settingsNotebook);
-#ifdef USE_JPWL
-	wxPanel* jpwlSettings = CreatePart11SettingsPage(m_settingsNotebook);
-#endif // USE_JPWL
-
-#ifdef USE_JPWL
-	m_settingsNotebook->AddPage(jpwlSettings, wxT("JPWL"), false);
-#endif // USE_JPWL
-	m_settingsNotebook->AddPage(jpeg2000_1Settings, wxT("JPEG 2000 - 1"), false);
-	m_settingsNotebook->AddPage(jpeg2000_2Settings, wxT("JPEG 2000 - 2"), false);
-	m_settingsNotebook->AddPage(mainSettings, wxT("General"), false);
-
-	LayoutDialog();
-}
-
-OPJEncoderDialog::~OPJEncoderDialog()
-{
-}
-
-wxPanel* OPJEncoderDialog::CreateMainSettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-		// sub top sizer
-		wxBoxSizer *subtopSizer = new wxBoxSizer(wxVERTICAL);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-
-#ifdef USE_JPWL
-wxPanel* OPJEncoderDialog::CreatePart11SettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-	int specno;
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-		// add JPWL enabling check box
-		topSizer->Add(
-			m_enablejpwlCheck = new wxCheckBox(panel, OPJENCO_ENABLEJPWL, wxT("Enable JPWL"),
-			wxDefaultPosition, wxDefaultSize),
-			0, wxGROW | wxALL | wxALIGN_CENTER, 5);
-		m_enablejpwlCheck->SetValue(wxGetApp().m_enablejpwle);
-
-		// sub top sizer
-		wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3);
-
-			// header settings, column
-			wxStaticBox* headerBox = new wxStaticBox(panel, wxID_ANY, wxT("Header protection"));
-			wxBoxSizer* headerSizer = new wxStaticBoxSizer(headerBox, wxVERTICAL);
-
-				// info sizer, row
-				wxBoxSizer* info1Sizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				info1Sizer->Add(new wxStaticText(panel, wxID_ANY,
-								wxT("Type")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
-
-				// add some horizontal space
-				info1Sizer->Add(3, 3, 1, wxALL, 0);
-
-				// add some text
-				info1Sizer->Add(new wxStaticText(panel, wxID_ANY,
-								wxT("Tile part")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
-
-			headerSizer->Add(info1Sizer, 0, wxGROW | wxALL, 0);
-
-			// specify specs
-			wxString hprotvalues[] = {wxT("None"), wxT("Pred."), wxT("CRC16"), wxT("CRC32"),
-				wxT("RS37"), wxT("RS38"), wxT("RS40"), wxT("RS43"), wxT("RS45"), wxT("RS48"),
-				wxT("RS51"), wxT("RS53"), wxT("RS56"), wxT("RS64"), wxT("RS75"), wxT("RS80"),
-				wxT("RS85"), wxT("RS96"), wxT("RS112"), wxT("RS128")};
-			for (specno = 0; specno < MYJPWL_MAX_NO_TILESPECS; specno++) {
-
-					// tile+hprot sizer, row
-					wxBoxSizer* tilehprotSizer = new wxBoxSizer(wxHORIZONTAL);
-
-					// add the value selection
-					tilehprotSizer->Add(
-						m_hprotChoice[specno] = new wxChoice(panel, OPJENCO_HPROT,
-							wxDefaultPosition, wxSize(60, wxDefaultCoord),
-							WXSIZEOF(hprotvalues), hprotvalues),
-						0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 1);
-					m_hprotChoice[specno]->SetSelection(wxGetApp().m_hprotsel[specno]);
-
-					// add some horizontal space
-					tilehprotSizer->Add(3, 3, 1, wxALL, 0);
-
-					// add the value control
-					tilehprotSizer->Add(
-						m_htileCtrl[specno] = new wxSpinCtrl(panel, OPJENCO_HTILE,
-							wxString::Format(wxT("%d"), wxGetApp().m_htileval[specno]),
-							wxDefaultPosition, wxSize(45, wxDefaultCoord),
-							wxSP_ARROW_KEYS,
-							0, JPWL_MAXIMUM_TILES - 1, 0),
-						0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 1);
-
-				headerSizer->Add(tilehprotSizer, 0, wxGROW | wxALL, 0);
-			}
-
-			wxCommandEvent event1;
-			OnHprotSelect(event1);
-
-		subtopSizer->Add(headerSizer, 0, wxGROW | wxALL, 3);
-
-			// packet settings, column
-			wxStaticBox* packetBox = new wxStaticBox(panel, wxID_ANY, wxT("Packet protection"));
-			wxBoxSizer* packetSizer = new wxStaticBoxSizer(packetBox, wxVERTICAL);
-
-				// info sizer, row
-				wxBoxSizer* info2Sizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				info2Sizer->Add(new wxStaticText(panel, wxID_ANY,
-								wxT("Type")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
-
-				// add some horizontal space
-				info2Sizer->Add(3, 3, 1, wxALL, 0);
-
-				// add some text
-				info2Sizer->Add(new wxStaticText(panel, wxID_ANY,
-								wxT("Tile part")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
-
-				// add some horizontal space
-				info2Sizer->Add(3, 3, 1, wxALL, 0);
-
-				// add some text
-				info2Sizer->Add(new wxStaticText(panel, wxID_ANY,
-								wxT("Packet")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
-
-			packetSizer->Add(info2Sizer, 0, wxGROW | wxALL, 0);
-
-			// specify specs
-			wxString pprotvalues[] = {wxT("None"), wxT("Pred."), wxT("CRC16"), wxT("CRC32"),
-				wxT("RS37"), wxT("RS38"), wxT("RS40"), wxT("RS43"), wxT("RS45"), wxT("RS48"),
-				wxT("RS51"), wxT("RS53"), wxT("RS56"), wxT("RS64"), wxT("RS75"), wxT("RS80"),
-				wxT("RS85"), wxT("RS96"), wxT("RS112"), wxT("RS128")};
-			for (specno = 0; specno < MYJPWL_MAX_NO_TILESPECS; specno++) {
-
-					// tile+pprot sizer, row
-					wxBoxSizer* tilepprotSizer = new wxBoxSizer(wxHORIZONTAL);
-
-					// add the value selection
-					tilepprotSizer->Add(
-						m_pprotChoice[specno] = new wxChoice(panel, OPJENCO_PPROT,
-							wxDefaultPosition, wxSize(60, wxDefaultCoord),
-							WXSIZEOF(pprotvalues), pprotvalues),
-						0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 1);
-					m_pprotChoice[specno]->SetSelection(wxGetApp().m_pprotsel[specno]);
-
-					// add some horizontal space
-					tilepprotSizer->Add(3, 3, 1, wxALL, 0);
-
-					// add the value control
-					tilepprotSizer->Add(
-						m_ptileCtrl[specno] = new wxSpinCtrl(panel, OPJENCO_PTILE,
-							wxString::Format(wxT("%d"), wxGetApp().m_ptileval[specno]),
-							wxDefaultPosition, wxSize(45, wxDefaultCoord),
-							wxSP_ARROW_KEYS,
-							0, JPWL_MAXIMUM_TILES - 1, 0),
-						0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 1);
-
-					// add some horizontal space
-					tilepprotSizer->Add(3, 3, 1, wxALL, 0);
-
-					// add the value control
-					tilepprotSizer->Add(
-						m_ppackCtrl[specno] = new wxSpinCtrl(panel, OPJENCO_PPACK,
-							wxString::Format(wxT("%d"), wxGetApp().m_ppackval[specno]),
-							wxDefaultPosition, wxSize(50, wxDefaultCoord),
-							wxSP_ARROW_KEYS,
-							0, 2047, 0),
-						0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 1);
-
-				packetSizer->Add(tilepprotSizer, 0, wxGROW | wxALL, 0);
-			}
-
-			wxCommandEvent event2;
-			OnPprotSelect(event2);
-
-		subtopSizer->Add(packetSizer, 0, wxGROW | wxALL, 3);
-
-			// sensitivity settings, column
-			wxStaticBox* sensiBox = new wxStaticBox(panel, wxID_ANY, wxT("Sensitivity"));
-			wxBoxSizer* sensiSizer = new wxStaticBoxSizer(sensiBox, wxVERTICAL);
-
-				// info sizer, row
-				wxBoxSizer* info3Sizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				info3Sizer->Add(new wxStaticText(panel, wxID_ANY,
-								wxT("Type")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
-
-				// add some horizontal space
-				info3Sizer->Add(3, 3, 1, wxALL, 0);
-
-				// add some text
-				info3Sizer->Add(new wxStaticText(panel, wxID_ANY,
-								wxT("Tile part")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 1);
-
-			sensiSizer->Add(info3Sizer, 0, wxGROW | wxALL, 0);
-
-			// specify specs
-			wxString sensivalues[] = {wxT("None"), wxT("RELATIVE ERROR"), wxT("MSE"),
-				wxT("MSE REDUCTION"), wxT("PSNR INCREMENT"), wxT("MAXERR"), wxT("TSE")};
-			for (specno = 0; specno < MYJPWL_MAX_NO_TILESPECS; specno++) {
-
-					// tile+sensi sizer, row
-					wxBoxSizer* tilesensiSizer = new wxBoxSizer(wxHORIZONTAL);
-
-					// add the value selection
-					tilesensiSizer->Add(
-						m_sensiChoice[specno] = new wxChoice(panel, OPJENCO_SENSI,
-							wxDefaultPosition, wxSize(110, wxDefaultCoord),
-							WXSIZEOF(sensivalues), sensivalues),
-						0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 1);
-					m_sensiChoice[specno]->SetSelection(wxGetApp().m_sensisel[specno]);
-
-					// add some horizontal space
-					tilesensiSizer->Add(3, 3, 1, wxALL, 0);
-
-					// add the value control
-					tilesensiSizer->Add(
-						m_stileCtrl[specno] = new wxSpinCtrl(panel, OPJENCO_STILE,
-							wxString::Format(wxT("%d"), wxGetApp().m_stileval[specno]),
-							wxDefaultPosition, wxSize(45, wxDefaultCoord),
-							wxSP_ARROW_KEYS,
-							0, JPWL_MAXIMUM_TILES - 1, 0),
-						0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 1);
-
-				sensiSizer->Add(tilesensiSizer, 0, wxGROW | wxALL, 0);
-			}
-
-			wxCommandEvent event3;
-			OnSensiSelect(event3);
-
-		subtopSizer->Add(sensiSizer, 0, wxGROW | wxALL, 3);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-#endif // USE_JPWL
-
-wxPanel* OPJEncoderDialog::CreatePart1_1SettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-	// add some space
-	//topSizer->AddSpacer(5);
-
-		// sub top sizer
-		wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3);
-
-			// image settings, column
-			wxStaticBox* imageBox = new wxStaticBox(panel, wxID_ANY, wxT("Image"));
-			wxBoxSizer* imageSizer = new wxStaticBoxSizer(imageBox, wxVERTICAL);
-
-				// subsampling factor sizer, row
-				wxBoxSizer* subsSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				subsSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Subsampling:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				subsSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				subsSizer->Add(
-					m_subsamplingCtrl = new wxTextCtrl(panel, OPJENCO_SUBSAMPLING,
-								wxGetApp().m_subsampling,
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			imageSizer->Add(subsSizer, 0, wxGROW | wxALL, 3);
-
-				// origin sizer, row
-				wxBoxSizer* imorigSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				imorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				imorigSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				imorigSizer->Add(
-					m_originCtrl = new wxTextCtrl(panel, OPJENCO_IMORIG,
-								wxGetApp().m_origin,
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			imageSizer->Add(imorigSizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(imageSizer, 0, wxGROW | wxALL, 3);
-
-			// layer settings, column
-			wxStaticBox* layerBox = new wxStaticBox(panel, wxID_ANY, wxT("Layers/compression"));
-			wxBoxSizer* layerSizer = new wxStaticBoxSizer(layerBox, wxVERTICAL);
-
-				// rate factor sizer, row
-				wxBoxSizer* rateSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				/*rateSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Rate values:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);*/
-
-				// add the radio button
-				rateSizer->Add(
-					m_rateRadio = new wxRadioButton(panel, OPJENCO_RATERADIO, wxT("&Rate values"),
-								wxDefaultPosition, wxDefaultSize,
-								wxRB_GROUP),
-								0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
-								);
-				m_rateRadio->SetValue(!(wxGetApp().m_enablequality));
-
-				// add some horizontal space
-				rateSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				rateSizer->Add(
-					m_rateCtrl = new wxTextCtrl(panel, OPJENCO_RATEFACTOR,
-								wxGetApp().m_rates,
-								wxDefaultPosition, wxSize(100, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-				if (wxGetApp().m_enablequality == true)
-					m_rateCtrl->Enable(false);
-
-			layerSizer->Add(rateSizer, 0, wxGROW | wxALL, 3);
-
-				// quality factor sizer, row
-				wxBoxSizer* qualitySizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				/*qualitySizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Quality values:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);*/
-
-				// add the radio button
-				qualitySizer->Add(
-					m_qualityRadio = new wxRadioButton(panel, OPJENCO_QUALITYRADIO, wxT("&Quality values"),
-								wxDefaultPosition, wxDefaultSize),
-								0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
-								);
-				m_qualityRadio->SetValue(wxGetApp().m_enablequality);
-
-				// add some horizontal space
-				qualitySizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				qualitySizer->Add(
-					m_qualityCtrl = new wxTextCtrl(panel, OPJENCO_QUALITYFACTOR,
-								wxGetApp().m_quality,
-								wxDefaultPosition, wxSize(100, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-				if (wxGetApp().m_enablequality == false)
-					m_qualityCtrl->Enable(false);
-
-			layerSizer->Add(qualitySizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(layerSizer, 0, wxGROW | wxALL, 3);
-
-			// wavelet settings, column
-			wxStaticBox* transformBox = new wxStaticBox(panel, wxID_ANY, wxT("Transforms"));
-			wxBoxSizer* transformSizer = new wxStaticBoxSizer(transformBox, wxVERTICAL);
-
-			// multiple component check box
-			transformSizer->Add(
-				m_mctCheck = new wxCheckBox(panel, OPJENCO_ENABLEMCT, wxT("Multiple component"),
-				wxDefaultPosition, wxDefaultSize),
-				0, wxGROW | wxALL, 3);
-			m_mctCheck->SetValue(wxGetApp().m_multicomp);
-
-			// irreversible wavelet check box
-			transformSizer->Add(
-				m_irrevCheck = new wxCheckBox(panel, OPJENCO_ENABLEIRREV, wxT("Irreversible wavelet"),
-				wxDefaultPosition, wxDefaultSize),
-				0, wxGROW | wxALL, 3);
-			m_irrevCheck->SetValue(wxGetApp().m_irreversible);
-
-				// resolution number sizer, row
-				wxBoxSizer* resnumSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				resnumSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Resolutions:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				resnumSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				resnumSizer->Add(
-					m_resolutionsCtrl = new wxSpinCtrl(panel, OPJENCO_RESNUMBER,
-								wxString::Format(wxT("%d"), wxGetApp().m_resolutions),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								1, 256, 6),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			transformSizer->Add(resnumSizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(transformSizer, 0, wxGROW | wxALL, 3);
-
-			// codestream settings, column
-			wxStaticBox* codestreamBox = new wxStaticBox(panel, wxID_ANY, wxT("Codestream"));
-			wxBoxSizer* codestreamSizer = new wxStaticBoxSizer(codestreamBox, wxVERTICAL);
-
-				// codeblock sizer, row
-				wxBoxSizer* codeblockSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				codeblockSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Codeblocks size:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				codeblockSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				codeblockSizer->Add(
-					m_cbsizeCtrl = new wxTextCtrl(panel, OPJENCO_CODEBLOCKSIZE,
-								wxGetApp().m_cbsize,
-								wxDefaultPosition, wxSize(100, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			codestreamSizer->Add(codeblockSizer, 0, wxGROW | wxALL, 3);
-
-				// precinct sizer, row
-				wxBoxSizer* precinctSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				precinctSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Precincts size:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				precinctSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				precinctSizer->Add(
-					m_prsizeCtrl = new wxTextCtrl(panel, OPJENCO_PRECINCTSIZE,
-								wxGetApp().m_prsize,
-								wxDefaultPosition, wxSize(100, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			codestreamSizer->Add(precinctSizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(codestreamSizer, 0, wxGROW | wxALL, 3);
-
-			// tile settings, column
-			wxStaticBox* tileBox = new wxStaticBox(panel, wxID_ANY, wxT("Tiles"));
-			wxBoxSizer* tileSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL);
-
-				// tile size sizer, row
-				wxBoxSizer* tilesizeSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				tilesizeSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Size:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				tilesizeSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				tilesizeSizer->Add(
-					m_tsizeCtrl = new wxTextCtrl(panel, OPJENCO_TILESIZE,
-								wxGetApp().m_tsize,
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			tileSizer->Add(tilesizeSizer, 0, wxGROW | wxALL, 3);
-
-				// tile origin sizer, row
-				wxBoxSizer* tilorigSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				tilorigSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Origin:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				tilorigSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				tilorigSizer->Add(
-					m_toriginCtrl = new wxTextCtrl(panel, OPJENCO_TILORIG,
-								wxGetApp().m_torigin,
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			tileSizer->Add(tilorigSizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(tileSizer, 0, wxGROW | wxALL, 3);
-
-			// progression and profile settings, column
-			wxString choices[] = {wxT("LRCP"), wxT("RLCP"), wxT("RPCL"), wxT("PCRL"), wxT("CPRL"),
-				wxT("DCI2K24"), wxT("DCI2K48"), wxT("DCI4K")};
-			progressionBox = new wxRadioBox(panel, OPJENCO_PROGRESSION,
-				wxT("Progression order/profile"),
-				wxDefaultPosition, wxDefaultSize,
-				WXSIZEOF(choices),
-				choices,
-				3,
-				wxRA_SPECIFY_COLS);
-			progressionBox->SetSelection(wxGetApp().m_progression);
-
-		subtopSizer->Add(progressionBox, 0, wxGROW | wxALL, 3);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-
-wxPanel* OPJEncoderDialog::CreatePart1_2SettingsPage(wxWindow* parent)
-{
-    wxPanel* panel = new wxPanel(parent, wxID_ANY);
-
-	// top sizer
-    wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
-
-	// add some space
-	//topSizer->AddSpacer(5);
-
-		// sub top sizer
-		wxFlexGridSizer *subtopSizer = new wxFlexGridSizer(2, 3, 3);
-			
-			// resilience settings, column
-			wxStaticBox* resilBox = new wxStaticBox(panel, wxID_ANY, wxT("Error resilience"));
-			wxBoxSizer* resilSizer = new wxStaticBoxSizer(resilBox, wxVERTICAL);
-
-				// resil2 sizer, row
-				wxBoxSizer* resil2Sizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// SOP check box
-				resil2Sizer->Add(
-					m_sopCheck = new wxCheckBox(panel, OPJENCO_ENABLESOP, wxT("SOP"),
-						wxDefaultPosition, wxDefaultSize),
-						0, wxGROW | wxALL, 3);
-				m_sopCheck->SetValue(wxGetApp().m_enablesop);
-
-				// EPH check box
-				resil2Sizer->Add(
-					m_ephCheck = new wxCheckBox(panel, OPJENCO_ENABLEEPH, wxT("EPH"),
-						wxDefaultPosition, wxDefaultSize),
-						0, wxGROW | wxALL, 3);
-				m_ephCheck->SetValue(wxGetApp().m_enableeph);
-
-			resilSizer->Add(resil2Sizer, 0, wxGROW | wxALL, 3);
-
-			// separation
-			resilSizer->Add(new wxStaticLine(panel, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 3);
-
-				// resil3 sizer, row
-				wxFlexGridSizer* resil3Sizer = new wxFlexGridSizer(3, 3, 3);
-
-				// BYPASS check box
-				resil3Sizer->Add(
-					m_enablebypassCheck = new wxCheckBox(panel, OPJENCO_ENABLEBYPASS, wxT("BYPASS"),
-					wxDefaultPosition, wxDefaultSize),
-					0, wxGROW | wxALL, 3);
-				m_enablebypassCheck->SetValue(wxGetApp().m_enablebypass);
-
-				// RESET check box
-				resil3Sizer->Add(
-					m_enableresetCheck = new wxCheckBox(panel, OPJENCO_ENABLERESET, wxT("RESET"),
-					wxDefaultPosition, wxDefaultSize),
-					0, wxGROW | wxALL, 3);
-				m_enableresetCheck->SetValue(wxGetApp().m_enablereset);
-
-				// RESTART check box
-				resil3Sizer->Add(
-					m_enablerestartCheck = new wxCheckBox(panel, OPJENCO_ENABLERESTART, wxT("RESTART"),
-					wxDefaultPosition, wxDefaultSize),
-					0, wxGROW | wxALL, 3);
-				m_enablerestartCheck->SetValue(wxGetApp().m_enablerestart);
-
-				// VSC check box
-				resil3Sizer->Add(
-					m_enablevscCheck = new wxCheckBox(panel, OPJENCO_ENABLEVSC, wxT("VSC"),
-					wxDefaultPosition, wxDefaultSize),
-					0, wxGROW | wxALL, 3);
-				m_enablevscCheck->SetValue(wxGetApp().m_enablevsc);
-
-				// ERTERM check box
-				resil3Sizer->Add(
-					m_enableertermCheck = new wxCheckBox(panel, OPJENCO_ENABLEERTERM, wxT("ERTERM"),
-					wxDefaultPosition, wxDefaultSize),
-					0, wxGROW | wxALL, 3);
-				m_enableertermCheck->SetValue(wxGetApp().m_enableerterm);
-
-				// SEGMARK check box
-				resil3Sizer->Add(
-					m_enablesegmarkCheck = new wxCheckBox(panel, OPJENCO_ENABLESEGMARK, wxT("SEGMARK"),
-					wxDefaultPosition, wxDefaultSize),
-					0, wxGROW | wxALL, 3);
-				m_enablesegmarkCheck->SetValue(wxGetApp().m_enablesegmark);
-
-			resilSizer->Add(resil3Sizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(resilSizer, 0, wxGROW | wxALL, 3);
-
-			// ROI settings, column
-			wxStaticBox* roiBox = new wxStaticBox(panel, wxID_ANY, wxT("Region Of Interest"));
-			wxBoxSizer* roiSizer = new wxStaticBoxSizer(roiBox, wxVERTICAL);
-
-				// component number sizer, row
-				wxBoxSizer* roicompSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				roicompSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Component:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				roicompSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				roicompSizer->Add(
-					/*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROICOMP,
-								wxT("0"),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								0, 256, 0),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			roiSizer->Add(roicompSizer, 0, wxGROW | wxALL, 3);
-
-				// upshift sizer, row
-				wxBoxSizer* roishiftSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				roishiftSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Upshift:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				roishiftSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				roishiftSizer->Add(
-					/*m_layerCtrl =*/ new wxSpinCtrl(panel, OPJENCO_ROISHIFT,
-								wxT("0"),
-								wxDefaultPosition, wxSize(80, wxDefaultCoord),
-								wxSP_ARROW_KEYS,
-								0, 37, 0),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-
-			roiSizer->Add(roishiftSizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(roiSizer, 0, wxGROW | wxALL, 3);
-
-			// POC settings, column
-			wxStaticBox* pocBox = new wxStaticBox(panel, wxID_ANY, wxT("POC"));
-			wxBoxSizer* pocSizer = new wxStaticBoxSizer(pocBox, wxVERTICAL);
-
-			// POC check box
-			pocSizer->Add(
-				m_enablepocCheck = new wxCheckBox(panel, OPJENCO_ENABLEPOC, wxT("Enabled (tn=rs,cs,le,re,ce,pr)"),
-				wxDefaultPosition, wxDefaultSize),
-				0, wxGROW | wxALL, 3);
-			m_enablepocCheck->SetValue(wxGetApp().m_enablepoc);
-
-				// POC sizer, row
-				wxBoxSizer* pocspecSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				pocspecSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&Changes:")),
-								0, wxALL | wxALIGN_TOP, 3);
-
-				// add some horizontal space
-				pocspecSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				pocspecSizer->Add(
-					m_pocCtrl = new wxTextCtrl(panel, OPJENCO_POCSPEC,
-								wxGetApp().m_poc,
-								wxDefaultPosition, wxSize(140, 60),
-								wxTE_LEFT | wxTE_MULTILINE),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-				m_pocCtrl->Enable(wxGetApp().m_enablepoc);
-
-			pocSizer->Add(pocspecSizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(pocSizer, 0, wxGROW | wxALL, 3);
-			
-			// Comment settings, column
-			wxStaticBox* commentBox = new wxStaticBox(panel, wxID_ANY, wxT("Comment"));
-			wxBoxSizer* commentSizer = new wxStaticBoxSizer(commentBox, wxVERTICAL);
-
-			// commenting check box
-			commentSizer->Add(
-				m_enablecommCheck = new wxCheckBox(panel, OPJENCO_ENABLECOMM, wxT("Enabled (empty to reset)"),
-				wxDefaultPosition, wxDefaultSize),
-				0, wxGROW | wxALL, 3);
-			m_enablecommCheck->SetValue(wxGetApp().m_enablecomm);
-
-			// add some horizontal space
-			commentSizer->Add(3, 3, 1, wxALL, 0);
-
-			// add the value control
-			commentSizer->Add(
-				m_commentCtrl = new wxTextCtrl(panel, OPJENCO_COMMENTTEXT,
-							wxGetApp().m_comment,
-							wxDefaultPosition, wxSize(wxDefaultCoord, 60),
-							wxTE_LEFT | wxTE_MULTILINE),
-				0, wxGROW | wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-			m_commentCtrl->Enable(wxGetApp().m_enablecomm);
-
-		subtopSizer->Add(commentSizer, 0, wxGROW | wxALL, 3);
-
-			// Index file settings, column
-			wxStaticBox* indexBox = new wxStaticBox(panel, wxID_ANY, wxT("Indexing"));
-			wxBoxSizer* indexSizer = new wxStaticBoxSizer(indexBox, wxVERTICAL);
-
-			// indexing check box
-			indexSizer->Add(
-				m_enableidxCheck = new wxCheckBox(panel, OPJENCO_ENABLEINDEX, wxT("Enabled"),
-				wxDefaultPosition, wxDefaultSize),
-				0, wxGROW | wxALL, 3);
-			m_enableidxCheck->SetValue(wxGetApp().m_enableidx);
-
-				// index file sizer, row
-				wxBoxSizer* indexnameSizer = new wxBoxSizer(wxHORIZONTAL);
-
-				// add some text
-				indexnameSizer->Add(new wxStaticText(panel, wxID_ANY, wxT("&File name:")),
-								0, wxALL | wxALIGN_CENTER_VERTICAL, 3);
-
-				// add some horizontal space
-				indexnameSizer->Add(3, 3, 1, wxALL, 0);
-
-				// add the value control
-				indexnameSizer->Add(
-					m_indexCtrl = new wxTextCtrl(panel, OPJENCO_INDEXNAME,
-								wxGetApp().m_index,
-								wxDefaultPosition, wxSize(120, wxDefaultCoord),
-								wxTE_LEFT),
-					0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 3);
-				m_indexCtrl->Enable(wxGetApp().m_enableidx);
-
-			indexSizer->Add(indexnameSizer, 0, wxGROW | wxALL, 3);
-
-		subtopSizer->Add(indexSizer, 0, wxGROW | wxALL, 3);
-
-	topSizer->Add(subtopSizer, 1, wxGROW | wxALIGN_CENTRE | wxALL, 5);
-
-	// assign top and fit it
-    panel->SetSizer(topSizer);
-    topSizer->Fit(panel);
-
-    return panel;
-}
-
-void OPJEncoderDialog::OnEnableComm(wxCommandEvent& event)
-{
-	if (event.IsChecked()) {
-		wxLogMessage(wxT("Comment enabled"));
-		m_commentCtrl->Enable(true);
-	} else {
-		wxLogMessage(wxT("Comment disabled"));
-		m_commentCtrl->Enable(false);
-	}
-
-}
-
-void OPJEncoderDialog::OnEnableIdx(wxCommandEvent& event)
-{
-	if (event.IsChecked()) {
-		wxLogMessage(wxT("Index enabled"));
-		m_indexCtrl->Enable(true);
-	} else {
-		wxLogMessage(wxT("Index disabled"));
-		m_indexCtrl->Enable(false);
-	}
-
-}
-
-void OPJEncoderDialog::OnEnablePoc(wxCommandEvent& event)
-{
-	if (event.IsChecked()) {
-		wxLogMessage(wxT("POC enabled"));
-		m_pocCtrl->Enable(true);
-	} else {
-		wxLogMessage(wxT("POC disabled"));
-		m_pocCtrl->Enable(false);
-	}
-
-}
-
-void OPJEncoderDialog::OnRadioQualityRate(wxCommandEvent& event)
-{
-	if (event.GetId() == OPJENCO_QUALITYRADIO) {
-		wxLogMessage(wxT("Quality selected"));
-		m_rateCtrl->Enable(false);
-		m_qualityCtrl->Enable(true);
-	} else {
-		wxLogMessage(wxT("Rate selected"));
-		m_rateCtrl->Enable(true);
-		m_qualityCtrl->Enable(false);
-	}
-}
-
-#ifdef USE_JPWL
-void OPJEncoderDialog::OnEnableJPWL(wxCommandEvent& event)
-{
-	int specno;
-
-	if (event.IsChecked()) {
-		wxLogMessage(wxT("JPWL enabled"));
-		for (specno = 0; specno < MYJPWL_MAX_NO_TILESPECS; specno++) {
-			m_hprotChoice[specno]->Enable(true);
-			m_htileCtrl[specno]->Enable(true);
-			m_pprotChoice[specno]->Enable(true);
-			m_ptileCtrl[specno]->Enable(true);
-			m_ppackCtrl[specno]->Enable(true);
-			m_sensiChoice[specno]->Enable(true);
-			m_stileCtrl[specno]->Enable(true);
-		}
-		OnHprotSelect(event);
-		OnPprotSelect(event);
-		OnSensiSelect(event);
-	} else {
-		wxLogMessage(wxT("JPWL disabled"));
-		for (specno = 0; specno < MYJPWL_MAX_NO_TILESPECS; specno++) {
-			m_hprotChoice[specno]->Enable(false);
-			m_htileCtrl[specno]->Enable(false);
-			m_pprotChoice[specno]->Enable(false);
-			m_ptileCtrl[specno]->Enable(false);
-			m_ppackCtrl[specno]->Enable(false);
-			m_sensiChoice[specno]->Enable(false);
-			m_stileCtrl[specno]->Enable(false);
-		}
-	}
-
-}
-
-void OPJEncoderDialog::OnHprotSelect(wxCommandEvent& event)
-{
-	int specno;
-
-	// deactivate properly
-	for (specno = MYJPWL_MAX_NO_TILESPECS - 1; specno >= 0; specno--) {
-		if (!m_hprotChoice[specno]->GetSelection()) {
-			m_hprotChoice[specno]->Enable(false);
-			m_htileCtrl[specno]->Enable(false);
-		} else
-			break;
-	}
-	if (specno < (MYJPWL_MAX_NO_TILESPECS - 1)) {
-		m_hprotChoice[specno + 1]->Enable(true);
-		m_htileCtrl[specno + 1]->Enable(true);
-	}
-
-	//wxLogMessage(wxT("hprot changed: %d"), specno);
-}
-
-void OPJEncoderDialog::OnPprotSelect(wxCommandEvent& event)
-{
-	int specno;
-
-	// deactivate properly
-	for (specno = MYJPWL_MAX_NO_TILESPECS - 1; specno >= 0; specno--) {
-		if (!m_pprotChoice[specno]->GetSelection()) {
-			m_pprotChoice[specno]->Enable(false);
-			m_ptileCtrl[specno]->Enable(false);
-			m_ppackCtrl[specno]->Enable(false);
-		} else
-			break;
-	}
-	if (specno < (MYJPWL_MAX_NO_TILESPECS - 1)) {
-		m_pprotChoice[specno + 1]->Enable(true);
-		m_ptileCtrl[specno + 1]->Enable(true);
-		m_ppackCtrl[specno + 1]->Enable(true);
-	}
-
-	//wxLogMessage(wxT("pprot changed: %d"), specno);
-}
-
-void OPJEncoderDialog::OnSensiSelect(wxCommandEvent& event)
-{
-	int specno;
-
-	// deactivate properly
-	for (specno = MYJPWL_MAX_NO_TILESPECS - 1; specno >= 0; specno--) {
-		if (!m_sensiChoice[specno]->GetSelection()) {
-			m_sensiChoice[specno]->Enable(false);
-			m_stileCtrl[specno]->Enable(false);
-		} else
-			break;
-	}
-	if (specno < (MYJPWL_MAX_NO_TILESPECS - 1)) {
-		m_sensiChoice[specno + 1]->Enable(true);
-		m_stileCtrl[specno + 1]->Enable(true);
-	}
-
-	//wxLogMessage(wxT("sprot changed: %d"), specno);
-}
-
-
-#endif // USE_JPWL
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJThreads.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJThreads.cpp
deleted file mode 100644
index 3c93ee2..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJThreads.cpp
+++ /dev/null
@@ -1,1268 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "OPJViewer.h"
-
-
-/////////////////////////////////////////////////////////////////////
-// Encoding thread class
-/////////////////////////////////////////////////////////////////////
-
-OPJEncoThread::OPJEncoThread(OPJCanvas *canvas)
-        : wxThread()
-{
-    m_count = 0;
-    m_canvas = canvas;
-}
-
-void OPJEncoThread::WriteText(const wxString& text)
-{
-    wxString msg;
-
-    // before doing any GUI calls we must ensure that this thread is the only
-    // one doing it!
-
-#ifndef __WXGTK__ 
-    wxMutexGuiEnter();
-#endif // __WXGTK__
-
-    msg << text;
-    m_canvas->WriteText(msg);
-
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif // __WXGTK__
-}
-
-void OPJEncoThread::OnExit()
-{
-    wxCriticalSectionLocker locker(wxGetApp().m_enco_critsect);
-
-    wxArrayThread& ethreads = wxGetApp().m_enco_threads;
-    ethreads.Remove(this);
-
-    if (ethreads.IsEmpty() )
-    {
-        // signal the main thread that there are no more threads left if it is
-        // waiting for us
-        if (wxGetApp().m_enco_waitingUntilAllDone) {
-            wxGetApp().m_enco_waitingUntilAllDone = false;
-            wxGetApp().m_enco_semAllDone.Post();
-        }
-    }
-}
-
-void *OPJEncoThread::Entry()
-{
-    wxString text;
-
-	srand(GetId());
-	//int m_countnum = rand() % 9;
-    //text.Printf(wxT("Deco thread 0x%lx started (priority = %u, time = %d)."),
-    //            GetId(), GetPriority(), m_countnum);
-    text.Printf(wxT("Enco thread %d started"), m_canvas->m_childframe->m_winnumber);
-    WriteText(text);
-
-	// set handler properties
-	wxJPEG2000Handler *jpeg2000handler = (wxJPEG2000Handler *) wxImage::FindHandler(wxBITMAP_TYPE_JPEG2000);
-	jpeg2000handler->m_subsampling = wxGetApp().m_subsampling;
-	jpeg2000handler->m_origin = wxGetApp().m_origin;
-	jpeg2000handler->m_rates = wxGetApp().m_rates;
-	jpeg2000handler->m_quality = wxGetApp().m_quality;
-	jpeg2000handler->m_enablequality = wxGetApp().m_enablequality;
-	jpeg2000handler->m_multicomp = wxGetApp().m_multicomp;
-	jpeg2000handler->m_irreversible = wxGetApp().m_irreversible;
-	jpeg2000handler->m_resolutions = wxGetApp().m_resolutions;
-	jpeg2000handler->m_progression = wxGetApp().m_progression;
-	jpeg2000handler->m_cbsize = wxGetApp().m_cbsize;
-	jpeg2000handler->m_prsize = wxGetApp().m_prsize;
-	jpeg2000handler->m_tsize = wxGetApp().m_tsize;
-	jpeg2000handler->m_torigin = wxGetApp().m_torigin;
-	jpeg2000handler->m_enablesop = wxGetApp().m_enablesop;
-	jpeg2000handler->m_enableeph = wxGetApp().m_enableeph;
-	jpeg2000handler->m_enablebypass = wxGetApp().m_enablebypass;
-	jpeg2000handler->m_enablerestart = wxGetApp().m_enablerestart;
-	jpeg2000handler->m_enablereset = wxGetApp().m_enablereset;
-	jpeg2000handler->m_enablesegmark = wxGetApp().m_enablesegmark;
-	jpeg2000handler->m_enableerterm = wxGetApp().m_enableerterm;
-	jpeg2000handler->m_enablevsc = wxGetApp().m_enablevsc;
-	jpeg2000handler->m_enableidx = wxGetApp().m_enableidx;
-	jpeg2000handler->m_index = m_canvas->m_savename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + wxGetApp().m_index;
-	jpeg2000handler->m_enablecomm = wxGetApp().m_enablecomm;
-	jpeg2000handler->m_comment = wxGetApp().m_comment;
-	jpeg2000handler->m_enablepoc = wxGetApp().m_enablepoc;
-	jpeg2000handler->m_poc = wxGetApp().m_poc;
-
-	// save the file
-	if (!m_canvas->m_image100.SaveFile(m_canvas->m_savename.GetFullPath(), (wxBitmapType) wxBITMAP_TYPE_JPEG2000)) {
-		WriteText(wxT("Can't save image"));
-		return NULL;
-	}
-
-    text.Printf(wxT("Enco thread %d finished"), m_canvas->m_childframe->m_winnumber);
-    WriteText(text);
-    return NULL;
-}
-
-
-/////////////////////////////////////////////////////////////////////
-// Decoding thread class
-/////////////////////////////////////////////////////////////////////
-OPJDecoThread::OPJDecoThread(OPJCanvas *canvas)
-        : wxThread()
-{
-    m_count = 0;
-    m_canvas = canvas;
-}
-
-void OPJDecoThread::WriteText(const wxString& text)
-{
-    wxString msg;
-	
-	// we use a fake event and post it for inter-thread gui communication
-    wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, OPJFRAME_THREADLOGMSG);
-    event.SetInt(-1); 
-	msg << text;
-	event.SetString(msg);
-    wxPostEvent(this->m_canvas->m_childframe->m_frame, event);
-
-/*
-    // before doing any GUI calls we must ensure that this thread is the only
-    // one doing it!
-
-#ifndef __WXGTK__ 
-    wxMutexGuiEnter();
-#endif // __WXGTK__
-
-    msg << text;
-    m_canvas->WriteText(msg);
-
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif // __WXGTK__
-*/
-}
-
-void OPJDecoThread::OnExit()
-{
-    wxCriticalSectionLocker locker(wxGetApp().m_deco_critsect);
-
-    wxArrayThread& dthreads = wxGetApp().m_deco_threads;
-    dthreads.Remove(this);
-
-    if (dthreads.IsEmpty() )
-    {
-        // signal the main thread that there are no more threads left if it is
-        // waiting for us
-        if (wxGetApp().m_deco_waitingUntilAllDone) {
-            wxGetApp().m_deco_waitingUntilAllDone = false;
-            wxGetApp().m_deco_semAllDone.Post();
-        }
-    }
-}
-
-void *OPJDecoThread::Entry()
-{
-
-    wxString text;
-
-	//srand(GetId());
-	//int m_countnum = rand() % 9;
-    //text.Printf(wxT("Deco thread 0x%lx started (priority = %u, time = %d)."),
-    //            GetId(), GetPriority(), m_countnum);
-
-	// we have started
-    text.Printf(wxT("Deco thread %d started"), m_canvas->m_childframe->m_winnumber);
-    WriteText(text);
-
-	// prepare dummy wximage
-    wxBitmap bitmap(100, 100);
-    wxImage image(100, 100, true); //= bitmap.ConvertToImage();
-    image.Destroy();
-
-	// show image full name
-	WriteText(m_canvas->m_fname.GetFullPath());
-
-	// set handler properties
-	wxJPEG2000Handler *jpeg2000handler = (wxJPEG2000Handler *) wxImage::FindHandler(wxBITMAP_TYPE_JPEG2000);
-	jpeg2000handler->m_reducefactor = wxGetApp().m_reducefactor;
-	jpeg2000handler->m_qualitylayers = wxGetApp().m_qualitylayers;
-	jpeg2000handler->m_components = wxGetApp().m_components;
-	jpeg2000handler->m_framenum = wxGetApp().m_framenum;
-#ifdef USE_JPWL
-	jpeg2000handler->m_enablejpwl = wxGetApp().m_enablejpwl;
-	jpeg2000handler->m_expcomps = wxGetApp().m_expcomps;
-	jpeg2000handler->m_maxtiles = wxGetApp().m_maxtiles;
-#endif // USE_JPWL
-
-#ifdef USE_MXF
-	wxMXFHandler *mxfffhandler = (wxMXFHandler *) wxImage::FindHandler(wxBITMAP_TYPE_MXF);
-	mxfffhandler->m_reducefactor = wxGetApp().m_reducefactor;
-	mxfffhandler->m_qualitylayers = wxGetApp().m_qualitylayers;
-	mxfffhandler->m_components = wxGetApp().m_components;
-	mxfffhandler->m_framenum = wxGetApp().m_framenum;
-	mxfffhandler->m_filename = m_canvas->m_fname;
-#ifdef USE_JPWL
-	mxfffhandler->m_enablejpwl = wxGetApp().m_enablejpwl;
-	mxfffhandler->m_expcomps = wxGetApp().m_expcomps;
-	mxfffhandler->m_maxtiles = wxGetApp().m_maxtiles;
-#endif // USE_JPWL
-#endif // USE_MXF
-
-	// if decoding is enabled...
-	if (wxGetApp().m_enabledeco) {
-
-		// load the file
-		if (!image.LoadFile(m_canvas->m_fname.GetFullPath(), wxBITMAP_TYPE_ANY, 0)) {
-			WriteText(wxT("Can't load image!"));
-			return NULL;
-		}
-
-	} else {
-
-		// display a warning
-		if (!image.Create(300, 5, false)) {
-			WriteText(wxT("Can't create image!"));
-			return NULL;
-		}
-
-	}
-
-	// assign 100% image
-    m_canvas->m_image100 = wxBitmap(image);
-
-	// signal the frame to refresh the canvas
-    wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, OPJFRAME_VIEWFIT);
-	event.SetString(wxT("Fit me"));
-    event.SetInt(m_canvas->m_childframe->m_winnumber); 
-    wxPostEvent(m_canvas->m_childframe->m_frame, event);
-
-	// find a fit-to-width zoom
-	/*int zooml, wzooml, hzooml;
-	wxSize clientsize = m_canvas->GetClientSize();
-	wzooml = (int) floor(100.0 * (double) clientsize.GetWidth() / (double) (2 * OPJ_CANVAS_BORDER + image.GetWidth()));
-	hzooml = (int) floor(100.0 * (double) clientsize.GetHeight() / (double) (2 * OPJ_CANVAS_BORDER + image.GetHeight()));
-	zooml = wxMin(100, wxMin(wzooml, hzooml));*/
-
-	// fit to width
-#ifndef __WXGTK__
-	//m_canvas->m_childframe->m_frame->Rescale(zooml, m_canvas->m_childframe);
-#endif // __WXGTK__
-
-	//m_canvas->m_image = m_canvas->m_image100;
-	//m_canvas->Refresh();
-	//m_canvas->SetScrollbars(20, 20, (int)(0.5 + (double) image.GetWidth() / 20.0), (int)(0.5 + (double) image.GetHeight() / 20.0));
-
-    //text.Printf(wxT("Deco thread 0x%lx finished."), GetId());
-    text.Printf(wxT("Deco thread %d finished"), m_canvas->m_childframe->m_winnumber);
-    WriteText(text);
-    return NULL;
-
-}
-
-/////////////////////////////////////////////////////////////////////
-// Parsing thread class
-/////////////////////////////////////////////////////////////////////
-
-OPJParseThread::OPJParseThread(OPJMarkerTree *tree, wxTreeItemId parentid)
-        : wxThread()
-{
-    m_count = 0;
-    m_tree = tree;
-	m_parentid = parentid;
-}
-
-void OPJParseThread::WriteText(const wxString& text)
-{
-    wxString msg;
-	
-	// we use a fake event and post it for inter-thread gui communication
-    wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, OPJFRAME_THREADLOGMSG);
-    event.SetInt(-1); 
-	msg << text;
-	event.SetString(msg);
-    wxPostEvent(this->m_tree->m_childframe->m_frame, event);
-
-/*    // before doing any GUI calls we must ensure that this thread is the only
-    // one doing it!
-
-#ifndef __WXGTK__ 
-    wxMutexGuiEnter();
-#endif // __WXGTK
-
-    msg << text;
-    m_tree->WriteText(msg);
-
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif // __WXGTK*/
-}
-
-void OPJParseThread::OnExit()
-{
-    wxCriticalSectionLocker locker(wxGetApp().m_parse_critsect);
-
-    wxArrayThread& threads = wxGetApp().m_parse_threads;
-    threads.Remove(this);
-
-    if (threads.IsEmpty()) {
-        // signal the main thread that there are no more threads left if it is
-        // waiting for us
-        if (wxGetApp().m_parse_waitingUntilAllDone) {
-            wxGetApp().m_parse_waitingUntilAllDone = false;
-            wxGetApp().m_parse_semAllDone.Post();
-        }
-    }
-}
-
-void *OPJParseThread::Entry()
-{
-
-	printf("Entering\n\n");
-
-    wxString text;
-
-	srand(GetId());
-	int m_countnum = rand() % 9;
-    text.Printf(wxT("Parse thread 0x%lx started (priority = %u, time = %d)."),
-            GetId(), GetPriority(), m_countnum);
-    WriteText(text);
-    LoadFile(m_tree->m_fname);
-    text.Printf(wxT("Parse thread 0x%lx finished."), GetId());
-    WriteText(text);
-
-
-    //wxLogMessage(wxT("Entering\n")); //test wxLog thread safeness
-
-	//wxBusyCursor wait;
-	//wxBusyInfo wait(wxT("Decoding image ..."));
-
-
-    /*for ( m_count = 0; m_count < m_countnum; m_count++ )
-    {
-        // check if we were asked to exit
-        if ( TestDestroy() )
-            break;
-
-        text.Printf(wxT("[%u] Parse thread 0x%lx here."), m_count, GetId());
-        WriteText(text);
-
-        // wxSleep() can't be called from non-GUI thread!
-        wxThread::Sleep(10);
-    }*/
-
-    // wxLogMessage(text); -- test wxLog thread safeness
-
-	printf("Exiting\n\n");
-
-    return NULL;
-}
-
-
-///////////////////////////////////////////
-// Parsing hread and related
-///////////////////////////////////////////
-
-#if USE_GENERIC_TREECTRL
-BEGIN_EVENT_TABLE(OPJMarkerTree, wxGenericTreeCtrl)
-#else
-BEGIN_EVENT_TABLE(OPJMarkerTree, wxTreeCtrl)
-#endif
-    /*EVT_TREE_BEGIN_DRAG(TreeTest_Ctrl, OPJMarkerTree::OnBeginDrag)
-    EVT_TREE_BEGIN_RDRAG(TreeTest_Ctrl, OPJMarkerTree::OnBeginRDrag)
-    EVT_TREE_END_DRAG(TreeTest_Ctrl, OPJMarkerTree::OnEndDrag)*/
-    /*EVT_TREE_BEGIN_LABEL_EDIT(TreeTest_Ctrl, OPJMarkerTree::OnBeginLabelEdit)
-    EVT_TREE_END_LABEL_EDIT(TreeTest_Ctrl, OPJMarkerTree::OnEndLabelEdit)*/
-    /*EVT_TREE_DELETE_ITEM(TreeTest_Ctrl, OPJMarkerTree::OnDeleteItem)*/
-#if 0       // there are so many of those that logging them causes flicker
-    /*EVT_TREE_GET_INFO(TreeTest_Ctrl, OPJMarkerTree::OnGetInfo)*/
-#endif
-    /*EVT_TREE_SET_INFO(TreeTest_Ctrl, OPJMarkerTree::OnSetInfo)
-    EVT_TREE_ITEM_EXPANDED(TreeTest_Ctrl, OPJMarkerTree::OnItemExpanded)*/
-    EVT_TREE_ITEM_EXPANDING(TreeTest_Ctrl, OPJMarkerTree::OnItemExpanding)
-    /*EVT_TREE_ITEM_COLLAPSED(TreeTest_Ctrl, OPJMarkerTree::OnItemCollapsed)
-    EVT_TREE_ITEM_COLLAPSING(TreeTest_Ctrl, OPJMarkerTree::OnItemCollapsing)*/
-
-    EVT_TREE_SEL_CHANGED(TreeTest_Ctrl, OPJMarkerTree::OnSelChanged)
-    /*EVT_TREE_SEL_CHANGING(TreeTest_Ctrl, OPJMarkerTree::OnSelChanging)*/
-    /*EVT_TREE_KEY_DOWN(TreeTest_Ctrl, OPJMarkerTree::OnTreeKeyDown)*/
-    /*EVT_TREE_ITEM_ACTIVATED(TreeTest_Ctrl, OPJMarkerTree::OnItemActivated)*/
-
-    // so many differents ways to handle right mouse button clicks...
-    /*EVT_CONTEXT_MENU(OPJMarkerTree::OnContextMenu)*/
-    // EVT_TREE_ITEM_MENU is the preferred event for creating context menus
-    // on a tree control, because it includes the point of the click or item,
-    // meaning that no additional placement calculations are required.
-    EVT_TREE_ITEM_MENU(TreeTest_Ctrl, OPJMarkerTree::OnItemMenu)
-    /*EVT_TREE_ITEM_RIGHT_CLICK(TreeTest_Ctrl, OPJMarkerTree::OnItemRClick)*/
-
-    /*EVT_RIGHT_DOWN(OPJMarkerTree::OnRMouseDown)
-    EVT_RIGHT_UP(OPJMarkerTree::OnRMouseUp)
-    EVT_RIGHT_DCLICK(OPJMarkerTree::OnRMouseDClick)*/
-END_EVENT_TABLE()
-
-// OPJMarkerTree implementation
-#if USE_GENERIC_TREECTRL
-IMPLEMENT_DYNAMIC_CLASS(OPJMarkerTree, wxGenericTreeCtrl)
-#else
-IMPLEMENT_DYNAMIC_CLASS(OPJMarkerTree, wxTreeCtrl)
-#endif
-
-OPJMarkerTree::OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
-           const wxPoint& pos, const wxSize& size, long style)
-          : wxTreeCtrl(parent, id, pos, size, style)
-{
-    m_reverseSort = false;
-	m_fname = fname;
-
-	m_peektextCtrl = ((OPJFrame *) (parent->GetParent()->GetParent()))->m_textCtrlbrowse;
-    CreateImageList();
-
-    // Add some items to the tree
-    //AddTestItemsToTree(5, 5);
-    int image = wxGetApp().ShowImages() ? OPJMarkerTree::TreeCtrlIcon_Folder : -1;
-    wxTreeItemId rootId = AddRoot(name,
-                                  image, image,
-                                  new OPJMarkerData(name));
-
-    OPJParseThread *pthread = CreateParseThread(0x00, subframe);
-    if (pthread->Run() != wxTHREAD_NO_ERROR)
-        wxLogMessage(wxT("Can't start parse thread!"));
-    else
-		wxLogMessage(wxT("New parse thread started."));
-
-	m_childframe = subframe;
-}
-
-void OPJMarkerTree::CreateImageList(int size)
-{
-    if (size == -1) {
-        SetImageList(NULL);
-        return;
-    }
-    if (size == 0)
-        size = m_imageSize;
-    else
-        m_imageSize = size;
-
-    // Make an image list containing small icons
-    wxImageList *images = new wxImageList(size, size, true);
-
-    // should correspond to TreeCtrlIcon_xxx enum
-    wxBusyCursor wait;
-    wxIcon icons[5];
-    icons[0] = wxIcon(icon1_xpm);
-    icons[1] = wxIcon(icon2_xpm);
-    icons[2] = wxIcon(icon3_xpm);
-    icons[3] = wxIcon(icon4_xpm);
-    icons[4] = wxIcon(icon5_xpm);
-
-    int sizeOrig = icons[0].GetWidth();
-    for (size_t i = 0; i < WXSIZEOF(icons); i++) {
-        if (size == sizeOrig) {
-            images->Add(icons[i]);
-        } else {
-            images->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
-        }
-    }
-
-    AssignImageList(images);
-}
-
-#if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
-void OPJMarkerTree::CreateButtonsImageList(int size)
-{
-    if ( size == -1 ) {
-        SetButtonsImageList(NULL);
-        return;
-    }
-
-    // Make an image list containing small icons
-    wxImageList *images = new wxImageList(size, size, true);
-
-    // should correspond to TreeCtrlIcon_xxx enum
-    wxBusyCursor wait;
-    wxIcon icons[4];
-    icons[0] = wxIcon(icon3_xpm);   // closed
-    icons[1] = wxIcon(icon3_xpm);   // closed, selected
-    icons[2] = wxIcon(icon5_xpm);   // open
-    icons[3] = wxIcon(icon5_xpm);   // open, selected
-
-    for ( size_t i = 0; i < WXSIZEOF(icons); i++ ) {
-        int sizeOrig = icons[i].GetWidth();
-        if ( size == sizeOrig ) {
-            images->Add(icons[i]);
-        } else {
-            images->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
-        }
-    }
-
-    AssignButtonsImageList(images);
-#else
-void OPJMarkerTree::CreateButtonsImageList(int WXUNUSED(size))
-{
-#endif
-}
-
-void OPJParseThread::LoadFile(wxFileName fname)
-{
-	wxTreeItemId rootid;
-
-	// this is the root node
-	int image = wxGetApp().ShowImages() ? m_tree->TreeCtrlIcon_Folder : -1;
-
-	if (this->m_parentid) {
-		// leaf of a tree
-		rootid = m_parentid;
-		m_tree->SetItemText(rootid, wxT("Parsing..."));
-
-	} else {
-
-		// delete the existing tree hierarchy
-		m_tree->DeleteAllItems();
-
-		// new tree
-		rootid = m_tree->AddRoot(wxT("Parsing..."),
-			image,
-			image,
-			new OPJMarkerData(fname.GetFullPath())
-			);
-		//m_tree->SetItemFont(rootid, *wxITALIC_FONT);
-		m_tree->SetItemBold(rootid);
-	}
-
-	// open the file
-	wxFile m_file(fname.GetFullPath().c_str(), wxFile::read);
-
-	// parsing enabled?
-	if (wxGetApp().m_enableparse) {
-
-		// what is the extension?
-		if ((fname.GetExt() == wxT("j2k")) || (fname.GetExt() == wxT("j2c"))) {
-
-			// parse the file
-			ParseJ2KFile(&m_file, 0, m_file.Length(), rootid);
-
-		} else if ((fname.GetExt() == wxT("jp2")) || (fname.GetExt() == wxT("mj2"))) {
-
-			// parse the file
-			if (this->m_parentid) {
-				//WriteText(wxT("Only a subsection of jp2"));
-				OPJMarkerData *data = (OPJMarkerData *) m_tree->GetItemData(rootid);
-				ParseJ2KFile(&m_file, data->m_start, data->m_length, rootid);
-				m_tree->Expand(rootid);
-
-			} else {
-				// as usual
-				ParseJP2File(&m_file, 0, m_file.Length(), rootid);
-			}
-
-		} else {
-
-			// unknown extension
-			WriteText(wxT("Unknown file format!"));
-
-		}
-
-	}
-
-	// this is the root node
-	if (this->m_parentid)
-		m_tree->SetItemText(rootid, wxT("Codestream"));
-	else
-		//m_tree->SetItemText(rootid, wxString::Format(wxT("%s (%d B)"), fname.GetFullName(), m_file.Length()));
-		m_tree->SetItemText(rootid, fname.GetFullName());
-
-	// close the file
-	m_file.Close();
-
-	WriteText(wxT("Parsing finished!"));
-}
-
-/*int OPJMarkerTree::OnCompareItems(const wxTreeItemId& item1,
-                               const wxTreeItemId& item2)
-{
-    if ( m_reverseSort )
-    {
-        // just exchange 1st and 2nd items
-        return wxTreeCtrl::OnCompareItems(item2, item1);
-    }
-    else
-    {
-        return wxTreeCtrl::OnCompareItems(item1, item2);
-    }
-}*/
-
-/*void OPJMarkerTree::AddItemsRecursively(const wxTreeItemId& idParent,
-                                     size_t numChildren,
-                                     size_t depth,
-                                     size_t folder)
-{
-    if ( depth > 0 )
-    {
-        bool hasChildren = depth > 1;
-
-        wxString str;
-        for ( size_t n = 0; n < numChildren; n++ )
-        {
-            // at depth 1 elements won't have any more children
-            if ( hasChildren )
-                str.Printf(wxT("%s child %u"), wxT("Folder"), unsigned(n + 1));
-            else
-                str.Printf(wxT("%s child %u.%u"), wxT("File"), unsigned(folder), unsigned(n + 1));
-
-            // here we pass to AppendItem() normal and selected item images (we
-            // suppose that selected image follows the normal one in the enum)
-            int image, imageSel;
-            if ( wxGetApp().ShowImages() )
-            {
-                image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
-                imageSel = image + 1;
-            }
-            else
-            {
-                image = imageSel = -1;
-            }
-            wxTreeItemId id = AppendItem(idParent, str, image, imageSel,
-                                         new OPJMarkerData(str));
-
-            // and now we also set the expanded one (only for the folders)
-            if ( hasChildren && wxGetApp().ShowImages() )
-            {
-                SetItemImage(id, TreeCtrlIcon_FolderOpened,
-                             wxTreeItemIcon_Expanded);
-            }
-
-            // remember the last child for OnEnsureVisible()
-            if ( !hasChildren && n == numChildren - 1 )
-            {
-                m_lastItem = id;
-            }
-
-            AddItemsRecursively(id, numChildren, depth - 1, n + 1);
-        }
-    }
-    //else: done!
-}*/
-
-/*void OPJMarkerTree::AddTestItemsToTree(size_t numChildren,
-                                    size_t depth)
-{
-    int image = wxGetApp().ShowImages() ? OPJMarkerTree::TreeCtrlIcon_Folder : -1;
-    wxTreeItemId rootId = AddRoot(wxT("Root"),
-                                  image, image,
-                                  new OPJMarkerData(wxT("Root item")));
-    if ( image != -1 )
-    {
-        SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
-    }
-
-    AddItemsRecursively(rootId, numChildren, depth, 0);
-
-    // set some colours/fonts for testing
-    SetItemFont(rootId, *wxITALIC_FONT);
-
-    wxTreeItemIdValue cookie;
-    wxTreeItemId id = GetFirstChild(rootId, cookie);
-    SetItemTextColour(id, *wxBLUE);
-
-    id = GetNextChild(rootId, cookie);
-    id = GetNextChild(rootId, cookie);
-    SetItemTextColour(id, *wxRED);
-    SetItemBackgroundColour(id, *wxLIGHT_GREY);
-}*/
-
-/*void OPJMarkerTree::GetItemsRecursively(const wxTreeItemId& idParent,
-                                     wxTreeItemIdValue cookie)
-{
-    wxTreeItemId id;
-
-    if ( !cookie )
-        id = GetFirstChild(idParent, cookie);
-    else
-        id = GetNextChild(idParent, cookie);
-
-    if ( !id.IsOk() )
-        return;
-
-    wxString text = GetItemText(id);
-    wxLogMessage(text);
-
-    if (ItemHasChildren(id))
-        GetItemsRecursively(id);
-
-    GetItemsRecursively(idParent, cookie);
-}*/
-
-/*void OPJMarkerTree::DoToggleIcon(const wxTreeItemId& item)
-{
-    int image = (GetItemImage(item) == TreeCtrlIcon_Folder)
-                    ? TreeCtrlIcon_File
-                    : TreeCtrlIcon_Folder;
-    SetItemImage(item, image, wxTreeItemIcon_Normal);
-
-    image = (GetItemImage(item) == TreeCtrlIcon_FolderSelected)
-                    ? TreeCtrlIcon_FileSelected
-                    : TreeCtrlIcon_FolderSelected;
-    SetItemImage(item, image, wxTreeItemIcon_Selected);
-}*/
-
-void OPJMarkerTree::LogEvent(const wxChar *name, const wxTreeEvent& event)
-{
-    wxTreeItemId item = event.GetItem();
-    wxString text;
-    if ( item.IsOk() )
-        text << wxT('"') << GetItemText(item).c_str() << wxT('"');
-    else
-        text = wxT("invalid item");
-    wxLogMessage(wxT("%s(%s)"), name, text.c_str());
-}
-
-OPJParseThread *OPJMarkerTree::CreateParseThread(wxTreeItemId parentid, OPJChildFrame *subframe)
-{
-    OPJParseThread *pthread = new OPJParseThread(this, parentid);
-
-    if (pthread->Create() != wxTHREAD_NO_ERROR)
-		wxLogError(wxT("Can't create parse thread!"));
-
-    wxCriticalSectionLocker enter(wxGetApp().m_parse_critsect);
-    wxGetApp().m_parse_threads.Add(pthread);
-
-    return pthread;
-}
-
-
-/*// avoid repetition
-#define TREE_EVENT_HANDLER(name)                                 \
-void OPJMarkerTree::name(wxTreeEvent& event)                        \
-{                                                                \
-    LogEvent(_T(#name), event);                                  \
-    SetLastItem(wxTreeItemId());                                 \
-    event.Skip();                                                \
-}*/
-
-/*TREE_EVENT_HANDLER(OnBeginRDrag)*/
-/*TREE_EVENT_HANDLER(OnDeleteItem)*/
-/*TREE_EVENT_HANDLER(OnGetInfo)
-TREE_EVENT_HANDLER(OnSetInfo)*/
-/*TREE_EVENT_HANDLER(OnItemExpanded)
-TREE_EVENT_HANDLER(OnItemExpanding)*/
-/*TREE_EVENT_HANDLER(OnItemCollapsed)*/
-/*TREE_EVENT_HANDLER(OnSelChanged)
-TREE_EVENT_HANDLER(OnSelChanging)*/
-
-/*#undef TREE_EVENT_HANDLER*/
-
-void OPJMarkerTree::OnItemExpanding(wxTreeEvent& event)
-{
-	wxTreeItemId item = event.GetItem();
-	OPJMarkerData* data = (OPJMarkerData *) GetItemData(item);
-	wxString text;
-
-	if (item.IsOk())
-		text << wxT('"') << GetItemText(item).c_str() << wxT('"');
-	else
-		text = wxT("invalid item");
-
-	if (wxStrcmp(data->GetDesc1(), wxT("INFO-CSTREAM")))
-		return;
-
-	wxLogMessage(wxT("Expanding... (%s -> %s, %s, %d, %d)"),
-		text.c_str(), data->GetDesc1(), data->GetDesc2(),
-		data->m_start, data->m_length);
-
-	// the codestream box is being asked for expansion
-	wxTreeItemIdValue cookie;
-	if (!GetFirstChild(item, cookie).IsOk()) {
-		OPJParseThread *pthread = CreateParseThread(item);
-		if (pthread->Run() != wxTHREAD_NO_ERROR)
-			wxLogMessage(wxT("Can't start parse thread!"));
-		else
-			wxLogMessage(wxT("New parse thread started."));
-	}
-}
-
-void OPJMarkerTree::OnSelChanged(wxTreeEvent& event)
-{
-	int bunch_linesize = 16;
-	int bunch_numlines = 7;
-
-	wxTreeItemId item = event.GetItem();
-	OPJMarkerData* data = (OPJMarkerData *) GetItemData(item);
-	wxString text;
-	int l, c, pos = 0, pre_pos;
-
-	m_peektextCtrl->Clear();
-
-	/*text << wxString::Format(wxT("Selected... (%s -> %s, %s, %d, %d)"),
-		text.c_str(), data->GetDesc1(), data->GetDesc2(),
-		data->m_start, data->m_length) << wxT("\n");*/
-
-	// open the file and browse a little
-	wxFile *fp = new wxFile(m_fname.GetFullPath().c_str(), wxFile::read);
-
-	// go to position claimed
-	fp->Seek(data->m_start, wxFromStart);
-
-	// read a bunch
-	int max_read = wxMin(wxFileOffset(bunch_linesize * bunch_numlines), data->m_length - data->m_start + 1);
-	if (data->m_desc == wxT("MARK (65380)")) {
-		/*wxLogMessage(data->m_desc);*/
-		max_read = data->m_length - data->m_start + 1;
-		bunch_numlines = (int) ceil((float) max_read / (float) bunch_linesize);
-	}
-	unsigned char *buffer = new unsigned char[bunch_linesize * bunch_numlines];
-	fp->Read(buffer, max_read);
-
-	// write the file data between start and stop
-	pos = 0;
-	for (l = 0; l < bunch_numlines; l++) {
-
-		text << wxString::Format(wxT("%010d:"), data->m_start + pos);
-
-		pre_pos = pos;
-
-		// add hex browsing text
-		for (c = 0; c < bunch_linesize; c++) {
-
-			if (!(c % 8))
-				text << wxT(" ");
-
-			if (pos < max_read) {
-				text << wxString::Format(wxT("%02X "), buffer[pos]);
-			} else
-				text << wxT("   ");
-			pos++;
-		}
-
-		text << wxT("    ");
-
-		// add char browsing text
-		for (c = 0; c < bunch_linesize; c++) {
-
-			if (pre_pos < max_read) {
-				if ((buffer[pre_pos] == '\n') ||
-					(buffer[pre_pos] == '\t') ||
-					(buffer[pre_pos] == '\0') ||
-					(buffer[pre_pos] == 0x0D) ||
-					(buffer[pre_pos] == 0x0B))
-					buffer[pre_pos] = ' ';
-				text << wxString::FromAscii((char) buffer[pre_pos]) << wxT(".");
-			} else
-				text << wxT("  ");
-			pre_pos++;
-		}
-
-		text << wxT("\n");
-
-	}
-
-	// close the file
-	fp->Close();
-
-	m_peektextCtrl->WriteText(text);
-
-	delete buffer;
-}
-
-/*void LogKeyEvent(const wxChar *name, const wxKeyEvent& event)
-{
-    wxString key;
-    long keycode = event.GetKeyCode();
-    {
-        switch ( keycode )
-        {
-            case WXK_BACK: key = wxT("BACK"); break;
-            case WXK_TAB: key = wxT("TAB"); break;
-            case WXK_RETURN: key = wxT("RETURN"); break;
-            case WXK_ESCAPE: key = wxT("ESCAPE"); break;
-            case WXK_SPACE: key = wxT("SPACE"); break;
-            case WXK_DELETE: key = wxT("DELETE"); break;
-            case WXK_START: key = wxT("START"); break;
-            case WXK_LBUTTON: key = wxT("LBUTTON"); break;
-            case WXK_RBUTTON: key = wxT("RBUTTON"); break;
-            case WXK_CANCEL: key = wxT("CANCEL"); break;
-            case WXK_MBUTTON: key = wxT("MBUTTON"); break;
-            case WXK_CLEAR: key = wxT("CLEAR"); break;
-            case WXK_SHIFT: key = wxT("SHIFT"); break;
-            case WXK_ALT: key = wxT("ALT"); break;
-            case WXK_CONTROL: key = wxT("CONTROL"); break;
-            case WXK_MENU: key = wxT("MENU"); break;
-            case WXK_PAUSE: key = wxT("PAUSE"); break;
-            case WXK_CAPITAL: key = wxT("CAPITAL"); break;
-            case WXK_END: key = wxT("END"); break;
-            case WXK_HOME: key = wxT("HOME"); break;
-            case WXK_LEFT: key = wxT("LEFT"); break;
-            case WXK_UP: key = wxT("UP"); break;
-            case WXK_RIGHT: key = wxT("RIGHT"); break;
-            case WXK_DOWN: key = wxT("DOWN"); break;
-            case WXK_SELECT: key = wxT("SELECT"); break;
-            case WXK_PRINT: key = wxT("PRINT"); break;
-            case WXK_EXECUTE: key = wxT("EXECUTE"); break;
-            case WXK_SNAPSHOT: key = wxT("SNAPSHOT"); break;
-            case WXK_INSERT: key = wxT("INSERT"); break;
-            case WXK_HELP: key = wxT("HELP"); break;
-            case WXK_NUMPAD0: key = wxT("NUMPAD0"); break;
-            case WXK_NUMPAD1: key = wxT("NUMPAD1"); break;
-            case WXK_NUMPAD2: key = wxT("NUMPAD2"); break;
-            case WXK_NUMPAD3: key = wxT("NUMPAD3"); break;
-            case WXK_NUMPAD4: key = wxT("NUMPAD4"); break;
-            case WXK_NUMPAD5: key = wxT("NUMPAD5"); break;
-            case WXK_NUMPAD6: key = wxT("NUMPAD6"); break;
-            case WXK_NUMPAD7: key = wxT("NUMPAD7"); break;
-            case WXK_NUMPAD8: key = wxT("NUMPAD8"); break;
-            case WXK_NUMPAD9: key = wxT("NUMPAD9"); break;
-            case WXK_MULTIPLY: key = wxT("MULTIPLY"); break;
-            case WXK_ADD: key = wxT("ADD"); break;
-            case WXK_SEPARATOR: key = wxT("SEPARATOR"); break;
-            case WXK_SUBTRACT: key = wxT("SUBTRACT"); break;
-            case WXK_DECIMAL: key = wxT("DECIMAL"); break;
-            case WXK_DIVIDE: key = wxT("DIVIDE"); break;
-            case WXK_F1: key = wxT("F1"); break;
-            case WXK_F2: key = wxT("F2"); break;
-            case WXK_F3: key = wxT("F3"); break;
-            case WXK_F4: key = wxT("F4"); break;
-            case WXK_F5: key = wxT("F5"); break;
-            case WXK_F6: key = wxT("F6"); break;
-            case WXK_F7: key = wxT("F7"); break;
-            case WXK_F8: key = wxT("F8"); break;
-            case WXK_F9: key = wxT("F9"); break;
-            case WXK_F10: key = wxT("F10"); break;
-            case WXK_F11: key = wxT("F11"); break;
-            case WXK_F12: key = wxT("F12"); break;
-            case WXK_F13: key = wxT("F13"); break;
-            case WXK_F14: key = wxT("F14"); break;
-            case WXK_F15: key = wxT("F15"); break;
-            case WXK_F16: key = wxT("F16"); break;
-            case WXK_F17: key = wxT("F17"); break;
-            case WXK_F18: key = wxT("F18"); break;
-            case WXK_F19: key = wxT("F19"); break;
-            case WXK_F20: key = wxT("F20"); break;
-            case WXK_F21: key = wxT("F21"); break;
-            case WXK_F22: key = wxT("F22"); break;
-            case WXK_F23: key = wxT("F23"); break;
-            case WXK_F24: key = wxT("F24"); break;
-            case WXK_NUMLOCK: key = wxT("NUMLOCK"); break;
-            case WXK_SCROLL: key = wxT("SCROLL"); break;
-            case WXK_PAGEUP: key = wxT("PAGEUP"); break;
-            case WXK_PAGEDOWN: key = wxT("PAGEDOWN"); break;
-            case WXK_NUMPAD_SPACE: key = wxT("NUMPAD_SPACE"); break;
-            case WXK_NUMPAD_TAB: key = wxT("NUMPAD_TAB"); break;
-            case WXK_NUMPAD_ENTER: key = wxT("NUMPAD_ENTER"); break;
-            case WXK_NUMPAD_F1: key = wxT("NUMPAD_F1"); break;
-            case WXK_NUMPAD_F2: key = wxT("NUMPAD_F2"); break;
-            case WXK_NUMPAD_F3: key = wxT("NUMPAD_F3"); break;
-            case WXK_NUMPAD_F4: key = wxT("NUMPAD_F4"); break;
-            case WXK_NUMPAD_HOME: key = wxT("NUMPAD_HOME"); break;
-            case WXK_NUMPAD_LEFT: key = wxT("NUMPAD_LEFT"); break;
-            case WXK_NUMPAD_UP: key = wxT("NUMPAD_UP"); break;
-            case WXK_NUMPAD_RIGHT: key = wxT("NUMPAD_RIGHT"); break;
-            case WXK_NUMPAD_DOWN: key = wxT("NUMPAD_DOWN"); break;
-            case WXK_NUMPAD_PAGEUP: key = wxT("NUMPAD_PAGEUP"); break;
-            case WXK_NUMPAD_PAGEDOWN: key = wxT("NUMPAD_PAGEDOWN"); break;
-            case WXK_NUMPAD_END: key = wxT("NUMPAD_END"); break;
-            case WXK_NUMPAD_BEGIN: key = wxT("NUMPAD_BEGIN"); break;
-            case WXK_NUMPAD_INSERT: key = wxT("NUMPAD_INSERT"); break;
-            case WXK_NUMPAD_DELETE: key = wxT("NUMPAD_DELETE"); break;
-            case WXK_NUMPAD_EQUAL: key = wxT("NUMPAD_EQUAL"); break;
-            case WXK_NUMPAD_MULTIPLY: key = wxT("NUMPAD_MULTIPLY"); break;
-            case WXK_NUMPAD_ADD: key = wxT("NUMPAD_ADD"); break;
-            case WXK_NUMPAD_SEPARATOR: key = wxT("NUMPAD_SEPARATOR"); break;
-            case WXK_NUMPAD_SUBTRACT: key = wxT("NUMPAD_SUBTRACT"); break;
-            case WXK_NUMPAD_DECIMAL: key = wxT("NUMPAD_DECIMAL"); break;
-
-            default:
-            {
-               if ( keycode < 128 && wxIsprint((int)keycode) )
-                   key.Printf(wxT("'%c'"), (char)keycode);
-               else if ( keycode > 0 && keycode < 27 )
-                   key.Printf(_("Ctrl-%c"), wxT('A') + keycode - 1);
-               else
-                   key.Printf(wxT("unknown (%ld)"), keycode);
-            }
-        }
-    }
-
-    wxLogMessage(wxT("%s event: %s (flags = %c%c%c%c)"),
-                  name,
-                  key.c_str(),
-                  event.ControlDown() ? wxT('C') : wxT('-'),
-                  event.AltDown() ? wxT('A') : wxT('-'),
-                  event.ShiftDown() ? wxT('S') : wxT('-'),
-                  event.MetaDown() ? wxT('M') : wxT('-'));
-}
-
-void OPJMarkerTree::OnTreeKeyDown(wxTreeEvent& event)
-{
-    LogKeyEvent(wxT("Tree key down "), event.GetKeyEvent());
-
-    event.Skip();
-}*/
-
-/*void OPJMarkerTree::OnBeginDrag(wxTreeEvent& event)
-{
-    // need to explicitly allow drag
-    if ( event.GetItem() != GetRootItem() )
-    {
-        m_draggedItem = event.GetItem();
-
-        wxLogMessage(wxT("OnBeginDrag: started dragging %s"),
-                     GetItemText(m_draggedItem).c_str());
-
-        event.Allow();
-    }
-    else
-    {
-        wxLogMessage(wxT("OnBeginDrag: this item can't be dragged."));
-    }
-}
-
-void OPJMarkerTree::OnEndDrag(wxTreeEvent& event)
-{
-    wxTreeItemId itemSrc = m_draggedItem,
-                 itemDst = event.GetItem();
-    m_draggedItem = (wxTreeItemId)0l;
-
-    // where to copy the item?
-    if ( itemDst.IsOk() && !ItemHasChildren(itemDst) )
-    {
-        // copy to the parent then
-        itemDst = GetItemParent(itemDst);
-    }
-
-    if ( !itemDst.IsOk() )
-    {
-        wxLogMessage(wxT("OnEndDrag: can't drop here."));
-
-        return;
-    }
-
-    wxString text = GetItemText(itemSrc);
-    wxLogMessage(wxT("OnEndDrag: '%s' copied to '%s'."),
-                 text.c_str(), GetItemText(itemDst).c_str());
-
-    // just do append here - we could also insert it just before/after the item
-    // on which it was dropped, but this requires slightly more work... we also
-    // completely ignore the client data and icon of the old item but could
-    // copy them as well.
-    //
-    // Finally, we only copy one item here but we might copy the entire tree if
-    // we were dragging a folder.
-    int image = wxGetApp().ShowImages() ? TreeCtrlIcon_File : -1;
-    AppendItem(itemDst, text, image);
-}*/
-
-/*void OPJMarkerTree::OnBeginLabelEdit(wxTreeEvent& event)
-{
-    wxLogMessage(wxT("OnBeginLabelEdit"));
-
-    // for testing, prevent this item's label editing
-    wxTreeItemId itemId = event.GetItem();
-    if ( IsTestItem(itemId) )
-    {
-        wxMessageBox(wxT("You can't edit this item."));
-
-        event.Veto();
-    }
-    else if ( itemId == GetRootItem() )
-    {
-        // test that it is possible to change the text of the item being edited
-        SetItemText(itemId, _T("Editing root item"));
-    }
-}
-
-void OPJMarkerTree::OnEndLabelEdit(wxTreeEvent& event)
-{
-    wxLogMessage(wxT("OnEndLabelEdit"));
-
-    // don't allow anything except letters in the labels
-    if ( !event.GetLabel().IsWord() )
-    {
-        wxMessageBox(wxT("The new label should be a single word."));
-
-        event.Veto();
-    }
-}*/
-
-/*void OPJMarkerTree::OnItemCollapsing(wxTreeEvent& event)
-{
-    wxLogMessage(wxT("OnItemCollapsing"));
-
-    // for testing, prevent the user from collapsing the first child folder
-    wxTreeItemId itemId = event.GetItem();
-    if ( IsTestItem(itemId) )
-    {
-        wxMessageBox(wxT("You can't collapse this item."));
-
-        event.Veto();
-    }
-}*/
-
-/*void OPJMarkerTree::OnItemActivated(wxTreeEvent& event)
-{
-    // show some info about this item
-    wxTreeItemId itemId = event.GetItem();
-    OPJMarkerData *item = (OPJMarkerData *)GetItemData(itemId);
-
-    if ( item != NULL )
-    {
-        item->ShowInfo(this);
-    }
-
-    wxLogMessage(wxT("OnItemActivated"));
-}*/
-
-void OPJMarkerTree::OnItemMenu(wxTreeEvent& event)
-{
-    /*wxTreeItemId itemId = event.GetItem();
-    OPJMarkerData *item = itemId.IsOk() ? (OPJMarkerData *)GetItemData(itemId)
-                                         : NULL;
-
-    wxLogMessage(wxT("OnItemMenu for item \"%s\""), item ? item->GetDesc()
-                                                         : _T(""));*/
-
-	//wxLogMessage(wxT("EEEEEEEEEE"));
-
-    //event.Skip();
-}
-
-/*void OPJMarkerTree::OnContextMenu(wxContextMenuEvent& event)
-{
-    wxPoint pt = event.GetPosition();
-    wxTreeItemId item;
-    wxLogMessage(wxT("OnContextMenu at screen coords (%i, %i)"), pt.x, pt.y);
-
-    // check if event was generated by keyboard (MSW-specific?)
-    if ( pt.x == -1 && pt.y == -1 ) //(this is how MSW indicates it)
-    {
-        if ( !HasFlag(wxTR_MULTIPLE) )
-            item = GetSelection();
-
-        // attempt to guess where to show the menu
-        if ( item.IsOk() )
-        {
-            // if an item was clicked, show menu to the right of it
-            wxRect rect;
-            GetBoundingRect(item, rect, true );// only the label
-            pt = wxPoint(rect.GetRight(), rect.GetTop());
-        }
-        else
-        {
-            pt = wxPoint(0, 0);
-        }
-    }
-    else // event was generated by mouse, use supplied coords
-    {
-        pt = ScreenToClient(pt);
-        item = HitTest(pt);
-    }
-
-    ShowMenu(item, pt);
-}*/
-
-/*void OPJMarkerTree::ShowMenu(wxTreeItemId id, const wxPoint& pt)
-{
-    wxString title;
-    if ( id.IsOk() )
-    {
-        title << wxT("Menu for ") << GetItemText(id);
-    }
-    else
-    {
-        title = wxT("Menu for no particular item");
-    }
-
-#if wxUSE_MENUS
-    wxMenu menu(title);
-    menu.Append(TreeTest_About, wxT("&About..."));
-    menu.AppendSeparator();
-    menu.Append(TreeTest_Highlight, wxT("&Highlight item"));
-    menu.Append(TreeTest_Dump, wxT("&Dump"));
-
-    PopupMenu(&menu, pt);
-#endif // wxUSE_MENUS
-}*/
-
-/*void OPJMarkerTree::OnItemRClick(wxTreeEvent& event)
-{
-    wxTreeItemId itemId = event.GetItem();
-    OPJMarkerData *item = itemId.IsOk() ? (OPJMarkerData *)GetItemData(itemId)
-                                         : NULL;
-
-    wxLogMessage(wxT("Item \"%s\" right clicked"), item ? item->GetDesc()
-                                                        : _T(""));
-
-    event.Skip();
-}*/
-
-/*
-void OPJMarkerTree::OnRMouseDown(wxMouseEvent& event)
-{
-    wxLogMessage(wxT("Right mouse button down"));
-
-    event.Skip();
-}
-
-void OPJMarkerTree::OnRMouseUp(wxMouseEvent& event)
-{
-    wxLogMessage(wxT("Right mouse button up"));
-
-    event.Skip();
-}
-
-void OPJMarkerTree::OnRMouseDClick(wxMouseEvent& event)
-{
-    wxTreeItemId id = HitTest(event.GetPosition());
-    if ( !id )
-        wxLogMessage(wxT("No item under mouse"));
-    else
-    {
-        OPJMarkerData *item = (OPJMarkerData *)GetItemData(id);
-        if ( item )
-            wxLogMessage(wxT("Item '%s' under mouse"), item->GetDesc());
-    }
-
-    event.Skip();
-}
-*/
-
-static inline const wxChar *Bool2String(bool b)
-{
-    return b ? wxT("") : wxT("not ");
-}
-
-void OPJMarkerData::ShowInfo(wxTreeCtrl *tree)
-{
-    wxLogMessage(wxT("Item '%s': %sselected, %sexpanded, %sbold,\n")
-                 wxT("%u children (%u immediately under this item)."),
-                 m_desc.c_str(),
-                 Bool2String(tree->IsSelected(GetId())),
-                 Bool2String(tree->IsExpanded(GetId())),
-                 Bool2String(tree->IsBold(GetId())),
-                 unsigned(tree->GetChildrenCount(GetId())),
-                 unsigned(tree->GetChildrenCount(GetId(), false)));
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.cpp
deleted file mode 100644
index 8f2c86e..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.cpp
+++ /dev/null
@@ -1,1664 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/////////////////////////////////////////////////////////////////////////////
-// Name:        sashtest.cpp
-// Purpose:     Layout/sash sample
-// Author:      Julian Smart
-// Modified by:
-// Created:     04/01/98
-// RCS-ID:      $Id: sashtest.cpp,v 1.18 2005/08/23 15:54:35 ABX Exp $
-// Copyright:   (c) Julian Smart
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        treetest.cpp
-// Purpose:     wxTreeCtrl sample
-// Author:      Julian Smart
-// Modified by:
-// Created:     04/01/98
-// RCS-ID:      $Id: treetest.cpp,v 1.110 2006/11/04 11:26:51 VZ Exp $
-// Copyright:   (c) Julian Smart
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        dialogs.cpp
-// Purpose:     Common dialogs demo
-// Author:      Julian Smart
-// Modified by: ABX (2004) - adjustements for conditional building + new menu
-// Created:     04/01/98
-// RCS-ID:      $Id: dialogs.cpp,v 1.163 2006/11/04 10:57:24 VZ Exp $
-// Copyright:   (c) Julian Smart
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        thread.cpp
-// Purpose:     wxWidgets thread sample
-// Author:      Guilhem Lavaux, Vadim Zeitlin
-// Modified by:
-// Created:     06/16/98
-// RCS-ID:      $Id: thread.cpp,v 1.26 2006/10/02 05:36:28 PC Exp $
-// Copyright:   (c) 1998-2002 wxWidgets team
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-// Name:        samples/image/image.cpp
-// Purpose:     sample showing operations with wxImage
-// Author:      Robert Roebling
-// Modified by:
-// Created:     1998
-// RCS-ID:      $Id: image.cpp,v 1.120 2006/12/06 17:13:11 VZ Exp $
-// Copyright:   (c) 1998-2005 Robert Roebling
-// License:     wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        samples/console/console.cpp
-// Purpose:     A sample console (as opposed to GUI) program using wxWidgets
-// Author:      Vadim Zeitlin
-// Modified by:
-// Created:     04.10.99
-// RCS-ID:      $Id: console.cpp,v 1.206 2006/11/12 19:55:19 VZ Exp $
-// Copyright:   (c) 1999 Vadim Zeitlin <zeitlin at dptmaths.ens-cachan.fr>
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        samples/notebook/notebook.cpp
-// Purpose:     a sample demonstrating notebook usage
-// Author:      Julian Smart
-// Modified by: Dimitri Schoolwerth
-// Created:     26/10/98
-// RCS-ID:      $Id: notebook.cpp,v 1.49 2006/11/04 18:24:07 RR Exp $
-// Copyright:   (c) 1998-2002 wxWidgets team
-// License:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        dialogs.cpp
-// Purpose:     Common dialogs demo
-// Author:      Julian Smart
-// Modified by: ABX (2004) - adjustements for conditional building + new menu
-// Created:     04/01/98
-// RCS-ID:      $Id: dialogs.cpp,v 1.163 2006/11/04 10:57:24 VZ Exp $
-// Copyright:   (c) Julian Smart
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        dnd.cpp
-// Purpose:     Drag and drop sample
-// Author:      Vadim Zeitlin
-// Modified by:
-// Created:     04/01/98
-// RCS-ID:      $Id: dnd.cpp,v 1.107 2006/10/30 20:23:41 VZ Exp $
-// Copyright:
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        test.cpp
-// Purpose:     wxHtml testing example
-/////////////////////////////////////////////////////////////////////////////
-
-
-#include "OPJViewer.h"
-
-IMPLEMENT_APP(OPJViewerApp)
-
-// For drawing lines in a canvas
-long xpos = -1;
-long ypos = -1;
-
-int winNumber = 1;
-
-// Initialise this in OnInit, not statically
-bool OPJViewerApp::OnInit(void)
-{
-	int n;
-#if wxUSE_UNICODE
-
-    wxChar **wxArgv = new wxChar *[argc + 1];
-
-    for (n = 0; n < argc; n++ ) {
-        wxMB2WXbuf warg = wxConvertMB2WX((char *) argv[n]);
-        wxArgv[n] = wxStrdup(warg);
-    }
-
-    wxArgv[n] = NULL;
-
-#else // !wxUSE_UNICODE
-
-    #define wxArgv argv
-
-#endif // wxUSE_UNICODE/!wxUSE_UNICODE
-
-#if wxUSE_CMDLINE_PARSER
-
-    static const wxCmdLineEntryDesc cmdLineDesc[] =
-    {
-        { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show this help message"),
-            wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
-
-        { wxCMD_LINE_PARAM,  NULL, NULL, _T("input file"),
-            wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
-
-        { wxCMD_LINE_NONE }
-    };
-
-    wxCmdLineParser parser(cmdLineDesc, argc, wxArgv);
-
-    switch (parser.Parse()) {
-    case -1:
-        wxLogMessage(wxT("Help was given, terminating."));
-        break;
-
-    case 0:
-        ShowCmdLine(parser);
-        break;
-
-    default:
-        wxLogMessage(wxT("Syntax error detected."));
-        break;
-    }
-
-#endif // wxUSE_CMDLINE_PARSER
-
-    //wxInitAllImageHandlers();
-#if wxUSE_LIBJPEG
-  wxImage::AddHandler( new wxJPEGHandler );
-#endif
-#if wxUSE_LIBOPENJPEG
-  wxImage::AddHandler( new wxJPEG2000Handler );
-#endif
-#if USE_MXF
-  wxImage::AddHandler( new wxMXFHandler );
-#endif // USE_MXF
-#if OPJ_MANYFORMATS
-  wxImage::AddHandler( new wxBMPHandler );
-  wxImage::AddHandler( new wxPNGHandler );
-  wxImage::AddHandler( new wxGIFHandler );
-  wxImage::AddHandler( new wxPNMHandler );
-  wxImage::AddHandler( new wxTIFFHandler );
-#endif
-    // we use a XPM image in our HTML page
-    wxImage::AddHandler(new wxXPMHandler);
-
-	// memory file system
-    wxFileSystem::AddHandler(new wxMemoryFSHandler);
-
-#ifdef OPJ_INICONFIG
-	//load decoding engine parameters
-	OPJconfig = new wxConfig(OPJ_APPLICATION, OPJ_APPLICATION_VENDOR);
-
-	OPJconfig->Read(wxT("decode/enabledeco"), &m_enabledeco, (bool) true);
-	OPJconfig->Read(wxT("decode/enableparse"), &m_enableparse, (bool) true);
-	OPJconfig->Read(wxT("decode/resizemethod"), &m_resizemethod, (long) 0);
-	OPJconfig->Read(wxT("decode/xxxreducefactor"), &m_reducefactor, (long) 0);
-	OPJconfig->Read(wxT("decode/xxxqualitylayers"), &m_qualitylayers, (long) 0);
-	OPJconfig->Read(wxT("decode/xxxcomponents"), &m_components, (long) 0);
-	OPJconfig->Read(wxT("decode/xxxframenum"), &m_framenum, (long) 0);
-#ifdef USE_JPWL
-	OPJconfig->Read(wxT("decode/enablejpwl"), &m_enablejpwl, (bool) true);
-	OPJconfig->Read(wxT("decode/expcomps"), &m_expcomps, (long) JPWL_EXPECTED_COMPONENTS);
-	OPJconfig->Read(wxT("decode/maxtiles"), &m_maxtiles, (long) JPWL_MAXIMUM_TILES);
-#endif // USE_JPWL
-
-	OPJconfig->Write(wxT("teststring"), wxT("This is a test value"));
-	OPJconfig->Write(wxT("testbool"), (bool) true);
-	OPJconfig->Write(wxT("testlong"), (long) 245);
-
-	OPJconfig->Read(wxT("showtoolbar"), &m_showtoolbar, (bool) true);
-	OPJconfig->Read(wxT("showbrowser"), &m_showbrowser, (bool) true);
-	OPJconfig->Read(wxT("showpeeker"), &m_showpeeker, (bool) true);
-	OPJconfig->Read(wxT("browserwidth"), &m_browserwidth, (long) OPJ_BROWSER_WIDTH);
-	OPJconfig->Read(wxT("peekerheight"), &m_peekerheight, (long) OPJ_PEEKER_HEIGHT);
-	OPJconfig->Read(wxT("framewidth"), &m_framewidth, (long) OPJ_FRAME_WIDTH);
-	OPJconfig->Read(wxT("frameheight"), &m_frameheight, (long) OPJ_FRAME_HEIGHT);
-
-	// load encoding engine parameters
-	OPJconfig->Read(wxT("encode/subsampling"), &m_subsampling, (wxString) wxT("1,1"));
-	OPJconfig->Read(wxT("encode/origin"), &m_origin, (wxString) wxT("0,0"));
-	OPJconfig->Read(wxT("encode/rates"), &m_rates, (wxString) wxT("20,10,5"));
-	OPJconfig->Read(wxT("encode/quality"), &m_quality, (wxString) wxT("30,35,40"));
-	OPJconfig->Read(wxT("encode/enablequality"), &m_enablequality, (bool) false);
-	OPJconfig->Read(wxT("encode/multicomp"), &m_multicomp, (bool) false);	
-	OPJconfig->Read(wxT("encode/irreversible"), &m_irreversible, (bool) false);	
-	OPJconfig->Read(wxT("encode/resolutions"), &m_resolutions, (int) 6);	
-	OPJconfig->Read(wxT("encode/progression"), &m_progression, (int) 0);	
-	OPJconfig->Read(wxT("encode/cbsize"), &m_cbsize, (wxString) wxT("32,32"));
-	OPJconfig->Read(wxT("encode/prsize"), &m_prsize, (wxString) wxT("[128,128],[128,128]"));
-	OPJconfig->Read(wxT("encode/tsize"), &m_tsize, (wxString) wxT(""));
-	OPJconfig->Read(wxT("encode/torigin"), &m_torigin, (wxString) wxT("0,0"));
-	OPJconfig->Read(wxT("encode/enablesop"), &m_enablesop, (bool) false);	
-	OPJconfig->Read(wxT("encode/enableeph"), &m_enableeph, (bool) false);	
-	OPJconfig->Read(wxT("encode/enablebypass"), &m_enablebypass, (bool) false);	
-	OPJconfig->Read(wxT("encode/enablereset"), &m_enablereset, (bool) false);	
-	OPJconfig->Read(wxT("encode/enablerestart"), &m_enablerestart, (bool) false);	
-	OPJconfig->Read(wxT("encode/enablevsc"), &m_enablevsc, (bool) false);	
-	OPJconfig->Read(wxT("encode/enableerterm"), &m_enableerterm, (bool) false);	
-	OPJconfig->Read(wxT("encode/enablesegmark"), &m_enablesegmark, (bool) false);	
-	OPJconfig->Read(wxT("encode/enablecomm"), &m_enablecomm, (bool) true);	
-	OPJconfig->Read(wxT("encode/enablepoc"), &m_enablepoc, (bool) false);	
-	OPJconfig->Read(wxT("encode/comment"), &m_comment, (wxString) wxT(""));
-	OPJconfig->Read(wxT("encode/poc"), &m_poc, (wxString) wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL"));
-	OPJconfig->Read(wxT("encode/enableidx"), &m_enableidx, (bool) false);	
-	OPJconfig->Read(wxT("encode/index"), &m_index, (wxString) wxT("index.txt"));
-#ifdef USE_JPWL
-	OPJconfig->Read(wxT("encode/enablejpwl"), &m_enablejpwle, (bool) true);
-	for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
-		OPJconfig->Read(wxT("encode/jpwl/hprotsel") + wxString::Format(wxT("%02d"), n), &m_hprotsel[n], 0);
-		OPJconfig->Read(wxT("encode/jpwl/htileval") + wxString::Format(wxT("%02d"), n), &m_htileval[n], 0);
-		OPJconfig->Read(wxT("encode/jpwl/pprotsel") + wxString::Format(wxT("%02d"), n), &m_pprotsel[n], 0);
-		OPJconfig->Read(wxT("encode/jpwl/ptileval") + wxString::Format(wxT("%02d"), n), &m_ptileval[n], 0);
-		OPJconfig->Read(wxT("encode/jpwl/ppackval") + wxString::Format(wxT("%02d"), n), &m_ppackval[n], 0);
-		OPJconfig->Read(wxT("encode/jpwl/sensisel") + wxString::Format(wxT("%02d"), n), &m_sensisel[n], 0);
-		OPJconfig->Read(wxT("encode/jpwl/stileval") + wxString::Format(wxT("%02d"), n), &m_stileval[n], 0);
-	}
-#endif // USE_JPWL
-
-#else
-	// set decoding engine parameters
-	m_enabledeco = true;
-	m_enableparse = true;
-	m_resizemethod = 0;
-	m_reducefactor = 0;
-	m_qualitylayers = 0;
-	m_components = 0;
-	m_framenum = 0;
-#ifdef USE_JPWL
-	m_enablejpwl = true;
-	m_expcomps = JPWL_EXPECTED_COMPONENTS;
-	m_maxtiles = JPWL_MAXIMUM_TILES;
-#endif // USE_JPWL
-	m_showtoolbar = true;
-	m_showbrowser = true;
-	m_showpeeker = true;
-	m_browserwidth = OPJ_BROWSER_WIDTH;
-	m_peekerheight = OPJ_PEEKER_HEIGHT;
-	m_framewidth = OPJ_FRAME_WIDTH;
-	m_frameheight = OPJ_FRAME_HEIGHT;
-
-	// set encoding engine parameters
-	m_subsampling = wxT("1,1");
-	m_origin = wxT("0,0");
-	m_rates = wxT("20,10,5");
-	m_quality = wxT("30,35,40");
-	m_enablequality = false;
-	m_multicomp = false;
-	m_irreversible = false;
-	m_resolutions = 6;
-	m_progression = 0;
-	m_cbsize= wxT("32,32");
-	m_prsize= wxT("[128,128],[128,128]");
-	m_tsize = wxT("");
-	m_torigin = wxT("0,0");
-	m_enablesop = false;
-	m_enableeph = false;
-	m_enablebypass = false;
-	m_enablereset = false;
-	m_enablerestart = false;
-	m_enablevsc = false;
-	m_enableerterm = false;
-	m_enablesegmark = false;
-	m_enableidx = false;
-	m_index = wxT("index.txt");
-	m_enablecomm = true;
-	m_comment = wxT("");
-	m_enablepoc = false;
-	m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
-#ifdef USE_JPWL
-	m_enablejpwle = true;
-	for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
-		m_hprotsel[n] = 0;
-		m_htileval[n] = 0;
-		m_pprotsel[n] = 0;
-		m_ptileval[n] = 0;
-		m_sensisel[n] = 0;
-		m_stileval[n] = 0;
-	}
-#endif // USE_JPWL
-
-#endif // OPJ_INICONFIG
-
-	if (m_comment == wxT("")) {
-#if defined __WXMSW__
-		m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG  version ");
-#elif defined __WXGTK__
-		m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
-#else
-		m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
-#endif
-
-#ifdef USE_JPWL
-		m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
-#else
-		m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
-#endif
-	}
-
-	// Create the main frame window
-  OPJFrame *frame = new OPJFrame(NULL, wxID_ANY, OPJ_APPLICATION_TITLEBAR,
-					  wxDefaultPosition, wxSize(wxGetApp().m_framewidth, wxGetApp().m_frameheight),
-                      wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE |
-                      wxHSCROLL | wxVSCROLL);
-
-  // Give it an icon (this is ignored in MDI mode: uses resources)
-#ifdef __WXMSW__
-  frame->SetIcon(wxIcon(wxT("OPJViewer16")));
-#endif
-
-  frame->Show(true);
-
-  SetTopWindow(frame);
-
-	// if there are files on the command line, open them
-	if (!(m_filelist.IsEmpty())) {
-		//wxLogMessage(wxT("Habemus files!!!"));
-		wxArrayString paths, filenames;
-		for (unsigned int f = 0; f < wxGetApp().m_filelist.GetCount(); f++) {
-			paths.Add(wxFileName(wxGetApp().m_filelist[f]).GetFullPath());
-			filenames.Add(wxFileName(wxGetApp().m_filelist[f]).GetFullName());
-		}
-		//wxLogMessage(paths[0]);
-		frame->OpenFiles(paths, filenames);
-	}
-
-  return true;
-}
-
-int OPJViewerApp::OnExit()
-{
-	int n;
-
-#ifdef OPJ_INICONFIG
-	OPJconfig->Write(wxT("decode/enabledeco"), m_enabledeco);
-	OPJconfig->Write(wxT("decode/enableparse"), m_enableparse);
-	OPJconfig->Write(wxT("decode/resizemethod"), m_resizemethod);
-	OPJconfig->Write(wxT("decode/reducefactor"), m_reducefactor);
-	OPJconfig->Write(wxT("decode/qualitylayers"), m_qualitylayers);
-	OPJconfig->Write(wxT("decode/components"), m_components);
-	OPJconfig->Write(wxT("decode/framenum"), m_framenum);
-#ifdef USE_JPWL
-	OPJconfig->Write(wxT("decode/enablejpwl"), m_enablejpwl);
-	OPJconfig->Write(wxT("decode/expcomps"), m_expcomps);
-	OPJconfig->Write(wxT("decode/maxtiles"), m_maxtiles);
-#endif // USE_JPWL
-	OPJconfig->Write(wxT("showtoolbar"), m_showtoolbar);
-	OPJconfig->Write(wxT("showbrowser"), m_showbrowser);
-	OPJconfig->Write(wxT("showpeeker"), m_showpeeker);
-	OPJconfig->Write(wxT("browserwidth"), m_browserwidth);
-	OPJconfig->Write(wxT("peekerheight"), m_peekerheight);
-	OPJconfig->Write(wxT("framewidth"), m_framewidth);
-	OPJconfig->Write(wxT("frameheight"), m_frameheight);
-
-	OPJconfig->Write(wxT("encode/subsampling"), m_subsampling);
-	OPJconfig->Write(wxT("encode/origin"), m_origin);
-	OPJconfig->Write(wxT("encode/rates"), m_rates);
-	OPJconfig->Write(wxT("encode/quality"), m_quality);
-	OPJconfig->Write(wxT("encode/enablequality"), m_enablequality);
-	OPJconfig->Write(wxT("encode/multicomp"), m_multicomp);
-	OPJconfig->Write(wxT("encode/irreversible"), m_irreversible);
-	OPJconfig->Write(wxT("encode/resolutions"), m_resolutions);
-	OPJconfig->Write(wxT("encode/progression"), m_progression);
-	OPJconfig->Write(wxT("encode/cbsize"), m_cbsize);
-	OPJconfig->Write(wxT("encode/prsize"), m_prsize);
-	OPJconfig->Write(wxT("encode/tiles"), m_tsize);
-	OPJconfig->Write(wxT("encode/torigin"), m_torigin);
-	OPJconfig->Write(wxT("encode/enablesop"), m_enablesop);
-	OPJconfig->Write(wxT("encode/enableeph"), m_enableeph);
-	OPJconfig->Write(wxT("encode/enablebypass"), m_enablebypass);
-	OPJconfig->Write(wxT("encode/enablereset"), m_enablereset);
-	OPJconfig->Write(wxT("encode/enablerestart"), m_enablerestart);
-	OPJconfig->Write(wxT("encode/enablevsc"), m_enablevsc);
-	OPJconfig->Write(wxT("encode/enableerterm"), m_enableerterm);
-	OPJconfig->Write(wxT("encode/enablesegmark"), m_enablesegmark);
-	OPJconfig->Write(wxT("encode/enableidx"), m_enableidx);
-	OPJconfig->Write(wxT("encode/index"), m_index);
-	OPJconfig->Write(wxT("encode/enablecomm"), m_enablecomm);
-	OPJconfig->Write(wxT("encode/comment"), m_comment);
-	OPJconfig->Write(wxT("encode/enablepoc"), m_enablepoc);
-	OPJconfig->Write(wxT("encode/poc"), m_poc);
-#ifdef USE_JPWL
-	OPJconfig->Write(wxT("encode/enablejpwl"), m_enablejpwle);
-	for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
-		OPJconfig->Write(wxT("encode/jpwl/hprotsel") + wxString::Format(wxT("%02d"), n), m_hprotsel[n]);
-		OPJconfig->Write(wxT("encode/jpwl/htileval") + wxString::Format(wxT("%02d"), n), m_htileval[n]);
-		OPJconfig->Write(wxT("encode/jpwl/pprotsel") + wxString::Format(wxT("%02d"), n), m_pprotsel[n]);
-		OPJconfig->Write(wxT("encode/jpwl/ptileval") + wxString::Format(wxT("%02d"), n), m_ptileval[n]);
-		OPJconfig->Write(wxT("encode/jpwl/ppackval") + wxString::Format(wxT("%02d"), n), m_ppackval[n]);
-		OPJconfig->Write(wxT("encode/jpwl/sensisel") + wxString::Format(wxT("%02d"), n), m_sensisel[n]);
-		OPJconfig->Write(wxT("encode/jpwl/stileval") + wxString::Format(wxT("%02d"), n), m_stileval[n]);
-	}
-#endif // USE_JPWL
-
-#endif // OPJ_INICONFIG
-
-	return 1;
-}
-
-void OPJViewerApp::ShowCmdLine(const wxCmdLineParser& parser)
-{
-    wxString s = wxT("Command line parsed successfully:\nInput files: ");
-
-    size_t count = parser.GetParamCount();
-    for (size_t param = 0; param < count; param++) {
-        s << parser.GetParam(param) << ';';
-		m_filelist.Add(parser.GetParam(param));
-    }
-
-    //wxLogMessage(s);
-}
-
-// OPJFrame events
-
-// Event class for sending text messages between worker and GUI threads
-BEGIN_EVENT_TABLE(OPJFrame, wxMDIParentFrame)
-    EVT_MENU(OPJFRAME_HELPABOUT, OPJFrame::OnAbout)
-    EVT_MENU(OPJFRAME_FILEOPEN, OPJFrame::OnFileOpen)
-    EVT_MENU(OPJFRAME_FILESAVEAS, OPJFrame::OnFileSaveAs)
-    EVT_MENU(OPJFRAME_MEMORYOPEN, OPJFrame::OnMemoryOpen)
-    EVT_SIZE(OPJFrame::OnSize)
-    EVT_MENU(OPJFRAME_FILEEXIT, OPJFrame::OnQuit)
-    EVT_MENU(OPJFRAME_FILECLOSE, OPJFrame::OnClose)
-    EVT_MENU(OPJFRAME_VIEWZOOM, OPJFrame::OnZoom)
-    EVT_MENU(OPJFRAME_VIEWFIT, OPJFrame::OnFit)
-    EVT_MENU(OPJFRAME_VIEWRELOAD, OPJFrame::OnReload)
-    EVT_MENU(OPJFRAME_VIEWPREVFRAME, OPJFrame::OnPrevFrame)
-    EVT_MENU(OPJFRAME_VIEWHOMEFRAME, OPJFrame::OnHomeFrame)
-    EVT_MENU(OPJFRAME_VIEWNEXTFRAME, OPJFrame::OnNextFrame)
-    EVT_MENU(OPJFRAME_VIEWLESSLAYERS, OPJFrame::OnLessLayers)
-    EVT_MENU(OPJFRAME_VIEWALLLAYERS, OPJFrame::OnAllLayers)
-    EVT_MENU(OPJFRAME_VIEWMORELAYERS, OPJFrame::OnMoreLayers)
-    EVT_MENU(OPJFRAME_VIEWLESSRES, OPJFrame::OnLessRes)
-    EVT_MENU(OPJFRAME_VIEWFULLRES, OPJFrame::OnFullRes)
-    EVT_MENU(OPJFRAME_VIEWMORERES, OPJFrame::OnMoreRes)
-    EVT_MENU(OPJFRAME_VIEWPREVCOMP, OPJFrame::OnPrevComp)
-    EVT_MENU(OPJFRAME_VIEWALLCOMPS, OPJFrame::OnAllComps)
-    EVT_MENU(OPJFRAME_VIEWNEXTCOMP, OPJFrame::OnNextComp)
-    EVT_MENU(OPJFRAME_FILETOGGLEB, OPJFrame::OnToggleBrowser)
-    EVT_MENU(OPJFRAME_FILETOGGLEP, OPJFrame::OnTogglePeeker)
-    EVT_MENU(OPJFRAME_FILETOGGLET, OPJFrame::OnToggleToolbar)
-    EVT_MENU(OPJFRAME_SETSENCO, OPJFrame::OnSetsEnco)
-    EVT_MENU(OPJFRAME_SETSDECO, OPJFrame::OnSetsDeco)
-    EVT_SASH_DRAGGED_RANGE(OPJFRAME_BROWSEWIN, OPJFRAME_LOGWIN, OPJFrame::OnSashDrag)
-    EVT_NOTEBOOK_PAGE_CHANGED(LEFT_NOTEBOOK_ID, OPJFrame::OnNotebook)
-    EVT_MENU(OPJFRAME_THREADLOGMSG, OPJFrame::OnThreadLogmsg)
-END_EVENT_TABLE()
-
-// this is the frame constructor
-OPJFrame::OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
-				   const wxPoint& pos, const wxSize& size, const long style)
-		: wxMDIParentFrame(parent, id, title, pos, size, style)
-{
-	// file menu and its items
-	wxMenu *file_menu = new wxMenu;
-
-	file_menu->Append(OPJFRAME_FILEOPEN, wxT("&Open\tCtrl+O"));
-	file_menu->SetHelpString(OPJFRAME_FILEOPEN, wxT("Open one or more files"));
-
-	file_menu->Append(OPJFRAME_MEMORYOPEN, wxT("&Memory\tCtrl+M"));
-	file_menu->SetHelpString(OPJFRAME_MEMORYOPEN, wxT("Open a memory buffer"));
-
-	file_menu->Append(OPJFRAME_FILECLOSE, wxT("&Close\tCtrl+C"));
-	file_menu->SetHelpString(OPJFRAME_FILECLOSE, wxT("Close current image"));
-
-	file_menu->AppendSeparator();
-
-	file_menu->Append(OPJFRAME_FILESAVEAS, wxT("&Save as\tCtrl+S"));
-	file_menu->SetHelpString(OPJFRAME_FILESAVEAS, wxT("Save the current image"));
-	//file_menu->Enable(OPJFRAME_FILESAVEAS, false);
-
-	file_menu->AppendSeparator();
-
-	file_menu->Append(OPJFRAME_FILETOGGLEB, wxT("Toggle &browser\tCtrl+B"));
-	file_menu->SetHelpString(OPJFRAME_FILETOGGLEB, wxT("Toggle the left browsing pane"));
-
-	file_menu->Append(OPJFRAME_FILETOGGLEP, wxT("Toggle &peeker\tCtrl+P"));
-	file_menu->SetHelpString(OPJFRAME_FILETOGGLEP, wxT("Toggle the bottom peeking pane"));
-
-	file_menu->Append(OPJFRAME_FILETOGGLET, wxT("Toggle &toolbar\tCtrl+T"));
-	file_menu->SetHelpString(OPJFRAME_FILETOGGLET, wxT("Toggle the toolbar"));
-
-	file_menu->AppendSeparator();
-
-	file_menu->Append(OPJFRAME_FILEEXIT, wxT("&Exit\tCtrl+Q"));
-	file_menu->SetHelpString(OPJFRAME_FILEEXIT, wxT("Quit this program"));
-
-	// view menu and its items
-	wxMenu *view_menu = new wxMenu;
-
-	view_menu->Append(OPJFRAME_VIEWZOOM, wxT("&Zoom\tCtrl+Z"));
-	view_menu->SetHelpString(OPJFRAME_VIEWZOOM, wxT("Rescale the image"));
-
-	view_menu->Append(OPJFRAME_VIEWFIT, wxT("Zoom to &fit\tCtrl+F"));
-	view_menu->SetHelpString(OPJFRAME_VIEWFIT, wxT("Fit the image in canvas"));
-
-	view_menu->Append(OPJFRAME_VIEWRELOAD, wxT("&Reload image\tCtrl+R"));
-	view_menu->SetHelpString(OPJFRAME_VIEWRELOAD, wxT("Reload the current image"));
-
-	view_menu->AppendSeparator();
-
-	view_menu->Append(OPJFRAME_VIEWPREVFRAME, wxT("&Prev frame\tLeft"));
-	view_menu->SetHelpString(OPJFRAME_VIEWPREVFRAME, wxT("View previous frame"));
-
-	view_menu->Append(OPJFRAME_VIEWHOMEFRAME, wxT("&Start frame\tHome"));
-	view_menu->SetHelpString(OPJFRAME_VIEWHOMEFRAME, wxT("View starting frame"));
-
-	view_menu->Append(OPJFRAME_VIEWNEXTFRAME, wxT("&Next frame\tRight"));
-	view_menu->SetHelpString(OPJFRAME_VIEWNEXTFRAME, wxT("View next frame"));
-
-	view_menu->AppendSeparator();
-
-	view_menu->Append(OPJFRAME_VIEWLESSLAYERS, wxT("&Less layers\t-"));
-	view_menu->SetHelpString(OPJFRAME_VIEWLESSLAYERS, wxT("Remove a layer"));
-
-	view_menu->Append(OPJFRAME_VIEWALLLAYERS, wxT("&All layers\t0"));
-	view_menu->SetHelpString(OPJFRAME_VIEWALLLAYERS, wxT("Show all layers"));
-
-	view_menu->Append(OPJFRAME_VIEWMORELAYERS, wxT("&More layers\t+"));
-	view_menu->SetHelpString(OPJFRAME_VIEWMORELAYERS, wxT("Add a layer"));
-
-	view_menu->AppendSeparator();
-
-	view_menu->Append(OPJFRAME_VIEWLESSRES, wxT("&Less resolution\t<"));
-	view_menu->SetHelpString(OPJFRAME_VIEWLESSRES, wxT("Reduce the resolution"));
-
-	view_menu->Append(OPJFRAME_VIEWFULLRES, wxT("&Full resolution\tf"));
-	view_menu->SetHelpString(OPJFRAME_VIEWFULLRES, wxT("Full resolution"));
-
-	view_menu->Append(OPJFRAME_VIEWMORERES, wxT("&More resolution\t>"));
-	view_menu->SetHelpString(OPJFRAME_VIEWMORERES, wxT("Increase the resolution"));
-
-	view_menu->AppendSeparator();
-
-	view_menu->Append(OPJFRAME_VIEWPREVCOMP, wxT("&Prev component\tDown"));
-	view_menu->SetHelpString(OPJFRAME_VIEWPREVCOMP, wxT("View previous component"));
-
-	view_menu->Append(OPJFRAME_VIEWALLCOMPS, wxT("&All components\ta"));
-	view_menu->SetHelpString(OPJFRAME_VIEWALLCOMPS, wxT("View all components"));
-
-	view_menu->Append(OPJFRAME_VIEWNEXTCOMP, wxT("&Next component\tUp"));
-	view_menu->SetHelpString(OPJFRAME_VIEWNEXTCOMP, wxT("View next component"));
-
-
-	// settings menu and its items
-	wxMenu *sets_menu = new wxMenu;
-
-	sets_menu->Append(OPJFRAME_SETSENCO, wxT("&Encoder\tCtrl+E"));
-	sets_menu->SetHelpString(OPJFRAME_SETSENCO, wxT("Encoder settings"));
-
-	sets_menu->Append(OPJFRAME_SETSDECO, wxT("&Decoder\tCtrl+D"));
-	sets_menu->SetHelpString(OPJFRAME_SETSDECO, wxT("Decoder settings"));
-
-	// help menu and its items
-	wxMenu *help_menu = new wxMenu;
-
-	help_menu->Append(OPJFRAME_HELPABOUT, wxT("&About\tF1"));
-	help_menu->SetHelpString(OPJFRAME_HELPABOUT, wxT("Basic info on the program"));
-
-	// the whole menubar
-	wxMenuBar *menu_bar = new wxMenuBar;
-	menu_bar->Append(file_menu, wxT("&File"));
-	menu_bar->Append(view_menu, wxT("&View"));
-	menu_bar->Append(sets_menu, wxT("&Settings"));
-	menu_bar->Append(help_menu, wxT("&Help"));
-
-	// Associate the menu bar with the frame
-	SetMenuBar(menu_bar);
-
-	// the status bar
-	CreateStatusBar();
-
-	// the toolbar
-	tool_bar = new wxToolBar(this, OPJFRAME_TOOLBAR,
-								wxDefaultPosition, wxDefaultSize,
-								wxTB_HORIZONTAL | wxNO_BORDER);
-	wxBitmap bmpOpen = wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpSaveAs = wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpZoom = wxArtProvider::GetBitmap(wxART_FIND, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpFit = wxArtProvider::GetBitmap(wxART_FIND_AND_REPLACE, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpReload = wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpDecosettings = wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpEncosettings = wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpPrevframe = wxArtProvider::GetBitmap(wxART_GO_BACK, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpHomeframe = wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpNextframe = wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpLesslayers = bmpPrevframe;
-	wxBitmap bmpAlllayers = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpMorelayers = bmpNextframe;
-	wxBitmap bmpLessres = bmpPrevframe;
-	wxBitmap bmpFullres = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpMoreres = bmpNextframe;
-	wxBitmap bmpPrevcomp = bmpPrevframe;
-	wxBitmap bmpAllcomps = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR,
-												wxDefaultSize);
-	wxBitmap bmpNextcomp = bmpNextframe;
-
-	tool_bar->AddTool(OPJFRAME_FILEOPEN, bmpOpen, wxT("Open"));
-	tool_bar->AddTool(OPJFRAME_FILESAVEAS, bmpSaveAs, wxT("Save as "));
-	//tool_bar->EnableTool(OPJFRAME_FILESAVEAS, false);
-	tool_bar->AddSeparator();
-	tool_bar->AddTool(OPJFRAME_VIEWZOOM, bmpZoom, wxT("Zoom"));
-	tool_bar->AddTool(OPJFRAME_VIEWFIT, bmpFit, wxT("Zoom to fit"));
-	tool_bar->AddTool(OPJFRAME_VIEWRELOAD, bmpReload, wxT("Reload"));
-	tool_bar->AddSeparator();
-	tool_bar->AddTool(OPJFRAME_SETSDECO, bmpDecosettings, wxT("Decoder settings"));
-	tool_bar->AddTool(OPJFRAME_SETSENCO, bmpEncosettings, wxT("Encoder settings"));
-	tool_bar->AddSeparator();
-	tool_bar->AddTool(OPJFRAME_VIEWPREVFRAME, bmpPrevframe, wxT("Previous frame"));
-	tool_bar->AddTool(OPJFRAME_VIEWHOMEFRAME, bmpHomeframe, wxT("Starting frame"));
-	tool_bar->AddTool(OPJFRAME_VIEWNEXTFRAME, bmpNextframe, wxT("Next frame"));
-	tool_bar->AddSeparator();
-	tool_bar->AddTool(OPJFRAME_VIEWLESSLAYERS, bmpLesslayers, wxT("Remove a layer"));
-	tool_bar->AddTool(OPJFRAME_VIEWALLLAYERS, bmpAlllayers, wxT("Show all layers"));
-	tool_bar->AddTool(OPJFRAME_VIEWMORELAYERS, bmpMorelayers, wxT("Add a layer"));
-	tool_bar->AddSeparator();
-	tool_bar->AddTool(OPJFRAME_VIEWLESSRES, bmpLessres, wxT("Reduce the resolution"));
-	tool_bar->AddTool(OPJFRAME_VIEWFULLRES, bmpFullres, wxT("Full resolution"));
-	tool_bar->AddTool(OPJFRAME_VIEWMORERES, bmpMoreres, wxT("Increase the resolution"));
-	tool_bar->AddSeparator();
-	tool_bar->AddTool(OPJFRAME_VIEWPREVCOMP, bmpPrevcomp, wxT("Previous component"));
-	tool_bar->AddTool(OPJFRAME_VIEWALLCOMPS, bmpAllcomps, wxT("All components"));
-	tool_bar->AddTool(OPJFRAME_VIEWNEXTCOMP, bmpNextcomp, wxT("Next component"));
-	tool_bar->Realize();
-	
-	// associate the toolbar with the frame
-	SetToolBar(tool_bar);
-
-	// show the toolbar?
-	if (!wxGetApp().m_showtoolbar)
-		tool_bar->Show(false);
-	else
-		tool_bar->Show(true);
-
-	// the logging window
-	loggingWindow = new wxSashLayoutWindow(this, OPJFRAME_LOGWIN,
-											wxDefaultPosition, wxSize(400, wxGetApp().m_peekerheight),
-											wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN
-											);
-	loggingWindow->SetDefaultSize(wxSize(1000, wxGetApp().m_peekerheight));
-	loggingWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
-	loggingWindow->SetAlignment(wxLAYOUT_BOTTOM);
-	//loggingWindow->SetBackgroundColour(wxColour(0, 0, 255));
-	loggingWindow->SetSashVisible(wxSASH_TOP, true);
-
-	// show the logging?
-	if (!wxGetApp().m_showpeeker)
-		loggingWindow->Show(false);
-	else
-		loggingWindow->Show(true);
-
-	// create the bottom notebook
-	m_bookCtrlbottom = new wxNotebook(loggingWindow, BOTTOM_NOTEBOOK_ID,
-								wxDefaultPosition, wxDefaultSize,
-								wxBK_LEFT);
-
-	// create the text control of the logger
-	m_textCtrl = new wxTextCtrl(m_bookCtrlbottom, wxID_ANY, wxT(""),
-								wxDefaultPosition, wxDefaultSize,
-								wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY
-								);
-	m_textCtrl->SetValue(_T("Logging window\n"));
-
-	// add it to the notebook
-	m_bookCtrlbottom->AddPage(m_textCtrl, wxT("Log"));
-
-	// create the text control of the browser
-	m_textCtrlbrowse = new wxTextCtrl(m_bookCtrlbottom, wxID_ANY, wxT(""),
-								wxDefaultPosition, wxDefaultSize,
-								wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY | wxTE_RICH
-								);
-	wxFont *browsefont = new wxFont(wxNORMAL_FONT->GetPointSize(),
-		wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
-    m_textCtrlbrowse->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, *browsefont));
-	m_textCtrlbrowse->AppendText(wxT("Browsing window\n"));
-
-	// add it the notebook
-	m_bookCtrlbottom->AddPage(m_textCtrlbrowse, wxT("Peek"), false);
-
-	// the browser window
-	markerTreeWindow = new wxSashLayoutWindow(this, OPJFRAME_BROWSEWIN,
-											  wxDefaultPosition, wxSize(wxGetApp().m_browserwidth, 30),
-											  wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN
-											  );
-	markerTreeWindow->SetDefaultSize(wxSize(wxGetApp().m_browserwidth, 1000));
-	markerTreeWindow->SetOrientation(wxLAYOUT_VERTICAL);
-	markerTreeWindow->SetAlignment(wxLAYOUT_LEFT);
-	//markerTreeWindow->SetBackgroundColour(wxColour(0, 255, 0));
-	markerTreeWindow->SetSashVisible(wxSASH_RIGHT, true);
-	markerTreeWindow->SetExtraBorderSize(0);
-
-	// create the browser notebook
-	m_bookCtrl = new wxNotebook(markerTreeWindow, LEFT_NOTEBOOK_ID,
-								wxDefaultPosition, wxDefaultSize,
-								wxBK_TOP);
-
-	// show the browser?
-	if (!wxGetApp().m_showbrowser)
-		markerTreeWindow->Show(false);
-	else
-		markerTreeWindow->Show(true);
-
-#ifdef __WXMOTIF__
-	// For some reason, we get a memcpy crash in wxLogStream::DoLogStream
-	// on gcc/wxMotif, if we use wxLogTextCtl. Maybe it's just gcc?
-	delete wxLog::SetActiveTarget(new wxLogStderr);
-#else
-	// set our text control as the log target
-	wxLogTextCtrl *logWindow = new wxLogTextCtrl(m_textCtrl);
-	delete wxLog::SetActiveTarget(logWindow);
-#endif
-
-	// associate drop targets with the controls
-	SetDropTarget(new OPJDnDFile(this));
-
-}
-
-// this is the frame destructor
-OPJFrame::~OPJFrame(void)
-{
-	// save size settings
-	GetSize(&(wxGetApp().m_framewidth), &(wxGetApp().m_frameheight));
-
-	// delete all possible things
-	delete m_bookCtrl;
-	m_bookCtrl = NULL;
-
-	delete markerTreeWindow;
-	markerTreeWindow = NULL;
-
-	delete m_textCtrl;
-	m_textCtrl = NULL;
-
-	delete m_bookCtrlbottom;
-	m_bookCtrlbottom = NULL;
-
-	delete loggingWindow;
-	loggingWindow = NULL;
-}
-
-void OPJFrame::OnNotebook(wxNotebookEvent& event)
-{
-	int sel = event.GetSelection();
-	long childnum;
-
-	m_bookCtrl->GetPageText(sel).ToLong(&childnum);
-
-	if (m_childhash[childnum])
-		m_childhash[childnum]->Activate();
-
-	//wxLogMessage(wxT("Selection changed (now %d --> %d)"), childnum, m_childhash[childnum]->m_winnumber);
-
-}
-
-
-void OPJFrame::Resize(int number)
-{
-	wxSize size = GetClientSize();
-}
-
-void OPJFrame::OnSetsEnco(wxCommandEvent& event)
-{
-	int n;
-
-    OPJEncoderDialog dialog(this, event.GetId());
-
-    if (dialog.ShowModal() == wxID_OK) {
-
-		// load settings
-		wxGetApp().m_subsampling = dialog.m_subsamplingCtrl->GetValue();
-		wxGetApp().m_origin = dialog.m_originCtrl->GetValue();
-		wxGetApp().m_rates = dialog.m_rateCtrl->GetValue();
-		wxGetApp().m_quality = dialog.m_qualityCtrl->GetValue();
-		wxGetApp().m_enablequality = dialog.m_qualityRadio->GetValue();
-		wxGetApp().m_multicomp = dialog.m_mctCheck->GetValue();
-		wxGetApp().m_irreversible = dialog.m_irrevCheck->GetValue();
-		wxGetApp().m_resolutions = dialog.m_resolutionsCtrl->GetValue();
-		wxGetApp().m_cbsize = dialog.m_cbsizeCtrl->GetValue();
-		wxGetApp().m_prsize = dialog.m_prsizeCtrl->GetValue();
-		wxGetApp().m_tsize = dialog.m_tsizeCtrl->GetValue();
-		wxGetApp().m_torigin = dialog.m_toriginCtrl->GetValue();
-		wxGetApp().m_progression = dialog.progressionBox->GetSelection();
-		wxGetApp().m_enablesop = dialog.m_sopCheck->GetValue();
-		wxGetApp().m_enableeph = dialog.m_ephCheck->GetValue();
-		wxGetApp().m_enablebypass = dialog.m_enablebypassCheck->GetValue();
-		wxGetApp().m_enablereset = dialog.m_enableresetCheck->GetValue();
-		wxGetApp().m_enablerestart = dialog.m_enablerestartCheck->GetValue();
-		wxGetApp().m_enablevsc = dialog.m_enablevscCheck->GetValue();
-		wxGetApp().m_enableerterm = dialog.m_enableertermCheck->GetValue();
-		wxGetApp().m_enablesegmark = dialog.m_enablesegmarkCheck->GetValue();
-		wxGetApp().m_enableidx = dialog.m_enableidxCheck->GetValue();
-		wxGetApp().m_index = dialog.m_indexCtrl->GetValue();
-		wxGetApp().m_enablecomm = dialog.m_enablecommCheck->GetValue();
-		wxGetApp().m_comment = dialog.m_commentCtrl->GetValue();
-		wxGetApp().m_enablepoc = dialog.m_enablepocCheck->GetValue();
-		wxGetApp().m_poc = dialog.m_pocCtrl->GetValue();
-#ifdef USE_JPWL
-		wxGetApp().m_enablejpwle = dialog.m_enablejpwlCheck->GetValue();
-		for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
-			wxGetApp().m_hprotsel[n] = dialog.m_hprotChoice[n]->GetSelection();
-			wxGetApp().m_htileval[n] = dialog.m_htileCtrl[n]->GetValue();
-			wxGetApp().m_pprotsel[n] = dialog.m_pprotChoice[n]->GetSelection();
-			wxGetApp().m_ptileval[n] = dialog.m_ptileCtrl[n]->GetValue();
-			wxGetApp().m_ppackval[n] = dialog.m_ppackCtrl[n]->GetValue();
-			wxGetApp().m_sensisel[n] = dialog.m_sensiChoice[n]->GetSelection();
-			wxGetApp().m_stileval[n] = dialog.m_stileCtrl[n]->GetValue();
-		}
-#endif // USE_JPWL
-	};
-}
-
-void OPJFrame::OnSetsDeco(wxCommandEvent& event)
-{
-    OPJDecoderDialog dialog(this, event.GetId());
-
-    if (dialog.ShowModal() == wxID_OK) {
-
-		// load settings
-		wxGetApp().m_enabledeco = dialog.m_enabledecoCheck->GetValue();
-		wxGetApp().m_enableparse = dialog.m_enableparseCheck->GetValue();
-		wxGetApp().m_resizemethod = dialog.m_resizeBox->GetSelection() - 1;
-		wxGetApp().m_reducefactor = dialog.m_reduceCtrl->GetValue();
-		wxGetApp().m_qualitylayers = dialog.m_layerCtrl->GetValue();
-		wxGetApp().m_components = dialog.m_numcompsCtrl->GetValue();
-		wxGetApp().m_framenum = dialog.m_framenumCtrl->GetValue();
-#ifdef USE_JPWL
-		wxGetApp().m_enablejpwl = dialog.m_enablejpwlCheck->GetValue();
-		wxGetApp().m_expcomps = dialog.m_expcompsCtrl->GetValue();
-		wxGetApp().m_maxtiles = dialog.m_maxtilesCtrl->GetValue();
-#endif // USE_JPWL
-
-	};
-}
-
-void OPJFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
-{
-	Close(true);
-}
-
-void OPJFrame::OnClose(wxCommandEvent& WXUNUSED(event))
-{
-	// current frame
-	OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
-
-	if (!currframe)
-		return;
-
-	wxCloseEvent e;
-	currframe->OnClose(e);
-}
-
-void OPJFrame::OnFit(wxCommandEvent& event)
-{
-	OPJChildFrame *currchild;
-	wxString eventstring = event.GetString();
-
-	//wxLogMessage(wxT("OnFit:%d:%s"), event.GetInt(), eventstring);
-
-	// current child
-	if (event.GetInt() >= 1) {
-		currchild = m_childhash[event.GetInt()];
-	} else {
-		currchild = (OPJChildFrame *) GetActiveChild();
-	}
-
-	// problems
-	if (!currchild)
-		return;
-
-	// current canvas
-	OPJCanvas *currcanvas = currchild->m_canvas;
-
-	// find a fit-to-width zoom
-	/*int zooml, wzooml, hzooml;
-	wxSize clientsize = currcanvas->GetClientSize();
-	wzooml = (int) ceil(100.0 * (double) (clientsize.GetWidth() - 2 * OPJ_CANVAS_BORDER) / (double) (currcanvas->m_image100.GetWidth()));
-	hzooml = (int) ceil(100.0 * (double) (clientsize.GetHeight() - 2 * OPJ_CANVAS_BORDER) / (double) (currcanvas->m_image100.GetHeight()));
-	zooml = wxMin(100, wxMin(wzooml, hzooml));*/
-
-	// fit to width
-	Rescale(-1, currchild);
-}
-
-void OPJFrame::OnZoom(wxCommandEvent& WXUNUSED(event))
-{
-	// current frame
-	OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
-
-	if (!currframe)
-		return;
-
-	// get the preferred zoom
-	long zooml = wxGetNumberFromUser(wxT("Choose a scale between 5% and 300%"),
-		wxT("Zoom (%)"),
-		wxT("Image scale"),
-		currframe->m_canvas->m_zooml, 5, 300, NULL, wxDefaultPosition);
-
-	// rescale current frame image if necessary
-	if (zooml >= 5) {
-		Rescale(zooml, currframe);
-		wxLogMessage(wxT("zoom to %d%%"), zooml);
-	}
-}
-
-void OPJFrame::Rescale(int zooml, OPJChildFrame *currframe)
-{
-	wxImage new_image = currframe->m_canvas->m_image100.ConvertToImage();
-
-	// resizing enabled?
-	if (wxGetApp().m_resizemethod == -1) {
-
-		zooml = 100;
-
-	} else {
-
-		if (zooml < 0) {
-			// find a fit-to-width zoom
-			int wzooml, hzooml;
-			//wxSize clientsize = currframe->m_canvas->GetClientSize();
-			wxSize clientsize = currframe->m_frame->GetActiveChild()->GetClientSize();
-			wzooml = (int) floor(100.0 * (double) clientsize.GetWidth() / (double) (2 * OPJ_CANVAS_BORDER + currframe->m_canvas->m_image100.GetWidth()));
-			hzooml = (int) floor(100.0 * (double) clientsize.GetHeight() / (double) (2 * OPJ_CANVAS_BORDER + currframe->m_canvas->m_image100.GetHeight()));
-			zooml = wxMin(100, wxMin(wzooml, hzooml));
-		}
-	}
-
-	if (zooml != 100)
-		new_image.Rescale((int) ((double) zooml * (double) new_image.GetWidth() / 100.0),
-			(int) ((double) zooml * (double) new_image.GetHeight() / 100.0),
-			wxGetApp().m_resizemethod ? wxIMAGE_QUALITY_HIGH : wxIMAGE_QUALITY_NORMAL);
-	currframe->m_canvas->m_image = wxBitmap(new_image);
-	currframe->m_canvas->SetScrollbars(20,
-										20,
-										(int)(0.5 + (double) new_image.GetWidth() / 20.0),
-										(int)(0.5 + (double) new_image.GetHeight() / 20.0)
-										);
-
-	currframe->m_canvas->Refresh();
-
-	wxLogMessage(wxT("Rescale said %d%%"), zooml);
-
-	// update zoom
-	currframe->m_canvas->m_zooml = zooml;
-}
-
-
-void OPJFrame::OnReload(wxCommandEvent& event)
-{
-	OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
-
-	if (currframe) {
-		OPJDecoThread *dthread = currframe->m_canvas->CreateDecoThread();
-
-		if (dthread->Run() != wxTHREAD_NO_ERROR)
-			wxLogMessage(wxT("Can't start deco thread!"));
-		else
-			wxLogMessage(wxT("New deco thread started."));
-
-		currframe->m_canvas->Refresh();
-
-		// update zoom
-		//currframe->m_canvas->m_zooml = zooml;
-	}
-}
-
-void OPJFrame::OnPrevFrame(wxCommandEvent& event)
-{
-	if (--wxGetApp().m_framenum < 0)
-		wxGetApp().m_framenum = 0;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnHomeFrame(wxCommandEvent& event)
-{
-	wxGetApp().m_framenum = 0;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnNextFrame(wxCommandEvent& event)
-{
-	++wxGetApp().m_framenum;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnLessLayers(wxCommandEvent& event)
-{
-	if (--wxGetApp().m_qualitylayers < 1)
-		wxGetApp().m_qualitylayers = 1;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnAllLayers(wxCommandEvent& event)
-{
-	wxGetApp().m_qualitylayers = 0;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnMoreLayers(wxCommandEvent& event)
-{
-	++wxGetApp().m_qualitylayers;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnLessRes(wxCommandEvent& event)
-{
-	++wxGetApp().m_reducefactor;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnFullRes(wxCommandEvent& event)
-{
-	wxGetApp().m_reducefactor = 0;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnMoreRes(wxCommandEvent& event)
-{
-	if (--wxGetApp().m_reducefactor < 0)
-		wxGetApp().m_reducefactor = 0;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnPrevComp(wxCommandEvent& event)
-{
-	if (--wxGetApp().m_components < 1)
-		wxGetApp().m_components = 1;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnAllComps(wxCommandEvent& event)
-{
-	wxGetApp().m_components = 0;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnNextComp(wxCommandEvent& event)
-{
-	++wxGetApp().m_components;
-
-	wxCommandEvent e;
-	OnReload(e);
-}
-
-void OPJFrame::OnToggleBrowser(wxCommandEvent& WXUNUSED(event))
-{
-    if (markerTreeWindow->IsShown())
-        markerTreeWindow->Show(false);
-    else
-        markerTreeWindow->Show(true);
-
-    wxLayoutAlgorithm layout;
-    layout.LayoutMDIFrame(this);
-
-	wxGetApp().m_showbrowser = markerTreeWindow->IsShown();
-
-    // Leaves bits of itself behind sometimes
-    GetClientWindow()->Refresh();
-}
-
-void OPJFrame::OnTogglePeeker(wxCommandEvent& WXUNUSED(event))
-{
-    if (loggingWindow->IsShown())
-        loggingWindow->Show(false);
-    else
-        loggingWindow->Show(true);
-
-    wxLayoutAlgorithm layout;
-    layout.LayoutMDIFrame(this);
-
-	wxGetApp().m_showpeeker = loggingWindow->IsShown();
-
-    // Leaves bits of itself behind sometimes
-    GetClientWindow()->Refresh();
-}
-
-void OPJFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event))
-{
-    if (tool_bar->IsShown())
-        tool_bar->Show(false);
-    else
-        tool_bar->Show(true);
-
-    wxLayoutAlgorithm layout;
-    layout.LayoutMDIFrame(this);
-
-	wxGetApp().m_showtoolbar = tool_bar->IsShown();
-
-    // Leaves bits of itself behind sometimes
-    GetClientWindow()->Refresh();
-}
-
-void OPJFrame::OnSashDrag(wxSashEvent& event)
-{
-	int wid, hei;
-
-    if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
-        return;
-
-    switch (event.GetId()) {
-		case OPJFRAME_BROWSEWIN:
-		{
-			markerTreeWindow->SetDefaultSize(wxSize(event.GetDragRect().width, 1000));
-			break;
-		}
-		case OPJFRAME_LOGWIN:
-		{
-			loggingWindow->SetDefaultSize(wxSize(1000, event.GetDragRect().height));
-			break;
-		}
-    }
-
-    wxLayoutAlgorithm layout;
-    layout.LayoutMDIFrame(this);
-
-    // Leaves bits of itself behind sometimes
-    GetClientWindow()->Refresh();
-
-	// update dimensions
-	markerTreeWindow->GetSize(&wid, &hei);
-	wxGetApp().m_browserwidth = wid;
-
-	loggingWindow->GetSize(&wid, &hei);
-	wxGetApp().m_peekerheight = hei;
-
-}
-
-void OPJFrame::OnThreadLogmsg(wxCommandEvent& event)
-{
-#if 1
-    wxLogMessage(wxT("Frame got message from worker thread: %d"), event.GetInt());
-    wxLogMessage(event.GetString());
-#else
-    int n = event.GetInt();
-    if ( n == -1 )
-    {
-        m_dlgProgress->Destroy();
-        m_dlgProgress = (wxProgressDialog *)NULL;
-
-        // the dialog is aborted because the event came from another thread, so
-        // we may need to wake up the main event loop for the dialog to be
-        // really closed
-        wxWakeUpIdle();
-    }
-    else
-    {
-        if ( !m_dlgProgress->Update(n) )
-        {
-            wxCriticalSectionLocker lock(m_critsectWork);
-
-            m_cancelled = true;
-        }
-    }
-#endif
-}
-
-
-// physically save the file
-void OPJFrame::SaveFile(wxArrayString paths, wxArrayString filenames)
-{
-	size_t count = paths.GetCount();
-	wxString msg, s;
-
-	if (wxFile::Exists(paths[0].c_str())) {
-
-		s.Printf(wxT("File %s already exists. Do you want to overwrite it?\n"), filenames[0].c_str());
-		wxMessageDialog dialog3(this, s, _T("File exists"), wxYES_NO);
-		if (dialog3.ShowModal() == wxID_NO)
-			return;
-	}
-
-	/*s.Printf(_T("File %d: %s (%s)\n"), (int)0, paths[0].c_str(), filenames[0].c_str());
-	msg += s;
-
-	wxMessageDialog dialog2(this, msg, _T("Selected files"));
-	dialog2.ShowModal();*/
-
-	if (!GetActiveChild())
-		return;
-
-	((OPJChildFrame *) GetActiveChild())->m_canvas->m_savename = paths[0];
-
-	OPJEncoThread *ethread = ((OPJChildFrame *) GetActiveChild())->m_canvas->CreateEncoThread();
-
-    if (ethread->Run() != wxTHREAD_NO_ERROR)
-        wxLogMessage(wxT("Can't start enco thread!"));
-    else
-		wxLogMessage(wxT("New enco thread started."));
-
-
-}
-
-// physically open the files
-void OPJFrame::OpenFiles(wxArrayString paths, wxArrayString filenames)
-{
-
-	size_t count = paths.GetCount();
-	for (size_t n = 0; n < count; n++) {
-
-		wxString msg, s;
-		s.Printf(_T("File %d: %s (%s)\n"), (int)n, paths[n].c_str(), filenames[n].c_str());
-
-		msg += s;
-
-		/*wxMessageDialog dialog2(this, msg, _T("Selected files"));
-		dialog2.ShowModal();*/
-
-		// Make another frame, containing a canvas
-		OPJChildFrame *subframe = new OPJChildFrame(this,
-													paths[n],
-													winNumber,
-													wxT("Canvas Frame"),
-													wxDefaultPosition, wxSize(300, 300),
-													wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE
-													);
-		m_childhash[winNumber] = subframe;
-
-		// create own marker tree
-		m_treehash[winNumber] = new OPJMarkerTree(m_bookCtrl, subframe, paths[n], wxT("Parsing..."), TreeTest_Ctrl,
-												  wxDefaultPosition, wxDefaultSize,
-												  wxTR_DEFAULT_STYLE | wxSUNKEN_BORDER
-												  );
-
-		m_bookCtrl->AddPage(m_treehash[winNumber], wxString::Format(wxT("%u"), winNumber), false);
-
-		for (unsigned int p = 0; p < m_bookCtrl->GetPageCount(); p++) {
-			if (m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"), winNumber)) {
-				m_bookCtrl->ChangeSelection(p);
-				break;
-			}
-		}
-
-		winNumber++;
-	}
-}
-
-void OPJFrame::OnFileOpen(wxCommandEvent& WXUNUSED(event))
-{
-    wxString wildcards =
-#ifdef __WXMOTIF__
-	wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.*j*2*");
-#else
-#if wxUSE_LIBOPENJPEG
-	wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.jp2;*.j2k;*.j2c;*.mj2")
-#endif
-#if USE_MXF
-	wxT("|MXF JPEG 2000 video (*.mxf)|*.mxf")
-#endif // USE_MXF
-#if wxUSE_LIBJPEG
-		wxT("|JPEG files (*.jpg)|*.jpg")
-#endif
-#if OPJ_MANYFORMATS
-		wxT("|BMP files (*.bmp)|*.bmp")
-		wxT("|PNG files (*.png)|*.png")
-		wxT("|GIF files (*.gif)|*.gif")
-		wxT("|PNM files (*.pnm)|*.pnm")
-		wxT("|TIFF files (*.tif,*.tiff)|*.tif*")
-#endif
-		wxT("|All files|*");
-#endif
-    wxFileDialog dialog(this, _T("Open image file(s)"),
-                        wxEmptyString, wxEmptyString, wildcards,
-                        wxFD_OPEN|wxFD_MULTIPLE);
-
-    if (dialog.ShowModal() == wxID_OK) {
-        wxArrayString paths, filenames;
-
-        dialog.GetPaths(paths);
-        dialog.GetFilenames(filenames);
-
-		OpenFiles(paths, filenames);
-    }
-
-}
-
-void OPJFrame::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
-{
-    wxString wildcards =
-#ifdef wxUSE_LIBOPENJPEG
-#ifdef __WXMOTIF__
-	wxT("JPEG 2000 codestream (*.j2k)|*.*j*2*");
-#else
-	wxT("JPEG 2000 codestream (*.j2k)|*.j2k")
-	wxT("|JPEG 2000 file format (*.jp2)|*.jp2");
-#endif
-#endif
-
-    wxFileDialog dialog(this, _T("Save image file"),
-                        wxEmptyString, wxEmptyString, wildcards,
-                        wxFD_SAVE);
-
-    if (dialog.ShowModal() == wxID_OK) {
-        wxArrayString paths, filenames;
-
-        dialog.GetPaths(paths);
-        dialog.GetFilenames(filenames);
-
-		SaveFile(paths, filenames);
-    }
-
-
-}
-
-void OPJFrame::OnMemoryOpen(wxCommandEvent& WXUNUSED(event))
-{
-	// do nothing
-	return;
-	
-	wxTextEntryDialog dialog(this, wxT("Memory HEX address range: start_address-stop_address"),
-							wxT("Decode a memory buffer"),
-							wxT("0x-0x"),
-							wxOK | wxCANCEL | wxCENTRE,
-							wxDefaultPosition);
-
-	if (dialog.ShowModal() == wxID_OK) {
-
-	}
-
-}
-
-BEGIN_EVENT_TABLE(OPJCanvas, wxScrolledWindow)
-    EVT_MOUSE_EVENTS(OPJCanvas::OnEvent)
-    EVT_MENU(OPJCANVAS_THREADSIGNAL, OPJCanvas::OnThreadSignal)
-END_EVENT_TABLE()
-
-// Define a constructor for my canvas
-OPJCanvas::OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size)
-        : wxScrolledWindow(parent, wxID_ANY, pos, size,
-                           wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE)
-{
-    SetBackgroundColour(OPJ_CANVAS_COLOUR);
-
-	m_fname = fname;
-	m_childframe = (OPJChildFrame *) parent;
-	// 100% zoom
-	m_zooml = 100;
-
-
-    OPJDecoThread *dthread = CreateDecoThread();
-
-    if (dthread->Run() != wxTHREAD_NO_ERROR)
-        wxLogMessage(wxT("Can't start deco thread!"));
-    else
-		wxLogMessage(wxT("New deco thread started."));
-
-	// 100% zoom
-	//m_zooml = 100;
-
-}
-
-OPJDecoThread *OPJCanvas::CreateDecoThread(void)
-{
-    OPJDecoThread *dthread = new OPJDecoThread(this);
-
-    if (dthread->Create() != wxTHREAD_NO_ERROR)
-		wxLogError(wxT("Can't create deco thread!"));
-
-    wxCriticalSectionLocker enter(wxGetApp().m_deco_critsect);
-    wxGetApp().m_deco_threads.Add(dthread);
-
-    return dthread;
-}
-
-OPJEncoThread *OPJCanvas::CreateEncoThread(void)
-{
-    OPJEncoThread *ethread = new OPJEncoThread(this);
-
-    if (ethread->Create() != wxTHREAD_NO_ERROR)
-		wxLogError(wxT("Can't create enco thread!"));
-
-    wxCriticalSectionLocker enter(wxGetApp().m_enco_critsect);
-    wxGetApp().m_enco_threads.Add(ethread);
-
-    return ethread;
-}
-
-#define activeoverlay 0
-// Define the repainting behaviour
-void OPJCanvas::OnDraw(wxDC& dc)
-{
-	if (m_image.Ok()) {
-		dc.DrawBitmap(m_image, OPJ_CANVAS_BORDER, OPJ_CANVAS_BORDER);
-
-		if (activeoverlay) {
-			dc.SetPen(*wxRED_PEN);
-			dc.SetBrush(*wxTRANSPARENT_BRUSH);
-			//int tw, th;
-			dc.DrawRectangle(OPJ_CANVAS_BORDER, OPJ_CANVAS_BORDER,
-				(unsigned long int) (0.5 + (double) m_zooml * (double) m_childframe->m_twidth / 100.0),
-				(unsigned long int) (0.5 + (double) m_zooml * (double) m_childframe->m_theight / 100.0));
-		}
-
-	} else {
-		dc.SetFont(*wxSWISS_FONT);
-		dc.SetPen(*wxBLACK_PEN);
-#ifdef __WXGTK__
-		dc.DrawText(_T("Decoding image, please wait... (press \"Zoom to Fit\" to show the image)"), 40, 50);
-#else
-		dc.DrawText(_T("Decoding image, please wait..."), 40, 50);
-#endif
-	}
-}
-
-// This implements a tiny doodling program! Drag the mouse using
-// the left button.
-void OPJCanvas::OnEvent(wxMouseEvent& event)
-{
-#if USE_PENCIL_ON_CANVAS
-  wxClientDC dc(this);
-  PrepareDC(dc);
-
-  wxPoint pt(event.GetLogicalPosition(dc));
-
-  if ((xpos > -1) && (ypos > -1) && event.Dragging()) {
-    dc.SetPen(*wxRED_PEN);
-    dc.DrawLine(xpos, ypos, pt.x, pt.y);
-  }
-  xpos = pt.x;
-  ypos = pt.y;
-#endif
-}
-
-void OPJFrame::OnSize(wxSizeEvent& WXUNUSED(event))
-{
-    wxLayoutAlgorithm layout;
-    layout.LayoutMDIFrame(this);
-}
-
-void OPJCanvas::OnThreadSignal(wxCommandEvent& event)
-{
-#if 1
-    wxLogMessage(wxT("Canvas got signal from deco thread: %d"), event.GetInt());
-    wxLogMessage(event.GetString());
-#else
-    int n = event.GetInt();
-    if ( n == -1 )
-    {
-        m_dlgProgress->Destroy();
-        m_dlgProgress = (wxProgressDialog *)NULL;
-
-        // the dialog is aborted because the event came from another thread, so
-        // we may need to wake up the main event loop for the dialog to be
-        // really closed
-        wxWakeUpIdle();
-    }
-    else
-    {
-        if ( !m_dlgProgress->Update(n) )
-        {
-            wxCriticalSectionLocker lock(m_critsectWork);
-
-            m_cancelled = true;
-        }
-    }
-#endif
-}
-
-
-// Note that OPJFRAME_FILEOPEN and OPJFRAME_HELPABOUT commands get passed
-// to the parent window for processing, so no need to
-// duplicate event handlers here.
-
-BEGIN_EVENT_TABLE(OPJChildFrame, wxMDIChildFrame)
-  /*EVT_MENU(SASHTEST_CHILD_QUIT, OPJChildFrame::OnQuit)*/
-  EVT_CLOSE(OPJChildFrame::OnClose)
-  EVT_SET_FOCUS(OPJChildFrame::OnGotFocus)
-  EVT_KILL_FOCUS(OPJChildFrame::OnLostFocus)
-END_EVENT_TABLE()
-
-OPJChildFrame::OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size,
-const long style):
-  wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
-{
-	m_frame = (OPJFrame  *) parent;
-	m_canvas = NULL;
-	//my_children.Append(this);
-	m_fname = fname;
-	m_winnumber = winnumber;
-	SetTitle(wxString::Format(_T("%d: "), m_winnumber) + m_fname.GetFullName());
-
-	  // Give it an icon (this is ignored in MDI mode: uses resources)
-#ifdef __WXMSW__
-	SetIcon(wxIcon(wxT("OPJChild16")));
-#endif
-
-	// Give it a status line
-	/*CreateStatusBar();*/
-
-	int width, height;
-	GetClientSize(&width, &height);
-
-	OPJCanvas *canvas = new OPJCanvas(fname, this, wxPoint(0, 0), wxSize(width, height));
-#if USE_PENCIL_ON_CANVAS
-	canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
-#endif
-	m_canvas = canvas;
-
-	// Give it scrollbars
-	canvas->SetScrollbars(20, 20, 5, 5);
-
-	Show(true);
-	Maximize(true);
-
-	/*wxLogError(wxString::Format(wxT("Created tree %d (0x%x)"), m_winnumber, m_frame->m_treehash[m_winnumber]));*/
-
-}
-
-OPJChildFrame::~OPJChildFrame(void)
-{
-  //my_children.DeleteObject(this);
-}
-
-
-void OPJChildFrame::OnClose(wxCloseEvent& event)
-{
-	for (unsigned int p = 0; p < m_frame->m_bookCtrl->GetPageCount(); p++) {
-		if (m_frame->m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"), m_winnumber)) {
-			m_frame->m_bookCtrl->DeletePage(p);
-			break;
-		}
-	}
-	Destroy();
-
-	wxLogMessage(wxT("Closed: %d"), m_winnumber);
-}
-
-void OPJChildFrame::OnActivate(wxActivateEvent& event)
-{
-  /*if (event.GetActive() && m_canvas)
-    m_canvas->SetFocus();*/
-}
-
-void OPJChildFrame::OnGotFocus(wxFocusEvent& event)
-{
-	// we need to check if the notebook is being destroyed or not
-	if (!m_frame->m_bookCtrl)
-		return;
-
-	for (unsigned int p = 0; p < m_frame->m_bookCtrl->GetPageCount(); p++) {
-
-		if (m_frame->m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"), m_winnumber)) {
-			m_frame->m_bookCtrl->ChangeSelection(p);
-			break;
-		}
-
-	}
-
-	//wxLogMessage(wxT("Got focus: %d (%x)"), m_winnumber, event.GetWindow());
-}
-
-void OPJChildFrame::OnLostFocus(wxFocusEvent& event)
-{
-	//wxLogMessage(wxT("Lost focus: %d (%x)"), m_winnumber, event.GetWindow());
-}
-
-
-////////////////////////////////
-// drag and drop 
-////////////////////////////////
-
-bool OPJDnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
-{
-    /*size_t nFiles = filenames.GetCount();
-    wxString str;
-    str.Printf( _T("%d files dropped\n"), (int)nFiles);
-    for ( size_t n = 0; n < nFiles; n++ ) {
-        str << filenames[n] << wxT("\n");
-    }
-    wxLogMessage(str);*/
-	m_pOwner->OpenFiles(filenames, filenames);
-
-    return true;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.h b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.h
deleted file mode 100644
index 3574dac..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.h
+++ /dev/null
@@ -1,811 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/////////////////////////////////////////////////////////////////////////////
-// Name:        sashtest.h
-// Purpose:     Layout window/sash sample
-// Author:      Julian Smart
-// Modified by:
-// Created:     04/01/98
-// RCS-ID:      $Id: sashtest.h,v 1.5 2005/06/02 12:04:24 JS Exp $
-// Copyright:   (c) Julian Smart
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        treectrl.h
-// Purpose:     wxTreeCtrl sample
-// Author:      Julian Smart
-// Modified by:
-// Created:     04/01/98
-// RCS-ID:      $Id: treetest.h,v 1.50 2006/11/04 11:26:51 VZ Exp $
-// Copyright:   (c) Julian Smart
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Name:        dialogs.h
-// Purpose:     Common dialogs demo
-// Author:      Julian Smart
-// Modified by: ABX (2004) - adjustementd for conditional building
-// Created:     04/01/98
-// RCS-ID:      $Id: dialogs.h,v 1.50 2006/10/08 14:12:59 VZ Exp $
-// Copyright:   (c) Julian Smart
-// Licence:     wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef __OPJ_VIEWER_H__
-#define __OPJ_VIEWER_H__
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-#pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
-#include "wx/wx.h"
-#include "wx/mdi.h"
-#endif
-
-#include "wx/toolbar.h"
-#include "wx/laywin.h"
-#include "wx/treectrl.h"
-
-#include "icon1.xpm"
-#include "icon2.xpm"
-#include "icon3.xpm"
-#include "icon4.xpm"
-#include "icon5.xpm"
-
-#include "wx/filedlg.h"
-#include "wx/toolbar.h"
-#include <wx/filename.h>
-#include <wx/busyinfo.h>
-#include <wx/cmdline.h>
-#include <wx/file.h>
-#include "wx/notebook.h"
-#include <wx/numdlg.h>
-
-#include "wx/propdlg.h"
-#include "wx/spinctrl.h"
-
-#include <wx/dnd.h>
-#include "wx/wxhtml.h"
-#include "wx/statline.h"
-#include <wx/fs_mem.h>
-
-#include <wx/imaglist.h>
-
-#include "wx/toolbar.h"
-#include "wx/artprov.h"
-
-#include "libopenjpeg/openjpeg.h"
-
-//#include "imagj2k.h"
-//#include "imagjp2.h"
-//#include "imagmj2.h"
-#include "imagjpeg2000.h"
-#ifdef USE_MXF
-#include "imagmxf.h"
-#endif // USE_MXF
-
-#ifdef __WXMSW__
-typedef unsigned __int64 int8byte;
-#endif // __WXMSW__
-
-#ifdef __WXGTK__
-typedef unsigned long long int8byte;
-#endif // __WXGTK__
-
-#define USE_GENERIC_TREECTRL 0
-#define USE_PENCIL_ON_CANVAS 0
-
-#if USE_GENERIC_TREECTRL
-#include "wx/generic/treectlg.h"
-#ifndef wxTreeCtrl
-#define wxTreeCtrl wxGenericTreeCtrl
-#define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
-#endif
-#endif
-
-#define OPJ_APPLICATION             wxT("OPJViewer")
-#define OPJ_APPLICATION_NAME		wxT("OpenJPEG Viewer")
-#define OPJ_APPLICATION_VERSION		wxT("0.4 beta")
-#define OPJ_APPLICATION_TITLEBAR	OPJ_APPLICATION_NAME wxT(" ") OPJ_APPLICATION_VERSION
-#define OPJ_APPLICATION_COPYRIGHT	wxT("(C) 2007-2008, Giuseppe Baruffa")
-#define OPJ_APPLICATION_VENDOR      wxT("OpenJPEG")
-
-#ifdef __WXMSW__
-#define OPJ_APPLICATION_PLATFORM    wxT("Windows")
-#endif
-
-#ifdef __WXGTK__
-#define OPJ_APPLICATION_PLATFORM    wxT("Linux")
-#endif
-
-#define OPJ_FRAME_WIDTH   800
-#define OPJ_FRAME_HEIGHT  600
-
-#define OPJ_BROWSER_WIDTH 300
-#define OPJ_PEEKER_HEIGHT 130
-
-#define OPJ_CANVAS_BORDER 10
-#define OPJ_CANVAS_COLOUR *wxWHITE
-
-
-
-#ifdef USE_JPWL
-
-//#define MYJPWL_MAX_NO_TILESPECS JPWL_MAX_NO_TILESPECS
-#define MYJPWL_MAX_NO_TILESPECS 4
-
-#endif // USE_JPWL
-
-
-class OPJDecoThread;
-class OPJEncoThread;
-class OPJParseThread;
-WX_DEFINE_ARRAY_PTR(wxThread *, wxArrayThread);
-class OPJChildFrame;
-
-//////////////////////////////////
-// this is our main application //
-//////////////////////////////////
-class OPJViewerApp: public wxApp
-{
-	// public methods and variables
-	public:
-
-		// class constructor
-		OPJViewerApp() { m_showImages = true; m_showButtons = false; }
-
-		// other methods
-		bool OnInit(void);
-		int OnExit(void);
-		void SetShowImages(bool show) { m_showImages = show; }
-		bool ShowImages() const { return m_showImages; }
-		void ShowCmdLine(const wxCmdLineParser& parser);
-
-		// all the threads currently alive - as soon as the thread terminates, it's
-		// removed from the array
-		wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
-
-		// crit section protects access to all of the arrays below
-		wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
-
-		// semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
-		wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
-
-		// the last exiting thread should post to m_semAllDone if this is true
-		// (protected by the same m_critsect)
-		bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
-
-		// the list of all filenames written in the command line
-		wxArrayString m_filelist;
-
-		// displaying engine parameters
-		int m_resizemethod;
-
-		// decoding engine parameters
-		bool m_enabledeco, m_enableparse;
-		int m_reducefactor, m_qualitylayers, m_components, m_framenum;
-#ifdef USE_JPWL
-		bool m_enablejpwl, m_enablejpwle;
-		int m_expcomps, m_maxtiles;
-		int m_framewidth, m_frameheight;
-#endif // USE_JPWL
-
-		// encoding engine parameters
-		wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
-		wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
-		bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
-		bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
-		bool m_enablesegmark, m_enablepoc;
-		bool m_enablequality;
-		int m_resolutions, m_progression;
-#ifdef USE_JPWL
-		int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
-		int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
-			m_ppackval[MYJPWL_MAX_NO_TILESPECS];
-		int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
-#endif // USE_JPWL
-
-		// some layout settings
-		bool m_showtoolbar, m_showbrowser, m_showpeeker;
-		int m_browserwidth, m_peekerheight;
-
-		// application configuration
-		wxConfig *OPJconfig; 
-
-	// private methods and variables
-	private:
-		bool m_showImages, m_showButtons;
-
-};
-
-DECLARE_APP(OPJViewerApp)
-
-///////////////////////////////////////////
-// this canvas is used to draw the image //
-///////////////////////////////////////////
-class OPJCanvas: public wxScrolledWindow
-{
-	// public methods and variables
-	public:
-
-		// class constructor
-		OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
-
-		virtual void OnDraw(wxDC& dc);
-		void OnEvent(wxMouseEvent& event);
-		void WriteText(const wxString& text) {
-#ifndef __WXGTK__ 
-			wxMutexGuiEnter();
-#endif //__WXGTK__
-			wxLogMessage(text);
-#ifndef __WXGTK__ 
-			wxMutexGuiLeave();
-#endif //__WXGTK__
-		}
-
-		void OnThreadSignal(wxCommandEvent& event);
-
-		OPJDecoThread *CreateDecoThread(void);
-		OPJEncoThread *CreateEncoThread(void);
-
-
-		OPJChildFrame *m_childframe;
-
-		wxBitmap  m_image, m_image100;
-		wxFileName m_fname, m_savename;
-		long m_zooml;
-
-	DECLARE_EVENT_TABLE()
-};
-
-///////////////////////////////////////////////////
-// the data associated to each tree leaf or node //
-///////////////////////////////////////////////////
-class OPJMarkerData : public wxTreeItemData
-{
-	// public methods and variables
-	public:
-
-		// class constructor
-		OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname) { m_start = start; m_length = length; }
-
-		void ShowInfo(wxTreeCtrl *tree);
-		const wxChar *GetDesc1() const { return m_desc.c_str(); }
-		const wxChar *GetDesc2() const { return m_filestring.c_str(); }
-		wxFileOffset m_start, m_length;
-		wxString m_desc;
-
-	// private methods and variables
-	private:
-		wxString m_filestring;
-};
-
-
-class OPJMarkerTree : public wxTreeCtrl
-{
-public:
-    enum
-    {
-        TreeCtrlIcon_File,
-        TreeCtrlIcon_FileSelected,
-        TreeCtrlIcon_Folder,
-        TreeCtrlIcon_FolderSelected,
-        TreeCtrlIcon_FolderOpened
-    };
-
-    OPJMarkerTree() { };
-    OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
-               const wxPoint& pos, const wxSize& size,
-               long style);
-    virtual ~OPJMarkerTree(){};
-	OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
-    void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
-
-	wxFileName m_fname;
-	wxTextCtrl *m_peektextCtrl;
-	OPJChildFrame *m_childframe;
-
-    /*void OnBeginDrag(wxTreeEvent& event);
-    void OnBeginRDrag(wxTreeEvent& event);
-    void OnEndDrag(wxTreeEvent& event);*/
-    /*void OnBeginLabelEdit(wxTreeEvent& event);
-    void OnEndLabelEdit(wxTreeEvent& event);*/
-    /*void OnDeleteItem(wxTreeEvent& event);*/
-    /*void OnContextMenu(wxContextMenuEvent& event);*/
-    void OnItemMenu(wxTreeEvent& event);
-    /*void OnGetInfo(wxTreeEvent& event);
-    void OnSetInfo(wxTreeEvent& event);*/
-    /*void OnItemExpanded(wxTreeEvent& event);*/
-    void OnItemExpanding(wxTreeEvent& event);
-    /*void OnItemCollapsed(wxTreeEvent& event);
-    void OnItemCollapsing(wxTreeEvent& event);*/
-    void OnSelChanged(wxTreeEvent& event);
-    /*void OnSelChanging(wxTreeEvent& event);*/
-    /*void OnTreeKeyDown(wxTreeEvent& event);*/
-    /*void OnItemActivated(wxTreeEvent& event);*/
-    /*void OnItemRClick(wxTreeEvent& event);*/
-    /*void OnRMouseDown(wxMouseEvent& event);
-    void OnRMouseUp(wxMouseEvent& event);
-    void OnRMouseDClick(wxMouseEvent& event);*/
-    /*void GetItemsRecursively(const wxTreeItemId& idParent,
-                             wxTreeItemIdValue cookie = 0);*/
-
-    void CreateImageList(int size = 16);
-    void CreateButtonsImageList(int size = 11);
-
-    /*void AddTestItemsToTree(size_t numChildren, size_t depth);*/
-    /*void DoSortChildren(const wxTreeItemId& item, bool reverse = false)
-        { m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }*/
-    /*void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); }*/
-    /*void DoToggleIcon(const wxTreeItemId& item);*/
-    /*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
-
-    int ImageSize(void) const { return m_imageSize; }
-
-    void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
-
-protected:
-    /*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
-
-    // is this the test item which we use in several event handlers?
-    /*bool IsTestItem(const wxTreeItemId& item)
-    {
-        // the test item is the first child folder
-        return GetItemParent(item) == GetRootItem() && !GetPrevSibling(item);
-    }*/
-
-private:
-    /*void AddItemsRecursively(const wxTreeItemId& idParent,
-                             size_t nChildren,
-                             size_t depth,
-                             size_t folder);*/
-
-    void LogEvent(const wxChar *name, const wxTreeEvent& event);
-
-    int          m_imageSize;               // current size of images
-    bool         m_reverseSort;             // flag for OnCompareItems
-    wxTreeItemId m_lastItem,                // for OnEnsureVisible()
-                 m_draggedItem;             // item being dragged right now
-
-    // NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
-    //     if you want your overloaded OnCompareItems() to be called.
-    //     OTOH, if you don't want it you may omit the next line - this will
-    //     make default (alphabetical) sorting much faster under wxMSW.
-    DECLARE_DYNAMIC_CLASS(OPJMarkerTree)
-    DECLARE_EVENT_TABLE()
-};
-
-// this hash map stores all the trees of currently opened images, with an integer key
-WX_DECLARE_HASH_MAP(int, OPJMarkerTree*, wxIntegerHash, wxIntegerEqual, OPJMarkerTreeHash);
-
-// this hash map stores all the children of currently opened images, with an integer key
-WX_DECLARE_HASH_MAP(int, OPJChildFrame*, wxIntegerHash, wxIntegerEqual, OPJChildFrameHash);
-
-// Define a new frame
-class OPJFrame: public wxMDIParentFrame
-{
-  public:
-
-    OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
-
-    ~OPJFrame(void);
-	void OnSize(wxSizeEvent& WXUNUSED(event));
-    void OnAbout(wxCommandEvent& WXUNUSED(event));
-    void OnFileOpen(wxCommandEvent& WXUNUSED(event));
-    void OnFileSaveAs(wxCommandEvent& WXUNUSED(event));
-    void OnMemoryOpen(wxCommandEvent& WXUNUSED(event));
-    void OnQuit(wxCommandEvent& WXUNUSED(event));
-    void OnClose(wxCommandEvent& WXUNUSED(event));
-    void OnZoom(wxCommandEvent& WXUNUSED(event));
-	void OnFit(wxCommandEvent& event);
-	void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
-	void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
-	void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
-	void OnReload(wxCommandEvent& event);
-	void OnPrevFrame(wxCommandEvent& event);
-	void OnHomeFrame(wxCommandEvent& event);
-	void OnNextFrame(wxCommandEvent& event);
-	void OnLessLayers(wxCommandEvent& event);
-	void OnAllLayers(wxCommandEvent& event);
-	void OnMoreLayers(wxCommandEvent& event);
-	void OnLessRes(wxCommandEvent& event);
-	void OnFullRes(wxCommandEvent& event);
-	void OnMoreRes(wxCommandEvent& event);
-	void OnPrevComp(wxCommandEvent& event);
-	void OnAllComps(wxCommandEvent& event);
-	void OnNextComp(wxCommandEvent& event);
-	void OnSetsEnco(wxCommandEvent& event);
-	void OnSetsDeco(wxCommandEvent& event);
-	void OnSashDrag(wxSashEvent& event);
-	void OpenFiles(wxArrayString paths, wxArrayString filenames);
-	void SaveFile(wxArrayString paths, wxArrayString filenames);
-	void OnNotebook(wxNotebookEvent& event);
-	void Rescale(int scale, OPJChildFrame *child);
-	void OnThreadLogmsg(wxCommandEvent& event);
-
-	OPJMarkerTreeHash m_treehash;
-	OPJChildFrameHash m_childhash;
-    wxSashLayoutWindow* markerTreeWindow;
-    wxSashLayoutWindow* loggingWindow;
-	wxToolBar* tool_bar;
-    void Resize(int number);
-	wxNotebook *m_bookCtrl;
-	wxNotebook *m_bookCtrlbottom;
-    wxTextCtrl *m_textCtrlbrowse;
-
-  private:
-    void TogStyle(int id, long flag);
-
-    void DoSort(bool reverse = false);
-
-    wxPanel *m_panel;
-    wxTextCtrl *m_textCtrl;
-
-    void DoSetBold(bool bold = true);
-
-protected:
-    wxSashLayoutWindow* m_topWindow;
-    wxSashLayoutWindow* m_leftWindow2;
-
-DECLARE_EVENT_TABLE()
-};
-
-class OPJChildFrame: public wxMDIChildFrame
-{
-  public:
-    OPJCanvas *m_canvas;
-    OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
-    ~OPJChildFrame(void);
-    void OnActivate(wxActivateEvent& event);
-	/*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
-	void OnClose(wxCloseEvent& event);
-	void OnGotFocus(wxFocusEvent& event);
-	void OnLostFocus(wxFocusEvent& event);
-    OPJFrame *m_frame;
-	wxFileName m_fname;
-	int m_winnumber;
-
-	unsigned long  m_twidth, m_theight, m_tx, m_ty;
-
-	DECLARE_EVENT_TABLE()
-};
-
-// frame and main menu ids
-enum {
-	OPJFRAME_FILEEXIT = wxID_EXIT,
-	OPJFRAME_HELPABOUT = wxID_ABOUT,
-	OPJFRAME_FILEOPEN,
-	OPJFRAME_MEMORYOPEN,
-	OPJFRAME_FILESAVEAS,
-	OPJFRAME_FILETOGGLEB,
-	OPJFRAME_FILETOGGLEP,
-	OPJFRAME_FILETOGGLET,
-	OPJFRAME_VIEWZOOM,
-	OPJFRAME_VIEWFIT,
-	OPJFRAME_VIEWRELOAD,
-	OPJFRAME_VIEWPREVFRAME,
-	OPJFRAME_VIEWHOMEFRAME,
-	OPJFRAME_VIEWNEXTFRAME,
-	OPJFRAME_VIEWLESSLAYERS,
-	OPJFRAME_VIEWALLLAYERS,
-	OPJFRAME_VIEWMORELAYERS,
-	OPJFRAME_VIEWLESSRES,
-	OPJFRAME_VIEWFULLRES,
-	OPJFRAME_VIEWMORERES,
-	OPJFRAME_VIEWPREVCOMP,
-	OPJFRAME_VIEWALLCOMPS,
-	OPJFRAME_VIEWNEXTCOMP,
-	OPJFRAME_FILECLOSE,
-	OPJFRAME_SETSENCO,
-	OPJFRAME_SETSDECO,
-
-	OPJFRAME_BROWSEWIN = 10000,
-	OPJFRAME_LOGWIN,
-	OPJFRAME_TOOLBAR,
-
-	OPJFRAME_THREADLOGMSG,
-	OPJCANVAS_THREADSIGNAL
-};
-
-
-// menu and control ids
-enum
-{
-    TreeTest_Quit = wxID_EXIT,
-    TreeTest_About = wxID_ABOUT,
-    TreeTest_TogButtons = wxID_HIGHEST,
-    TreeTest_TogTwist,
-    TreeTest_TogLines,
-    TreeTest_TogEdit,
-    TreeTest_TogHideRoot,
-    TreeTest_TogRootLines,
-    TreeTest_TogBorder,
-    TreeTest_TogFullHighlight,
-    TreeTest_SetFgColour,
-    TreeTest_SetBgColour,
-    TreeTest_ResetStyle,
-    TreeTest_Highlight,
-    TreeTest_Dump,
-    TreeTest_DumpSelected,
-    TreeTest_Count,
-    TreeTest_CountRec,
-    TreeTest_Sort,
-    TreeTest_SortRev,
-    TreeTest_SetBold,
-    TreeTest_ClearBold,
-    TreeTest_Rename,
-    TreeTest_Delete,
-    TreeTest_DeleteChildren,
-    TreeTest_DeleteAll,
-    TreeTest_Recreate,
-    TreeTest_ToggleImages,
-    TreeTest_ToggleButtons,
-    TreeTest_SetImageSize,
-    TreeTest_ToggleSel,
-    TreeTest_CollapseAndReset,
-    TreeTest_EnsureVisible,
-    TreeTest_AddItem,
-    TreeTest_InsertItem,
-    TreeTest_IncIndent,
-    TreeTest_DecIndent,
-    TreeTest_IncSpacing,
-    TreeTest_DecSpacing,
-    TreeTest_ToggleIcon,
-    TreeTest_Select,
-    TreeTest_Unselect,
-    TreeTest_SelectRoot,
-    TreeTest_Ctrl = 1000,
-	BOTTOM_NOTEBOOK_ID,
-	LEFT_NOTEBOOK_ID
-};
-
-class OPJEncoThread : public wxThread
-{
-public:
-    OPJEncoThread(OPJCanvas *canvas);
-
-    // thread execution starts here
-    virtual void *Entry();
-
-    // called when the thread exits - whether it terminates normally or is
-    // stopped with Delete() (but not when it is Kill()ed!)
-    virtual void OnExit();
-
-    // write something to the text control
-    void WriteText(const wxString& text);
-
-public:
-    unsigned m_count;
-    OPJCanvas *m_canvas;
-};
-
-class OPJDecoThread : public wxThread
-{
-public:
-    OPJDecoThread(OPJCanvas *canvas);
-
-    // thread execution starts here
-    virtual void *Entry();
-
-    // called when the thread exits - whether it terminates normally or is
-    // stopped with Delete() (but not when it is Kill()ed!)
-    virtual void OnExit();
-
-    // write something to the text control
-    void WriteText(const wxString& text);
-
-public:
-    unsigned m_count;
-    OPJCanvas *m_canvas;
-};
-
-class OPJParseThread : public wxThread
-{
-public:
-    OPJParseThread(OPJMarkerTree *tree, wxTreeItemId parentid = 0x00);
-
-    // thread execution starts here
-    virtual void *Entry();
-
-    // called when the thread exits - whether it terminates normally or is
-    // stopped with Delete() (but not when it is Kill()ed!)
-    virtual void OnExit();
-
-    // write something to the text control
-    void WriteText(const wxString& text);
-	void LoadFile(wxFileName fname);
-	void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
-	void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
-
-    unsigned m_count;
-    OPJMarkerTree *m_tree;
-	wxTreeItemId m_parentid;
-
-private:
-	int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
-			wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
-	int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
-			wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
-
-};
-
-
-// Drag and drop files target
-class OPJDnDFile: public wxFileDropTarget
-{
-public:
-    OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
-    virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
-
-private:
-    OPJFrame *m_pOwner;
-};
-
-
-
-// Property sheet dialog: encoder
-class OPJEncoderDialog: public wxPropertySheetDialog
-{
-DECLARE_CLASS(OPJEncoderDialog)
-public:
-    OPJEncoderDialog(wxWindow* parent, int dialogType);
-    ~OPJEncoderDialog();
-
-	wxBookCtrlBase* m_settingsNotebook;
-
-    wxPanel* CreateMainSettingsPage(wxWindow* parent);
-    wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
-    wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
-/*    wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
-	void OnEnableComm(wxCommandEvent& event);
-	void OnEnableIdx(wxCommandEvent& event);
-	void OnEnablePoc(wxCommandEvent& event);
-	void OnRadioQualityRate(wxCommandEvent& event);
-#ifdef USE_JPWL
-	void OnEnableJPWL(wxCommandEvent& event);
-	wxPanel* CreatePart11SettingsPage(wxWindow* parent);
-	/*wxCheckBox *m_enablejpwlCheck;*/
-	wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
-	wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
-	wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
-	wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
-	wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
-	wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
-	wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
-	void OnHprotSelect(wxCommandEvent& event);
-	void OnPprotSelect(wxCommandEvent& event);
-	void OnSensiSelect(wxCommandEvent& event);
-#endif // USE_JPWL
-
-	wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
-	wxRadioButton *m_rateRadio, *m_qualityRadio;
-	wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
-	wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
-	wxRadioBox *progressionBox;
-	wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
-	wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
-		*m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
-	wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
-	wxSpinCtrl *m_resolutionsCtrl;
-
-protected:
-
-    enum {
-		OPJENCO_ENABLEJPWL = 100,
-		OPJENCO_RATEFACTOR,
-		OPJENCO_RATERADIO,
-		OPJENCO_QUALITYFACTOR,
-		OPJENCO_QUALITYRADIO,
-		OPJENCO_RESNUMBER,
-		OPJENCO_CODEBLOCKSIZE,
-		OPJENCO_PRECINCTSIZE,
-		OPJENCO_TILESIZE,
-		OPJENCO_PROGRESSION,
-		OPJENCO_SUBSAMPLING,
-		OPJENCO_ENABLESOP,
-		OPJENCO_ENABLEEPH,
-		OPJENCO_ENABLEBYPASS,
-		OPJENCO_ENABLERESET,
-		OPJENCO_ENABLERESTART,
-		OPJENCO_ENABLEVSC,
-		OPJENCO_ENABLEERTERM,
-		OPJENCO_ENABLESEGMARK,
-		OPJENCO_ENABLEPOC,
-		OPJENCO_ROICOMP,
-		OPJENCO_ROISHIFT,
-		OPJENCO_IMORIG,
-		OPJENCO_TILORIG,
-		OPJENCO_ENABLEMCT,
-		OPJENCO_ENABLEIRREV,
-		OPJENCO_ENABLEINDEX,
-		OPJENCO_INDEXNAME,
-		OPJENCO_POCSPEC,
-		OPJENCO_ENABLECOMM,
-		OPJENCO_COMMENTTEXT,
-		OPJENCO_HPROT,
-		OPJENCO_HTILE,
-		OPJENCO_PPROT,
-		OPJENCO_PTILE,
-		OPJENCO_PPACK,
-		OPJENCO_SENSI,
-		OPJENCO_STILE
-    };
-
-DECLARE_EVENT_TABLE()
-};
-
-// Property sheet dialog: decoder
-class OPJDecoderDialog: public wxPropertySheetDialog
-{
-DECLARE_CLASS(OPJDecoderDialog)
-public:
-    OPJDecoderDialog(wxWindow* parent, int dialogType);
-    ~OPJDecoderDialog();
-
-	wxBookCtrlBase* m_settingsNotebook;
-	wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
-	wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
-	wxRadioBox* m_resizeBox;
-
-	void OnEnableDeco(wxCommandEvent& event);
-
-    wxPanel* CreateMainSettingsPage(wxWindow* parent);
-    wxPanel* CreatePart1SettingsPage(wxWindow* parent);
-    wxPanel* CreatePart3SettingsPage(wxWindow* parent);
-#ifdef USE_JPWL
-	void OnEnableJPWL(wxCommandEvent& event);
-    wxPanel* CreatePart11SettingsPage(wxWindow* parent);
-	wxSpinCtrl *m_expcompsCtrl, *m_framenumCtrl, *m_maxtilesCtrl;
-	wxCheckBox *m_enablejpwlCheck;
-#endif // USE_JPWL
-
-
-protected:
-
-    enum {
-		OPJDECO_RESMETHOD = 100,
-		OPJDECO_REDUCEFACTOR,
-		OPJDECO_QUALITYLAYERS,
-		OPJDECO_NUMCOMPS,
-		OPJDECO_ENABLEDECO,
-		OPJDECO_ENABLEPARSE,
-		OPJDECO_ENABLEJPWL,
-		OPJDECO_EXPCOMPS,
-		OPJDECO_MAXTILES,
-		OPJDECO_FRAMENUM
-    };
-
-DECLARE_EVENT_TABLE()
-};
-
-#endif //__OPJ_VIEWER_H__
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.ico b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.ico
deleted file mode 100644
index 931d5e0..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.ico and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.rc b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.rc
deleted file mode 100644
index fb5a5de..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer.rc
+++ /dev/null
@@ -1,3 +0,0 @@
-OPJChild16 ICON OPJChild.ico
-OPJViewer16 ICON OPJViewer.ico
-#include "wx/msw/wx.rc"
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer16.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer16.xpm
deleted file mode 100644
index 27e522b..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/OPJViewer16.xpm
+++ /dev/null
@@ -1,26 +0,0 @@
-/* XPM */
-static char *OPJViewer16[] = {
-/* columns rows colors chars-per-pixel */
-"16 16 4 1",
-"  c black",
-". c #800000",
-"X c red",
-"o c None",
-/* pixels */
-"oooooooooooooooo",
-"ooo.XXXXoooooooo",
-"ooXXoo .Xooooooo",
-"o..oooo .ooooooo",
-"oX.oooo  ooooooo",
-"oX.oooo .ooooooo",
-"oXXoooo .ooooooo",
-"o.XXoo .oooooooo",
-"oo.XXXXooooooooo",
-"ooooooooo.Xo .oo",
-"ooooooooo X. ooo",
-"oooooooooo...ooo",
-"oooooooooo XXooo",
-"oooooooooo .Xooo",
-"oooooooooooooooo",
-"oooooooooooooooo"
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/about_htm.h b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/about_htm.h
deleted file mode 100644
index c39fdc5..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/about_htm.h
+++ /dev/null
@@ -1,54 +0,0 @@
-wxString htmlaboutpage = wxT(
-"<html>"
-"<body bgcolor=#FFFFFF>"
-"<table cellspacing=7 cellpadding=1 border=0 width=100%>"   
-"<tr>"
-"<td rowspan=3 valign=top align=center width=70>"
-"<img src=\"memory:opj_logo.xpm\"><br><br>" 
-"</td>"
-"<td align=center>"
-"<font size=+0 color=#000000><b>" 
-OPJ_APPLICATION " " OPJ_APPLICATION_VERSION 
-"</b></font><br>"
-"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"  
-"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"  
-"</td>"
-"</tr>"
-"<tr height=3 valign=center>"  
-"<td valign=center  bgcolor=#cc3300></td>"   
-"</tr>"
-"<tr>"
-"<td align=justify>"
-"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
-"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
-"In addition to the basic codec, various other features are under development.</font></p><br>"
-"<font size=-2 color=red>* Build: ")
-#include "build.h"
-wxT(", " __DATE__ ", " __TIME__ "</font><br>")
-wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
-wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
-#ifdef USE_JPWL
-wxT("<font size=-2 color=green>JPWL</font> ")
-#endif // USE_JPWL
-#ifdef USE_JPSEC
-wxT("<font size=-2 color=green>JPSEC</font> ")
-#endif // USE_JPSEC
-wxT(")</font><br>")
-#ifdef USE_MXF
-wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
-#endif // USE_MXF
-wxT("</td>"
-"</tr>"
-"<tr>"
-"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>" 
-"</tr>"
-"<tr>"
-"<td colspan=2>"
-"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
-"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
-"</td>"
-"</tr>"
-"</table>"
-"</body>"
-"</html>"
-);
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/build.h b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/build.h
deleted file mode 100644
index 9858dff..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/build.h
+++ /dev/null
@@ -1 +0,0 @@
-wxT("491") 
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon1.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon1.xpm
deleted file mode 100644
index fbc605b..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon1.xpm
+++ /dev/null
@@ -1,79 +0,0 @@
-/* XPM */
-static char *icon1_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"32 32 41 1",
-"> c #97C4E7",
-"# c #4381AA",
-"d c #FFFFFF",
-"< c #71B2DE",
-"+ c #538BB1",
-"& c #D1E5F5",
-"q c #63B3DE",
-"6 c #F1F4F7",
-"* c #CAE1F3",
-"y c #7AC4E5",
-"= c #C3DDF1",
-"X c #74A1BD",
-"- c #BCD9EF",
-"5 c #619BC4",
-"3 c #E6EAF1",
-"2 c #4B8EBF",
-"o c #6B97B6",
-". c #4B82A8",
-"  c None",
-"w c #54A6D8",
-"1 c #71A8D1",
-", c #85BBE2",
-"t c #EFF6FC",
-"7 c #DEEDF8",
-"@ c #4388B4",
-"a c #F7FBFD",
-"$ c #D7E0E9",
-"r c #FAFCFE",
-"4 c #DAEAF7",
-"e c #E9F3FA",
-"0 c #76BAE2",
-"% c #7FA6C0",
-"s c #FDFDFE",
-"O c #5896BE",
-"p c #B6D5EE",
-"8 c #87ABC3",
-": c #A5CCEA",
-"9 c #E5F0F9",
-"; c #AFD1EC",
-"i c #F4F9FD",
-"u c #8FB0C3",
-/* pixels */
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"        .XXXooOO++@#$           ",
-"        %&*=-;:>>,<123          ",
-"        %4&*=-;:>>,1>56         ",
-"        %74&*=-;:>>1*>56        ",
-"        89700qqqqwq1e*>X        ",
-"        8e974&*=-;:1re*>8       ",
-"        8te974&*=-;11111#       ",
-"        8tty000qqqqqww>,+       ",
-"        uitte974&*=-p:>>+       ",
-"        uaitte974&*=-p:>O       ",
-"        uaayyyy000qqqqp:O       ",
-"        uraaitte974&*=-po       ",
-"        urraaitte974&*=-o       ",
-"        usryyyyyyy000q*=X       ",
-"        ussrraaitte974&*X       ",
-"        udssrraaitte974&X       ",
-"        uddyyyyyyyyyy074%       ",
-"        udddssrraaitte97%       ",
-"        uddddssrraaitte9%       ",
-"        udddddssrraaitte8       ",
-"        uddddddssrraaitt8       ",
-"        uuuuuuuuuuuuuu88u       ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                "
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon2.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon2.xpm
deleted file mode 100644
index 7ae8c92..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon2.xpm
+++ /dev/null
@@ -1,53 +0,0 @@
-/* XPM */
-static char *icon2_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"32 32 15 1",
-". c Black",
-"O c #97C4E7",
-"$ c #63B3DE",
-"@ c #CAE1F3",
-"; c #7AC4E5",
-"* c #74A1BD",
-"+ c #619BC4",
-"o c #4B8EBF",
-"  c None",
-"% c #54A6D8",
-"= c #FAFCFE",
-"& c #E9F3FA",
-"# c #76BAE2",
-"X c #C00000",
-"- c #87ABC3",
-/* pixels */
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"        .............           ",
-"        .XXXXXXXXXX.o.          ",
-"        .XXXXXXXXXX.O+.         ",
-"        .XXXXXXXXXX. at O+.        ",
-"        .XX##$$$$%$.&@O*        ",
-"        .XXXXXXXXXX.=&@O-       ",
-"        .XXXXXXXXXX......       ",
-"        .XX;###$$$$$%%XX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XX;;;;###$$$$XX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XX;;;;;;;###$XX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XX;;;;;;;;;;#XX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .XXXXXXXXXXXXXXX.       ",
-"        .................       ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                "
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon3.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon3.xpm
deleted file mode 100644
index 722de6b..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon3.xpm
+++ /dev/null
@@ -1,79 +0,0 @@
-/* XPM */
-static char *icon3_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"32 32 41 1",
-"6 c #EDF2FB",
-"- c #AAC1E8",
-": c #B9CDED",
-"X c #295193",
-", c #C6D6F0",
-"a c #4A7CCE",
-"u c #779DDB",
-"y c #7FA2DD",
-"$ c #3263B4",
-"5 c #EAF0FA",
-". c #2D59A3",
-"o c #6E96D8",
-"* c #356AC1",
-"r c #F7F9FD",
-"> c #BED0EE",
-"3 c #E1E9F7",
-"7 c #F0F5FC",
-"< c #CBD9F1",
-"2 c #DAE5F6",
-"# c #3161B1",
-"  c None",
-"0 c #FDFEFF",
-"= c #9FB9E5",
-"e c #AEC5EA",
-"t c #89A9DF",
-"q c #98B5E4",
-"p c #5584D1",
-"d c #3A70CA",
-"@ c #305FAC",
-"i c #5D89D3",
-"1 c #D2DFF4",
-"% c #3366B9",
-"9 c #FAFCFE",
-"8 c #F5F8FD",
-"s c #4075CC",
-"O c #638ED5",
-"w c #90AFE2",
-"& c #3467BC",
-"+ c #2F5DA9",
-"; c #B3C8EB",
-"4 c #E5EDF9",
-/* pixels */
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"      ......X                   ",
-"      .oooooO+                  ",
-"      .ooooooo.                 ",
-"      .+@@@##$%%&&&&&****.      ",
-"      .=-;:>,<12345678900.      ",
-"      .q=-;:>,<1234567890.      ",
-"      .wq=-e:>,<12345678r.      ",
-"      .twq=-e:>,<12345678.      ",
-"      .ytwq=-e:>,<1234567.      ",
-"      .uytwq=-e:>,<123456.      ",
-"      .ouytwq=-e:>,<12345.      ",
-"      .Oouytwq=-e;>,<1234.      ",
-"      .iOouytwq=-e;>,<123.      ",
-"      .piOouytwq=-e;>,<12.      ",
-"      .apiOouytwq=-e;>,<1.      ",
-"      .sapiOouytwq=-e;>,<.      ",
-"      .dsapiOouytwq=-e;>,.      ",
-"      ...................#      ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                "
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon4.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon4.xpm
deleted file mode 100644
index a18e1a7..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon4.xpm
+++ /dev/null
@@ -1,43 +0,0 @@
-/* XPM */
-static char *icon4_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"32 32 5 1",
-". c Black",
-"o c #8399B4",
-"X c #8DA0B9",
-"  c None",
-"O c #800000",
-/* pixels */
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"      .......                   ",
-"      .XXXXXo.                  ",
-"      .XXXXXXX.                 ",
-"      ....................      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      .OOOOOOOOOOOOOOOOOO.      ",
-"      ....................      ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                "
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon5.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon5.xpm
deleted file mode 100644
index 9f63c31..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/icon5.xpm
+++ /dev/null
@@ -1,79 +0,0 @@
-/* XPM */
-static char *icon5_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"32 32 41 1",
-"0 c #AAC1E8",
-"q c #B9CDED",
-"X c #295193",
-"e c #C6D6F0",
-"a c #4A7CCE",
-"& c #779DDB",
-"* c #7FA2DD",
-"2 c #EAF0FA",
-"@ c #2D59A3",
-"o c #6E96D8",
-"y c #356AC1",
-"d c #214279",
-"w c #BED0EE",
-"= c #85A7DF",
-"< c #E1E9F7",
-"3 c #F0F5FC",
-"s c #CBD9F1",
-", c #DAE5F6",
-"7 c #3161B1",
-"  c None",
-". c #274D8B",
-"6 c #FDFEFF",
-"i c #E7EEF9",
-"9 c #9FB9E5",
-"- c #89A9DF",
-"8 c #98B5E4",
-"$ c #5584D1",
-"+ c #3569BF",
-"% c #305FAC",
-"O c #5D89D3",
-"> c #D2DFF4",
-"p c #3366B9",
-"5 c #FAFCFE",
-"4 c #F5F8FD",
-"t c #4075CC",
-"u c #638ED5",
-"r c #CEDCF2",
-"; c #90AFE2",
-"# c #2F5DA9",
-": c #B3C8EB",
-"1 c #E5EDF9",
-/* pixels */
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"     ......X                    ",
-"     XoooooO.                   ",
-"     Xoooooo+.                  ",
-"     Xooooooo at XXXXXXXXXX#       ",
-"     Xoooooooooooooooooo#       ",
-"     Xoooooooooooooooooo#       ",
-"     Xoo$###################    ",
-"     Xoo%O&*=-;:>,<123445667    ",
-"     XooX890:qwer>,<123445q#    ",
-"     Xoty;890:qwer>,<12344#     ",
-"     Xo%u-;890:qwer>,<i234#     ",
-"     XoX&*-;890:qwer>,<i2r#     ",
-"     Xtpo&*-;890:qwer>,<i#      ",
-"     X%auo&*-;890:qwer>,<#      ",
-"     XX$Ouo&*-;890:qwer>s#      ",
-"     d%a$Ouo&*-;890:qwer#       ",
-"     d+ta$Ouo&*-;890:qwe#       ",
-"     d..................#       ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                ",
-"                                "
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagjpeg2000.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagjpeg2000.cpp
deleted file mode 100644
index 66e1146..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagjpeg2000.cpp
+++ /dev/null
@@ -1,1464 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/////////////////////////////////////////////////////////////////////////////
-// Name:        imagjpeg2000.cpp
-// Purpose:     wxImage JPEG 2000 family file format handler
-// Author:      Giuseppe Baruffa - based on imagjpeg.cpp, Vaclav Slavik
-// RCS-ID:      $Id: imagjpeg2000.cpp,v 0.00 2008/01/31 10:58:00 MW Exp $
-// Copyright:   (c) Giuseppe Baruffa
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-    #pragma hdrstop
-#endif
-
-#if wxUSE_IMAGE && wxUSE_LIBOPENJPEG
-
-#include "imagjpeg2000.h"
-
-#ifndef WX_PRECOMP
-    #include "wx/log.h"
-    #include "wx/app.h"
-    #include "wx/intl.h"
-    #include "wx/bitmap.h"
-    #include "wx/module.h"
-#endif
-
-#include "libopenjpeg/openjpeg.h"
-
-#include "wx/filefn.h"
-#include "wx/wfstream.h"
-
-// ----------------------------------------------------------------------------
-// types
-// ----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// wxJPEG2000Handler
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxJPEG2000Handler,wxImageHandler)
-
-#if wxUSE_STREAMS
-
-//------------- JPEG 2000 Data Source Manager
-
-#define J2K_CFMT 0
-#define JP2_CFMT 1
-#define JPT_CFMT 2
-#define MJ2_CFMT 3
-#define PXM_DFMT 0
-#define PGX_DFMT 1
-#define BMP_DFMT 2
-#define YUV_DFMT 3
-
-#define MAX_MESSAGE_LEN 200
-
-/* check file type */
-int
-jpeg2000familytype(unsigned char *hdr, int hdr_len)
-{
-	// check length
-    if (hdr_len < 24)
-        return -1;
-
-	// check format
-	if (hdr[0] == 0x00 &&
-			hdr[1] == 0x00 &&
-			hdr[2] == 0x00 &&
-			hdr[3] == 0x0C &&
-			hdr[4] == 0x6A &&
-			hdr[5] == 0x50 &&
-			hdr[6] == 0x20 &&
-			hdr[7] == 0x20 &&
-			hdr[20] == 0x6A &&
-			hdr[21] == 0x70 &&
-			hdr[22] == 0x32)
-		// JP2 file format
-		return JP2_CFMT;
-	else if (hdr[0] == 0x00 &&
-			hdr[1] == 0x00 &&
-			hdr[2] == 0x00 &&
-			hdr[3] == 0x0C &&
-			hdr[4] == 0x6A &&
-			hdr[5] == 0x50 &&
-			hdr[6] == 0x20 &&
-			hdr[7] == 0x20 &&
-			hdr[20] == 0x6D &&
-			hdr[21] == 0x6A &&
-			hdr[22] == 0x70 &&
-			hdr[23] == 0x32)
-		// MJ2 file format
-		return MJ2_CFMT;
-	else if (hdr[0] == 0xFF &&
-			hdr[1] == 0x4F)
-		// J2K file format
-		return J2K_CFMT;
-	else
-		// unknown format
-		return -1;
-
-}
-
-/* we have to use this to avoid GUI-noGUI threads crashing */
-void printevent(const char *msg)
-{
-#ifndef __WXGTK__ 
-	wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-	wxLogMessage(wxT("%s"), msg);
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-}
-
-/* sample error callback expecting a FILE* client object */
-void jpeg2000_error_callback(const char *msg, void *client_data) {
-	char mess[MAX_MESSAGE_LEN + 20];
-	int message_len = strlen(msg);
-
-	if (message_len > MAX_MESSAGE_LEN)
-		message_len = MAX_MESSAGE_LEN;
-	
-	if (msg[message_len - 1] == '\n')
-		message_len--;
-
-	sprintf(mess, "[ERROR] %.*s", message_len, msg);
-	printevent(mess);
-}
-
-/* sample warning callback expecting a FILE* client object */
-void jpeg2000_warning_callback(const char *msg, void *client_data) {
-	char mess[MAX_MESSAGE_LEN + 20];
-	int message_len = strlen(msg);
-
-	if (message_len > MAX_MESSAGE_LEN)
-		message_len = MAX_MESSAGE_LEN;
-	
-	if (msg[message_len - 1] == '\n')
-		message_len--;
-
-	sprintf(mess, "[WARNING] %.*s", message_len, msg);
-	printevent(mess);
-}
-
-/* sample debug callback expecting no client object */
-void jpeg2000_info_callback(const char *msg, void *client_data) {
-	char mess[MAX_MESSAGE_LEN + 20];
-	int message_len = strlen(msg);
-
-	if (message_len > MAX_MESSAGE_LEN)
-		message_len = MAX_MESSAGE_LEN;
-	
-	if (msg[message_len - 1] == '\n')
-		message_len--;
-
-	sprintf(mess, "[INFO] %.*s", message_len, msg);
-	printevent(mess);
-}
-
-/* macro functions */
-/* From little endian to big endian, 2 and 4 bytes */
-#define	BYTE_SWAP2(X)	((X & 0x00FF) << 8) | ((X & 0xFF00) >> 8)
-#define	BYTE_SWAP4(X)	((X & 0x000000FF) << 24) | ((X & 0x0000FF00) << 8) | ((X & 0x00FF0000) >> 8) | ((X & 0xFF000000) >> 24)
-
-#ifdef __WXGTK__
-#define	BYTE_SWAP8(X)	((X & 0x00000000000000FFULL) << 56) | ((X & 0x000000000000FF00ULL) << 40) | \
-                        ((X & 0x0000000000FF0000ULL) << 24) | ((X & 0x00000000FF000000ULL) << 8) | \
-						((X & 0x000000FF00000000ULL) >> 8)  | ((X & 0x0000FF0000000000ULL) >> 24) | \
-						((X & 0x00FF000000000000ULL) >> 40) | ((X & 0xFF00000000000000ULL) >> 56)
-#else
-#define	BYTE_SWAP8(X)	((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
-                        ((X & 0x0000000000FF0000) << 24) | ((X & 0x00000000FF000000) << 8) | \
-						((X & 0x000000FF00000000) >> 8)  | ((X & 0x0000FF0000000000) >> 24) | \
-						((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56)
-#endif
-
-/* From codestream to int values */
-#define STREAM_TO_UINT32(C, P)	(((unsigned long int) (C)[(P) + 0] << 24) + \
-								((unsigned long int) (C)[(P) + 1] << 16) + \
-								((unsigned long int) (C)[(P) + 2] << 8) + \
-								((unsigned long int) (C)[(P) + 3] << 0))
-
-#define STREAM_TO_UINT16(C, P)	(((unsigned long int) (C)[(P) + 0] << 8) + \
-								((unsigned long int) (C)[(P) + 1] << 0))
-
-/* defines */
-#define SHORT_DESCR_LEN        32
-#define LONG_DESCR_LEN         256
-
-/* enumeration for file formats */
-#define JPEG2000FILENUM              4
-typedef enum {
-
-        JP2_FILE,
-        J2K_FILE,
-		MJ2_FILE,
-		UNK_FILE
-
-} jpeg2000filetype;
-
-/* enumeration for the box types */
-#define JPEG2000BOXNUM                23
-typedef enum {
-
-			FILE_BOX,
-			JP_BOX,
-			FTYP_BOX,
-			JP2H_BOX,
-			IHDR_BOX,
-			COLR_BOX,
-			JP2C_BOX,
-			JP2I_BOX,
-			XML_BOX,
-			UUID_BOX,
-			UINF_BOX,
-			MOOV_BOX,
-			MVHD_BOX,
-			TRAK_BOX,
-			TKHD_BOX,
-			MDIA_BOX,
-			MINF_BOX,
-			STBL_BOX,
-			STSD_BOX,
-			MJP2_BOX,
-			MDAT_BOX,
-			ANY_BOX,
-			UNK_BOX
-
-} jpeg2000boxtype;
-
-/* jpeg2000 family box signatures */
-#define FILE_SIGN           ""
-#define JP_SIGN             "jP\040\040"
-#define FTYP_SIGN           "ftyp"
-#define JP2H_SIGN           "jp2h"
-#define IHDR_SIGN           "ihdr"
-#define COLR_SIGN           "colr"
-#define JP2C_SIGN           "jp2c"
-#define JP2I_SIGN           "jp2i"
-#define XML_SIGN            "xml\040"
-#define UUID_SIGN           "uuid"
-#define UINF_SIGN           "uinf"
-#define MOOV_SIGN           "moov"
-#define MVHD_SIGN           "mvhd"
-#define TRAK_SIGN           "trak"
-#define TKHD_SIGN           "tkhd"
-#define MDIA_SIGN           "mdia"
-#define MINF_SIGN           "minf"
-#define VMHD_SIGN           "vmhd"
-#define STBL_SIGN           "stbl"
-#define STSD_SIGN           "stsd"
-#define MJP2_SIGN           "mjp2"
-#define MDAT_SIGN           "mdat"
-#define ANY_SIGN 			""
-#define UNK_SIGN            ""
-
-/* the box structure itself */
-struct jpeg2000boxdef {
-
-        char                  value[5];                 /* hexadecimal value/string*/
-		char                  name[SHORT_DESCR_LEN];    /* short description       */
-		char                  descr[LONG_DESCR_LEN];    /* long  description       */
-		int                   sbox;                     /* is it a superbox?       */
-		int                   req[JPEG2000FILENUM];     /* mandatory box           */
-		jpeg2000boxtype       ins;                      /* contained in box...     */
-
-};
-
-/* the possible boxes */
-struct jpeg2000boxdef jpeg2000box[] =
-{
-/* sign */	{FILE_SIGN,
-/* short */	"placeholder for nothing",
-/* long */	"Nothing to say",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{JP_SIGN,
-/* short */	"JPEG 2000 Signature box",
-/* long */	"This box uniquely identifies the file as being part of the JPEG 2000 family of files",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{FTYP_SIGN,
-/* short */	"File Type box",
-/* long */	"This box specifies file type, version and compatibility information, including specifying if this file "
-			"is a conforming JP2 file or if it can be read by a conforming JP2 reader",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{JP2H_SIGN,
-/* short */	"JP2 Header box",
-/* long */	"This box contains a series of boxes that contain header-type information about the file",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{IHDR_SIGN,
-/* short */	"Image Header box",
-/* long */	"This box specifies the size of the image and other related fields",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	JP2H_BOX},
-
-/* sign */	{COLR_SIGN,
-/* short */	"Colour Specification box",
-/* long */	"This box specifies the colourspace of the image",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	JP2H_BOX},
-
-/* sign */	{JP2C_SIGN,
-/* short */	"Contiguous Codestream box",
-/* long */	"This box contains the codestream as defined by Annex A",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{JP2I_SIGN,
-/* short */	"Intellectual Property box",
-/* long */	"This box contains intellectual property information about the image",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{XML_SIGN,
-/* short */	"XML box",
-/* long */	"This box provides a tool by which vendors can add XML formatted information to a JP2 file",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{UUID_SIGN,
-/* short */	"UUID box",
-/* long */	"This box provides a tool by which vendors can add additional information to a file "
-			"without risking conflict with other vendors",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{UINF_SIGN,
-/* short */	"UUID Info box",
-/* long */	"This box provides a tool by which a vendor may provide access to additional information associated with a UUID",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{MOOV_SIGN,
-/* short */	"Movie box",
-/* long */	"This box contains the media data. In video tracks, this box would contain JPEG2000 video frames",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{MVHD_SIGN,
-/* short */	"Movie Header box",
-/* long */	"This box defines overall information which is media-independent, and relevant to the entire presentation "
-			"considered as a whole",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MOOV_BOX},
-
-/* sign */	{TRAK_SIGN,
-/* short */	"Track box",
-/* long */	"This is a container box for a single track of a presentation. A presentation may consist of one or more tracks",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	MOOV_BOX},
-
-/* sign */	{TKHD_SIGN,
-/* short */	"Track Header box",
-/* long */	"This box specifies the characteristics of a single track. Exactly one Track Header Box is contained in a track",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	TRAK_BOX},
-
-/* sign */	{MDIA_SIGN,
-/* short */	"Media box",
-/* long */	"The media declaration container contains all the objects which declare information about the media data "
-			"within a track",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	TRAK_BOX},
-
-/* sign */	{MINF_SIGN,
-/* short */	"Media Information box",
-/* long */	"This box contains all the objects which declare characteristic information of the media in the track",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	MDIA_BOX},
-
-/* sign */	{STBL_SIGN,
-/* short */	"Sample Table box",
-/* long */	"The sample table contains all the time and data indexing of the media samples in a track",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	MINF_BOX},
-
-/* sign */	{STSD_SIGN,
-/* short */	"Sample Description box",
-/* long */	"The sample description table gives detailed information about the coding type used, and any initialization "
-			"information needed for that coding",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MINF_BOX},
-
-/* sign */	{MJP2_SIGN,
-/* short */	"MJP2 Sample Description box",
-/* long */	"The MJP2 sample description table gives detailed information about the coding type used, and any initialization "
-			"information needed for that coding",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MINF_BOX},
-
-/* sign */	{MDAT_SIGN,
-/* short */	"Media Data box",
-/* long */	"The meta-data for a presentation is stored in the single Movie Box which occurs at the top-level of a file",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{ANY_SIGN,
-/* short */	"Any box",
-/* long */	"All the existing boxes",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{UNK_SIGN,
-/* short */	"Unknown Type box",
-/* long */	"The signature is not recognised to be that of an existing box",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	ANY_BOX}
-
-};
-
-/* declaration */
-int
-jpeg2000_box_handler_function(jpeg2000boxtype boxtype, wxInputStream& stream, unsigned long int filepoint,
-							  unsigned long int filelimit, int level, char *scansign,
-							  unsigned long int *scanpoint);
-
-#ifdef __WXMSW__
-typedef unsigned __int64 int8byte;
-#endif // __WXMSW__
-
-#ifdef __WXGTK__
-typedef unsigned long long int8byte;
-#endif // __WXGTK__
-
-/* internal mini-search for a box signature */
-int
-jpeg2000_file_parse(wxInputStream& stream, unsigned long int filepoint, unsigned long int filelimit, int level,
-					char *scansign, unsigned long int *scanpoint)
-{
-	unsigned long int       LBox = 0x00000000;
-	char                    TBox[5] = "\0\0\0\0";
-	int8byte                XLBox = 0x0000000000000000;
-	unsigned long int       box_length = 0;
-	int                     last_box = 0, box_num = 0;
-	int                     box_type = ANY_BOX;
-	unsigned char           fourbytes[4];
-	int                     box_number = 0;
-
-	/* cycle all over the file */
-	box_num = 0;
-	last_box = 0;
-	while (!last_box) {
-
-		/* do not exceed file limit */
-		if (filepoint >= filelimit)
-			return (0);
-
-		/* seek on file */
-		if (stream.SeekI(filepoint, wxFromStart) == wxInvalidOffset)
-			return (-1);
-
-		/* read the mandatory LBox, 4 bytes */
-		if (!stream.Read(fourbytes, 4)) {
-			wxLogError(wxT("Problem reading LBox from the file (file ended?)"));
-			return -1;
-		};
-		LBox = STREAM_TO_UINT32(fourbytes, 0);
-
-		/* read the mandatory TBox, 4 bytes */
-		if (!stream.Read(TBox, 4)) {
-			wxLogError(wxT("Problem reading TBox from the file (file ended?)"));
-			return -1;
-		};
-
-		/* look if scansign is got */
-		if ((scansign != NULL) && (memcmp(TBox, scansign, 4) == 0)) {
-			/* hack/exploit */
-			// stop as soon as you find the level-th codebox
-			if (box_number == level) {
-				memcpy(scansign, "    ", 4);
-				*scanpoint = filepoint;
-				return (0);
-			} else
-				box_number++;
-
-		};
-
-		/* determine the box type */
-		for (box_type = JP_BOX; box_type < UNK_BOX; box_type++)
-			if (memcmp(TBox, jpeg2000box[box_type].value, 4) == 0)
-				break;	
-
-		/* read the optional XLBox, 8 bytes */
-		if (LBox == 1) {
-
-			if (!stream.Read(&XLBox, 8)) {
-				wxLogError(wxT("Problem reading XLBox from the file (file ended?)"));
-				return -1;
-			};
-			box_length = (unsigned long int) BYTE_SWAP8(XLBox);
-
-		} else if (LBox == 0x00000000) {
-
-			/* last box in file */
-			last_box = 1; 
-			box_length = filelimit - filepoint;
-
-		} else
-
-			box_length = LBox;
-
-
-		/* go deep in the box */
-		jpeg2000_box_handler_function((jpeg2000boxtype) box_type,
-			stream, (LBox == 1) ? (filepoint + 16) : (filepoint + 8),
-			filepoint + box_length, level, scansign, scanpoint);
-
-		/* if it's a superbox go inside it */
-		if (jpeg2000box[box_type].sbox)
-			jpeg2000_file_parse(stream, (LBox == 1) ? (filepoint + 16) : (filepoint + 8), filepoint + box_length,
-				level, scansign, scanpoint);
-
-		/* increment box number and filepoint*/
-		box_num++;
-		filepoint += box_length;
-
-	};
-
-	/* all good */
-	return (0);
-}
-
-// search first contiguos codestream box in an mj2 file
-unsigned long int
-searchjpeg2000c(wxInputStream& stream, unsigned long int fsize, int number)
-{
-	char scansign[] = "jp2c";
-	unsigned long int scanpoint = 0L;
-
-	wxLogMessage(wxT("Searching jp2c box... "));
-
-	/* do the parsing */
-	if (jpeg2000_file_parse(stream, 0, fsize, number, scansign, &scanpoint) < 0)		
-		wxLogMessage(wxT("Unrecoverable error during JPEG 2000 box parsing: stopping"));
-
-	if (strcmp(scansign, "    "))
-		wxLogMessage(wxT("Box not found"));
-	else {
-
-		wxLogMessage(wxString::Format(wxT("Box found at byte %d"), scanpoint));
-
-	};
-
-	return (scanpoint);
-}
-
-// search the jp2h box in the file
-unsigned long int
-searchjpeg2000headerbox(wxInputStream& stream, unsigned long int fsize)
-{
-	char scansign[] = "jp2h";
-	unsigned long int scanpoint = 0L;
-
-	wxLogMessage(wxT("Searching jp2h box... "));
-
-	/* do the parsing */
-	if (jpeg2000_file_parse(stream, 0, fsize, 0, scansign, &scanpoint) < 0)		
-		wxLogMessage(wxT("Unrecoverable error during JPEG 2000 box parsing: stopping"));
-
-	if (strcmp(scansign, "    "))
-		wxLogMessage(wxT("Box not found"));
-	else
-		wxLogMessage(wxString::Format(wxT("Box found at byte %d"), scanpoint));
-
-	return (scanpoint);
-}
-
-/* handling functions */
-#define ITEM_PER_ROW	10
-
-/* Box handler function */
-int
-jpeg2000_box_handler_function(jpeg2000boxtype boxtype, wxInputStream& stream, unsigned long int filepoint,
-							  unsigned long int filelimit, int level,
-							  char *scansign, unsigned long int *scanpoint)
-{
-	switch (boxtype) {
-
-	/* Sample Description box */
-	case (STSD_BOX):
-		jpeg2000_file_parse(stream, filepoint + 8, filelimit, level, scansign, scanpoint);
-		break;
-
-	/* MJP2 Sample Description box */
-	case (MJP2_BOX):
-		jpeg2000_file_parse(stream, filepoint + 78, filelimit, level, scansign, scanpoint);
-		break;
-		
-	/* not yet implemented */
-	default:
-		break;
-
-	};
-
-	return (0);
-}
-
-// the jP and ftyp parts of the header
-#define jpeg2000headSIZE	32
-unsigned char jpeg2000head[jpeg2000headSIZE] = {
-		0x00, 0x00, 0x00, 0x0C,  'j',  'P',  ' ',  ' ',
-		0x0D, 0x0A, 0x87, 0x0A, 0x00, 0x00, 0x00, 0x14,
-		 'f',  't',  'y',  'p',  'j',  'p',  '2',  ' ',
-		0x00, 0x00, 0x00, 0x00,  'j',  'p',  '2',  ' '			
-};
-
-/////////////////////////////////////////////////
-/////////////////////////////////////////////////
-
-// load the jpeg2000 file format
-bool wxJPEG2000Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index)
-{
-	opj_dparameters_t parameters;	/* decompression parameters */
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_image_t *opjimage = NULL;
-	unsigned char *src = NULL;
-    unsigned char *ptr;
-	int file_length, jp2c_point, jp2h_point;
-	unsigned long int jp2hboxlen, jp2cboxlen;
-	opj_codestream_info_t cstr_info;  /* Codestream information structure */
-    unsigned char hdr[24];
-	int jpfamform;
-
-	// destroy the image
-    image->Destroy();
-
-	/* read the beginning of the file to check the type */ 
-    if (!stream.Read(hdr, WXSIZEOF(hdr)))
-        return false;
-	if ((jpfamform = jpeg2000familytype(hdr, WXSIZEOF(hdr))) < 0)
-		return false;
-	stream.SeekI(0, wxFromStart);
-
-	/* handle to a decompressor */
-	opj_dinfo_t* dinfo = NULL;	
-	opj_cio_t *cio = NULL;
-
-	/* configure the event callbacks */
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = jpeg2000_error_callback;
-	event_mgr.warning_handler = jpeg2000_warning_callback;
-	event_mgr.info_handler = jpeg2000_info_callback;
-
-	/* set decoding parameters to default values */
-	opj_set_default_decoder_parameters(&parameters);
-
-	/* prepare parameters */
-	strncpy(parameters.infile, "", sizeof(parameters.infile) - 1);
-	strncpy(parameters.outfile, "", sizeof(parameters.outfile) - 1);
-	parameters.decod_format = jpfamform;
-	parameters.cod_format = BMP_DFMT;
-	if (m_reducefactor)
-		parameters.cp_reduce = m_reducefactor;
-	if (m_qualitylayers)
-		parameters.cp_layer = m_qualitylayers;
-	/*if (n_components)
-		parameters. = n_components;*/
-
-	/* JPWL only */
-#ifdef USE_JPWL
-	parameters.jpwl_exp_comps = m_expcomps;
-	parameters.jpwl_max_tiles = m_maxtiles;
-	parameters.jpwl_correct = m_enablejpwl;
-#endif /* USE_JPWL */
-
-	/* get a decoder handle */
-	if (jpfamform == JP2_CFMT || jpfamform == MJ2_CFMT)
-		dinfo = opj_create_decompress(CODEC_JP2);
-	else if (jpfamform == J2K_CFMT)
-		dinfo = opj_create_decompress(CODEC_J2K);
-	else
-		return false;
-
-	/* find length of the stream */
-	stream.SeekI(0, wxFromEnd);
-	file_length = (int) stream.TellI();
-
-	/* it's a movie */
-	if (jpfamform == MJ2_CFMT) {
-		/* search for the first codestream box and the movie header box  */
-		jp2c_point = searchjpeg2000c(stream, file_length, m_framenum);
-		jp2h_point = searchjpeg2000headerbox(stream, file_length);
-
-		// read the jp2h box and store it
-		stream.SeekI(jp2h_point, wxFromStart);
-		stream.Read(&jp2hboxlen, sizeof(unsigned long int));
-		jp2hboxlen = BYTE_SWAP4(jp2hboxlen);
-
-		// read the jp2c box and store it
-		stream.SeekI(jp2c_point, wxFromStart);
-		stream.Read(&jp2cboxlen, sizeof(unsigned long int));
-		jp2cboxlen = BYTE_SWAP4(jp2cboxlen);
-
-		// malloc memory source
-		src = (unsigned char *) malloc(jpeg2000headSIZE + jp2hboxlen + jp2cboxlen);
-
-		// copy the jP and ftyp
-		memcpy(src, jpeg2000head, jpeg2000headSIZE);
-
-		// copy the jp2h
-		stream.SeekI(jp2h_point, wxFromStart);
-		stream.Read(&src[jpeg2000headSIZE], jp2hboxlen);
-
-		// copy the jp2c
-		stream.SeekI(jp2c_point, wxFromStart);
-		stream.Read(&src[jpeg2000headSIZE + jp2hboxlen], jp2cboxlen);
-	} else 	if (jpfamform == JP2_CFMT || jpfamform == J2K_CFMT) {
-		/* It's a plain image */
-		/* get data */
-		stream.SeekI(0, wxFromStart);
-		src = (unsigned char *) malloc(file_length);
-		stream.Read(src, file_length);
-	} else
-		return false;
-
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-	/* setup the decoder decoding parameters using user parameters */
-	opj_setup_decoder(dinfo, &parameters);
-
-	/* open a byte stream */
-	if (jpfamform == MJ2_CFMT)
-		cio = opj_cio_open((opj_common_ptr)dinfo, src, jpeg2000headSIZE + jp2hboxlen + jp2cboxlen);
-	else if (jpfamform == JP2_CFMT || jpfamform == J2K_CFMT)
-		cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-	else {
-		free(src);
-		return false;
-	}
-
-	/* decode the stream and fill the image structure */
-	opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
-	if (!opjimage) {
-		wxMutexGuiEnter();
-		wxLogError(wxT("JPEG 2000 failed to decode image!"));
-		wxMutexGuiLeave();
-		opj_destroy_decompress(dinfo);
-		opj_cio_close(cio);
-		free(src);
-		return false;
-	}
-
-	/* close the byte stream */
-	opj_cio_close(cio);
-
-	/*
-
-	- At this point, we have the structure "opjimage" that is filled with decompressed
-	  data, as processed by the OpenJPEG decompression engine
-
-	- We need to fill the class "image" with the proper pixel sample values
-
-	*/
-	{
-		int shiftbpp;
-		int c, tempcomps;
-
-		// check components number
-		if (m_components > opjimage->numcomps)
-			m_components = opjimage->numcomps;
-
-		// check image depth (only on the first one, for now)
-		if (m_components)
-			shiftbpp = opjimage->comps[m_components - 1].prec - 8;
-		else
-			shiftbpp = opjimage->comps[0].prec - 8;
-
-		// prepare image size
-		if (m_components)
-			image->Create(opjimage->comps[m_components - 1].w, opjimage->comps[m_components - 1].h, true);
-		else
-			image->Create(opjimage->comps[0].w, opjimage->comps[0].h, true);
-
-		// access image raw data
-		image->SetMask(false);
-		ptr = image->GetData();
-
-		// workaround for components different from 1 or 3
-		if ((opjimage->numcomps != 1) && (opjimage->numcomps != 3)) {
-#ifndef __WXGTK__ 
-			wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-			wxLogMessage(wxT("JPEG2000: weird number of components"));
-#ifndef __WXGTK__ 
-			wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-			tempcomps = 1;
-		} else
-			tempcomps = opjimage->numcomps;
-
-		// workaround for subsampled components
-		for (c = 1; c < tempcomps; c++) {
-			if ((opjimage->comps[c].w != opjimage->comps[c - 1].w) || (opjimage->comps[c].h != opjimage->comps[c - 1].h)) {
-				tempcomps = 1;
-				break;
-			}
-		}
-
-		// workaround for different precision components
-		for (c = 1; c < tempcomps; c++) {
-			if (opjimage->comps[c].bpp != opjimage->comps[c - 1].bpp) {
-				tempcomps = 1;
-				break;
-			}
-		}
-
-		// only one component selected
-		if (m_components)
-			tempcomps = 1;
-
-		// RGB color picture
-		if (tempcomps == 3) {
-			int row, col;
-			int *r = opjimage->comps[0].data;
-			int *g = opjimage->comps[1].data;
-			int *b = opjimage->comps[2].data;
-			if (shiftbpp > 0) {
-				for (row = 0; row < opjimage->comps[0].h; row++) {
-					for (col = 0; col < opjimage->comps[0].w; col++) {
-						
-						*(ptr++) = (*(r++)) >> shiftbpp;
-						*(ptr++) = (*(g++)) >> shiftbpp;
-						*(ptr++) = (*(b++)) >> shiftbpp;
-
-					}
-				}
-
-			} else if (shiftbpp < 0) {
-				for (row = 0; row < opjimage->comps[0].h; row++) {
-					for (col = 0; col < opjimage->comps[0].w; col++) {
-						
-						*(ptr++) = (*(r++)) << -shiftbpp;
-						*(ptr++) = (*(g++)) << -shiftbpp;
-						*(ptr++) = (*(b++)) << -shiftbpp;
-
-					}
-				}
-				
-			} else {
-				for (row = 0; row < opjimage->comps[0].h; row++) {
-					for (col = 0; col < opjimage->comps[0].w; col++) {
-
-						*(ptr++) = *(r++);
-						*(ptr++) = *(g++);
-						*(ptr++) = *(b++);
-					
-					}
-				}
-			}
-		}
-
-		// B/W picture
-		if (tempcomps == 1) {
-			int row, col;
-			int selcomp;
-
-			if (m_components)
-				selcomp = m_components - 1;
-			else
-				selcomp = 0;
-
-			int *y = opjimage->comps[selcomp].data;
-			if (shiftbpp > 0) {
-				for (row = 0; row < opjimage->comps[selcomp].h; row++) {
-					for (col = 0; col < opjimage->comps[selcomp].w; col++) {
-						
-						*(ptr++) = (*(y)) >> shiftbpp;
-						*(ptr++) = (*(y)) >> shiftbpp;
-						*(ptr++) = (*(y++)) >> shiftbpp;
-
-					}
-				}
-			} else if (shiftbpp < 0) {
-				for (row = 0; row < opjimage->comps[selcomp].h; row++) {
-					for (col = 0; col < opjimage->comps[selcomp].w; col++) {
-						
-						*(ptr++) = (*(y)) << -shiftbpp;
-						*(ptr++) = (*(y)) << -shiftbpp;
-						*(ptr++) = (*(y++)) << -shiftbpp;
-
-					}
-				}
-			} else {
-				for (row = 0; row < opjimage->comps[selcomp].h; row++) {
-					for (col = 0; col < opjimage->comps[selcomp].w; col++) {
-						
-						*(ptr++) = *(y);
-						*(ptr++) = *(y);
-						*(ptr++) = *(y++);
-
-					}
-				}
-			}
-		}
-
-
-	}
-
-    wxMutexGuiEnter();
-    wxLogMessage(wxT("JPEG 2000 image loaded."));
-    wxMutexGuiLeave();
-
-	/* close openjpeg structs */
-	opj_destroy_decompress(dinfo);
-	opj_image_destroy(opjimage);
-	free(src);
-
-	if (!image->Ok())
-		return false;
-	else
-		return true;
-
-}
-
-#define CINEMA_24_CS 1302083	/* Codestream length for 24fps */
-#define CINEMA_48_CS 651041		/* Codestream length for 48fps */
-#define COMP_24_CS 1041666		/* Maximum size per color component for 2K & 4K @ 24fps */
-#define COMP_48_CS 520833		/* Maximum size per color component for 2K @ 48fps */
-
-// save the j2k codestream
-bool wxJPEG2000Handler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbose )
-{
-        opj_cparameters_t parameters;	/* compression parameters */
-        opj_event_mgr_t event_mgr;		/* event manager */
-        opj_image_t *oimage = NULL;
-        opj_image_cmptparm_t *cmptparm;	
-        opj_cio_t *cio = NULL;
-        opj_codestream_info_t cstr_info;
-        int codestream_length;
-        bool bSuccess;
-        int i;
-        char indexfilename[OPJ_PATH_LEN] = "";	/* index file name */
-
-        /*
-        configure the event callbacks (not required)
-        setting of each callback is optionnal
-        */
-        memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-        event_mgr.error_handler = jpeg2000_error_callback;
-        event_mgr.warning_handler = jpeg2000_warning_callback;
-        event_mgr.info_handler = jpeg2000_info_callback;
-
-        /* set encoding parameters to default values */
-        opj_set_default_encoder_parameters(&parameters);
-
-        /* load parameters */
-        parameters.cp_cinema = OFF;
-
-        /* subsampling */
-        if (sscanf(m_subsampling.ToAscii(), "%d,%d", &(parameters.subsampling_dx), &(parameters.subsampling_dy)) != 2) {
-                wxLogError(wxT("Wrong sub-sampling encoder setting: dx,dy"));
-                return false;
-        }
-
-        /* compression rates */
-        if ((m_rates != wxT("")) && (!m_enablequality)) {
-                const char *s1 = m_rates.ToAscii();
-                wxLogMessage(wxT("rates %s"), s1);
-                while (sscanf(s1, "%f", &(parameters.tcp_rates[parameters.tcp_numlayers])) == 1) {
-                        parameters.tcp_numlayers++;
-                        while (*s1 && *s1 != ',') {
-                                s1++;
-                        }
-                        if (!*s1)
-                                break;
-                        s1++;
-                }
-                wxLogMessage(wxT("%d layers"), parameters.tcp_numlayers);
-                parameters.cp_disto_alloc = 1;
-        }
-
-        /* image quality, dB */
-        if ((m_quality != wxT("")) && (m_enablequality)) {
-                const char *s2 = m_quality.ToAscii();
-                wxLogMessage(wxT("qualities %s"), s2);
-                while (sscanf(s2, "%f", &parameters.tcp_distoratio[parameters.tcp_numlayers]) == 1) {
-                        parameters.tcp_numlayers++;
-                        while (*s2 && *s2 != ',') {
-                                s2++;
-                        }
-                        if (!*s2)
-                                break;
-                        s2++;
-                }
-                wxLogMessage(wxT("%d layers"), parameters.tcp_numlayers);
-                parameters.cp_fixed_quality = 1;
-        }
-
-        /* image origin */
-        if (sscanf(m_origin.ToAscii(), "%d,%d", &parameters.image_offset_x0, &parameters.image_offset_y0) != 2) {
-                wxLogError(wxT("bad coordinate of the image origin: x0,y0"));
-                return false;
-        }
-                                
-        /* Create comment for codestream */
-        if(m_enablecomm) {
-                parameters.cp_comment = (char *) malloc(strlen(m_comment.ToAscii()) + 1);
-                if(parameters.cp_comment) {
-                        strcpy(parameters.cp_comment, m_comment.ToAscii());
-                }
-        } else {
-                parameters.cp_comment = NULL;
-        }
-
-        /* indexing file */
-        if (m_enableidx) {
-                strncpy(indexfilename, m_index.ToAscii(), OPJ_PATH_LEN);
-                wxLogMessage(wxT("index file is %s"), indexfilename);
-        }
-
-        /* if no rate entered, lossless by default */
-        if (parameters.tcp_numlayers == 0) {
-                parameters.tcp_rates[0] = 0;	/* MOD antonin : losslessbug */
-                parameters.tcp_numlayers++;
-                parameters.cp_disto_alloc = 1;
-        }
-
-        /* irreversible transform */
-        parameters.irreversible = (m_irreversible == true) ? 1 : 0;
-
-        /* resolutions */
-        parameters.numresolution = m_resolutions;
-
-        /* codeblocks size */
-        if (m_cbsize != wxT("")) {
-                int cblockw_init = 0, cblockh_init = 0;
-                sscanf(m_cbsize.ToAscii(), "%d,%d", &cblockw_init, &cblockh_init);
-                if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024 || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
-                        wxLogError(wxT("!! Size of code_block error !! Restrictions:\n  width*height<=4096\n  4<=width,height<= 1024"));
-                        return false;
-                }
-                parameters.cblockw_init = cblockw_init;
-                parameters.cblockh_init = cblockh_init;
-        }
-
-        /* precincts size */
-        if (m_prsize != wxT("")) {
-                char sep;
-                int res_spec = 0;
-                char *s = (char *) m_prsize.c_str();
-                do {
-                        sep = 0;
-                        sscanf(s, "[%d,%d]%c", &parameters.prcw_init[res_spec], &parameters.prch_init[res_spec], &sep);
-                        parameters.csty |= 0x01;
-                        res_spec++;
-                        s = strpbrk(s, "]") + 2;
-                } while (sep == ',');
-                parameters.res_spec = res_spec;
-        }
-
-        /* tiles */
-        if (m_tsize != wxT("")) {
-                sscanf(m_tsize.ToAscii(), "%d,%d", &parameters.cp_tdx, &parameters.cp_tdy);
-                parameters.tile_size_on = true;
-        }
-
-        /* tile origin */
-        if (sscanf(m_torigin.ToAscii(), "%d,%d", &parameters.cp_tx0, &parameters.cp_ty0) != 2) {
-                wxLogError(wxT("tile offset setting error: X0,Y0"));
-                return false;
-        }
-
-        /* use SOP */
-        if (m_enablesop)
-                parameters.csty |= 0x02;
-
-        /* use EPH */
-        if (m_enableeph)
-                parameters.csty |= 0x04;
-
-        /* multiple component transform */
-        if (m_multicomp)
-                parameters.tcp_mct = 1;
-        else
-                parameters.tcp_mct = 0;
-
-        /* mode switch */
-        parameters.mode = (m_enablebypass ? 1 : 0) + (m_enablereset ? 2 : 0)
-                + (m_enablerestart ? 4 : 0) + (m_enablevsc ? 8 : 0)
-                + (m_enableerterm ? 16 : 0) + (m_enablesegmark ? 32 : 0);
-
-        /* progression order */
-        switch (m_progression) {
-
-                /* LRCP */
-        case 0:
-                parameters.prog_order = LRCP;
-                break;
-
-                /* RLCP */
-        case 1:
-                parameters.prog_order = RLCP;
-                break;
-
-                /* RPCL */
-        case 2:
-                parameters.prog_order = RPCL;
-                break;
-
-                /* PCRL */
-        case 3:
-                parameters.prog_order = PCRL;
-                break;
-
-                /* CPRL */
-        case 4:
-                parameters.prog_order = CPRL;
-                break;
-
-                /* DCI2K24 */
-        case 5:
-                parameters.cp_cinema = CINEMA2K_24;
-                parameters.cp_rsiz = CINEMA2K;
-                break;
-
-                /* DCI2K48 */
-        case 6:
-                parameters.cp_cinema = CINEMA2K_48;
-                parameters.cp_rsiz = CINEMA2K;
-                break;
-
-                /* DCI4K */
-        case 7:
-                parameters.cp_cinema = CINEMA4K_24;
-                parameters.cp_rsiz = CINEMA4K;
-                break;
-
-        default:
-                break;
-        }
-
-        /* check cinema */
-        if (parameters.cp_cinema) {
-
-                /* set up */
-                parameters.tile_size_on = false;
-                parameters.cp_tdx=1;
-                parameters.cp_tdy=1;
-                
-                /*Tile part*/
-                parameters.tp_flag = 'C';
-                parameters.tp_on = 1;
-
-                /*Tile and Image shall be at (0,0)*/
-                parameters.cp_tx0 = 0;
-                parameters.cp_ty0 = 0;
-                parameters.image_offset_x0 = 0;
-                parameters.image_offset_y0 = 0;
-
-                /*Codeblock size= 32*32*/
-                parameters.cblockw_init = 32;	
-                parameters.cblockh_init = 32;
-                parameters.csty |= 0x01;
-
-                /*The progression order shall be CPRL*/
-                parameters.prog_order = CPRL;
-
-                /* No ROI */
-                parameters.roi_compno = -1;
-
-                parameters.subsampling_dx = 1;
-                parameters.subsampling_dy = 1;
-
-                /* 9-7 transform */
-                parameters.irreversible = 1;
-
-        }				
-
-        /* convert wx image into opj image */
-        cmptparm = (opj_image_cmptparm_t*) malloc(3 * sizeof(opj_image_cmptparm_t));
-
-        /* initialize opj image components */	
-        memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-        for(i = 0; i < 3; i++) {		
-                cmptparm[i].prec = 8;
-                cmptparm[i].bpp = 8;
-                cmptparm[i].sgnd = false;
-                cmptparm[i].dx = parameters.subsampling_dx;
-                cmptparm[i].dy = parameters.subsampling_dy;
-                cmptparm[i].w = wimage->GetWidth();
-                cmptparm[i].h = wimage->GetHeight();
-        }
-
-        /* create the image */
-        oimage = opj_image_create(3, &cmptparm[0], CLRSPC_SRGB);
-        if(!oimage) {
-                if (cmptparm)
-                        free(cmptparm);
-                return false;
-        }
-
-        /* set image offset and reference grid */
-        oimage->x0 = parameters.image_offset_x0;
-        oimage->y0 = parameters.image_offset_y0;
-        oimage->x1 = parameters.image_offset_x0 + (wimage->GetWidth() - 1) * 1 + 1;
-        oimage->y1 = parameters.image_offset_y0 + (wimage->GetHeight() - 1) * 1 + 1;
-
-        /* load image data */
-        unsigned char *value = wimage->GetData(); 
-        int area = wimage->GetWidth() * wimage->GetHeight();
-        for (i = 0; i < area; i++) {
-                        oimage->comps[0].data[i] = *(value++);
-                        oimage->comps[1].data[i] = *(value++);
-                        oimage->comps[2].data[i] = *(value++);
-        }
-
-        /* check cinema again */
-        if (parameters.cp_cinema) {
-                int i;
-                float temp_rate;
-                opj_poc_t *POC = NULL;
-
-                switch (parameters.cp_cinema) {
-
-                case CINEMA2K_24:
-                case CINEMA2K_48:
-                        if (parameters.numresolution > 6) {
-                                parameters.numresolution = 6;
-                        }
-                        if (!((oimage->comps[0].w == 2048) | (oimage->comps[0].h == 1080))) {
-                                wxLogWarning(wxT("Image coordinates %d x %d is not 2K compliant. JPEG Digital Cinema Profile-3 "
-                                        "(2K profile) compliance requires that at least one of coordinates match 2048 x 1080"),
-                                        oimage->comps[0].w, oimage->comps[0].h);
-                                parameters.cp_rsiz = STD_RSIZ;
-                        }
-                break;
-                
-                case CINEMA4K_24:
-                        if (parameters.numresolution < 1) {
-                                        parameters.numresolution = 1;
-                        } else if (parameters.numresolution > 7) {
-                                        parameters.numresolution = 7;
-                        }
-                        if (!((oimage->comps[0].w == 4096) | (oimage->comps[0].h == 2160))) {
-                                wxLogWarning(wxT("Image coordinates %d x %d is not 4K compliant. JPEG Digital Cinema Profile-4" 
-                                        "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160"),
-                                        oimage->comps[0].w, oimage->comps[0].h);
-                                parameters.cp_rsiz = STD_RSIZ;
-                        }
-                        parameters.POC[0].tile  = 1; 
-                        parameters.POC[0].resno0  = 0; 
-                        parameters.POC[0].compno0 = 0;
-                        parameters.POC[0].layno1  = 1;
-                        parameters.POC[0].resno1  = parameters.numresolution - 1;
-                        parameters.POC[0].compno1 = 3;
-                        parameters.POC[0].prg1 = CPRL;
-                        parameters.POC[1].tile  = 1;
-                        parameters.POC[1].resno0  = parameters.numresolution - 1; 
-                        parameters.POC[1].compno0 = 0;
-                        parameters.POC[1].layno1  = 1;
-                        parameters.POC[1].resno1  = parameters.numresolution;
-                        parameters.POC[1].compno1 = 3;
-                        parameters.POC[1].prg1 = CPRL;
-                        parameters.numpocs = 2;
-                        break;
-                }
-
-                switch (parameters.cp_cinema) {
-                case CINEMA2K_24:
-                case CINEMA4K_24:
-                        for (i = 0 ; i < parameters.tcp_numlayers; i++) {
-                                temp_rate = 0;
-                                if (parameters.tcp_rates[i] == 0) {
-                                        parameters.tcp_rates[0] = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / 
-                                        (CINEMA_24_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
-                                }else{
-                                        temp_rate = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / 
-                                                (parameters.tcp_rates[i] * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
-                                        if (temp_rate > CINEMA_24_CS ) {
-                                                parameters.tcp_rates[i]= ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / 
-                                                (CINEMA_24_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
-                                        } else {
-                                                /* do nothing */
-                                        }
-                                }
-                        }
-                        parameters.max_comp_size = COMP_24_CS;
-                        break;
-                        
-                case CINEMA2K_48:
-                        for (i = 0; i < parameters.tcp_numlayers; i++) {
-                                temp_rate = 0 ;
-                                if (parameters.tcp_rates[i] == 0) {
-                                        parameters.tcp_rates[0] = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / 
-                                        (CINEMA_48_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
-                                }else{
-                                        temp_rate =((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / 
-                                                (parameters.tcp_rates[i] * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
-                                        if (temp_rate > CINEMA_48_CS ){
-                                                parameters.tcp_rates[0]= ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) / 
-                                                (CINEMA_48_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
-                                        }else{
-                                                /* do nothing */
-                                        }
-                                }
-                        }
-                        parameters.max_comp_size = COMP_48_CS;
-                        break;
-                }
-
-                parameters.cp_disto_alloc = 1;
-        }
-        
-        /* get a J2K compressor handle */
-        opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);
-
-        /* catch events using our callbacks and give a local context */
-        opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
-
-        /* setup the encoder parameters using the current image and user parameters */
-        opj_setup_encoder(cinfo, &parameters, oimage);
-
-        /* open a byte stream for writing */
-        /* allocate memory for all tiles */
-        cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
-
-        /* encode the image */
-        bSuccess = opj_encode_with_info(cinfo, cio, oimage, &cstr_info);
-        if (!bSuccess) {
-
-                opj_cio_close(cio);
-                opj_destroy_compress(cinfo);
-                opj_image_destroy(oimage);
-                if (cmptparm)
-                        free(cmptparm);
-                if(parameters.cp_comment)
-                        free(parameters.cp_comment);
-                if(parameters.cp_matrice)
-                        free(parameters.cp_matrice);
-
-#ifndef __WXGTK__ 
-    wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-
-                wxLogError(wxT("failed to encode image"));
-
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-
-                return false;
-        }
-        codestream_length = cio_tell(cio);
-        wxLogMessage(wxT("Codestream: %d bytes"), codestream_length);
-
-        /* write the buffer to stream */
-        stream.Write(cio->buffer, codestream_length);
-
-        /* close and free the byte stream */
-        opj_cio_close(cio);
-
-        /* Write the index to disk */
-        if (*indexfilename) {
-                if (write_index_file(&cstr_info, indexfilename)) {
-                        wxLogError(wxT("Failed to output index file"));
-                }
-        }
-
-        /* free remaining compression structures */
-        opj_destroy_compress(cinfo);
-
-        /* free image data */
-        opj_image_destroy(oimage);
-
-        if (cmptparm)
-                free(cmptparm);
-        if(parameters.cp_comment)
-                free(parameters.cp_comment);
-        if(parameters.cp_matrice)
-                free(parameters.cp_matrice);
-
-#ifndef __WXGTK__ 
-    wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-
-    wxLogMessage(wxT("J2K: Image encoded!"));
-
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-
-    return true;
-}
-
-#ifdef __VISUALC__
-    #pragma warning(default:4611)
-#endif /* VC++ */
-
-// recognize the JPEG 2000 family starting box or the 0xFF4F JPEG 2000 SOC marker
-bool wxJPEG2000Handler::DoCanRead(wxInputStream& stream)
-{
-    unsigned char hdr[24];
-	int jpfamform;
-
-    if ( !stream.Read(hdr, WXSIZEOF(hdr)) )
-        return false;
-
-	jpfamform = jpeg2000familytype(hdr, WXSIZEOF(hdr));
-
-	return ((jpfamform == JP2_CFMT) || (jpfamform == MJ2_CFMT) || (jpfamform == J2K_CFMT));
-}
-
-#endif   // wxUSE_STREAMS
-
-#endif   // wxUSE_LIBOPENJPEG
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagjpeg2000.h b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagjpeg2000.h
deleted file mode 100644
index 2fea20a..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagjpeg2000.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/////////////////////////////////////////////////////////////////////////////
-// Name:        imagalljpeg2000.h
-// Purpose:     wxImage JPEG 2000 family file format handler
-// Author:      G. Baruffa - based on imagjpeg.h, Vaclav Slavik
-// RCS-ID:      $Id: imagalljpeg2000.h,v 0.0 2008/01/31 11:22:00 VZ Exp $
-// Copyright:   (c) Giuseppe Baruffa
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_IMAGJPEG2000_H_
-#define _WX_IMAGJPEG2000_H_
-
-#include "wx/defs.h"
-
-//-----------------------------------------------------------------------------
-// wxJPEG2000Handler
-//-----------------------------------------------------------------------------
-
-#if wxUSE_LIBOPENJPEG
-
-#include "wx/image.h"
-#include "libopenjpeg/openjpeg.h"
-#include "codec/index.h"
-
-#define wxBITMAP_TYPE_JPEG2000	50
-
-class WXDLLEXPORT wxJPEG2000Handler: public wxImageHandler
-{
-public:
-    inline wxJPEG2000Handler()
-    {
-        m_name = wxT("JPEG 2000 family file format");
-        m_extension = wxT("mj2");
-        m_type = wxBITMAP_TYPE_JPEG2000;
-        m_mime = wxT("image/mj2");
-
-		/* decoding */
-		m_reducefactor = 0;
-		m_qualitylayers = 0;
-		m_components = 0;
-#ifdef USE_JPWL
-		m_enablejpwl = true;
-		m_expcomps = JPWL_EXPECTED_COMPONENTS;
-		m_maxtiles = JPWL_MAXIMUM_TILES;
-#endif // USE_JPWL
-
-		/* encoding */
-		m_subsampling = wxT("1,1");
-		m_origin = wxT("0,0");
-		m_rates = wxT("20,10,5");
-		m_quality = wxT("30,35,40");
-		m_enablequality = false;
-		m_multicomp = false;
-		m_irreversible = false;
-		m_resolutions = 6;
-		m_progression = 0;
-		m_cbsize = wxT("32,32");
-		m_prsize = wxT("[128,128],[128,128]");
-		m_tsize = wxT("");
-		m_torigin = wxT("0,0");
-		/*m_progression
-		m_resilience*/
-		m_enablesop = false;
-		m_enableeph = false;
-		m_enablereset = false;
-		m_enablesegmark = false;
-		m_enablevsc = false;
-		m_enablerestart = false;
-		m_enableerterm = false;
-		m_enablebypass = false;
-		/*m_roicompo
-		m_roiup
-		m_indexfname*/
-		m_enableidx = false;
-		m_index = wxT("index.txt");
-		m_enablepoc = false;
-		m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
-		m_enablecomm = true;
-
-#if defined __WXMSW__
-		m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG  version ");
-#elif defined __WXGTK__
-		m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
-#else
-		m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
-#endif
-
-#ifdef USE_JPWL
-		m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
-#else
-		m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
-#endif
-
-    }
-
-	// decoding engine parameters
-	int m_reducefactor, m_qualitylayers, m_components, m_framenum;
-#ifdef USE_JPWL
-	bool m_enablejpwl;
-	int m_expcomps, m_maxtiles;
-#endif // USE_JPWL
-
-	// encoding engine parameters
-	wxString m_subsampling;
-	wxString m_origin;
-	wxString m_rates;
-	wxString m_quality;
-	bool m_enablequality;
-	bool m_multicomp;
-	bool m_irreversible;
-	int m_resolutions;
-	int m_progression;
-	wxString m_cbsize;
-	wxString m_prsize;
-	wxString m_tsize;
-	wxString m_torigin;
-	/*m_progression
-	m_resilience*/
-	bool m_enablesop;
-	bool m_enableeph;
-	bool m_enablebypass;
-	bool m_enableerterm;
-	bool m_enablerestart;
-	bool m_enablereset;
-	bool m_enablesegmark;
-	bool m_enablevsc;
-	/*m_roicompo
-	m_roiup
-	m_indexfname*/
-	bool m_enableidx;
-	wxString m_index;
-	bool m_enablecomm;
-	wxString m_comment;
-	bool m_enablepoc;
-	wxString m_poc;
-
-#if wxUSE_STREAMS
-    virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
-    virtual bool SaveFile(wxImage *image, wxOutputStream& stream, bool verbose=true);
-protected:
-    virtual bool DoCanRead(wxInputStream& stream);
-#endif
-
-private:
-	OPJ_PROG_ORDER give_progression(char progression[4]);
-    DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
-};
-
-#endif // wxUSE_LIBOPENJPEG
-
-#endif // _WX_IMAGJPEG2000_H_
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagmxf.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagmxf.cpp
deleted file mode 100644
index 99d0b93..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagmxf.cpp
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/////////////////////////////////////////////////////////////////////////////
-// Name:        imagmxf.cpp
-// Purpose:     wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
-// Author:      Giuseppe Baruffa - based on imagjpeg.cpp, Vaclav Slavik
-// RCS-ID:      $Id: imagmxf.cpp,v 0.00 2007/11/19 17:00:00 MW Exp $
-// Copyright:   (c) Giuseppe Baruffa
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef USE_MXF
-
-#include "mxflib/mxflib.h"
-using namespace mxflib;
-
-namespace
-{
-	//! Structure holding information about the essence in each body stream
-	struct EssenceInfo
-	{
-		UMIDPtr PackageID;
-		PackagePtr Package;
-		MDObjectPtr Descriptor;
-	};
-	//! Map of EssenceInfo structures indexed by BodySID
-	typedef std::map<UInt32, EssenceInfo> EssenceInfoMap;
-
-	//! The map of essence info for this file
-	EssenceInfoMap EssenceLookup;
-};
-
-//! Build an EssenceInfoMap for the essence in a given file
-/*! \return True if al OK, else false
- */
-bool BuildEssenceInfo(MXFFilePtr &File, EssenceInfoMap &EssenceLookup);
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-    #pragma hdrstop
-#endif
-
-#if wxUSE_IMAGE && wxUSE_LIBOPENJPEG
-
-#include "imagmxf.h"
-
-#ifndef WX_PRECOMP
-    #include "wx/log.h"
-    #include "wx/app.h"
-    #include "wx/intl.h"
-    #include "wx/bitmap.h"
-    #include "wx/module.h"
-#endif
-
-
-#include "libopenjpeg/openjpeg.h"
-
-
-#include "wx/filefn.h"
-#include "wx/wfstream.h"
-
-// ----------------------------------------------------------------------------
-// types
-// ----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// wxMXFHandler
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxMXFHandler,wxImageHandler)
-
-#if wxUSE_STREAMS
-
-#include <stdarg.h>
-#define MAX_MESSAGE_LEN 200
-
-//------------- MXF Manager
-
-// Debug and error messages
-
-//! Display a warning message
-void mxflib::warning(const char *Fmt, ...)
-{
-	char msg[MAX_MESSAGE_LEN];
-	va_list args;
-
-	va_start(args, Fmt);
-	_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
-	va_end(args);
-
-	int message_len = strlen(msg) - 1;
-	if (msg[message_len] != '\n')
-		message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__ 
-		wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-	wxLogMessage(wxT("[WARNING_MXF] %.*s"), message_len, msg);
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-}
-
-//! Display an error message
-void mxflib::error(const char *Fmt, ...)
-{
-	char msg[MAX_MESSAGE_LEN];
-	va_list args;
-
-	va_start(args, Fmt);
-	_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
-	va_end(args);
-
-	int message_len = strlen(msg) - 1;
-	if (msg[message_len] != '\n')
-		message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__ 
-		wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-	wxLogMessage(wxT("[ERROR_MXF] %.*s"), message_len, msg);
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-}
-
-//! Display an error message
-void mxflib::debug(const char *Fmt, ...)
-{
-	char msg[MAX_MESSAGE_LEN];
-	va_list args;
-
-	va_start(args, Fmt);
-	_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
-	va_end(args);
-
-	int message_len = strlen(msg) - 1;
-	if (msg[message_len] != '\n')
-		message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__ 
-		wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-	wxLogMessage(wxT("[DEBUG_MXF] %.*s"), message_len, msg);
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-}
-
-
-
-//------------- JPEG 2000 Data Source Manager
-
-#define J2K_CFMT 0
-#define JP2_CFMT 1
-#define JPT_CFMT 2
-#define MJ2_CFMT 3
-#define PXM_DFMT 0
-#define PGX_DFMT 1
-#define BMP_DFMT 2
-#define YUV_DFMT 3
-
-/* sample error callback expecting a FILE* client object */
-void mxf_error_callback(const char *msg, void *client_data) {
-	int message_len = strlen(msg) - 1;
-	if (msg[message_len] != '\n')
-		message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__ 
-		wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-	wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-}
-
-/* sample warning callback expecting a FILE* client object */
-void mxf_warning_callback(const char *msg, void *client_data) {
-	int message_len = strlen(msg) - 1;
-	if (msg[message_len] != '\n')
-		message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__ 
-		wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-	wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-}
-
-/* sample debug callback expecting no client object */
-void mxf_info_callback(const char *msg, void *client_data) {
-	int message_len = strlen(msg) - 1;
-	if (msg[message_len] != '\n')
-		message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__ 
-		wxMutexGuiEnter();
-#endif /* __WXGTK__ */
-	wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
-#ifndef __WXGTK__ 
-    wxMutexGuiLeave();
-#endif /* __WXGTK__ */
-}
-
-
-/////////////////////////////////////////////////
-/////////////////////////////////////////////////
-
-// load the mxf file format
-bool wxMXFHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index)
-{
-	opj_dparameters_t parameters;	/* decompression parameters */
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_image_t *opjimage = NULL;
-	unsigned char *src = NULL;
-    unsigned char *ptr;
-	int file_length, j2k_point, j2k_len;
-	opj_codestream_info_t cstr_info;  /* Codestream information structure */
-	
-	// simply display the version of the library
-	wxLogMessage(wxT("Version of MXF: %s   "), wxString::FromAscii(LibraryVersion().c_str()));
-	//wxLogMessage(wxT("MXF file name: %s"), m_filename.GetFullPath());
-
-	// open MXF file
-	MXFFilePtr TestFile = new MXFFile;
-	if (! TestFile->Open(m_filename.GetFullPath().c_str(), true))
-	{
-		wxLogError(wxT("Could not find %s"), m_filename.GetFullPath().c_str());
-		return false;
-	} else
-		wxLogMessage(wxT("Found %s"), m_filename.GetFullPath().c_str());
-
-	// Get the size
-	TestFile->SeekEnd();
-	wxLogMessage(wxT("Size is %d bytes"), TestFile->Tell());
-	TestFile->Seek(0);
-
-	// essence information
-	//BuildEssenceInfo(TestFile, EssenceLookup);
-
-	// close MXF file
-	TestFile->Close();
-
-	return false;
-	
-	// destroy the image
-    image->Destroy();
-
-	/* handle to a decompressor */
-	opj_dinfo_t* dinfo = NULL;	
-	opj_cio_t *cio = NULL;
-
-	/* configure the event callbacks (not required) */
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = mxf_error_callback;
-	event_mgr.warning_handler = mxf_warning_callback;
-	event_mgr.info_handler = mxf_info_callback;
-
-	/* set decoding parameters to default values */
-	opj_set_default_decoder_parameters(&parameters);
-
-	/* prepare parameters */
-	strncpy(parameters.infile, "", sizeof(parameters.infile)-1);
-	strncpy(parameters.outfile, "", sizeof(parameters.outfile)-1);
-	parameters.decod_format = J2K_CFMT;
-	parameters.cod_format = BMP_DFMT;
-	if (m_reducefactor)
-		parameters.cp_reduce = m_reducefactor;
-	if (m_qualitylayers)
-		parameters.cp_layer = m_qualitylayers;
-	/*if (n_components)
-		parameters. = n_components;*/
-
-	/* JPWL only */
-#ifdef USE_JPWL
-	parameters.jpwl_exp_comps = m_expcomps;
-	parameters.jpwl_max_tiles = m_maxtiles;
-	parameters.jpwl_correct = m_enablejpwl;
-#endif /* USE_JPWL */
-
-	/* get a decoder handle */
-	dinfo = opj_create_decompress(CODEC_J2K);
-
-	/* find length of the stream */
-	stream.SeekI(0, wxFromEnd);
-	file_length = (int) stream.TellI();
-
-	/* search for the m_framenum codestream position and length  */
-	//jp2c_point = searchjp2c(stream, file_length, m_framenum);
-	//jp2c_len = searchjp2c(stream, file_length, m_framenum);
-	j2k_point = 0;
-	j2k_len = 10;
-
-	// malloc memory source
-    src = (unsigned char *) malloc(j2k_len);
-
-	// copy the jp2c
-	stream.SeekI(j2k_point, wxFromStart);
-	stream.Read(src, j2k_len);
-
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-	/* setup the decoder decoding parameters using user parameters */
-	opj_setup_decoder(dinfo, &parameters);
-
-	/* open a byte stream */
-	cio = opj_cio_open((opj_common_ptr)dinfo, src, j2k_len);
-
-	/* decode the stream and fill the image structure */
-	opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
-	if (!opjimage) {
-		wxMutexGuiEnter();
-		wxLogError(wxT("MXF: failed to decode image!"));
-		wxMutexGuiLeave();
-		opj_destroy_decompress(dinfo);
-		opj_cio_close(cio);
-		free(src);
-		return false;
-	}
-
-	/* close the byte stream */
-	opj_cio_close(cio);
-
-	/* common rendering method */
-#include "imagjpeg2000.cpp"
-
-    wxMutexGuiEnter();
-    wxLogMessage(wxT("MXF: image loaded."));
-    wxMutexGuiLeave();
-
-	/* close openjpeg structs */
-	opj_destroy_decompress(dinfo);
-	opj_image_destroy(opjimage);
-	free(src);
-
-	if (!image->Ok())
-		return false;
-	else
-		return true;
-
-}
-
-// save the mxf file format
-bool wxMXFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )
-{
-    wxLogError(wxT("MXF: Couldn't save movie -> not implemented."));
-    return false;
-}
-
-#ifdef __VISUALC__
-    #pragma warning(default:4611)
-#endif /* VC++ */
-
-// recognize the MXF JPEG 2000 starting box
-bool wxMXFHandler::DoCanRead( wxInputStream& stream )
-{
-    unsigned char hdr[4];
-
-    if ( !stream.Read(hdr, WXSIZEOF(hdr)) )
-        return false;
-
-    return (hdr[0] == 0x06 &&
-			hdr[1] == 0x0E &&
-			hdr[2] == 0x2B &&
-			hdr[3] == 0x34);
-}
-
-//! Build an EssenceInfoMap for the essence in a given file
-/*! \return True if al OK, else false
- */
-bool BuildEssenceInfo(MXFFilePtr &File, EssenceInfoMap &EssenceLookup)
-{
-	// Empty any old data
-	EssenceLookup.clear();
-
-	// Get the master metadata set (or the header if we must)
-	PartitionPtr MasterPartition = File->ReadMasterPartition();
-	if(!MasterPartition)
-	{
-		File->Seek(0);
-		MasterPartition = File->ReadPartition();
-		warning("File %s does not contain a cloased copy of header metadata - using the open copy in the file header\n", File->Name.c_str());
-	}
-
-	if(!MasterPartition) 
-	{
-		error("Could not read header metadata from file %s\n", File->Name.c_str());
-		return false;
-	}
-
-	// Read and parse the metadata
-	MasterPartition->ReadMetadata();
-	MetadataPtr HMeta = MasterPartition->ParseMetadata();
-	
-	if(!HMeta) 
-	{
-		error("Could not read header metadata from file %s\n", File->Name.c_str());
-		return false;
-	}
-
-	/* Scan the Essence container data sets to get PackageID to BodySID mapping */
-	MDObjectPtr ECDSet = HMeta[ContentStorage_UL];
-	if(ECDSet) ECDSet = ECDSet->GetLink();
-	if(ECDSet) ECDSet = ECDSet[EssenceContainerDataBatch_UL];
-	if(!ECDSet)
-	{
-		error("Header metadata in file %s does not contain an EssenceContainerData set\n", File->Name.c_str());
-		return false;
-	}
-
-	MDObject::iterator it = ECDSet->begin();
-	while(it != ECDSet->end())
-	{
-		MDObjectPtr ThisECDSet = (*it).second->GetLink();
-		MDObjectPtr PackageID;
-		if(ThisECDSet) PackageID = ThisECDSet->Child(LinkedPackageUID_UL);
-		if(PackageID)
-		{
-			EssenceInfo NewEI;
-			NewEI.PackageID = new UMID(PackageID->PutData()->Data);
-
-			// Inset the basic essence info - but not if this is external essence (BodySID == 0)
-			UInt32 BodySID = ThisECDSet->GetUInt(BodySID_UL);
-			if(BodySID) EssenceLookup[BodySID] = NewEI;
-		}
-		it++;
-	}
-
-	/* Now find the other items for the essence lookup map */
-	if(EssenceLookup.size())
-	{
-		PackageList::iterator it = HMeta->Packages.begin();
-		while(it != HMeta->Packages.end())
-		{
-			// Only Source Packages are of interest
-			if((*it)->IsA(SourcePackage_UL))
-			{
-				MDObjectPtr Descriptor = (*it)->Child(Descriptor_UL);
-				if(Descriptor) Descriptor = Descriptor->GetLink();
-
-				if(Descriptor)
-				{
-					MDObjectPtr PackageID = (*it)->Child(PackageUID_UL);
-					if(PackageID)
-					{
-						UMIDPtr TheID = new UMID(PackageID->PutData()->Data);
-						
-						/* Now do a lookup in the essence lookup map (it will need to be done the long way here */
-						EssenceInfoMap::iterator EL_it = EssenceLookup.begin();
-						while(EL_it != EssenceLookup.end())
-						{
-							if((*((*EL_it).second.PackageID)) == (*TheID))
-							{
-								// If found, set the missing items and stop searching
-								(*EL_it).second.Package = (*it);
-								(*EL_it).second.Descriptor = Descriptor;
-								break;
-							}
-							EL_it++;
-						}
-					}
-				}
-			}
-
-			it++;
-		}
-	}
-
-	return true;
-}
-
-
-#endif   // wxUSE_STREAMS
-
-#endif   // wxUSE_LIBOPENJPEG
-
-#endif // USE_MXF
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagmxf.h b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagmxf.h
deleted file mode 100644
index c87a4cb..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/imagmxf.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/////////////////////////////////////////////////////////////////////////////
-// Name:        imagmxf.h
-// Purpose:     wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
-// Author:      G. Baruffa - based on imagjpeg.h, Vaclav Slavik
-// RCS-ID:      $Id: imagmj2.h,v 0.0 2007/11/19 17:00:00 VZ Exp $
-// Copyright:   (c) Giuseppe Baruffa
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_IMAGMXF_H_
-#define _WX_IMAGMXF_H_
-
-#ifdef USE_MXF
-
-#include "wx/defs.h"
-#include "wx/filename.h"
-
-//-----------------------------------------------------------------------------
-// wxMXFHandler
-//-----------------------------------------------------------------------------
-
-#if wxUSE_LIBOPENJPEG
-
-#include "wx/image.h"
-#include "libopenjpeg/openjpeg.h"
-
-#define wxBITMAP_TYPE_MXF	51
-
-class WXDLLEXPORT wxMXFHandler: public wxImageHandler
-{
-public:
-    inline wxMXFHandler()
-    {
-        m_name = wxT("MXF JPEG 2000 file format");
-        m_extension = wxT("mxf");
-        m_type = wxBITMAP_TYPE_MXF;
-        m_mime = wxT("image/mxf");
-
-		m_reducefactor = 0;
-		m_qualitylayers = 0;
-		m_components = 0;
-		m_filename = wxT("");
-#ifdef USE_JPWL
-		m_enablejpwl = true;
-		m_expcomps = JPWL_EXPECTED_COMPONENTS;
-		m_maxtiles = JPWL_MAXIMUM_TILES;
-#endif // USE_JPWL
-    }
-
-		// decoding engine parameters
-		int m_reducefactor, m_qualitylayers, m_components, m_framenum;
-		wxFileName m_filename;
-#ifdef USE_JPWL
-		bool m_enablejpwl;
-		int m_expcomps, m_maxtiles;
-#endif // USE_JPWL
-
-#if wxUSE_STREAMS
-    virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
-    virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true );
-protected:
-    virtual bool DoCanRead( wxInputStream& stream );
-#endif
-
-private:
-    DECLARE_DYNAMIC_CLASS(wxMXFHandler)
-};
-
-#endif // wxUSE_LIBOPENJPEG
-
-#endif // USE_MXF
-
-#endif // _WX_IMAGMXF_H_
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/license.txt b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/license.txt
deleted file mode 100644
index 81d6b34..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/license.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
-Copyright (c) 2002-2007, Professor Benoit Macq
-Copyright (c) 2001-2003, David Janssens
-Copyright (c) 2002-2003, Yannick Verschueren
-Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
-Copyright (c) 2005, Herve Drolon, FreeImage Team
-Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditionsare met:
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF [...]
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/opj_logo.xpm b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/opj_logo.xpm
deleted file mode 100644
index c64d0a7..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/opj_logo.xpm
+++ /dev/null
@@ -1,285 +0,0 @@
-/* XPM */
-static char *opj_logo[] = {
-/* columns rows colors chars-per-pixel */
-"90 61 218 2",
-"   c #BE3D12",
-".  c #BF461D",
-"X  c #AD5435",
-"o  c #B64925",
-"O  c #B54E2B",
-"+  c #BC4620",
-"@  c #BB4B25",
-"#  c #BC4E29",
-"$  c #B5502F",
-"%  c #BD512C",
-"&  c #B45334",
-"*  c #B35638",
-"=  c #B45B3D",
-"-  c #BB5533",
-";  c #BE5937",
-":  c #BC5C3D",
-">  c #9C766A",
-",  c #AD5D42",
-"<  c #B55F41",
-"1  c #BA5E40",
-"2  c #A7634D",
-"3  c #A76C57",
-"4  c #AA6750",
-"5  c #AC6B56",
-"6  c #AA6E5A",
-"7  c #A4705E",
-"8  c #B46045",
-"9  c #B1644B",
-"0  c #BD6244",
-"q  c #B96448",
-"w  c #BC694D",
-"e  c #B36B53",
-"r  c #B26E58",
-"t  c #BB6C52",
-"y  c #B2725D",
-"u  c #BD7056",
-"i  c #BB745C",
-"p  c #A67566",
-"a  c #A57B6D",
-"s  c #AE7562",
-"d  c #AB7867",
-"f  c #AA7C6C",
-"g  c #A07E73",
-"h  c #AA7F71",
-"j  c #B37661",
-"k  c #B47863",
-"l  c #B27D6B",
-"z  c #BB7863",
-"x  c #BA7E69",
-"c  c #C73605",
-"v  c #C63A0B",
-"b  c #CB3300",
-"n  c #CA3807",
-"m  c #C93A0A",
-"M  c #C43E11",
-"N  c #C93E10",
-"B  c #C44115",
-"V  c #C3441A",
-"C  c #C4481E",
-"Z  c #CA4113",
-"A  c #C94519",
-"S  c #CB481C",
-"D  c #C24A23",
-"F  c #C24F28",
-"G  c #CD4D23",
-"H  c #C4522D",
-"J  c #CB532B",
-"K  c #C25632",
-"L  c #C35936",
-"P  c #C25C3B",
-"I  c #C85630",
-"U  c #CB5933",
-"Y  c #CB5E3A",
-"T  c #D05026",
-"R  c #CC613D",
-"E  c #C26343",
-"W  c #C46748",
-"Q  c #C1694C",
-"!  c #CD6744",
-"~  c #CA6C4D",
-"^  c #C37155",
-"/  c #C4755B",
-"(  c #CB7356",
-")  c #C8765B",
-"_  c #D06D4C",
-"`  c #D07253",
-"'  c #D47B5E",
-"]  c #C37B63",
-"[  c #C27E68",
-"{  c #C97F68",
-"}  c #A68175",
-"|  c #A48479",
-" . c #AD8172",
-".. c #AD8578",
-"X. c #AB897D",
-"o. c #B1806F",
-"O. c #BA816F",
-"+. c #B38373",
-"@. c #B58778",
-"#. c #B3897B",
-"$. c #BA8472",
-"%. c #BB8C7C",
-"&. c #C2816B",
-"*. c #CD846C",
-"=. c #C38470",
-"-. c #C38976",
-";. c #C38D7B",
-":. c #CC8973",
-">. c #CF8F7A",
-",. c #CB907D",
-"<. c #D1937F",
-"1. c #948E8C",
-"2. c #9D8C86",
-"3. c #9D8F89",
-"4. c #96908E",
-"5. c #9C918D",
-"6. c #949392",
-"7. c #9B9492",
-"8. c #9D9997",
-"9. c #9D9C9C",
-"0. c #A38B83",
-"q. c #AA8D83",
-"w. c #A4918B",
-"e. c #AC9087",
-"r. c #AB938C",
-"t. c #A49590",
-"y. c #A29996",
-"u. c #A19D9C",
-"i. c #AA9790",
-"p. c #AC9994",
-"a. c #AC9E99",
-"s. c #B18D81",
-"d. c #B59084",
-"f. c #B49389",
-"g. c #BA9184",
-"h. c #B89589",
-"j. c #BA988D",
-"k. c #B29B93",
-"l. c #BC9C92",
-"z. c #ACA19D",
-"x. c #B1A19D",
-"c. c #BCA39B",
-"v. c #A3A3A3",
-"b. c #ABA5A3",
-"n. c #AEA9A7",
-"m. c #ABABAA",
-"M. c #B3A5A1",
-"N. c #B3A9A6",
-"B. c #B3ADAA",
-"V. c #B9A6A0",
-"C. c #B9AAA5",
-"Z. c #BAADA9",
-"A. c #B4B0AF",
-"S. c #BAB0AD",
-"D. c #B4B3B3",
-"F. c #BAB5B3",
-"G. c #BDB8B6",
-"H. c #BBBBBB",
-"J. c #C39384",
-"K. c #C0978A",
-"L. c #C2998B",
-"P. c #CA9483",
-"I. c #CD9A8A",
-"U. c #C19D92",
-"Y. c #D69B89",
-"T. c #DB9680",
-"R. c #C2A095",
-"E. c #C4A69C",
-"W. c #CCA193",
-"Q. c #C8A599",
-"!. c #CBA99D",
-"~. c #C6AEA6",
-"^. c #CCACA2",
-"/. c #CBB2AB",
-"(. c #C3B8B5",
-"). c #C2BDBC",
-"_. c #C9B9B3",
-"`. c #D3ADA0",
-"'. c #D3B4A9",
-"]. c #DCB2A4",
-"[. c #DEB6A8",
-"{. c #D1BFB9",
-"}. c #D9BEB5",
-"|. c #C5C0BE",
-" X c #CDC0BC",
-".X c #D2C1BB",
-"XX c #DDC3BB",
-"oX c #E0C5BC",
-"OX c #E0C8BF",
-"+X c #C2C2C2",
-"@X c #CBC4C2",
-"#X c #CDC8C6",
-"$X c #CCCBCB",
-"%X c #D2C6C2",
-"&X c #D1CECD",
-"*X c #DDC8C1",
-"=X c #DECFCA",
-"-X c #D9D1CE",
-";X c #D3D3D3",
-":X c #D9D5D4",
-">X c #DED9D7",
-",X c #DBDBDB",
-"<X c #E1CAC3",
-"1X c #E2CFC8",
-"2X c #E1D3CE",
-"3X c #E2D5D0",
-"4X c #E5D8D3",
-"5X c #E4DDDB",
-"6X c #E8DBD6",
-"7X c #EADEDA",
-"8X c #E6E0DE",
-"9X c #EBE0DC",
-"0X c #E4E4E4",
-"qX c #E8E2E0",
-"wX c #EBEBEB",
-"eX c #F0EAE8",
-"rX c #F3F3F3",
-"tX c #FEFEFE",
-/* pixels */
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXrXrXtXrXrXrXrXrXrXrXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXrXtXrXrXrXwXwXrXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXrXrXrXwXwX0X0XqX0X0X0X0XwXwXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXrXtXrXwXwX2X[.[.].].].].].1XwXrXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXrXrXrXwX0X0XL.J b b b b b b b J '.0X0XwXwXrXrXrXrXrXrXrXrXrXrXtXrXrXrXtXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXrXrXwX0XXXt m b m B V N b b v >.;X0XwXwXwXwXrXwXwXrXrXrXrXtXrXtXrXrXrXwXrXrXrXrXrXrXrXrXrXrXrXwXrXrXwXrXrXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXrXrXrX0X,X'.S b b P l.z.M.k.w n b b g.;X,X,X,X0X0X0X0X0XwXwXwXwXwXwXwXwXwX0X0X0XwX0X0XwXwXwXwX0X0X0X0X0X0XwXwXwXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrXrXrXwX0X:XT.m b A ] G.D.D.m.$.m b b $.$X&X.X}.XX>XOX}.oXXX<X0X0XwXwXwX0X2XXXoXXXoXOX5X0XwX0X1XoXXX5X*X}.}.oX<XqXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrXrXwX0X,XL.b b D M.H.D.D.D.D.m.L b b W H.Z.# b Y / m b b b Z P.:X:X:X$X:.Z b b b b n :.;X;X;XR b A &.Z b b b b *.wXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXrXwX0X:X$.b b E B.H.H.D.D.D.D.P b b E H.V.. b U L v v n b b ( #X;X$X~.Y b m N m b b ! {.&X#XI b C R v v n b b ! 0XwXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrXwX0X:X!.A b Z F.H.H.H.H.H.D.m.L b b e b.+.b b V k i.r.t n b b s.H.x v b L q.b.p.D b b t F.$.n b M l a.M.y b b A :X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrXwX0X:XL.m b D H.).H.+XH.H.H.D.H b b 6 v.j b b - a.A.m. at .m b b h D.< b b w z.b.b.P b b q B.z b b @ B.D.m...v b G :X,XwXwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXwX0X,X&X/ b b , D.H.+X+X+X+XH.f.B b b 5.8.M b M w.v.v.v.r.D b b h l v b b M     V v b b q u.X b n @.v.m.v.j b b Q &X,X0XwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXwX0X,X$X^ b b , H.H.+X+XH.H.H.s.N b n 7.7.v b B 8.v.v.v.w.M b b g r b b b n n n b b b b e y.O b n X.m.v.n.e b b u &X,X0XrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrX0X,X$X/ b b + F.H.H.H.+XH.d.b b M | 8.> c b @ 9.v.9.u., b b - 3.& b b 7 1.1.4.4.4.6.7.9.w.m b + t.v.m.p.D b b K.;X,X0XwXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXwX0X,X$X-.b b b i D.H.G.H.J.N b b = 9.9.5 c b B 7.9.v.y.b b m f 4.O b b 3 6.6.6.g 9 4 h u.h b b - b.m.m.s.b b N ~.;X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXwX0X,X;XE.G b b I z ] ] ] W n b H l 9.8.9 b b m e 6 r e b b # 0.y.< b b O 6 p 6 < # ; q.v.t b b 0 n.A.A.+.b b H _.;X,XwXwXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXwXwX,X;X#Xf.b b b b b b b b b - a.v.v.w.@ b b v b b b b b @ b.m.v.w.M b b b b b b v ..m.n.A b n g.H.H.H.4 b b [ &X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXwXwX0X:X$XZ.Q H v n b m B H E x n.m.m.q.B b v < . v N + E z m.m.m.b.e - M m v M - t k.D.m.; # - V.H.+XH.s # # K.:X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrXwXwX,X,X$X+XG.Z.Z.B.C.S.F.H.H.H.D.D.j b b q v.b.a.n.B.H.H.+X+X+XH.H.D.Z.C.Z.Z.F.H.H.+X+XH.).H.$X&X&X;X$X#X#X:X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrXrXwX0X,X;X#X+X+X+XH.H.+X+X+XH.H.H.D.e b n i n.m.D.H.H.+X#X$X$X+X+X+X+XH.H.H.H.+X+X+X$X&X&X&X$X;X;X;X:X;X:X,X,X0XwXwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXrXrXwXwX,X,X;X;X$X$X$X;X;X&X;X$X#X+XF b v s.H.H.+X$X&X;X;X,X,X,X;X:X;X;X;X;X;X;X:X,X,X,X0X,X0X,X0X0X0X0X0X0X0XwXwXrXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXrXtXrXwXwX0X,X:X;X;X;X;X;X:X;X;X;X$X+XC b B k.+X+X$X$X;X,X,X0X0X0X0X0X;X,X,X,X,X,X,X,X,X0X0X0X0X0X0XwX0X0X0XwXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXrXrXrXrXwXwXwX0X0X0X0X0X0X0X,X,X:X^.^.!.$X$X;X,X,X0XwXwXwXwXwXwXwXwX0X0X0X0XwXwXwXwXwXwXrXrXwXrXrXrXrXrXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXrXrXrXrXwXwXwXwX0XwXwXwX0X0X,X:X;X$X&X&X;X,X,X0XwXwXwXrXrXrXrXrXwXwXwXwXwXwXwXrXrXrXwXrXrXrXrXrXrXrXrXrXrXtXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXrXwXwXwXwX0X,X0X0X0XwXwXrXrXrXrXrXrXrXrXrXrXrXrXrXrXwXrXrXrXrXrXtXrXrXrXtXrXrXrXrXrXrXrXrXrXtXtXtXrXrXtXtXtXtXrXrXtXrXrXtXrXtXrXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXrXtXtXrXtXrXrXrXrXrXrXwXwXwX0XwX0XwXwXwXrXrXrXtXtXrXrXrXrXrXrXrXrXwXrXwXrXwXwXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXtXrXrXtXtXrXrXrXrXrXrXrXrXrXrXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXwXrXrXrXrXrXrXtXrXtXrXrXrXrXrXwXwXwXwXwX0X0XwX0XwXwXwXwXwXwXwXrXwXwXwX0X0X0X0XwX0XwXwXrXrXrXwXrXwXwXwX0XwX0XwXwXwXrXrXrXrXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXtXtXrXrXtXrXrXeX7X7X9XwXwXwX5X3X3X3X2X2X2X5X0XwXwXwXwXwX8X3X3X2X2X2X2X2X3X6X6X7XwXwXwXwXwXwX7X1XXXOXOX1X8XwXwXrXrXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXtXtXrXrXrXwXT.T T :.,X,X-X` G G G G G G U _ J.-X,X,X,X[ G G G G G G G G G G _ >XwX0X,X&XI.R N b b b m ! `.5XwXrXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXtXtXrXtXrXrXrXwX0X' b b ] >X,X%XJ b b b b b b b b Q {.:X;X:Xq b b b b b b b b b b Y >X0X,X-X'.^ n b b b b b m *.1XwXwXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrX0X0X%XL b b L. at X+X-.b b M L L L D b b b M V.+X(.N b b D H H H H H U U W.;X&X^.H b b n W -.-.W n b b J &XwXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX0X XF b b U.+X+X[ b b D z z j P v b b N U.H.S.m b m E Q t ^ ) / ) ) /.$X$X;.m b n A %.H.H.J.N b b N .XwXwXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX,X:X!.m b L N.D.m.* b b y v.v.v.v.p.n b M f.m.w b b D u.v.m.m.D.G.H.H.+X).g.b b B j.F.D.D.D.D.l.; F I /.0XwXrXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwX,X:XU.n b E B.A.n.$ b b s v.9.v.v.r.n n M r.b.1 b b D u.v.m.m.D.D.H.H.).H.k b b # M.G.D.D.D.D.Z.t w u _.0XwXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX,X;X$XJ b m h b.v.i.m b M a 5.5.2.p M b c < 8.2.+ b b M o o o o # % j G.H.g.m b A M.D.D.D.B.M.M.M.M.Z.(.:X0XwXrXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXwX,X,X&X(.n b M 0.v.v.s b b b b b n b b c b M u.v.g M b b b b b b b b b i G.D.0 b b 8 D.D.H.G.P n b b n b U :X,XwXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXwX0X,X;X$XV.n b M w.v.9.< b b b b b b b b c H r 9.v.a n b   * < < w w Q Q g.D.B.: b b r D.D.D.m.C b b b b b ) ;X0XwXrXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrX6XP.=.K.;X#X+Xx n b D v.u.7.. b b M D . D & 2 q.b.b.v.v.< b b X 6.9.9.b.m.D.D.D.D.n.# b b f D.D.D.b.= 1 * N b n !.;X,XwXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXwX<X~ P x $X+XH.z b b - v.v.3.M b b < r r r k 0.a.m.m.m.v.# b b , 6.9.v.m.D.D.D.H.D.z.O b b s D.D.D.N.f l 9 v b M ~.;X,XwXrXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXwX0XY.n b e H.H.V.F b b p b.v.h v b v v.m.A.D.H.+X+X+XH.D.p.b b m p 9.v.m.D.D.H.H.H.D.N.- b b - m.A.D.A.m.a.B b b - (.:X0XwXrXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX0XY.n b ; Z.C.$.A b v 0.m.m.l n b M m.D.D.H.+X#X+X+XH.H.r.b b m < d l l l $.;.J.V.H.B.w b b C @.s.a.k.#.j n b b : ).:X,XwXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX0X'.N b b A B n b n z m.D.B.0 b b 9 H.H.+X$X;X:X;X$X$X+Xl b b b b b b b b b b b s.H.H.B.H b b b n Z Z b b V n b ] $X:X0XwXrXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwX0X,X.XR b b b b b A P d.D.D.C.H b b j H.$X$X;X:X,X,X;X;X+X/ b b b b b b b b b b b a.H.H.D.u G b b b b b B H : v m ;.$X,XwXwXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX,X:X Xg.j 5 y s.C.H.H.+X+X|.E.Q.Q. X;X;X,X0XwXwX0X0X,X;X/.U.j.h.g.f.h.j.U.U.U.!.$X$X+X+XH.Z.g.y 4 6 l x.D.A.l.~.#X,X0XwXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXwX0X:X$XG.k.e.f.B.H.H.+X$X$X$X#X$X$X;X;X,X0XwXwXwXwX0X0X;X$X+XH.D.D.D.F.H.+X+X#X&X$X;X$X$X+X+XA.r.X.e.a.H.H.H.+X+X;X,X0XwXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwX,X,X$X&X$X$X$X$X;X;X,X,X,X,X,X,X0XwXwXwXrXtXrXrXwXwX0X,X;X$X$X+X$X$X$X;X;X:X,X,X,X,X,X;X$X&X#X#X$X$X$X$X$X;X,X,X0XwXrXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX0X,X:X;X;X$X;X;X:X,X,X0X0X,X0X0X0XwXwXwXrXrXtXrXrXwXwX0X;X;X$X&X$X$X&X:X,X,X,X,X0X,X,X:X;X;X$X$X$X$X$X;X:X,X,X0XwXwXrXrXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXwXwXwX0X0X0X0X0X0XwXwXwXwXwXwXwXwXrXwXrXtXtXrXtXtXrXrXrXwX0X0X0X0X,X,X0X0X0X0XwXwXwXwXwXwX0X0X0X,X,X,X,X0X0XwXwXwXrXtXrXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXwXwX0X0X0X0X0XwXwXwXrXwXrXrXrXrXrXtXrXtXtXtXtXrXrXrXwXwXwX0X0X0X0X0X0X0XwXwXwXwXwXwXwXwXwX0X0X0X0XwXwXwXwXwXrXrXrXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXrXrXrXrXrXrXrXrXtXtXrXtXtXrXtXtXtXtXtXtXtXrXtXrXtXrXrXrXrXwXwXrXrXrXrXrXrXrXtXrXrXrXrXrXrXrXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXrXrXrXrXtXtXrXtXrXtXrXrXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXrXrXrXtXtXrXtXrXrXtXrXrXrXrXrXrXrXrXtXrXrXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
-"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX"
-};
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/readmeafter.txt b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/readmeafter.txt
deleted file mode 100644
index d5e8fb9..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/readmeafter.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-This viewer is conceived to open and display information and image content of J2K, JP2,
-and MJ2 files.
-The viewer application interface is divided into three main panels:
-- a browsing pane;
-- a viewing pane;
-- a log/peek pane.
-
-The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
-
-filename
-|
-|_ #000: Marker/Box short name (Hex code)
-|  |
-|  |_ *** Marker/Box long name ***
-|  |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
-|  |_ Additional info, depending on the marker/box type
-|  |_ ...
-|
-|_ #001: Marker/Box short name (Hex code)
-|  |
-|  |_ ...
-|
-...
-
-
-The viewing pane will display the decoded image contained in the JPEG 2000 file.
-It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
-
-
-The log/peek pane is shared among two different subpanels:
-
-- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
-- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section. 
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/readmebefore.txt b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/readmebefore.txt
deleted file mode 100644
index c5e1ed8..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/readmebefore.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-What is OpenJPEG ?
-==================
-The OpenJPEG library is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, the new still-image compression standard from the Joint Photographic Experts Group (JPEG). In addition to the basic codec, various other features are under development, among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool useful for the JPIP protocol, JPWL-tools for error-resilience, a Java-viewer for j2k-images, ... 
-
-Who can use the library ?
-=========================
-Anybody. As the OpenJPEG library is released under the BSD license, anybody can use or modify the library, even for commercial applications. The only restriction is to retain the copyright in the sources or the binaries documentation.
-
-Who is developing the library ?
-===============================
-The library is developed by the Communications and Remote Sensing Lab (TELE), in the Universit� Catholique de Louvain (UCL). The JPWL module is developped and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly. 
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/wxj2kparser.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/wxj2kparser.cpp
deleted file mode 100644
index 600fd65..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/wxj2kparser.cpp
+++ /dev/null
@@ -1,1465 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "OPJViewer.h"
-
-/* From little endian to big endian, 2 bytes */
-#define	BYTE_SWAP2(X)	((X & 0x00FF) << 8) | ((X & 0xFF00) >> 8)
-#define	BYTE_SWAP4(X)	((X & 0x000000FF) << 24) | ((X & 0x0000FF00) << 8) | ((X & 0x00FF0000) >> 8) | ((X & 0xFF000000) >> 24)
-
-/* From codestream to int values */
-#define STREAM_TO_UINT32(C, P)	(((unsigned long int) (C)[(P) + 0] << 24) + \
-								((unsigned long int) (C)[(P) + 1] << 16) + \
-								((unsigned long int) (C)[(P) + 2] << 8) + \
-								((unsigned long int) (C)[(P) + 3] << 0))
-
-#define STREAM_TO_UINT16(C, P)	(((unsigned long int) (C)[(P) + 0] << 8) + \
-								((unsigned long int) (C)[(P) + 1] << 0))
-
-
-/* Markers values */
-#define J2KMARK_NUM 24
-enum {
-	SOC_VAL = 0xFF4F,
-	SOT_VAL	= 0xFF90,
-	SOD_VAL = 0xFF93,
-	EOC_VAL	= 0xFFD9,
-	SIZ_VAL	= 0xFF51,
-	COD_VAL	= 0xFF52,
-	COC_VAL = 0xFF53,
-	RGN_VAL = 0xFF5E,
-	QCD_VAL	= 0xFF5C,
-	QCC_VAL	= 0xFF5D,
-	POD_VAL	= 0xFF5F,
-	TLM_VAL	= 0xFF55,
-	PLM_VAL	= 0xFF57,
-	PLT_VAL	= 0xFF58,
-	PPM_VAL	= 0xFF60,
-	PPT_VAL	= 0xFF61,
-	SOP_VAL	= 0xFF91,
-	EPH_VAL	= 0xFF92,
-	COM_VAL	= 0xFF64
-#ifdef USE_JPWL
-	, EPB_VAL	= 0xFF66,
-	ESD_VAL	= 0xFF67,
-	EPC_VAL	= 0xFF68,
-	RED_VAL	= 0xFF69
-	/*, EPB_VAL = 0xFF96,
-	ESD_VAL	= 0xFF98,
-	EPC_VAL	= 0xFF97,
-	RED_VAL	= 0xFF99*/
-#endif // USE_JPWL
-#ifdef USE_JPSEC
-	, SEC_VAL = 0xFF65
-#endif // USE_JPSEC
-};
-
-// All the markers in one vector
-unsigned short int marker_val[] = {
-	SOC_VAL, SOT_VAL, SOD_VAL, EOC_VAL,
-	SIZ_VAL,
-	COD_VAL, COC_VAL, RGN_VAL, QCD_VAL, QCC_VAL, POD_VAL,
-	TLM_VAL, PLM_VAL, PLT_VAL, PPM_VAL, PPT_VAL,
-	SOP_VAL, EPH_VAL,
-	COM_VAL
-#ifdef USE_JPWL
-	, EPB_VAL, ESD_VAL, EPC_VAL, RED_VAL
-#endif // USE_JPWL
-#ifdef USE_JPSEC
-	, SEC_VAL
-#endif // USE_JPSEC
-};
-
-// Marker names
-char *marker_name[] = {
-	"SOC", "SOT", "SOD", "EOC",
-	"SIZ",
-	"COD", "COC", "RGN", "QCD", "QCC", "POD",
-	"TLM", "PLM", "PLT", "PPM", "PPT",
-	"SOP", "EPH",
-	"COM"
-#ifdef USE_JPWL
-	, "EPB", "ESD", "EPC", "RED"
-#endif // USE_JPWL
-#ifdef USE_JPSEC
-	, "SEC"
-#endif // USE_JPSEC
-};
-
-// Marker descriptions
-char *marker_descr[] = {
-	"Start of codestream", "Start of tile-part", "Start of data", "End of codestream",
-	"Image and tile size",
-	"Coding style default", "Coding style component", "Region-of-interest", "Quantization default",
-	"Quantization component", "Progression order change, default",
-	"Tile-part lengths, main header", "Packet length, main header", "Packets length, tile-part header",
-	"Packed packet headers, main header", "Packed packet headers, tile-part header",
-	"Start of packet", "End of packet header",
-	"Comment and extension"
-#ifdef USE_JPWL
-	, "Error Protection Block", "Error Sensitivity Descriptor", "Error Protection Capability",
-	"Residual Errors Descriptor"
-#endif // USE_JPWL
-#ifdef USE_JPSEC
-	, "Main security marker"
-#endif // USE_JPSEC
-};
-
-void OPJParseThread::ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid)
-{
-	unsigned short int csiz = 0;
-
-	// check if the file is opened
-	if (m_file->IsOpened())
-		WriteText(wxT("File OK"));
-	else
-		return;
-
-	// position at the beginning
-	m_file->Seek(offset, wxFromStart);
-
-	// navigate the file
-	int m, inside_sod = 0, inside_sop = 0;
-	int nmarks = 0, maxmarks = 10000;
-	unsigned char onebyte[1];
-	unsigned char twobytes[2], firstbyte, secondbyte;
-	unsigned char fourbytes[4];
-	unsigned short int currmark;
-	unsigned short int currlen;
-	int lastPsot = 0, lastsotpos = 0;
-
-	WriteText(wxT("Start search..."));
-
-// advancing macro
-#define OPJ_ADVANCE(A) {offset += A; if (offset < length) m_file->Seek(offset, wxFromStart); else return;}
-
-	// begin search
-	while ((offset < length) && (!m_file->Eof())) {
-
-		// read one byte
-		if (m_file->Read(&firstbyte, 1) != 1)
-			break;
-
-		// look for 0xFF
-		if (firstbyte == 0xFF) {
-
-			// it is a possible marker
-			if (m_file->Read(&secondbyte, 1) != 1)
-				break;
-			else
-				currmark = (((unsigned short int) firstbyte) << 8) + (unsigned short int) secondbyte;
-
-		} else {
-
-			// nope, advance by one and search again
-			OPJ_ADVANCE(1);
-			continue;
-		}
-		
-		// search the marker
-		for (m = 0; m < J2KMARK_NUM; m++) {
-			if (currmark == marker_val[m])
-				break;
-		}
-
-		// marker not found
-		if (m == J2KMARK_NUM) {
-			// nope, advance by one and search again
-			OPJ_ADVANCE(1);
-			continue;
-		}
-
-		// if we are inside SOD, only some markers are allowed
-		if (inside_sod) {
-
-			// we are inside SOP
-			if (inside_sop) {
-
-			}
-
-			// randomly marker coincident data
-			if ((currmark != SOT_VAL) &&
-				(currmark != EOC_VAL) &&
-				(currmark != SOP_VAL) &&
-				(currmark != EPH_VAL)) {
-				OPJ_ADVANCE(1);
-				continue;
-			}
-
-			// possible SOT?
-			if ((currmark == SOT_VAL)) {
-				// too early SOT
-				if (offset < (lastsotpos + lastPsot)) {
-					OPJ_ADVANCE(1);
-					continue;
-				}
-				// we were not in the last tile
-				/*if (lastPsot != 0) {
-					OPJ_ADVANCE(1);
-					break;
-				}*/
-			}
-		}
-
-		// beyond this point, the marker MUST BE real
-
-		// length of current marker segment
-		if ((currmark == SOD_VAL) ||
-			(currmark == SOC_VAL) ||
-			(currmark == EOC_VAL) ||
-			(currmark == EPH_VAL))
-
-			// zero length markers
-			currlen = 0;
-
-		else {
-
-			// read length field
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-
-			currlen = (((unsigned short int) twobytes[0]) << 8) + (unsigned short int) twobytes[1];
-		}
-
-		// here we pass to AppendItem() normal and selected item images (we
-		// suppose that selected image follows the normal one in the enum)
-		int image, imageSel;
-		image = m_tree->TreeCtrlIcon_Folder;
-		imageSel = image + 1;
-
-		// append the marker
-		wxTreeItemId currid = m_tree->AppendItem(parentid,
-			wxString::Format(wxT("%03d: "), nmarks) +
-			wxString::FromAscii(marker_name[m]) + 
-			wxString::Format(wxT(" (0x%04X)"), marker_val[m]),
-			image, imageSel,
-			new OPJMarkerData(wxT("MARK") + wxString::Format(wxT(" (%d)"), marker_val[m]),
-				m_tree->m_fname.GetFullPath(), offset, offset + currlen + 1)
-			);
-
-		// append some info
-		image = m_tree->TreeCtrlIcon_File;
-		imageSel = image + 1;
-
-		// marker name
-		wxTreeItemId subcurrid1 = m_tree->AppendItem(currid,
-			wxT("*** ") + wxString::FromAscii(marker_descr[m]) + wxT(" ***"),
-			image, imageSel,
-			new OPJMarkerData(wxT("INFO"))
-			);
-		m_tree->SetItemFont(subcurrid1, *wxITALIC_FONT);
-
-		// position and length
-		wxTreeItemId subcurrid2 = m_tree->AppendItem(currid,
-			wxLongLong(offset).ToString() + wxT(" > ") + wxLongLong(offset + currlen + 1).ToString() + 
-			wxT(", ") + wxString::Format(wxT("%d + 2 (%d)"), currlen, currlen + 2),
-			image, imageSel,
-			new OPJMarkerData(wxT("INFO"))
-			);
-
-		// give additional info on markers
-		switch (currmark) {
-
-		/////////
-		// SOP //
-		/////////
-		case SOP_VAL:
-			{
-			// read packet number
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-			int packnum = STREAM_TO_UINT16(twobytes, 0);
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				wxString::Format(wxT("Pack. no. %d"), packnum),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			inside_sop = 1;
-			};
-			break;
-
-#ifdef USE_JPWL
-		/////////
-		// RED //
-		/////////
-		case RED_VAL:
-			{
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char pred = onebyte[0];
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			wxString address[] = {
-				wxT("Packet addressing"),
-				wxT("Byte-range addressing"),
-				wxT("Packet-range addressing"),
-				wxT("Reserved")
-			};
-
-			wxTreeItemId subcurrid = m_tree->AppendItem(currid,
-				address[(pred & 0xC0) >> 6],
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("%d bytes range"), (((pred & 0x02) >> 1) + 1) * 2),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				pred & 0x01 ? wxT("Errors/erasures in codestream") : wxT("Error free codestream"),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("Residual corruption level: %d"), (pred & 0x38) >> 3),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			}
-			break;
-
-		/////////
-		// ESD //
-		/////////
-		case ESD_VAL:
-			{
-			unsigned short int cesd;
-			if (csiz < 257) {
-				if (m_file->Read(onebyte, 1) != 1)
-					break;
-				cesd = onebyte[0];
-			} else {
-				if (m_file->Read(twobytes, 2) != 2)
-					break;
-				cesd = STREAM_TO_UINT16(twobytes, 0);
-			}
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char pesd = onebyte[0];
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			wxTreeItemId subcurrid = m_tree->AppendItem(currid,
-				pesd & 0x01 ? wxT("Comp. average") : wxString::Format(wxT("Comp. no. %d"), cesd),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			wxString meth[] = {
-				wxT("Relative error sensitivity"),
-				wxT("MSE"),
-				wxT("MSE reduction"),
-				wxT("PSNR"),
-				wxT("PSNR increase"),
-				wxT("MAXERR (absolute peak error)"),
-				wxT("TSE (total squared error)"),
-				wxT("Reserved")
-			};
-
-			subcurrid = m_tree->AppendItem(currid,
-				meth[(pesd & 0x38) >> 3],
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			wxString address[] = {
-				wxT("Packet addressing"),
-				wxT("Byte-range addressing"),
-				wxT("Packet-range addressing"),
-				wxT("Reserved")
-			};
-
-			subcurrid = m_tree->AppendItem(currid,
-				address[(pesd & 0xC0) >> 6],
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("%d bytes/value, %d bytes range"), ((pesd & 0x04) >> 2) + 1, (((pesd & 0x02) >> 1) + 1) * 2),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			}
-			break;
-
-		/////////
-		// EPC //
-		/////////
-		case EPC_VAL:
-			{
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-			unsigned short int pcrc = STREAM_TO_UINT16(twobytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int dl = STREAM_TO_UINT32(fourbytes, 0);
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char pepc = onebyte[0];
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			wxTreeItemId subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("CRC-16 = 0x%x"), pcrc),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("Tot. length = %d"), dl),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("%s%s%s%s"),
-					pepc & 0x10 ? wxT("ESD, ") : wxT(""),
-					pepc & 0x20 ? wxT("RED, ") : wxT(""),
-					pepc & 0x40 ? wxT("EPB, ") : wxT(""),
-					pepc & 0x80 ? wxT("Info") : wxT("")
-					),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			}
-			break;
-
-		/////////
-		// EPB //
-		/////////
-		case EPB_VAL:
-			{
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char depb = onebyte[0];
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int ldpepb = STREAM_TO_UINT32(fourbytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int pepb = STREAM_TO_UINT32(fourbytes, 0);
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			wxTreeItemId subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("No. %d, %slatest, %spacked"),
-					depb & 0x3F,
-					depb & 0x40 ? wxT("") : wxT("not "),
-					depb & 0x80 ? wxT("") : wxT("un")),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("%d bytes protected"), ldpepb),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (pepb == 0x00000000)
-
-				subcurrid = m_tree->AppendItem(currid,
-					wxT("Predefined codes"),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			else if ((pepb >= 0x10000000) && (pepb <= 0x1FFFFFFF)) {
-
-				wxString text = wxT("CRC code");
-				if (pepb == 0x10000000)
-					text << wxT(", CCITT (X25) 16 bits");
-				else if (pepb == 0x10000001)
-					text << wxT(", Ethernet 32 bits");
-				else
-					text << wxT(", JPWL RA");
-				subcurrid = m_tree->AppendItem(currid,
-					text,
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			} else if ((pepb >= 0x20000000) && (pepb <= 0x2FFFFFFF)) {
-
-				wxString text;
-				subcurrid = m_tree->AppendItem(currid,
-					wxString::Format(wxT("RS code, RS(%d, %d)"),
-						(pepb & 0x0000FF00) >> 8,
-						(pepb & 0x000000FF)),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			} else if ((pepb >= 0x30000000) && (pepb <= 0x3FFFFFFE))
-
-				subcurrid = m_tree->AppendItem(currid,
-					wxT("JPWL RA"),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			else if (pepb == 0xFFFFFFFF)
-
-				subcurrid = m_tree->AppendItem(currid,
-					wxT("No method"),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			}
-			break;
-#endif // USE_JPWL
-
-#ifdef USE_JPSEC
-		case SEC_VAL:
-			{
-
-			}
-			break;
-#endif // USE_JPSEC
-
-		/////////
-		// SIZ //
-		/////////
-		case SIZ_VAL:
-			{
-			int c;
-			
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-			unsigned short int rsiz = STREAM_TO_UINT16(twobytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int xsiz = STREAM_TO_UINT32(fourbytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int ysiz = STREAM_TO_UINT32(fourbytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int xosiz = STREAM_TO_UINT32(fourbytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int yosiz = STREAM_TO_UINT32(fourbytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int xtsiz = STREAM_TO_UINT32(fourbytes, 0);
-			this->m_tree->m_childframe->m_twidth = xtsiz;
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int ytsiz = STREAM_TO_UINT32(fourbytes, 0);
-			this->m_tree->m_childframe->m_theight = ytsiz;
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int xtosiz = STREAM_TO_UINT32(fourbytes, 0);
-			this->m_tree->m_childframe->m_tx = xtosiz;
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int ytosiz = STREAM_TO_UINT32(fourbytes, 0);
-			this->m_tree->m_childframe->m_ty = ytosiz;
-
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-			csiz = STREAM_TO_UINT16(twobytes, 0);
-
-			bool equaldepth = true, equalsize = true;
-			unsigned char *ssiz  = new unsigned char(csiz);
-			unsigned char *xrsiz = new unsigned char(csiz);
-			unsigned char *yrsiz = new unsigned char(csiz);
-
-			for (c = 0; c < csiz; c++) {
-
-				if (m_file->Read(&ssiz[c], 1) != 1)
-					break;
-
-				if (c > 0)
-					equaldepth = equaldepth && (ssiz[c] == ssiz[c - 1]);
-
-				if (m_file->Read(&xrsiz[c], 1) != 1)
-					break;
-
-				if (m_file->Read(&yrsiz[c], 1) != 1)
-					break;
-
-				if (c > 0)
-					equalsize = equalsize && (xrsiz[c] == xrsiz[c - 1]) && (yrsiz[c] == yrsiz[c - 1]) ;
-
-			}
-
-			if (equaldepth && equalsize)
-				wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-					wxString::Format(wxT("I: %dx%d (%d, %d), %d c., %d%s bpp"),
-					xsiz, ysiz,
-					xosiz, yosiz,
-					csiz, ((ssiz[0] & 0x7F) + 1),
-					(ssiz[0] & 0x80) ? wxT("s") : wxT("u")),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-			else
-				wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-					wxString::Format(wxT("I: %dx%d (%d, %d), %d c."),
-					xsiz, ysiz,
-					xosiz, yosiz,
-					csiz),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				wxString::Format(wxT("T: %dx%d (%d, %d)"),
-				xtsiz, ytsiz,
-				xtosiz, ytosiz),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			image = m_tree->TreeCtrlIcon_Folder;
-			imageSel = image + 1;
-
-			wxTreeItemId subcurrid4 = m_tree->AppendItem(currid,
-				wxT("Components"),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			for (c = 0; c < csiz; c++) {
-
-				wxTreeItemId subcurrid5 = m_tree->AppendItem(subcurrid4,
-					wxString::Format(wxT("#%d: %dx%d, %d%s bpp"),
-					c,
-					xsiz/xrsiz[c], ysiz/yrsiz[c],
-					((ssiz[c] & 0x7F) + 1),
-					(ssiz[c] & 0x80) ? wxT("s") : wxT("u")),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			}
-
-			};
-			break;
-
-		/////////
-		// SOT //
-		/////////
-		case SOT_VAL:
-			{
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-			unsigned short int isot = STREAM_TO_UINT16(twobytes, 0);
-
-			if (m_file->Read(fourbytes, 4) != 4)
-				break;
-			unsigned long int psot = STREAM_TO_UINT32(fourbytes, 0);
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char tpsot = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char tnsot = onebyte[0];
-
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				wxString::Format(wxT("tile %d, psot = %d, part %d of %d"), isot, psot, tpsot, tnsot),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			lastPsot = psot;
-			lastsotpos = offset;
-			inside_sod = 0;
-			};
-			break;
-
-		/////////
-		// COC //
-		/////////
-		case COC_VAL:
-			{
-			unsigned short int ccoc;
-			if (csiz < 257) {
-				if (m_file->Read(onebyte, 1) != 1)
-					break;
-				ccoc = onebyte[0];
-			} else {
-				if (m_file->Read(twobytes, 2) != 2)
-					break;
-				ccoc = STREAM_TO_UINT16(twobytes, 0);
-			}
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char scoc = onebyte[0];
-
-			wxTreeItemId subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("Comp. no. %d"), ccoc),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			
-			wxString text;
-			if (scoc & 0x01)
-				text << wxT("Partitioned entropy coder");
-			else
-				text << wxT("Unpartitioned entropy coder");
-
-			subcurrid = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char decomplevs = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char cbswidth = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char cbsheight = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char cbstyle = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char transform = onebyte[0];
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("%d levels (%d resolutions)"), decomplevs, decomplevs + 1),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (transform & 0x01)
-				text = wxT("5-3 reversible wavelet");
-			else
-				text = wxT("9-7 irreversible wavelet");
-			subcurrid = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("Code-blocks: %dx%d"), 1 << ((cbswidth & 0x0F) + 2), 1 << ((cbsheight & 0x0F) + 2)),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			image = m_tree->TreeCtrlIcon_Folder;
-			imageSel = image + 1;
-
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				wxT("Coding styles"),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			if (cbstyle & 0x01)
-				text = wxT("Selective arithmetic coding bypass");
-			else
-				text = wxT("No selective arithmetic coding bypass");
-			wxTreeItemId subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x02)
-				text = wxT("Reset context probabilities on coding pass boundaries");
-			else
-				text = wxT("No reset of context probabilities on coding pass boundaries");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x04)
-				text = wxT("Termination on each coding passs");
-			else
-				text = wxT("No termination on each coding pass");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x08)
-				text = wxT("Vertically stripe causal context");
-			else
-				text = wxT("No vertically stripe causal context");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x10)
-				text = wxT("Predictable termination");
-			else
-				text = wxT("No predictable termination");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x20)
-				text = wxT("Segmentation symbols are used");
-			else
-				text = wxT("No segmentation symbols are used");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			}
-			break;
-
-		/////////
-		// COD //
-		/////////
-		case COD_VAL:
-			{
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char scod = onebyte[0];
-
-			wxString text;
-
-			if (scod & 0x01)
-				text << wxT("Partitioned entropy coder");
-			else
-				text << wxT("Unpartitioned entropy coder");
-
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			text = wxT("");
-			if (scod & 0x02)
-				text << wxT("Possible SOPs");
-			else
-				text << wxT("No SOPs");
-
-			if (scod & 0x04)
-				text << wxT(", possible EPHs");
-			else
-				text << wxT(", no EPHs");
-
-			subcurrid3 = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char progord = onebyte[0];
-
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-			unsigned short int numlayers = STREAM_TO_UINT16(twobytes, 0);
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char mctransform = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char decomplevs = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char cbswidth = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char cbsheight = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char cbstyle = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char transform = onebyte[0];
-
-			subcurrid3 = m_tree->AppendItem(currid,
-				wxString::Format(wxT("%d levels (%d resolutions)"), decomplevs, decomplevs + 1),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			text = wxT("");
-			switch (progord) {
-			case (0):
-				text << wxT("LRCP");
-				break;
-			case (1):
-				text << wxT("RLCP");
-				break;
-			case (2):
-				text << wxT("LRCP");
-				break;
-			case (3):
-				text << wxT("RPCL");
-				break;
-			case (4):
-				text << wxT("CPRL");
-				break;
-			default:
-				text << wxT("unknown progression");
-				break;
-			}
-			text << wxString::Format(wxT(", %d layers"), numlayers);
-			if (transform & 0x01)
-				text << wxT(", 5-3 rev.");
-			else
-				text << wxT(", 9-7 irr.");
-			subcurrid3 = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid3 = m_tree->AppendItem(currid,
-				wxString::Format(wxT("Code-blocks: %dx%d"), 1 << ((cbswidth & 0x0F) + 2), 1 << ((cbsheight & 0x0F) + 2)),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			switch (mctransform) {
-			case (0):
-				{
-				text = wxT("No MCT");
-				}
-				break;
-			case (1):
-				{
-				text = wxT("Reversible MCT on 0, 1, 2");
-				}
-				break;
-			case (2):
-				{
-				text = wxT("Irreversible MCT on 0, 1, 2");
-				}
-				break;
-			default:
-				{
-				text = wxT("Unknown");
-				}
-				break;
-			};
-			subcurrid3 = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-
-			image = m_tree->TreeCtrlIcon_Folder;
-			imageSel = image + 1;
-
-			subcurrid3 = m_tree->AppendItem(currid,
-				wxT("Coding styles"),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			if (cbstyle & 0x01)
-				text = wxT("Selective arithmetic coding bypass");
-			else
-				text = wxT("No selective arithmetic coding bypass");
-			wxTreeItemId subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x02)
-				text = wxT("Reset context probabilities on coding pass boundaries");
-			else
-				text = wxT("No reset of context probabilities on coding pass boundaries");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x04)
-				text = wxT("Termination on each coding passs");
-			else
-				text = wxT("No termination on each coding pass");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x08)
-				text = wxT("Vertically stripe causal context");
-			else
-				text = wxT("No vertically stripe causal context");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x10)
-				text = wxT("Predictable termination");
-			else
-				text = wxT("No predictable termination");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (cbstyle & 0x20)
-				text = wxT("Segmentation symbols are used");
-			else
-				text = wxT("No segmentation symbols are used");
-			subcurrid4 = m_tree->AppendItem(subcurrid3,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			};
-			break;
-
-		/////////
-		// QCC //
-		/////////
-		case QCC_VAL:
-			{
-			unsigned short int cqcc;
-			if (csiz < 257) {
-				if (m_file->Read(onebyte, 1) != 1)
-					break;
-				cqcc = onebyte[0];
-			} else {
-				if (m_file->Read(twobytes, 2) != 2)
-					break;
-				cqcc = STREAM_TO_UINT16(twobytes, 0);
-			}
-
-			wxTreeItemId subcurrid = m_tree->AppendItem(currid,
-				wxString::Format(wxT("Comp. no. %d"), cqcc),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char sqcc = onebyte[0];
-
-			wxString text;
-			switch (sqcc & 0x1F) {
-			case (0):
-				text = wxT("No quantization");
-				break;
-			case (1):
-				text = wxT("Scalar implicit");
-				break;
-			case (2):
-				text = wxT("Scalar explicit");
-				break;
-			default:
-				text = wxT("Unknown");
-				break;
-			}
-			text << wxString::Format(wxT(", %d guard bits"), (sqcc & 0xE0) >> 5);
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			}
-			break;
-
-		/////////
-		// QCD //
-		/////////
-		case QCD_VAL:
-			{
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char sqcd = onebyte[0];
-
-			wxString text;
-			switch (sqcd & 0x1F) {
-			case (0):
-				text = wxT("No quantization");
-				break;
-			case (1):
-				text = wxT("Scalar implicit");
-				break;
-			case (2):
-				text = wxT("Scalar explicit");
-				break;
-			default:
-				text = wxT("Unknown");
-				break;
-			}
-			text << wxString::Format(wxT(", %d guard bits"), (sqcd & 0xE0) >> 5);
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			};
-			break;
-
-		/////////
-		// COM //
-		/////////
-		case COM_VAL:
-			{
-			#define showlen 25
-			char comment[showlen];
-			wxString comments;
-
-			if (m_file->Read(twobytes, 2) != 2)
-				break;
-			unsigned short int rcom = STREAM_TO_UINT16(twobytes, 0);
-
-			wxString text;
-			if (rcom == 0)
-				text = wxT("Binary values");
-			else if (rcom == 1)
-				text = wxT("ISO 8859-1 (latin-1) values");
-			else if (rcom < 65535)
-				text = wxT("Reserved for registration");
-			else
-				text = wxT("Reserved for extension");
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				text,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (m_file->Read(comment, showlen) != showlen)
-				break;
-			comments = wxString::FromAscii(comment).Truncate(wxMin(showlen, currlen - 4));
-			if ((currlen - 4) > showlen)
-				comments << wxT("...");
-			subcurrid3 = m_tree->AppendItem(currid,
-				comments,
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			};
-			break;
-
-		/////////
-		// TLM //
-		/////////
-		case TLM_VAL:
-			{
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char ztlm = onebyte[0];
-
-			if (m_file->Read(onebyte, 1) != 1)
-				break;
-			unsigned char stlm = onebyte[0];
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-				wxString::Format(wxT("TLM #%d"), ztlm),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			subcurrid3 = m_tree->AppendItem(currid,
-				wxString::Format(wxT("%d bits/index, %d bits/length"),
-				8 * ((stlm & 0x30) >> 4), 16 + 16 * ((stlm & 0x40) >> 6)),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			int n, numparts;
-
-			numparts = (currlen - 2) / ( ((stlm & 0x30) >> 4) + 2 + 2 * ((stlm & 0x40) >> 6));
-
-			image = m_tree->TreeCtrlIcon_Folder;
-			imageSel = image + 1;
-
-			subcurrid3 = m_tree->AppendItem(currid,
-				wxT("Tile parts"),
-				image, imageSel,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			image = m_tree->TreeCtrlIcon_File;
-			imageSel = image + 1;
-
-			for (n = 0; n < numparts; n++) {
-
-				unsigned short int ttlm;
-				unsigned long int ptlm;
-
-				switch (((stlm & 0x30) >> 4)) {
-
-				case 0:
-					ttlm = 0;
-					break;
-
-				case 1:
-					if (m_file->Read(onebyte, 1) != 1)
-						break;
-					ttlm = onebyte[0];
-					break;
-
-				case 2:
-					if (m_file->Read(twobytes, 2) != 2)
-						break;
-					ttlm = STREAM_TO_UINT16(twobytes, 0);
-					break;
-
-				}
-
-				switch (((stlm & 0x40) >> 6)) {
-
-				case 0:
-					if (m_file->Read(twobytes, 2) != 2)
-						break;
-					ptlm = STREAM_TO_UINT16(twobytes, 0);
-					break;
-
-				case 1:
-					if (m_file->Read(fourbytes, 4) != 4)
-						break;
-					ptlm = STREAM_TO_UINT32(fourbytes, 0);
-					break;
-
-				}
-
-				wxTreeItemId subcurrid4 = m_tree->AppendItem(subcurrid3,
-					wxString::Format(wxT("Tile %d: %d bytes"), ttlm, ptlm),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			}
-
-			}
-			break;
-
-		/////////
-		// POD //
-		/////////
-		case POD_VAL:
-			{
-			int n, numchanges;
-
-			if (csiz < 257)
-				numchanges = (currlen - 2) / 7;
-			else
-				numchanges = (currlen - 2) / 9;
-
-			for (n = 0; n < numchanges; n++) {
-
-				image = m_tree->TreeCtrlIcon_Folder;
-				imageSel = image + 1;
-
-				wxTreeItemId subcurrid3 = m_tree->AppendItem(currid,
-					wxString::Format(wxT("Change #%d"), n),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-				if (m_file->Read(onebyte, 1) != 1)
-					break;
-				unsigned char rspod = onebyte[0];
-
-				unsigned short int cspod;
-				if (csiz < 257) {
-					if (m_file->Read(onebyte, 1) != 1)
-						break;
-					cspod = onebyte[0];
-				} else {
-					if (m_file->Read(twobytes, 2) != 2)
-						break;
-					cspod = STREAM_TO_UINT16(twobytes, 0);
-				}
-
-				if (m_file->Read(twobytes, 2) != 2)
-					break;
-				unsigned short int lyepod = STREAM_TO_UINT16(twobytes, 0);
-
-				if (m_file->Read(onebyte, 1) != 1)
-					break;
-				unsigned char repod = onebyte[0];
-
-				unsigned short int cepod;
-				if (csiz < 257) {
-					if (m_file->Read(onebyte, 1) != 1)
-						break;
-					cepod = onebyte[0];
-				} else {
-					if (m_file->Read(twobytes, 2) != 2)
-						break;
-					cepod = STREAM_TO_UINT16(twobytes, 0);
-				}
-
-				if (m_file->Read(onebyte, 1) != 1)
-					break;
-				unsigned char ppod = onebyte[0];
-
-				image = m_tree->TreeCtrlIcon_File;
-				imageSel = image + 1;
-
-				wxTreeItemId subcurrid4 = m_tree->AppendItem(subcurrid3,
-					wxString::Format(wxT("%d <= Resolution < %d"), rspod, repod),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-				subcurrid4 = m_tree->AppendItem(subcurrid3,
-					wxString::Format(wxT("%d <= Component < %d"), cspod, cepod),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-				subcurrid4 = m_tree->AppendItem(subcurrid3,
-					wxString::Format(wxT("0 <= Layer < %d"), lyepod),
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-				wxString text = wxT("");
-				switch (ppod) {
-				case (0):
-					text << wxT("LRCP");
-					break;
-				case (1):
-					text << wxT("RLCP");
-					break;
-				case (2):
-					text << wxT("LRCP");
-					break;
-				case (3):
-					text << wxT("RPCL");
-					break;
-				case (4):
-					text << wxT("CPRL");
-					break;
-				default:
-					text << wxT("unknown progression");
-					break;
-				}
-				subcurrid4 = m_tree->AppendItem(subcurrid3,
-					text,
-					image, imageSel,
-					new OPJMarkerData(wxT("INFO"))
-					);
-			}
-
-			}
-			break;
-
-		/////////
-		// SOD //
-		/////////
-		case SOD_VAL:
-			{
-			inside_sod = 1;
-			};
-			break;
-
-		default:
-			break;
-			
-		}
-								
-		// increment number of markers
-		if (nmarks++ >= maxmarks) {
-			WriteText(wxT("Maximum amount of markers exceeded"));
-			break;
-		}
-
-		// advance position
-		OPJ_ADVANCE(currlen + 2);
-	}	
-
-	WriteText(wxT("Search finished"));
-}
diff --git a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/wxjp2parser.cpp b/Utilities/gdcmopenjpeg-v1/OPJViewer/source/wxjp2parser.cpp
deleted file mode 100644
index 6e89390..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJViewer/source/wxjp2parser.cpp
+++ /dev/null
@@ -1,1116 +0,0 @@
-/*
- * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "OPJViewer.h"
-
-/* defines */
-#define SHORT_DESCR_LEN        32
-#define LONG_DESCR_LEN         256
-
-/* enumeration for file formats */
-#define J2FILENUM              4
-typedef enum {
-
-        JP2_FILE,
-        J2K_FILE,
-		MJ2_FILE,
-		UNK_FILE
-
-} j2filetype;
-
-/* enumeration for the box types */
-#define j22boxNUM                23
-typedef enum {
-
-			FILE_BOX,
-			JP_BOX,
-			FTYP_BOX,
-			JP2H_BOX,
-			IHDR_BOX,
-			COLR_BOX,
-			JP2C_BOX,
-			JP2I_BOX,
-			XML_BOX,
-			UUID_BOX,
-			UINF_BOX,
-			MOOV_BOX,
-			MVHD_BOX,
-			TRAK_BOX,
-			TKHD_BOX,
-			MDIA_BOX,
-			MDHD_BOX,
-			HDLR_BOX,
-			MINF_BOX,
-			VMHD_BOX,
-			STBL_BOX,
-			STSD_BOX,
-			STSZ_BOX,
-			MJP2_BOX,
-			MDAT_BOX,
-			ANY_BOX,
-			UNK_BOX
-
-} j22boxtype;
-
-/* the box structure itself */
-struct boxdef {
-
-        char                  value[5];                 /* hexadecimal value/string*/
-		char                  name[SHORT_DESCR_LEN];    /* short description       */
-		char                  descr[LONG_DESCR_LEN];    /* long  description       */
-		int                   sbox;                     /* is it a superbox?       */
-		int                   req[J2FILENUM];           /* mandatory box           */
-		j22boxtype             ins;                      /* contained in box...     */
-
-};
-
-
-/* jp2 family box signatures */
-#define FILE_SIGN           ""
-#define JP_SIGN             "jP\040\040"
-#define FTYP_SIGN           "ftyp"
-#define JP2H_SIGN           "jp2h"
-#define IHDR_SIGN           "ihdr"
-#define COLR_SIGN           "colr"
-#define JP2C_SIGN           "jp2c"
-#define JP2I_SIGN           "jp2i"
-#define XML_SIGN            "xml\040"
-#define UUID_SIGN           "uuid"
-#define UINF_SIGN           "uinf"
-#define MOOV_SIGN           "moov"
-#define MVHD_SIGN           "mvhd"
-#define TRAK_SIGN           "trak"
-#define TKHD_SIGN           "tkhd"
-#define MDIA_SIGN           "mdia"
-#define MDHD_SIGN           "mdhd"
-#define HDLR_SIGN           "hdlr"
-#define MINF_SIGN           "minf"
-#define VMHD_SIGN           "vmhd"
-#define STBL_SIGN           "stbl"
-#define STSD_SIGN           "stsd"
-#define STSZ_SIGN           "stsz"
-#define MJP2_SIGN           "mjp2"
-#define MDAT_SIGN           "mdat"
-#define ANY_SIGN 			""
-#define UNK_SIGN            ""
-
-/* the possible boxes */
-struct boxdef j22box[] =
-{
-/* sign */	{FILE_SIGN,
-/* short */	"placeholder for nothing",
-/* long */	"Nothing to say",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{JP_SIGN,
-/* short */	"JPEG 2000 Signature box",
-/* long */	"This box uniquely identifies the file as being part of the JPEG 2000 family of files",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{FTYP_SIGN,
-/* short */	"File Type box",
-/* long */	"This box specifies file type, version and compatibility information, including specifying if this file "
-			"is a conforming JP2 file or if it can be read by a conforming JP2 reader",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{JP2H_SIGN,
-/* short */	"JP2 Header box",
-/* long */	"This box contains a series of boxes that contain header-type information about the file",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{IHDR_SIGN,
-/* short */	"Image Header box",
-/* long */	"This box specifies the size of the image and other related fields",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	JP2H_BOX},
-
-/* sign */	{COLR_SIGN,
-/* short */	"Colour Specification box",
-/* long */	"This box specifies the colourspace of the image",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	JP2H_BOX},
-
-/* sign */	{JP2C_SIGN,
-/* short */	"Contiguous Codestream box",
-/* long */	"This box contains the codestream as defined by Annex A",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{JP2I_SIGN,
-/* short */	"Intellectual Property box",
-/* long */	"This box contains intellectual property information about the image",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{XML_SIGN,
-/* short */	"XML box",
-/* long */	"This box provides a tool by which vendors can add XML formatted information to a JP2 file",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{UUID_SIGN,
-/* short */	"UUID box",
-/* long */	"This box provides a tool by which vendors can add additional information to a file "
-			"without risking conflict with other vendors",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{UINF_SIGN,
-/* short */	"UUID Info box",
-/* long */	"This box provides a tool by which a vendor may provide access to additional information associated with a UUID",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{MOOV_SIGN,
-/* short */	"Movie box",
-/* long */	"This box contains the media data. In video tracks, this box would contain JPEG2000 video frames",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{MVHD_SIGN,
-/* short */	"Movie Header box",
-/* long */	"This box defines overall information which is media-independent, and relevant to the entire presentation "
-			"considered as a whole",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MOOV_BOX},
-
-/* sign */	{TRAK_SIGN,
-/* short */	"Track box",
-/* long */	"This is a container box for a single track of a presentation. A presentation may consist of one or more tracks",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	MOOV_BOX},
-
-/* sign */	{TKHD_SIGN,
-/* short */	"Track Header box",
-/* long */	"This box specifies the characteristics of a single track. Exactly one Track Header Box is contained in a track",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	TRAK_BOX},
-
-/* sign */	{MDIA_SIGN,
-/* short */	"Media box",
-/* long */	"The media declaration container contains all the objects which declare information about the media data "
-			"within a track",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	TRAK_BOX},
-
-/* sign */	{MDHD_SIGN,
-/* short */	"Media Header box",
-/* long */	"The media header declares overall information which is media-independent, and relevant to characteristics "
-			"of the media in a track",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MDIA_BOX},
-
-/* sign */	{HDLR_SIGN,
-/* short */	"Handler Reference box",
-/* long */	"This box within a Media Box declares the process by which the media-data in the track may be presented, "
-			"and thus, the nature of the media in a track",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MDIA_BOX},
-
-/* sign */	{MINF_SIGN,
-/* short */	"Media Information box",
-/* long */	"This box contains all the objects which declare characteristic information of the media in the track",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	MDIA_BOX},
-
-/* sign */	{VMHD_SIGN,
-/* short */	"Video Media Header box",
-/* long */	"The video media header contains general presentation information, independent of the coding, for video media",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MINF_BOX},
-
-/* sign */	{STBL_SIGN,
-/* short */	"Sample Table box",
-/* long */	"The sample table contains all the time and data indexing of the media samples in a track",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	MINF_BOX},
-
-/* sign */	{STSD_SIGN,
-/* short */	"STSD Sample Description box",
-/* long */	"The sample description table gives detailed information about the coding type used, and any initialization "
-			"information needed for that coding",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MINF_BOX},
-
-/* sign */	{STSZ_SIGN,
-/* short */	"Sample Size box",
-/* long */	"This box contains the sample count and a table giving the size of each sample",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	STBL_BOX},
-
-/* sign */	{MJP2_SIGN,
-/* short */	"MJP2 Sample Description box",
-/* long */	"The MJP2 sample description table gives detailed information about the coding type used, and any initialization "
-			"information needed for that coding",
-/* sbox */	0,
-/* req */	{1, 1, 1},
-/* ins */	MINF_BOX},
-
-/* sign */	{MDAT_SIGN,
-/* short */	"Media Data box",
-/* long */	"The meta-data for a presentation is stored in the single Movie Box which occurs at the top-level of a file",
-/* sbox */	1,
-/* req */	{1, 1, 1},
-/* ins */	FILE_BOX},
-
-/* sign */	{ANY_SIGN,
-/* short */	"Any box",
-/* long */	"All the existing boxes",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	FILE_BOX},
-
-/* sign */	{UNK_SIGN,
-/* short */	"Unknown Type box",
-/* long */	"The signature is not recognised to be that of an existing box",
-/* sbox */	0,
-/* req */	{0, 0, 0},
-/* ins */	ANY_BOX}
-
-};
-
-
-/* macro functions */
-/* From little endian to big endian, 2 and 4 bytes */
-#define	BYTE_SWAP2(X)	((X & 0x00FF) << 8) | ((X & 0xFF00) >> 8)
-#define	BYTE_SWAP4(X)	((X & 0x000000FF) << 24) | ((X & 0x0000FF00) << 8) | ((X & 0x00FF0000) >> 8) | ((X & 0xFF000000) >> 24)
-
-#ifdef __WXGTK__
-#define	BYTE_SWAP8(X)	((X & 0x00000000000000FFULL) << 56) | ((X & 0x000000000000FF00ULL) << 40) | \
-                        ((X & 0x0000000000FF0000ULL) << 24) | ((X & 0x00000000FF000000ULL) << 8) | \
-						((X & 0x000000FF00000000ULL) >> 8)  | ((X & 0x0000FF0000000000ULL) >> 24) | \
-						((X & 0x00FF000000000000ULL) >> 40) | ((X & 0xFF00000000000000ULL) >> 56)
-#else
-#define	BYTE_SWAP8(X)	((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
-                        ((X & 0x0000000000FF0000) << 24) | ((X & 0x00000000FF000000) << 8) | \
-						((X & 0x000000FF00000000) >> 8)  | ((X & 0x0000FF0000000000) >> 24) | \
-						((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56)
-#endif
-
-/* From codestream to int values */
-#define STREAM_TO_UINT32(C, P)	(((unsigned long int) (C)[(P) + 0] << 24) + \
-								((unsigned long int) (C)[(P) + 1] << 16) + \
-								((unsigned long int) (C)[(P) + 2] << 8) + \
-								((unsigned long int) (C)[(P) + 3] << 0))
-
-#define STREAM_TO_UINT16(C, P)	(((unsigned long int) (C)[(P) + 0] << 8) + \
-								((unsigned long int) (C)[(P) + 1] << 0))
-
-#define OPJREAD_LONG(F,L,N) { \
-							if (F->Read(fourbytes, 4) < 4) { \
-								wxLogMessage(wxT("Problem reading " N " from the file (file ended?)")); \
-								return -1; \
-							}; \
-							L = STREAM_TO_UINT32(fourbytes, 0); \
-							}
-
-/* handling functions */
-#define ITEM_PER_ROW	10
-
-//#define indprint	if (0) printf("%.*s", 2 * level + 9, indent), printf
-char    indent[] =  "                                                                   "
-					"                                                                   "
-					"                                                                   "
-					"                                                                   ";
-
-void indprint(wxString printout, int level)
-{
-	wxLogMessage(/*wxString::Format(wxT("%.*s"), 2 * level + 9, indent) + */printout);
-}
-
-/* Box handler function */
-int OPJParseThread::box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
-						 wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint)
-{
-	switch ((j22boxtype) boxtype) {
-
-
-	/* JPEG 2000 Signature box */
-	case (JP_BOX): {
-
-			unsigned long int checkdata = 0;
-			fileid->Read(&checkdata, sizeof(unsigned long int));
-			checkdata = BYTE_SWAP4(checkdata);
-
-			// add info
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Check data: %X -> %s"), checkdata, (checkdata == 0x0D0A870A) ? wxT("OK") : wxT("KO")),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-		};
-		break;
-
-
-	/* JPEG 2000 codestream box */
-	case (JP2C_BOX): {
-
-			// add info
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString(wxT("Codestream")),
-				m_tree->TreeCtrlIcon_Folder, m_tree->TreeCtrlIcon_Folder + 1,
-				new OPJMarkerData(wxT("INFO-CSTREAM"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-				);
-
-			m_tree->SetItemHasChildren(currid);
-
-			// parse the file
-			//ParseJ2KFile(fileid, filepoint, filelimit, currid);
-
-		};
-		break;
-
-
-
-
-
-	/* File Type box */
-	case (FTYP_BOX): {
-
-			char BR[4], CL[4];
-			unsigned long int MinV, numCL, i;
-			fileid->Read(BR, sizeof(char) * 4);
-			fileid->Read(&MinV, sizeof(unsigned long int));
-			MinV = BYTE_SWAP4(MinV);
-			numCL = (filelimit - fileid->Tell()) / 4;				
-
-			// add info
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxT("Brand/Minor version: ") +
-				wxString::FromAscii(BR).Truncate(4) +
-				wxString::Format(wxT("/%d"), MinV),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Compatibility list")),
-				m_tree->TreeCtrlIcon_Folder, m_tree->TreeCtrlIcon_Folder + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			for (i = 0; i < numCL; i++) {
-				fileid->Read(CL, sizeof(char) * 4);
-				m_tree->AppendItem(currid,
-					wxString::FromAscii(CL).Truncate(4),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-			};
-			
-		};
-		break;
-
-
-
-	/* JP2 Header box */
-	case (IHDR_BOX): {
-
-			unsigned long int height, width;
-			unsigned short int nc;
-			unsigned char bpc, C, UnkC, IPR;
-			fileid->Read(&height, sizeof(unsigned long int));
-			height = BYTE_SWAP4(height);
-			fileid->Read(&width, sizeof(unsigned long int));
-			width = BYTE_SWAP4(width);
-			fileid->Read(&nc, sizeof(unsigned short int));
-			nc = BYTE_SWAP2(nc);
-			fileid->Read(&bpc, sizeof(unsigned char));
-			fileid->Read(&C, sizeof(unsigned char));
-			fileid->Read(&UnkC, sizeof(unsigned char));
-			fileid->Read(&IPR, sizeof(unsigned char));
-			
-			// add info
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Dimensions: %d x %d x %d @ %d bpc"), width, height, nc, bpc + 1),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Compression type: %d"), C),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Colourspace unknown: %d"), UnkC),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Intellectual Property Rights: %d"), IPR),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			
-		};
-		break;
-
-
-
-	/* Colour Specification box */
-	case (COLR_BOX): {
-
-			unsigned char METH, PREC, APPROX;
-			char methdescr[80], enumcsdescr[80];
-			unsigned long int EnumCS;
-			fileid->Read(&METH, sizeof(unsigned char));
-			switch (METH) {
-			case 1:
-				strcpy(methdescr, "Enumerated Colourspace");
-				break;
-			case 2:
-				strcpy(methdescr, "Restricted ICC profile");
-				break;
-			default:
-				strcpy(methdescr, "Unknown");
-				break;
-			};
-			fileid->Read(&PREC, sizeof(unsigned char));
-			fileid->Read(&APPROX, sizeof(unsigned char));
-			if (METH != 2) {
-				fileid->Read(&EnumCS, sizeof(unsigned long int));
-				EnumCS = BYTE_SWAP4(EnumCS);
-				switch (EnumCS) {
-				case 16:
-					strcpy(enumcsdescr, "sRGB");
-					break;
-				case 17:
-					strcpy(enumcsdescr, "greyscale");
-					break;
-				case 18:
-					strcpy(enumcsdescr, "sYCC");
-					break;
-				default:
-					strcpy(enumcsdescr, "Unknown");
-					break;
-				};
-			};
-
-			// add info
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Specification method: %d ("), METH) +
-				wxString::FromAscii(methdescr) +
-				wxT(")"),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Precedence: %d"), PREC),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Colourspace approximation: %d"), APPROX),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-
-			if (METH != 2)
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Enumerated colourspace: %d ("), EnumCS) +
-					wxString::FromAscii(enumcsdescr) +
-					wxT(")"),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-			if (METH != 1)
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("ICC profile: there is one")),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-
-
-		};
-		break;
-
-
-
-
-		
-
-	/* Movie Header Box */
-	case (MVHD_BOX): {
-
-			unsigned long int version, rate, matrix[9], next_track_ID;
-			unsigned short int volume;
-			fileid->Read(&version, sizeof(unsigned long int));
-			version = BYTE_SWAP4(version);
-			if (version == 0) {
-				unsigned long int creation_time, modification_time, timescale, duration;
-				fileid->Read(&creation_time, sizeof(unsigned long int));
-				creation_time = BYTE_SWAP4(creation_time);
-				fileid->Read(&modification_time, sizeof(unsigned long int));
-				modification_time = BYTE_SWAP4(modification_time);
-				fileid->Read(&timescale, sizeof(unsigned long int));
-				timescale = BYTE_SWAP4(timescale);
-				fileid->Read(&duration, sizeof(unsigned long int));
-				duration = BYTE_SWAP4(duration);
-				const long unix_time = creation_time - 2082844800L;
-				wxTreeItemId currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Creation time: %u (%.24s)"), creation_time, ctime(&unix_time)),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				const long unix_time1 = modification_time - 2082844800L;
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Modification time: %u (%.24s)"), modification_time, ctime(&unix_time1)),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Timescale: %u (%.6fs)"), timescale, 1.0 / (float) timescale),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Duration: %u (%.3fs)"), duration, (float) duration / (float) timescale),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-			} else {
-				int8byte creation_time, modification_time, duration;
-				unsigned long int timescale;
-				fileid->Read(&creation_time, sizeof(int8byte));
-				creation_time = BYTE_SWAP8(creation_time);
-				fileid->Read(&modification_time, sizeof(int8byte));
-				modification_time = BYTE_SWAP8(modification_time);
-				fileid->Read(&timescale, sizeof(unsigned long int));
-				timescale = BYTE_SWAP4(timescale);
-				fileid->Read(&duration, sizeof(int8byte));
-				duration = BYTE_SWAP8(duration);
-				wxTreeItemId currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Creation time: %u"), creation_time),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Modification time: %u"), modification_time),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Timescale: %u"), timescale),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Duration: %u"), duration),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-			};
-			fileid->Read(&rate, sizeof(unsigned long int));
-			rate = BYTE_SWAP4(rate);
-			fileid->Read(&volume, sizeof(unsigned short int));
-			volume = BYTE_SWAP2(volume);
-			fileid->Seek(6, wxFromCurrent);
-			fileid->Read(&matrix, sizeof(unsigned char) * 9);
-			fileid->Seek(4, wxFromCurrent);
-			fileid->Read(&next_track_ID, sizeof(unsigned long int));
-			next_track_ID = BYTE_SWAP4(next_track_ID);
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Rate: %d (%d.%d)"), rate, rate >> 16, rate & 0x0000FFFF),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Volume: %d (%d.%d)"), volume, volume >> 8, volume & 0x00FF),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Next track ID: %d"), next_track_ID),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-		};
-		break;
-
-
-			/* Sample Description box */
-	case (STSD_BOX): {
-
-			unsigned long int version, entry_count;
-			fileid->Read(&version, sizeof(unsigned long int));
-			version = BYTE_SWAP4(version);
-			fileid->Read(&entry_count, sizeof(unsigned long int));
-			entry_count = BYTE_SWAP4(entry_count);
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Entry count: %d"), entry_count),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-				);
-			jpeg2000parse(fileid, filepoint + 8, filelimit, parentid, level + 1, scansign, scanpoint);
-		};
-		break;
-
-
-			/* Sample Size box */
-	case (STSZ_BOX): {
-
-			unsigned long int version, sample_size, sample_count, entry_size;
-			
-			fileid->Read(&version, sizeof(unsigned long int));
-			version = BYTE_SWAP4(version);
-			
-			fileid->Read(&sample_size, sizeof(unsigned long int));
-			sample_size = BYTE_SWAP4(sample_size);
-
-			if (sample_size == 0) {
-				fileid->Read(&sample_count, sizeof(unsigned long int));
-				sample_count = BYTE_SWAP4(sample_count);
-
-				wxTreeItemId currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Sample count: %d"), sample_count),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-					);
-
-				currid = m_tree->AppendItem(parentid,
-					wxT("Entries size (bytes)"),
-					m_tree->TreeCtrlIcon_Folder, m_tree->TreeCtrlIcon_Folder + 1,
-					new OPJMarkerData(wxT("INFO"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-					);
-
-				wxString text;
-				for (unsigned int s = 0; s < sample_count; s++) {
-					fileid->Read(&entry_size, sizeof(unsigned long int));
-					entry_size = BYTE_SWAP4(entry_size);
-					
-					text << wxString::Format(wxT("%d, "), entry_size);
-
-					if (((s % 10) == (ITEM_PER_ROW - 1)) || (s == (sample_count - 1))) {
-						m_tree->AppendItem(currid,
-							text,
-							m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-							new OPJMarkerData(wxT("INFO"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-							);
-						text = wxT("");
-					}
-
-				}
-				
-			}
-
-		};
-		break;
-
-
-			/* Video Media Header box */
-	case (VMHD_BOX): {
-
-			unsigned long int version;
-			unsigned short int graphicsmode, opcolor[3];
-			char graphicsdescr[100];
-
-			fileid->Read(&version, sizeof(unsigned long int));
-			version = BYTE_SWAP4(version);
-
-			fileid->Read(&graphicsmode, sizeof(unsigned short int));
-			graphicsmode = BYTE_SWAP2(graphicsmode);
-			switch (graphicsmode) {
-			case (0x00):
-					strcpy(graphicsdescr, "copy");
-					break;
-			case (0x24):
-					strcpy(graphicsdescr, "transparent");
-					break;
-			case (0x0100):
-					strcpy(graphicsdescr, "alpha");
-					break;
-			case (0x0101):
-					strcpy(graphicsdescr, "whitealpha");
-					break;
-			case (0x0102):
-					strcpy(graphicsdescr, "blackalpha");
-					break;
-			default:
-					strcpy(graphicsdescr, "unknown");
-					break;
-			};
-
-			fileid->Read(opcolor, 3 * sizeof(unsigned short int));
-			opcolor[0] = BYTE_SWAP2(opcolor[0]);
-			opcolor[1] = BYTE_SWAP2(opcolor[1]);
-			opcolor[2] = BYTE_SWAP2(opcolor[2]);
-
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Composition mode: %d (")) + 
-				wxString::FromAscii(graphicsdescr) +
-				wxT(")"),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-				);
-
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("OP color: %d %d %d"), opcolor[0], opcolor[1], opcolor[2]),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-				);
-		};
-		break;
-
-
-
-			/* MJP2 Sample Description box */
-	case (MJP2_BOX): {
-
-			unsigned short int height, width, depth;
-			unsigned long int horizresolution, vertresolution;
-			char compressor_name[32];
-			fileid->Seek(24, wxFromCurrent);
-			fileid->Read(&width, sizeof(unsigned short int));
-			width = BYTE_SWAP2(width);
-			fileid->Read(&height, sizeof(unsigned short int));
-			height = BYTE_SWAP2(height);
-			fileid->Read(&horizresolution, sizeof(unsigned long int));
-			horizresolution = BYTE_SWAP4(horizresolution);
-			fileid->Read(&vertresolution, sizeof(unsigned long int));
-			vertresolution = BYTE_SWAP4(vertresolution);
-			fileid->Seek(6, wxFromCurrent);
-			fileid->Read(compressor_name, sizeof(char) * 32);
-			fileid->Read(&depth, sizeof(unsigned short int));
-			depth = BYTE_SWAP2(depth);
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Dimensions: %d x %d @ %d bpp"), width, height, depth),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"), m_tree->m_fname.GetFullPath(), filepoint, filelimit)
-				);
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Resolution: %d.%d x %d.%d"), horizresolution >> 16, horizresolution & 0x0000FFFF,
-				vertresolution >> 16, vertresolution & 0x0000FFFF),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Compressor: %.32s"), compressor_name),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-			jpeg2000parse(fileid, filepoint + 78, filelimit, parentid, level + 1, scansign, scanpoint);
-
-		};
-		break;
-
-		/* Media Header box */
-	case (MDHD_BOX): {
-			unsigned long int version;
-			unsigned short int language;
-			fileid->Read(&version, sizeof(unsigned long int));
-			version = BYTE_SWAP4(version);
-			if (version == 0) {
-				unsigned long int creation_time, modification_time, timescale, duration;
-				fileid->Read(&creation_time, sizeof(unsigned long int));
-				creation_time = BYTE_SWAP4(creation_time);
-				fileid->Read(&modification_time, sizeof(unsigned long int));
-				modification_time = BYTE_SWAP4(modification_time);
-				fileid->Read(&timescale, sizeof(unsigned long int));
-				timescale = BYTE_SWAP4(timescale);
-				fileid->Read(&duration, sizeof(unsigned long int));
-				duration = BYTE_SWAP4(duration);
-				const long unix_time = creation_time - 2082844800L;
-				wxTreeItemId currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Creation time: %u (%.24s)"), creation_time, ctime(&unix_time)),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				const long unix_time1 = modification_time - 2082844800L;
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Modification time: %u (%.24s)"), modification_time, ctime(&unix_time1)),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Timescale: %u (%.6fs)"), timescale, 1.0 / (float) timescale),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Duration: %u (%.3fs)"), duration, (float) duration / (float) timescale),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-			} else {
-				int8byte creation_time, modification_time, duration;
-				unsigned long int timescale;
-				fileid->Read(&creation_time, sizeof(int8byte));
-				creation_time = BYTE_SWAP8(creation_time);
-				fileid->Read(&modification_time, sizeof(int8byte));
-				modification_time = BYTE_SWAP8(modification_time);
-				fileid->Read(&timescale, sizeof(unsigned long int));
-				timescale = BYTE_SWAP4(timescale);
-				fileid->Read(&duration, sizeof(int8byte));
-				duration = BYTE_SWAP8(duration);
-				wxTreeItemId currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Creation time: %u"), creation_time),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Modification time: %u"), modification_time),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Timescale: %u"), timescale),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-				currid = m_tree->AppendItem(parentid,
-					wxString::Format(wxT("Duration: %u"), duration),
-					m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-					new OPJMarkerData(wxT("INFO"))
-					);
-			}
-			fileid->Read(&language, sizeof(unsigned short int));
-
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Language: %d (%c%c%c)"), language & 0xEFFF,
-				0x60 + (char) ((language >> 10) & 0x001F), 0x60 + (char) ((language >> 5) & 0x001F), 0x60 + (char) ((language >> 0) & 0x001F)),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-		};
-		break;
-		
-		/* Media Handler box */
-	case (HDLR_BOX): {
-			unsigned long int version, predefined, temp[3];
-			char handler[4], name[256];
-			int namelen = wxMin(256, (filelimit - filepoint - 24));
-			fileid->Read(&version, sizeof(unsigned long int));
-			version = BYTE_SWAP4(version);
-			fileid->Read(&predefined, sizeof(unsigned long int));
-			fileid->Read(handler, 4 * sizeof(char));
-			fileid->Read(&temp, 3 * sizeof(unsigned long int));
-			fileid->Read(name, namelen * sizeof(char));
-
-			wxTreeItemId currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Handler: %.4s"), handler),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-					 
-			currid = m_tree->AppendItem(parentid,
-				wxString::Format(wxT("Name: %.255s"), name),
-				m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
-				new OPJMarkerData(wxT("INFO"))
-				);
-					 				 
-		}
-		break;
-
-	/* not yet implemented */
-	default:
-		break;
-
-	};
-
-	return (0);
-}
-
-
-void OPJParseThread::ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid)
-{
-	unsigned long int scanpoint;
-
-	jpeg2000parse(fileid, filepoint, filelimit, parentid, 0, NULL, &scanpoint);
-}
-
-/* the parsing function itself */
-/*
-  fileid    = fid of the file to scan (you should open it by yourself)
-  filepoint = first byte where to start to scan from (usually 0)
-  filelimit = first byte where to stop to scan from (usually the file size)
-  level     = set this to 0
-  scansign  = signature to scan for (NULL avoids search, returns "    " if successful)
-  scanpoint = point where the scan signature lies
-*/
-int OPJParseThread::jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
-								  wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint)
-{
-	unsigned long int       LBox = 0x00000000;
-	//int                     LBox_read;
-	char                    TBox[5] = "\0\0\0\0";
-	//int                     TBox_read;
-	int8byte				XLBox = 0x0000000000000000;
-	//int                     XLBox_read;
-	unsigned long int       box_length = 0;
-	int                     last_box = 0, box_num = 0;
-	int                     box_type = ANY_BOX;
-	unsigned char           /*onebyte[1], twobytes[2],*/ fourbytes[4];
-
-	/* cycle all over the file */
-	box_num = 0;
-	last_box = 0;
-	while (!last_box) {
-
-		/* do not exceed file limit */
-		if (filepoint >= filelimit)
-			return (0);
-
-		/* seek on file */
-		if (fileid->Seek(filepoint, wxFromStart) == wxInvalidOffset)
-			return (-1);
-
-		/* read the mandatory LBox, 4 bytes */
-		if (fileid->Read(fourbytes, 4) < 4) {
-			WriteText(wxT("Problem reading LBox from the file (file ended?)"));
-			return -1;
-		};
-		LBox = STREAM_TO_UINT32(fourbytes, 0);
-
-		/* read the mandatory TBox, 4 bytes */
-		if (fileid->Read(TBox, 4) < 4) {
-			WriteText(wxT("Problem reading TBox from the file (file ended?)"));
-			return -1;
-		};
-
-		/* look if scansign is got */
-		if ((scansign != NULL) && (memcmp(TBox, scansign, 4) == 0)) {
-			memcpy(scansign, "    ", 4);
-			*scanpoint = filepoint;
-
-			/* hack/exploit */
-			// stop as soon as you find the codebox
-			return (0);
-
-		};
-
-		/* determine the box type */
-		for (box_type = JP_BOX; box_type < UNK_BOX; box_type++)
-			if (memcmp(TBox, j22box[box_type].value, 4) == 0)
-				break;	
-
-		/* read the optional XLBox, 8 bytes */
-		if (LBox == 1) {
-
-			if (fileid->Read(&XLBox, 8) < 8) {
-				WriteText(wxT("Problem reading XLBox from the file (file ended?)"));
-				return -1;
-			};
-			box_length = (unsigned long int) BYTE_SWAP8(XLBox);
-
-		} else if (LBox == 0x00000000) {
-
-			/* last box in file */
-			last_box = 1; 
-			box_length = filelimit - filepoint;
-
-		} else
-
-			box_length = LBox;
-
-		/* show box info */
-
-		// append the marker
-		int image, imageSel;
-		image = m_tree->TreeCtrlIcon_Folder;
-		imageSel = image + 1;
-		wxTreeItemId currid = m_tree->AppendItem(parentid,
-			wxString::Format(wxT("%03d: "), box_num) +
-			wxString::FromAscii(TBox) +
-			wxString::Format(wxT(" (0x%04X)"),
-				((unsigned long int) TBox[3]) + ((unsigned long int) TBox[2] << 8) +
-				((unsigned long int) TBox[1] << 16) + ((unsigned long int) TBox[0] << 24)
-			),
-			image, imageSel,
-			new OPJMarkerData(wxT("BOX"), m_tree->m_fname.GetFullPath(), filepoint, filepoint + box_length)
-			);
-
-		// append some info
-		image = m_tree->TreeCtrlIcon_File;
-		imageSel = image + 1;
-
-		// box name
-		wxTreeItemId subcurrid1 = m_tree->AppendItem(currid,
-			wxT("*** ") + wxString::FromAscii(j22box[box_type].name) + wxT(" ***"),
-			image, imageSel,
-			new OPJMarkerData(wxT("INFO"))
-			);
-		m_tree->SetItemFont(subcurrid1, *wxITALIC_FONT);
-
-		// position and length
-		wxTreeItemId subcurrid2 = m_tree->AppendItem(currid,
-			wxLongLong(filepoint).ToString() + wxT(" > ") + wxLongLong(filepoint + box_length - 1).ToString() + 
-			wxT(", ") + wxString::Format(wxT("%d + 8 (%d)"), box_length, box_length + 8),
-			image, imageSel,
-			new OPJMarkerData(wxT("INFO"))
-			);
-
-		/* go deep in the box */
-		box_handler_function((int) box_type, fileid, (LBox == 1) ? (filepoint + 16) : (filepoint + 8), filepoint + box_length,
-			currid, level, scansign, scanpoint);
-
-		/* if it's a superbox go inside it */
-		if (j22box[box_type].sbox)
-			jpeg2000parse(fileid, (LBox == 1) ? (filepoint + 16) : (filepoint + 8), filepoint + box_length,
-				currid, level + 1, scansign, scanpoint);
-
-		/* increment box number and filepoint*/
-		box_num++;
-		filepoint += box_length;
-
-	};
-
-	/* all good */
-	return (0);
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Param_File_v0_1.txt b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Param_File_v0_1.txt
deleted file mode 100644
index 881c92d..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Param_File_v0_1.txt
+++ /dev/null
@@ -1,100 +0,0 @@
-#Version 0.1 - February 9th 2007
-#Usage: OPJ_Validate OpenJPEG_command_line
-#Example: OPJ_Validate image_to_j2k.exe -i original/Bretagne1.ppm -o original/Bretagne1.j2k -r 200, 50, 10
-#Attention: don't forget the *.exe extension for the executable file, and check the paths
-
-image_to_j2k.exe -i original/Bretagne1.ppm -o temp/Bretagne1_0.j2k -r 200,50,10
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.ppm
-image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_0.j2k -c [128,128],[128,128],[128,128] -r 100,20,2 -t 640,480 -b 32,32
-j2k_to_image.exe -i original/Bretagne2.j2k -o temp/Bretagne2.ppm -r 2
-image_to_j2k.exe -i original/Cevennes1.bmp -o temp/Cevennes1.j2k -r 10
-j2k_to_image.exe -i original/Cevennes1.j2k -o temp/Cevennes1.bmp -l 2
-image_to_j2k.exe -i original/Cevennes2.ppm -o temp/Cevennes2.jp2 -r 50
-j2k_to_image.exe -i original/Cevennes2.jp2 -o temp/Cevennes2.ppm
-image_to_j2k.exe -i original/Rome.bmp -o temp/Rome.jp2 -q 30,35,50 -p LRCP -n 3
-j2k_to_image.exe -i original/Rome.jp2 -o temp/Rome.ppm
-image_to_j2k.exe -i original/Bretagne1.ppm -o temp/Bretagne1_1.j2k -q 30,35,40 -n 2
-image_to_j2k.exe -i original/Bretagne1.ppm -o temp/Bretagne1_2.j2k -q 30,35,40 -b 16,16 -c [101,101]
-image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_1.j2k -t 127,127 -p PCRL
-image_to_j2k.exe -i original/X_4_2K_24_185_CBR_WB_000.tif -o temp/X_4_2K_24_185_CBR_WB_000.j2k -cinema2K 24
-image_to_j2k.exe -i original/X_5_2K_24_235_CBR_STEM24_000.tif -o temp/X_5_2K_24_235_CBR_STEM24_000.j2k -cinema2K 48
-image_to_j2k.exe -i original/X_6_2K_24_FULL_CBR_CIRCLE_000.tif -o temp/X_6_2K_24_FULL_CBR_CIRCLE_000.j2k -cinema2K 24
-#� remettre
-#image_to_j2k.exe -i original/X_16_4K_24_185_CBR_WB_000.tif -o temp/X_16_4K_24_185_CBR_WB_000.j2k -cinema4K
-j2k_to_image.exe -i original/A_4_2K_24_185_CBR_WB_000.j2k -o temp/A_4_2K_24_185_CBR_WB_000.tif
-j2k_to_image.exe -i original/B_5_2K_24_235_CBR_STEM24_000.j2k -o temp/B_5_2K_24_235_CBR_STEM24_000.tif
-j2k_to_image.exe -i original/C_6_2K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_6_2K_24_FULL_CBR_CIRCLE_000.tif
-#� remettre
-#j2k_to_image.exe -i original/C_18_4K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_18_4K_24_FULL_CBR_CIRCLE_000.tif
-j2k_to_image.exe -i original/p0_01.j2k -o temp/p0_01.tif
-j2k_to_image.exe -i original/p0_02.j2k -o temp/p0_02.tif
-j2k_to_image.exe -i original/p0_03.j2k -o temp/p0_03.tif
-j2k_to_image.exe -i original/p0_04.j2k -o temp/p0_04.tif
-#� remettre
-#j2k_to_image.exe -i original/p0_07.j2k -o temp/p0_07.tif
-j2k_to_image.exe -i original/p0_08.j2k -o temp/p0_08.tif
-j2k_to_image.exe -i original/p0_09.j2k -o temp/p0_09.tif
-j2k_to_image.exe -i original/p0_10.j2k -o temp/p0_10.tif
-j2k_to_image.exe -i original/p0_11.j2k -o temp/p0_11.tif
-j2k_to_image.exe -i original/p0_12.j2k -o temp/p0_12.tif
-j2k_to_image.exe -i original/p0_14.j2k -o temp/p0_14.tif
-j2k_to_image.exe -i original/p0_15.j2k -o temp/p0_15.tif
-j2k_to_image.exe -i original/p0_16.j2k -o temp/p0_16.tif
-j2k_to_image.exe -i original/p1_01.j2k -o temp/p1_01.tif
-j2k_to_image.exe -i original/p1_02.j2k -o temp/p1_02.tif
-j2k_to_image.exe -i original/p1_04.j2k -o temp/p1_04.tif
-j2k_to_image.exe -i original/p1_05.j2k -o temp/p1_05.tif
-j2k_to_image.exe -i original/p1_06.j2k -o temp/p1_06.tif
-image_to_j2k.exe -i original/c0p0_01.pgx -o temp/c0p0_01.j2k
-image_to_j2k.exe -i original/c0p0_02.pgx -o temp/c0p0_02.j2k
-image_to_j2k.exe -i original/c0p0_03r0.pgx -o temp/c0p0_03r0.j2k
-image_to_j2k.exe -i original/c0p0_03r1.pgx -o temp/c0p0_03r1.j2k
-image_to_j2k.exe -i original/c0p0_04.pgx -o temp/c00_p04.j2k
-image_to_j2k.exe -i original/c0p0_05.pgx -o temp/c0p0_05.j2k
-image_to_j2k.exe -i original/c0p0_06.pgx -o temp/c0p0_06.j2k
-image_to_j2k.exe -i original/c0p0_07.pgx -o temp/c0p0_07.j2k
-image_to_j2k.exe -i original/c0p0_08.pgx -o temp/c0p0_08.j2k
-image_to_j2k.exe -i original/c0p0_09.pgx -o temp/c0p0_09.j2k
-image_to_j2k.exe -i original/c0p0_10.pgx -o temp/c0p0_10.j2k
-image_to_j2k.exe -i original/c0p0_11.pgx -o temp/c0p0_11.j2k
-image_to_j2k.exe -i original/c0p0_12.pgx -o temp/c0p0_12.j2k
-image_to_j2k.exe -i original/c0p0_13.pgx -o temp/c0p0_13.j2k
-image_to_j2k.exe -i original/c0p0_14.pgx -o temp/c0p0_14.j2k
-image_to_j2k.exe -i original/c0p0_15r0.pgx -o temp/c0p0_15r0.j2k
-image_to_j2k.exe -i original/c0p0_15r1.pgx -o temp/c0p0_15r1.j2k
-image_to_j2k.exe -i original/c0p0_16.pgx -o temp/c0p0_16.j2k
-image_to_j2k.exe -i original/c0p1_04r0.pgx -o temp/c0p1_04r0.j2k
-image_to_j2k.exe -i original/c0p1_05.pgx -o temp/c0p1_05.j2k
-image_to_j2k.exe -i original/c1p0_01_0.pgx -o temp/c1p0_01_0.j2k
-image_to_j2k.exe -i original/c1p0_02_0.pgx -o temp/c1p0_02_0.j2k
-image_to_j2k.exe -i original/c1p0_03_0.pgx -o temp/c1p0_03_0.j2k
-image_to_j2k.exe -i original/c1p0_04_0.pgx -o temp/c1p0_04_0.j2k
-image_to_j2k.exe -i original/c1p0_05_0.pgx -o temp/c1p0_05_0.j2k
-image_to_j2k.exe -i original/c1p0_06_0.pgx -o temp/c1p0_06_0.j2k
-image_to_j2k.exe -i original/c1p0_07_0.pgx -o temp/c1p0_07_0.j2k
-image_to_j2k.exe -i original/c1p0_08_0.pgx -o temp/c1p0_08_0.j2k
-image_to_j2k.exe -i original/c1p0_09_0.pgx -o temp/c1p0_09_0.j2k
-image_to_j2k.exe -i original/c1p0_10_0.pgx -o temp/c1p0_10_0.j2k
-image_to_j2k.exe -i original/c1p0_11_0.pgx -o temp/c1p0_11_0.j2k
-image_to_j2k.exe -i original/c1p0_12_0.pgx -o temp/c1p0_12_0.j2k
-image_to_j2k.exe -i original/c1p0_13_0.pgx -o temp/c1p0_13_0.j2k
-image_to_j2k.exe -i original/c1p0_14_0.pgx -o temp/c1p0_14_0.j2k
-image_to_j2k.exe -i original/c1p0_15_0.pgx -o temp/c1p0_15_0.j2k
-image_to_j2k.exe -i original/c1p0_16_0.pgx -o temp/c1p0_16_0.j2k
-image_to_j2k.exe -i original/c1p1_02_0.pgx -o temp/c1p1_02_0.j2k
-image_to_j2k.exe -i original/c1p1_05_0.pgx -o temp/c1p1_05_0.j2k
-image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_2.j2k -s 2,2 -SOP
-image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_3.j2k -EPH -M 38
-image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_4.j2k -d 150,300 -r 800
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.bmp
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.bmp -r 2
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.tga
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.tga -r 2
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.pnm
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.pnm -r 2
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.ppm -r 2
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.raw
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.raw -r 2
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.tif
-j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.tif -r 2
-j2k_to_image.exe -i original/p0_03.j2k -o p0_03.pgx
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.c b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.c
deleted file mode 100644
index 9bd1da5..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
-* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
-* Copyright (c) 2002-2007, Professor Benoit Macq
-* Copyright (c) 2003-2007, Francois-Olivier Devaux 
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef _WIN32
-#include <windows.h>
-#endif /* _WIN32 */
-#include <stdio.h>
-#include <string.h>
-#include "md5.h"
-
-#define OPJ_Bin_Dir "OPJ_Binaries"
-
-int doprocess(char programme[4096],char command_line[4096]) {
-
-#ifdef _WIN32
-	
-	int exit=STILL_ACTIVE;
-	STARTUPINFO siStartupInfo;
-	PROCESS_INFORMATION piProcessInfo;
-	
-	memset(&siStartupInfo, 0, sizeof(siStartupInfo));
-	memset(&piProcessInfo, 0, sizeof(piProcessInfo));
-	siStartupInfo.cb = sizeof(siStartupInfo);
-	
-	if(CreateProcess(programme, // Application name
-		command_line, // Application arguments
-		0,
-		0,
-		FALSE,
-		CREATE_DEFAULT_ERROR_MODE,
-		0,
-		0, // Working directory
-		&siStartupInfo,
-		&piProcessInfo) == FALSE)	
-		return 1;
-	
-	exit=STILL_ACTIVE;
-	while(exit==STILL_ACTIVE) {
-		Sleep(1000);
-		GetExitCodeProcess(piProcessInfo.hProcess,&exit);
-	}
-	
-	return 0;
-
-#else /* !_WIN32 */
-	printf("\n%s\n", command_line);
-	system(command_line);
-	return 0;
-
-#endif /* _WIN32 */
-	
-}
-
-char MD5_process(char *input_filename, char *md5_filename) {
-	MD5_CTX mdContext;
-	int bytes;
-  unsigned char data[1024];
-	FILE *input_file, *md5_file;
-	
-	input_file = fopen(input_filename, "rb");
-	if (!input_file) {
-		printf("Error opening file %s\n", input_filename);
-		return 1;
-	}
-	
-	md5_file = fopen(md5_filename, "wb");
-	if (!md5_file) {
-		printf("Error opening file %s\n", md5_filename);
-		return 1;
-	}
-	
-	MD5Init (&mdContext);
-  while ((bytes = fread (data, 1, 1024, input_file)) != 0)
-    MD5Update (&mdContext, data, bytes);
-  MD5Final (&mdContext);
-	
-	fwrite(mdContext.digest,16,1,md5_file);
-	
-	fclose(input_file);
-	fclose(md5_file);
-	
-	return 0;
-}
-
-char fcompare(char *input_filename, char *output_filename) {
-	FILE *input_file, *output_file;
-	unsigned char input_buffer[17], output_buffer[17];
-	char comparison;
-	
-	input_file = fopen(input_filename, "rb");
-	if (!input_file) {
-		printf("Error opening file %s\n", input_filename);
-		return -1;
-	}
-	
-	output_file = fopen(output_filename, "rb");
-	if (!output_file) {
-		printf("Error opening file %s\n", output_filename);
-		return -1;
-	}
-	
-	fread(input_buffer,16,1,input_file);
-	fread(output_buffer,16,1,output_file);
-	fclose(input_file);
-	fclose(output_file);
-	input_buffer[16] = 0;
-	output_buffer[16] = 0;
-	
-	comparison = strcmp(input_buffer, output_buffer);
-	
-	if (comparison)
-		return 1;
-	return 0;
-}
-
-int main(int argc, char* argv[]) {
-	FILE *param_file, *md5_file;
-	FILE *report_file;
-	char line[4096];
-	char md5_filename[4096], tempmd5_filename[4096], temp[4096], report_filename[4096];
-	char output_filename[4096];
-	char input_cmdline[4096];
-	char command_line[4096], exefile[4096];
-	int task_counter = 0, word_counter;
-	char bin_dir[4096];
-	unsigned int word_pointer;
-	char ch[4096];				
-	char comparison;
-	int num_failed = 0;
-	int num_inexistant = 0;
-	int num_passed = 0;
-		
-	if (argc != 3) {
-		printf("Error with command line. \nExpected: OPJ_Validate parameter_filename bin_directory\n Example: OPJ_Validate parameters_01.txt version1.1.a\n\n");
-		return 1;
-	}
-	
-	param_file = fopen(argv[1],"rb");
-	if (!param_file) {
-		printf("Error opening parameter file %s\n",argv[1]);
-		return 1;
-	}	
-	
-	sprintf(bin_dir,"%s/%s",OPJ_Bin_Dir,argv[2]);
-	sprintf(tempmd5_filename,"temp/tempmd5.txt");
-	sprintf(report_filename,"%s/report.txt",bin_dir);
-	report_file = fopen(report_filename, "wb");
-	if (!report_file) {
-		printf("Unable to open report file %s", report_filename);
-		return 1;
-	}
-	
-	while (fgets(line, 4096, param_file) != NULL) {
-		
-		if (line[0] != '#' && line[0] != 0x0d) {	// If not a comment line
-			sscanf(line, "%s", temp);
-			word_pointer = 0;
-			sprintf(input_cmdline,"");	
-			sscanf(line+word_pointer,"%s",ch);
-			sprintf(exefile,"%s/%s",bin_dir,ch);				
-			word_counter = 0;
-			while (sscanf(line+word_pointer,"%s",ch) > 0) {
-				if (word_counter == 4) 
-					strcpy(output_filename, ch);
-				word_pointer += strlen(ch)+1;
-				sprintf(input_cmdline,"%s%s ",input_cmdline, ch);				
-				word_counter++;
-			}			
-			sprintf(md5_filename,"%s.md5",output_filename);
-			task_counter++;
-			sprintf(command_line,"%s/%s",bin_dir,input_cmdline);
-			printf("Task %d\nMD5 file: %s\nCommand line: \"%s\"\n",task_counter, md5_filename,command_line);
-			fprintf(report_file,"Task %d\n   MD5 file: %s\n   Command line: \"%s\"\n",task_counter, md5_filename,command_line);
-			
-			if (doprocess(exefile,command_line)) {
-				printf("Error executing: \"%s\" \n", command_line);
-				fprintf(report_file,"Task %d failed because command line is not valid.\n\n", task_counter);
-			}
-			else {
-				
-				// Check if MD5 reference exists
-				md5_file = fopen(md5_filename,"rb");
-				if (md5_file) {
-					fclose(md5_file);
-					if (MD5_process(output_filename, tempmd5_filename)) 
-						return 1;
-					
-					comparison = fcompare(tempmd5_filename, md5_filename);
-					if (comparison == -1)
-						return 1;
-					else if (comparison) {
-						printf("ERROR: %s and %s are different.\nThe codec seems to behave differently.\n\n", tempmd5_filename, md5_filename);
-						fprintf(report_file,"ERROR: %s and %s are different.\nThe codec seems to behave differently.\n\n", tempmd5_filename, md5_filename);
-						num_failed++;
-					}
-					else {
-						printf("%s and %s are the same.\nTask %d OK\n\n",tempmd5_filename, md5_filename, task_counter);
-						fprintf(report_file,"   %s and %s are the same.\nTask %d OK\n\n",tempmd5_filename, md5_filename, task_counter);
-						num_passed++;
-					}
-					remove(tempmd5_filename);
-				}	
-				else {
-					if (MD5_process(output_filename, md5_filename))
-						return 1;
-					printf("...  MD5 of %s was inexistant. It has been created\n\n", output_filename);
-					fprintf(report_file,"MD5 of %s was inexistant. It has been created\n\n", output_filename);
-					num_inexistant++;
-				}
-			}
-		}
-	}		
-
-	printf("\nREPORT;\n%d tests num_passed\n%d tests num_failed\n%d MD5 were num_inexistant\n", num_passed, num_failed, num_inexistant);
-	fprintf(report_file,"\nREPORT;\n%d tests num_passed\n%d tests num_failed\n%d MD5 were num_inexistant\n", num_passed, num_failed, num_inexistant);
-	fclose(param_file);
-	fclose(report_file);
-		
-}
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsp b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsp
deleted file mode 100644
index 7463089..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsp
+++ /dev/null
@@ -1,108 +0,0 @@
-# Microsoft Developer Studio Project File - Name="OPJ_Validate" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=OPJ_Validate - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "OPJ_Validate.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "OPJ_Validate.mak" CFG="OPJ_Validate - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "OPJ_Validate - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "OPJ_Validate - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "OPJ_Validate - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x80c /d "NDEBUG"
-# ADD RSC /l 0x80c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "OPJ_Validate - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x80c /d "_DEBUG"
-# ADD RSC /l 0x80c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF 
-
-# Begin Target
-
-# Name "OPJ_Validate - Win32 Release"
-# Name "OPJ_Validate - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\md5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\OPJ_Validate.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\md5.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsw b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsw
deleted file mode 100644
index 05a3403..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate.dsw
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "OPJ_Validate"=".\OPJ_Validate.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat
deleted file mode 100644
index 0fd61ad..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat
+++ /dev/null
@@ -1,8 +0,0 @@
-cd temp
-erase *.ppm
-erase *.j2k
-erase *.bmp
-erase *.tif
-erase *.jp2
-cd ..
-OPJ_Validate.exe OPJ_Param_File_v0_1.txt testv2
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh
deleted file mode 100644
index edd3eaa..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-cd temp
-erase *.ppm
-erase *.j2k
-erase *.bmp
-erase *.tif
-erase *.jp2
-cd ..
-
-echo
-echo "Type the name of the directory (inside OPJ_Binaries) "
-echo "containing your executables to compared with reference, followed by [ENTER] (example: rev101):"
-read compdir
-
-./OPJ_Validate linux_OPJ_Param_File_v0_1.txt $compdir
-echo
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Create_Ref.bat b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Create_Ref.bat
deleted file mode 100644
index 83332fc..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Create_Ref.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-cd temp
-erase *.md5
-cd ..
-OPJ_Validate.exe OPJ_Param_File_v0_1.txt rev490
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Create_Ref.sh b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Create_Ref.sh
deleted file mode 100644
index e44e053..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/OPJ_Validate_Create_Ref.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-#Create Reference images and hash
-
-echo
-echo "Type the name of the directory (inside OPJ_Binaries) "
-echo "containing your reference executables, followed by [ENTER] (example: rev100):"
-read refdir
-cd temp
-rm *.md5
-cd ..
-./OPJ_Validate linux_OPJ_Param_File_v0_1.txt $refdir
-echo
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/README.txt b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/README.txt
deleted file mode 100644
index 364ef8e..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/README.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-Initialization
---------------
-Download the source images into the /original directory from http://www.openjpeg.org/OPJ_Validate_OriginalImages.7z
-
-Usage
------
-Usage: OPJ_Validate batch_text_file bin_directory
-Example: OPJ_Validate OPJ_Param_File_v0_1.txt v1.1.a
-where OPJ_Param_File_v0_1.txt is a file containing a list of compression and decompression parameters
-and v1.1.a is a directory inside the directory OPJ_Binaries containing the openjpeg executables (j2k_to_image.exe and image_to_j2k.exe)
-
-Example with batch file: You consider revision 490 (/rev490) as stable, and would like to compare it a new version, revision 493 (rev493).
-
-Batch mode
-----------
-1) Calculate the reference by running the "OPJ_Validate_Create_Ref rev490" file (.sh or .bat depending on your os)
-2) Compare the candidate revision with ther reference by running the "OPJ_Validate_Candidate_vs_Ref rev493" file
-3) The results of the comparison are given at the end of the processing. They are also available in the bin directory OPJ_Binaries/rev493/report.txt
-
-Manual mode
------------
-1) Put the j2k_to_image.exe and image_to_j2k.exe binaries of both revisions in the OPJ_Binaries directory (OPJ_Binaries/rev490 and OPJ_Binaries/rev493)  
-2) Start by initializing the validation with revision 490. 
-	a) Modify OPJ_Validate_init.bat and set the last line to "OPJ_Validate.exe OPJ_Param_File_v0_1.txt rev490"
-	b) Execute OPJ_Validate_init.bat
-3) Compare the reference files generated in the previous step with files generated with revision 493
-	a) Modify OPJ_Validate_run.bat and set the last line to "OPJ_Validate.exe OPJ_Param_File_v0_1.txt rev493"
-	b) Execute OPJ_Validate_run.bat
-4) Read the results in the binaries directory of revision 493 (OPJ_Binaries/rev493/report.txt)
-	Search for the word "ERROR:" in that file. 
-	If this word is not present in the report, this means that both codecs of rev490 and rev493 gave the same results.
-	Otherwise, it means that for certain encoding/decoding parameters, the codecs behave differently.
-
-	Example of error
-		Task 17
-		   MD5 file: temp/A_4_2K_24_185_CBR_WB_000.tif.md5
-		   Command line: "OPJ_Binaries/rev473/j2k_to_image.exe -i original/A_4_2K_24_185_CBR_WB_000.j2k -o temp/A_4_2K_24_185_CBR_WB_000.tif "
-		ERROR: temp/tempmd5.txt and temp/A_4_2K_24_185_CBR_WB_000.tif.md5 are different.
-		The codec seems to behave differently.
-
-	This means that the rev490 and rev493 created two different versions of file A_4_2K_24_185_CBR_WB_000.tif with the command line given above.
-	An error might have been caused by switching to this new revision.
-
-	Warning: Do not take the last line of the report.txt file into account ( Cool. All files passed the tests !) as it is a bug. Search for the word "ERROR:" to detect potential errors.
-5) If no error is detected, you can commit the changes to the OpenJPEG repository
-
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/linux_OPJ_Param_File_v0_1.txt b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/linux_OPJ_Param_File_v0_1.txt
deleted file mode 100644
index 0dafe2c..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/linux_OPJ_Param_File_v0_1.txt
+++ /dev/null
@@ -1,89 +0,0 @@
-#OPJ Parameter file
-#Version 0.1 - February 9th 2007
-#Usage: OPJ_Validate OpenJPEG_command_line
-#Example: OPJ_Validate image_to_j2k.exe -i original/Bretagne1.ppm -o original/Bretagne1.j2k -r 200, 50, 10
-#Attention: don't forget the *.exe extension for the executable file, and check the paths
-#
-image_to_j2k -i original/Bretagne1.ppm -o temp/Bretagne1_0.j2k -r 200,50,10
-j2k_to_image -i original/Bretagne1.j2k -o temp/Bretagne1.ppm
-image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_0.j2k -c [128,128],[128,128],[128,128] -r 100,20,2 -t 640,480 -b 32,32
-j2k_to_image -i original/Bretagne2.j2k -o temp/Bretagne2.ppm -r 2
-image_to_j2k -i original/Cevennes1.bmp -o temp/Cevennes1.j2k -r 10
-j2k_to_image -i original/Cevennes1.j2k -o temp/Cevennes1.bmp -l 2
-image_to_j2k -i original/Cevennes2.ppm -o temp/Cevennes2.jp2 -r 50
-j2k_to_image -i original/Cevennes2.jp2 -o temp/Cevennes2.ppm
-image_to_j2k -i original/Rome.bmp -o temp/Rome.jp2 -q 30,35,50 -p LRCP -n 3
-j2k_to_image -i original/Rome.jp2 -o temp/Rome.ppm
-image_to_j2k -i original/Bretagne1.ppm -o temp/Bretagne1_1.j2k -q 30,35,40 -n 2
-image_to_j2k -i original/Bretagne1.ppm -o temp/Bretagne1_2.j2k -q 30,35,40 -b 16,16 -c [101,101]
-image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_1.j2k -t 127,127 -p PCRL
-image_to_j2k -i original/X_4_2K_24_185_CBR_WB_000.tif -o temp/X_4_2K_24_185_CBR_WB_000.j2k -cinema2K 24
-image_to_j2k -i original/X_5_2K_24_235_CBR_STEM24_000.tif -o temp/X_5_2K_24_235_CBR_STEM24_000.j2k -cinema2K 48
-image_to_j2k -i original/X_6_2K_24_FULL_CBR_CIRCLE_000.tif -o temp/X_6_2K_24_FULL_CBR_CIRCLE_000.j2k -cinema2K 24
-#� remettre
-#image_to_j2k -i original/X_16_4K_24_185_CBR_WB_000.tif -o temp/X_16_4K_24_185_CBR_WB_000.j2k -cinema4K 
-j2k_to_image -i original/A_4_2K_24_185_CBR_WB_000.j2k -o temp/A_4_2K_24_185_CBR_WB_000.tif
-j2k_to_image -i original/B_5_2K_24_235_CBR_STEM24_000.j2k -o temp/B_5_2K_24_235_CBR_STEM24_000.tif
-j2k_to_image -i original/C_6_2K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_6_2K_24_FULL_CBR_CIRCLE_000.tif
-#� remettre
-#j2k_to_image -i original/C_18_4K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_18_4K_24_FULL_CBR_CIRCLE_000.tif
-j2k_to_image -i original/p0_01.j2k -o temp/p0_01.tif
-j2k_to_image -i original/p0_02.j2k -o temp/p0_02.tif
-j2k_to_image -i original/p0_03.j2k -o temp/p0_03.tif
-j2k_to_image -i original/p0_04.j2k -o temp/p0_04.tif
-#a remettre
-#j2k_to_image -i original/p0_07.j2k -o temp/p0_07.tif
-j2k_to_image -i original/p0_08.j2k -o temp/p0_08.tif
-j2k_to_image -i original/p0_09.j2k -o temp/p0_09.tif
-j2k_to_image -i original/p0_10.j2k -o temp/p0_10.tif
-j2k_to_image -i original/p0_11.j2k -o temp/p0_11.tif
-j2k_to_image -i original/p0_12.j2k -o temp/p0_12.tif
-j2k_to_image -i original/p0_14.j2k -o temp/p0_14.tif
-j2k_to_image -i original/p0_15.j2k -o temp/p0_15.tif
-j2k_to_image -i original/p0_16.j2k -o temp/p0_16.tif
-j2k_to_image -i original/p1_01.j2k -o temp/p1_01.tif
-j2k_to_image -i original/p1_02.j2k -o temp/p1_02.tif
-j2k_to_image -i original/p1_04.j2k -o temp/p1_04.tif
-j2k_to_image -i original/p1_05.j2k -o temp/p1_05.tif
-j2k_to_image -i original/p1_06.j2k -o temp/p1_06.tif
-image_to_j2k -i original/c0p0_01.pgx -o temp/c0p0_01.j2k
-image_to_j2k -i original/c0p0_02.pgx -o temp/c0p0_02.j2k
-image_to_j2k -i original/c0p0_03r0.pgx -o temp/c0p0_03r0.j2k
-image_to_j2k -i original/c0p0_03r1.pgx -o temp/c0p0_03r1.j2k
-image_to_j2k -i original/c0p0_04.pgx -o temp/c00_p04.j2k
-image_to_j2k -i original/c0p0_05.pgx -o temp/c0p0_05.j2k
-image_to_j2k -i original/c0p0_06.pgx -o temp/c0p0_06.j2k
-image_to_j2k -i original/c0p0_07.pgx -o temp/c0p0_07.j2k
-image_to_j2k -i original/c0p0_08.pgx -o temp/c0p0_08.j2k
-image_to_j2k -i original/c0p0_09.pgx -o temp/c0p0_09.j2k
-image_to_j2k -i original/c0p0_10.pgx -o temp/c0p0_10.j2k
-image_to_j2k -i original/c0p0_11.pgx -o temp/c0p0_11.j2k
-image_to_j2k -i original/c0p0_12.pgx -o temp/c0p0_12.j2k
-image_to_j2k -i original/c0p0_13.pgx -o temp/c0p0_13.j2k
-image_to_j2k -i original/c0p0_14.pgx -o temp/c0p0_14.j2k
-image_to_j2k -i original/c0p0_15r0.pgx -o temp/c0p0_15r0.j2k
-image_to_j2k -i original/c0p0_15r1.pgx -o temp/c0p0_15r1.j2k
-image_to_j2k -i original/c0p0_16.pgx -o temp/c0p0_16.j2k
-image_to_j2k -i original/c0p1_04r0.pgx -o temp/c0p1_04r0.j2k
-image_to_j2k -i original/c0p1_05.pgx -o temp/c0p1_05.j2k
-image_to_j2k -i original/c1p0_01_0.pgx -o temp/c1p0_01_0.j2k
-image_to_j2k -i original/c1p0_02_0.pgx -o temp/c1p0_02_0.j2k
-image_to_j2k -i original/c1p0_03_0.pgx -o temp/c1p0_03_0.j2k
-image_to_j2k -i original/c1p0_04_0.pgx -o temp/c1p0_04_0.j2k
-image_to_j2k -i original/c1p0_05_0.pgx -o temp/c1p0_05_0.j2k
-image_to_j2k -i original/c1p0_06_0.pgx -o temp/c1p0_06_0.j2k
-image_to_j2k -i original/c1p0_07_0.pgx -o temp/c1p0_07_0.j2k
-image_to_j2k -i original/c1p0_08_0.pgx -o temp/c1p0_08_0.j2k
-image_to_j2k -i original/c1p0_09_0.pgx -o temp/c1p0_09_0.j2k
-image_to_j2k -i original/c1p0_10_0.pgx -o temp/c1p0_10_0.j2k
-image_to_j2k -i original/c1p0_11_0.pgx -o temp/c1p0_11_0.j2k
-image_to_j2k -i original/c1p0_12_0.pgx -o temp/c1p0_12_0.j2k
-image_to_j2k -i original/c1p0_13_0.pgx -o temp/c1p0_13_0.j2k
-image_to_j2k -i original/c1p0_14_0.pgx -o temp/c1p0_14_0.j2k
-image_to_j2k -i original/c1p0_15_0.pgx -o temp/c1p0_15_0.j2k
-image_to_j2k -i original/c1p0_16_0.pgx -o temp/c1p0_16_0.j2k
-image_to_j2k -i original/c1p1_02_0.pgx -o temp/c1p1_02_0.j2k
-image_to_j2k -i original/c1p1_05_0.pgx -o temp/c1p1_05_0.j2k
-image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_2.j2k -s 2,2 -SOP
-image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_3.j2k -EPH -M 38
-image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_4.j2k -d 150,300 -r 800
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.c b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.c
deleted file mode 100644
index 735a27c..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- **********************************************************************
- ** md5.c                                                            **
- ** RSA Data Security, Inc. MD5 Message Digest Algorithm             **
- ** Created: 2/17/90 RLR                                             **
- ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version                  **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- **                                                                  **
- ** License to copy and use this software is granted provided that   **
- ** it is identified as the "RSA Data Security, Inc. MD5 Message     **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function.                                       **
- **                                                                  **
- ** License is also granted to make and use derivative works         **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD5 Message Digest Algorithm" in all         **
- ** material mentioning or referencing the derived work.             **
- **                                                                  **
- ** RSA Data Security, Inc. makes no representations concerning      **
- ** either the merchantability of this software or the suitability   **
- ** of this software for any particular purpose.  It is provided "as **
- ** is" without express or implied warranty of any kind.             **
- **                                                                  **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software.                                   **
- **********************************************************************
- */
-
-/* -- include the following line if the md5.h header file is separate -- */
-#include "md5.h" 
-
-/* forward declaration */
-static void Transform ();
-
-static unsigned char PADDING[64] = {
-  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-/* F, G and H are basic MD5 functions: selection, majority, parity */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z))) 
-
-/* ROTATE_LEFT rotates x left n bits */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
-/* Rotation is separate from addition to prevent recomputation */
-#define FF(a, b, c, d, x, s, ac) \
-  {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-#define GG(a, b, c, d, x, s, ac) \
-  {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-#define HH(a, b, c, d, x, s, ac) \
-  {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-#define II(a, b, c, d, x, s, ac) \
-  {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
-   (a) = ROTATE_LEFT ((a), (s)); \
-   (a) += (b); \
-  }
-
-void MD5Init (mdContext)
-MD5_CTX *mdContext;
-{
-  mdContext->i[0] = mdContext->i[1] = (UINT4)0;
-
-  /* Load magic initialization constants.
-   */
-  mdContext->buf[0] = (UINT4)0x67452301;
-  mdContext->buf[1] = (UINT4)0xefcdab89;
-  mdContext->buf[2] = (UINT4)0x98badcfe;
-  mdContext->buf[3] = (UINT4)0x10325476;
-}
-
-void MD5Update (mdContext, inBuf, inLen)
-MD5_CTX *mdContext;
-unsigned char *inBuf;
-unsigned int inLen;
-{
-  UINT4 in[16];
-  int mdi;
-  unsigned int i, ii;
-
-  /* compute number of bytes mod 64 */
-  mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
-  /* update number of bits */
-  if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
-    mdContext->i[1]++;
-  mdContext->i[0] += ((UINT4)inLen << 3);
-  mdContext->i[1] += ((UINT4)inLen >> 29);
-
-  while (inLen--) {
-    /* add new character to buffer, increment mdi */
-    mdContext->in[mdi++] = *inBuf++;
-
-    /* transform if necessary */
-    if (mdi == 0x40) {
-      for (i = 0, ii = 0; i < 16; i++, ii += 4)
-        in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
-                (((UINT4)mdContext->in[ii+2]) << 16) |
-                (((UINT4)mdContext->in[ii+1]) << 8) |
-                ((UINT4)mdContext->in[ii]);
-      Transform (mdContext->buf, in);
-      mdi = 0;
-    }
-  }
-}
-
-void MD5Final (mdContext)
-MD5_CTX *mdContext;
-{
-  UINT4 in[16];
-  int mdi;
-  unsigned int i, ii;
-  unsigned int padLen;
-
-  /* save number of bits */
-  in[14] = mdContext->i[0];
-  in[15] = mdContext->i[1];
-
-  /* compute number of bytes mod 64 */
-  mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
-  /* pad out to 56 mod 64 */
-  padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
-  MD5Update (mdContext, PADDING, padLen);
-
-  /* append length in bits and transform */
-  for (i = 0, ii = 0; i < 14; i++, ii += 4)
-    in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
-            (((UINT4)mdContext->in[ii+2]) << 16) |
-            (((UINT4)mdContext->in[ii+1]) << 8) |
-            ((UINT4)mdContext->in[ii]);
-  Transform (mdContext->buf, in);
-
-  /* store buffer in digest */
-  for (i = 0, ii = 0; i < 4; i++, ii += 4) {
-    mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
-    mdContext->digest[ii+1] =
-      (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
-    mdContext->digest[ii+2] =
-      (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
-    mdContext->digest[ii+3] =
-      (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
-  }
-}
-
-/* Basic MD5 step. Transform buf based on in.
- */
-static void Transform (buf, in)
-UINT4 *buf;
-UINT4 *in;
-{
-  UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
-
-  /* Round 1 */
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-  FF ( a, b, c, d, in[ 0], S11, 3614090360); /* 1 */
-  FF ( d, a, b, c, in[ 1], S12, 3905402710); /* 2 */
-  FF ( c, d, a, b, in[ 2], S13,  606105819); /* 3 */
-  FF ( b, c, d, a, in[ 3], S14, 3250441966); /* 4 */
-  FF ( a, b, c, d, in[ 4], S11, 4118548399); /* 5 */
-  FF ( d, a, b, c, in[ 5], S12, 1200080426); /* 6 */
-  FF ( c, d, a, b, in[ 6], S13, 2821735955); /* 7 */
-  FF ( b, c, d, a, in[ 7], S14, 4249261313); /* 8 */
-  FF ( a, b, c, d, in[ 8], S11, 1770035416); /* 9 */
-  FF ( d, a, b, c, in[ 9], S12, 2336552879); /* 10 */
-  FF ( c, d, a, b, in[10], S13, 4294925233); /* 11 */
-  FF ( b, c, d, a, in[11], S14, 2304563134); /* 12 */
-  FF ( a, b, c, d, in[12], S11, 1804603682); /* 13 */
-  FF ( d, a, b, c, in[13], S12, 4254626195); /* 14 */
-  FF ( c, d, a, b, in[14], S13, 2792965006); /* 15 */
-  FF ( b, c, d, a, in[15], S14, 1236535329); /* 16 */
-
-  /* Round 2 */
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-  GG ( a, b, c, d, in[ 1], S21, 4129170786); /* 17 */
-  GG ( d, a, b, c, in[ 6], S22, 3225465664); /* 18 */
-  GG ( c, d, a, b, in[11], S23,  643717713); /* 19 */
-  GG ( b, c, d, a, in[ 0], S24, 3921069994); /* 20 */
-  GG ( a, b, c, d, in[ 5], S21, 3593408605); /* 21 */
-  GG ( d, a, b, c, in[10], S22,   38016083); /* 22 */
-  GG ( c, d, a, b, in[15], S23, 3634488961); /* 23 */
-  GG ( b, c, d, a, in[ 4], S24, 3889429448); /* 24 */
-  GG ( a, b, c, d, in[ 9], S21,  568446438); /* 25 */
-  GG ( d, a, b, c, in[14], S22, 3275163606); /* 26 */
-  GG ( c, d, a, b, in[ 3], S23, 4107603335); /* 27 */
-  GG ( b, c, d, a, in[ 8], S24, 1163531501); /* 28 */
-  GG ( a, b, c, d, in[13], S21, 2850285829); /* 29 */
-  GG ( d, a, b, c, in[ 2], S22, 4243563512); /* 30 */
-  GG ( c, d, a, b, in[ 7], S23, 1735328473); /* 31 */
-  GG ( b, c, d, a, in[12], S24, 2368359562); /* 32 */
-
-  /* Round 3 */
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-  HH ( a, b, c, d, in[ 5], S31, 4294588738); /* 33 */
-  HH ( d, a, b, c, in[ 8], S32, 2272392833); /* 34 */
-  HH ( c, d, a, b, in[11], S33, 1839030562); /* 35 */
-  HH ( b, c, d, a, in[14], S34, 4259657740); /* 36 */
-  HH ( a, b, c, d, in[ 1], S31, 2763975236); /* 37 */
-  HH ( d, a, b, c, in[ 4], S32, 1272893353); /* 38 */
-  HH ( c, d, a, b, in[ 7], S33, 4139469664); /* 39 */
-  HH ( b, c, d, a, in[10], S34, 3200236656); /* 40 */
-  HH ( a, b, c, d, in[13], S31,  681279174); /* 41 */
-  HH ( d, a, b, c, in[ 0], S32, 3936430074); /* 42 */
-  HH ( c, d, a, b, in[ 3], S33, 3572445317); /* 43 */
-  HH ( b, c, d, a, in[ 6], S34,   76029189); /* 44 */
-  HH ( a, b, c, d, in[ 9], S31, 3654602809); /* 45 */
-  HH ( d, a, b, c, in[12], S32, 3873151461); /* 46 */
-  HH ( c, d, a, b, in[15], S33,  530742520); /* 47 */
-  HH ( b, c, d, a, in[ 2], S34, 3299628645); /* 48 */
-
-  /* Round 4 */
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-  II ( a, b, c, d, in[ 0], S41, 4096336452); /* 49 */
-  II ( d, a, b, c, in[ 7], S42, 1126891415); /* 50 */
-  II ( c, d, a, b, in[14], S43, 2878612391); /* 51 */
-  II ( b, c, d, a, in[ 5], S44, 4237533241); /* 52 */
-  II ( a, b, c, d, in[12], S41, 1700485571); /* 53 */
-  II ( d, a, b, c, in[ 3], S42, 2399980690); /* 54 */
-  II ( c, d, a, b, in[10], S43, 4293915773); /* 55 */
-  II ( b, c, d, a, in[ 1], S44, 2240044497); /* 56 */
-  II ( a, b, c, d, in[ 8], S41, 1873313359); /* 57 */
-  II ( d, a, b, c, in[15], S42, 4264355552); /* 58 */
-  II ( c, d, a, b, in[ 6], S43, 2734768916); /* 59 */
-  II ( b, c, d, a, in[13], S44, 1309151649); /* 60 */
-  II ( a, b, c, d, in[ 4], S41, 4149444226); /* 61 */
-  II ( d, a, b, c, in[11], S42, 3174756917); /* 62 */
-  II ( c, d, a, b, in[ 2], S43,  718787259); /* 63 */
-  II ( b, c, d, a, in[ 9], S44, 3951481745); /* 64 */
-
-  buf[0] += a;
-  buf[1] += b;
-  buf[2] += c;
-  buf[3] += d;
-}
-
-/*
- **********************************************************************
- ** End of md5.c                                                     **
- ******************************* (cut) ********************************
- */
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.h b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.h
deleted file mode 100644
index 6fb35cf..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/md5.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- **********************************************************************
- ** md5.h -- Header file for implementation of MD5                   **
- ** RSA Data Security, Inc. MD5 Message Digest Algorithm             **
- ** Created: 2/17/90 RLR                                             **
- ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version              **
- ** Revised (for MD5): RLR 4/27/91                                   **
- **   -- G modified to have y&~z instead of y&z                      **
- **   -- FF, GG, HH modified to add in last register done            **
- **   -- Access pattern: round 2 works mod 5, round 3 works mod 3    **
- **   -- distinct additive constant for each step                    **
- **   -- round 4 added, working mod 7                                **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- **                                                                  **
- ** License to copy and use this software is granted provided that   **
- ** it is identified as the "RSA Data Security, Inc. MD5 Message     **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function.                                       **
- **                                                                  **
- ** License is also granted to make and use derivative works         **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD5 Message Digest Algorithm" in all         **
- ** material mentioning or referencing the derived work.             **
- **                                                                  **
- ** RSA Data Security, Inc. makes no representations concerning      **
- ** either the merchantability of this software or the suitability   **
- ** of this software for any particular purpose.  It is provided "as **
- ** is" without express or implied warranty of any kind.             **
- **                                                                  **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software.                                   **
- **********************************************************************
- */
-
-/* typedef a 32 bit type */
-typedef unsigned long int UINT4;
-
-/* Data structure for MD5 (Message Digest) computation */
-typedef struct {
-  UINT4 i[2];                   /* number of _bits_ handled mod 2^64 */
-  UINT4 buf[4];                                    /* scratch buffer */
-  unsigned char in[64];                              /* input buffer */
-  unsigned char digest[16];     /* actual digest after MD5Final call */
-} MD5_CTX;
-
-void MD5Init ();
-void MD5Update ();
-void MD5Final ();
-
-/*
- **********************************************************************
- ** End of md5.h                                                     **
- ******************************* (cut) ********************************
- */
diff --git a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/original/README.txt b/Utilities/gdcmopenjpeg-v1/OPJ_Validate/original/README.txt
deleted file mode 100644
index d78d1bd..0000000
--- a/Utilities/gdcmopenjpeg-v1/OPJ_Validate/original/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-Download the source images into this directory from http://www.openjpeg.org/OPJ_Validate_OriginalImages.7z
diff --git a/Utilities/gdcmopenjpeg-v1/OpenJPEG.rc b/Utilities/gdcmopenjpeg-v1/OpenJPEG.rc
deleted file mode 100644
index 4711c57..0000000
--- a/Utilities/gdcmopenjpeg-v1/OpenJPEG.rc
+++ /dev/null
@@ -1,109 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// French (France) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
-#ifdef _WIN32
-LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifndef _MAC
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,1,0,0
- PRODUCTVERSION 1,1,0,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x40004L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-BEGIN
-    BLOCK "StringFileInfo"
-    BEGIN
-        BLOCK "000004b0"
-        BEGIN
-            VALUE "Comments", "The OpenJPEG library is an open-source JPEG 2000 codec. \0"
-            VALUE "CompanyName", "OpenJPEG\0"
-            VALUE "FileDescription", "OpenJPEG\0"
-            VALUE "FileVersion", "1, 1, 0, 0\0"
-            VALUE "InternalName", "OpenJPEG\0"
-            VALUE "LegalCopyright", "Copyright � 2002-2007, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium\0"
-            VALUE "LegalTrademarks", "See http://www.openjpeg.org for details\0"
-            VALUE "OriginalFilename", "OpenJPEG.dll\0"
-            VALUE "PrivateBuild", "\0"
-            VALUE "ProductName", "OpenJPEG\0"
-            VALUE "ProductVersion", "1, 1, 0, 0\0"
-            VALUE "SpecialBuild", "\0"
-        END
-    END
-    BLOCK "VarFileInfo"
-    BEGIN
-        VALUE "Translation", 0x0, 1200
-    END
-END
-
-#endif    // !_MAC
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE 
-BEGIN
-    "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE 
-BEGIN
-    "#include ""afxres.h""\r\n"
-    "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE 
-BEGIN
-    "\r\n"
-    "\0"
-END
-
-#endif    // APSTUDIO_INVOKED
-
-#endif    // French (France) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif    // not APSTUDIO_INVOKED
-
diff --git a/Utilities/gdcmopenjpeg-v1/README b/Utilities/gdcmopenjpeg-v1/README
deleted file mode 100644
index 031cf3d..0000000
--- a/Utilities/gdcmopenjpeg-v1/README
+++ /dev/null
@@ -1 +0,0 @@
-see INSTALL for installation procedures.
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/README.msvc b/Utilities/gdcmopenjpeg-v1/README.msvc
deleted file mode 100644
index fc9ea89..0000000
--- a/Utilities/gdcmopenjpeg-v1/README.msvc
+++ /dev/null
@@ -1,40 +0,0 @@
-How to compile the library under MS VC++ 6.0
---------------------------------------------
-
-The library comes in two versions : 
-- a static library that can be linked against any C/C++ program
-- a Dynamic Link Library (Windows DLL) that can be used in any C/C++ program and in most interpreted languages (e.g. VB, C#, ...). 
-
-In order to compile the library version *or* the DLL version, you will have to : 
-
-1) Open the MSVC workspace named LibOpenJPEG.dsw
-2) Set the choosen target as the active project, that means : 
- a) Go to the Menu 'Build -> Set Active Configuration'
- b) Choose one of the following configuration : 
- - DllOpenJPEG - Win32 Release => creates a DLL in release mode named OpenJPEG.dll
- - DllOpenJPEG - Win32 Debug => creates a DLL in debug mode named OpenJPEGd.dll 
- - LibOpenJPEG - Win32 Release => creates a static library in release mode named LibOpenJPEG.lib
- - LibOpenJPEG - Win32 Debug => creates a static library in debug mode named LibOpenJPEGd.lib
-3) Build the project : Menu -> Build -> Rebuild All
-
-The build process will create a directory named 'dist' that will contain all you need in order to use the library. 
-
-Simple codec compilation
-------------------------
-
-Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and use one of the following projects to build an encoder and decoder respectively:
-- image_to_j2k.dsw
-- j2k_to_image.dsw
-
-IMPORTANT NOTE : 
-----------------
-
-The encoder and decoder samples are configured to use the static version of the library. A link to the LibOpenJPEG static project is included in these projects so that you can build both a codec and the library in a single pass. 
-
-However, you MUST NOTE that in order to use LibOpenJPEG as a static library in your program, you NEED to add the following compiler directive to your project : OPJ_STATIC
-Look at the menu 'Project -> Settings -> C/C++ tab -> preprocessor definition' to see how this is configured. 
-When using OpenJPEG as a DLL, this compiler directive MUST NOT be used. 
-
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/codec/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/codec/CMakeLists.txt
deleted file mode 100644
index e1ed267..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/CMakeLists.txt
+++ /dev/null
@@ -1,102 +0,0 @@
-  # Build the demo app, small examples
-
-# First thing define the common source:
-set(common_SRCS
-  convert.c
-  index.c
-  ${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/common/color.c
-)
-
-# If not getopt was found then add it to the lib:
-if(DONT_HAVE_GETOPT)
-  set(common_SRCS
-    ${common_SRCS}
-    ${OPENJPEG_SOURCE_DIR}/common/getopt.c
-  )
-endif()
-
-# Headers file are located here:
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  ${LCMS_INCLUDE_DIR}
-  ${OPENJPEG_SOURCE_DIR}/common
-  )
-if(PNG_FOUND)
-  include_directories(${PNG_INCLUDE_DIR})
-endif()
-if(TIFF_FOUND)
-  include_directories(${TIFF_INCLUDE_DIR})
-endif()
-
-if(WIN32)
-  if(BUILD_SHARED_LIBS)
-    add_definitions(-DOPJ_EXPORTS)
-  else()
-    add_definitions(-DOPJ_STATIC)
-  endif()
-endif()
-
-# Loop over all executables:
-foreach(exe j2k_to_image image_to_j2k j2k_dump)
-  add_executable(${exe} ${exe}.c ${common_SRCS})
-  target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
-  if(PNG_FOUND)
-    target_link_libraries(${exe} ${PNG_LIBRARIES})
-  endif()
-  if(TIFF_FOUND)
-    target_link_libraries(${exe} ${TIFF_LIBRARIES})
-  endif()
-  add_test(NAME ${exe} COMMAND ${exe})
-  # calling those exe without option will make them fail always:
-  set_tests_properties(${exe} PROPERTIES WILL_FAIL TRUE)
-  # On unix you need to link to the math library:
-  if(UNIX)
-    target_link_libraries(${exe} m)
-  endif()
-  # Install exe
-  install(TARGETS ${exe}
-    EXPORT OpenJPEGTargets
-    DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
-  )
-endforeach()
-
-# Install man pages
-install(
-  FILES       ../doc/man/man1/image_to_j2k.1
-              ../doc/man/man1/j2k_dump.1
-              ../doc/man/man1/j2k_to_image.1
-  DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
-#
-
-if(BUILD_TESTING)
-# Do testing here, once we know the examples are being built:
-file(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
-  "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
-  "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
-  "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
-  )
-
-foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
-  get_filename_component(filename_temp ${filename} NAME)
-  get_filename_component(filename_ext ${filename} EXT)
-  execute_process(COMMAND j2k_dump -i ${filename}
-    OUTPUT_VARIABLE dump_success
-    OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump
-    ERROR_QUIET
-  )
-  if(dump_success)
-  file(READ ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump numcomp_file)
-  string(REGEX REPLACE ".*numcomps=([0-9]+).*" "\\1"
-    numcomps "${numcomp_file}")
-  #message( "found:${output_variable} for ${filename_temp}" )
-  endif()
-  add_test(NAME dump-${filename_temp} COMMAND j2k_dump -i ${filename})
-  foreach(codec_type ppm pgx bmp tif raw tga png)
-    add_test(NAME j2i-${filename_temp}-${codec_type} COMMAND j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
-    add_test(NAME i2j-${filename_temp}-${codec_type} COMMAND image_to_j2k -i ${filename_temp}.${codec_type} -o ${filename_temp}.${codec_type}${filename_ext})
-    #if(UNIX)
-    #  add_test(cmp-${filename_temp}-${codec_type} cmp ${filename} ${filename_temp}.${codec_type}${filename_ext})
-    #endif()
-  endforeach()
-endforeach()
-endif()
diff --git a/Utilities/gdcmopenjpeg-v1/codec/README b/Utilities/gdcmopenjpeg-v1/codec/README
deleted file mode 100644
index 8004998..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/README
+++ /dev/null
@@ -1,8 +0,0 @@
-Simple codec compilation
-------------------------
-Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively:
-
-gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-
-You should add '-L..' to those lines if you did not use the 'install' target when building the library.
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/codec/convert.c b/Utilities/gdcmopenjpeg-v1/codec/convert.c
deleted file mode 100644
index 25e715b..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/convert.c
+++ /dev/null
@@ -1,2686 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "opj_config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_LIBTIFF
-#ifdef _WIN32
-#include "../libs/libtiff/tiffio.h"
-#else
-#include <tiffio.h>
-#endif /* _WIN32 */
-#endif /* HAVE_LIBTIFF */
-
-#ifdef HAVE_LIBPNG
-#ifdef _WIN32
-#include "../libs/png/png.h"
-#else
-#include <png.h>
-#endif /* _WIN32 */
-#endif /* HAVE_LIBPNG */
-
-#include "../libopenjpeg/openjpeg.h"
-#include "convert.h"
-
-/*
- * Get logarithm of an integer and round downwards.
- *
- * log2(a)
- */
-static int int_floorlog2(int a) {
-	int l;
-	for (l = 0; a > 1; l++) {
-		a >>= 1;
-	}
-	return l;
-}
-
-/*
- * Divide an integer by a power of 2 and round upwards.
- *
- * a divided by 2^b
- */
-static int int_ceildivpow2(int a, int b) {
-	return (a + (1 << b) - 1) >> b;
-}
-
-/*
- * Divide an integer and round upwards.
- *
- * a divided by b
- */
-static int int_ceildiv(int a, int b) {
-	return (a + b - 1) / b;
-}
-
-
-/* -->> -->> -->> -->>
-
-  TGA IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-// TGA header definition.
-#pragma pack(push,1) // Pack structure byte aligned
-typedef struct tga_header
-{                           
-    unsigned char   id_length;              /* Image id field length    */
-    unsigned char   colour_map_type;        /* Colour map type          */
-    unsigned char   image_type;             /* Image type               */
-    /*
-    ** Colour map specification
-    */
-    unsigned short  colour_map_index;       /* First entry index        */
-    unsigned short  colour_map_length;      /* Colour map length        */
-    unsigned char   colour_map_entry_size;  /* Colour map entry size    */
-    /*
-    ** Image specification
-    */
-    unsigned short  x_origin;               /* x origin of image        */
-    unsigned short  y_origin;               /* u origin of image        */
-    unsigned short  image_width;            /* Image width              */
-    unsigned short  image_height;           /* Image height             */
-    unsigned char   pixel_depth;            /* Pixel depth              */
-    unsigned char   image_desc;             /* Image descriptor         */
-} tga_header;
-#pragma pack(pop) // Return to normal structure packing alignment.
-
-int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, 
-	unsigned int *width, unsigned int *height, int *flip_image)
-{
-	int palette_size;
-	tga_header tga ;
-
-	if (!bits_per_pixel || !width || !height || !flip_image)
-		return 0;
-	
-	// Read TGA header
-	fread((unsigned char*)&tga, sizeof(tga_header), 1, fp);
-
-	*bits_per_pixel = tga.pixel_depth;
-	
-	*width  = tga.image_width;
-	*height = tga.image_height ;
-
-	// Ignore tga identifier, if present ...
-	if (tga.id_length)
-	{
-		unsigned char *id = (unsigned char *) malloc(tga.id_length);
-		fread(id, tga.id_length, 1, fp);
-		free(id);  
-	}
-
-	// Test for compressed formats ... not yet supported ...
-	// Note :-  9 - RLE encoded palettized.
-	//	  	   10 - RLE encoded RGB.
-	if (tga.image_type > 8)
-	{
-		fprintf(stderr, "Sorry, compressed tga files are not currently supported.\n");
-		return 0 ;
-	}
-
-	*flip_image = !(tga.image_desc & 32);
-
-	// Palettized formats are not yet supported, skip over the palette, if present ... 
-	palette_size = tga.colour_map_length * (tga.colour_map_entry_size/8);
-	
-	if (palette_size>0)
-	{
-		fprintf(stderr, "File contains a palette - not yet supported.");
-		fseek(fp, palette_size, SEEK_CUR);
-	}
-	return 1;
-}
-
-int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, 
-	bool flip_image)
-{
-	tga_header tga;
-
-	if (!bits_per_pixel || !width || !height)
-		return 0;
-
-	memset(&tga, 0, sizeof(tga_header));
-
-	tga.pixel_depth = bits_per_pixel;
-	tga.image_width  = width;
-	tga.image_height = height;
-	tga.image_type = 2; // Uncompressed.
-	tga.image_desc = 8; // 8 bits per component.
-
-	if (flip_image)
-		tga.image_desc |= 32;
-
-	// Write TGA header
-	fwrite((unsigned char*)&tga, sizeof(tga_header), 1, fp);
-
-	return 1;
-}
-
-opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
-	FILE *f;
-	opj_image_t *image;
-	unsigned int image_width, image_height, pixel_bit_depth;
-	unsigned int x, y;
-	int flip_image=0;
-	opj_image_cmptparm_t cmptparm[4];	/* maximum 4 components */
-	int numcomps;
-	OPJ_COLOR_SPACE color_space;
-	bool mono ;
-	bool save_alpha;
-	int subsampling_dx, subsampling_dy;
-	int i;	
-
-	f = fopen(filename, "rb");
-	if (!f) {
-		fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-		return 0;
-	}
-
-	if (!tga_readheader(f, &pixel_bit_depth, &image_width, &image_height, &flip_image))
-		return NULL;
-
-	// We currently only support 24 & 32 bit tga's ...
-	if (!((pixel_bit_depth == 24) || (pixel_bit_depth == 32)))
-		return NULL;
-
-	/* initialize image components */   
-	memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
-
-	mono = (pixel_bit_depth == 8) || (pixel_bit_depth == 16);  // Mono with & without alpha.
-	save_alpha = (pixel_bit_depth == 16) || (pixel_bit_depth == 32); // Mono with alpha, or RGB with alpha
-
-	if (mono) {
-		color_space = CLRSPC_GRAY;
-		numcomps = save_alpha ? 2 : 1;
-	}	
-	else {
-		numcomps = save_alpha ? 4 : 3;
-		color_space = CLRSPC_SRGB;
-	}
-
-	subsampling_dx = parameters->subsampling_dx;
-	subsampling_dy = parameters->subsampling_dy;
-
-	for (i = 0; i < numcomps; i++) {
-		cmptparm[i].prec = 8;
-		cmptparm[i].bpp = 8;
-		cmptparm[i].sgnd = 0;
-		cmptparm[i].dx = subsampling_dx;
-		cmptparm[i].dy = subsampling_dy;
-		cmptparm[i].w = image_width;
-		cmptparm[i].h = image_height;
-	}
-
-	/* create the image */
-	image = opj_image_create(numcomps, &cmptparm[0], color_space);
-
-	if (!image)
-		return NULL;
-
-	/* set image offset and reference grid */
-	image->x0 = parameters->image_offset_x0;
-	image->y0 = parameters->image_offset_y0;
-	image->x1 =	!image->x0 ? (image_width - 1) * subsampling_dx + 1 : image->x0 + (image_width - 1) * subsampling_dx + 1;
-	image->y1 =	!image->y0 ? (image_height - 1) * subsampling_dy + 1 : image->y0 + (image_height - 1) * subsampling_dy + 1;
-
-	/* set image data */
-	for (y=0; y < image_height; y++) 
-	{
-		int index;
-
-		if (flip_image)
-			index = (image_height-y-1)*image_width;
-		else
-			index = y*image_width;
-
-		if (numcomps==3)
-		{
-			for (x=0;x<image_width;x++) 
-			{
-				unsigned char r,g,b;
-				fread(&b, 1, 1, f);
-				fread(&g, 1, 1, f);
-				fread(&r, 1, 1, f);
-
-				image->comps[0].data[index]=r;
-				image->comps[1].data[index]=g;
-				image->comps[2].data[index]=b;
-				index++;
-			}
-		}
-		else if (numcomps==4)
-		{
-			for (x=0;x<image_width;x++) 
-			{
-				unsigned char r,g,b,a;
-				fread(&b, 1, 1, f);
-				fread(&g, 1, 1, f);
-				fread(&r, 1, 1, f);
-				fread(&a, 1, 1, f);
-
-				image->comps[0].data[index]=r;
-				image->comps[1].data[index]=g;
-				image->comps[2].data[index]=b;
-				image->comps[3].data[index]=a;
-				index++;
-			}
-		}
-		else {
-			fprintf(stderr, "Currently unsupported bit depth : %s\n", filename);
-		}
-	}	
-	return image;
-}
-
-int imagetotga(opj_image_t * image, const char *outfile) {
-	int width, height, bpp, x, y;
-	bool write_alpha;
-	int i;
-	unsigned int alpha_channel;
-	float r,g,b,a;
-	unsigned char value;
-	float scale;
-	FILE *fdest;
-
-	fdest = fopen(outfile, "wb");
-	if (!fdest) {
-		fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-		return 1;
-	}
-
-	for (i = 0; i < image->numcomps-1; i++)	{
-		if ((image->comps[0].dx != image->comps[i+1].dx) 
-			||(image->comps[0].dy != image->comps[i+1].dy) 
-			||(image->comps[0].prec != image->comps[i+1].prec))	{
-      fprintf(stderr, "Unable to create a tga file with such J2K image charateristics.");
-      return 1;
-   }
-	}
-
-	width = image->comps[0].w;
-	height = image->comps[0].h; 
-
-	// Mono with alpha, or RGB with alpha.
-	write_alpha = (image->numcomps==2) || (image->numcomps==4);   
-
-	// Write TGA header 
-	bpp = write_alpha ? 32 : 24;
-	if (!tga_writeheader(fdest, bpp, width , height, true))
-		return 1;
-
-	alpha_channel = image->numcomps-1; 
-
-	scale = 255.0f / (float)((1<<image->comps[0].prec)-1);
-
-	for (y=0; y < height; y++) {
-		unsigned int index=y*width;
-
-		for (x=0; x < width; x++, index++)	{
-			r = (float)(image->comps[0].data[index]);
-
-			if (image->numcomps>2) {
-				g = (float)(image->comps[1].data[index]);
-				b = (float)(image->comps[2].data[index]);
-			}
-			else  {// Greyscale ...
-				g = r;
-				b = r;
-			}
-
-			// TGA format writes BGR ...
-			value = (unsigned char)(b*scale);
-			fwrite(&value,1,1,fdest);
-
-			value = (unsigned char)(g*scale);
-			fwrite(&value,1,1,fdest);
-
-			value = (unsigned char)(r*scale);
-			fwrite(&value,1,1,fdest);
-
-			if (write_alpha) {
-				a = (float)(image->comps[alpha_channel].data[index]);
-				value = (unsigned char)(a*scale);
-				fwrite(&value,1,1,fdest);
-			}
-		}
-	}
-
-	return 0;
-}
-
-/* -->> -->> -->> -->>
-
-  BMP IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-/* WORD defines a two byte word */
-typedef unsigned short int WORD;
-
-/* DWORD defines a four byte word */
-typedef unsigned long int DWORD;
-
-typedef struct {
-  WORD bfType;			/* 'BM' for Bitmap (19776) */
-  DWORD bfSize;			/* Size of the file        */
-  WORD bfReserved1;		/* Reserved : 0            */
-  WORD bfReserved2;		/* Reserved : 0            */
-  DWORD bfOffBits;		/* Offset                  */
-} BITMAPFILEHEADER_t;
-
-typedef struct {
-  DWORD biSize;			/* Size of the structure in bytes */
-  DWORD biWidth;		/* Width of the image in pixels */
-  DWORD biHeight;		/* Heigth of the image in pixels */
-  WORD biPlanes;		/* 1 */
-  WORD biBitCount;		/* Number of color bits by pixels */
-  DWORD biCompression;		/* Type of encoding 0: none 1: RLE8 2: RLE4 */
-  DWORD biSizeImage;		/* Size of the image in bytes */
-  DWORD biXpelsPerMeter;	/* Horizontal (X) resolution in pixels/meter */
-  DWORD biYpelsPerMeter;	/* Vertical (Y) resolution in pixels/meter */
-  DWORD biClrUsed;		/* Number of color used in the image (0: ALL) */
-  DWORD biClrImportant;		/* Number of important color (0: ALL) */
-} BITMAPINFOHEADER_t;
-
-opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters) {
-	int subsampling_dx = parameters->subsampling_dx;
-	int subsampling_dy = parameters->subsampling_dy;
-
-	int i, numcomps, w, h;
-	OPJ_COLOR_SPACE color_space;
-	opj_image_cmptparm_t cmptparm[3];	/* maximum of 3 components */
-	opj_image_t * image = NULL;
-
-	FILE *IN;
-	BITMAPFILEHEADER_t File_h;
-	BITMAPINFOHEADER_t Info_h;
-	unsigned char *RGB;
-	unsigned char *table_R, *table_G, *table_B;
-	unsigned int j, PAD = 0;
-
-	int x, y, index;
-	int gray_scale = 1, not_end_file = 1; 
-
-	unsigned int line = 0, col = 0;
-	unsigned char v, v2;
-	DWORD W, H;
-  
-	IN = fopen(filename, "rb");
-	if (!IN) {
-		fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-		return 0;
-	}
-	
-	File_h.bfType = getc(IN);
-	File_h.bfType = (getc(IN) << 8) + File_h.bfType;
-	
-	if (File_h.bfType != 19778) {
-		fprintf(stderr,"Error, not a BMP file!\n");
-		return 0;
-	} else {
-		/* FILE HEADER */
-		/* ------------- */
-		File_h.bfSize = getc(IN);
-		File_h.bfSize = (getc(IN) << 8) + File_h.bfSize;
-		File_h.bfSize = (getc(IN) << 16) + File_h.bfSize;
-		File_h.bfSize = (getc(IN) << 24) + File_h.bfSize;
-
-		File_h.bfReserved1 = getc(IN);
-		File_h.bfReserved1 = (getc(IN) << 8) + File_h.bfReserved1;
-
-		File_h.bfReserved2 = getc(IN);
-		File_h.bfReserved2 = (getc(IN) << 8) + File_h.bfReserved2;
-
-		File_h.bfOffBits = getc(IN);
-		File_h.bfOffBits = (getc(IN) << 8) + File_h.bfOffBits;
-		File_h.bfOffBits = (getc(IN) << 16) + File_h.bfOffBits;
-		File_h.bfOffBits = (getc(IN) << 24) + File_h.bfOffBits;
-
-		/* INFO HEADER */
-		/* ------------- */
-
-		Info_h.biSize = getc(IN);
-		Info_h.biSize = (getc(IN) << 8) + Info_h.biSize;
-		Info_h.biSize = (getc(IN) << 16) + Info_h.biSize;
-		Info_h.biSize = (getc(IN) << 24) + Info_h.biSize;
-
-		Info_h.biWidth = getc(IN);
-		Info_h.biWidth = (getc(IN) << 8) + Info_h.biWidth;
-		Info_h.biWidth = (getc(IN) << 16) + Info_h.biWidth;
-		Info_h.biWidth = (getc(IN) << 24) + Info_h.biWidth;
-		w = Info_h.biWidth;
-
-		Info_h.biHeight = getc(IN);
-		Info_h.biHeight = (getc(IN) << 8) + Info_h.biHeight;
-		Info_h.biHeight = (getc(IN) << 16) + Info_h.biHeight;
-		Info_h.biHeight = (getc(IN) << 24) + Info_h.biHeight;
-		h = Info_h.biHeight;
-
-		Info_h.biPlanes = getc(IN);
-		Info_h.biPlanes = (getc(IN) << 8) + Info_h.biPlanes;
-
-		Info_h.biBitCount = getc(IN);
-		Info_h.biBitCount = (getc(IN) << 8) + Info_h.biBitCount;
-
-		Info_h.biCompression = getc(IN);
-		Info_h.biCompression = (getc(IN) << 8) + Info_h.biCompression;
-		Info_h.biCompression = (getc(IN) << 16) + Info_h.biCompression;
-		Info_h.biCompression = (getc(IN) << 24) + Info_h.biCompression;
-
-		Info_h.biSizeImage = getc(IN);
-		Info_h.biSizeImage = (getc(IN) << 8) + Info_h.biSizeImage;
-		Info_h.biSizeImage = (getc(IN) << 16) + Info_h.biSizeImage;
-		Info_h.biSizeImage = (getc(IN) << 24) + Info_h.biSizeImage;
-
-		Info_h.biXpelsPerMeter = getc(IN);
-		Info_h.biXpelsPerMeter = (getc(IN) << 8) + Info_h.biXpelsPerMeter;
-		Info_h.biXpelsPerMeter = (getc(IN) << 16) + Info_h.biXpelsPerMeter;
-		Info_h.biXpelsPerMeter = (getc(IN) << 24) + Info_h.biXpelsPerMeter;
-
-		Info_h.biYpelsPerMeter = getc(IN);
-		Info_h.biYpelsPerMeter = (getc(IN) << 8) + Info_h.biYpelsPerMeter;
-		Info_h.biYpelsPerMeter = (getc(IN) << 16) + Info_h.biYpelsPerMeter;
-		Info_h.biYpelsPerMeter = (getc(IN) << 24) + Info_h.biYpelsPerMeter;
-
-		Info_h.biClrUsed = getc(IN);
-		Info_h.biClrUsed = (getc(IN) << 8) + Info_h.biClrUsed;
-		Info_h.biClrUsed = (getc(IN) << 16) + Info_h.biClrUsed;
-		Info_h.biClrUsed = (getc(IN) << 24) + Info_h.biClrUsed;
-
-		Info_h.biClrImportant = getc(IN);
-		Info_h.biClrImportant = (getc(IN) << 8) + Info_h.biClrImportant;
-		Info_h.biClrImportant = (getc(IN) << 16) + Info_h.biClrImportant;
-		Info_h.biClrImportant = (getc(IN) << 24) + Info_h.biClrImportant;
-
-		/* Read the data and store them in the OUT file */
-    
-		if (Info_h.biBitCount == 24) {
-			numcomps = 3;
-			color_space = CLRSPC_SRGB;
-			/* initialize image components */
-			memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-			for(i = 0; i < numcomps; i++) {
-				cmptparm[i].prec = 8;
-				cmptparm[i].bpp = 8;
-				cmptparm[i].sgnd = 0;
-				cmptparm[i].dx = subsampling_dx;
-				cmptparm[i].dy = subsampling_dy;
-				cmptparm[i].w = w;
-				cmptparm[i].h = h;
-			}
-			/* create the image */
-			image = opj_image_create(numcomps, &cmptparm[0], color_space);
-			if(!image) {
-				fclose(IN);
-				return NULL;
-			}
-
-			/* set image offset and reference grid */
-			image->x0 = parameters->image_offset_x0;
-			image->y0 = parameters->image_offset_y0;
-			image->x1 =	!image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-			image->y1 =	!image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-			/* set image data */
-
-			/* Place the cursor at the beginning of the image information */
-			fseek(IN, 0, SEEK_SET);
-			fseek(IN, File_h.bfOffBits, SEEK_SET);
-			
-			W = Info_h.biWidth;
-			H = Info_h.biHeight;
-
-			/* PAD = 4 - (3 * W) % 4; */
-			/* PAD = (PAD == 4) ? 0 : PAD; */
-			PAD = (3 * W) % 4 ? 4 - (3 * W) % 4 : 0;
-			
-			RGB = (unsigned char *) malloc((3 * W + PAD) * H * sizeof(unsigned char));
-			
-			fread(RGB, sizeof(unsigned char), (3 * W + PAD) * H, IN);
-			
-			index = 0;
-
-			for(y = 0; y < (int)H; y++) {
-				unsigned char *scanline = RGB + (3 * W + PAD) * (H - 1 - y);
-				for(x = 0; x < (int)W; x++) {
-					unsigned char *pixel = &scanline[3 * x];
-					image->comps[0].data[index] = pixel[2];	/* R */
-					image->comps[1].data[index] = pixel[1];	/* G */
-					image->comps[2].data[index] = pixel[0];	/* B */
-					index++;
-				}
-			}
-
-			free(RGB);
-
-		} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) {
-			table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
-			table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
-			table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
-			
-			for (j = 0; j < Info_h.biClrUsed; j++) {
-				table_B[j] = getc(IN);
-				table_G[j] = getc(IN);
-				table_R[j] = getc(IN);
-				getc(IN);
-				if (table_R[j] != table_G[j] && table_R[j] != table_B[j] && table_G[j] != table_B[j])
-					gray_scale = 0;
-			}
-			
-			/* Place the cursor at the beginning of the image information */
-			fseek(IN, 0, SEEK_SET);
-			fseek(IN, File_h.bfOffBits, SEEK_SET);
-			
-			W = Info_h.biWidth;
-			H = Info_h.biHeight;
-			if (Info_h.biWidth % 2)
-				W++;
-			
-			numcomps = gray_scale ? 1 : 3;
-			color_space = gray_scale ? CLRSPC_GRAY : CLRSPC_SRGB;
-			/* initialize image components */
-			memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-			for(i = 0; i < numcomps; i++) {
-				cmptparm[i].prec = 8;
-				cmptparm[i].bpp = 8;
-				cmptparm[i].sgnd = 0;
-				cmptparm[i].dx = subsampling_dx;
-				cmptparm[i].dy = subsampling_dy;
-				cmptparm[i].w = w;
-				cmptparm[i].h = h;
-			}
-			/* create the image */
-			image = opj_image_create(numcomps, &cmptparm[0], color_space);
-			if(!image) {
-				fclose(IN);
-				return NULL;
-			}
-
-			/* set image offset and reference grid */
-			image->x0 = parameters->image_offset_x0;
-			image->y0 = parameters->image_offset_y0;
-			image->x1 =	!image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-			image->y1 =	!image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-			/* set image data */
-
-			RGB = (unsigned char *) malloc(W * H * sizeof(unsigned char));
-			
-			fread(RGB, sizeof(unsigned char), W * H, IN);
-			if (gray_scale) {
-				index = 0;
-				for (j = 0; j < W * H; j++) {
-					if ((j % W < W - 1 && Info_h.biWidth % 2) || !(Info_h.biWidth % 2)) {
-						image->comps[0].data[index] = table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]];
-						index++;
-					}
-				}
-
-			} else {		
-				index = 0;
-				for (j = 0; j < W * H; j++) {
-					if ((j % W < W - 1 && Info_h.biWidth % 2) || !(Info_h.biWidth % 2)) {
-						unsigned char pixel_index = RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)];
-						image->comps[0].data[index] = table_R[pixel_index];
-						image->comps[1].data[index] = table_G[pixel_index];
-						image->comps[2].data[index] = table_B[pixel_index];
-						index++;
-					}
-				}
-			}
-			free(RGB);
-      free(table_R);
-      free(table_G);
-      free(table_B);
-		} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) {				
-			table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
-			table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
-			table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
-			
-			for (j = 0; j < Info_h.biClrUsed; j++) {
-				table_B[j] = getc(IN);
-				table_G[j] = getc(IN);
-				table_R[j] = getc(IN);
-				getc(IN);
-				if (table_R[j] != table_G[j] && table_R[j] != table_B[j] && table_G[j] != table_B[j])
-					gray_scale = 0;
-			}
-
-			numcomps = gray_scale ? 1 : 3;
-			color_space = gray_scale ? CLRSPC_GRAY : CLRSPC_SRGB;
-			/* initialize image components */
-			memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-			for(i = 0; i < numcomps; i++) {
-				cmptparm[i].prec = 8;
-				cmptparm[i].bpp = 8;
-				cmptparm[i].sgnd = 0;
-				cmptparm[i].dx = subsampling_dx;
-				cmptparm[i].dy = subsampling_dy;
-				cmptparm[i].w = w;
-				cmptparm[i].h = h;
-			}
-			/* create the image */
-			image = opj_image_create(numcomps, &cmptparm[0], color_space);
-			if(!image) {
-				fclose(IN);
-				return NULL;
-			}
-
-			/* set image offset and reference grid */
-			image->x0 = parameters->image_offset_x0;
-			image->y0 = parameters->image_offset_y0;
-			image->x1 =	!image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-			image->y1 =	!image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-			/* set image data */
-			
-			/* Place the cursor at the beginning of the image information */
-			fseek(IN, 0, SEEK_SET);
-			fseek(IN, File_h.bfOffBits, SEEK_SET);
-			
-			RGB = (unsigned char *) malloc(Info_h.biWidth * Info_h.biHeight * sizeof(unsigned char));
-            
-			while (not_end_file) {
-				v = getc(IN);
-				if (v) {
-					v2 = getc(IN);
-					for (i = 0; i < (int) v; i++) {
-						RGB[line * Info_h.biWidth + col] = v2;
-						col++;
-					}
-				} else {
-					v = getc(IN);
-					switch (v) {
-						case 0:
-							col = 0;
-							line++;
-							break;
-						case 1:
-							line++;
-							not_end_file = 0;
-							break;
-						case 2:
-							fprintf(stderr,"No Delta supported\n");
-							opj_image_destroy(image);
-							fclose(IN);
-							return NULL;
-						default:
-							for (i = 0; i < v; i++) {
-								v2 = getc(IN);
-								RGB[line * Info_h.biWidth + col] = v2;
-								col++;
-							}
-							if (v % 2)
-								v2 = getc(IN);
-							break;
-					}
-				}
-			}
-			if (gray_scale) {
-				index = 0;
-				for (line = 0; line < Info_h.biHeight; line++) {
-					for (col = 0; col < Info_h.biWidth; col++) {
-						image->comps[0].data[index] = table_R[(int)RGB[(Info_h.biHeight - line - 1) * Info_h.biWidth + col]];
-						index++;
-					}
-				}
-			} else {
-				index = 0;
-				for (line = 0; line < Info_h.biHeight; line++) {
-					for (col = 0; col < Info_h.biWidth; col++) {
-						unsigned char pixel_index = (int)RGB[(Info_h.biHeight - line - 1) * Info_h.biWidth + col];
-						image->comps[0].data[index] = table_R[pixel_index];
-						image->comps[1].data[index] = table_G[pixel_index];
-						image->comps[2].data[index] = table_B[pixel_index];
-						index++;
-					}
-				}
-			}
-			free(RGB);
-      free(table_R);
-      free(table_G);
-      free(table_B);
-	} else {
-		fprintf(stderr, 
-			"Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n", Info_h.biBitCount);
-	}
-	fclose(IN);
- }
- 
- return image;
-}
-
-int imagetobmp(opj_image_t * image, const char *outfile) {
-	int w, h;
-	int i, pad;
-	FILE *fdest = NULL;
-	int adjustR, adjustG, adjustB;
-
-	if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
-		&& image->comps[1].dx == image->comps[2].dx
-		&& image->comps[0].dy == image->comps[1].dy
-		&& image->comps[1].dy == image->comps[2].dy
-		&& image->comps[0].prec == image->comps[1].prec
-		&& image->comps[1].prec == image->comps[2].prec) {
-		
-		/* -->> -->> -->> -->>    
-		24 bits color	    
-		<<-- <<-- <<-- <<-- */
-	    
-		fdest = fopen(outfile, "wb");
-		if (!fdest) {
-			fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-			return 1;
-		}
-	    
-		w = image->comps[0].w;	    
-		h = image->comps[0].h;
-	    
-		fprintf(fdest, "BM");
-	    
-		/* FILE HEADER */
-		/* ------------- */
-		fprintf(fdest, "%c%c%c%c",
-			(unsigned char) (h * w * 3 + 3 * h * (w % 2) + 54) & 0xff,
-			(unsigned char) ((h * w * 3 + 3 * h * (w % 2) + 54)	>> 8) & 0xff,
-			(unsigned char) ((h * w * 3 + 3 * h * (w % 2) + 54)	>> 16) & 0xff,
-			(unsigned char) ((h * w * 3 + 3 * h * (w % 2) + 54)	>> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
-	    
-		/* INFO HEADER   */
-		/* ------------- */
-		fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,	((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (unsigned char) ((w) & 0xff),
-			(unsigned char) ((w) >> 8) & 0xff,
-			(unsigned char) ((w) >> 16) & 0xff,
-			(unsigned char) ((w) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (unsigned char) ((h) & 0xff),
-			(unsigned char) ((h) >> 8) & 0xff,
-			(unsigned char) ((h) >> 16) & 0xff,
-			(unsigned char) ((h) >> 24) & 0xff);
-		fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
-		fprintf(fdest, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (unsigned char) (3 * h * w + 3 * h * (w % 2)) & 0xff,
-			(unsigned char) ((h * w * 3 + 3 * h * (w % 2)) >> 8) & 0xff,
-			(unsigned char) ((h * w * 3 + 3 * h * (w % 2)) >> 16) & 0xff,
-			(unsigned char) ((h * w * 3 + 3 * h * (w % 2)) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,	((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-	    
-		if (image->comps[0].prec > 8) {
-			adjustR = image->comps[0].prec - 8;
-			printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
-		}
-		else 
-			adjustR = 0;
-		if (image->comps[1].prec > 8) {
-			adjustG = image->comps[1].prec - 8;
-			printf("BMP CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
-		}
-		else 
-			adjustG = 0;
-		if (image->comps[2].prec > 8) {
-			adjustB = image->comps[2].prec - 8;
-			printf("BMP CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
-		}
-		else 
-			adjustB = 0;
-
-		for (i = 0; i < w * h; i++) {
-			unsigned char rc, gc, bc;
-			int r, g, b;
-							
-			r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-			r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-			rc = (unsigned char) ((r >> adjustR)+((r >> (adjustR-1))%2));
-			g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-			g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
-			gc = (unsigned char) ((g >> adjustG)+((g >> (adjustG-1))%2));
-			b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-			b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
-			bc = (unsigned char) ((b >> adjustB)+((b >> (adjustB-1))%2));
-
-			fprintf(fdest, "%c%c%c", bc, gc, rc);
-			
-			if ((i + 1) % w == 0) {
-				for (pad = (3 * w) % 4 ? 4 - (3 * w) % 4 : 0; pad > 0; pad--)	/* ADD */
-					fprintf(fdest, "%c", 0);
-			}
-		}
-		fclose(fdest);
-	} else {			/* Gray-scale */
-
-		/* -->> -->> -->> -->>
-		8 bits non code (Gray scale)
-		<<-- <<-- <<-- <<-- */
-
-		fdest = fopen(outfile, "wb");
-		w = image->comps[0].w;	    
-		h = image->comps[0].h;
-	    
-		fprintf(fdest, "BM");
-	    
-		/* FILE HEADER */
-		/* ------------- */
-		fprintf(fdest, "%c%c%c%c", (unsigned char) (h * w + 54 + 1024 + h * (w % 2)) & 0xff,
-			(unsigned char) ((h * w + 54 + 1024 + h * (w % 2)) >> 8) & 0xff,
-			(unsigned char) ((h * w + 54 + 1024 + h * (w % 2)) >> 16) & 0xff,
-			(unsigned char) ((h * w + 54 + 1024 + w * (w % 2)) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (54 + 1024) & 0xff, ((54 + 1024) >> 8) & 0xff, 
-			((54 + 1024) >> 16) & 0xff,
-			((54 + 1024) >> 24) & 0xff);
-	    
-		/* INFO HEADER */
-		/* ------------- */
-		fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,	((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (unsigned char) ((w) & 0xff),
-			(unsigned char) ((w) >> 8) & 0xff,
-			(unsigned char) ((w) >> 16) & 0xff,
-			(unsigned char) ((w) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (unsigned char) ((h) & 0xff),
-			(unsigned char) ((h) >> 8) & 0xff,
-			(unsigned char) ((h) >> 16) & 0xff,
-			(unsigned char) ((h) >> 24) & 0xff);
-		fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
-		fprintf(fdest, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (unsigned char) (h * w + h * (w % 2)) & 0xff,
-			(unsigned char) ((h * w + h * (w % 2)) >> 8) &	0xff,
-			(unsigned char) ((h * w + h * (w % 2)) >> 16) &	0xff,
-			(unsigned char) ((h * w + h * (w % 2)) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,	((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,	((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
-		fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
-
-		if (image->comps[0].prec > 8) {
-			adjustR = image->comps[0].prec - 8;
-			printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
-		}else 
-			adjustR = 0;
-
-		for (i = 0; i < 256; i++) {
-			fprintf(fdest, "%c%c%c%c", i, i, i, 0);
-		}
-
-		for (i = 0; i < w * h; i++) {
-			unsigned char rc;
-			int r;
-			
-			r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-			r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-			rc = (unsigned char) ((r >> adjustR)+((r >> (adjustR-1))%2));
-			
-			fprintf(fdest, "%c", rc);
-
-			if ((i + 1) % w == 0) {
-				for (pad = w % 4 ? 4 - w % 4 : 0; pad > 0; pad--)	/* ADD */
-					fprintf(fdest, "%c", 0);
-			}
-		}
-		fclose(fdest);
-	}
-
-	return 0;
-}
-
-/* -->> -->> -->> -->>
-
-PGX IMAGE FORMAT
-
-<<-- <<-- <<-- <<-- */
-
-
-unsigned char readuchar(FILE * f)
-{
-  unsigned char c1;
-  fread(&c1, 1, 1, f);
-  return c1;
-}
-
-unsigned short readushort(FILE * f, int bigendian)
-{
-  unsigned char c1, c2;
-  fread(&c1, 1, 1, f);
-  fread(&c2, 1, 1, f);
-  if (bigendian)
-    return (c1 << 8) + c2;
-  else
-    return (c2 << 8) + c1;
-}
-
-unsigned int readuint(FILE * f, int bigendian)
-{
-  unsigned char c1, c2, c3, c4;
-  fread(&c1, 1, 1, f);
-  fread(&c2, 1, 1, f);
-  fread(&c3, 1, 1, f);
-  fread(&c4, 1, 1, f);
-  if (bigendian)
-    return (c1 << 24) + (c2 << 16) + (c3 << 8) + c4;
-  else
-    return (c4 << 24) + (c3 << 16) + (c2 << 8) + c1;
-}
-
-opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) {
-	FILE *f = NULL;
-	int w, h, prec;
-	int i, numcomps, max;
-	OPJ_COLOR_SPACE color_space;
-	opj_image_cmptparm_t cmptparm;	/* maximum of 1 component  */
-	opj_image_t * image = NULL;
-
-	char endian1,endian2,sign;
-	char signtmp[32];
-
-	char temp[32];
-	int bigendian;
-	opj_image_comp_t *comp = NULL;
-
-	numcomps = 1;
-	color_space = CLRSPC_GRAY;
-
-	memset(&cmptparm, 0, sizeof(opj_image_cmptparm_t));
-
-	max = 0;
-
-	f = fopen(filename, "rb");
-	if (!f) {
-	  fprintf(stderr, "Failed to open %s for reading !\n", filename);
-	  return NULL;
-	}
-
-	fseek(f, 0, SEEK_SET);
-	fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h);
-	
-	i=0;
-	sign='+';		
-	while (signtmp[i]!='\0') {
-		if (signtmp[i]=='-') sign='-';
-		i++;
-	}
-	
-	fgetc(f);
-	if (endian1=='M' && endian2=='L') {
-		bigendian = 1;
-	} else if (endian2=='M' && endian1=='L') {
-		bigendian = 0;
-	} else {
-		fprintf(stderr, "Bad pgx header, please check input file\n");
-		return NULL;
-	}
-
-	/* initialize image component */
-
-	cmptparm.x0 = parameters->image_offset_x0;
-	cmptparm.y0 = parameters->image_offset_y0;
-	cmptparm.w = !cmptparm.x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm.x0 + (w - 1) * parameters->subsampling_dx + 1;
-	cmptparm.h = !cmptparm.y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm.y0 + (h - 1) * parameters->subsampling_dy + 1;
-	
-	if (sign == '-') {
-		cmptparm.sgnd = 1;
-	} else {
-		cmptparm.sgnd = 0;
-	}
-	cmptparm.prec = prec;
-	cmptparm.bpp = prec;
-	cmptparm.dx = parameters->subsampling_dx;
-	cmptparm.dy = parameters->subsampling_dy;
-	
-	/* create the image */
-	image = opj_image_create(numcomps, &cmptparm, color_space);
-	if(!image) {
-		fclose(f);
-		return NULL;
-	}
-	/* set image offset and reference grid */
-	image->x0 = cmptparm.x0;
-	image->y0 = cmptparm.x0;
-	image->x1 = cmptparm.w;
-	image->y1 = cmptparm.h;
-
-	/* set image data */
-
-	comp = &image->comps[0];
-
-	for (i = 0; i < w * h; i++) {
-		int v;
-		if (comp->prec <= 8) {
-			if (!comp->sgnd) {
-				v = readuchar(f);
-			} else {
-				v = (char) readuchar(f);
-			}
-		} else if (comp->prec <= 16) {
-			if (!comp->sgnd) {
-				v = readushort(f, bigendian);
-			} else {
-				v = (short) readushort(f, bigendian);
-			}
-		} else {
-			if (!comp->sgnd) {
-				v = readuint(f, bigendian);
-			} else {
-				v = (int) readuint(f, bigendian);
-			}
-		}
-		if (v > max)
-			max = v;
-		comp->data[i] = v;
-	}
-	fclose(f);
-	comp->bpp = int_floorlog2(max) + 1;
-
-	return image;
-}
-
-int imagetopgx(opj_image_t * image, const char *outfile) {
-	int w, h;
-	int i, j, compno;
-	FILE *fdest = NULL;
-
-	for (compno = 0; compno < image->numcomps; compno++) {
-		opj_image_comp_t *comp = &image->comps[compno];
-		char bname[256]; /* buffer for name */
-    char *name = bname; /* pointer */
-    int nbytes = 0;
-    const size_t olen = strlen(outfile);
-    const size_t dotpos = olen - 4;
-    const size_t total = dotpos + 1 + 1 + 4; /* '-' + '[1-3]' + '.pgx' */
-    if( outfile[dotpos] != '.' ) {
-      /* `pgx` was recognized but there is no dot at expected position */
-      fprintf(stderr, "ERROR -> Impossible happen." );
-      return 1;
-      }
-    if( total > 256 ) {
-      name = (char*)malloc(total+1);
-      }
-    strncpy(name, outfile, dotpos);
-		if (image->numcomps > 1) {
-			sprintf(name+dotpos, "-%d.pgx", compno);
-		} else {
-			strcpy(name+dotpos, ".pgx");
-		}
-		fdest = fopen(name, "wb");
-		if (!fdest) {
-			fprintf(stderr, "ERROR -> failed to open %s for writing\n", name);
-			return 1;
-		}
-    /* dont need name anymore */
-    if( total > 256 ) {
-      free(name);
-      }
-
-		w = image->comps[compno].w;
-		h = image->comps[compno].h;
-	    
-		fprintf(fdest, "PG ML %c %d %d %d\n", comp->sgnd ? '-' : '+', comp->prec, w, h);
-		if (comp->prec <= 8) {
-			nbytes = 1;
-		} else if (comp->prec <= 16) {
-			nbytes = 2;
-		} else {
-			nbytes = 4;
-		}
-		for (i = 0; i < w * h; i++) {
-			int v = image->comps[compno].data[i];
-			for (j = nbytes - 1; j >= 0; j--) {
-				char byte = (char) (v >> (j * 8));
-				fwrite(&byte, 1, 1, fdest);
-			}
-		}
-		fclose(fdest);
-	}
-
-	return 0;
-}
-
-/* -->> -->> -->> -->>
-
-PNM IMAGE FORMAT
-
-<<-- <<-- <<-- <<-- */
-
-opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) {
-	int subsampling_dx = parameters->subsampling_dx;
-	int subsampling_dy = parameters->subsampling_dy;
-
-	FILE *f = NULL;
-	int i, compno, numcomps, w, h;
-	OPJ_COLOR_SPACE color_space;
-	opj_image_cmptparm_t cmptparm[3];	/* maximum of 3 components */
-	opj_image_t * image = NULL;
-	char value;
-	
-	f = fopen(filename, "rb");
-	if (!f) {
-		fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-		return 0;
-	}
-
-	if (fgetc(f) != 'P')
-		return 0;
-	value = fgetc(f);
-
-		switch(value) {
-			case '2':	/* greyscale image type */
-			case '5':
-				numcomps = 1;
-				color_space = CLRSPC_GRAY;
-				break;
-				
-			case '3':	/* RGB image type */
-			case '6':
-				numcomps = 3;
-				color_space = CLRSPC_SRGB;
-				break;
-				
-			default:
-				fclose(f);
-				return NULL;
-		}
-		
-		fgetc(f);
-		
-		/* skip comments */
-		while(fgetc(f) == '#') while(fgetc(f) != '\n');
-		
-		fseek(f, -1, SEEK_CUR);
-		fscanf(f, "%d %d\n255", &w, &h);			
-		fgetc(f);	/* <cr><lf> */
-		
-	/* initialize image components */
-	memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-	for(i = 0; i < numcomps; i++) {
-		cmptparm[i].prec = 8;
-		cmptparm[i].bpp = 8;
-		cmptparm[i].sgnd = 0;
-		cmptparm[i].dx = subsampling_dx;
-		cmptparm[i].dy = subsampling_dy;
-		cmptparm[i].w = w;
-		cmptparm[i].h = h;
-	}
-	/* create the image */
-	image = opj_image_create(numcomps, &cmptparm[0], color_space);
-	if(!image) {
-		fclose(f);
-		return NULL;
-	}
-
-	/* set image offset and reference grid */
-	image->x0 = parameters->image_offset_x0;
-	image->y0 = parameters->image_offset_y0;
-	image->x1 = parameters->image_offset_x0 + (w - 1) *	subsampling_dx + 1;
-	image->y1 = parameters->image_offset_y0 + (h - 1) *	subsampling_dy + 1;
-
-	/* set image data */
-
-	if ((value == '2') || (value == '3')) {	/* ASCII */
-		for (i = 0; i < w * h; i++) {
-			for(compno = 0; compno < numcomps; compno++) {
-				unsigned int index = 0;
-				fscanf(f, "%u", &index);
-				/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
-				image->comps[compno].data[i] = index;
-			}
-		}
-	} else if ((value == '5') || (value == '6')) {	/* BINARY */
-		for (i = 0; i < w * h; i++) {
-			for(compno = 0; compno < numcomps; compno++) {
-				unsigned char index = 0;
-				fread(&index, 1, 1, f);
-				/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
-				image->comps[compno].data[i] = index;
-			}
-		}
-	}
-
-	fclose(f);
-
-	return image;
-}
-
-int imagetopnm(opj_image_t * image, const char *outfile) {
-	int w, wr, h, hr, max;
-	int i, compno;
-	int adjustR, adjustG, adjustB, adjustX;
-	FILE *fdest = NULL;
-	char S2;
-	const char *tmp = outfile;
-
-	while (*tmp) {
-		tmp++;
-	}
-	tmp--;
-	tmp--;
-	S2 = *tmp;
-
-	if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
-		&& image->comps[1].dx == image->comps[2].dx
-		&& image->comps[0].dy == image->comps[1].dy
-		&& image->comps[1].dy == image->comps[2].dy
-		&& image->comps[0].prec == image->comps[1].prec
-		&& image->comps[1].prec == image->comps[2].prec
-		&& S2 !='g' && S2 !='G') {
-
-		fdest = fopen(outfile, "wb");
-		if (!fdest) {
-			fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-			return 1;
-		}
-
-		w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
-		wr = image->comps[0].w;
-        
-		h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
-		hr = image->comps[0].h;
-	    
-		max = image->comps[0].prec > 8 ? 255 : (1 << image->comps[0].prec) - 1;
-	    
-		image->comps[0].x0 = int_ceildivpow2(image->comps[0].x0 - int_ceildiv(image->x0, image->comps[0].dx), image->comps[0].factor);
-		image->comps[0].y0 = int_ceildivpow2(image->comps[0].y0 -	int_ceildiv(image->y0, image->comps[0].dy), image->comps[0].factor);
-
-		fprintf(fdest, "P6\n%d %d\n%d\n", wr, hr, max);
-
-		if (image->comps[0].prec > 8) {
-			adjustR = image->comps[0].prec - 8;
-			printf("PNM CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
-		}
-		else 
-			adjustR = 0;
-		if (image->comps[1].prec > 8) {
-			adjustG = image->comps[1].prec - 8;
-			printf("PNM CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
-		}
-		else 
-			adjustG = 0;
-		if (image->comps[2].prec > 8) {
-			adjustB = image->comps[2].prec - 8;
-			printf("PNM CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
-		}
-		else 
-			adjustB = 0;
-
-
-		for (i = 0; i < wr * hr; i++) {
-			int r, g, b;
-			unsigned char rc,gc,bc;
-			r = image->comps[0].data[i];
-			r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-			rc = (unsigned char) ((r >> adjustR)+((r >> (adjustR-1))%2));
-
-			g = image->comps[1].data[i];
-			g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
-			gc = (unsigned char) ((g >> adjustG)+((g >> (adjustG-1))%2));
-			
-			b = image->comps[2].data[i];
-			b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
-			bc = (unsigned char) ((b >> adjustB)+((b >> (adjustB-1))%2));
-			
-			fprintf(fdest, "%c%c%c", rc, gc, bc);
-		}
-		fclose(fdest);
-
-	} else {
-		int ncomp=(S2=='g' || S2=='G')?1:image->numcomps;
-		if (image->numcomps > ncomp) {
-			fprintf(stderr,"WARNING -> [PGM files] Only the first component\n");
-			fprintf(stderr,"           is written to the file\n");
-		}
-		for (compno = 0; compno < ncomp; compno++) {
-			char name[256];
-			if (ncomp > 1) {
-				sprintf(name, "%d.%s", compno, outfile);
-			} else {
-				sprintf(name, "%s", outfile);
-			}
-			
-			fdest = fopen(name, "wb");
-			if (!fdest) {
-				fprintf(stderr, "ERROR -> failed to open %s for writing\n", name);
-				return 1;
-			}
-            
-			w = int_ceildiv(image->x1 - image->x0, image->comps[compno].dx);
-			wr = image->comps[compno].w;
-			
-			h = int_ceildiv(image->y1 - image->y0, image->comps[compno].dy);
-			hr = image->comps[compno].h;
-			
-			max = image->comps[compno].prec > 8 ? 255 : (1 << image->comps[compno].prec) - 1;
-			
-			image->comps[compno].x0 = int_ceildivpow2(image->comps[compno].x0 - int_ceildiv(image->x0, image->comps[compno].dx), image->comps[compno].factor);
-			image->comps[compno].y0 = int_ceildivpow2(image->comps[compno].y0 - int_ceildiv(image->y0, image->comps[compno].dy), image->comps[compno].factor);
-			
-			fprintf(fdest, "P5\n%d %d\n%d\n", wr, hr, max);
-			
-			if (image->comps[compno].prec > 8) {
-				adjustX = image->comps[0].prec - 8;
-				printf("PNM CONVERSION: Truncating component %d from %d bits to 8 bits\n",compno, image->comps[compno].prec);
-			}
-			else 
-				adjustX = 0;
-			
-			for (i = 0; i < wr * hr; i++) {
-				int l;
-				unsigned char lc;
-				l = image->comps[compno].data[i];
-				l += (image->comps[compno].sgnd ? 1 << (image->comps[compno].prec - 1) : 0);
-				lc = (unsigned char) ((l >> adjustX)+((l >> (adjustX-1))%2));
-				fprintf(fdest, "%c", lc);
-			}
-			fclose(fdest);
-		}
-	}
-
-	return 0;
-}
-
-#ifdef HAVE_LIBTIFF
-/* -->> -->> -->> -->>
-
-	TIFF IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-typedef struct tiff_infoheader{
-	DWORD tiWidth;  // Width of Image in pixel
-	DWORD tiHeight; // Height of Image in pixel
-	DWORD tiPhoto;	// Photometric
-	WORD  tiBps;	// Bits per sample
-	WORD  tiSf;		// Sample Format
-	WORD  tiSpp;	// Sample per pixel 1-bilevel,gray scale , 2- RGB
-	WORD  tiPC;	// Planar config (1-Interleaved, 2-Planarcomp)
-}tiff_infoheader_t;
-
-int imagetotif(opj_image_t * image, const char *outfile) {
-	int width, height, imgsize;
-	int bps,index,adjust = 0;
-	int last_i=0;
-	TIFF *tif;
-	tdata_t buf;
-	tstrip_t strip;
-	tsize_t strip_size;
-
-	if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
-		&& image->comps[1].dx == image->comps[2].dx
-		&& image->comps[0].dy == image->comps[1].dy
-		&& image->comps[1].dy == image->comps[2].dy
-		&& image->comps[0].prec == image->comps[1].prec
-		&& image->comps[1].prec == image->comps[2].prec) {
-
-			/* -->> -->> -->>    
-			RGB color	    
-			<<-- <<-- <<-- */
-
-			tif = TIFFOpen(outfile, "wb"); 
-			if (!tif) {
-				fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-				return 1;
-			}
-
-			width	= image->comps[0].w;
-			height	= image->comps[0].h;
-			imgsize = width * height ;
-			bps		= image->comps[0].prec;
-			/* Set tags */
-			TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
-			TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
-			TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
-			TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
-			TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
-			TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
-			TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
-			TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
-
-			/* Get a buffer for the data */
-			strip_size=TIFFStripSize(tif);
-			buf = _TIFFmalloc(strip_size);
-			index=0;		
-			adjust = image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0;
-			for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-				unsigned char *dat8;
-				tsize_t i, ssize;
-				ssize = TIFFStripSize(tif);
-				dat8 = (unsigned char*)buf;
-				if (image->comps[0].prec == 8){
-					for (i=0; i<ssize-2; i+=3) {	// 8 bits per pixel 
-						int r = 0,g = 0,b = 0;
-						if(index < imgsize){
-							r = image->comps[0].data[index];
-							g = image->comps[1].data[index];
-							b = image->comps[2].data[index];
-							if (image->comps[0].sgnd){			
-								r += adjust;
-								g += adjust;
-								b += adjust;
-							}
-							dat8[i+0] = r ;	// R 
-							dat8[i+1] = g ;	// G 
-							dat8[i+2] = b ;	// B 
-							index++;
-							last_i = i+3;
-						}else
-							break;
-					}
-					if(last_i < ssize){
-						for (i=last_i; i<ssize; i+=3) {	// 8 bits per pixel 
-							int r = 0,g = 0,b = 0;
-							if(index < imgsize){
-								r = image->comps[0].data[index];
-								g = image->comps[1].data[index];
-								b = image->comps[2].data[index];
-								if (image->comps[0].sgnd){			
-									r += adjust;
-									g += adjust;
-									b += adjust;
-								}
-								dat8[i+0] = r ;	// R 
-								if(i+1 <ssize) dat8[i+1] = g ;	else break;// G 
-								if(i+2 <ssize) dat8[i+2] = b ;	else break;// B 
-								index++;
-							}else
-								break;
-						}
-					}
-				}else if (image->comps[0].prec == 12){
-					for (i=0; i<ssize-8; i+=9) {	// 12 bits per pixel 
-						int r = 0,g = 0,b = 0;
-						int r1 = 0,g1 = 0,b1 = 0;
-						if((index < imgsize)&(index+1 < imgsize)){
-							r  = image->comps[0].data[index];
-							g  = image->comps[1].data[index];
-							b  = image->comps[2].data[index];
-							r1 = image->comps[0].data[index+1];
-							g1 = image->comps[1].data[index+1];
-							b1 = image->comps[2].data[index+1];
-							if (image->comps[0].sgnd){														
-								r  += adjust;
-								g  += adjust;
-								b  += adjust;
-								r1 += adjust;
-								g1 += adjust;
-								b1 += adjust;
-							}
-							dat8[i+0] = (r >> 4);
-							dat8[i+1] = ((r & 0x0f) << 4 )|((g >> 8)& 0x0f);
-							dat8[i+2] = g ;		
-							dat8[i+3] = (b >> 4);
-							dat8[i+4] = ((b & 0x0f) << 4 )|((r1 >> 8)& 0x0f);
-							dat8[i+5] = r1;		
-							dat8[i+6] = (g1 >> 4);
-							dat8[i+7] = ((g1 & 0x0f)<< 4 )|((b1 >> 8)& 0x0f);
-							dat8[i+8] = b1;
-							index+=2;
-							last_i = i+9;
-						}else
-							break;
-					}
-					if(last_i < ssize){
-						for (i= last_i; i<ssize; i+=9) {	// 12 bits per pixel 
-							int r = 0,g = 0,b = 0;
-							int r1 = 0,g1 = 0,b1 = 0;
-							if((index < imgsize)&(index+1 < imgsize)){
-								r  = image->comps[0].data[index];
-								g  = image->comps[1].data[index];
-								b  = image->comps[2].data[index];
-								r1 = image->comps[0].data[index+1];
-								g1 = image->comps[1].data[index+1];
-								b1 = image->comps[2].data[index+1];
-								if (image->comps[0].sgnd){														
-									r  += adjust;
-									g  += adjust;
-									b  += adjust;
-									r1 += adjust;
-									g1 += adjust;
-									b1 += adjust;
-								}
-								dat8[i+0] = (r >> 4);
-								if(i+1 <ssize) dat8[i+1] = ((r & 0x0f) << 4 )|((g >> 8)& 0x0f); else break;
-								if(i+2 <ssize) dat8[i+2] = g ;			else break;
-								if(i+3 <ssize) dat8[i+3] = (b >> 4);	else break;
-								if(i+4 <ssize) dat8[i+4] = ((b & 0x0f) << 4 )|((r1 >> 8)& 0x0f);else break;
-								if(i+5 <ssize) dat8[i+5] = r1;			else break;
-								if(i+6 <ssize) dat8[i+6] = (g1 >> 4);	else break;
-								if(i+7 <ssize) dat8[i+7] = ((g1 & 0x0f)<< 4 )|((b1 >> 8)& 0x0f);else break;
-								if(i+8 <ssize) dat8[i+8] = b1;			else break;
-								index+=2;
-							}else
-								break;
-						}
-					}
-				}else if (image->comps[0].prec == 16){
-					for (i=0 ; i<ssize-5 ; i+=6) {	// 16 bits per pixel 
-						int r = 0,g = 0,b = 0;
-						if(index < imgsize){
-							r = image->comps[0].data[index];
-							g = image->comps[1].data[index];
-							b = image->comps[2].data[index];
-							if (image->comps[0].sgnd){
-							r += adjust;
-							g += adjust;
-							b += adjust;
-							}
-							dat8[i+0] =  r;//LSB
-							dat8[i+1] = (r >> 8);//MSB	 
-							dat8[i+2] =  g;		
-							dat8[i+3] = (g >> 8);
-							dat8[i+4] =  b;	
-							dat8[i+5] = (b >> 8);
-							index++;
-							last_i = i+6;
-						}else
-							break; 
-					}
-					if(last_i < ssize){
-						for (i=0 ; i<ssize ; i+=6) {	// 16 bits per pixel 
-							int r = 0,g = 0,b = 0;
-							if(index < imgsize){
-								r = image->comps[0].data[index];
-								g = image->comps[1].data[index];
-								b = image->comps[2].data[index];
-								if (image->comps[0].sgnd){
-									r += adjust;
-									g += adjust;
-									b += adjust;
-								}
-								dat8[i+0] =  r;//LSB
-								if(i+1 <ssize) dat8[i+1] = (r >> 8);else break;//MSB	 
-								if(i+2 <ssize) dat8[i+2] =  g;		else break;
-								if(i+3 <ssize) dat8[i+3] = (g >> 8);else break;
-								if(i+4 <ssize) dat8[i+4] =  b;		else break;
-								if(i+5 <ssize) dat8[i+5] = (b >> 8);else break;
-								index++;
-							}else
-								break; 
-						}						
-					}
-				}else{
-					fprintf(stderr,"Bits=%d, Only 8,12,16 bits implemented\n",image->comps[0].prec);
-					fprintf(stderr,"Aborting\n");
-					return 1;
-				}
-				(void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size);
-			}
-			_TIFFfree((void*)buf);
-			TIFFClose(tif);
-		}else if (image->numcomps == 1){
-			/* -->> -->> -->>    
-			Black and White	    
-			<<-- <<-- <<-- */
-
-			tif = TIFFOpen(outfile, "wb"); 
-			if (!tif) {
-				fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-				return 1;
-			}
-
-			width	= image->comps[0].w;
-			height	= image->comps[0].h;
-			imgsize = width * height;
-			bps		= image->comps[0].prec;
-
-			/* Set tags */
-			TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
-			TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
-			TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
-			TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
-			TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
-			TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
-			TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
-			TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
-
-			/* Get a buffer for the data */
-			strip_size = TIFFStripSize(tif);
-			buf = _TIFFmalloc(strip_size);
-			index = 0;			
-			for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-				unsigned char *dat8;
-				tsize_t i;
-				dat8 = (unsigned char*)buf;
-				if (image->comps[0].prec == 8){
-					for (i=0; i<TIFFStripSize(tif); i+=1) {	// 8 bits per pixel 
-						if(index < imgsize){
-							int r = 0;
-							r = image->comps[0].data[index];
-							if (image->comps[0].sgnd){
-								r  += adjust;
-							}
-							dat8[i+0] = r;
-							index++;
-						}else
-							break; 
-					}
-				}else if (image->comps[0].prec == 12){
-					for (i = 0; i<TIFFStripSize(tif); i+=3) {	// 12 bits per pixel 
-						if(index < imgsize){
-							int r = 0, r1 = 0;
-							r  = image->comps[0].data[index];
-							r1 = image->comps[0].data[index+1];
-							if (image->comps[0].sgnd){
-								r  += adjust;
-								r1 += adjust;
-							}
-							dat8[i+0] = (r >> 4);
-							dat8[i+1] = ((r & 0x0f) << 4 )|((r1 >> 8)& 0x0f);
-							dat8[i+2] = r1 ;
-							index+=2;
-						}else
-							break; 
-					}
-				}else if (image->comps[0].prec == 16){
-					for (i=0; i<TIFFStripSize(tif); i+=2) {	// 16 bits per pixel 
-						if(index < imgsize){
-							int r = 0;
-							r = image->comps[0].data[index];
-							if (image->comps[0].sgnd){
-								r  += adjust;
-							}
-							dat8[i+0] = r;
-							dat8[i+1] = r >> 8;
-							index++;
-						}else
-							break; 
-					}
-				}else{
-					fprintf(stderr,"TIFF file creation. Bits=%d, Only 8,12,16 bits implemented\n",image->comps[0].prec);
-					fprintf(stderr,"Aborting\n");
-					return 1;
-				}
-				(void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size);
-			}
-			_TIFFfree(buf);
-			TIFFClose(tif);
-		}else{
-			fprintf(stderr,"TIFF file creation. Bad color format. Only RGB & Grayscale has been implemented\n");
-			fprintf(stderr,"Aborting\n");
-			return 1;
-		}
-		return 0;
-}
-
-opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
-{
-	int subsampling_dx = parameters->subsampling_dx;
-	int subsampling_dy = parameters->subsampling_dy;
-	TIFF *tif;
-	tiff_infoheader_t Info;
-	tdata_t buf;
-	tstrip_t strip;
-	tsize_t strip_size;
-	int j, numcomps, w, h,index;
-	OPJ_COLOR_SPACE color_space;
-	opj_image_cmptparm_t cmptparm[3];
-	opj_image_t * image = NULL;
-	int imgsize = 0;
-
-	tif = TIFFOpen(filename, "r");
-
-	if (!tif) {
-		fprintf(stderr, "Failed to open %s for reading\n", filename);
-		return 0;
-	}
-
-	TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &Info.tiWidth);
-	TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &Info.tiHeight);
-	TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &Info.tiBps);
-	TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &Info.tiSf);
-	TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &Info.tiSpp);
-	Info.tiPhoto = 0;
-	TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &Info.tiPhoto);
-	TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &Info.tiPC);
-	w= Info.tiWidth;
-	h= Info.tiHeight;
-	
-	if (Info.tiPhoto == 2) { 
-		/* -->> -->> -->>    
-		RGB color	    
-		<<-- <<-- <<-- */
-
-		numcomps = 3;
-		color_space = CLRSPC_SRGB;
-		/* initialize image components*/ 
-		memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-		for(j = 0; j < numcomps; j++) {
-			if (parameters->cp_cinema) {
-				cmptparm[j].prec = 12;
-				cmptparm[j].bpp = 12;
-			}else{
-				cmptparm[j].prec = Info.tiBps;
-				cmptparm[j].bpp = Info.tiBps;
-			}
-			cmptparm[j].sgnd = 0;
-			cmptparm[j].dx = subsampling_dx;
-			cmptparm[j].dy = subsampling_dy;
-			cmptparm[j].w = w;
-			cmptparm[j].h = h;
-		}
-		/* create the image*/ 
-		image = opj_image_create(numcomps, &cmptparm[0], color_space);
-		if(!image) {
-			TIFFClose(tif);
-			return NULL;
-		}
-
-		/* set image offset and reference grid */
-		image->x0 = parameters->image_offset_x0;
-		image->y0 = parameters->image_offset_y0;
-		image->x1 =	!image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-		image->y1 =	!image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-		buf = _TIFFmalloc(TIFFStripSize(tif));
-		strip_size=0;
-		strip_size=TIFFStripSize(tif);
-		index = 0;
-		imgsize = image->comps[0].w * image->comps[0].h ;
-		/* Read the Image components*/
-		for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-			unsigned char *dat8;
-			int i, ssize;
-			ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
-			dat8 = (unsigned char*)buf;
-
-			if (Info.tiBps==12){
-				for (i=0; i<ssize; i+=9) {	/*12 bits per pixel*/
-					if((index < imgsize)&(index+1 < imgsize)){
-						image->comps[0].data[index]   = ( dat8[i+0]<<4 )		|(dat8[i+1]>>4);
-						image->comps[1].data[index]   = ((dat8[i+1]& 0x0f)<< 8)	| dat8[i+2];
-						image->comps[2].data[index]   = ( dat8[i+3]<<4)			|(dat8[i+4]>>4);
-						image->comps[0].data[index+1] = ((dat8[i+4]& 0x0f)<< 8)	| dat8[i+5];
-						image->comps[1].data[index+1] = ( dat8[i+6] <<4)		|(dat8[i+7]>>4);
-						image->comps[2].data[index+1] = ((dat8[i+7]& 0x0f)<< 8)	| dat8[i+8];
-						index+=2;
-					}else
-						break;
-				}
-			}
-			else if( Info.tiBps==16){
-				for (i=0; i<ssize; i+=6) {	/* 16 bits per pixel */
-					if(index < imgsize){
-						image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0]; // R 
-						image->comps[1].data[index] = ( dat8[i+3] << 8 ) | dat8[i+2]; // G 
-						image->comps[2].data[index] = ( dat8[i+5] << 8 ) | dat8[i+4]; // B 
-						if(parameters->cp_cinema){/* Rounding to 12 bits*/
-							image->comps[0].data[index] = (image->comps[0].data[index] + 0x08) >> 4 ;
-							image->comps[1].data[index] = (image->comps[1].data[index] + 0x08) >> 4 ;
-							image->comps[2].data[index] = (image->comps[2].data[index] + 0x08) >> 4 ;
-						}
-						index++;
-					}else
-						break;
-				}
-			}
-			else if ( Info.tiBps==8){
-				for (i=0; i<ssize; i+=3) {	/* 8 bits per pixel */
-					if(index < imgsize){
-						image->comps[0].data[index] = dat8[i+0];// R 
-						image->comps[1].data[index] = dat8[i+1];// G 
-						image->comps[2].data[index] = dat8[i+2];// B 
-						if(parameters->cp_cinema){/* Rounding to 12 bits*/
-							image->comps[0].data[index] = image->comps[0].data[index] << 4 ;
-							image->comps[1].data[index] = image->comps[1].data[index] << 4 ;
-							image->comps[2].data[index] = image->comps[2].data[index] << 4 ;
-						}
-						index++;
-					}else
-						break;
-				}
-			}
-			else{
-				fprintf(stderr,"TIFF file creation. Bits=%d, Only 8,12,16 bits implemented\n",Info.tiBps);
-				fprintf(stderr,"Aborting\n");
-				return NULL;
-			}
-		}
-
-		_TIFFfree(buf);
-		TIFFClose(tif);
-	}else if(Info.tiPhoto == 1) { 
-		/* -->> -->> -->>    
-		Black and White
-		<<-- <<-- <<-- */
-
-		numcomps = 1;
-		color_space = CLRSPC_GRAY;
-		/* initialize image components*/ 
-		memset(&cmptparm[0], 0, sizeof(opj_image_cmptparm_t));
-		cmptparm[0].prec = Info.tiBps;
-		cmptparm[0].bpp = Info.tiBps;
-		cmptparm[0].sgnd = 0;
-		cmptparm[0].dx = subsampling_dx;
-		cmptparm[0].dy = subsampling_dy;
-		cmptparm[0].w = w;
-		cmptparm[0].h = h;
-
-		/* create the image*/ 
-		image = opj_image_create(numcomps, &cmptparm[0], color_space);
-		if(!image) {
-			TIFFClose(tif);
-			return NULL;
-		}
-		/* set image offset and reference grid */
-		image->x0 = parameters->image_offset_x0;
-		image->y0 = parameters->image_offset_y0;
-		image->x1 =	!image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-		image->y1 =	!image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-		buf = _TIFFmalloc(TIFFStripSize(tif));
-		strip_size = 0;
-		strip_size = TIFFStripSize(tif);
-		index = 0;
-		imgsize = image->comps[0].w * image->comps[0].h ;
-		/* Read the Image components*/
-		for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-			unsigned char *dat8;
-			int i, ssize;
-			ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
-			dat8 = (unsigned char*)buf;
-
-			if (Info.tiBps==12){
-				for (i=0; i<ssize; i+=3) {	/* 12 bits per pixel*/
-					if(index < imgsize){
-						image->comps[0].data[index]   = ( dat8[i+0]<<4 )		|(dat8[i+1]>>4) ;
-						image->comps[0].data[index+1] = ((dat8[i+1]& 0x0f)<< 8)	| dat8[i+2];
-						index+=2;
-					}else
-						break;
-				}
-			}
-			else if( Info.tiBps==16){
-				for (i=0; i<ssize; i+=2) {	/* 16 bits per pixel */
-					if(index < imgsize){
-						image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0];
-						index++;
-					}else
-						break;
-				}
-			}
-			else if ( Info.tiBps==8){
-				for (i=0; i<ssize; i+=1) {	/* 8 bits per pixel */
-					if(index < imgsize){
-						image->comps[0].data[index] = dat8[i+0];
-						index++;
-					}else
-						break;
-				}
-			}
-			else{
-				fprintf(stderr,"TIFF file creation. Bits=%d, Only 8,12,16 bits implemented\n",Info.tiBps);
-				fprintf(stderr,"Aborting\n");
-				return NULL;
-			}
-		}
-
-		_TIFFfree(buf);
-		TIFFClose(tif);
-	}else{
-		fprintf(stderr,"TIFF file creation. Bad color format. Only RGB & Grayscale has been implemented\n");
-		fprintf(stderr,"Aborting\n");
-		return NULL;
-	}
-	return image;
-}
-
-#endif /* HAVE_LIBTIFF */
-
-/* -->> -->> -->> -->>
-
-	RAW IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
-	int subsampling_dx = parameters->subsampling_dx;
-	int subsampling_dy = parameters->subsampling_dy;
-
-	FILE *f = NULL;
-	int i, compno, numcomps, w, h;
-	OPJ_COLOR_SPACE color_space;
-	opj_image_cmptparm_t *cmptparm;	
-	opj_image_t * image = NULL;
-	unsigned short ch;
-	
-	if((! (raw_cp->rawWidth & raw_cp->rawHeight & raw_cp->rawComp & raw_cp->rawBitDepth)) == 0)
-	{
-		fprintf(stderr,"\nError: invalid raw image parameters\n");
-		fprintf(stderr,"Please use the Format option -F:\n");
-		fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-		fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-		fprintf(stderr,"Aborting\n");
-		return NULL;
-	}
-
-	f = fopen(filename, "rb");
-	if (!f) {
-		fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-		fprintf(stderr,"Aborting\n");
-		return NULL;
-	}
-	numcomps = raw_cp->rawComp;
-	color_space = CLRSPC_SRGB;
-	w = raw_cp->rawWidth;
-	h = raw_cp->rawHeight;
-	cmptparm = (opj_image_cmptparm_t*) malloc(numcomps * sizeof(opj_image_cmptparm_t));
-	
-	/* initialize image components */	
-	memset(&cmptparm[0], 0, numcomps * sizeof(opj_image_cmptparm_t));
-	for(i = 0; i < numcomps; i++) {		
-		cmptparm[i].prec = raw_cp->rawBitDepth;
-		cmptparm[i].bpp = raw_cp->rawBitDepth;
-		cmptparm[i].sgnd = raw_cp->rawSigned;
-		cmptparm[i].dx = subsampling_dx;
-		cmptparm[i].dy = subsampling_dy;
-		cmptparm[i].w = w;
-		cmptparm[i].h = h;
-	}
-	/* create the image */
-	image = opj_image_create(numcomps, &cmptparm[0], color_space);
-	if(!image) {
-		fclose(f);
-		return NULL;
-	}
-	/* set image offset and reference grid */
-	image->x0 = parameters->image_offset_x0;
-	image->y0 = parameters->image_offset_y0;
-	image->x1 = parameters->image_offset_x0 + (w - 1) *	subsampling_dx + 1;
-	image->y1 = parameters->image_offset_y0 + (h - 1) *	subsampling_dy + 1;
-
-	if(raw_cp->rawBitDepth <= 8)
-	{
-		unsigned char value = 0;
-		for(compno = 0; compno < numcomps; compno++) {
-			for (i = 0; i < w * h; i++) {
-				if (!fread(&value, 1, 1, f)) {
-					fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
-					return NULL;
-				}
-				image->comps[compno].data[i] = raw_cp->rawSigned?(char)value:value;
-			}
-		}
-	}
-	else if(raw_cp->rawBitDepth <= 16)
-	{
-		unsigned short value;
-		for(compno = 0; compno < numcomps; compno++) {
-			for (i = 0; i < w * h; i++) {
-				unsigned char temp;
-				if (!fread(&temp, 1, 1, f)) {
-					fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
-					return NULL;
-				}
-				value = temp << 8;
-				if (!fread(&temp, 1, 1, f)) {
-					fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
-					return NULL;
-				}
-				value += temp;
-				image->comps[compno].data[i] = raw_cp->rawSigned?(short)value:value;
-			}
-		}
-	}
-	else {
-		fprintf(stderr,"OpenJPEG cannot encode raw components with bit depth higher than 16 bits.\n");
-		return NULL;
-	}
-
-	if (fread(&ch, 1, 1, f)) {
-		fprintf(stderr,"Warning. End of raw file not reached... processing anyway\n");
-	}
-	fclose(f);
-
-	return image;
-}
-
-int imagetoraw(opj_image_t * image, const char *outfile)
-{
-	FILE *rawFile = NULL;
-	int compno;
-	int w, h;
-	int line, row;
-	int *ptr;
-
-	if((image->numcomps * image->x1 * image->y1) == 0)
-	{
-		fprintf(stderr,"\nError: invalid raw image parameters\n");
-		return 1;
-	}
-
-	rawFile = fopen(outfile, "wb");
-	if (!rawFile) {
-		fprintf(stderr, "Failed to open %s for writing !!\n", outfile);
-		return 1;
-	}
-
-	fprintf(stdout,"Raw image characteristics: %d components\n", image->numcomps);
-
-	for(compno = 0; compno < image->numcomps; compno++)
-	{
-		fprintf(stdout,"Component %d characteristics: %dx%dx%d %s\n", compno, image->comps[compno].w,
-			image->comps[compno].h, image->comps[compno].prec, image->comps[compno].sgnd==1 ? "signed": "unsigned");
-
-		w = image->comps[compno].w;
-		h = image->comps[compno].h;
-
-		if(image->comps[compno].prec <= 8)
-		{
-			if(image->comps[compno].sgnd == 1)
-			{
-				signed char curr;
-				int mask = (1 << image->comps[compno].prec) - 1;
-				ptr = image->comps[compno].data;
-				for (line = 0; line < h; line++) {
-					for(row = 0; row < w; row++)	{				
-						curr = (signed char) (*ptr & mask);
-						fwrite(&curr, sizeof(signed char), 1, rawFile);
-						ptr++;
-					}
-				}
-			}
-			else if(image->comps[compno].sgnd == 0)
-			{
-				unsigned char curr;
-				int mask = (1 << image->comps[compno].prec) - 1;
-				ptr = image->comps[compno].data;
-				for (line = 0; line < h; line++) {
-					for(row = 0; row < w; row++)	{	
-						curr = (unsigned char) (*ptr & mask);
-						fwrite(&curr, sizeof(unsigned char), 1, rawFile);
-						ptr++;
-					}
-				}
-			}
-		}
-		else if(image->comps[compno].prec <= 16)
-		{
-			if(image->comps[compno].sgnd == 1)
-			{
-				signed short int curr;
-				int mask = (1 << image->comps[compno].prec) - 1;
-				ptr = image->comps[compno].data;
-				for (line = 0; line < h; line++) {
-					for(row = 0; row < w; row++)	{					
-						unsigned char temp;
-						curr = (signed short int) (*ptr & mask);
-						temp = (unsigned char) (curr >> 8);
-						fwrite(&temp, 1, 1, rawFile);
-						temp = (unsigned char) curr;
-						fwrite(&temp, 1, 1, rawFile);
-						ptr++;
-					}
-				}
-			}
-			else if(image->comps[compno].sgnd == 0)
-			{
-				unsigned short int curr;
-				int mask = (1 << image->comps[compno].prec) - 1;
-				ptr = image->comps[compno].data;
-				for (line = 0; line < h; line++) {
-					for(row = 0; row < w; row++)	{				
-						unsigned char temp;
-						curr = (unsigned short int) (*ptr & mask);
-						temp = (unsigned char) (curr >> 8);
-						fwrite(&temp, 1, 1, rawFile);
-						temp = (unsigned char) curr;
-						fwrite(&temp, 1, 1, rawFile);
-						ptr++;
-					}
-				}
-			}
-		}
-		else if (image->comps[compno].prec <= 32)
-		{
-			fprintf(stderr,"More than 16 bits per component no handled yet\n");
-			return 1;
-		}
-		else
-		{
-			fprintf(stderr,"Error: invalid precision: %d\n", image->comps[compno].prec);
-			return 1;
-		}
-	}
-	fclose(rawFile);
-	return 0;
-}
-
-#ifdef HAVE_LIBPNG
-
-#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
-#define MAGIC_SIZE 8
-/* PNG allows bits per sample: 1, 2, 4, 8, 16 */
-
-opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
-{
-	png_structp  png;
-	png_infop    info;
-	double gamma, display_exponent;
-	int bit_depth, interlace_type,compression_type, filter_type;
-	int unit;
-	png_uint_32 resx, resy;
-	unsigned int i, j;
-	png_uint_32  width, height;
-	int color_type, has_alpha, is16;
-	unsigned char *s;
-	FILE *reader;
-	unsigned char **rows;
-/* j2k: */
-	opj_image_t *image;
-	opj_image_cmptparm_t cmptparm[4];
-	int sub_dx, sub_dy;
-	unsigned int nr_comp;
-	int *r, *g, *b, *a;
-	unsigned char sigbuf[8];
-
-	if((reader = fopen(read_idf, "rb")) == NULL)
-   {
-	fprintf(stderr,"pngtoimage: can not open %s\n",read_idf);
-	return NULL;
-   }
-	image = NULL; png = NULL; rows = NULL;
-
-	if(fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE
-	|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0)
-   {
-	fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf);
-	goto fin;
-   }
-/* libpng-VERSION/example.c: 
- * PC : screen_gamma = 2.2;
- * Mac: screen_gamma = 1.7 or 1.0;
-*/
-	display_exponent = 2.2;
-
-	if((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
-				    NULL, NULL, NULL)) == NULL)
-	  goto fin;
-	if((info = png_create_info_struct(png)) == NULL)
-	  goto fin;
-
-	if(setjmp(png_jmpbuf(png)))
-	  goto fin;
-
-	png_init_io(png, reader);
-	png_set_sig_bytes(png, MAGIC_SIZE);
-
-	png_read_info(png, info);
-
-	if(png_get_IHDR(png, info, &width, &height,
-		&bit_depth, &color_type, &interlace_type, 
-		&compression_type, &filter_type) == 0)
-	 goto fin;
-
-/* png_set_expand():
- * expand paletted images to RGB, expand grayscale images of
- * less than 8-bit depth to 8-bit depth, and expand tRNS chunks
- * to alpha channels.
-*/
-	if(color_type == PNG_COLOR_TYPE_PALETTE)
-	  png_set_expand(png);
-	else
-	if(color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
-	  png_set_expand(png);
-
-	if(png_get_valid(png, info, PNG_INFO_tRNS))
-	  png_set_expand(png);
-
-	is16 = (bit_depth == 16);
-
-/* GRAY => RGB; GRAY_ALPHA => RGBA
-*/
-	if(color_type == PNG_COLOR_TYPE_GRAY
-	|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-   {
-	png_set_gray_to_rgb(png);
-	color_type = 
-	 (color_type == PNG_COLOR_TYPE_GRAY? PNG_COLOR_TYPE_RGB:
-		PNG_COLOR_TYPE_RGB_ALPHA);
-   }
-	if( !png_get_gAMA(png, info, &gamma))
-	  gamma = 0.45455;
-
-	png_set_gamma(png, display_exponent, gamma);
-
-	png_read_update_info(png, info);
-
-	png_get_pHYs(png, info, &resx, &resy, &unit);
-
-	color_type = png_get_color_type(png, info);
-
-	has_alpha = (color_type == PNG_COLOR_TYPE_RGB_ALPHA);
-
-	nr_comp = 3 + has_alpha;
-
-	bit_depth = png_get_bit_depth(png, info);
-
-	rows = (unsigned char**)calloc(height+1, sizeof(unsigned char*));
-	for(i = 0; i < height; ++i)
-	 rows[i] = (unsigned char*)malloc(png_get_rowbytes(png,info));
-
-	png_read_image(png, rows);
-
-	memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t));
-
-	sub_dx = params->subsampling_dx; sub_dy = params->subsampling_dy;
-
-	for(i = 0; i < nr_comp; ++i)
-   {
-	cmptparm[i].prec = bit_depth;
-/* bits_per_pixel: 8 or 16 */
-	cmptparm[i].bpp = bit_depth;
-	cmptparm[i].sgnd = 0;
-	cmptparm[i].dx = sub_dx;
-	cmptparm[i].dy = sub_dy;
-	cmptparm[i].w = width;
-	cmptparm[i].h = height;
-   }
-
-	image = opj_image_create(nr_comp, &cmptparm[0], CLRSPC_SRGB);
-
-	if(image == NULL) goto fin;
-
-    image->x0 = params->image_offset_x0;
-    image->y0 = params->image_offset_y0;
-    image->x1 = image->x0 + (width  - 1) * sub_dx + 1 + image->x0;
-    image->y1 = image->y0 + (height - 1) * sub_dy + 1 + image->y0;
-
-	r = image->comps[0].data;
-	g = image->comps[1].data;
-	b = image->comps[2].data;
-	a = image->comps[3].data;
-
-	for(i = 0; i < height; ++i)
-   {
-	s = rows[i];
-
-	for(j = 0; j < width; ++j)
-  {
-	if(is16)
- {
-	*r++ = s[0]<<8|s[1]; s += 2;
-
-	*g++ = s[0]<<8|s[1]; s += 2;
-	
-	*b++ = s[0]<<8|s[1]; s += 2;
-	
-	if(has_alpha) { *a++ = s[0]<<8|s[1]; s += 2; }
-
-	continue;
- }
-	*r++ = *s++; *g++ = *s++; *b++ = *s++;
-
-	if(has_alpha) *a++ = *s++;
-  }
-   }
-fin:
-	if(rows)
-   {
-	for(i = 0; i < height; ++i)
-	 free(rows[i]);
-	free(rows);
-   }
-	if(png)
-	  png_destroy_read_struct(&png, &info, NULL);
-
-	fclose(reader);
-
-	return image;
-
-}/* pngtoimage() */
-
-int imagetopng(opj_image_t * image, const char *write_idf)
-{
-	FILE *writer;
-	png_structp png;
-	png_infop info;
-	int *red, *green, *blue, *alpha;
-	unsigned char *row_buf, *d;
-	int has_alpha, width, height, nr_comp, color_type;
-	int adjustR, adjustG, adjustB, x, y, fails, is16, force16;
-  int opj_prec, prec, ushift, dshift;
-	unsigned short mask = 0xffff;
-	png_color_8 sig_bit;
-
-	is16 = force16 = ushift = dshift = 0; fails = 1;
-	prec = opj_prec = image->comps[0].prec;
-
-	if(prec > 8 && prec < 16)
-   {
-	 prec = 16; force16 = 1;
-   }
-	if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16)
-   {
-	fprintf(stderr,"imagetopng: can not create %s"
-	 "\n\twrong bit_depth %d\n", write_idf, prec);
-	return fails;
-   }
-	writer = fopen(write_idf, "wb");
-
-	if(writer == NULL) return fails;
-
-	info = NULL; has_alpha = 0;
-
-/* Create and initialize the png_struct with the desired error handler
- * functions.  If you want to use the default stderr and longjump method,
- * you can supply NULL for the last three parameters.  We also check that
- * the library version is compatible with the one used at compile time,
- * in case we are using dynamically linked libraries.  REQUIRED.
-*/
-	png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
-		NULL, NULL, NULL);
-/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
-
-	if(png == NULL) goto fin;
-
-/* Allocate/initialize the image information data.  REQUIRED 
-*/
-	info = png_create_info_struct(png);
-
-	if(info == NULL) goto fin;
-
-/* Set error handling.  REQUIRED if you are not supplying your own
- * error handling functions in the png_create_write_struct() call.
-*/
-	if(setjmp(png_jmpbuf(png))) goto fin;
-
-/* I/O initialization functions is REQUIRED 
-*/
-	png_init_io(png, writer);
-
-/* Set the image information here.  Width and height are up to 2^31,
- * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
- * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
- * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
- * or PNG_COLOR_TYPE_RGB_ALPHA.  interlace is either PNG_INTERLACE_NONE or
- * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
- * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. 
- * REQUIRED
-*/
-	png_set_compression_level(png, Z_BEST_COMPRESSION);
-
-	if(prec == 16) mask = 0xffff;
-	else
-	if(prec == 8) mask = 0x00ff;
-	else
-	if(prec == 4) mask = 0x000f;
-	else
-	if(prec == 2) mask = 0x0003;
-	else
-	if(prec == 1) mask = 0x0001;
-
-	nr_comp = image->numcomps;
-
-	if(nr_comp >= 3
-    && image->comps[0].dx == image->comps[1].dx
-    && image->comps[1].dx == image->comps[2].dx
-    && image->comps[0].dy == image->comps[1].dy
-    && image->comps[1].dy == image->comps[2].dy
-    && image->comps[0].prec == image->comps[1].prec
-    && image->comps[1].prec == image->comps[2].prec)
-   {
-	int v;
-
-    has_alpha = (nr_comp > 3); 
-
-	is16 = (prec == 16);
-	
-    width = image->comps[0].w;
-    height = image->comps[0].h;
-
-	red = image->comps[0].data;
-	green = image->comps[1].data;
-	blue = image->comps[2].data;
-
-    sig_bit.red = sig_bit.green = sig_bit.blue = prec;
-
-	if(has_alpha) 
-  {
-	sig_bit.alpha = prec;
-	alpha = image->comps[3].data; 
-	color_type = PNG_COLOR_TYPE_RGB_ALPHA;
-  }
-	else 
-  {
-	sig_bit.alpha = 0; alpha = NULL;
-	color_type = PNG_COLOR_TYPE_RGB;
-  }
-	png_set_sBIT(png, info, &sig_bit);
-
-	png_set_IHDR(png, info, width, height, prec, 
-	 color_type,
-	 PNG_INTERLACE_NONE,
-	 PNG_COMPRESSION_TYPE_BASE,  PNG_FILTER_TYPE_BASE);
-
-/*=============================*/
-	png_write_info(png, info);
-/*=============================*/
-	if(opj_prec < 8)
-  {
-	png_set_packing(png);
-  }
-	if(force16)
-  {
-	ushift = 16 - opj_prec; dshift = opj_prec - ushift;	
-  }
-    adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-    adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
-    adjustB = (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
-
-	row_buf = (unsigned char*)malloc(width * nr_comp * 2);
-
-	for(y = 0; y < height; ++y)
-  {
-	d = row_buf;
-
-	for(x = 0; x < width; ++x)
- {
-		if(is16)
-	   {
-/* Network byte order */
-		v = *red + adjustR; ++red;
-		
-		if(force16) { v = (v<<ushift) + (v>>dshift); }
-
-	    *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v;
-
-		v = *green + adjustG; ++green;
-		
-		if(force16) { v = (v<<ushift) + (v>>dshift); }
-
-	    *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v;
-
-		v =  *blue + adjustB; ++blue;
-		
-		if(force16) { v = (v<<ushift) + (v>>dshift); }
-
-	    *d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v;
-
-		if(has_alpha)
-	  {
-		v = *alpha++;
-		
-		if(force16) { v = (v<<ushift) + (v>>dshift); }
-
-		*d++ = (unsigned char)(v>>8); *d++ = (unsigned char)v;
-	  }
-		continue;
-	   }
-		*d++ = (unsigned char)((*red + adjustR) & mask); ++red;
-		*d++ = (unsigned char)((*green + adjustG) & mask); ++green;
-		*d++ = (unsigned char)((*blue + adjustB) & mask); ++blue;
-
-		if(has_alpha)
-	   {
-		*d++ = (unsigned char)(*alpha & mask); ++alpha;
-	   }
- }	/* for(x) */
-
-	png_write_row(png, row_buf);
-
-  }	/* for(y) */
-	free(row_buf);
-
-   }/* nr_comp >= 3 */
-	else
-	if(nr_comp == 1 /* GRAY */
-	|| (   nr_comp == 2 /* GRAY_ALPHA */
-		&& image->comps[0].dx == image->comps[1].dx
-		&& image->comps[0].dy == image->comps[1].dy
-		&& image->comps[0].prec == image->comps[1].prec))
-   {
-	int v;
-
-	red = image->comps[0].data;
-
-    if(force16)
-  {
-    ushift = 16 - opj_prec; dshift = opj_prec - ushift;
-  }
-
-    sig_bit.gray = prec;
-    sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 0;
-	alpha = NULL;
-	color_type = PNG_COLOR_TYPE_GRAY;
-
-    if(nr_comp == 2) 
-  { 
-	has_alpha = 1; sig_bit.alpha = prec;
-	alpha = image->comps[1].data;
-	color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
-  }
-    width = image->comps[0].w;
-    height = image->comps[0].h;
-
-	png_set_IHDR(png, info, width, height, sig_bit.gray,
-     color_type,
-     PNG_INTERLACE_NONE,
-     PNG_COMPRESSION_TYPE_BASE,  PNG_FILTER_TYPE_BASE);
-
-	png_set_sBIT(png, info, &sig_bit);
-/*=============================*/
-	png_write_info(png, info);
-/*=============================*/
-	adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-
-	if(opj_prec < 8)
-  {
-	png_set_packing(png);
-  }
-
-	if(prec > 8)
-  {
-/* Network byte order */
-
-
-	row_buf = (unsigned char*)
-	 malloc(width * nr_comp * sizeof(unsigned short));
-
-	for(y = 0; y < height; ++y)
- {
-	d = row_buf;
-
-		for(x = 0; x < width; ++x)
-	   {
-		v = *red + adjustR; ++red;
-
-		if(force16) { v = (v<<ushift) + (v>>dshift); }
-
-		*d++ = (unsigned char)(v>>8); *d++ = (unsigned char)(v & 0xff);
-
-		if(has_alpha)
-	  {
-		v = *alpha++;
-
-		if(force16) { v = (v<<ushift) + (v>>dshift); }
-
-		*d++ = (unsigned char)(v>>8); *d++ = (unsigned char)(v & 0xff);
-	  }
-	   }/* for(x) */
-	png_write_row(png, row_buf);
-
- }	/* for(y) */
-	free(row_buf);
-  }
-	else /* prec <= 8 */
-  {
-	row_buf = (unsigned char*)calloc(width, nr_comp * 2);
-
-	for(y = 0; y < height; ++y)
- {
-	d = row_buf;
-
-		for(x = 0; x < width; ++x)
-	   {
-		*d++ = (unsigned char)((*red + adjustR) & mask); ++red;
-
-		if(has_alpha)
-	  {
-		*d++ = (unsigned char)(*alpha & mask); ++alpha;
-	  }
-	   }/* for(x) */
-
-	png_write_row(png, row_buf);
-
- }	/* for(y) */
-	free(row_buf);
-  }
-   }
-	else
-   {
-	fprintf(stderr,"imagetopng: can not create %s\n",write_idf);
-	goto fin;
-   }
-	png_write_end(png, info);
-
-	fails = 0;
-
-fin:
-
-	if(png)
-   {
-    png_destroy_write_struct(&png, &info);
-   }
-	fclose(writer);
-
-	if(fails) remove(write_idf);
-
-	return fails;
-}/* imagetopng() */
-#endif /* HAVE_LIBPNG */
-
diff --git a/Utilities/gdcmopenjpeg-v1/codec/convert.h b/Utilities/gdcmopenjpeg-v1/codec/convert.h
deleted file mode 100644
index 1dc58d7..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/convert.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __J2K_CONVERT_H
-#define __J2K_CONVERT_H
-
-/**@name RAW image encoding parameters */
-/*@{*/
-typedef struct raw_cparameters {
-	/** width of the raw image */
-	int rawWidth;
-	/** height of the raw image */
-	int rawHeight;
-	/** components of the raw image */
-	int rawComp;
-	/** bit depth of the raw image */
-	int rawBitDepth;
-	/** signed/unsigned raw image */
-	bool rawSigned;
-	/*@}*/
-} raw_cparameters_t;
-
-/* TGA conversion */
-opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetotga(opj_image_t * image, const char *outfile);
-
-/* BMP conversion */
-opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetobmp(opj_image_t *image, const char *outfile);
-
-/* TIFF conversion*/
-opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetotif(opj_image_t *image, const char *outfile);
-/**
-Load a single image component encoded in PGX file format
- at param filename Name of the PGX file to load
- at param parameters *List ?*
- at return Returns a greyscale image if successful, returns NULL otherwise
-*/
-opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetopgx(opj_image_t *image, const char *outfile);
-
-opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetopnm(opj_image_t *image, const char *outfile);
-
-/* RAW conversion */
-int imagetoraw(opj_image_t * image, const char *outfile);
-opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
-
-/* PNG conversion*/
-extern int imagetopng(opj_image_t *image, const char *write_idf);
-extern opj_image_t* pngtoimage(const char *filename, opj_cparameters_t *parameters);
-
-#endif /* __J2K_CONVERT_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.c b/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.c
deleted file mode 100644
index 443d4e0..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.c
+++ /dev/null
@@ -1,1789 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-#ifdef _WIN32
-#include "windirent.h"
-#else
-#include <dirent.h>
-#endif /* _WIN32 */
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <strings.h>
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#endif /* _WIN32 */
-
-#include "opj_config.h"
-#include "openjpeg.h"
-#include "getopt.h"
-#include "convert.h"
-#include "index.h"
-
-#include "format_defs.h"
-
-#define CINEMA_24_CS 1302083	/*Codestream length for 24fps*/
-#define CINEMA_48_CS 651041		/*Codestream length for 48fps*/
-#define COMP_24_CS 1041666		/*Maximum size per color component for 2K & 4K @ 24fps*/
-#define COMP_48_CS 520833		/*Maximum size per color component for 2K @ 48fps*/
-
-typedef struct dircnt{
-	/** Buffer for holding images read from Directory*/
-	char *filename_buf;
-	/** Pointer to the buffer*/
-	char **filename;
-}dircnt_t;
-
-typedef struct img_folder{
-	/** The directory path of the folder containing input images*/
-	char *imgdirpath;
-	/** Output format*/
-	char *out_format;
-	/** Enable option*/
-	char set_imgdir;
-	/** Enable Cod Format for output*/
-	char set_out_format;
-	/** User specified rate stored in case of cinema option*/
-	float *rates;
-}img_fol_t;
-
-void encode_help_display() {
-	fprintf(stdout,"HELP for image_to_j2k\n----\n\n");
-	fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-/* UniPG>> */
-	fprintf(stdout,"List of parameters for the JPEG 2000 "
-#ifdef USE_JPWL
-		"+ JPWL "
-#endif /* USE_JPWL */
-		"encoder:\n");
-/* <<UniPG */
-	fprintf(stdout,"\n");
-	fprintf(stdout,"REMARKS:\n");
-	fprintf(stdout,"---------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
-	fprintf(stdout,"COD and QCD never appear in the tile_header.\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"By default:\n");
-	fprintf(stdout,"------------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout," * Lossless\n");
-	fprintf(stdout," * 1 tile\n");
-	fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
-	fprintf(stdout," * Size of code-block : 64 x 64\n");
-	fprintf(stdout," * Number of resolutions: 6\n");
-	fprintf(stdout," * No SOP marker in the codestream\n");
-	fprintf(stdout," * No EPH marker in the codestream\n");
-	fprintf(stdout," * No sub-sampling in x or y direction\n");
-	fprintf(stdout," * No mode switch activated\n");
-	fprintf(stdout," * Progression order: LRCP\n");
-	fprintf(stdout," * No index file\n");
-	fprintf(stdout," * No ROI upshifted\n");
-	fprintf(stdout," * No offset of the origin of the image\n");
-	fprintf(stdout," * No offset of the origin of the tiles\n");
-	fprintf(stdout," * Reversible DWT 5-3\n");
-/* UniPG>> */
-#ifdef USE_JPWL
-	fprintf(stdout," * No JPWL protection\n");
-#endif /* USE_JPWL */
-/* <<UniPG */
-	fprintf(stdout,"\n");
-	fprintf(stdout,"Parameters:\n");
-	fprintf(stdout,"------------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"Required Parameters (except with -h):\n");
-	fprintf(stdout,"One of the two options -ImgDir or -i must be used\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-ImgDir      : Image file Directory path (example ../Images) \n");
-	fprintf(stdout,"    When using this option -OutFor must be used\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-OutFor \n");
-	fprintf(stdout,"    REQUIRED only if -ImgDir is used\n");
-	fprintf(stdout,"	  Need to specify only format without filename <BMP>  \n");
-	fprintf(stdout,"    Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA formats\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-i           : source file  (-i source.pnm also *.pgm, *.ppm, *.pgx, *png, *.bmp, *.tif, *.raw, *.tga) \n");
-	fprintf(stdout,"    When using this option -o must be used\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-o           : destination file (-o dest.j2k or .jp2) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"Optional Parameters:\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-h           : display the help information \n ");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-cinema2K    : Digital Cinema 2K profile compliant codestream for 2K resolution.(-cinema2k 24 or 48) \n");
-  fprintf(stdout,"	  Need to specify the frames per second for a 2K resolution. Only 24 or 48 fps is allowed\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-cinema4K    : Digital Cinema 4K profile compliant codestream for 4K resolution \n");
-	fprintf(stdout,"	  Frames per second not required. Default value is 24fps\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-r           : different compression ratios for successive layers (-r 20,10,5)\n ");
-	fprintf(stdout,"	         - The rate specified for each quality level is the desired \n");
-	fprintf(stdout,"	           compression factor.\n");
-	fprintf(stdout,"		   Example: -r 20,10,1 means quality 1: compress 20x, \n");
-	fprintf(stdout,"		     quality 2: compress 10x and quality 3: compress lossless\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-	fprintf(stdout,"\n");
-
-	fprintf(stdout,"-q           : different psnr for successive layers (-q 30,40,50) \n ");
-
-	fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-n           : number of resolutions (-n 3) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-b           : size of code block (-b 32,32) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-c           : size of precinct (-c 128,128) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-t           : size of tile (-t 512,512) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-p           : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-s           : subsampling factor (-s 2,2) [-s X,Y] \n");
-	fprintf(stdout,"	     Remark: subsampling bigger than 2 can produce error\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-POC         : Progression order change (-POC T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL) \n");
-	fprintf(stdout,"      Example: T1=0,0,1,5,3,CPRL \n");
-	fprintf(stdout,"			 : Ttilenumber=Resolution num start,Component num start,Layer num end,Resolution num end,Component num end,Progression order\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-SOP         : write SOP marker before each packet \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-EPH         : write EPH marker after each header packet \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-M           : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
-	fprintf(stdout,"                 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
-	fprintf(stdout,"                 Indicate multiple modes by adding their values. \n");
-	fprintf(stdout,"                 ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-x           : create an index file *.Idx (-x index_name.Idx) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-ROI         : c=%%d,U=%%d : quantization indices upshifted \n");
-	fprintf(stdout,"               for component c=%%d [%%d = 0,1,2]\n");
-	fprintf(stdout,"               with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI c=0,U=25) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-d           : offset of the origin of the image (-d 150,300) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-T           : offset of the origin of the tiles (-T 100,75) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-I           : use the irreversible DWT 9-7 (-I) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-F           : characteristics of the raw input image\n");
-	fprintf(stdout,"               -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-	fprintf(stdout,"               Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-	fprintf(stdout,"\n");
-/* UniPG>> */
-#ifdef USE_JPWL
-	fprintf(stdout,"-W           : adoption of JPWL (Part 11) capabilities (-W params)\n");
-	fprintf(stdout,"               The parameters can be written and repeated in any order:\n");
-	fprintf(stdout,"               [h<tilepart><=type>,s<tilepart><=method>,a=<addr>,...\n");
-	fprintf(stdout,"                ...,z=<size>,g=<range>,p<tilepart:pack><=type>]\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 h selects the header error protection (EPB): 'type' can be\n");
-	fprintf(stdout,"                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
-	fprintf(stdout,"                   if 'tilepart' is absent, it is for main and tile headers\n");
-	fprintf(stdout,"                   if 'tilepart' is present, it applies from that tile\n");
-	fprintf(stdout,"                     onwards, up to the next h<> spec, or to the last tilepart\n");
-	fprintf(stdout,"                     in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 p selects the packet error protection (EEP/UEP with EPBs)\n");
-	fprintf(stdout,"                  to be applied to raw data: 'type' can be\n");
-	fprintf(stdout,"                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
-	fprintf(stdout,"                   if 'tilepart:pack' is absent, it is from tile 0, packet 0\n");
-	fprintf(stdout,"                   if 'tilepart:pack' is present, it applies from that tile\n");
-	fprintf(stdout,"                     and that packet onwards, up to the next packet spec\n");
-	fprintf(stdout,"                     or to the last packet in the last tilepart in the stream\n");
-	fprintf(stdout,"                     (max. %d specs)\n", JPWL_MAX_NO_PACKSPECS);
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 s enables sensitivity data insertion (ESD): 'method' can be\n");
-	fprintf(stdout,"                   [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR\n");
-	fprintf(stdout,"                    4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]\n");
-	fprintf(stdout,"                   if 'tilepart' is absent, it is for main header only\n");
-	fprintf(stdout,"                   if 'tilepart' is present, it applies from that tile\n");
-	fprintf(stdout,"                     onwards, up to the next s<> spec, or to the last tilepart\n");
-	fprintf(stdout,"                     in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 g determines the addressing mode: <range> can be\n");
-	fprintf(stdout,"                   [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 a determines the size of data addressing: <addr> can be\n");
-	fprintf(stdout,"                   2/4 bytes (small/large codestreams). If not set, auto-mode\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 z determines the size of sensitivity values: <size> can be\n");
-	fprintf(stdout,"                   1/2 bytes, for the transformed pseudo-floating point value\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 ex.:\n");
-	fprintf(stdout,"                   h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,\n");
-	fprintf(stdout,"                     s0=6,s3=-1,a=0,g=1,z=1\n");
-	fprintf(stdout,"                 means\n");
-	fprintf(stdout,"                   predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,\n");
-	fprintf(stdout,"                   CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,\n");
-	fprintf(stdout,"                   UEP rs(78,32) for packets 0 to 23 of tile 0,\n");
-	fprintf(stdout,"                   UEP rs(56,32) for packs. 24 to the last of tilepart 0,\n");
-	fprintf(stdout,"                   UEP rs default for packets of tilepart 1,\n");
-	fprintf(stdout,"                   no UEP for packets 0 to 19 of tilepart 3,\n");
-	fprintf(stdout,"                   UEP CRC-32 for packs. 20 of tilepart 3 to last tilepart,\n");
-	fprintf(stdout,"                   relative sensitivity ESD for MH,\n");
-	fprintf(stdout,"                   TSE ESD from TPH 0 to TPH 2, byte range with automatic\n");
-	fprintf(stdout,"                   size of addresses and 1 byte for each sensitivity value\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 ex.:\n");
-	fprintf(stdout,"                       h,s,p\n");
-	fprintf(stdout,"                 means\n");
-	fprintf(stdout,"                   default protection to headers (MH and TPHs) as well as\n");
-	fprintf(stdout,"                   data packets, one ESD in MH\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"                 N.B.: use the following recommendations when specifying\n");
-	fprintf(stdout,"                       the JPWL parameters list\n");
-	fprintf(stdout,"                   - when you use UEP, always pair the 'p' option with 'h'\n");
-	fprintf(stdout,"                 \n");
-#endif /* USE_JPWL */
-/* <<UniPG */
-	fprintf(stdout,"IMPORTANT:\n");
-	fprintf(stdout,"-----------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"The index file has the structure below:\n");
-	fprintf(stdout,"---------------------------------------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"Image_height Image_width\n");
-	fprintf(stdout,"progression order\n");
-	fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
-	fprintf(stdout,"Tiles_nb_X Tiles_nb_Y\n");
-	fprintf(stdout,"Components_nb\n");
-	fprintf(stdout,"Layers_nb\n");
-	fprintf(stdout,"decomposition_levels\n");
-	fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
-	fprintf(stdout,"   [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
-	fprintf(stdout,"Main_header_start_position\n");
-	fprintf(stdout,"Main_header_end_position\n");
-	fprintf(stdout,"Codestream_size\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"INFO ON TILES\n");
-	fprintf(stdout,"tileno start_pos end_hd end_tile nbparts disto nbpix disto/nbpix\n");
-	fprintf(stdout,"Tile_0 start_pos end_Theader end_pos NumParts TotalDisto NumPix MaxMSE\n");
-	fprintf(stdout,"Tile_1   ''           ''        ''        ''       ''    ''      ''\n");
-	fprintf(stdout,"...\n");
-	fprintf(stdout,"Tile_Nt   ''           ''        ''        ''       ''    ''     ''\n");
-	fprintf(stdout,"...\n");
-	fprintf(stdout,"TILE 0 DETAILS\n");
-	fprintf(stdout,"part_nb tileno num_packs start_pos end_tph_pos end_pos\n");
-	fprintf(stdout,"...\n");
-	fprintf(stdout,"Progression_string\n");
-	fprintf(stdout,"pack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");
-	fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
-	fprintf(stdout,"...\n");
-	fprintf(stdout,"Tpacket_Np ''   ''    ''   ''    ''       ''       ''     ''\n");
-
-	fprintf(stdout,"MaxDisto\n");
-
-	fprintf(stdout,"TotalDisto\n\n");
-}
-
-OPJ_PROG_ORDER give_progression(char progression[4]) {
-	if(strncmp(progression, "LRCP", 4) == 0) {
-		return LRCP;
-	}
-	if(strncmp(progression, "RLCP", 4) == 0) {
-		return RLCP;
-	}
-	if(strncmp(progression, "RPCL", 4) == 0) {
-		return RPCL;
-	}
-	if(strncmp(progression, "PCRL", 4) == 0) {
-		return PCRL;
-	}
-	if(strncmp(progression, "CPRL", 4) == 0) {
-		return CPRL;
-	}
-
-	return PROG_UNKNOWN;
-}
-
-int get_num_images(char *imgdirpath){
-	DIR *dir;
-	struct dirent* content;
-	int num_images = 0;
-
-	/*Reading the input images from given input directory*/
-
-	dir= opendir(imgdirpath);
-	if(!dir){
-		fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-		return 0;
-	}
-
-	num_images=0;
-	while((content=readdir(dir))!=NULL){
-		if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-			continue;
-		num_images++;
-	}
-	return num_images;
-}
-
-int load_images(dircnt_t *dirptr, char *imgdirpath){
-	DIR *dir;
-	struct dirent* content;
-	int i = 0;
-
-	/*Reading the input images from given input directory*/
-
-	dir= opendir(imgdirpath);
-	if(!dir){
-		fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-		return 1;
-	}else	{
-		fprintf(stderr,"Folder opened successfully\n");
-	}
-
-	while((content=readdir(dir))!=NULL){
-		if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-			continue;
-
-		strcpy(dirptr->filename[i],content->d_name);
-		i++;
-	}
-	return 0;
-}
-
-int get_file_format(char *filename) {
-	unsigned int i;
-	static const char *extension[] = {
-    "pgx", "pnm", "pgm", "ppm", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "j2c", "jpc"
-    };
-	static const int format[] = {
-    PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, J2K_CFMT, J2K_CFMT
-    };
-	char * ext = strrchr(filename, '.');
-	if (ext == NULL)
-		return -1;
-	ext++;
-	for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
-		if(_strnicmp(ext, extension[i], 3) == 0) {
-			return format[i];
-		}
-	}
-	return -1;
-}
-
-char * get_file_name(char *name){
-	char *fname;
-	fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char));
-	fname= strtok(name,".");
-	return fname;
-}
-
-char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters){
-	char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
-  char *temp_p, temp1[OPJ_PATH_LEN]="";
-
-	strcpy(image_filename,dirptr->filename[imageno]);
-	fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
-	parameters->decod_format = get_file_format(image_filename);
-	if (parameters->decod_format == -1)
-		return 1;
-	sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
-	strncpy(parameters->infile, infilename, sizeof(infilename));
-
-	//Set output file
-	strcpy(temp_ofname,get_file_name(image_filename));
-	while((temp_p = strtok(NULL,".")) != NULL){
-		strcat(temp_ofname,temp1);
-		sprintf(temp1,".%s",temp_p);
-	}
-	if(img_fol->set_out_format==1){
-		sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
-		strncpy(parameters->outfile, outfilename, sizeof(outfilename));
-	}
- return 0;
-}
-
-static int initialise_4K_poc(opj_poc_t *POC, int numres){
-	POC[0].tile  = 1;
-	POC[0].resno0  = 0;
-	POC[0].compno0 = 0;
-	POC[0].layno1  = 1;
-	POC[0].resno1  = numres-1;
-	POC[0].compno1 = 3;
-	POC[0].prg1 = CPRL;
-	POC[1].tile  = 1;
-	POC[1].resno0  = numres-1;
-	POC[1].compno0 = 0;
-	POC[1].layno1  = 1;
-	POC[1].resno1  = numres;
-	POC[1].compno1 = 3;
-	POC[1].prg1 = CPRL;
-	return 2;
-}
-
-void cinema_parameters(opj_cparameters_t *parameters){
-	parameters->tile_size_on = false;
-	parameters->cp_tdx=1;
-	parameters->cp_tdy=1;
-
-	/*Tile part*/
-	parameters->tp_flag = 'C';
-	parameters->tp_on = 1;
-
-	/*Tile and Image shall be at (0,0)*/
-	parameters->cp_tx0 = 0;
-	parameters->cp_ty0 = 0;
-	parameters->image_offset_x0 = 0;
-	parameters->image_offset_y0 = 0;
-
-	/*Codeblock size= 32*32*/
-	parameters->cblockw_init = 32;
-	parameters->cblockh_init = 32;
-	parameters->csty |= 0x01;
-
-	/*The progression order shall be CPRL*/
-	parameters->prog_order = CPRL;
-
-	/* No ROI */
-	parameters->roi_compno = -1;
-
-	parameters->subsampling_dx = 1;		parameters->subsampling_dy = 1;
-
-	/* 9-7 transform */
-	parameters->irreversible = 1;
-
-}
-
-void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
-	int i;
-	float temp_rate;
-
-	switch (parameters->cp_cinema){
-	case CINEMA2K_24:
-	case CINEMA2K_48:
-		if(parameters->numresolution > 6){
-			parameters->numresolution = 6;
-		}
-		if (!((image->comps[0].w == 2048) | (image->comps[0].h == 1080))){
-			fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
-				"(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
-				image->comps[0].w,image->comps[0].h);
-			parameters->cp_rsiz = STD_RSIZ;
-		}
-	break;
-
-	case CINEMA4K_24:
-		if(parameters->numresolution < 1){
-				parameters->numresolution = 1;
-			}else if(parameters->numresolution > 7){
-				parameters->numresolution = 7;
-			}
-		if (!((image->comps[0].w == 4096) | (image->comps[0].h == 2160))){
-			fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
-				"(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
-				image->comps[0].w,image->comps[0].h);
-			parameters->cp_rsiz = STD_RSIZ;
-		}
-		parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution);
-		break;
-	default :
-		break;
-	}
-
-	switch (parameters->cp_cinema){
-		case CINEMA2K_24:
-		case CINEMA4K_24:
-			for(i=0 ; i<parameters->tcp_numlayers ; i++){
-				temp_rate = 0 ;
-				if (img_fol->rates[i]== 0){
-					parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-					(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-				}else{
-					temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-						(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
-					if (temp_rate > CINEMA_24_CS ){
-						parameters->tcp_rates[i]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-						(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-					}else{
-						parameters->tcp_rates[i]= img_fol->rates[i];
-					}
-				}
-			}
-			parameters->max_comp_size = COMP_24_CS;
-			break;
-
-		case CINEMA2K_48:
-			for(i=0 ; i<parameters->tcp_numlayers ; i++){
-				temp_rate = 0 ;
-				if (img_fol->rates[i]== 0){
-					parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-					(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-				}else{
-					temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-						(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
-					if (temp_rate > CINEMA_48_CS ){
-						parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-						(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-					}else{
-						parameters->tcp_rates[i]= img_fol->rates[i];
-					}
-				}
-			}
-			parameters->max_comp_size = COMP_48_CS;
-			break;
-		default:
-			break;
-	}
-	parameters->cp_disto_alloc = 1;
-}
-
-/* ------------------------------------------------------------------------------------ */
-
-int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
-													img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
-	int i, j,totlen;
-	option_t long_option[]={
-		{"cinema2K",REQ_ARG, NULL ,'w'},
-		{"cinema4K",NO_ARG, NULL ,'y'},
-		{"ImgDir",REQ_ARG, NULL ,'z'},
-		{"TP",REQ_ARG, NULL ,'v'},
-		{"SOP",NO_ARG, NULL ,'S'},
-		{"EPH",NO_ARG, NULL ,'E'},
-		{"OutFor",REQ_ARG, NULL ,'O'},
-		{"POC",REQ_ARG, NULL ,'P'},
-		{"ROI",REQ_ARG, NULL ,'R'},
-	};
-
-	/* parse the command line */
-	const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:"
-#ifdef USE_JPWL
-		"W:"
-#endif /* USE_JPWL */
-		"h";
-
-	totlen=sizeof(long_option);
-	img_fol->set_out_format=0;
-	raw_cp->rawWidth = 0;
-
-	while (1) {
-    int c = getopt_long(argc, argv, optlist,long_option,totlen);
-		if (c == -1)
-			break;
-		switch (c) {
-			case 'i':			/* input file */
-			{
-				char *infile = optarg;
-				parameters->decod_format = get_file_format(infile);
-				switch(parameters->decod_format) {
-					case PGX_DFMT:
-					case PXM_DFMT:
-					case BMP_DFMT:
-					case TIF_DFMT:
-					case RAW_DFMT:
-					case TGA_DFMT:
-					case PNG_DFMT:
-						break;
-					default:
-						fprintf(stderr,
-							"!! Unrecognized format for infile : %s "
-              "[accept only *.pnm, *.pgm, *.ppm, *.pgx, *png, *.bmp, *.tif, *.raw or *.tga] !!\n\n",
-							infile);
-						return 1;
-				}
-				strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'o':			/* output file */
-			{
-				char *outfile = optarg;
-				parameters->cod_format = get_file_format(outfile);
-				switch(parameters->cod_format) {
-					case J2K_CFMT:
-					case JP2_CFMT:
-						break;
-					default:
-						fprintf(stderr, "Unknown output format image %s [only *.j2k, *.j2c or *.jp2]!! \n", outfile);
-						return 1;
-				}
-				strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-			case 'O':			/* output format */
-				{
-					char outformat[50];
-					char *of = optarg;
-					sprintf(outformat,".%s",of);
-					img_fol->set_out_format = 1;
-					parameters->cod_format = get_file_format(outformat);
-					switch(parameters->cod_format) {
-						case J2K_CFMT:
-						case JP2_CFMT:
-							img_fol->out_format = optarg;
-							break;
-						default:
-							fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
-							return 1;
-					}
-				}
-				break;
-
-
-				/* ----------------------------------------------------- */
-
-
-			case 'r':			/* rates rates/distorsion */
-			{
-				char *s = optarg;
-				parameters->tcp_numlayers = 0;
-				while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
-					parameters->tcp_numlayers++;
-					while (*s && *s != ',') {
-						s++;
-					}
-					if (!*s)
-						break;
-					s++;
-				}
-				parameters->cp_disto_alloc = 1;
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-
-			case 'F':			/* Raw image format parameters */
-			{
-				char signo;
-				char *s = optarg;
-				if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
-					if (signo == 's') {
-						raw_cp->rawSigned = true;
-						fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Signed\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
-					}
-					else if (signo == 'u') {
-						raw_cp->rawSigned = false;
-						fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Unsigned\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
-					}
-					else {
-						fprintf(stderr,"\nError: invalid raw image parameters: Unknown sign of raw file\n");
-						fprintf(stderr,"Please use the Format option -F:\n");
-						fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-						fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-						fprintf(stderr,"Aborting\n");
-					}
-				}
-				else {
-					fprintf(stderr,"\nError: invalid raw image parameters\n");
-					fprintf(stderr,"Please use the Format option -F:\n");
-					fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-						fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-					fprintf(stderr,"Aborting\n");
-					return 1;
-				}
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'q':			/* add fixed_quality */
-			{
-				char *s = optarg;
-				while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
-					parameters->tcp_numlayers++;
-					while (*s && *s != ',') {
-						s++;
-					}
-					if (!*s)
-						break;
-					s++;
-				}
-				parameters->cp_fixed_quality = 1;
-			}
-			break;
-
-				/* dda */
-				/* ----------------------------------------------------- */
-
-			case 'f':			/* mod fixed_quality (before : -q) */
-			{
-				int *row = NULL, *col = NULL;
-				int numlayers = 0, numresolution = 0, matrix_width = 0;
-
-				char *s = optarg;
-				sscanf(s, "%d", &numlayers);
-				s++;
-				if (numlayers > 9)
-					s++;
-
-				parameters->tcp_numlayers = numlayers;
-				numresolution = parameters->numresolution;
-				matrix_width = numresolution * 3;
-				parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
-				s = s + 2;
-
-				for (i = 0; i < numlayers; i++) {
-					row = &parameters->cp_matrice[i * matrix_width];
-					col = row;
-					parameters->tcp_rates[i] = 1;
-					sscanf(s, "%d,", &col[0]);
-					s += 2;
-					if (col[0] > 9)
-						s++;
-					col[1] = 0;
-					col[2] = 0;
-					for (j = 1; j < numresolution; j++) {
-						col += 3;
-						sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
-						s += 6;
-						if (col[0] > 9)
-							s++;
-						if (col[1] > 9)
-							s++;
-						if (col[2] > 9)
-							s++;
-					}
-					if (i < numlayers - 1)
-						s++;
-				}
-				parameters->cp_fixed_alloc = 1;
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 't':			/* tiles */
-			{
-				sscanf(optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy);
-				parameters->tile_size_on = true;
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'n':			/* resolution */
-			{
-				sscanf(optarg, "%d", &parameters->numresolution);
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-			case 'c':			/* precinct dimension */
-			{
-				char sep;
-				int res_spec = 0;
-
-				char *s = optarg;
-				do {
-					sep = 0;
-					sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
-                                 &parameters->prch_init[res_spec], &sep);
-					parameters->csty |= 0x01;
-					res_spec++;
-					s = strpbrk(s, "]") + 2;
-				}
-				while (sep == ',');
-				parameters->res_spec = res_spec;
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'b':			/* code-block dimension */
-			{
-				int cblockw_init = 0, cblockh_init = 0;
-				sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
-				if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
-					|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
-					fprintf(stderr,
-						"!! Size of code_block error (option -b) !!\n\nRestriction :\n"
-            "    * width*height<=4096\n    * 4<=width,height<= 1024\n\n");
-					return 1;
-				}
-				parameters->cblockw_init = cblockw_init;
-				parameters->cblockh_init = cblockh_init;
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'x':			/* creation of index file */
-			{
-				char *index = optarg;
-				strncpy(indexfilename, index, OPJ_PATH_LEN);
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'p':			/* progression order */
-			{
-				char progression[4];
-
-				strncpy(progression, optarg, 4);
-				parameters->prog_order = give_progression(progression);
-				if (parameters->prog_order == -1) {
-					fprintf(stderr, "Unrecognized progression order "
-            "[LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
-					return 1;
-				}
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 's':			/* subsampling factor */
-			{
-				if (sscanf(optarg, "%d,%d", &parameters->subsampling_dx,
-                                    &parameters->subsampling_dy) != 2) {
-					fprintf(stderr,	"'-s' sub-sampling argument error !  [-s dx,dy]\n");
-					return 1;
-				}
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'd':			/* coordonnate of the reference grid */
-			{
-				if (sscanf(optarg, "%d,%d", &parameters->image_offset_x0,
-                                    &parameters->image_offset_y0) != 2) {
-					fprintf(stderr,	"-d 'coordonnate of the reference grid' argument "
-            "error !! [-d x0,y0]\n");
-					return 1;
-				}
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'h':			/* display an help description */
-				encode_help_display();
-				return 1;
-
-				/* ----------------------------------------------------- */
-
-			case 'P':			/* POC */
-			{
-				int numpocs = 0;		/* number of progression order change (POC) default 0 */
-				opj_poc_t *POC = NULL;	/* POC : used in case of Progression order change */
-
-				char *s = optarg;
-				POC = parameters->POC;
-
-				while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
-					&POC[numpocs].resno0, &POC[numpocs].compno0,
-					&POC[numpocs].layno1, &POC[numpocs].resno1,
-					&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
-					POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
-					numpocs++;
-					while (*s && *s != '/') {
-						s++;
-					}
-					if (!*s) {
-						break;
-					}
-					s++;
-				}
-				parameters->numpocs = numpocs;
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'S':			/* SOP marker */
-			{
-				parameters->csty |= 0x02;
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'E':			/* EPH marker */
-			{
-				parameters->csty |= 0x04;
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'M':			/* Mode switch pas tous au point !! */
-			{
-				int value = 0;
-				if (sscanf(optarg, "%d", &value) == 1) {
-					for (i = 0; i <= 5; i++) {
-						int cache = value & (1 << i);
-						if (cache)
-							parameters->mode |= (1 << i);
-					}
-				}
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'R':			/* ROI */
-			{
-				if (sscanf(optarg, "c=%d,U=%d", &parameters->roi_compno,
-                                           &parameters->roi_shift) != 2) {
-					fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
-					return 1;
-				}
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'T':			/* Tile offset */
-			{
-				if (sscanf(optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) {
-					fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
-					return 1;
-				}
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'C':			/* add a comment */
-			{
-				parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
-				if(parameters->cp_comment) {
-					strcpy(parameters->cp_comment, optarg);
-				}
-			}
-			break;
-
-
-				/* ------------------------------------------------------ */
-
-			case 'I':			/* reversible or not */
-			{
-				parameters->irreversible = 1;
-			}
-			break;
-
-			/* ------------------------------------------------------ */
-
-			case 'v':			/* Tile part generation*/
-			{
-				parameters->tp_flag = optarg[0];
-				parameters->tp_on = 1;
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'z':			/* Image Directory path */
-			{
-				img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
-				strcpy(img_fol->imgdirpath,optarg);
-				img_fol->set_imgdir=1;
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'w':			/* Digital Cinema 2K profile compliance*/
-			{
-				int fps=0;
-				sscanf(optarg,"%d",&fps);
-				if(fps == 24){
-					parameters->cp_cinema = CINEMA2K_24;
-				}else if(fps == 48 ){
-					parameters->cp_cinema = CINEMA2K_48;
-				}else {
-					fprintf(stderr,"Incorrect value!! must be 24 or 48\n");
-					return 1;
-				}
-				fprintf(stdout,"CINEMA 2K compliant codestream\n");
-				parameters->cp_rsiz = CINEMA2K;
-
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-			case 'y':			/* Digital Cinema 4K profile compliance*/
-			{
-				parameters->cp_cinema = CINEMA4K_24;
-				fprintf(stdout,"CINEMA 4K compliant codestream\n");
-				parameters->cp_rsiz = CINEMA4K;
-			}
-			break;
-
-				/* ------------------------------------------------------ */
-
-/* UniPG>> */
-#ifdef USE_JPWL
-				/* ------------------------------------------------------ */
-
-			case 'W':			/* JPWL capabilities switched on */
-			{
-				char *token = NULL;
-				int hprot, pprot, sens, addr, size, range;
-
-				/* we need to enable indexing */
-				if (!indexfilename || !*indexfilename) {
-					strncpy(indexfilename, JPWL_PRIVATEINDEX_NAME, OPJ_PATH_LEN);
-				}
-
-				/* search for different protection methods */
-
-				/* break the option in comma points and parse the result */
-				token = strtok(optarg, ",");
-				while(token != NULL) {
-
-					/* search header error protection method */
-					if (*token == 'h') {
-
-						static int tile = 0, tilespec = 0, lasttileno = 0;
-
-						hprot = 1; /* predefined method */
-
-						if(sscanf(token, "h=%d", &hprot) == 1) {
-							/* Main header, specified */
-							if (!((hprot == 0) || (hprot == 1) || (hprot == 16) || (hprot == 32) ||
-								((hprot >= 37) && (hprot <= 128)))) {
-								fprintf(stderr, "ERROR -> invalid main header protection method h = %d\n", hprot);
-								return 1;
-							}
-							parameters->jpwl_hprot_MH = hprot;
-
-						} else if(sscanf(token, "h%d=%d", &tile, &hprot) == 2) {
-							/* Tile part header, specified */
-							if (!((hprot == 0) || (hprot == 1) || (hprot == 16) || (hprot == 32) ||
-								((hprot >= 37) && (hprot <= 128)))) {
-								fprintf(stderr, "ERROR -> invalid tile part header protection method h = %d\n", hprot);
-								return 1;
-							}
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
-								return 1;
-							}
-							if (tilespec < JPWL_MAX_NO_TILESPECS) {
-								parameters->jpwl_hprot_TPH_tileno[tilespec] = lasttileno = tile;
-								parameters->jpwl_hprot_TPH[tilespec++] = hprot;
-							}
-
-						} else if(sscanf(token, "h%d", &tile) == 1) {
-							/* Tile part header, unspecified */
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
-								return 1;
-							}
-							if (tilespec < JPWL_MAX_NO_TILESPECS) {
-								parameters->jpwl_hprot_TPH_tileno[tilespec] = lasttileno = tile;
-								parameters->jpwl_hprot_TPH[tilespec++] = hprot;
-							}
-
-
-						} else if (!strcmp(token, "h")) {
-							/* Main header, unspecified */
-							parameters->jpwl_hprot_MH = hprot;
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid protection method selection = %s\n", token);
-							return 1;
-						};
-
-					}
-
-					/* search packet error protection method */
-					if (*token == 'p') {
-
-						static int pack = 0, tile = 0, packspec = 0;
-
-						pprot = 1; /* predefined method */
-
-						if (sscanf(token, "p=%d", &pprot) == 1) {
-							/* Method for all tiles and all packets */
-							if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-								((pprot >= 37) && (pprot <= 128)))) {
-								fprintf(stderr, "ERROR -> invalid default packet protection method p = %d\n", pprot);
-								return 1;
-							}
-							parameters->jpwl_pprot_tileno[0] = 0;
-							parameters->jpwl_pprot_packno[0] = 0;
-							parameters->jpwl_pprot[0] = pprot;
-
-						} else if (sscanf(token, "p%d=%d", &tile, &pprot) == 2) {
-							/* method specified from that tile on */
-							if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-								((pprot >= 37) && (pprot <= 128)))) {
-								fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
-								return 1;
-							}
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-								return 1;
-							}
-							if (packspec < JPWL_MAX_NO_PACKSPECS) {
-								parameters->jpwl_pprot_tileno[packspec] = tile;
-								parameters->jpwl_pprot_packno[packspec] = 0;
-								parameters->jpwl_pprot[packspec++] = pprot;
-							}
-
-						} else if (sscanf(token, "p%d:%d=%d", &tile, &pack, &pprot) == 3) {
-							/* method fully specified from that tile and that packet on */
-							if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-								((pprot >= 37) && (pprot <= 128)))) {
-								fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
-								return 1;
-							}
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-								return 1;
-							}
-							if (pack < 0) {
-								fprintf(stderr, "ERROR -> invalid packet number on protection method p = %d\n", pack);
-								return 1;
-							}
-							if (packspec < JPWL_MAX_NO_PACKSPECS) {
-								parameters->jpwl_pprot_tileno[packspec] = tile;
-								parameters->jpwl_pprot_packno[packspec] = pack;
-								parameters->jpwl_pprot[packspec++] = pprot;
-							}
-
-						} else if (sscanf(token, "p%d:%d", &tile, &pack) == 2) {
-							/* default method from that tile and that packet on */
-							if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-								((pprot >= 37) && (pprot <= 128)))) {
-								fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
-								return 1;
-							}
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-								return 1;
-							}
-							if (pack < 0) {
-								fprintf(stderr, "ERROR -> invalid packet number on protection method p = %d\n", pack);
-								return 1;
-							}
-							if (packspec < JPWL_MAX_NO_PACKSPECS) {
-								parameters->jpwl_pprot_tileno[packspec] = tile;
-								parameters->jpwl_pprot_packno[packspec] = pack;
-								parameters->jpwl_pprot[packspec++] = pprot;
-							}
-
-						} else if (sscanf(token, "p%d", &tile) == 1) {
-							/* default from a tile on */
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-								return 1;
-							}
-							if (packspec < JPWL_MAX_NO_PACKSPECS) {
-								parameters->jpwl_pprot_tileno[packspec] = tile;
-								parameters->jpwl_pprot_packno[packspec] = 0;
-								parameters->jpwl_pprot[packspec++] = pprot;
-							}
-
-
-						} else if (!strcmp(token, "p")) {
-							/* all default */
-							parameters->jpwl_pprot_tileno[0] = 0;
-							parameters->jpwl_pprot_packno[0] = 0;
-							parameters->jpwl_pprot[0] = pprot;
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid protection method selection = %s\n", token);
-							return 1;
-						};
-
-					}
-
-					/* search sensitivity method */
-					if (*token == 's') {
-
-						static int tile = 0, tilespec = 0, lasttileno = 0;
-
-						sens = 0; /* predefined: relative error */
-
-						if(sscanf(token, "s=%d", &sens) == 1) {
-							/* Main header, specified */
-							if ((sens < -1) || (sens > 7)) {
-								fprintf(stderr, "ERROR -> invalid main header sensitivity method s = %d\n", sens);
-								return 1;
-							}
-							parameters->jpwl_sens_MH = sens;
-
-						} else if(sscanf(token, "s%d=%d", &tile, &sens) == 2) {
-							/* Tile part header, specified */
-							if ((sens < -1) || (sens > 7)) {
-								fprintf(stderr, "ERROR -> invalid tile part header sensitivity method s = %d\n", sens);
-								return 1;
-							}
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
-								return 1;
-							}
-							if (tilespec < JPWL_MAX_NO_TILESPECS) {
-								parameters->jpwl_sens_TPH_tileno[tilespec] = lasttileno = tile;
-								parameters->jpwl_sens_TPH[tilespec++] = sens;
-							}
-
-						} else if(sscanf(token, "s%d", &tile) == 1) {
-							/* Tile part header, unspecified */
-							if (tile < 0) {
-								fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
-								return 1;
-							}
-							if (tilespec < JPWL_MAX_NO_TILESPECS) {
-								parameters->jpwl_sens_TPH_tileno[tilespec] = lasttileno = tile;
-								parameters->jpwl_sens_TPH[tilespec++] = hprot;
-							}
-
-						} else if (!strcmp(token, "s")) {
-							/* Main header, unspecified */
-							parameters->jpwl_sens_MH = sens;
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid sensitivity method selection = %s\n", token);
-							return 1;
-						};
-
-						parameters->jpwl_sens_size = 2; /* 2 bytes for default size */
-					}
-
-					/* search addressing size */
-					if (*token == 'a') {
-
-
-						addr = 0; /* predefined: auto */
-
-						if(sscanf(token, "a=%d", &addr) == 1) {
-							/* Specified */
-							if ((addr != 0) && (addr != 2) && (addr != 4)) {
-								fprintf(stderr, "ERROR -> invalid addressing size a = %d\n", addr);
-								return 1;
-							}
-							parameters->jpwl_sens_addr = addr;
-
-						} else if (!strcmp(token, "a")) {
-							/* default */
-							parameters->jpwl_sens_addr = addr; /* auto for default size */
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid addressing selection = %s\n", token);
-							return 1;
-						};
-
-					}
-
-					/* search sensitivity size */
-					if (*token == 'z') {
-
-
-						size = 1; /* predefined: 1 byte */
-
-						if(sscanf(token, "z=%d", &size) == 1) {
-							/* Specified */
-							if ((size != 0) && (size != 1) && (size != 2)) {
-								fprintf(stderr, "ERROR -> invalid sensitivity size z = %d\n", size);
-								return 1;
-							}
-							parameters->jpwl_sens_size = size;
-
-						} else if (!strcmp(token, "a")) {
-							/* default */
-							parameters->jpwl_sens_size = size; /* 1 for default size */
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid size selection = %s\n", token);
-							return 1;
-						};
-
-					}
-
-					/* search range method */
-					if (*token == 'g') {
-
-
-						range = 0; /* predefined: 0 (packet) */
-
-						if(sscanf(token, "g=%d", &range) == 1) {
-							/* Specified */
-							if ((range < 0) || (range > 3)) {
-								fprintf(stderr, "ERROR -> invalid sensitivity range method g = %d\n", range);
-								return 1;
-							}
-							parameters->jpwl_sens_range = range;
-
-						} else if (!strcmp(token, "g")) {
-							/* default */
-							parameters->jpwl_sens_range = range;
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid range selection = %s\n", token);
-							return 1;
-						};
-
-					}
-
-					/* next token or bust */
-					token = strtok(NULL, ",");
-				};
-
-
-				/* some info */
-				fprintf(stdout, "Info: JPWL capabilities enabled\n");
-				parameters->jpwl_epc_on = true;
-
-			}
-			break;
-#endif /* USE_JPWL */
-/* <<UniPG */
-
-				/* ------------------------------------------------------ */
-
-			default:
-				fprintf(stderr, "ERROR -> Command line not valid\n");
-				return 1;
-		}
-	}
-
-	/* check for possible errors */
-	if (parameters->cp_cinema){
-		if(parameters->tcp_numlayers > 1){
-			parameters->cp_rsiz = STD_RSIZ;
-     	fprintf(stdout,"Warning: DC profiles do not allow more than one quality layer. The codestream created will not be compliant with the DC profile\n");
-		}
-	}
-	if(img_fol->set_imgdir == 1){
-		if(!(parameters->infile[0] == 0)){
-			fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
-			return 1;
-		}
-		if(img_fol->set_out_format == 0){
-			fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
-			fprintf(stderr, "Only one format allowed! Valid formats are j2k and jp2!!\n");
-			return 1;
-		}
-		if(!((parameters->outfile[0] == 0))){
-			fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
-			fprintf(stderr, "Specify OutputFormat using -OutFor<FORMAT> !!\n");
-			return 1;
-		}
-	}else{
-		if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
-			fprintf(stderr, "Example: %s -i image.ppm  -o image.j2k\n",argv[0]);
-			fprintf(stderr, "    Try: %s -h\n",argv[0]);
-			return 1;
-		}
-	}
-
-	if (parameters->decod_format == RAW_DFMT && raw_cp->rawWidth == 0) {
-			fprintf(stderr,"\nError: invalid raw image parameters\n");
-			fprintf(stderr,"Please use the Format option -F:\n");
-			fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-						fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-			fprintf(stderr,"Aborting\n");
-			return 1;
-	}
-
-	if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality)
-		&& (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_alloc ^ parameters->cp_fixed_quality))) {
-		fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
-		return 1;
-	}				/* mod fixed_quality */
-
-	/* if no rate entered, lossless by default */
-	if (parameters->tcp_numlayers == 0) {
-		parameters->tcp_rates[0] = 0;	/* MOD antonin : losslessbug */
-		parameters->tcp_numlayers++;
-		parameters->cp_disto_alloc = 1;
-	}
-
-	if((parameters->cp_tx0 > parameters->image_offset_x0) || (parameters->cp_ty0 > parameters->image_offset_y0)) {
-		fprintf(stderr,
-			"Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
-			parameters->cp_tx0, parameters->image_offset_x0, parameters->cp_ty0, parameters->image_offset_y0);
-		return 1;
-	}
-
-	for (i = 0; i < parameters->numpocs; i++) {
-		if (parameters->POC[i].prg == -1) {
-			fprintf(stderr,
-				"Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
-				i + 1);
-		}
-	}
-
-	return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char **argv) {
-	bool bSuccess;
-	opj_cparameters_t parameters;	/* compression parameters */
-	img_fol_t img_fol;
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_image_t *image = NULL;
-	int i,num_images;
-	int imageno;
-	dircnt_t *dirptr;
-	raw_cparameters_t raw_cp;
-	opj_codestream_info_t cstr_info;		/* Codestream information structure */
-	char indexfilename[OPJ_PATH_LEN];	/* index file name */
-
-	/*
-	configure the event callbacks (not required)
-	setting of each callback is optionnal
-	*/
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* set encoding parameters to default values */
-	opj_set_default_encoder_parameters(&parameters);
-
-	/* Initialize indexfilename and img_fol */
-	*indexfilename = 0;
-	memset(&img_fol,0,sizeof(img_fol_t));
-
-	/* parse input and get user encoding parameters */
-	if(parse_cmdline_encoder(argc, argv, &parameters,&img_fol, &raw_cp, indexfilename) == 1) {
-		return 1;
-	}
-
-	if (parameters.cp_cinema){
-		img_fol.rates = (float*)malloc(parameters.tcp_numlayers * sizeof(float));
-		for(i=0; i< parameters.tcp_numlayers; i++){
-			img_fol.rates[i] = parameters.tcp_rates[i];
-		}
-		cinema_parameters(&parameters);
-	}
-
-	/* Create comment for codestream */
-	if(parameters.cp_comment == NULL) {
-    const char comment[] = "Created by OpenJPEG version ";
-		const size_t clen = strlen(comment);
-    const char *version = opj_version();
-/* UniPG>> */
-#ifdef USE_JPWL
-		parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
-		sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
-#else
-		parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
-		sprintf(parameters.cp_comment,"%s%s", comment, version);
-#endif
-/* <<UniPG */
-	}
-
-	/* Read directory if necessary */
-	if(img_fol.set_imgdir==1){
-		num_images=get_num_images(img_fol.imgdirpath);
-		dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
-		if(dirptr){
-			dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char));	// Stores at max 10 image file names
-			dirptr->filename = (char**) malloc(num_images*sizeof(char*));
-			if(!dirptr->filename_buf){
-				return 0;
-			}
-			for(i=0;i<num_images;i++){
-				dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
-			}
-		}
-		if(load_images(dirptr,img_fol.imgdirpath)==1){
-			return 0;
-		}
-		if (num_images==0){
-			fprintf(stdout,"Folder is empty\n");
-			return 0;
-		}
-	}else{
-		num_images=1;
-	}
-	/*Encoding image one by one*/
-	for(imageno=0;imageno<num_images;imageno++)	{
-		image = NULL;
-		fprintf(stderr,"\n");
-
-		if(img_fol.set_imgdir==1){
-			if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
-				fprintf(stderr,"skipping file...\n");
-				continue;
-			}
-		}
-		switch(parameters.decod_format) {
-			case PGX_DFMT:
-				break;
-			case PXM_DFMT:
-				break;
-			case BMP_DFMT:
-				break;
-			case TIF_DFMT:
-				break;
-			case RAW_DFMT:
-				break;
-			case TGA_DFMT:
-				break;
-			case PNG_DFMT:
-				break;
-			default:
-				fprintf(stderr,"skipping file...\n");
-				continue;
-		}
-
-			/* decode the source image */
-			/* ----------------------- */
-
-			switch (parameters.decod_format) {
-				case PGX_DFMT:
-					image = pgxtoimage(parameters.infile, &parameters);
-					if (!image) {
-						fprintf(stderr, "Unable to load pgx file\n");
-						return 1;
-					}
-					break;
-
-				case PXM_DFMT:
-					image = pnmtoimage(parameters.infile, &parameters);
-					if (!image) {
-						fprintf(stderr, "Unable to load pnm file\n");
-						return 1;
-					}
-					break;
-
-				case BMP_DFMT:
-					image = bmptoimage(parameters.infile, &parameters);
-					if (!image) {
-						fprintf(stderr, "Unable to load bmp file\n");
-						return 1;
-					}
-					break;
-#ifdef HAVE_LIBTIFF
-				case TIF_DFMT:
-					image = tiftoimage(parameters.infile, &parameters);
-					if (!image) {
-						fprintf(stderr, "Unable to load tiff file\n");
-						return 1;
-					}
-				break;
-#endif /* HAVE_LIBTIFF */
-				case RAW_DFMT:
-					image = rawtoimage(parameters.infile, &parameters, &raw_cp);
-					if (!image) {
-						fprintf(stderr, "Unable to load raw file\n");
-						return 1;
-					}
-				break;
-
-				case TGA_DFMT:
-					image = tgatoimage(parameters.infile, &parameters);
-					if (!image) {
-						fprintf(stderr, "Unable to load tga file\n");
-						return 1;
-					}
-				break;
-#ifdef HAVE_LIBPNG
-				case PNG_DFMT:
-					image = pngtoimage(parameters.infile, &parameters);
-					if (!image) {
-						fprintf(stderr, "Unable to load png file\n");
-						return 1;
-					}
-					break;
-#endif /* HAVE_LIBPNG */
-		}
-/* Can happen if input file is TIFF or PNG 
- * and HAVE_LIBTIF or HAVE_LIBPNG is undefined
-*/
-			if( !image)
-		   {
-			fprintf(stderr, "Unable to load file: got no image\n");
-			return 1;
-		   }
-			/* Decide if MCT should be used */
-			parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
-
-			if(parameters.cp_cinema){
-				cinema_setup_encoder(&parameters,image,&img_fol);
-			}
-
-			/* encode the destination image */
-			/* ---------------------------- */
-
-			if (parameters.cod_format == J2K_CFMT) {	/* J2K format output */
-				int codestream_length;
-				opj_cio_t *cio = NULL;
-				FILE *f = NULL;
-
-				/* get a J2K compressor handle */
-				opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);
-
-				/* catch events using our callbacks and give a local context */
-				opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
-
-				/* setup the encoder parameters using the current image and user parameters */
-				opj_setup_encoder(cinfo, &parameters, image);
-
-				/* open a byte stream for writing */
-				/* allocate memory for all tiles */
-				cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
-
-				/* encode the image */
-				if (*indexfilename)					// If need to extract codestream information
-					bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
-				else
-					bSuccess = opj_encode(cinfo, cio, image, NULL);
-				if (!bSuccess) {
-					opj_cio_close(cio);
-					fprintf(stderr, "failed to encode image\n");
-					return 1;
-				}
-				codestream_length = cio_tell(cio);
-
-				/* write the buffer to disk */
-				f = fopen(parameters.outfile, "wb");
-				if (!f) {
-					fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
-					return 1;
-				}
-				fwrite(cio->buffer, 1, codestream_length, f);
-				fclose(f);
-
-				fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
-				/* close and free the byte stream */
-				opj_cio_close(cio);
-
-				/* Write the index to disk */
-				if (*indexfilename) {
-					bSuccess = write_index_file(&cstr_info, indexfilename);
-					if (bSuccess) {
-						fprintf(stderr, "Failed to output index file into [%s]\n", indexfilename);
-					}
-				}
-
-				/* free remaining compression structures */
-				opj_destroy_compress(cinfo);
-				if (*indexfilename)
-					opj_destroy_cstr_info(&cstr_info);
-			} else {			/* JP2 format output */
-				int codestream_length;
-				opj_cio_t *cio = NULL;
-				FILE *f = NULL;
-
-				/* get a JP2 compressor handle */
-				opj_cinfo_t* cinfo = opj_create_compress(CODEC_JP2);
-
-				/* catch events using our callbacks and give a local context */
-				opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
-
-				/* setup the encoder parameters using the current image and using user parameters */
-				opj_setup_encoder(cinfo, &parameters, image);
-
-				/* open a byte stream for writing */
-				/* allocate memory for all tiles */
-				cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
-
-				/* encode the image */
-				if (*indexfilename)					// If need to extract codestream information
-					bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
-				else
-					bSuccess = opj_encode(cinfo, cio, image, NULL);
-				if (!bSuccess) {
-					opj_cio_close(cio);
-					fprintf(stderr, "failed to encode image\n");
-					return 1;
-				}
-				codestream_length = cio_tell(cio);
-
-				/* write the buffer to disk */
-				f = fopen(parameters.outfile, "wb");
-				if (!f) {
-					fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
-					return 1;
-				}
-				fwrite(cio->buffer, 1, codestream_length, f);
-				fclose(f);
-				fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
-				/* close and free the byte stream */
-				opj_cio_close(cio);
-
-				/* Write the index to disk */
-				if (*indexfilename) {
-					bSuccess = write_index_file(&cstr_info, indexfilename);
-					if (bSuccess) {
-						fprintf(stderr, "Failed to output index file\n");
-					}
-				}
-
-				/* free remaining compression structures */
-				opj_destroy_compress(cinfo);
-				if (*indexfilename)
-					opj_destroy_cstr_info(&cstr_info);
-			}
-
-			/* free image data */
-			opj_image_destroy(image);
-	}
-
-	/* free user parameters structure */
-  if(parameters.cp_comment) free(parameters.cp_comment);
-	if(parameters.cp_matrice) free(parameters.cp_matrice);
-
-	return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsp b/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsp
deleted file mode 100644
index 3e1b0f6..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsp
+++ /dev/null
@@ -1,118 +0,0 @@
-# Microsoft Developer Studio Project File - Name="image_to_j2k" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=image_to_j2k - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "image_to_j2k.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "image_to_j2k.mak" CFG="image_to_j2k - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "image_to_j2k - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "image_to_j2k - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "image_to_j2k - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x40c /d "NDEBUG"
-# ADD RSC /l 0x40c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBC"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "image_to_j2k - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x40c /d "_DEBUG"
-# ADD RSC /l 0x40c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBC" /nodefaultlib:"LIBCMT" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF 
-
-# Begin Target
-
-# Name "image_to_j2k - Win32 Release"
-# Name "image_to_j2k - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\convert.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\convert.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\compat\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\compat\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\image_to_j2k.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\index.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\index.h
-# End Source File
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsw b/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsw
deleted file mode 100644
index fd19c26..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "LibOpenJPEG"=..\LibOpenJPEG.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "image_to_j2k"=.\image_to_j2k.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.sln b/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.sln
deleted file mode 100644
index de773c8..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.sln and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.vcproj b/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.vcproj
deleted file mode 100644
index 8968eb4..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/image_to_j2k.vcproj
+++ /dev/null
@@ -1,292 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="image_to_j2k"
-	ProjectGUID="{81FBE6CF-1DFB-413F-8215-0851F8E2D252}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/image_to_j2k.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="2"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/image_to_j2k.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1036"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
-				OutputFile=".\Release/image_to_j2k.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="LIBC"
-				ProgramDatabaseFile=".\Release/image_to_j2k.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/image_to_j2k.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Debug/image_to_j2k.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\Debug/image_to_j2k.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1036"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
-				OutputFile=".\Debug/image_to_j2k.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="LIBC,LIBCMT"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\Debug/image_to_j2k.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Debug/image_to_j2k.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<File
-			RelativePath="convert.c"
-			>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="convert.h"
-			>
-		</File>
-		<File
-			RelativePath="compat\getopt.c"
-			>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="compat\getopt.h"
-			>
-		</File>
-		<File
-			RelativePath="image_to_j2k.c"
-			>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath=".\index.c"
-			>
-		</File>
-		<File
-			RelativePath=".\index.h"
-			>
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/codec/index.c b/Utilities/gdcmopenjpeg-v1/codec/index.c
deleted file mode 100644
index 873b340..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/index.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include "openjpeg.h"
-#include "index.h"
-
-/* ------------------------------------------------------------------------------------ */
-
-/**
-Write a structured index to a file
- at param cstr_info Codestream information 
- at param index Index filename
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
-	int tileno, compno, layno, resno, precno, pack_nb, x, y;
-	FILE *stream = NULL;
-	double total_disto = 0;
-/* UniPG>> */
-	int tilepartno;
-	char disto_on, numpix_on;
-
-#ifdef USE_JPWL
-	if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
-		return 0;
-#endif /* USE_JPWL */
-/* <<UniPG */
-
-	if (!cstr_info)		
-		return 1;
-
-	stream = fopen(index, "w");
-	if (!stream) {
-		fprintf(stderr, "failed to open index file [%s] for writing\n", index);
-		return 1;
-	}
-	
-	if (cstr_info->tile[0].distotile)
-		disto_on = 1;
-	else 
-		disto_on = 0;
-
-	if (cstr_info->tile[0].numpix)
-		numpix_on = 1;
-	else 
-		numpix_on = 0;
-
-	fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
-	fprintf(stream, "%d\n", cstr_info->prog);
-	fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
-	fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
-	fprintf(stream, "%d\n", cstr_info->numcomps);
-	fprintf(stream, "%d\n", cstr_info->numlayers);
-	fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
-
-	for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
-		fprintf(stream, "[%d,%d] ", 
-			(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno]));	/* based on tile 0 and component 0 */
-	}
-
-	fprintf(stream, "\n");
-/* UniPG>> */
-	fprintf(stream, "%d\n", cstr_info->main_head_start);
-/* <<UniPG */
-	fprintf(stream, "%d\n", cstr_info->main_head_end);
-	fprintf(stream, "%d\n", cstr_info->codestream_size);
-	
-	fprintf(stream, "\nINFO ON TILES\n");
-	fprintf(stream, "tileno start_pos  end_hd  end_tile   nbparts");
-	if (disto_on)
-		fprintf(stream,"         disto");
-	if (numpix_on)
-		fprintf(stream,"     nbpix");
-	if (disto_on && numpix_on)
-		fprintf(stream,"  disto/nbpix");
-	fprintf(stream, "\n");
-
-	for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
-		fprintf(stream, "%4d %9d %9d %9d %9d", 
-			cstr_info->tile[tileno].tileno,
-			cstr_info->tile[tileno].start_pos,
-			cstr_info->tile[tileno].end_header,
-			cstr_info->tile[tileno].end_pos,
-			cstr_info->tile[tileno].num_tps);
-		if (disto_on)
-			fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
-		if (numpix_on)
-			fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
-		if (disto_on && numpix_on)
-			fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
-		fprintf(stream, "\n");
-	}
-		
-	for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
-		int start_pos, end_ph_pos, end_pos;
-		double disto = 0;
-		int max_numdecompos = 0;
-		pack_nb = 0;
-
-		for (compno = 0; compno < cstr_info->numcomps; compno++) {
-			if (max_numdecompos < cstr_info->numdecompos[compno])
-				max_numdecompos = cstr_info->numdecompos[compno];
-		}	
-
-		fprintf(stream, "\nTILE %d DETAILS\n", tileno);	
-		fprintf(stream, "part_nb tileno  start_pack num_packs  start_pos end_tph_pos   end_pos\n");
-		for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
-			fprintf(stream, "%4d %9d   %9d %9d  %9d %11d %9d\n",
-				tilepartno, tileno,
-				cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
-				cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
-				cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
-				cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
-				cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
-				);
-
-		if (cstr_info->prog == LRCP) {	/* LRCP */
-			fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
-			if (disto_on)
-				fprintf(stream, " disto");
-			fprintf(stream,"\n");
-
-			for (layno = 0; layno < cstr_info->numlayers; layno++) {
-				for (resno = 0; resno < max_numdecompos + 1; resno++) {
-					for (compno = 0; compno < cstr_info->numcomps; compno++) {
-						int prec_max;
-						if (resno > cstr_info->numdecompos[compno])
-							break;
-						prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-						for (precno = 0; precno < prec_max; precno++) {
-							start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-							end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-							end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-							disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-							fprintf(stream, "%4d %6d %7d %5d %6d  %6d    %6d     %6d %7d",
-								pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
-							if (disto_on)
-								fprintf(stream, " %8e", disto);
-							fprintf(stream, "\n");
-							total_disto += disto;
-							pack_nb++;
-						}
-					}
-				}
-			}
-		} /* LRCP */
-
-		else if (cstr_info->prog == RLCP) {	/* RLCP */			
-			fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
-			if (disto_on)
-				fprintf(stream, " disto");
-			fprintf(stream,"\n");
-
-			for (resno = 0; resno < max_numdecompos + 1; resno++) {
-				for (layno = 0; layno < cstr_info->numlayers; layno++) {
-					for (compno = 0; compno < cstr_info->numcomps; compno++) {
-						int prec_max; 
-						if (resno > cstr_info->numdecompos[compno])
-							break;
-						prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-						for (precno = 0; precno < prec_max; precno++) {
-							start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-							end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-							end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-							disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-							fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d   %9d %7d",
-								pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
-							if (disto_on)
-								fprintf(stream, " %8e", disto);
-							fprintf(stream, "\n");
-							total_disto += disto;
-							pack_nb++;
-						}
-					}
-				}
-			}
-		} /* RLCP */
-
-		else if (cstr_info->prog == RPCL) {	/* RPCL */
-
-			fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos"); 
-			if (disto_on)
-				fprintf(stream, " disto");
-			fprintf(stream,"\n");
-
-			for (resno = 0; resno < max_numdecompos + 1; resno++) {
-				int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-				for (precno = 0; precno < numprec; precno++) {								
-					/* I suppose components have same XRsiz, YRsiz */
-					int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
-					int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
-					int x1 = x0 + cstr_info->tile_x;
-					int y1 = y0 + cstr_info->tile_y;
-					for (compno = 0; compno < cstr_info->numcomps; compno++) {					
-						int pcnx = cstr_info->tile[tileno].pw[resno];
-						int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
-						int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
-						int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-						int precno_y = (int) floor( (float)precno/(float)pcnx );
-						if (resno > cstr_info->numdecompos[compno])
-							break;
-						for(y = y0; y < y1; y++) {							
-							if (precno_y*pcy == y ) {
-								for (x = x0; x < x1; x++) {									
-									if (precno_x*pcx == x ) {
-										for (layno = 0; layno < cstr_info->numlayers; layno++) {
-											start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-											end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-											end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-											disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-											fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d   %9d %7d",
-												pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos); 
-											if (disto_on)
-												fprintf(stream, " %8e", disto);
-											fprintf(stream, "\n");
-											total_disto += disto;
-											pack_nb++; 
-										}
-									}
-								}/* x = x0..x1 */
-							} 
-						}  /* y = y0..y1 */
-					} /* precno */
-				} /* compno */
-			} /* resno */
-		} /* RPCL */
-
-		else if (cstr_info->prog == PCRL) {	/* PCRL */
-			/* I suppose components have same XRsiz, YRsiz */
-			int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
-			int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
-			int x1 = x0 + cstr_info->tile_x;
-			int y1 = y0 + cstr_info->tile_y;
-
-			// Count the maximum number of precincts 
-			int max_numprec = 0;
-			for (resno = 0; resno < max_numdecompos + 1; resno++) {
-				int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-				if (numprec > max_numprec)
-					max_numprec = numprec;
-			}
-
-			fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos"); 
-			if (disto_on)
-				fprintf(stream, " disto");
-			fprintf(stream,"\n");
-
-			for (precno = 0; precno < max_numprec; precno++) {
-				for (compno = 0; compno < cstr_info->numcomps; compno++) {
-					for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
-						int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-						int pcnx = cstr_info->tile[tileno].pw[resno];
-						int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
-						int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
-						int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-						int precno_y = (int) floor( (float)precno/(float)pcnx );
-						if (precno >= numprec)
-							continue;
-						for(y = y0; y < y1; y++) {							
-							if (precno_y*pcy == y ) {
-								for (x = x0; x < x1; x++) {									
-									if (precno_x*pcx == x ) {
-										for (layno = 0; layno < cstr_info->numlayers; layno++) {
-											start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-											end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-											end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-											disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-											fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d   %9d %7d",
-												pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos); 
-											if (disto_on)
-												fprintf(stream, " %8e", disto);
-											fprintf(stream, "\n");
-											total_disto += disto;
-											pack_nb++; 
-										}
-									}
-								}/* x = x0..x1 */
-							} 
-						}  /* y = y0..y1 */
-					} /* resno */
-				} /* compno */
-			} /* precno */
-		} /* PCRL */
-
-		else {	/* CPRL */
-			// Count the maximum number of precincts 
-			int max_numprec = 0;
-			for (resno = 0; resno < max_numdecompos + 1; resno++) {
-				int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-				if (numprec > max_numprec)
-					max_numprec = numprec;
-			}
-
-			fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos"); 
-			if (disto_on)
-				fprintf(stream, " disto");
-			fprintf(stream,"\n");
-
-			for (compno = 0; compno < cstr_info->numcomps; compno++) {
-				/* I suppose components have same XRsiz, YRsiz */
-				int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
-				int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
-				int x1 = x0 + cstr_info->tile_x;
-				int y1 = y0 + cstr_info->tile_y;
-
-				for (precno = 0; precno < max_numprec; precno++) {
-					for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
-						int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-						int pcnx = cstr_info->tile[tileno].pw[resno];
-						int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
-						int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
-						int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-						int precno_y = (int) floor( (float)precno/(float)pcnx );
-						if (precno >= numprec)
-							continue;
-
-						for(y = y0; y < y1; y++) {
-							if (precno_y*pcy == y ) {
-								for (x = x0; x < x1; x++) {
-									if (precno_x*pcx == x ) {
-										for (layno = 0; layno < cstr_info->numlayers; layno++) {
-											start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-											end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-											end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-											disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-											fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d   %9d %7d",
-												pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos); 
-											if (disto_on)
-												fprintf(stream, " %8e", disto);
-											fprintf(stream, "\n");
-											total_disto += disto;
-											pack_nb++; 
-										}
-									}
-								}/* x = x0..x1 */
-							}
-						} /* y = y0..y1 */
-					} /* resno */
-				} /* precno */
-			} /* compno */
-		} /* CPRL */   
-	} /* tileno */
-	
-	if (disto_on) {
-		fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */	
-		fprintf(stream, "%.8e\n", total_disto);	/* SE totale */
-	}
-/* UniPG>> */
-	/* print the markers' list */
-	if (cstr_info->marknum) {
-		fprintf(stream, "\nMARKER LIST\n");
-		fprintf(stream, "%d\n", cstr_info->marknum);
-		fprintf(stream, "type\tstart_pos    length\n");
-		for (x = 0; x < cstr_info->marknum; x++)
-			fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
-	}
-/* <<UniPG */
-	fclose(stream);
-
-	fprintf(stderr,"Generated index file %s\n", index);
-
-	return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/codec/j2k_dump.c b/Utilities/gdcmopenjpeg-v1/codec/j2k_dump.c
deleted file mode 100644
index 508dd65..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/j2k_dump.c
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- * Copyright (c) 20010, Mathieu Malaterre, GDCM
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-#ifdef _WIN32
-#include "windirent.h"
-#else
-#include <dirent.h>
-#endif /* _WIN32 */
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <strings.h>
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#endif /* _WIN32 */
-
-#include "opj_config.h"
-#include "openjpeg.h"
-#include "../libopenjpeg/j2k.h"
-#include "../libopenjpeg/jp2.h"
-#include "getopt.h"
-#include "convert.h"
-#include "index.h"
-
-#include "format_defs.h"
-
-typedef struct dircnt{
-	/** Buffer for holding images read from Directory*/
-	char *filename_buf;
-	/** Pointer to the buffer*/
-	char **filename;
-}dircnt_t;
-
-
-typedef struct img_folder{
-	/** The directory path of the folder containing input images*/
-	char *imgdirpath;
-	/** Output format*/
-	const char *out_format;
-	/** Enable option*/
-	char set_imgdir;
-	/** Enable Cod Format for output*/
-	char set_out_format;
-
-}img_fol_t;
-
-void decode_help_display() {
-	fprintf(stdout,"HELP for j2k_dump\n----\n\n");
-	fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-/* UniPG>> */
-	fprintf(stdout,"List of parameters for the JPEG 2000 "
-#ifdef USE_JPWL
-		"+ JPWL "
-#endif /* USE_JPWL */
-		"decoder:\n");
-/* <<UniPG */
-	fprintf(stdout,"\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"  -ImgDir \n");
-	fprintf(stdout,"	Image file Directory path \n");
-	fprintf(stdout,"  -i <compressed file>\n");
-	fprintf(stdout,"    REQUIRED only if an Input image directory not specified\n");
-	fprintf(stdout,"    Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
-	fprintf(stdout,"    is identified based on its suffix.\n");
-	fprintf(stdout,"\n");
-}
-
-/* -------------------------------------------------------------------------- */
-static void j2k_dump_image(FILE *fd, opj_image_t * img);
-static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
-
-int get_num_images(char *imgdirpath){
-	DIR *dir;
-	struct dirent* content;	
-	int num_images = 0;
-
-	/*Reading the input images from given input directory*/
-
-	dir= opendir(imgdirpath);
-	if(!dir){
-		fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-		return 0;
-	}
-	
-	while((content=readdir(dir))!=NULL){
-		if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-			continue;
-		num_images++;
-	}
-	return num_images;
-}
-
-int load_images(dircnt_t *dirptr, char *imgdirpath){
-	DIR *dir;
-	struct dirent* content;	
-	int i = 0;
-
-	/*Reading the input images from given input directory*/
-
-	dir= opendir(imgdirpath);
-	if(!dir){
-		fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-		return 1;
-	}else	{
-		fprintf(stderr,"Folder opened successfully\n");
-	}
-	
-	while((content=readdir(dir))!=NULL){
-		if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-			continue;
-
-		strcpy(dirptr->filename[i],content->d_name);
-		i++;
-	}
-	return 0;	
-}
-
-int get_file_format(char *filename) {
-	unsigned int i;
-	static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc"  };
-	static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
-	char * ext = strrchr(filename, '.');
-	if (ext == NULL)
-		return -1;
-	ext++;
-	if(ext) {
-		for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
-			if(_strnicmp(ext, extension[i], 3) == 0) {
-				return format[i];
-			}
-		}
-	}
-
-	return -1;
-}
-
-char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
-	char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
-	char *temp_p, temp1[OPJ_PATH_LEN]="";
-
-	strcpy(image_filename,dirptr->filename[imageno]);
-	fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
-	parameters->decod_format = get_file_format(image_filename);
-	if (parameters->decod_format == -1)
-		return 1;
-	sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
-	strncpy(parameters->infile, infilename, sizeof(infilename));
-
-	//Set output file
-	strcpy(temp_ofname,strtok(image_filename,"."));
-	while((temp_p = strtok(NULL,".")) != NULL){
-		strcat(temp_ofname,temp1);
-		sprintf(temp1,".%s",temp_p);
-	}
-	if(img_fol->set_out_format==1){
-		sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
-		strncpy(parameters->outfile, outfilename, sizeof(outfilename));
-	}
-	return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
-	/* parse the command line */
-	int totlen;
-	option_t long_option[]={
-		{"ImgDir",REQ_ARG, NULL ,'y'},
-	};
-
-	const char optlist[] = "i:h";
-	totlen=sizeof(long_option);
-	img_fol->set_out_format = 0;
-	while (1) {
-		int c = getopt_long(argc, argv,optlist,long_option,totlen);
-		if (c == -1)
-			break;
-		switch (c) {
-			case 'i':			/* input file */
-			{
-				char *infile = optarg;
-				parameters->decod_format = get_file_format(infile);
-				switch(parameters->decod_format) {
-					case J2K_CFMT:
-					case JP2_CFMT:
-					case JPT_CFMT:
-						break;
-					default:
-						fprintf(stderr, 
-							"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n", 
-							infile);
-						return 1;
-				}
-				strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-
-			case 'h': 			/* display an help description */
-				decode_help_display();
-				return 1;				
-
-				/* ------------------------------------------------------ */
-
-			case 'y':			/* Image Directory path */
-				{
-					img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
-					strcpy(img_fol->imgdirpath,optarg);
-					img_fol->set_imgdir=1;
-				}
-				break;
-
-				/* ----------------------------------------------------- */
-			
-			default:
-				fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
-				break;
-		}
-	}
-
-	/* check for possible errors */
-	if(img_fol->set_imgdir==1){
-		if(!(parameters->infile[0]==0)){
-			fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
-			return 1;
-		}
-		if(img_fol->set_out_format == 0){
-			fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
-			fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
-			return 1;
-		}
-		if(!((parameters->outfile[0] == 0))){
-			fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
-			return 1;
-		}
-	}else{
-		if((parameters->infile[0] == 0) ) {
-			fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
-			fprintf(stderr, "    Try: %s -h\n",argv[0]);
-			return 1;
-		}
-	}
-
-	return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	(void)client_data;
-	fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char *argv[])
-{
-	opj_dparameters_t parameters;	/* decompression parameters */
-	img_fol_t img_fol;
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_image_t *image = NULL;
-	FILE *fsrc = NULL;
-	unsigned char *src = NULL;
-	int file_length;
-	int num_images;
-	int i,imageno;
-	dircnt_t *dirptr = NULL;
-	opj_dinfo_t* dinfo = NULL;	/* handle to a decompressor */
-	opj_cio_t *cio = NULL;
-	opj_codestream_info_t cstr_info;  /* Codestream information structure */
-	char indexfilename[OPJ_PATH_LEN];	/* index file name */
-
-	/* configure the event callbacks (not required) */
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* set decoding parameters to default values */
-	opj_set_default_decoder_parameters(&parameters);
-
-	/* Initialize indexfilename and img_fol */
-	*indexfilename = 0;
-	memset(&img_fol,0,sizeof(img_fol_t));
-
-	/* parse input and get user encoding parameters */
-	if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol, indexfilename) == 1) {
-		return 1;
-	}
-
-	/* Initialize reading of directory */
-	if(img_fol.set_imgdir==1){	
-		num_images=get_num_images(img_fol.imgdirpath);
-
-		dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
-		if(dirptr){
-			dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char));	// Stores at max 10 image file names
-			dirptr->filename = (char**) malloc(num_images*sizeof(char*));
-
-			if(!dirptr->filename_buf){
-				return 1;
-			}
-			for(i=0;i<num_images;i++){
-				dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
-			}
-		}
-		if(load_images(dirptr,img_fol.imgdirpath)==1){
-			return 1;
-		}
-		if (num_images==0){
-			fprintf(stdout,"Folder is empty\n");
-			return 1;
-		}
-	}else{
-		num_images=1;
-	}
-
-	/*Encoding image one by one*/
-	for(imageno = 0; imageno < num_images ; imageno++)
-  {
-		image = NULL;
-		fprintf(stderr,"\n");
-
-		if(img_fol.set_imgdir==1){
-			if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
-				fprintf(stderr,"skipping file...\n");
-				continue;
-			}
-		}
-
-		/* read the input file and put it in memory */
-		/* ---------------------------------------- */
-		fsrc = fopen(parameters.infile, "rb");
-		if (!fsrc) {
-			fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
-			return 1;
-		}
-		fseek(fsrc, 0, SEEK_END);
-		file_length = ftell(fsrc);
-		fseek(fsrc, 0, SEEK_SET);
-		src = (unsigned char *) malloc(file_length);
-		fread(src, 1, file_length, fsrc);
-		fclose(fsrc);
-
-		/* decode the code-stream */
-		/* ---------------------- */
-
-		switch(parameters.decod_format) {
-		case J2K_CFMT:
-		{
-			/* JPEG-2000 codestream */
-
-			/* get a decoder handle */
-			dinfo = opj_create_decompress(CODEC_J2K);
-
-			/* catch events using our callbacks and give a local context */
-			opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-			/* setup the decoder decoding parameters using user parameters */
-			opj_setup_decoder(dinfo, &parameters);
-
-			/* open a byte stream */
-			cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-			/* decode the stream and fill the image structure */
-			if (*indexfilename)				// If need to extract codestream information
-				image = opj_decode_with_info(dinfo, cio, &cstr_info);
-			else
-				image = opj_decode(dinfo, cio);
-			if(!image) {
-				fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-				opj_destroy_decompress(dinfo);
-				opj_cio_close(cio);
-				return 1;
-			}
-			/* dump image */
-      j2k_dump_image(stdout, image);
-
-			/* dump cp */
-      j2k_dump_cp(stdout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
-
-			/* close the byte stream */
-			opj_cio_close(cio);
-
-			/* Write the index to disk */
-			if (*indexfilename) {
-				char bSuccess;
-				bSuccess = write_index_file(&cstr_info, indexfilename);
-				if (bSuccess) {
-					fprintf(stderr, "Failed to output index file\n");
-				}
-			}
-		}
-		break;
-
-		case JP2_CFMT:
-		{
-			/* JPEG 2000 compressed image data */
-
-			/* get a decoder handle */
-			dinfo = opj_create_decompress(CODEC_JP2);
-
-			/* catch events using our callbacks and give a local context */
-			opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-			/* setup the decoder decoding parameters using the current image and user parameters */
-			opj_setup_decoder(dinfo, &parameters);
-
-			/* open a byte stream */
-			cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-			/* decode the stream and fill the image structure */
-			if (*indexfilename)				// If need to extract codestream information
-				image = opj_decode_with_info(dinfo, cio, &cstr_info);
-			else
-				image = opj_decode(dinfo, cio);			
-			if(!image) {
-				fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-				opj_destroy_decompress(dinfo);
-				opj_cio_close(cio);
-				return 1;
-			}
-			/* dump image */
-	  if(image->icc_profile_buf)
-	 {
-	  free(image->icc_profile_buf); image->icc_profile_buf = NULL;
-	 }	
-      j2k_dump_image(stdout, image);
-
-			/* dump cp */
-      j2k_dump_cp(stdout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp);
-
-			/* close the byte stream */
-			opj_cio_close(cio);
-
-			/* Write the index to disk */
-			if (*indexfilename) {
-				char bSuccess;
-				bSuccess = write_index_file(&cstr_info, indexfilename);
-				if (bSuccess) {
-					fprintf(stderr, "Failed to output index file\n");
-				}
-			}
-		}
-		break;
-
-		case JPT_CFMT:
-		{
-			/* JPEG 2000, JPIP */
-
-			/* get a decoder handle */
-			dinfo = opj_create_decompress(CODEC_JPT);
-
-			/* catch events using our callbacks and give a local context */
-			opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-			/* setup the decoder decoding parameters using user parameters */
-			opj_setup_decoder(dinfo, &parameters);
-
-			/* open a byte stream */
-			cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-			/* decode the stream and fill the image structure */
-			if (*indexfilename)				// If need to extract codestream information
-				image = opj_decode_with_info(dinfo, cio, &cstr_info);
-			else
-				image = opj_decode(dinfo, cio);
-			if(!image) {
-				fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-				opj_destroy_decompress(dinfo);
-				opj_cio_close(cio);
-				return 1;
-			}
-
-			/* close the byte stream */
-			opj_cio_close(cio);
-
-			/* Write the index to disk */
-			if (*indexfilename) {
-				char bSuccess;
-				bSuccess = write_index_file(&cstr_info, indexfilename);
-				if (bSuccess) {
-					fprintf(stderr, "Failed to output index file\n");
-				}
-			}
-		}
-		break;
-
-		default:
-			fprintf(stderr, "skipping file..\n");
-			continue;
-	}
-
-		/* free the memory containing the code-stream */
-		free(src);
-		src = NULL;
-
-		/* free remaining structures */
-		if(dinfo) {
-			opj_destroy_decompress(dinfo);
-		}
-		/* free codestream information structure */
-		if (*indexfilename)	
-			opj_destroy_cstr_info(&cstr_info);
-		/* free image data structure */
-		opj_image_destroy(image);
-
-	}
-
-  return EXIT_SUCCESS;
-}
-
-
-static void j2k_dump_image(FILE *fd, opj_image_t * img) {
-	int compno;
-	fprintf(fd, "image {\n");
-	fprintf(fd, "  x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
-	fprintf(fd, "  numcomps=%d\n", img->numcomps);
-	for (compno = 0; compno < img->numcomps; compno++) {
-		opj_image_comp_t *comp = &img->comps[compno];
-		fprintf(fd, "  comp %d {\n", compno);
-		fprintf(fd, "    dx=%d, dy=%d\n", comp->dx, comp->dy);
-		fprintf(fd, "    prec=%d\n", comp->prec);
-		//fprintf(fd, "    bpp=%d\n", comp->bpp);
-		fprintf(fd, "    sgnd=%d\n", comp->sgnd);
-		fprintf(fd, "  }\n");
-	}
-	fprintf(fd, "}\n");
-}
-
-static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
-	int tileno, compno, layno, bandno, resno, numbands;
-	fprintf(fd, "coding parameters {\n");
-	fprintf(fd, "  tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
-	fprintf(fd, "  tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
-	fprintf(fd, "  tw=%d, th=%d\n", cp->tw, cp->th);
-	for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-		opj_tcp_t *tcp = &cp->tcps[tileno];
-		fprintf(fd, "  tile %d {\n", tileno);
-		fprintf(fd, "    csty=%x\n", tcp->csty);
-		fprintf(fd, "    prg=%d\n", tcp->prg);
-		fprintf(fd, "    numlayers=%d\n", tcp->numlayers);
-		fprintf(fd, "    mct=%d\n", tcp->mct);
-		fprintf(fd, "    rates=");
-		for (layno = 0; layno < tcp->numlayers; layno++) {
-			fprintf(fd, "%.1f ", tcp->rates[layno]);
-		}
-		fprintf(fd, "\n");
-		for (compno = 0; compno < img->numcomps; compno++) {
-			opj_tccp_t *tccp = &tcp->tccps[compno];
-			fprintf(fd, "    comp %d {\n", compno);
-			fprintf(fd, "      csty=%x\n", tccp->csty);
-			fprintf(fd, "      numresolutions=%d\n", tccp->numresolutions);
-			fprintf(fd, "      cblkw=%d\n", tccp->cblkw);
-			fprintf(fd, "      cblkh=%d\n", tccp->cblkh);
-			fprintf(fd, "      cblksty=%x\n", tccp->cblksty);
-			fprintf(fd, "      qmfbid=%d\n", tccp->qmfbid);
-			fprintf(fd, "      qntsty=%d\n", tccp->qntsty);
-			fprintf(fd, "      numgbits=%d\n", tccp->numgbits);
-			fprintf(fd, "      roishift=%d\n", tccp->roishift);
-			fprintf(fd, "      stepsizes=");
-			numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
-			for (bandno = 0; bandno < numbands; bandno++) {
-				fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
-					tccp->stepsizes[bandno].expn);
-			}
-			fprintf(fd, "\n");
-			
-			if (tccp->csty & J2K_CCP_CSTY_PRT) {
-				fprintf(fd, "      prcw=");
-				for (resno = 0; resno < tccp->numresolutions; resno++) {
-					fprintf(fd, "%d ", tccp->prcw[resno]);
-				}
-				fprintf(fd, "\n");
-				fprintf(fd, "      prch=");
-				for (resno = 0; resno < tccp->numresolutions; resno++) {
-					fprintf(fd, "%d ", tccp->prch[resno]);
-				}
-				fprintf(fd, "\n");
-			}
-			fprintf(fd, "    }\n");
-		}
-		fprintf(fd, "  }\n");
-	}
-	fprintf(fd, "}\n");
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.c b/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.c
deleted file mode 100644
index ff6141e..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.c
+++ /dev/null
@@ -1,845 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-#ifdef _WIN32
-#include "windirent.h"
-#else
-#include <dirent.h>
-#endif /* _WIN32 */
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <strings.h>
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#endif /* _WIN32 */
-
-#include "opj_config.h"
-#include "openjpeg.h"
-#include "getopt.h"
-#include "convert.h"
-#include "index.h"
-
-#ifdef HAVE_LIBLCMS2
-#include <lcms2.h>
-#endif
-#ifdef HAVE_LIBLCMS1
-#include <lcms.h>
-#endif
-#include "color.h"
-
-#include "format_defs.h"
-
-typedef struct dircnt{
-	/** Buffer for holding images read from Directory*/
-	char *filename_buf;
-	/** Pointer to the buffer*/
-	char **filename;
-}dircnt_t;
-
-
-typedef struct img_folder{
-	/** The directory path of the folder containing input images*/
-	char *imgdirpath;
-	/** Output format*/
-	const char *out_format;
-	/** Enable option*/
-	char set_imgdir;
-	/** Enable Cod Format for output*/
-	char set_out_format;
-
-}img_fol_t;
-
-void decode_help_display() {
-	fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
-	fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-/* UniPG>> */
-	fprintf(stdout,"List of parameters for the JPEG 2000 "
-#ifdef USE_JPWL
-		"+ JPWL "
-#endif /* USE_JPWL */
-		"decoder:\n");
-/* <<UniPG */
-	fprintf(stdout,"\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"  -ImgDir \n");
-	fprintf(stdout,"	Image file Directory path \n");
-	fprintf(stdout,"  -OutFor \n");
-	fprintf(stdout,"    REQUIRED only if -ImgDir is used\n");
-	fprintf(stdout,"	  Need to specify only format without filename <BMP>  \n");
-	fprintf(stdout,"    Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA formats\n");
-	fprintf(stdout,"  -i <compressed file>\n");
-	fprintf(stdout,"    REQUIRED only if an Input image directory not specified\n");
-	fprintf(stdout,"    Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
-	fprintf(stdout,"    is identified based on its suffix.\n");
-	fprintf(stdout,"  -o <decompressed file>\n");
-	fprintf(stdout,"    REQUIRED\n");
-	fprintf(stdout,"    Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA files\n");
-	fprintf(stdout,"    Binary data is written to the file (not ascii). If a PGX\n");
-	fprintf(stdout,"    filename is given, there will be as many output files as there are\n");
-	fprintf(stdout,"    components: an indice starting from 0 will then be appended to the\n");
-	fprintf(stdout,"    output filename, just before the \"pgx\" extension. If a PGM filename\n");
-	fprintf(stdout,"    is given and there are more than one component, only the first component\n");
-	fprintf(stdout,"    will be written to the file.\n");
-	fprintf(stdout,"  -r <reduce factor>\n");
-	fprintf(stdout,"    Set the number of highest resolution levels to be discarded. The\n");
-	fprintf(stdout,"    image resolution is effectively divided by 2 to the power of the\n");
-	fprintf(stdout,"    number of discarded levels. The reduce factor is limited by the\n");
-	fprintf(stdout,"    smallest total number of decomposition levels among tiles.\n");
-	fprintf(stdout,"  -l <number of quality layers to decode>\n");
-	fprintf(stdout,"    Set the maximum number of quality layers to decode. If there are\n");
-	fprintf(stdout,"    less quality layers than the specified number, all the quality layers\n");
-	fprintf(stdout,"    are decoded.\n");
-	fprintf(stdout,"  -x  \n"); 
-	fprintf(stdout,"    Create an index file *.Idx (-x index_name.Idx) \n");
-	fprintf(stdout,"\n");
-/* UniPG>> */
-#ifdef USE_JPWL
-	fprintf(stdout,"  -W <options>\n");
-	fprintf(stdout,"    Activates the JPWL correction capability, if the codestream complies.\n");
-	fprintf(stdout,"    Options can be a comma separated list of <param=val> tokens:\n");
-	fprintf(stdout,"    c, c=numcomps\n");
-	fprintf(stdout,"       numcomps is the number of expected components in the codestream\n");
-	fprintf(stdout,"       (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
-#endif /* USE_JPWL */
-/* <<UniPG */
-	fprintf(stdout,"\n");
-}
-
-/* -------------------------------------------------------------------------- */
-
-int get_num_images(char *imgdirpath){
-	DIR *dir;
-	struct dirent* content;	
-	int num_images = 0;
-
-	/*Reading the input images from given input directory*/
-
-	dir= opendir(imgdirpath);
-	if(!dir){
-		fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-		return 0;
-	}
-	
-	while((content=readdir(dir))!=NULL){
-		if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-			continue;
-		num_images++;
-	}
-	return num_images;
-}
-
-int load_images(dircnt_t *dirptr, char *imgdirpath){
-	DIR *dir;
-	struct dirent* content;	
-	int i = 0;
-
-	/*Reading the input images from given input directory*/
-
-	dir= opendir(imgdirpath);
-	if(!dir){
-		fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-		return 1;
-	}else	{
-		fprintf(stderr,"Folder opened successfully\n");
-	}
-	
-	while((content=readdir(dir))!=NULL){
-		if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-			continue;
-
-		strcpy(dirptr->filename[i],content->d_name);
-		i++;
-	}
-	return 0;	
-}
-
-int get_file_format(char *filename) {
-	unsigned int i;
-	static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
-	static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
-	char * ext = strrchr(filename, '.');
-	if (ext == NULL)
-		return -1;
-	ext++;
-	if(ext) {
-		for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
-			if(_strnicmp(ext, extension[i], 3) == 0) {
-				return format[i];
-			}
-		}
-	}
-
-	return -1;
-}
-
-char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
-	char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
-	char *temp_p, temp1[OPJ_PATH_LEN]="";
-
-	strcpy(image_filename,dirptr->filename[imageno]);
-	fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
-	parameters->decod_format = get_file_format(image_filename);
-	if (parameters->decod_format == -1)
-		return 1;
-	sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
-	strncpy(parameters->infile, infilename, sizeof(infilename));
-
-	//Set output file
-	strcpy(temp_ofname,strtok(image_filename,"."));
-	while((temp_p = strtok(NULL,".")) != NULL){
-		strcat(temp_ofname,temp1);
-		sprintf(temp1,".%s",temp_p);
-	}
-	if(img_fol->set_out_format==1){
-		sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
-		strncpy(parameters->outfile, outfilename, sizeof(outfilename));
-	}
-	return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
-	/* parse the command line */
-	int totlen;
-	option_t long_option[]={
-		{"ImgDir",REQ_ARG, NULL ,'y'},
-		{"OutFor",REQ_ARG, NULL ,'O'},
-	};
-
-	const char optlist[] = "i:o:r:l:x:"
-
-/* UniPG>> */
-#ifdef USE_JPWL
-					"W:"
-#endif /* USE_JPWL */
-/* <<UniPG */
-			"h"		;
-	totlen=sizeof(long_option);
-	img_fol->set_out_format = 0;
-	while (1) {
-		int c = getopt_long(argc, argv,optlist,long_option,totlen);
-		if (c == -1)
-			break;
-		switch (c) {
-			case 'i':			/* input file */
-			{
-				char *infile = optarg;
-				parameters->decod_format = get_file_format(infile);
-				switch(parameters->decod_format) {
-					case J2K_CFMT:
-					case JP2_CFMT:
-					case JPT_CFMT:
-						break;
-					default:
-						fprintf(stderr, 
-							"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n", 
-							infile);
-						return 1;
-				}
-				strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-
-			case 'o':			/* output file */
-			{
-				char *outfile = optarg;
-				parameters->cod_format = get_file_format(outfile);
-				switch(parameters->cod_format) {
-					case PGX_DFMT:
-					case PXM_DFMT:
-					case BMP_DFMT:
-					case TIF_DFMT:
-					case RAW_DFMT:
-					case TGA_DFMT:
-					case PNG_DFMT:
-						break;
-					default:
-						fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
-						return 1;
-				}
-				strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
-			}
-			break;
-			
-				/* ----------------------------------------------------- */
-
-			case 'O':			/* output format */
-			{
-				char outformat[50];
-				char *of = optarg;
-				sprintf(outformat,".%s",of);
-				img_fol->set_out_format = 1;
-				parameters->cod_format = get_file_format(outformat);
-				switch(parameters->cod_format) {
-					case PGX_DFMT:
-						img_fol->out_format = "pgx";
-						break;
-					case PXM_DFMT:
-						img_fol->out_format = "ppm";
-						break;
-					case BMP_DFMT:
-						img_fol->out_format = "bmp";
-						break;
-					case TIF_DFMT:
-						img_fol->out_format = "tif";
-						break;
-					case RAW_DFMT:
-						img_fol->out_format = "raw";
-						break;
-					case TGA_DFMT:
-						img_fol->out_format = "raw";
-						break;
-					case PNG_DFMT:
-						img_fol->out_format = "png";
-						break;
-					default:
-						fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
-						return 1;
-						break;
-				}
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-
-			case 'r':		/* reduce option */
-			{
-				sscanf(optarg, "%d", &parameters->cp_reduce);
-			}
-			break;
-			
-				/* ----------------------------------------------------- */
-      
-
-			case 'l':		/* layering option */
-			{
-				sscanf(optarg, "%d", &parameters->cp_layer);
-			}
-			break;
-			
-				/* ----------------------------------------------------- */
-
-			case 'h': 			/* display an help description */
-				decode_help_display();
-				return 1;				
-
-				/* ------------------------------------------------------ */
-
-			case 'y':			/* Image Directory path */
-				{
-					img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
-					strcpy(img_fol->imgdirpath,optarg);
-					img_fol->set_imgdir=1;
-				}
-				break;
-				/* ----------------------------------------------------- */								
-			case 'x':			/* Creation of index file */
-				{
-					char *index = optarg;
-					strncpy(indexfilename, index, OPJ_PATH_LEN);
-				}
-				break;
-				/* ----------------------------------------------------- */
-				/* UniPG>> */
-#ifdef USE_JPWL
-			
-			case 'W': 			/* activate JPWL correction */
-			{
-				char *token = NULL;
-
-				token = strtok(optarg, ",");
-				while(token != NULL) {
-
-					/* search expected number of components */
-					if (*token == 'c') {
-
-						static int compno;
-
-						compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
-
-						if(sscanf(token, "c=%d", &compno) == 1) {
-							/* Specified */
-							if ((compno < 1) || (compno > 256)) {
-								fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
-								return 1;
-							}
-							parameters->jpwl_exp_comps = compno;
-
-						} else if (!strcmp(token, "c")) {
-							/* default */
-							parameters->jpwl_exp_comps = compno; /* auto for default size */
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
-							return 1;
-						};
-					}
-
-					/* search maximum number of tiles */
-					if (*token == 't') {
-
-						static int tileno;
-
-						tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
-
-						if(sscanf(token, "t=%d", &tileno) == 1) {
-							/* Specified */
-							if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
-								fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
-								return 1;
-							}
-							parameters->jpwl_max_tiles = tileno;
-
-						} else if (!strcmp(token, "t")) {
-							/* default */
-							parameters->jpwl_max_tiles = tileno; /* auto for default size */
-
-						} else {
-							fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
-							return 1;
-						};
-					}
-
-					/* next token or bust */
-					token = strtok(NULL, ",");
-				};
-				parameters->jpwl_correct = true;
-				fprintf(stdout, "JPWL correction capability activated\n");
-				fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
-			}
-			break;	
-#endif /* USE_JPWL */
-/* <<UniPG */            
-
-				/* ----------------------------------------------------- */
-			
-			default:
-				fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
-				break;
-		}
-	}
-
-	/* check for possible errors */
-	if(img_fol->set_imgdir==1){
-		if(!(parameters->infile[0]==0)){
-			fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
-			return 1;
-		}
-		if(img_fol->set_out_format == 0){
-			fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
-			fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
-			return 1;
-		}
-		if(!((parameters->outfile[0] == 0))){
-			fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
-			return 1;
-		}
-	}else{
-		if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
-			fprintf(stderr, "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
-			fprintf(stderr, "    Try: %s -h\n",argv[0]);
-			return 1;
-		}
-	}
-
-	return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	(void)client_data;
-	fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char **argv) {
-	opj_dparameters_t parameters;	/* decompression parameters */
-	img_fol_t img_fol;
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_image_t *image = NULL;
-	FILE *fsrc = NULL;
-	unsigned char *src = NULL;
-	int file_length;
-	int num_images;
-	int i,imageno;
-	dircnt_t *dirptr;
-	opj_dinfo_t* dinfo = NULL;	/* handle to a decompressor */
-	opj_cio_t *cio = NULL;
-	opj_codestream_info_t cstr_info;  /* Codestream information structure */
-	char indexfilename[OPJ_PATH_LEN];	/* index file name */
-
-	/* configure the event callbacks (not required) */
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* set decoding parameters to default values */
-	opj_set_default_decoder_parameters(&parameters);
-
-	/* Initialize indexfilename and img_fol */
-	*indexfilename = 0;
-	memset(&img_fol,0,sizeof(img_fol_t));
-
-	/* parse input and get user encoding parameters */
-	if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol, indexfilename) == 1) {
-		return 1;
-	}
-
-	/* Initialize reading of directory */
-	if(img_fol.set_imgdir==1){	
-		num_images=get_num_images(img_fol.imgdirpath);
-
-		dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
-		if(dirptr){
-			dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char));	// Stores at max 10 image file names
-			dirptr->filename = (char**) malloc(num_images*sizeof(char*));
-
-			if(!dirptr->filename_buf){
-				return 1;
-			}
-			for(i=0;i<num_images;i++){
-				dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
-			}
-		}
-		if(load_images(dirptr,img_fol.imgdirpath)==1){
-			return 1;
-		}
-		if (num_images==0){
-			fprintf(stdout,"Folder is empty\n");
-			return 1;
-		}
-	}else{
-		num_images=1;
-	}
-
-	/*Encoding image one by one*/
-	for(imageno = 0; imageno < num_images ; imageno++)	{
-		image = NULL;
-		fprintf(stderr,"\n");
-
-		if(img_fol.set_imgdir==1){
-			if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
-				fprintf(stderr,"skipping file...\n");
-				continue;
-			}
-		}
-
-		/* read the input file and put it in memory */
-		/* ---------------------------------------- */
-		fsrc = fopen(parameters.infile, "rb");
-		if (!fsrc) {
-			fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
-			return 1;
-		}
-		fseek(fsrc, 0, SEEK_END);
-		file_length = ftell(fsrc);
-		fseek(fsrc, 0, SEEK_SET);
-		src = (unsigned char *) malloc(file_length);
-		fread(src, 1, file_length, fsrc);
-		fclose(fsrc);
-
-		/* decode the code-stream */
-		/* ---------------------- */
-
-		switch(parameters.decod_format) {
-		case J2K_CFMT:
-		{
-			/* JPEG-2000 codestream */
-
-			/* get a decoder handle */
-			dinfo = opj_create_decompress(CODEC_J2K);
-
-			/* catch events using our callbacks and give a local context */
-			opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-			/* setup the decoder decoding parameters using user parameters */
-			opj_setup_decoder(dinfo, &parameters);
-
-			/* open a byte stream */
-			cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-			/* decode the stream and fill the image structure */
-			if (*indexfilename)				// If need to extract codestream information
-				image = opj_decode_with_info(dinfo, cio, &cstr_info);
-			else
-				image = opj_decode(dinfo, cio);
-			if(!image) {
-				fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-				opj_destroy_decompress(dinfo);
-				opj_cio_close(cio);
-				return 1;
-			}
-
-			/* close the byte stream */
-			opj_cio_close(cio);
-
-			/* Write the index to disk */
-			if (*indexfilename) {
-				char bSuccess;
-				bSuccess = write_index_file(&cstr_info, indexfilename);
-				if (bSuccess) {
-					fprintf(stderr, "Failed to output index file\n");
-				}
-			}
-		}
-		break;
-
-		case JP2_CFMT:
-		{
-			/* JPEG 2000 compressed image data */
-
-			/* get a decoder handle */
-			dinfo = opj_create_decompress(CODEC_JP2);
-
-			/* catch events using our callbacks and give a local context */
-			opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-			/* setup the decoder decoding parameters using the current image and user parameters */
-			opj_setup_decoder(dinfo, &parameters);
-
-			/* open a byte stream */
-			cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-			/* decode the stream and fill the image structure */
-			if (*indexfilename)				// If need to extract codestream information
-				image = opj_decode_with_info(dinfo, cio, &cstr_info);
-			else
-				image = opj_decode(dinfo, cio);			
-			if(!image) {
-				fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-				opj_destroy_decompress(dinfo);
-				opj_cio_close(cio);
-				return 1;
-			}
-
-			/* close the byte stream */
-			opj_cio_close(cio);
-
-			/* Write the index to disk */
-			if (*indexfilename) {
-				char bSuccess;
-				bSuccess = write_index_file(&cstr_info, indexfilename);
-				if (bSuccess) {
-					fprintf(stderr, "Failed to output index file\n");
-				}
-			}
-		}
-		break;
-
-		case JPT_CFMT:
-		{
-			/* JPEG 2000, JPIP */
-
-			/* get a decoder handle */
-			dinfo = opj_create_decompress(CODEC_JPT);
-
-			/* catch events using our callbacks and give a local context */
-			opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-			/* setup the decoder decoding parameters using user parameters */
-			opj_setup_decoder(dinfo, &parameters);
-
-			/* open a byte stream */
-			cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-			/* decode the stream and fill the image structure */
-			if (*indexfilename)				// If need to extract codestream information
-				image = opj_decode_with_info(dinfo, cio, &cstr_info);
-			else
-				image = opj_decode(dinfo, cio);
-			if(!image) {
-				fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-				opj_destroy_decompress(dinfo);
-				opj_cio_close(cio);
-				return 1;
-			}
-
-			/* close the byte stream */
-			opj_cio_close(cio);
-
-			/* Write the index to disk */
-			if (*indexfilename) {
-				char bSuccess;
-				bSuccess = write_index_file(&cstr_info, indexfilename);
-				if (bSuccess) {
-					fprintf(stderr, "Failed to output index file\n");
-				}
-			}
-		}
-		break;
-
-		default:
-			fprintf(stderr, "skipping file..\n");
-			continue;
-	}
-
-		/* free the memory containing the code-stream */
-		free(src);
-		src = NULL;
-
-	if(image->color_space == CLRSPC_SYCC)
-   {
-	color_sycc_to_rgb(image);
-   }
-
-	if(image->icc_profile_buf)
-   {
-#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-	color_apply_icc_profile(image);
-#endif
-
-	free(image->icc_profile_buf);
-	image->icc_profile_buf = NULL; image->icc_profile_len = 0;
-   }
-
-		/* create output image */
-		/* ------------------- */
-		switch (parameters.cod_format) {
-		case PXM_DFMT:			/* PNM PGM PPM */
-			if (imagetopnm(image, parameters.outfile)) {
-				fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-			}
-			else {
-				fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-			}
-			break;
-
-		case PGX_DFMT:			/* PGX */
-			if(imagetopgx(image, parameters.outfile)){
-				fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-			}
-			else {
-				fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-			}
-			break;
-
-		case BMP_DFMT:			/* BMP */
-			if(imagetobmp(image, parameters.outfile)){
-				fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-			}
-			else {
-				fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-			}
-			break;
-#ifdef HAVE_LIBTIFF
-		case TIF_DFMT:			/* TIFF */
-			if(imagetotif(image, parameters.outfile)){
-				fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-			}
-			else {
-				fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-			}
-			break;
-#endif /* HAVE_LIBTIFF */
-		case RAW_DFMT:			/* RAW */
-			if(imagetoraw(image, parameters.outfile)){
-				fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
-			}
-			else {
-				fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
-			}
-			break;
-
-		case TGA_DFMT:			/* TGA */
-			if(imagetotga(image, parameters.outfile)){
-				fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
-			}
-			else {
-				fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
-			}
-			break;
-#ifdef HAVE_LIBPNG
-		case PNG_DFMT:			/* PNG */
-			if(imagetopng(image, parameters.outfile)){
-				fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
-			}
-			else {
-				fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
-			}
-			break;
-#endif /* HAVE_LIBPNG */
-/* Can happen if output file is TIFF or PNG
- * and HAVE_LIBTIF or HAVE_LIBPNG is undefined
-*/
-			default:
-				fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
-		}
-
-		/* free remaining structures */
-		if(dinfo) {
-			opj_destroy_decompress(dinfo);
-		}
-		/* free codestream information structure */
-		if (*indexfilename)	
-			opj_destroy_cstr_info(&cstr_info);
-		/* free image data structure */
-		opj_image_destroy(image);
-
-	}
-	return 0;
-}
-//end main
-
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsp b/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsp
deleted file mode 100644
index 927f1a5..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsp
+++ /dev/null
@@ -1,117 +0,0 @@
-# Microsoft Developer Studio Project File - Name="j2k_to_image" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=j2k_to_image - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "j2k_to_image.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "j2k_to_image.mak" CFG="j2k_to_image - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "j2k_to_image - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "j2k_to_image - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "j2k_to_image - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x40c /d "NDEBUG"
-# ADD RSC /l 0x40c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libc"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "j2k_to_image - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x40c /d "_DEBUG"
-# ADD RSC /l 0x40c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"libcmt" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF 
-
-# Begin Target
-
-# Name "j2k_to_image - Win32 Release"
-# Name "j2k_to_image - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\convert.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\convert.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\compat\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\compat\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\index.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\index.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\j2k_to_image.c
-# End Source File
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsw b/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsw
deleted file mode 100644
index 5a01ee0..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "LibOpenJPEG"=..\LibOpenJPEG.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "j2k_to_image"=.\j2k_to_image.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.sln b/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.sln
deleted file mode 100644
index 22103f5..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.sln and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.vcproj b/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.vcproj
deleted file mode 100644
index efed885..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/j2k_to_image.vcproj
+++ /dev/null
@@ -1,291 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="j2k_to_image"
-	ProjectGUID="{28931669-81A2-4B90-8981-CD707C4E76E6}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Debug/j2k_to_image.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\Debug/j2k_to_image.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1036"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
-				OutputFile=".\Debug/j2k_to_image.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="libc,libcmt"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\Debug/j2k_to_image.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Debug/j2k_to_image.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/j2k_to_image.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="2"
-				FavorSizeOrSpeed="1"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/j2k_to_image.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1036"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
-				OutputFile=".\Release/j2k_to_image.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="libc"
-				ProgramDatabaseFile=".\Release/j2k_to_image.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/j2k_to_image.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<File
-			RelativePath="convert.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="convert.h"
-			>
-		</File>
-		<File
-			RelativePath="compat\getopt.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="compat\getopt.h"
-			>
-		</File>
-		<File
-			RelativePath=".\index.c"
-			>
-		</File>
-		<File
-			RelativePath=".\index.h"
-			>
-		</File>
-		<File
-			RelativePath="j2k_to_image.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/codec/windirent.h b/Utilities/gdcmopenjpeg-v1/codec/windirent.h
deleted file mode 100644
index 037569d..0000000
--- a/Utilities/gdcmopenjpeg-v1/codec/windirent.h
+++ /dev/null
@@ -1,677 +0,0 @@
-
-/*
- * uce-dirent.h - operating system independent dirent implementation
- * 
- * Copyright (C) 1998-2002  Toni Ronkko
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * ``Software''), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- * 
- * 
- * May 28 1998, Toni Ronkko <tronkko at messi.uku.fi>
- *
- * $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
- *
- * $Log: uce-dirent.h,v $
- * Revision 1.7  2002/05/13 10:48:35  tr
- * embedded some source code directly to the header so that no source
- * modules need to be included in the MS Visual C project using the
- * interface, removed all the dependencies to other headers of the `uce'
- * library so that the header can be made public
- *
- * Revision 1.6  2002/04/12 16:22:04  tr
- * Unified Compiling Environment (UCE) replaced `std' library
- *
- * Revision 1.5  2001/07/20 16:33:40  tr
- * moved to `std' library and re-named defines accordingly
- *
- * Revision 1.4  2001/07/10 16:47:18  tronkko
- * revised comments
- *
- * Revision 1.3  2001/01/11 13:16:43  tr
- * using ``uce-machine.h'' for finding out defines such as `FREEBSD'
- *
- * Revision 1.2  2000/10/08 16:00:41  tr
- * copy of FreeBSD man page
- *
- * Revision 1.1  2000/07/10 05:53:16  tr
- * Initial revision
- *
- * Revision 1.2  1998/07/19 18:29:14  tr
- * Added error reporting capabilities and some asserts.
- *
- * Revision 1.1  1998/07/04 16:27:51  tr
- * Initial revision
- *
- * 
- * MSVC 1.0 scans automatic dependencies incorrectly when your project
- * contains this very header.  The problem is that MSVC cannot handle
- * include directives inside #if..#endif block those are never entered.
- * Since this header ought to compile in many different operating systems,
- * there had to be several conditional blocks that are compiled only in
- * operating systems for what they were designed for.  MSVC 1.0 cannot
- * handle inclusion of sys/dir.h in a part that is compiled only in Apollo
- * operating system.  To fix the problem you need to insert DIR.H into
- * SYSINCL.DAT located in MSVC\BIN directory and restart visual C++.
- * Consult manuals for more informaton about the problem.
- *
- * Since many UNIX systems have dirent.h we assume to have one also.
- * However, if your UNIX system does not have dirent.h you can download one
- * for example at: http://ftp.uni-mannheim.de/ftp/GNU/dirent/dirent.tar.gz.
- * You can also see if you have one of dirent.h, direct.h, dir.h, ndir.h,
- * sys/dir.h and sys/ndir.h somewhere.  Try defining HAVE_DIRENT_H,
- * HAVE_DIRECT_H, HAVE_DIR_H, HAVE_NDIR_H, HAVE_SYS_DIR_H and
- * HAVE_SYS_NDIR_H according to the files found.
- */
-#ifndef DIRENT_H
-#define DIRENT_H
-#define DIRENT_H_INCLUDED
-
-/* find out platform */
-#if defined(MSDOS)                             /* MS-DOS */
-#elif defined(__MSDOS__)                       /* Turbo C/Borland */
-# define MSDOS
-#elif defined(__DOS__)                         /* Watcom */
-# define MSDOS
-#endif
-
-#if defined(WIN32)                             /* MS-Windows */
-#elif defined(__NT__)                          /* Watcom */
-# define WIN32
-#elif defined(_WIN32)                          /* Microsoft */
-# define WIN32
-#elif defined(__WIN32__)                       /* Borland */
-# define WIN32
-#endif
-
-/*
- * See what kind of dirent interface we have unless autoconf has already
- * determinated that.
- */
-#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
-# if defined(_MSC_VER)                         /* Microsoft C/C++ */
-    /* no dirent.h */
-# elif defined(__BORLANDC__)                   /* Borland C/C++ */
-#   define HAVE_DIRENT_H
-#   define VOID_CLOSEDIR
-# elif defined(__TURBOC__)                     /* Borland Turbo C */
-    /* no dirent.h */
-# elif defined(__WATCOMC__)                    /* Watcom C/C++ */
-#   define HAVE_DIRECT_H
-# elif defined(__apollo)                       /* Apollo */
-#   define HAVE_SYS_DIR_H
-# elif defined(__hpux)                         /* HP-UX */
-#   define HAVE_DIRENT_H
-# elif (defined(__alpha) || defined(__alpha__)) && !defined(__linux__)  /* Alpha OSF1 */
-#   error "not implemented"
-# elif defined(__sgi)                          /* Silicon Graphics */
-#   define HAVE_DIRENT_H
-# elif defined(sun) || defined(_sun)           /* Sun Solaris */
-#   define HAVE_DIRENT_H
-# elif defined(__FreeBSD__)                    /* FreeBSD */
-#   define HAVE_DIRENT_H
-# elif defined(__linux__)                      /* Linux */
-#   define HAVE_DIRENT_H
-# elif defined(__GNUC__)                       /* GNU C/C++ */
-#   define HAVE_DIRENT_H
-# else
-#   error "not implemented"
-# endif
-#endif
-
-/* include proper interface headers */
-#if defined(HAVE_DIRENT_H)
-# include <dirent.h>
-# ifdef FREEBSD
-#   define NAMLEN(dp) ((int)((dp)->d_namlen))
-# else
-#   define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
-# endif
-
-#elif defined(HAVE_NDIR_H)
-# include <ndir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_DIRECT_H)
-# include <direct.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_DIR_H)
-# include <dir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_SYS_DIR_H)
-# include <sys/types.h>
-# include <sys/dir.h>
-# ifndef dirent
-#   define dirent direct
-# endif
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(MSDOS) || defined(WIN32)
-
-  /* figure out type of underlaying directory interface to be used */
-# if defined(WIN32)
-#   define DIRENT_WIN32_INTERFACE
-# elif defined(MSDOS)
-#   define DIRENT_MSDOS_INTERFACE
-# else
-#   error "missing native dirent interface"
-# endif
-
-  /*** WIN32 specifics ***/
-# if defined(DIRENT_WIN32_INTERFACE)
-#   include <windows.h>
-#   if !defined(DIRENT_MAXNAMLEN)
-#     define DIRENT_MAXNAMLEN (MAX_PATH)
-#   endif
-
-
-  /*** MS-DOS specifics ***/
-# elif defined(DIRENT_MSDOS_INTERFACE)
-#   include <dos.h>
-
-    /* Borland defines file length macros in dir.h */
-#   if defined(__BORLANDC__)
-#     include <dir.h>
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
-#     endif
-#     if !defined(_find_t)
-#       define _find_t find_t
-#     endif
-
-    /* Turbo C defines ffblk structure in dir.h */
-#   elif defined(__TURBOC__)
-#     include <dir.h>
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
-#     endif
-#     define DIRENT_USE_FFBLK
-
-    /* MSVC */
-#   elif defined(_MSC_VER)
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN (12)
-#     endif
-
-    /* Watcom */
-#   elif defined(__WATCOMC__)
-#     if !defined(DIRENT_MAXNAMLEN)
-#       if defined(__OS2__) || defined(__NT__)
-#         define DIRENT_MAXNAMLEN (255)
-#       else
-#         define DIRENT_MAXNAMLEN (12)
-#       endif
-#     endif
-
-#   endif
-# endif
-
-  /*** generic MS-DOS and MS-Windows stuff ***/
-# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
-#   define NAME_MAX DIRENT_MAXNAMLEN
-# endif
-# if NAME_MAX < DIRENT_MAXNAMLEN
-#   error "assertion failed: NAME_MAX >= DIRENT_MAXNAMLEN"
-# endif
-
-
-  /*
-   * Substitute for real dirent structure.  Note that `d_name' field is a
-   * true character array although we have it copied in the implementation
-   * dependent data.  We could save some memory if we had declared `d_name'
-   * as a pointer refering the name within implementation dependent data.
-   * We have not done that since some code may rely on sizeof(d_name) to be
-   * something other than four.  Besides, directory entries are typically so
-   * small that it takes virtually no time to copy them from place to place.
-   */
-  typedef struct dirent {
-    char d_name[NAME_MAX + 1];
-
-    /*** Operating system specific part ***/
-# if defined(DIRENT_WIN32_INTERFACE)       /*WIN32*/
-    WIN32_FIND_DATA data;
-# elif defined(DIRENT_MSDOS_INTERFACE)     /*MSDOS*/
-#   if defined(DIRENT_USE_FFBLK)
-    struct ffblk data;
-#   else
-    struct _find_t data;
-#   endif
-# endif
-  } dirent;
-
-  /* DIR substitute structure containing directory name.  The name is
-   * essential for the operation of ``rewinndir'' function. */
-  typedef struct DIR {
-    char          *dirname;                    /* directory being scanned */
-    dirent        current;                     /* current entry */
-    int           dirent_filled;               /* is current un-processed? */
-
-  /*** Operating system specific part ***/
-#  if defined(DIRENT_WIN32_INTERFACE)
-    HANDLE        search_handle;
-#  elif defined(DIRENT_MSDOS_INTERFACE)
-#  endif
-  } DIR;
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/* supply prototypes for dirent functions */
-static DIR *opendir (const char *dirname);
-static struct dirent *readdir (DIR *dirp);
-static int closedir (DIR *dirp);
-static void rewinddir (DIR *dirp);
-
-/*
- * Implement dirent interface as static functions so that the user does not
- * need to change his project in any way to use dirent function.  With this
- * it is sufficient to include this very header from source modules using
- * dirent functions and the functions will be pulled in automatically.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-
-/* use ffblk instead of _find_t if requested */
-#if defined(DIRENT_USE_FFBLK)
-# define _A_ARCH   (FA_ARCH)
-# define _A_HIDDEN (FA_HIDDEN)
-# define _A_NORMAL (0)
-# define _A_RDONLY (FA_RDONLY)
-# define _A_SUBDIR (FA_DIREC)
-# define _A_SYSTEM (FA_SYSTEM)
-# define _A_VOLID  (FA_LABEL)
-# define _dos_findnext(dest) findnext(dest)
-# define _dos_findfirst(name,flags,dest) findfirst(name,dest,flags)
-#endif
-
-static int _initdir (DIR *p);
-static const char *_getdirname (const struct dirent *dp);
-static void _setdirname (struct DIR *dirp);
-
-/*
- * <function name="opendir">
- * <intro>open directory stream for reading
- * <syntax>DIR *opendir (const char *dirname);
- *
- * <desc>Open named directory stream for read and return pointer to the
- * internal working area that is used for retrieving individual directory
- * entries.  The internal working area has no fields of your interest.
- *
- * <ret>Returns a pointer to the internal working area or NULL in case the 
- * directory stream could not be opened.  Global `errno' variable will set
- * in case of error as follows:
- *
- * <table>
- * [EACESS  |Permission denied.
- * [EMFILE  |Too many open files used by the process.
- * [ENFILE  |Too many open files in system.
- * [ENOENT  |Directory does not exist.
- * [ENOMEM  |Insufficient memory.
- * [ENOTDIR |dirname does not refer to directory.  This value is not
- *           reliable on MS-DOS and MS-Windows platforms.  Many
- *           implementations return ENOENT even when the name refers to a
- *           file.]
- * </table>
- * </function>
- */
-static DIR *opendir(const char *dirname)
-{
-  DIR *dirp;
-  assert (dirname != NULL);
-  
-  dirp = (DIR*)malloc (sizeof (struct DIR));
-  if (dirp != NULL) {
-    char *p;
-    
-    /* allocate room for directory name */
-    dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
-    if (dirp->dirname == NULL) {
-      /* failed to duplicate directory name.  errno set by malloc() */
-      free (dirp);
-      return NULL;
-    }
-    /* Copy directory name while appending directory separator and "*.*".
-     * Directory separator is not appended if the name already ends with
-     * drive or directory separator.  Directory separator is assumed to be
-     * '/' or '\' and drive separator is assumed to be ':'. */
-    strcpy (dirp->dirname, dirname);
-    p = strchr (dirp->dirname, '\0');
-    if (dirp->dirname < p  &&
-        *(p - 1) != '\\'  &&  *(p - 1) != '/'  &&  *(p - 1) != ':')
-    {
-      strcpy (p++, "\\");
-    }
-# ifdef DIRENT_WIN32_INTERFACE
-    strcpy (p, "*"); /*scan files with and without extension in win32*/
-# else
-    strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
-# endif
-
-    /* open stream */
-    if (_initdir (dirp) == 0) {
-      /* initialization failed */
-      free (dirp->dirname);
-      free (dirp);
-      return NULL;
-    }
-  }
-  return dirp;
-}
-
-
-/*
- * <function name="readdir">
- * <intro>read a directory entry
- * <syntax>struct dirent *readdir (DIR *dirp);
- *
- * <desc>Read individual directory entry and return pointer to a structure
- * containing the name of the entry.  Individual directory entries returned
- * include normal files, sub-directories, pseudo-directories "." and ".."
- * and also volume labels, hidden files and system files in MS-DOS and
- * MS-Windows.   You might want to use stat(2) function to determinate which
- * one are you dealing with.  Many dirent implementations already contain
- * equivalent information in dirent structure but you cannot depend on
- * this.
- *
- * The dirent structure contains several system dependent fields that
- * generally have no interest to you.  The only interesting one is char
- * d_name[] that is also portable across different systems.  The d_name
- * field contains the name of the directory entry without leading path.
- * While d_name is portable across different systems the actual storage
- * capacity of d_name varies from system to system and there is no portable
- * way to find out it at compile time as different systems define the
- * capacity of d_name with different macros and some systems do not define
- * capacity at all (besides actual declaration of the field). If you really
- * need to find out storage capacity of d_name then you might want to try
- * NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
- * there are many MS-DOS and MS-Windows implementations those do not define
- * it.  There are also systems that declare d_name as "char d_name[1]" and
- * then allocate suitable amount of memory at run-time.  Thanks to Alain
- * Decamps (Alain.Decamps at advalvas.be) for pointing it out to me.
- *
- * This all leads to the fact that it is difficult to allocate space
- * for the directory names when the very same program is being compiled on
- * number of operating systems.  Therefore I suggest that you always
- * allocate space for directory names dynamically.
- *
- * <ret>
- * Returns a pointer to a structure containing name of the directory entry
- * in `d_name' field or NULL if there was an error.  In case of an error the
- * global `errno' variable will set as follows:
- *
- * <table>
- * [EBADF  |dir parameter refers to an invalid directory stream.  This value
- *          is not set reliably on all implementations.]
- * </table>
- * </function>
- */
-static struct dirent *
-readdir (DIR *dirp)
-{
-  assert(dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return NULL;
-  }
-
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle == INVALID_HANDLE_VALUE) {
-    /* directory stream was opened/rewound incorrectly or it ended normally */
-    errno = EBADF;
-    return NULL;
-  }
-#endif
-
-  if (dirp->dirent_filled != 0) {
-    /*
-     * Directory entry has already been retrieved and there is no need to
-     * retrieve a new one.  Directory entry will be retrieved in advance
-     * when the user calls readdir function for the first time.  This is so
-     * because real dirent has separate functions for opening and reading
-     * the stream whereas Win32 and DOS dirents open the stream
-     * automatically when we retrieve the first file.  Therefore, we have to
-     * save the first file when opening the stream and later we have to
-     * return the saved entry when the user tries to read the first entry.
-     */
-    dirp->dirent_filled = 0;
-  } else {
-    /* fill in entry and return that */
-#if defined(DIRENT_WIN32_INTERFACE)
-    if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
-      /* Last file has been processed or an error occured */
-      FindClose (dirp->search_handle);
-      dirp->search_handle = INVALID_HANDLE_VALUE;
-      errno = ENOENT;
-      return NULL;
-    }
-
-# elif defined(DIRENT_MSDOS_INTERFACE)
-    if (_dos_findnext (&dirp->current.data) != 0) {
-      /* _dos_findnext and findnext will set errno to ENOENT when no
-       * more entries could be retrieved. */
-      return NULL;
-    }
-# endif
-
-    _setdirname (dirp);
-    assert (dirp->dirent_filled == 0);
-  }
-  return &dirp->current;
-}
-
-
-/*
- * <function name="closedir">
- * <intro>close directory stream.
- * <syntax>int closedir (DIR *dirp);
- *
- * <desc>Close directory stream opened by the `opendir' function.  Close of
- * directory stream invalidates the DIR structure as well as previously read
- * dirent entry.
- *
- * <ret>The function typically returns 0 on success and -1 on failure but
- * the function may be declared to return void on same systems.  At least
- * Borland C/C++ and some UNIX implementations use void as a return type.
- * The dirent wrapper tries to define VOID_CLOSEDIR whenever closedir is
- * known to return nothing.  The very same definition is made by the GNU
- * autoconf if you happen to use it.
- *
- * The global `errno' variable will set to EBADF in case of error.
- * </function>
- */
-static int
-closedir (DIR *dirp)
-{   
-  int retcode = 0;
-
-  /* make sure that dirp points to legal structure */
-  assert (dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return -1;
-  }
- 
-  /* free directory name and search handles */
-  if (dirp->dirname != NULL) free (dirp->dirname);
-
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle != INVALID_HANDLE_VALUE) {
-    if (FindClose (dirp->search_handle) == FALSE) {
-      /* Unknown error */
-      retcode = -1;
-      errno = EBADF;
-    }
-  }
-#endif                     
-
-  /* clear dirp structure to make sure that it cannot be used anymore*/
-  memset (dirp, 0, sizeof (*dirp));
-# if defined(DIRENT_WIN32_INTERFACE)
-  dirp->search_handle = INVALID_HANDLE_VALUE;
-# endif
-
-  free (dirp);
-  return retcode;
-}
-
-
-/*
- * <function name="rewinddir">
- * <intro>rewind directory stream to the beginning
- * <syntax>void rewinddir (DIR *dirp);
- *
- * <desc>Rewind directory stream to the beginning so that the next call of
- * readdir() returns the very first directory entry again.  However, note
- * that next call of readdir() may not return the same directory entry as it
- * did in first time.  The directory stream may have been affected by newly
- * created files.
- *
- * Almost every dirent implementation ensure that rewinddir will update
- * the directory stream to reflect any changes made to the directory entries
- * since the previous ``opendir'' or ``rewinddir'' call.  Keep an eye on
- * this if your program depends on the feature.  I know at least one dirent
- * implementation where you are required to close and re-open the stream to
- * see the changes.
- *
- * <ret>Returns nothing.  If something went wrong while rewinding, you will
- * notice it later when you try to retrieve the first directory entry.
- */
-static void
-rewinddir (DIR *dirp)
-{   
-  /* make sure that dirp is legal */
-  assert (dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return;
-  }
-  assert (dirp->dirname != NULL);
-  
-  /* close previous stream */
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle != INVALID_HANDLE_VALUE) {
-    if (FindClose (dirp->search_handle) == FALSE) {
-      /* Unknown error */
-      errno = EBADF;
-    }
-  }
-#endif
-
-  /* re-open previous stream */
-  if (_initdir (dirp) == 0) {
-    /* initialization failed but we cannot deal with error.  User will notice
-     * error later when she tries to retrieve first directory enty. */
-    /*EMPTY*/;
-  }
-}
-
-
-/*
- * Open native directory stream object and retrieve first file.
- * Be sure to close previous stream before opening new one.
- */
-static int
-_initdir (DIR *dirp)
-{ 
-  assert (dirp != NULL);
-  assert (dirp->dirname != NULL);
-  dirp->dirent_filled = 0;
-
-# if defined(DIRENT_WIN32_INTERFACE)
-  /* Open stream and retrieve first file */
-  dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
-  if (dirp->search_handle == INVALID_HANDLE_VALUE) {
-    /* something went wrong but we don't know what.  GetLastError() could
-     * give us more information about the error, but then we should map
-     * the error code into errno. */
-    errno = ENOENT;
-    return 0;
-  }
-
-# elif defined(DIRENT_MSDOS_INTERFACE)
-  if (_dos_findfirst (dirp->dirname,
-          _A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
-          &dirp->current.data) != 0)
-  {
-    /* _dos_findfirst and findfirst will set errno to ENOENT when no 
-     * more entries could be retrieved. */
-    return 0;
-  }
-# endif
-
-  /* initialize DIR and it's first entry */
-  _setdirname (dirp);
-  dirp->dirent_filled = 1;
-  return 1;
-}
-
-
-/*
- * Return implementation dependent name of the current directory entry.
- */
-static const char *
-_getdirname (const struct dirent *dp)
-{
-#if defined(DIRENT_WIN32_INTERFACE)
-  return dp->data.cFileName;
-  
-#elif defined(DIRENT_USE_FFBLK)
-  return dp->data.ff_name;
-  
-#else
-  return dp->data.name;
-#endif  
-}
-
-
-/*
- * Copy name of implementation dependent directory entry to the d_name field.
- */
-static void
-_setdirname (struct DIR *dirp) {
-  /* make sure that d_name is long enough */
-  assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
-  
-  strncpy (dirp->current.d_name,
-      _getdirname (&dirp->current),
-      NAME_MAX);
-  dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
-}
-  
-# ifdef __cplusplus
-}
-# endif
-# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
-
-#else
-# error "missing dirent interface"
-#endif
-
-
-#endif /*DIRENT_H*/
diff --git a/Utilities/gdcmopenjpeg-v1/common/color.c b/Utilities/gdcmopenjpeg-v1/common/color.c
deleted file mode 100644
index ac0921a..0000000
--- a/Utilities/gdcmopenjpeg-v1/common/color.c
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "opj_config.h"
-#include "openjpeg.h"
-#include "color.h"
-
-#ifdef HAVE_LIBLCMS2
-#include <lcms2.h>
-#endif
-#ifdef HAVE_LIBLCMS1
-#include <lcms.h>
-#endif
-
-/*--------------------------------------------------------
-Matrix f�r sYCC, Amendment 1 to IEC 61966-2-1
-
-Y :   0.299   0.587    0.114   :R
-Cb:  -0.1687 -0.3312   0.5     :G
-Cr:   0.5    -0.4187  -0.0812  :B
-
-Inverse:
-
-R: 1        -3.68213e-05    1.40199      :Y
-G: 1.00003  -0.344125      -0.714128     :Cb - 2^(prec - 1)
-B: 0.999823  1.77204       -8.04142e-06  :Cr - 2^(prec - 1)
-
------------------------------------------------------------*/
-static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
-	int *out_r, int *out_g, int *out_b)
-{
-	int r, g, b;
-
-	cb -= offset; cr -= offset;
-	r = y + (int)(1.402 * (float)cr);
-	if(r < 0) r = 0; else if(r > upb) r = upb; *out_r = r;
-
-	g = y - (int)(0.344 * (float)cb + 0.714 * (float)cr);
-	if(g < 0) g = 0; else if(g > upb) g = upb; *out_g = g;
-
-	b = y + (int)(1.772 * (float)cb);
-	if(b < 0) b = 0; else if(b > upb) b = upb; *out_b = b;
-}
-
-static void sycc444_to_rgb(opj_image_t *img)
-{
-	int *d0, *d1, *d2, *r, *g, *b;
-	const int *y, *cb, *cr;
-	int maxw, maxh, max, i, offset, upb;
-
-	i = img->comps[0].prec;
-	offset = 1<<(i - 1); upb = (1<<i)-1;
-
-	maxw = img->comps[0].w; maxh = img->comps[0].h;
-	max = maxw * maxh;
-
-	y = img->comps[0].data;
-	cb = img->comps[1].data;
-	cr = img->comps[2].data;
-
-	d0 = r = (int*)malloc(sizeof(int) * max);
-	d1 = g = (int*)malloc(sizeof(int) * max);
-	d2 = b = (int*)malloc(sizeof(int) * max);
-
-	for(i = 0; i < max; ++i)
-   {
-	sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);	
-
-	++y; ++cb; ++cr; ++r; ++g; ++b;
-   }	
-	free(img->comps[0].data); img->comps[0].data = d0;
-	free(img->comps[1].data); img->comps[1].data = d1;
-	free(img->comps[2].data); img->comps[2].data = d2;
-
-}/* sycc444_to_rgb() */
-
-static void sycc422_to_rgb(opj_image_t *img)
-{	
-	int *d0, *d1, *d2, *r, *g, *b;
-	const int *y, *cb, *cr;
-	int maxw, maxh, max, offset, upb;
-	int i, j;
-
-	i = img->comps[0].prec;
-	offset = 1<<(i - 1); upb = (1<<i)-1;
-
-	maxw = img->comps[0].w; maxh = img->comps[0].h;
-	max = maxw * maxh;
-
-	y = img->comps[0].data;
-	cb = img->comps[1].data;
-	cr = img->comps[2].data;
-
-	d0 = r = (int*)malloc(sizeof(int) * max);
-	d1 = g = (int*)malloc(sizeof(int) * max);
-	d2 = b = (int*)malloc(sizeof(int) * max);
-
-	for(i=0; i < maxh; ++i)
-   {
-	for(j=0; j < maxw; j += 2)
-  {
-	sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
-
-	++y; ++r; ++g; ++b;
-
-	sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
-
-	++y; ++r; ++g; ++b; ++cb; ++cr;
-  }
-   }
-	free(img->comps[0].data); img->comps[0].data = d0;
-	free(img->comps[1].data); img->comps[1].data = d1;
-	free(img->comps[2].data); img->comps[2].data = d2;
-
-	img->comps[1].w = maxw; img->comps[1].h = maxh;
-	img->comps[2].w = maxw; img->comps[2].h = maxh;
-	img->comps[1].dx = img->comps[0].dx;
-	img->comps[2].dx = img->comps[0].dx;
-	img->comps[1].dy = img->comps[0].dy;
-	img->comps[2].dy = img->comps[0].dy;
-
-}/* sycc422_to_rgb() */
-
-static void sycc420_to_rgb(opj_image_t *img)
-{
-	int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
-	const int *y, *cb, *cr, *ny;
-	int maxw, maxh, max, offset, upb;
-	int i, j;
-
-	i = img->comps[0].prec;
-	offset = 1<<(i - 1); upb = (1<<i)-1;
-
-	maxw = img->comps[0].w; maxh = img->comps[0].h;
-	max = maxw * maxh;
-
-	y = img->comps[0].data;
-	cb = img->comps[1].data;
-	cr = img->comps[2].data;
-
-	d0 = r = (int*)malloc(sizeof(int) * max);
-	d1 = g = (int*)malloc(sizeof(int) * max);
-	d2 = b = (int*)malloc(sizeof(int) * max);
-
-	for(i=0; i < maxh; i += 2)
-   {
-	ny = y + maxw;
-	nr = r + maxw; ng = g + maxw; nb = b + maxw;
-
-	for(j=0; j < maxw;  j += 2)
-  {
-	sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
-
-	++y; ++r; ++g; ++b;
-
-	sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
-
-	++y; ++r; ++g; ++b;
-
-	sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
-
-	++ny; ++nr; ++ng; ++nb;
-
-	sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
-
-	++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
-  }
-	y += maxw; r += maxw; g += maxw; b += maxw;
-   }
-	free(img->comps[0].data); img->comps[0].data = d0;
-	free(img->comps[1].data); img->comps[1].data = d1;
-	free(img->comps[2].data); img->comps[2].data = d2;
-
-	img->comps[1].w = maxw; img->comps[1].h = maxh;
-	img->comps[2].w = maxw; img->comps[2].h = maxh;
-	img->comps[1].dx = img->comps[0].dx;
-	img->comps[2].dx = img->comps[0].dx;
-	img->comps[1].dy = img->comps[0].dy;
-	img->comps[2].dy = img->comps[0].dy;
-
-}/* sycc420_to_rgb() */
-
-void color_sycc_to_rgb(opj_image_t *img)
-{
-	if(img->numcomps < 3) 
-   {
-	img->color_space = CLRSPC_GRAY;
-	return;
-   }
-
-	if((img->comps[0].dx == 1)
-	&& (img->comps[1].dx == 2)
-	&& (img->comps[2].dx == 2)
-	&& (img->comps[0].dy == 1)
-	&& (img->comps[1].dy == 2)
-	&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
-  {
-	sycc420_to_rgb(img);
-  }
-	else
-	if((img->comps[0].dx == 1)
-	&& (img->comps[1].dx == 2)
-	&& (img->comps[2].dx == 2)
-	&& (img->comps[0].dy == 1)
-	&& (img->comps[1].dy == 1)
-	&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
-  {
-	sycc422_to_rgb(img);
-  }
-	else
-	if((img->comps[0].dx == 1)
-	&& (img->comps[1].dx == 1)
-	&& (img->comps[2].dx == 1)
-	&& (img->comps[0].dy == 1)
-	&& (img->comps[1].dy == 1)
-	&& (img->comps[2].dy == 1))/* no sub-sample */
-  {
-	sycc444_to_rgb(img);
-  }
-	else
-  {
-	fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n",
-	 __FILE__,__LINE__);
-	return;
-  }
-	img->color_space = CLRSPC_SRGB;
-
-}/* color_sycc_to_rgb() */
-
-#if defined(HAVE_LIBLCMS2) || defined(HAVE_LIBLCMS1)
-#ifdef HAVE_LIBLCMS1
-/* Bob Friesenhahn proposed:*/
-#define cmsSigXYZData   icSigXYZData
-#define cmsSigLabData   icSigLabData
-#define cmsSigCmykData  icSigCmykData
-#define cmsSigYCbCrData icSigYCbCrData
-#define cmsSigLuvData   icSigLuvData
-#define cmsSigGrayData  icSigGrayData
-#define cmsSigRgbData   icSigRgbData
-#define cmsUInt32Number DWORD
-
-#define cmsColorSpaceSignature icColorSpaceSignature
-#define cmsGetHeaderRenderingIntent cmsTakeRenderingIntent
-
-#endif /* HAVE_LIBLCMS1 */
-
-void color_apply_icc_profile(opj_image_t *image)
-{
-	cmsHPROFILE in_prof, out_prof;
-	cmsHTRANSFORM transform;
-	cmsColorSpaceSignature in_space, out_space;
-	cmsUInt32Number intent, in_type, out_type, nr_samples;
-	int *r, *g, *b;
-	int prec, i, max, max_w, max_h;
-	OPJ_COLOR_SPACE oldspace;
-
-	in_prof = 
-	 cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
-	in_space = cmsGetPCS(in_prof);
-	out_space = cmsGetColorSpace(in_prof);
-	intent = cmsGetHeaderRenderingIntent(in_prof);
-
-	
-	max_w = image->comps[0].w; max_h = image->comps[0].h;
-	prec = image->comps[0].prec;
-	oldspace = image->color_space;
-
-	if(out_space == cmsSigRgbData) /* enumCS 16 */
-   {
-	in_type = TYPE_RGB_16;
-	out_type = TYPE_RGB_16;
-	out_prof = cmsCreate_sRGBProfile();
-	image->color_space = CLRSPC_SRGB;
-   }
-	else
-	if(out_space == cmsSigGrayData) /* enumCS 17 */
-   {
-	in_type = TYPE_GRAY_8;
-	out_type = TYPE_RGB_8;
-	out_prof = cmsCreate_sRGBProfile();
-	image->color_space = CLRSPC_SRGB;
-   }
-	else
-	if(out_space == cmsSigYCbCrData) /* enumCS 18 */
-   {
-	in_type = TYPE_YCbCr_16;
-	out_type = TYPE_RGB_16;
-	out_prof = cmsCreate_sRGBProfile();
-	image->color_space = CLRSPC_SRGB;
-   }
-	else
-   {
-#ifdef DEBUG_PROFILE
-fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
-"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
-__FILE__,__LINE__,out_space,
-(out_space>>24) & 0xff,(out_space>>16) & 0xff,
-(out_space>>8) & 0xff, out_space & 0xff);
-#endif
-	return;
-   }
-
-#ifdef DEBUG_PROFILE
-fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
-"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
-max_w,max_h, (void*)in_prof,(void*)out_prof);
-
-fprintf(stderr,"\trender_intent (%u)\n\t"
-"color_space: in(%#x)(%c%c%c%c)   out:(%#x)(%c%c%c%c)\n\t"
-"       type: in(%u)              out:(%u)\n",
-intent,
-in_space,
-(in_space>>24) & 0xff,(in_space>>16) & 0xff,
-(in_space>>8) & 0xff, in_space & 0xff,
-
-out_space,
-(out_space>>24) & 0xff,(out_space>>16) & 0xff,
-(out_space>>8) & 0xff, out_space & 0xff,
-
-in_type,out_type
- );
-#endif /* DEBUG_PROFILE */
-
-	transform = cmsCreateTransform(in_prof, in_type,
-	 out_prof, out_type, intent, 0);
-
-#ifdef HAVE_LIBLCMS2
-/* Possible for: LCMS_VERSION >= 2000 :*/
-	cmsCloseProfile(in_prof);
-	cmsCloseProfile(out_prof);
-#endif
-
-	if(transform == NULL)
-   {
-#ifdef DEBUG_PROFILE
-fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
-"ICC Profile ignored.\n",__FILE__,__LINE__);
-#endif
-	image->color_space = oldspace;
-#ifdef HAVE_LIBLCMS1
-	cmsCloseProfile(in_prof);
-	cmsCloseProfile(out_prof);
-#endif
-	return;
-   }
-
-	if(image->numcomps > 2)/* RGB, RGBA */
-   {
-	unsigned short *inbuf, *outbuf, *in, *out;
-	max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned short);
-	in = inbuf = (unsigned short*)malloc(nr_samples);
-	out = outbuf = (unsigned short*)malloc(nr_samples);
-
-	r = image->comps[0].data;
-	g = image->comps[1].data;
-	b = image->comps[2].data;
-
-	for(i = 0; i < max; ++i)
-  {
-	*in++ = (unsigned short)*r++;
-	*in++ = (unsigned short)*g++;
-	*in++ = (unsigned short)*b++;
-  }
-
-	cmsDoTransform(transform, inbuf, outbuf, max);
-
-	r = image->comps[0].data;
-	g = image->comps[1].data;
-	b = image->comps[2].data;
-
-	for(i = 0; i < max; ++i)
-  {
-	*r++ = (int)*out++;
-	*g++ = (int)*out++;
-	*b++ = (int)*out++;
-  }
-	free(inbuf); free(outbuf);
-   }
-	else /* GRAY, GRAYA */
-   {
-	unsigned char *in, *inbuf, *out, *outbuf;
-
-	max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned char);
-	in = inbuf = (unsigned char*)malloc(nr_samples);
-	out = outbuf = (unsigned char*)malloc(nr_samples);
-
-	image->comps = (opj_image_comp_t*)
-	 realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
-
-	if(image->numcomps == 2)
-	 image->comps[3] = image->comps[1];
-
-	image->comps[1] = image->comps[0];
-	image->comps[2] = image->comps[0];
-
-	image->comps[1].data = (int*)calloc(max, sizeof(int));
-	image->comps[2].data = (int*)calloc(max, sizeof(int));
-
-	image->numcomps += 2;
-
-	r = image->comps[0].data;
-
-	for(i = 0; i < max; ++i)
-  {
-	*in++ = (unsigned char)*r++;
-  }
-	cmsDoTransform(transform, inbuf, outbuf, max);
-
-	r = image->comps[0].data;
-	g = image->comps[1].data;
-	b = image->comps[2].data;
-
-	for(i = 0; i < max; ++i)
-  {
-	*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
-  }
-	free(inbuf); free(outbuf);
-
-   }/* if(image->numcomps */
-
-	cmsDeleteTransform(transform);
-
-#ifdef HAVE_LIBLCMS1
-	cmsCloseProfile(in_prof);
-	cmsCloseProfile(out_prof);
-#endif
-}/* color_apply_icc_profile() */
-
-#endif /* HAVE_LIBLCMS2 || HAVE_LIBLCMS1 */
-
diff --git a/Utilities/gdcmopenjpeg-v1/common/color.h b/Utilities/gdcmopenjpeg-v1/common/color.h
deleted file mode 100644
index 26117b0..0000000
--- a/Utilities/gdcmopenjpeg-v1/common/color.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _OPJ_COLOR_H_
-#define _OPJ_COLOR_H_
-
-extern void color_sycc_to_rgb(opj_image_t *img);
-extern void color_apply_icc_profile(opj_image_t *image);
-
-#endif /* _OPJ_COLOR_H_ */
diff --git a/Utilities/gdcmopenjpeg-v1/common/format_defs.h b/Utilities/gdcmopenjpeg-v1/common/format_defs.h
deleted file mode 100644
index d4be93b..0000000
--- a/Utilities/gdcmopenjpeg-v1/common/format_defs.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _OPJ_FORMAT_DEFS_H_
-#define _OPJ_FORMAT_DEFS_H_
-
-#define J2K_CFMT 0
-#define JP2_CFMT 1
-#define JPT_CFMT 2
-
-#define PXM_DFMT 10
-#define PGX_DFMT 11
-#define BMP_DFMT 12
-#define YUV_DFMT 13
-#define TIF_DFMT 14
-#define RAW_DFMT 15
-#define TGA_DFMT 16
-#define PNG_DFMT 17
-
-#endif /* _OPJ_FORMAT_DEFS_H_ */
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/common/getopt.c b/Utilities/gdcmopenjpeg-v1/common/getopt.c
deleted file mode 100644
index 5e444d3..0000000
--- a/Utilities/gdcmopenjpeg-v1/common/getopt.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (c) 1987, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* last review : october 29th, 2002 */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getopt.c	8.3 (Berkeley) 4/27/95";
-#endif				/* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int opterr = 1,			/* if error message should be printed */
- optind = 1,			/* index into parent argv vector */
- optopt,			/* character checked for validity */
- optreset;			/* reset getopt */
-const char *optarg;			/* argument associated with option */
-
-typedef struct option
-{
-	const char *name;
-	int has_arg;
-	int *flag;
-	int val;
-}option_t;
-
-#define	BADCH	(int)'?'
-#define	BADARG	(int)':'
-#define	EMSG	""
-
-/* As this class remembers its values from one Java call to the other, reset the values before each use */
-void reset_options_reading() {
-	opterr = 1;
-	optind = 1;
-}
-
-/*
- * getopt --
- *	Parse argc/argv argument vector.
- */
-int getopt(int nargc, char *const *nargv, const char *ostr) {
-#  define __progname nargv[0]
-  static const char *place = EMSG;	/* option letter processing */
-  char *oli;			/* option letter list index */
-
-  if (optreset || !*place) {	/* update scanning pointer */
-    optreset = 0;
-    if (optind >= nargc || *(place = nargv[optind]) != '-') {
-      place = EMSG;
-      return (-1);
-    }
-    if (place[1] && *++place == '-') {	/* found "--" */
-      ++optind;
-      place = EMSG;
-      return (-1);
-    }
-  }				/* option letter okay? */
-  if ((optopt = (int) *place++) == (int) ':' ||
-      !(oli = strchr(ostr, optopt))) {
-    /*
-     * if the user didn't specify '-' as an option,
-     * assume it means -1.
-     */
-    if (optopt == (int) '-')
-      return (-1);
-    if (!*place)
-      ++optind;
-		if (opterr && *ostr != ':') {
-      fprintf(stderr,
-		     "%s: illegal option -- %c\n", __progname, optopt);
-			return (BADCH);
-		}
-  }
-  if (*++oli != ':') {		/* don't need argument */
-    optarg = NULL;
-    if (!*place)
-      ++optind;
-  } else {			/* need an argument */
-    if (*place)			/* no white space */
-      optarg = place;
-    else if (nargc <= ++optind) {	/* no arg */
-      place = EMSG;
-      if (*ostr == ':')
-	return (BADARG);
-			if (opterr) {
-				fprintf(stderr,
-		       "%s: option requires an argument -- %c\n",
-		       __progname, optopt);
-				return (BADCH);
-			}
-    } else			/* white space */
-      optarg = nargv[optind];
-    place = EMSG;
-    ++optind;
-  }
-  return (optopt);		/* dump back option letter */
-}
-
-
-int getopt_long(int argc, char * const argv[], const char *optstring,
-struct option *longopts, int totlen) {
-	static int lastidx,lastofs;
-	char *tmp;
-	int i,len;
-	char param = 1;
-
-again:
-	if (optind >= argc || !argv[optind] || *argv[optind]!='-')
-		return -1;
-
-	if (argv[optind][0]=='-' && argv[optind][1]==0) {
-		if(optind >= (argc - 1)){ /* no more input parameters */
-			param = 0;
-		}
-		else{ /* more input parameters */
-			if(argv[optind + 1][0] == '-'){
-				param = 0; /* Missing parameter after '-' */
-			}
-			else{
-				param = 2;
-			}
-		}
-	}
-
-	if (param == 0) {
-		++optind;
-		return (BADCH);
-	}
-
-	if (argv[optind][0]=='-') {	/* long option */
-		char* arg=argv[optind]+1;
-		const struct option* o;
-		o=longopts;
-		len=sizeof(longopts[0]);
-
-		if (param > 1){
-			arg = argv[optind+1];
-			optind++;
-		}
-		else
-			arg = argv[optind]+1;
-
-		if(strlen(arg)>1){
-			for (i=0;i<totlen;i=i+len,o++) {
-				if (!strcmp(o->name,arg)) {	/* match */
-					if (o->has_arg == 0) {
-						if ((argv[optind+1])&&(!(argv[optind+1][0]=='-'))){
-							fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[optind+1]);
-							++optind;
-						}
-					}else{ 
-						optarg=argv[optind+1];
-						if(optarg){
-							if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */								
-								if (opterr) {
-									fprintf(stderr,"%s: option requires an argument\n",arg);
-									return (BADCH);
-								}
-							}
-						}
-						if (!optarg && o->has_arg==1) {	/* no argument there */
-							if (opterr) {
-								fprintf(stderr,"%s: option requires an argument \n",arg);
-								return (BADCH);
-							}
-						}
-						++optind;
-					}
-					++optind;
-					if (o->flag)
-						*(o->flag)=o->val;
-					else
-						return o->val;
-					return 0;
-				}
-			}//(end for)String not found in the list
-			fprintf(stderr,"Invalid option %s\n",arg);
-			++optind;
-			return (BADCH);
-		}else{ /*Single character input parameter*/
-			if (*optstring==':') return ':';
-			if (lastidx!=optind) {
-				lastidx=optind; lastofs=0;
-			}
-			optopt=argv[optind][lastofs+1];
-			if ((tmp=strchr(optstring,optopt))) {/*Found input parameter in list*/
-				if (*tmp==0) {	/* apparently, we looked for \0, i.e. end of argument */
-					++optind;
-					goto again;
-				}
-				if (tmp[1]==':') {	/* argument expected */
-					if (tmp[2]==':' || argv[optind][lastofs+2]) {	/* "-foo", return "oo" as optarg */
-						if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
-						goto found;
-					}
-					optarg=argv[optind+1];
-					if(optarg){
-						if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
-							if (opterr) {
-								fprintf(stderr,"%s: option requires an argument\n",arg);
-								return (BADCH);
-							}
-						}
-					}
-					if (!optarg) {	/* missing argument */
-						if (opterr) {
-							fprintf(stderr,"%s: option requires an argument\n",arg);
-							return (BADCH);
-						}
-					}
-					++optind;
-				}else {/*Argument not expected*/
-					++lastofs;
-					return optopt;
-				}
-found:
-				++optind;
-				return optopt;
-			}	else {	/* not found */
-				fprintf(stderr,"Invalid option %s\n",arg);
-				++optind;
-				return (BADCH);
-			}//end of not found
-		
-		}// end of single character
-	}//end '-'
-	fprintf(stderr,"Invalid option\n");
-	++optind;
-	return (BADCH);;
-}//end function
diff --git a/Utilities/gdcmopenjpeg-v1/common/getopt.h b/Utilities/gdcmopenjpeg-v1/common/getopt.h
deleted file mode 100644
index 779fe47..0000000
--- a/Utilities/gdcmopenjpeg-v1/common/getopt.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* last review : october 29th, 2002 */
-
-#ifndef _GETOPT_H_
-#define _GETOPT_H_
-
-typedef struct option
-{
-	const char *name;
-	int has_arg;
-	int *flag;
-	int val;
-}option_t;
-
-#define	NO_ARG	0
-#define REQ_ARG	1
-#define OPT_ARG	2
-
-extern int opterr;
-extern int optind;
-extern int optopt;
-extern int optreset;
-extern char *optarg;
-
-extern int getopt(int nargc, char *const *nargv, const char *ostr);
-extern int getopt_long(int argc, char * const argv[], const char *optstring,
-			const struct option *longopts, int totlen);
-extern void reset_options_reading();
-
-#endif				/* _GETOPT_H_ */
diff --git a/Utilities/gdcmopenjpeg-v1/doc/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/doc/CMakeLists.txt
deleted file mode 100644
index 23f7895..0000000
--- a/Utilities/gdcmopenjpeg-v1/doc/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-find_package(Doxygen)
-#
-if(DOXYGEN_EXECUTABLE)
-# The Doxyfile.dox is poorly defined and produce output
-# in the source dir
-add_custom_target(doxygen
-# By default doxygen target is added to the 'all' target. Project is small
-# thus running doxygen is not too time consuming
-  ALL
-  ${DOXYGEN}
-  ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox
-  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
-endif()
-
diff --git a/Utilities/gdcmopenjpeg-v1/doc/Doxyfile.dox b/Utilities/gdcmopenjpeg-v1/doc/Doxyfile.dox
deleted file mode 100644
index c60a4de..0000000
--- a/Utilities/gdcmopenjpeg-v1/doc/Doxyfile.dox
+++ /dev/null
@@ -1,234 +0,0 @@
-# Doxyfile 1.4.2
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME           = OpenJPEG
-PROJECT_NUMBER         = 
-OUTPUT_DIRECTORY       = .
-CREATE_SUBDIRS         = NO
-OUTPUT_LANGUAGE        = English
-USE_WINDOWS_ENCODING   = YES
-BRIEF_MEMBER_DESC      = YES
-REPEAT_BRIEF           = YES
-ABBREVIATE_BRIEF       = "The $name class" \
-                         "The $name widget" \
-                         "The $name file" \
-                         is \
-                         provides \
-                         specifies \
-                         contains \
-                         represents \
-                         a \
-                         an \
-                         the
-ALWAYS_DETAILED_SEC    = NO
-INLINE_INHERITED_MEMB  = NO
-FULL_PATH_NAMES        = NO
-STRIP_FROM_PATH        = C://
-STRIP_FROM_INC_PATH    = 
-SHORT_NAMES            = NO
-JAVADOC_AUTOBRIEF      = YES
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP         = YES
-INHERIT_DOCS           = YES
-DISTRIBUTE_GROUP_DOC   = NO
-SEPARATE_MEMBER_PAGES  = NO
-TAB_SIZE               = 8
-ALIASES                = 
-OPTIMIZE_OUTPUT_FOR_C  = YES
-OPTIMIZE_OUTPUT_JAVA   = NO
-SUBGROUPING            = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL            = YES
-EXTRACT_PRIVATE        = YES
-EXTRACT_STATIC         = YES
-EXTRACT_LOCAL_CLASSES  = YES
-EXTRACT_LOCAL_METHODS  = NO
-HIDE_UNDOC_MEMBERS     = NO
-HIDE_UNDOC_CLASSES     = NO
-HIDE_FRIEND_COMPOUNDS  = NO
-HIDE_IN_BODY_DOCS      = NO
-INTERNAL_DOCS          = NO
-CASE_SENSE_NAMES       = NO
-HIDE_SCOPE_NAMES       = NO
-SHOW_INCLUDE_FILES     = YES
-INLINE_INFO            = YES
-SORT_MEMBER_DOCS       = YES
-SORT_BRIEF_DOCS        = NO
-SORT_BY_SCOPE_NAME     = NO
-GENERATE_TODOLIST      = YES
-GENERATE_TESTLIST      = YES
-GENERATE_BUGLIST       = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS       = 
-MAX_INITIALIZER_LINES  = 30
-SHOW_USED_FILES        = YES
-SHOW_DIRECTORIES       = NO
-FILE_VERSION_FILTER    = 
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET                  = NO
-WARNINGS               = YES
-WARN_IF_UNDOCUMENTED   = YES
-WARN_IF_DOC_ERROR      = YES
-WARN_NO_PARAMDOC       = NO
-WARN_FORMAT            = "$file:$line: $text"
-WARN_LOGFILE           = 
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT                  = ../libopenjpeg \
-						 ../jpwl
-FILE_PATTERNS          = *.h \
-                         *.c
-RECURSIVE              = NO
-EXCLUDE                = 
-EXCLUDE_SYMLINKS       = NO
-EXCLUDE_PATTERNS       = 
-EXAMPLE_PATH           = 
-EXAMPLE_PATTERNS       = *
-EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = 
-INPUT_FILTER           = 
-FILTER_PATTERNS        = 
-FILTER_SOURCE_FILES    = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER         = NO
-INLINE_SOURCES         = NO
-STRIP_CODE_COMMENTS    = YES
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION    = YES
-VERBATIM_HEADERS       = YES
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX     = NO
-COLS_IN_ALPHA_INDEX    = 5
-IGNORE_PREFIX          = 
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML          = YES
-HTML_OUTPUT            = ./html
-HTML_FILE_EXTENSION    = .html
-HTML_HEADER            = 
-HTML_FOOTER            = 
-HTML_STYLESHEET        = 
-HTML_ALIGN_MEMBERS     = YES
-GENERATE_HTMLHELP      = NO
-CHM_FILE               = 
-HHC_LOCATION           = 
-GENERATE_CHI           = NO
-BINARY_TOC             = NO
-TOC_EXPAND             = NO
-DISABLE_INDEX          = NO
-ENUM_VALUES_PER_LINE   = 4
-GENERATE_TREEVIEW      = NO
-TREEVIEW_WIDTH         = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX         = NO
-LATEX_OUTPUT           = latex
-LATEX_CMD_NAME         = latex
-MAKEINDEX_CMD_NAME     = makeindex
-COMPACT_LATEX          = NO
-PAPER_TYPE             = a4wide
-EXTRA_PACKAGES         = 
-LATEX_HEADER           = 
-PDF_HYPERLINKS         = NO
-USE_PDFLATEX           = NO
-LATEX_BATCHMODE        = NO
-LATEX_HIDE_INDICES     = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF           = NO
-RTF_OUTPUT             = rtf
-COMPACT_RTF            = NO
-RTF_HYPERLINKS         = NO
-RTF_STYLESHEET_FILE    = 
-RTF_EXTENSIONS_FILE    = 
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN           = NO
-MAN_OUTPUT             = man
-MAN_EXTENSION          = .3
-MAN_LINKS              = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML           = NO
-XML_OUTPUT             = xml
-XML_SCHEMA             = 
-XML_DTD                = 
-XML_PROGRAMLISTING     = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF   = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD       = NO
-PERLMOD_LATEX          = NO
-PERLMOD_PRETTY         = YES
-PERLMOD_MAKEVAR_PREFIX = 
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING   = YES
-MACRO_EXPANSION        = NO
-EXPAND_ONLY_PREDEF     = NO
-SEARCH_INCLUDES        = YES
-INCLUDE_PATH           = 
-INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = USE_JPWL \
-                         USE_JPSEC
-EXPAND_AS_DEFINED      = 
-SKIP_FUNCTION_MACROS   = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references   
-#---------------------------------------------------------------------------
-TAGFILES               = 
-GENERATE_TAGFILE       = 
-ALLEXTERNALS           = NO
-EXTERNAL_GROUPS        = YES
-PERL_PATH              = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS         = YES
-HIDE_UNDOC_RELATIONS   = YES
-HAVE_DOT               = NO
-CLASS_GRAPH            = YES
-COLLABORATION_GRAPH    = YES
-GROUP_GRAPHS           = YES
-UML_LOOK               = NO
-TEMPLATE_RELATIONS     = NO
-INCLUDE_GRAPH          = YES
-INCLUDED_BY_GRAPH      = YES
-CALL_GRAPH             = NO
-GRAPHICAL_HIERARCHY    = YES
-DIRECTORY_GRAPH        = YES
-DOT_IMAGE_FORMAT       = png
-DOT_PATH               = 
-DOTFILE_DIRS           = 
-MAX_DOT_GRAPH_WIDTH    = 1024
-MAX_DOT_GRAPH_HEIGHT   = 1024
-MAX_DOT_GRAPH_DEPTH    = 1000
-DOT_TRANSPARENT        = NO
-DOT_MULTI_TARGETS      = NO
-GENERATE_LEGEND        = YES
-DOT_CLEANUP            = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine   
-#---------------------------------------------------------------------------
-SEARCHENGINE           = NO
diff --git a/Utilities/gdcmopenjpeg-v1/doc/man/man1/image_to_j2k.1 b/Utilities/gdcmopenjpeg-v1/doc/man/man1/image_to_j2k.1
deleted file mode 100644
index 331af0e..0000000
--- a/Utilities/gdcmopenjpeg-v1/doc/man/man1/image_to_j2k.1
+++ /dev/null
@@ -1,222 +0,0 @@
-'\" t
-'\" The line above instructs most `man' programs to invoke tbl
-'\"
-'\" Separate paragraphs; not the same as PP which resets indent level.
-.de SP
-.if t .sp .5
-.if n .sp
-..
-'\"
-'\" Replacement em-dash for nroff (default is too short).
-.ie n .ds m " -
-.el .ds m \(em
-'\"
-'\" Placeholder macro for if longer nroff arrow is needed.
-.ds RA \(->
-'\"
-'\" Decimal point set slightly raised
-.if t .ds d \v'-.15m'.\v'+.15m'
-.if n .ds d .
-'\"
-'\" Enclosure macro for examples
-.de EX
-.SP
-.nf
-.ft CW
-..
-.de EE
-.ft R
-.SP
-.fi
-..
-.TH image_to_j2k 1 "Version 1.4.0" "image_to_j2k" "converts to jpeg2000 files"
-.P
-.SH NAME
-image_to_j2k - 
-This program reads in an image of a certain type and converts it to a
-jpeg2000 file. It is part of the OpenJPEG library.
-.SP
-Valid input image extensions are
-.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
-.SP
-Valid output image extensions are
-.B .j2k, .jp2
-.SH SYNOPSIS
-.P
-.B image_to_j2k -i \fRinfile.bmp \fB-o \fRoutfile.j2k
-.P
-.B image_to_j2k -ImgDir \fRdirectory_name \fB-OutFor \fRjp2
-.P
-.B image_to_j2k -h \fRPrint a help message and exit.
-.P
-.R See JPWL OPTIONS for special options
-.SH OPTIONS
-.TP
-.B \-\^b " n,n"
-(Size of code block (e.g. -b 32,32). Default: 64 x 64)
-.TP
-.B \-\^c " n"
-(Size of precinct (e.g. -c 128,128). Default: 2^15 x 2^15)
-.TP
-.B \-\^cinema2K " fps"
-Digital Cinema 2K profile compliant codestream. Valid \fBfps\fR values are 24 or 48.
-.TP
-.B \-\^cinema4K
-Digital Cinema 4K profile compliant codestream. Does not need an fps: default is 24 fps.
-.TP
-.B \-\^d " X,Y"
-(Offset of image origin (e.g. -d 150,300))
-.TP
-.B \-\^h
-Print a help message and exit.
-.TP
-.B \-\^i " name"
-(input file name)
-.TP
-.B \-\^n " n"
-(Number of resolutions. Default: 6)
-.TP
-.B \-\^o " name"
-(output file name)
-.TP
-.B \-\^p " name"
-Progression order. \fBname\fR can be one out of:LRCP, RLCP, RPCL, PCRL, CPRL. Default: LRCP.
-.TP
-.B \-\^q " n"
-different psnr for successive layers
-.br
-.B Note: \fR(options -r and -q cannot be used together)
-.TP
-.B \-\^r " n"
-different compression ratio(s) for successive layers. The rate specified for each quality level is the desired compression factor.
-.br
-.B Note: \fR(options -r and -q cannot be used together)
-.TP
-.B \-\^s " X,Y"
-sub-sampling factor (e.g. -s 2,2). Default: No sub-sampling in x or y direction.
-.br
-.B Remark: \fRsub-sampling bigger than 2 can produce errors.
-.TP
-.B \-\^t " W,H"
-(Size of tile (e.g. -t 512,512) )
-.TP
-.B \-\^x " name"
-(Create index file and fill it. Default: no index file)
-.TP
-.B \-\^EPH
-(Write EPH marker after each header packet. Default:no EPH)
-.TP
-.B \-\^F " rawWidth,rawHeight,rawComp,rawBitDepth,s_or_u"
-characteristics of the raw input image
-.TP
-.B \-\^I
-(Use the irreversible DWT 9-7. Default: Reversible DWT 5-3)
-.TP
-.B \-\^ImgDir " directory_name"
-(directory containing input files)
-.TP
-.B \-\^M " n"
-mode switch with values: 1, 2, 4, 8, 16, 32. Default:No mode switch activated. 
-.br
-\fIMeaning:\fR
-.br
-BYPASS(1) 
-.br
-RESET(2) 
-.br
-RESTART(4) 
-.br
-VSC(8) 
-.br
-ERTERM(16) 
-.br
-SEGMARK(32)
-.br
-Values can be added: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38
-.TP
-.B \-\^OutFor "ext"
-(extension for output files)
-.TP
-.B \-\^POC "TtileNr=resolutionStart, componentStart, layerEnd, resolutionEnd, componentEnd, progressionOrder"
-(see Examples)
-.TP
-.B \-\^ROI "c=n,U=n"
-quantization indices upshifted for component c (0 or 1 or 2) with a value of U (>= 0 and <= 37)
-.br
-e.g. \fB-ROI c=0,U=25\fR
-.TP
-.B \-\^SOP
-(Write SOP marker before each packet. Default: No SOP marker in the codestream.)
-.TP
-.B \-\^T "X,Y"
-(Offset of the origin of the tiles (e.g. -T 100,75) )
-.TP
-.B \-\^W
-(see JPWL OPTIONS)
-.P
-.SH JPWL OPTIONS
-Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
-.P
-.B      -W h<tilepart><=type>, s<tilepart><=method>, a=<addr>, z=<size>, g=<range>, p<tilepart:pack><=type>
-.P
-.B h\fR selects the header error protection (EPB): \fBtype\fR can be
-   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
-   if \fBtilepart\fR is absent, it is for main and tile headers
-   if \fBtilepart\fR is present, it applies from that tile
-     onwards, up to the next h<> spec, or to the last tilepart
-     in the codestream (max. 16 specs)
-.P
-.B p \fRselects the packet error protection (EEP/UEP with EPBs)
-  to be applied to raw data: \fBtype\fR can be
-   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
-   if \fBtilepart:pack\fR is absent, it is from tile 0, packet 0
-   if \fBtilepart:pack\fR is present, it applies from that tile
-     and that packet onwards, up to the next packet spec
-     or to the last packet in the last tilepart in the stream
-     (max. 16 specs)
-.P
-.B s \fRenables sensitivity data insertion (ESD): \fBmethod\fR can be
-   [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
-    4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
-   if \fBtilepart\fR is absent, it is for main header only
-   if \fBtilepart\fR is present, it applies from that tile
-     onwards, up to the next s<> spec, or to the last tilepart
-     in the codestream (max. 16 specs)
-.P
-.B g \fRdetermines the addressing mode: \fBrange\fR can be
-   [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]
-.P
-.B a \fRdetermines the size of data addressing: \fBaddr\fR can be
-   2/4 bytes (small/large codestreams). If not set, auto-mode
-.P
-.B z \fRdetermines the size of sensitivity values: \fBsize\fR can be
-   1/2 bytes, for the transformed pseudo-floating point value
-.P
-.SH EXAMPLES
-.P
-.B image_to_j2k -i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
-.P
-.B image_to_j2k -i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
-.P
-.B image_to_j2k -i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
-.P
-.B image_to_j2k -i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
-.P
-.SH AUTHORS
-Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
-.br
-Copyright (c) 2002-2007, Professor Benoit Macq
-.br
-Copyright (c) 2001-2003, David Janssens
-.br
-Copyright (c) 2002-2003, Yannick Verschueren
-.br
-Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
-.br
-Copyright (c) 2005, Herve Drolon, FreeImage Team
-.br
-Copyright (c) 2006-2007, Parvatha Elangovan
-.P
-.SH "SEE ALSO"
-j2k_to_image(1) j2k_dump(1)
-
diff --git a/Utilities/gdcmopenjpeg-v1/doc/man/man1/j2k_dump.1 b/Utilities/gdcmopenjpeg-v1/doc/man/man1/j2k_dump.1
deleted file mode 100644
index c45e9f4..0000000
--- a/Utilities/gdcmopenjpeg-v1/doc/man/man1/j2k_dump.1
+++ /dev/null
@@ -1,62 +0,0 @@
-'\" t
-'\" The line above instructs most `man' programs to invoke tbl
-'\"
-'\" Separate paragraphs; not the same as PP which resets indent level.
-.de SP
-.if t .sp .5
-.if n .sp
-..
-'\"
-'\" Replacement em-dash for nroff (default is too short).
-.ie n .ds m " -
-.el .ds m \(em
-'\"
-'\" Placeholder macro for if longer nroff arrow is needed.
-.ds RA \(->
-'\"
-'\" Decimal point set slightly raised
-.if t .ds d \v'-.15m'.\v'+.15m'
-.if n .ds d .
-'\"
-'\" Enclosure macro for examples
-.de EX
-.SP
-.nf
-.ft CW
-..
-.de EE
-.ft R
-.SP
-.fi
-..
-.TH j2k_dump 1 "Version 1.4.0" "j2k_dump" "dumps jpeg2000 files"
-.P
-.SH NAME
-j2k_dump - 
-This program reads in a jpeg2000 image and dumps the contents to stdout. It is part of the OpenJPEG library.
-.SP
-Valid input image extensions are
-.B .j2k, .jp2, .jpt
-.SP
-.SH SYNOPSIS
-.P
-.B j2k_dump -i \fRinfile.j2k 
-.P
-.B j2k_dump -ImgDir \fRimages/ \fRDump all files in images/
-.P
-.B j2k_dump -h  \fRPrint help message and exit
-.P
-.SH OPTIONS
-.TP
-.B \-\^i "name"
-(jpeg2000 input file name)
-.TP
-.B \-\^ImgDir "directory_name"
-(directory containing jpeg2000 input files)
-.P
-'\".SH BUGS
-.SH AUTHORS
-Copyright (c) 20010, Mathieu Malaterre
-.P
-.SH "SEE ALSO"
-image_to_j2k(1) j2k_to_image(1)
diff --git a/Utilities/gdcmopenjpeg-v1/doc/man/man1/j2k_to_image.1 b/Utilities/gdcmopenjpeg-v1/doc/man/man1/j2k_to_image.1
deleted file mode 100644
index 733a37d..0000000
--- a/Utilities/gdcmopenjpeg-v1/doc/man/man1/j2k_to_image.1
+++ /dev/null
@@ -1,109 +0,0 @@
-'\" t
-'\" The line above instructs most `man' programs to invoke tbl
-'\"
-'\" Separate paragraphs; not the same as PP which resets indent level.
-.de SP
-.if t .sp .5
-.if n .sp
-..
-'\"
-'\" Replacement em-dash for nroff (default is too short).
-.ie n .ds m " -
-.el .ds m \(em
-'\"
-'\" Placeholder macro for if longer nroff arrow is needed.
-.ds RA \(->
-'\"
-'\" Decimal point set slightly raised
-.if t .ds d \v'-.15m'.\v'+.15m'
-.if n .ds d .
-'\"
-'\" Enclosure macro for examples
-.de EX
-.SP
-.nf
-.ft CW
-..
-.de EE
-.ft R
-.SP
-.fi
-..
-.TH j2k_to_image 1 "Version 1.4.0" "j2k_to_image" "converts jpeg2000 files"
-.P
-.SH NAME
-j2k_to_image - 
-This program reads in a jpeg2000 image and converts it to another 
-image type. It is part of the OpenJPEG library.
-.SP
-Valid input image extensions are
-.B .j2k, .jp2, .j2c, .jpt
-.SP
-Valid output image extensions are
-.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
-.SH SYNOPSIS
-.P
-.B j2k_to_image -i \fRinfile.j2k \fB-o \fRoutfile.png
-.P
-.B j2k_to_image -ImgDir \fRimages/ \fB-OutFor \fRbmp
-.P
-.B j2k_to_image -h  \fRPrint help message and exit
-.P
-.R See JPWL OPTIONS for special options
-.SH OPTIONS
-.TP
-.B \-\^i "name"
-(jpeg2000 input file name)
-.TP
-.B \-\^l "n"
-n is the maximum number of quality layers to decode. See LAYERS below)
-.TP
-.B \-\^o "name"
-(output file name with extension)
-.TP
-.B \-\^r "n"
-(n is the highest resolution level to be discarded. See REDUCTION below)
-.TP
-.B \-\^x "name"
-(use name as index file and fill it)
-.TP
-.B \-\^ImgDir "directory_name"
-(directory containing input files)
-.TP
-.B \-\^OutFor "ext"
-(extension for output files)
-.P
-.SH JPWL OPTIONS
-Options usable only if the library has been compiled with
-.B -DUSE_JPWL
-.TP
-.B -W c\fR[=Nc] (Nc is the  number of expected components in the codestream; default:3)
-.TP
-.B -W t\fR[=Nt] (Nt is the maximum number of tiles in the codestream; default:8192)
-.TP
-.B -W c\fR[=Nc]\fB, t\fR[=Nt] \fR(same as above)
-.P
-.SH REDUCTION
-Set the number of highest resolution levels to be discarded.
-The image resolution is effectively divided by 2 to the power of the number of discarded levels. The reduce factor is limited by the smallest total number of decomposition levels among tiles.
-.SH TILES
-Set the maximum number of quality layers to decode. If there are less quality layers than the specified number, all the quality layers are decoded.
-.P
-'\".SH BUGS
-.SH AUTHORS
-Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
-.br
-Copyright (c) 2002-2007, Professor Benoit Macq
-.br
-Copyright (c) 2001-2003, David Janssens
-.br
-Copyright (c) 2002-2003, Yannick Verschueren
-.br
-Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
-.br
-Copyright (c) 2005, Herve Drolon, FreeImage Team
-.br
-Copyright (c) 2006-2007, Parvatha Elangovan
-.P
-.SH "SEE ALSO"
-image_to_j2k(1) j2k_dump(1)
diff --git a/Utilities/gdcmopenjpeg-v1/doc/man/man3/libopenjpeg.3 b/Utilities/gdcmopenjpeg-v1/doc/man/man3/libopenjpeg.3
deleted file mode 100644
index 071c1d5..0000000
--- a/Utilities/gdcmopenjpeg-v1/doc/man/man3/libopenjpeg.3
+++ /dev/null
@@ -1,337 +0,0 @@
-'\" t
-'\" The line above instructs most `man' programs to invoke tbl
-'\"
-'\" Separate paragraphs; not the same as PP which resets indent level.
-.de SP
-.if t .sp .5
-.if n .sp
-..
-'\"
-'\" Replacement em-dash for nroff (default is too short).
-.ie n .ds m " -
-.el .ds m \(em
-'\"
-'\" Placeholder macro for if longer nroff arrow is needed.
-.ds RA \(->
-'\"
-'\" Decimal point set slightly raised
-.if t .ds d \v'-.15m'.\v'+.15m'
-.if n .ds d .
-'\"
-'\" Enclosure macro for examples
-.de EX
-.SP
-.nf
-.ft CW
-..
-.de EE
-.ft R
-.SP
-.fi
-..
-.TH libopenjpeg 3 "Oct 2010" "Version 1.4.0" "Oct 2010"
-.P
-.SH NAME
-libopenjpeg - 
-a library for reading and writing JPEG2000 image files.
-.SP
-.SH SYNOPSIS
-.P
-.B #include <openjpeg.h>
-.P
-.SS CONVERSION FORMATS
-.B PGX: imagetopgx() \fR/\fB pgxtoimage()
-.P
-.B PXM: imagetopnm() \fR/\fB pnmtoimage()
-.P
-.B BMP: imagetobmp() \fR/\fB bmptoimage()
-.P
-.B TIF: imagetotif() \fR/\fB tiftoimage()
-.P
-.B RAW: imagetoraw() \fR/\fB rawtoimage()
-.P
-.B TGA: imagetotga() \fR/\fB tgatoimage()
-.P
-.B PNG: imagetopng() \fR/\fB pngtoimage()
-.P
-.B YUV: imagetoyuv() \fR/\fB yuvtoimage() \fR(MJ2) 
-.P
-.SS READ
-.B opj_set_default_decoder_parameters(opj_dparameters_t *\fIparams\fB);
-.P
-.B opj_dinfo_t *opj_create_decompress(OPJ_CODEC_FORMAT \fIformat\fB);
-.P
-.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
-.P
-.B void opj_setup_decoder(opj_dinfo_t *\fIdinfo\fB, opj_dparameters_t * \fIparams\fB);
-.P
-.B opj_cio_t *opj_cio_open(opj_common_ptr \fIinfo\fB, unsigned char *\fIbuf\fB, int \fIbuf_len\fB);
-.P
-.B opj_image_t *opj_decode(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB);
-.P
-.B void opj_cio_close(opj_cio_t *\fIcio\fB);
-.P
-.B void opj_destroy_decompress(opj_dinfo_t *\fIdinfo\fB);
-.P
-.B void opj_image_destroy(opj_image_t *\fIimage\fB);
-.P
-.SS WRITE
-.B void opj_set_default_encoder_parameters(opj_cparameters_t *\fIparams\fB);
-.P
-/*
-.B opj_image_t *FORMATtoimage(const char *\fIfname\fB, opj_cparameters_t *\fIparams\fB);
-.P
-*/
-.br
-.B opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT \fIformat\fB);
-.P
-.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
-.P
-.B void opj_setup_encoder(opj_cinfo_t *\fIcinfo\fB, opj_cparameters_t *\fIparams\fB, opj_image_t *\fIimage\fB);
-.P
-.B opj_cio_t *opj_cio_open(opj_common_ptr \fIcinfo\fB, \fINULL\fB, \fI0\fB);
-.P
-.B  bool opj_encode(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, char *\fIindex\fB);
-.P
-.B void opj_cio_close(opj_cio_t *\fIcio\fB);
-.P
-.B void opj_destroy_compress(opj_cinfo_t *\fIcinfo\fB);
-.P
-.B void opj_image_destroy(opj_image_t *\fIimage\fB);
-.P
-.SS GENERAL
-.P
-.B void opj_image_create(int \fInumcmpts\fB, opj_image_cmptparm_t *\fIcmptparms\fB, OPJ_COLOR_SPACE \fIclrspc\fB);
-.P
-.B int cio_tell(opj_cio_t *\fIcio\fB);
-.P
-.B void cio_seek(opj_cio_t *\fIcio\fB, int \fIpos\fB);
-.P
-.B opj_image_t *opj_decode_with_info(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB, opj_codestream_info_t *\fIcstr_info\fB);
-.P
-.B bool opj_encode_with_info(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, opj_codestream_info_t *\fIcstr_info\fB);
-.P
-.B void opj_destroy_cstr_info(opj_codestream_info_t *\fIcstr_info\fB);
-.P
-.B const char *opj_version(\fIvoid\fB);
-.P
-.SH OPJ_CODEC_FORMAT
-.P
-.B CODEC_J2K\fR or \fBCODEC_JPT\fR or \fBCODEC_JP2
-.P
-.SH OPJ_COLOR_SPACE
-.P
-.B CLRSPC_UNKNOWN\fR or \fBCLRSPC_UNSPECIFIED\fR or \fBCLRSPC_SRGB\fR or \fBCLRSPC_GRAY\fR or \fBCLRSPC_SYCC
-.P
-.SH DECOMPRESSION PARAMETERS
-.p
-typedef struct opj_dparameters 
-.br
-{
-    /*
-    Set the number of highest resolution levels to be discarded.
-    The image resolution is effectively divided by 2 to the power 
-    of the number of discarded levels.
-    The reduce factor is limited by the smallest total number of 
-    decomposition levels among tiles.
-    if != 0, then original dimension divided by 2^(reduce);
-    if == 0 or not used, image is decoded to the full resolution
-    */
-    \fBint\fR cp_reduce;
-    /*
-    Set the maximum number of quality layers to decode.
-    If there are less quality layers than the specified number, 
-    all the quality layers are decoded.
-    if != 0, then only the first "layer" layers are decoded;
-    if == 0 or not used, all the quality layers are decoded
-    */
-    \fBint\fR cp_layer;
-
-    /*command line encoder parameters (not used inside the library) */
-    /* input file name */
-    \fBchar\fR infile[OPJ_PATH_LEN];
-    /* output file name */
-    \fBchar\fR outfile[OPJ_PATH_LEN];
-    /* input file format: see OPJ_CODEC_FORMAT */
-    \fBint\fR decod_format;
-    /* output file format */
-    \fBint\fR cod_format;
-
-    /*JPWL decoding parameters */
-    /* activates the JPWL correction capabilities */
-    \fBbool\fR jpwl_correct;
-    /* expected number of components */
-    \fBint\fR jpwl_exp_comps;
-    /* maximum number of tiles */
-    \fBint\fR jpwl_max_tiles;
-
-    /*
-    Specify whether the decoding should be done on the entire 
-    codestream, or be limited to the main header
-    Limiting the decoding to the main header makes it possible 
-    to extract the characteristics of the codestream
-    if == NO_LIMITATION, the entire codestream is decoded;
-    if == LIMIT_TO_MAIN_HEADER, only the main header is decoded;
-    */
-    \fBOPJ_LIMIT_DECODING\fR cp_limit_decoding;
-.br
-} opj_dparameters_t;
-
-.SH COMPRESSION PARAMETERS
-.P
-typedef struct opj_cparameters 
-.br
-{
-    /* size of tile: tile_size_on = false (not in argument) 
-    or tile_size_on = true (in argument) */
-    \fBbool\fR tile_size_on;
-    /* XTOsiz */
-    \fBint\fR cp_tx0;
-    /* YTOsiz */
-    \fBint\fR cp_ty0;
-    /* XTsiz */
-    \fBint\fR cp_tdx;
-    /* YTsiz */
-    \fBint\fR cp_tdy;
-    /* allocation by rate/distortion */
-    \fBint\fR cp_disto_alloc;
-    /* allocation by fixed layer */
-    \fBint\fR cp_fixed_alloc;
-    /* add fixed_quality */
-    \fBint\fR cp_fixed_quality;
-    /* fixed layer */
-    \fBint *\fRcp_matrice;
-    /* comment for coding */
-    \fBchar *\fRcp_comment;
-    /* coding style */
-    \fBint\fR csty;
-    /* progression order:
-       PROG_UNKNOWN, LRCP(default), RLCP, RPCL, PCRL, CPRL */
-    \fBOPJ_PROG_ORDER\fR prog_order;
-    /* progression order changes */
-    \fBopj_poc_t\fR POC[32];
-    /* number of progression order changes (POC), default: 0 */
-    \fBint\fR numpocs;
-    /* number of layers */
-    \fBint\fR tcp_numlayers;
-    /* rates of layers */
-    \fBfloat\fR tcp_rates[100];
-    /* different psnr for successive layers */
-    \fBfloat\fR tcp_distoratio[100];
-    /* number of resolutions */
-    \fBint\fR numresolution;
-    /* initial code block width, default: 64 */
-    \fBint\fR cblockw_init;
-    /* initial code block height, default: 64 */
-    \fBint\fR cblockh_init;
-    /* mode switch (cblk_style) */
-    /* 1 : use the irreversible DWT 9-7, 
-        0 : use lossless compression (default) */
-    \fBint\fR irreversible;
-    /* region of interest: affected component in [0..3], 
-        -1 means no ROI */
-    \fBint\fR roi_compno;
-    /* region of interest: upshift value */
-    \fBint\fR roi_shift;
-    /* number of precinct size specifications */
-    \fBint\fR res_spec;
-    /* initial precinct width */
-    \fBint\fR prcw_init[J2K_MAXRLVLS];
-    /* initial precinct height */
-    \fBint\fR prch_init[J2K_MAXRLVLS];
-
-    /*command line encoder parameters (not used inside the library) */
-    /* input file name */
-    \fBchar\fR infile[OPJ_PATH_LEN];
-    /* output file name */
-    \fBchar\fR outfile[OPJ_PATH_LEN];
-    /* DEPRECATED. Index generation is now handeld with the 
-        opj_encode_with_info() function. Set to NULL */
-    \fBint\fR index_on;
-    /* DEPRECATED. Index generation is now handeld with the 
-        opj_encode_with_info() function. Set to NULL */
-    \fBchar\fR index[OPJ_PATH_LEN];
-    /* subimage encoding: origin image offset in x direction */
-    \fBint\fR image_offset_x0;
-    /* subimage encoding: origin image offset in y direction */
-    \fBint\fR image_offset_y0;
-    /* subsampling value for dx */
-    \fBint\fR subsampling_dx;
-    /* subsampling value for dy */
-    \fBint\fR subsampling_dy;
-    /* input file format */
-    \fBint\fR decod_format;
-    /* output file format: see OPJ_CODEC_FORMAT */
-    \fBint\fR cod_format;
-
-    /*JPWL encoding parameters */
-    /* enables writing of EPC in MH, thus activating JPWL */
-    \fBbool\fR jpwl_epc_on;
-    /* error protection method for MH (0,1,16,32,37-128) */
-    \fBint\fR jpwl_hprot_MH;
-    /* tile number of header protection specification (>=0) */
-    \fBint\fR jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-    /* error protection methods for TPHs (0,1,16,32,37-128) */
-    \fBint\fR jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
-    /* tile number of packet protection specification (>=0) */
-    \fBint\fR jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
-    /* packet number of packet protection specification (>=0) */
-    \fBint\fR jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
-    /* error protection methods for packets (0,1,16,32,37-128) */
-    \fBint\fR jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
-    /* enables writing of ESD, (0=no/1/2 bytes) */
-    \fBint\fR jpwl_sens_size;
-    /* sensitivity addressing size (0=auto/2/4 bytes) */
-    \fBint\fR jpwl_sens_addr;
-    /* sensitivity range (0-3) */
-    \fBint\fR jpwl_sens_range;
-    /* sensitivity method for MH (-1=no,0-7) */
-    \fBint\fR jpwl_sens_MH;
-    /* tile number of sensitivity specification (>=0) */
-    \fBint\fR jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-    /* sensitivity methods for TPHs (-1=no,0-7) */
-    \fBint\fR jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
-
-    /* Digital Cinema compliance: OFF-not compliant, 
-       CINEMA2K_24, CINEMA2K_48, CINEMA4K_24 */
-    \fBOPJ_CINEMA_MODE\fR cp_cinema;
-    /* Maximum rate for each component. 
-        If == 0, component size limitation is not considered */
-    \fBint\fR max_comp_size;
-    /* Profile name*/
-    \fBOPJ_RSIZ_CAPABILITIES\fR cp_rsiz;
-    /* Tile part generation*/
-    \fBchar\fR tp_on;
-    /* Flag for Tile part generation*/
-    \fBchar\fR tp_flag;
-    /* MCT (multiple component transform) */
-    \fBchar\fR tcp_mct;
-.br
-} opj_cparameters_t;
-
-
-'\".SH OPTIONS
-'\".SH BUGS
-.SH AUTHORS
-Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
-
-Copyright (c) 2002-2007, Professor Benoit Macq
-
-Copyright (c) 2001-2003, David Janssens
-
-Copyright (c) 2002-2003, Yannick Verschueren
-
-Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
-
-Copyright (c) 2005, Herve Drolon, FreeImage Team
-
-Copyright (c) 2006-2007, Parvatha Elangovan
-
-.P
-.SH "SEE ALSO"
-\fBimage_to_j2k\fR(1) \fBj2k_to_image\fR(1) \fBj2k_dump\fR(1)
-
-\fBJPWL_image_to_j2k\fR(1) \fBJPWL_j2k_to_image\fR(1)
-
-\fBextract_j2k_from_mj2\fR(1) \fBwrap_j2k_in_mj2\fR(1) 
-\fBframes_to_mj2\fR(1) \fBmj2_to_frames\fR(1)
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/CMakeLists.txt
deleted file mode 100644
index 2d8e6c4..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# index_create
-
-add_executable(index_create
-bio.c cio.c int.c pi.c t2.c tgt.c tcd.c index_create.c jpip.c jp2.c
-)
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/bio.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/bio.c
deleted file mode 100644
index 2c989e5..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/bio.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "bio.h"
-#include <setjmp.h>
-
-static unsigned char *bio_start, *bio_end, *bio_bp;
-static unsigned int bio_buf;
-static int bio_ct;
-
-extern jmp_buf j2k_error;
-
-/// <summary>
-/// Number of bytes written.
-/// </summary>
-int bio_numbytes() {
-    return bio_bp-bio_start;
-}
-
-/// <summary>
-/// Init decoder.
-/// </summary>
-/// <param name="bp">Input buffer</param>
-/// <param name="len">Input buffer length</param>
-void bio_init_dec(unsigned char *bp, int len) {
-    bio_start=bp;
-    bio_end=bp+len;
-    bio_bp=bp;
-    bio_buf=0;
-    bio_ct=0;
-}
-
-int bio_byteout()
-{
-	bio_buf = (bio_buf << 8) & 0xffff;
-	bio_ct = bio_buf == 0xff00 ? 7 : 8;
-	if (bio_bp >= bio_end)
-		return 1;
-	*bio_bp++ = bio_buf >> 8;
-	return 0;
-}
-
-/// <summary>
-/// Read byte. 
-/// </summary>
-int bio_bytein() {
-    bio_buf=(bio_buf<<8)&0xffff;
-    bio_ct=bio_buf==0xff00?7:8;
-    if (bio_bp>=bio_end) return 1; //longjmp(j2k_error, 1);
-    bio_buf|=*bio_bp++;
-    return 0;
-}
-
-/// <summary>
-/// Read bit.
-/// </summary>
-int bio_getbit() {
-    if (bio_ct==0) {
-        bio_bytein();
-    }
-    bio_ct--;
-    return (bio_buf>>bio_ct)&1;
-}
-
-/// <summary>
-/// Read bits.
-/// </summary>
-/// <param name="n">Number of bits to read</param>
-int bio_read(int n) {
-    int i, v;
-    v=0;
-    for (i=n-1; i>=0; i--) {
-        v+=bio_getbit()<<i;
-    }
-    return v;
-}
-
-/// <summary>
-/// Flush bits.
-/// </summary>
-int bio_flush() {
-    bio_ct=0;
-    bio_byteout();
-    if (bio_ct==7) {
-        bio_ct=0;
-       if ( bio_byteout()) return 1;;
-    }
-    return 0;
-}
-
-/// <summary>
-/// </summary>
-int bio_inalign() {
-    bio_ct=0;
-    if ((bio_buf&0xff)==0xff) {
-       if( bio_bytein()) return 1;
-        bio_ct=0;
-    }
-    return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.c
deleted file mode 100644
index 29f160e..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "cio.h"
-#include <setjmp.h>
-
-static unsigned char *cio_start, *cio_end, *cio_bp;
-
-extern jmp_buf j2k_error;
-
-/// <summary>
-/// Number of bytes written.
-/// </summary>
-int cio_numbytes() {
-    return cio_bp-cio_start;
-}
-
-/// <summary>
-/// Get position in byte stream.
-/// </summary>
-int cio_tell() {
-    return cio_bp-cio_start;
-}
-
-/// <summary>
-/// Set position in byte stream.
-/// </summary>
-void cio_seek(int pos) {
-    cio_bp=cio_start+pos;
-}
-
-/// <summary>
-/// Number of bytes left before the end of the stream.
-/// </summary>
-int cio_numbytesleft() {
-    return cio_end-cio_bp;
-}
-
-/// <summary>
-/// Get pointer to the current position in the stream.
-/// </summary>
-unsigned char *cio_getbp() {
-    return cio_bp;
-}
-
-/// <summary>
-/// Initialize byte IO.
-/// </summary>
-void cio_init(unsigned char *bp, int len) {
-    cio_start=bp;
-    cio_end=bp+len;
-    cio_bp=bp;
-}
-
-/// <summary>
-/// Write a byte.
-/// </summary>
-void cio_byteout(unsigned char v) {
-  if (cio_bp>=cio_end) longjmp(j2k_error, 1);
-  *cio_bp++=v;
-    
-}
-
-/// <summary>
-/// Read a byte.
-/// </summary>
-unsigned char cio_bytein() {
-    if (cio_bp>=cio_end) longjmp(j2k_error, 1);
-    return *cio_bp++;
-}
-
-/// <summary>
-/// Write a byte.
-/// </summary>
-//void cio_write(unsigned int v, int n) {
-void cio_write(long long v, int n) {
-    int i;
-    for (i=n-1; i>=0; i--) 
-      {
-	cio_byteout((unsigned char)((v>>(i<<3))&0xff));
-      }
-}
-
-/// <summary>
-/// Read some bytes.
-/// </summary>
-/* unsigned int cio_read(int n) { */
-long long cio_read(int n) {
-    int i;
-    /*unsigned int v;*/
-    long long v;
-    v=0;
-    for (i=n-1; i>=0; i--) {
-      v+=cio_bytein()<<(i<<3);
-    }
-    return v;
-}
-
-/// <summary>
-/// Write some bytes.
-/// </summary>
-void cio_skip(int n) {
-    cio_bp+=n;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.h
deleted file mode 100644
index 3e29789..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/cio.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __CIO_H
-#define __CIO_H
-
-int cio_tell();
-void cio_seek(int pos);
-int cio_numbytes();
-int cio_numbytesleft();
-unsigned char *cio_getbp();
-void cio_init(unsigned char *bp, int len);
-/* void cio_write(unsigned int v, int n); */
-void cio_write(long long v, int n);
-/* unsigned int cio_read(int n); */
-long long cio_read(int n);
-void cio_skip(int n);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.c
deleted file mode 100644
index 6bf08c6..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "fix.h"
-
-#ifdef _WIN32
-#include <windows.h>
-
-#define int64 __int64
-#else
-#define int64 long long
-#endif /* _WIN32 */
-
-/// <summary>
-/// Multiply two fixed-precision rational numbers.
-/// </summary>
-int fix_mul(int a, int b) {
-    return (int)((int64)a*(int64)b>>13);
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.h
deleted file mode 100644
index 4b6e1b5..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/fix.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __FIX_H
-#define __FIX_H
-
-int fix_mul(int a, int b);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/index_create.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/index_create.c
deleted file mode 100644
index 518e70f..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/index_create.c
+++ /dev/null
@@ -1,1219 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <setjmp.h>
-#include <math.h>
-
-#include "j2k.h"
-#include "cio.h"
-#include "tcd.h"
-#include "int.h"
-#include "jpip.h"
-#include "jp2.h"
-
-#define J2K_MS_SOC 0xff4f
-#define J2K_MS_SOT 0xff90
-#define J2K_MS_SOD 0xff93
-#define J2K_MS_EOC 0xffd9
-#define J2K_MS_SIZ 0xff51
-#define J2K_MS_COD 0xff52
-#define J2K_MS_COC 0xff53
-#define J2K_MS_RGN 0xff5e
-#define J2K_MS_QCD 0xff5c
-#define J2K_MS_QCC 0xff5d
-#define J2K_MS_POC 0xff5f
-#define J2K_MS_TLM 0xff55
-#define J2K_MS_PLM 0xff57
-#define J2K_MS_PLT 0xff58
-#define J2K_MS_PPM 0xff60
-#define J2K_MS_PPT 0xff61
-#define J2K_MS_SOP 0xff91
-#define J2K_MS_EPH 0xff92
-#define J2K_MS_CRG 0xff63
-#define J2K_MS_COM 0xff64
-
-#define J2K_STATE_MHSOC 0x0001
-#define J2K_STATE_MHSIZ 0x0002
-#define J2K_STATE_MH 0x0004
-#define J2K_STATE_TPHSOT 0x0008
-#define J2K_STATE_TPH 0x0010
-#define J2K_STATE_MT 0x0020
-
-#define START_NB 5
-#define INCREMENT 5
-
-jmp_buf j2k_error;
-
-static int j2k_state;
-static int j2k_curtileno;
-static j2k_tcp_t j2k_default_tcp;
-static unsigned char *j2k_eot;
-
-static j2k_image_t *j2k_img;
-static j2k_cp_t *j2k_cp;
-
-static unsigned char **j2k_tile_data;
-static int *j2k_tile_len;
-
-static info_image_t img;
-
-
-void j2k_clean() {
-  int tileno = 0;
-  int compno=0, resno=0, precno=0;
-
-  tcd_free(j2k_img, j2k_cp);
-  for (tileno = 0; tileno < j2k_cp->tw * j2k_cp->th; tileno++) {
-    info_tile_t *tile_Idx = &img.tile[tileno];
-    
-    for (compno = 0; compno < img.Comp; compno++)
-      {
-	info_compo_t *compo_Idx = &tile_Idx->compo[compno];
-	for(resno = 0; resno < img.Decomposition + 1; resno++)
-	  {
-	    info_reso_t *reso_Idx = &compo_Idx->reso[resno];
-	    for (precno = 0; precno < img.tile[tileno].pw * img.tile[tileno].ph; precno++)
-	      {
-		info_prec_t *prec_Idx = &reso_Idx->prec[precno];
-		free(prec_Idx->layer);
-	      }
-	    free(reso_Idx->prec);
-	  }
-	free(compo_Idx->reso);
-      }
-    free(tile_Idx->compo);
-    free(tile_Idx->marker);
-    free(tile_Idx->tile_parts);
-    free(tile_Idx->marker_mul.COC);
-    free(tile_Idx->marker_mul.RGN);
-    free(tile_Idx->marker_mul.QCC);
-    free(tile_Idx->marker_mul.PLT);
-    free(tile_Idx->marker_mul.PPT);
-    free(tile_Idx->marker_mul.COM);
-}
-  free(img.tile);
-  free(img.marker);
-  free(img.marker_mul.COC);
-  free(img.marker_mul.RGN);
-  free(img.marker_mul.QCC);
-  free(img.marker_mul.PLM);
-  free(img.marker_mul.PPM);
-  free(img.marker_mul.COM);
-}
-
-
-
-void j2k_read_soc() {
-  j2k_state=J2K_STATE_MHSIZ;
-}
-
-
-
-void j2k_read_siz() {
-    int len, i;
-    info_tile_t *tile;
-
-    len = cio_read(2);
-
-    /* <INDEX> [MHIX BOX] */
-    img.marker[img.num_marker].type = J2K_MS_SIZ;
-    img.marker[img.num_marker].start_pos = cio_tell()-2;
-    img.marker[img.num_marker].len = len;
-    img.num_marker++;
-    /* </INDEX> [MHIX BOX] */
-    
-    cio_read(2);                      /* Rsiz (capabilities) */
-    j2k_img->x1 = cio_read(4);        /* Xsiz                */
-    j2k_img->y1 = cio_read(4);        /* Ysiz                */
-    j2k_img->x0 = cio_read(4);        /* X0siz               */
-    j2k_img->y0 = cio_read(4);        /* Y0siz               */
-    j2k_cp->tdx = cio_read(4);        /* XTsiz               */
-    j2k_cp->tdy = cio_read(4);        /* YTsiz               */
-    j2k_cp->tx0 = cio_read(4);        /* XT0siz              */
-    j2k_cp->ty0 = cio_read(4);        /* YTOsiz              */
-
-    j2k_img->numcomps = cio_read(2);  /* Csiz                */
-    j2k_img->comps = (j2k_comp_t*)malloc(j2k_img->numcomps * sizeof(j2k_comp_t));
-    for (i = 0; i < j2k_img->numcomps; i++) {
-        int tmp, w, h;
-        tmp = cio_read(1);
-        j2k_img->comps[i].prec = (tmp & 0x7f) + 1;
-        j2k_img->comps[i].sgnd = tmp >> 7;
-        j2k_img->comps[i].dx = cio_read(1);
-        j2k_img->comps[i].dy = cio_read(1);
-        w = int_ceildiv(j2k_img->x1-j2k_img->x0, j2k_img->comps[i].dx);
-        h = int_ceildiv(j2k_img->y1-j2k_img->y0, j2k_img->comps[i].dy);
-        j2k_img->comps[i].data = (int*)malloc(sizeof(int) * w * h);
-    }
-    j2k_cp->tw = int_ceildiv(j2k_img->x1 - j2k_cp->tx0, j2k_cp->tdx);
-    j2k_cp->th = int_ceildiv(j2k_img->y1 - j2k_cp->ty0, j2k_cp->tdy);
-
-    j2k_cp->tcps = (j2k_tcp_t*)calloc((j2k_cp->tw * j2k_cp->th), sizeof(j2k_tcp_t));
-
-    for (i = 0; i < j2k_cp->tw * j2k_cp->th; i++)
-      {
-	j2k_cp->tcps[i].POC = 0;
-	j2k_cp->tcps[i].numpocs = 0;
-	// j2k_cp->tcps[i].first=1;
-      }
-
-    /* Initialization for PPM marker */
-    j2k_cp->ppm = 0;
-    j2k_cp->ppm_data = NULL;
-    j2k_cp->ppm_previous = 0;
-    j2k_cp->ppm_store = 0;
-
-    j2k_default_tcp.tccps = (j2k_tccp_t*)malloc(j2k_img->numcomps * sizeof(j2k_tccp_t));
-    for (i = 0; i < j2k_cp->tw * j2k_cp->th; i++) {
-	j2k_cp->tcps[i].tccps = (j2k_tccp_t*)malloc(j2k_img->numcomps * sizeof(j2k_tccp_t));
-    }
-    j2k_tile_data = (unsigned char**)calloc(j2k_cp->tw * j2k_cp->th, sizeof(char*));
-    j2k_tile_len = (int*)calloc(j2k_cp->tw * j2k_cp->th, sizeof(int));
-    j2k_state = J2K_STATE_MH;
-
-    /* <INDEX> */
-    img.Im_w = j2k_img->x1 - j2k_img->x0;
-    img.Im_h = j2k_img->y1 - j2k_img->y0;
-    img.Tile_x = j2k_cp->tdx;
-    img.Tile_y = j2k_cp->tdy;
-    img.Comp = j2k_img->numcomps;
-    img.tw = j2k_cp->tw;
-    img.th = j2k_cp->th;
-    img.tile = (info_tile_t*)malloc(img.tw * img.th * sizeof(info_tile_t));
-
-    for (i = 0; i < img.tw * img.th; i++)
-      {
-	tile = &img.tile[i];
-	tile->marker = (info_marker_t*)malloc(32 * sizeof(info_marker_t));
-	tile->num_marker = 0;
-	tile->marker_mul.num_COC = 0;
-	tile->marker_mul.CzCOC = START_NB;
-	tile->marker_mul.num_RGN = 0;
-	tile->marker_mul.CzRGN = START_NB;
-	tile->marker_mul.num_QCC = 0;
-	tile->marker_mul.CzQCC = START_NB;
-	tile->marker_mul.num_PLT = 0;
-	tile->marker_mul.CzPLT = START_NB;
-	tile->marker_mul.num_PPT = 0;
-	tile->marker_mul.CzPPT = START_NB;
-	tile->marker_mul.num_COM = 0;
-	tile->marker_mul.CzCOM = START_NB;
-      }
-    /* </INDEX> */
-
-
- }
-
-void j2k_read_com() {
-    int len;
-    info_tile_t *tile;
-    info_marker_t *tmp;
-
-    len = cio_read(2);
-
-    /* <INDEX> [MHIX BOX] */
-    if (j2k_state == J2K_STATE_MH)
-      {
-	if (!img.marker_mul.num_COM) 
-	  img.marker_mul.COM = (info_marker_t*)malloc(img.marker_mul.CzCOM * sizeof(info_marker_t));
-	if (img.marker_mul.num_COM >= img.marker_mul.CzCOM)
-	  {
-	    tmp = (info_marker_t*)malloc(2 * img.marker_mul.CzCOM * sizeof(info_marker_t));
-	    memcpy(tmp,img.marker_mul.COM,img.marker_mul.CzCOM);
-	    img.marker_mul.CzCOM *= 2;
-	    free(img.marker_mul.COM);
-	    img.marker_mul.COM = tmp;
-	  }
-
-	img.marker_mul.COM[img.marker_mul.num_COM].type = J2K_MS_COM;
-	img.marker_mul.COM[img.marker_mul.num_COM].start_pos = cio_tell()-2;
-	img.marker_mul.COM[img.marker_mul.num_COM].len = len;
-	img.marker_mul.num_COM++;
-      } else
-	{
-	  tile = &img.tile[j2k_curtileno];
-	  if (!tile->marker_mul.num_COM)
-	    tile->marker_mul.COM = (info_marker_t*)calloc(START_NB, sizeof(info_marker_t));
-	  if (tile->marker_mul.num_COM >= tile->marker_mul.CzCOM)
-	    {
-	      tmp = (info_marker_t*)malloc(2 * tile->marker_mul.CzCOM * sizeof(info_marker_t));
-	      memcpy(tmp,tile->marker_mul.COM,tile->marker_mul.CzCOM);
-	      tile->marker_mul.CzCOM *= 2;
-	      free(tile->marker_mul.COM);
-	      tile->marker_mul.COM = tmp;
-	    }
-	  tile->marker_mul.COM[tile->marker_mul.num_COM].type = J2K_MS_COM;
-	  tile->marker_mul.COM[tile->marker_mul.num_COM].start_pos = cio_tell()-2;
-	  tile->marker_mul.COM[tile->marker_mul.num_COM].len = len;
-	  tile->marker_mul.num_COM++;
-	}
-    /* </INDEX> [MHIX BOX] */
-
-    cio_skip(len - 2);
-}
-
-
-
-
-void j2k_read_cox(int compno) {
-    int i;
-    j2k_tcp_t *tcp;
-    j2k_tccp_t *tccp;
-
-    tcp = j2k_state == J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
-    tccp = &tcp->tccps[compno];
-    tccp->numresolutions = cio_read(1) + 1;
-
-    img.Decomposition = tccp->numresolutions - 1; /* <INDEX> */
-
-    tccp->cblkw = cio_read(1) + 2;
-    tccp->cblkh = cio_read(1) + 2;
-    tccp->cblksty = cio_read(1);
-    tccp->qmfbid = cio_read(1);
-    if (tccp->csty&J2K_CP_CSTY_PRT) {
-        for (i = 0; i < tccp->numresolutions; i++) {
-            int tmp = cio_read(1);
-            tccp->prcw[i] = tmp&0xf;
-            tccp->prch[i] = tmp>>4; 
-        }
-    }
-}
-
-
-
-
-void j2k_read_cod() {
-    int len, i, pos;
-    j2k_tcp_t *tcp;
-    info_tile_t *tile;
-
-    tcp = j2k_state == J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
-    len = cio_read(2);
-
-    /* <INDEX> [MHIX BOX] */
-    if (j2k_state == J2K_STATE_MH)
-      {
-	img.marker[img.num_marker].type = J2K_MS_SIZ;
-	img.marker[img.num_marker].start_pos = cio_tell()-2;
-	img.marker[img.num_marker].len = len;
-	img.num_marker++;
-      }
-    else
-      {
-	tile = &img.tile[j2k_curtileno];
-	tile->marker[tile->num_marker].type = J2K_MS_SIZ;
-	tile->marker[tile->num_marker].start_pos = cio_tell()-2;
-	tile->marker[tile->num_marker].len = len;
-	tile->num_marker++;
-  }
-    /* </INDEX> [MHIX BOX] */
-    
-    tcp->csty = cio_read(1);
-    tcp->prg = cio_read(1);
-    tcp->numlayers = cio_read(2);
-    tcp->mct = cio_read(1);
-
-    pos = cio_tell();
-    for (i = 0; i < j2k_img->numcomps; i++) {
-        tcp->tccps[i].csty = tcp->csty&J2K_CP_CSTY_PRT;
-        cio_seek(pos);
-        j2k_read_cox(i);
-    }
-    
-    /* <INDEX> */
-    img.Prog = tcp->prg;
-    img.Layer = tcp->numlayers;
-    /* </INDEX> */
-}
-
-
-
-
-void j2k_read_coc() {
-    int len, compno;
-    j2k_tcp_t *tcp;
-    info_tile_t *tile;
-    info_marker_t *tmp;
-
-    tcp = j2k_state == J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
-    len = cio_read(2);
-    
-    /* <INDEX> [MHIX BOX] */
-    if (j2k_state == J2K_STATE_MH)
-      {
-	if (!img.marker_mul.num_COC)
-	  img.marker_mul.COC = (info_marker_t*)malloc(img.marker_mul.CzCOC * sizeof(info_marker_t));
-	if (img.marker_mul.num_COC >= img.marker_mul.CzCOC)
-	  {
-	    tmp = (info_marker_t*)malloc((INCREMENT + img.marker_mul.CzCOC) * sizeof(info_marker_t));
-	    memcpy(tmp,img.marker_mul.COC,img.marker_mul.CzCOC);
-	    img.marker_mul.CzCOC += INCREMENT;
-	    free(img.marker_mul.COC);
-	    img.marker_mul.COC = tmp;
-	  }
-	img.marker_mul.COC[img.marker_mul.num_COC].type = J2K_MS_COC;
-	img.marker_mul.COC[img.marker_mul.num_COC].start_pos = cio_tell()-2;
-	img.marker_mul.COC[img.marker_mul.num_COC].len = len;
-	img.marker_mul.num_COC++;
-      } else
-	{
-	  tile = &img.tile[j2k_curtileno];
-	  if (!tile->marker_mul.num_COC)
-	    tile->marker_mul.COC = (info_marker_t*)malloc(tile->marker_mul.CzCOC * sizeof(info_marker_t));
-	  if (tile->marker_mul.num_COC >= tile->marker_mul.CzCOC)
-	    {
-	      tmp = (info_marker_t*)malloc((INCREMENT + tile->marker_mul.CzCOC) * sizeof(info_marker_t));
-	      memcpy(tmp,tile->marker_mul.COC,tile->marker_mul.CzCOC);
-	      tile->marker_mul.CzCOC += INCREMENT;
-	      free(tile->marker_mul.COC);
-	      tile->marker_mul.COC = tmp;
-	    }
-	  tile->marker_mul.COC[tile->marker_mul.num_COC].type = J2K_MS_COC;
-	  tile->marker_mul.COC[tile->marker_mul.num_COC].start_pos = cio_tell() - 2;
-	  tile->marker_mul.COC[tile->marker_mul.num_COC].len = len;
-	  tile->marker_mul.num_COC++;
-	}
-    /* </INDEX> [MHIX BOX] */
-    
-    compno =cio_read(j2k_img->numcomps <= 256 ? 1 : 2);
-
-    tcp->tccps[compno].csty = cio_read(1);
-    j2k_read_cox(compno);
-}
-
-
-
-
-void j2k_read_qcx(int compno, int len) {
-    int tmp;
-    j2k_tcp_t *tcp;
-    j2k_tccp_t *tccp;
-    int bandno, numbands;
-
-    tcp = j2k_state == J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
-    tccp = &tcp->tccps[compno];
-    tmp = cio_read(1);
-    tccp->qntsty = tmp & 0x1f;
-    tccp->numgbits = tmp >> 5;
-    numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT ? len - 1 : (len - 1) / 2);
-    for (bandno = 0; bandno < numbands; bandno++) {
-        int expn, mant;
-        if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) { /* WHY STEPSIZES WHEN NOQNT ? */
-            expn = cio_read(1) >> 3;
-            mant = 0;
-        } else {
-            tmp = cio_read(2);
-            expn = tmp >> 11;
-            mant = tmp & 0x7ff;
-        }
-        tccp->stepsizes[bandno].expn = expn;
-        tccp->stepsizes[bandno].mant = mant;
-    }
-}
-
-
-
-
-void j2k_read_qcd() {
-    int len, i, pos;
-    info_tile_t *tile;
-
-    len = cio_read(2);    
-
-    /* <INDEX> [MHIX BOX] */
-    if (j2k_state == J2K_STATE_MH)
-      {
-	img.marker[img.num_marker].type = J2K_MS_QCD;
-	img.marker[img.num_marker].start_pos = cio_tell()-2;
-	img.marker[img.num_marker].len = len;
-	img.num_marker++;
-      }	 else
-	{
-	  tile = &img.tile[j2k_curtileno];
-	  tile->marker[tile->num_marker].type = J2K_MS_QCD;
-	  tile->marker[tile->num_marker].start_pos = cio_tell()-2;
-	  tile->marker[tile->num_marker].len = len;
-	  tile->num_marker++;
-	}
-    /* </INDEX> [MHIX BOX] */
-    
-    
-    pos=cio_tell();
-    for (i = 0; i < j2k_img->numcomps; i++) {
-        cio_seek(pos);
-        j2k_read_qcx(i, len - 2);
-    }
-}
-
-
-
-
-void j2k_read_qcc() {
-  int len, compno;
-  info_tile_t *tile;
-  info_marker_t *tmp;
-
-  len = cio_read(2);  
-  /* <INDEX> [MHIX BOX] */
-  if (j2k_state == J2K_STATE_MH)
-    {
-      if (!img.marker_mul.num_QCC)
-	img.marker_mul.QCC = (info_marker_t*)malloc(img.marker_mul.CzQCC * sizeof(info_marker_t));
-	if (img.marker_mul.num_QCC >= img.marker_mul.CzQCC)
-	  {
-	    tmp = (info_marker_t*)malloc((INCREMENT + img.marker_mul.CzQCC) * sizeof(info_marker_t));
-	    memcpy(tmp,img.marker_mul.QCC,img.marker_mul.CzQCC);
-	    img.marker_mul.CzQCC += INCREMENT;
-	    free(img.marker_mul.QCC);
-	    img.marker_mul.QCC = tmp;
-	  }
-      img.marker_mul.QCC[img.marker_mul.num_QCC].type = J2K_MS_QCC;
-      img.marker_mul.QCC[img.marker_mul.num_QCC].start_pos = cio_tell() - 2;
-      img.marker_mul.QCC[img.marker_mul.num_QCC].len = len;
-      img.marker_mul.num_QCC++;
-    } else
-      {
-	tile = &img.tile[j2k_curtileno];
-	if (!tile->marker_mul.num_QCC)
-	  tile->marker_mul.QCC = (info_marker_t*)malloc(tile->marker_mul.CzQCC * sizeof(info_marker_t));
-	if (tile->marker_mul.num_QCC >= tile->marker_mul.CzQCC)
-	  {
-	    tmp = (info_marker_t*)malloc((INCREMENT + tile->marker_mul.CzQCC) * sizeof(info_marker_t));
-	    memcpy(tmp,tile->marker_mul.QCC,tile->marker_mul.CzQCC);
-	    tile->marker_mul.CzQCC += INCREMENT;
-	    free(tile->marker_mul.QCC);
-	    tile->marker_mul.QCC = tmp;
-	  }
-	tile->marker_mul.QCC[tile->marker_mul.num_QCC].type = J2K_MS_QCC;
-	tile->marker_mul.QCC[tile->marker_mul.num_QCC].start_pos = cio_tell()-2;
-	tile->marker_mul.QCC[tile->marker_mul.num_QCC].len = len;
-	tile->marker_mul.num_QCC++;
-      }
-  /* </INDEX> [MHIX BOX] */
- 
-  compno = cio_read(j2k_img->numcomps <= 256 ? 1 : 2);
-  j2k_read_qcx(compno, len - 2 - (j2k_img->numcomps <= 256 ? 1 : 2));
-}
-
-
-
-
-void j2k_read_poc() {
-  int len, numpchgs, i, old_poc;
-  j2k_tcp_t *tcp;
-  j2k_tccp_t *tccp;
-  info_tile_t *tile;
-
-  tcp = j2k_state == J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
-  old_poc = tcp->POC ? tcp->numpocs+1 : 0;
-  tcp->POC = 1;
-  tccp = &tcp->tccps[0];
-  len = cio_read(2);
-  
-  /* <INDEX> [MHIX BOX] */
-  if (j2k_state == J2K_STATE_MH)
-    {
-      img.marker[img.num_marker].type = J2K_MS_POC;
-      img.marker[img.num_marker].start_pos = cio_tell()-2;
-      img.marker[img.num_marker].len = len;
-      img.num_marker++;
-    } else
-      {
-	tile = &img.tile[j2k_curtileno];
-	tile->marker[tile->num_marker].type = J2K_MS_POC;
-	tile->marker[tile->num_marker].start_pos = cio_tell()-2;
-	tile->marker[tile->num_marker].len = len;
-	tile->num_marker++;
-      }
-  /* </INDEX> [MHIX BOX] */
-
-    numpchgs = (len - 2) / (5 + 2 * (j2k_img->numcomps <= 256 ? 1 : 2));
-    for (i = 0; i < numpchgs; i++) {
-      j2k_poc_t *poc;
-      poc = &tcp->pocs[i];
-      poc->resno0 = cio_read(1);
-      poc->compno0 = cio_read(j2k_img->numcomps <= 256 ? 1 : 2);
-      poc->layno1 = int_min(cio_read(2), tcp->numlayers);
-      poc->resno1 = int_min(cio_read(1), tccp->numresolutions);
-      poc->compno1 = int_min(cio_read(j2k_img->numcomps <= 256 ? 1 : 2), j2k_img->numcomps);
-      poc->prg = cio_read(1);
-    }
-
-    tcp->numpocs = numpchgs + old_poc - 1;
-}
-
-
-
-
-void j2k_read_crg() {
-    int len, i, Xcrg_i, Ycrg_i;
-
-    len = cio_read(2);
-
-    /* <INDEX> [MHIX BOX] */
-    img.marker[img.num_marker].type = J2K_MS_CRG;
-    img.marker[img.num_marker].start_pos = cio_tell()-2;
-    img.marker[img.num_marker].len = len;
-    img.num_marker++;
-    /* </INDEX> [MHIX BOX] */
-
-    for (i = 0; i < j2k_img->numcomps; i++)
-      {  
-	Xcrg_i = cio_read(2);
-	Ycrg_i = cio_read(2);
-      }
-}
-
-
-
-
-void j2k_read_tlm() {
-    int len, Ztlm, Stlm, ST, SP, tile_tlm, i;
-    long int Ttlm_i, Ptlm_i;
-    info_marker_t *tmp;
-
-    len = cio_read(2);
-
-    /* <INDEX> [MHIX BOX] */
-    if (!img.marker_mul.num_TLM)
-      img.marker_mul.TLM = (info_marker_t*)malloc(img.marker_mul.CzTLM * sizeof(info_marker_t));
-    if (img.marker_mul.num_TLM >= img.marker_mul.CzTLM)
-      {
-	tmp = (info_marker_t*)malloc((INCREMENT + img.marker_mul.CzTLM) * sizeof(info_marker_t));
-	memcpy(tmp,img.marker_mul.TLM,img.marker_mul.CzTLM);
-	img.marker_mul.CzTLM += INCREMENT;
-	free(img.marker_mul.TLM);
-	img.marker_mul.TLM = tmp;
-      }
-    img.marker_mul.TLM[img.marker_mul.num_TLM].type = J2K_MS_TLM;
-    img.marker_mul.TLM[img.marker_mul.num_TLM].start_pos = cio_tell()-2;
-    img.marker_mul.TLM[img.marker_mul.num_TLM].len = len;
-    img.marker_mul.num_TLM++;
-    /* </INDEX> [MHIX BOX] */
-    
-    Ztlm = cio_read(1);
-    Stlm = cio_read(1);
-    ST = ((Stlm >> 4) & 0x01) + ((Stlm >> 4) & 0x02);
-    SP = (Stlm >> 6) & 0x01;
-    tile_tlm = (len - 4) / ((SP + 1) * 2 + ST);
-    for (i = 0; i < tile_tlm; i++)
-      {
-	Ttlm_i = cio_read(ST);
-	Ptlm_i = cio_read(SP ? 4 : 2);
-      }
-}
-
-
-
-
-void j2k_read_plm() {
-    int len, i, Z_plm, N_plm, add, packet_len=0;
-    info_marker_t *tmp;
-
-    len=cio_read(2);
-
-    /* <INDEX> [MHIX BOX] */
-    if (!img.marker_mul.num_PLM)
-      img.marker_mul.PLM = (info_marker_t*)malloc(img.marker_mul.CzPLM * sizeof(info_marker_t));
-    if (img.marker_mul.num_PLM >= img.marker_mul.CzPLM)
-      {
-	tmp = (info_marker_t*)malloc((INCREMENT + img.marker_mul.CzPLM) * sizeof(info_marker_t));
-	memcpy(tmp,img.marker_mul.PLM,img.marker_mul.CzPLM);
-	img.marker_mul.CzPLM += INCREMENT;
-	free(img.marker_mul.PLM);
-	img.marker_mul.PLM = tmp;
-      }
-    img.marker_mul.PLM[img.marker_mul.num_PLM].type = J2K_MS_PLM;
-    img.marker_mul.PLM[img.marker_mul.num_PLM].start_pos = cio_tell()-2;
-    img.marker_mul.PLM[img.marker_mul.num_PLM].len = len;
-    img.marker_mul.num_PLM++;
-    /* </INDEX> [MHIX BOX] */
-
-    Z_plm = cio_read(1);
-    len -= 3;
-    while (len > 0)
-      {
-	N_plm = cio_read(4);
-	len -= 4;
-	for (i = N_plm ; i > 0 ; i--)
-	  {
-	    add = cio_read(1);
-	    len--;
-	    packet_len = (packet_len << 7) + add;
-	    if ((add & 0x80) == 0)
-	      {
-		/* New packet */
-		packet_len = 0;
-	      }
-	    if (len <= 0) break;
-	  } 
-      }
-}
-
-
-
-
-void j2k_read_plt() {
-    int len, i, Zplt, packet_len=0, add;
-    info_tile_t *tile;
-    info_marker_t *tmp;
-;
-    len = cio_read(2);
- 
-    /* <INDEX> [MHIX BOX] */
-    tile = &img.tile[j2k_curtileno];
-    if (!tile->marker_mul.num_PLT)
-      tile->marker_mul.PLT = (info_marker_t*)malloc(tile->marker_mul.CzPLT * sizeof(info_marker_t));
-    if (tile->marker_mul.num_PLT >= tile->marker_mul.CzPLT)
-      {
-	tmp = (info_marker_t*)malloc((INCREMENT + tile->marker_mul.CzPLT) * sizeof(info_marker_t));
-	memcpy(tmp,tile->marker_mul.PLT,tile->marker_mul.CzPLT);
-	tile->marker_mul.CzPLT += INCREMENT;
-	free(tile->marker_mul.PLT);
-	tile->marker_mul.PLT = tmp;
-      }
-
-    tile->marker_mul.PLT[tile->marker_mul.num_PLT].type = J2K_MS_PLT;
-    tile->marker_mul.PLT[tile->marker_mul.num_PLT].start_pos = cio_tell()-2;
-    tile->marker_mul.PLT[tile->marker_mul.num_PLT].len = len;
-    tile->marker_mul.num_PLT++;
-    /* </INDEX> [MHIX BOX] */
-    
-    Zplt = cio_read(1);
-    for (i = len-3; i > 0; i--)
-      {
-	add = cio_read(1);
-	packet_len = (packet_len << 7) + add;
-	if ((add & 0x80) == 0)
-	  {
-	    /* New packet */
-	    packet_len = 0;
-	  }
-      }
-}
-
-
-
-
-void j2k_read_ppm() {
-    int len, Z_ppm, i, j;
-    int N_ppm;
-    info_marker_t *tmp;
-
-    len = cio_read(2);
-    
-    /* <INDEX> [MHIX BOX] */
-    if (!img.marker_mul.num_PPM)
-      img.marker_mul.PPM = (info_marker_t*)malloc(img.marker_mul.CzPPM * sizeof(info_marker_t));
-    if (img.marker_mul.num_PPM >= img.marker_mul.CzPPM)
-      {
-	tmp = (info_marker_t*)malloc((INCREMENT + img.marker_mul.CzPPM) * sizeof(info_marker_t));
-	memcpy(tmp,img.marker_mul.PPM,img.marker_mul.CzPPM);
-	img.marker_mul.CzPPM += INCREMENT;
-	free(img.marker_mul.PPM);
-	img.marker_mul.PPM = tmp;
-      }
-    img.marker_mul.PLM[img.marker_mul.num_PPM].type = J2K_MS_PPM;
-    img.marker_mul.PLM[img.marker_mul.num_PPM].start_pos = cio_tell()-2;
-    img.marker_mul.PLM[img.marker_mul.num_PPM].len = len;
-    img.marker_mul.num_PPM++;
-    /* </INDEX> [MHIX BOX] */
-    
-    j2k_cp->ppm = 1;
-    
-    Z_ppm = cio_read(1); /* Z_ppm */
-    len -= 3;
-    while (len > 0)
-      {
-	if (j2k_cp->ppm_previous == 0)
-	  {
-	    N_ppm = cio_read(4); /* N_ppm */
-	    len -= 4;
-	  } else
-	    {
-	      N_ppm = j2k_cp->ppm_previous;
-	    }
-	
-	j = j2k_cp->ppm_store;
-	if (Z_ppm == 0) /* First PPM marker */
-	  j2k_cp->ppm_data = (unsigned char*)calloc(N_ppm, sizeof(unsigned char));
-	else      /* NON-first PPM marker */
-	  j2k_cp->ppm_data = (unsigned char*)realloc(j2k_cp->ppm_data, (N_ppm + j2k_cp->ppm_store) * sizeof(unsigned char));
-	
-	for (i = N_ppm ; i > 0 ; i--) /* Read packet header */
-	  {
-	    j2k_cp->ppm_data[j] = cio_read(1);
-	    j++;
-	    len--;
-	    if (len == 0) break; /* Case of non-finished packet header in present marker but finished in next one */
-	  }
-	
-	j2k_cp->ppm_previous = i - 1;
-	j2k_cp->ppm_store = j;
-      }
-}
-
-
-
-
-void j2k_read_ppt() {
-    int len, Z_ppt, i, j = 0;
-    j2k_tcp_t *tcp;
-    info_tile_t *tile;
-    len=cio_read(2);
-
-    /* <INDEX> [MHIX BOX] */
-    tile = & img.tile[j2k_curtileno];
-    tile->marker[tile->num_marker].type = J2K_MS_PPT;
-    tile->marker[tile->num_marker].start_pos = cio_tell()-2;
-    tile->marker[tile->num_marker].len = len;
-    tile->num_marker++;
-    /* </INDEX> [MHIX BOX] */
-
-    Z_ppt = cio_read(1);
-    tcp = &j2k_cp->tcps[j2k_curtileno];
-    tcp->ppt = 1;
-    if (Z_ppt == 0) /* First PPT marker */
-      {
-	tcp->ppt_data = (unsigned char*)calloc(len - 3, sizeof(unsigned char));
-	tcp->ppt_store = 0;
-      }
-    else      /* NON-first PPT marker */
-      tcp->ppt_data = (unsigned char*)realloc(tcp->ppt_data, (len - 3 + tcp->ppt_store) * sizeof(unsigned char));
-    
-    j = tcp->ppt_store;
-    for (i = len - 3 ; i > 0 ; i--)
-      {
-	tcp->ppt_data[j] = cio_read(1);
-	j++;
-      }
-    tcp->ppt_store = j;
-}
-
-
-
-
-void j2k_read_sot() {
-    int len, tileno, totlen, partno, numparts, i;
-    j2k_tcp_t *tcp;
-    j2k_tccp_t *tmp;
-    info_tile_t *tile;
-    info_tile_part_t *tilepart_tmp;
-    
- 
-    //fprintf(stderr,"SOT\n");
-    len = cio_read(2);
-    tileno = cio_read(2);
-    /* <INDEX> [MHIX BOX] */
-    tile = & img.tile[tileno];
-    tile->marker[tile->num_marker].type = J2K_MS_SOT;
-    tile->marker[tile->num_marker].start_pos = cio_tell() - 4;
-    tile->marker[tile->num_marker].len = len;
-    tile->num_marker++;
-    /* </INDEX> [MHIX BOX] */
- 
-    totlen = cio_read(4);
-    if (!totlen) totlen = cio_numbytesleft() + 8;
-    partno = cio_read(1);
-    numparts = cio_read(1);
-
-    /* <INDEX> */
-    if (tileno == 0 && partno == 0 ) 
-      img.Main_head_end = cio_tell() - 7;  /* Correction End = First byte of first SOT */
-    
-    img.tile[tileno].num_tile = tileno;
-    /* </INDEX> */
-  
-    tile->numparts = partno + 1;                                               /* INDEX : Number of tile_parts for the tile */ 
-    img.num_max_tile_parts = int_max(tile->numparts, img.num_max_tile_parts);  /* INDEX : Maximum number of tile_part per tile */
-
-    if (partno == 0)
-    {
-      tile->tile_parts = (info_tile_part_t*)malloc(START_NB * sizeof(info_tile_part_t*));
-      tile->Cztile_parts = START_NB;
-    }
-    if (partno >= tile->Cztile_parts)
-      {
-	tilepart_tmp = (info_tile_part_t*)malloc((INCREMENT + tile->Cztile_parts) * sizeof(info_tile_part_t));
-	memcpy(tilepart_tmp, tile->tile_parts, tile->Cztile_parts);
-	tile->Cztile_parts += INCREMENT;
-	free(tile->tile_parts);
-	tile->tile_parts = tilepart_tmp;
-      }
-
-    tile->tile_parts[partno].start_pos = cio_tell() - 12;        /* INDEX : start_pos of the tile_part       */
-    tile->tile_parts[partno].length = totlen;                    /* INDEX : length of the tile_part          */  
-    tile->tile_parts[partno].end_pos = totlen + cio_tell() - 12; /* INDEX : end position of the tile_part    */
-
-
-    j2k_curtileno = tileno;
-    j2k_eot = cio_getbp() - 12 + totlen;
-    j2k_state = J2K_STATE_TPH;
-    tcp = &j2k_cp->tcps[j2k_curtileno];
-    
-    tile->tile_parts[numparts].num_reso_AUX = tcp->tccps[0].numresolutions; /* INDEX : AUX value for TPIX       */
-
-     if (partno == 0)
-       //  if (tcp->first == 1) 
-      {
-	tmp = tcp->tccps;
-	*tcp = j2k_default_tcp;
-	/* Initialization PPT */
-	tcp->ppt = 0; 
-	tcp->ppt_data = NULL;
-	
-	tcp->tccps = tmp;
-	for (i = 0; i < j2k_img->numcomps; i++) {
-	  tcp->tccps[i] = j2k_default_tcp.tccps[i];
-	}
-	//j2k_cp->tcps[j2k_curtileno].first=0;
-      }
-}
-
-
-
-void j2k_read_rgn() {
-    int len, compno, roisty;
-    j2k_tcp_t *tcp;
-    info_tile_t *tile;
-    info_marker_t *tmp;
-    // fprintf(stderr,"RGN\n");
-    tcp = j2k_state == J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
-    len = cio_read(2);
-    
-    /* <INDEX> [MHIX BOX]*/
-    if (j2k_state == J2K_STATE_MH)
-      {
-	if (!img.marker_mul.num_RGN)
-	  img.marker_mul.RGN = (info_marker_t*)malloc(img.marker_mul.CzRGN * sizeof(info_marker_t));
-	if (img.marker_mul.num_RGN >= img.marker_mul.CzRGN)
-	  {
-	    tmp = (info_marker_t*)malloc((INCREMENT + img.marker_mul.CzRGN) * sizeof(info_marker_t));
-	    memcpy(tmp,img.marker_mul.RGN, img.marker_mul.CzRGN);
-	    img.marker_mul.CzRGN += INCREMENT;
-	    free(img.marker_mul.RGN);
-	    img.marker_mul.RGN = tmp;
-	  }
-	img.marker_mul.RGN[img.marker_mul.num_RGN].type = J2K_MS_RGN;
-	img.marker_mul.RGN[img.marker_mul.num_RGN].start_pos = cio_tell() - 2;
-	img.marker_mul.RGN[img.marker_mul.num_RGN].len = len;
-	img.marker_mul.num_RGN++;
-      } else
-      {
-	tile = &img.tile[j2k_curtileno];
-	if (!tile->marker_mul.num_RGN)
-	  tile->marker_mul.RGN = (info_marker_t*)malloc(tile->marker_mul.CzRGN * sizeof(info_marker_t));
-	if (tile->marker_mul.num_RGN >= tile->marker_mul.CzRGN)
-	  {
-	    tmp = (info_marker_t*)malloc((INCREMENT + tile->marker_mul.CzRGN) * sizeof(info_marker_t));
-	    memcpy(tmp,tile->marker_mul.RGN,tile->marker_mul.CzRGN);
-	    tile->marker_mul.CzRGN += INCREMENT;
-	    free(tile->marker_mul.RGN);
-	    tile->marker_mul.RGN = tmp;
-	  }
-
-	tile->marker_mul.RGN[tile->marker_mul.num_RGN].type = J2K_MS_RGN;
-	tile->marker_mul.RGN[tile->marker_mul.num_RGN].start_pos = cio_tell() - 2;
-        tile->marker_mul.RGN[tile->marker_mul.num_RGN].len = len;
-	tile->marker_mul.num_RGN++;
-      }
-    /* </INDEX> [MHIX BOX] */
-    
-    compno = cio_read(j2k_img->numcomps <= 256 ? 1 : 2);
-    roisty = cio_read(1);
-    tcp->tccps[compno].roishift = cio_read(1);
-}
-
-
-
-
-
-void j2k_read_sod() {
-    int len;
-    unsigned char *data;
-    info_tile_t *tile;
-    info_tile_part_t *tile_part;
-    // fprintf(stderr,"SOD\n");
-    /* <INDEX> [MHIX BOX] */
-    tile = &img.tile[j2k_curtileno];
-    tile->marker[tile->num_marker].type = J2K_MS_SOD;
-    tile->marker[tile->num_marker].start_pos = cio_tell();
-    tile->marker[tile->num_marker].len = 0;
-    tile->num_marker++;
-    /* </INDEX> [MHIX BOX] */
-
-    tile_part = &tile->tile_parts[tile->numparts - 1];                   /* INDEX : Current tilepart of a tile                  */
-    tile_part->length_header = cio_tell() - 1 - tile_part->start_pos;    /* INDEX : length of the tile-part header              */
-    tile_part->end_header = cio_tell() - 1;                              /* INDEX : end header position of the tile-part header */
-
-    len = int_min(j2k_eot - cio_getbp(), cio_numbytesleft());
-    
-    j2k_tile_len[j2k_curtileno] += len;
-    data = (unsigned char*)realloc(j2k_tile_data[j2k_curtileno], j2k_tile_len[j2k_curtileno]);   
-    memcpy(data, cio_getbp(), len);
-    j2k_tile_data[j2k_curtileno] = data;
-    cio_skip(len);
-    j2k_state = J2K_STATE_TPHSOT;
-}
-
-void j2k_read_eoc() {
-    int tileno;
-    tcd_init(j2k_img, j2k_cp, &img);
-    for (tileno = 0; tileno<j2k_cp->tw * j2k_cp->th; tileno++) {
-        tcd_decode_tile(j2k_tile_data[tileno], j2k_tile_len[tileno], tileno, &img);
-    }
-
-    j2k_state = J2K_STATE_MT;
-     longjmp(j2k_error, 1);
-}
-
-
-
-
-void j2k_read_unk() {
-    fprintf(stderr, "warning: unknown marker\n");
-}
-
-
-
-
-int j2k_index_JPIP(char *Idx_file, char *J2K_file, int len, int version){
-  FILE *dest;
-  unsigned char *index;
-  int pos_iptr, end_pos;
-  int len_cidx, pos_cidx;
-  int len_jp2c, pos_jp2c;
-  int len_fidx, pos_fidx;
-
-  dest=fopen(Idx_file, "wb");
-  if (!dest) {
-    fprintf(stderr, "Failed to open %s for reading !!\n", Idx_file);
-    return 0;
-  }
-
-  /* INDEX MODE JPIP */
- index = (unsigned char*)malloc(len); 
- cio_init(index, len);
- jp2_write_jp();
- jp2_write_ftyp();
- 
- jp2_write_jp2h(j2k_img);
- jp2_write_dbtl(Idx_file);
-
- pos_iptr=cio_tell();
- cio_skip(24); /* IPTR further ! */
- 
- pos_jp2c = cio_tell();
- len_jp2c = jp2_write_jp2c(J2K_file);
-
- pos_cidx = cio_tell();
- len_cidx = jpip_write_cidx(pos_jp2c + 8,img, j2k_cp, version); /* Correction len_jp2C --> pos_jp2c + 8 */  
-
- 
- pos_fidx = cio_tell();
- len_fidx = jpip_write_fidx(pos_jp2c, len_jp2c, pos_cidx, len_cidx);
-
-end_pos = cio_tell();
-
- cio_seek(pos_iptr);
- jpip_write_iptr(pos_fidx,len_fidx);
- cio_seek(end_pos);
- 
- fwrite(index, 1, cio_tell(), dest);
- free(index);
-
- fclose(dest);
- return 1;
-}
-
-
-
-typedef struct {
-  int id;
-    int states;
-    void (*handler)();
-} j2k_dec_mstabent_t;
-
-j2k_dec_mstabent_t j2k_dec_mstab[]={
-    {J2K_MS_SOC, J2K_STATE_MHSOC, j2k_read_soc},
-    {J2K_MS_SOT, J2K_STATE_MH|J2K_STATE_TPHSOT, j2k_read_sot},
-    {J2K_MS_SOD, J2K_STATE_TPH, j2k_read_sod},
-    {J2K_MS_EOC, J2K_STATE_TPHSOT, j2k_read_eoc},
-    {J2K_MS_SIZ, J2K_STATE_MHSIZ, j2k_read_siz},
-    {J2K_MS_COD, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_cod},
-    {J2K_MS_COC, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_coc},
-    {J2K_MS_RGN, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_rgn},
-    {J2K_MS_QCD, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_qcd},
-    {J2K_MS_QCC, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_qcc},
-    {J2K_MS_POC, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_poc},
-    {J2K_MS_TLM, J2K_STATE_MH, j2k_read_tlm},
-    {J2K_MS_PLM, J2K_STATE_MH, j2k_read_plm},
-    {J2K_MS_PLT, J2K_STATE_TPH, j2k_read_plt},
-    {J2K_MS_PPM, J2K_STATE_MH, j2k_read_ppm},
-    {J2K_MS_PPT, J2K_STATE_TPH, j2k_read_ppt},
-    {J2K_MS_SOP, 0, 0},
-    {J2K_MS_CRG, J2K_STATE_MH, j2k_read_crg},
-    {J2K_MS_COM, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_com},
-    {0, J2K_STATE_MH|J2K_STATE_TPH, j2k_read_unk}
-};
-
-j2k_dec_mstabent_t *j2k_dec_mstab_lookup(int id) {
-  j2k_dec_mstabent_t *e;
-  for (e = j2k_dec_mstab; e->id != 0; e++) {
-    if (e->id == id) {
-      break;
-    }
-  }
-  return e;
-}
-
-int j2k_decode(unsigned char *src, int len, j2k_image_t **image, j2k_cp_t **cp) {
-    if (setjmp(j2k_error)) {
-        if (j2k_state != J2K_STATE_MT) {
-            fprintf(stderr, "WARNING: incomplete bitstream\n");
-            return 0;
-        }
-        return cio_numbytes();
-    }
-    j2k_img = (j2k_image_t*)calloc(1, sizeof(j2k_image_t));
-    j2k_cp = (j2k_cp_t*)calloc(1, sizeof(j2k_cp_t));
-    *image = j2k_img;
-    *cp = j2k_cp;
-    j2k_state = J2K_STATE_MHSOC;
-    cio_init(src, len);
-    for (;;) {
-        j2k_dec_mstabent_t *e;
-        int id = cio_read(2);
-        if (id >> 8 != 0xff) {
-            fprintf(stderr, "%.8x: expected a marker instead of %x\n", cio_tell() - 2, id);
-            return 0;
-        }
-        e = j2k_dec_mstab_lookup(id);
-        if (!(j2k_state & e->states)) {
-            fprintf(stderr, "%.8x: unexpected marker %x\n", cio_tell() - 2, id);
-            return 0;
-        }
-        if (e->handler) {
-            (*e->handler)();
-        }
-    }
-
-}
-
-
-#ifdef _WIN32
-#include <windows.h>
-
-BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
-    switch (ul_reason_for_call) {
-		case DLL_PROCESS_ATTACH:
-		case DLL_THREAD_ATTACH:
-		case DLL_THREAD_DETACH:
-		case DLL_PROCESS_DETACH:
-			break;
-    }
-    return TRUE;
-}
-#endif /* _WIN32 */
-
-int main(int argc, char **argv)
-{  
-  FILE *src;
-  int totlen;
-  unsigned char *j2kfile;
-  j2k_image_t *imgg;
-  j2k_cp_t *cp;
-  int version;
-
-  if (argc != 4)
-    {
-      fprintf(stderr,"\nUSAGE : ./index_create J2K-file JP2-file version\n\nVersion : 0, 1, 2 or 3\n  0 : [faix] 4-byte and no AUX fields\n  1 : [faix] 8-byte and no AUX fields\n  2 : [faix] 4-byte and AUX fields\n  3 : [faix] 8-byte and AUX fields\n\nReference Document : annex I from JPIP-FCD-version 2 (SC 29 N5727)\n\n");
-      return 1;
-    }
-
-  src=fopen(argv[1], "rb");
-  if (!src) {
-    fprintf(stderr, "Failed to open %s for reading !!\n", argv[1]);
-    return 1;
-  }
-
-  /* length of the codestream */
-  fseek(src, 0, SEEK_END);
-  totlen = ftell(src);
-  fseek(src, 0, SEEK_SET);
-  
-  j2kfile = (unsigned char*)malloc(totlen);
-  fread(j2kfile, 1, totlen, src);
-  fclose(src);
-
-  img.marker = (info_marker_t*)malloc(32 * sizeof(info_marker_t));
-  img.num_marker = 0;
-  img.num_max_tile_parts = 0;
-  img.marker_mul.num_COC = 0;
-  img.marker_mul.CzCOC = START_NB;
-  img.marker_mul.num_RGN = 0;
-  img.marker_mul.CzRGN = START_NB;
-  img.marker_mul.num_QCC = 0;
-  img.marker_mul.CzQCC = START_NB;
-  img.marker_mul.num_TLM = 0;
-  img.marker_mul.CzTLM = START_NB;
-  img.marker_mul.num_PLM = 0;
-  img.marker_mul.CzPLM = START_NB;
-  img.marker_mul.num_PPM = 0;
-  img.marker_mul.CzPPM = START_NB;
-  img.marker_mul.num_COM = 0;
-  img.marker_mul.CzCOM = START_NB;
-
-  /* decode */ 
-
-  if (!j2k_decode(j2kfile, totlen, &imgg, &cp)) {
-    fprintf(stderr, "Index_creator: failed to decode image!\n");
-    free(j2kfile);
-    return 1;
-  }
-  free(j2kfile);
-  
-  // fseek(src, 0, SEEK_SET);
-  img.codestream_size = totlen;
-  sscanf(argv[3], "%d", &version);
-  if (version > 3)
-    {
-      fprintf(stderr,"Error : value of version unauthorized !!  Value accepted : 0, 1, 2 or 3 !!\n");
-      return 0;
-    }
-
-  j2k_index_JPIP(argv[2], argv[1], totlen * 2 > 60000 ? totlen * 2 : 60000, version);
-  
-  j2k_clean();
-  return 0;
-}
- 
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.c
deleted file mode 100644
index 29f778c..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/// <summary>
-/// Get the minimum of two integers.
-/// </summary>
-int int_min(int a, int b) {
-    return a<b?a:b;
-}
-
-/// <summary>
-/// Get the maximum of two integers.
-/// </summary>
-int int_max(int a, int b) {
-    return a>b?a:b;
-}
-
-/// <summary>
-/// Clamp an integer inside an interval.
-/// </summary>
-int int_clamp(int a, int min, int max) {
-    if (a<min) return min;
-    if (a>max) return max;
-    return a;
-}
-
-/// <summary>
-/// Get absolute value of integer.
-/// </summary>
-int int_abs(int a) {
-    return a<0?-a:a;
-}
-
-/// <summary>
-/// Divide an integer and round upwards.
-/// </summary>
-int int_ceildiv(int a, int b) {
-    return (a+b-1)/b;
-}
-
-/// <summary>
-/// Divide an integer by a power of 2 and round upwards.
-/// </summary>
-int int_ceildivpow2(int a, int b) {
-    return (a+(1<<b)-1)>>b;
-}
-
-/// <summary>
-/// Divide an integer by a power of 2 and round downwards.
-/// </summary>
-int int_floordivpow2(int a, int b) {
-    return a>>b;
-}
-
-/// <summary>
-/// Get logarithm of an integer and round downwards.
-/// </summary>
-int int_floorlog2(int a) {
-    int l;
-    for (l=0; a>1; l++) {
-        a>>=1;
-    }
-    return l;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.h
deleted file mode 100644
index 4921ff4..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/int.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __INT_H
-#define __INT_H
-
-int int_min(int a, int b);
-int int_max(int a, int b);
-int int_clamp(int a, int min, int max);
-int int_abs(int a);
-int int_ceildiv(int a, int b);
-int int_ceildivpow2(int a, int b);
-int int_floordivpow2(int a, int b);
-int int_floorlog2(int a);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/j2k.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/j2k.h
deleted file mode 100644
index 6c9a3c6..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/j2k.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved. 
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define VERSION "0.0.8"
-
-#ifdef _WIN32
-#ifdef LIBJ2K_EXPORTS
-#define LIBJ2K_API __declspec(dllexport)
-#else
-#define LIBJ2K_API __declspec(dllimport)
-#endif
-#else
-#define LIBJ2K_API
-#endif
-
-#ifndef __J2K_H
-#define __J2K_H
-
-#define J2K_MAXRLVLS 33
-#define J2K_MAXBANDS (3*J2K_MAXRLVLS+1)
-
-#define J2K_CP_CSTY_PRT 0x01
-#define J2K_CP_CSTY_SOP 0x02
-#define J2K_CP_CSTY_EPH 0x04
-#define J2K_CCP_CSTY_PRT 0x01
-#define J2K_CCP_CBLKSTY_LAZY 0x01
-#define J2K_CCP_CBLKSTY_RESET 0x02
-#define J2K_CCP_CBLKSTY_TERMALL 0x04
-#define J2K_CCP_CBLKSTY_VSC 0x08
-#define J2K_CCP_CBLKSTY_PTERM 0x10
-#define J2K_CCP_CBLKSTY_SEGSYM 0x20
-#define J2K_CCP_QNTSTY_NOQNT 0
-#define J2K_CCP_QNTSTY_SIQNT 1
-#define J2K_CCP_QNTSTY_SEQNT 2
-
-typedef struct 
-{
-  int dx, dy;   /* XRsiz, YRsiz            */
-  int prec;     /* precision               */
-  int bpp;      /* deapth of image in bits */
-  int sgnd;     /* signed                  */
-  int *data;    /* image-component data    */
-} j2k_comp_t;
-
-typedef struct {
-  int version;
-  int x0, y0;          /* XOsiz, YOsiz              */
-  int x1, y1;          /* Xsiz, Ysiz                */ 
-  int numcomps;        /* number of components      */
-  int index_on;        /* 0 = no index || 1 = index */
-  j2k_comp_t *comps;   /* image-components          */
-} j2k_image_t;
-
-typedef struct {
-  int expn;     /* exponent */
-  int mant;     /* mantissa */
-} j2k_stepsize_t;
-
-typedef struct {
-  int csty;                                /* coding style                          */
-  int numresolutions;                      /* number of resolutions                 */
-  int cblkw;                               /* width of code-blocks                  */
-  int cblkh;                               /* height of code-blocks                 */
-  int cblksty;                             /* code-block coding style               */
-  int qmfbid;                              /* discrete wavelet transform identifier */
-  int qntsty;                              /* quantisation style                    */
-  j2k_stepsize_t stepsizes[J2K_MAXBANDS];  /* stepsizes used for quantisation       */
-  int numgbits;                            /* number of guard bits                  */
-  int roishift;                            /* Region of Interest shift              */
-  int prcw[J2K_MAXRLVLS];                  /* Precinct width                        */
-  int prch[J2K_MAXRLVLS];                  /* Precinct height                       */
-} j2k_tccp_t;
-
-typedef struct {
-    int resno0, compno0; 
-    int layno1, resno1, compno1;
-    int prg;
-    int tile;
-    char progorder[4];
-} j2k_poc_t;
-
-typedef struct {
-  int csty;                  /* coding style                                                            */  
-  int prg;                   /* progression order                                                       */
-  int numlayers;             /* number of layers                                                        */
-  int mct;                   /* multi-component transform identifier                                    */
-  int rates[100];            /* rates of layers                                                         */
-  int numpocs;               /* number of progression order changes                                     */
-  int POC;                   /* Precise if a POC marker has been used O:NO, 1:YES                       */
-  j2k_poc_t pocs[32];        /* progression order changes                                               */
-  unsigned char *ppt_data;   /* packet header store there for futur use in t2_decode_packet             */
-  int ppt;                   /* If ppt == 1 --> there was a PPT marker for the present tile             */
-  int ppt_store;             /* Use in case of multiple marker PPT (number of info already store)       */
-  j2k_tccp_t *tccps;         /* tile-component coding parameters                                        */
-} j2k_tcp_t;
-
-typedef struct {
-  int tx0, ty0;              /* XTOsiz, YTOsiz                                                          */
-  int tdx, tdy;              /* XTsiz, YTsiz                                                            */
-  int tw, th;
-  unsigned char *ppm_data;   /* packet header store there for futur use in t2_decode_packet             */
-  int ppm;                   /* If ppm == 1 --> there was a PPM marker for the present tile             */
-  int ppm_store;             /* Use in case of multiple marker PPM (number of info already store)       */
-  int ppm_previous;          /* Use in case of multiple marker PPM (case on non-finished previous info) */
-  j2k_tcp_t *tcps;           /* tile coding parameters                                                  */
-} j2k_cp_t;
-
-
-
-
-
-/* Packet information : Layer level */
-typedef struct {  
-  int len;               /* Length of the body of the packet   */
-  int len_header;        /* Length of the header of the packet */
-  int offset;            /* Offset of the body of the packet   */
-  int offset_header;     /* Offset of the header of the packet */
-} info_layer_t;
-
-
-/* Access to packet information : precinct level */
-typedef struct {  
-  info_layer_t *layer;
-} info_prec_t;
-
-
-/* Access to packet information : resolution level */
-typedef struct {  
-  info_prec_t *prec;
-} info_reso_t;
-
-
-/* Access to packet information : component level */
-typedef struct {  
-  info_reso_t *reso;
-} info_compo_t;
-
-
-/* Information about the marker */
-typedef struct {
-  int type;       /* type of marker [SIZ, QCD, POC, PPM, CRG, COD] appearing only once */
-  int start_pos;  /* Start position of the marker                                      */
-  int len;        /* Length of the marker                                              */
-} info_marker_t;
-
-
-/* Multiple marker in tile header */
-typedef struct{
-  info_marker_t *COC;    /* COC markers                    */
-  int num_COC;           /* Number of COC marker           */
-  int CzCOC;             /* Current size of the vector COC */
-  
-  info_marker_t *RGN;    /* RGN markers                    */
-  int num_RGN;           /* Number of RGN marker           */
-  int CzRGN;             /* Current size of the vector RGN */
-  
-  info_marker_t *QCC;    /* QCC markers                    */
-  int num_QCC;           /* Number of QCC marker           */
-  int CzQCC;             /* Current size of the vector QCC */
-  
-  info_marker_t *PLT;    /* PLT markers                    */
-  int num_PLT;           /* Number of PLT marker           */
-  int CzPLT;             /* Current size of the vector PLT */
-  
-  info_marker_t *PPT;    /* PPT markers                    */
-  int num_PPT;           /* Number of PPT marker           */
-  int CzPPT;             /* Current size of the vector PPT */
-  
-  info_marker_t *COM;    /* COM markers                    */
-  int num_COM;           /* Number of COM marker           */
-  int CzCOM;             /* Current size of the vector COC */
-} info_marker_mul_tile_t; 
-
-
-/* Information about each tile_part for a particulary tile */
-typedef struct{
-  int start_pos;                      /* Start position of the tile_part       */ 
-  int length;                         /* Length of the tile_part header + body */
-  int length_header;                  /* Length of the header                  */
-  int end_pos;                        /* End position of the tile part         */
-  int end_header;                     /* End position of the tile part header  */
-
-  int num_reso_AUX;                   /* Number of resolution level completed  */
-} info_tile_part_t;
-
-
-/* Information about each tile */
-typedef struct {
-  int num_tile;                       /* Number of Tile                                                    */
-  int pw, ph;                         /* number of precinct by tile                                        */
-  int num_packet;                     /* number of packet in the tile                                      */
-  info_compo_t *compo;                /* component [packet]                                                */
-  
-  info_marker_t *marker;              /* information concerning markers inside image [only one apparition] */
-  info_marker_mul_tile_t marker_mul;  /* information concerning markers inside image [multiple apparition] */ 
-  int num_marker;                     /* number of marker                                                  */
-  
-  int numparts;                       /* number of tile_part for this tile                                 */
-  info_tile_part_t *tile_parts;       /* Information about each tile_part                                  */
-  int Cztile_parts;                   /* Current size of the tile_parts vector                             */
-} info_tile_t;                        /* index struct                                                      */
-
-
-/* Multiple marker in main header */
-typedef struct{
-  info_marker_t *COC;    /* COC markers                    */
-  int num_COC;           /* Number of COC marker           */
-  int CzCOC;             /* Current size of the vector COC */
- 
-  info_marker_t *RGN;    /* RGN markers                    */
-  int num_RGN;           /* Number of RGN marker           */
-  int CzRGN;             /* Current size of the vector RGN */
-  
-  info_marker_t *QCC;    /* QCC markers                    */
-  int num_QCC;           /* Number of QCC marker           */
-  int CzQCC;             /* Current size of the vector QCC */
-  
-  info_marker_t *TLM;    /* TLM markers                    */
-  int num_TLM;           /* Number of TLM marker           */
-  int CzTLM;             /* Current size of the vector TLM */
-  
-  info_marker_t *PLM;    /* PLM markers                    */
-  int num_PLM;           /* Number of PLM marker           */
-  int CzPLM;             /* Current size of the vector PLM */
-  
-  info_marker_t *PPM;    /* PPM markers                    */
-  int num_PPM;           /* Number of PPM marker           */
-  int CzPPM;             /* Current size of the vector PPM */
-  
-  info_marker_t *COM;    /* COM markers                    */
-  int num_COM;           /* Number of COM marker           */
-  int CzCOM;             /* Current size of the vector COM */
-} info_marker_mul_t; /* index struct */
-
-
-/* Information about image */
-typedef struct {
-  int Im_w, Im_h;                /* Image width and Height                                            */
-  int Tile_x, Tile_y;            /* Number of Tile in X and Y                                         */
-  int tw, th;
-  int pw, ph;                    /* nombre precinct in X and Y                                        */
-  int pdx, pdy;                  /* size of precinct in X and Y                                       */
-
-  int Prog;                      /* progression order                                                 */
-  int Comp;                      /* Component numbers                                                 */
-  int Layer;                     /* number of layer                                                   */
-  int Decomposition;             /* number of decomposition                                           */
-
-  int Main_head_end;             /* Main header position                                              */
-  int codestream_size;           /* codestream's size                                                 */
-
-  info_marker_t *marker;         /* information concerning markers inside image [only one apparition] */
-  info_marker_mul_t marker_mul;  /* information concerning markers inside image [multiple apparition] */ 
-  int num_marker;                /* number of marker                                                  */
-
-  int num_packet_max;            /* Maximum number of packet                                          */
-
-  int num_max_tile_parts;        /* Maximum number of tile-part                                       */
-  info_tile_t *tile;             /* information concerning tiles inside image                         */
-} info_image_t; /* index struct */
-
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.c
deleted file mode 100644
index ff2d22e..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2003-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "j2k.h"
-#include "cio.h"
-#include "tcd.h"
-#include "int.h"
-
-#define JPIP_JPIP 0x6a706970
-
-#define JP2_JP   0x6a502020
-#define JP2_FTYP 0x66747970
-#define JP2_JP2H 0x6a703268
-#define JP2_IHDR 0x69686472
-#define JP2_COLR 0x636f6c72
-#define JP2_JP2C 0x6a703263
-#define JP2_URL  0x75726c20
-#define JP2_DBTL 0x6474626c
-#define JP2_BPCC 0x62706363
-#define JP2      0x6a703220
-
-
-void jp2_write_url(char *Idx_file)
-{
-  int len, lenp; 
-  unsigned int i;
-  char str[256];
-
-  sprintf(str, "%s", Idx_file);
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_URL, 4);  // DBTL
-  cio_write(0,1);          // VERS
-  cio_write(0,3);          // FLAG
-
-  for (i=0; i<strlen(str); i++) {
-        cio_write(str[i], 1);
-    }
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         // L
-  cio_seek(lenp+len);
-}
-
-void jp2_write_dbtl(char *Idx_file)
-{
-  int len, lenp;
-
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_DBTL, 4);  // DBTL
-  cio_write(1,2);           // NDR : Only 1
-  
-  jp2_write_url(Idx_file); // URL Box
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         // L
-  cio_seek(lenp+len);
-}
-
-int jp2_write_ihdr(j2k_image_t *j2k_img)
-{
-  int len, lenp,i; 
-  int depth_0,depth, sign, BPC_ok=1;
-
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_IHDR, 4);  // IHDR
-
-  cio_write(j2k_img->y1-j2k_img->x0,4);   // HEIGHT
-  cio_write(j2k_img->x1-j2k_img->x0,4);   // WIDTH
-  cio_write(j2k_img->numcomps,2);   // NC
-
-  depth_0=j2k_img->comps[0].prec-1;
-  sign=j2k_img->comps[0].sgnd;
-
-  for(i=1;i<j2k_img->numcomps;i++)
-    {
-      depth=j2k_img->comps[i].prec-1;
-      sign=j2k_img->comps[i].sgnd;
-      if(depth_0!=depth) BPC_ok=0;
-    }
-  
-  if (BPC_ok)
-    cio_write(depth_0+(sign<<7),1);
-  else
-    cio_write(255,1);
-
-  cio_write(7,1);          // C : Always 7
-  cio_write(1,1);          // UnkC, colorspace unknow
-  cio_write(0,1);          // IPR, no intellectual property
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         // L
-  cio_seek(lenp+len);
-
-  return BPC_ok;
-}
-
-void jp2_write_bpcc(j2k_image_t *j2k_img)
-{
-  int len, lenp, i;
-  
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_BPCC, 4);  // BPCC
-  
-  for(i=0;i<j2k_img->numcomps;i++)
-    cio_write(j2k_img->comps[i].prec-1+(j2k_img->comps[i].sgnd<<7),1);
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         // L
-  cio_seek(lenp+len);
-}
-
-void jp2_write_colr(int BPC_ok, j2k_image_t *j2k_img)
-{
-  int len, lenp, meth;
-  
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_COLR, 4);  // COLR
-
-  if ((j2k_img->numcomps==1 || j2k_img->numcomps==3) && (BPC_ok && j2k_img->comps[0].prec==8))
-    meth=1;
-  else
-    meth=2;
-
-  cio_write(meth,1);       // METH
-  cio_write(0,1);          // PREC
-  cio_write(0,1);          // APPROX
-  
-  if (meth==1)
-    cio_write(j2k_img->numcomps>1?16:17,4);          // EnumCS
-
-  if (meth==2)
-    cio_write(0,1);        // PROFILE (??) 
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         // L
-  cio_seek(lenp+len);
-}
-
-/*
- * Write the JP2H box
- *
- * JP2 Header box
- *
- */
-void jp2_write_jp2h(j2k_image_t *j2k_img)
-{
-  int len, lenp, BPC_ok;
-  
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_JP2H, 4);           /* JP2H */
-
-  BPC_ok=jp2_write_ihdr(j2k_img);
-
-  if (!BPC_ok)
-    jp2_write_bpcc(j2k_img);
-  jp2_write_colr(BPC_ok, j2k_img);
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         /* L */
-  cio_seek(lenp+len);
-}
-
-/*
- * Write the FTYP box
- *
- * File type box
- *
- */
-void jp2_write_ftyp()
-{
-  int len, lenp;
-  
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_FTYP, 4);   /* FTYP       */
-
-  cio_write(JP2,4);         /* BR         */
-  cio_write(0,4);           /* MinV       */
-  cio_write(JP2,4);         /* CL0 : JP2  */
-  cio_write(JPIP_JPIP,4);   /* CL1 : JPIP */
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         /* L          */
-  cio_seek(lenp+len);
-}
-
-/*
- * Read the FTYP box
- *
- * File type box
- *
- */
-void jp2_read_ftyp(int length)
-{
-  int BR, MinV, type, i;
-
-  BR = cio_read(4);         /* BR              */
-  MinV = cio_read(4);       /* MinV            */
-  length-=8;
-  
-  for (i=length/4;i>0;i--)
-    type = cio_read(4);     /* CLi : JP2, JPIP */
-}
-
-int jp2_write_jp2c(char *J2K_file)
-{
-  int len, lenp, totlen, i;
-  FILE *src;
-  char *j2kfile;
-
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_JP2C, 4);  // JP2C
-
-  src=fopen(J2K_file, "rb");
-  fseek(src, 0, SEEK_END);
-  totlen=ftell(src);
-  fseek(src, 0, SEEK_SET);
-  
-  j2kfile=(char*)malloc(totlen);
-  fread(j2kfile, 1, totlen, src);
-  fclose(src);
-
-  for (i=0;i<totlen;i++)
-    cio_write(j2kfile[i],1);
-  
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         // L
-  cio_seek(lenp+len);
-  return lenp;
-}
-
-void jp2_write_jp()
-{
-  int len, lenp;
-  
-  lenp=cio_tell();
-  cio_skip(4);
-  cio_write(JP2_JP, 4);  // JP
-  cio_write(0x0d0a870a,4);
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len,4);         // L
-  cio_seek(lenp+len);
-}
-
-/*
- * Read the JP box
- *
- * JPEG 2000 signature
- *
- * return 1 if error else 0
- */
-int jp2_read_jp()
-{
-  if (0x0d0a870a!=cio_read(4))
-    return 1;
-  else
-    return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.h
deleted file mode 100644
index d5510f5..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jp2.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __JP2_H
-#define __JP2_H
-
-#include "j2k.h"
-
-void jp2_write_url(char *Idx_file);
-
-void jp2_write_dbtl(char *Idx_file);
-
-void jp2_write_jp2h(j2k_image_t *j2k_img);
-
-void jp2_write_ftyp();
-
-int jp2_write_jp2c(char *J2K_file);
-
-void jp2_write_jp();
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.c
deleted file mode 100644
index a86fbca..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.c
+++ /dev/null
@@ -1,768 +0,0 @@
-/*
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <setjmp.h>
-#include <math.h>
-
-#include "j2k.h"
-#include "cio.h"
-#include "tcd.h"
-#include "int.h"
-
-#define JPIP_CIDX 0x63696478   /* Codestream index                */
-#define JPIP_CPTR 0x63707472   /* Codestream Finder Box           */
-#define JPIP_MANF 0x6d616e66   /* Manifest Box                    */
-#define JPIP_FAIX 0x66616978   /* Fragment array Index box        */
-#define JPIP_MHIX 0x6d686978   /* Main Header Index Table         */
-#define JPIP_TPIX 0x74706978   /* Tile-part Index Table box       */
-#define JPIP_THIX 0x74686978   /* Tile header Index Table box     */
-#define JPIP_PPIX 0x70706978   /* Precinct Packet Index Table box */
-#define JPIP_PHIX 0x70686978   /* Packet Header index Table       */
-#define JPIP_FIDX 0x66696478   /* File Index                      */
-#define JPIP_FPTR 0x66707472   /* File Finder                     */
-#define JPIP_PRXY 0x70727879   /* Proxy boxes                     */
-#define JPIP_IPTR 0x69707472   /* Index finder box                */
-#define JPIP_PHLD 0x70686c64   /* Place holder                    */
-
-#define JP2C      0x6a703263
-
-//static info_marker_t marker_jpip[32], marker_local_jpip[32];  /* SIZE to precise ! */
-//static int num_marker_jpip, num_marker_local_jpip;
-
-/* 
- * Write the CPTR box
- *
- * Codestream finder box (box)
- *
- */
-void jpip_write_cptr(int offset, info_image_t img)
-{
-  int len, lenp;
-
-  lenp=cio_tell(); 
-  cio_skip(4);                       /* L [at the end]     */
-  cio_write(JPIP_CPTR,4);            /* T                  */
-  cio_write(0,2);                    /* DR  A PRECISER !!  */
-  cio_write(0,2);                    /* CONT               */
-  cio_write(offset,8);               /* COFF A PRECISER !! */
-  cio_write(img.codestream_size,8);  /* CLEN               */
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);                 /* L                  */
-  cio_seek(lenp+len);
-}
-
-/* 
- * Read the CPTR box
- *
- * Codestream finder box (box)
- *
- */
-void jpip_read_cptr()
-{
-  int DR, CONT;
-  long long Coff, codestream_size;
-
-  DR = cio_read(2);               /* DR   */
-  CONT = cio_read(2);             /* CONT */
-  Coff = cio_read(8);             /* COFF */
-  codestream_size = cio_read(8);  /* CLEN */
-}
-
-/* 
- * Write the MANF box
- *
- * Manifest box (box)
- *
- */
-void jpip_write_manf(int second, int v, info_marker_t *marker)
-{
-  int len, lenp, i;
-  lenp=cio_tell(); 
-  cio_skip(4);                         /* L [at the end]                    */
-  cio_write(JPIP_MANF,4);              /* T                                 */
-
-  if (second)                          /* Write only during the second pass */
-    {
-      for(i=0;i<v;i++)
-	{
-	  cio_write(marker[i].len,4);  /* Marker length                     */ 
-	  cio_write(marker[i].type,4); /* Marker type                       */
-	}
-    }
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);                   /* L                                 */
-  cio_seek(lenp+len);
-}
-
-/* 
- * Read the MANF box
- *
- * Manifest box (box)
- *
- */
-void jpip_read_manf(int len)
-{
-  int i, v, marker_len, marker_type;
-  
-  v = (len - 8)/ 8;
-  
-  for(i=0;i<v;i++)
-    {
-      marker_len = cio_read(4);       /* Marker length */ 
-      marker_type = cio_read(4);      /* Marker type   */
-    }
-}
-
-/* 
- * Write the MHIX box
- *
- * Main Header Index Table (box)
- *
- */
-int jpip_write_mhix(info_image_t img, int status, int tileno)
-{
-  int len, lenp, i;
-  info_tile_t *tile;
-  lenp=cio_tell();
-  cio_skip(4);                               /* L [at the end]                    */
-  cio_write(JPIP_MHIX, 4);                   /* MHIX                              */
-
-  if (status) /* MAIN HEADER */
-    {
-      cio_write(img.Main_head_end,8);        /* TLEN                              */
-      
-      for(i = 0; i < img.num_marker; i++)    /* Marker restricted to 1 apparition */
-	{
-	  cio_write(img.marker[i].type, 2);
-	  cio_write(0, 2);
-	  cio_write(img.marker[i].start_pos, 8);
-	  cio_write(img.marker[i].len, 2);
-	}
-      
-      /* Marker NOT restricted to 1 apparition */
-      for(i = img.marker_mul.num_COC - 1; i >= 0; i--) /* COC */
-	{
-	  cio_write(img.marker_mul.COC[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(img.marker_mul.COC[i].start_pos, 8);
-	  cio_write(img.marker_mul.COC[i].len, 2);
-	}
-      
-      for(i = img.marker_mul.num_RGN - 1; i >= 0; i--) /* RGN */
-	{
-	  cio_write(img.marker_mul.RGN[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(img.marker_mul.RGN[i].start_pos, 8);
-	  cio_write(img.marker_mul.RGN[i].len, 2);
-	}
-      
-      for(i = img.marker_mul.num_QCC - 1; i >= 0; i--) /* QCC */
-	{
-	  cio_write(img.marker_mul.QCC[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(img.marker_mul.QCC[i].start_pos, 8);
-	  cio_write(img.marker_mul.QCC[i].len, 2);
-	}
-      
-      for(i = img.marker_mul.num_TLM - 1; i >= 0; i--) /* TLM */
-	{
-	  cio_write(img.marker_mul.TLM[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(img.marker_mul.TLM[i].start_pos, 8);
-	  cio_write(img.marker_mul.TLM[i].len, 2);
-	}
-      
-      for(i = img.marker_mul.num_PLM - 1; i >= 0; i--) /* PLM */
-	{
-	  cio_write(img.marker_mul.PLM[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(img.marker_mul.PLM[i].start_pos, 8);
-	  cio_write(img.marker_mul.PLM[i].len, 2);
-	}
-      
-      for(i = img.marker_mul.num_PPM - 1; i >= 0; i--) /* PPM */
-	{
-	  cio_write(img.marker_mul.PPM[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(img.marker_mul.PPM[i].start_pos, 8);
-	  cio_write(img.marker_mul.PPM[i].len, 2);
-	}
-
-      for(i = img.marker_mul.num_COM - 1; i >= 0; i--) /* COM */
-	{
-	  cio_write(img.marker_mul.COM[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(img.marker_mul.COM[i].start_pos, 8);
-	  cio_write(img.marker_mul.COM[i].len, 2);
-	}
-    } 
-  else /* TILE HEADER */
-    {
-      tile = &img.tile[tileno];
-      cio_write(tile->tile_parts[0].length_header, 8);  /* TLEN                              */ 
-      
-      for(i = 0; i < tile->num_marker; i++)             /* Marker restricted to 1 apparition */
-	{
-	  cio_write(tile->marker[i].type, 2);
-	  cio_write(0, 2);
-	  cio_write(tile->marker[i].start_pos, 8);
-	  cio_write(tile->marker[i].len, 2);
-	}
-      
-      /* Marker NOT restricted to 1 apparition */
-      for(i = tile->marker_mul.num_COC - 1; i >= 0; i--) /* COC */
-	{
-	  cio_write(tile->marker_mul.COC[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(tile->marker_mul.COC[i].start_pos, 8);
-	  cio_write(tile->marker_mul.COC[i].len, 2);
-	}
-      
-      for(i = tile->marker_mul.num_RGN - 1; i >= 0; i--) /* RGN */
-	{
-	  cio_write(tile->marker_mul.RGN[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(tile->marker_mul.RGN[i].start_pos, 8);
-	  cio_write(tile->marker_mul.RGN[i].len, 2);
-	}
-      
-      for(i = tile->marker_mul.num_QCC - 1; i >= 0; i--) /* QCC */
-	{
-	  cio_write(tile->marker_mul.QCC[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(tile->marker_mul.QCC[i].start_pos, 8);
-	  cio_write(tile->marker_mul.QCC[i].len, 2);
-	}
-      
-      for(i = tile->marker_mul.num_PLT - 1; i >= 0; i--) /* PLT */
-	{
-	  cio_write(tile->marker_mul.PLT[i].type,2);
-	  cio_write(i,2);
-	  cio_write(tile->marker_mul.PLT[i].start_pos,8);
-	  cio_write(tile->marker_mul.PLT[i].len,2);
-	}
-      
-      for(i = tile->marker_mul.num_PPT - 1; i >= 0; i--) /* PPT */
-	{
-	  cio_write(tile->marker_mul.PPT[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(tile->marker_mul.PPT[i].start_pos, 8);
-	  cio_write(tile->marker_mul.PPT[i].len, 2);
-	}
-      
-      for(i = tile->marker_mul.num_COM - 1; i >= 0; i--) /* COM */
-	{
-	  cio_write(tile->marker_mul.COM[i].type, 2);
-	  cio_write(i, 2);
-	  cio_write(tile->marker_mul.COM[i].start_pos, 8);
-	  cio_write(tile->marker_mul.COM[i].len, 2);
-	} 
-    }      
-  
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);        /* L           */
-  cio_seek(lenp+len);
-  
-  return len;
-}
-
-/* 
- * Read the MHIX box
- *
- * Main Header Index Table (box)
- *
- */
-void jpip_read_mhix(int len)
-{
-  int i, v, marker_type, marker_start_pos, marker_len, marker_remains;
-
-  v = (len - 8) / 14;
-
-  for (i=0; i<v ; i++)
-    {
-      marker_type = cio_read(2);       /* Type of the marker               */ 
-      marker_remains = cio_read(2);    /* Number of same markers following */
-      marker_start_pos = cio_read(2);  /* Start position of the marker     */
-      marker_len = cio_read(2);        /* Length of the marker             */
-    }
-}
-
-/* 
- * Write the FAIX box
- *
- * Fragment array Index box (box)
- *
- */
-int jpip_write_faix(int v, int compno, info_image_t img, j2k_cp_t *j2k_cp, int version)
-{
-  int len, lenp, i, j;
-  /*int version = 0;*/
-  int tileno, resno, precno, layno, num_packet=0;
-
-  lenp=cio_tell();
-  cio_skip(4);              /* L [at the end]      */
-  cio_write(JPIP_FAIX, 4);  /* FAIX                */ 
-  cio_write(version,1);     /* Version 0 = 4 bytes */
-  
-  switch(v)
-    {
-    case 0:   /* TPIX */
-      cio_write(img.num_max_tile_parts,(version & 0x01)?8:4);                      /* NMAX           */
-      cio_write(img.tw*img.th,(version & 0x01)?8:4);                               /* M              */
-      for (i = 0; i < img.tw*img.th; i++)
-	{
-	  for (j = 0; j < img.tile[i].numparts ; j++)
-	    {
-	      cio_write(img.tile[i].tile_parts[j].start_pos,(version & 0x01)?8:4); /* start position */
-	      cio_write(img.tile[i].tile_parts[j].length,(version & 0x01)?8:4);    /* length         */
-	      if (version & 0x02)
-		cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4); /* Aux_i,j : Auxiliary value */
-	      //cio_write(0,4);
-	    }
-	  /* PADDING */
-	  while (j < img.num_max_tile_parts)
-	    {
-	      cio_write(0,(version & 0x01)?8:4); /* start position            */
-	      cio_write(0,(version & 0x01)?8:4); /* length                    */
-	      if (version & 0x02)
-		cio_write(0,4);                  /* Aux_i,j : Auxiliary value */
-	      j++;
-	    }
-	}
-      break;
-      
-      /*   case 1: */   /* THIX */
-      /* cio_write(1,(version & 0x01)?8:4);  */           /* NMAX */
-      /* cio_write(img.tw*img.th,(version & 0x01)?8:4); */ /* M    */
-      /* for (i=0;i<img.tw*img.th;i++) */
-      /* { */
-      /* cio_write(img.tile[i].start_pos,(version & 0x01)?8:4); */                         /* start position */
-      /* cio_write(img.tile[i].end_header-img.tile[i].start_pos,(version & 0x01)?8:4); */  /* length         */
-      /* if (version & 0x02)*/
-      /* cio_write(0,4); */ /* Aux_i,j : Auxiliary value */
-      /* } */
-      /* break; */
-
-    case 2:  /* PPIX  NOT FINISHED !! */
-      cio_write(img.num_packet_max,(version & 0x01)?8:4); /* NMAX */
-      cio_write(img.tw*img.th,(version & 0x01)?8:4);      /* M    */
-      for(tileno=0;tileno<img.tw*img.th;tileno++)
-	{
-	  info_tile_t *tile_Idx = &img.tile[tileno];
-	  info_compo_t *compo_Idx = &tile_Idx->compo[compno];
-	  int correction;
-	  
-	  num_packet=0;
-	  
-	  if(j2k_cp->tcps[tileno].csty&J2K_CP_CSTY_EPH)
-	    correction=3;
-	  else
-	    correction=1;
-	  for(resno=0;resno<img.Decomposition+1;resno++)
-	    {
-	      info_reso_t *reso_Idx = &compo_Idx->reso[resno];
-	      for (precno=0;precno<img.tile[tileno].pw*img.tile[tileno].ph;precno++)
-		{
-		  info_prec_t *prec_Idx = &reso_Idx->prec[precno];
-		  for(layno=0;layno<img.Layer;layno++)
-		    {
-		      info_layer_t *layer_Idx = &prec_Idx->layer[layno];
-		      cio_write(layer_Idx->offset,(version & 0x01)?8:4);                                   /* start position */
-		      cio_write((layer_Idx->len_header-correction)?0:layer_Idx->len,(version & 0x01)?8:4); /* length         */
-		      if (version & 0x02)
-			cio_write(0,4); /* Aux_i,j : Auxiliary value */
-		      num_packet++;
-		    }
-		}
-	    }
-	  /* PADDING */
-	  while (num_packet < img.num_packet_max)
-	    {
-	      cio_write(0,(version & 0x01)?8:4); /* start position            */
-	      cio_write(0,(version & 0x01)?8:4); /* length                    */
-	      if (version & 0x02)
-		cio_write(0,4);                  /* Aux_i,j : Auxiliary value */
-	      num_packet++;
-	    }
-	}
-      
-      break;
-      
-    case 3:  /* PHIX NOT FINISHED !! */
-      cio_write(img.num_packet_max,(version & 0x01)?8:4); /* NMAX */
-      cio_write(img.tw*img.th,(version & 0x01)?8:4);      /* M    */
-      for(tileno=0;tileno<img.tw*img.th;tileno++)
-	{
-	  info_tile_t *tile_Idx = &img.tile[tileno];
-	  info_compo_t *compo_Idx = &tile_Idx->compo[compno];
-	  int correction;
-
-	  num_packet = 0;
-	  if(j2k_cp->tcps[tileno].csty&J2K_CP_CSTY_EPH)
-	    correction=3;
-	  else
-	    correction=1;
-	  for(resno=0;resno<img.Decomposition+1;resno++)
-	    {
-	      info_reso_t *reso_Idx = &compo_Idx->reso[resno];
-	      for (precno=0;precno<img.tile[tileno].pw*img.tile[tileno].ph;precno++)
-		{
-		  info_prec_t *prec_Idx = &reso_Idx->prec[precno];
-		  for(layno=0;layno<img.Layer;layno++)
-		    {
-		      info_layer_t *layer_Idx = &prec_Idx->layer[layno];
-		      cio_write(layer_Idx->offset_header,(version & 0x01)?8:4);                                   /* start position */
-		      cio_write((layer_Idx->len_header-correction)?0:layer_Idx->len_header,(version & 0x01)?8:4); /* length         */
-		      if (version & 0x02)
-			cio_write(0,4); /* Aux_i,j : Auxiliary value */
-		      num_packet++;
-		    }
-		}
-	    }
-	  /* PADDING */
-	  while (num_packet<img.num_packet_max)
-	    {
-	      cio_write(0,(version & 0x01)?8:4); /* start position            */
-	      cio_write(0,(version & 0x01)?8:4); /* length                    */
-	      if (version & 0x02)
-		cio_write(0,4);                  /* Aux_i,j : Auxiliary value */
-	      num_packet++;
-	    }
-	}
-      break;
-    }
-  
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);        /* L  */
-  cio_seek(lenp+len);
-
-  return len;
-}
-
-/* 
- * Write the TPIX box
- *
- * Tile-part Index table box (superbox)
- *
- */
-int jpip_write_tpix(info_image_t img, j2k_cp_t *j2k_cp, int version)
-{
-  int len, lenp;
-  lenp=cio_tell();
-  cio_skip(4);              /* L [at the end] */
-  cio_write(JPIP_TPIX, 4);  /* TPIX           */
-  
-  jpip_write_faix(0,0,img, j2k_cp, version);
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);        /* L              */
-  cio_seek(lenp+len);
-
-  return len;
-}
-
-/* 
- * Write the THIX box
- *
- * Tile header Index table box (superbox)
- *
- */
-//int jpip_write_thix(info_image_t img, j2k_cp_t *j2k_cp)
-//  {
-//  int len, lenp;
-//  lenp=cio_tell();
-//  cio_skip(4);              /* L [at the end] */
-//  cio_write(JPIP_THIX, 4);  /* THIX           */
-  
-//  jpip_write_faix(1,0,img, j2k_cp);
-
-//  len=cio_tell()-lenp;
-//  cio_seek(lenp);
-//  cio_write(len, 4);        /* L              */
-//  cio_seek(lenp+len);
-
-//  return len;
-//}
-
-int jpip_write_thix(info_image_t img, j2k_cp_t *j2k_cp)
-{
-  int len, lenp, i;
-  int tileno;
-  info_marker_t *marker;
-  int num_marker_local_jpip;
-
-  marker = (info_marker_t*)calloc(sizeof(info_marker_t), j2k_cp->tw*j2k_cp->th);
-
-  for ( i = 0; i < 2 ; i++ )
-    {
-      if (i) cio_seek(lenp);
-      
-      lenp = cio_tell();
-      cio_skip(4);              /* L [at the end] */
-      cio_write(JPIP_THIX, 4);  /* THIX           */
-      jpip_write_manf(i, j2k_cp->tw*j2k_cp->th, marker);
-      num_marker_local_jpip=img.Comp;
-      
-      for (tileno = 0; tileno < j2k_cp->tw*j2k_cp->th; tileno++)
-	{
-	  marker[tileno].len = jpip_write_mhix(img, 1, tileno);
-	  marker[tileno].type = JPIP_MHIX;
-	}
-      
-      len=cio_tell()-lenp;
-      cio_seek(lenp);
-      cio_write(len, 4);        /* L              */
-      cio_seek(lenp+len);
-    }
-
-  free(marker);
-
-  return len;
-}
-/* 
- * Write the PPIX box
- *
- * Precinct Packet Index table box (superbox)
- *
- */
-int jpip_write_ppix(info_image_t img,j2k_cp_t *j2k_cp)
-{
-  int len, lenp, compno, i;
-  info_marker_t *marker;
-  int num_marker_local_jpip;
-  marker = (info_marker_t*)calloc(sizeof(info_marker_t), img.Comp);
-  
-  for (i=0;i<2;i++)
-    {
-      if (i) cio_seek(lenp);
-      
-      lenp=cio_tell();
-      cio_skip(4);              /* L [at the end] */
-      cio_write(JPIP_PPIX, 4);  /* PPIX           */
-      jpip_write_manf(i,img.Comp,marker);
-      num_marker_local_jpip=img.Comp;
-      
-      for (compno=0; compno<img.Comp; compno++)
-	{
-	  marker[compno].len=jpip_write_faix(2,compno,img, j2k_cp, 0);
-	  marker[compno].type=JPIP_FAIX;
-	}
-   
-      len=cio_tell()-lenp;
-      cio_seek(lenp);
-      cio_write(len, 4);        /* L              */
-      cio_seek(lenp+len);
-    }
-  
-  free(marker);
-
-  return len;
-}
-
-/* 
- * Write the PHIX box
- *
- * Packet Header Index table box (superbox)
- *
- */
-int jpip_write_phix(info_image_t img, j2k_cp_t *j2k_cp)
-{
-  int len, lenp=0, compno, i;
-  info_marker_t *marker;
-
-  marker = (info_marker_t*)calloc(sizeof(info_marker_t), img.Comp);
-
-  for (i=0;i<2;i++)
-    {
-      if (i) cio_seek(lenp);
-      
-      lenp=cio_tell();
-      cio_skip(4);              /* L [at the end] */
-      cio_write(JPIP_PHIX, 4);  /* PHIX           */
-      
-      jpip_write_manf(i,img.Comp,marker);
-
-      for (compno=0; compno<img.Comp; compno++)
-	{	
-	  marker[compno].len=jpip_write_faix(3,compno,img, j2k_cp, 0);
-	  marker[compno].type=JPIP_FAIX;
-	}
-
-      len=cio_tell()-lenp;
-      cio_seek(lenp);
-      cio_write(len, 4);        /* L              */
-      cio_seek(lenp+len);
-    }
-
-  free(marker);
-
-  return len;
-}
-
-/* 
- * Write the CIDX box
- *
- * Codestream Index box (superbox)
- *
- */
-int jpip_write_cidx(int offset, info_image_t img, j2k_cp_t *j2k_cp, int version)
-{
-  int len, lenp = 0, i;
-  info_marker_t *marker_jpip;
-  int num_marker_jpip = 0;
-
-  marker_jpip = (info_marker_t*)calloc(sizeof(info_marker_t), 32);
-
-  for (i=0;i<2;i++)
-    {
-      if(i)
-	cio_seek(lenp);
-
-      lenp=cio_tell();
-
-      cio_skip(4);              /* L [at the end] */
-      cio_write(JPIP_CIDX, 4);  /* CIDX           */
-      jpip_write_cptr(offset, img);
-
-      jpip_write_manf(i,num_marker_jpip, marker_jpip);
-
-      num_marker_jpip=0;
-      marker_jpip[num_marker_jpip].len=jpip_write_mhix(img, 0, 0);
-      marker_jpip[num_marker_jpip].type=JPIP_MHIX;
-      num_marker_jpip++;
-
-      marker_jpip[num_marker_jpip].len=jpip_write_tpix(img, j2k_cp, version);
-      marker_jpip[num_marker_jpip].type=JPIP_TPIX;
-      num_marker_jpip++;
-
-      marker_jpip[num_marker_jpip].len=jpip_write_thix(img, j2k_cp);
-      marker_jpip[num_marker_jpip].type=JPIP_THIX;
-      num_marker_jpip++;
-
-      marker_jpip[num_marker_jpip].len=jpip_write_ppix(img, j2k_cp);
-      marker_jpip[num_marker_jpip].type=JPIP_PPIX;
-      num_marker_jpip++;
-
-      marker_jpip[num_marker_jpip].len=jpip_write_phix(img, j2k_cp);
-      marker_jpip[num_marker_jpip].type=JPIP_PHIX;
-      num_marker_jpip++;
-
-      len=cio_tell()-lenp;
-      cio_seek(lenp);
-      cio_write(len, 4);        /* L             */
-      cio_seek(lenp+len);
-    }
-
-  free(marker_jpip);
-
-  return len;
-
-}
-
-/* 
- * Write the IPTR box
- *
- * Index Finder box
- *
- */
-void jpip_write_iptr(int offset, int length)
-{
-  int len, lenp;
-  lenp=cio_tell();
-  cio_skip(4);              /* L [at the end] */
-  cio_write(JPIP_IPTR, 4);  /* IPTR           */
-  
-  cio_write(offset,8);
-  cio_write(length,8);
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);        /* L             */
-  cio_seek(lenp+len);
-}
-
-/* 
- * Write the PRXY box
- *
- * proxy (box)
- *
- */
-void jpip_write_prxy(int offset_jp2c, int length_jp2c, int offset_idx, int length_idx)
-{
-  int len, lenp;
-  lenp=cio_tell();
-  cio_skip(4);              /* L [at the end] */
-  cio_write(JPIP_PRXY, 4);  /* IPTR           */
-  
-  cio_write(offset_jp2c,8); /* OOFF           */
-  cio_write(length_jp2c,4); /* OBH part 1     */
-  cio_write(JP2C,4);        /* OBH part 2     */
-  
-  cio_write(1,1);           /* NI             */
-
-  cio_write(offset_idx,8);  /* IOFF           */
-  cio_write(length_idx,4);  /* IBH part 1     */
-  cio_write(JPIP_CIDX,4);   /* IBH part 2     */
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);        /* L              */
-  cio_seek(lenp+len);
-}
-
-
-/* 
- * Write the FIDX box
- *
- * File Index (superbox)
- *
- */
-int jpip_write_fidx(int offset_jp2c, int length_jp2c, int offset_idx, int length_idx)
-{
-  int len, lenp;
-  lenp=cio_tell();
-  cio_skip(4);              /* L [at the end] */
-  cio_write(JPIP_FIDX, 4);  /* IPTR           */
-  
-  jpip_write_prxy(offset_jp2c, length_jp2c, offset_idx, offset_jp2c);
-
-  len=cio_tell()-lenp;
-  cio_seek(lenp);
-  cio_write(len, 4);        /* L              */
-  cio_seek(lenp+len);
-
-  return len;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.h
deleted file mode 100644
index 84df355..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/jpip.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __JPIP_H
-#define __JPIP_H
-
-#include "j2k.h"
-
-// Codestream index box (superbox)
-int jpip_write_cidx(int offset, info_image_t img, j2k_cp_t *j2k_cp, int version);
-
-// Index Finder Box
-void jpip_write_iptr(int offset, int length);
-
-// File Index Box
-int jpip_write_fidx(int offset_jp2c, int length_jp2c, int offset_idx, int length_idx);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.c
deleted file mode 100644
index 691ef49..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "pi.h"
-#include "int.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-
-/* <summary> */
-/* Create a packet iterator.   */
-/* </summary> */
-pi_iterator_t *pi_create(j2k_image_t * img, j2k_cp_t * cp, int tileno)
-{
-	int p, q;
-	int compno, resno, pino;
-	int maxres = 0;
-	pi_iterator_t *pi;
-	j2k_tcp_t *tcp;
-	j2k_tccp_t *tccp;
-
-	tcp = &cp->tcps[tileno];
-	pi = (pi_iterator_t *) malloc((tcp->numpocs + 1) * sizeof(pi_iterator_t));
-
-	for (pino = 0; pino < tcp->numpocs + 1; pino++) {	/* change */
-		p = tileno % cp->tw;
-		q = tileno / cp->tw;
-
-		pi[pino].tx0 = int_max(cp->tx0 + p * cp->tdx, img->x0);
-		pi[pino].ty0 = int_max(cp->ty0 + q * cp->tdy, img->y0);
-		pi[pino].tx1 = int_min(cp->tx0 + (p + 1) * cp->tdx, img->x1);
-		pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, img->y1);
-		pi[pino].numcomps = img->numcomps;
-		pi[pino].comps = (pi_comp_t *) malloc(img->numcomps * sizeof(pi_comp_t));
-
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			int tcx0, tcy0, tcx1, tcy1;
-			pi_comp_t *comp = &pi[pino].comps[compno];
-			tccp = &tcp->tccps[compno];
-			comp->dx = img->comps[compno].dx;
-			comp->dy = img->comps[compno].dy;
-			comp->numresolutions = tccp->numresolutions;
-			comp->resolutions =
-				(pi_resolution_t *) malloc(comp->numresolutions *
-																	 sizeof(pi_resolution_t));
-			tcx0 = int_ceildiv(pi->tx0, comp->dx);
-			tcy0 = int_ceildiv(pi->ty0, comp->dy);
-			tcx1 = int_ceildiv(pi->tx1, comp->dx);
-			tcy1 = int_ceildiv(pi->ty1, comp->dy);
-			if (comp->numresolutions > maxres) {
-				maxres = comp->numresolutions;
-			}
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int levelno;
-				int rx0, ry0, rx1, ry1;
-				int px0, py0, px1, py1;
-				pi_resolution_t *res = &comp->resolutions[resno];
-				if (tccp->csty & J2K_CCP_CSTY_PRT) {
-					res->pdx = tccp->prcw[resno];
-					res->pdy = tccp->prch[resno];
-				} else {
-					res->pdx = 15;
-					res->pdy = 15;
-				}
-				levelno = comp->numresolutions - 1 - resno;
-				rx0 = int_ceildivpow2(tcx0, levelno);
-				ry0 = int_ceildivpow2(tcy0, levelno);
-				rx1 = int_ceildivpow2(tcx1, levelno);
-				ry1 = int_ceildivpow2(tcy1, levelno);
-				px0 = int_floordivpow2(rx0, res->pdx) << res->pdx;
-				py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
-				px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
-				py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
-				res->pw = (px1 - px0) >> res->pdx;
-				res->ph = (py1 - py0) >> res->pdy;
-			}
-		}
-		
-		tccp = &tcp->tccps[0];
-		pi[pino].step_p=1;
-		pi[pino].step_c=100*pi[pino].step_p;
-		pi[pino].step_r=img->numcomps*pi[pino].step_c;
-		pi[pino].step_l=maxres*pi[pino].step_r;
-		
-		if (pino==0)
-		  pi[pino].include=(short int*)calloc(img->numcomps*maxres*tcp->numlayers*100,sizeof(short int));
-		else
-		  pi[pino].include=pi[pino-1].include;
-
-		/*if (pino == tcp->numpocs) {*/
-		  if (tcp->POC == 0) {
-			pi[pino].first = 1;
-			pi[pino].poc.resno0 = 0;
-			pi[pino].poc.compno0 = 0;
-			pi[pino].poc.layno1 = tcp->numlayers;
-			pi[pino].poc.resno1 = maxres;
-			pi[pino].poc.compno1 = img->numcomps;
-			pi[pino].poc.prg = tcp->prg;
-		} else {
-			pi[pino].first = 1;
-			pi[pino].poc.resno0 = tcp->pocs[pino].resno0;
-			pi[pino].poc.compno0 = tcp->pocs[pino].compno0;
-			pi[pino].poc.layno1 = tcp->pocs[pino].layno1;
-			pi[pino].poc.resno1 = tcp->pocs[pino].resno1;
-			pi[pino].poc.compno1 = tcp->pocs[pino].compno1;
-			pi[pino].poc.prg = tcp->pocs[pino].prg;
-		}
-	}
-	return pi;
-}
-
-/* <summary> */
-/* Get next packet in layer=resolution-component-precinct order.   */
-/* </summary> */
-int pi_next_lrcp(pi_iterator_t * pi)
-{
-	pi_comp_t *comp;
-	pi_resolution_t *res;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		res = &comp->resolutions[pi->resno];
-		goto skip;
-	} else {
-		pi->first = 0;
-	}
-	for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-		for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
-				 pi->resno++) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
-					 pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				if (pi->resno >= comp->numresolutions) {
-
-					continue;
-				}
-				res = &comp->resolutions[pi->resno];
-				for (pi->precno = 0; pi->precno < res->pw * res->ph; pi->precno++) {
-				  if (!pi->include[pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p]){
-				    pi->include[pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p] = 1;
-				    return 1;
-					}
-				skip:;
-				}
-			}
-		}
-	}
-	return 0;
-}
-
-/* <summary> */
-/* Get next packet in resolution-layer-component-precinct order.   */
-/* </summary> */
-int pi_next_rlcp(pi_iterator_t * pi)
-{
-	pi_comp_t *comp;
-	pi_resolution_t *res;
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		res = &comp->resolutions[pi->resno];
-		goto skip;
-	} else {
-		pi->first = 0;
-	}
-	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-		for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
-					 pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				if (pi->resno >= comp->numresolutions) {
-					continue;
-				}
-				res = &comp->resolutions[pi->resno];
-				for (pi->precno = 0; pi->precno < res->pw * res->ph; pi->precno++) {
-				  if (!pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
-				    pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
-				    return 1;
-				  }
-				skip:;
-				}
-			}
-		}
-	}
-	return 0;
-}
-
-/* <summary> */
-/* Get next packet in resolution-precinct-component-layer order.   */
-/* </summary> */
-int pi_next_rpcl(pi_iterator_t * pi)
-{
-	pi_comp_t *comp;
-	pi_resolution_t *res;
-	if (!pi->first) {
-		goto skip;
-	} else {
-		int compno, resno;
-		pi->first = 0;
-		pi->dx = 0;
-		pi->dy = 0;
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			comp = &pi->comps[compno];
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int dx, dy;
-				res = &comp->resolutions[resno];
-				dx =
-					comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-				dy =
-					comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-				pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-				pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-			}
-		}
-	}
-	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-		for (pi->y = pi->ty0; pi->y < pi->ty1;
-				 pi->y += pi->dy - (pi->y % pi->dy)) {
-			for (pi->x = pi->tx0; pi->x < pi->tx1;
-					 pi->x += pi->dx - (pi->x % pi->dx)) {
-				for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
-						 pi->compno++) {
-					int levelno;
-					int trx0, try0;
-					int rpx, rpy;
-					int prci, prcj;
-					comp = &pi->comps[pi->compno];
-					if (pi->resno >= comp->numresolutions) {
-						continue;
-					}
-					res = &comp->resolutions[pi->resno];
-					levelno = comp->numresolutions - 1 - pi->resno;
-					trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-					try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-					rpx = res->pdx + levelno;
-					rpy = res->pdy + levelno;
-					if (!
-							(pi->x % (comp->dx << rpx) == 0
-							 || (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
-						continue;
-					}
-					if (!
-							(pi->y % (comp->dy << rpy) == 0
-							 || (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
-						continue;
-					}
-					prci =
-						int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno),
-														 res->pdx) - int_floordivpow2(trx0, res->pdx);
-					prcj =
-						int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno),
-														 res->pdy) - int_floordivpow2(try0, res->pdy);
-					pi->precno = prci + prcj * res->pw;
-					for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-					  if (!pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
-					    pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
-					    return 1;
-						}
-					skip:;
-					}
-				}
-			}
-		}
-	}
-	return 0;
-}
-
-/* <summary> */
-/* Get next packet in precinct-component-resolution-layer order.   */
-/* </summary> */
-int pi_next_pcrl(pi_iterator_t * pi)
-{
-	pi_comp_t *comp;
-	pi_resolution_t *res;
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		goto skip;
-	} else {
-		int compno, resno;
-		pi->first = 0;
-		pi->dx = 0;
-		pi->dy = 0;
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			comp = &pi->comps[compno];
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int dx, dy;
-				res = &comp->resolutions[resno];
-				dx =
-					comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-				dy =
-					comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-				pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-				pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-			}
-		}
-	}
-	for (pi->y = pi->ty0; pi->y < pi->ty1;
-			 pi->y += pi->dy - (pi->y % pi->dy)) {
-		for (pi->x = pi->tx0; pi->x < pi->tx1;
-				 pi->x += pi->dx - (pi->x % pi->dx)) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
-					 pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				for (pi->resno = pi->poc.resno0;
-						 pi->resno < int_min(pi->poc.resno1, comp->numresolutions);
-						 pi->resno++) {
-					int levelno;
-					int trx0, try0;
-					int rpx, rpy;
-					int prci, prcj;
-					res = &comp->resolutions[pi->resno];
-					levelno = comp->numresolutions - 1 - pi->resno;
-					trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-					try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-					rpx = res->pdx + levelno;
-					rpy = res->pdy + levelno;
-					if (!
-							(pi->x % (comp->dx << rpx) == 0
-							 || (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
-						continue;
-					}
-					if (!
-							(pi->y % (comp->dy << rpy) == 0
-							 || (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
-						continue;
-					}
-					prci =
-						int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno),
-														 res->pdx) - int_floordivpow2(trx0, res->pdx);
-					prcj =
-						int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno),
-														 res->pdy) - int_floordivpow2(try0, res->pdy);
-					pi->precno = prci + prcj * res->pw;
-					for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-					  if (! pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
-					    pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
-							return 1;
-						}
-					skip:;
-					}
-				}
-			}
-		}
-	}
-	return 0;
-}
-
-/* <summary> */
-/* Get next packet in component-precinct-resolution-layer order.   */
-/* </summary> */
-int pi_next_cprl(pi_iterator_t * pi)
-{
-	pi_comp_t *comp;
-	pi_resolution_t *res;
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		goto skip;
-	} else {
-		pi->first = 0;
-	}
-	for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
-			 pi->compno++) {
-		int resno;
-		comp = &pi->comps[pi->compno];
-		pi->dx = 0;
-		pi->dy = 0;
-		for (resno = 0; resno < comp->numresolutions; resno++) {
-			int dx, dy;
-			res = &comp->resolutions[resno];
-			dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-			dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-			pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-			pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-		}
-		for (pi->y = pi->ty0; pi->y < pi->ty1;
-				 pi->y += pi->dy - (pi->y % pi->dy)) {
-			for (pi->x = pi->tx0; pi->x < pi->tx1;
-					 pi->x += pi->dx - (pi->x % pi->dx)) {
-				for (pi->resno = pi->poc.resno0;
-						 pi->resno < int_min(pi->poc.resno1, comp->numresolutions);
-						 pi->resno++) {
-					int levelno;
-					int trx0, try0;
-					int rpx, rpy;
-					int prci, prcj;
-					res = &comp->resolutions[pi->resno];
-					levelno = comp->numresolutions - 1 - pi->resno;
-					trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-					try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-					rpx = res->pdx + levelno;
-					rpy = res->pdy + levelno;
-					if (!
-							(pi->x % (comp->dx << rpx) == 0
-							 || (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
-						continue;
-					}
-					if (!
-							(pi->y % (comp->dy << rpy) == 0
-							 || (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
-						continue;
-					}
-					prci =
-						int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno),
-														 res->pdx) - int_floordivpow2(trx0, res->pdx);
-					prcj =
-						int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno),
-														 res->pdy) - int_floordivpow2(try0, res->pdy);
-					pi->precno = prci + prcj * res->pw;
-					for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-					  if (! pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
-					    pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
-					    return 1;
-						}
-					skip:;
-					}
-				}
-			}
-		}
-	}
-	return 0;
-}
-
-/* <summary> */
-/* Get next packet.   */
-/* </summary> */
-int pi_next(pi_iterator_t * pi)
-{
-	switch (pi->poc.prg) {
-	case 0:
-		return pi_next_lrcp(pi);
-	case 1:
-		return pi_next_rlcp(pi);
-	case 2:
-		return pi_next_rpcl(pi);
-	case 3:
-		return pi_next_pcrl(pi);
-	case 4:
-		return pi_next_cprl(pi);
-	}
-	return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.h
deleted file mode 100644
index b300b9e..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/pi.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PI_H
-#define __PI_H
-
-#include "j2k.h"
-#include "tcd.h"
-
-typedef struct {
-	int pdx, pdy;
-	int pw, ph;
-} pi_resolution_t;
-
-typedef struct {
-	int dx, dy;
-	int numresolutions;
-	pi_resolution_t *resolutions;
-} pi_comp_t;
-
-typedef struct {
-	short int *include;
-  int step_l, step_r, step_c, step_p; 
-	int compno, resno, precno, layno;	/* component, resolution, precinct and layer that indentify the packet */
-	int first;
-	j2k_poc_t poc;
-	int numcomps;
-	pi_comp_t *comps;
-	int tx0, ty0, tx1, ty1;
-	int x, y, dx, dy;
-} pi_iterator_t;								/* packet iterator */
-
-/*
- * Create a packet iterator
- * img: raw image for which the packets will be listed
- * cp: coding paremeters
- * tileno: number that identifies the tile for which to list the packets
- * return value: returns a packet iterator that points to the first packet of the tile
- */
-pi_iterator_t *pi_create(j2k_image_t * img, j2k_cp_t * cp, int tileno);
-
-/* 
- * Modify the packet iterator to point to the next packet
- * pi: packet iterator to modify
- * return value: returns 0 if pi pointed to the last packet or else returns 1 
- */
-int pi_next(pi_iterator_t * pi);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.c
deleted file mode 100644
index 14a44be..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "t2.h"
-#include "tcd.h"
-#include "bio.h"
-#include "j2k.h"
-#include "pi.h"
-#include "tgt.h"
-#include "int.h"
-#include "cio.h"
-#include <stdio.h>
-#include <setjmp.h>
-#include <string.h>
-#include <stdlib.h> 
-
-#define RESTART 0x04
-
-extern jmp_buf j2k_error;
-
-int t2_getcommacode() {
-    int n;
-    for (n=0; bio_read(1); n++) {}
-    return n;
-}
-
-int t2_getnumpasses()
-{
-    int n;
-    if (!bio_read(1)) return 1;
-    if (!bio_read(1)) return 2;
-    if ((n=bio_read(2))!=3) return 3+n;
-    if ((n=bio_read(5))!=31) return 6+n;
-    return 37+bio_read(7);
-}
-
-void t2_init_seg(tcd_seg_t *seg, int cblksty) {
-    seg->numpasses=0;
-    seg->len=0;
-    seg->maxpasses=cblksty&J2K_CCP_CBLKSTY_TERMALL?1:100;
-}
-
-int t2_decode_packet(unsigned char *src, int len, tcd_tile_t *tile, j2k_cp_t * cp, j2k_tcp_t *tcp, int compno, int resno, int precno, int layno, info_layer_t *layer_Idx) {
-    int bandno, cblkno;
-    tcd_tilecomp_t *tilec = &tile->comps[compno];
-    tcd_resolution_t *res = &tilec->resolutions[resno];
-    unsigned char *c = src;
-    unsigned char *d = c;
-    int e;
-    int present;
-
-    if (layno == 0) {
-        for (bandno = 0; bandno < res->numbands; bandno++) {
-            tcd_band_t *band = &res->bands[bandno];
-            tcd_precinct_t *prc = &band->precincts[precno];
-            tgt_reset(prc->incltree);
-            tgt_reset(prc->imsbtree);
-            for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-                tcd_cblk_t *cblk = &prc->cblks[cblkno];
-                cblk->numsegs = 0;
-            }
-        }  
-    }
-    /* INDEX */
-    layer_Idx->len_header = 0;
-
-    /* When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
-       This part deal with this caracteristic
-       step 1: Read packet header in the saved structure
-       step 2: (futher) return to codestream for decoding */
-    if (cp->ppm == 1) /* PPM */
-      {	    
-	c = cp->ppm_data;
-	d = c;
-	bio_init_dec(c, 1000);
-      } else 
-	{
-	  if (tcp->ppt == 1) /* PPT */
-	    {
-	      c = tcp->ppt_data;
-	      d = c;
-	      bio_init_dec(c, 1000);
-	    } else /* Normal Case */
-	      {
-		if (tcp->csty & J2K_CP_CSTY_SOP) 
-		  {
-		    if ((*c) != 255 || (*(c+1) != 145)) {printf("Error : expected SOP marker [1]!!!\n");}
-		    c += 6;
-		  }
-		bio_init_dec(c, src + len - c);
-		layer_Idx->len_header = -6;
-	      }
-	}
-    
-    present = bio_read(1);
-    
-    if (!present) 
-      {
-	bio_inalign();
-	/* Normal case */
-	c += bio_numbytes();
-	if (tcp->csty & J2K_CP_CSTY_EPH) 
-	  {
-	    if ((*c) != 255 || (*(c+1) != 146)) {printf("Error : expected EPH marker [1]!!!\n");}
-	    c += 2;
-	  }
-	/* INDEX */
-	layer_Idx->len_header += (c-d);
-
-	/* PPT and PPM dealing */
-	if (cp->ppm == 1) /* PPM */
-	  {	
-	    cp->ppm_data = c;	    
-	    return 0;
-	  }
-	if (tcp->ppt == 1) /* PPT */
-	  {
-	    tcp->ppt_data = c;
-	    return 0;
-	  }
-	return c - src;
-      }
-    
-    for (bandno=0; bandno<res->numbands; bandno++) {
-        tcd_band_t *band = &res->bands[bandno];
-        tcd_precinct_t *prc = &band->precincts[precno];
-        for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-            int included, increment, n;
-            tcd_cblk_t *cblk = &prc->cblks[cblkno];
-            tcd_seg_t *seg;
-            if (!cblk->numsegs) {
-                included = tgt_decode(prc->incltree, cblkno, layno+1);
-            } else {
-                included = bio_read(1);
-            }
-            if (!included) {
-                cblk->numnewpasses = 0;
-                continue;
-            }
-            if (!cblk->numsegs) {
-                int i, numimsbs;
-                for (i = 0; !tgt_decode(prc->imsbtree, cblkno, i); i++) {}
-                numimsbs = i-1;
-                cblk->numbps = band->numbps - numimsbs;
-                cblk->numlenbits = 3;
-            }
-            cblk->numnewpasses = t2_getnumpasses();
-            increment = t2_getcommacode();
-            cblk->numlenbits += increment;
-            if (!cblk->numsegs) {
-                seg = &cblk->segs[0];
-                t2_init_seg(seg, tcp->tccps[compno].cblksty);
-            } else {
-                seg = &cblk->segs[cblk->numsegs - 1];
-                if (seg->numpasses == seg->maxpasses) {
-                    t2_init_seg(++seg, tcp->tccps[compno].cblksty);
-                }
-            }
-            n = cblk->numnewpasses;
-            do {
-                seg->numnewpasses = int_min(seg->maxpasses-seg->numpasses, n);
-                seg->newlen = bio_read(cblk->numlenbits + int_floorlog2(seg->numnewpasses));
-                n -= seg->numnewpasses;
-                if (n > 0) {
-                    t2_init_seg(++seg, tcp->tccps[compno].cblksty);
-                }
-            } while (n > 0);
-        }
-    }
-    if(bio_inalign()) return -999;
-    c += bio_numbytes();
-
-    if (tcp->csty & J2K_CP_CSTY_EPH) { /* EPH marker */
-      if ((*c) != 255 || (*(c+1) != 146)) {printf("Error : expected EPH marker [2]!!!\n"); }
-      c += 2;
-    }
-    
-    /* INDEX */
-    layer_Idx->len_header += (c-d);
-
-    /* PPT Step 2 : see above for details */
-    if (cp->ppm == 1)
-      {
-	cp->ppm_data = c; /* Update pointer */
-
-	/* INDEX */
-	layer_Idx->len_header = c-d;
-
-	c = src;
-	d = c;
-	if (tcp->csty & J2K_CP_CSTY_SOP) 
-	  {
-	    if ((*c) != 255 || (*(c+1) != 145)) {printf("Error : expected SOP marker [2] !!!\n"); }
-	    c += 6;
-	  }
-	bio_init_dec(c, src + len - c);
-      } else 
-	{
-	  if (tcp->ppt == 1)
-	    { 
-	      tcp->ppt_data = c; /* Update pointer */
-	      /* INDEX */
-	      layer_Idx->len_header = c-d;
-
-	      c = src;
-	      d = c;
-	      if (tcp->csty & J2K_CP_CSTY_SOP) /* SOP marker */
-		{ 
-		  if ((*c) != 255 || (*(c+1) != 145)) {printf("Error : expected SOP marker [2] !!!\n"); }
-		  c += 6;
-		}
-	      bio_init_dec(c, src + len - c);
-	      
-	    }
-	}
-
-    for (bandno = 0; bandno < res->numbands; bandno++) {
-        tcd_band_t *band = &res->bands[bandno];
-        tcd_precinct_t *prc = &band->precincts[precno];
-        for (cblkno = 0; cblkno < prc->cw*prc->ch; cblkno++) {
-            tcd_cblk_t *cblk = &prc->cblks[cblkno];
-            tcd_seg_t *seg;
-            if (!cblk->numnewpasses) continue;
-            if (!cblk->numsegs) {
-                seg = &cblk->segs[cblk->numsegs++];
-                cblk->len = 0;
-            } else {
-                seg = &cblk->segs[cblk->numsegs-1];
-                if (seg->numpasses == seg->maxpasses) {
-                    seg++;
-                    cblk->numsegs++;
-                }
-            }
-            do {
-	      if (c + seg->newlen > src + len) return -999;
-                memcpy(cblk->data + cblk->len, c, seg->newlen);
-                if (seg->numpasses == 0) {
-                    seg->data = cblk->data + cblk->len;
-                }
-                c += seg->newlen;
-                cblk->len += seg->newlen;
-                seg->len += seg->newlen;
-                seg->numpasses += seg->numnewpasses;
-                cblk->numnewpasses -= seg->numnewpasses;
-                if (cblk->numnewpasses > 0) {
-                    seg++;
-                    cblk->numsegs++;
-                }
-            } while (cblk->numnewpasses > 0);
-        }
-    }
-    /* <INDEX> */
-    e = c-d;
-    layer_Idx->len = e;
-    /* </INDEX> */
-
-    return c-src;
-}
-
-void t2_init_info_packets(info_image_t *img, j2k_cp_t *cp)
-{
-  int compno, tileno, resno, precno, layno;
-
-  for(compno = 0; compno < img->Comp; compno++)
-    {
-      for(tileno = 0; tileno < img->tw*img->th; tileno++)
-	{
-	  info_tile_t *tile_Idx = &img->tile[tileno];
-	  info_compo_t *compo_Idx = &tile_Idx->compo[compno];
-	  for(resno = 0; resno < img->Decomposition + 1 ; resno++)
-	    {
-	      info_reso_t *reso_Idx = &compo_Idx->reso[resno];
-	      for (precno = 0; precno < img->tile[tileno].pw * img->tile[tileno].ph; precno++)
-		{
-		  info_prec_t *prec_Idx = &reso_Idx->prec[precno];
-		  for(layno = 0; layno < img->Layer ; layno++)
-		    {
-		      info_layer_t *layer_Idx = &prec_Idx->layer[layno];
-		      layer_Idx->offset = 0;        /* start position */
-		      layer_Idx->len_header = 0;    /* length         */
-		    }
-		}
-	    }
-	}
-    }
-}
-
-int t2_decode_packets(unsigned char *src, int len, j2k_image_t *img, j2k_cp_t *cp, int tileno, tcd_tile_t *tile, info_image_t *imgg) {
-    unsigned char *c = src;
-    pi_iterator_t *pi;
-    int pino, compno,e;
-    int partno;
-    info_tile_part_t *tile_part;
-    int position;
-    int length_read;
-    info_tile_t *tile_Idx;
-    info_compo_t *compo_Idx;
-    info_reso_t *reso_Idx;
-    info_prec_t *prec_Idx;
-    info_layer_t *layer_Idx;
-
-    t2_init_info_packets(imgg, cp); /* Initialize the packets information : LEN and OFFSET to 0 */
-
-    tile_Idx = &imgg->tile[tileno];
-    tile_Idx->num_packet = 0;
-    pi = pi_create(img, cp, tileno);
-    partno = 0;
-    tile_part = &tile_Idx->tile_parts[partno];
-    position = tile_part->end_header + 1;
-    length_read = 0;
-
-    for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++)
-      {
-	while (pi_next(&pi[pino])) 
-	  {   
-	    compo_Idx = &tile_Idx->compo[pi[pino].compno];
-	    reso_Idx = &compo_Idx->reso[pi[pino].resno];
-	    prec_Idx = &reso_Idx->prec[pi[pino].precno];
-	    layer_Idx = &prec_Idx->layer[pi[pino].layno];
-	    
-	    layer_Idx->offset = position;
-	    layer_Idx->offset_header = position;
-	    
-	    e = t2_decode_packet(c, src+len-c, tile, cp, &cp->tcps[tileno], pi[pino].compno, pi[pino].resno, pi[pino].precno, pi[pino].layno,layer_Idx);
-	    if (e == -999)
-	      {
-		break;
-	      } else
-		c += e;
-	    position += e;
-	    
-	    /* Update position in case of multiple tile-parts for a tile >> */
-	    length_read += e;
-	    if (length_read >= (tile_part->end_pos - tile_part->end_header))
-	      {
-		partno++;
-		tile_part = &tile_Idx->tile_parts[partno];
-		position = tile_part->end_header + 1;
-		length_read = 0;
-	      }
-	    /* << end_update */
-	    
-	    tile_Idx->num_packet++;
-	  }
-	
-	// FREE space memory taken by pi
-	for (compno = 0; compno < pi[pino].numcomps; compno++) 
-	  { 
-	    free(pi[pino].comps[compno].resolutions);
-	  } 
-	free(pi[pino].comps);
-      }
-    
-    free(pi[0].include);
-    free(pi);
- 
-    if (e==-999)
-      return e;
-    else
-      {
-	imgg->num_packet_max=int_max(imgg->num_packet_max,tile_Idx->num_packet);
-	return c-src;
-      }
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.h
deleted file mode 100644
index f495107..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/t2.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __T2_H
-#define __T2_H
-
-#include "tcd.h"
-#include "j2k.h"
-
-/*
- * Decode the packets of a tile from a source buffer
- * src: the source buffer
- * len: length of the source buffer
- * img: destination image
- * cp: image coding parameters
- * tileno: number that identifies the tile for which to decode the packets
- * tile: tile for which to decode the packets
- */
-int t2_decode_packets(unsigned char *src, int len, j2k_image_t *img, j2k_cp_t *cp, int tileno, tcd_tile_t *tile, info_image_t *imgg);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.c
deleted file mode 100644
index c4045c7..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "tcd.h"
-#include "int.h"
-#include "t2.h"
-#include <setjmp.h>
-#include <float.h>
-#include <stdio.h>
-#include <time.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-static tcd_image_t tcd_image;
-
-static j2k_image_t *tcd_img;
-static j2k_cp_t *tcd_cp;
-
-extern jmp_buf j2k_error;
-
-void tcd_init(j2k_image_t *img, j2k_cp_t *cp, info_image_t *imgg) {
-    int tileno, compno, resno, bandno, precno, cblkno;
-    tcd_img=img;
-    tcd_cp=cp;
-    tcd_image.tw=cp->tw;
-    tcd_image.th=cp->th;
-    tcd_image.tiles=(tcd_tile_t*)malloc(cp->tw*cp->th*sizeof(tcd_tile_t));
-    for (tileno=0; tileno<cp->tw*cp->th; tileno++) {
-        j2k_tcp_t *tcp=&cp->tcps[tileno];
-        tcd_tile_t *tile=&tcd_image.tiles[tileno];
-        // cfr p59 ISO/IEC FDIS15444-1 : 2000 (18 august 2000)
-        int p=tileno%cp->tw;  // si numerotation matricielle ..
-        int q=tileno/cp->tw;  // .. coordonnees de la tile (q,p) q pour ligne et p pour colonne
-	info_tile_t *tile_Idx=&imgg->tile[tileno]; // INDEX
-
-	// 4 borders of the tile rescale on the image if necessary
-        tile->x0=int_max(cp->tx0+p*cp->tdx, img->x0);
-        tile->y0=int_max(cp->ty0+q*cp->tdy, img->y0);
-        tile->x1=int_min(cp->tx0+(p+1)*cp->tdx, img->x1);
-        tile->y1=int_min(cp->ty0+(q+1)*cp->tdy, img->y1);
-	
-        tile->numcomps=img->numcomps;
-        tile->comps=(tcd_tilecomp_t*)malloc(img->numcomps*sizeof(tcd_tilecomp_t));
-        tile_Idx->compo=(info_compo_t*)malloc(img->numcomps*sizeof(info_compo_t)); // INDEX
-	for (compno=0; compno<tile->numcomps; compno++) {
-            j2k_tccp_t *tccp=&tcp->tccps[compno];
-            tcd_tilecomp_t *tilec=&tile->comps[compno];
-	    info_compo_t *compo_Idx=&tile_Idx->compo[compno]; // INDEX
-
-	    // border of each tile component (global)
-            tilec->x0=int_ceildiv(tile->x0, img->comps[compno].dx);
-            tilec->y0=int_ceildiv(tile->y0, img->comps[compno].dy);
-	    tilec->x1=int_ceildiv(tile->x1, img->comps[compno].dx);
-            tilec->y1=int_ceildiv(tile->y1, img->comps[compno].dy);
-	    
-            tilec->data=(int*)malloc(sizeof(int)*(tilec->x1-tilec->x0)*(tilec->y1-tilec->y0));
-            tilec->numresolutions=tccp->numresolutions;
-            tilec->resolutions=(tcd_resolution_t*)malloc(tilec->numresolutions*sizeof(tcd_resolution_t));
-	    compo_Idx->reso=(info_reso_t*)malloc(tilec->numresolutions*sizeof(info_reso_t)); // INDEX
-            for (resno=0; resno<tilec->numresolutions; resno++) {
-                int pdx, pdy;
-                int levelno=tilec->numresolutions-1-resno;
-                int tlprcxstart, tlprcystart, brprcxend, brprcyend;
-                int tlcbgxstart, tlcbgystart, brcbgxend, brcbgyend;
-                int cbgwidthexpn, cbgheightexpn;
-                int cblkwidthexpn, cblkheightexpn;
-                tcd_resolution_t *res=&tilec->resolutions[resno];
-		info_reso_t *res_Idx=&compo_Idx->reso[resno]; // INDEX
-		int precno_Idx; // INDEX
-
-		// border for each resolution level (global)
-                res->x0=int_ceildivpow2(tilec->x0, levelno);
-                res->y0=int_ceildivpow2(tilec->y0, levelno);
-                res->x1=int_ceildivpow2(tilec->x1, levelno);
-                res->y1=int_ceildivpow2(tilec->y1, levelno);
-		
-		res->numbands=resno==0?1:3;
-		// p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000)
-                if (tccp->csty&J2K_CCP_CSTY_PRT) {
-                    pdx=tccp->prcw[resno];
-                    pdy=tccp->prch[resno];
-		} else {
-                    pdx=15;
-                    pdy=15;
-                }
-		// p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000) 
-                tlprcxstart=int_floordivpow2(res->x0, pdx)<<pdx;
-                tlprcystart=int_floordivpow2(res->y0, pdy)<<pdy;
-                brprcxend=int_ceildivpow2(res->x1, pdx)<<pdx;
-                brprcyend=int_ceildivpow2(res->y1, pdy)<<pdy;
-                res->pw=(brprcxend-tlprcxstart)>>pdx;
-                res->ph=(brprcyend-tlprcystart)>>pdy;
-
-		// <INDEX>
-		imgg->tile[tileno].pw=res->pw;
-		imgg->tile[tileno].ph=res->ph;
-		
-		res_Idx->prec=(info_prec_t*)malloc(res->pw*res->ph*sizeof(info_prec_t));
-		for (precno_Idx=0;precno_Idx<res->pw*res->ph;precno_Idx++)
-		  {
-		    info_prec_t *prec_Idx = &res_Idx->prec[precno_Idx];
-		    prec_Idx->layer=(info_layer_t*)malloc(imgg->Layer*sizeof(info_layer_t));
-		  }
-		
-		imgg->pw=res->pw;  // old parser version
-		imgg->ph=res->ph;  // old parser version
-		imgg->pdx=1<<pdx;
-		imgg->pdy=1<<pdy;
-		// </INDEX>
-
-                if (resno==0) {
-                    tlcbgxstart=tlprcxstart;
-                    tlcbgystart=tlprcystart;
-                    brcbgxend=brprcxend;
-                    brcbgyend=brprcyend;
-                    cbgwidthexpn=pdx;
-                    cbgheightexpn=pdy;
-                } else {
-                    tlcbgxstart=int_ceildivpow2(tlprcxstart, 1);
-                    tlcbgystart=int_ceildivpow2(tlprcystart, 1);
-                    brcbgxend=int_ceildivpow2(brprcxend, 1);
-                    brcbgyend=int_ceildivpow2(brprcyend, 1);
-                    cbgwidthexpn=pdx-1;
-                    cbgheightexpn=pdy-1;
-                }
-
-                cblkwidthexpn=int_min(tccp->cblkw, cbgwidthexpn);
-                cblkheightexpn=int_min(tccp->cblkh, cbgheightexpn);
-
-                for (bandno=0; bandno<res->numbands; bandno++) {
-                    int x0b, y0b;
-                    tcd_band_t *band=&res->bands[bandno];
-                    band->bandno=resno==0?0:bandno+1;
-                    x0b=(band->bandno==1)||(band->bandno==3)?1:0;
-                    y0b=(band->bandno==2)||(band->bandno==3)?1:0;
-
-                    if (band->bandno==0) {
-		      // band border (global)
-		      band->x0=int_ceildivpow2(tilec->x0, levelno);
-		      band->y0=int_ceildivpow2(tilec->y0, levelno);
-		      band->x1=int_ceildivpow2(tilec->x1, levelno);
-		      band->y1=int_ceildivpow2(tilec->y1, levelno);
-                    } else {
-		      // band border (global)
-		      band->x0=int_ceildivpow2(tilec->x0-(1<<levelno)*x0b, levelno+1);
-		      band->y0=int_ceildivpow2(tilec->y0-(1<<levelno)*y0b, levelno+1);
-		      band->x1=int_ceildivpow2(tilec->x1-(1<<levelno)*x0b, levelno+1);
-		      band->y1=int_ceildivpow2(tilec->y1-(1<<levelno)*y0b, levelno+1);
-                    }
-
-                    band->precincts=(tcd_precinct_t*)malloc(res->pw*res->ph*sizeof(tcd_precinct_t));
-
-                    for (precno=0; precno<res->pw*res->ph; precno++) {
-                        int tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;
-                        int cbgxstart=tlcbgxstart+(precno%res->pw)*(1<<cbgwidthexpn);
-                        int cbgystart=tlcbgystart+(precno/res->pw)*(1<<cbgheightexpn);
-                        int cbgxend=cbgxstart+(1<<cbgwidthexpn);
-                        int cbgyend=cbgystart+(1<<cbgheightexpn);
-                        tcd_precinct_t *prc=&band->precincts[precno];
-			// precinct size (global)
-                        prc->x0=int_max(cbgxstart, band->x0);
-                        prc->y0=int_max(cbgystart, band->y0);
-                        prc->x1=int_min(cbgxend, band->x1);
-                        prc->y1=int_min(cbgyend, band->y1);
-
-                        tlcblkxstart=int_floordivpow2(prc->x0, cblkwidthexpn)<<cblkwidthexpn;
-                        tlcblkystart=int_floordivpow2(prc->y0, cblkheightexpn)<<cblkheightexpn;
-                        brcblkxend=int_ceildivpow2(prc->x1, cblkwidthexpn)<<cblkwidthexpn;
-                        brcblkyend=int_ceildivpow2(prc->y1, cblkheightexpn)<<cblkheightexpn;
-                        prc->cw=(brcblkxend-tlcblkxstart)>>cblkwidthexpn;
-                        prc->ch=(brcblkyend-tlcblkystart)>>cblkheightexpn;
-
-                        prc->cblks=(tcd_cblk_t*)malloc(prc->cw*prc->ch*sizeof(tcd_cblk_t));
-
-                        prc->incltree=tgt_create(prc->cw, prc->ch);
-                        prc->imsbtree=tgt_create(prc->cw, prc->ch);
-
-                        for (cblkno=0; cblkno<prc->cw*prc->ch; cblkno++) {
-                            int cblkxstart=tlcblkxstart+(cblkno%prc->cw)*(1<<cblkwidthexpn);
-                            int cblkystart=tlcblkystart+(cblkno/prc->cw)*(1<<cblkheightexpn);
-                            int cblkxend=cblkxstart+(1<<cblkwidthexpn);
-                            int cblkyend=cblkystart+(1<<cblkheightexpn);
-                            tcd_cblk_t *cblk=&prc->cblks[cblkno];
-			    // code-block size (global)
-                            cblk->x0=int_max(cblkxstart, prc->x0);
-                            cblk->y0=int_max(cblkystart, prc->y0);
-                            cblk->x1=int_min(cblkxend, prc->x1);
-                            cblk->y1=int_min(cblkyend, prc->y1);
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
-
-
-void tcd_free(j2k_image_t *img, j2k_cp_t *cp) {
-  int tileno, compno, resno, bandno, precno;
-  tcd_img=img;
-  tcd_cp=cp;
-  tcd_image.tw=cp->tw;
-  tcd_image.th=cp->th;
-  for (tileno=0; tileno<tcd_image.tw*tcd_image.th; tileno++) 
-    {
-      //  j2k_tcp_t *tcp=&cp->tcps[curtileno];
-      tcd_tile_t *tile=&tcd_image.tiles[tileno];
-      for (compno=0; compno<tile->numcomps; compno++) 
-	{
-	 tcd_tilecomp_t *tilec=&tile->comps[compno];
-	  for (resno=0; resno<tilec->numresolutions; resno++) 
-	    {
-	      tcd_resolution_t *res=&tilec->resolutions[resno];
-	      for (bandno=0; bandno<res->numbands; bandno++) 
-		{
-		 tcd_band_t *band=&res->bands[bandno];
-		  for (precno=0; precno<res->pw*res->ph; precno++) 
-		    {
-		     tcd_precinct_t *prc=&band->precincts[precno];
-		      
-		      if (prc->incltree!=NULL)
-			tgt_destroy(prc->incltree);
-		      if (prc->imsbtree!=NULL)
-			tgt_destroy(prc->imsbtree);
-		      free(prc->cblks);
-		    } // for (precno
-		  free(band->precincts);
-		} // for (bandno
-	    }	// for (resno
-	  free(tilec->resolutions);
-	}	// for (compno
-      free(tile->comps);
-    }	// for (tileno
-  free(tcd_image.tiles);
-}
-
-
-int tcd_decode_tile(unsigned char *src, int len, int tileno, info_image_t *imgg) {
-    int l;
-    int eof=0;
-    tcd_tile_t *tile;
-
-    tile = &tcd_image.tiles[tileno];
-
-    l = t2_decode_packets(src, len, tcd_img, tcd_cp, tileno, tile, imgg);
-
-    if (l==-999)
-      {
-	eof=1;
-	fprintf(stderr, "tcd_decode: incomplete bistream\n");
-      }
-    
-     if (eof) {
-       longjmp(j2k_error, 1);
-     }
-
-    l=1;
-    return l;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.h
deleted file mode 100644
index 9a31723..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tcd.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TCD_H
-#define __TCD_H
-
-#include "j2k.h"
-#include "tgt.h"
-
-typedef struct {
-    int numpasses;
-    int len;
-    unsigned char *data;
-    int maxpasses;
-    int numnewpasses;
-    int newlen;
-} tcd_seg_t;
-
-typedef struct {
-    int rate;
-    double distortiondec;
-} tcd_pass_t;
-
-typedef struct {
-    int numpasses;
-    int len;
-    unsigned char *data;
-} tcd_layer_t;
-
-typedef struct {
-    int x0, y0, x1, y1;
-    int numbps;
-    int numlenbits;
-    int len;
-    int numpasses;
-    int numnewpasses;
-    int numsegs;
-    tcd_seg_t segs[100];
-    unsigned char data[8192];
-    int numpassesinlayers;
-    tcd_layer_t layers[100];
-    int totalpasses;
-    tcd_pass_t passes[100];
-} tcd_cblk_t;
-
-typedef struct {
-    int x0, y0, x1, y1;
-    int cw, ch;
-    tcd_cblk_t *cblks;
-    tgt_tree_t *incltree;
-    tgt_tree_t *imsbtree;
-} tcd_precinct_t;
-
-typedef struct {
-    int x0, y0, x1, y1;
-    int bandno;
-    tcd_precinct_t *precincts;
-    int numbps;
-    int stepsize;
-} tcd_band_t;
-
-typedef struct {
-    int x0, y0, x1, y1;  
-  int previous_x0, previous_y0, previous_x1, previous_y1; // usefull for the DWT
-  int cas_col, cas_row; // usefull for the DWT
-    int pw, ph;
-    int numbands;
-    tcd_band_t bands[3];
-} tcd_resolution_t;
-
-typedef struct {
-    int x0, y0, x1, y1;
-  int previous_row, previous_col; // usefull for the DWT
-    int numresolutions;
-    tcd_resolution_t *resolutions;
-    int *data;
-} tcd_tilecomp_t;
-
-typedef struct {
-    int x0, y0, x1, y1;
-    int numcomps;
-  //int PPT;
-  //int len_ppt;
-    tcd_tilecomp_t *comps;
-} tcd_tile_t;
-
-typedef struct {
-    int tw, th;
-    tcd_tile_t *tiles;
-} tcd_image_t;
-
-/*
- * Initialize the tile coder/decoder
- * img: raw image
- * cp: coding parameters
- * imgg: creation of index file
- */
-
-void tcd_init(j2k_image_t *img, j2k_cp_t *cp, info_image_t *imgg);
-
-void tcd_free(j2k_image_t *img, j2k_cp_t *cp);
-
-/*
- * Decode a tile from a buffer into a raw image
- * src: source buffer
- * len: length of the source buffer
- * tileno: number that identifies the tile that will be decoded
- * imgg : Structure for index file
- */
-int tcd_decode_tile(unsigned char *src, int len, int tileno, info_image_t *imgg);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.c b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.c
deleted file mode 100644
index c2b4682..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "tgt.h"
-#include "bio.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-/// <summary>
-/// Reset tag-tree.
-/// </summary>
-void tgt_reset(tgt_tree_t *tree)
-{
-    int i;
-    for (i=0; i<tree->numnodes; i++) {
-        tree->nodes[i].value=999;
-        tree->nodes[i].low=0;
-        tree->nodes[i].known=0;
-    }
-}
-
-/// <summary>
-/// Create tag-tree.
-/// </summary>
-tgt_tree_t *tgt_create(int numleafsh, int numleafsv)
-{
-    int nplh[32];
-    int nplv[32];
-    tgt_node_t *node;
-    tgt_node_t *parentnode;
-    tgt_node_t *parentnode0;
-    tgt_tree_t *tree;
-    int i, j, k;
-    int numlvls;
-    int n;
-
-    tree=(tgt_tree_t*)malloc(sizeof(tgt_tree_t));
-    tree->numleafsh=numleafsh;
-    tree->numleafsv=numleafsv;
-
-    numlvls=0;
-    nplh[0]=numleafsh;
-    nplv[0]=numleafsv;
-    tree->numnodes=0;
-    do {
-        n=nplh[numlvls]*nplv[numlvls];
-        nplh[numlvls+1]=(nplh[numlvls]+1)/2;
-        nplv[numlvls+1]=(nplv[numlvls]+1)/2;
-        tree->numnodes+=n;
-        ++numlvls;
-    } while (n>1);
-
-    tree->nodes=(tgt_node_t*)malloc(tree->numnodes*sizeof(tgt_node_t));
-
-    node=tree->nodes;
-    parentnode=&tree->nodes[tree->numleafsh*tree->numleafsv];
-    parentnode0=parentnode;
-
-    for (i=0; i<numlvls-1; ++i) {
-        for (j=0; j<nplv[i]; ++j) {
-            k=nplh[i];
-            while (--k>=0) {
-                node->parent=parentnode;
-                ++node;
-                if (--k >= 0) {
-                    node->parent=parentnode;
-                    ++node;
-                }
-                ++parentnode;
-            }
-            if ((j&1)||j==nplv[i]-1) {
-                parentnode0=parentnode;
-            } else {
-                parentnode=parentnode0;
-                parentnode0+=nplh[i];
-            }
-        }
-    }
-    node->parent=0;
-
-    tgt_reset(tree);
-
-    return tree;
-}
-
-/// <summary>
-/// Destroy tag-tree.
-/// </summary>
-void tgt_destroy(tgt_tree_t *t) {
-    free(t->nodes);
-    free(t);
-}
-
-/// <summary>
-/// Set the value of a leaf of the tag-tree.
-/// </summary>
-void tgt_setvalue(tgt_tree_t *tree, int leafno, int value) {
-    tgt_node_t *node;
-    node=&tree->nodes[leafno];
-    while (node && node->value>value) {
-        node->value=value;
-        node=node->parent;
-    }
-}
-
-/// <summary>
-/// Decode the value of a leaf of the tag-tree.
-/// </summary>
-int tgt_decode(tgt_tree_t *tree, int leafno, int threshold)
-{
-    tgt_node_t *stk[31];
-    tgt_node_t **stkptr;
-    tgt_node_t *node;
-    int low;
-
-    stkptr=stk;
-    node=&tree->nodes[leafno];
-    while (node->parent) {
-        *stkptr++=node;
-        node=node->parent;
-    }
-
-    low=0;
-    for (;;) {
-        if (low>node->low) {
-            node->low=low;
-        } else {
-            low=node->low;
-        }
-        while (low<threshold && low<node->value) {
-            if (bio_read(1)) {
-                node->value=low;
-            } else {
-                ++low;
-            }
-        }
-        node->low=low;
-        if (stkptr==stk) {
-            break;
-        }
-        node=*--stkptr;
-    }
-
-    return (node->value<threshold)?1:0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.h b/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.h
deleted file mode 100644
index 9d85ade..0000000
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/tgt.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2001-2002, David Janssens
- * Copyright (c) 2003, Yannick Verschueren
- * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TGT_H
-#define __TGT_H
-
-typedef struct tgt_node {
-	struct tgt_node *parent;
-	int value;
-	int low;
-	int known;
-} tgt_node_t;
-
-typedef struct {
-	int numleafsh;
-	int numleafsv;
-	int numnodes;
-	tgt_node_t *nodes;
-} tgt_tree_t;
-
-/*
- * Create a tag-tree
- * numleafsh: width of the array of leafs of the tree
- * numleafsv: height of the array of leafs of the tree
- */
-tgt_tree_t *tgt_create(int numleafsh, int numleafsv);
-
-/*
- * Reset a tag-tree (set all leafs to 0)
- * tree: tag-tree to reset
- */
-void tgt_reset(tgt_tree_t *tree);
-
-/*
- * Destroy a tag-tree, liberating memory
- * tree: tag-tree to destroy
- */
-void tgt_destroy(tgt_tree_t *tree);
-
-/*
- * Set the value of a leaf of a tag-tree
- * tree: tag-tree to modify
- * leafno: number that identifies the leaf to modify
- * value: new value of the leaf
- */
-void tgt_setvalue(tgt_tree_t *tree, int leafno, int value);
-
-/*
- * Decode the value of a leaf of the tag-tree up to a given threshold
- * leafno: number that identifies the leaf to decode
- * threshold: threshold to use when decoding value of the leaf
- */
-int tgt_decode(tgt_tree_t *tree, int leafno, int threshold);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/jp3d/CMakeLists.txt
deleted file mode 100644
index 6e1897e..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# jp3d
-
-# Headers file are located here:
-include_directories(
-  ${CMAKE_CURRENT_SOURCE_DIR}/codec
-  ${CMAKE_CURRENT_SOURCE_DIR}/libjp3dvm
-  )
-
-
-subdirs(
-  libjp3dvm
-  codec
-)
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.dsp b/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.dsp
deleted file mode 100755
index 39c8b68..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.dsp
+++ /dev/null
@@ -1,273 +0,0 @@
-# Microsoft Developer Studio Project File - Name="DllOpenJPEG" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=DllOpenJPEG - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "DllOpenJPEG.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "DllOpenJPEG.mak" CFG="DllOpenJPEG - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "DllOpenJPEG - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "DllOpenJPEG - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "DllOpenJPEG - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40c /d "NDEBUG"
-# ADD RSC /l 0x40c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/OpenJPEG.dll"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=if not exist dist mkdir dist	copy libopenjpeg\openjpeg3d.h dist	copy Release\OpenJPEG.dll dist	copy Release\OpenJPEG.lib dist
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "DllOpenJPEG - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40c /d "_DEBUG"
-# ADD RSC /l 0x40c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/OpenJPEGd.dll" /pdbtype:sept
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=if not exist dist mkdir dist	copy libopenjpeg\openjpeg3d.h dist	copy Debug\OpenJPEGd.dll dist	copy Debug\OpenJPEGd.lib dist
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "DllOpenJPEG - Win32 Release"
-# Name "DllOpenJPEG - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\libopenjpeg\bio.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\cio.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\dwt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\event.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\image.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\j2k.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\j2k_lib.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\jp2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\jpt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\mct.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\mqc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\openjpeg.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\pi.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\raw.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\t1.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\t2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\tcd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\tgt.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\libopenjpeg\bio.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\cio.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\dwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\event.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\fix.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\image.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\int.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\j2k.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\j2k_lib.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\jp2.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\jpt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\mct.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\mqc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\openjpeg3d.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\opj_includes.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\pi.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\raw.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\t1.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\t2.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\tcd.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libopenjpeg\tgt.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\OpenJPEG.rc
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.sln b/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.sln
deleted file mode 100755
index 7b97dad..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.sln
+++ /dev/null
@@ -1,21 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DllOpenJPEG", "DllJp3dVM.vcproj", "{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		Debug = Debug
-		Release = Release
-	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Debug.ActiveCfg = Debug|Win32
-		{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Debug.Build.0 = Debug|Win32
-		{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Release.ActiveCfg = Release|Win32
-		{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Release.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.vcproj b/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.vcproj
deleted file mode 100755
index f8ca5e1..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/DllJp3dVM.vcproj
+++ /dev/null
@@ -1,278 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="7.10"
-	Name="DllOpenJP3D"
-	ProjectGUID="{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}"
-	SccProjectName=""
-	SccLocalPath="">
-	<Platforms>
-		<Platform
-			Name="Win32"/>
-	</Platforms>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="2"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OPJ_EXPORTS"
-				StringPooling="TRUE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="TRUE"
-				PrecompiledHeaderFile=".\Release/DllOpenJPEG.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile="Release/OpenJP3D.dll"
-				LinkIncremental="1"
-				SuppressStartupBanner="TRUE"
-				ProgramDatabaseFile=".\Release/OpenJP3D.pdb"
-				ImportLibrary=".\Release/OpenJP3D.lib"
-				TargetMachine="1"/>
-			<Tool
-				Name="VCMIDLTool"
-				PreprocessorDefinitions="NDEBUG"
-				MkTypLibCompatible="TRUE"
-				SuppressStartupBanner="TRUE"
-				TargetEnvironment="1"
-				TypeLibraryName=".\Release/DllOpenJPEG.tlb"
-				HeaderFileName=""/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="if not exist bin mkdir bin
-copy libjp3dvm\openjpeg3d.h bin
-copy Release\OpenJP3D.dll bin
-copy Release\OpenJP3D.lib bin
-"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1036"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="2"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OPJ_EXPORTS"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\Debug/DllOpenJPEG.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				DebugInformationFormat="4"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile="Debug/OpenJP3D.dll"
-				LinkIncremental="1"
-				SuppressStartupBanner="TRUE"
-				GenerateDebugInformation="TRUE"
-				ProgramDatabaseFile=".\Debug/OpenJP3D.pdb"
-				ImportLibrary=".\Debug/OpenJP3D.lib"
-				TargetMachine="1"/>
-			<Tool
-				Name="VCMIDLTool"
-				PreprocessorDefinitions="_DEBUG"
-				MkTypLibCompatible="TRUE"
-				SuppressStartupBanner="TRUE"
-				TargetEnvironment="1"
-				TypeLibraryName=".\Debug/DllOpenJPEG.tlb"
-				HeaderFileName=""/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="if not exist bin mkdir bin
-copy libjp3dvm\openjpeg3d.h bin
-copy Debug\OpenJP3D.dll bin
-"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1034"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
-			<File
-				RelativePath=".\libjp3dvm\bio.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\cio.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\dwt.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\event.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d_lib.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mct.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mqc.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\openjpeg.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\pi.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\raw.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1_3d.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t2.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tcd.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tgt.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\volume.c">
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl">
-			<File
-				RelativePath=".\libjp3dvm\bio.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\cio.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\dirent.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\dwt.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\event.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\fix.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\int.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d_lib.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mct.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mqc.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\openjpeg3d.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\opj_includes.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\pi.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\raw.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1_3d.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t2.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tcd.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tgt.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\volume.h">
-			</File>
-		</Filter>
-		<Filter
-			Name="Resource Files"
-			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/LICENSE.txt b/Utilities/gdcmopenjpeg-v1/jp3d/LICENSE.txt
deleted file mode 100755
index 4716ce3..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/LICENSE.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez, Image Processing Laboratory (LPI) - University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.sln b/Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.sln
deleted file mode 100755
index 7309c7a..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.sln
+++ /dev/null
@@ -1,21 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibJp3dVM", "LibJp3dVM.vcproj", "{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		Debug = Debug
-		Release = Release
-	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.ActiveCfg = Debug|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.Build.0 = Debug|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.ActiveCfg = Release|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.vcproj b/Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.vcproj
deleted file mode 100755
index d3b0465..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/LibJp3dVM.vcproj
+++ /dev/null
@@ -1,249 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="7.10"
-	Name="LibJp3dVM"
-	ProjectGUID="{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
-	SccProjectName=""
-	SccLocalPath="">
-	<Platforms>
-		<Platform
-			Name="Win32"/>
-	</Platforms>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="4"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				InlineFunctionExpansion="0"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPJ_STATIC"
-				StringPooling="TRUE"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="TRUE"
-				PrecompiledHeaderFile=".\Release/LibJp3dVM.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile=".\Release\LibJp3dVM.lib"
-				SuppressStartupBanner="TRUE"/>
-			<Tool
-				Name="VCMIDLTool"/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="if not exist bin mkdir bin
-copy Release\LibJp3dVM.lib bin
-copy libjp3dvm\openjpeg3d.h bin
-"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1036"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="4"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPJ_STATIC"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\Debug/LibJp3dVM.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				DebugInformationFormat="4"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile=".\Debug\LibJp3dVM.lib"
-				SuppressStartupBanner="TRUE"/>
-			<Tool
-				Name="VCMIDLTool"/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="if not exist bin mkdir bin
-copy Debug\LibJp3dVM.lib bin
-copy libjp3dvm\openjpeg3d.h bin
-"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1036"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
-			<File
-				RelativePath=".\libjp3dvm\bio.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\cio.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\dwt.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\event.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d_lib.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mct.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mqc.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\openjpeg.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\pi.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\raw.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1_3d.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t2.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tcd.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tgt.c">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\volume.c">
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl">
-			<File
-				RelativePath=".\libjp3dvm\bio.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\cio.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\dirent.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\dwt.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\event.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\fix.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\int.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\jp3d_lib.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mct.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\mqc.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\openjpeg3d.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\opj_includes.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\pi.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\raw.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t1_3d.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\t2.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tcd.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\tgt.h">
-			</File>
-			<File
-				RelativePath=".\libjp3dvm\volume.h">
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/README.txt b/Utilities/gdcmopenjpeg-v1/jp3d/README.txt
deleted file mode 100755
index ce04072..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/README.txt
+++ /dev/null
@@ -1,285 +0,0 @@
-===============================================================================
-	JPEG2000 Part 10 (ISO/IEC 15444-10 JP3D) Verification Model
-
-				Version 1.1
-===============================================================================
-
-
-1. Scope
-================
-
-This document describes the installation and the use of the JP3D VM decoder and encoder under several operating systems (Linux, Unix, Windows, ...). Version 1.1 contains a complete JPEG 2000 Part 10 encoder, as well as a decoder.
-The supported functionalities are compliant with the JPEG2000 part 10 algorithm as described in the WD 6.0.
-The provided encoder and the decoder are compatible also with the International standard IS 15444-1 (core coding system).
-This implementation has been developped from OpenJPEG implementation of JPEG2000 standard, and for this reason it is written in C language. 
-
-If you find some bugs or if you have problems using the encoder/decoder, please send an e-mail to jp3d at lpi.tel.uva.es
-
-2. Installing the code 
-======================================================
-
-- After decompressing the zip file provided, you should find 
-at least the following files in the created 'jp3d_vm' directory:
-
- * libjp3dvm - This directory contains all library related code
- * codec - This directory contains all codec related code
- * tcltk - This directory contains the API scripts
- * README - The file you are reading
- * LICENCE - Copyright statement of the JP3D VM software
-
-2.1. Compiling the source code in Windows
--------------------------------------------
-
-This version has been compiled with Visual Studio 2003 using
-the projects included in the distribution:
-
- * LibJp3dVM.vcproj - Creates the library with all the JP3D functionalities
- * jp3d_vm_enc.vcproj - Test encoder 
- * jp3d_vm_dec.vcproj - Test decoder 
-
-2.2. Compiling the source code in Unix-like systems
--------------------------------------------
-
-Library compilation
-------------------------
-This version of the library has been tested under the following OS:
-- Fedora Core 
-
-The installation process is as simple as this : 
-1) Enter the 'jp3d_vm' directory
-2) Build the distribution : 
-make
-make install
-3) Clean all files produced during the build process
-make clean
-
-Codec compilation
-------------------------
-Once you've built the library, you should compile the JP3D codec.
-
-1) Go to the 'codec' directory 
-2) Build the encoder and decoder programs:
-
-gcc convert.c volume_to_jp3d.c -o jp3d_vm_enc -I ../libjp3dvm/ -lm -ljp3dvm
-gcc convert.c jp3d_to_volume.c -o jp3d_vm_dec -I ../libjp3dvm/ -lm -ljp3dvm
-
-Note: You should add '-L ../libjp3dvm/' to those lines if you
-did not use the 'install' target (and the 'clean' target neither...).
-
-3. Running the JP3D VM
-====================================================
-
-3.1. JP3D ENCODER
-====================================================
-
-Required arguments
-------------------------
-
- * Input file(s): -i Involume [*.bin, *.pgx]
-
-Specifies the volume to compress. Accepted formats are *.BIN (raw binary data) or *.PGX files.
-Both formats need some particular settings:
-
-  a) BIN format. As it has no header, volume characteristics will be obtained from a .IMG file. Its location will be specified through the following argument:
-	   -m Involumeinfo.IMG
-     This file shall have the following structure, with the appropiate value in each case (bit per voxel, color map, dimensions in X,Y,Z):
-	o Bpp	%d
-	o Color Map	%d
-	o Dimensions	%d %d %d
-
-  b) PGX format. Program will consider it as a volume slice. In order to denote a volume through a sequence of slices, you can define the input filename with the common pattern of the set of PGX files followed by a dash (as a wildcard character for the sequence numbers).
-	
- * Output file: -o Outfile [*.jp3d, *j2k]
-
-Specifies the name of the file where the codestream will be saved. 
-Part 1 compliant codestream will be created when an outfile has .j2k format.
-
-Options 
---------
-
-    * Rate values : -r 20,10,5
-      This option offers the possibility to define the compression rate to apply. 
-      Each value is a factor of compression (i.e. 20 : 1) and will generate a different quality layer. A lossless compression will be signified by the value 1.
-      NOTE : The order used to define the different levels of compression is important and must be from left to right in descending order.
-
-    * Quality values : -q 30,35,40
-      This option offers the possibility to define the quality level to achieve. Each value is a psnr, to be given in dB, and represents a quality layer. 
-      NOTE : The order used to define the different psnr-values is important and must be from left to right in ascending order.
-
-
-    * Number of resolutions : -n 3,3,2
-      This option offers the possibility to define the number of resolution levels computed for each dimension of the volume through the discret wavelet transform (DWT). Resolution in axial dimension can have a different value than in horizontal and vertical cases, but must be lower.
-      DEFAULT VALUE : 3,3,1 
-
-
-    * Switch modes : -M 3
-      This option offers the possibility to use a mode switch during the encoding process:
-          o BYPASS(LAZY)	[1]
-          o RESET		[2]
-          o RESTART(TERMALL)	[4]
-          o VSC			[8]
-          o ERTERM(SEGTERM)	[16]
-          o SEGMARK(SEGSYM)	[32]
-          o 3D_CONTEXT		[64]
-      For several mode switch just sum corresponding values: i.e. -M 38  => RESTART(4) + RESET(2) + SEGMARK(32)
-      DEFAULT VALUE: 0
-
-
-    * Progression order : -p LRCP
-      This option offers the possibility to specify the progression order. Possible progression orders are : LRCP, RLCP, RPCL, PCRL and CPRL.
-      DEFAULT VALUE: LRCP.
-
-
-    * Code-block size : -b 32,32,32
-      This option offers the possibility to define the size of the code-block. The dimension must respect the constraint defined in the JPEG-2000 standard. The maximum value autorized is 64x64x64.
-      DEFAULT VALUE: 64,64,64
-
-
-    * Precinct size : -c [128,128,128],[128,128,128],...
-      This option offers the possibility to define the size of the precincts at each resolution. Multiple records may be supplied, in which case the first record refers to the highest resolution level and subsequent records to lower resolution levels. The last specified record is right-shifted for each remaining lower resolution levels.
-      NOTE : specified values must be power of 2.
-      DEFAULT VALUE: 2^15 x 2^15 x 2^15
-
-
-    * Tile size : -t 512,512,512
-      This option offers the possibility to divide the volume in several tiles. The three values define the width, the heigth and the depth of the tile respectivily. 
-      DEFAULT VALUE: Volume dimensions (one tile)
-
-
-    * Subsampling factor : -s 2,2,2
-      This option offers the possibility to apply a subsampling factor for X, Y and Z axis. Value higher than 2 can be a source of error ! 
-      DEFAULT VALUE: 1,1,1
-
-
-    * SOP marker before each packet : -SOP
-      This option offers the possibility to add a specific marker before each packet. It is the marker SOP (Start of packet). If the option is not used no SOP marker will be added.
-
-
-    * EPH marker after each packet header : -EPH
-      This option offers the possibility to add a specific marker at the head of each packet header. It is the marker EPH (End of packet Header). If the option is not used no EPH marker will be added.
-
-
-    * Offset of the volume origin : -d 150,300,10
-      This option offers the possibility to move the origine of the volume in X, Y and/or Z axis. The division in tile could be modified as the anchor point for tiling will be different than the volume origin.
-      NOTE : the offset of the volume can not be higher than the tile dimension if the tile option is used.
-      DEFAULT VALUE: 0,0,0
-
-
-    * Offset of the tile origin : -T 100,75,5
-      This option offers the possibility to move the anchor point of the volume in X, Y and/or Z axis.
-      NOTE : the tile anchor point can not be on the volume area.
-      DEFAULT VALUE: 0,0,0
-
-
-    * Display the help menu : -help
-      This option displays on screen the content of this page
-
-Additional options 
-----------------------------------
-
-    * Encoding information file: -x index_name.idx
-      This option offers the possibility to create a text file with some structured information generated through the encoding. The name of the file must be specified, with .idx extension. The information structure is the following: 
-          o Volume size:
-                + VolW   + VolH   + VolD
-          o Progression Order:
-                + Prog
-          o Tile size: 
-                + TileW   + TileH   + TileD
-          o Number of components:
-                + NumComp
-          o Number of layers:
-                + NumLayer
-          o Number of decompositions (=(number of resolutions - 1)):
-                + NumDWTx   + NumDWTy   + NumDWTz
-          o Precinct size:
-                + [Precinct_width(NumDWT),Precinct_height(NumDWT),Precinct_depth(NumDWT)]
-                + [Precinct_width(NumDWT-1),Precinct_height(NumDWT-1),Precinct_depth(NumDWT-1)]
-                + ...
-                + [Precinct_width(0),Precinct_height(0),Precinct_depth(0)] 
-          o Main Header end position:
-                + MH_EndPos
-          o Codestream size:
-                + CSSize
-          o Tile 0 information:
-                + TileNum (0) 
-                + StartPos
-                + TileHeader_EndPos
-                + EndPos
-                + TotalDisto (this is the sum of the distortion reductions brought by each packet belonging to this tile)
-                + NumPix (this is the number of pixels in the tile)
-                + MaxMSE (=TotalDisto/NumPix)
-          o Tile1 information:
-                + TileNum (1)
-                + ...
-          o ...
-          o Tile N information:
-                + TileNum (N)
-                + ...
-          o Packet 0 from Tile 0 information:
-                + PackNum (0)
-                + TileNum (0) 
-                + LayerNum
-                + ResNum
-                + CompNum
-                + PrecNum
-                + StartPos
-                + EndPos
-                + Disto (distortion reduction brought by this packet)
-          o Packet 1 from Tile 0 information:
-                + PackNum (1)
-                + ...
-          o ...
-          o Packet M from Tile 0 information
-          o Packet 0 from Tile 1 information
-          o ...
-          o Packet M from Tile N information
-          o Maximum distortion reduction on the whole volume:
-                + MaxDisto
-          o Total distortion on the whole volume (sum of the distortion reductions from all packets in the volume):
-                + TotalDisto
-
-3.2. JP3D DECODER
-====================================================
-
-Required arguments
-------------------------
-
-    * Infile : -i compressed file
-      Currently accepts JP3D and J2K-files. The file type is identified based on its suffix (*.jp3d, *.j2k).
-
-
-    * Outfile(s) : -o decompressed file(s)
-      Currently accepts BIN-files and PGX-files. Binary data is written to the file (not ascii). 
-      If a BIN-file is defined, decoder will create automatically the volume characteristic file appending a .IMG extension to the provided output filename.
-      If a PGX-file is defined, decoder will understand this as a file pattern, appending corresponding indice from 0 to the number of decoded slices.
-      NOTE : There will be as many output files as there are components: an indice starting from 0 will then be appended to the output filename, just before the extension.
-
-
-Options available
-------------------------
-
-    * Reduce factor : -r 1,1,0
-      Set the number of highest resolution levels to be discarded in each dimension. The decoded volume size is effectively divided by 2 to the power of the number of discarded levels. 
-      NOTE : The reduce factor is limited by the smallest total number of decomposition levels among tiles.
-
-
-    * Layer number : -l 2
-      Set the maximum number of quality layers to decode. If there are less quality layers than the specified number, all the quality layers are decoded.
-
-
-    * Performance comparisons : -O original-file
-      This option offers the possibility to compute some quality results for the decompressed volume, like the PSNR value achieved or the global SSIM value. Needs the original file in order to compare with the new one.
-      NOTE: Only valid when -r option is 0,0,0 (both original and decompressed volumes have same resolutions)
-      NOTE: If original file is .BIN file, the volume characteristics file shall be defined with the -m option.
-	    (i.e. -O original-BIN-file -m original-IMG-file)
-
-
-    * Byte order (Big-endian / Little-endian) : -BE
-      This option offers the possibility to save the decompressed volume with a predefined byte order. 
-      DEFAULT VALUE: Little-endian
-
-
-    * Display the help menu : -help
-      This option displays on screen the content of this page
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/jp3d/codec/CMakeLists.txt
deleted file mode 100644
index 35c6452..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Build the demo app, small examples
-
-# First thing define the common source:
-set(common_SRCS
-  convert.c
-  )
-# Then check if getopt is present:
-include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-set(DONT_HAVE_GETOPT 1)
-if(UNIX) #I am pretty sure only *nix sys have this anyway
-  CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
-  # Seems like we need the contrary:
-  if(CMAKE_HAVE_GETOPT_H)
-    set(DONT_HAVE_GETOPT 0)
-  endif()
-endif()
-
-# If not getopt was found then add it to the lib:
-if(DONT_HAVE_GETOPT)
-  add_definitions(-DDONT_HAVE_GETOPT)
-  set(common_SRCS
-    ${common_SRCS}
-    getopt.c
-  )
-endif()
-
-if(WIN32)
-  if(BUILD_SHARED_LIBS)
-    add_definitions(-DOPJ_EXPORTS)
-  else()
-    add_definitions(-DOPJ_STATIC)
-  endif()
-endif()
-
-# Loop over all executables:
-foreach(exe jp3d_to_volume volume_to_jp3d)
-  add_executable(${exe} ${exe}.c ${common_SRCS})
-  target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME}_JP3D) # ${TIFF_LIBRARIES})
-  # On unix you need to link to the math library:
-  if(UNIX)
-    target_link_libraries(${exe} m)
-  endif()
-  # Install exe
-  install_targets(/bin/ ${exe})
-endforeach()
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.c b/Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.c
deleted file mode 100755
index 92a8163..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.c
+++ /dev/null
@@ -1,997 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../libjp3dvm/openjpeg3d.h"
-#ifdef _WIN32
-#include "windirent.h"
-#else
-#include <dirent.h>
-#endif /* _WIN32 */
-
-
-
-void dump_volume(FILE *fd, opj_volume_t * vol) {
-	int compno;
-	fprintf(fd, "volume {\n");
-	fprintf(fd, "  x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d\n", vol->x0, vol->y0, vol->z0,vol->x1, vol->y1,  vol->z1);
-	fprintf(fd, "  numcomps=%d\n", vol->numcomps);
-	for (compno = 0; compno < vol->numcomps; compno++) {
-		opj_volume_comp_t *comp = &vol->comps[compno];
-		fprintf(fd, "  comp %d {\n", compno);
-		fprintf(fd, "    dx=%d, dy=%d, dz=%d\n", comp->dx, comp->dy, comp->dz);
-		fprintf(fd, "    prec=%d\n", comp->prec);
-		fprintf(fd, "    sgnd=%d\n", comp->sgnd);
-		fprintf(fd, "  }\n");
-	}
-	fprintf(fd, "}\n");
-}
-
-/*
- * Get logarithm of an integer and round downwards.
- *
- * log2(a)
- */
-static int int_floorlog2(int a) {
-	int l;
-	for (l = 0; a > 1; l++) {
-		a >>= 1;
-	}
-	return l;
-}
-
-/*
- * Divide an integer by a power of 2 and round upwards.
- *
- * a divided by 2^b
- */
-static int int_ceildivpow2(int a, int b) {
-	return (a + (1 << b) - 1) >> b;
-}
-
-/*
- * Divide an integer and round upwards.
- *
- * a divided by b
- */
-static int int_ceildiv(int a, int b) {
-	return (a + b - 1) / b;
-}
-
-
-/* -->> -->> -->> -->>
-
-PGX IMAGE FORMAT
-
-<<-- <<-- <<-- <<-- */
-
-
-unsigned char readuchar(FILE * f)
-{
-  unsigned char c1;
-  fread(&c1, 1, 1, f);
-  return c1;
-}
-
-unsigned short readushort(FILE * f, int bigendian)
-{
-  unsigned char c1, c2;
-  fread(&c1, 1, 1, f);
-  fread(&c2, 1, 1, f);
-  if (bigendian)
-    return (c1 << 8) + c2;
-  else
-    return (c2 << 8) + c1;
-}
-
-unsigned int readuint(FILE * f, int bigendian)
-{
-  unsigned char c1, c2, c3, c4;
-  fread(&c1, 1, 1, f);
-  fread(&c2, 1, 1, f);
-  fread(&c3, 1, 1, f);
-  fread(&c4, 1, 1, f);
-  if (bigendian)
-    return (c1 << 24) + (c2 << 16) + (c3 << 8) + c4;
-  else
-    return (c4 << 24) + (c3 << 16) + (c2 << 8) + c1;
-}
-/*****************************************/
-static unsigned short ShortSwap(unsigned short v)
-{
-  unsigned char c1, c2;
-  c1 = v & 0xff;
-  c2 = (v >> 8) & 0xff;
-  return (c1 << 8) + c2;
-}
-
-static unsigned int LongSwap (unsigned int i)
-{
-  unsigned char b1, b2, b3, b4;
-  b1 = i & 255;
-  b2 = ( i >> 8 ) & 255;
-  b3 = ( i>>16 ) & 255;
-  b4 = ( i>>24 ) & 255;
-  return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4;
-}
-/*****************************************/
-
-opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
-	
-	FILE *f = NULL;
-	int w, h, prec;
-	unsigned long offset;
-	int i, s, numcomps, maxvalue, sliceno, slicepos, maxslice = 0;
-	
-	OPJ_COLOR_SPACE color_space;
-	opj_volume_cmptparm_t cmptparm;	// maximum of 1 component 
-	opj_volume_t * volume = NULL;
-
-	char endian1,endian2,sign;
-	char signtmp[32];
-	char temp[32];
-	opj_volume_comp_t *comp = NULL;
-
-		DIR *dirp;
-    struct dirent *direntp;
-	
-	char *tmp = NULL, *tmp2 = NULL,
-		*point = NULL, *pgx = NULL;
-	char tmpdirpath[MAX_PATH];
-	char dirpath[MAX_PATH];
-	char pattern[MAX_PATH];
-	char pgxfiles[MAX_SLICES][MAX_PATH];
-	int pgxslicepos[MAX_SLICES];
-	char tmpno[3];
-	
-	numcomps = 1;
-	color_space = CLRSPC_GRAY;
-	sliceno = 0;
-	maxvalue = 0;
-	memset(pgxfiles, 0, MAX_SLICES * MAX_PATH * sizeof(char));
-	memset(&cmptparm, 0, sizeof(opj_volume_cmptparm_t));
-	
-	/* Separaci�n del caso de un �nico slice frente al de muchos */
-	if ((tmp = strrchr(relpath,'-')) == NULL){ 
-		//fprintf(stdout,"[INFO] A volume of only one slice....\n");
-		sliceno = 1;
-		maxslice = 1;
-		strcpy(pgxfiles[0],relpath);
-	
-	} else {
-		//Fetch only the path 
-		strcpy(tmpdirpath,relpath);
-		if ((tmp = strrchr(tmpdirpath,'/')) != NULL){
-			tmp++; *tmp='\0';
-			strcpy(dirpath,tmpdirpath);
-		} else {
-			strcpy(dirpath,"./");
-		}
-
-		//Fetch the pattern of the volume slices
-		if ((tmp = strrchr (relpath,'/')) != NULL) 
-			tmp++;	
-		else 
-			tmp = relpath;
-        if ((tmp2 = strrchr(tmp,'-')) != NULL)
-            *tmp2='\0';
-		else{ 
-			fprintf(stdout, "[ERROR] tmp2 ha dado null. no ha encontrado el * %s %s",tmp,relpath);
-			return NULL;
-		}
-        strcpy(pattern,tmp);
-
-		dirp = opendir( dirpath );
-		if (dirp == NULL){
-			fprintf(stdout, "[ERROR] Infile must be a .pgx file or a directory that contain pgx files");
-			return NULL;
-		}
-
-		/*Read all .pgx files of directory */
-		while ( (direntp = readdir( dirp )) != NULL )
-		{
-			/* Found a directory, but ignore . and .. */
-			if(strcmp(".",direntp->d_name) == 0 || strcmp("..",direntp->d_name) == 0)
-					continue;
-			
-			if( ((pgx = strstr(direntp->d_name,pattern)) != NULL) && ((tmp2 = strstr(direntp->d_name,".pgx")) != NULL) ){
-			
-				strcpy(tmp,dirpath);
-				tmp = strcat(tmp,direntp->d_name);
-						
-				//Obtenemos el index de la secuencia de slices
-				if ((tmp2 = strpbrk (direntp->d_name, "0123456789")) == NULL) 
-					continue;
-				i = 0;
-				while (tmp2 != NULL) {					
-					tmpno[i++] = *tmp2;
-					point = tmp2;
-					tmp2 = strpbrk (tmp2+1,"0123456789");
-				}tmpno[i]='\0';
-
-				//Comprobamos que no estamos leyendo algo raro como pattern.jp3d
-				if ((point = strpbrk (point,".")) == NULL){
-					break;
-				}
-				//Slicepos --> index de slice; Sliceno --> no de slices hasta el momento
-				slicepos = atoi(tmpno);
-				pgxslicepos[sliceno] = slicepos - 1;
-				sliceno++;
-				if (slicepos>maxslice)
-					maxslice = slicepos;
-				
-				//Colocamos el slices en su posicion correspondiente
-				strcpy(pgxfiles[slicepos-1],tmp);
-			}
-		}
-	
-	}/* else if pattern*.pgx */
-
-	if (!sliceno) {
-		fprintf(stdout,"[ERROR] No slices with this pattern founded !! Please check input volume name\n");
-		return NULL;
-	}
-	/*if ( maxslice != sliceno) {
-		fprintf(stdout,"[ERROR] Slices are not sequentially numbered !! Please rename them accordingly\n");
-		return NULL;
-	}*/
-	
-	for (s=0;s<sliceno;s++)
-	{
-			int pos = maxslice == sliceno ? s: pgxslicepos[s];
-			f = fopen(pgxfiles[pos], "rb");
-			if (!f) {
-				fprintf(stdout, "[ERROR] Failed to open %s for reading !\n", pgxfiles[s]);
-				return NULL;
-			}
-			fprintf(stdout, "[INFO] Loading %s \n",pgxfiles[pos]);
-
-			fseek(f, 0, SEEK_SET);
-			fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h);
-
-			i=0;
-			sign='+';		
-			while (signtmp[i]!='\0') {
-				if (signtmp[i]=='-') sign='-';
-				i++;
-			}
-		
-			fgetc(f);
-			if (endian1=='M' && endian2=='L') {
-				cmptparm.bigendian = 1;
-			} else if (endian2=='M' && endian1=='L') {
-				cmptparm.bigendian = 0;
-			} else {
-				fprintf(stdout, "[ERROR] Bad pgx header, please check input file\n");
-				return NULL;
-			}
-
-			if (s==0){
-				/* initialize volume component */
-
-				cmptparm.x0 = parameters->volume_offset_x0;
-				cmptparm.y0 = parameters->volume_offset_y0;
-				cmptparm.z0 = parameters->volume_offset_z0;
-				cmptparm.w = !cmptparm.x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm.x0 + (w - 1) * parameters->subsampling_dx + 1;
-				cmptparm.h = !cmptparm.y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm.y0 + (h - 1) * parameters->subsampling_dy + 1;
-				cmptparm.l = !cmptparm.z0 ? (sliceno - 1) * parameters->subsampling_dz + 1 : cmptparm.z0 + (sliceno - 1) * parameters->subsampling_dz + 1;
-				
-				if (sign == '-') {
-					cmptparm.sgnd = 1;
-				} else {
-					cmptparm.sgnd = 0;
-				}
-				cmptparm.prec = prec;
-				cmptparm.bpp = prec;
-				cmptparm.dcoffset = parameters->dcoffset;
-				cmptparm.dx = parameters->subsampling_dx;
-				cmptparm.dy = parameters->subsampling_dy;
-				cmptparm.dz = parameters->subsampling_dz;
-				
-				/* create the volume */
-				volume = opj_volume_create(numcomps, &cmptparm, color_space);
-				if(!volume) {
-					fclose(f);
-					return NULL;
-				}
-				/* set volume offset and reference grid */
-				volume->x0 = cmptparm.x0;
-				volume->y0 = cmptparm.y0;
-				volume->z0 = cmptparm.z0;
-				volume->x1 = cmptparm.w;
-				volume->y1 = cmptparm.h;
-				volume->z1 = cmptparm.l;
-				
-				/* set volume data :only one component, that is a volume*/
-				comp = &volume->comps[0];
-			
-			}//if sliceno==1
-			
-			offset = w * h * s;
-			
-			for (i = 0; i < w * h; i++) {
-				int v;
-				if (comp->prec <= 8) {
-					if (!comp->sgnd) {
-						v = readuchar(f);
-					} else {
-						v = (char) readuchar(f);
-					}
-				} else if (comp->prec <= 16) {
-					if (!comp->sgnd) {
-						v = readushort(f, cmptparm.bigendian);
-					} else {
-						v = (short) readushort(f, cmptparm.bigendian);
-					}
-				} else {
-					if (!comp->sgnd) {
-						v = readuint(f, cmptparm.bigendian);
-					} else {
-						v = (int) readuint(f, cmptparm.bigendian);
-					}
-				}				
-				if (v > maxvalue)
-					maxvalue = v;
-				comp->data[i + offset] = v;
-				
-			}
-			fclose(f);
-	} // for s --> sliceno
-	comp->bpp = int_floorlog2(maxvalue) + 1;
-	if (sliceno != 1)
-		closedir( dirp );
-	//dump_volume(stdout, volume);
-	return volume;
-}
-
-
-int volumetopgx(opj_volume_t * volume, char *outfile) {
-	int w, wr, wrr, h, hr, hrr, l, lr, lrr;
-	int i, j, compno, offset, sliceno;
-	FILE *fdest = NULL;
-
-	for (compno = 0; compno < volume->numcomps; compno++) {
-		opj_volume_comp_t *comp = &volume->comps[compno];
-		char name[256];
-		int nbytes = 0;
-		char *tmp = outfile;
-		while (*tmp) {
-			tmp++;
-		}
-		while (*tmp!='.') {
-			tmp--;
-		}
-		*tmp='\0';
-		for(sliceno = 0; sliceno < volume->z1 - volume->z0; sliceno++) {
-
-			if (volume->numcomps > 1) {
-				sprintf(name, "%s%d-%d.pgx", outfile, sliceno+1, compno);
-			} else if ((volume->z1 - volume->z0) > 1) {
-				sprintf(name, "%s%d.pgx", outfile, sliceno+1);
-			} else {
-				sprintf(name, "%s.pgx", outfile);
-			}
-
-			fdest = fopen(name, "wb");
-			if (!fdest) {
-				fprintf(stdout, "[ERROR] Failed to open %s for writing \n", name);
-				return 1;
-			}
-
-			fprintf(stdout,"[INFO] Writing in %s (%s)\n",name,volume->comps[0].bigendian ? "Bigendian" : "Little-endian");
-
-			w = int_ceildiv(volume->x1 - volume->x0, volume->comps[compno].dx);
-			wr = volume->comps[compno].w;
-			wrr = int_ceildivpow2(volume->comps[compno].w, volume->comps[compno].factor[0]);
-			
-			h = int_ceildiv(volume->y1 - volume->y0, volume->comps[compno].dy);
-			hr = volume->comps[compno].h;
-			hrr = int_ceildivpow2(volume->comps[compno].h, volume->comps[compno].factor[1]);
-			
-			l = int_ceildiv(volume->z1 - volume->z0, volume->comps[compno].dz);
-			lr = volume->comps[compno].l;
-			lrr = int_ceildivpow2(volume->comps[compno].l, volume->comps[compno].factor[2]);
-
-			fprintf(fdest, "PG %c%c %c%d %d %d\n", comp->bigendian ? 'M':'L', comp->bigendian ? 'L':'M',comp->sgnd ? '-' : '+', comp->prec, wr, hr);
-			if (comp->prec <= 8) {
-				nbytes = 1;
-			} else if (comp->prec <= 16) {
-				nbytes = 2;
-			} else {
-				nbytes = 4;
-			}
-
-			offset = (sliceno / lrr * l) + (sliceno % lrr);
-			offset = wrr * hrr * offset;
-			//fprintf(stdout,"%d %d %d %d\n",offset,wrr*hrr,wrr,w);
-			for (i = 0; i < wrr * hrr; i++) {
-				int v = volume->comps[0].data[(i / wrr * w) + (i % wrr) + offset];
-				if (volume->comps[0].bigendian) {
-					for (j = nbytes - 1; j >= 0; j--) {
-                        char byte = (char) ((v >> (j * 8)) & 0xff);
-                        fwrite(&byte, 1, 1, fdest);
-					}
-				} else {
-					for (j = 0; j <= nbytes - 1; j++) {
-                        char byte = (char) ((v >> (j * 8)) & 0xff);
-						fwrite(&byte, 1, 1, fdest);
-					}
-				}
-			}
-
-			fclose(fdest);
-		}//for sliceno
-	}//for compno
-
-	return 0;
-}
-
-/* -->> -->> -->> -->>
-
-BIN IMAGE FORMAT
-
-<<-- <<-- <<-- <<-- */
-
-opj_volume_t* bintovolume(char *filename, char *fileimg, opj_cparameters_t *parameters) {
-	int subsampling_dx =  parameters->subsampling_dx;
-	int subsampling_dy =  parameters->subsampling_dy;
-	int subsampling_dz =  parameters->subsampling_dz;
-	
-	int i, compno, w, h, l, numcomps = 1;
-	int prec, max = 0;
-
-//	char temp[32];
-	char line[100];
-	int bigendian;
-	
-	FILE *f = NULL;
-	FILE *fimg = NULL;
-	OPJ_COLOR_SPACE color_space;
-	opj_volume_cmptparm_t cmptparm;	/* maximum of 1 component */
-	opj_volume_t * volume = NULL;
-	opj_volume_comp_t *comp = NULL;
-
-	bigendian = 0;
-	color_space = CLRSPC_GRAY;
-
-	fimg = fopen(fileimg,"r");
-	if (!fimg) { 
-		fprintf(stdout, "[ERROR] Failed to open %s for reading !!\n", fileimg);
-		return 0;
-	}
-
-	fseek(fimg, 0, SEEK_SET);
-	while (!feof(fimg)) {
-        fgets(line,100,fimg);
-		//fprintf(stdout,"%s %d \n",line,feof(fimg));
-		if (strncmp(line,"Bpp",3) == 0){
-			sscanf(line,"%*s%*[ \t]%d",&prec);
-		} else if (strncmp(line,"Color",5) == 0){
-			sscanf(line, "%*s%*[ \t]%d",&color_space);
-		} else if (strncmp(line,"Dim",3) == 0){
-			sscanf(line, "%*s%*[ \t]%d%*[ \t]%d%*[ \t]%d",&w,&h,&l);
-		}
-	}
-	//fscanf(fimg, "Bpp%[ \t]%d%[ \t\n]",temp,&prec,temp);
-	//fscanf(fimg, "Color Map%[ \t]%d%[ \n\t]Dimensions%[ \t]%d%[ \t]%d%[ \t]%d%[ \n\t]",temp,&color_space,temp,temp,&w,temp,&h,temp,&l,temp);
-	//fscanf(fimg, "Resolution(mm)%[ \t]%d%[ \t]%d%[ \t]%d%[ \n\t]",temp,&subsampling_dx,temp,&subsampling_dy,temp,&subsampling_dz,temp);
-
-	#ifdef VERBOSE
-		fprintf(stdout, "[INFO] %d \t %d %d %d \t %3.2f %2.2f %2.2f \t %d \n",color_space,w,h,l,subsampling_dx,subsampling_dy,subsampling_dz,prec);
-	#endif
-	fclose(fimg);
-	
-	/* initialize volume components */
-	memset(&cmptparm, 0, sizeof(opj_volume_cmptparm_t));
-	
-	cmptparm.prec = prec;
-	cmptparm.bpp = prec;
-	cmptparm.sgnd = 0;
-	cmptparm.bigendian = bigendian;
-	cmptparm.dcoffset = parameters->dcoffset;
-	cmptparm.dx = subsampling_dx;
-	cmptparm.dy = subsampling_dy;
-	cmptparm.dz = subsampling_dz;
-	cmptparm.w = w;
-	cmptparm.h = h;
-	cmptparm.l = l;
-	
-	/* create the volume */
-	volume = opj_volume_create(numcomps, &cmptparm, color_space);
-	if(!volume) {
-		fprintf(stdout,"[ERROR] Unable to create volume");	
-		fclose(f);
-		return NULL;
-	}
-	
-	/* set volume offset and reference grid */
-	volume->x0 = parameters->volume_offset_x0;
-	volume->y0 = parameters->volume_offset_y0;
-	volume->z0 = parameters->volume_offset_z0;
-	volume->x1 = parameters->volume_offset_x0 + (w - 1) *	subsampling_dx + 1;
-	volume->y1 = parameters->volume_offset_y0 + (h - 1) *	subsampling_dy + 1;
-	volume->z1 = parameters->volume_offset_z0 + (l - 1) *	subsampling_dz + 1;
-	
-	/* set volume data */
-	f = fopen(filename, "rb");
-	if (!f) {
-		fprintf(stdout, "[ERROR] Failed to open %s for reading !!\n", filename);
-		return 0;
-	}
-	
-	/* BINARY */
-	for (compno = 0; compno < volume->numcomps; compno++) {
-		int whl = w * h * l;
-		/* set volume data */
-		comp = &volume->comps[compno];
-		
-		/*if (comp->prec <= 8) {
-			if (!comp->sgnd) {
-                unsigned char *data = (unsigned char *) malloc(whl * sizeof(unsigned char));
-				fread(data, 1, whl, f);
-				for (i = 0; i < whl; i++) {
-					comp->data[i] = data[i];
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			} else {
-				char *data = (char *) malloc(whl);
-				fread(data, 1, whl, f);
-				for (i = 0; i < whl; i++) {
-					comp->data[i] = data[i];
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			}
-		} else if (comp->prec <= 16) {
-			if (!comp->sgnd) {
-                unsigned short *data = (unsigned short *) malloc(whl * sizeof(unsigned short));
-				int leido = fread(data, 2, whl, f);
-				if (!leido)	{
-					free(data);	fclose(f);
-					return NULL;
-				}
-				
-				for (i = 0; i < whl; i++) {
-					if (bigendian)	//(c1 << 8) + c2;
-						comp->data[i] = data[i];
-					else{			//(c2 << 8) + c1;
-						comp->data[i] = ShortSwap(data[i]);
-					}
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			} else {
-				short *data = (short *) malloc(whl);
-				int leido = fread(data, 2, whl, f);
-				if (!leido)	{
-					free(data);	fclose(f);
-					return NULL;
-				}
-				for (i = 0; i < whl; i++) {
-					if (bigendian){	//(c1 << 8) + c2;
-						comp->data[i] = data[i];
-					}else{			//(c2 << 8) + c1;
-						comp->data[i] = (short) ShortSwap((unsigned short) data[i]);
-					}
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			}
-		} else {
-			if (!comp->sgnd) {
-                unsigned int *data = (unsigned int *) malloc(whl * sizeof(unsigned int));
-				int leido = fread(data, 4, whl, f);
-				if (!leido)	{
-					free(data);	fclose(f);
-					return NULL;
-				}				for (i = 0; i < whl; i++) {
-					if (!bigendian)
-						comp->data[i] = LongSwap(data[i]);
-					else
-						comp->data[i] = data[i];
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			} else {
-				int leido = fread(comp->data, 4, whl, f);
-				if (!leido)	{
-					fclose(f);
-					return NULL;
-				}				
-				for (i = 0; i < whl; i++) {
-					if (!bigendian) 
-						comp->data[i] = (int) LongSwap((unsigned int) comp->data[i]);
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-			}
-		}*/
-		
-		for (i = 0; i < whl; i++) {
-			int v;
-			if (comp->prec <= 8) {
-				if (!comp->sgnd) {
-					v = readuchar(f);
-				} else {
-					v = (char) readuchar(f);
-				}
-			} else if (comp->prec <= 16) {
-				if (!comp->sgnd) {
-					v = readushort(f, bigendian);
-				} else {
-					v = (short) readushort(f, bigendian);
-				}
-			} else {
-				if (!comp->sgnd) {
-					v = readuint(f, bigendian);
-				} else {
-					v = (int) readuint(f, bigendian);
-				}
-			}
-			if (v > max)
-				max = v;
-			comp->data[i] = v;
-		}
-		comp->bpp = int_floorlog2(max) + 1;
-	}
-	fclose(f);
-	return volume;
-}
-
-int volumetobin(opj_volume_t * volume, char *outfile) {
-	int w, wr, wrr, h, hr, hrr, l, lr, lrr, max;
-	int i,j, compno, nbytes;
-	int offset, sliceno;
-	FILE *fdest = NULL;
-	FILE *fimgdest = NULL;
-//	char *imgtemp;
-	char name[256];
-
-	for (compno = 0; compno < 1; compno++) { //Only one component
-		
-		fdest = fopen(outfile, "wb");
-		if (!fdest) {
-			fprintf(stdout, "[ERROR] Failed to open %s for writing\n", outfile);
-			return 1;
-		}
-        fprintf(stdout,"[INFO] Writing outfile %s (%s) \n",outfile, volume->comps[0].bigendian ? "Bigendian" : "Little-endian");
-
-		w = int_ceildiv(volume->x1 - volume->x0, volume->comps[compno].dx);
-		wr = volume->comps[compno].w;
-		wrr = int_ceildivpow2(volume->comps[compno].w, volume->comps[compno].factor[0]);
-		
-		h = int_ceildiv(volume->y1 - volume->y0, volume->comps[compno].dy);
-		hr = volume->comps[compno].h;
-		hrr = int_ceildivpow2(volume->comps[compno].h, volume->comps[compno].factor[1]);
-		
-		l = int_ceildiv(volume->z1 - volume->z0, volume->comps[compno].dz);
-		lr = volume->comps[compno].l;
-		lrr = int_ceildivpow2(volume->comps[compno].l, volume->comps[compno].factor[2]);
-
-		max = (volume->comps[compno].prec <= 8) ? 255 : (1 << volume->comps[compno].prec) - 1;
-		
-		volume->comps[compno].x0 = int_ceildivpow2(volume->comps[compno].x0 - int_ceildiv(volume->x0, volume->comps[compno].dx), volume->comps[compno].factor[0]);
-		volume->comps[compno].y0 = int_ceildivpow2(volume->comps[compno].y0 - int_ceildiv(volume->y0, volume->comps[compno].dy), volume->comps[compno].factor[1]);
-		volume->comps[compno].z0 = int_ceildivpow2(volume->comps[compno].z0 - int_ceildiv(volume->z0, volume->comps[compno].dz), volume->comps[compno].factor[2]);
-		
-		if (volume->comps[0].prec <= 8) {
-			nbytes = 1;
-		} else if (volume->comps[0].prec <= 16) {
-			nbytes = 2;
-		} else {
-			nbytes = 4;
-		}
-
-		//fprintf(stdout,"w %d wr %d wrr %d h %d hr %d hrr %d l %d lr %d lrr %d max %d nbytes %d\n Factor %d %d %d",w,wr,wrr,h,hr,hrr,l,lr,lrr,max,nbytes,volume->comps[compno].factor[0],volume->comps[compno].factor[1],volume->comps[compno].factor[2]);
-
-		for(sliceno = 0; sliceno < lrr; sliceno++) {
-			offset = (sliceno / lrr * l) + (sliceno % lrr);
-            offset = wrr * hrr * offset;
-			for (i = 0; i < wrr * hrr; i++) {
-				int v = volume->comps[0].data[(i / wrr * w) + (i % wrr) + offset];
-				if (volume->comps[0].bigendian) {
-					for (j = nbytes - 1; j >= 0; j--) {
-                        char byte = (char) ((v >> (j * 8)) & 0xff);
-                        fwrite(&byte, 1, 1, fdest);
-					}
-				} else {
-					for (j = 0; j <= nbytes - 1; j++) {
-                        char byte = (char) ((v >> (j * 8)) & 0xff);
-						fwrite(&byte, 1, 1, fdest);
-					}
-				}
-			}
-		}
-	
-	}
-	
-	fclose(fdest);
-
-	sprintf(name,"%s.img",outfile);
-	fimgdest = fopen(name, "w");
-		if (!fimgdest) {
-			fprintf(stdout, "[ERROR] Failed to open %s for writing\n", name);
-			return 1;
-		}
-	fprintf(fimgdest, "Bpp\t%d\nColor Map\t2\nDimensions\t%d\t%d\t%d\nResolution(mm)\t%d\t%d\t%d\t\n",
-		volume->comps[0].prec,wrr,hrr,lrr,volume->comps[0].dx,volume->comps[0].dy,volume->comps[0].dz);
-
-	fclose(fimgdest);
-	return 0;
-}
-/* -->> -->> -->> -->>
-
-IMG IMAGE FORMAT
-
-<<-- <<-- <<-- <<-- */
-opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters) {
-	int subsampling_dx =  parameters->subsampling_dx;
-	int subsampling_dy =  parameters->subsampling_dy;
-	int subsampling_dz =  parameters->subsampling_dz;
-	
-	int i, compno, w, h, l, numcomps = 1;
-	int prec, max = 0, min = 0;
-	float dx, dy, dz;
-	char filename[100], tmpdirpath[100], dirpath[100], *tmp;
-	char line[100], datatype[100];
-	int bigendian;
-	
-	FILE *f = NULL;
-	FILE *fimg = NULL;
-	OPJ_COLOR_SPACE color_space;
-	opj_volume_cmptparm_t cmptparm;	/* maximum of 1 component */
-	opj_volume_t * volume = NULL;
-	opj_volume_comp_t *comp = NULL;
-
-	bigendian = 0;
-	color_space = CLRSPC_GRAY;
-
-	fimg = fopen(fileimg,"r");
-	if (!fimg) { 
-		fprintf(stderr, "[ERROR] Failed to open %s for reading !!\n", fileimg);
-		return 0;
-	}
-
-	//Fetch only the path 
-	strcpy(tmpdirpath,fileimg);
-	if ((tmp = strrchr(tmpdirpath,'/')) != NULL){
-		tmp++; *tmp='\0';
-		strcpy(dirpath,tmpdirpath);
-	} else {
-		strcpy(dirpath,"./");
-	}
-
-	fseek(fimg, 0, SEEK_SET);
-	while (!feof(fimg)) {
-        fgets(line,100,fimg);
-		//fprintf(stdout,"%s %d \n",line,feof(fimg));
-		if (strncmp(line,"Image",5) == 0){
-			sscanf(line,"%*s%*[ \t]%s",datatype);
-		} else if (strncmp(line,"File",4) == 0){
-			sscanf(line,"%*s %*s%*[ \t]%s",filename);
-			strcat(dirpath, filename);
-			strcpy(filename,dirpath);
-		} else if (strncmp(line,"Min",3) == 0){
-			sscanf(line,"%*s %*s%*[ \t]%d%*[ \t]%d",&min,&max);
-			prec = int_floorlog2(max - min + 1);
-		} else if (strncmp(line,"Bpp",3) == 0){
-			sscanf(line,"%*s%*[ \t]%d",&prec);
-		} else if (strncmp(line,"Color",5) == 0){
-			sscanf(line, "%*s %*s%*[ \t]%d",&color_space);
-		} else if (strncmp(line,"Dim",3) == 0){
-			sscanf(line, "%*s%*[ \t]%d%*[ \t]%d%*[ \t]%d",&w,&h,&l);
-		} else if (strncmp(line,"Res",3) == 0){
-			sscanf(line,"%*s%*[ \t]%f%*[ \t]%f%*[ \t]%f",&dx,&dy,&dz);
-		}
-
-	}
-	#ifdef VERBOSE
-		fprintf(stdout, "[INFO] %s %d \t %d %d %d \t %f %f %f \t %d %d %d \n",filename,color_space,w,h,l,dx,dy,dz,max,min,prec);
-	#endif
-	fclose(fimg);
-
-	/* error control */
-	if ( !prec || !w || !h || !l ){
-		fprintf(stderr,"[ERROR] Unable to read IMG file correctly. Found some null values.");	
-		return NULL;
-	}
-
-	/* initialize volume components */
-	memset(&cmptparm, 0, sizeof(opj_volume_cmptparm_t));
-	
-	cmptparm.prec = prec;
-	cmptparm.bpp = prec;
-	cmptparm.sgnd = 0;
-	cmptparm.bigendian = bigendian;
-	cmptparm.dcoffset = parameters->dcoffset;
-	cmptparm.dx = subsampling_dx;
-	cmptparm.dy = subsampling_dy;
-	cmptparm.dz = subsampling_dz;
-	cmptparm.w = w;
-	cmptparm.h = h;
-	cmptparm.l = l;
-	
-	/* create the volume */
-	volume = opj_volume_create(numcomps, &cmptparm, color_space);
-	if(!volume) {
-		fprintf(stdout,"[ERROR] Unable to create volume");	
-		return NULL;
-	}
-	
-	/* set volume offset and reference grid */
-	volume->x0 = parameters->volume_offset_x0;
-	volume->y0 = parameters->volume_offset_y0;
-	volume->z0 = parameters->volume_offset_z0;
-	volume->x1 = parameters->volume_offset_x0 + (w - 1) *	subsampling_dx + 1;
-	volume->y1 = parameters->volume_offset_y0 + (h - 1) *	subsampling_dy + 1;
-	volume->z1 = parameters->volume_offset_z0 + (l - 1) *	subsampling_dz + 1;
-	
-	max = 0;
-	/* set volume data */
-	f = fopen(filename, "rb");
-	if (!f) {
-		fprintf(stderr, "[ERROR] Failed to open %s for reading !!\n", filename);
-		fclose(f);
-		return 0;
-	}
-	
-	/* BINARY */
-	for (compno = 0; compno < volume->numcomps; compno++) {
-		int whl = w * h * l;
-		/* set volume data */
-		comp = &volume->comps[compno];
-		
-		/*if (comp->prec <= 8) {
-			if (!comp->sgnd) {
-                unsigned char *data = (unsigned char *) malloc(whl * sizeof(unsigned char));
-				fread(data, 1, whl, f);
-				for (i = 0; i < whl; i++) {
-					comp->data[i] = data[i];
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			} else {
-				char *data = (char *) malloc(whl);
-				fread(data, 1, whl, f);
-				for (i = 0; i < whl; i++) {
-					comp->data[i] = data[i];
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			}
-		} else if (comp->prec <= 16) {
-			if (!comp->sgnd) {
-                unsigned short *data = (unsigned short *) malloc(whl * sizeof(unsigned short));
-				int leido = fread(data, 2, whl, f);
-				if (!leido)	{
-					free(data);	fclose(f);
-					return NULL;
-				}
-				
-				for (i = 0; i < whl; i++) {
-					if (bigendian)	//(c1 << 8) + c2;
-						comp->data[i] = data[i];
-					else{			//(c2 << 8) + c1;
-						comp->data[i] = ShortSwap(data[i]);
-					}
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			} else {
-				short *data = (short *) malloc(whl);
-				int leido = fread(data, 2, whl, f);
-				if (!leido)	{
-					free(data);	fclose(f);
-					return NULL;
-				}
-				for (i = 0; i < whl; i++) {
-					if (bigendian){	//(c1 << 8) + c2;
-						comp->data[i] = data[i];
-					}else{			//(c2 << 8) + c1;
-						comp->data[i] = (short) ShortSwap((unsigned short) data[i]);
-					}
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			}
-		} else {
-			if (!comp->sgnd) {
-                unsigned int *data = (unsigned int *) malloc(whl * sizeof(unsigned int));
-				int leido = fread(data, 4, whl, f);
-				if (!leido)	{
-					free(data);	fclose(f);
-					return NULL;
-				}				for (i = 0; i < whl; i++) {
-					if (!bigendian)
-						comp->data[i] = LongSwap(data[i]);
-					else
-						comp->data[i] = data[i];
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-				free(data);
-			} else {
-				int leido = fread(comp->data, 4, whl, f);
-				if (!leido)	{
-					fclose(f);
-					return NULL;
-				}				
-				for (i = 0; i < whl; i++) {
-					if (!bigendian) 
-						comp->data[i] = (int) LongSwap((unsigned int) comp->data[i]);
-					if (comp->data[i] > max)
-						max = comp->data[i];
-				}
-			}
-		}*/
-		
-		for (i = 0; i < whl; i++) {
-			int v;
-			if (comp->prec <= 8) {
-				if (!comp->sgnd) {
-					v = readuchar(f);
-				} else {
-					v = (char) readuchar(f);
-				}
-			} else if (comp->prec <= 16) {
-				if (!comp->sgnd) {
-					v = readushort(f, bigendian);
-				} else {
-					v = (short) readushort(f, bigendian);
-				}
-			} else {
-				if (!comp->sgnd) {
-					v = readuint(f, bigendian);
-				} else {
-					v = (int) readuint(f, bigendian);
-				}
-			}
-			if (v > max)
-				max = v;
-			comp->data[i] = v;
-		}
-		comp->bpp = int_floorlog2(max) + 1;
-	}
-	fclose(f);
-	return volume;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.h b/Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.h
deleted file mode 100755
index 18ae212..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/convert.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __JP3D_CONVERT_H
-#define __JP3D_CONVERT_H
-
-/**
-Load a single volume component encoded in PGX file format
- at param filename Name of the PGX file to load
- at param parameters *List ?*
- at return Returns a greyscale volume if successful, returns NULL otherwise
-*/
-opj_volume_t* pgxtovolume(char *filename, opj_cparameters_t *parameters);
-
-int volumetopgx(opj_volume_t *volume, char *outfile);
-
-opj_volume_t* bintovolume(char *filename,char *fileimg, opj_cparameters_t *parameters);
-
-int volumetobin(opj_volume_t *volume, char *outfile);
-
-opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters);
-
-#endif /* __J2K_CONVERT_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.c b/Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.c
deleted file mode 100755
index 69addc9..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1987, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* last review : october 29th, 2002 */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getopt.c	8.3 (Berkeley) 4/27/95";
-#endif				/* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int opterr = 1,			/* if error message should be printed */
- optind = 1,			/* index into parent argv vector */
- optopt,				/* character checked for validity */
- optreset;				/* reset getopt */
-char *optarg;			/* argument associated with option */
-
-#define	BADCH	(int)'?'
-#define	BADARG	(int)':'
-#define	EMSG	""
-
-/*
- * getopt --
- *	Parse argc/argv argument vector.
- */
-int getopt(int nargc, char *const *nargv, const char *ostr) {
-	
-  #  define __progname nargv[0] /* program name */
-	
-  static char *place = EMSG;	/* option letter processing */
-  char *oli;					/* option letter list index */
-
-  if (optreset || !*place) {	/* update scanning pointer */
-    optreset = 0;
-    if (optind >= nargc || *(place = nargv[optind]) != '-') {
-      place = EMSG;
-      return (-1);
-    }
-    if (place[1] && *++place == '-') {	/* found "--" */
-      ++optind;
-      place = EMSG;
-      return (-1);
-    }
-  }	/* option letter okay? */
-  
-  if ((optopt = (int) *place++) == (int) ':' || !(oli = strchr(ostr, optopt))) {
-    /* if the user didn't specify '-' as an option, assume it means -1. */
-    if (optopt == (int) '-')
-      return (-1);
-    if (!*place)
-      ++optind;
-    if (opterr && *ostr != ':')
-      (void) fprintf(stdout,"[ERROR] %s: illegal option -- %c\n", __progname, optopt);
-    return (BADCH);
-  }
-
-  if (*++oli != ':') {		/* don't need argument */
-    optarg = NULL;
-    if (!*place)
-      ++optind;
-  } else {					/* need an argument */
-    if (*place)						/* no white space */
-      optarg = place;
-    else if (nargc <= ++optind) {	/* no arg */
-      place = EMSG;
-      if (*ostr == ':')
-		return (BADARG);
-      if (opterr)
-		(void) fprintf(stdout, "[ERROR] %s: option requires an argument -- %c\n", __progname, optopt);
-      return (BADCH);
-    } else							/* white space */
-      optarg = nargv[optind];
-    place = EMSG;
-    ++optind;
-  }
-  return (optopt);		/* dump back option letter */
-}
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.h b/Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.h
deleted file mode 100755
index 23299d1..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/getopt.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* last review : october 29th, 2002 */
-
-#ifndef _GETOPT_H_
-#define _GETOPT_H_
-
-extern int opterr;
-extern int optind;
-extern int optopt;
-extern int optreset;
-extern char *optarg;
-
-extern int getopt(int nargc, char *const *nargv, const char *ostr);
-
-#endif				/* _GETOPT_H_ */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_to_volume.c b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_to_volume.c
deleted file mode 100755
index 8df9c40..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_to_volume.c
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "../libjp3dvm/openjpeg3d.h"
-#include "getopt.h"
-#include "convert.h"
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#define stricmp strcasecmp
-#define strnicmp strncasecmp
-#endif /* _WIN32 */
-
-/* ----------------------------------------------------------------------- */
-static double calc_PSNR(opj_volume_t *original, opj_volume_t *decoded)
-{
-	int max, i, k, compno = 0, size;
-	double sum, total = 0;
-	int global = 1;
-    
-	max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
-	if (global) {
-		size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
-
-		for (compno = 0; compno < original->numcomps; compno++) {
-			for(sum = 0, i = 0; i < size; ++i) {
-				if ((decoded->comps[compno].data[i] < 0) || (decoded->comps[compno].data[i] > max))
-					fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
-				else
-					sum += (original->comps[compno].data[i] - decoded->comps[compno].data[i]) * (original->comps[compno].data[i] - decoded->comps[compno].data[i]);        
-			}
-		}
-		sum /= size;
-		total = ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
-	} else {
-		size = (original->x1 - original->x0) * (original->y1 - original->y0);
-
-		for (k = 0; k < original->z1 - original->z0; k++) {
-			int offset = k * size;
-			for (sum = 0, compno = 0; compno < original->numcomps; compno++) {
-				for(i = 0; i < size; ++i) {
-					if ((decoded->comps[compno].data[i + offset] < 0) || (decoded->comps[compno].data[i + offset] > max))
-						fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
-					else
-						sum += (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]) * (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]);        
-				}
-			}
-			sum /= size;
-			total = total + ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
-		}
-
-	}
-	if(total == 0) /* perfect reconstruction, PSNR should return infinity */
-		return -1.0;
-	
-	return total;
-	//return 20 * log10((max - 1) / sqrt(sum));
-}
-
-static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
-{
-	int max, i, compno = 0, size, sizeM;
-	double sum;
-	double mux = 0.0, muy = 0.0, sigmax = 0.0, sigmay = 0.0,
-		sigmaxy = 0.0, structx = 0.0, structy = 0.0;
-	double lcomp,ccomp,scomp;
-	double C1,C2,C3;
-
-	max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
-	size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
-
-	//MSSIM
-
-//	sizeM = size / (original->z1 - original->z0);
-
-	sizeM = size;	
-	for(sum = 0, i = 0; i < sizeM; ++i) {
-		// First, the luminance of each signal is compared.
-		mux += original->comps[compno].data[i];
-		muy += decoded->comps[compno].data[i];
-	}
-	mux /= sizeM;
-	muy /= sizeM;
-	
-	//We use the standard deviation (the square root of variance) as an estimate of the signal contrast.
-    for(sum = 0, i = 0; i < sizeM; ++i) {
-		// First, the luminance of each signal is compared.
-		sigmax += (original->comps[compno].data[i] - mux) * (original->comps[compno].data[i] - mux);
-		sigmay += (decoded->comps[compno].data[i] - muy) * (decoded->comps[compno].data[i] - muy);
-		sigmaxy += (original->comps[compno].data[i] - mux) * (decoded->comps[compno].data[i] - muy);
-	}
-	sigmax /= sizeM - 1;
-	sigmay /= sizeM - 1;
-	sigmaxy /= sizeM - 1;
-	
-	sigmax = sqrt(sigmax);
-	sigmay = sqrt(sigmay);
-	sigmaxy = sqrt(sigmaxy);
-
-	//Third, the signal is normalized (divided) by its own standard deviation, 
-	//so that the two signals being compared have unit standard deviation.
-
-	//Luminance comparison
-	C1 = (0.01 * max) * (0.01 * max);
-	lcomp = ((2 * mux * muy) + C1)/((mux*mux) + (muy*mux) + C1);
-	//Constrast comparison
-	C2 = (0.03 * max) * (0.03 * max);
-	ccomp = ((2 * sigmax * sigmay) + C2)/((sigmax*sigmax) + (sigmay*sigmay) + C2);
-	//Structure comparison
-	C3 = C2 / 2;
-	scomp = (sigmaxy + C3) / (sigmax * sigmay + C3);
-	//Similarity measure
-
-	sum = lcomp * ccomp * scomp;
-	return sum;
-}
-
-void decode_help_display() {
-	fprintf(stdout,"HELP\n----\n\n");
-	fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-	fprintf(stdout,"List of parameters for the JPEG 2000 encoder:\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout," Required arguments \n");
-	fprintf(stdout," ---------------------------- \n");
-	fprintf(stdout,"  -i <compressed file> ( *.jp3d, *.j3d )\n");
-	fprintf(stdout,"    Currently accepts J3D-files. The file type is identified based on its suffix.\n");
-	fprintf(stdout,"  -o <decompressed file> ( *.pgx, *.bin )\n");
-	fprintf(stdout,"    Currently accepts PGX-files and BIN-files. Binary data is written to the file (not ascii). \n");
-	fprintf(stdout,"    If a PGX filename is given, there will be as many output files as slices; \n");
-	fprintf(stdout,"    an indice starting from 0 will then be appended to the output filename,\n");
-	fprintf(stdout,"    just before the \"pgx\" extension.\n");
-	fprintf(stdout,"  -m <characteristics file> ( *.img ) \n");
-	fprintf(stdout,"    Required only for BIN-files. Ascii data of volume characteristics is written. \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout," Optional  \n");
-	fprintf(stdout," ---------------------------- \n");
-	fprintf(stdout,"  -h \n ");
-	fprintf(stdout,"    Display the help information\n");
-	fprintf(stdout,"  -r <RFx,RFy,RFz>\n");
-	fprintf(stdout,"    Set the number of highest resolution levels to be discarded on each dimension. \n");
-	fprintf(stdout,"    The volume resolution is effectively divided by 2 to the power of the\n");
-	fprintf(stdout,"    number of discarded levels. The reduce factor is limited by the\n");
-	fprintf(stdout,"    smallest total number of decomposition levels among tiles.\n");
-	fprintf(stdout,"  -l <number of quality layers to decode>\n");
-	fprintf(stdout,"    Set the maximum number of quality layers to decode. If there are\n");
-	fprintf(stdout,"    less quality layers than the specified number, all the quality layers\n");
-	fprintf(stdout,"    are decoded. \n");
-	fprintf(stdout,"  -O original-file \n");
-    fprintf(stdout,"    This option offers the possibility to compute some quality results  \n");
-	fprintf(stdout,"    for the decompressed volume, like the PSNR value achieved or the global SSIM value.  \n");
-	fprintf(stdout,"    Needs the original file in order to compare with the new one.\n");
-    fprintf(stdout,"    NOTE: Only valid when -r option is 0,0,0 (both original and decompressed volumes have same resolutions) \n");
-    fprintf(stdout,"    NOTE: If original file is .BIN file, the volume characteristics file shall be defined with the -m option. \n");
-	fprintf(stdout,"    (i.e. -O original-BIN-file -m original-IMG-file) \n");
-	fprintf(stdout,"  -BE \n");
-	fprintf(stdout,"    Define that the recovered volume data will be saved with big endian byte order.\n");
-	fprintf(stdout,"    By default, little endian byte order is used.\n");
-	fprintf(stdout,"\n");
-}
-
-/* -------------------------------------------------------------------------- */
-
-int get_file_format(char *filename) {
-	int i;
-	static const char *extension[] = {"pgx", "bin", "j3d", "jp3d", "j2k", "img"};
-	static const int format[] = { PGX_DFMT, BIN_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT, IMG_DFMT};
-	char * ext = strrchr(filename, '.');
-	if(ext) {
-		ext++;
-		for(i = 0; i < sizeof(format) / sizeof(format[0]); i++) {
-			if(strnicmp(ext, extension[i], 3) == 0) {
-				return format[i];
-			}
-		}
-	}
-
-	return -1;
-}
-
-/* -------------------------------------------------------------------------- */
-
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters) {
-	/* parse the command line */
-
-	while (1) {
-		int c = getopt(argc, argv, "i:o:O:r:l:B:m:h");
-		if (c == -1)			  
-			break;
-		switch (c) {
-			case 'i':			/* input file */
-			{
-				char *infile = optarg;
-				parameters->decod_format = get_file_format(infile);
-				switch(parameters->decod_format) {
-					case J3D_CFMT:
-					case J2K_CFMT:
-						break;
-					default:
-						fprintf(stdout, "[ERROR] Unknown format for infile %s [only *.j3d]!! \n", infile);
-						return 1;
-						break;
-				}
-				strncpy(parameters->infile, infile, MAX_PATH);
-				fprintf(stdout,	"[INFO] Infile: %s \n", parameters->infile);
-
-			}
-			break;
-
-			case 'm':			/* img file */
-			{
-				char *imgfile = optarg;
-				int imgformat = get_file_format(imgfile);
-				switch(imgformat) {
-					case IMG_DFMT:
-						break;
-					default:
-						fprintf(stdout,	"[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n", imgfile);
-						return 1;
-						break;
-				}
-				strncpy(parameters->imgfile, imgfile, MAX_PATH);
-				fprintf(stdout,	"[INFO] Imgfile: %s Format: %d\n", parameters->imgfile, imgformat);
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-
-			case 'o':			/* output file */
-			{
-				char *outfile = optarg;
-				parameters->cod_format = get_file_format(outfile);
-				switch(parameters->cod_format) {
-					case PGX_DFMT:
-					case BIN_DFMT:
-						break;
-					default:
-						fprintf(stdout,	"[ERROR] Unrecognized format for outfile : %s [accept only *.pgx or *.bin] !!\n\n", outfile);
-						return 1;
-						break;
-				}
-				strncpy(parameters->outfile, outfile, MAX_PATH);
-				fprintf(stdout,	"[INFO] Outfile: %s \n", parameters->outfile);
-
-			}
-			break;
-			
-				/* ----------------------------------------------------- */
-
-			case 'O':		/* Original image for PSNR computing */
-			{
-				char *original = optarg;
-				parameters->orig_format = get_file_format(original);
-				switch(parameters->orig_format) {
-					case PGX_DFMT:
-					case BIN_DFMT:
-						break;
-					default:
-						fprintf(stdout,	"[ERROR] Unrecognized format for original file : %s [accept only *.pgx or *.bin] !!\n\n", original);
-						return 1;
-						break;
-				}
-				strncpy(parameters->original, original, MAX_PATH);
-				fprintf(stdout,	"[INFO] Original file: %s \n", parameters->original);
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-	    
-			case 'r':		/* reduce option */
-			{
-				//sscanf(optarg, "%d, %d, %d", &parameters->cp_reduce[0], &parameters->cp_reduce[1], &parameters->cp_reduce[2]);
-				int aux;
-				aux = sscanf(optarg, "%d,%d,%d", &parameters->cp_reduce[0], &parameters->cp_reduce[1], &parameters->cp_reduce[2]);
-				if (aux == 2) 
-					parameters->cp_reduce[2] = 0;
-				else if (aux == 1) {
-					parameters->cp_reduce[1] = parameters->cp_reduce[0];
-					parameters->cp_reduce[2] = 0;
-				}else if (aux == 0){
-					parameters->cp_reduce[0] = 0;
-					parameters->cp_reduce[1] = 0;
-					parameters->cp_reduce[2] = 0;
-				}
-			}
-			break;
-			
-				/* ----------------------------------------------------- */
-
-			case 'l':		/* layering option */
-			{
-				sscanf(optarg, "%d", &parameters->cp_layer);
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-
-			case 'B':		/* BIGENDIAN vs. LITTLEENDIAN */
-			{
-				parameters->bigendian = 1;
-			}
-			break;
-			
-				/* ----------------------------------------------------- */
-
-			case 'L':		/* BIGENDIAN vs. LITTLEENDIAN */
-			{
-				parameters->decod_format = LSE_CFMT;
-			}
-			break;
-			
-			/* ----------------------------------------------------- */
-			
-			case 'h': 			/* display an help description */
-			{
-				decode_help_display();
-				return 1;
-			}
-			break;
-            
-				/* ----------------------------------------------------- */
-			
-			default:
-				fprintf(stdout,"[WARNING] This option is not valid \"-%c %s\"\n",c, optarg);
-				break;
-		}
-	}
-
-	/* check for possible errors */
-
-	if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
-		fprintf(stdout,"[ERROR] At least one required argument is missing\n Check jp3d_to_volume -help for usage information\n");
-		return 1;
-	}
-
-	return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char **argv) {
-
-	opj_dparameters_t parameters;	/* decompression parameters */
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_volume_t *volume = NULL;
-
-	opj_volume_t *original = NULL;
-	opj_cparameters_t cparameters;	/* original parameters */
-
-	FILE *fsrc = NULL;
-	unsigned char *src = NULL; 
-	int file_length;
-	int decodeok;
-	double psnr, ssim;
-
-	opj_dinfo_t* dinfo = NULL;	/* handle to a decompressor */
-	opj_cio_t *cio = NULL;
-
-	/* configure the event callbacks (not required) */
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* set decoding parameters to default values */
-	opj_set_default_decoder_parameters(&parameters);
-
-    /* parse input and get user decoding parameters */
-	strcpy(parameters.original,"NULL");
-	strcpy(parameters.imgfile,"NULL");
-	if(parse_cmdline_decoder(argc, argv, &parameters) == 1) {
-		return 0;
-	}
-	
-	/* read the input file and put it in memory */
-	/* ---------------------------------------- */
-	fprintf(stdout, "[INFO] Loading %s file \n",parameters.decod_format==J3D_CFMT ? ".jp3d" : ".j2k");
-	fsrc = fopen(parameters.infile, "rb");
-	if (!fsrc) {
-		fprintf(stdout, "[ERROR] Failed to open %s for reading\n", parameters.infile);
-		return 1;
-	}  
-	fseek(fsrc, 0, SEEK_END);
-	file_length = ftell(fsrc);
-	fseek(fsrc, 0, SEEK_SET);
-	src = (unsigned char *) malloc(file_length);
-	fread(src, 1, file_length, fsrc);
-	fclose(fsrc);
-	
-	/* decode the code-stream */
-	/* ---------------------- */
-	if (parameters.decod_format == J3D_CFMT || parameters.decod_format == J2K_CFMT) {		
-		/* get a JP3D or J2K decoder handle */
-		if (parameters.decod_format == J3D_CFMT) 
-			dinfo = opj_create_decompress(CODEC_J3D);
-		else if (parameters.decod_format == J2K_CFMT) 
-			dinfo = opj_create_decompress(CODEC_J2K);
-
-		/* catch events using our callbacks and give a local context */
-		opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);			
-
-		/* setup the decoder decoding parameters using user parameters */
-		opj_setup_decoder(dinfo, &parameters);
-
-		/* open a byte stream */
-		cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
-		/* decode the stream and fill the volume structure */
-		volume = opj_decode(dinfo, cio);
-		if(!volume) {
-			fprintf(stdout, "[ERROR] jp3d_to_volume: failed to decode volume!\n");				
-			opj_destroy_decompress(dinfo);
-			opj_cio_close(cio);
-			return 1;
-		}	
-
-		/* close the byte stream */
-		opj_cio_close(cio);
-	}
-  
-	/* free the memory containing the code-stream */
-	free(src);
-	src = NULL;
-
-	/* create output volume */
-	/* ------------------- */
-
-	switch (parameters.cod_format) {
-		case PGX_DFMT:			/* PGX */
-			decodeok = volumetopgx(volume, parameters.outfile);
-			if (decodeok)
-				fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
-			break;
-		
-		case BIN_DFMT:			/* BMP */
-			decodeok = volumetobin(volume, parameters.outfile);
-			if (decodeok)
-				fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
-			break;
-	}
-	switch (parameters.orig_format) {
-		case PGX_DFMT:			/* PGX */
-			if (strcmp("NULL",parameters.original) != 0){
- 				fprintf(stdout,"Loading original file %s \n",parameters.original);
-				cparameters.subsampling_dx = 1;	cparameters.subsampling_dy = 1;	cparameters.subsampling_dz = 1;
-				cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
-				original = pgxtovolume(parameters.original,&cparameters);
-			}
-			break;
-		
-		case BIN_DFMT:			/* BMP */
-			if (strcmp("NULL",parameters.original) != 0 && strcmp("NULL",parameters.imgfile) != 0){
-				fprintf(stdout,"Loading original file %s %s\n",parameters.original,parameters.imgfile);
-				cparameters.subsampling_dx = 1;	cparameters.subsampling_dy = 1;	cparameters.subsampling_dz = 1;
-				cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
-				original = bintovolume(parameters.original,parameters.imgfile,&cparameters);
-			}
-			break;
-	}
-
-	fprintf(stdout, "[RESULT] Volume: %d x %d x %d (x %d bpv)\n ", 
-			 (volume->comps[0].w >> volume->comps[0].factor[0]),
-			 (volume->comps[0].h >> volume->comps[0].factor[1]),
-			 (volume->comps[0].l >> volume->comps[0].factor[2]),volume->comps[0].prec);
-
-	if(original){
-		psnr = calc_PSNR(original,volume);
-		ssim = calc_SSIM(original,volume);
-		if (psnr < 0.0)
-			fprintf(stdout, "  PSNR: Inf , SSMI %f -- Perfect reconstruction!\n",ssim);
-		else
-			fprintf(stdout, "  PSNR: %f , SSIM %f \n",psnr,ssim);
-	}
-	/* free remaining structures */
-	if(dinfo) {
-		opj_destroy_decompress(dinfo);
-	}
-
-	/* free volume data structure */
-	opj_volume_destroy(volume);
-   
-	return 0;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.ncb b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.ncb
deleted file mode 100755
index fc66b66..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.ncb and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.sln b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.sln
deleted file mode 100755
index e696c5f..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.sln
+++ /dev/null
@@ -1,30 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jp3d_vm_dec", "jp3d_vm_dec.vcproj", "{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}"
-	ProjectSection(ProjectDependencies) = postProject
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibJp3dVM", "..\LibJp3dVM.vcproj", "{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		Debug = Debug
-		Release = Release
-	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Debug.ActiveCfg = Debug|Win32
-		{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Debug.Build.0 = Debug|Win32
-		{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Release.ActiveCfg = Release|Win32
-		{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Release.Build.0 = Release|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.ActiveCfg = Debug|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.Build.0 = Debug|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.ActiveCfg = Release|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.suo b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.suo
deleted file mode 100755
index 28c2e25..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.suo and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.vcproj b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.vcproj
deleted file mode 100755
index 142c68d..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_dec.vcproj
+++ /dev/null
@@ -1,157 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="7.10"
-	Name="jp3d_vm_dec"
-	ProjectGUID="{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}"
-	SccProjectName=""
-	SccLocalPath="">
-	<Platforms>
-		<Platform
-			Name="Win32"/>
-	</Platforms>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libjp3dvm"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="2"
-				PrecompiledHeaderFile=".\Debug/jp3d_vm_dec.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				DebugInformationFormat="4"
-				CompileAs="0"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Debug/jp3d_vm_dec.exe"
-				LinkIncremental="0"
-				SuppressStartupBanner="TRUE"
-				GenerateDebugInformation="TRUE"
-				ProgramDatabaseFile=".\Debug/jp3d_vm_dec.pdb"
-				SubSystem="1"
-				TargetMachine="1"/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Debug/j2k_to_image.tlb"
-				HeaderFileName=""/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="copy Debug\jp3d_vm_dec.exe ..\bin"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1036"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="../libjp3dvm"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC"
-				StringPooling="TRUE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="TRUE"
-				PrecompiledHeaderFile=".\Release/jp3d_vm_dec.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				CompileAs="0"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Release/jp3d_vm_dec.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="TRUE"
-				ProgramDatabaseFile=".\Release/jp3d_vm_dec.pdb"
-				SubSystem="1"
-				TargetMachine="1"/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/j2k_to_image.tlb"
-				HeaderFileName=""/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="copy Release\jp3d_vm_dec.exe ..\bin"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1036"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<File
-			RelativePath=".\convert.c">
-		</File>
-		<File
-			RelativePath=".\convert.h">
-		</File>
-		<File
-			RelativePath=".\getopt.c">
-		</File>
-		<File
-			RelativePath=".\getopt.h">
-		</File>
-		<File
-			RelativePath=".\jp3d_to_volume.c">
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.ncb b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.ncb
deleted file mode 100755
index 7f0733b..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.ncb and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.sln b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.sln
deleted file mode 100755
index a0e6a74..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.sln
+++ /dev/null
@@ -1,35 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jp3d_vm_enc", "jp3d_vm_enc.vcproj", "{A9704A2E-3B93-4BAA-9229-02FC93D27201}"
-	ProjectSection(ProjectDependencies) = postProject
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibJp3dVM", "..\LibJp3dVM.vcproj", "{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
-	ProjectSection(ProjectDependencies) = postProject
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		Debug = Debug
-		Release = Release
-	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Debug.ActiveCfg = Debug|Win32
-		{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Debug.Build.0 = Debug|Win32
-		{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Release.ActiveCfg = Release|Win32
-		{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Release.Build.0 = Release|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.ActiveCfg = Debug|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.Build.0 = Debug|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.ActiveCfg = Release|Win32
-		{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.suo b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.suo
deleted file mode 100755
index 702d0dd..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.suo and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.vcproj b/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.vcproj
deleted file mode 100755
index 4c24b35..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/jp3d_vm_enc.vcproj
+++ /dev/null
@@ -1,157 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="7.10"
-	Name="jp3d_vm_enc"
-	ProjectGUID="{A9704A2E-3B93-4BAA-9229-02FC93D27201}"
-	SccProjectName=""
-	SccLocalPath="">
-	<Platforms>
-		<Platform
-			Name="Win32"/>
-	</Platforms>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="../libjp3dvm"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC"
-				StringPooling="TRUE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="TRUE"
-				PrecompiledHeaderFile=".\Release/jp3d_vm_enc.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				CompileAs="0"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Release/jp3d_vm_enc.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="TRUE"
-				ProgramDatabaseFile=".\Release/jp3d_vm_enc.pdb"
-				SubSystem="1"
-				TargetMachine="1"/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/image_to_j2k.tlb"
-				HeaderFileName=""/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="copy Release\jp3d_vm_enc.exe ..\bin"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1036"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libjp3dvm"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\Debug/jp3d_vm_enc.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				DebugInformationFormat="4"
-				CompileAs="0"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Debug/jp3d_vm_enc.exe"
-				LinkIncremental="0"
-				SuppressStartupBanner="TRUE"
-				AdditionalLibraryDirectories=""
-				GenerateDebugInformation="TRUE"
-				ProgramDatabaseFile=".\Debug/jp3d_vm_enc.pdb"
-				SubSystem="1"
-				TargetMachine="1"/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Debug/image_to_j2k.tlb"
-				HeaderFileName=""/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="copy Debug\jp3d_vm_enc.exe ..\bin"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1036"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"/>
-			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<File
-			RelativePath=".\convert.c">
-		</File>
-		<File
-			RelativePath=".\convert.h">
-		</File>
-		<File
-			RelativePath=".\getopt.c">
-		</File>
-		<File
-			RelativePath=".\getopt.h">
-		</File>
-		<File
-			RelativePath=".\volume_to_jp3d.c">
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/volume_to_jp3d.c b/Utilities/gdcmopenjpeg-v1/jp3d/codec/volume_to_jp3d.c
deleted file mode 100755
index d966f2e..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/volume_to_jp3d.c
+++ /dev/null
@@ -1,906 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "../libjp3dvm/openjpeg3d.h"
-#include "getopt.h"
-#include "convert.h"
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#define stricmp strcasecmp
-#define strnicmp strncasecmp
-#endif /* _WIN32 */
-
-/* ----------------------------------------------------------------------- */
-
-void encode_help_display() {
-	fprintf(stdout,"List of parameters for the JPEG2000 Part 10 encoder:\n");
-	fprintf(stdout,"------------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"Required Parameters (except with -h):\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-i           : source file  (-i source.bin or source*.pgx) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-m           : source characteristics file (-m imgfile.img) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-o           : destination file (-o dest.jp3d) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"Optional Parameters:\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-h           : display the help information \n ");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-n           : number of resolutions (-n 3,3,3) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-I           : use the irreversible transforms: ICT + DWT 9-7 (-I) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-C           : coding algorithm (-C 2EB) [2EB, 3EB] \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-r           : different compression ratios for successive layers (-r 20,10,5)\n ");
-	fprintf(stdout,"	         - The rate specified for each quality level is the desired compression factor.\n");
-	fprintf(stdout,"	         - Rate 1 means lossless compression\n");
-	fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-q           : different psnr for successive layers (-q 30,40,50) \n ");
-	fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-b           : size of code block (-b 32,32,32) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-c           : size of precinct (-c 128,128,128) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-t           : size of tile (-t 512,512,512) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-p           : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-s           : subsampling factor (-s 2,2,2) [-s X,Y,Z] \n");
-	fprintf(stdout,"			  - Remark: subsampling bigger than 2 can produce error\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-SOP         : write SOP marker before each packet \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-EPH         : write EPH marker after each header packet \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-M           : code-block style (-M 0) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
-	fprintf(stdout,"                 8=VSC 16=PTERM 32=SEGSYM 64=3DCTXT] \n");
-	fprintf(stdout,"                 Indicate multiple modes by adding their values. \n");
-	fprintf(stdout,"                 ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-D           : define DC offset (-D 12) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-x           : create an index file *.Idx (-x index_name.Idx) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-ROI         : c=%%d,U=%%d : quantization indices upshifted \n");
-	fprintf(stdout,"               for component c=%%d [%%d = 0,1,2]\n");
-	fprintf(stdout,"               with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-d           : offset of the origin of the volume (-d 150,300,100) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"-l           : offset of the origin of the tiles (-l 100,75,25) \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"DEFAULT CODING:\n");
-	fprintf(stdout,"------------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout," * Lossless\n");
-	fprintf(stdout," * 1 tile\n");
-	fprintf(stdout," * Size of precinct : 2^15 x 2^15 x 2^15 (means 1 precinct)\n");
-	fprintf(stdout," * Size of code-block : 64 x 64 x 64\n");
-	fprintf(stdout," * Number of resolutions in x, y and z axis: 3\n");
-	fprintf(stdout," * No SOP marker in the codestream\n");
-	fprintf(stdout," * No EPH marker in the codestream\n");
-	fprintf(stdout," * No sub-sampling in x, y or z direction\n");
-	fprintf(stdout," * No mode switch activated\n");
-	fprintf(stdout," * Progression order: LRCP\n");
-	fprintf(stdout," * No index file\n");
-	fprintf(stdout," * No ROI upshifted\n");
-	fprintf(stdout," * No offset of the origin of the volume\n");
-	fprintf(stdout," * No offset of the origin of the tiles\n");
-	fprintf(stdout," * Reversible DWT 5-3 on each 2D slice\n");
-	fprintf(stdout," * Coding algorithm: 2D-EBCOT \n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"REMARKS:\n");
-	fprintf(stdout,"---------\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"- The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
-	fprintf(stdout,"- COD and QCD markers will never appear in the tile_header.\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"- You need enough disk space memory (twice the original) to encode \n");
-	fprintf(stdout,"the volume,i.e. for a 1.5 GB volume you need a minimum of 3GB of disk memory)\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"- When loading *.pgx files, a relative path to directory is needed for input argument \n");
-	fprintf(stdout," followed by the common prefix of the slices and a '*' character representing sequential numeration.\n");
-	fprintf(stdout,"( -i relativepath/slices*.pgx )\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout," - The index file has the structure below:\n");
-	fprintf(stdout,"\n");
-	fprintf(stdout,"\t	Image_height Image_width Image_depth\n");
-	fprintf(stdout,"\t	Progression order: 0 (LRCP)\n");
-	fprintf(stdout,"\t	Tiles_size_X Tiles_size_Y Tiles_size_Z\n");
-	fprintf(stdout,"\t	Components_nb\n");
-	fprintf(stdout,"\t	Layers_nb\n");
-	fprintf(stdout,"\t	Decomposition_levels\n");
-	fprintf(stdout,"\t	[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr Precincts_size_Z_res_Nr]\n\t  ...\n");
-	fprintf(stdout,"\t	[Precincts_size_X_res_0 Precincts_size_Y_res_0 Precincts_size_Z_res_0]\n");
-	fprintf(stdout,"\t	Main_header_end_position\n");
-	fprintf(stdout,"\t	Codestream_size\n");
-	fprintf(stdout,"\t	Tile_0 [start_pos end_header end_pos TotalDisto NumPix MaxMSE]\n");
-	fprintf(stdout,"\t	...\n");
-	fprintf(stdout,"\t	Tile_Nt [  ''         ''        ''        ''       ''    ''  ]\n");
-	fprintf(stdout,"\t  Tpacket_0 [Tile layer res. comp. prec. start_pos end_pos disto]\n");
-	fprintf(stdout,"\t  ...\n");
-	fprintf(stdout,"\t  Tpacket_Np [''   ''    ''   ''    ''       ''       ''     '' ]\n");
-	fprintf(stdout,"\t  MaxDisto\n");
-	fprintf(stdout,"\t  TotalDisto\n\n");
-	fprintf(stdout,"\n");
-
-}
-
-OPJ_PROG_ORDER give_progression(char progression[4]) {
-	if(strncmp(progression, "LRCP", 4) == 0) {
-		return LRCP;
-	}
-	if(strncmp(progression, "RLCP", 4) == 0) {
-		return RLCP;
-	}
-	if(strncmp(progression, "RPCL", 4) == 0) {
-		return RPCL;
-	}
-	if(strncmp(progression, "PCRL", 4) == 0) {
-		return PCRL;
-	}
-	if(strncmp(progression, "CPRL", 4) == 0) {
-		return CPRL;
-	}
-
-	return PROG_UNKNOWN;
-}
-
-OPJ_TRANSFORM give_transform(char transform[4]) {
-	if(strncmp(transform, "2DWT", 4) == 0) {
-		return TRF_2D_DWT;
-	}
-	if(strncmp(transform, "3DWT", 4) == 0) {
-		return TRF_3D_DWT;
-	}
-	return TRF_UNKNOWN;
-}
-
-OPJ_ENTROPY_CODING give_coding(char coding[3]) {
-
-	if(strncmp(coding, "2EB", 3) == 0) {
-		return ENCOD_2EB;
-	}
-	if(strncmp(coding, "3EB", 3) == 0) {
-		return ENCOD_3EB;
-	}
-	/*if(strncmp(coding, "2GR", 3) == 0) {
-		return ENCOD_2GR;
-	}
-	if(strncmp(coding, "3GR", 3) == 0) {
-		return ENCOD_3GR;
-	}*/
-
-	return ENCOD_UNKNOWN;
-}
-
-int get_file_format(char *filename) {
-	int i;
-	static const char *extension[] = {"pgx", "bin", "img", "j3d", "jp3d", "j2k"};
-	static const int format[] = { PGX_DFMT, BIN_DFMT, IMG_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT};
-	char * ext = strrchr(filename, '.');
-	if (ext) {
-		ext++;
-        for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
-			if(strnicmp(ext, extension[i], 3) == 0) {
-                return format[i];
-			}
-		}
-	}
-
-	return -1;
-}
-
-/* ------------------------------------------------------------------------------------ */
-
-int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters) {
-	int i, value;
-
-	/* parse the command line */
-
-	while (1) {
-		int c = getopt(argc, argv, "i:m:o:r:q:f:t:n:c:b:x:p:s:d:hP:S:E:M:D:R:l:T:C:A:I");
-		if (c == -1)
-			break;
-		switch (c) {
-			case 'i':			/* input file */
-			{
-				char *infile = optarg;
-				parameters->decod_format = get_file_format(infile);
-				switch(parameters->decod_format) {
-					case PGX_DFMT:
-					case BIN_DFMT:
-					case IMG_DFMT:
-						break;
-					default:
-						fprintf(stdout,	"[ERROR] Unrecognized format for infile : %s [accept only *.pgx or *.bin] !!\n\n", infile);
-						return 1;
-						break;
-				}
-				strncpy(parameters->infile, infile, MAX_PATH);
-				fprintf(stdout,	"[INFO] Infile: %s \n", parameters->infile);
-
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			case 'm':			/* input IMG file */
-			{
-				char *imgfile = optarg;
-				int imgformat = get_file_format(imgfile);
-				switch(imgformat) {
-					case IMG_DFMT:
-						break;
-					default:
-						fprintf(stdout,	"[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n", imgfile);
-						return 1;
-						break;
-				}
-				strncpy(parameters->imgfile, imgfile, MAX_PATH);
-				fprintf(stdout,	"[INFO] Imgfile: %s Format: %d\n", parameters->imgfile, imgformat);
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			case 'o':			/* output file */
-			{
-				char *outfile = optarg;
-				parameters->cod_format = get_file_format(outfile);
-				switch(parameters->cod_format) {
-					case J3D_CFMT:
-					case J2K_CFMT:
-					case LSE_CFMT:
-						break;
-					default:
-						fprintf(stdout, "[ERROR] Unknown output format volume %s [only *.j2k, *.lse3d or *.jp3d]!! \n", outfile);
-						return 1;
-						break;
-				}
-				strncpy(parameters->outfile, outfile, MAX_PATH);
-				fprintf(stdout,	"[INFO] Outfile: %s \n", parameters->outfile);
-			}
-			break;
-
-				/* ----------------------------------------------------- */
-			
-			case 'r':			/* define compression rates for each layer */
-			{
-				char *s = optarg;
-				while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
-					parameters->tcp_numlayers++;
-					while (*s && *s != ',') {
-						s++;
-					}
-					if (!*s)
-						break;
-					s++;
-				}
-				parameters->cp_disto_alloc = 1;
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 'q':			/* define distorsion (PSNR) for each layer */
-			{
-				char *s = optarg;
-				while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
-					parameters->tcp_numlayers++;
-					while (*s && *s != ',') {
-						s++;
-					}
-					if (!*s)
-						break;
-					s++;
-				}
-				parameters->cp_fixed_quality = 1;
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-
-			case 'f':	
-			{
-				fprintf(stdout, "/---------------------------------------------------\\\n");
-				fprintf(stdout, "|  Fixed layer allocation option not implemented !!  |\n");
-				fprintf(stdout, "\\---------------------------------------------------/\n");
-				/*int *row = NULL, *col = NULL;
-				int numlayers = 0, matrix_width = 0;
-
-				char *s = optarg;
-				sscanf(s, "%d", &numlayers);
-				s++;
-				if (numlayers > 9)
-					s++;
-
-				parameters->tcp_numlayers = numlayers;
-				matrix_width = parameters->numresolution[0] + parameters->numresolution[1] + parameters->numresolution[2];
-				parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
-				s = s + 2;
-
-				for (i = 0; i < numlayers; i++) {
-					row = &parameters->cp_matrice[i * matrix_width];
-					col = row;
-					parameters->tcp_rates[i] = 1;
-					sscanf(s, "%d,", &col[0]);
-					s += 2;
-					if (col[0] > 9)
-						s++;
-					col[1] = 0;
-					col[2] = 0;
-					for (j = 1; j < matrix_width; j++) {
-						col += 3; j+=2;
-						sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
-						s += 6;
-						if (col[0] > 9)
-							s++;
-						if (col[1] > 9)
-							s++;
-						if (col[2] > 9)
-							s++;
-					}
-					if (i < numlayers - 1)
-						s++;
-				}
-				parameters->cp_fixed_alloc = 1; */
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-
-			case 't':			/* tiles */
-			{
-				if (sscanf(optarg, "%d,%d,%d", &parameters->cp_tdx, &parameters->cp_tdy, &parameters->cp_tdz) !=3) {
-					fprintf(stdout,	"[ERROR] '-t' 'dimensions of tiles' argument error !  [-t tdx,tdy,tdz]\n");
-					return 1;
-				}
-				parameters->tile_size_on = true;
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 'n':			/* resolution */
-			{
-				int aux;
-				aux = sscanf(optarg, "%d,%d,%d", &parameters->numresolution[0], &parameters->numresolution[1], &parameters->numresolution[2]);
-				if (aux == 2) 
-					parameters->numresolution[2] = 1;
-				else if (aux == 1) {
-					parameters->numresolution[1] = parameters->numresolution[0];
-					parameters->numresolution[2] = 1;
-				}else if (aux == 0){
-					parameters->numresolution[0] = 1;
-					parameters->numresolution[1] = 1;
-					parameters->numresolution[2] = 1;
-				}
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			case 'c':			/* precinct dimension */
-			{
-				char sep;
-				int res_spec = 0;
-				int aux;
-				char *s = optarg;
-				do {
-					sep = 0;
-					aux = sscanf(s, "[%d,%d,%d]%c", &parameters->prct_init[0][res_spec], &parameters->prct_init[1][res_spec], &parameters->prct_init[2][res_spec], &sep);
-					if (sep == ',' && aux != 4) {
-						fprintf(stdout,	"[ERROR] '-c' 'dimensions of precincts' argument error !  [-c [prcx_res0,prcy_res0,prcz_res0],...,[prcx_resN,prcy_resN,prcz_resN]]\n");
-						return 1;
-					}
-					parameters->csty |= 0x01;
-					res_spec++;
-					s = strpbrk(s, "]") + 2;
-				}
-				while (sep == ',');
-				parameters->res_spec = res_spec; /* number of precinct size specifications */
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 'b':			/* code-block dimension */
-			{
-				int cblockw_init = 0, cblockh_init = 0, cblockl_init = 0;
-				if (sscanf(optarg, "%d,%d,%d", &cblockw_init, &cblockh_init, &cblockl_init) != 3) {
-					fprintf(stdout,	"[ERROR] '-b' 'dimensions of codeblocks' argument error !  [-b cblkx,cblky,cblkz]\n");
-					return 1;
-				}
-				if (cblockw_init * cblockh_init * cblockl_init > (1<<18) || cblockw_init > 1024 || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4 || cblockl_init > 1024 || cblockl_init < 4) {
-					fprintf(stdout,"[ERROR] Size of code_block error (option -b) !!\n\nRestriction :\n * width*height*length<=4096\n * 4<=width,height,length<= 1024\n\n");
-					return 1;
-				}
-				parameters->cblock_init[0] = cblockw_init;
-				parameters->cblock_init[1] = cblockh_init;
-				parameters->cblock_init[2] = cblockl_init;
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 'x':			/* creation of index file */
-			{
-				char *index = optarg;
-				strncpy(parameters->index, index, MAX_PATH);
-				parameters->index_on = 1;
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 'p':			/* progression order */
-			{
-				char progression[4];
-
-				strncpy(progression, optarg, 4);
-				parameters->prog_order = give_progression(progression);
-				if (parameters->prog_order == -1) {
-					fprintf(stdout, "[ERROR] Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
-					return 1;
-				}
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 's':			/* subsampling factor */
-			{
-				if (sscanf(optarg, "%d,%d,%d", &parameters->subsampling_dx, &parameters->subsampling_dy, &parameters->subsampling_dz) != 2) {
-					fprintf(stdout,	"[ERROR] '-s' sub-sampling argument error !  [-s dx,dy,dz]\n");
-					return 1;
-				}
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 'd':			/* coordonnate of the reference grid */
-			{
-				if (sscanf(optarg, "%d,%d,%d", &parameters->volume_offset_x0, &parameters->volume_offset_y0, &parameters->volume_offset_z0) != 3) {
-					fprintf(stdout,	"[ERROR] -d 'coordonnate of the reference grid' argument error !! [-d x0,y0,z0]\n");
-					return 1;
-				}
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-			
-			case 'h':			/* display an help description */
-			{
-				encode_help_display();
-				return 1;
-			}
-			break;
-				
-				/* ----------------------------------------------------- */
-
-			case 'P':			/* POC */
-			{
-				int numpocs = 0;		/* number of progression order change (POC) default 0 */
-				opj_poc_t *POC = NULL;	/* POC : used in case of Progression order change */
-
-				char *s = optarg;
-				POC = parameters->POC;
-
-				fprintf(stdout, "/----------------------------------\\\n");
-				fprintf(stdout, "|  POC option not fully tested !!  |\n");
-				fprintf(stdout, "\\----------------------------------/\n");
-				
-				while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%s", &POC[numpocs].tile,
-														&POC[numpocs].resno0, &POC[numpocs].compno0,
-														&POC[numpocs].layno1, &POC[numpocs].resno1,
-														&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
-					POC[numpocs].prg = give_progression(POC[numpocs].progorder);
-					/* POC[numpocs].tile; */
-					numpocs++;
-					while (*s && *s != '/') {
-						s++;
-					}
-					if (!*s) {
-						break;
-					}
-					s++;
-				}
-				parameters->numpocs = numpocs;
-			}
-			break;
-				
-				/* ------------------------------------------------------ */
-				
-			case 'S':			/* SOP marker */
-			{
-				parameters->csty |= 0x02;
-			}
-			break;
-				
-				/* ------------------------------------------------------ */
-			
-			case 'E':			/* EPH marker */
-			{
-				parameters->csty |= 0x04;
-			}
-			break;
-				
-				/* ------------------------------------------------------ */
-			
-			case 'M':			/* Codification mode switch */
-			{
-				fprintf(stdout, "[INFO] Mode switch option not fully tested !!\n");
-				value = 0;
-				if (sscanf(optarg, "%d", &value) == 1) {
-					for (i = 0; i <= 6; i++) {
-						int cache = value & (1 << i);
-						if (cache)
-							parameters->mode |= (1 << i);
-					}
-				}
-			}
-			break;
-				
-				/* ------------------------------------------------------ */
-			
-			case 'D':			/* DCO */
-			{
-				if (sscanf(optarg, "%d", &parameters->dcoffset) != 1) {
-					fprintf(stdout, "[ERROR] DC offset error !! [-D %d]\n",parameters->dcoffset);
-					return 1;
-				}
-			}
-			break;
-				
-				/* ------------------------------------------------------ */
-			
-			case 'R':			/* ROI */
-			{
-				if (sscanf(optarg, "OI:c=%d,U=%d", &parameters->roi_compno, &parameters->roi_shift) != 2) {
-					fprintf(stdout, "[ERROR] ROI error !! [-ROI:c='compno',U='shift']\n");
-					return 1;
-				}
-			}
-			break;
-				
-				/* ------------------------------------------------------ */
-			
-			case 'l':			/* Tile offset */
-			{
-				if (sscanf(optarg, "%d,%d,%d", &parameters->cp_tx0, &parameters->cp_ty0, &parameters->cp_tz0) != 3) {
-					fprintf(stdout, "[ERROR] -l 'tile offset' argument error !! [-l X0,Y0,Z0]");
-					return 1;
-				}
-			}
-			break;
-				
-				/* ------------------------------------------------------ 
-				
-			case 'T':			// Tranformation of original data (2D-DWT/3D-DWT/3D-RLS/2D-DWT+1D-RLS) 
-			{
-				char transform[4];
-
-				strncpy(transform, optarg, 4);
-				parameters->transform_format = give_transform(transform);
-				if (parameters->transform_format == -1) {
-					fprintf(stdout, "[ERROR] -T 'Transform domain' argument error !! [-T 2DWT, 3DWT, 3RLS or 3LSE only]");
-                    return 1;
-				}
-			}
-			break;
-				
-				 ------------------------------------------------------ */
-			
-			case 'C':			/* Coding of transformed data */
-			{
-				char coding[3];
-
-				strncpy(coding, optarg, 3);
-				parameters->encoding_format = give_coding(coding);
-				if (parameters->encoding_format == -1) {
-					fprintf(stdout, "[ERROR] -C 'Coding algorithm' argument error !! [-C 2EB, 3EB, 2GR, 3GR or GRI only]");
-                    return 1;
-				}
-			}
-			break;
-			
-			/* ------------------------------------------------------ */
-			
-			case 'I':			/* reversible or not */
-			{
-				parameters->irreversible = 1;
-			}
-			break;
-				
-			default:
-				fprintf(stdout, "[ERROR] This option is not valid \"-%c %s\"\n", c, optarg);
-				return 1;
-		}
-	}
-
-	/* check for possible errors */
-
-	if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
-		fprintf(stdout, "usage: jp3d_vm_enc -i volume-file -o jp3d-file (+ options)\n");
-		return 1;
-	}
-
-	if((parameters->decod_format == BIN_DFMT) && (parameters->imgfile[0] == 0)) {
-		fprintf(stdout, "usage: jp3d_vm_enc -i bin-volume-file -m img-file -o jp3d-file (+ options)\n");
-		return 1;
-	}
-
-	if((parameters->decod_format != BIN_DFMT) && (parameters->decod_format != PGX_DFMT) && (parameters->decod_format != IMG_DFMT)) {
-		fprintf(stdout, "usage: jp3d_vm_enc -i input-volume-file [*.bin,*.pgx,*.img] -o jp3d-file [*.jp3d,*.j2k] (+ options)\n");
-		return 1;
-	}
-	if((parameters->cod_format != J3D_CFMT) && (parameters->cod_format != J2K_CFMT)) {
-		fprintf(stdout, "usage: jp3d_vm_enc -i input-volume-file [*.bin,*.pgx,*.img] -o jp3d-file [*.jp3d,*.j2k] (+ options)\n");
-		return 1;
-	}
-
-	if((parameters->encoding_format == ENCOD_2GR || parameters->encoding_format == ENCOD_3GR) && parameters->transform_format != TRF_3D_LSE && parameters->transform_format != TRF_3D_RLS) {
-		fprintf(stdout, "[ERROR] Entropy coding options -C [2GR,3GR] are only compatible with predictive-based transform algorithms: -T [3RLS,3LSE].\n");
-		return 1;
-	}
-	if (parameters->encoding_format == ENCOD_3EB)
-		parameters->mode |= (1 << 6);
-
-	if ((parameters->mode >> 6) & 1) {
-		parameters->encoding_format = ENCOD_3EB;
-	}
-
-	if((parameters->numresolution[2] == 0 || (parameters->numresolution[1] == 0) || (parameters->numresolution[0] == 0))) {
-		fprintf(stdout, "[ERROR] -n 'resolution levels' argument error ! Resolutions must be greater than 1 in order to perform DWT.\n");
-		return 1;
-	}
-	if (parameters->numresolution[1] != parameters->numresolution[0]) {
-		fprintf(stdout, "[ERROR] -n 'resolution levels' argument error ! Resolutions in X and Y axis must be the same in this implementation.\n");
-		return 1;
-	}
-	
-	if (parameters->numresolution[2] > parameters->numresolution[0]) {
-		fprintf(stdout, "[ERROR] -n 'resolution levels' argument error ! Resolutions in Z axis must be lower than in X-Y axis.\n");
-		return 1;
-	}
-	
-	if (parameters->dcoffset >= 128 && parameters->dcoffset <= -128) {
-		fprintf(stdout, "[ERROR] -D 'DC offset' argument error ! Value must be -128<=DCO<=128.\n");
-		return 1;
-	}
-
-	if(parameters->numresolution[2] != 1) {
-		parameters->transform_format = TRF_3D_DWT;
-		//fprintf(stdout, "[Warning] Resolution level in axial dim > 1 : 3D-DWT will be performed... \n");
-	} else if (parameters->numresolution[2] == 1) {
-		parameters->transform_format = TRF_2D_DWT;
-		//fprintf(stdout, "[Warning] Resolution level in axial dim == 1 : 2D-DWT will be performed... \n");
-	}
-	
-	if ((parameters->cod_format == J2K_CFMT) && (parameters->transform_format != TRF_2D_DWT || parameters->encoding_format != ENCOD_2EB)) {
-		fprintf(stdout, "[WARNING] Incompatible options -o *.j2k and defined transform or encoding algorithm. Latter will be ignored\n");
-		parameters->transform_format = TRF_2D_DWT;
-		parameters->encoding_format = ENCOD_2EB;
-	}
-
-	if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality) && (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_quality))) {
-		fprintf(stdout, "[ERROR] Options -r and -q cannot be used together !!\n");
-		return 1;
-	}				/* mod fixed_quality */
-
-	/* if no rate entered, lossless by default */
-	if (parameters->tcp_numlayers == 0) {
-		parameters->tcp_rates[0] = 0.0;	/* MOD antonin : losslessbug */
-		parameters->tcp_numlayers++;
-		parameters->cp_disto_alloc = 1;
-	}
-
-	if((parameters->cp_tx0 > parameters->volume_offset_x0) || (parameters->cp_ty0 > parameters->volume_offset_y0) || (parameters->cp_tz0 > parameters->volume_offset_z0)) {
-		fprintf(stdout,	"[ERROR] Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) TZO(%d)<=IMG_Z0(%d)\n",
-			parameters->cp_tx0, parameters->volume_offset_x0, parameters->cp_ty0, parameters->volume_offset_y0, 
-			parameters->cp_tz0, parameters->volume_offset_z0);
-		return 1;
-	}
-
-	for (i = 0; i < parameters->numpocs; i++) {
-		if (parameters->POC[i].prg == -1) {
-			fprintf(stdout,"[ERROR] Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",i + 1);
-		}
-	}
-	return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char **argv) {
-	bool bSuccess;
-	bool delete_comment = true;
-	opj_cparameters_t parameters;	/* compression parameters */
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_volume_t *volume = NULL;
-
-	/* 
-	configure the event callbacks (not required)
-	setting of each callback is optionnal 
-	*/
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* set encoding parameters to default values */
-	opj_set_default_encoder_parameters(&parameters);
-
-	/* parse input and get user encoding parameters */
-	if(parse_cmdline_encoder(argc, argv, &parameters) == 1) {
-		return 0;
-	}
-
-	if(parameters.cp_comment == NULL) {
-		parameters.cp_comment = "Created by OpenJPEG version JP3D";
-		/* no need to delete parameters.cp_comment on exit */
-		delete_comment = false;
-	}
-	
-	/* encode the destination volume */
-	/* ---------------------------- */
-	if (parameters.cod_format == J3D_CFMT || parameters.cod_format == J2K_CFMT)	{
-		int codestream_length, pixels, bitsin;
-		opj_cio_t *cio = NULL;
-		FILE *f = NULL;
-		opj_cinfo_t* cinfo = NULL;
-		
-		/* decode the source volume */
-		/* ----------------------- */
-		switch (parameters.decod_format) {
-			case PGX_DFMT: 
-				fprintf(stdout, "[INFO] Loading pgx file(s)\n");
-				volume = pgxtovolume(parameters.infile, &parameters);
-				if (!volume) {
-					fprintf(stdout, "[ERROR] Unable to load pgx files\n");
-					return 1;
-				}
-				break;
-			
-			case BIN_DFMT:
-				fprintf(stdout, "[INFO] Loading bin file\n");
-				volume = bintovolume(parameters.infile, parameters.imgfile, &parameters);
-				if (!volume) {
-					fprintf(stdout, "[ERROR] Unable to load bin file\n");
-					return 1;
-				}
-				break;
-
-			case IMG_DFMT:
-				fprintf(stdout, "[INFO] Loading img file\n");
-				volume = imgtovolume(parameters.infile, &parameters);
-				if (!volume) {
-					fprintf(stderr, "[ERROR] Unable to load img file\n");
-					return 1;
-				}
-				break;
-		}
-		
-		/* get a JP3D or J2K compressor handle */
-		if (parameters.cod_format == J3D_CFMT) 
-            cinfo = opj_create_compress(CODEC_J3D);
-		else if (parameters.cod_format == J2K_CFMT) 
-            cinfo = opj_create_compress(CODEC_J2K);
-
-		/* catch events using our callbacks and give a local context */
-		opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stdout);			
-
-		/* setup the encoder parameters using the current volume and using user parameters */
-		opj_setup_encoder(cinfo, &parameters, volume);
-		
-		/* open a byte stream for writing */
-		/* allocate memory for all tiles */
-		cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
-
-		/* encode the volume */
-		//fprintf(stdout, "[INFO] Encode the volume\n");
-		bSuccess = opj_encode(cinfo, cio, volume, parameters.index);
-		if (!bSuccess) {
-			opj_cio_close(cio);
-			fprintf(stdout, "[ERROR] Failed to encode volume\n");
-			return 1;
-		}
-		codestream_length = cio_tell(cio);
-		pixels =(volume->x1 - volume->x0) * (volume->y1 - volume->y0) * (volume->z1 - volume->z0);
-		bitsin = pixels * volume->comps[0].prec;
-		fprintf(stdout, "[RESULT] Volume: %d x %d x %d (x %d bpv)\n Codestream: %d B,  Ratio: %5.3f bpv,  (%5.3f : 1) \n", 
-			(volume->x1 - volume->x0),(volume->y1 - volume->y0),(volume->z1 - volume->z0),volume->comps[0].prec,
-			codestream_length, ((double)codestream_length * 8.0/(double)pixels), ((double)bitsin/(8.0*(double)codestream_length)));
-
-		/* write the buffer to disk */
-		f = fopen(parameters.outfile, "wb");
-		if (!f) {
-			fprintf(stdout, "[ERROR] Failed to open %s for writing\n", parameters.outfile);
-			return 1;
-		}
-		fwrite(cio->buffer, 1, codestream_length, f);
-		fclose(f);
-
-		/* close and free the byte stream */
-		opj_cio_close(cio);
-
-		/* free remaining compression structures */
-		opj_destroy_compress(cinfo);
-	} else {
-		fprintf(stdout, "[ERROR] Cod_format != JP3d !!! \n");
-		return 1;
-	}
-
-	/* free user parameters structure */
-	if(delete_comment) {
-		if(parameters.cp_comment) free(parameters.cp_comment);
-	}
-	if(parameters.cp_matrice) free(parameters.cp_matrice);
-
-	/* free volume data */
-	opj_volume_destroy(volume);
-	
-	return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/codec/windirent.h b/Utilities/gdcmopenjpeg-v1/jp3d/codec/windirent.h
deleted file mode 100644
index a67e587..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/codec/windirent.h
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- * uce-dirent.h - operating system independent dirent implementation
- * 
- * Copyright (C) 1998-2002  Toni Ronkko
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * ``Software''), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- * 
- * 
- * May 28 1998, Toni Ronkko <tronkko at messi.uku.fi>
- *
- * $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
- *
- * $Log: uce-dirent.h,v $
- * Revision 1.7  2002/05/13 10:48:35  tr
- * embedded some source code directly to the header so that no source
- * modules need to be included in the MS Visual C project using the
- * interface, removed all the dependencies to other headers of the `uce'
- * library so that the header can be made public
- *
- * Revision 1.6  2002/04/12 16:22:04  tr
- * Unified Compiling Environment (UCE) replaced `std' library
- *
- * Revision 1.5  2001/07/20 16:33:40  tr
- * moved to `std' library and re-named defines accordingly
- *
- * Revision 1.4  2001/07/10 16:47:18  tronkko
- * revised comments
- *
- * Revision 1.3  2001/01/11 13:16:43  tr
- * using ``uce-machine.h'' for finding out defines such as `FREEBSD'
- *
- * Revision 1.2  2000/10/08 16:00:41  tr
- * copy of FreeBSD man page
- *
- * Revision 1.1  2000/07/10 05:53:16  tr
- * Initial revision
- *
- * Revision 1.2  1998/07/19 18:29:14  tr
- * Added error reporting capabilities and some asserts.
- *
- * Revision 1.1  1998/07/04 16:27:51  tr
- * Initial revision
- *
- * 
- * MSVC 1.0 scans automatic dependencies incorrectly when your project
- * contains this very header.  The problem is that MSVC cannot handle
- * include directives inside #if..#endif block those are never entered.
- * Since this header ought to compile in many different operating systems,
- * there had to be several conditional blocks that are compiled only in
- * operating systems for what they were designed for.  MSVC 1.0 cannot
- * handle inclusion of sys/dir.h in a part that is compiled only in Apollo
- * operating system.  To fix the problem you need to insert DIR.H into
- * SYSINCL.DAT located in MSVC\BIN directory and restart visual C++.
- * Consult manuals for more informaton about the problem.
- *
- * Since many UNIX systems have dirent.h we assume to have one also.
- * However, if your UNIX system does not have dirent.h you can download one
- * for example at: http://ftp.uni-mannheim.de/ftp/GNU/dirent/dirent.tar.gz.
- * You can also see if you have one of dirent.h, direct.h, dir.h, ndir.h,
- * sys/dir.h and sys/ndir.h somewhere.  Try defining HAVE_DIRENT_H,
- * HAVE_DIRECT_H, HAVE_DIR_H, HAVE_NDIR_H, HAVE_SYS_DIR_H and
- * HAVE_SYS_NDIR_H according to the files found.
- */
-#ifndef DIRENT_H
-#define DIRENT_H
-#define DIRENT_H_INCLUDED
-
-/* find out platform */
-#if defined(MSDOS)                             /* MS-DOS */
-#elif defined(__MSDOS__)                       /* Turbo C/Borland */
-# define MSDOS
-#elif defined(__DOS__)                         /* Watcom */
-# define MSDOS
-#endif
-
-#if defined(WIN32)                             /* MS-Windows */
-#elif defined(__NT__)                          /* Watcom */
-# define WIN32
-#elif defined(_WIN32)                          /* Microsoft */
-# define WIN32
-#elif defined(__WIN32__)                       /* Borland */
-# define WIN32
-#endif
-
-/*
- * See what kind of dirent interface we have unless autoconf has already
- * determinated that.
- */
-#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
-# if defined(_MSC_VER)                         /* Microsoft C/C++ */
-    /* no dirent.h */
-# elif defined(__BORLANDC__)                   /* Borland C/C++ */
-#   define HAVE_DIRENT_H
-#   define VOID_CLOSEDIR
-# elif defined(__TURBOC__)                     /* Borland Turbo C */
-    /* no dirent.h */
-# elif defined(__WATCOMC__)                    /* Watcom C/C++ */
-#   define HAVE_DIRECT_H
-# elif defined(__apollo)                       /* Apollo */
-#   define HAVE_SYS_DIR_H
-# elif defined(__hpux)                         /* HP-UX */
-#   define HAVE_DIRENT_H
-# elif defined(__alpha) || defined(__alpha__)  /* Alpha OSF1 */
-#   error "not implemented"
-# elif defined(__sgi)                          /* Silicon Graphics */
-#   define HAVE_DIRENT_H
-# elif defined(sun) || defined(_sun)           /* Sun Solaris */
-#   define HAVE_DIRENT_H
-# elif defined(__FreeBSD__)                    /* FreeBSD */
-#   define HAVE_DIRENT_H
-# elif defined(__linux__)                      /* Linux */
-#   define HAVE_DIRENT_H
-# elif defined(__GNUC__)                       /* GNU C/C++ */
-#   define HAVE_DIRENT_H
-# else
-#   error "not implemented"
-# endif
-#endif
-
-/* include proper interface headers */
-#if defined(HAVE_DIRENT_H)
-# include <dirent.h>
-# ifdef FREEBSD
-#   define NAMLEN(dp) ((int)((dp)->d_namlen))
-# else
-#   define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
-# endif
-
-#elif defined(HAVE_NDIR_H)
-# include <ndir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_DIRECT_H)
-# include <direct.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_DIR_H)
-# include <dir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_SYS_DIR_H)
-# include <sys/types.h>
-# include <sys/dir.h>
-# ifndef dirent
-#   define dirent direct
-# endif
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(MSDOS) || defined(WIN32)
-
-  /* figure out type of underlaying directory interface to be used */
-# if defined(WIN32)
-#   define DIRENT_WIN32_INTERFACE
-# elif defined(MSDOS)
-#   define DIRENT_MSDOS_INTERFACE
-# else
-#   error "missing native dirent interface"
-# endif
-
-  /*** WIN32 specifics ***/
-# if defined(DIRENT_WIN32_INTERFACE)
-#   include <windows.h>
-#   if !defined(DIRENT_MAXNAMLEN)
-#     define DIRENT_MAXNAMLEN (MAX_PATH)
-#   endif
-
-
-  /*** MS-DOS specifics ***/
-# elif defined(DIRENT_MSDOS_INTERFACE)
-#   include <dos.h>
-
-    /* Borland defines file length macros in dir.h */
-#   if defined(__BORLANDC__)
-#     include <dir.h>
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
-#     endif
-#     if !defined(_find_t)
-#       define _find_t find_t
-#     endif
-
-    /* Turbo C defines ffblk structure in dir.h */
-#   elif defined(__TURBOC__)
-#     include <dir.h>
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
-#     endif
-#     define DIRENT_USE_FFBLK
-
-    /* MSVC */
-#   elif defined(_MSC_VER)
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN (12)
-#     endif
-
-    /* Watcom */
-#   elif defined(__WATCOMC__)
-#     if !defined(DIRENT_MAXNAMLEN)
-#       if defined(__OS2__) || defined(__NT__)
-#         define DIRENT_MAXNAMLEN (255)
-#       else
-#         define DIRENT_MAXNAMLEN (12)
-#       endif
-#     endif
-
-#   endif
-# endif
-
-  /*** generic MS-DOS and MS-Windows stuff ***/
-# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
-#   define NAME_MAX DIRENT_MAXNAMLEN
-# endif
-# if NAME_MAX < DIRENT_MAXNAMLEN
-#   error "assertion failed: NAME_MAX >= DIRENT_MAXNAMLEN"
-# endif
-
-
-  /*
-   * Substitute for real dirent structure.  Note that `d_name' field is a
-   * true character array although we have it copied in the implementation
-   * dependent data.  We could save some memory if we had declared `d_name'
-   * as a pointer refering the name within implementation dependent data.
-   * We have not done that since some code may rely on sizeof(d_name) to be
-   * something other than four.  Besides, directory entries are typically so
-   * small that it takes virtually no time to copy them from place to place.
-   */
-  typedef struct dirent {
-    char d_name[NAME_MAX + 1];
-
-    /*** Operating system specific part ***/
-# if defined(DIRENT_WIN32_INTERFACE)       /*WIN32*/
-    WIN32_FIND_DATA data;
-# elif defined(DIRENT_MSDOS_INTERFACE)     /*MSDOS*/
-#   if defined(DIRENT_USE_FFBLK)
-    struct ffblk data;
-#   else
-    struct _find_t data;
-#   endif
-# endif
-  } dirent;
-
-  /* DIR substitute structure containing directory name.  The name is
-   * essential for the operation of ``rewinndir'' function. */
-  typedef struct DIR {
-    char          *dirname;                    /* directory being scanned */
-    dirent        current;                     /* current entry */
-    int           dirent_filled;               /* is current un-processed? */
-
-  /*** Operating system specific part ***/
-#  if defined(DIRENT_WIN32_INTERFACE)
-    HANDLE        search_handle;
-#  elif defined(DIRENT_MSDOS_INTERFACE)
-#  endif
-  } DIR;
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/* supply prototypes for dirent functions */
-static DIR *opendir (const char *dirname);
-static struct dirent *readdir (DIR *dirp);
-static int closedir (DIR *dirp);
-static void rewinddir (DIR *dirp);
-
-/*
- * Implement dirent interface as static functions so that the user does not
- * need to change his project in any way to use dirent function.  With this
- * it is sufficient to include this very header from source modules using
- * dirent functions and the functions will be pulled in automatically.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-
-/* use ffblk instead of _find_t if requested */
-#if defined(DIRENT_USE_FFBLK)
-# define _A_ARCH   (FA_ARCH)
-# define _A_HIDDEN (FA_HIDDEN)
-# define _A_NORMAL (0)
-# define _A_RDONLY (FA_RDONLY)
-# define _A_SUBDIR (FA_DIREC)
-# define _A_SYSTEM (FA_SYSTEM)
-# define _A_VOLID  (FA_LABEL)
-# define _dos_findnext(dest) findnext(dest)
-# define _dos_findfirst(name,flags,dest) findfirst(name,dest,flags)
-#endif
-
-static int _initdir (DIR *p);
-static const char *_getdirname (const struct dirent *dp);
-static void _setdirname (struct DIR *dirp);
-
-/*
- * <function name="opendir">
- * <intro>open directory stream for reading
- * <syntax>DIR *opendir (const char *dirname);
- *
- * <desc>Open named directory stream for read and return pointer to the
- * internal working area that is used for retrieving individual directory
- * entries.  The internal working area has no fields of your interest.
- *
- * <ret>Returns a pointer to the internal working area or NULL in case the 
- * directory stream could not be opened.  Global `errno' variable will set
- * in case of error as follows:
- *
- * <table>
- * [EACESS  |Permission denied.
- * [EMFILE  |Too many open files used by the process.
- * [ENFILE  |Too many open files in system.
- * [ENOENT  |Directory does not exist.
- * [ENOMEM  |Insufficient memory.
- * [ENOTDIR |dirname does not refer to directory.  This value is not
- *           reliable on MS-DOS and MS-Windows platforms.  Many
- *           implementations return ENOENT even when the name refers to a
- *           file.]
- * </table>
- * </function>
- */
-static DIR *opendir(const char *dirname)
-{
-  DIR *dirp;
-  assert (dirname != NULL);
-  
-  dirp = (DIR*)malloc (sizeof (struct DIR));
-  if (dirp != NULL) {
-    char *p;
-    
-    /* allocate room for directory name */
-    dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
-    if (dirp->dirname == NULL) {
-      /* failed to duplicate directory name.  errno set by malloc() */
-      free (dirp);
-      return NULL;
-    }
-    /* Copy directory name while appending directory separator and "*.*".
-     * Directory separator is not appended if the name already ends with
-     * drive or directory separator.  Directory separator is assumed to be
-     * '/' or '\' and drive separator is assumed to be ':'. */
-    strcpy (dirp->dirname, dirname);
-    p = strchr (dirp->dirname, '\0');
-    if (dirp->dirname < p  &&
-        *(p - 1) != '\\'  &&  *(p - 1) != '/'  &&  *(p - 1) != ':')
-    {
-      strcpy (p++, "\\");
-    }
-# ifdef DIRENT_WIN32_INTERFACE
-    strcpy (p, "*"); /*scan files with and without extension in win32*/
-# else
-    strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
-# endif
-
-    /* open stream */
-    if (_initdir (dirp) == 0) {
-      /* initialization failed */
-      free (dirp->dirname);
-      free (dirp);
-      return NULL;
-    }
-  }
-  return dirp;
-}
-
-
-/*
- * <function name="readdir">
- * <intro>read a directory entry
- * <syntax>struct dirent *readdir (DIR *dirp);
- *
- * <desc>Read individual directory entry and return pointer to a structure
- * containing the name of the entry.  Individual directory entries returned
- * include normal files, sub-directories, pseudo-directories "." and ".."
- * and also volume labels, hidden files and system files in MS-DOS and
- * MS-Windows.   You might want to use stat(2) function to determinate which
- * one are you dealing with.  Many dirent implementations already contain
- * equivalent information in dirent structure but you cannot depend on
- * this.
- *
- * The dirent structure contains several system dependent fields that
- * generally have no interest to you.  The only interesting one is char
- * d_name[] that is also portable across different systems.  The d_name
- * field contains the name of the directory entry without leading path.
- * While d_name is portable across different systems the actual storage
- * capacity of d_name varies from system to system and there is no portable
- * way to find out it at compile time as different systems define the
- * capacity of d_name with different macros and some systems do not define
- * capacity at all (besides actual declaration of the field). If you really
- * need to find out storage capacity of d_name then you might want to try
- * NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
- * there are many MS-DOS and MS-Windows implementations those do not define
- * it.  There are also systems that declare d_name as "char d_name[1]" and
- * then allocate suitable amount of memory at run-time.  Thanks to Alain
- * Decamps (Alain.Decamps at advalvas.be) for pointing it out to me.
- *
- * This all leads to the fact that it is difficult to allocate space
- * for the directory names when the very same program is being compiled on
- * number of operating systems.  Therefore I suggest that you always
- * allocate space for directory names dynamically.
- *
- * <ret>
- * Returns a pointer to a structure containing name of the directory entry
- * in `d_name' field or NULL if there was an error.  In case of an error the
- * global `errno' variable will set as follows:
- *
- * <table>
- * [EBADF  |dir parameter refers to an invalid directory stream.  This value
- *          is not set reliably on all implementations.]
- * </table>
- * </function>
- */
-static struct dirent *
-readdir (DIR *dirp)
-{
-  assert(dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return NULL;
-  }
-
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle == INVALID_HANDLE_VALUE) {
-    /* directory stream was opened/rewound incorrectly or it ended normally */
-    errno = EBADF;
-    return NULL;
-  }
-#endif
-
-  if (dirp->dirent_filled != 0) {
-    /*
-     * Directory entry has already been retrieved and there is no need to
-     * retrieve a new one.  Directory entry will be retrieved in advance
-     * when the user calls readdir function for the first time.  This is so
-     * because real dirent has separate functions for opening and reading
-     * the stream whereas Win32 and DOS dirents open the stream
-     * automatically when we retrieve the first file.  Therefore, we have to
-     * save the first file when opening the stream and later we have to
-     * return the saved entry when the user tries to read the first entry.
-     */
-    dirp->dirent_filled = 0;
-  } else {
-    /* fill in entry and return that */
-#if defined(DIRENT_WIN32_INTERFACE)
-    if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
-      /* Last file has been processed or an error occured */
-      FindClose (dirp->search_handle);
-      dirp->search_handle = INVALID_HANDLE_VALUE;
-      errno = ENOENT;
-      return NULL;
-    }
-
-# elif defined(DIRENT_MSDOS_INTERFACE)
-    if (_dos_findnext (&dirp->current.data) != 0) {
-      /* _dos_findnext and findnext will set errno to ENOENT when no
-       * more entries could be retrieved. */
-      return NULL;
-    }
-# endif
-
-    _setdirname (dirp);
-    assert (dirp->dirent_filled == 0);
-  }
-  return &dirp->current;
-}
-
-
-/*
- * <function name="closedir">
- * <intro>close directory stream.
- * <syntax>int closedir (DIR *dirp);
- *
- * <desc>Close directory stream opened by the `opendir' function.  Close of
- * directory stream invalidates the DIR structure as well as previously read
- * dirent entry.
- *
- * <ret>The function typically returns 0 on success and -1 on failure but
- * the function may be declared to return void on same systems.  At least
- * Borland C/C++ and some UNIX implementations use void as a return type.
- * The dirent wrapper tries to define VOID_CLOSEDIR whenever closedir is
- * known to return nothing.  The very same definition is made by the GNU
- * autoconf if you happen to use it.
- *
- * The global `errno' variable will set to EBADF in case of error.
- * </function>
- */
-static int
-closedir (DIR *dirp)
-{   
-  int retcode = 0;
-
-  /* make sure that dirp points to legal structure */
-  assert (dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return -1;
-  }
- 
-  /* free directory name and search handles */
-  if (dirp->dirname != NULL) free (dirp->dirname);
-
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle != INVALID_HANDLE_VALUE) {
-    if (FindClose (dirp->search_handle) == FALSE) {
-      /* Unknown error */
-      retcode = -1;
-      errno = EBADF;
-    }
-  }
-#endif                     
-
-  /* clear dirp structure to make sure that it cannot be used anymore*/
-  memset (dirp, 0, sizeof (*dirp));
-# if defined(DIRENT_WIN32_INTERFACE)
-  dirp->search_handle = INVALID_HANDLE_VALUE;
-# endif
-
-  free (dirp);
-  return retcode;
-}
-
-
-/*
- * <function name="rewinddir">
- * <intro>rewind directory stream to the beginning
- * <syntax>void rewinddir (DIR *dirp);
- *
- * <desc>Rewind directory stream to the beginning so that the next call of
- * readdir() returns the very first directory entry again.  However, note
- * that next call of readdir() may not return the same directory entry as it
- * did in first time.  The directory stream may have been affected by newly
- * created files.
- *
- * Almost every dirent implementation ensure that rewinddir will update
- * the directory stream to reflect any changes made to the directory entries
- * since the previous ``opendir'' or ``rewinddir'' call.  Keep an eye on
- * this if your program depends on the feature.  I know at least one dirent
- * implementation where you are required to close and re-open the stream to
- * see the changes.
- *
- * <ret>Returns nothing.  If something went wrong while rewinding, you will
- * notice it later when you try to retrieve the first directory entry.
- */
-static void
-rewinddir (DIR *dirp)
-{   
-  /* make sure that dirp is legal */
-  assert (dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return;
-  }
-  assert (dirp->dirname != NULL);
-  
-  /* close previous stream */
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle != INVALID_HANDLE_VALUE) {
-    if (FindClose (dirp->search_handle) == FALSE) {
-      /* Unknown error */
-      errno = EBADF;
-    }
-  }
-#endif
-
-  /* re-open previous stream */
-  if (_initdir (dirp) == 0) {
-    /* initialization failed but we cannot deal with error.  User will notice
-     * error later when she tries to retrieve first directory enty. */
-    /*EMPTY*/;
-  }
-}
-
-
-/*
- * Open native directory stream object and retrieve first file.
- * Be sure to close previous stream before opening new one.
- */
-static int
-_initdir (DIR *dirp)
-{ 
-  assert (dirp != NULL);
-  assert (dirp->dirname != NULL);
-  dirp->dirent_filled = 0;
-
-# if defined(DIRENT_WIN32_INTERFACE)
-  /* Open stream and retrieve first file */
-  dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
-  if (dirp->search_handle == INVALID_HANDLE_VALUE) {
-    /* something went wrong but we don't know what.  GetLastError() could
-     * give us more information about the error, but then we should map
-     * the error code into errno. */
-    errno = ENOENT;
-    return 0;
-  }
-
-# elif defined(DIRENT_MSDOS_INTERFACE)
-  if (_dos_findfirst (dirp->dirname,
-          _A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
-          &dirp->current.data) != 0)
-  {
-    /* _dos_findfirst and findfirst will set errno to ENOENT when no 
-     * more entries could be retrieved. */
-    return 0;
-  }
-# endif
-
-  /* initialize DIR and it's first entry */
-  _setdirname (dirp);
-  dirp->dirent_filled = 1;
-  return 1;
-}
-
-
-/*
- * Return implementation dependent name of the current directory entry.
- */
-static const char *
-_getdirname (const struct dirent *dp)
-{
-#if defined(DIRENT_WIN32_INTERFACE)
-  return dp->data.cFileName;
-  
-#elif defined(DIRENT_USE_FFBLK)
-  return dp->data.ff_name;
-  
-#else
-  return dp->data.name;
-#endif  
-}
-
-
-/*
- * Copy name of implementation dependent directory entry to the d_name field.
- */
-static void
-_setdirname (struct DIR *dirp) {
-  /* make sure that d_name is long enough */
-  assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
-  
-  strncpy (dirp->current.d_name,
-      _getdirname (&dirp->current),
-      NAME_MAX);
-  dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
-}
-  
-# ifdef __cplusplus
-}
-# endif
-# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
-
-#else
-# error "missing dirent interface"
-#endif
-
-
-#endif /*DIRENT_H*/
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/CMakeLists.txt
deleted file mode 100644
index 7b7541b..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-if(UNIX OR CYGWIN)
- add_definitions(-O3)
-elseif(MINGW)
- add_definitions(-Os)
-elseif(WIN32)
-  add_definitions(/Os)
-endif()
-#
-include_regular_expression("^.*$")
-# Defines the source code for the library
-set(JP3DVM_SRCS
-bio.c  cio.c  dwt.c  event.c  jp3d.c  jp3d_lib.c  mct.c  mqc.c  openjpeg.c  pi.c  raw.c  t1.c  t1_3d.c  t2.c  tcd.c  tgt.c  volume.c
-)
-
-# Build the library
-if(WIN32)
-  if(BUILD_SHARED_LIBS)
-    add_definitions(-DOPJ_EXPORTS)
-  else()
-    add_definitions(-DOPJ_STATIC)
-  endif()
-endif()
-add_library(${OPENJPEG_LIBRARY_NAME}_JP3D ${JP3DVM_SRCS})
-set_target_properties(${OPENJPEG_LIBRARY_NAME}_JP3D
-  PROPERTIES
-    VERSION   1.3.0
-    SOVERSION 1)
-
-# Install library
-install(TARGETS ${OPENJPEG_LIBRARY_NAME}_JP3D
-DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
-)
-
-# Install includes files
-install(FILES openjpeg3d.h
-  DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/openjpeg3d-1.3
-)
-install(CODE
-  "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_INCLUDE_DIR}/openjpeg3d-1.3/openjpeg3d.h \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_INCLUDE_DIR}/openjpeg3d.h)")
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.c
deleted file mode 100755
index 3ac9315..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup BIO BIO - Individual bit input-output stream */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Write a bit
- at param bio BIO handle
- at param b Bit to write (0 or 1)
-*/
-static void bio_putbit(opj_bio_t *bio, int b);
-/**
-Read a bit
- at param bio BIO handle
- at return Returns the read bit
-*/
-static int bio_getbit(opj_bio_t *bio);
-/**
-Write a byte
- at param bio BIO handle
- at return Returns 0 if successful, returns 1 otherwise
-*/
-static int bio_byteout(opj_bio_t *bio);
-/**
-Read a byte
- at param bio BIO handle
- at return Returns 0 if successful, returns 1 otherwise
-*/
-static int bio_bytein(opj_bio_t *bio);
-
-/*@}*/
-
-/*@}*/
-
-
-/* 
-==========================================================
-   local functions
-==========================================================
-*/
-
-static int bio_byteout(opj_bio_t *bio) {
-	bio->buf = (bio->buf << 8) & 0xffff;
-	bio->ct = bio->buf == 0xff00 ? 7 : 8;
-	if (bio->bp >= bio->end) {
-		return 1;
-	}
-	*bio->bp++ = bio->buf >> 8;
-	return 0;
-}
-
-static int bio_bytein(opj_bio_t *bio) {
-	bio->buf = (bio->buf << 8) & 0xffff;
-	bio->ct = bio->buf == 0xff00 ? 7 : 8;
-	if (bio->bp >= bio->end) {
-		return 1;
-	}
-	bio->buf |= *bio->bp++;
-	return 0;
-}
-
-static void bio_putbit(opj_bio_t *bio, int b) {
-	if (bio->ct == 0) {
-		bio_byteout(bio);
-	}
-	bio->ct--;
-	bio->buf |= b << bio->ct;
-}
-
-/* MOD antonin */
-static int bio_getbit(opj_bio_t *bio) {
-/* DOM */
-	if (bio->ct == 0) {
-		bio_bytein(bio);
-	}
-	bio->ct--;
-	return (bio->buf >> bio->ct) & 1;
-}
-
-/* 
-==========================================================
-   Bit Input/Output interface
-==========================================================
-*/
-
-opj_bio_t* bio_create() {
-	opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
-	return bio;
-}
-
-void bio_destroy(opj_bio_t *bio) {
-	if(bio) {
-		opj_free(bio);
-	}
-}
-
-int bio_numbytes(opj_bio_t *bio) {
-	return (bio->bp - bio->start);
-}
-
-void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) {
-	bio->start = bp;
-	bio->end = bp + len;
-	bio->bp = bp;
-	bio->buf = 0;
-	bio->ct = 8;
-}
-
-void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) {
-	bio->start = bp;
-	bio->end = bp + len;
-	bio->bp = bp;
-	bio->buf = 0;
-	bio->ct = 0;
-}
-
-void bio_write(opj_bio_t *bio, int v, int n) {
-	int i;
-	for (i = n - 1; i >= 0; i--) {
-		bio_putbit(bio, (v >> i) & 1);
-	}
-}
-
-int bio_read(opj_bio_t *bio, int n) {
-	int i, v;
-	v = 0;
-	for (i = n - 1; i >= 0; i--) {
-		v += bio_getbit(bio) << i;
-	}
-	return v;
-}
-
-int bio_flush(opj_bio_t *bio) {
-	bio->ct = 0;
-	if (bio_byteout(bio)) {
-		return 1;
-	}
-	if (bio->ct == 7) {
-		bio->ct = 0;
-		if (bio_byteout(bio)) {
-			return 1;
-		}
-	}
-	return 0;
-}
-
-int bio_inalign(opj_bio_t *bio) {
-	bio->ct = 0;
-	if ((bio->buf & 0xff) == 0xff) {
-		if (bio_bytein(bio)) {
-			return 1;
-		}
-		bio->ct = 0;
-	}
-	return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.h
deleted file mode 100755
index c65103b..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/bio.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __BIO_H
-#define __BIO_H
-/** 
- at file bio.h
- at brief Implementation of an individual bit input-output (BIO)
-
-The functions in BIO.C have for goal to realize an individual bit input - output.
-*/
-
-/** @defgroup BIO BIO - Individual bit input-output stream */
-/*@{*/
-
-/**
-Individual bit input-output stream (BIO)
-*/
-typedef struct opj_bio {
-/** pointer to the start of the buffer */
-	unsigned char *start;	
-/** pointer to the end of the buffer */
-	unsigned char *end;		
-/** pointer to the present position in the buffer */
-	unsigned char *bp;		
-/** temporary place where each byte is read or written */
-	unsigned int buf;		
-/** coder : number of bits free to write. decoder : number of bits read */
-	int ct;					
-} opj_bio_t;
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new BIO handle 
- at return Returns a new BIO handle if successful, returns NULL otherwise
-*/
-opj_bio_t* bio_create();
-/**
-Destroy a previously created BIO handle
- at param bio BIO handle to destroy
-*/
-void bio_destroy(opj_bio_t *bio);
-/**
-Number of bytes written.
- at param bio BIO handle
- at return Returns the number of bytes written
-*/
-int bio_numbytes(opj_bio_t *bio);
-/**
-Init encoder
- at param bio BIO handle
- at param bp Output buffer
- at param len Output buffer length 
-*/
-void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len);
-/**
-Init decoder
- at param bio BIO handle
- at param bp Input buffer
- at param len Input buffer length 
-*/
-void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len);
-/**
-Write bits
- at param bio BIO handle
- at param v Value of bits
- at param n Number of bits to write
-*/
-void bio_write(opj_bio_t *bio, int v, int n);
-/**
-Read bits
- at param bio BIO handle
- at param n Number of bits to read 
- at return Returns the corresponding read number
-*/
-int bio_read(opj_bio_t *bio, int n);
-/**
-Flush bits
- at param bio BIO handle
- at return Returns 1 if successful, returns 0 otherwise
-*/
-int bio_flush(opj_bio_t *bio);
-/**
-Passes the ending bits (coming from flushing)
- at param bio BIO handle
- at return Returns 1 if successful, returns 0 otherwise
-*/
-int bio_inalign(opj_bio_t *bio);
-/**
-Read a bit
- at param bio BIO handle
- at return Returns the read bit
-*/
-/* MOD antonin */
-//int bio_getbit(opj_bio_t *bio);
-/* DOM */
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __BIO_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.c
deleted file mode 100755
index 8814a33..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* ----------------------------------------------------------------------- */
-
-opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) {
-	opj_cp_t *cp = NULL;
-	opj_cio_t *cio = (opj_cio_t*)opj_malloc(sizeof(opj_cio_t));
-	if(!cio) return NULL;
-	cio->cinfo = cinfo;
-	if(buffer && length) {
-		/* wrap a user buffer containing the encoded image */
-		cio->openmode = OPJ_STREAM_READ;
-		cio->buffer = buffer;
-		cio->length = length;
-	}
-	else if(!buffer && !length && cinfo) {
-		/* allocate a buffer for the encoded image */
-		cio->openmode = OPJ_STREAM_WRITE;
-		switch(cinfo->codec_format) {
-			case CODEC_J3D:
-			case CODEC_J2K:
-				cp = ((opj_j3d_t*)cinfo->j3d_handle)->cp;
-				break;
-			default:
-				opj_free(cio);
-				return NULL;
-		}
-		cio->length = cp->tdx * cp->tdy * cp->tdz * cp->tw * cp->th * cp->tl * 4;
-		cio->buffer = (unsigned char *)opj_malloc(cio->length);
-		if(!cio->buffer) {
-			opj_free(cio);
-			return NULL;
-		}
-	}
-	else {
-		opj_free(cio);
-		return NULL;
-	}
-
-	/* Initialize byte IO */
-	cio->start = cio->buffer;
-	cio->end = cio->buffer + cio->length;
-	cio->bp = cio->buffer;
-
-	return cio;
-}
-
-void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) {
-	if(cio) {
-		if(cio->openmode == OPJ_STREAM_WRITE) {
-			/* destroy the allocated buffer */
-			opj_free(cio->buffer);
-		}
-		/* destroy the cio */
-		opj_free(cio);
-	}
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-/*
- * Get position in byte stream.
- */
-int OPJ_CALLCONV cio_tell(opj_cio_t *cio) {
-	return cio->bp - cio->start;
-}
-
-/*
- * Set position in byte stream.
- *
- * pos : position, in number of bytes, from the beginning of the stream
- */
-void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos) {
-	cio->bp = cio->start + pos;
-}
-
-/*
- * Number of bytes left before the end of the stream.
- */
-int cio_numbytesleft(opj_cio_t *cio) {
-	return cio->end - cio->bp;
-}
-
-/*
- * Get pointer to the current position in the stream.
- */
-unsigned char *cio_getbp(opj_cio_t *cio) {
-	return cio->bp;
-}
-
-/*
- * Write a byte.
- */
-bool cio_byteout(opj_cio_t *cio, unsigned char v) {
-	if (cio->bp >= cio->end) {
-		opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
-		return false;
-	}
-	*cio->bp++ = v;
-	return true;
-}
-
-/*
- * Read a byte.
- */
-unsigned char cio_bytein(opj_cio_t *cio) {
-	if (cio->bp >= cio->end) {
-		opj_event_msg(cio->cinfo, EVT_ERROR, "read error\n");
-		return 0;
-	}
-	return *cio->bp++;
-}
-
-/*
- * Write some bytes.
- *
- * v : value to write
- * n : number of bytes to write
- */
-unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
-	int i;
-	for (i = n - 1; i >= 0; i--) {
-		if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
-			return 0;
-	}
-	return n;
-}
-
-/*
- * Read some bytes.
- *
- * n : number of bytes to read
- *
- * return : value of the n bytes read
- */
-unsigned int cio_read(opj_cio_t *cio, int n) {
-	int i;
-	unsigned int v;
-	v = 0;
-	for (i = n - 1; i >= 0; i--) {
-		v += cio_bytein(cio) << (i << 3);
-	}
-	return v;
-}
-
-/* 
- * Skip some bytes.
- *
- * n : number of bytes to skip
- */
-void cio_skip(opj_cio_t *cio, int n) {
-	cio->bp += n;
-}
-
-/*
- * Write some bytes.
- *
- * v : value to write
- * n : number of bytes to write
- */
-int cio_write_int(opj_cio_t *cio, int v, int n) {
-	int i;
-	for (i = n - 1; i >= 0; i--) {
-		if( !cio_byteout(cio, (char) ((v >> (i << 3)) & 0xff)) )
-			return 0;
-	}
-	return n;
-}
-
-/*
- * Read some bytes.
- *
- * n : number of bytes to read
- *
- * return : value of the n bytes read
- */
-int cio_read_int(opj_cio_t *cio, int n) {
-	int i;
-	int v;
-	v = 0;
-	for (i = n - 1; i >= 0; i--) {
-		v += cio_bytein(cio) << (i << 3);
-	}
-	return v;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.h
deleted file mode 100755
index 6f58aea..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/cio.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __CIO_H
-#define __CIO_H
-/**
- at file cio.h
- at brief Implementation of a byte input-output process (CIO)
-
-The functions in CIO.C have for goal to realize a byte input / output process.
-*/
-
-/** @defgroup CIO CIO - byte input-output stream */
-/*@{*/
-
-/** @name Funciones generales (see also openjpeg3d.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Number of bytes left before the end of the stream
- at param cio CIO handle
- at return Returns the number of bytes before the end of the stream
-*/
-int cio_numbytesleft(opj_cio_t *cio);
-/**
-Get pointer to the current position in the stream
- at param cio CIO handle
- at return Returns a pointer to the current position
-*/
-unsigned char *cio_getbp(opj_cio_t *cio);
-/**
-Write some bytes
- at param cio CIO handle
- at param v Value to write
- at param n Number of bytes to write
- at return Returns the number of bytes written or 0 if an error occured
-*/
-unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n);
-/**
-Read some bytes
- at param cio CIO handle
- at param n Number of bytes to read
- at return Returns the value of the n bytes read
-*/
-unsigned int cio_read(opj_cio_t *cio, int n);
-/**
-Skip some bytes
- at param cio CIO handle
- at param n Number of bytes to skip
-*/
-void cio_skip(opj_cio_t *cio, int n);
-/**
-Write some bytes
- at param cio CIO handle
- at param v Signed integer value to write
- at param n Number of bytes to write
- at return Returns the number of bytes written or 0 if an error occured
-*/
-int cio_write_int(opj_cio_t *cio, int v, int n);
-/**
-Read some bytes
- at param cio CIO handle
- at param n Number of bytes to read
- at return Returns the value of the n bytes read
-*/
-int cio_read_int(opj_cio_t *cio, int n);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __CIO_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.c
deleted file mode 100755
index 4ac23bb..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.c
+++ /dev/null
@@ -1,1016 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyrigth (c) 2006, M�nica D�ez, LPI-UVA, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- *  NOTE:
- *  This is a modified version of the openjpeg dwt.c file.
- *  Average speed improvement compared to the original file (measured on
- *  my own machine, a P4 running at 3.0 GHz):
- *  5x3 wavelets about 2 times faster
- *  9x7 wavelets about 3 times faster
- *  for both, encoding and decoding.
- *
- *  The better performance is caused by doing the 1-dimensional DWT
- *  within a temporary buffer where the data can be accessed sequential
- *  for both directions, horizontal and vertical. The 2d vertical DWT was
- *  the major bottleneck in the former version.
- *
- *  I have also removed the "Add Patrick" part because it is not longer
- *  needed.  
- *
- *  6/6/2005
- *  -Ive (aka Reiner Wahler)
- *  mail: ive at lilysoft.com
- */
-
-#include "opj_includes.h"
-
-/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-unsigned int ops;
-/**
-Forward lazy transform (horizontal)
-*/
-static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas);
-/**
-Forward lazy transform (vertical)
-*/
-static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas);
-/**
-Forward lazy transform (axial)
-*/
-static void dwt_deinterleave_z(int *a, int *b, int dn, int sn, int xy, int cas);
-/**
-Inverse lazy transform (horizontal)
-*/
-static void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas);
-/**
-Inverse lazy transform (vertical)
-*/
-static void dwt_interleave_v(int *a, int *b, int dn, int sn, int x, int cas);
-/**
-Inverse lazy transform (axial)
-*/
-static void dwt_interleave_z(int *a, int *b, int dn, int sn, int xy, int cas);
-/**
-Forward 5-3 wavelet tranform in 1-D
-*/
-static void dwt_encode_53(int *a, int dn, int sn, int cas);
-static void dwt_encode_97(int *a, int dn, int sn, int cas);
-/**
-Inverse 5-3 wavelet tranform in 1-D
-*/
-static void dwt_decode_53(int *a, int dn, int sn, int cas);
-static void dwt_decode_97(int *a, int dn, int sn, int cas);
-/**
-Computing of wavelet transform L2 norms for arbitrary transforms
-*/
-static double dwt_calc_wtnorms(int orient, int level[3], int dwtid[3], opj_wtfilt_t *wtfiltx, opj_wtfilt_t *wtfilty, opj_wtfilt_t *wtfiltz);
-/**
-Encoding of quantification stepsize
-*/
-static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize);
-/*@}*/
-
-/*@}*/
-
-#define S(i) a[(i)*2]
-#define D(i) a[(1+(i)*2)]
-#define S_(i) ((i)<0?S(0):((i)>=sn?S(sn-1):S(i)))
-#define D_(i) ((i)<0?D(0):((i)>=dn?D(dn-1):D(i)))
-/* new */
-#define SS_(i) ((i)<0?S(0):((i)>=dn?S(dn-1):S(i)))
-#define DD_(i) ((i)<0?D(0):((i)>=sn?D(sn-1):D(i)))
-
-/* <summary>                                                              */
-/* This table contains the norms of the 5-3 wavelets for different bands. */
-/* </summary>                                                             */
-static double dwt_norm[10][10][10][8];
-static int flagnorm[10][10][10][8];
-
-/*static const double dwt_norms[5][8][10] = {
-	{//ResZ=1
-		{1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
-		{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
-	},{//ResZ=2
-		{1.000, 1.8371, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
-		{1.2717, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{1.2717, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{.8803, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93},
-		{1.2717},
-		{.8803},
-		{.8803},
-		{.6093},
-	},{ //ResZ=3
-		{1.000, 1.8371, 4.5604, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
-		{1.2717, 2.6403, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{1.2717, 2.6403, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{.8803, 1.5286, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93},
-		{1.2717, 2.6403},
-		{.8803, 1.5286},
-		{.8803, 1.5286},
-		{.6093, 0.8850},
-	},{ //ResZ=4
-		{1.000, 1.8371, 4.5604, 12.4614, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
-		{1.2717, 2.6403, 6.7691 , 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{1.2717, 2.6403, 6.7691 , 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{.8803, 1.5286, 3.6770 , 3.043, 6.019, 12.01, 24.00, 47.97, 95.93},
-		{1.2717, 2.6403, 6.7691 },
-		{.8803, 1.5286, 3.6770 },
-		{.8803, 1.5286, 3.6770 },
-		{.6093, 0.8850, 1.9974 },
-	},{ //ResZ=5
-		{1.000, 1.8371, 4.5604, 12.4614, 34.9025, 21.34, 42.67, 85.33, 170.7, 341.3},
-		{1.2717, 2.6403, 6.7691 , 18.6304 , 11.33, 22.64, 45.25, 90.48, 180.9},
-		{1.2717, 2.6403, 6.7691 , 18.6304, 11.33, 22.64, 45.25, 90.48, 180.9},
-		{.8803, 1.5286, 3.6770 , 9.9446, 6.019, 12.01, 24.00, 47.97, 95.93},
-		{1.2717, 2.6403, 6.7691, 18.6304},
-		{.8803, 1.5286, 3.6770, 9.9446 },
-		{.8803, 1.5286, 3.6770, 9.9446 },
-		{.6093, 0.8850, 1.9974, 5.3083 },
-	}
-};*/
-
-/* <summary>                                                              */
-/* This table contains the norms of the 9-7 wavelets for different bands. */
-/* </summary>                                                             */
-/*static const double dwt_norms_real[5][8][10] = {
-	{//ResZ==1
-		{1.000, 1.9659, 4.1224, 8.4167, 16.9356, 33.9249, 67.8772, 135.7680, 271.5430, 543.0894},
-		{1.0113, 1.9968, 4.1834, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{1.0113, 1.9968, 4.1834, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{0.5202, 0.9672, 2.0793, 4.3005, 8.6867, 17.4188, 34.8608, 69.7332, 139.4722}
-	}, { //ResZ==2
-		{1.000, 2.7564, 4.1224, 8.4167, 16.9356, 33.9249, 67.8772, 135.7680, 271.5430, 543.0894},
-		{1.4179, 1.9968, 4.1834, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{1.4179, 1.9968, 4.1834, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{0.7294, 0.9672, 2.0793, 4.3005, 8.6867, 17.4188, 34.8608, 69.7332, 139.4722},
-		{1.4179},
-		{0.7294},
-		{0.7294},
-		{0.3752} //HHH
-	},{ //ResZ==3
-		{1.000, 2.7564, 8.3700, 8.4167, 16.9356, 33.9249, 67.8772, 135.7680, 271.5430, 543.0894},
-		{1.4179, 4.0543, 4.1834, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{1.4179, 4.0543, 4.1834, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{0.7294, 1.9638, 2.0793, 4.3005, 8.6867, 17.4188, 34.8608, 69.7332, 139.4722},
-		{1.4179, 4.0543},
-		{0.7294, 1.9638},
-		{0.7294, 1.9638},
-		{0.3752, 0.9512} //HHH
-	},{ //ResZ==4
-		{1.000, 2.7564, 8.3700, 24.4183, 16.9356, 33.9249, 67.8772, 135.7680, 271.5430, 543.0894},
-		{1.4179, 4.0543, 12.1366, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{1.4179, 4.0543, 12.1366, 8.5341, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{0.7294, 1.9638, 6.0323, 4.3005, 8.6867, 17.4188, 34.8608, 69.7332, 139.4722},
-		{1.4179, 4.0543, 12.1366},
-		{0.7294, 1.9638, 6.0323},
-		{0.7294, 1.9638, 6.0323},
-		{0.3752, 0.9512, 2.9982} //HHH
-	},{ //ResZ==5
-		{1.000, 2.7564, 8.3700, 24.4183, 69.6947, 33.9249, 67.8772, 135.7680, 271.5430, 543.0894},
-		{1.4179, 4.0543, 12.1366, 35.1203, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{1.4179, 4.0543, 12.1366, 35.1203, 17.1667, 34.3852, 68.7967, 137.6065, 275.2196},
-		{0.7294, 1.9638, 6.0323, 17.6977, 8.6867, 17.4188, 34.8608, 69.7332, 139.4722},
-		{1.4179, 4.0543, 12.1366, 35.1203},
-		{0.7294, 1.9638, 6.0323, 17.6977},
-		{0.7294, 1.9638, 6.0323, 17.6977},
-		{0.3752, 0.9512, 2.9982, 8.9182} //HHH
-	}
-};*/
-
-static opj_atk_t atk_info_wt[] = {
-	{0, 1, J3D_ATK_WS, J3D_ATK_IRR, 0, J3D_ATK_WS, 1.230174104, 4, {0}, {0}, {0}, {1,1,1,1}, {-1.586134342059924, -0.052980118572961, 0.882911075530934, 0.443506852043971}},/* WT 9-7 IRR*/
-	{1, 0, J3D_ATK_WS, J3D_ATK_REV, 0, J3D_ATK_WS, 0, 2, {0}, {1,2}, {1,2}, {1,1}, {-1,1}},/* WT 5-3 REV*/
-	{2, 0, J3D_ATK_ARB, J3D_ATK_REV, 0, J3D_ATK_CON, 0, 2, {0,0}, {0,1}, {0,1}, {1,1}, {{-1},{1}}}, /* WT 2-2 REV*/
-	{3, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-1}, {0,1,2}, {0,1,2}, {1,1,3}, {{-1},{1},{1,0,-1}}}, /* WT 2-6 REV*/
-	{4, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-2}, {0,1,6}, {0,1,32}, {1,1,5}, {{-1},{1},{-3,22,0,-22,3}}}, /* WT 2-10 REV*/
-	{5, 1, J3D_ATK_ARB, J3D_ATK_IRR, 1, J3D_ATK_WS, 1, 7, {0}, {0}, {0}, {1,1,2,1,2,1,3},{{-1},{1.58613434206},{-0.460348209828, 0.460348209828},{0.25},{0.374213867768,-0.374213867768},{-1.33613434206},{0.29306717103,0,-0.29306717103}}}, /* WT 6-10 IRR*/
-	{6, 1, J3D_ATK_ARB, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 11, {0}, {0}, {0}, {1,1,2,1,2,1,2,1,2,1,5},{{-1},{0,99715069105},{-1.00573127827, 1.00573127827},{-0.27040357631},{2.20509972343, -2.20509972343},{0.08059995736},
-		{-1.62682532350, 1.62682532350},{0.52040357631},{0.60404664250, -0.60404664250},{-0.82775064841},{-0.06615812964, 0.29402137720, 0, -0.29402137720, 0.06615812964}}}, /* WT 10-18 IRR*/
-	{7, 1, J3D_ATK_WS, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 2, {0}, {0}, {0}, {1,1}, {-0.5, 0.25}},	/* WT 5-3 IRR*/
-	{8, 0, J3D_ATK_WS, J3D_ATK_REV, 0, J3D_ATK_WS, 0, 2, {0}, {4,4}, {8,8}, {2,2}, {{-9,1},{5,-1}}}		/* WT 13-7 REV*/
-};
-/* 
-==========================================================
-   local functions
-==========================================================
-*/
-
-/* <summary>			                 */
-/* Forward lazy transform (horizontal).  */
-/* </summary>                            */ 
-static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas) {
-	int i;
-    for (i=0; i<sn; i++) b[i]=a[2*i+cas];
-    for (i=0; i<dn; i++) b[sn+i]=a[(2*i+1-cas)];
-}
-
-/* <summary>                             */  
-/* Forward lazy transform (vertical).    */
-/* </summary>                            */ 
-static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
-    int i;
-    for (i=0; i<sn; i++) b[i*x]=a[2*i+cas];
-    for (i=0; i<dn; i++) b[(sn+i)*x]=a[(2*i+1-cas)];
-}
-
-/* <summary>                             */  
-/* Forward lazy transform (axial).       */
-/* </summary>                            */ 
-static void dwt_deinterleave_z(int *a, int *b, int dn, int sn, int xy, int cas) {
-    int i;
-    for (i=0; i<sn; i++) b[i*xy]=a[2*i+cas];
-    for (i=0; i<dn; i++) b[(sn+i)*xy]=a[(2*i+1-cas)];
-}
-
-/* <summary>                             */
-/* Inverse lazy transform (horizontal).  */
-/* </summary>                            */
-static void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas) {
-    int i;
-    int *ai = NULL;
-    int *bi = NULL;
-    ai = a;
-    bi = b + cas;
-    for (i = 0; i < sn; i++) {
-      *bi = *ai;  
-	  bi += 2;  
-	  ai++;
-    }
-    ai = a + sn;
-    bi = b + 1 - cas;
-    for (i = 0; i < dn; i++) {
-      *bi = *ai;
-	  bi += 2;
-	  ai++;
-    }
-}
-
-/* <summary>                             */  
-/* Inverse lazy transform (vertical).    */
-/* </summary>                            */ 
-static void dwt_interleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
-    int i;
-    int *ai = NULL;
-    int *bi = NULL;
-    ai = a;
-    bi = b + cas;
-    for (i = 0; i < sn; i++) {
-      *bi = *ai;
-	  bi += 2;
-	  ai += x;
-    }
-    ai = a + (sn * x);
-    bi = b + 1 - cas;
-    for (i = 0; i < dn; i++) {
-      *bi = *ai;
-	  bi += 2;  
-	  ai += x;
-    }
-}
-
-/* <summary>                             */
-/* Inverse lazy transform (axial).  */
-/* </summary>                            */
-static void dwt_interleave_z(int *a, int *b, int dn, int sn, int xy, int cas) {
-    int i;
-    int *ai = NULL;
-    int *bi = NULL;
-    ai = a;
-    bi = b + cas;
-    for (i = 0; i < sn; i++) {
-      *bi = *ai;  
-	  bi += 2;  
-	  ai += xy;
-    }
-    ai = a + (sn * xy);
-    bi = b + 1 - cas;
-    for (i = 0; i < dn; i++) {
-      *bi = *ai;
-	  bi += 2;
-	  ai += xy;
-    }
-}
-
-
-/* <summary>                            */
-/* Forward 5-3 or 9-7 wavelet tranform in 1-D. */
-/* </summary>                           */
-static void dwt_encode_53(int *a, int dn, int sn, int cas) {
-	int i;
-
-	if (!cas) {
-		if ((dn > 0) || (sn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-			//for (i = 0; i < dn; i++) D(i) -= (S_(i) + S_(i + 1)) >> 1;
-			//for (i = 0; i < sn; i++) S(i) += (D_(i - 1) + D_(i) + 2) >> 2;
-			for (i = 0; i < dn; i++){
-				D(i) -= (S_(i) + S_(i + 1)) >> 1;
-				//ops += 2;
-			}
-			for (i = 0; i < sn; i++){
-				S(i) += (D_(i - 1) + D_(i) + 2) >> 2;
-				//ops += 3;
-			}
-		}
-	} else {
-		/*if (!sn && dn == 1)
-			S(0) *= 2;
-		else {
-			for (i = 0; i < dn; i++) S(i) -= (DD_(i) + DD_(i - 1)) >> 1;
-			for (i = 0; i < sn; i++) D(i) += (SS_(i) + SS_(i + 1) + 2) >> 2;
-		}*/
-		if (!sn && dn == 1){
-			S(0) *= 2;
-			//ops++;
-		} else {
-			for (i = 0; i < dn; i++){
-				S(i) -= (DD_(i) + DD_(i - 1)) >> 1;
-			//	ops += 2;
-			}
-			for (i = 0; i < sn; i++){
-				D(i) += (SS_(i) + SS_(i + 1) + 2) >> 2;
-			//	ops += 3;
-			}
-		}
-	}
-}
-static void dwt_encode_97(int *a, int dn, int sn, int cas) {
-	int i;
-
-	if (!cas) {
-			if ((dn > 0) || (sn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-				for (i = 0; i < dn; i++)
-					D(i) -= fix_mul(S_(i) + S_(i + 1), 12993);
-				for (i = 0; i < sn; i++)
-					S(i) -= fix_mul(D_(i - 1) + D_(i), 434);
-				for (i = 0; i < dn; i++)
-					D(i) += fix_mul(S_(i) + S_(i + 1), 7233);
-				for (i = 0; i < sn; i++)
-					S(i) += fix_mul(D_(i - 1) + D_(i), 3633);
-				for (i = 0; i < dn; i++)
-					D(i) = fix_mul(D(i), 5038);	/*5038 */
-				for (i = 0; i < sn; i++)
-					S(i) = fix_mul(S(i), 6659);	/*6660 */
-			}
-		} else {
-			if ((sn > 0) || (dn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-				for (i = 0; i < dn; i++)
-					S(i) -= fix_mul(DD_(i) + DD_(i - 1), 12993);
-				for (i = 0; i < sn; i++)
-					D(i) -= fix_mul(SS_(i) + SS_(i + 1), 434);
-				for (i = 0; i < dn; i++)
-					S(i) += fix_mul(DD_(i) + DD_(i - 1), 7233);
-				for (i = 0; i < sn; i++)
-					D(i) += fix_mul(SS_(i) + SS_(i + 1), 3633);
-				for (i = 0; i < dn; i++)
-					S(i) = fix_mul(S(i), 5038);	/*5038 */
-				for (i = 0; i < sn; i++)
-					D(i) = fix_mul(D(i), 6659);	/*6660 */
-			}
-		}
-}
-/* <summary>                            */
-/* Inverse 5-3 or 9-7 wavelet tranform in 1-D. */
-/* </summary>                           */ 
-static void dwt_decode_53(int *a, int dn, int sn, int cas) {
-	int i;
-	if (!cas) {
-		if ((dn > 0) || (sn > 1)) { /* NEW :  CASE ONE ELEMENT */
-			for (i = 0; i < sn; i++) S(i) -= (D_(i - 1) + D_(i) + 2) >> 2;
-			for (i = 0; i < dn; i++) D(i) += (S_(i) + S_(i + 1)) >> 1;
-		}
-	} else {
-		if (!sn  && dn == 1)          /* NEW :  CASE ONE ELEMENT */
-			S(0) /= 2;
-		else {
-			for (i = 0; i < sn; i++) D(i) -= (SS_(i) + SS_(i + 1) + 2) >> 2;
-			for (i = 0; i < dn; i++) S(i) += (DD_(i) + DD_(i - 1)) >> 1;
-		}
-	}
-}
-static void dwt_decode_97(int *a, int dn, int sn, int cas) {
-	int i;
-
-	if (!cas) {
-		if ((dn > 0) || (sn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-			for (i = 0; i < sn; i++)
-				S(i) = fix_mul(S(i), 10078);	/* 10076 */
-			for (i = 0; i < dn; i++)
-				D(i) = fix_mul(D(i), 13318);	/* 13320 */
-			for (i = 0; i < sn; i++)
-				S(i) -= fix_mul(D_(i - 1) + D_(i), 3633);
-			for (i = 0; i < dn; i++)
-				D(i) -= fix_mul(S_(i) + S_(i + 1), 7233);
-			for (i = 0; i < sn; i++)
-				S(i) += fix_mul(D_(i - 1) + D_(i), 434);
-			for (i = 0; i < dn; i++)
-				D(i) += fix_mul(S_(i) + S_(i + 1), 12994);	/* 12993 */
-		}
-	} else {
-		if ((sn > 0) || (dn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-			for (i = 0; i < sn; i++)
-				D(i) = fix_mul(D(i), 10078);	/* 10076 */
-			for (i = 0; i < dn; i++)
-				S(i) = fix_mul(S(i), 13318);	/* 13320 */
-			for (i = 0; i < sn; i++)
-				D(i) -= fix_mul(SS_(i) + SS_(i + 1), 3633);
-			for (i = 0; i < dn; i++)
-				S(i) -= fix_mul(DD_(i) + DD_(i - 1), 7233);
-			for (i = 0; i < sn; i++)
-				D(i) += fix_mul(SS_(i) + SS_(i + 1), 434);
-			for (i = 0; i < dn; i++)
-				S(i) += fix_mul(DD_(i) + DD_(i - 1), 12994);	/* 12993 */
-		}
-	}
-}
-
-
-/* <summary>                */
-/* Get norm of arbitrary wavelet transform. */
-/* </summary>               */
-static int upandconv(double *nXPS, double *LPS, int lenXPS, int lenLPS) {
-	/* Perform the convolution of the vectors. */
-	int i,j;
-	double *tmp = (double *)opj_malloc(2*lenXPS * sizeof(double));
-	//Upsample
-	memset(tmp, 0, 2*lenXPS*sizeof(double));
-	for (i = 0; i < lenXPS; i++) {
-		*(tmp + 2*i) = *(nXPS + i);
-		*(nXPS + i) = 0;
-	}
-	//Convolution
-	for (i = 0; i < 2*lenXPS; i++) {
-		for (j = 0; j < lenLPS; j++) {
-			*(nXPS+i+j) = *(nXPS+i+j) + *(tmp + i) * *(LPS + j);
-			//fprintf(stdout,"*(tmp + %d) * *(LPS + %d) = %f * %f \n",i,j,*(tmp + i),*(LPS + j));
-		}
-	}
-	free(tmp);
-	return 2*lenXPS+lenLPS-1;
-}
-
-static double dwt_calc_wtnorms(int orient, int level[3], int dwtid[3], opj_wtfilt_t *wtfiltX,  opj_wtfilt_t *wtfiltY,  opj_wtfilt_t *wtfiltZ) {
-	int i, lenLPS, lenHPS;
-	double	Lx = 0, Ly= 0, Hx= 0, Hy= 0, Lz= 0, Hz= 0;
-	double *nLPSx, *nHPSx,*nLPSy, *nHPSy,*nLPSz, *nHPSz;
-	int levelx, levely, levelz;
-	    
-	levelx = (orient == 0) ? level[0]-1 : level[0];
-	levely = (orient == 0) ? level[1]-1 : level[1];
-	levelz = (orient == 0) ? level[2]-1 : level[2];
-	
-	//X axis
-	lenLPS = wtfiltX->lenLPS;
-	lenHPS = wtfiltX->lenHPS;
-	for (i = 0; i < levelx; i++) {
-		lenLPS *= 2;
-		lenHPS *= 2;
-		lenLPS += wtfiltX->lenLPS - 1;
-		lenHPS += wtfiltX->lenLPS - 1;
-	}
-	nLPSx = (double *)opj_malloc(lenLPS * sizeof(double));
-	nHPSx = (double *)opj_malloc(lenHPS * sizeof(double));
-
-	memcpy(nLPSx, wtfiltX->LPS, wtfiltX->lenLPS * sizeof(double));
-	memcpy(nHPSx, wtfiltX->HPS, wtfiltX->lenHPS * sizeof(double));
-	lenLPS = wtfiltX->lenLPS;
-	lenHPS = wtfiltX->lenHPS;
-	for (i = 0; i < levelx; i++) {
-		lenLPS = upandconv(nLPSx, wtfiltX->LPS, lenLPS, wtfiltX->lenLPS);
-		lenHPS = upandconv(nHPSx, wtfiltX->LPS, lenHPS, wtfiltX->lenLPS);
-	}
-	for (i = 0; i < lenLPS; i++)
-		Lx += nLPSx[i] * nLPSx[i];
-	for (i = 0; i < lenHPS; i++)
-		Hx += nHPSx[i] * nHPSx[i];
-	Lx = sqrt(Lx);
-	Hx = sqrt(Hx);
-	free(nLPSx);
-	free(nHPSx);
-	
-	//Y axis
-	if (dwtid[0] != dwtid[1] || level[0] != level[1]){
-		lenLPS = wtfiltY->lenLPS;
-		lenHPS = wtfiltY->lenHPS;
-		for (i = 0; i < levely; i++) {
-			lenLPS *= 2;
-			lenHPS *= 2;
-			lenLPS += wtfiltY->lenLPS - 1;
-			lenHPS += wtfiltY->lenLPS - 1;
-		}
-		nLPSy = (double *)opj_malloc(lenLPS * sizeof(double));
-		nHPSy = (double *)opj_malloc(lenHPS * sizeof(double));
-
-		memcpy(nLPSy, wtfiltY->LPS, wtfiltY->lenLPS * sizeof(double));
-		memcpy(nHPSy, wtfiltY->HPS, wtfiltY->lenHPS * sizeof(double));
-		lenLPS = wtfiltY->lenLPS;
-		lenHPS = wtfiltY->lenHPS;
-		for (i = 0; i < levely; i++) {
-			lenLPS = upandconv(nLPSy, wtfiltY->LPS, lenLPS, wtfiltY->lenLPS);
-			lenHPS = upandconv(nHPSy, wtfiltY->LPS, lenHPS, wtfiltY->lenLPS);
-		}
-		for (i = 0; i < lenLPS; i++)
-			Ly += nLPSy[i] * nLPSy[i];
-		for (i = 0; i < lenHPS; i++)
-			Hy += nHPSy[i] * nHPSy[i];
-		Ly = sqrt(Ly);
-		Hy = sqrt(Hy);
-		free(nLPSy);
-		free(nHPSy);
-	} else { 
-		Ly = Lx;
-		Hy = Hx;
-	}
-	//Z axis
-	if (levelz >= 0) { 
-		lenLPS = wtfiltZ->lenLPS;
-		lenHPS = wtfiltZ->lenHPS;
-		for (i = 0; i < levelz; i++) {
-			lenLPS *= 2;
-			lenHPS *= 2;
-			lenLPS += wtfiltZ->lenLPS - 1;
-			lenHPS += wtfiltZ->lenLPS - 1;
-		}
-		nLPSz = (double *)opj_malloc(lenLPS * sizeof(double));
-		nHPSz = (double *)opj_malloc(lenHPS * sizeof(double));
-
-		memcpy(nLPSz, wtfiltZ->LPS, wtfiltZ->lenLPS * sizeof(double));
-		memcpy(nHPSz, wtfiltZ->HPS, wtfiltZ->lenHPS * sizeof(double));
-		lenLPS = wtfiltZ->lenLPS;
-		lenHPS = wtfiltZ->lenHPS;
-		for (i = 0; i < levelz; i++) {
-			lenLPS = upandconv(nLPSz, wtfiltZ->LPS, lenLPS, wtfiltZ->lenLPS);
-			lenHPS = upandconv(nHPSz, wtfiltZ->LPS, lenHPS, wtfiltZ->lenLPS);
-		}
-		for (i = 0; i < lenLPS; i++)
-			Lz += nLPSz[i] * nLPSz[i];
-		for (i = 0; i < lenHPS; i++)
-			Hz += nHPSz[i] * nHPSz[i];
-		Lz = sqrt(Lz);
-		Hz = sqrt(Hz);
-		free(nLPSz);
-		free(nHPSz);
-	} else {
-		Lz = 1.0; Hz = 1.0;
-	}
-	switch (orient) {
-		case 0: 
-			return Lx * Ly * Lz;
-		case 1:
-			return Lx * Hy * Lz;
-		case 2:
-			return Hx * Ly * Lz;
-		case 3:
-			return Hx * Hy * Lz;
-		case 4:
-			return Lx * Ly * Hz;
-		case 5:
-			return Lx * Hy * Hz;
-		case 6: 
-			return Hx * Ly * Hz;
-		case 7:
-			return Hx * Hy * Hz;
-		default:
-			return -1;
-	}
-	
-}
-static void dwt_getwtfilters(opj_wtfilt_t *wtfilt, int dwtid) {
-	if (dwtid == 0) { //DWT 9-7 
-			wtfilt->lenLPS = 7;		wtfilt->lenHPS = 9;
-			wtfilt->LPS = (double *)opj_malloc(wtfilt->lenLPS * sizeof(double));
-			wtfilt->HPS = (double *)opj_malloc(wtfilt->lenHPS * sizeof(double));
-			wtfilt->LPS[0] = -0.091271763114;	wtfilt->HPS[0] = 0.026748757411;
-			wtfilt->LPS[1] = -0.057543526228;	wtfilt->HPS[1] = 0.016864118443;
-			wtfilt->LPS[2] = 0.591271763114;	wtfilt->HPS[2] = -0.078223266529;
-			wtfilt->LPS[3] = 1.115087052457;	wtfilt->HPS[3] = -0.266864118443;
-			wtfilt->LPS[4] = 0.591271763114;	wtfilt->HPS[4] = 0.602949018236;
-			wtfilt->LPS[5] = -0.057543526228;	wtfilt->HPS[5] = -0.266864118443;
-			wtfilt->LPS[6] = -0.091271763114;	wtfilt->HPS[6] = -0.078223266529;
-												wtfilt->HPS[7] = 0.016864118443;
-												wtfilt->HPS[8] = 0.026748757411;			
-	} else if (dwtid == 1) { //DWT 5-3 
-			wtfilt->lenLPS = 3;		wtfilt->lenHPS = 5;
-			wtfilt->LPS = (double *)opj_malloc(wtfilt->lenLPS * sizeof(double));
-			wtfilt->HPS = (double *)opj_malloc(wtfilt->lenHPS * sizeof(double));
-			wtfilt->LPS[0] = 0.5;	wtfilt->HPS[0] = -0.125; 
-			wtfilt->LPS[1] = 1;		wtfilt->HPS[1] = -0.25; 
-			wtfilt->LPS[2] = 0.5;	wtfilt->HPS[2] = 0.75;
-									wtfilt->HPS[3] = -0.25; 
-									wtfilt->HPS[4] = -0.125;
-	} else {
-		fprintf(stdout,"[ERROR] Sorry, this wavelet hasn't been implemented so far ... Try another one :-)\n");
-		exit(1);
-	}
-}
-/* <summary>                            */
-/* Encoding of quantization stepsize for each subband. */
-/* </summary>                           */ 
-static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize) {
-	int p, n;
-	p = int_floorlog2(stepsize) - 13;
-	n = 11 - int_floorlog2(stepsize);
-	bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
-	bandno_stepsize->expn = numbps - p;
-	//if J3D_CCP_QNTSTY_NOQNT --> stepsize = 8192.0 --> p = 0, n = -2 --> mant = 0; expn = (prec+gain)
-	//else --> bandno_stepsize = (1<<(numbps - expn)) + (1<<(numbps - expn - 11)) * Ub
-}
-
-/* 
-==========================================================
-   DWT interface
-==========================================================
-*/
-/* <summary>                            */
-/* Forward 5-3 wavelet tranform in 3-D. */
-/* </summary>                           */
-void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]) {
-	int i, j, k;
-	int x, y, z;
-	int w, h, wh, d;
-	int level,levelx,levely,levelz,diff;
-	int *a = NULL;
-	int *aj = NULL;
-	int *bj = NULL;
-	int *cj = NULL;
-	
-	ops = 0;
-
-	memset(flagnorm,0,8000*sizeof(int));
-	w = tilec->x1-tilec->x0;
-	h = tilec->y1-tilec->y0;
-	d = tilec->z1-tilec->z0;
-	wh = w * h;
-	levelx = tilec->numresolution[0]-1;
-	levely = tilec->numresolution[1]-1;
-	levelz = tilec->numresolution[2]-1;
-	level = int_max(levelx,int_max(levely,levelz));
-	diff = tilec->numresolution[0] - tilec->numresolution[2];
-
-	a = tilec->data;
-
-	for (x = 0, y = 0, z = 0; (x < levelx) && (y < levely); x++, y++, z++) {
-		int rw;			/* width of the resolution level computed                                                           */
-		int rh;			/* heigth of the resolution level computed                                                          */
-		int rd;			/* depth of the resolution level computed                                                          */
-		int rw1;		/* width of the resolution level once lower than computed one                                       */
-		int rh1;		/* height of the resolution level once lower than computed one                                      */
-		int rd1;		/* depth of the resolution level once lower than computed one                                      */
-		int cas_col;	/* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
-		int cas_row;	/* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
-		int cas_axl;	/* 0 = non inversion on axial filtering 1 = inversion between low-pass and high-pass filtering   */
-		int dn, sn;
-		
-		rw = tilec->resolutions[level - x].x1 - tilec->resolutions[level - x].x0;
-		rh = tilec->resolutions[level - y].y1 - tilec->resolutions[level - y].y0;
-		rd = tilec->resolutions[level - z].z1 - tilec->resolutions[level - z].z0;
-		rw1= tilec->resolutions[level - x - 1].x1 - tilec->resolutions[level - x - 1].x0;
-		rh1= tilec->resolutions[level - y - 1].y1 - tilec->resolutions[level - y - 1].y0;
-		rd1= tilec->resolutions[level - z - 1].z1 - tilec->resolutions[level - z - 1].z0;
-		
-		cas_col = tilec->resolutions[level - x].x0 % 2; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
-		cas_row = tilec->resolutions[level - y].y0 % 2; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
-		cas_axl = tilec->resolutions[level - z].z0 % 2;
-	
-		/*fprintf(stdout," x %d y %d z %d \n",x,y,z);
-		fprintf(stdout," levelx %d levely %d levelz %d \n",levelx,levely,levelz);
-		fprintf(stdout," z1 %d z0 %d\n",tilec->resolutions[level - z].z1,tilec->resolutions[level - z].z0);
-		fprintf(stdout," rw %d rh %d rd %d \n rw1 %d rh1 %d rd1 %d \n",rw,rh,rd,rw1,rh1,rd1);*/
-
-		for (i = 0; i < rd; i++) {
-			
-			cj = a + (i * wh);
-			
-			//Horizontal
-			sn = rw1;
-			dn = rw - rw1;
-			bj = (int*)opj_malloc(rw * sizeof(int));
-			if (dwtid[0] == 0) {
-				for (j = 0; j < rh; j++) {
-					aj = cj + j * w;
-					for (k = 0; k < rw; k++)  bj[k] = aj[k];
-					dwt_encode_97(bj, dn, sn, cas_row);
-					dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
-				}
-			} else if (dwtid[0] == 1) {
-				for (j = 0; j < rh; j++) {
-					aj = cj + j * w;
-					for (k = 0; k < rw; k++)  bj[k] = aj[k];
-					dwt_encode_53(bj, dn, sn, cas_row);
-					dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
-				}
-			} 
-			opj_free(bj);
-
-			//Vertical
-			sn = rh1;
-			dn = rh - rh1;
-			bj = (int*)opj_malloc(rh * sizeof(int));
-			if (dwtid[1] == 0) { /*DWT 9-7*/
-				for (j = 0; j < rw; j++) {
-					aj = cj + j;
-					for (k = 0; k < rh; k++)  bj[k] = aj[k*w];
-					dwt_encode_97(bj, dn, sn, cas_col);
-					dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
-				}
-            } else if (dwtid[1] == 1) { /*DWT 5-3*/
-				for (j = 0; j < rw; j++) {
-					aj = cj + j;
-					for (k = 0; k < rh; k++)  bj[k] = aj[k*w];
-					dwt_encode_53(bj, dn, sn, cas_col);
-					dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
-				}
-			} 
-			opj_free(bj);
-		}
-
-		if (z < levelz){
-			//Axial fprintf(stdout,"Axial DWT Transform %d %d %d\n",z,rd,rd1);
-			sn = rd1;
-			dn = rd - rd1;
-			bj = (int*)opj_malloc(rd * sizeof(int));
-			if (dwtid[2] == 0) {
-                for (j = 0; j < (rw*rh); j++) {
-					aj = a + j;
-					for (k = 0; k < rd; k++)  bj[k] = aj[k*wh];
-					dwt_encode_97(bj, dn, sn, cas_axl);
-					dwt_deinterleave_z(bj, aj, dn, sn, wh, cas_axl);
-				}
-			} else if (dwtid[2] == 1) {
-				for (j = 0; j < (rw*rh); j++) {
-					aj = a + j;
-					for (k = 0; k < rd; k++)  bj[k] = aj[k*wh];
-					dwt_encode_53(bj, dn, sn, cas_axl);
-					dwt_deinterleave_z(bj, aj, dn, sn, wh, cas_axl);
-				}
-			} 
-			opj_free(bj);
-		}
-	}
-
-	//fprintf(stdout,"[INFO] Ops: %d \n",ops);
-}
-
-
-/* <summary>                            */
-/* Inverse 5-3 wavelet tranform in 3-D. */
-/* </summary>                           */
-void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3]) {
-	int i, j, k;
-	int x, y, z;
-	int w, h, wh, d;
-	int level, levelx, levely, levelz, diff;
-	int *a = NULL;
-	int *aj = NULL;
-	int *bj = NULL;
-	int *cj = NULL;
-	
-	a = tilec->data;
-
-	w = tilec->x1-tilec->x0;
-	h = tilec->y1-tilec->y0;
-	d = tilec->z1-tilec->z0;
-	wh = w * h;
-	levelx = tilec->numresolution[0]-1;
-	levely = tilec->numresolution[1]-1;
-	levelz = tilec->numresolution[2]-1;
-	level = int_max(levelx,int_max(levely,levelz));
-	diff = tilec->numresolution[0] - tilec->numresolution[2];
-		
-/* General lifting framework -- DCCS-LIWT */
-	for (x = level - 1, y = level - 1, z = level - 1; (x >= stops[0]) && (y >= stops[1]); x--, y--, z--) {
-		int rw;			/* width of the resolution level computed                                                           */
-		int rh;			/* heigth of the resolution level computed                                                          */
-		int rd;			/* depth of the resolution level computed                                                          */
-		int rw1;		/* width of the resolution level once lower than computed one                                       */
-		int rh1;		/* height of the resolution level once lower than computed one                                      */
-		int rd1;		/* depth of the resolution level once lower than computed one                                      */
-		int cas_col;	/* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
-		int cas_row;	/* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
-		int cas_axl;	/* 0 = non inversion on axial filtering 1 = inversion between low-pass and high-pass filtering   */
-		int dn, sn;
-		
-		rw = tilec->resolutions[level - x].x1 - tilec->resolutions[level - x].x0;
-		rh = tilec->resolutions[level - y].y1 - tilec->resolutions[level - y].y0;
-		rd = tilec->resolutions[level - z].z1 - tilec->resolutions[level - z].z0;
-		rw1= tilec->resolutions[level - x - 1].x1 - tilec->resolutions[level - x - 1].x0;
-		rh1= tilec->resolutions[level - y - 1].y1 - tilec->resolutions[level - y - 1].y0;
-		rd1= tilec->resolutions[level - z - 1].z1 - tilec->resolutions[level - z - 1].z0;
-		
-		cas_col = tilec->resolutions[level - x].x0 % 2; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
-		cas_row = tilec->resolutions[level - y].y0 % 2; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
-		cas_axl = tilec->resolutions[level - z].z0 % 2;
-	
-		/*fprintf(stdout," x %d y %d z %d \n",x,y,z);
-		fprintf(stdout," levelx %d levely %d levelz %d \n",levelx,levely,levelz);
-		fprintf(stdout," dwtid[0] %d [1] %d [2] %d \n",dwtid[0],dwtid[1],dwtid[2]);
-		fprintf(stdout," rw %d rh %d rd %d \n rw1 %d rh1 %d rd1 %d \n",rw,rh,rd,rw1,rh1,rd1);
-		fprintf(stdout,"IDWT Transform %d %d %d %d\n",level, z, rd,rd1);*/
-
-		if (z >= stops[2] && rd != rd1) {
-			//fprintf(stdout,"Axial Transform %d %d %d %d\n",levelz, z, rd,rd1);
-			sn = rd1;
-			dn = rd - rd1;
-			bj = (int*)opj_malloc(rd * sizeof(int));
-			if (dwtid[2] == 0) {
-				for (j = 0; j < (rw*rh); j++) {
-					aj = a + j;
-					dwt_interleave_z(aj, bj, dn, sn, wh, cas_axl);
-					dwt_decode_97(bj, dn, sn, cas_axl);
-					for (k = 0; k < rd; k++)  aj[k * wh] = bj[k];
-				}
-			} else if (dwtid[2] == 1) {
-				for (j = 0; j < (rw*rh); j++) {
-					aj = a + j;
-					dwt_interleave_z(aj, bj, dn, sn, wh, cas_axl);
-					dwt_decode_53(bj, dn, sn, cas_axl);
-					for (k = 0; k < rd; k++)  aj[k * wh] = bj[k];
-				}
-			} 
-			opj_free(bj);
-		}
-
-		for (i = 0; i < rd; i++) {
-			//Fetch corresponding slice for doing DWT-2D
- 			cj = tilec->data + (i * wh);
-			
-			//Vertical
-			sn = rh1;
-			dn = rh - rh1;
-			bj = (int*)opj_malloc(rh * sizeof(int));
-			if (dwtid[1] == 0) {
-				for (j = 0; j < rw; j++) {
-					aj = cj + j;
-					dwt_interleave_v(aj, bj, dn, sn, w, cas_col);
-					dwt_decode_97(bj, dn, sn, cas_col);
-					for (k = 0; k < rh; k++)  aj[k * w] = bj[k];
-				}
-			} else if (dwtid[1] == 1) {
-				for (j = 0; j < rw; j++) {
-					aj = cj + j;
-					dwt_interleave_v(aj, bj, dn, sn, w, cas_col);
-					dwt_decode_53(bj, dn, sn, cas_col);
-					for (k = 0; k < rh; k++)  aj[k * w] = bj[k];
-				}
-			} 
-			opj_free(bj);
-
-			//Horizontal
-			sn = rw1;
-			dn = rw - rw1;
-			bj = (int*)opj_malloc(rw * sizeof(int));
-			if (dwtid[0]==0) {
-				for (j = 0; j < rh; j++) {
-					aj = cj + j*w;
-					dwt_interleave_h(aj, bj, dn, sn, cas_row);
-					dwt_decode_97(bj, dn, sn, cas_row);
-					for (k = 0; k < rw; k++)  aj[k] = bj[k];
-				}
-			} else if (dwtid[0]==1) {
-				for (j = 0; j < rh; j++) {
-					aj = cj + j*w;
-					dwt_interleave_h(aj, bj, dn, sn, cas_row);
-					dwt_decode_53(bj, dn, sn, cas_row);
-					for (k = 0; k < rw; k++)  aj[k] = bj[k];
-				}
-			} 
-			opj_free(bj);
-			
-		}
-	
-	}
-
-}
-
-
-/* <summary>                          */
-/* Get gain of wavelet transform. */
-/* </summary>                         */
-int dwt_getgain(int orient, int reversible) {
-	if (reversible == 1) { 
-		if (orient == 0)
-			return 0;
-		else if (orient == 1 || orient == 2 || orient == 4 )
-			return 1;
-		else if (orient == 3 || orient == 5 || orient == 6 )
-			return 2;
-		else 
-			return 3;
-	}
-	//else if (reversible == 0){
-	return 0;
-}
-
-/* <summary>                */
-/* Get norm of wavelet transform. */
-/* </summary>               */
-double dwt_getnorm(int orient, int level[3], int dwtid[3]) {
-	int levelx = level[0];
-	int levely = level[1];
-	int levelz = (level[2] < 0) ? 0 : level[2];
-	double norm;
-
-	if (flagnorm[levelx][levely][levelz][orient] == 1) {
-		norm = dwt_norm[levelx][levely][levelz][orient];
-		//fprintf(stdout,"[INFO] Level: %d %d %d Orient %d Dwt_norm: %f \n",level[0],level[1],level[2],orient,norm);
-	} else {
-		opj_wtfilt_t *wtfiltx =(opj_wtfilt_t *) opj_malloc(sizeof(opj_wtfilt_t));
-		opj_wtfilt_t *wtfilty =(opj_wtfilt_t *) opj_malloc(sizeof(opj_wtfilt_t));
-		opj_wtfilt_t *wtfiltz =(opj_wtfilt_t *) opj_malloc(sizeof(opj_wtfilt_t));
-		//Fetch equivalent filters for each dimension
-		dwt_getwtfilters(wtfiltx, dwtid[0]);
-		dwt_getwtfilters(wtfilty, dwtid[1]);
-		dwt_getwtfilters(wtfiltz, dwtid[2]);
-		//Calculate the corresponding norm 
-		norm = dwt_calc_wtnorms(orient, level, dwtid, wtfiltx, wtfilty, wtfiltz);
-		//Save norm in array (no recalculation)
-		dwt_norm[levelx][levely][levelz][orient] = norm;
-		flagnorm[levelx][levely][levelz][orient] = 1;
-		//Free reserved space
-		opj_free(wtfiltx->LPS);	opj_free(wtfilty->LPS);	opj_free(wtfiltz->LPS);
-		opj_free(wtfiltx->HPS);	opj_free(wtfilty->HPS);	opj_free(wtfiltz->HPS);
-		opj_free(wtfiltx);		opj_free(wtfilty);		opj_free(wtfiltz);
-		//fprintf(stdout,"[INFO] Dwtid: %d %d %d Level: %d %d %d Orient %d Norm: %f \n",dwtid[0],dwtid[1],dwtid[2],level[0],level[1],level[2],orient,norm);
-	} 
-	return norm;
-}
-/* <summary>								*/
-/* Calculate explicit stepsizes for DWT.	*/
-/* </summary>								*/
-void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec) { 
-	int totnumbands, bandno, diff;
-	
-	assert(tccp->numresolution[0] >= tccp->numresolution[2]);	
-	diff = tccp->numresolution[0] - tccp->numresolution[2];		/*if RESx=RESy != RESz */
-	totnumbands = (7 * tccp->numresolution[0] - 6) - 4 * diff; /* 3-D */
-		
-	for (bandno = 0; bandno < totnumbands; bandno++) {
-		double stepsize;
-		int resno, level[3], orient, gain;
-
-		/* Bandno:	0 - LLL 	1 - LHL 
-					2 - HLL		3 - HHL
-					4 - LLH		5 - LHH
-					6 - HLH		7 - HHH	*/
-
-		resno = (bandno == 0) ? 0 : ( (bandno <= 3 * diff) ? ((bandno - 1) / 3 + 1) : ((bandno + 4*diff - 1) / 7 + 1));
-		orient = (bandno == 0) ? 0 : ( (bandno <= 3 * diff) ? ((bandno - 1) % 3 + 1) : ((bandno + 4*diff - 1) % 7 + 1));
-		level[0] = tccp->numresolution[0] - 1 - resno;
-		level[1] = tccp->numresolution[1] - 1 - resno;
-		level[2] = tccp->numresolution[2] - 1 - resno;
-	
-		/* Gain:	0 - LLL 	1 - LHL 
-					1 - HLL		2 - HHL
-					1 - LLH		2 - LHH
-					2 - HLH		3 - HHH		*/
-		gain = (tccp->reversible == 0) ? 0 : ( (orient == 0) ? 0 : 
-				( ((orient == 1) || (orient == 2) || (orient == 4)) ? 1 : 
-						(((orient == 3) || (orient == 5) || (orient == 6)) ? 2 : 3)) );
-				
-		if (tccp->qntsty == J3D_CCP_QNTSTY_NOQNT) {
-			stepsize = 1.0;
-		} else {
-			double norm = dwt_getnorm(orient,level,tccp->dwtid); //Fetch norms if irreversible transform (by the moment only I9.7)
-			stepsize = (1 << (gain + 1)) / norm;
-		}
-		//fprintf(stdout,"[INFO] Bandno: %d Orient: %d Level: %d %d %d Stepsize: %f\n",bandno,orient,level[0],level[1],level[2],stepsize);
-		dwt_encode_stepsize((int) floor(stepsize * 8192.0), prec + gain, &tccp->stepsizes[bandno]);
-	}
-}
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.h
deleted file mode 100755
index afb1ba4..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/dwt.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyrigth (c) 2006, M�nica D�ez, LPI-UVA, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __DWT_H
-#define __DWT_H
-/**
- at file dwt.h
- at brief Implementation of a discrete wavelet transform (DWT)
-
-The functions in DWT.C have for goal to realize forward and inverse discret wavelet
-transform with filter 5-3 (reversible) and filter 9-7 (irreversible). The functions in
-DWT.C are used by some function in TCD.C.
-*/
-
-/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
-/*@{*/
-
-/**
-DCCS-LIWT properties
-*/
-
-
-typedef struct opj_wtfilt {
-	double *LPS;
-	int lenLPS;
-	double *HPS;
-	int lenHPS;
-} opj_wtfilt_t;
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Forward 5-3 wavelet tranform in 3-D. 
-Apply a reversible DWT transform to a component of an volume.
- at param tilec Tile component information (current tile)
- at param dwtid Number of identification of wavelet kernel(s) used in DWT in each direction
-*/
-void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]);
-/**
-Inverse 5-3 wavelet tranform in 3-D.
-Apply a reversible inverse DWT transform to a component of an volume.
- at param tilec Tile component information (current tile)
- at param stops Number of decoded resolution levels in each dimension
- at param dwtid Number of identification of wavelet kernel(s) used in DWT in each dimension
-*/
-void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3]);
-/* ----------------------------------------------------------------------- */
-/**
-Get the gain of a subband for the reversible 3-D DWT.
- at param orient Number that identifies the subband (0->LLL, 1->HLL, 2->LHL, 3->HHL, 4->LLH, 5->HLH, 6->LHH, 7->HHH)
- at param reversible Wavelet transformation type
- at return Returns 0 if orient = 0, returns 1 if orient = 1,2 or 4, returns 2 if orient = 3,5 or 6, returns 3 otherwise
-*/
-int dwt_getgain(int orient, int reversible);
-/**
-Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT or irreversible 9-7 in 3-D.
- at param orient Band of the wavelet function
- at param level Levels of the wavelet function in X,Y,Z axis
- at param dwtid Wavelet transformation identifier
- at return Returns the norm of the wavelet function
-*/
-double dwt_getnorm(int orient, int level[3], int dwtid[3]);
-/* ----------------------------------------------------------------------- */
-/**
-Calcula el valor del escal�n de cuantificaci�n correspondiente a cada subbanda.
- at param tccp Tile component coding parameters
- at param prec Precision of data
-*/
-void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec);
-/*@}*/
-
-#endif /* __DWT_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.c
deleted file mode 100755
index c558218..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-// ==========================================================
-//   Utility functions
-// ==========================================================
-
-#ifndef _WIN32
-static char*
-i2a(unsigned i, char *a, unsigned r) {
-	if (i/r > 0) a = i2a(i/r,a,r);
-	*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
-	return a+1;
-}
-
-/** 
- Transforms integer i into an ascii string and stores the result in a; 
- string is encoded in the base indicated by r.
- @param i Number to be converted
- @param a String result
- @param r Base of value; must be in the range 2 - 36
- @return Returns a
-*/
-static char *
-_itoa(int i, char *a, int r) {
-	r = ((r < 2) || (r > 36)) ? 10 : r;
-	if(i < 0) {
-		*a = '-';
-		*i2a(-i, a+1, r) = 0;
-	}
-	else *i2a(i, a, r) = 0;
-	return a;
-}
-
-#endif // !_WIN32
-
-/* ----------------------------------------------------------------------- */
-
-opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
-	if(cinfo) {
-		opj_event_mgr_t *previous = cinfo->event_mgr;
-		cinfo->event_mgr = event_mgr;
-		cinfo->client_data = context;
-		return previous;
-	}
-
-	return NULL;
-}
-
-bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
-#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
-	opj_msg_callback msg_handler = NULL;
-
-	opj_event_mgr_t *event_mgr = cinfo->event_mgr;
-	if(event_mgr != NULL) {
-		switch(event_type) {
-			case EVT_ERROR:
-				msg_handler = event_mgr->error_handler;
-				break;
-			case EVT_WARNING:
-				msg_handler = event_mgr->warning_handler;
-				break;
-			case EVT_INFO:
-				msg_handler = event_mgr->info_handler;
-				break;
-			default:
-				break;
-		}
-		if(msg_handler == NULL) {
-			return false;
-		}
-	} else {
-		return false;
-	}
-
-	if ((fmt != NULL) && (event_mgr != NULL)) {
-		va_list arg;
-		int str_length, i, j;
-		char message[MSG_SIZE];
-		memset(message, 0, MSG_SIZE);
-		/* initialize the optional parameter list */
-		va_start(arg, fmt);
-		/* check the length of the format string */
-		str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt);
-		/* parse the format string and put the result in 'message' */
-		for (i = 0, j = 0; i < str_length; ++i) {
-			if (fmt[i] == '%') {
-				if (i + 1 < str_length) {
-					switch(tolower(fmt[i + 1])) {
-						case '%' :
-							message[j++] = '%';
-							break;
-						case 'o' : /* octal numbers */
-						{
-							char tmp[16];
-							_itoa(va_arg(arg, int), tmp, 8);
-							strcat(message, tmp);
-							j += strlen(tmp);
-							++i;
-							break;
-						}
-						case 'i' : /* decimal numbers */
-						case 'd' :
-						{
-							char tmp[16];
-							_itoa(va_arg(arg, int), tmp, 10);
-							strcat(message, tmp);
-							j += strlen(tmp);
-							++i;
-							break;
-						}
-						case 'x' : /* hexadecimal numbers */
-						{
-							char tmp[16];
-							_itoa(va_arg(arg, int), tmp, 16);
-							strcat(message, tmp);
-							j += strlen(tmp);
-							++i;
-							break;
-						}
-						case 's' : /* strings */
-						{
-							char *tmp = va_arg(arg, char*);
-							strcat(message, tmp);
-							j += strlen(tmp);
-							++i;
-							break;
-						}
-						case 'f' :	/* floats */
-						{
-							char tmp[16];
-							double value = va_arg(arg, double);
-							sprintf(tmp, "%f", value);
-							strcat(message, tmp);
-							j += strlen(tmp);
-							++i;
-							break;
-						}
-					};
-				} else {
-					message[j++] = fmt[i];
-				}
-			} else {
-				message[j++] = fmt[i];
-			};
-		}
-		/* deinitialize the optional parameter list */
-		va_end(arg);
-
-		/* output the message to the user program */
-		msg_handler(message, cinfo->client_data);
-	}
-
-	return true;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.h
deleted file mode 100755
index 5a83bd2..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/event.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __EVENT_H
-#define __EVENT_H
-/**
- at file event.h
- at brief Implementation of a event callback system
-
-The functions in EVENT.C have for goal to send output messages (errors, warnings, debug) to the user.
-*/
-
-#define EVT_ERROR	1	/**< Error event type */
-#define EVT_WARNING	2	/**< Warning event type */
-#define EVT_INFO	4	/**< Debug event type */
-
-/** @defgroup EVENT EVENT - Implementation of a event callback system */
-/*@{*/
-
-/** @name Funciones generales (see also openjpeg3d.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Write formatted data to a string and send the string to a user callback. 
- at param cinfo Codec context info
- at param event_type Event type or callback to use to send the message
- at param fmt Format-control string (plus optionnal arguments)
- at return Returns true if successful, returns false otherwise
-*/
-bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __EVENT_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/fix.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/fix.h
deleted file mode 100755
index f2113b5..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/fix.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __FIX_H
-#define __FIX_H
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define int64 __int64
-#else
-#define int64 long long
-#endif
-
-/**
- at file fix.h
- at brief Implementation of operations of specific multiplication (FIX)
-
-The functions in FIX.H have for goal to realize specific multiplication.
-*/
-
-/** @defgroup FIX FIX - Implementation of operations of specific multiplication */
-/*@{*/
-
-/**
-Multiply two fixed-precision rational numbers.
- at param a
- at param b
- at return Returns a * b
-*/
-static  int fix_mul(int a, int b) {
-    int64 temp = (int64) a * (int64) b >> 12;
-    return (int) ((temp >> 1) + (temp & 1)) ;
-}
-
-/*@}*/
-
-#endif /* __FIX_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/int.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/int.h
deleted file mode 100755
index 38932d9..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/int.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __INT_H
-#define __INT_H
-/**
- at file int.h
- at brief Implementation of operations on integers (INT)
-
-The functions in INT.H have for goal to realize operations on integers.
-*/
-
-/** @defgroup INT INT - Implementation of operations on integers */
-/*@{*/
-
-/** @name Funciones generales (see also openjpeg3d.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Get the minimum of two integers
- at return Returns a if a < b else b
-*/
-static  int int_min(int a, int b) {
-	return a < b ? a : b;
-}
-/**
-Get the maximum of two integers
- at return Returns a if a > b else b
-*/
-static  int int_max(int a, int b) {
-	return (a > b) ? a : b;
-}
-/**
-Clamp an integer inside an interval
- at return
-<ul>
-<li>Returns a if (min < a < max)
-<li>Returns max if (a > max)
-<li>Returns min if (a < min) 
-</ul>
-*/
-static int int_clamp(int a, int min, int max) {
-	if (a < min)
-		return min;
-	if (a > max)
-		return max;
-	return a;
-}
-/**
- at return Get absolute value of integer
-*/
-static  int int_abs(int a) {
-	return a < 0 ? -a : a;
-}
-
-static double dbl_abs(double a) {
-	return a < 0 ? -a : a;
-}
-/**
-Divide an integer and round upwards
- at return Returns a divided by b
-*/
-static  int int_ceildiv(int a, int b) {
-	return (a + b - 1) / b;
-}
-/**
-Divide an integer by a power of 2 and round upwards
- at return Returns a divided by 2^b
-*/
-static  int int_ceildivpow2(int a, int b) {
-	return (a + (1 << b) - 1) >> b;
-}
-/**
-Divide an integer by a power of 2 and round downwards
- at return Returns a divided by 2^b
-*/
-static  int int_floordivpow2(int a, int b) {
-	return a >> b;
-}
-/**
-Get logarithm of an integer and round downwards
- at return Returns log2(a)
-*/
-static  int int_floorlog2(int a) {
-	int l;
-	for (l = 0; a > 1; l++) {
-		a >>= 1;
-	}
-	return l;
-}
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.c
deleted file mode 100755
index 4a5527b..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.c
+++ /dev/null
@@ -1,2328 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup J3D J3D - JPEG-2000 PART 10 codestream reader/writer */
-/*@{*/
-
-/** @name Funciones locales */
-/*@{*/
-
-/**
-Write the SOC marker (Start Of Codestream)
- at param j3d J3D handle
-*/
-static void j3d_write_soc(opj_j3d_t *j3d);
-/**
-Read the SOC marker (Start of Codestream)
- at param j3d J3D handle
-*/
-static void j3d_read_soc(opj_j3d_t *j3d);
-/**
-Write the SIZ marker (2D volume and tile size)
- at param j3d J3D handle
-*/
-static void j3d_write_siz(opj_j3d_t *j3d);
-/**
-Read the SIZ marker (2D volume and tile size)
- at param j3d J3D handle
-*/
-static void j3d_read_siz(opj_j3d_t *j3d);
-/**
-Write the ZSI marker (3rd volume and tile size)
- at param j3d J3D handle
-*/
-static void j3d_write_zsi(opj_j3d_t *j3d);
-/**
-Read the ZSI marker (3rd volume and tile size)
- at param j3d J3D handle
-*/
-static void j3d_read_zsi(opj_j3d_t *j3d);
-/**
-Write the COM marker (comment)
- at param j3d J3D handle
-*/
-static void j3d_write_com(opj_j3d_t *j3d);
-/**
-Read the COM marker (comment)
- at param j3d J3D handle
-*/
-static void j3d_read_com(opj_j3d_t *j3d);
-/**
-Write the value concerning the specified component in the marker COD and COC
- at param j3d J3D handle
- at param compno Number of the component concerned by the information written
-*/
-static void j3d_write_cox(opj_j3d_t *j3d, int compno);
-/**
-Read the value concerning the specified component in the marker COD and COC
- at param j3d J3D handle
- at param compno Number of the component concerned by the information read
-*/
-static void j3d_read_cox(opj_j3d_t *j3d, int compno);
-/**
-Write the COD marker (coding style default)
- at param j3d J3D handle
-*/
-static void j3d_write_cod(opj_j3d_t *j3d);
-/**
-Read the COD marker (coding style default)
- at param j3d J3D handle
-*/
-static void j3d_read_cod(opj_j3d_t *j3d);
-/**
-Write the COC marker (coding style component)
- at param j3d J3D handle
- at param compno Number of the component concerned by the information written
-*/
-static void j3d_write_coc(opj_j3d_t *j3d, int compno);
-/**
-Read the COC marker (coding style component)
- at param j3d J3D handle
-*/
-static void j3d_read_coc(opj_j3d_t *j3d);
-/**
-Write the value concerning the specified component in the marker QCD and QCC
- at param j3d J3D handle
- at param compno Number of the component concerned by the information written
-*/
-static void j3d_write_qcx(opj_j3d_t *j3d, int compno);
-/**
-Read the value concerning the specified component in the marker QCD and QCC
- at param j3d J3D handle
- at param compno Number of the component concern by the information read
- at param len Length of the information in the QCX part of the marker QCD/QCC
-*/
-static void j3d_read_qcx(opj_j3d_t *j3d, int compno, int len);
-/**
-Write the QCD marker (quantization default)
- at param j3d J3D handle
-*/
-static void j3d_write_qcd(opj_j3d_t *j3d);
-/**
-Read the QCD marker (quantization default)
- at param j3d J3D handle
-*/
-static void j3d_read_qcd(opj_j3d_t *j3d);
-/**
-Write the QCC marker (quantization component)
- at param j3d J3D handle
- at param compno Number of the component concerned by the information written
-*/
-static void j3d_write_qcc(opj_j3d_t *j3d, int compno);
-/**
-Read the QCC marker (quantization component)
- at param j3d J3D handle
-*/
-static void j3d_read_qcc(opj_j3d_t *j3d);
-/**
-Write the POC marker (progression order change)
- at param j3d J3D handle
-*/
-static void j3d_write_poc(opj_j3d_t *j3d);
-/**
-Read the POC marker (progression order change)
- at param j3d J3D handle
-*/
-static void j3d_read_poc(opj_j3d_t *j3d);
-/**
-Read the CRG marker (component registration)
- at param j3d J3D handle
-*/
-static void j3d_read_crg(opj_j3d_t *j3d);
-/**
-Read the TLM marker (tile-part lengths)
- at param j3d J3D handle
-*/
-static void j3d_read_tlm(opj_j3d_t *j3d);
-/**
-Read the PLM marker (packet length, main header)
- at param j3d J3D handle
-*/
-static void j3d_read_plm(opj_j3d_t *j3d);
-/**
-Read the PLT marker (packet length, tile-part header)
- at param j3d J3D handle
-*/
-static void j3d_read_plt(opj_j3d_t *j3d);
-/**
-Read the PPM marker (packet packet headers, main header)
- at param j3d J3D handle
-*/
-static void j3d_read_ppm(opj_j3d_t *j3d);
-/**
-Read the PPT marker (packet packet headers, tile-part header)
- at param j3d J3D handle
-*/
-static void j3d_read_ppt(opj_j3d_t *j3d);
-/**
-Write the SOT marker (start of tile-part)
- at param j3d J3D handle
-*/
-static void j3d_write_sot(opj_j3d_t *j3d);
-/**
-Read the SOT marker (start of tile-part)
- at param j3d J3D handle
-*/
-static void j3d_read_sot(opj_j3d_t *j3d);
-/**
-Write the SOD marker (start of data)
- at param j3d J3D handle
- at param tile_coder Pointer to a TCD handle
-*/
-static void j3d_write_sod(opj_j3d_t *j3d, void *tile_coder);
-/**
-Read the SOD marker (start of data)
- at param j3d J3D handle
-*/
-static void j3d_read_sod(opj_j3d_t *j3d);
-/**
-Write the RGN marker (region-of-interest)
- at param j3d J3D handle
- at param compno Number of the component concerned by the information written
- at param tileno Number of the tile concerned by the information written
-*/
-static void j3d_write_rgn(opj_j3d_t *j3d, int compno, int tileno);
-/**
-Read the RGN marker (region-of-interest)
- at param j3d J3D handle
-*/
-static void j3d_read_rgn(opj_j3d_t *j3d);
-/**
-Write the EOC marker (end of codestream)
- at param j3d J3D handle
-*/
-static void j3d_write_eoc(opj_j3d_t *j3d);
-/**
-Read the EOC marker (end of codestream)
- at param j3d J3D handle
-*/
-static void j3d_read_eoc(opj_j3d_t *j3d);
-/**
-Read an unknown marker
- at param j3d J3D handle
-*/
-static void j3d_read_unk(opj_j3d_t *j3d);
-/**
-Write the CAP marker (extended capabilities)
- at param j3d J3D handle
-*/
-static void j3d_write_cap(opj_j3d_t *j3d);
-/**
-Read the CAP marker (extended capabilities)
- at param j3d J3D handle
-*/
-static void j3d_read_cap(opj_j3d_t *j3d);
-/**
-Write the DCO marker (Variable DC offset)
- at param j3d J3D handle
-*/
-static void j3d_write_dco(opj_j3d_t *j3d);
-/**
-Read the DCO marker (Variable DC offset)
- at param j3d J3D handle
-*/
-static void j3d_read_dco(opj_j3d_t *j3d);
-/**
-Write the ATK marker (arbitrary transformation kernel)
- at param j3d J3D handle
-*/
-static void j3d_write_atk(opj_j3d_t *j3d);
-/**
-Read the ATK marker (arbitrary transformation kernel)
- at param j3d J3D handle
-*/
-static void j3d_read_atk(opj_j3d_t *j3d);
-/**
-Write the CBD marker (component bit depth definition)
- at param j3d J3D handle
-*/
-static void j3d_write_cbd(opj_j3d_t *j3d);
-/**
-Read the CBD marker (component bit depth definition)
- at param j3d J3D handle
-*/
-static void j3d_read_cbd(opj_j3d_t *j3d);
-/**
-Write the MCT marker (multiple component transfomation definition)
- at param j3d J3D handle
-*/
-static void j3d_write_mct(opj_j3d_t *j3d);
-/**
-Read the MCT marker (multiple component transfomation definition)
- at param j3d J3D handle
-*/
-static void j3d_read_mct(opj_j3d_t *j3d);
-/**
-Write the MCC marker (multiple component transfomation collection)
- at param j3d J3D handle
-*/
-static void j3d_write_mcc(opj_j3d_t *j3d);
-/**
-Read the MCC marker (multiple component transfomation collection)
- at param j3d J3D handle
-*/
-static void j3d_read_mcc(opj_j3d_t *j3d);
-/**
-Write the MCO marker (multiple component transfomation ordering)
- at param j3d J3D handle
-*/
-static void j3d_write_mco(opj_j3d_t *j3d);
-/**
-Read the MCO marker (multiple component transfomation ordering)
- at param j3d J3D handle
-*/
-static void j3d_read_mco(opj_j3d_t *j3d);
-/**
-Write the NLT marker (non-linearity point transformation)
- at param j3d J3D handle
-*/
-static void j3d_write_nlt(opj_j3d_t *j3d);
-/**
-Read the NLT marker (non-linearity point transformation)
- at param j3d J3D handle
-*/
-static void j3d_read_nlt(opj_j3d_t *j3d);
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-void j3d_dump_volume(FILE *fd, opj_volume_t * vol) {
-	int compno;
-	fprintf(fd, "volume {\n");
-	fprintf(fd, "  x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d\n", vol->x0, vol->y0, vol->z0,vol->x1, vol->y1,  vol->z1);
-	fprintf(fd, "  numcomps=%d\n", vol->numcomps);
-	for (compno = 0; compno < vol->numcomps; compno++) {
-		opj_volume_comp_t *comp = &vol->comps[compno];
-		fprintf(fd, "  comp %d {\n", compno);
-		fprintf(fd, "    dx=%d, dy=%d, dz=%d\n", comp->dx, comp->dy, comp->dz);
-		fprintf(fd, "    prec=%d\n", comp->prec);
-		fprintf(fd, "    sgnd=%d\n", comp->sgnd);
-		fprintf(fd, "  }\n");
-	}
-	fprintf(fd, "}\n");
-}
-
-void j3d_dump_cp(FILE *fd, opj_volume_t * vol, opj_cp_t * cp) {
-	int tileno, compno, layno, bandno, resno, numbands;
-	fprintf(fd, "coding parameters {\n");
-	fprintf(fd, "  tx0=%d, ty0=%d, tz0=%d\n", cp->tx0, cp->ty0, cp->tz0);
-	fprintf(fd, "  tdx=%d, tdy=%d, tdz=%d\n", cp->tdx, cp->tdy, cp->tdz);
-	fprintf(fd, "  tw=%d, th=%d, tl=%d\n", cp->tw, cp->th, cp->tl);
-	fprintf(fd, "  transform format: %d\n", cp->transform_format);
-	fprintf(fd, "  encoding format: %d\n", cp->encoding_format);
-	for (tileno = 0; tileno < cp->tw * cp->th * cp->tl; tileno++) {
-		opj_tcp_t *tcp = &cp->tcps[tileno];
-		fprintf(fd, "  tile %d {\n", tileno);
-		fprintf(fd, "    csty=%x\n", tcp->csty);
-		fprintf(fd, "    prg=%d\n", tcp->prg);
-		fprintf(fd, "    numlayers=%d\n", tcp->numlayers);
-		fprintf(fd, "    mct=%d\n", tcp->mct);
-		fprintf(fd, "    rates=");
-		for (layno = 0; layno < tcp->numlayers; layno++) {
-			fprintf(fd, "%f ", tcp->rates[layno]);
-		}
-		fprintf(fd, "\n");
-		fprintf(fd, "    first=%d\n", tcp->first);
-		for (compno = 0; compno < vol->numcomps; compno++) {
-			opj_tccp_t *tccp = &tcp->tccps[compno];
-			fprintf(fd, "    comp %d {\n", compno);
-			fprintf(fd, "      csty=%x\n", tccp->csty);
-			fprintf(fd, "      numresx=%d, numresy=%d, numresz=%d\n", tccp->numresolution[0], tccp->numresolution[1], tccp->numresolution[2]);
-			fprintf(fd, "      cblkw=%d, cblkh=%d, cblkl=%d\n", tccp->cblk[0], tccp->cblk[1], tccp->cblk[2]);
-			fprintf(fd, "      cblksty=%x\n", tccp->cblksty);
-			fprintf(fd, "      qntsty=%d\n", tccp->qntsty);
-			fprintf(fd, "      numgbits=%d\n", tccp->numgbits);
-			fprintf(fd, "      roishift=%d\n", tccp->roishift);
-			fprintf(fd, "      reversible=%d\n", tccp->reversible);
-			fprintf(fd, "      dwtidx=%d dwtidy=%d dwtidz=%d\n", tccp->dwtid[0], tccp->dwtid[1], tccp->dwtid[2]);
-			if (tccp->atk != NULL) {
-                fprintf(fd, "      atk.index=%d\n", tccp->atk->index);
-				fprintf(fd, "      atk.coeff_typ=%d\n", tccp->atk->coeff_typ);
-				fprintf(fd, "      atk.filt_cat=%d\n", tccp->atk->filt_cat);
-				fprintf(fd, "      atk.exten=%d\n", tccp->atk->exten);
-				fprintf(fd, "      atk.minit=%d\n", tccp->atk->minit);
-				fprintf(fd, "      atk.wt_typ=%d\n", tccp->atk->wt_typ);
-			}
-			fprintf(fd, "      stepsizes of bands=");
-            numbands = (tccp->qntsty == J3D_CCP_QNTSTY_SIQNT) ? 1 :
-			( (cp->transform_format == TRF_2D_DWT) ? (tccp->numresolution[0] * 3 - 2) :
-				(tccp->numresolution[0] * 7 - 6) - 4 *(tccp->numresolution[0] - tccp->numresolution[2]) );
-			for (bandno = 0; bandno < numbands; bandno++) {
-				fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,tccp->stepsizes[bandno].expn);
-			}
-			fprintf(fd, "\n");
-			
-			if (tccp->csty & J3D_CCP_CSTY_PRT) {
-				fprintf(fd, "      prcw=");
-				for (resno = 0; resno < tccp->numresolution[0]; resno++) {
-					fprintf(fd, "%d ", tccp->prctsiz[0][resno]);
-				}
-				fprintf(fd, "\n");
-				fprintf(fd, "      prch=");
-				for (resno = 0; resno < tccp->numresolution[0]; resno++) {
-					fprintf(fd, "%d ", tccp->prctsiz[1][resno]);
-				}
-				fprintf(fd, "\n");
-				fprintf(fd, "      prcl=");
-				for (resno = 0; resno < tccp->numresolution[0]; resno++) {
-					fprintf(fd, "%d ", tccp->prctsiz[2][resno]);
-				}
-				fprintf(fd, "\n");
-			}
-			fprintf(fd, "    }\n");
-		}
-		fprintf(fd, "  }\n");
-	}
-	fprintf(fd, "}\n");
-}
-
-/* ----------------------------------------------------------------------- 
-Extended capabilities
-------------------------------------------------------------------------*/
-
-static void j3d_write_cap(opj_j3d_t *j3d){
-	int len,lenp;
-
-	opj_cio_t *cio = j3d->cio;
-	cio_write(cio, J3D_MS_CAP, 2);	/* CAP */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio,J3D_CAP_10, 4); 
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Lsiz */
-	cio_seek(cio, lenp + len);
-
-}
-static void j3d_read_cap(opj_j3d_t *j3d){
-	int len, Cap;
-	opj_cio_t *cio = j3d->cio;
-	/*cio_read(cio, 2);	 CAP */
-	len = cio_read(cio, 2);
-	Cap = cio_read(cio, 4);
-}
-static void j3d_write_zsi(opj_j3d_t *j3d) {
-	int i;
-	int lenp, len;
-
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_cp_t *cp = j3d->cp;
-	
-	cio_write(cio, J3D_MS_ZSI, 2);	/* ZSI */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio, volume->z1, 4);	/* Zsiz */
-	cio_write(cio, volume->z0, 4);	/* Z0siz */
-	cio_write(cio, cp->tdz, 4);		/* ZTsiz */
-	cio_write(cio, cp->tz0, 4);		/* ZT0siz */
-	for (i = 0; i < volume->numcomps; i++) {
-		cio_write(cio, volume->comps[i].dz, 1);	/* ZRsiz_i */
-	}
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Lsiz */
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_zsi(opj_j3d_t *j3d) {
-	int len, i;
-	
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_cp_t *cp = j3d->cp;
-	
-	len = cio_read(cio, 2);			/* Lsiz */
-	volume->z1 = cio_read(cio, 4);	/* Zsiz */
-	volume->z0 = cio_read(cio, 4);	/* Z0siz */
-	cp->tdz = cio_read(cio, 4);		/* ZTsiz */
-	cp->tz0 = cio_read(cio, 4);		/* ZT0siz */
-	for (i = 0; i < volume->numcomps; i++) {
-		volume->comps[i].dz = cio_read(cio, 1);	/* ZRsiz_i */
-	}
-	
-	//Initialization of volume
-	cp->tw = int_ceildiv(volume->x1 - cp->tx0, cp->tdx);
-	cp->th = int_ceildiv(volume->y1 - cp->ty0, cp->tdy);
-	cp->tl = int_ceildiv(volume->z1 - cp->tz0, cp->tdz);
-	cp->tcps = (opj_tcp_t *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(opj_tcp_t));
-	cp->tileno = (int *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(int));
-	cp->tileno_size = 0;
-	
-	for (i = 0; i < cp->tw * cp->th * cp->tl ; i++) {
-		cp->tcps[i].POC = 0;
-		cp->tcps[i].numpocs = 0;
-		cp->tcps[i].first = 1;
-	}
-	
-	/* Initialization for PPM marker (Packets header)*/
-	cp->ppm = 0;
-	cp->ppm_data = NULL;
-	cp->ppm_data_first = NULL;
-	cp->ppm_previous = 0;
-	cp->ppm_store = 0;
-	
-	j3d->default_tcp->tccps = (opj_tccp_t *) opj_malloc(sizeof(opj_tccp_t) * volume->numcomps);
-	for (i = 0; i < cp->tw * cp->th * cp->tl ; i++) {
-		cp->tcps[i].tccps = (opj_tccp_t *) opj_malloc(sizeof(opj_tccp_t) * volume->numcomps);
-	}
-	j3d->tile_data = (unsigned char **) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(unsigned char *));
-	j3d->tile_len = (int *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(int));
-	j3d->state = J3D_STATE_MH;
-	
-}
-static void j3d_write_dco(opj_j3d_t *j3d){
-	int lenp, len, i;
-	int dcotype;	
-
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_cp_t *cp = j3d->cp;
-	
-	dcotype = 1; /* Offsets are 16bit signed integers Table A21 15444-2 */
-	cio_write(cio, J3D_MS_DCO, 2);	/* DCO */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio, dcotype, 1);	
-	if (dcotype == 0) {
-		for (i = 0; i < volume->numcomps; i++) 
-			cio_write(cio, volume->comps[i].dcoffset, 1);	/* SPdco_i */
-	} else if (dcotype == 1) {
-		for (i = 0; i < volume->numcomps; i++){ 
-			cio_write(cio, volume->comps[i].dcoffset, 1);	/* SPdco_i */
-			opj_event_msg(j3d->cinfo, EVT_INFO, "dcotype %d DCO %d \n",dcotype,volume->comps[i].dcoffset);
-		}
-	}
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Ldco */
-	cio_seek(cio, lenp + len);
-
-}
-static void j3d_read_dco(opj_j3d_t *j3d){
-	int len, i;
-	int dcotype;
-
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_cp_t *cp = j3d->cp;
-	
-	len = cio_read(cio, 2);			/* Lsiz */
-	dcotype = cio_read(cio, 1); //offset 8bit unsigned / 16bit signed integers
-	if (dcotype == 0) {
-		for (i = 0; i < volume->numcomps; i++) {
-			volume->comps[i].dcoffset = cio_read(cio, 1);
-			if (volume->comps[i].dcoffset > 128) 
-				volume->comps[i].dcoffset = volume->comps[i].dcoffset - 256;
-		}
-	} else if (dcotype == 1) {
-		for (i = 0; i < volume->numcomps; i++) {
-			volume->comps[i].dcoffset = cio_read(cio, 1);
-			if (volume->comps[i].dcoffset > 128) 
-				volume->comps[i].dcoffset = volume->comps[i].dcoffset - 256;
-		}
-	}
-	
-}
-static void j3d_write_atk(opj_j3d_t *j3d){
-	int lenp, len, s, k;
-
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_atk_t *atk = j3d->cp->tcps->tccps->atk;
-	
-	cio_write(cio, J3D_MS_ATK, 2);	/* ATK */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);				
-	cio_write(cio, atk->index + (atk->coeff_typ << 8) + (atk->filt_cat << 11) 
-		+ (atk->wt_typ << 12) + (atk->minit << 13) + (atk->exten << 14), 2);			/* Satk */
-    if (atk->wt_typ == J3D_ATK_IRR) 
-		cio_write(cio,(unsigned int) (atk->Katk * 8192.0), 1 << atk->coeff_typ);
-	cio_write(cio, atk->Natk, 1);
-	for (s = 0; s < atk->Natk; s++){
-		if (atk->filt_cat == J3D_ATK_ARB) 
-			cio_write(cio, atk->Oatk[s], 1);
-		if (atk->wt_typ == J3D_ATK_REV){
-			cio_write(cio, atk->Eatk[s], 1);
-			cio_write(cio, atk->Batk[s], 1);
-		}
-		cio_write(cio, atk->LCatk[s], 1);
-		for (k = 0; k < atk->LCatk[s]; k++)
-			cio_write(cio,(unsigned int) (atk->Aatk[s][k] * 8192.0), 1 << atk->coeff_typ);
-	}
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Latk */
-	cio_seek(cio, lenp + len);
-}
-static void j3d_read_atk(opj_j3d_t *j3d){
-	int len, i, Satk, k;
-	
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_cp_t *cp = j3d->cp;
-	opj_atk_t *atk = cp->tcps->tccps->atk; 
-	
-	len = cio_read(cio, 2);			/* Latk */
-	Satk = cio_read(cio, 2); 
-	atk->index = Satk & 0x00ff;
-	atk->coeff_typ = Satk >> 8 & 0x0007;
-	atk->filt_cat = Satk >> 11 & 0x0001;
-	atk->wt_typ = Satk >> 12  & 0x0001;
-	atk->minit = Satk >> 13 & 0x0001;
-	atk->exten = Satk >> 14 & 0x0001;
-    if (atk->wt_typ == J3D_ATK_IRR) 
-		atk->Katk = ((double) cio_read(cio, 1 << atk->coeff_typ) / 8192.0);
-	atk->Natk = cio_read(cio, 1);
-	for (i = 0; i < atk->Natk; i++) {
-		if (atk->filt_cat == J3D_ATK_ARB) 
-			atk->Oatk[i] = cio_read(cio, 1);
-		if (atk->wt_typ == J3D_ATK_REV){
-			atk->Eatk[i] = cio_read(cio, 1);
-			atk->Batk[i] = cio_read(cio, 1);
-		}
-		atk->LCatk[i] = cio_read(cio, 1);
-		for (k = 0; k < atk->LCatk[i]; k++)
-			atk->Aatk[i][k] = ((double) cio_read(cio, 1 << atk->coeff_typ) / 8192.0);
-	}
-}
-static void j3d_write_cbd(opj_j3d_t *j3d){
-}
-static void j3d_read_cbd(opj_j3d_t *j3d){
-}
-static void j3d_write_mct(opj_j3d_t *j3d){
-}
-static void j3d_read_mct(opj_j3d_t *j3d){
-}
-static void j3d_write_mcc(opj_j3d_t *j3d){
-}
-static void j3d_read_mcc(opj_j3d_t *j3d){
-}
-static void j3d_write_mco(opj_j3d_t *j3d){
-}
-static void j3d_read_mco(opj_j3d_t *j3d){
-}
-static void j3d_write_nlt(opj_j3d_t *j3d){
-}
-static void j3d_read_nlt(opj_j3d_t *j3d){
-}
-/* ----------------------------------------------------------------------- 
-15444-1 codestream syntax
-------------------------------------------------------------------------*/
-static void j3d_write_soc(opj_j3d_t *j3d) {
-	opj_cio_t *cio = j3d->cio;
-	cio_write(cio, J3D_MS_SOC, 2);
-}
-
-static void j3d_read_soc(opj_j3d_t *j3d) {
-	j3d->state = J3D_STATE_MHSIZ;
-}
-
-static void j3d_write_siz(opj_j3d_t *j3d) {
-	int i;
-	int lenp, len;
-	int Rsiz;
-
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_cp_t *cp = j3d->cp;
-	
-	cio_write(cio, J3D_MS_SIZ, 2);	/* SIZ */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	//cio_write(cio, 0, 2);			/* Rsiz (capabilities of 15444-1 only) */
-	Rsiz = J3D_RSIZ_DCO | J3D_RSIZ_ATK; /** | J3D_RSIZ_MCT | J3D_RSIZ_NONLT (not implemented yet)*/
-	cio_write(cio, Rsiz, 2); /* capabilities of WDv5.2*/
-	cio_write(cio, volume->x1, 4);	/* Xsiz */
-	cio_write(cio, volume->y1, 4);	/* Ysiz */
-	cio_write(cio, volume->x0, 4);	/* X0siz */
-	cio_write(cio, volume->y0, 4);	/* Y0siz */
-	cio_write(cio, cp->tdx, 4);		/* XTsiz */
-	cio_write(cio, cp->tdy, 4);		/* YTsiz */
-	cio_write(cio, cp->tx0, 4);		/* XT0siz */
-	cio_write(cio, cp->ty0, 4);		/* YT0siz */
-	cio_write(cio, volume->numcomps, 2);	/* Csiz */
-	for (i = 0; i < volume->numcomps; i++) {
-		cio_write(cio, volume->comps[i].prec - 1 + (volume->comps[i].sgnd << 7), 1);	/* Ssiz_i */
-		cio_write(cio, volume->comps[i].dx, 1);	/* XRsiz_i */
-		cio_write(cio, volume->comps[i].dy, 1);	/* YRsiz_i */
-	}
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Lsiz */
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_siz(opj_j3d_t *j3d) {
-	int len, i;
-	
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	opj_cp_t *cp = j3d->cp;
-	
-	len = cio_read(cio, 2);			/* Lsiz */
-	cp->rsiz = cio_read(cio, 2);	/* Rsiz (capabilities) */
-	volume->x1 = cio_read(cio, 4);	/* Xsiz */
-	volume->y1 = cio_read(cio, 4);	/* Ysiz */
-	volume->x0 = cio_read(cio, 4);	/* X0siz */
-	volume->y0 = cio_read(cio, 4);	/* Y0siz */
-	cp->tdx = cio_read(cio, 4);		/* XTsiz */
-	cp->tdy = cio_read(cio, 4);		/* YTsiz */
-	cp->tx0 = cio_read(cio, 4);		/* XT0siz */
-	cp->ty0 = cio_read(cio, 4);		/* YT0siz */
-	
-	volume->numcomps = cio_read(cio, 2);	/* Csiz */
-	volume->comps = (opj_volume_comp_t *) opj_malloc(volume->numcomps * sizeof(opj_volume_comp_t));
-	for (i = 0; i < volume->numcomps; i++) {
-		int tmp, j;
-		tmp = cio_read(cio, 1);		/* Ssiz_i */
-		volume->comps[i].prec = (tmp & 0x7f) + 1;
-		volume->comps[i].sgnd = tmp >> 7;
-		volume->comps[i].dx = cio_read(cio, 1);	/* XRsiz_i */
-		volume->comps[i].dy = cio_read(cio, 1);	/* YRsiz_i */
-		for (j = 0; j < 3; j++) {
-			volume->comps[i].resno_decoded[j] = 0;		/* number of resolution decoded */
-			volume->comps[i].factor[j] = 0;		/* reducing factor per component */
-		}
-	}
-
-	if (j3d->cinfo->codec_format == CODEC_J2K){
-		volume->z1 = 1;
-		volume->z0 = 0;
-		volume->numslices = 1;
-		cp->tdz = 1;
-		cp->tz0 = 0;
-		for (i = 0; i < volume->numcomps; i++) 
-			volume->comps[i].dz = 1;
-
-		//Initialization of volume
-		cp->tw = int_ceildiv(volume->x1 - cp->tx0, cp->tdx);
-		cp->th = int_ceildiv(volume->y1 - cp->ty0, cp->tdy);
-		cp->tl = int_ceildiv(volume->z1 - cp->tz0, cp->tdz);
-		cp->tcps = (opj_tcp_t *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(opj_tcp_t));
-		cp->tileno = (int *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(int));
-		cp->tileno_size = 0;
-		
-		for (i = 0; i < cp->tw * cp->th * cp->tl ; i++) {
-			cp->tcps[i].POC = 0;
-			cp->tcps[i].numpocs = 0;
-			cp->tcps[i].first = 1;
-		}
-		
-		/* Initialization for PPM marker (Packets header)*/
-		cp->ppm = 0;
-		cp->ppm_data = NULL;
-		cp->ppm_data_first = NULL;
-		cp->ppm_previous = 0;
-		cp->ppm_store = 0;
-		
-		j3d->default_tcp->tccps = (opj_tccp_t *) opj_malloc(sizeof(opj_tccp_t) * volume->numcomps);
-		for (i = 0; i < cp->tw * cp->th * cp->tl ; i++) {
-			cp->tcps[i].tccps = (opj_tccp_t *) opj_malloc(sizeof(opj_tccp_t) * volume->numcomps);
-		}
-		j3d->tile_data = (unsigned char **) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(unsigned char *));
-		j3d->tile_len = (int *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(int));
-		j3d->state = J3D_STATE_MH;
-	}
-}
-
-
-
-static void j3d_write_com(opj_j3d_t *j3d) {
-	unsigned int i;
-	int lenp, len;
-
-	opj_cio_t *cio = j3d->cio;
-
-	cio_write(cio, J3D_MS_COM, 2);
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	//cio_write(cio, 0, 2);
-	cio_write(cio, j3d->cp->transform_format,1);
-	cio_write(cio, j3d->cp->encoding_format,1);
-	//opj_event_msg(j3d->cinfo, EVT_INFO, "TRF %D ENCOD %d\n",j3d->cp->transform_format,j3d->cp->encoding_format);
-	if (j3d->cp->comment != NULL) {
-		char *comment = j3d->cp->comment;
-		for (i = 0; i < strlen(comment); i++) {
-            cio_write(cio, comment[i], 1);
-		}
-	}
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_com(opj_j3d_t *j3d) {
-	int len;
-	opj_cio_t *cio = j3d->cio;
-
-	len = cio_read(cio, 2);
-	
-	j3d->cp->transform_format = (OPJ_TRANSFORM) cio_read(cio, 1);
-	j3d->cp->encoding_format = (OPJ_ENTROPY_CODING) cio_read(cio, 1);
-	//opj_event_msg(j3d->cinfo, EVT_INFO, "TRF %D ENCOD %d\n",j3d->cp->transform_format,j3d->cp->encoding_format);
-
-	cio_skip(cio, len - 4);  //posible comments
-}
-
-static void j3d_write_cox(opj_j3d_t *j3d, int compno) {
-	int i;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = &cp->tcps[j3d->curtileno];
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j3d->cio;
-	
-	cio_write(cio, tccp->numresolution[0] - 1, 1);	/* SPcox (D) No of decomposition levels in x-axis*/
-	if (j3d->cinfo->codec_format == CODEC_J3D) {
-		cio_write(cio, tccp->numresolution[1] - 1, 1);	/* SPcox (E) No of decomposition levels in y-axis*/
-		cio_write(cio, tccp->numresolution[2] - 1, 1);	/* SPcox (F) No of decomposition levels in z-axis*/
-	}
-	/* (cblkw - 2) + (cblkh - 2) + (cblkl - 2) <= 18*/
-	cio_write(cio, tccp->cblk[0] - 2, 1);				/* SPcox (G) Cblk width entre 10 y 2 (8 y 0)*/
-	cio_write(cio, tccp->cblk[1] - 2, 1);				/* SPcox (H) Cblk height*/
-	if (j3d->cinfo->codec_format == CODEC_J3D) {
-		cio_write(cio, tccp->cblk[2] - 2, 1);			/* SPcox (I) Cblk depth*/
-	}
-	cio_write(cio, tccp->cblksty, 1);				/* SPcox (J) Cblk style*/
-	cio_write(cio, tccp->dwtid[0], 1);				/* SPcox (K) WT in x-axis 15444-2 Table A10*/
-	if (j3d->cinfo->codec_format == CODEC_J3D) {
-		cio_write(cio, tccp->dwtid[1], 1);				/* SPcox (L) WT in y-axis 15444-2 Table A10*/
-		cio_write(cio, tccp->dwtid[2], 1);				/* SPcox (M) WT in z-axis 15444-2 Table A10*/
-	}
-	
-	if (tccp->csty & J3D_CCP_CSTY_PRT) {
-		for (i = 0; i < tccp->numresolution[0]; i++) {
-			if (i < tccp->numresolution[2])
-                cio_write(cio, tccp->prctsiz[0][i] + (tccp->prctsiz[1][i] << 4) + (tccp->prctsiz[2][i] << 8), 2);	/* SPcox (N_i) Table A9*/
-			else
-				if (j3d->cinfo->codec_format == CODEC_J3D) 
-                    cio_write(cio, tccp->prctsiz[0][i] + (tccp->prctsiz[1][i] << 4), 2);	/* SPcox (N_i) Table A9*/
-				else
-                    cio_write(cio, tccp->prctsiz[0][i] + (tccp->prctsiz[1][i] << 4), 1);	/* SPcox (N_i) Table A9*/		}
-	}
-}
-
-static void j3d_read_cox(opj_j3d_t *j3d, int compno) {
-	int i;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = j3d->state == J3D_STATE_TPH ? &cp->tcps[j3d->curtileno] : j3d->default_tcp;
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j3d->cio;
-
-	tccp->numresolution[0] = cio_read(cio, 1) + 1;	/* SPcox (D) No of decomposition levels in x-axis*/
-	if (j3d->cinfo->codec_format == CODEC_J3D) {
-		tccp->numresolution[1] = cio_read(cio, 1) + 1;	/* SPcox (E) No of decomposition levels in y-axis*/
-		tccp->numresolution[2] = cio_read(cio, 1) + 1;	/* SPcox (F) No of decomposition levels in z-axis*/
-	}else if (j3d->cinfo->codec_format == CODEC_J2K) {
-		tccp->numresolution[1] = tccp->numresolution[0];	
-		tccp->numresolution[2] = 1;							
-	}
-	/* check the reduce value */
-	cp->reduce[0] = int_min((tccp->numresolution[0])-1, cp->reduce[0]);
-	cp->reduce[1] = int_min((tccp->numresolution[1])-1, cp->reduce[1]);
-	cp->reduce[2] = int_min((tccp->numresolution[2])-1, cp->reduce[2]);
-	
-	tccp->cblk[0] = cio_read(cio, 1) + 2;	/* SPcox (G) */
-	tccp->cblk[1] = cio_read(cio, 1) + 2;	/* SPcox (H) */
-	if (j3d->cinfo->codec_format == CODEC_J3D)
-		tccp->cblk[2] = cio_read(cio, 1) + 2;	/* SPcox (I) */
-	else
-		tccp->cblk[2] = tccp->cblk[0];
-
-	tccp->cblksty = cio_read(cio, 1);	/* SPcox (J) */
-	tccp->dwtid[0] = cio_read(cio, 1);	/* SPcox (K) */
-	if (j3d->cinfo->codec_format == CODEC_J3D) {
-		tccp->dwtid[1] = cio_read(cio, 1);	/* SPcox (L) */
-		tccp->dwtid[2] = cio_read(cio, 1);	/* SPcox (M) */
-	}else{
-		tccp->dwtid[1] = tccp->dwtid[0];	/* SPcox (L) */
-		tccp->dwtid[2] = tccp->dwtid[0];	/* SPcox (M) */
-	}
-	tccp->reversible = (tccp->dwtid[0]>=1 && tccp->dwtid[1]>=1 && tccp->dwtid[2]>=1); //TODO: only valid for irreversible 9x7 WTs
-	if (tccp->csty & J3D_CP_CSTY_PRT) {
-		for (i = 0; i < tccp->numresolution[0]; i++) {
-			int tmp = cio_read(cio, 2);	/* SPcox (N_i) */
-			tccp->prctsiz[0][i] = tmp & 0xf;
-			tccp->prctsiz[1][i] = tmp >> 4;
-			tccp->prctsiz[2][i] = tmp >> 8;
-		}
-	}
-}
-
-static void j3d_write_cod(opj_j3d_t *j3d) {
-	opj_cp_t *cp = NULL;
-	opj_tcp_t *tcp = NULL;
-	int lenp, len;
-
-	opj_cio_t *cio = j3d->cio;
-	
-	cio_write(cio, J3D_MS_COD, 2);	/* COD */
-	
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	
-	cp = j3d->cp;
-	tcp = &cp->tcps[j3d->curtileno];
-
-	/* Scod : Table A-4*/
-	cio_write(cio, tcp->csty, 1);		/* Scod : Coding style parameters */
-	/* SGcod : Table A-5*/
-	cio_write(cio, tcp->prg, 1);		/* SGcod (A) : Progression order */
-	cio_write(cio, tcp->numlayers, 2);	/* SGcod (B) : No of layers */
-	cio_write(cio, tcp->mct, 1);		/* SGcod (C) : Multiple component transformation usage */
-	/* SPcod : Table A-6*/
-	j3d_write_cox(j3d, 0);				
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Lcod */
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_cod(opj_j3d_t *j3d) {
-	int len, i, pos;
-	
-	opj_cio_t *cio = j3d->cio;
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = j3d->state == J3D_STATE_TPH ? &cp->tcps[j3d->curtileno] : j3d->default_tcp;
-	opj_volume_t *volume = j3d->volume;
-
-	/* Lcod */
-	len = cio_read(cio, 2);				
-	/* Scod : Table A-4*/
-	tcp->csty = cio_read(cio, 1);		
-	/* SGcod : Table A-5*/
-	tcp->prg = (OPJ_PROG_ORDER)cio_read(cio, 1);
-	tcp->numlayers = cio_read(cio, 2);	
-	tcp->mct = cio_read(cio, 1);		
-	
-	pos = cio_tell(cio);
-	for (i = 0; i < volume->numcomps; i++) {
-		tcp->tccps[i].csty = tcp->csty & J3D_CP_CSTY_PRT;
-		cio_seek(cio, pos);
-		j3d_read_cox(j3d, i);
-	}
-}
-
-static void j3d_write_coc(opj_j3d_t *j3d, int compno) {
-	int lenp, len;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = &cp->tcps[j3d->curtileno];
-	opj_volume_t *volume = j3d->volume;
-	opj_cio_t *cio = j3d->cio;
-	
-	cio_write(cio, J3D_MS_COC, 2);	/* COC */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio, compno, volume->numcomps <= 256 ? 1 : 2);	/* Ccoc */
-	cio_write(cio, tcp->tccps[compno].csty, 1);					/* Scoc */
-	
-	j3d_write_cox(j3d, compno);
-	
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);			/* Lcoc */
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_coc(opj_j3d_t *j3d) {
-	int len, compno;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = j3d->state == J3D_STATE_TPH ? &cp->tcps[j3d->curtileno] : j3d->default_tcp;
-	opj_volume_t *volume = j3d->volume;
-	opj_cio_t *cio = j3d->cio;
-	
-	len = cio_read(cio, 2);		/* Lcoc */
-	compno = cio_read(cio, volume->numcomps <= 256 ? 1 : 2);	/* Ccoc */
-	tcp->tccps[compno].csty = cio_read(cio, 1);	/* Scoc */
-	j3d_read_cox(j3d, compno);
-}
-
-static void j3d_write_qcx(opj_j3d_t *j3d, int compno) {
-	int bandno, numbands;
-	int expn, mant;
-	
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = &cp->tcps[j3d->curtileno];
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j3d->cio;
-	
-	cio_write(cio, tccp->qntsty + (tccp->numgbits << 5), 1);	/* Sqcx : Table A28 de 15444-1*/
-	
-	if (j3d->cinfo->codec_format == CODEC_J2K)
-        numbands = tccp->qntsty == J3D_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolution[0] * 3 - 2; 
-	else if (j3d->cinfo->codec_format == CODEC_J3D) {
-		int diff = tccp->numresolution[0] - tccp->numresolution[2];
-        numbands = (tccp->qntsty == J3D_CCP_QNTSTY_SIQNT) ? 1 : (tccp->numresolution[0] * 7 - 6) - 4 *diff; /* SIQNT vs. SEQNT */
-	}
-	
-	for (bandno = 0; bandno < numbands; bandno++) {
-		expn = tccp->stepsizes[bandno].expn;
-		mant = tccp->stepsizes[bandno].mant;
-		
-		if (tccp->qntsty == J3D_CCP_QNTSTY_NOQNT) {
-			cio_write(cio, expn << 3, 1);	/* SPqcx_i */
-		} else {
-			cio_write(cio, (expn << 11) + mant, 2);	/* SPqcx_i */
-		}
-	}
-}
-
-static void j3d_read_qcx(opj_j3d_t *j3d, int compno, int len) {
-	int tmp;
-	int bandno, numbands;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = j3d->state == J3D_STATE_TPH ? &cp->tcps[j3d->curtileno] : j3d->default_tcp;
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j3d->cio;
-
-	tmp = cio_read(cio, 1);		/* Sqcx */
-	tccp->qntsty = tmp & 0x1f;
-	tccp->numgbits = tmp >> 5;
-
-	/*Numbands = 1				si SIQNT
-			     len - 1		si NOQNT
-				 (len - 1) / 2	si SEQNT */
-	numbands = tccp->qntsty == J3D_CCP_QNTSTY_SIQNT ? 1 : ((tccp->qntsty == J3D_CCP_QNTSTY_NOQNT) ? len - 1 : (len - 1) / 2);
-
-	for (bandno = 0; bandno < numbands; bandno++) {
-		int expn, mant;
-		if (tccp->qntsty == J3D_CCP_QNTSTY_NOQNT) {
-			expn = cio_read(cio, 1) >> 3;	/* SPqcx_i */
-			mant = 0;
-		} else {
-			tmp = cio_read(cio, 2);			/* SPqcx_i */
-			expn = tmp >> 11;
-			mant = tmp & 0x7ff;
-		}
-		tccp->stepsizes[bandno].expn = expn;
-		tccp->stepsizes[bandno].mant = mant;
-	}
-	
-	/* Add Antonin : if scalar_derived -> compute other stepsizes */
-	if (tccp->qntsty == J3D_CCP_QNTSTY_SIQNT) {
-		for (bandno = 1; bandno < J3D_MAXBANDS; bandno++) {
-			int numbands = (cp->transform_format==TRF_2D_DWT) ? 3 : 7;
-			tccp->stepsizes[bandno].expn = tccp->stepsizes[0].expn - ((bandno - 1) / numbands);
-			tccp->stepsizes[bandno].mant = tccp->stepsizes[0].mant;
-		}
-	}
-	/* ddA */
-}
-
-static void j3d_write_qcd(opj_j3d_t *j3d) {
-	int lenp, len;
-
-	opj_cio_t *cio = j3d->cio;
-	
-	cio_write(cio, J3D_MS_QCD, 2);	/* QCD */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	j3d_write_qcx(j3d, 0);			/* Sqcd*/
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);			/* Lqcd */
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_qcd(opj_j3d_t *j3d) {
-	int len, i, pos;
-
-	opj_cio_t *cio = j3d->cio;
-	opj_volume_t *volume = j3d->volume;
-	
-	len = cio_read(cio, 2);		/* Lqcd */
-	pos = cio_tell(cio);
-	for (i = 0; i < volume->numcomps; i++) {
-		cio_seek(cio, pos);
-		j3d_read_qcx(j3d, i, len - 2);
-	}
-}
-
-static void j3d_write_qcc(opj_j3d_t *j3d, int compno) {
-	int lenp, len;
-
-	opj_cio_t *cio = j3d->cio;
-	
-	cio_write(cio, J3D_MS_QCC, 2);	/* QCC */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio, compno, j3d->volume->numcomps <= 256 ? 1 : 2);	/* Cqcc */
-	j3d_write_qcx(j3d, compno);
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);			/* Lqcc */
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_qcc(opj_j3d_t *j3d) {
-	int len, compno;
-	int numcomp = j3d->volume->numcomps;
-	opj_cio_t *cio = j3d->cio;
-	
-	len = cio_read(cio, 2);	/* Lqcc */
-	compno = cio_read(cio, numcomp <= 256 ? 1 : 2);	/* Cqcc */
-	j3d_read_qcx(j3d, compno, len - 2 - (numcomp <= 256 ? 1 : 2));
-}
-
-static void j3d_write_poc(opj_j3d_t *j3d) {
-	int len, numpchgs, i;
-
-	int numcomps = j3d->volume->numcomps;
-	
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = &cp->tcps[j3d->curtileno];
-	opj_tccp_t *tccp = &tcp->tccps[0];
-	opj_cio_t *cio = j3d->cio;
-
-	numpchgs = tcp->numpocs;
-	cio_write(cio, J3D_MS_POC, 2);	/* POC  */
-	len = 2 + (5 + 2 * (numcomps <= 256 ? 1 : 2)) * numpchgs;
-	cio_write(cio, len, 2);		/* Lpoc */
-	for (i = 0; i < numpchgs; i++) {
-		opj_poc_t *poc = &tcp->pocs[i];
-		cio_write(cio, poc->resno0, 1);	/* RSpoc_i */
-		cio_write(cio, poc->compno0, (numcomps <= 256 ? 1 : 2));	/* CSpoc_i */
-		cio_write(cio, poc->layno1, 2);	/* LYEpoc_i */
-		poc->layno1 = int_min(poc->layno1, tcp->numlayers);
-		cio_write(cio, poc->resno1, 1);	/* REpoc_i */
-		poc->resno1 = int_min(poc->resno1, tccp->numresolution[0]);
-		cio_write(cio, poc->compno1, (numcomps <= 256 ? 1 : 2));	/* CEpoc_i */
-		poc->compno1 = int_min(poc->compno1, numcomps);
-		cio_write(cio, poc->prg, 1);	/* Ppoc_i */
-	}
-}
-
-static void j3d_read_poc(opj_j3d_t *j3d) {
-	int len, numpchgs, i, old_poc;
-
-	int numcomps = j3d->volume->numcomps;
-	
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = j3d->state == J3D_STATE_TPH ? &cp->tcps[j3d->curtileno] : j3d->default_tcp;
-	opj_tccp_t *tccp = &tcp->tccps[0];
-	opj_cio_t *cio = j3d->cio;
-	
-	old_poc = tcp->POC ? tcp->numpocs + 1 : 0;
-	tcp->POC = 1;
-	len = cio_read(cio, 2);		/* Lpoc */
-	numpchgs = (len - 2) / (5 + 2 * (numcomps <= 256 ? 1 : 2));
-	
-	for (i = old_poc; i < numpchgs + old_poc; i++) {
-		opj_poc_t *poc;
-		poc = &tcp->pocs[i];
-		poc->resno0 = cio_read(cio, 1);	/* RSpoc_i */
-		poc->compno0 = cio_read(cio, numcomps <= 256 ? 1 : 2);	/* CSpoc_i */
-		poc->layno1 = int_min(cio_read(cio, 2), (unsigned int) tcp->numlayers);	/* LYEpoc_i */
-		poc->resno1 = int_min(cio_read(cio, 1), (unsigned int) tccp->numresolution[0]);	/* REpoc_i */
-		poc->compno1 = int_min(
-			cio_read(cio, numcomps <= 256 ? 1 : 2), (unsigned int) numcomps);	/* CEpoc_i */
-		poc->prg = (OPJ_PROG_ORDER)cio_read(cio, 1);	/* Ppoc_i */
-	}
-	
-	tcp->numpocs = numpchgs + old_poc - 1;
-}
-
-static void j3d_read_crg(opj_j3d_t *j3d) {
-	int len, i, Xcrg_i, Ycrg_i, Zcrg_i;
-	
-	opj_cio_t *cio = j3d->cio;
-	int numcomps = j3d->volume->numcomps;
-	
-	len = cio_read(cio, 2);			/* Lcrg */
-	for (i = 0; i < numcomps; i++) {
-		Xcrg_i = cio_read(cio, 2);	/* Xcrg_i */
-		Ycrg_i = cio_read(cio, 2);	/* Ycrg_i */
-		Zcrg_i = cio_read(cio, 2);	/* Zcrg_i */
-	}
-}
-
-static void j3d_read_tlm(opj_j3d_t *j3d) {
-	int len, Ztlm, Stlm, ST, SP, tile_tlm, i;
-	long int Ttlm_i, Ptlm_i;
-
-	opj_cio_t *cio = j3d->cio;
-	
-	len = cio_read(cio, 2);		/* Ltlm */
-	Ztlm = cio_read(cio, 1);	/* Ztlm */
-	Stlm = cio_read(cio, 1);	/* Stlm */
-	ST = ((Stlm >> 4) & 0x01) + ((Stlm >> 4) & 0x02);
-	SP = (Stlm >> 6) & 0x01;
-	tile_tlm = (len - 4) / ((SP + 1) * 2 + ST);
-	for (i = 0; i < tile_tlm; i++) {
-		Ttlm_i = cio_read(cio, ST);	/* Ttlm_i */
-		Ptlm_i = cio_read(cio, SP ? 4 : 2);	/* Ptlm_i */
-	}
-}
-
-static void j3d_read_plm(opj_j3d_t *j3d) {
-	int len, i, Zplm, Nplm, add, packet_len = 0;
-	
-	opj_cio_t *cio = j3d->cio;
-
-	len = cio_read(cio, 2);		/* Lplm */
-	Zplm = cio_read(cio, 1);	/* Zplm */
-	len -= 3;
-	while (len > 0) {
-		Nplm = cio_read(cio, 4);		/* Nplm */
-		len -= 4;
-		for (i = Nplm; i > 0; i--) {
-			add = cio_read(cio, 1);
-			len--;
-			packet_len = (packet_len << 7) + add;	/* Iplm_ij */
-			if ((add & 0x80) == 0) {
-				/* New packet */
-				packet_len = 0;
-			}
-			if (len <= 0)
-				break;
-		}
-	}
-}
-
-static void j3d_read_plt(opj_j3d_t *j3d) {
-	int len, i, Zplt, packet_len = 0, add;
-	
-	opj_cio_t *cio = j3d->cio;
-	
-	len = cio_read(cio, 2);		/* Lplt */
-	Zplt = cio_read(cio, 1);	/* Zplt */
-	for (i = len - 3; i > 0; i--) {
-		add = cio_read(cio, 1);
-		packet_len = (packet_len << 7) + add;	/* Iplt_i */
-		if ((add & 0x80) == 0) {
-			/* New packet */
-			packet_len = 0;
-		}
-	}
-}
-
-static void j3d_read_ppm(opj_j3d_t *j3d) {
-	int len, Z_ppm, i, j;
-	int N_ppm;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_cio_t *cio = j3d->cio;
-	
-	len = cio_read(cio, 2);
-	cp->ppm = 1;
-	
-	Z_ppm = cio_read(cio, 1);	/* Z_ppm */
-	len -= 3;
-	while (len > 0) {
-		if (cp->ppm_previous == 0) {
-			N_ppm = cio_read(cio, 4);	/* N_ppm */
-			len -= 4;
-		} else {
-			N_ppm = cp->ppm_previous;
-		}
-		j = cp->ppm_store;
-		if (Z_ppm == 0) {	/* First PPM marker */
-			cp->ppm_data = (unsigned char *) opj_malloc(N_ppm * sizeof(unsigned char));
-			cp->ppm_data_first = cp->ppm_data;
-			cp->ppm_len = N_ppm;
-		} else {			/* NON-first PPM marker */
-			cp->ppm_data = (unsigned char *) opj_realloc(cp->ppm_data, (N_ppm +	cp->ppm_store) * sizeof(unsigned char));
-			cp->ppm_data_first = cp->ppm_data;
-			cp->ppm_len = N_ppm + cp->ppm_store;
-		}
-		for (i = N_ppm; i > 0; i--) {	/* Read packet header */
-			cp->ppm_data[j] = cio_read(cio, 1);
-			j++;
-			len--;
-			if (len == 0)
-				break;			/* Case of non-finished packet header in present marker but finished in next one */
-		}
-		cp->ppm_previous = i - 1;
-		cp->ppm_store = j;
-	}
-}
-
-static void j3d_read_ppt(opj_j3d_t *j3d) {
-	int len, Z_ppt, i, j = 0;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = cp->tcps + j3d->curtileno;
-	opj_cio_t *cio = j3d->cio;
-
-	len = cio_read(cio, 2);
-	Z_ppt = cio_read(cio, 1);
-	tcp->ppt = 1;
-	if (Z_ppt == 0) {		/* First PPT marker */
-		tcp->ppt_data = (unsigned char *) opj_malloc((len - 3) * sizeof(unsigned char));
-		tcp->ppt_data_first = tcp->ppt_data;
-		tcp->ppt_store = 0;
-		tcp->ppt_len = len - 3;
-	} else {			/* NON-first PPT marker */
-		tcp->ppt_data =	(unsigned char *) opj_realloc(tcp->ppt_data, (len - 3 + tcp->ppt_store) * sizeof(unsigned char));
-		tcp->ppt_data_first = tcp->ppt_data;
-		tcp->ppt_len = len - 3 + tcp->ppt_store;
-	}
-	j = tcp->ppt_store;
-	for (i = len - 3; i > 0; i--) {
-		tcp->ppt_data[j] = cio_read(cio, 1);
-		j++;
-	}
-	tcp->ppt_store = j;
-}
-
-static void j3d_write_sot(opj_j3d_t *j3d) {
-	int lenp, len;
-
-	opj_cio_t *cio = j3d->cio;
-
-	j3d->sot_start = cio_tell(cio);
-	cio_write(cio, J3D_MS_SOT, 2);		/* SOT */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);					/* Lsot (further) */
-	cio_write(cio, j3d->curtileno, 2);	/* Isot */
-	cio_skip(cio, 4);					/* Psot (further in j3d_write_sod) */
-	cio_write(cio, 0, 1);				/* TPsot */
-	cio_write(cio, 1, 1);				/* TNsot (no of tile-parts of this tile in this codestream)*/
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);				/* Lsot */
-	cio_seek(cio, lenp + len);
-}
-
-static void j3d_read_sot(opj_j3d_t *j3d) {
-	int len, tileno, totlen, partno, numparts, i;
-	opj_tcp_t *tcp = NULL;
-	char status = 0;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_cio_t *cio = j3d->cio;
-	
-	len = cio_read(cio, 2);
-	tileno = cio_read(cio, 2);
-	
-	if (cp->tileno_size == 0) {
-		cp->tileno[cp->tileno_size] = tileno;
-		cp->tileno_size++;
-	} else {
-		i = 0;
-		while (i < cp->tileno_size && status == 0) {
-			status = cp->tileno[i] == tileno ? 1 : 0;
-			i++;
-		}
-		if (status == 0) {
-			cp->tileno[cp->tileno_size] = tileno;
-			cp->tileno_size++;
-		}
-	}
-	
-	totlen = cio_read(cio, 4);
-	if (!totlen)
-		totlen = cio_numbytesleft(cio) + 8;
-	
-	partno = cio_read(cio, 1);
-	numparts = cio_read(cio, 1);
-	
-	j3d->curtileno = tileno;
-	j3d->eot = cio_getbp(cio) - 12 + totlen;
-	j3d->state = J3D_STATE_TPH;
-	tcp = &cp->tcps[j3d->curtileno];
-	
-	if (tcp->first == 1) {
-		
-		/* Initialization PPT */
-		opj_tccp_t *tmp = tcp->tccps;
-		memcpy(tcp, j3d->default_tcp, sizeof(opj_tcp_t));
-		tcp->ppt = 0;
-		tcp->ppt_data = NULL;
-		tcp->ppt_data_first = NULL;
-		tcp->tccps = tmp;
-
-		for (i = 0; i < j3d->volume->numcomps; i++) {
-			tcp->tccps[i] = j3d->default_tcp->tccps[i];
-		}
-		cp->tcps[j3d->curtileno].first = 0;
-	}
-}
-
-static void j3d_write_sod(opj_j3d_t *j3d, void *tile_coder) {
-	int l, layno;
-	int totlen;
-	opj_tcp_t *tcp = NULL;
-	opj_volume_info_t *volume_info = NULL;
-	
-	opj_tcd_t *tcd = (opj_tcd_t*)tile_coder;	/* cast is needed because of conflicts in header inclusions */
-	opj_cp_t *cp = j3d->cp;
-	opj_cio_t *cio = j3d->cio;
-	
-	cio_write(cio, J3D_MS_SOD, 2);
-	if (j3d->curtileno == 0) {
-		j3d->sod_start = cio_tell(cio) + j3d->pos_correction;
-	}
-	
-	/* INDEX >> */
-	volume_info = j3d->volume_info;
-	if (volume_info && volume_info->index_on) {
-		volume_info->tile[j3d->curtileno].end_header = cio_tell(cio) + j3d->pos_correction - 1;
-	}
-	/* << INDEX */
-	
-	tcp = &cp->tcps[j3d->curtileno];
-	for (layno = 0; layno < tcp->numlayers; layno++) {
-		tcp->rates[layno] -= tcp->rates[layno] ? (j3d->sod_start / (cp->th * cp->tw * cp->tl)) : 0;
-	}
-	
-	if(volume_info) {
-		volume_info->num = 0;
-	}
-
-	l = tcd_encode_tile(tcd, j3d->curtileno, cio_getbp(cio), cio_numbytesleft(cio) - 2, volume_info);
-	
-	/* Writing Psot in SOT marker */
-	totlen = cio_tell(cio) + l - j3d->sot_start;
-	cio_seek(cio, j3d->sot_start + 6);
-	cio_write(cio, totlen, 4);
-	cio_seek(cio, j3d->sot_start + totlen);
-}
-
-static void j3d_read_sod(opj_j3d_t *j3d) {
-	int len, truncate = 0, i;
-	unsigned char *data = NULL, *data_ptr = NULL;
-
-	opj_cio_t *cio = j3d->cio;
-	int curtileno = j3d->curtileno;
-	
-	len = int_min(j3d->eot - cio_getbp(cio), cio_numbytesleft(cio) + 1);
-	
-	if (len == cio_numbytesleft(cio) + 1) {
-		truncate = 1;		/* Case of a truncate codestream */
-	}
-	
-	data = (unsigned char *) opj_malloc((j3d->tile_len[curtileno] + len) * sizeof(unsigned char));
-
-	for (i = 0; i < j3d->tile_len[curtileno]; i++) {
-		data[i] = j3d->tile_data[curtileno][i];
-	}
-
-	data_ptr = data + j3d->tile_len[curtileno];
-	for (i = 0; i < len; i++) {
-		data_ptr[i] = cio_read(cio, 1);
-	}
-	
-	j3d->tile_len[curtileno] += len;
-	opj_free(j3d->tile_data[curtileno]);
-	j3d->tile_data[curtileno] = data;
-	
-	if (!truncate) {
-		j3d->state = J3D_STATE_TPHSOT;
-	} else {
-		j3d->state = J3D_STATE_NEOC;	/* RAJOUTE !! */
-	}
-}
-
-static void j3d_write_rgn(opj_j3d_t *j3d, int compno, int tileno) {
-	
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = &cp->tcps[tileno];
-	opj_cio_t *cio = j3d->cio;
-	int numcomps = j3d->volume->numcomps;
-	
-	cio_write(cio, J3D_MS_RGN, 2);						/* RGN  */
-	cio_write(cio, numcomps <= 256 ? 5 : 6, 2);			/* Lrgn */
-	cio_write(cio, compno, numcomps <= 256 ? 1 : 2);	/* Crgn */
-	cio_write(cio, 0, 1);								/* Srgn */
-	cio_write(cio, tcp->tccps[compno].roishift, 1);		/* SPrgn */
-}
-
-static void j3d_read_rgn(opj_j3d_t *j3d) {
-	int len, compno, roisty;
-
-	opj_cp_t *cp = j3d->cp;
-	opj_tcp_t *tcp = j3d->state == J3D_STATE_TPH ? &cp->tcps[j3d->curtileno] : j3d->default_tcp;
-	opj_cio_t *cio = j3d->cio;
-	int numcomps = j3d->volume->numcomps;
-
-	len = cio_read(cio, 2);										/* Lrgn */
-	compno = cio_read(cio, numcomps <= 256 ? 1 : 2);			/* Crgn */
-	roisty = cio_read(cio, 1);									/* Srgn */
-	tcp->tccps[compno].roishift = cio_read(cio, 1);				/* SPrgn */
-}
-
-static void j3d_write_eoc(opj_j3d_t *j3d) {
-	opj_cio_t *cio = j3d->cio;
-	/* opj_event_msg(j3d->cinfo, "%.8x: EOC\n", cio_tell(cio) + j3d->pos_correction); */
-	cio_write(cio, J3D_MS_EOC, 2);
-}
-
-static void j3d_read_eoc(opj_j3d_t *j3d) {
-	int i, tileno;
-
-#ifndef NO_PACKETS_DECODING  
-	opj_tcd_t *tcd = tcd_create(j3d->cinfo);
-    tcd_malloc_decode(tcd, j3d->volume, j3d->cp);
-	/*j3d_dump_volume(stdout, tcd->volume);
-	j3d_dump_cp(stdout, tcd->volume, tcd->cp);*/
-	for (i = 0; i < j3d->cp->tileno_size; i++) {
-		tileno = j3d->cp->tileno[i];
-		//opj_event_msg(j3d->cinfo, EVT_INFO, "tcd_decode_tile \n");
-		tcd_decode_tile(tcd, j3d->tile_data[tileno], j3d->tile_len[tileno], tileno);
-		opj_free(j3d->tile_data[tileno]);
-		j3d->tile_data[tileno] = NULL;
-	}
-	tcd_free_decode(tcd);
-	tcd_destroy(tcd);
-#else 
-	for (i = 0; i < j3d->cp->tileno_size; i++) {
-		tileno = j3d->cp->tileno[i];
-		opj_free(j3d->tile_data[tileno]);
-		j3d->tile_data[tileno] = NULL;
-	}
-#endif
-	
-	j3d->state = J3D_STATE_MT;
-}
-
-static void j3d_read_unk(opj_j3d_t *j3d) {
-	opj_event_msg(j3d->cinfo, EVT_WARNING, "Unknown marker\n");
-}
-
-static opj_atk_t atk_info_wt[] = {
-	{0, 1, J3D_ATK_WS, J3D_ATK_IRR, 0, J3D_ATK_WS, 1.230174104, 4, {0}, {0}, {0}, {1,1,1,1}, {-1.586134342059924, -0.052980118572961, 0.882911075530934, 0.443506852043971}},/* WT 9-7 IRR*/
-	{1, 0, J3D_ATK_WS, J3D_ATK_REV, 0, J3D_ATK_WS, 0, 2, {0}, {1,2}, {1,2}, {1,1}, {-1.0,1.0}},/* WT 5-3 REV*/
-	{2, 0, J3D_ATK_ARB, J3D_ATK_REV, 0, J3D_ATK_CON, 0, 2, {0,0}, {0,1}, {0,1}, {1,1}, {{-1.0},{1.0}}}, /* WT 2-2 REV*/
-	{3, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-1}, {0,1,2}, {0,1,2}, {1,1,3}, {{-1.0},{1.0},{1.0,0.0,-1.0}}}, /* WT 2-6 REV*/
-	{4, 0, J3D_ATK_ARB, J3D_ATK_REV, 1, J3D_ATK_CON, 0, 3, {0,0,-2}, {0,1,6}, {0,1,32}, {1,1,5}, {{-1},{1},{-3.0,22.0,0.0,-22.0,3.0}}}, /* WT 2-10 REV*/
-	{5, 1, J3D_ATK_ARB, J3D_ATK_IRR, 1, J3D_ATK_WS, 1, 7, {0}, {0}, {0}, {1,1,2,1,2,1,3},{{-1},{1.58613434206},{-0.460348209828, 0.460348209828},{0.25},{0.374213867768,-0.374213867768},{-1.33613434206},{0.29306717103,0,-0.29306717103}}}, /* WT 6-10 IRR*/
-	{6, 1, J3D_ATK_ARB, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 11, {0}, {0}, {0}, {1,1,2,1,2,1,2,1,2,1,5},{{-1},{0,99715069105},{-1.00573127827, 1.00573127827},{-0.27040357631},{2.20509972343, -2.20509972343},{0.08059995736},
-		{-1.62682532350, 1.62682532350},{0.52040357631},{0.60404664250, -0.60404664250},{-0.82775064841},{-0.06615812964, 0.29402137720, 0, -0.29402137720, 0.06615812964}}}, /* WT 10-18 IRR*/
-	{7, 1, J3D_ATK_WS, J3D_ATK_IRR, 0, J3D_ATK_WS, 1, 2, {0}, {0}, {0}, {1,1}, {-0.5, 0.25}},	/* WT 5-3 IRR*/
-	{8, 0, J3D_ATK_WS, J3D_ATK_REV, 0, J3D_ATK_WS, 0, 2, {0}, {4,4}, {8,8}, {2,2}, {{-9,1},{5,-1}}}		/* WT 13-7 REV*/
-};
-
-typedef struct opj_dec_mstabent {
-	/** marker value */
-	int id;
-	/** value of the state when the marker can appear */
-	int states;
-	/** action linked to the marker */
-	void (*handler) (opj_j3d_t *j3d);
-} opj_dec_mstabent_t;
-
-opj_dec_mstabent_t j3d_dec_mstab[] = {
-  {J3D_MS_SOC, J3D_STATE_MHSOC, j3d_read_soc},
-  {J3D_MS_SOT, J3D_STATE_MH | J3D_STATE_TPHSOT, j3d_read_sot},
-  {J3D_MS_SOD, J3D_STATE_TPH, j3d_read_sod},
-  {J3D_MS_EOC, J3D_STATE_TPHSOT, j3d_read_eoc},
-  {J3D_MS_CAP, J3D_STATE_MHSIZ, j3d_read_cap},
-  {J3D_MS_SIZ, J3D_STATE_MHSIZ, j3d_read_siz},
-  {J3D_MS_ZSI, J3D_STATE_MHSIZ, j3d_read_zsi},
-  {J3D_MS_COD, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_cod},
-  {J3D_MS_COC, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_coc},
-  {J3D_MS_RGN, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_rgn},
-  {J3D_MS_QCD, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_qcd},
-  {J3D_MS_QCC, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_qcc},
-  {J3D_MS_POC, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_poc},
-  {J3D_MS_TLM, J3D_STATE_MH, j3d_read_tlm},
-  {J3D_MS_PLM, J3D_STATE_MH, j3d_read_plm},
-  {J3D_MS_PLT, J3D_STATE_TPH, j3d_read_plt},
-  {J3D_MS_PPM, J3D_STATE_MH, j3d_read_ppm},
-  {J3D_MS_PPT, J3D_STATE_TPH, j3d_read_ppt},
-  {J3D_MS_SOP, 0, 0},
-  {J3D_MS_CRG, J3D_STATE_MH, j3d_read_crg},
-  {J3D_MS_COM, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_com},
-  {J3D_MS_DCO, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_dco},
-  {J3D_MS_ATK, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_atk},
-  {0, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_unk}
-  /*, -->must define the j3d_read functions
-  {J3D_MS_CBD, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_cbd},
-  {J3D_MS_MCT, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_mct},
-  {J3D_MS_MCC, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_mcc},
-  {J3D_MS_MCO, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_mco},
-  {J3D_MS_NLT, J3D_STATE_MH | J3D_STATE_TPH, j3d_read_nlt},
-  {J3D_MS_VMS, J3D_STATE_MH, j3d_read_vms},
-  {J3D_MS_DFS, J3D_STATE_MH, j3d_read_dfs},
-  {J3D_MS_ADS, J3D_STATE_MH, j3d_read_ads},
-  {J3D_MS_QPD, J3D_STATE_MH, j3d_read_qpd},
-  {J3D_MS_QPC, J3D_STATE_TPH, j3d_read_qpc}*/
-};
-
-/**
-Read the lookup table containing all the marker, status and action
- at param id Marker value
-*/
-static opj_dec_mstabent_t *j3d_dec_mstab_lookup(int id) {
-	opj_dec_mstabent_t *e;
-	for (e = j3d_dec_mstab; e->id != 0; e++) {
-		if (e->id == id) {
-			break;
-		}
-	}
-	return e;
-}
-
-/* ----------------------------------------------------------------------- */
-/* J3D / JPT decoder interface                                             */
-/* ----------------------------------------------------------------------- */
-
-opj_j3d_t* j3d_create_decompress(opj_common_ptr cinfo) {
-	opj_j3d_t *j3d = (opj_j3d_t*)opj_malloc(sizeof(opj_j3d_t));
-	if(j3d) {
-		j3d->cinfo = cinfo;
-		j3d->default_tcp = (opj_tcp_t*)opj_malloc(sizeof(opj_tcp_t));
-		if(!j3d->default_tcp) {
-			opj_free(j3d);
-			return NULL;
-		}
-	}
-	return j3d;
-}
-
-void j3d_destroy_decompress(opj_j3d_t *j3d) {
-	int i = 0;
-
-	if(j3d->tile_len != NULL) {
-		opj_free(j3d->tile_len);
-	}
-	if(j3d->tile_data != NULL) {
-		opj_free(j3d->tile_data);
-	}
-	if(j3d->default_tcp != NULL) {
-		opj_tcp_t *default_tcp = j3d->default_tcp;
-		if(default_tcp->ppt_data_first != NULL) {
-			opj_free(default_tcp->ppt_data_first);
-		}
-		if(j3d->default_tcp->tccps != NULL) {
-			opj_free(j3d->default_tcp->tccps);
-		}
-		opj_free(j3d->default_tcp);
-	}
-	if(j3d->cp != NULL) {
-		opj_cp_t *cp = j3d->cp;
-		if(cp->tcps != NULL) {
-			for(i = 0; i < cp->tw * cp->th * cp->tl; i++) {
-				if(cp->tcps[i].ppt_data_first != NULL) {
-					opj_free(cp->tcps[i].ppt_data_first);
-				}
-				if(cp->tcps[i].tccps != NULL) {
-					opj_free(cp->tcps[i].tccps);
-				}
-			}
-			opj_free(cp->tcps);
-		}
-		if(cp->ppm_data_first != NULL) {
-			opj_free(cp->ppm_data_first);
-		}
-		if(cp->tileno != NULL) {
-			opj_free(cp->tileno);  
-		}
-		if(cp->comment != NULL) {
-			opj_free(cp->comment);
-		}
-
-		opj_free(cp);
-	}
-
-	opj_free(j3d);
-}
-
-void j3d_setup_decoder(opj_j3d_t *j3d, opj_dparameters_t *parameters) {
-	if(j3d && parameters) {
-		/* create and initialize the coding parameters structure */
-		opj_cp_t *cp = (opj_cp_t*)opj_malloc(sizeof(opj_cp_t));
-		cp->reduce[0] = parameters->cp_reduce[0];
-		cp->reduce[1] = parameters->cp_reduce[1];
-		cp->reduce[2] = parameters->cp_reduce[2];
-		cp->layer = parameters->cp_layer;
-		cp->bigendian = parameters->bigendian;
-		
-		
-		cp->encoding_format = ENCOD_2EB;
-		cp->transform_format = TRF_2D_DWT;
-		
-		/* keep a link to cp so that we can destroy it later in j3d_destroy_decompress */
-		j3d->cp = cp;
-	}
-}
-
-opj_volume_t* j3d_decode(opj_j3d_t *j3d, opj_cio_t *cio) {
-	opj_volume_t *volume = NULL;
-
-	opj_common_ptr cinfo = j3d->cinfo;
-
-	j3d->cio = cio;
-
-	/* create an empty volume */
-	volume = (opj_volume_t*)opj_malloc(sizeof(opj_volume_t));
-	j3d->volume = volume;
-
-	j3d->state = J3D_STATE_MHSOC;
-	
-	for (;;) {
-		opj_dec_mstabent_t *e;
-		int id = cio_read(cio, 2);
-		if (id >> 8 != 0xff) {
-			opj_volume_destroy(volume);
-			opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
-			return 0;
-		}
-		e = j3d_dec_mstab_lookup(id);
-		//opj_event_msg(cinfo, EVT_INFO, "MARKER %x PREVSTATE %d E->STATE %d\n",e->id,j3d->state,e->states);
-		if (!(j3d->state & e->states)) {
-			opj_volume_destroy(volume);
-			opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id);
-			return 0;
-		}
-		if (e->handler) {
-			(*e->handler)(j3d);
-		}
-		//opj_event_msg(cinfo, EVT_INFO, "POSTSTATE %d\n",j3d->state);
-		if (j3d->state == J3D_STATE_MT) {
-			break;
-		}
-		if (j3d->state == J3D_STATE_NEOC) {
-			break;
-		}
-	}
-	if (j3d->state == J3D_STATE_NEOC) {
-		j3d_read_eoc(j3d);
-	}
-
-	if (j3d->state != J3D_STATE_MT) {
-		opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n");
-	}
-	
-	return volume;
-}
-
-/* ----------------------------------------------------------------------- */
-/* J3D encoder interface                                                       */
-/* ----------------------------------------------------------------------- */
-
-opj_j3d_t* j3d_create_compress(opj_common_ptr cinfo) {
-	opj_j3d_t *j3d = (opj_j3d_t*)opj_malloc(sizeof(opj_j3d_t));
-	if(j3d) {
-		j3d->cinfo = cinfo;
-	}
-	return j3d;
-}
-
-void j3d_destroy_compress(opj_j3d_t *j3d) {
-	int tileno;
-
-	if(!j3d) return;
-
-	if(j3d->volume_info != NULL) {
-		opj_volume_info_t *volume_info = j3d->volume_info;
-		if (volume_info->index_on && j3d->cp) {
-			opj_cp_t *cp = j3d->cp;
-			for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-				opj_tile_info_t *tile_info = &volume_info->tile[tileno];
-				opj_free(tile_info->thresh);
-				opj_free(tile_info->packet);
-			}
-			opj_free(volume_info->tile);
-		}
-		opj_free(volume_info);
-	}
-	if(j3d->cp != NULL) {
-		opj_cp_t *cp = j3d->cp;
-
-		if(cp->comment) {
-			opj_free(cp->comment);
-		}
-		if(cp->matrice) {
-			opj_free(cp->matrice);
-		}
-		for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-			opj_free(cp->tcps[tileno].tccps);
-		}
-		opj_free(cp->tcps);
-		opj_free(cp);
-	}
-
-	opj_free(j3d);
-}
-
-void j3d_setup_encoder(opj_j3d_t *j3d, opj_cparameters_t *parameters, opj_volume_t *volume) {
-	int i, j, tileno, numpocs_tile;
-	opj_cp_t *cp = NULL;
-
-	if(!j3d || !parameters || ! volume) {
-		return;
-	}
-
-	/* create and initialize the coding parameters structure */
-	cp = (opj_cp_t*)opj_malloc(sizeof(opj_cp_t));
-
-	/* keep a link to cp so that we can destroy it later in j3d_destroy_compress */
-	j3d->cp = cp;
-
-	/* set default values for cp */
-	cp->tw = 1;
-	cp->th = 1;
-	cp->tl = 1;
-
-	/* copy user encoding parameters */
-	cp->disto_alloc = parameters->cp_disto_alloc;
-	cp->fixed_alloc = parameters->cp_fixed_alloc;
-	cp->fixed_quality = parameters->cp_fixed_quality;
-
-	/* transform and coding method */
-	cp->transform_format = parameters->transform_format;
-	cp->encoding_format = parameters->encoding_format;
-
-	/* mod fixed_quality */
-	if(parameters->cp_matrice) {
-		size_t array_size = parameters->tcp_numlayers * 3 * parameters->numresolution[0] * sizeof(int);
-		cp->matrice = (int *) opj_malloc(array_size);
-		memcpy(cp->matrice, parameters->cp_matrice, array_size);
-	} 
-
-	/* creation of an index file ? */
-	cp->index_on = parameters->index_on;
-	if(cp->index_on) {
-		j3d->volume_info = (opj_volume_info_t*)opj_malloc(sizeof(opj_volume_info_t));
-	}
-	
-	/* tiles */
-	cp->tdx = parameters->cp_tdx;
-	cp->tdy = parameters->cp_tdy;
-	cp->tdz = parameters->cp_tdz;
-	/* tile offset */
-	cp->tx0 = parameters->cp_tx0;
-	cp->ty0 = parameters->cp_ty0;
-	cp->tz0 = parameters->cp_tz0;
-	/* comment string */
-	if(parameters->cp_comment) {
-		cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) + 1);
-		if(cp->comment) {
-			strcpy(cp->comment, parameters->cp_comment);
-		}
-	}
-
-	/*calculate other encoding parameters*/
-	if (parameters->tile_size_on) {
-		cp->tw = int_ceildiv(volume->x1 - cp->tx0, cp->tdx);
-		cp->th = int_ceildiv(volume->y1 - cp->ty0, cp->tdy);
-		cp->tl = int_ceildiv(volume->z1 - cp->tz0, cp->tdz);
-	} else {
-		cp->tdx = volume->x1 - cp->tx0;
-		cp->tdy = volume->y1 - cp->ty0;
-		cp->tdz = volume->z1 - cp->tz0;
-	}
-
-	/* initialize the multiple tiles */
-	/* ---------------------------- */
-	cp->tcps = (opj_tcp_t *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(opj_tcp_t));
-
-	for (tileno = 0; tileno < cp->tw * cp->th * cp->tl; tileno++) {
-		opj_tcp_t *tcp = &cp->tcps[tileno];
-		tcp->numlayers = parameters->tcp_numlayers;
-		for (j = 0; j < tcp->numlayers; j++) {
-			if (cp->fixed_quality) {	/* add fixed_quality */
-				tcp->distoratio[j] = parameters->tcp_distoratio[j];
-			} else {
-				tcp->rates[j] = parameters->tcp_rates[j];
-			}
-		}
-		tcp->csty = parameters->csty;
-		tcp->prg = parameters->prog_order;
-		tcp->mct = volume->numcomps == 3 ? 1 : 0;
-
-		numpocs_tile = 0;
-		tcp->POC = 0;
-		if (parameters->numpocs) {
-			/* initialisation of POC */
-			tcp->POC = 1;
-			for (i = 0; i < parameters->numpocs; i++) {
-				if((tileno == parameters->POC[i].tile - 1) || (parameters->POC[i].tile == -1)) {
-					opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
-					tcp_poc->resno0		= parameters->POC[numpocs_tile].resno0;
-					tcp_poc->compno0	= parameters->POC[numpocs_tile].compno0;
-					tcp_poc->layno1		= parameters->POC[numpocs_tile].layno1;
-					tcp_poc->resno1		= parameters->POC[numpocs_tile].resno1;
-					tcp_poc->compno1	= parameters->POC[numpocs_tile].compno1;
-					tcp_poc->prg		= parameters->POC[numpocs_tile].prg;
-					tcp_poc->tile		= parameters->POC[numpocs_tile].tile;
-					numpocs_tile++;
-				}
-			}
-		}
-		tcp->numpocs = numpocs_tile;
-
-		tcp->tccps = (opj_tccp_t *) opj_malloc(volume->numcomps * sizeof(opj_tccp_t));
-		
-		for (i = 0; i < volume->numcomps; i++) {
-			opj_tccp_t *tccp = &tcp->tccps[i];
-			tccp->csty = parameters->csty & J3D_CCP_CSTY_PRT;	/* 0 => standard precint || 1 => custom-defined precinct  */
-			tccp->numresolution[0] = parameters->numresolution[0];
-			tccp->numresolution[1] = parameters->numresolution[1];
-			tccp->numresolution[2] = parameters->numresolution[2];
-						assert (parameters->cblock_init[0] <= T1_MAXCBLKW);
-						assert (parameters->cblock_init[0] >= T1_MINCBLKW);
-						assert (parameters->cblock_init[1] <= T1_MAXCBLKH);
-						assert (parameters->cblock_init[1] >= T1_MINCBLKH);
-						assert (parameters->cblock_init[2] <= T1_MAXCBLKD);
-						assert (parameters->cblock_init[2] >= T1_MINCBLKD);
-			tccp->cblk[0] = int_floorlog2(parameters->cblock_init[0]); 
-			tccp->cblk[1] = int_floorlog2(parameters->cblock_init[1]); 
-			tccp->cblk[2] = int_floorlog2(parameters->cblock_init[2]); 
-						assert (tccp->cblk[0]+tccp->cblk[1]+tccp->cblk[1] <= T1_MAXWHD);
-			tccp->cblksty = parameters->mode; //Codeblock style --> Table A.19 (default 0)
-
-			/*ATK / transform */
-			tccp->reversible = parameters->irreversible ? 0 : 1; /* 0 => DWT 9-7 || 1 => DWT 5-3  */
-			for (j = 0; j < 3; j++) {
-					tccp->dwtid[j] = parameters->irreversible ? 0 : 1; /* 0 => DWT 9-7 || 1 => DWT 5-3  */
-			}
-      						
-			/* Quantification: SEQNT (Scalar Expounded, value for each subband) / NOQNT (no quant)*/
-			tccp->qntsty = parameters->irreversible ? J3D_CCP_QNTSTY_SEQNT : J3D_CCP_QNTSTY_NOQNT;
-			tccp->numgbits = 2;
-			if (i == parameters->roi_compno) {
-				tccp->roishift = parameters->roi_shift;
-			} else {
-				tccp->roishift = 0;
-			}
-			/* Custom defined precints */
-			if (parameters->csty & J3D_CCP_CSTY_PRT) {
-				int k;
-				for (k = 0; k < 3; k++) {
-					int p = 0;
-					for (j = tccp->numresolution[k] - 1; j >= 0; j--) {
-						if (p < parameters->res_spec) {/* p < number of precinct size specifications */
-							if (parameters->prct_init[k][p] < 1) {
-								tccp->prctsiz[k][j] = 1;
-							} else {
-								tccp->prctsiz[k][j] = int_floorlog2(parameters->prct_init[k][p]);
-							}
-						} else {
-							int res_spec = parameters->res_spec;
-							int size_prct = parameters->prct_init[k][res_spec - 1] >> (p - (res_spec - 1));
-							if (size_prct < 1) {
-								tccp->prctsiz[k][j] = 1;
-							} else {
-								tccp->prctsiz[k][j] = int_floorlog2(size_prct);
-							}
-						}
-					}
-					p++;
-				}
-			} else {
-				int k;
-				for (k = 0; k < 3; k++) {
-                    for (j = 0; j < tccp->numresolution[k]; j++) {
-                        tccp->prctsiz[k][j] = 15;
-					}
-				}
-			}
-			//Calcular stepsize for each subband (if NOQNT -->stepsize = 1.0)
-			dwt_calc_explicit_stepsizes(tccp, volume->comps[i].prec);
-		}
-	}
-}
-
-/**
-Create an index file
- at param j3d
- at param cio
- at param volume_info
- at param index Index filename
- at return Returns 1 if successful, returns 0 otherwise
-*/
-static int j3d_create_index(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_info_t *volume_info, char *index) {
-	
-	int tileno, compno, layno, resno, precno, pack_nb, x, y, z;
-	FILE *stream = NULL;
-	double total_disto = 0;
-
-	volume_info->codestream_size = cio_tell(cio) + j3d->pos_correction;	/* Correction 14/4/03 suite rmq de Patrick */
-
-	stream = fopen(index, "w");
-	if (!stream) {
-		opj_event_msg(j3d->cinfo, EVT_ERROR, "failed to open %s for writing\n", index);
-		return 0;
-	}
-	
-	fprintf(stream, "w %d\t h %d\t l %d\n", volume_info->volume_w, volume_info->volume_h, volume_info->volume_l);
-	fprintf(stream, "TRASNFORM\t%d\n", volume_info->transform_format);
-	fprintf(stream, "ENTROPY CODING\t%d\n", volume_info->encoding_format);
-	fprintf(stream, "PROG\t%d\n", volume_info->prog);
-	fprintf(stream, "TILE\tx %d y %d z %d\n", volume_info->tile_x, volume_info->tile_y, volume_info->tile_z);
-	fprintf(stream, "NOTILE\tx %d y %d z %d\n", volume_info->tw, volume_info->th, volume_info->tl);
-	fprintf(stream, "COMPONENTS\t%d\n", volume_info->comp);
-	fprintf(stream, "LAYER\t%d\n", volume_info->layer);
-	fprintf(stream, "RESOLUTIONS\tx %d y %d z %d\n", volume_info->decomposition[0], volume_info->decomposition[1], volume_info->decomposition[2]);
-	
-	fprintf(stream, "Precint sizes for each resolution:\n");
-	for (resno = volume_info->decomposition[0]; resno >= 0; resno--) {
-		fprintf(stream, "Resno %d \t [%d,%d,%d] \n", resno,
-			(1 << volume_info->tile[0].prctsiz[0][resno]), (1 << volume_info->tile[0].prctsiz[0][resno]), (1 << volume_info->tile[0].prctsiz[2][resno]));	/* based on tile 0 */
-	}
-	fprintf(stream, "HEADER_END\t%d\n", volume_info->main_head_end);
-	fprintf(stream, "CODESTREAM\t%d\n", volume_info->codestream_size);
-	fprintf(stream, "Num_tile Start_pos End_header End_pos Distotile Nbpix Ratio\n");
-	for (tileno = 0; tileno < (volume_info->tw * volume_info->th * volume_info->tl); tileno++) {
-		fprintf(stream, "%4d\t%9d\t%9d\t%9d\t%9e\t%9d\t%9e\n",
-			volume_info->tile[tileno].num_tile,
-			volume_info->tile[tileno].start_pos,
-			volume_info->tile[tileno].end_header,
-			volume_info->tile[tileno].end_pos,
-			volume_info->tile[tileno].distotile, volume_info->tile[tileno].nbpix,
-			volume_info->tile[tileno].distotile / volume_info->tile[tileno].nbpix);
-	}
-	
-	for (tileno = 0; tileno < (volume_info->tw * volume_info->th * volume_info->tl); tileno++) {
-		int start_pos, end_pos;
-		double disto = 0;
-		pack_nb = 0;
-		if (volume_info->prog == LRCP) {	/* LRCP */
-			fprintf(stream, "pack_nb tileno layno resno compno precno start_pos  end_pos   disto\n");
-			for (layno = 0; layno < volume_info->layer; layno++) {
-				for (resno = 0; resno < volume_info->decomposition[0] + 1; resno++) {
-					for (compno = 0; compno < volume_info->comp; compno++) {
-						int prec_max = volume_info->tile[tileno].prctno[0][resno] * volume_info->tile[tileno].prctno[1][resno] * volume_info->tile[tileno].prctno[2][resno];
-						for (precno = 0; precno < prec_max; precno++) {
-							start_pos = volume_info->tile[tileno].packet[pack_nb].start_pos;
-							end_pos = volume_info->tile[tileno].packet[pack_nb].end_pos;
-							disto = volume_info->tile[tileno].packet[pack_nb].disto;
-							fprintf(stream, "%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",pack_nb, tileno, layno, resno, compno, precno, start_pos, end_pos, disto);
-							total_disto += disto;
-							pack_nb++;
-						}
-					}
-				}
-			}
-		} /* LRCP */
-		else if (volume_info->prog == RLCP) {	/* RLCP */
-			/*
-			fprintf(stream, "pack_nb tileno resno layno compno precno start_pos  end_pos   disto");
-			*/
-			for (resno = 0; resno < volume_info->decomposition[0] + 1; resno++) {
-				for (layno = 0; layno < volume_info->layer; layno++) {
-					for (compno = 0; compno < volume_info->comp; compno++) {
-						int prec_max = volume_info->tile[tileno].prctno[0][resno] * volume_info->tile[tileno].prctno[1][resno]* volume_info->tile[tileno].prctno[2][resno];
-						for (precno = 0; precno < prec_max; precno++) {
-							start_pos = volume_info->tile[tileno].packet[pack_nb].start_pos;
-							end_pos = volume_info->tile[tileno].packet[pack_nb].end_pos;
-							disto = volume_info->tile[tileno].packet[pack_nb].disto;
-							fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %8e\n",
-								pack_nb, tileno, resno, layno, compno, precno, start_pos, end_pos, disto);
-							total_disto += disto;
-							pack_nb++;
-						}
-					}
-				}
-			}
-		} /* RLCP */
-		else if (volume_info->prog == RPCL) {	/* RPCL */
-			/*
-			fprintf(stream, "\npack_nb tileno resno precno compno layno start_pos  end_pos   disto\n"); 
-			*/
-			for (resno = 0; resno < volume_info->decomposition[0] + 1; resno++) {
-				/* I suppose components have same XRsiz, YRsiz */
-				//int x0 = volume_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tw * volume_info->tile_x;
-				//int y0 = volume_info->tile_Ox + (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tile_y;
-				int x0 = volume_info->tile_Ox + (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tile_x;
-				int y0 = volume_info->tile_Oy + (int)floor( (float)tileno/(float)volume_info->th ) * volume_info->tile_y;
-				int z0 = volume_info->tile_Ox + (int)floor( (float)tileno/(float)volume_info->tl ) * volume_info->tile_z;
-				int x1 = x0 + volume_info->tile_x;
-				int y1 = y0 + volume_info->tile_y;
-				int z1 = z0 + volume_info->tile_z;
-				for(z = z0; z < z1; z++) {
-					for(y = y0; y < y1; y++) {
-						for(x = x0; x < x1; x++) {
-							for (compno = 0; compno < volume_info->comp; compno++) {
-								int prec_max = volume_info->tile[tileno].prctno[0][resno] * volume_info->tile[tileno].prctno[1][resno] * volume_info->tile[tileno].prctno[2][resno];
-								for (precno = 0; precno < prec_max; precno++) {
-									int pcnx = volume_info->tile[tileno].prctno[0][resno];
-									int pcx = (int) pow( 2, volume_info->tile[tileno].prctsiz[0][resno] + volume_info->decomposition[0] - resno );
-									int pcy = (int) pow( 2, volume_info->tile[tileno].prctsiz[1][resno] + volume_info->decomposition[1] - resno );
-									int pcz = (int) pow( 2, volume_info->tile[tileno].prctsiz[2][resno] + volume_info->decomposition[2] - resno );
-									int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-									int precno_y = (int) floor( (float)precno/(float)pcnx );
-									if (precno_y*pcy == y ) {
-										if (precno_x*pcx == x ) {
-											for (layno = 0; layno < volume_info->layer; layno++) {
-												start_pos = volume_info->tile[tileno].packet[pack_nb].start_pos;
-												end_pos = volume_info->tile[tileno].packet[pack_nb].end_pos;
-												disto = volume_info->tile[tileno].packet[pack_nb].disto;
-												fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %8e\n",
-													pack_nb, tileno, resno, precno, compno, layno, start_pos, end_pos, disto); 
-												total_disto += disto;
-												pack_nb++; 
-											}
-										}
-									}
-								} /* precno */
-							} /* compno */
-						} /* x = x0..x1 */
-					} /* y = y0..y1 */
-				} /* z = z0..z1 */
-			} /* resno */
-		} /* RPCL */
-		else if (volume_info->prog == PCRL) {	/* PCRL */
-			/* I suppose components have same XRsiz, YRsiz */
-			int x0 = volume_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tw * volume_info->tile_x;
-			int y0 = volume_info->tile_Ox + (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tile_y;
-			int z0 = volume_info->tile_Oz + (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tile_z;
-			int x1 = x0 + volume_info->tile_x;
-			int y1 = y0 + volume_info->tile_y;
-			int z1 = z0 + volume_info->tile_z;
-			/*
-			fprintf(stream, "\npack_nb tileno precno compno resno layno start_pos  end_pos   disto\n"); 
-			*/
-			for(z = z0; z < z1; z++) {
-				for(y = y0; y < y1; y++) {
-					for(x = x0; x < x1; x++) {
-						for (compno = 0; compno < volume_info->comp; compno++) {
-							for (resno = 0; resno < volume_info->decomposition[0] + 1; resno++) {
-								int prec_max = volume_info->tile[tileno].prctno[0][resno] * volume_info->tile[tileno].prctno[1][resno];
-								for (precno = 0; precno < prec_max; precno++) {
-								int pcnx = volume_info->tile[tileno].prctno[0][resno];
-								int pcx = (int) pow( 2, volume_info->tile[tileno].prctsiz[0][resno] + volume_info->decomposition[0] - resno );
-								int pcy = (int) pow( 2, volume_info->tile[tileno].prctsiz[1][resno] + volume_info->decomposition[1] - resno );
-								int pcz = (int) pow( 2, volume_info->tile[tileno].prctsiz[2][resno] + volume_info->decomposition[2] - resno );
-								int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-								int precno_y = (int) floor( (float)precno/(float)pcnx );
-								int precno_z = (int) floor( (float)precno/(float)pcnx );
-								if (precno_z*pcz == z ) {
-									if (precno_y*pcy == y ) {
-										if (precno_x*pcx == x ) {
-											for (layno = 0; layno < volume_info->layer; layno++) {
-												start_pos = volume_info->tile[tileno].packet[pack_nb].start_pos;
-												end_pos = volume_info->tile[tileno].packet[pack_nb].end_pos;
-												disto = volume_info->tile[tileno].packet[pack_nb].disto;
-												fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %8e\n",
-													pack_nb, tileno, precno, compno, resno, layno, start_pos, end_pos, disto); 
-												total_disto += disto;
-												pack_nb++; 
-											}
-										}
-									}
-								}
-							} /* precno */
-						} /* resno */
-					} /* compno */
-				} /* x = x0..x1 */
-			} /* y = y0..y1 */
-			}
-		} /* PCRL */
-		else {	/* CPRL */
-			/*
-			fprintf(stream, "\npack_nb tileno compno precno resno layno start_pos  end_pos   disto\n"); 
-			*/
-			for (compno = 0; compno < volume_info->comp; compno++) {
-				/* I suppose components have same XRsiz, YRsiz */
-				int x0 = volume_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tw * volume_info->tile_x;
-				int y0 = volume_info->tile_Ox + (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tile_y;
-				int z0 = volume_info->tile_Oz + (int)floor( (float)tileno/(float)volume_info->tw ) * volume_info->tile_z;
-				int x1 = x0 + volume_info->tile_x;
-				int y1 = y0 + volume_info->tile_y;
-				int z1 = z0 + volume_info->tile_z;
-				for(z = z0; z < z1; z++) {
-					for(y = y0; y < y1; y++) {
-						for(x = x0; x < x1; x++) {
-							for (resno = 0; resno < volume_info->decomposition[0] + 1; resno++) {
-								int prec_max = volume_info->tile[tileno].prctno[0][resno] * volume_info->tile[tileno].prctno[1][resno] * volume_info->tile[tileno].prctno[2][resno];
-								for (precno = 0; precno < prec_max; precno++) {
-									int pcnx = volume_info->tile[tileno].prctno[0][resno];
-									int pcny = volume_info->tile[tileno].prctno[1][resno];
-									int pcx = (int) pow( 2, volume_info->tile[tileno].prctsiz[0][resno] + volume_info->decomposition[0] - resno );
-									int pcy = (int) pow( 2, volume_info->tile[tileno].prctsiz[1][resno] + volume_info->decomposition[1] - resno );
-									int pcz = (int) pow( 2, volume_info->tile[tileno].prctsiz[2][resno] + volume_info->decomposition[2] - resno );
-									int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-									int precno_y = (int) floor( (float)precno/(float)pcnx );
-									int precno_z = 0; /*???*/
-									if (precno_z*pcz == z ) {
-										if (precno_y*pcy == y ) {
-											if (precno_x*pcx == x ) {
-												for (layno = 0; layno < volume_info->layer; layno++) {
-													start_pos = volume_info->tile[tileno].packet[pack_nb].start_pos;
-													end_pos = volume_info->tile[tileno].packet[pack_nb].end_pos;
-													disto = volume_info->tile[tileno].packet[pack_nb].disto;
-													fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %8e\n",
-														pack_nb, tileno, compno, precno, resno, layno, start_pos, end_pos, disto); 
-													total_disto += disto;
-													pack_nb++; 
-												}
-											}
-										}
-									}
-								} /* precno */
-							} /* resno */
-						} /* x = x0..x1 */
-					} /* y = y0..y1 */
-				} /* z = z0..z1 */
-			} /* comno */
-		} /* CPRL */   
-	} /* tileno */
-	
-	fprintf(stream, "SE_MAX\t%8e\n", volume_info->D_max);	/* SE max */
-	fprintf(stream, "SE_TOTAL\t%.8e\n", total_disto);			/* SE totale */
-	
-
-	fclose(stream);
-
-	return 1;
-}
-
-bool j3d_encode(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_t *volume, char *index) {
-	int tileno, compno;
-	opj_volume_info_t *volume_info = NULL;
-	opj_cp_t *cp = NULL;
-	opj_tcd_t *tcd = NULL;	/* TCD component */
-
-	j3d->cio = cio;	
-	j3d->volume = volume;
-	cp = j3d->cp;
-
-	/*j3d_dump_volume(stdout, volume);
-	j3d_dump_cp(stdout, volume, cp);*/
-
-	/* INDEX >> */
-	volume_info = j3d->volume_info;
-	if (volume_info && cp->index_on) {
-		volume_info->index_on = cp->index_on;
-		volume_info->tile = (opj_tile_info_t *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(opj_tile_info_t));
-		volume_info->volume_w = volume->x1 - volume->x0;
-		volume_info->volume_h = volume->y1 - volume->y0;
-		volume_info->volume_l = volume->z1 - volume->z0;
-		volume_info->prog = (&cp->tcps[0])->prg;
-		volume_info->tw = cp->tw;
-		volume_info->th = cp->th;
-		volume_info->tl = cp->tl;
-		volume_info->tile_x = cp->tdx;	/* new version parser */
-		volume_info->tile_y = cp->tdy;	/* new version parser */
-		volume_info->tile_z = cp->tdz;	/* new version parser */
-		volume_info->tile_Ox = cp->tx0;	/* new version parser */
-		volume_info->tile_Oy = cp->ty0;	/* new version parser */
-		volume_info->tile_Oz = cp->tz0;	/* new version parser */
-		volume_info->transform_format = cp->transform_format;
-		volume_info->encoding_format = cp->encoding_format;
-		volume_info->comp = volume->numcomps;
-		volume_info->layer = (&cp->tcps[0])->numlayers;
-		volume_info->decomposition[0] = (&cp->tcps[0])->tccps->numresolution[0] - 1;
-		volume_info->decomposition[1] = (&cp->tcps[0])->tccps->numresolution[1] - 1;
-		volume_info->decomposition[2] = (&cp->tcps[0])->tccps->numresolution[2] - 1;
-		volume_info->D_max = 0;		/* ADD Marcela */
-	}
-	/* << INDEX */
-
-	j3d_write_soc(j3d);
-	j3d_write_siz(j3d);
-	if (j3d->cinfo->codec_format == CODEC_J3D) {
-		j3d_write_cap(j3d);
-		j3d_write_zsi(j3d);
-	}
-	j3d_write_cod(j3d);
-	j3d_write_qcd(j3d);
-	for (compno = 0; compno < volume->numcomps; compno++) {
-		opj_tcp_t *tcp = &cp->tcps[0];
-		if (tcp->tccps[compno].roishift)
-			j3d_write_rgn(j3d, compno, 0);			
-	}
-	/*Optional 15444-2 markers*/
-	if (j3d->cp->tcps->tccps[0].atk != NULL)
-        j3d_write_atk(j3d);
-	if (j3d->volume->comps[0].dcoffset != 0)
-        j3d_write_dco(j3d);
-
-	if (j3d->cp->transform_format != TRF_2D_DWT || j3d->cp->encoding_format != ENCOD_2EB)
-		j3d_write_com(j3d);
-	
-	/* INDEX >> */
-	if(volume_info && volume_info->index_on) {
-		volume_info->main_head_end = cio_tell(cio) - 1;
-	}
-	/* << INDEX */
-
-	/* create the tile encoder */
-	tcd = tcd_create(j3d->cinfo);
-
-	/* encode each tile */
-	for (tileno = 0; tileno < cp->tw * cp->th * cp->tl; tileno++) {
-		opj_event_msg(j3d->cinfo, EVT_INFO, "tile number %d / %d\n", tileno + 1, cp->tw * cp->th * cp->tl);
-		
-		j3d->curtileno = tileno;
-
-		/* initialisation before tile encoding  */
-		if (tileno == 0) {	
-			tcd_malloc_encode(tcd, volume, cp, j3d->curtileno);
-		} else {
-			tcd_init_encode(tcd, volume, cp, j3d->curtileno);
-		}
-		
-		/* INDEX >> */
-		if(volume_info && volume_info->index_on) {
-			volume_info->tile[j3d->curtileno].num_tile = j3d->curtileno;
-			volume_info->tile[j3d->curtileno].start_pos = cio_tell(cio) + j3d->pos_correction;
-		}
-		/* << INDEX */
-		
-		j3d_write_sot(j3d);
-	
-		for (compno = 1; compno < volume->numcomps; compno++) {
-			j3d_write_coc(j3d, compno);
-			j3d_write_qcc(j3d, compno);
-		}
-
-		if (cp->tcps[tileno].numpocs) {
-			j3d_write_poc(j3d);
-		}
-		j3d_write_sod(j3d, tcd); //--> tcd_encode_tile
-
-		/* INDEX >> */
-		if(volume_info && volume_info->index_on) {
-			volume_info->tile[j3d->curtileno].end_pos = cio_tell(cio) + j3d->pos_correction - 1;
-		}
-		/* << INDEX */		
-	}
-	
-	/* destroy the tile encoder */
-	tcd_free_encode(tcd);
-	tcd_destroy(tcd);
-
-	j3d_write_eoc(j3d);
-	
-	/* Creation of the index file */
-	if(volume_info && volume_info->index_on) {
-		if(!j3d_create_index(j3d, cio, volume_info, index)) {
-			opj_event_msg(j3d->cinfo, EVT_ERROR, "failed to create index file %s\n", index);
-			return false;
-		}
-	}
-	  
-	return true;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.h
deleted file mode 100755
index d9dcc8e..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d.h
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __J3D_H
-#define __J3D_H
-/**
- at file j3d.h
- at brief The JPEG-2000 Codestream Reader/Writer (J3D)
-
-The functions in J3D.C have for goal to read/write the several parts of the codestream: markers and data.
-*/
-
-/** @defgroup J3D J3D - JPEG-2000 codestream reader/writer */
-/*@{*/
-
-#define J3D_CP_CSTY_PRT 0x01
-#define J3D_CP_CSTY_SOP 0x02
-#define J3D_CP_CSTY_EPH 0x04
-#define J3D_CCP_CSTY_PRT 0x01
-/** Table A-8 */
-#define J3D_CCP_CBLKSTY_LAZY 0x01	 /* Selective arithmetic coding bypass */
-#define J3D_CCP_CBLKSTY_RESET 0x02   /* Reset context probabilities on coding pass boundaries */
-#define J3D_CCP_CBLKSTY_TERMALL 0x04 /* Termination on each coding pass */
-#define J3D_CCP_CBLKSTY_VSC 0x08	 /* Vertically causal context, add also hook for switching off and on 3D context models */	
-#define J3D_CCP_CBLKSTY_PTERM 0x10	 /* Predictable termination */
-#define J3D_CCP_CBLKSTY_SEGSYM 0x20	 /* Segmentation symbols are used */
-#define J3D_CCP_CBLKSTY_3DCTXT 0x40  /* 3D context models (3D-EBCOT) vs 2D context models */
-
-#define J3D_CCP_QNTSTY_NOQNT 0	/* Quantization style : no quantization */
-#define J3D_CCP_QNTSTY_SIQNT 1	/* Quantization style : scalar derived (values signalled only in LLL subband) */
-#define J3D_CCP_QNTSTY_SEQNT 2	/* Quantization style : scalar expounded (values signalled for each subband) */
-
-/* ----------------------------------------------------------------------- */
-
-#define J3D_MS_SOC 0xff4f	/**< SOC marker value */
-#define J3D_MS_SOT 0xff90	/**< SOT marker value */
-#define J3D_MS_SOD 0xff93	/**< SOD marker value */
-#define J3D_MS_EOC 0xffd9	/**< EOC marker value */
-#define J3D_MS_CAP 0xff50	/**< CAP marker value */
-#define J3D_MS_SIZ 0xff51	/**< SIZ marker value */
-#define J3D_MS_ZSI 0xff54	/**< ZSI marker value */
-#define J3D_MS_COD 0xff52	/**< COD marker value */
-#define J3D_MS_COC 0xff53	/**< COC marker value */
-#define J3D_MS_RGN 0xff5e	/**< RGN marker value */
-#define J3D_MS_QCD 0xff5c	/**< QCD marker value */
-#define J3D_MS_QCC 0xff5d	/**< QCC marker value */
-#define J3D_MS_POC 0xff5f	/**< POC marker value */
-#define J3D_MS_TLM 0xff55	/**< TLM marker value */
-#define J3D_MS_PLM 0xff57	/**< PLM marker value */
-#define J3D_MS_PLT 0xff58	/**< PLT marker value */
-#define J3D_MS_PPM 0xff60	/**< PPM marker value */
-#define J3D_MS_PPT 0xff61	/**< PPT marker value */
-#define J3D_MS_SOP 0xff91	/**< SOP marker value */
-#define J3D_MS_EPH 0xff92	/**< EPH marker value */
-#define J3D_MS_CRG 0xff63	/**< CRG marker value */
-#define J3D_MS_COM 0xff64	/**< COM marker value */
-//15444-2
-#define J3D_MS_DCO 0xff70	/**< DCO marker value */
-#define J3D_MS_VMS 0xff71   /**< VMS marker value */
-#define J3D_MS_DFS 0xff72	/**< DFS marker value */
-#define J3D_MS_ADS 0xff73	/**< ADS marker value */
-#define J3D_MS_ATK 0xff79	/**< ATK marker value */
-#define J3D_MS_CBD 0xff78	/**< CBD marker value */
-#define J3D_MS_MCT 0xff74	/**< MCT marker value */
-#define J3D_MS_MCC 0xff75	/**< MCC marker value */
-#define J3D_MS_MCO 0xff77	/**< MCO marker value */
-#define J3D_MS_NLT 0xff76	/**< NLT marker value */
-#define J3D_MS_QPD 0xff5a	/**< QPD marker value */
-#define J3D_MS_QPC 0xff5b	/**< QPC marker value */
-
-/* ----------------------------------------------------------------------- */
-/* Capability RSIZ parameter, extended */
-#define J3D_RSIZ_BASIC 0x0000
-
-#define J3D_RSIZ_DCO   0x8001 /* Required */
-#define J3D_RSIZ_VSQNT 0x8002
-#define J3D_RSIZ_TCQNT 0x8004
-#define J3D_RSIZ_VMASK 0x8008
-#define J3D_RSIZ_SSOVL 0x8010
-#define J3D_RSIZ_ADECS 0x8020
-#define J3D_RSIZ_ATK   0x8040 /*Required*/
-#define J3D_RSIZ_SSYMK 0x8080
-#define J3D_RSIZ_MCT   0x8100 /*Not compatible with DCO*/
-#define J3D_RSIZ_NLT   0x8200 /*Required*/
-#define J3D_RSIZ_ASHAP 0x8400
-#define J3D_RSIZ_PRQNT 0x8800
-
-#define J3D_CAP_10		0x00400000
-/* Arbitrary transformation kernel, 15444-2 */
-#define J3D_ATK_IRR 0
-#define J3D_ATK_REV 1
-#define J3D_ATK_ARB 0
-#define J3D_ATK_WS 1
-#define J3D_ATK_CON 0
-/* ----------------------------------------------------------------------- */
-
-/**
-Values that specify the status of the decoding process when decoding the main header. 
-These values may be combined with a | operator. 
-*/
-typedef enum J3D_STATUS {
-	/**< a SOC marker is expected */
-	J3D_STATE_MHSOC  = 0x0001, 
-	/**< a SIZ marker is expected */
-	J3D_STATE_MHSIZ  = 0x0002, 
-	/**< the decoding process is in the main header */
-	J3D_STATE_MH     = 0x0004, 
-	/**< the decoding process is in a tile part header and expects a SOT marker */
-	J3D_STATE_TPHSOT = 0x0008, 
-	/**< the decoding process is in a tile part header */
-	J3D_STATE_TPH    = 0x0010, 
-	/**< the EOC marker has just been read */
-	J3D_STATE_MT     = 0x0020, 
-	/**< the decoding process must not expect a EOC marker because the codestream is truncated */
-	J3D_STATE_NEOC   = 0x0040  
-} J3D_STATUS;
-
-
-
-/**
-Arbitrary transformation kernel
-*/
-typedef struct opj_atk {
-/** index of wavelet kernel */
-	int index;
-/** Numerical type of scaling factor and lifting step parameters */
-	int coeff_typ;		
-/** Wavelet filter category */
-	int filt_cat;		
-/** Wavelet transformation type (REV/IRR) */
-	int wt_typ;			
-/** Initial odd/even subsequence */
-	int minit;			
-/** Boundary extension method (constant CON / whole-sample symmetric WS) */
-	int exten;			
-/** Scaling factor. Only for wt_typ=IRR */
-	double Katk;			
-/** Number of lifting steps */
-	int Natk;			
-/** Offset for lifting step s. Only for filt_cat=ARB */
-	int Oatk[256];		
-/** Base 2 scaling exponent for lifting step s. Only for wt_typ=REV */
-	int Eatk[256];		
-/** Additive residue for lifting step s. Only for wt_typ=REV */
-	int Batk[256];		
-/** Number of lifting coefficients signaled for lifting step s  */
-	int LCatk[256];	
-/** Lifting coefficient k for lifting step s */
-	double Aatk[256][256];	
-} opj_atk_t;
-
-
-/**
-Quantization stepsize
-*/
-typedef struct opj_stepsize {
-/** exponent */
-	int expn;	
-/** mantissa */
-	int mant;	
-} opj_stepsize_t;
-
-/**
-Tile-component coding parameters
-*/
-typedef struct opj_tccp {
-	/** coding style */
-	int csty;							
-	/** number of resolutions of x, y and z-axis */
-	int numresolution[3];	
-	/** code-blocks width height & depth*/
-	int cblk[3];			
-	/** code-block coding style */
-	int cblksty;			
-	/** 0: no ATK (only 9-7 or 5-3) 1: ATK defined WT*/
-	int atk_wt[3];				
-	/** Arbitrary transformation kernel (15444-2)*/
-	opj_atk_t *atk;			
-	/** DWT identifier for x, y and z-axis (0:WT9-7 1:WT5-3	>1:WT-atk->index) */
-	int dwtid[3];
-	/** reversible/irreversible wavelet transfomation (0:irrev 1:reversible)*/	
-	int reversible; 		
-	/** quantisation style */
-	int qntsty;				
-	/** stepsizes used for quantization */
-	opj_stepsize_t stepsizes[J3D_MAXBANDS];	
-	/** number of guard bits. Table A28 de 15444-1*/
-	int numgbits;			
-	/** Region Of Interest shift */
-	int roishift;			
-	/** precinct width heigth & depth*/
-	int prctsiz[3][J3D_MAXRLVLS];		
-} opj_tccp_t;
-
-/**
-Tile coding parameters : coding/decoding parameters common to all tiles 
-(information like COD, COC in main header)
-*/
-typedef struct opj_tcp {
-/** 1 : first part-tile of a tile */
-	int first;				
-	/** coding style */
-	int csty;				
-	/** progression order */
-	OPJ_PROG_ORDER prg;		
-	/** number of layers */
-	int numlayers;			
-	/** multi-component transform identifier */
-	int mct;				
-	/** rates of layers */
-	float rates[100];			
-	/** number of progression order changes */
-	int numpocs;			
-	/** indicates if a POC marker has been used O:NO, 1:YES */
-	int POC;				
-	/** progression order changes */
-	opj_poc_t pocs[J3D_MAXRLVLS - 1];
-	/** add fixed_quality */
-	float distoratio[100];
-	/** tile-component coding parameters */
-	opj_tccp_t *tccps;		
-/** packet header store there for futur use in t2_decode_packet */
-	unsigned char *ppt_data;		
-	/** pointer remaining on the first byte of the first header if ppt is used */
-	unsigned char *ppt_data_first;	
-	/** If ppt == 1 --> there was a PPT marker for the present tile */
-	int ppt;		
-	/** used in case of multiple marker PPT (number of info already stored) */
-	int ppt_store;	
-	int ppt_len;	
-} opj_tcp_t;
-
-/**
-Coding parameters
-*/
-typedef struct opj_cp {
-/** transform format 0: 2DWT, 1: 2D1P, 2: 3DWT, 3: 3RLS */
-	OPJ_TRANSFORM transform_format;		
-	/** entropy coding format 0: 2EB, 1: 3EB, 2: 2GR, 3: 3GR, 4: GRI*/
-	OPJ_ENTROPY_CODING encoding_format;	
-	/** allocation by rate/distortion */
-	int disto_alloc;	
-	/** allocation by fixed layer */
-	int fixed_alloc;	
-	/** add fixed_quality */
-	int fixed_quality;	
-	/** Rsiz: capabilities */
-	int rsiz;			
-	/** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, volume is decoded to the full resolution */
-	int reduce[3];		
-	/** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
-	int layer;			
-	/** 0 = no index || 1 = index */
-	int index_on;		
-	/** Big-Endian/Little-endian order */
-	int bigendian;
-	/** XTOsiz */
-	int tx0;	
-	/** YTOsiz */
-	int ty0;		
-	/** ZTOsiz */
-	int tz0;	
-	/** XTsiz */
-	int tdx;	
-	/** YTsiz */
-	int tdy;	
-	/** ZTsiz */
-	int tdz;	
-	/** comment for coding */
-	char *comment;		
-	/** number of tiles in width, heigth and depth */
-	int tw;		
-	int th;
-	int tl;
-	/** ID number of the tiles present in the codestream */
-	int *tileno;	
-	/** size of the vector tileno */
-	int tileno_size;
-	/** tile coding parameters */
-	opj_tcp_t *tcps;
-	/** fixed layer */
-	int *matrice;		
-
-	/** packet header store there for futur use in t2_decode_packet */
-	unsigned char *ppm_data;		
-	/** pointer remaining on the first byte of the first header if ppm is used */
-	unsigned char *ppm_data_first;	
-	/** if ppm == 1 --> there was a PPM marker for the present tile */
-	int ppm;			
-	/** use in case of multiple marker PPM (number of info already store) */
-	int ppm_store;		
-	/** use in case of multiple marker PPM (case on non-finished previous info) */
-	int ppm_previous;	
-	int ppm_len;		
-} opj_cp_t;
-
-/**
-Information concerning a packet inside tile
-*/
-typedef struct opj_packet_info {
-	/** start position */
-	int start_pos;	
-	/** end position */
-	int end_pos;	
-	/** distorsion introduced */
-	double disto;	
-} opj_packet_info_t;
-
-/**
-Index structure : information regarding tiles inside volume
-*/
-typedef struct opj_tile_info {
-	/** value of thresh for each layer by tile cfr. Marcela   */
-	double *thresh;		
-	/** number of tile */
-	int num_tile;		
-	/** start position */
-	int start_pos;		
-	/** end position of the header */
-	int end_header;		
-	/** end position */
-	int end_pos;		
-	/** precinct number for each resolution level (width, heigth and depth) */
-	int prctno[3][J3D_MAXRLVLS];	
-	/** precinct size (in power of 2), in X for each resolution level */
-	int prctsiz[3][J3D_MAXRLVLS];	
-	/** information concerning packets inside tile */
-	opj_packet_info_t *packet;		
-	
-	/** add fixed_quality */
-	int nbpix;			
-	/** add fixed_quality */
-	double distotile;	
-} opj_tile_info_t;
-
-/**
-Index structure
-*/
-typedef struct opj_volume_info {
-	
-	/** transform format 0: 2DWT, 1: 2D1P, 2: 3DWT, 3: 3RLS */
-	OPJ_TRANSFORM transform_format;		
-	/** output file format 0: 2EB, 1: 3EB, 2: 2GR, 3: 3GR, 4: GRI*/
-	OPJ_ENTROPY_CODING encoding_format;	/** 0 = no index || 1 = index */
-	int index_on;	
-	/** 0 = wt 9-7 || 1 = wt 5-3 || >=2 wt atk defined */
-	int dwtid[3];	
-	/** maximum distortion reduction on the whole volume (add for Marcela) */
-	double D_max;	
-	/** packet number */
-	int num;		
-	/** writing the packet in the index with t2_encode_packets */
-	int index_write;	
-	/** volume width, height and depth */
-	int volume_w;	
-	int volume_h;
-	int volume_l;
-	/** progression order */
-	OPJ_PROG_ORDER prog;	
-	/** tile size in x, y and z */
-	int tile_x;		
-	int tile_y;
-	int tile_z;
-	/** tile origin in x, y and z */
-	int tile_Ox;	
-	int tile_Oy;
-	int tile_Oz;
-	/** number of tiles in X, Y and Z */
-	int tw;			
-	int th;
-	int tl;
-	/** component numbers */
-	int comp;				
-	/** number of layer */
-	int layer;				
-	/** number of decomposition in X, Y and Z*/
-	int decomposition[3];	
-	/** DC offset (15444-2) */
-	int dcoffset;	
-	/** main header position */
-	int main_head_end;		
-	/** codestream's size */
-	int codestream_size;	
-	/** information regarding tiles inside volume */
-	opj_tile_info_t *tile;	
-} opj_volume_info_t;
-
-/**
-JPEG-2000 codestream reader/writer
-*/
-typedef struct opj_j3d {
-	/** codec context */
-	opj_common_ptr cinfo;	
-	/** locate in which part of the codestream the decoder is (main header, tile header, end) */
-	int state;				
-	/** number of the tile curently concern by coding/decoding */
-	int curtileno;			
-	/** locate the position of the end of the tile in the codestream, used to detect a truncated codestream (in j3d_read_sod)	*/
-	unsigned char *eot;	
-	/**	locate the start position of the SOT marker of the current coded tile:  */
-	int sot_start;		
-	/*  after encoding the tile, a jump (in j3d_write_sod) is done to the SOT marker to store the value of its length. */
-	int sod_start;		
-	/**	as the J3D-file is written in several parts during encoding, it enables to make the right correction in position return by cio_tell	*/
-	int pos_correction;	
-	/** array used to store the data of each tile */
-	unsigned char **tile_data;	
-	/** array used to store the length of each tile */
-	int *tile_len;				
-
-	/** decompression only : store decoding parameters common to all tiles */
-	opj_tcp_t *default_tcp;		
-	/** pointer to the encoded / decoded volume */
-	opj_volume_t *volume;		
-	/** pointer to the coding parameters */
-	opj_cp_t *cp;				
-	/** helper used to write the index file */
-	opj_volume_info_t *volume_info;	
-	/** pointer to the byte i/o stream */
-    opj_cio_t *cio;						
-} opj_j3d_t;
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Creates a J3D decompression structure
- at param cinfo Codec context info
- at return Returns a handle to a J3D decompressor if successful, returns NULL otherwise
-*/
-opj_j3d_t* j3d_create_decompress(opj_common_ptr cinfo);
-/**
-Destroy a J3D decompressor handle
- at param j3d J3D decompressor handle to destroy
-*/
-void j3d_destroy_decompress(opj_j3d_t *j3d);
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in j3d->cp. 
- at param j3d J3D decompressor handle
- at param parameters decompression parameters
-*/
-void j3d_setup_decoder(opj_j3d_t *j3d, opj_dparameters_t *parameters);
-/**
-Decode an volume from a JPEG-2000 codestream
- at param j3d J3D decompressor handle
- at param cio Input buffer stream
- at return Returns a decoded volume if successful, returns NULL otherwise
-*/
-opj_volume_t* j3d_decode(opj_j3d_t *j3d, opj_cio_t *cio);
-/**
-Decode an volume form a JPT-stream (JPEG 2000, JPIP)
- at param j3d J3D decompressor handle
- at param cio Input buffer stream
- at return Returns a decoded volume if successful, returns NULL otherwise
-*/
-opj_volume_t* j3d_decode_jpt_stream(opj_j3d_t *j3d, opj_cio_t *cio);
-/**
-Creates a J3D compression structure
- at param cinfo Codec context info
- at return Returns a handle to a J3D compressor if successful, returns NULL otherwise
-*/
-opj_j3d_t* j3d_create_compress(opj_common_ptr cinfo);
-/**
-Destroy a J3D compressor handle
- at param j3d J3D compressor handle to destroy
-*/
-void j3d_destroy_compress(opj_j3d_t *j3d);
-/**
-Setup the encoder parameters using the current volume and using user parameters. 
-Coding parameters are returned in j3d->cp. 
- at param j3d J3D compressor handle
- at param parameters compression parameters
- at param volume input filled volume
-*/
-void j3d_setup_encoder(opj_j3d_t *j3d, opj_cparameters_t *parameters, opj_volume_t *volume);
-/**
-Encode an volume into a JPEG-2000 codestream
- at param j3d J3D compressor handle
- at param cio Output buffer stream
- at param volume Volume to encode
- at param index Name of the index file if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-bool j3d_encode(opj_j3d_t *j3d, opj_cio_t *cio, opj_volume_t *volume, char *index);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __J3D_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d_lib.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d_lib.c
deleted file mode 100755
index b230399..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d_lib.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/times.h>
-#endif /* _WIN32 */
-#include "opj_includes.h"
-
-double opj_clock() {
-#ifdef _WIN32
-	/* WIN32: use QueryPerformance (very accurate) */
-    LARGE_INTEGER freq , t ;
-    /* freq is the clock speed of the CPU */
-    QueryPerformanceFrequency(&freq) ;
-	/* cout << "freq = " << ((double) freq.QuadPart) << endl; */
-    /* t is the high resolution performance counter (see MSDN) */
-    QueryPerformanceCounter ( & t ) ;
-    return ( t.QuadPart /(double) freq.QuadPart ) ;
-#else
-	/* Unix or Linux: use resource usage */
-    struct rusage t;
-    double procTime;
-    /* (1) Get the rusage data structure at this moment (man getrusage) */
-    getrusage(0,&t);
-    /* (2) What is the elapsed time ? - CPU time = User time + System time */
-	/* (2a) Get the seconds */
-    procTime = t.ru_utime.tv_sec + t.ru_stime.tv_sec;
-    /* (2b) More precisely! Get the microseconds part ! */
-    return ( procTime + (t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
-#endif /* _WIN32 */
-}
-
-void* opj_malloc( size_t size ) {
-	void *memblock = malloc(size);
-	if(memblock) {
-		memset(memblock, 0, size);
-	}
-	return memblock;
-}
-
-void* opj_realloc( void *memblock, size_t size ) {
-	return realloc(memblock, size);
-}
-
-void opj_free( void *memblock ) {
-	free(memblock);
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.c
deleted file mode 100755
index be4b875..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* <summary> */
-/* This table contains the norms of the basis function of the reversible MCT. */
-/* </summary> */
-static const double mct_norms[3] = { 1.732, .8292, .8292 };
-
-/* <summary> */
-/* This table contains the norms of the basis function of the irreversible MCT. */
-/* </summary> */
-static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
-
-/* <summary> */
-/* Foward reversible MCT. */
-/* </summary> */
-void mct_encode(int *c0, int *c1, int *c2, int n) {
-	int i;
-	for (i = 0; i < n; i++) {
-		int r, g, b, y, u, v;
-		r = c0[i];
-		g = c1[i];
-		b = c2[i];
-		y = (r + (g << 1) + b) >> 2;
-		u = b - g;
-		v = r - g;
-		c0[i] = y;
-		c1[i] = u;
-		c2[i] = v;
-	}
-}
-
-/* <summary> */
-/* Inverse reversible MCT. */
-/* </summary> */
-void mct_decode(int *c0, int *c1, int *c2, int n) {
-	int i;
-	for (i = 0; i < n; i++) {
-		int y, u, v, r, g, b;
-		y = c0[i];
-		u = c1[i];
-		v = c2[i];
-		g = y - ((u + v) >> 2);
-		r = v + g;
-		b = u + g;
-		c0[i] = r;
-		c1[i] = g;
-		c2[i] = b;
-	}
-}
-
-/* <summary> */
-/* Get norm of basis function of reversible MCT. */
-/* </summary> */
-double mct_getnorm(int compno) {
-	return mct_norms[compno];
-}
-
-/* <summary> */
-/* Foward irreversible MCT. */
-/* </summary> */
-void mct_encode_real(int *c0, int *c1, int *c2, int n) {
-	int i;
-	for (i = 0; i < n; i++) {
-		int r, g, b, y, u, v;
-		r = c0[i];
-		g = c1[i];
-		b = c2[i];
-		y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
-		u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
-		v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
-		c0[i] = y;
-		c1[i] = u;
-		c2[i] = v;
-	}
-}
-
-/* <summary> */
-/* Inverse irreversible MCT. */
-/* </summary> */
-void mct_decode_real(int *c0, int *c1, int *c2, int n) {
-	int i;
-	for (i = 0; i < n; i++) {
-		int y, u, v, r, g, b;
-		y = c0[i];
-		u = c1[i];
-		v = c2[i];
-		r = y + fix_mul(v, 11485);
-		g = y - fix_mul(u, 2819) - fix_mul(v, 5850);
-		b = y + fix_mul(u, 14516);
-		c0[i] = r;
-		c1[i] = g;
-		c2[i] = b;
-	}
-}
-
-/* <summary> */
-/* Get norm of basis function of irreversible MCT. */
-/* </summary> */
-double mct_getnorm_real(int compno) {
-	return mct_norms_real[compno];
-}
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.h
deleted file mode 100755
index 81513f7..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mct.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MCT_H
-#define __MCT_H
-/**
- at file mct.h
- at brief Implementation of a multi-component transforms (MCT)
-
-The functions in MCT.C have for goal to realize reversible and irreversible multicomponent
-transform. The functions in MCT.C are used by some function in TCD.C.
-*/
-
-/** @defgroup MCT MCT - Implementation of a multi-component transform */
-/*@{*/
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Apply a reversible multi-component transform to an image
- at param c0 Samples for red component
- at param c1 Samples for green component
- at param c2 Samples blue component
- at param n Number of samples for each component
-*/
-void mct_encode(int *c0, int *c1, int *c2, int n);
-/**
-Apply a reversible multi-component inverse transform to an image
- at param c0 Samples for luminance component
- at param c1 Samples for red chrominance component
- at param c2 Samples for blue chrominance component
- at param n Number of samples for each component
-*/
-void mct_decode(int *c0, int *c1, int *c2, int n);
-/**
-Get norm of the basis function used for the reversible multi-component transform
- at param compno Number of the component (0->Y, 1->U, 2->V)
- at return 
-*/
-double mct_getnorm(int compno);
-
-/**
-Apply an irreversible multi-component transform to an image
- at param c0 Samples for red component
- at param c1 Samples for green component
- at param c2 Samples blue component
- at param n Number of samples for each component
-*/
-void mct_encode_real(int *c0, int *c1, int *c2, int n);
-/**
-Apply an irreversible multi-component inverse transform to an image
- at param c0 Samples for luminance component
- at param c1 Samples for red chrominance component
- at param c2 Samples for blue chrominance component
- at param n Number of samples for each component
-*/
-void mct_decode_real(int *c0, int *c1, int *c2, int n);
-/**
-Get norm of the basis function used for the irreversible multi-component transform
- at param compno Number of the component (0->Y, 1->U, 2->V)
- at return 
-*/
-double mct_getnorm_real(int compno);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __MCT_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.c
deleted file mode 100755
index 4117bf1..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup MQC MQC - Implementation of an MQ-Coder */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Output a byte, doing bit-stuffing if necessary.
-After a 0xff byte, the next byte must be smaller than 0x90.
- at param mqc MQC handle
-*/
-static void mqc_byteout(opj_mqc_t *mqc);
-/**
-Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000
- at param mqc MQC handle
-*/
-static void mqc_renorme(opj_mqc_t *mqc);
-/**
-Encode the most probable symbol
- at param mqc MQC handle
-*/
-static void mqc_codemps(opj_mqc_t *mqc);
-/**
-Encode the most least symbol
- at param mqc MQC handle
-*/
-static void mqc_codelps(opj_mqc_t *mqc);
-/**
-Fill mqc->c with 1's for flushing
- at param mqc MQC handle
-*/
-static void mqc_setbits(opj_mqc_t *mqc);
-/**
-Exchange MPS with LPS
- at param mqc MQC handle
- at return 
-*/
-static int mqc_mpsexchange(opj_mqc_t *mqc);
-/**
-Exchange LPS with MPS
- at param mqc MQC handle
- at return 
-*/
-static int mqc_lpsexchange(opj_mqc_t *mqc);
-/**
-Input a byte
- at param mqc MQC handle
-*/
-static void mqc_bytein(opj_mqc_t *mqc);
-/**
-Renormalize mqc->a and mqc->c while decoding
- at param mqc MQC handle
-*/
-static void mqc_renormd(opj_mqc_t *mqc);
-
-/*@}*/
-
-/*@}*/
-
-/* <summary> */
-/* This array defines all the possible states for a context. */
-/* </summary> */
-static opj_mqc_state_t mqc_states[47 * 2] = {
-	{0x5601, 0, &mqc_states[2], &mqc_states[3]},
-	{0x5601, 1, &mqc_states[3], &mqc_states[2]},
-	{0x3401, 0, &mqc_states[4], &mqc_states[12]},
-	{0x3401, 1, &mqc_states[5], &mqc_states[13]},
-	{0x1801, 0, &mqc_states[6], &mqc_states[18]},
-	{0x1801, 1, &mqc_states[7], &mqc_states[19]},
-	{0x0ac1, 0, &mqc_states[8], &mqc_states[24]},
-	{0x0ac1, 1, &mqc_states[9], &mqc_states[25]},
-	{0x0521, 0, &mqc_states[10], &mqc_states[58]},
-	{0x0521, 1, &mqc_states[11], &mqc_states[59]},
-	{0x0221, 0, &mqc_states[76], &mqc_states[66]},
-	{0x0221, 1, &mqc_states[77], &mqc_states[67]},
-	{0x5601, 0, &mqc_states[14], &mqc_states[13]},
-	{0x5601, 1, &mqc_states[15], &mqc_states[12]},
-	{0x5401, 0, &mqc_states[16], &mqc_states[28]},
-	{0x5401, 1, &mqc_states[17], &mqc_states[29]},
-	{0x4801, 0, &mqc_states[18], &mqc_states[28]},
-	{0x4801, 1, &mqc_states[19], &mqc_states[29]},
-	{0x3801, 0, &mqc_states[20], &mqc_states[28]},
-	{0x3801, 1, &mqc_states[21], &mqc_states[29]},
-	{0x3001, 0, &mqc_states[22], &mqc_states[34]},
-	{0x3001, 1, &mqc_states[23], &mqc_states[35]},
-	{0x2401, 0, &mqc_states[24], &mqc_states[36]},
-	{0x2401, 1, &mqc_states[25], &mqc_states[37]},
-	{0x1c01, 0, &mqc_states[26], &mqc_states[40]},
-	{0x1c01, 1, &mqc_states[27], &mqc_states[41]},
-	{0x1601, 0, &mqc_states[58], &mqc_states[42]},
-	{0x1601, 1, &mqc_states[59], &mqc_states[43]},
-	{0x5601, 0, &mqc_states[30], &mqc_states[29]},
-	{0x5601, 1, &mqc_states[31], &mqc_states[28]},
-	{0x5401, 0, &mqc_states[32], &mqc_states[28]},
-	{0x5401, 1, &mqc_states[33], &mqc_states[29]},
-	{0x5101, 0, &mqc_states[34], &mqc_states[30]},
-	{0x5101, 1, &mqc_states[35], &mqc_states[31]},
-	{0x4801, 0, &mqc_states[36], &mqc_states[32]},
-	{0x4801, 1, &mqc_states[37], &mqc_states[33]},
-	{0x3801, 0, &mqc_states[38], &mqc_states[34]},
-	{0x3801, 1, &mqc_states[39], &mqc_states[35]},
-	{0x3401, 0, &mqc_states[40], &mqc_states[36]},
-	{0x3401, 1, &mqc_states[41], &mqc_states[37]},
-	{0x3001, 0, &mqc_states[42], &mqc_states[38]},
-	{0x3001, 1, &mqc_states[43], &mqc_states[39]},
-	{0x2801, 0, &mqc_states[44], &mqc_states[38]},
-	{0x2801, 1, &mqc_states[45], &mqc_states[39]},
-	{0x2401, 0, &mqc_states[46], &mqc_states[40]},
-	{0x2401, 1, &mqc_states[47], &mqc_states[41]},
-	{0x2201, 0, &mqc_states[48], &mqc_states[42]},
-	{0x2201, 1, &mqc_states[49], &mqc_states[43]},
-	{0x1c01, 0, &mqc_states[50], &mqc_states[44]},
-	{0x1c01, 1, &mqc_states[51], &mqc_states[45]},
-	{0x1801, 0, &mqc_states[52], &mqc_states[46]},
-	{0x1801, 1, &mqc_states[53], &mqc_states[47]},
-	{0x1601, 0, &mqc_states[54], &mqc_states[48]},
-	{0x1601, 1, &mqc_states[55], &mqc_states[49]},
-	{0x1401, 0, &mqc_states[56], &mqc_states[50]},
-	{0x1401, 1, &mqc_states[57], &mqc_states[51]},
-	{0x1201, 0, &mqc_states[58], &mqc_states[52]},
-	{0x1201, 1, &mqc_states[59], &mqc_states[53]},
-	{0x1101, 0, &mqc_states[60], &mqc_states[54]},
-	{0x1101, 1, &mqc_states[61], &mqc_states[55]},
-	{0x0ac1, 0, &mqc_states[62], &mqc_states[56]},
-	{0x0ac1, 1, &mqc_states[63], &mqc_states[57]},
-	{0x09c1, 0, &mqc_states[64], &mqc_states[58]},
-	{0x09c1, 1, &mqc_states[65], &mqc_states[59]},
-	{0x08a1, 0, &mqc_states[66], &mqc_states[60]},
-	{0x08a1, 1, &mqc_states[67], &mqc_states[61]},
-	{0x0521, 0, &mqc_states[68], &mqc_states[62]},
-	{0x0521, 1, &mqc_states[69], &mqc_states[63]},
-	{0x0441, 0, &mqc_states[70], &mqc_states[64]},
-	{0x0441, 1, &mqc_states[71], &mqc_states[65]},
-	{0x02a1, 0, &mqc_states[72], &mqc_states[66]},
-	{0x02a1, 1, &mqc_states[73], &mqc_states[67]},
-	{0x0221, 0, &mqc_states[74], &mqc_states[68]},
-	{0x0221, 1, &mqc_states[75], &mqc_states[69]},
-	{0x0141, 0, &mqc_states[76], &mqc_states[70]},
-	{0x0141, 1, &mqc_states[77], &mqc_states[71]},
-	{0x0111, 0, &mqc_states[78], &mqc_states[72]},
-	{0x0111, 1, &mqc_states[79], &mqc_states[73]},
-	{0x0085, 0, &mqc_states[80], &mqc_states[74]},
-	{0x0085, 1, &mqc_states[81], &mqc_states[75]},
-	{0x0049, 0, &mqc_states[82], &mqc_states[76]},
-	{0x0049, 1, &mqc_states[83], &mqc_states[77]},
-	{0x0025, 0, &mqc_states[84], &mqc_states[78]},
-	{0x0025, 1, &mqc_states[85], &mqc_states[79]},
-	{0x0015, 0, &mqc_states[86], &mqc_states[80]},
-	{0x0015, 1, &mqc_states[87], &mqc_states[81]},
-	{0x0009, 0, &mqc_states[88], &mqc_states[82]},
-	{0x0009, 1, &mqc_states[89], &mqc_states[83]},
-	{0x0005, 0, &mqc_states[90], &mqc_states[84]},
-	{0x0005, 1, &mqc_states[91], &mqc_states[85]},
-	{0x0001, 0, &mqc_states[90], &mqc_states[86]},
-	{0x0001, 1, &mqc_states[91], &mqc_states[87]},
-	{0x5601, 0, &mqc_states[92], &mqc_states[92]},
-	{0x5601, 1, &mqc_states[93], &mqc_states[93]},
-};
-
-/* 
-==========================================================
-   local functions
-==========================================================
-*/
-
-static void mqc_byteout(opj_mqc_t *mqc) {
-	if (*mqc->bp == 0xff) {
-		mqc->bp++;
-		*mqc->bp = mqc->c >> 20;
-		mqc->c &= 0xfffff;
-		mqc->ct = 7;
-	} else {
-		if ((mqc->c & 0x8000000) == 0) {	/* ((mqc->c&0x8000000)==0) CHANGE */
-			mqc->bp++;
-			*mqc->bp = mqc->c >> 19;
-			mqc->c &= 0x7ffff;
-			mqc->ct = 8;
-		} else {
-			(*mqc->bp)++;
-			if (*mqc->bp == 0xff) {
-				mqc->c &= 0x7ffffff;
-				mqc->bp++;
-				*mqc->bp = mqc->c >> 20;
-				mqc->c &= 0xfffff;
-				mqc->ct = 7;
-			} else {
-				mqc->bp++;
-				*mqc->bp = mqc->c >> 19;
-				mqc->c &= 0x7ffff;
-				mqc->ct = 8;
-			}
-		}
-	}
-}
-
-static void mqc_renorme(opj_mqc_t *mqc) {
-	do {
-		mqc->a <<= 1;
-		mqc->c <<= 1;
-		mqc->ct--;
-		if (mqc->ct == 0) {
-			mqc_byteout(mqc);
-		}
-	} while ((mqc->a & 0x8000) == 0);
-}
-
-static void mqc_codemps(opj_mqc_t *mqc) {
-	mqc->a -= (*mqc->curctx)->qeval;
-	if ((mqc->a & 0x8000) == 0) {
-		if (mqc->a < (*mqc->curctx)->qeval) {
-			mqc->a = (*mqc->curctx)->qeval;
-		} else {
-			mqc->c += (*mqc->curctx)->qeval;
-		}
-		*mqc->curctx = (*mqc->curctx)->nmps;
-		mqc_renorme(mqc);
-	} else {
-		mqc->c += (*mqc->curctx)->qeval;
-	}
-}
-
-static void mqc_codelps(opj_mqc_t *mqc) {
-	mqc->a -= (*mqc->curctx)->qeval;
-	if (mqc->a < (*mqc->curctx)->qeval) {
-		mqc->c += (*mqc->curctx)->qeval;
-	} else {
-		mqc->a = (*mqc->curctx)->qeval;
-	}
-	*mqc->curctx = (*mqc->curctx)->nlps;
-	mqc_renorme(mqc);
-}
-
-static void mqc_setbits(opj_mqc_t *mqc) {
-	unsigned int tempc = mqc->c + mqc->a;
-	mqc->c |= 0xffff;
-	if (mqc->c >= tempc) {
-		mqc->c -= 0x8000;
-	}
-}
-
-static int mqc_mpsexchange(opj_mqc_t *mqc) {
-	int d;
-	if (mqc->a < (*mqc->curctx)->qeval) {
-		d = 1 - (*mqc->curctx)->mps;
-		*mqc->curctx = (*mqc->curctx)->nlps;
-	} else {
-		d = (*mqc->curctx)->mps;
-		*mqc->curctx = (*mqc->curctx)->nmps;
-	}
-	
-	return d;
-}
-
-static int mqc_lpsexchange(opj_mqc_t *mqc) {
-	int d;
-	if (mqc->a < (*mqc->curctx)->qeval) {
-		mqc->a = (*mqc->curctx)->qeval;
-		d = (*mqc->curctx)->mps;
-		*mqc->curctx = (*mqc->curctx)->nmps;
-	} else {
-		mqc->a = (*mqc->curctx)->qeval;
-		d = 1 - (*mqc->curctx)->mps;
-		*mqc->curctx = (*mqc->curctx)->nlps;
-	}
-	
-	return d;
-}
-
-static void mqc_bytein(opj_mqc_t *mqc) {
-	if (mqc->bp != mqc->end) {
-		unsigned int c;
-		if (mqc->bp + 1 != mqc->end) {
-			c = *(mqc->bp + 1);
-		} else {
-			c = 0xff;
-		}
-		if (*mqc->bp == 0xff) {
-			if (c > 0x8f) {
-				mqc->c += 0xff00;
-				mqc->ct = 8;
-			} else {
-				mqc->bp++;
-				mqc->c += c << 9;
-				mqc->ct = 7;
-			}
-		} else {
-			mqc->bp++;
-			mqc->c += c << 8;
-			mqc->ct = 8;
-		}
-	} else {
-		mqc->c += 0xff00;
-		mqc->ct = 8;
-	}
-}
-
-static void mqc_renormd(opj_mqc_t *mqc) {
-	do {
-		if (mqc->ct == 0) {
-			mqc_bytein(mqc);
-		}
-		mqc->a <<= 1;
-		mqc->c <<= 1;
-		mqc->ct--;
-	} while (mqc->a < 0x8000);
-}
-
-/* 
-==========================================================
-   MQ-Coder interface
-==========================================================
-*/
-
-opj_mqc_t* mqc_create() {
-	opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
-	return mqc;
-}
-
-void mqc_destroy(opj_mqc_t *mqc) {
-	if(mqc) {
-		opj_free(mqc);
-	}
-}
-
-int mqc_numbytes(opj_mqc_t *mqc) {
-	return mqc->bp - mqc->start;
-}
-
-void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp) {
-	mqc_setcurctx(mqc, 0);
-	mqc->a = 0x8000;
-	mqc->c = 0;
-	mqc->bp = bp - 1;
-	mqc->ct = 12;
-	if (*mqc->bp == 0xff) {
-		mqc->ct = 13;
-	}
-	mqc->start = bp;
-}
-
-void mqc_setcurctx(opj_mqc_t *mqc, int ctxno) {
-	mqc->curctx = &mqc->ctxs[ctxno];
-}
-
-void mqc_encode(opj_mqc_t *mqc, int d) {
-	if ((*mqc->curctx)->mps == d) {
-		mqc_codemps(mqc);
-	} else {
-		mqc_codelps(mqc);
-	}
-}
-
-void mqc_flush(opj_mqc_t *mqc) {
-	mqc_setbits(mqc);
-	mqc->c <<= mqc->ct;
-	mqc_byteout(mqc);
-	mqc->c <<= mqc->ct;
-	mqc_byteout(mqc);
-	
-	if (*mqc->bp != 0xff) {
-		mqc->bp++;
-	}
-}
-
-void mqc_bypass_init_enc(opj_mqc_t *mqc) {
-	mqc->c = 0;
-	mqc->ct = 8;
-	/*if (*mqc->bp == 0xff) {
-	mqc->ct = 7;
-     } */
-}
-
-void mqc_bypass_enc(opj_mqc_t *mqc, int d) {
-	mqc->ct--;
-	mqc->c = mqc->c + (d << mqc->ct);
-	if (mqc->ct == 0) {
-		mqc->bp++;
-		*mqc->bp = mqc->c;
-		mqc->ct = 8;
-		if (*mqc->bp == 0xff) {
-			mqc->ct = 7;
-		}
-		mqc->c = 0;
-	}
-}
-
-int mqc_bypass_flush_enc(opj_mqc_t *mqc) {
-	unsigned char bit_padding;
-	
-	bit_padding = 0;
-	
-	if (mqc->ct != 0) {
-		while (mqc->ct > 0) {
-			mqc->ct--;
-			mqc->c += bit_padding << mqc->ct;
-			bit_padding = (bit_padding + 1) & 0x01;
-		}
-		mqc->bp++;
-		*mqc->bp = mqc->c;
-		mqc->ct = 8;
-		mqc->c = 0;
-	}
-	
-	return 1;
-}
-
-void mqc_reset_enc(opj_mqc_t *mqc) {
-	mqc_resetstates(mqc);
-	mqc_setstate(mqc, 18, 0, 46);
-	mqc_setstate(mqc, 0, 0, 3);
-	mqc_setstate(mqc, 1, 0, 4);
-}
-
-void mqc_reset_enc_3(opj_mqc_t *mqc) {
-	mqc_resetstates(mqc);
-	mqc_setstate(mqc, T1_3D_CTXNO_UNI, 0, 46);
-	mqc_setstate(mqc, T1_3D_CTXNO_AGG, 0, 3);
-	mqc_setstate(mqc, T1_3D_CTXNO_ZC, 0, 4);
-}
-
-int mqc_restart_enc(opj_mqc_t *mqc) {
-	int correction = 1;
-	
-	/* <flush part> */
-	int n = 27 - 15 - mqc->ct;
-	mqc->c <<= mqc->ct;
-	while (n > 0) {
-		mqc_byteout(mqc);
-		n -= mqc->ct;
-		mqc->c <<= mqc->ct;
-	}
-	mqc_byteout(mqc);
-	
-	return correction;
-}
-
-void mqc_restart_init_enc(opj_mqc_t *mqc) {
-	/* <Re-init part> */
-	mqc_setcurctx(mqc, 0);
-	mqc->a = 0x8000;
-	mqc->c = 0;
-	mqc->ct = 12;
-	mqc->bp--;
-	if (*mqc->bp == 0xff) {
-		mqc->ct = 13;
-	}
-}
-
-void mqc_erterm_enc(opj_mqc_t *mqc) {
-	int k = 11 - mqc->ct + 1;
-	
-	while (k > 0) {
-		mqc->c <<= mqc->ct;
-		mqc->ct = 0;
-		mqc_byteout(mqc);
-		k -= mqc->ct;
-	}
-	
-	if (*mqc->bp != 0xff) {
-		mqc_byteout(mqc);
-	}
-}
-
-void mqc_segmark_enc(opj_mqc_t *mqc) {
-	int i;
-	mqc_setcurctx(mqc, 18);
-	
-	for (i = 1; i < 5; i++) {
-		mqc_encode(mqc, i % 2);
-	}
-}
-
-void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) {
-	mqc_setcurctx(mqc, 0);
-	mqc->start = bp;
-	mqc->end = bp + len;
-	mqc->bp = bp;
-	if (len==0) mqc->c = 0xff << 16;
-	else mqc->c = *mqc->bp << 16;
-	mqc_bytein(mqc);
-	mqc->c <<= 7;
-	mqc->ct -= 7;
-	mqc->a = 0x8000;
-}
-
-int mqc_decode(opj_mqc_t *mqc) {
-	int d;
-	mqc->a -= (*mqc->curctx)->qeval;
-	if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
-		d = mqc_lpsexchange(mqc);
-		mqc_renormd(mqc);
-	} else {
-		mqc->c -= (*mqc->curctx)->qeval << 16;
-		if ((mqc->a & 0x8000) == 0) {
-			d = mqc_mpsexchange(mqc);
-			mqc_renormd(mqc);
-		} else {
-			d = (*mqc->curctx)->mps;
-		}
-	}
-
-	return d;
-}
-
-void mqc_resetstates(opj_mqc_t *mqc) {
-	int i;
-	for (i = 0; i < MQC_NUMCTXS; i++) {
-		mqc->ctxs[i] = mqc_states;
-	}
-}
-
-void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob) {
-	mqc->ctxs[ctxno] = &mqc_states[msb + (prob << 1)];
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.h
deleted file mode 100755
index 67cfc00..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/mqc.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MQC_H
-#define __MQC_H
-/**
- at file mqc.h
- at brief Implementation of an MQ-Coder (MQC)
-
-The functions in MQC.C have for goal to realize the MQ-coder operations. The functions
-in MQC.C are used by some function in T1.C.
-*/
-
-/** @defgroup MQC MQC - Implementation of an MQ-Coder */
-/*@{*/
-
-/**
-This struct defines the state of a context.
-*/
-typedef struct opj_mqc_state {
-	/** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */
-	unsigned int qeval;
-	/** the Most Probable Symbol (0 or 1) */
-	int mps;
-	/** next state if the next encoded symbol is the MPS */
-	struct opj_mqc_state *nmps;
-	/** next state if the next encoded symbol is the LPS */
-	struct opj_mqc_state *nlps;
-} opj_mqc_state_t;
-
-#define MQC_NUMCTXS 32
-
-/**
-MQ coder
-*/
-typedef struct opj_mqc {
-	unsigned int c;
-	unsigned int a;
-	unsigned int ct;
-	unsigned char *bp;
-	unsigned char *start;
-	unsigned char *end;
-	opj_mqc_state_t *ctxs[MQC_NUMCTXS];
-	opj_mqc_state_t **curctx;
-} opj_mqc_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new MQC handle 
- at return Returns a new MQC handle if successful, returns NULL otherwise
-*/
-opj_mqc_t* mqc_create();
-/**
-Destroy a previously created MQC handle
- at param mqc MQC handle to destroy
-*/
-void mqc_destroy(opj_mqc_t *mqc);
-/**
-Return the number of bytes written/read since initialisation
- at param mqc MQC handle
- at return Returns the number of bytes already encoded
-*/
-int mqc_numbytes(opj_mqc_t *mqc);
-/**
-Reset the states of all the context of the coder/decoder 
-(each context is set to a state where 0 and 1 are more or less equiprobable)
- at param mqc MQC handle
-*/
-void mqc_resetstates(opj_mqc_t *mqc);
-/**
-Set the state of a particular context
- at param mqc MQC handle
- at param ctxno Number that identifies the context
- at param msb The MSB of the new state of the context
- at param prob Number that identifies the probability of the symbols for the new state of the context
-*/
-void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob);
-/**
-Initialize the encoder
- at param mqc MQC handle
- at param bp Pointer to the start of the buffer where the bytes will be written
-*/
-void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp);
-/**
-Set the current context used for coding/decoding
- at param mqc MQC handle
- at param ctxno Number that identifies the context
-*/
-void mqc_setcurctx(opj_mqc_t *mqc, int ctxno);
-/**
-Encode a symbol using the MQ-coder
- at param mqc MQC handle
- at param d The symbol to be encoded (0 or 1)
-*/
-void mqc_encode(opj_mqc_t *mqc, int d);
-/**
-Flush the encoder, so that all remaining data is written
- at param mqc MQC handle
-*/
-void mqc_flush(opj_mqc_t *mqc);
-/**
-BYPASS mode switch, initialization operation. 
-JPEG 2000 p 505. 
-<h2>Not fully implemented and tested !!</h2>
- at param mqc MQC handle
-*/
-void mqc_bypass_init_enc(opj_mqc_t *mqc);
-/**
-BYPASS mode switch, coding operation. 
-JPEG 2000 p 505. 
-<h2>Not fully implemented and tested !!</h2>
- at param mqc MQC handle
- at param d The symbol to be encoded (0 or 1)
-*/
-void mqc_bypass_enc(opj_mqc_t *mqc, int d);
-/**
-BYPASS mode switch, flush operation
-<h2>Not fully implemented and tested !!</h2>
- at param mqc MQC handle
- at return Returns 1 (always)
-*/
-int mqc_bypass_flush_enc(opj_mqc_t *mqc);
-/**
-RESET mode switch
- at param mqc MQC handle
-*/
-void mqc_reset_enc(opj_mqc_t *mqc);
-/**
-RESET mode switch
- at param mqc MQC handle
-*/
-void mqc_reset_enc_3(opj_mqc_t *mqc);
-/**
-RESTART mode switch (TERMALL)
- at param mqc MQC handle
- at return Returns 1 (always)
-*/
-int mqc_restart_enc(opj_mqc_t *mqc);
-/**
-RESTART mode switch (TERMALL) reinitialisation
- at param mqc MQC handle
-*/
-void mqc_restart_init_enc(opj_mqc_t *mqc);
-/**
-ERTERM mode switch (PTERM)
- at param mqc MQC handle
-*/
-void mqc_erterm_enc(opj_mqc_t *mqc);
-/**
-SEGMARK mode switch (SEGSYM)
- at param mqc MQC handle
-*/
-void mqc_segmark_enc(opj_mqc_t *mqc);
-/**
-Initialize the decoder
- at param mqc MQC handle
- at param bp Pointer to the start of the buffer from which the bytes will be read
- at param len Length of the input buffer
-*/
-void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len);
-/**
-Decode a symbol
- at param mqc MQC handle
- at return Returns the decoded symbol (0 or 1)
-*/
-int mqc_decode(opj_mqc_t *mqc);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __MQC_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg.c
deleted file mode 100755
index 8e3a078..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef _WIN32
-#include <windows.h>
-#endif /* _WIN32 */
-
-#include "opj_includes.h"
-#define JP3D_VERSION "1.3.0"
-/* ---------------------------------------------------------------------- */
-#ifdef _WIN32
-#ifndef OPJ_STATIC
-BOOL APIENTRY
-DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
-	switch (ul_reason_for_call) {
-		case DLL_PROCESS_ATTACH :
-			break;
-		case DLL_PROCESS_DETACH :
-			break;
-		case DLL_THREAD_ATTACH :
-		case DLL_THREAD_DETACH :
-			break;
-    }
-
-    return TRUE;
-}
-#endif /* OPJ_STATIC */
-#endif /* _WIN32 */
-
-/* ---------------------------------------------------------------------- */
-
-const char* OPJ_CALLCONV opj_version() {
-    return JP3D_VERSION;
-}
-opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
-	opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
-	if(!dinfo) return NULL;
-	dinfo->is_decompressor = true;
-	switch(format) {
-		case CODEC_J3D:
-		case CODEC_J2K:
-			/* get a J3D decoder handle */
-			dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);
-			if(!dinfo->j3d_handle) {
-				opj_free(dinfo);
-				return NULL;
-			}
-			break;
-		default:
-			opj_free(dinfo);
-			return NULL;
-	}
-
-	dinfo->codec_format = format;
-
-	return dinfo;
-}
-
-void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
-	if(dinfo) {
-		/* destroy the codec */
-		if(dinfo->codec_format != CODEC_UNKNOWN) {
-			j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);
-		}
-		/* destroy the decompressor */
-		opj_free(dinfo);
-	}
-}
-
-void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
-	if(parameters) {
-		memset(parameters, 0, sizeof(opj_dparameters_t));
-		/* default decoding parameters */
-		parameters->cp_layer = 0;
-		parameters->cp_reduce[0] = 0;
-		parameters->cp_reduce[1] = 0;
-		parameters->cp_reduce[2] = 0;
-		parameters->bigendian = 0;
-
-		parameters->decod_format = -1;
-		parameters->cod_format = -1;
-	}
-}
-
-void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
-	if(dinfo && parameters) {
-		if (dinfo->codec_format != CODEC_UNKNOWN) {
-			j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
-		}
-	}
-}
-
-opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
-	if(dinfo && cio) {
-		if (dinfo->codec_format != CODEC_UNKNOWN) {
-			return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
-		}
-	}
-
-	return NULL;
-}
-
-opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
-	opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
-	if(!cinfo) return NULL;
-	cinfo->is_decompressor = false;
-	switch(format) {
-		case CODEC_J3D:
-		case CODEC_J2K:
-			/* get a J3D coder handle */
-			cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);
-			if(!cinfo->j3d_handle) {
-				opj_free(cinfo);
-				return NULL;
-			}
-			break;
-		default:
-			opj_free(cinfo);
-			return NULL;
-	}
-
-	cinfo->codec_format = format;
-
-	return cinfo;
-}
-
-void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
-	if(cinfo) {
-		/* destroy the codec */
-		if (cinfo->codec_format != CODEC_UNKNOWN) {
-				j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);
-		}
-		/* destroy the decompressor */
-		opj_free(cinfo);
-	}
-}
-
-void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
-	if(parameters) {
-		memset(parameters, 0, sizeof(opj_cparameters_t));
-		/* default coding parameters */
-		parameters->numresolution[0] = 3;
-		parameters->numresolution[1] = 3;
-		parameters->numresolution[2] = 1;
-		parameters->cblock_init[0] = 64;
-		parameters->cblock_init[1] = 64;
-		parameters->cblock_init[2] = 64;
-		parameters->prog_order = LRCP;
-		parameters->roi_compno = -1;		/* no ROI */
-		parameters->atk_wt[0] = 1;				/* 5-3 WT */
-		parameters->atk_wt[1] = 1;				/* 5-3 WT */
-		parameters->atk_wt[2] = 1;				/* 5-3 WT */
-		parameters->irreversible = 0;
-		parameters->subsampling_dx = 1;
-		parameters->subsampling_dy = 1;
-		parameters->subsampling_dz = 1;
-
-		parameters->decod_format = -1;
-		parameters->cod_format = -1;
-		parameters->encoding_format = ENCOD_2EB;
-		parameters->transform_format = TRF_2D_DWT;
-	}
-}
-
-void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {
-	if(cinfo && parameters && volume) {
-		if (cinfo->codec_format != CODEC_UNKNOWN) {
-			j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
-		}
-	}
-}
-
-bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {
-	if(cinfo && cio && volume) {
-		if (cinfo->codec_format != CODEC_UNKNOWN) {
-			return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);
-		}
-	}
-
-	return false;
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg3d.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg3d.h
deleted file mode 100755
index ee878eb..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/openjpeg3d.h
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPENJPEG_H
-#define OPENJPEG_H
-
-/* 
-==========================================================
-   Compiler directives
-==========================================================
-*/
-
-#if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
-#define OPJ_API
-#define OPJ_CALLCONV
-#else
-#define OPJ_CALLCONV __stdcall
-/*
-The following ifdef block is the standard way of creating macros which make exporting 
-from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
-symbol defined on the command line. this symbol should not be defined on any project
-that uses this DLL. This way any other project whose source files include this file see 
-OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
-defined with this macro as being exported.
-*/
-#ifdef OPJ_EXPORTS
-#define OPJ_API __declspec(dllexport)
-#else
-#define OPJ_API __declspec(dllimport)
-#endif /* OPJ_EXPORTS */
-#endif /* !OPJ_STATIC || !WIN32 */
-
-#ifndef __cplusplus
-#if defined(HAVE_STDBOOL_H)
-/*
-The C language implementation does correctly provide the standard header
-file "stdbool.h".
- */
-#include <stdbool.h>
-#else
-/*
-The C language implementation does not provide the standard header file
-"stdbool.h" as required by ISO/IEC 9899:1999.  Try to compensate for this
-braindamage below.
-*/
-#if !defined(bool)
-#define	bool	int
-#endif
-#if !defined(true)
-#define true	1
-#endif
-#if !defined(false)
-#define	false	0
-#endif
-#endif
-#endif /* __cplusplus */
-
-/* 
-==========================================================
-   Useful constant definitions
-==========================================================
-*/
-#ifndef MAX_SLICES
-#define MAX_SLICES 300	/**< Maximum allowed size for slices */
-#endif /* MAX_PATH */
-
-#ifndef MAX_PATH
-#define MAX_PATH 260	/**< Maximum allowed size for filenames */
-#endif /* MAX_PATH */
-
-#define J3D_MAXRLVLS 32					/**< Number of maximum resolution level authorized */
-#define J3D_MAXBANDS (7*J3D_MAXRLVLS + 1)	/**< Number of maximum sub-band linked to number of resolution level */
-
-#define TINY 1.0E-20
-/* 
-==========================================================
-   enum definitions
-==========================================================
-*/
-
-#define J2K_CFMT 0
-#define J3D_CFMT 1
-#define LSE_CFMT 2
-
-#define BIN_DFMT 0
-#define PGX_DFMT 1
-#define IMG_DFMT 2
-/* ----------------------------------------------------------------------- */
-
-/** Progression order */
-typedef enum PROG_ORDER {
-/**< place-holder */	
-	PROG_UNKNOWN = -1,	
-/**< layer-resolution-component-precinct order */	
-	LRCP = 0,		
-/**< resolution-layer-component-precinct order */	
-	RLCP = 1,		
-/**< resolution-precinct-component-layer order */	
-	RPCL = 2,		
-/**< precinct-component-resolution-layer order */	
-	PCRL = 3,		
-/**< component-precinct-resolution-layer order */	
-	CPRL = 4		
-} OPJ_PROG_ORDER;
-
-/**
-Supported volume color spaces
-*/
-typedef enum COLOR_SPACE {
-/**< place-holder */	
-	CLRSPC_UNKNOWN = -1,	
-/**< sRGB */	
-	CLRSPC_SRGB = 1,		
-/**< grayscale */	
-	CLRSPC_GRAY = 2,		
-/**< YUV */	
-	CLRSPC_SYCC = 3			
-} OPJ_COLOR_SPACE;
-
-/**
-Supported codec
-*/
-typedef enum CODEC_FORMAT {
-	/**< place-holder */
-	CODEC_UNKNOWN = -1,
-/**< JPEG-2000 codestream : read/write */
-	CODEC_J2K = 0,		
-/**< JPEG-2000 Part 10 file format : read/write */
-	CODEC_J3D = 1		
-} OPJ_CODEC_FORMAT;
-
-/**
-Supported entropy coding algorithms
-*/
-typedef enum ENTROPY_CODING {
-/**< place-holder */
-	ENCOD_UNKNOWN = -1,
-/**< 2D EBCOT encoding */
-	ENCOD_2EB = 0,		
-/**< 3D EBCOT encoding */
-	ENCOD_3EB = 1,		
-/**< Golomb-Rice coding with 2D context */
-	ENCOD_2GR = 2,		
-/**< Golomb-Rice coding with 3D context  */
-	ENCOD_3GR = 3		
-} OPJ_ENTROPY_CODING;
-
-/**
-Supported transforms
-*/
-typedef enum TRANSFORM {
-/**< place-holder */
-	TRF_UNKNOWN = -1,	
-/**< 2D DWT, no transform in axial dim */
-	TRF_2D_DWT = 0,		
-/**< 3D DWT */
-	TRF_3D_DWT = 1,		
-/**< 3D prediction*/
-	TRF_3D_RLS = 2,		
-	TRF_3D_LSE = 3
-} OPJ_TRANSFORM;
-/* 
-==========================================================
-   event manager typedef definitions
-==========================================================
-*/
-
-/**
-Callback function prototype for events
- at param msg Event message
- at param client_data 
-*/
-typedef void (*opj_msg_callback) (const char *msg, void *client_data);
-
-/**
-Message handler object
-used for 
-<ul>
-<li>Error messages
-<li>Warning messages
-<li>Debugging messages
-</ul>
-*/
-typedef struct opj_event_mgr {
-	/** Error message callback if available, NULL otherwise */
-	opj_msg_callback error_handler;
-	/** Warning message callback if available, NULL otherwise */
-	opj_msg_callback warning_handler;
-	/** Debug message callback if available, NULL otherwise */
-	opj_msg_callback info_handler;
-} opj_event_mgr_t;
-
-
-/* 
-==========================================================
-   codec typedef definitions
-==========================================================
-*/
-
-/**
-Progression order changes
-*/
-typedef struct opj_poc {
-  int resno0, compno0;
-  int layno1, resno1, compno1;
-  OPJ_PROG_ORDER prg;
-  int tile;
-  char progorder[4];
-} opj_poc_t;
-
-
-/**
-Compression parameters
-*/
-typedef struct opj_cparameters {
-/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
-	bool tile_size_on;	
-/** XTOsiz */
-	int cp_tx0;
-/** YTOsiz */
-	int cp_ty0;	
-/** ZTOsiz */
-	int cp_tz0;		
-
-/** XTsiz */
-	int cp_tdx;	
-/** YTsiz */
-	int cp_tdy;	
-/** ZTsiz */
-	int cp_tdz;		
-							
-/** allocation by rate/distortion */
-	int cp_disto_alloc;		
-/** allocation by fixed layer */		
-	int cp_fixed_alloc;		
-/** add fixed_quality */	
-	int cp_fixed_quality;	
-/** fixed layer */
-	int *cp_matrice;
-/** number of layers */
-	int tcp_numlayers;
-/** rates for successive layers */
-	float tcp_rates[100];
-/** psnr's for successive layers */
-	float tcp_distoratio[100];	
-/** comment for coding */
-	char *cp_comment;
-/** csty : coding style */
-	int csty;					
-/** DC offset (DCO) */
-	int dcoffset;
-/** progression order (default LRCP) */
-	OPJ_PROG_ORDER prog_order;	
-/** progression order changes */
-	opj_poc_t POC[J3D_MAXRLVLS-1];	
-/** number of progression order changes (POC), default to 0 */
-	int numpocs;				
-
-/** number of resolutions */
-	int numresolution[3];		
-/** initial code block width, height and depth, default to 64 */
- 	int cblock_init[3];			
-/** mode switch (1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL) 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)) */
-	int mode;					
-
-/** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
-	int irreversible;			
-/** WT from ATK, default to 0 (false), no of atk used */
-	int atk_wt[3];
-/** region of interest: affected component in [0..3], -1 means no ROI */
-	int roi_compno;				
-/** region of interest: upshift value */
-	int roi_shift;				
-
-/* number of precinct size specifications */
-	int res_spec;				
-/** initial precinct width */
-	int prct_init[3][J3D_MAXRLVLS];	
-
-/** transform format 0: 0: 2DWT, 1: 2D1P, 2: 3DWT, 3: 3RLS */
-	OPJ_TRANSFORM transform_format;	
-/** output file format 0: 2EB, 1: 3EB, 2: 2GR, 3: 3GR, 4: GRI */
-	OPJ_ENTROPY_CODING encoding_format;	
-
-	/**@name command line encoder parameters (not used inside the library) */
-	/*@{*/
-	char infile[MAX_PATH];		/** input file name */
-	char outfile[MAX_PATH];		/** output file name */
-	char imgfile[MAX_PATH];		/** IMG file name for BIN volumes*/
-	int index_on;				/** creation of an index file, default to 0 (false) */
-	char index[MAX_PATH];		/** index file name */
-	
-	int volume_offset_x0;		/** subvolume encoding: origin volume offset in x, y and z direction */
-	int volume_offset_y0;
-	int volume_offset_z0;
-	
-	int subsampling_dx;			/** subsampling value for dx */
-	int subsampling_dy;
-	int subsampling_dz;
-	
-	int decod_format;			/** input file format 0: BIN, 1: PGX */
-	int cod_format;				/** output file format 0: JP3D */
-	/*@}*/
-} opj_cparameters_t;
-
-/**
-Decompression parameters
-*/
-typedef struct opj_dparameters {
-/** Set the number of highest resolution levels to be discarded. if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, volume is decoded to the full resolution */
-	int cp_reduce[3];		
-/** Set the maximum number of quality layers to decode. if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded 	*/
-	int cp_layer;	
-	int bigendian;
-	
-	/**@name command line encoder parameters (not used inside the library) */
-	/*@{*/
-/** input file name */
-	char infile[MAX_PATH];	
-/** output file name */
-	char outfile[MAX_PATH];	
-/** IMG file name for BIN volumes*/
-	char imgfile[MAX_PATH];
-/** Original file name for PSNR measures*/
-	char original[MAX_PATH];
-/** input file format 0: J2K, 1: JP3D */
-	int decod_format;		
-/** input file format 0: BIN, 1: PGM */
-	int cod_format;
-/** original file format 0: BIN, 1: PGM */
-	int orig_format;	
-	/*@}*/
-} opj_dparameters_t;
-
-/** Common fields between JPEG-2000 compression and decompression master structs. */
-#define opj_common_fields \
-	opj_event_mgr_t *event_mgr;	/**< pointer to the event manager */\
-	void * client_data;			/**< Available for use by application */\
-	bool is_decompressor;		/**< So common code can tell which is which */\
-	OPJ_CODEC_FORMAT codec_format;		/**< selected codec */\
-	OPJ_ENTROPY_CODING encoding_format;	/**< selected entropy coding */\
-	OPJ_TRANSFORM transform_format;		/**< selected transform */\
-	void *j3d_handle			/**< pointer to the J3D codec */
-	
-/* Routines that are to be used by both halves of the library are declared
- * to receive a pointer to this structure.  There are no actual instances of
- * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
- */
-typedef struct opj_common_struct {
-  opj_common_fields;		/* Fields common to both master struct types */
-  /* Additional fields follow in an actual opj_cinfo_t or
-   * opj_dinfo_t.  All three structs must agree on these
-   * initial fields!  (This would be a lot cleaner in C++.)
-   */
-} opj_common_struct_t;
-
-typedef opj_common_struct_t * opj_common_ptr;
-
-/**
-Compression context info
-*/
-typedef struct opj_cinfo {
-	/** Fields shared with opj_dinfo_t */
-	opj_common_fields;	
-	/* other specific fields go here */
-} opj_cinfo_t;
-
-/**
-Decompression context info
-*/
-typedef struct opj_dinfo {
-	/** Fields shared with opj_cinfo_t */
-	opj_common_fields;	
-	/* other specific fields go here */
-} opj_dinfo_t;
-
-/* 
-==========================================================
-   I/O stream typedef definitions
-==========================================================
-*/
-
-/*
- * Stream open flags.
- */
-/** The stream was opened for reading. */
-#define OPJ_STREAM_READ	0x0001
-/** The stream was opened for writing. */
-#define OPJ_STREAM_WRITE 0x0002
-
-/**
-Byte input-output stream (CIO)
-*/
-typedef struct opj_cio {
-/** codec context */
-	opj_common_ptr cinfo;	
-/** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
-	int openmode;			
-/** pointer to the start of the buffer */
-	unsigned char *buffer;	
-/** buffer size in bytes */
-	int length;				
-/** pointer to the start of the stream */
-	unsigned char *start;		
-/** pointer to the end of the stream */
-	unsigned char *end;			
-/** pointer to the current position */
-	unsigned char *bp;			
-} opj_cio_t;
-
-/* 
-==========================================================
-   volume typedef definitions
-==========================================================
-*/
-
-/**
-Defines a single volume component
-*/
-typedef struct opj_volume_comp {
-/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
-	int dx;	
-/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-	int dy;	
-/** ZRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-	int dz;
-/** data width */
-	int w;	
-	/** data height */
-	int h;	
-	/** data length : no of slices */
-	int l;	
-	/** x component offset compared to the whole volume */
-	int x0;	
-	/** y component offset compared to the whole volume */
-	int y0;	
-	/** z component offset compared to the whole volume */
-	int z0;	
-	/** precision */
-	int prec;	
-	/** volume depth in bits */
-	int bpp;	
-	/** DC offset (15444-2) */
-	int dcoffset;
-	/** signed (1) / unsigned (0) */
-	int sgnd;		
-	/** BE byte order (1) / LE byte order  (0) */
-	int bigendian;
-	/** number of decoded resolution */
-	int resno_decoded[3];	
-	/** number of division by 2 of the out volume compared to the original size of volume */
-	int factor[3];	
-	/** volume component data */
-	int *data;				
-} opj_volume_comp_t;
-
-/** 
-Defines volume data and characteristics
-*/
-typedef struct opj_volume {
-/** XOsiz: horizontal offset from the origin of the reference grid to the left side of the volume area */
-	int x0;	
-/** YOsiz: vertical offset from the origin of the reference grid to the top side of the volume area */
-	int y0;	
-/** ZOsiz: vertical offset from the origin of the reference grid to the top side of the volume area */
-	int z0;	
-/** Xsiz: width of the reference grid */
-	int x1;	
-/** Ysiz: height of the reference grid */
-	int y1;	
-/** Zsiz: length of the reference grid */
-	int z1;	
-/** number of components in the volume */
-	int numcomps;	
-/** number of slices in the volume */
-	int numslices;	
-/** color space: sRGB, Greyscale or YUV */
-	OPJ_COLOR_SPACE color_space;
-/** volume components */
-	opj_volume_comp_t *comps;	
-} opj_volume_t;
-
-/**
-Component parameters structure used by the opj_volume_create function
-*/
-typedef struct opj_volume_comptparm {
-	/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
-	int dx;	
-	/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-	int dy;	
-	/** ZRsiz: axial separation of a sample of ith component with respect to the reference grid */
-	int dz;	
-	/** data width */
-	int w;	
-	/** data height */
-	int h;	
-	/** data length */
-	int l;	
-	/** x component offset compared to the whole volume */
-	int x0;	
-	/** y component offset compared to the whole volume */
-	int y0;
-	/** z component offset compared to the whole volume */
-	int z0;	
-	/** precision */
-	int prec;
-	/** volume depth in bits */
-	int bpp;	
-	/** signed (1) / unsigned (0) */
-	int sgnd;
-	/** DC offset*/
-	int dcoffset;
-	/** BE byte order (1) / LE byte order  (0) */
-	int bigendian;
-} opj_volume_cmptparm_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* 
-==========================================================
-   openjpeg version
-==========================================================
-*/
-
-OPJ_API const char * OPJ_CALLCONV opj_version();
-
-/* 
-==========================================================
-   volume functions definitions
-==========================================================
-*/
-
-/**
-Create an volume
- at param numcmpts number of components
- at param cmptparms components parameters
- at param clrspc volume color space
- at return returns a new volume structure if successful, returns NULL otherwise
-*/
-OPJ_API opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
-
-/**
-Deallocate any resources associated with an volume
- at param volume volume to be destroyed
-*/
-OPJ_API void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume);
-
-/* 
-==========================================================
-   stream functions definitions
-==========================================================
-*/
-
-/**
-Open and allocate a memory stream for read / write. 
-On reading, the user must provide a buffer containing encoded data. The buffer will be 
-wrapped by the returned CIO handle. 
-On writing, buffer parameters must be set to 0: a buffer will be allocated by the library 
-to contain encoded data. 
- at param cinfo Codec context info
- at param buffer Reading: buffer address. Writing: NULL
- at param length Reading: buffer length. Writing: 0
- at return Returns a CIO handle if successful, returns NULL otherwise
-*/
-OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
-
-/**
-Close and free a CIO handle
- at param cio CIO handle to free
-*/
-OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
-
-/**
-Get position in byte stream
- at param cio CIO handle
- at return Returns the position in bytes
-*/
-OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
-/**
-Set position in byte stream
- at param cio CIO handle
- at param pos Position, in number of bytes, from the beginning of the stream
-*/
-OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
-
-/* 
-==========================================================
-   event manager functions definitions
-==========================================================
-*/
-
-OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
-
-/* 
-==========================================================
-   codec functions definitions
-==========================================================
-*/
-/**
-Creates a J3D decompression structure
- at param format Decoder to select
- at return Returns a handle to a decompressor if successful, returns NULL otherwise
-*/
-OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
-/**
-Destroy a decompressor handle
- at param dinfo decompressor handle to destroy
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
-/**
-Set decoding parameters to default values
- at param parameters Decompression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in j3d->cp. 
- at param dinfo decompressor handle
- at param parameters decompression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
-/**
-Decode an volume from a JPEG-2000 codestream
- at param dinfo decompressor handle
- at param cio Input buffer stream
- at return Returns a decoded volume if successful, returns NULL otherwise
-*/
-OPJ_API opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
-/**
-Creates a J3D/JP2 compression structure
- at param format Coder to select
- at return Returns a handle to a compressor if successful, returns NULL otherwise
-*/
-OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
-/**
-Destroy a compressor handle
- at param cinfo compressor handle to destroy
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
-/**
-Set encoding parameters to default values, that means : 
-<ul>
-<li>Lossless
-<li>1 tile
-<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
-<li>Size of code-block : 64 x 64
-<li>Number of resolutions: 6
-<li>No SOP marker in the codestream
-<li>No EPH marker in the codestream
-<li>No sub-sampling in x or y direction
-<li>No mode switch activated
-<li>Progression order: LRCP
-<li>No index file
-<li>No ROI upshifted
-<li>No offset of the origin of the volume
-<li>No offset of the origin of the tiles
-<li>Reversible DWT 5-3
-</ul>
- at param parameters Compression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
-/**
-Setup the encoder parameters using the current volume and using user parameters. 
- at param cinfo compressor handle
- at param parameters compression parameters
- at param volume input filled volume
-*/
-OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume);
-/**
-Encode an volume into a JPEG-2000 codestream
- at param cinfo compressor handle
- at param cio Output buffer stream
- at param volume Volume to encode
- at param index Name of the index file if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPENJPEG_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/opj_includes.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/opj_includes.h
deleted file mode 100755
index 0c70ff1..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/opj_includes.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_INCLUDES_H
-#define OPJ_INCLUDES_H
-
-/*
- ==========================================================
-   Standard includes used by the library
- ==========================================================
-*/
-#include <memory.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <float.h>
-#include <time.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <assert.h>
-/*
- ==========================================================
-   OpenJPEG interface
- ==========================================================
- */
-#include "openjpeg3d.h"
-
-/*
- ==========================================================
-   OpenJPEG modules
- ==========================================================
-*/
-
-#include "jp3d_lib.h"
-#include "event.h"
-#include "cio.h"
-
-#include "volume.h"
-#include "jp3d.h"
-
-#include "mqc.h"
-#include "raw.h"
-#include "bio.h"
-#include "tgt.h"
-#include "tcd.h"
-#include "t1.h"
-#include "t1_3d.h"
-#include "dwt.h"
-#include "pi.h"
-#include "t2.h"
-#include "mct.h"
-#include "int.h"
-#include "fix.h"
-
-//#include "pred.h"
-//#include "golomb.h"
-
-#endif /* OPJ_INCLUDES_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.c
deleted file mode 100755
index 5fd673f..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez, LPI-UVA, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup PI PI - Implementation of a packet iterator */
-/*@{*/
-
-/** @name Funciones locales */
-/*@{*/
-
-/**
-Get next packet in layer-resolution-component-precinct order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_lrcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-layer-component-precinct order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_rlcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-precinct-component-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_rpcl(opj_pi_iterator_t * pi);
-/**
-Get next packet in precinct-component-resolution-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_pcrl(opj_pi_iterator_t * pi);
-/**
-Get next packet in component-precinct-resolution-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_cprl(opj_pi_iterator_t * pi);
-
-/*@}*/
-
-/*@}*/
-
-/* 
-==========================================================
-   local functions
-==========================================================
-*/
-
-static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		res = &comp->resolutions[pi->resno];
-		goto LABEL_SKIP;
-	} else {
-		pi->first = 0;
-	}
-
-	for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-		for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				if (pi->resno >= comp->numresolution[0]) {
-					continue;
-				}
-				res = &comp->resolutions[pi->resno];
-				//for (pi->precno = 0; pi->precno < (res->prctno[0] * res->prctno[1]); pi->precno++) {
-				for (pi->precno = 0; pi->precno < (res->prctno[0] * res->prctno[1] * res->prctno[2]); pi->precno++) {
-					index = pi->layno * pi->step_l 
-						+ pi->resno * pi->step_r 
-						+ pi->compno * pi->step_c 
-						+ pi->precno * pi->step_p;
-					if (!pi->include[index]) {
-						pi->include[index] = 1;
-						return true;
-					}
-LABEL_SKIP:;
-
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		res = &comp->resolutions[pi->resno];
-		goto LABEL_SKIP;
-	} else {
-		pi->first = 0;
-	}
-
-	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-		for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				if (pi->resno >= comp->numresolution[0]) {
-					continue;
-				}
-				res = &comp->resolutions[pi->resno];
-				//for (pi->precno = 0; pi->precno < (res->prctno[0] * res->prctno[1]); pi->precno++) {
-				for (pi->precno = 0; pi->precno < (res->prctno[0] * res->prctno[1] * res->prctno[2]); pi->precno++) {
-					index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-					if (!pi->include[index]) {
-						pi->include[index] = 1;
-						return true;
-					}
-LABEL_SKIP:;
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		goto LABEL_SKIP;
-	} else {
-		int compno, resno;
-		pi->first = 0;
-		pi->dx = 0;
-		pi->dy = 0;
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			comp = &pi->comps[compno];
-			for (resno = 0; resno < comp->numresolution[0]; resno++) {
-				int dx, dy,dz;
-				res = &comp->resolutions[resno];
-				dx = comp->dx * (1 << (res->pdx + comp->numresolution[0] - 1 - resno));
-				dy = comp->dy * (1 << (res->pdy + comp->numresolution[1] - 1 - resno));
-				dz = comp->dz * (1 << (res->pdz + comp->numresolution[2] - 1 - resno));
-				pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-				pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-				pi->dz = !pi->dz ? dz : int_min(pi->dz, dz);
-			}
-		}
-	}
-
-	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-		for (pi->z = pi->tz0; pi->z < pi->tz1; pi->z += pi->dz - (pi->z % pi->dz)) {
-			for (pi->y = pi->ty0; pi->y < pi->ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-				for (pi->x = pi->tx0; pi->x < pi->tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-					for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-						int levelnox, levelnoy, levelnoz;
-						int trx0, try0, trz0;
-						int trx1, try1, trz1;
-						int rpx, rpy, rpz;
-						int prci, prcj, prck;
-						comp = &pi->comps[pi->compno];
-						if (pi->resno >= comp->numresolution[0]) {
-							continue;
-						}
-						res = &comp->resolutions[pi->resno];
-						levelnox = comp->numresolution[0] - 1 - pi->resno;
-						levelnoy = comp->numresolution[1] - 1 - pi->resno;
-						levelnoz = comp->numresolution[2] - 1 - pi->resno;
-						trx0 = int_ceildiv(pi->tx0, comp->dx << levelnox);
-						try0 = int_ceildiv(pi->ty0, comp->dy << levelnoy);
-						trz0 = int_ceildiv(pi->tz0, comp->dz << levelnoz);
-						trx1 = int_ceildiv(pi->tx1, comp->dx << levelnox);
-						try1 = int_ceildiv(pi->ty1, comp->dy << levelnoy);
-						trz1 = int_ceildiv(pi->tz1, comp->dz << levelnoz);
-						rpx = res->pdx + levelnox;
-						rpy = res->pdy + levelnoy;
-						rpz = res->pdz + levelnoz;
-						if ((!(pi->x % (comp->dx << rpx) == 0) || (pi->x == pi->tx0 && (trx0 << levelnox) % (1 << rpx)))) {
-							continue;
-						}
-						if ((!(pi->y % (comp->dy << rpy) == 0) || (pi->y == pi->ty0 && (try0 << levelnoy) % (1 << rpx)))) {
-							continue;
-						}
-						if ((!(pi->z % (comp->dz << rpz) == 0) || (pi->z == pi->tz0 && (trz0 << levelnoz) % (1 << rpx)))) {
-							continue;
-						}
-						if ((res->prctno[0]==0)||(res->prctno[1]==0)||(res->prctno[2]==0)) continue;
-						
-						if ((trx0==trx1)||(try0==try1)||(trz0==trz1)) continue;
-						
-						prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelnox), res->pdx) 
-							- int_floordivpow2(trx0, res->pdx);
-						prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelnoy), res->pdy) 
-							- int_floordivpow2(try0, res->pdy);
-						prck = int_floordivpow2(int_ceildiv(pi->z, comp->dz << levelnoz), res->pdz) 
-							- int_floordivpow2(trz0, res->pdz);
-						pi->precno = prci + prcj * res->prctno[0] + prck * res->prctno[0] * res->prctno[1];
-						for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-							index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-							if (!pi->include[index]) {
-								pi->include[index] = 1;
-								return true;
-							}
-	LABEL_SKIP:;
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		goto LABEL_SKIP;
-	} else {
-		int compno, resno;
-		pi->first = 0;
-		pi->dx = 0;
-		pi->dy = 0;
-		pi->dz = 0;
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			comp = &pi->comps[compno];
-			for (resno = 0; resno < comp->numresolution[0]; resno++) {
-				int dx, dy, dz;
-				res = &comp->resolutions[resno];
-				dx = comp->dx * (1 << (res->pdx + comp->numresolution[0] - 1 - resno));
-				dy = comp->dy * (1 << (res->pdy + comp->numresolution[1] - 1 - resno));
-				dz = comp->dz * (1 << (res->pdy + comp->numresolution[2] - 1 - resno));
-				pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-				pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-				pi->dz = !pi->dz ? dz : int_min(pi->dz, dz);
-			}
-		}
-	}
-
-for (pi->z = pi->tz0; pi->z < pi->tz1; pi->z += pi->dz - (pi->z % pi->dz)) {
-	for (pi->y = pi->ty0; pi->y < pi->ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-		for (pi->x = pi->tx0; pi->x < pi->tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				for (pi->resno = pi->poc.resno0; pi->resno < int_min(pi->poc.resno1, comp->numresolution[0]); pi->resno++) {
-						int levelnox, levelnoy, levelnoz;
-						int trx0, try0, trz0;
-						int trx1, try1, trz1;
-						int rpx, rpy, rpz;
-						int prci, prcj, prck;
-						comp = &pi->comps[pi->compno];
-						if (pi->resno >= comp->numresolution[0]) {
-							continue;
-						}
-						res = &comp->resolutions[pi->resno];
-						levelnox = comp->numresolution[0] - 1 - pi->resno;
-						levelnoy = comp->numresolution[1] - 1 - pi->resno;
-						levelnoz = comp->numresolution[2] - 1 - pi->resno;
-						trx0 = int_ceildiv(pi->tx0, comp->dx << levelnox);
-						try0 = int_ceildiv(pi->ty0, comp->dy << levelnoy);
-						trz0 = int_ceildiv(pi->tz0, comp->dz << levelnoz);
-						trx1 = int_ceildiv(pi->tx1, comp->dx << levelnox);
-						try1 = int_ceildiv(pi->ty1, comp->dy << levelnoy);
-						trz1 = int_ceildiv(pi->tz1, comp->dz << levelnoz);
-						rpx = res->pdx + levelnox;
-						rpy = res->pdy + levelnoy;
-						rpz = res->pdz + levelnoz;
-						if ((!(pi->x % (comp->dx << rpx) == 0) || (pi->x == pi->tx0 && (trx0 << levelnox) % (1 << rpx)))) {
-							continue;
-						}
-						if ((!(pi->y % (comp->dy << rpy) == 0) || (pi->y == pi->ty0 && (try0 << levelnoy) % (1 << rpx)))) {
-							continue;
-						}
-						if ((!(pi->z % (comp->dz << rpz) == 0) || (pi->z == pi->tz0 && (trz0 << levelnoz) % (1 << rpx)))) {
-							continue;
-						}
-						if ((res->prctno[0]==0)||(res->prctno[1]==0)||(res->prctno[2]==0)) continue;
-						
-						if ((trx0==trx1)||(try0==try1)||(trz0==trz1)) continue;
-						
-						prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelnox), res->pdx) 
-							- int_floordivpow2(trx0, res->pdx);
-						prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelnoy), res->pdy) 
-							- int_floordivpow2(try0, res->pdy);
-						prck = int_floordivpow2(int_ceildiv(pi->z, comp->dz << levelnoz), res->pdz) 
-							- int_floordivpow2(trz0, res->pdz);
-						pi->precno = prci + prcj * res->prctno[0] + prck * res->prctno[0] * res->prctno[1];
-						for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-							index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-							if (!pi->include[index]) {
-								pi->include[index] = 1;
-								return true;
-							}	
-LABEL_SKIP:;
-					}
-				}
-			}
-		}
-	}
-}
-	
-	return false;
-}
-
-static bool pi_next_cprl(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		goto LABEL_SKIP;
-	} else {
-		pi->first = 0;
-	}
-
-	for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-		int resno;
-		comp = &pi->comps[pi->compno];
-		pi->dx = 0;
-		pi->dy = 0;
-		for (resno = 0; resno < comp->numresolution[0]; resno++) {
-			int dx, dy;
-			res = &comp->resolutions[resno];
-			dx = comp->dx * (1 << (res->pdx + comp->numresolution[0] - 1 - resno));
-			dy = comp->dy * (1 << (res->pdy + comp->numresolution[0] - 1 - resno));
-			pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-			pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-		}
-	for (pi->z = pi->tz0; pi->z < pi->tz1; pi->z += pi->dz - (pi->z % pi->dz)) {
-		for (pi->y = pi->ty0; pi->y < pi->ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-			for (pi->x = pi->tx0; pi->x < pi->tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-				for (pi->resno = pi->poc.resno0; pi->resno < int_min(pi->poc.resno1, comp->numresolution[0]); pi->resno++) {
-						int levelnox, levelnoy, levelnoz;
-						int trx0, try0, trz0;
-						int trx1, try1, trz1;
-						int rpx, rpy, rpz;
-						int prci, prcj, prck;
-						comp = &pi->comps[pi->compno];
-						if (pi->resno >= comp->numresolution[0]) {
-							continue;
-						}
-						res = &comp->resolutions[pi->resno];
-						levelnox = comp->numresolution[0] - 1 - pi->resno;
-						levelnoy = comp->numresolution[1] - 1 - pi->resno;
-						levelnoz = comp->numresolution[2] - 1 - pi->resno;
-						trx0 = int_ceildiv(pi->tx0, comp->dx << levelnox);
-						try0 = int_ceildiv(pi->ty0, comp->dy << levelnoy);
-						trz0 = int_ceildiv(pi->tz0, comp->dz << levelnoz);
-						trx1 = int_ceildiv(pi->tx1, comp->dx << levelnox);
-						try1 = int_ceildiv(pi->ty1, comp->dy << levelnoy);
-						trz1 = int_ceildiv(pi->tz1, comp->dz << levelnoz);
-						rpx = res->pdx + levelnox;
-						rpy = res->pdy + levelnoy;
-						rpz = res->pdz + levelnoz;
-						if ((!(pi->x % (comp->dx << rpx) == 0) || (pi->x == pi->tx0 && (trx0 << levelnox) % (1 << rpx)))) {
-							continue;
-						}
-						if ((!(pi->y % (comp->dy << rpy) == 0) || (pi->y == pi->ty0 && (try0 << levelnoy) % (1 << rpx)))) {
-							continue;
-						}
-						if ((!(pi->z % (comp->dz << rpz) == 0) || (pi->z == pi->tz0 && (trz0 << levelnoz) % (1 << rpx)))) {
-							continue;
-						}
-						if ((res->prctno[0]==0)||(res->prctno[1]==0)||(res->prctno[2]==0)) continue;
-						
-						if ((trx0==trx1)||(try0==try1)||(trz0==trz1)) continue;
-						
-						prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelnox), res->pdx) 
-							- int_floordivpow2(trx0, res->pdx);
-						prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelnoy), res->pdy) 
-							- int_floordivpow2(try0, res->pdy);
-						prck = int_floordivpow2(int_ceildiv(pi->z, comp->dz << levelnoz), res->pdz) 
-							- int_floordivpow2(trz0, res->pdz);
-						pi->precno = prci + prcj * res->prctno[0] + prck * res->prctno[0] * res->prctno[1];
-						for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
-							index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-							if (!pi->include[index]) {
-								pi->include[index] = 1;
-								return true;
-							}
-	LABEL_SKIP:;
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-/* 
-==========================================================
-   Packet iterator interface
-==========================================================
-*/
-
-opj_pi_iterator_t *pi_create(opj_volume_t *volume, opj_cp_t *cp, int tileno) {
-	int p, q, r;
-	int compno, resno, pino;
-	opj_pi_iterator_t *pi = NULL;
-	opj_tcp_t *tcp = NULL;
-	opj_tccp_t *tccp = NULL;
-	size_t array_size;
-	
-	tcp = &cp->tcps[tileno];
-
-	array_size = (tcp->numpocs + 1) * sizeof(opj_pi_iterator_t);
-	pi = (opj_pi_iterator_t *) opj_malloc(array_size);
-	if(!pi) {
-		fprintf(stdout,"[ERROR] Malloc of opj_pi_iterator failed \n");
-		return NULL;
-	}
-	
-	for (pino = 0; pino < tcp->numpocs + 1; pino++) {	/* change */
-		int maxres = 0;
-		int maxprec = 0;
-		p = tileno % cp->tw;
-		q = tileno / cp->tw;
-		r = tileno / (cp->tw * cp->th);
-
-		pi[pino].tx0 = int_max(cp->tx0 + p * cp->tdx, volume->x0);
-		pi[pino].ty0 = int_max(cp->ty0 + q * cp->tdy, volume->y0);
-		pi[pino].tz0 = int_max(cp->tz0 + r * cp->tdz, volume->z0);
-		pi[pino].tx1 = int_min(cp->tx0 + (p + 1) * cp->tdx, volume->x1);
-		pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, volume->y1);
-		pi[pino].tz1 = int_min(cp->tz0 + (r + 1) * cp->tdz, volume->z1);
-		pi[pino].numcomps = volume->numcomps;
-
-		array_size = volume->numcomps * sizeof(opj_pi_comp_t);
-		pi[pino].comps = (opj_pi_comp_t *) opj_malloc(array_size);
-		if(!pi[pino].comps) {
-			fprintf(stdout,"[ERROR] Malloc of opj_pi_comp failed \n");
-			pi_destroy(pi, cp, tileno);
-			return NULL;
-		}
-		memset(pi[pino].comps, 0, array_size);
-		
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			int tcx0, tcx1, tcy0, tcy1, tcz0, tcz1;
-			int i;
-			opj_pi_comp_t *comp = &pi[pino].comps[compno];
-			tccp = &tcp->tccps[compno];
-			
-			comp->dx = volume->comps[compno].dx;
-			comp->dy = volume->comps[compno].dy;
-			comp->dz = volume->comps[compno].dz;
-			for (i = 0; i < 3; i++) {
-				comp->numresolution[i] = tccp->numresolution[i];
-				if (comp->numresolution[i] > maxres) {
-					maxres = comp->numresolution[i];
-				}
-			}
-			array_size = comp->numresolution[0] * sizeof(opj_pi_resolution_t);
-			comp->resolutions =	(opj_pi_resolution_t *) opj_malloc(array_size);
-			if(!comp->resolutions) {
-				fprintf(stdout,"[ERROR] Malloc of opj_pi_resolution failed \n");
-				pi_destroy(pi, cp, tileno);
-				return NULL;
-			}
-
-			tcx0 = int_ceildiv(pi->tx0, comp->dx);
-			tcy0 = int_ceildiv(pi->ty0, comp->dy);
-			tcz0 = int_ceildiv(pi->tz0, comp->dz);
-			tcx1 = int_ceildiv(pi->tx1, comp->dx);
-			tcy1 = int_ceildiv(pi->ty1, comp->dy);
-			tcz1 = int_ceildiv(pi->tz1, comp->dz);
-			
-			for (resno = 0; resno < comp->numresolution[0]; resno++) {
-				int levelnox, levelnoy, levelnoz, diff;
-				int rx0, ry0, rz0, rx1, ry1, rz1;
-				int px0, py0, pz0, px1, py1, pz1;
-				opj_pi_resolution_t *res = &comp->resolutions[resno];
-				if (tccp->csty & J3D_CCP_CSTY_PRT) {
-					res->pdx = tccp->prctsiz[0][resno];
-					res->pdy = tccp->prctsiz[1][resno];
-					res->pdz = tccp->prctsiz[2][resno];
-				} else {
-					res->pdx = 15;
-					res->pdy = 15;
-					res->pdz = 15;
-				}
-				levelnox = comp->numresolution[0] - 1 - resno;
-				levelnoy = comp->numresolution[1] - 1 - resno;
-                levelnoz = comp->numresolution[2] - 1 - resno;
-				if (levelnoz < 0) levelnoz = 0; 
-				diff = comp->numresolution[0] - comp->numresolution[2];
-
-				rx0 = int_ceildivpow2(tcx0, levelnox);
-				ry0 = int_ceildivpow2(tcy0, levelnoy);
-				rz0 = int_ceildivpow2(tcz0, levelnoz);
-				rx1 = int_ceildivpow2(tcx1, levelnox);
-				ry1 = int_ceildivpow2(tcy1, levelnoy);
-				rz1 = int_ceildivpow2(tcz1, levelnoz);
-				px0 = int_floordivpow2(rx0, res->pdx) << res->pdx;
-				py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
-				pz0 = int_floordivpow2(rz0, res->pdz) << res->pdz;
-				px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
-				py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
-				pz1 = int_ceildivpow2(rz1, res->pdz) << res->pdz;
-				res->prctno[0] = (rx0==rx1)? 0 : ((px1 - px0) >> res->pdx);
-				res->prctno[1] = (ry0==ry1)? 0 : ((py1 - py0) >> res->pdy);
-				res->prctno[2] = (rz0==rz1)? 0 : ((pz1 - pz0) >> res->pdz);
-
-				if (res->prctno[0]*res->prctno[1]*res->prctno[2] > maxprec) {
-					maxprec = res->prctno[0]*res->prctno[1]*res->prctno[2];
-				}
-			}
-		}
-		
-		tccp = &tcp->tccps[0];
-		pi[pino].step_p = 1;
-		pi[pino].step_c = maxprec * pi[pino].step_p;
-		pi[pino].step_r = volume->numcomps * pi[pino].step_c;
-		pi[pino].step_l = maxres * pi[pino].step_r;
-		
-		if (pino == 0) {
-			array_size = volume->numcomps * maxres * tcp->numlayers * maxprec * sizeof(short int);
-			pi[pino].include = (short int *) opj_malloc(array_size);
-			if(!pi[pino].include) {
-				fprintf(stdout,"[ERROR] Malloc of pi[pino].include failed \n");
-				pi_destroy(pi, cp, tileno);
-				return NULL;
-			}
-		}
-		else {
-			pi[pino].include = pi[pino - 1].include;
-		}
-		
-		if (tcp->POC == 0) {
-			pi[pino].first = 1;
-			pi[pino].poc.resno0 = 0;
-			pi[pino].poc.compno0 = 0;
-			pi[pino].poc.layno1 = tcp->numlayers;
-			pi[pino].poc.resno1 = maxres;
-			pi[pino].poc.compno1 = volume->numcomps;
-			pi[pino].poc.prg = tcp->prg;
-		} else {
-			pi[pino].first = 1;
-			pi[pino].poc.resno0 = tcp->pocs[pino].resno0;
-			pi[pino].poc.compno0 = tcp->pocs[pino].compno0;
-			pi[pino].poc.layno1 = tcp->pocs[pino].layno1;
-			pi[pino].poc.resno1 = tcp->pocs[pino].resno1;
-			pi[pino].poc.compno1 = tcp->pocs[pino].compno1;
-			pi[pino].poc.prg = tcp->pocs[pino].prg;
-		}
-	}
-	
-	return pi;
-}
-
-void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) {
-	int compno, pino;
-	opj_tcp_t *tcp = &cp->tcps[tileno];
-	if(pi) {
-		for (pino = 0; pino < tcp->numpocs + 1; pino++) {	
-			if(pi[pino].comps) {
-				for (compno = 0; compno < pi->numcomps; compno++) {
-					opj_pi_comp_t *comp = &pi[pino].comps[compno];
-					if(comp->resolutions) {
-						opj_free(comp->resolutions);
-					}
-				}
-				opj_free(pi[pino].comps);
-			}
-		}
-		if(pi->include) {
-			opj_free(pi->include);
-		}
-		opj_free(pi);
-	}
-}
-
-bool pi_next(opj_pi_iterator_t * pi) {
-	switch (pi->poc.prg) {
-		case LRCP:
-			return pi_next_lrcp(pi);
-		case RLCP:
-			return pi_next_rlcp(pi);
-		case RPCL:
-			return pi_next_rpcl(pi);
-		case PCRL:
-			return pi_next_pcrl(pi);
-		case CPRL:
-			return pi_next_cprl(pi);
-	}
-	
-	return false;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.h
deleted file mode 100755
index 1d3340b..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/pi.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PI_H
-#define __PI_H
-/**
- at file pi.h
- at brief Implementation of a packet iterator (PI)
-
-The functions in PI.C have for goal to realize a packet iterator that permits to get the next
-packet following the progression order and change of it. The functions in PI.C are used
-by some function in T2.C.
-*/
-
-/** @defgroup PI PI - Implementation of a packet iterator */
-/*@{*/
-
-/**
-Packet iterator : resolution level information 
-*/
-typedef struct opj_pi_resolution {
-/** Size of precints in horizontal axis */
-	int pdx;
-/** Size of precints in vertical axis */
-	int pdy;
-/** Size of precints in axial axis */
-	int pdz;
-/** Number of precints in each axis */
-	int prctno[3];				
-} opj_pi_resolution_t;
-
-/**
-Packet iterator : component information 
-*/
-typedef struct opj_pi_comp {
-/** Size in horizontal axis */
-	int dx;
-/** Size in vertical axis */
-	int dy;
-/** Size in axial axis */
-	int dz;
-/** Number of resolution levels */
-	int numresolution[3];			
-/** Packet iterator : resolution level information */
-	opj_pi_resolution_t *resolutions;
-} opj_pi_comp_t;
-
-/** 
-Packet iterator 
-*/
-typedef struct opj_pi_iterator {
-/** precise if the packet has been already used (usefull for progression order change) */
-	short int *include;		
-/** layer step used to localize the packet in the include vector */
-	int step_l;		
-/** resolution step used to localize the packet in the include vector */
-	int step_r;	
-/** component step used to localize the packet in the include vector */
-	int step_c;				
-/** precinct step used to localize the packet in the include vector */
-	int step_p;				
-/** component that identify the packet */
-	int compno;				
-/** resolution that identify the packet */
-	int resno;				
-/** precinct that identify the packet */
-	int precno;				
-/** layer that identify the packet */
-	int layno;				
-/** 0 if the first packet */
-	int first;				
-/** progression order change information */
-	opj_poc_t poc;			
-/**	Packet iterator : component information */
-opj_pi_comp_t *comps;
-	
-	int numcomps;
-	int tx0, ty0, tz0;
-	int tx1, ty1, tz1;
-	int x, y, z;
-	int dx, dy, dz;
-} opj_pi_iterator_t;
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a packet iterator
- at param volume Raw volume for which the packets will be listed
- at param cp Coding parameters
- at param tileno Number that identifies the tile for which to list the packets
- at return Returns a packet iterator that points to the first packet of the tile
- at see pi_destroy
-*/
-opj_pi_iterator_t *pi_create(opj_volume_t * volume, opj_cp_t * cp, int tileno);
-
-/**
-Destroy a packet iterator
- at param pi Previously created packet iterator
- at param cp Coding parameters
- at param tileno Number that identifies the tile for which the packets were listed
- at see pi_create
-*/
-void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno);
-
-/**
-Modify the packet iterator to point to the next packet
- at param pi Packet iterator to modify
- at return Returns false if pi pointed to the last packet or else returns true 
-*/
-bool pi_next(opj_pi_iterator_t * pi);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __PI_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.c
deleted file mode 100755
index 59d7d35..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* 
-==========================================================
-   local functions
-==========================================================
-*/
-
-
-/* 
-==========================================================
-   RAW encoding interface
-==========================================================
-*/
-
-opj_raw_t* raw_create() {
-	opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
-	return raw;
-}
-
-void raw_destroy(opj_raw_t *raw) {
-	if(raw) {
-		opj_free(raw);
-	}
-}
-
-int raw_numbytes(opj_raw_t *raw) {
-	return raw->bp - raw->start;
-}
-
-void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) {
-	raw->start = bp;
-	raw->lenmax = len;
-	raw->len = 0;
-	raw->c = 0;
-	raw->ct = 0;
-}
-
-int raw_decode(opj_raw_t *raw) {
-	int d;
-	if (raw->ct == 0) {
-		raw->ct = 8;
-		if (raw->len == raw->lenmax) {
-			raw->c = 0xff;
-		} else {
-			if (raw->c == 0xff) {
-				raw->ct = 7;
-			}
-			raw->c = *(raw->start + raw->len);
-			raw->len++;
-		}
-	}
-	raw->ct--;
-	d = (raw->c >> raw->ct) & 0x01;
-	
-	return d;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.h
deleted file mode 100755
index e17070a..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/raw.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __RAW_H
-#define __RAW_H
-/**
- at file raw.h
- at brief Implementation of operations for raw encoding (RAW)
-
-The functions in RAW.C have for goal to realize the operation of raw encoding linked
-with the corresponding mode switch.
-*/
-
-/** @defgroup RAW RAW - Implementation of operations for raw encoding */
-/*@{*/
-
-/**
-RAW encoding operations
-*/
-typedef struct opj_raw {
-/** Temporary buffer where bits are coded or decoded */
-	unsigned char c;		
-/** Number of bits already read or free to write */
-	unsigned int ct;		
-/** Maximum length to decode */
-	unsigned int lenmax;	
-/** Length decoded */
-	unsigned int len;		
-/** Pointer to the current position in the buffer */
-	unsigned char *bp;		
-/** Pointer to the start of the buffer */
-	unsigned char *start;	
-/** Pointer to the end of the buffer */
-	unsigned char *end;		
-} opj_raw_t;
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new RAW handle 
- at return Returns a new RAW handle if successful, returns NULL otherwise
-*/
-opj_raw_t* raw_create();
-/**
-Destroy a previously created RAW handle
- at param raw RAW handle to destroy
-*/
-void raw_destroy(opj_raw_t *raw);
-/**
-Return the number of bytes written/read since initialisation
- at param raw RAW handle to destroy
- at return Returns the number of bytes already encoded
-*/
-int raw_numbytes(opj_raw_t *raw);
-/**
-Initialize the decoder
- at param raw RAW handle
- at param bp Pointer to the start of the buffer from which the bytes will be read
- at param len Length of the input buffer
-*/
-void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len);
-/**
-Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
- at param raw RAW handle
- at return Returns the decoded symbol (0 or 1)
-*/
-int raw_decode(opj_raw_t *raw);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __RAW_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.c
deleted file mode 100755
index 43a78b6..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.c
+++ /dev/null
@@ -1,1181 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup T1 T1 - Implementation of the tier-1 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static int t1_getctxno_zc(opj_t1_t *t1, int f, int orient);
-static int t1_getctxno_sc(opj_t1_t *t1, int f);
-static int t1_getctxno_mag(opj_t1_t *t1, int f);
-static int t1_getspb(opj_t1_t *t1, int f);
-static int t1_getnmsedec_sig(opj_t1_t *t1, int x, int bitpos);
-static int t1_getnmsedec_ref(opj_t1_t *t1, int x, int bitpos);
-static void t1_updateflags(int *fp, int s);
-/**
-Encode significant pass
-*/
-static void t1_enc_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc);
-/**
-Decode significant pass
-*/
-static void t1_dec_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, char type, int vsc);
-/**
-Encode significant pass
-*/
-static void t1_enc_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty);
-/**
-Decode significant pass
-*/
-static void t1_dec_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty);
-/**
-Encode refinement pass
-*/
-static void t1_enc_refpass_step(opj_t1_t *t1, int *fp, int *dp, int bpno, int one, int *nmsedec, char type, int vsc);
-/**
-Decode refinement pass
-*/
-static void t1_dec_refpass_step(opj_t1_t *t1, int *fp, int *dp, int poshalf, int neghalf, char type, int vsc);
-/**
-Encode refinement pass
-*/
-static void t1_enc_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty);
-/**
-Decode refinement pass
-*/
-static void t1_dec_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, char type, int cblksty);
-/**
-Encode clean-up pass
-*/
-static void t1_enc_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc);
-/**
-Decode clean-up pass
-*/
-static void t1_dec_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, int partial, int vsc);
-/**
-Encode clean-up pass
-*/
-static void t1_enc_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty);
-/**
-Decode clean-up pass
-*/
-static void t1_dec_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int cblksty);
-/**
-Encode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param compno Component number
- at param level
- at param dwtid
- at param stepsize
- at param cblksty Code-block style
- at param numcomps
- at param tile
-*/
-static void t1_encode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno, int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile);
-/**
-Decode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param roishift Region of interest shifting value
- at param cblksty Code-block style
-*/
-static void t1_decode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty);
-
-static int t1_init_ctxno_zc(int f, int orient);
-static int t1_init_ctxno_sc(int f);
-static int t1_init_ctxno_mag(int f);
-static int t1_init_spb(int f);
-/**
-Initialize the look-up tables of the Tier-1 coder/decoder
- at param t1 T1 handle
-*/
-static void t1_init_luts(opj_t1_t *t1);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-static int t1_getctxno_zc(opj_t1_t *t1, int f, int orient) {
-	return t1->lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)];
-}
-
-static int t1_getctxno_sc(opj_t1_t *t1, int f) {
-	return t1->lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
-}
-
-static int t1_getctxno_mag(opj_t1_t *t1, int f) {
-	return t1->lut_ctxno_mag[(f & T1_SIG_OTH) | (((f & T1_REFINE) != 0) << 11)];
-}
-
-static int t1_getspb(opj_t1_t *t1, int f) {
-	return t1->lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
-}
-
-static int t1_getnmsedec_sig(opj_t1_t *t1, int x, int bitpos) {
-	if (bitpos > T1_NMSEDEC_FRACBITS) {
-		return t1->lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-	}
-	
-	return t1->lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static int t1_getnmsedec_ref(opj_t1_t *t1, int x, int bitpos) {
-	if (bitpos > T1_NMSEDEC_FRACBITS) {
-		return t1->lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-	}
-
-    return t1->lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static void t1_updateflags(int *fp, int s) {
-	int *np = fp - (T1_MAXCBLKW + 2);
-	int *sp = fp + (T1_MAXCBLKW + 2);
-	np[-1] |= T1_SIG_SE;
-	np[1] |= T1_SIG_SW;
-	sp[-1] |= T1_SIG_NE;
-	sp[1] |= T1_SIG_NW;
-	*np |= T1_SIG_S;
-	*sp |= T1_SIG_N;
-	fp[-1] |= T1_SIG_E;
-	fp[1] |= T1_SIG_W;
-	if (s) {
-		*np |= T1_SGN_S;
-		*sp |= T1_SGN_N;
-		fp[-1] |= T1_SGN_E;
-		fp[1] |= T1_SGN_W;
-	}
-}
-
-static void t1_enc_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc) {
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*fp);
-	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-		v = int_abs(*dp) & one ? 1 : 0;
-		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-			mqc_setcurctx(mqc, t1_getctxno_zc(t1, flag, orient));	/* ESSAI */
-			mqc_bypass_enc(mqc, v);
-		} else {
-			mqc_setcurctx(mqc, t1_getctxno_zc(t1, flag, orient));
-			mqc_encode(mqc, v);
-		}
-		if (v) {
-			v = *dp < 0 ? 1 : 0;
-			*nmsedec +=	t1_getnmsedec_sig(t1, int_abs(*dp), bpno + T1_NMSEDEC_FRACBITS);
-			if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-				mqc_setcurctx(mqc, t1_getctxno_sc(t1, flag));	/* ESSAI */
-				mqc_bypass_enc(mqc, v);
-			} else {
-				mqc_setcurctx(mqc, t1_getctxno_sc(t1, flag));
-				mqc_encode(mqc, v ^ t1_getspb(t1, flag));
-			}
-			t1_updateflags(fp, v);
-			*fp |= T1_SIG;
-		}
-		*fp |= T1_VISIT;
-	}
-}
-
-static void t1_dec_sigpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, char type, int vsc) {
-	int v, flag;
-	
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*fp);
-	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-		if (type == T1_TYPE_RAW) {
-			if (raw_decode(raw)) {
-				v = raw_decode(raw);	/* ESSAI */
-				*dp = v ? -oneplushalf : oneplushalf;
-				t1_updateflags(fp, v);
-				*fp |= T1_SIG;
-			}
-		} else {
-			mqc_setcurctx(mqc, t1_getctxno_zc(t1, flag, orient));
-			if (mqc_decode(mqc)) {
-				mqc_setcurctx(mqc, t1_getctxno_sc(t1, flag));
-				v = mqc_decode(mqc) ^ t1_getspb(t1, flag);
-				*dp = v ? -oneplushalf : oneplushalf;
-				t1_updateflags(fp, v);
-				*fp |= T1_SIG;
-			}
-		}
-		*fp |= T1_VISIT;
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_enc_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty) {
-	int i, j, k, m, one, vsc;
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (m = 0; m < l; m++) {
-	for (k = 0; k < h; k += 4) {
-		for (i = 0; i < w; i++) {
-			for (j = k; j < k + 4 && j < h; j++) {
-				vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-				t1_enc_sigpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->data[m][j][i], orient, bpno, one, nmsedec, type, vsc);
-			}
-		}
-	}
-	}
-}
-
-static void t1_dec_sigpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty) {
-	int i, j, k, m, one, half, oneplushalf, vsc;
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	for (m = 0; m < l; m++) {
-	for (k = 0; k < h; k += 4) {
-		for (i = 0; i < w; i++) {
-			for (j = k; j < k + 4 && j < h; j++) {
-				vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-				t1_dec_sigpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->data[m][j][i], orient, oneplushalf, type, vsc);
-			}
-		}
-	}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_enc_refpass_step(opj_t1_t *t1, int *fp, int *dp, int bpno, int one, int *nmsedec, char type, int vsc) {
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*fp);
-	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-		*nmsedec += t1_getnmsedec_ref(t1, int_abs(*dp), bpno + T1_NMSEDEC_FRACBITS);
-		v = int_abs(*dp) & one ? 1 : 0;
-		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-			mqc_setcurctx(mqc, t1_getctxno_mag(t1, flag));	/* ESSAI */
-			mqc_bypass_enc(mqc, v);
-		} else {
-			mqc_setcurctx(mqc, t1_getctxno_mag(t1, flag));
-			mqc_encode(mqc, v);
-		}
-		*fp |= T1_REFINE;
-	}
-}
-
-static void t1_dec_refpass_step(opj_t1_t *t1, int *fp, int *dp, int poshalf, int neghalf, char type, int vsc) {
-	int v, t, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	
-	flag = vsc ? ((*fp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*fp);
-	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-		if (type == T1_TYPE_RAW) {
-			mqc_setcurctx(mqc, t1_getctxno_mag(t1, flag));	/* ESSAI */
-			v = raw_decode(raw);
-		} else {
-			mqc_setcurctx(mqc, t1_getctxno_mag(t1, flag));
-			v = mqc_decode(mqc);
-		}
-		t = v ? poshalf : neghalf;
-		*dp += *dp < 0 ? -t : t;
-		*fp |= T1_REFINE;
-	}
-}				/* VSC and  BYPASS by Antonin  */
-
-static void t1_enc_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty) {
-	int i, j, k, m, one, vsc;
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-		for (i = 0; i < w; i++) {
-			for (j = k; j < k + 4 && j < h; j++) {
-				vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-				t1_enc_refpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->data[m][j][i], bpno, one, nmsedec, type, vsc);
-			}
-		}
-	}
-	}
-}
-
-static void t1_dec_refpass(opj_t1_t *t1, int w, int h, int l, int bpno, char type, int cblksty) {
-	int i, j, k, m, one, poshalf, neghalf;
-	int vsc;
-	one = 1 << bpno;
-	poshalf = one >> 1;
-	neghalf = bpno > 0 ? -poshalf : -1;
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-		for (i = 0; i < w; i++) {
-			for (j = k; j < k + 4 && j < h; j++) {
-				vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-				t1_dec_refpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->data[m][j][i], poshalf, neghalf, type, vsc);
-			}
-		}
-	}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_enc_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc) {
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*fp);
-	if (partial) {
-		goto LABEL_PARTIAL;
-	}
-	if (!(*fp & (T1_SIG | T1_VISIT))) {
-		mqc_setcurctx(mqc, t1_getctxno_zc(t1, flag, orient));
-		v = int_abs(*dp) & one ? 1 : 0;
-		mqc_encode(mqc, v);
-		if (v) {
-LABEL_PARTIAL:
-			*nmsedec += t1_getnmsedec_sig(t1, int_abs(*dp), bpno + T1_NMSEDEC_FRACBITS);
-			mqc_setcurctx(mqc, t1_getctxno_sc(t1, flag));
-			v = *dp < 0 ? 1 : 0;
-			mqc_encode(mqc, v ^ t1_getspb(t1, flag));
-			t1_updateflags(fp, v);
-			*fp |= T1_SIG;
-		}
-	}
-	*fp &= ~T1_VISIT;
-}
-
-static void t1_dec_clnpass_step(opj_t1_t *t1, int *fp, int *dp, int orient, int oneplushalf, int partial, int vsc) {
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*fp);
-	if (partial) {
-		goto LABEL_PARTIAL;
-	}
-	if (!(flag & (T1_SIG | T1_VISIT))) {
-		mqc_setcurctx(mqc, t1_getctxno_zc(t1, flag, orient));
-		if (mqc_decode(mqc)) {
-LABEL_PARTIAL:
-			mqc_setcurctx(mqc, t1_getctxno_sc(t1, flag));
-			v = mqc_decode(mqc) ^ t1_getspb(t1, flag);
-			*dp = v ? -oneplushalf : oneplushalf;
-			t1_updateflags(fp, v);
-			*fp |= T1_SIG;
-		}
-	}
-	*fp &= ~T1_VISIT;
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_enc_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty) {
-	int i, j, k, m, one, agg, runlen, vsc;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-			for (i = 0; i < w; i++) {
-				if (k + 3 < h) {
-					if (cblksty & J3D_CCP_CBLKSTY_VSC) {
-						agg = !(t1->flags[1 + m][1 + k][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-							|| t1->flags[1 + m][1 + k + 1][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-							|| t1->flags[1 + m][1 + k + 2][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-							|| (t1->flags[1 + m][1 + k + 3][1 + i] 
-							& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |	T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-					} else {
-						agg = !(t1->flags[1 + m][1 + k][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-							|| t1->flags[1 + m][1 + k + 1][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-							|| t1->flags[1 + m][1 + k + 2][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-							|| t1->flags[1 + m][1 + k + 3][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-					}
-				} else {
-					agg = 0;
-				}
-				if (agg) {
-					for (runlen = 0; runlen < 4; runlen++) {
-						if (int_abs(t1->data[m][k + runlen][i]) & one)
-							break;
-					}
-					mqc_setcurctx(mqc, T1_CTXNO_AGG);
-					mqc_encode(mqc, runlen != 4);
-					if (runlen == 4) {
-						continue;
-					}
-					mqc_setcurctx(mqc, T1_CTXNO_UNI);
-					mqc_encode(mqc, runlen >> 1);
-					mqc_encode(mqc, runlen & 1);
-				} else {
-					runlen = 0;
-				}
-				for (j = k + runlen; j < k + 4 && j < h; j++) {
-					vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-					t1_enc_clnpass_step(t1, &(t1->flags[1 + m][1 + j][1 + i]), &(t1->data[m][j][i]), orient, bpno, one, nmsedec, agg && (j == k + runlen), vsc);
-				}
-			}
-	}
-	}
-}
-
-static void t1_dec_clnpass(opj_t1_t *t1, int w, int h, int l, int bpno, int orient, int cblksty) {
-	int i, j, k, m, one, half, oneplushalf, agg, runlen, vsc;
-	int segsym = cblksty & J3D_CCP_CBLKSTY_SEGSYM;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-		for (i = 0; i < w; i++) {
-			if (k + 3 < h) {
-				if (cblksty & J3D_CCP_CBLKSTY_VSC) {
-					agg = !(t1->flags[1 + m][1 + k][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| t1->flags[1 + m][1 + k + 1][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| t1->flags[1 + m][1 + k + 2][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| (t1->flags[1 + m][1 + k + 3][1 + i] 
-						& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |	T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-				} else {
-					agg = !(t1->flags[1 + m][1 + k][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| t1->flags[1 + m][1 + k + 1][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| t1->flags[1 + m][1 + k + 2][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| t1->flags[1 + m][1 + k + 3][1 + i] & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-				}
-			} else {
-				agg = 0;
-			}
-			if (agg) {
-				mqc_setcurctx(mqc, T1_CTXNO_AGG);
-				if (!mqc_decode(mqc)) {
-					continue;
-				}
-				mqc_setcurctx(mqc, T1_CTXNO_UNI);
-				runlen = mqc_decode(mqc);
-				runlen = (runlen << 1) | mqc_decode(mqc);
-			} else {
-				runlen = 0;
-			}
-			for (j = k + runlen; j < k + 4 && j < h; j++) {
-				vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-				t1_dec_clnpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->data[m][j][i], orient, oneplushalf, agg && (j == k + runlen), vsc);
-			}
-		}
-	}
-	}
-	if (segsym) {
-		int v = 0;
-		mqc_setcurctx(mqc, T1_CTXNO_UNI);
-		v = mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		/*
-		if (v!=0xa) {
-			opj_event_msg(t1->cinfo, EVT_WARNING, "Bad segmentation symbol %x\n", v);
-		} 
-		*/
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-
-static void t1_encode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno, int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile) {
-	int i, j, k;
-	int w, h, l;
-	int passno;
-	int bpno, passtype;
-	int max;
-	int nmsedec = 0;
-	double cumwmsedec = 0;
-	char type = T1_TYPE_MQ;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	w = cblk->x1 - cblk->x0;
-	h = cblk->y1 - cblk->y0;
-	l = cblk->z1 - cblk->z0;
-
-	max = 0;
-	for (k = 0; k < l; k++) {
-		for (j = 0; j < h; j++) {
-			for (i = 0; i < w; i++) {
-				max = int_max(max, int_abs(t1->data[k][j][i]));
-			}
-		}
-	}
-	for (k = 0; k <= l; k++) {
-		for (j = 0; j <= h; j++) {
-			for (i = 0; i <= w; i++) {
-				t1->flags[k][j][i] = 0;	
-			}
-		}
-	}
-
-	cblk->numbps = max ? (int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
-	
-	bpno = cblk->numbps - 1;
-	passtype = 2;
-	
-	mqc_reset_enc(mqc);
-	mqc_init_enc(mqc, cblk->data);
-	
-	for (passno = 0; bpno >= 0; passno++) {
-		opj_tcd_pass_t *pass = &cblk->passes[passno];
-		int correction = 3;
-		double tmpwmsedec;
-		type = ((bpno < (cblk->numbps - 4)) && (passtype < 2) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-		//fprintf(stdout,"passno %d passtype %d w %d h %d l %d bpno %d orient %d type %d cblksty %d\n",passno,passtype,w,h,l,bpno,orient,type,cblksty);
-
-		switch (passtype) {
-			case 0:
-				t1_enc_sigpass(t1, w, h, l, bpno, orient, &nmsedec, type, cblksty);
-				break;
-			case 1:
-				t1_enc_refpass(t1, w, h, l, bpno, &nmsedec, type, cblksty);
-				break;
-			case 2:
-				//fprintf(stdout,"w %d h %d l %d bpno %d orient %d \n",w,h,l,bpno,orient);
-				t1_enc_clnpass(t1, w, h, l, bpno, orient, &nmsedec, cblksty);
-				/* code switch SEGMARK (i.e. SEGSYM) */
-				if (cblksty & J3D_CCP_CBLKSTY_SEGSYM)
-					mqc_segmark_enc(mqc);
-				break;
-		}
-		
-		/* fixed_quality */
-		tmpwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, stepsize, numcomps, dwtid);
-		cumwmsedec += tmpwmsedec;
-		tile->distotile += tmpwmsedec;
-		
-		/* Code switch "RESTART" (i.e. TERMALL) */
-		if ((cblksty & J3D_CCP_CBLKSTY_TERMALL)	&& !((passtype == 2) && (bpno - 1 < 0))) {
-			if (type == T1_TYPE_RAW) {
-				mqc_flush(mqc);
-				correction = 1;
-				/* correction = mqc_bypass_flush_enc(); */
-			} else {			/* correction = mqc_restart_enc(); */
-				mqc_flush(mqc);
-				correction = 1;
-			}
-			pass->term = 1;
-		} else {
-			if (((bpno < (cblk->numbps - 4) && (passtype > 0)) 
-				|| ((bpno == (cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) {
-				if (type == T1_TYPE_RAW) {
-					mqc_flush(mqc);
-					correction = 1;
-					/* correction = mqc_bypass_flush_enc(); */
-				} else {		/* correction = mqc_restart_enc(); */
-					mqc_flush(mqc);
-					correction = 1;
-				}
-				pass->term = 1;
-			} else {
-				pass->term = 0;
-			}
-		}
-		
-		if (++passtype == 3) {
-			passtype = 0;
-			bpno--;
-		}
-		
-		if (pass->term && bpno > 0) {
-			type = ((bpno < (cblk->numbps - 4)) && (passtype < 2) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-			if (type == T1_TYPE_RAW)
-				mqc_bypass_init_enc(mqc);
-			else
-				mqc_restart_init_enc(mqc);
-		}
-		
-		pass->distortiondec = cumwmsedec;
-		pass->rate = mqc_numbytes(mqc) + correction;	/* FIXME */
-		pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);
-		
-		/* Code-switch "RESET" */
-		if (cblksty & J3D_CCP_CBLKSTY_RESET)
-			mqc_reset_enc(mqc);
-	}
-	
-	/* Code switch "ERTERM" (i.e. PTERM) */
-	if (cblksty & J3D_CCP_CBLKSTY_PTERM)
-		mqc_erterm_enc(mqc);
-	else /* Default coding */ if (!(cblksty & J3D_CCP_CBLKSTY_LAZY))
-		mqc_flush(mqc);
-	
-	cblk->totalpasses = passno;
-}
-
-static void t1_decode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty) {
-	int i, j, k, w, h, l;
-	int bpno, passtype;
-	int segno, passno;
-	char type = T1_TYPE_MQ; /* BYPASS mode */
-	
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	w = cblk->x1 - cblk->x0;
-	h = cblk->y1 - cblk->y0;
-	l = cblk->z1 - cblk->z0;
-
-    for (k = 0; k < l; k++) {
-		for (j = 0; j < h; j++) {
-			for (i = 0; i < w; i++) {
-				t1->data[k][j][i] = 0;
-			}
-		}
-	}
-	
-	for (k = 0; k <= l; k++) {
-		for (j = 0; j <= h; j++) {
-			for (i = 0; i <= w; i++) {
-				t1->flags[k][j][i] = 0;
-			}
-		}
-	}
-
-	bpno = roishift + cblk->numbps - 1;
-	passtype = 2;
-	
-	mqc_reset_enc(mqc);
-	
-	for (segno = 0; segno < cblk->numsegs; segno++) {
-		opj_tcd_seg_t *seg = &cblk->segs[segno];
-		
-		/* BYPASS mode */
-		type = ((bpno <= (cblk->numbps - 1) - 4) && (passtype < 2) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-		if (type == T1_TYPE_RAW) {
-			raw_init_dec(raw, seg->data, seg->len);
-		} else {
-			mqc_init_dec(mqc, seg->data, seg->len);
-		}
-
-		for (passno = 0; passno < seg->numpasses; passno++) {
-			switch (passtype) {
-				case 0:
-					t1_dec_sigpass(t1, w, h, l, bpno+1, orient, type, cblksty);
-					break;
-				case 1:
-					t1_dec_refpass(t1, w, h, l, bpno+1, type, cblksty);
-					break;
-				case 2:
-					t1_dec_clnpass(t1, w, h, l, bpno+1, orient, cblksty);
-					break;
-			}
-			
-			if ((cblksty & J3D_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
-				mqc_reset_enc(mqc);
-			}
-			if (++passtype == 3) {
-				passtype = 0;
-				bpno--;
-			}
-		}
-	}
-}
-
-static int t1_init_ctxno_zc(int f, int orient) {
-	int h, v, d, n, t, hv;
-	n = 0;
-	h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0);
-	v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0);
-	d = ((f & T1_SIG_NW) != 0) + ((f & T1_SIG_NE) != 0) + ((f & T1_SIG_SE) != 0) + ((f & T1_SIG_SW) != 0);
-	
-	switch (orient) {
-		case 2:
-			t = h;
-			h = v;
-			v = t;
-		case 0:
-		case 1:
-			if (!h) {
-				if (!v) {
-					if (!d)
-						n = 0;
-					else if (d == 1)
-						n = 1;
-					else
-						n = 2;
-				} else if (v == 1) {
-					n = 3;
-				} else {
-					n = 4;
-				}
-			} else if (h == 1) {
-				if (!v) {
-					if (!d)
-						n = 5;
-					else
-						n = 6;
-				} else {
-					n = 7;
-				}
-			} else
-				n = 8;
-			break;
-		case 3:
-			hv = h + v;
-			if (!d) {
-				if (!hv) {
-					n = 0;
-				} else if (hv == 1) {
-					n = 1;
-				} else {
-					n = 2;
-				}
-			} else if (d == 1) {
-				if (!hv) {
-					n = 3;
-				} else if (hv == 1) {
-					n = 4;
-				} else {
-					n = 5;
-				}
-			} else if (d == 2) {
-				if (!hv) {
-					n = 6;
-				} else {
-					n = 7;
-				}
-			} else {
-				n = 8;
-			}
-			break;
-	}
-	
-	return (T1_CTXNO_ZC + n);
-}
-
-static int t1_init_ctxno_sc(int f) {
-	int hc, vc, n;
-	n = 0;
-
-	hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
-		T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
-	       1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
-		   (T1_SIG_E | T1_SGN_E)) +
-		   ((f & (T1_SIG_W | T1_SGN_W)) ==
-		   (T1_SIG_W | T1_SGN_W)), 1);
-	
-	vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
-		T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
-	       1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
-		   (T1_SIG_N | T1_SGN_N)) +
-		   ((f & (T1_SIG_S | T1_SGN_S)) ==
-		   (T1_SIG_S | T1_SGN_S)), 1);
-	
-	if (hc < 0) {
-		hc = -hc;
-		vc = -vc;
-	}
-	if (!hc) {
-		if (vc == -1)
-			n = 1;
-		else if (!vc)
-			n = 0;
-		else
-			n = 1;
-	} else if (hc == 1) {
-		if (vc == -1)
-			n = 2;
-		else if (!vc)
-			n = 3;
-		else
-			n = 4;
-	}
-	
-	return (T1_CTXNO_SC + n);
-}
-
-static int t1_init_ctxno_mag(int f) {
-	int n;
-	if (!(f & T1_REFINE))
-		n = (f & (T1_SIG_OTH)) ? 1 : 0;
-	else
-		n = 2;
-	
-	return (T1_CTXNO_MAG + n);
-}
-
-static int t1_init_spb(int f) {
-	int hc, vc, n;
-	
-	hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
-		T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
-	       1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
-		   (T1_SIG_E | T1_SGN_E)) +
-		   ((f & (T1_SIG_W | T1_SGN_W)) ==
-		   (T1_SIG_W | T1_SGN_W)), 1);
-	
-	vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
-		T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
-	       1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
-		   (T1_SIG_N | T1_SGN_N)) +
-		   ((f & (T1_SIG_S | T1_SGN_S)) ==
-		   (T1_SIG_S | T1_SGN_S)), 1);
-	
-	if (!hc && !vc)
-		n = 0;
-	else
-		n = (!(hc > 0 || (!hc && vc > 0)));
-	
-	return n;
-}
-
-static void t1_init_luts(opj_t1_t *t1) {
-	int i, j;
-	double u, v, t;
-	for (j = 0; j < 4; j++) {
-		for (i = 0; i < 256; ++i) {
-			t1->lut_ctxno_zc[(j << 8) | i] = t1_init_ctxno_zc(i, j);
-		}
-	}
-	for (i = 0; i < 256; i++) {
-		t1->lut_ctxno_sc[i] = t1_init_ctxno_sc(i << 4);
-	}
-	for (j = 0; j < 2; j++) {
-		for (i = 0; i < 2048; ++i) {
-			t1->lut_ctxno_mag[(j << 11) + i] = t1_init_ctxno_mag((j ? T1_REFINE : 0) | i);
-		}
-	}
-	for (i = 0; i < 256; ++i) {
-		t1->lut_spb[i] = t1_init_spb(i << 4);
-	}
-	/* FIXME FIXME FIXME */
-	/* fprintf(stdout,"nmsedec luts:\n"); */
-	for (i = 0; i < (1 << T1_NMSEDEC_BITS); i++) {
-		t = i / pow(2, T1_NMSEDEC_FRACBITS);
-		u = t;
-		v = t - 1.5;
-		t1->lut_nmsedec_sig[i] = 
-			int_max(0, 
-			(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-		t1->lut_nmsedec_sig0[i] =
-			int_max(0,
-			(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-		u = t - 1.0;
-		if (i & (1 << (T1_NMSEDEC_BITS - 1))) {
-			v = t - 1.5;
-		} else {
-			v = t - 0.5;
-		}
-		t1->lut_nmsedec_ref[i] =
-			int_max(0,
-			(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-		t1->lut_nmsedec_ref0[i] =
-			int_max(0,
-			(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-	}
-}
-
-/* ----------------------------------------------------------------------- */
-
-opj_t1_t* t1_create(opj_common_ptr cinfo) {
-	opj_t1_t *t1 = (opj_t1_t*)opj_malloc(sizeof(opj_t1_t));
-	if(t1) {
-		t1->cinfo = cinfo;
-		/* create MQC and RAW handles */
-		t1->mqc = mqc_create();
-		t1->raw = raw_create();
-		/* initialize the look-up tables of the Tier-1 coder/decoder */
-		t1_init_luts(t1);
-	}
-	return t1;
-}
-
-void t1_destroy(opj_t1_t *t1) {
-	if(t1) {
-		/* destroy MQC and RAW handles */
-		mqc_destroy(t1->mqc);
-		raw_destroy(t1->raw);
-		//opj_free(t1->data);
-		//opj_free(t1->flags);
-		opj_free(t1);
-	}
-}
-
-void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
-	int compno, resno, bandno, precno, cblkno;
-	int x, y, z, i, j, k, orient;
-	int n=0;
-	int level[3];
-	FILE *fid = NULL;
-//	char filename[10];
-	tile->distotile = 0;		/* fixed_quality */
-	
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-
-		for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			
-			/* Weighted first order entropy
-			sprintf(filename,"res%d.txt",resno);
-			if ((fid = fopen(filename,"w")) == 0){
-				fprintf(stdout,"Error while opening %s\n", filename);
-				exit(1);
-			}
-			*/
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-					for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-						opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-
-						//fprintf(stdout,"Precno %d Cblkno %d \n",precno,cblkno);
-						if (band->bandno == 0) {
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 1) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 2) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 3) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 4) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 5) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 6) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 7) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						}
-
-						if (tcp->tccps[compno].reversible == 1) {
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-                                    for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-                                        t1->data[k][j][i] = 
-										tilec->data[(x + i) + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] << T1_NMSEDEC_FRACBITS;
-//fprintf(fid," %d",t1->data[k][j][i]);
-									}
-								}
-							}
-						} else if (tcp->tccps[compno].reversible == 0) {
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-                                    for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-                                        t1->data[k][j][i] = fix_mul(
-										tilec->data[(x + i) + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)],
-										8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (13 - T1_NMSEDEC_FRACBITS);
-									}
-								}
-							}
-						}
-
-						orient = band->bandno;	/* FIXME */
-						if (orient == 2) {
-							orient = 1;
-						} else if (orient == 1) {
-							orient = 2;
-						}
-						for (i = 0; i < 3; i++) 
-							level[i] = tilec->numresolution[i] - 1 - resno;
-						//fprintf(stdout,"t1_encode_cblk(t1, cblk, %d, %d, %d %d %d, %d, %f, %d, %d, tile);\n", orient, compno, level[0], level[1], level[2], tcp->tccps[compno].reversible, band->stepsize, tcp->tccps[compno].cblksty, tile->numcomps);
-						t1_encode_cblk(t1, cblk, orient, compno, level, tcp->tccps[compno].dwtid, band->stepsize, tcp->tccps[compno].cblksty, tile->numcomps, tile);
-							
-					} /* cblkno */
-				} /* precno */
-//fprintf(fid,"\n");
-			} /* bandno */
-//fclose(fid);
-		} /* resno  */
-	} /* compno  */
-}
-
-void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
-	int compno, resno, bandno, precno, cblkno;
-	
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-
-		for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-					for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-						int x, y, k, i, j, z, orient;
-						opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-
-						orient = band->bandno;	/* FIXME */
-						if (orient == 2) {
-							orient = 1;
-						} else if (orient == 1) {
-							orient = 2;
-						}
-
-						t1_decode_cblk(t1, cblk, orient, tcp->tccps[compno].roishift, tcp->tccps[compno].cblksty);
-
-						if (band->bandno == 0) {
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 1) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 2) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 3) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 4) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 5) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 6) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 7) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						}
-						
-						if (tcp->tccps[compno].roishift) {
-							int thresh, val, mag;
-							thresh = 1 << tcp->tccps[compno].roishift;
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-									for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-										val = t1->data[k][j][i];
-										mag = int_abs(val);
-										if (mag >= thresh) {
-											mag >>= tcp->tccps[compno].roishift;
-											t1->data[k][j][i] = val < 0 ? -mag : mag;
-										}
-									}
-								}
-							}
-						}
-						
-						if (tcp->tccps[compno].reversible == 1) {
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-									for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-										int tmp = t1->data[k][j][i];
-										tilec->data[x + i + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] = tmp/2;
-									}
-								}
-							}
-						} else {		/* if (tcp->tccps[compno].reversible == 0) */
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-									for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-										double tmp = (double)(t1->data[k][j][i] * band->stepsize * 4096.0);
-										if (t1->data[k][j][i] >> 1 == 0) {
-											tilec->data[x + i + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] = 0;
-										} else {
-											int tmp2 = ((int) (floor(fabs(tmp)))) + ((int) floor(fabs(tmp*2))%2);
-											tilec->data[x + i + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] = ((tmp<0)?-tmp2:tmp2);
-										}
-									}
-								}
-							}
-						}
-					} /* cblkno */
-				} /* precno */
-			} /* bandno */
-		} /* resno */
-	} /* compno */
-}
-
-
-/** mod fixed_quality */
-double t1_getwmsedec(int nmsedec, int compno, int level[3], int orient, int bpno, double stepsize, int numcomps, int dwtid[3])	{
-	double w1, w2, wmsedec;
-	
-	if (dwtid[0] == 1 || dwtid[1] == 1 || dwtid[2] == 1) {
-		w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1;
-	} else {			
-		w1 = (numcomps > 1) ? mct_getnorm(compno) : 1;
-	}
-	w2 = dwt_getnorm(orient, level, dwtid);
-
-	//fprintf(stdout,"nmsedec %d level %d %d %d orient %d bpno %d stepsize %f \n",nmsedec ,level[0],level[1],level[2],orient,bpno,stepsize);
-	wmsedec = w1 * w2 * stepsize * (1 << bpno);
-	wmsedec *= wmsedec * nmsedec / 8192.0;
-	
-	return wmsedec;
-}
-/** mod fixed_quality */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.h
deleted file mode 100755
index ec7160c..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __T1_H
-#define __T1_H
-/**
- at file t1.h
- at brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1)
-
-The functions in T1.C have for goal to realize the tier-1 coding operation. The functions
-in T1.C are used by some function in TCD.C.
-*/
-
-/** @defgroup T1 T1 - Implementation of the tier-1 coding */
-/*@{*/
-
-/* ----------------------------------------------------------------------- */
-#define T1_NMSEDEC_BITS 7
-
-#define T1_MAXCBLKW 256	/*< Maximum size of code-block (width) */
-#define T1_MAXCBLKH 256	/*< Maximum size of code-block (heigth) */
-#define T1_MAXCBLKD 256	/*< Maximum size of code-block (depth) */
-#define T1_MINCBLKW 4		/*< Minimum size of code-block (width) */
-#define T1_MINCBLKH 4		/*< Minimum size of code-block (heigth) */
-#define T1_MINCBLKD 4		/*< Minimum size of code-block (depth) */
-#define T1_MAXWHD 18	
-#define T1_CBLKW 256
-#define T1_CBLKH 256
-#define T1_CBLKD 256
-
-#define T1_SIG_NE 0x0001	/*< Context orientation : North-East direction */
-#define T1_SIG_SE 0x0002	/*< Context orientation : South-East direction */
-#define T1_SIG_SW 0x0004	/*< Context orientation : South-West direction */
-#define T1_SIG_NW 0x0008	/*< Context orientation : North-West direction */
-#define T1_SIG_N 0x0010		/*< Context orientation : North direction */
-#define T1_SIG_E 0x0020		/*< Context orientation : East direction */
-#define T1_SIG_S 0x0040		/*< Context orientation : South direction */
-#define T1_SIG_W 0x0080		/*< Context orientation : West direction */
-#define T1_SIG_OTH (T1_SIG_N|T1_SIG_NE|T1_SIG_E|T1_SIG_SE|T1_SIG_S|T1_SIG_SW|T1_SIG_W|T1_SIG_NW)
-#define T1_SIG_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W)
-
-#define T1_SGN_N 0x0100
-#define T1_SGN_E 0x0200
-#define T1_SGN_S 0x0400
-#define T1_SGN_W 0x0800
-#define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W)
-
-#define T1_SIG 0x1000
-#define T1_REFINE 0x2000
-#define T1_VISIT 0x4000
-
-#define T1_NUMCTXS_AGG 1
-#define T1_NUMCTXS_ZC 9
-#define T1_NUMCTXS_MAG 3
-#define T1_NUMCTXS_SC 5
-#define T1_NUMCTXS_UNI 1
-
-#define T1_CTXNO_AGG 0
-#define T1_CTXNO_ZC (T1_CTXNO_AGG+T1_NUMCTXS_AGG)
-#define T1_CTXNO_MAG (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
-#define T1_CTXNO_SC (T1_CTXNO_MAG+T1_NUMCTXS_MAG)
-#define T1_CTXNO_UNI (T1_CTXNO_SC+T1_NUMCTXS_SC)
-#define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
-
-#define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
-
-#define T1_TYPE_MQ 0	/*< Normal coding using entropy coder */
-#define T1_TYPE_RAW 1	/*< No encoding the information is store under raw format in codestream (mode switch RAW)*/
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Tier-1 coding (coding of code-block coefficients)
-*/
-typedef struct opj_t1 {
-	/** codec context */
-	opj_common_ptr cinfo;
-
-	/** MQC component */
-	opj_mqc_t *mqc;
-	/** RAW component */
-	opj_raw_t *raw;
-	/** LUTs for context-based coding */
-	int lut_ctxno_zc[1024];
-	int lut_ctxno_sc[256];
-	int lut_ctxno_mag[4096];
-	int lut_spb[256];
-	/** LUTs for decoding normalised MSE */
-	int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
-	int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
-	int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
-	int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
-	/** Codeblock data */
-	int data[T1_CBLKD][T1_CBLKH][T1_CBLKW];//int ***data;
-	/** Context information for each voxel in codeblock */
-	int flags[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];//int ***flags;
-} opj_t1_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new T1 handle 
-and initialize the look-up tables of the Tier-1 coder/decoder
- at return Returns a new T1 handle if successful, returns NULL otherwise
- at see t1_init_luts
-*/
-opj_t1_t* t1_create(opj_common_ptr cinfo);
-/**
-Destroy a previously created T1 handle
- at param t1 T1 handle to destroy
-*/
-void t1_destroy(opj_t1_t *t1);
-/**
-Encode the code-blocks of a tile
- at param t1 T1 handle
- at param tile The tile to encode
- at param tcp Tile coding parameters
-*/
-void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
-/**
-Decode the code-blocks of a tile
- at param t1 T1 handle
- at param tile The tile to decode
- at param tcp Tile coding parameters
-*/
-void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
-/**
-Get weigths of MSE decoding
- at param nmsedec The normalized MSE reduction
- at param compno 
- at param level 
- at param orient
- at param bpno
- at param stepsize
- at param numcomps
- at param dwtid
-returns MSE associated to decoding pass
-*/
-double t1_getwmsedec(int nmsedec, int compno, int level[3], int orient, int bpno, double stepsize, int numcomps, int dwtid[3]);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __T1_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.c
deleted file mode 100755
index efdf2ef..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.c
+++ /dev/null
@@ -1,1230 +0,0 @@
-/*
- * Copyrigth (c) 2006, M�nica D�ez, LPI-UVA, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup T1_3D T1_3D - Implementation of the tier-1 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static int t1_3d_getctxno_zc(unsigned int f, int orient);
-static int t1_3d_getctxno_sc(unsigned int f);
-static int t1_3d_getctxno_mag(unsigned int f, int fsvr);
-static int t1_3d_getspb(unsigned int f);
-static int t1_3d_getnmsedec_sig(opj_t1_3d_t *t1, int x, int bitpos);
-static int t1_3d_getnmsedec_ref(opj_t1_3d_t *t1, int x, int bitpos);
-static void t1_3d_updateflags(unsigned int *fp, int s);
-/**
-Encode significant pass
-*/
-static void t1_3d_enc_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc);
-/**
-Decode significant pass
-*/
-static void t1_3d_dec_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, char type, int vsc);
-/**
-Encode significant pass
-*/
-static void t1_3d_enc_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty);
-/**
-Decode significant pass
-*/
-static void t1_3d_dec_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty);
-/**
-Encode refinement pass
-*/
-static void t1_3d_enc_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int bpno, int one, int *nmsedec, char type, int vsc);
-/**
-Decode refinement pass
-*/
-static void t1_3d_dec_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int poshalf, int neghalf, char type, int vsc);
-/**
-Encode refinement pass
-*/
-static void t1_3d_enc_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty);
-/**
-Decode refinement pass
-*/
-static void t1_3d_dec_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, char type, int cblksty);
-/**
-Encode clean-up pass
-*/
-static void t1_3d_enc_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc);
-/**
-Decode clean-up pass
-*/
-static void t1_3d_dec_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, int partial, int vsc);
-/**
-Encode clean-up pass
-*/
-static void t1_3d_enc_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty);
-/**
-Decode clean-up pass
-*/
-static void t1_3d_dec_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int cblksty);
-/**
-Encode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param compno Component number
- at param level[3]
- at param dwtid[3]
- at param stepsize
- at param cblksty Code-block style
- at param numcomps
- at param tile
-*/
-static void t1_3d_encode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno,  int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile);
-/**
-Decode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param roishift Region of interest shifting value
- at param cblksty Code-block style
-*/
-static void t1_3d_decode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty);
-static int t1_3d_init_ctxno_zc(unsigned int f, int orient);
-static int t1_3d_init_ctxno_sc(unsigned int f);
-static int t1_3d_init_ctxno_mag(unsigned int f, int f2);
-static int t1_3d_init_spb(unsigned int f);
-/**
-Initialize the look-up tables of the Tier-1 coder/decoder
- at param t1 T1 handle
-*/
-static void t1_3d_init_luts(opj_t1_3d_t *t1);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-static int t1_3d_getctxno_zc(unsigned int f, int orient) {
-	return t1_3d_init_ctxno_zc((f & T1_3D_SIG_OTH), orient);
-}
-
-static int t1_3d_getctxno_sc(unsigned int f) {
-	return t1_3d_init_ctxno_sc((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN));
-	//return t1->lut_ctxno_sc[((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN)) >> 4];
-}
-
-static int t1_3d_getctxno_mag(unsigned int f, int fsvr) {
-	return t1_3d_init_ctxno_mag((f & T1_3D_SIG_OTH), fsvr);
-}
-
-static int t1_3d_getspb(unsigned int f) {
-	return t1_3d_init_spb((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN));
-	//return t1->lut_spb[((f & T1_3D_SIG_PRIM) | ((f >> 16) & T1_3D_SGN)) >> 4];
-}
-
-static int t1_3d_getnmsedec_sig(opj_t1_3d_t *t1, int x, int bitpos) {
-	if (bitpos > T1_NMSEDEC_FRACBITS) {
-		return t1->lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-	}
-	
-	return t1->lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static int t1_3d_getnmsedec_ref(opj_t1_3d_t *t1, int x, int bitpos) {
-	if (bitpos > T1_NMSEDEC_FRACBITS) {
-		return t1->lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-	}
-
-    return t1->lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static void t1_3d_updateflags(unsigned int *fp, int s) {
-	unsigned int *np = fp - (T1_MAXCBLKW + 2);
-	unsigned int *sp = fp + (T1_MAXCBLKW + 2);
-
-	unsigned int *bwp = fp + ((T1_MAXCBLKW + 2)*(T1_MAXCBLKH +2));
-	unsigned int *bnp = bwp - (T1_MAXCBLKW + 2);
-	unsigned int *bsp = bwp + (T1_MAXCBLKW + 2);
-	
-	unsigned int *fwp = fp - ((T1_MAXCBLKW + 2)*(T1_MAXCBLKH +2));
-	unsigned int *fnp = fwp - (T1_MAXCBLKW + 2);
-	unsigned int *fsp = fwp + (T1_MAXCBLKW + 2);
-
-	np[-1] |= T1_3D_SIG_SE;
-	np[1] |= T1_3D_SIG_SW;
-	sp[-1] |= T1_3D_SIG_NE;
-	sp[1] |= T1_3D_SIG_NW;
-	*np |= T1_3D_SIG_S;
-	*sp |= T1_3D_SIG_N;
-	fp[-1] |= T1_3D_SIG_E;
-	fp[1] |= T1_3D_SIG_W;
-
-	*fwp |= T1_3D_SIG_FC;
-	*bwp |= T1_3D_SIG_BC;
-
-	fnp[-1] |= T1_3D_SIG_FSE;
-	fnp[1] |= T1_3D_SIG_FSW;
-	fsp[-1] |= T1_3D_SIG_FNE;
-	fsp[1] |= T1_3D_SIG_FNW;
-	*fnp |= T1_3D_SIG_FS;
-	*fsp |= T1_3D_SIG_FN;
-	fwp[-1] |= T1_3D_SIG_FE;
-	fwp[1] |= T1_3D_SIG_FW;
-
-	bnp[-1] |= T1_3D_SIG_BSE;
-	bnp[1] |= T1_3D_SIG_BSW;
-	bsp[-1] |= T1_3D_SIG_BNE;
-	bsp[1] |= T1_3D_SIG_BNW;
-	*bnp |= T1_3D_SIG_BS;
-	*bsp |= T1_3D_SIG_BN;
-	bwp[-1] |= T1_3D_SIG_BE;
-	bwp[1] |= T1_3D_SIG_BW;
-
-	if (s) {
-		*np |= (T1_3D_SGN_S << 16);
-		*sp |= (T1_3D_SGN_N << 16);
-		fp[-1] |= (T1_3D_SGN_E << 16);
-		fp[1] |= (T1_3D_SGN_W << 16);
-		*fwp |= (T1_3D_SGN_F << 16);
-		*bwp |= (T1_3D_SGN_B << 16);
-	}
-}
-
-static void t1_3d_enc_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, char type, int vsc) {
-	int v, flagsvr;
-	unsigned int flag;
-
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) : (*fp);
-	flagsvr = (*fsvr);
-	if ((flag & T1_3D_SIG_OTH) && !(flagsvr & (T1_3D_SIG | T1_3D_VISIT))) {
-		v = int_abs(*dp) & one ? 1 : 0;
-		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-			mqc_setcurctx(mqc, t1_3d_getctxno_zc(flag, orient));	/* ESSAI */
-			mqc_bypass_enc(mqc, v);
-		} else {
-			mqc_setcurctx(mqc, t1_3d_getctxno_zc(flag, orient));
-			mqc_encode(mqc, v);
-		}
-		if (v) {
-			v = *dp < 0 ? 1 : 0;
-			*nmsedec +=	t1_3d_getnmsedec_sig(t1, int_abs(*dp), bpno + T1_NMSEDEC_FRACBITS);
-			if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-				mqc_setcurctx(mqc, t1_3d_getctxno_sc(flag));	/* ESSAI */
-				mqc_bypass_enc(mqc, v);
-			} else {
-				mqc_setcurctx(mqc, t1_3d_getctxno_sc(flag));
-				mqc_encode(mqc, v ^ t1_3d_getspb(flag));
-			}
-			t1_3d_updateflags(fp, v);
-			*fsvr |= T1_3D_SIG;
-		}
-		*fsvr |= T1_3D_VISIT;
-	}
-}
-
-static void t1_3d_dec_sigpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, char type, int vsc) {
-	int v, flagsvr;
-	unsigned int flag;
-	
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) : (*fp);
-	flagsvr = (*fsvr);
-	if ((flag & T1_3D_SIG_OTH) && !(flagsvr & (T1_3D_SIG | T1_3D_VISIT))) {
-		if (type == T1_TYPE_RAW) {
-			if (raw_decode(raw)) {
-				v = raw_decode(raw);	/* ESSAI */
-				*dp = v ? -oneplushalf : oneplushalf;
-				t1_3d_updateflags(fp, v);
-				*fsvr |= T1_3D_SIG;
-			}
-		} else {
-			mqc_setcurctx(mqc, t1_3d_getctxno_zc(flag, orient));
-			if (mqc_decode(mqc)) {
-				mqc_setcurctx(mqc, t1_3d_getctxno_sc(flag));
-				v = mqc_decode(mqc) ^ t1_3d_getspb(flag);
-				*dp = v ? -oneplushalf : oneplushalf;
-				t1_3d_updateflags(fp, v);
-				*fsvr |= T1_3D_SIG;
-			}
-		}
-		*fsvr |= T1_3D_VISIT;
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_3d_enc_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, char type, int cblksty) {
-	int i, j, k, m, one, vsc;
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-			for (i = 0; i < w; i++) {
-				for (j = k; j < k + 4 && j < h; j++) {
-					vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-					t1_3d_enc_sigpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->flagSVR[1 + m][1 + j][1 + i], &t1->data[m][j][i], orient, bpno, one, nmsedec, type, vsc);
-				}
-			}
-		}
-	}
-}
-
-static void t1_3d_dec_sigpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, char type, int cblksty) {
-	int i, j, k, m, one, half, oneplushalf, vsc;
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-			for (i = 0; i < w; i++) {
-				for (j = k; j < k + 4 && j < h; j++) {
-					vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-					t1_3d_dec_sigpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->flagSVR[1 + m][1 + j][1 + i], &t1->data[m][j][i], orient, oneplushalf, type, vsc);
-				}
-			}
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_3d_enc_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int bpno, int one, int *nmsedec, char type, int vsc) {
-	int v, flagsvr;
-	unsigned int flag;
-
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) : (*fp);
-	flagsvr = (*fsvr);
-	if ((flagsvr & (T1_3D_SIG | T1_3D_VISIT)) == T1_3D_SIG) {
-		*nmsedec += t1_3d_getnmsedec_ref(t1, int_abs(*dp), bpno + T1_NMSEDEC_FRACBITS);
-		v = int_abs(*dp) & one ? 1 : 0;
-		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-			mqc_setcurctx(mqc, t1_3d_getctxno_mag(flag, flagsvr));	/* ESSAI */
-			mqc_bypass_enc(mqc, v);
-		} else {
-			mqc_setcurctx(mqc, t1_3d_getctxno_mag(flag, flagsvr));
-			mqc_encode(mqc, v);
-		}
-		*fsvr |= T1_3D_REFINE;
-	}
-}
-
-static void t1_3d_dec_refpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int poshalf, int neghalf, char type, int vsc) {
-	int v, t, flagsvr;
-	unsigned int flag;
-
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	
-	flag = vsc ? ((*fp) & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) : (*fp);
-	flagsvr = (*fsvr);
-	if ((flagsvr & (T1_3D_SIG | T1_3D_VISIT)) == T1_3D_SIG) {
-		if (type == T1_TYPE_RAW) {
-			mqc_setcurctx(mqc, t1_3d_getctxno_mag(flag, flagsvr));	/* ESSAI */
-			v = raw_decode(raw);
-		} else {
-			mqc_setcurctx(mqc, t1_3d_getctxno_mag(flag, flagsvr));
-			v = mqc_decode(mqc);
-		}
-		t = v ? poshalf : neghalf;
-		*dp += *dp < 0 ? -t : t;
-		*fsvr |= T1_3D_REFINE;
-	}
-}				/* VSC and  BYPASS by Antonin  */
-
-static void t1_3d_enc_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int *nmsedec, char type, int cblksty) {
-	int i, j, k, m, one, vsc;
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (m = 0; m < l; m++){
-		for (k = 0; k < h; k += 4) {
-			for (i = 0; i < w; i++) {
-				for (j = k; j < k + 4 && j < h; j++) {
-					vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-					t1_3d_enc_refpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->flagSVR[1 + m][1 + j][1 + i], &t1->data[m][j][i], bpno, one, nmsedec, type, vsc);
-				}
-			}
-		}
-	}	
-}
-
-static void t1_3d_dec_refpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, char type, int cblksty) {
-	int i, j, k, m, one, poshalf, neghalf;
-	int vsc;
-	one = 1 << bpno;
-	poshalf = one >> 1;
-	neghalf = bpno > 0 ? -poshalf : -1;
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-			for (i = 0; i < w; i++) {
-				for (j = k; j < k + 4 && j < h; j++) {
-					vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-					t1_3d_dec_refpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->flagSVR[1 + m][1 + j][1 + i], &t1->data[m][j][i], poshalf, neghalf, type, vsc);
-				}
-			}
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_3d_enc_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int bpno, int one, int *nmsedec, int partial, int vsc) {
-	int v, flagsvr;
-	unsigned int flag;
-
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) : (*fp);
-	flagsvr = (*fsvr);
-	if (partial) {
-		goto LABEL_PARTIAL;
-	}
-	if (!(*fsvr & (T1_3D_SIG | T1_3D_VISIT))) {
-		mqc_setcurctx(mqc, t1_3d_getctxno_zc(flag, orient));
-		v = int_abs(*dp) & one ? 1 : 0;
-		mqc_encode(mqc, v);
-		if (v) {
-LABEL_PARTIAL:
-			*nmsedec += t1_3d_getnmsedec_sig(t1, int_abs(*dp), bpno + T1_NMSEDEC_FRACBITS);
-			mqc_setcurctx(mqc, t1_3d_getctxno_sc(flag));
-			v = *dp < 0 ? 1 : 0;
-			mqc_encode(mqc, v ^ t1_3d_getspb(flag));
-			t1_3d_updateflags(fp, v);
-			*fsvr |= T1_3D_SIG;
-		}
-	}
-	*fsvr &= ~T1_3D_VISIT;
-}
-
-static void t1_3d_dec_clnpass_step(opj_t1_3d_t *t1, unsigned int *fp, int *fsvr, int *dp, int orient, int oneplushalf, int partial, int vsc) {
-	int v, flagsvr;
-	unsigned int flag;
-
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*fp) & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) : (*fp);
-	flagsvr = (*fsvr);
-	if (partial) {
-		goto LABEL_PARTIAL;
-	}
-	if (!(flagsvr & (T1_3D_SIG | T1_3D_VISIT))) {
-		mqc_setcurctx(mqc, t1_3d_getctxno_zc(flag, orient));
-		if (mqc_decode(mqc)) {
-LABEL_PARTIAL:
-			mqc_setcurctx(mqc, t1_3d_getctxno_sc(flag));
-			v = mqc_decode(mqc) ^ t1_3d_getspb(flag);
-			*dp = v ? -oneplushalf : oneplushalf;
-			t1_3d_updateflags(fp, v);
-			*fsvr |= T1_3D_SIG;
-		}
-	}
-	*fsvr &= ~T1_3D_VISIT;
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_3d_enc_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int *nmsedec, int cblksty) {
-	int i, j, k, m, one, agg, runlen, vsc;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-			for (i = 0; i < w; i++) {
-				if (k + 3 < h) {
-					if (cblksty & J3D_CCP_CBLKSTY_VSC) {
-						agg = !( ((t1->flagSVR[1 + m][1 + k][1 + i] | (T1_3D_SIG | T1_3D_VISIT)) & (t1->flags[1 + m][1 + k][1 + i] & T1_3D_SIG_OTH))
-							||   ((t1->flagSVR[1 + m][1 + k + 1][1 + i] | (T1_3D_SIG | T1_3D_VISIT)) & (t1->flags[1 + m][1 + k + 1][1 + i] & T1_3D_SIG_OTH))
-							||   ((t1->flagSVR[1 + m][1 + k + 2][1 + i] | (T1_3D_SIG | T1_3D_VISIT)) & (t1->flags[1 + m][1 + k + 2][1 + i] & T1_3D_SIG_OTH))
-							||   ((t1->flagSVR[1 + m][1 + k + 3][1 + i] | (T1_3D_SIG | T1_3D_VISIT)) & ((t1->flags[1 + m][1 + k + 3][1 + i] & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) & (T1_3D_SIG_OTH)))
-							);
-					} else {
-						agg = !(
-							((t1->flagSVR[1 + m][1 + k][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 1][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 1][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 2][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 2][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 3][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 3][1 + i] & T1_3D_SIG_OTH))
-							);
-					}
-				} else {
-					agg = 0;
-				}
-				if (agg) {
-					for (runlen = 0; runlen < 4; runlen++) {
-						if (int_abs(t1->data[m][k + runlen][i]) & one)
-							break;
-					}
-					mqc_setcurctx(mqc, T1_CTXNO_AGG);
-					mqc_encode(mqc, runlen != 4);
-					if (runlen == 4) {
-						continue;
-					}
-					mqc_setcurctx(mqc, T1_CTXNO_UNI);
-					mqc_encode(mqc, runlen >> 1);
-					mqc_encode(mqc, runlen & 1);
-				} else {
-					runlen = 0;
-				}
-				for (j = k + runlen; j < k + 4 && j < h; j++) {
-					vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-					t1_3d_enc_clnpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->flagSVR[1 + m][1 + j][1 + i], &t1->data[m][j][i], orient, bpno, one, nmsedec, agg && (j == k + runlen), vsc);
-				}
-			}
-		}
-	}
-}
-
-static void t1_3d_dec_clnpass(opj_t1_3d_t *t1, int w, int h, int l, int bpno, int orient, int cblksty) {
-	int i, j, k, m, one, half, oneplushalf, agg, runlen, vsc;
-	int segsym = cblksty & J3D_CCP_CBLKSTY_SEGSYM;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	for (m = 0; m < l; m++) {
-		for (k = 0; k < h; k += 4) {
-			for (i = 0; i < w; i++) {
-				if (k + 3 < h) {
-					if (cblksty & J3D_CCP_CBLKSTY_VSC) {
-						agg = !(
-							((t1->flagSVR[1 + m][1 + k][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 1][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 1][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 2][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 2][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 3][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | ((t1->flags[1 + m][1 + k + 3][1 + i] & (~(T1_3D_SIG_S | T1_3D_SIG_SE | T1_3D_SIG_SW | (T1_3D_SGN_S << 16)))) & (T1_3D_SIG_OTH)))
-							);
-					} else {
-						agg = !(
-							((t1->flagSVR[1 + m][1 + k][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 1][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 1][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 2][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 2][1 + i] & T1_3D_SIG_OTH))
-							|| ((t1->flagSVR[1 + m][1 + k + 3][1 + i] & (T1_3D_SIG | T1_3D_VISIT)) | (t1->flags[1 + m][1 + k + 3][1 + i] & T1_3D_SIG_OTH))
-							);
-					}
-				} else {
-					agg = 0;
-				}
-				if (agg) {
-					mqc_setcurctx(mqc, T1_CTXNO_AGG);
-					if (!mqc_decode(mqc)) {
-						continue;
-					}
-					mqc_setcurctx(mqc, T1_CTXNO_UNI);
-					runlen = mqc_decode(mqc);
-					runlen = (runlen << 1) | mqc_decode(mqc);
-				} else {
-					runlen = 0;
-				}
-				for (j = k + runlen; j < k + 4 && j < h; j++) {
-					vsc = ((cblksty & J3D_CCP_CBLKSTY_VSC) && (j == k + 3 || j == h - 1)) ? 1 : 0;
-					t1_3d_dec_clnpass_step(t1, &t1->flags[1 + m][1 + j][1 + i], &t1->flagSVR[1 + m][1 + j][1 + i], &t1->data[m][j][i], orient, oneplushalf, agg && (j == k + runlen), vsc);
-				}
-			}
-		}
-	}
-	if (segsym) {
-		int v = 0;
-		mqc_setcurctx(mqc, T1_CTXNO_UNI);
-		v = mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		/*
-		if (v!=0xa) {
-			opj_event_msg(t1->cinfo, EVT_WARNING, "Bad segmentation symbol %x\n", v);
-		} 
-		*/
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-
-static void t1_3d_encode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int compno, int level[3], int dwtid[3], double stepsize, int cblksty, int numcomps, opj_tcd_tile_t * tile) {
-	int i, j, k;
-	int w, h, l;
-	int passno;
-	int bpno, passtype;
-	int max;
-	int nmsedec = 0;
-	double cumwmsedec = 0;
-	char type = T1_TYPE_MQ;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	w = cblk->x1 - cblk->x0;
-	h = cblk->y1 - cblk->y0;
-	l = cblk->z1 - cblk->z0;
-
-	max = 0;
-	for (k = 0; k < l; k++) {
-		for (j = 0; j < h; j++) {
-			for (i = 0; i < w; i++) {
-				max = int_max(max, int_abs(t1->data[k][j][i]));
-			}
-		}
-	}
-	for (k = 0; k <= l; k++) {
-		for (j = 0; j <= h; j++) {
-			for (i = 0; i <= w; i++) {
-				t1->flags[k][j][i] = 0;
-				t1->flagSVR[k][j][i] = 0;
-			}
-		}
-	}
-	
-	cblk->numbps = max ? (int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
-	
-	bpno = cblk->numbps - 1;
-	passtype = 2;
-	
-	mqc_reset_enc(mqc);
-	mqc_init_enc(mqc, cblk->data);
-	
-	for (passno = 0; bpno >= 0; passno++) {
-		opj_tcd_pass_t *pass = &cblk->passes[passno];
-		int correction = 3;
-		double tmpwmsedec;
-		type = ((bpno < (cblk->numbps - 4)) && (passtype < 2) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-		
-		switch (passtype) {
-			case 0:
-				t1_3d_enc_sigpass(t1, w, h, l, bpno, orient, &nmsedec, type, cblksty);
-				break;
-			case 1:
-				t1_3d_enc_refpass(t1, w, h, l, bpno, &nmsedec, type, cblksty);
-				break;
-			case 2:
-				t1_3d_enc_clnpass(t1, w, h, l, bpno, orient, &nmsedec, cblksty);
-				/* code switch SEGMARK (i.e. SEGSYM) */
-				if (cblksty & J3D_CCP_CBLKSTY_SEGSYM)
-					mqc_segmark_enc(mqc);
-				break;
-		}
-		
-		/* fixed_quality */
-		tmpwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, stepsize, numcomps, dwtid);
-		cumwmsedec += tmpwmsedec;
-		tile->distotile += tmpwmsedec;
-		
-		/* Code switch "RESTART" (i.e. TERMALL) */
-		if ((cblksty & J3D_CCP_CBLKSTY_TERMALL)	&& !((passtype == 2) && (bpno - 1 < 0))) {
-			if (type == T1_TYPE_RAW) {
-				mqc_flush(mqc);
-				correction = 1;
-				/* correction = mqc_bypass_flush_enc(); */
-			} else {			/* correction = mqc_restart_enc(); */
-				mqc_flush(mqc);
-				correction = 1;
-			}
-			pass->term = 1;
-		} else {
-			if (((bpno < (cblk->numbps - 4) && (passtype > 0)) 
-				|| ((bpno == (cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) {
-				if (type == T1_TYPE_RAW) {
-					mqc_flush(mqc);
-					correction = 1;
-				} else {	
-					mqc_flush(mqc);
-					correction = 1;
-				}
-				pass->term = 1;
-			} else {
-				pass->term = 0;
-			}
-		}
-		
-		if (++passtype == 3) {
-			passtype = 0;
-			bpno--;
-		}
-		
-		if (pass->term && bpno > 0) {
-			type = ((bpno < (cblk->numbps - 4)) && (passtype < 2) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-			if (type == T1_TYPE_RAW)
-				mqc_bypass_init_enc(mqc);
-			else
-				mqc_restart_init_enc(mqc);
-		}
-		
-		pass->distortiondec = cumwmsedec;
-		pass->rate = mqc_numbytes(mqc) + correction;	/* FIXME */
-		pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);
-
-		/* Code-switch "RESET" */
-		if (cblksty & J3D_CCP_CBLKSTY_RESET)
-			mqc_reset_enc(mqc);
-	}
-	
-	/* Code switch "ERTERM" (i.e. PTERM) */
-	if (cblksty & J3D_CCP_CBLKSTY_PTERM)
-		mqc_erterm_enc(mqc);
-	else /* Default coding */ if (!(cblksty & J3D_CCP_CBLKSTY_LAZY))
-		mqc_flush(mqc);
-	
-	cblk->totalpasses = passno;
-}
-
-static void t1_3d_decode_cblk(opj_t1_3d_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty) {
-	int i, j, k;
-	int w, h, l;
-	int bpno, passtype;
-	int segno, passno;
-	char type = T1_TYPE_MQ; /* BYPASS mode */
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	w = cblk->x1 - cblk->x0;
-	h = cblk->y1 - cblk->y0;
-	l = cblk->z1 - cblk->z0;
-
-    for (k = 0; k < l; k++) {
-		for (j = 0; j < h; j++) {
-			for (i = 0; i < w; i++) {
-				t1->data[k][j][i] = 0;
-			}
-		}
-	}
-	
-	for (k = 0; k <= l; k++) {
-		for (j = 0; j <= h; j++) {
-			for (i = 0; i <= w; i++) {
-				t1->flags[k][j][i] = 0;
-				t1->flagSVR[k][j][i] = 0;
-			}
-		}
-	}
-
-	
-	bpno = roishift + cblk->numbps - 1;
-	passtype = 2;
-	
-	mqc_reset_enc(mqc);
-	
-	for (segno = 0; segno < cblk->numsegs; segno++) {
-		opj_tcd_seg_t *seg = &cblk->segs[segno];
-		
-		/* BYPASS mode */
-		type = ((bpno <= (cblk->numbps - 1) - 4) && (passtype < 2) && (cblksty & J3D_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-		if (type == T1_TYPE_RAW) {
-			raw_init_dec(raw, seg->data, seg->len);
-		} else {
-			mqc_init_dec(mqc, seg->data, seg->len);
-		}
-		
-		for (passno = 0; passno < seg->numpasses; passno++) {
-			switch (passtype) {
-				case 0:
-					t1_3d_dec_sigpass(t1, w, h, l, bpno+1, orient, type, cblksty);
-					break;
-				case 1:
-					t1_3d_dec_refpass(t1, w, h, l, bpno+1, type, cblksty);
-					break;
-				case 2:
-					t1_3d_dec_clnpass(t1, w, h, l, bpno+1, orient, cblksty);
-					break;
-			}
-			
-			if ((cblksty & J3D_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
-				mqc_reset_enc(mqc);
-			}
-			if (++passtype == 3) {
-				passtype = 0;
-				bpno--;
-			}
-
-		}
-	}
-}
-
-static int t1_3d_init_ctxno_zc(unsigned int f, int orient) {
-	unsigned int h, v, c;
-	unsigned int d2xy, d2xz, d2yz, d3;
-	int n;
-	unsigned int hvc, hc, d2, d2xy2yz, d2xy2xz;
-	n = 0;
-	h = ((f & T1_3D_SIG_W) != 0) + ((f & T1_3D_SIG_E) != 0);
-	v = ((f & T1_3D_SIG_N) != 0) + ((f & T1_3D_SIG_S) != 0);
-	c = ((f & T1_3D_SIG_FC) != 0) + ((f & T1_3D_SIG_BC) != 0);
-	d2xy = ((f & T1_3D_SIG_NW) != 0) + ((f & T1_3D_SIG_NE) != 0) + ((f & T1_3D_SIG_SE) != 0) + ((f & T1_3D_SIG_SW) != 0);
-	d2xz = ((f & T1_3D_SIG_FW) != 0) + ((f & T1_3D_SIG_BW) != 0) + ((f & T1_3D_SIG_FE) != 0) + ((f & T1_3D_SIG_BE) != 0);
-	d2yz = ((f & T1_3D_SIG_FN) != 0) + ((f & T1_3D_SIG_FS) != 0) + ((f & T1_3D_SIG_BN) != 0) + ((f & T1_3D_SIG_BS) != 0);
-    d3 = ((f & T1_3D_SIG_FNW) != 0) + ((f & T1_3D_SIG_FNE) != 0) + ((f & T1_3D_SIG_FSE) != 0) + ((f & T1_3D_SIG_FSW) != 0) 
-		+ ((f & T1_3D_SIG_BNW) != 0) + ((f & T1_3D_SIG_BNE) != 0) + ((f & T1_3D_SIG_BSE) != 0) + ((f & T1_3D_SIG_BSW) != 0);
-	
-	switch (orient) {
-		case 0: //LLL
-		case 7: //HHH
-			hvc = h + v + c;
-			d2 = d2xy + d2xz + d2yz;
-			if (!hvc) {
-				if (!d2) {
-                    n = (!d3) ? 0 : 1;
-				} else if (d2 == 1) {
-					n = (!d3) ? 2 : 3;
-				} else {
-					n = (!d3) ? 4 : 5;
-				}
-			} else if (hvc == 1) {
-				if (!d2) {
-                    n = (!d3) ? 6 : 7;
-				} else if (d2 == 1) {
-					n = (!d3) ? 8 : 9;
-				} else {
-					n = 10;
-				}
-			} else if (hvc == 2) {
-				if (!d2) {
-                    n = (!d3) ? 11 : 12;
-				} else {
-					n = 13;
-				}
-			} else if (hvc == 3) {
-				n = 14;
-			} else {
-				n = 15;
-			}
-			break;
-		//LHL, HLL, LLH
-		case 1:
-		case 2:
-		case 4:
-			hc = h + c;
-			d2xy2yz = d2xy + d2yz;
-            if (!hc) {
-				if (!v) {
-					if (!d2xy) {
-						n = (!d2xy2yz) ? ((!d3) ? 0 : 1) : ((!d3) ? 2 : 3);	
-					} else if (d2xy == 1) {
-						n = (!d2xy2yz) ? ((!d3) ? 4 : 5) : 6;	
-					} else { //>=2
-                        n = 7;
-					}
-				} else {
-					n = (v == 1) ? 8 : 9; // =1 or =2
-				} 
-			} else if (hc == 1) {
-				n = (!v) ? ( (!d2xy) ? ( (!d2xy2yz) ? ( (!d3) ? 10 : 11) : (12) ) : (13) ) : (14);
-			} else { //if (hc >= 2)
-				n = 15;
-			}
-			break;
-		//HLH, HHL, LHH
-		case 3:
-		case 5:
-		case 6:
-			hc = h + c;
-			d2xy2xz = d2xy + d2xz;
-			if (!v) {
-				if (!d2xz) {
-					if (!hc && !d2xy2xz) {
-						n = (!d3) ? 0 : 1;
-					} else if (hc == 1) {
-						n = (!d2xy2xz) ?  2 : 3;
-					} else { //if >= 2
-						n = 4;
-					}
-				} else if ( d2xz>=1 && !hc ) {
-					n = 5;
-				} else if ( hc>=1 ) {
-					n = (d2xz==1) ? 6 : 7;
-				} 
-			} else if (v == 1) {
-				if (!d2xz) {
-					n = (!hc) ? 8 : 9;
-				} else if (d2xz == 1) {
-					n = (!hc) ? 10 : 11;
-				} else if (d2xz == 2) {
-					n = (!hc) ? 12 : 13;
-				} else { // if (d2xz >= 3) {
-					n = 14;
-				}
-			} else if (v == 2) {
-				n = 15;
-			} 
-			break;
-	}
-	
-	return (T1_3D_CTXNO_ZC + n);
-}
-
-static int t1_3d_init_ctxno_sc(unsigned int f) {
-	int hc, vc, cc;
-	int n = 0;
-
-	hc = int_min( ( (f & (T1_3D_SIG_E | T1_3D_SGN_E)) == T1_3D_SIG_E ) 
-					+ ( (f & (T1_3D_SIG_W | T1_3D_SGN_W)) == T1_3D_SIG_W ) , 1) 
-		- int_min( ( (f & (T1_3D_SIG_E | T1_3D_SGN_E)) == (T1_3D_SIG_E | T1_3D_SGN_E) ) 
-					+ ( (f & (T1_3D_SIG_W | T1_3D_SGN_W) ) == (T1_3D_SIG_W | T1_3D_SGN_W)), 1);
-	
-	vc = int_min(((f & (T1_3D_SIG_N | T1_3D_SGN_N)) == T1_3D_SIG_N) 
-					+ ((f & (T1_3D_SIG_S | T1_3D_SGN_S)) == T1_3D_SIG_S), 1) 
-		- int_min(((f & (T1_3D_SIG_N | T1_3D_SGN_N)) == (T1_3D_SIG_N | T1_3D_SGN_N)) 
-					+ ((f & (T1_3D_SIG_S | T1_3D_SGN_S)) == (T1_3D_SIG_S | T1_3D_SGN_S)), 1);
-	
-	cc = int_min(((f & (T1_3D_SIG_FC | T1_3D_SGN_F)) == T1_3D_SIG_FC) 
-					+ ((f & (T1_3D_SIG_BC | T1_3D_SGN_B)) == T1_3D_SIG_BC), 1) 
-		- int_min(((f & (T1_3D_SIG_FC | T1_3D_SGN_F)) == (T1_3D_SIG_FC | T1_3D_SGN_F)) 
-					+ ((f & (T1_3D_SIG_BC | T1_3D_SGN_B)) == (T1_3D_SIG_BC | T1_3D_SGN_B)), 1);
-	if (hc < 0) {
-		hc = -hc;
-		vc = -vc;
-		cc = -cc;
-	}
-
-	if (!hc) {
-		if (!vc) 
-			n = (!cc) ? 0 : 1;
-		else if (vc == -1)
-			n = (!cc) ? 1 : ( (cc>0) ? 2 : 4);
-		else if (vc == 1)
-			n = (!cc) ? 1 : ( (cc<0) ? 2 : 4);
-	} else if (hc == 1) {
-		if (!vc)
-			n = (!cc) ? 1 : ( (cc<0) ? 2 : 4);
-		else if (vc == 1)
-			n = (!cc) ? 4 : ( (cc>0) ? 5 : 3);
-		else if (vc == -1)
-			n = (!cc) ? 2 : 3;
-	} else if (hc == -1) {
-		if (!vc)
-			n = (!cc) ? 1 : ( (cc>0) ? 2 : 4);
-		else if (vc == 1)
-			n = (!cc) ? 2 : 3;
-		else if (vc == -1)
-			n = (!cc) ? 4 : ( (cc<0) ? 5 : 3);
-	}
-	
-	return (T1_3D_CTXNO_SC + n);
-}
-
-static int t1_3d_init_ctxno_mag(unsigned int f, int f2) {
-	int n;
-	if (!(f2 & T1_3D_REFINE))	//First refinement for this coefficient (no previous refinement)
-		n = (f & (T1_3D_SIG_PRIM)) ? 1 : 0;
-	else
-		n = 2;
-	
-	return (T1_3D_CTXNO_MAG + n);
-}
-
-static int t1_3d_init_spb(unsigned int f) {
-	int hc, vc, cc;
-	int n = 0;
-	
-	hc = int_min( ( (f & (T1_3D_SIG_E | T1_3D_SGN_E)) == T1_3D_SIG_E ) 
-					+ ( (f & (T1_3D_SIG_W | T1_3D_SGN_W)) == T1_3D_SIG_W ) , 1) 
-		- int_min( ( (f & (T1_3D_SIG_E | T1_3D_SGN_E)) == (T1_3D_SIG_E | T1_3D_SGN_E) ) 
-					+ ( (f & (T1_3D_SIG_W | T1_3D_SGN_W) ) == (T1_3D_SIG_W | T1_3D_SGN_W)), 1);
-	
-	vc = int_min(((f & (T1_3D_SIG_N | T1_3D_SGN_N)) == T1_3D_SIG_N) 
-					+ ((f & (T1_3D_SIG_S | T1_3D_SGN_S)) == T1_3D_SIG_S), 1) 
-		- int_min(((f & (T1_3D_SIG_N | T1_3D_SGN_N)) == (T1_3D_SIG_N | T1_3D_SGN_N)) 
-					+ ((f & (T1_3D_SIG_S | T1_3D_SGN_S)) == (T1_3D_SIG_S | T1_3D_SGN_S)), 1);
-	
-	cc = int_min(((f & (T1_3D_SIG_FC | T1_3D_SGN_F)) == T1_3D_SIG_FC) 
-					+ ((f & (T1_3D_SIG_BC | T1_3D_SGN_B)) == T1_3D_SIG_BC), 1) 
-		- int_min(((f & (T1_3D_SIG_FC | T1_3D_SGN_F)) == (T1_3D_SIG_FC | T1_3D_SGN_F)) 
-					+ ((f & (T1_3D_SIG_BC | T1_3D_SGN_B)) == (T1_3D_SIG_BC | T1_3D_SGN_B)), 1);
-	
-	n = ((hc + vc + cc) < 0); 
-	
-	return n;
-}
-
-static void t1_3d_init_luts(opj_t1_3d_t *t1) {
-	int i;
-	double u, v, t;
-	/*for (j = 0; j < 4; j++) {
-		for (i = 0; i < 256; ++i) {
-			t1->lut_ctxno_zc[(j << 8) | i] = t1_3d_init_ctxno_zc(i, j);
-		}
-	}
-	for (i = 0; i < 4096; i++) {
-		t1->lut_ctxno_sc[i] = t1_3d_init_ctxno_sc(i << 4);
-	}
-	for (j = 0; j < 2; j++) {
-		for (i = 0; i < 2048; ++i) {
-			t1->lut_ctxno_mag[(j << 11) + i] = t1_3d_init_ctxno_mag((j ? T1_3D_REFINE : 0) | i);
-		}
-	}
-	for (i = 0; i < 4096; ++i) {
-		t1->lut_spb[i] = t1_3d_init_spb(i << 4);
-	}*/
-	/* FIXME FIXME FIXME */
-	for (i = 0; i < (1 << T1_NMSEDEC_BITS); i++) {
-		t = i / pow(2, T1_NMSEDEC_FRACBITS);
-		u = t;
-		v = t - 1.5;
-		t1->lut_nmsedec_sig[i] = 
-			int_max(0, 
-			(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-		t1->lut_nmsedec_sig0[i] =
-			int_max(0,
-			(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-		u = t - 1.0;
-		if (i & (1 << (T1_NMSEDEC_BITS - 1))) {
-			v = t - 1.5;
-		} else {
-			v = t - 0.5;
-		}
-		t1->lut_nmsedec_ref[i] =
-			int_max(0,
-			(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-		t1->lut_nmsedec_ref0[i] =
-			int_max(0,
-			(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
-	}
-}
-
-/* ----------------------------------------------------------------------- */
-
-opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo) {
-	opj_t1_3d_t *t1 = (opj_t1_3d_t*)opj_malloc(sizeof(opj_t1_3d_t));
-	if(t1) {
-		t1->cinfo = cinfo;
-		/* create MQC and RAW handles */
-		t1->mqc = mqc_create();
-		t1->raw = raw_create();
-		/* initialize the look-up tables of the Tier-1 coder/decoder */
-		t1_3d_init_luts(t1);
-	}
-	return t1;
-}
-
-void t1_3d_destroy(opj_t1_3d_t *t1) {
-	if(t1) {
-		/* destroy MQC and RAW handles */
-		mqc_destroy(t1->mqc);
-		raw_destroy(t1->raw);
-		opj_free(t1);
-	}
-}
-
-void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
-	int compno, resno, bandno, precno, cblkno;
-	int x, y, z, i, j, k, orient;
-	int level[3];
-	tile->distotile = 0;		/* fixed_quality */
-
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-
-		for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-					for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-						opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-
-						if (band->bandno == 0) {
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 1) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 2) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 3) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 4) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 5) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 6) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 7) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						}
-
-						if (tcp->tccps[compno].reversible == 1) {
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-                                    for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-                                        t1->data[k][j][i] = 
-										tilec->data[(x + i) + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] << T1_NMSEDEC_FRACBITS;
-									}
-								}
-							}
-						} else if (tcp->tccps[compno].reversible == 0) {
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-                                    for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-                                        t1->data[k][j][i] = fix_mul(
-										tilec->data[(x + i) + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)],
-										8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (13 - T1_NMSEDEC_FRACBITS);
-									}
-								}
-							}
-						}
-						orient = band->bandno;	/* FIXME */
-						for (i = 0; i < 3; i++) 
-							level[i] = tilec->numresolution[i] - 1 - resno;
-
-						t1_3d_encode_cblk(t1, cblk, orient, compno, level, tcp->tccps[compno].dwtid, band->stepsize, tcp->tccps[compno].cblksty, tile->numcomps, tile);
-							
-					} /* cblkno */
-				} /* precno */
-			} /* bandno */
-		} /* resno  */
-	} /* compno  */
-}
-
-void t1_3d_decode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
-	int compno, resno, bandno, precno, cblkno;
-	
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-
-		for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-					for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-						int x, y, z, i, j, k, orient;
-						opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-
-						orient = band->bandno;	/* FIXME */
-
-						//fprintf(stdout,"[INFO] t1_3d_decode_cblk(t1, cblk, orient(%d), tcp->tccps[compno].roishift (%d), tcp->tccps[compno].cblksty (%d));\n",orient,tcp->tccps[compno].roishift, tcp->tccps[compno].cblksty);
-						t1_3d_decode_cblk(t1, cblk, orient, tcp->tccps[compno].roishift, tcp->tccps[compno].cblksty);
-
-						if (band->bandno == 0) {
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 1) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 2) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 3) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = cblk->z0 - band->z0;
-						} else if (band->bandno == 4) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 5) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 6) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						} else if (band->bandno == 7) {		
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
-							y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
-							z = pres->z1 - pres->z0 + cblk->z0 - band->z0;
-						}
-					
-						if (tcp->tccps[compno].roishift) {
-							int thresh, val, mag;
-							thresh = 1 << tcp->tccps[compno].roishift;
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-									for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-										val = t1->data[k][j][i];
-										mag = int_abs(val);
-										if (mag >= thresh) {
-											mag >>= tcp->tccps[compno].roishift;
-											t1->data[k][j][i] = val < 0 ? -mag : mag;
-										}
-									}
-								}
-							}
-						}
-						
-						if (tcp->tccps[compno].reversible == 1) {
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-									for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-										int tmp = t1->data[k][j][i];
-										tilec->data[x + i + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] = tmp/2;
-									}
-								}
-							}
-						} else {		/* if (tcp->tccps[compno].reversible == 0) */
-							for (k = 0; k < cblk->z1 - cblk->z0; k++) {
-								for (j = 0; j < cblk->y1 - cblk->y0; j++) {
-									for (i = 0; i < cblk->x1 - cblk->x0; i++) {
-										double tmp = (double)(t1->data[k][j][i] * band->stepsize * 4096.0);
-										if (t1->data[k][j][i] >> 1 == 0) {
-											tilec->data[x + i + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] = 0;
-										} else {
-											int tmp2 = ((int) (floor(fabs(tmp)))) + ((int) floor(fabs(tmp*2))%2);
-											tilec->data[x + i + (y + j) * (tilec->x1 - tilec->x0) + (z + k) * (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0)] = ((tmp<0)?-tmp2:tmp2);
-										}
-									}
-								}
-							}
-						}
-					} /* cblkno */
-				} /* precno */
-			} /* bandno */
-		} /* resno */
-	} /* compno */
-}
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.h
deleted file mode 100755
index dd73763..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t1_3d.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyrigth (c) 2006, M�nica D�ez, LPI-UVA, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __T1_3D_H
-#define __T1_3D_H
-/**
- at file t1_3d.h
- at brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1)
-
-The functions in T1_3D.C have for goal to realize the tier-1 coding operation of 3D-EBCOT.
-The functions in T1_3D.C are used by some function in TCD.C.
-*/
-
-/** @defgroup T1_3D T1_3D - Implementation of the tier-1 coding */
-/*@{*/
-
-/* ----------------------------------------------------------------------- */
-
-/* Neighbourhood of 3D EBCOT (Significance context)*/
-#define T1_3D_SIG_NE  0x00000001	/*< Context orientation : North-East direction */
-#define T1_3D_SIG_SE  0x00000002	/*< Context orientation : South-East direction */
-#define T1_3D_SIG_SW  0x00000004	/*< Context orientation : South-West direction */
-#define T1_3D_SIG_NW  0x00000008	/* Context orientation : North-West direction */
-#define T1_3D_SIG_N   0x00000010	/*< Context orientation : North direction */
-#define T1_3D_SIG_E   0x00000020	/*< Context orientation : East direction */
-#define T1_3D_SIG_S   0x00000040	/*< Context orientation : South direction */
-#define T1_3D_SIG_W   0x00000080	/*< Context orientation : West direction */
-#define T1_3D_SIG_FC  0x00000100	/*< Context orientation : Forward Central direction */		
-#define T1_3D_SIG_BC  0x00000200	/*< Context orientation : Backward Central direction */	
-#define T1_3D_SIG_FNE 0x00000400	/*< Context orientation : Forward North-East direction */	
-#define T1_3D_SIG_FSE 0x00000800	/*< Context orientation : Forward South-East direction */	
-#define T1_3D_SIG_FSW 0x00001000	/*< Context orientation : Forward South-West direction */	
-#define T1_3D_SIG_FNW 0x00002000	/*< Context orientation : Forward North-West direction */	
-#define T1_3D_SIG_FN  0x00004000	/*< Context orientation : Forward North direction */		
-#define T1_3D_SIG_FE  0x00008000	/*< Context orientation : Forward East direction */		
-#define T1_3D_SIG_FS  0x00010000	/*< Context orientation : Forward South direction */		
-#define T1_3D_SIG_FW  0x00020000	/*< Context orientation : Forward West direction */		
-#define T1_3D_SIG_BNE 0x00040000	/*< Context orientation : Backward North-East direction */	
-#define T1_3D_SIG_BSE 0x00080000	/*< Context orientation : Backward South-East direction */	
-#define T1_3D_SIG_BSW 0x00100000	/*< Context orientation : Backward South-West direction */	
-#define T1_3D_SIG_BNW 0x00200000	/*< Context orientation : Backward North-West direction */	
-#define T1_3D_SIG_BN  0x00400000	/*< Context orientation : Backward North direction */		
-#define T1_3D_SIG_BE  0x00800000	/*< Context orientation : Backward East direction */		
-#define T1_3D_SIG_BS  0x01000000	/*< Context orientation : Backward South direction */		
-#define T1_3D_SIG_BW  0x02000000	/*< Context orientation : Backward West direction */		
-#define T1_3D_SIG_COTH	(T1_3D_SIG_N|T1_3D_SIG_NE|T1_3D_SIG_E|T1_3D_SIG_SE|T1_3D_SIG_S|T1_3D_SIG_SW|T1_3D_SIG_W|T1_3D_SIG_NW)
-#define T1_3D_SIG_BOTH	(T1_3D_SIG_BN|T1_3D_SIG_BNE|T1_3D_SIG_BE|T1_3D_SIG_BSE|T1_3D_SIG_BS|T1_3D_SIG_BSW|T1_3D_SIG_BW|T1_3D_SIG_BNW|T1_3D_SIG_BC)
-#define T1_3D_SIG_FOTH  (T1_3D_SIG_FN|T1_3D_SIG_FNE|T1_3D_SIG_FE|T1_3D_SIG_FSE|T1_3D_SIG_FS|T1_3D_SIG_FSW|T1_3D_SIG_FW|T1_3D_SIG_FNW|T1_3D_SIG_FC)
-#define T1_3D_SIG_OTH	(T1_3D_SIG_FOTH|T1_3D_SIG_BOTH|T1_3D_SIG_COTH)
-#define T1_3D_SIG_PRIM	(T1_3D_SIG_N|T1_3D_SIG_E|T1_3D_SIG_S|T1_3D_SIG_W|T1_3D_SIG_FC|T1_3D_SIG_BC)
-
-#define T1_3D_SGN_N		0x0400		
-#define T1_3D_SGN_E		0x0800		
-#define T1_3D_SGN_S		0x1000		
-#define T1_3D_SGN_W		0x2000		
-#define T1_3D_SGN_F		0x4000	
-#define T1_3D_SGN_B		0x8000
-#define T1_3D_SGN		(T1_3D_SGN_N|T1_3D_SGN_E|T1_3D_SGN_S|T1_3D_SGN_W|T1_3D_SGN_F|T1_3D_SGN_B)
-
-#define T1_3D_SIG		0x0001  //Significance state
-#define T1_3D_REFINE	0x0002  //Delayed significance
-#define T1_3D_VISIT		0x0004  //First-pass membership
-
-#define T1_3D_NUMCTXS_AGG	1
-#define T1_3D_NUMCTXS_ZC	16
-#define T1_3D_NUMCTXS_MAG	3
-#define T1_3D_NUMCTXS_SC	6
-#define T1_3D_NUMCTXS_UNI	1
-
-#define T1_3D_CTXNO_AGG 0
-#define T1_3D_CTXNO_ZC	(T1_3D_CTXNO_AGG+T1_3D_NUMCTXS_AGG) //1
-#define T1_3D_CTXNO_MAG (T1_3D_CTXNO_ZC+T1_3D_NUMCTXS_ZC)	//17
-#define T1_3D_CTXNO_SC	(T1_3D_CTXNO_MAG+T1_3D_NUMCTXS_MAG)	//20
-#define T1_3D_CTXNO_UNI (T1_3D_CTXNO_SC+T1_3D_NUMCTXS_SC)	//26
-#define T1_3D_NUMCTXS	(T1_3D_CTXNO_UNI+T1_3D_NUMCTXS_UNI) //27
-
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Tier-1 coding (coding of code-block coefficients)
-*/
-typedef struct opj_t1_3d {
-	/** Codec context */
-	opj_common_ptr cinfo;
-	/** MQC component */
-	opj_mqc_t *mqc;
-	/** RAW component */
-	opj_raw_t *raw;
-	/** LUTs for decoding normalised MSE */
-	int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
-	int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
-	int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
-	int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
-	/** Codeblock data */
-	int data[T1_CBLKD][T1_CBLKH][T1_CBLKW];
-	/** Context information for each voxel in codeblock */
-	unsigned int flags[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];
-	/** Voxel information (significance/visited/refined) */
-	int flagSVR[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];
-} opj_t1_3d_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new T1_3D handle 
-and initialize the look-up tables of the Tier-1 coder/decoder
- at return Returns a new T1 handle if successful, returns NULL otherwise
- at see t1_init_luts
-*/
-opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo);
-/**
-Destroy a previously created T1_3D handle
- at param t1 T1_3D handle to destroy
-*/
-void t1_3d_destroy(opj_t1_3d_t *t1);
-/**
-Encode the code-blocks of a tile
- at param t1 T1_3D handle
- at param tile The tile to encode
- at param tcp Tile coding parameters
-*/
-void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
-/**
-Decode the code-blocks of a tile
- at param t1 T1_3D handle
- at param tile The tile to decode
- at param tcp Tile coding parameters
-*/
-void t1_3d_decode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
-/**
-Get weigths of MSE decoding
- at param nmsedec The normalized MSE reduction
- at param compno 
- at param level 
- at param orient
- at param bpno
- at param reversible
- at param stepsize
- at param numcomps
- at param dwtid
-returns MSE associated to decoding pass
-double t1_3d_getwmsedec(int nmsedec, int compno, int levelxy, int levelz, int orient, int bpno, int reversible, double stepsize, int numcomps, int dwtid);
-*/
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __T1_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.c
deleted file mode 100755
index 20d8e7d..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup T2 T2 - Implementation of a tier-2 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static void t2_putcommacode(opj_bio_t *bio, int n);
-static int t2_getcommacode(opj_bio_t *bio);
-/**
-Variable length code for signalling delta Zil (truncation point)
- at param bio Bit Input/Output component
- at param n delta Zil
-*/
-static void t2_putnumpasses(opj_bio_t *bio, int n);
-static int t2_getnumpasses(opj_bio_t *bio);
-/**
-Encode a packet of a tile to a destination buffer
- at param tile Tile for which to write the packets
- at param tcp Tile coding parameters
- at param pi Packet identity
- at param dest Destination buffer
- at param len Length of the destination buffer
- at param volume_info Structure to create an index file
- at param tileno Number of the tile encoded
- at param cp Coding parameters
- at return Number of bytes encoded from the packet
-*/
-static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_volume_info_t *volume_info, int tileno, opj_cp_t *cp);
-/**
-Initialize the segment decoder
- at param seg Segment instance
- at param cblksty Codeblock style
- at param first Is first segment
-*/
-static void t2_init_seg(opj_tcd_seg_t *seg, int cblksty, int first);
-/**
-Decode a packet of a tile from a source buffer
- at param t2 T2 handle
- at param src Source buffer
- at param len Length of the source buffer
- at param tile Tile for which to write the packets
- at param tcp Tile coding parameters
- at param pi Packet identity
- at return Number of bytes decoded from the packet
-*/
-int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-/* #define RESTART 0x04 */
-static void t2_putcommacode(opj_bio_t *bio, int n) {
-	while (--n >= 0) {
-		bio_write(bio, 1, 1);
-	}
-	bio_write(bio, 0, 1);
-}
-
-static int t2_getcommacode(opj_bio_t *bio) {
-	int n;
-	for (n = 0; bio_read(bio, 1); n++) {
-		;
-	}
-	return n;
-}
-
-static void t2_putnumpasses(opj_bio_t *bio, int n) {
-	if (n == 1) {
-		bio_write(bio, 0, 1);
-	} else if (n == 2) {
-		bio_write(bio, 2, 2);
-	} else if (n <= 5) {
-		bio_write(bio, 0xc | (n - 3), 4);
-	} else if (n <= 36) {
-		bio_write(bio, 0x1e0 | (n - 6), 9);
-	} else if (n <= 164) {
-		bio_write(bio, 0xff80 | (n - 37), 16);
-	}
-}
-
-static int t2_getnumpasses(opj_bio_t *bio) {
-	int n;
-	if (!bio_read(bio, 1))
-		return 1;
-	if (!bio_read(bio, 1))
-		return 2;
-	if ((n = bio_read(bio, 2)) != 3)
-		return (3 + n);
-	if ((n = bio_read(bio, 5)) != 31)
-		return (6 + n);
-	return (37 + bio_read(bio, 7));
-}
-
-static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_volume_info_t * volume_info, int tileno, opj_cp_t *cp) {
-	int bandno, cblkno;
-	unsigned char *sop = 0, *eph = 0;
-	unsigned char *c = dest;
-
-	int compno = pi->compno;	/* component value */
-	int resno  = pi->resno;		/* resolution level value */
-	int precno = pi->precno;	/* precinct value */
-	int layno  = pi->layno;		/* quality layer value */
-
-	opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-	opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-	
-	opj_bio_t *bio = NULL;	/* BIO component */
-
-	/* <SOP 0xff91> */
-	if ((tcp->csty & J3D_CP_CSTY_SOP)) {
-		sop = (unsigned char *) opj_malloc(6 * sizeof(unsigned char));
-		sop[0] = 255;
-		sop[1] = 145;
-		sop[2] = 0;
-		sop[3] = 4;
-		sop[4] = (volume_info) ? (volume_info->num % 65536) / 256 : (0 % 65536) / 256 ;
-		sop[5] = (volume_info) ? (volume_info->num % 65536) % 256 : (0 % 65536) % 256 ;
-		memcpy(c, sop, 6);
-		opj_free(sop);
-		c += 6;
-	} 
-	/* </SOP> */
-	
-	if (!layno) {
-		for (bandno = 0; bandno < res->numbands; bandno++) {
-			opj_tcd_band_t *band = &res->bands[bandno];
-			opj_tcd_precinct_t *prc = &band->precincts[precno];
-			tgt_reset(prc->incltree);
-			tgt_reset(prc->imsbtree);
-			for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-				opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-				cblk->numpasses = 0;
-                tgt_setvalue(prc->imsbtree, cblkno, band->numbps - cblk->numbps);
-			}
-		}
-	}
-		
-	bio = bio_create();
-	bio_init_enc(bio, c, len);
-	bio_write(bio, 1, 1);		/* Empty header bit */
-	
-	/* Writing Packet header */
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-			opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-			opj_tcd_layer_t *layer = &cblk->layers[layno];
-			if (!cblk->numpasses && layer->numpasses) {
-                tgt_setvalue(prc->incltree, cblkno, layno);
-			}
-		}
-
-		for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-			opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-			opj_tcd_layer_t *layer = &cblk->layers[layno];
-			int increment = 0;
-			int nump = 0;
-			int len = 0, passno;
-			/* cblk inclusion bits */
-			if (!cblk->numpasses) {
-				tgt_encode(bio, prc->incltree, cblkno, layno + 1);
-			} else {
-				bio_write(bio, layer->numpasses != 0, 1);
-			}
-			/* if cblk not included, go to the next cblk  */
-			if (!layer->numpasses) {
-				continue;
-			}
-			/* if first instance of cblk --> zero bit-planes information */
-			if (!cblk->numpasses) {
-				cblk->numlenbits = 3;
-				tgt_encode(bio, prc->imsbtree, cblkno, 999);
-			}
-			/* number of coding passes included */
-			t2_putnumpasses(bio, layer->numpasses);
-			
-			/* computation of the increase of the length indicator and insertion in the header     */
-			for (passno = cblk->numpasses; passno < cblk->numpasses + layer->numpasses; passno++) {
-				opj_tcd_pass_t *pass = &cblk->passes[passno];
-				nump++;
-				len += pass->len;
-				if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
-					increment = int_max(increment, int_floorlog2(len) + 1 - (cblk->numlenbits + int_floorlog2(nump)));
-					len = 0;
-					nump = 0;
-				}
-			}
-			t2_putcommacode(bio, increment);
-
-			/* computation of the new Length indicator */
-			cblk->numlenbits += increment;
-
-			/* insertion of the codeword segment length */
-			for (passno = cblk->numpasses; passno < cblk->numpasses + layer->numpasses; passno++) {
-				opj_tcd_pass_t *pass = &cblk->passes[passno];
-				nump++;
-				len += pass->len;
-				if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
-					bio_write(bio, len, cblk->numlenbits + int_floorlog2(nump));
-					len = 0;
-					nump = 0;
-				}
-			}
-
-		}
-	}
-	
-	
-	if (bio_flush(bio)) {
-		return -999;		/* modified to eliminate longjmp !! */
-	}
-	
-	c += bio_numbytes(bio);
-
-	bio_destroy(bio);
-	
-	/* <EPH 0xff92> */
-	if (tcp->csty & J3D_CP_CSTY_EPH) {
-		eph = (unsigned char *) opj_malloc(2 * sizeof(unsigned char));
-		eph[0] = 255;
-		eph[1] = 146;
-		memcpy(c, eph, 2);
-		opj_free(eph);
-		c += 2;
-	}
-	/* </EPH> */
-	
-	/* Writing the packet body */
-	
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-			opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-			opj_tcd_layer_t *layer = &cblk->layers[layno];
-			if (!layer->numpasses) {
-				continue;
-			}
-			if (c + layer->len > dest + len) {
-				return -999;
-			}
-			
-			memcpy(c, layer->data, layer->len);
-			cblk->numpasses += layer->numpasses;
-			c += layer->len;
-			/* ADD for index Cfr. Marcela --> delta disto by packet */
-			if(volume_info && volume_info->index_write && volume_info->index_on) {
-				opj_tile_info_t *info_TL = &volume_info->tile[tileno];
-				opj_packet_info_t *info_PK = &info_TL->packet[volume_info->num];
-				info_PK->disto += layer->disto;
-				if (volume_info->D_max < info_PK->disto) {
-					volume_info->D_max = info_PK->disto;
-				}
-			}
-			/* </ADD> */
-		}
-	}
-	
-	return (c - dest);
-}
-
-static void t2_init_seg(opj_tcd_seg_t * seg, int cblksty, int first) {
-	seg->numpasses = 0;
-	seg->len = 0;
-	if (cblksty & J3D_CCP_CBLKSTY_TERMALL) {
-		seg->maxpasses = 1;
-	}
-	else if (cblksty & J3D_CCP_CBLKSTY_LAZY) {
-		if (first) {
-			seg->maxpasses = 10;
-		} else {
-			seg->maxpasses = (((seg - 1)->maxpasses == 1) || ((seg - 1)->maxpasses == 10)) ? 2 : 1;
-		}
-	} else {
-		seg->maxpasses = 109;
-	}
-}
-
-int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi) {
-	int bandno, cblkno;
-	unsigned char *c = src;
-
-	opj_cp_t *cp = t2->cp;
-
-	int compno = pi->compno;	/* component value */
-	int resno  = pi->resno;		/* resolution level value */
-	int precno = pi->precno;	/* precinct value */
-	int layno  = pi->layno;		/* quality layer value */
-
-	opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-	opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-	
-	unsigned char *hd = NULL;
-	int present;
-	
-	opj_bio_t *bio = NULL;	/* BIO component */
-	
-	if (layno == 0) {
-		for (bandno = 0; bandno < res->numbands; bandno++) {
-			opj_tcd_band_t *band = &res->bands[bandno];
-			opj_tcd_precinct_t *prc = &band->precincts[precno];
-			
-			if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)||(band->z1-band->z0 == 0)) continue;
-
-			tgt_reset(prc->incltree);
-			tgt_reset(prc->imsbtree);
-			for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-				opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-				cblk->numsegs = 0;
-			}
-		}
-	}
-	
-	/* SOP markers */
-	
-	if (tcp->csty & J3D_CP_CSTY_SOP) {
-		if ((*c) != 0xff || (*(c + 1) != 0x91)) {
-			opj_event_msg(t2->cinfo, EVT_WARNING, "Expected SOP marker\n");
-		} else {
-			c += 6;
-		}
-		
-		/** TODO : check the Nsop value */
-	}
-	
-	/* 
-	When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
-	This part deal with this caracteristic
-	step 1: Read packet header in the saved structure
-	step 2: Return to codestream for decoding 
-	*/
-
-	bio = bio_create();
-	
-	if (cp->ppm == 1) {		/* PPM */
-		hd = cp->ppm_data;
-		bio_init_dec(bio, hd, cp->ppm_len);
-	} else if (tcp->ppt == 1) {	/* PPT */
-		hd = tcp->ppt_data;
-		bio_init_dec(bio, hd, tcp->ppt_len);
-	} else {			/* Normal Case */
-		hd = c;
-		bio_init_dec(bio, hd, src+len-hd);
-	}
-	
-	present = bio_read(bio, 1);
-	
-	if (!present) {
-		bio_inalign(bio);
-		hd += bio_numbytes(bio);
-		bio_destroy(bio);
-		
-		/* EPH markers */
-		
-		if (tcp->csty & J3D_CP_CSTY_EPH) {
-			if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
-				printf("Error : expected EPH marker\n");
-			} else {
-				hd += 2;
-			}
-		}
-		
-		if (cp->ppm == 1) {		/* PPM case */
-			cp->ppm_len += cp->ppm_data-hd;
-			cp->ppm_data = hd;
-			return (c - src);
-		}
-		if (tcp->ppt == 1) {	/* PPT case */
-			tcp->ppt_len+=tcp->ppt_data-hd;
-			tcp->ppt_data = hd;
-			return (c - src);
-		}
-		
-		return (hd - src);
-	}
-	
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		
-		if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)||(band->z1-band->z0 == 0)) continue;
-		
-		for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-			int included, increment, n;
-			opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-			opj_tcd_seg_t *seg = NULL;
-			/* if cblk not yet included before --> inclusion tagtree */
-			if (!cblk->numsegs) {
-                included = tgt_decode(bio, prc->incltree, cblkno, layno + 1);
-				/* else one bit */
-			} else {
-				included = bio_read(bio, 1);
-			}
-			/* if cblk not included */
-			if (!included) {
-				cblk->numnewpasses = 0;
-				continue;
-			}
-			/* if cblk not yet included --> zero-bitplane tagtree */
-			if (!cblk->numsegs) {
-				int i, numimsbs;
-				for (i = 0; !tgt_decode(bio, prc->imsbtree, cblkno, i); i++);
-				numimsbs = i - 1;
-				cblk->numbps = band->numbps - numimsbs;
-				cblk->numlenbits = 3;
-			}
-			/* number of coding passes */
-			cblk->numnewpasses = t2_getnumpasses(bio);
-			increment = t2_getcommacode(bio);
-			/* length indicator increment */
-			cblk->numlenbits += increment;
-			if (!cblk->numsegs) {
-				seg = &cblk->segs[0];
-				t2_init_seg(seg, tcp->tccps[compno].cblksty, 1);
-			} else {
-				seg = &cblk->segs[cblk->numsegs - 1];
-				if (seg->numpasses == seg->maxpasses) {
-					t2_init_seg(++seg, tcp->tccps[compno].cblksty, 0);
-				}
-			}
-			n = cblk->numnewpasses;
-			
-			do {
-				seg->numnewpasses = int_min(seg->maxpasses - seg->numpasses, n);
-				seg->newlen = bio_read(bio, cblk->numlenbits + int_floorlog2(seg->numnewpasses));
-				n -= seg->numnewpasses;
-				if (n > 0) {
-					t2_init_seg(++seg, tcp->tccps[compno].cblksty, 0);
-				}
-			} while (n > 0);
-		}
-	}
-	
-	if (bio_inalign(bio)) {
-		bio_destroy(bio);
-		return -999;
-	}
-	
-	hd += bio_numbytes(bio);
-	bio_destroy(bio);
-	
-	/* EPH markers */
-	if (tcp->csty & J3D_CP_CSTY_EPH) {
-		if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
-			opj_event_msg(t2->cinfo, EVT_ERROR, "Expected EPH marker\n");
-		} else {
-			hd += 2;
-		}
-	}
-	
-	if (cp->ppm==1) {
-		cp->ppm_len+=cp->ppm_data-hd;
-		cp->ppm_data = hd;
-	} else if (tcp->ppt == 1) {
-		tcp->ppt_len+=tcp->ppt_data-hd;
-		tcp->ppt_data = hd;
-	} else {
-		c=hd;
-	}
-	
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		
-		if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)||(band->z1-band->z0 == 0)) continue;		
-
-		for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-			opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-			opj_tcd_seg_t *seg = NULL;
-			if (!cblk->numnewpasses)
-				continue;
-			if (!cblk->numsegs) {
-				seg = &cblk->segs[0];
-				cblk->numsegs++;
-				cblk->len = 0;
-			} else {
-				seg = &cblk->segs[cblk->numsegs - 1];
-				if (seg->numpasses == seg->maxpasses) {
-					seg++;
-					cblk->numsegs++;
-				}
-			}
-			
-			do {
-				if (c + seg->newlen > src + len) {
-					return -999;
-				}
-				
-				memcpy(cblk->data + cblk->len, c, seg->newlen);
-				if (seg->numpasses == 0) {
-					seg->data = cblk->data + cblk->len;
-				}
-				c += seg->newlen;
-				cblk->len += seg->newlen;
-				seg->len += seg->newlen;
-				seg->numpasses += seg->numnewpasses;
-				cblk->numnewpasses -= seg->numnewpasses;
-				if (cblk->numnewpasses > 0) {
-					seg++;
-					cblk->numsegs++;
-				}
-			} while (cblk->numnewpasses > 0);
-		}
-	}
-	
-	return (c - src);
-}
-
-/* ----------------------------------------------------------------------- */
-
-int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_volume_info_t *volume_info) {
-	unsigned char *c = dest;
-	int e = 0;
-	opj_pi_iterator_t *pi = NULL;
-	int pino;
-
-	opj_volume_t *volume = t2->volume;
-	opj_cp_t *cp = t2->cp;
-	
-	/* create a packet iterator */
-	pi = pi_create(volume, cp, tileno);
-	if(!pi) {
-		fprintf(stdout,"[ERROR] Failed to create a pi structure\n");
-		return -999;
-	}
-	
-	if(volume_info) {
-		volume_info->num = 0;
-	}
-	
-	for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
-		while (pi_next(&pi[pino])) {
-			if (pi[pino].layno < maxlayers) {
-				e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[pino], c, dest + len - c, volume_info, tileno, cp);
-				//opj_event_msg(t2->cinfo, EVT_INFO, "  t2_encode_packet: %d bytes coded\n",e);
-				if (e == -999) {
-					break;
-				} else {
-					c += e;
-				}
-				
-				/* INDEX >> */
-				if(volume_info && volume_info->index_on) {
-					if(volume_info->index_write) {
-						opj_tile_info_t *info_TL = &volume_info->tile[tileno];
-						opj_packet_info_t *info_PK = &info_TL->packet[volume_info->num];
-						if (!volume_info->num) {
-							info_PK->start_pos = info_TL->end_header + 1;
-						} else {
-							info_PK->start_pos = info_TL->packet[volume_info->num - 1].end_pos + 1;
-						}
-						info_PK->end_pos = info_PK->start_pos + e - 1;
-					}
-
-					volume_info->num++;
-				}
-				/* << INDEX */
-			}
-		}
-	}
-
-	/* don't forget to release pi */
-	pi_destroy(pi, cp, tileno);
-	
-	if (e == -999) {
-		return e;
-	}
-
-    return (c - dest);
-}
-
-int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile) {
-	unsigned char *c = src;
-	opj_pi_iterator_t *pi;
-	int pino, e = 0;
-	int n = 0,i;
-
-	opj_volume_t *volume = t2->volume;
-	opj_cp_t *cp = t2->cp;
-	
-	/* create a packet iterator */
-	pi = pi_create(volume, cp, tileno);
-	if(!pi) {
-		/* TODO: throw an error */
-		return -999;
-	}
-	
-	for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
-		while (pi_next(&pi[pino])) {
-			if ((cp->layer==0) || (cp->layer>=((pi[pino].layno)+1))) {
-				e = t2_decode_packet(t2, c, src + len - c, tile, &cp->tcps[tileno], &pi[pino]);
-			} else {
-				e = 0;
-			}
-			
-			/* progression in resolution */
-			for (i = 0; i < 3; i++){
-                volume->comps[pi[pino].compno].resno_decoded[i] = (e > 0) ? int_max(pi[pino].resno, volume->comps[pi[pino].compno].resno_decoded[i]) : volume->comps[pi[pino].compno].resno_decoded[i];
-			}
-			n++;
-			
-			if (e == -999) {		/* ADD */
-				break;
-			} else {
-				opj_event_msg(t2->cinfo, EVT_INFO, "  t2_decode_packet: %d bytes decoded\n",e);
-				c += e;
-			}
-		}
-	}
-
-	/* don't forget to release pi */
-	pi_destroy(pi, cp, tileno);
-	
-	if (e == -999) {
-		return e;
-	}
-	
-    return (c - src);
-}
-
-/* ----------------------------------------------------------------------- */
-
-opj_t2_t* t2_create(opj_common_ptr cinfo, opj_volume_t *volume, opj_cp_t *cp) {
-	/* create the tcd structure */
-	opj_t2_t *t2 = (opj_t2_t*)opj_malloc(sizeof(opj_t2_t));
-	if(!t2) return NULL;
-	t2->cinfo = cinfo;
-	t2->volume = volume;
-	t2->cp = cp;
-
-	return t2;
-}
-
-void t2_destroy(opj_t2_t *t2) {
-	if(t2) {
-		opj_free(t2);
-	}
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.h
deleted file mode 100755
index 191d0bc..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/t2.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __T2_H
-#define __T2_H
-/**
- at file t2.h
- at brief Implementation of a tier-2 coding (packetization of code-block data) (T2)
-
-*/
-
-/** @defgroup T2 T2 - Implementation of a tier-2 coding */
-/*@{*/
-
-/**
-Tier-2 coding
-*/
-typedef struct opj_t2 {
-/** Codec context */
-	opj_common_ptr cinfo;	
-/** Encoding: pointer to the src volume. Decoding: pointer to the dst volume. */
-	opj_volume_t *volume;	
-/** Pointer to the volume coding parameters */
-	opj_cp_t *cp;			
-} opj_t2_t;
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Encode the packets of a tile to a destination buffer
- at param t2 T2 handle
- at param tileno number of the tile encoded
- at param tile the tile for which to write the packets
- at param maxlayers maximum number of layers
- at param dest the destination buffer
- at param len the length of the destination buffer
- at param volume_info structure to create an index file
- at return Number of bytes written from packets
-*/
-int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_volume_info_t *volume_info);
-
-/**
-Decode the packets of a tile from a source buffer
- at param t2 T2 handle
- at param src the source buffer
- at param len length of the source buffer
- at param tileno number that identifies the tile for which to decode the packets
- at param tile tile for which to decode the packets
- at return Number of bytes read from packets
- */
-int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile);
-
-/**
-Create a T2 handle
- at param cinfo Codec context info
- at param volume Source or destination volume
- at param cp Volume coding parameters
- at return Returns a new T2 handle if successful, returns NULL otherwise
-*/
-opj_t2_t* t2_create(opj_common_ptr cinfo, opj_volume_t *volume, opj_cp_t *cp);
-/**
-Destroy a T2 handle
- at param t2 T2 handle to destroy
-*/
-void t2_destroy(opj_t2_t *t2);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __T2_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.c
deleted file mode 100755
index b0184d5..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.c
+++ /dev/null
@@ -1,1738 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez, LPI-UVA, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_volume_t * vol) {
-	int tileno, compno, resno, bandno, precno, cblkno;
-
-	fprintf(fd, "volume {\n");
-	fprintf(fd, "  tw=%d, th=%d, tl=%d, x0=%d x1=%d y0=%d y1=%d z0=%d z1=%d\n", 
-		vol->tw, vol->th, vol->tl, tcd->volume->x0, tcd->volume->x1, tcd->volume->y0, tcd->volume->y1, tcd->volume->z0, tcd->volume->z1);
-
-	for (tileno = 0; tileno < vol->th * vol->tw * vol->tl; tileno++) {
-		opj_tcd_tile_t *tile = &tcd->tcd_volume->tiles[tileno];
-		fprintf(fd, "  tile {\n");
-		fprintf(fd, "    x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d, numcomps=%d\n",
-			tile->x0, tile->y0, tile->z0, tile->x1, tile->y1, tile->z1, tile->numcomps);
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-			fprintf(fd, "    tilecomp %d {\n",compno);
-			fprintf(fd,	"     x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d, numresx=%d, numresy=%d, numresz=%d\n",
-				tilec->x0, tilec->y0, tilec->z0, tilec->x1, tilec->y1, tilec->z1, tilec->numresolution[0], tilec->numresolution[1], tilec->numresolution[2]);
-			for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-				opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-				fprintf(fd, "     res %d{\n",resno);
-				fprintf(fd,"      x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d, pw=%d, ph=%d, pl=%d, numbands=%d\n",
-					res->x0, res->y0, res->z0, res->x1, res->y1, res->z1, res->prctno[0], res->prctno[1], res->prctno[2], res->numbands);
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					opj_tcd_band_t *band = &res->bands[bandno];
-					fprintf(fd, "       band %d{\n", bandno);
-					fprintf(fd,	"		 x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d, stepsize=%f, numbps=%d\n",
-						band->x0, band->y0, band->z0, band->x1, band->y1, band->z1, band->stepsize, band->numbps);
-					for (precno = 0; precno < (res->prctno[0] * res->prctno[1] * res->prctno[2]); precno++) {
-						opj_tcd_precinct_t *prec = &band->precincts[precno];
-						fprintf(fd, "		  prec %d{\n",precno);
-						fprintf(fd,	"		   x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d, cw=%d, ch=%d, cl=%d,\n",
-							prec->x0, prec->y0, prec->z0, prec->x1, prec->y1, prec->z1, prec->cblkno[0], prec->cblkno[1], prec->cblkno[2]);
-						for (cblkno = 0; cblkno < (prec->cblkno[0] * prec->cblkno[1] * prec->cblkno[2]); cblkno++) {
-							opj_tcd_cblk_t *cblk = &prec->cblks[cblkno];
-							fprintf(fd, "		    cblk %d{\n",cblkno);
-							fprintf(fd,	"		     x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d\n", cblk->x0, cblk->y0, cblk->z0, cblk->x1, cblk->y1, cblk->z1);
-							fprintf(fd, "            }\n");
-						}
-						fprintf(fd, "          }\n");
-					}
-					fprintf(fd, "        }\n");
-				}
-				fprintf(fd, "      }\n");
-			}
-			fprintf(fd, "    }\n");
-		}
-		fprintf(fd, "  }\n");
-	}
-	fprintf(fd, "}\n");
-}
-
-void tilec_dump(FILE *fd, opj_tcd_tilecomp_t *tilec) {
-
-	int i=0,k;
-	int datalen;
-	int *a;
-
-	fprintf(fd, "    tilecomp{\n");
-	fprintf(fd,	"     x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d, numresx=%d, numresy=%d, numresz=%d\n",
-		tilec->x0, tilec->y0, tilec->z0, tilec->x1, tilec->y1, tilec->z1, tilec->numresolution[0], tilec->numresolution[1], tilec->numresolution[2]);
-	fprintf(fd, "     data {\n");
-	datalen = (tilec->z1 - tilec->z0) * (tilec->y1 - tilec->y0) * (tilec->x1 - tilec->x0);
-	a = tilec->data;
-	for (k = 0; k < datalen; k++) {
-		if (!(k % tilec->x1)){
-			fprintf(fd, "\n");
-		}
-		if (!(k % (tilec->y1 * tilec->x1))){
-			fprintf(fd, "Slice %d\n",i++);
-		}
-		fprintf(fd," %d",a[k]);
-		
-		
-	}			
-	fprintf(fd, "     }\n");
-	/*i=0;
-	fprintf(fd, "Slice %d\n");
-	if (tilec->prediction->prederr) {
-		fprintf(fd, "     prederror {\n");
-		a = tilec->prediction->prederr;
-		for (k = 0; k < datalen; k++) {
-			fprintf(fd," %d",*(a++));
-			if (!(k % (tilec->y1 - tilec->y0) * (tilec->x1 - tilec->x0))){
-				fprintf(fd, "\n");fprintf(fd, "Slice %d\n",i++);
-			}
-			if (!(k % (tilec->x1 - tilec->x0))){
-				fprintf(fd, "\n");
-			}
-		}
-	}
-	fprintf(fd, "     }\n");*/
-	fprintf(fd, "}\n");
-}
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Create a new TCD handle
-*/
-opj_tcd_t* tcd_create(opj_common_ptr cinfo) {
-	/* create the tcd structure */
-	opj_tcd_t *tcd = (opj_tcd_t*)opj_malloc(sizeof(opj_tcd_t));
-	if(!tcd) return NULL;
-	tcd->cinfo = cinfo;
-	tcd->tcd_volume = (opj_tcd_volume_t*)opj_malloc(sizeof(opj_tcd_volume_t));
-	if(!tcd->tcd_volume) {
-		opj_free(tcd);
-		return NULL;
-	}
-
-	return tcd;
-}
-
-/**
-Destroy a previously created TCD handle
-*/
-void tcd_destroy(opj_tcd_t *tcd) {
-	if(tcd) {
-		opj_free(tcd->tcd_volume);
-		opj_free(tcd);
-	}
-}
-
-/* ----------------------------------------------------------------------- */
-void tcd_malloc_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno) {
-	int compno, resno, bandno, precno, cblkno, i, j;//, k;
-
-	opj_tcd_tile_t		*tile = NULL;		/* pointer to tcd->tile */
-	opj_tcd_tilecomp_t	*tilec = NULL;		/* pointer to tcd->tilec */
-	opj_tcd_resolution_t	*res = NULL;		/* pointer to tcd->res */
-	opj_tcd_band_t		*band = NULL;		/* pointer to tcd->band */
-	opj_tcd_precinct_t	*prc = NULL;		/* pointer to tcd->prc */
-	opj_tcd_cblk_t		*cblk = NULL;		/* pointer to tcd->cblk */
-	opj_tcp_t		*tcp = &cp->tcps[curtileno];
-	int p,q,r;
-
-	tcd->volume = volume;
-	tcd->cp = cp;
-	tcd->tcd_volume->tw = cp->tw;
-	tcd->tcd_volume->th = cp->th;
-	tcd->tcd_volume->tl = cp->tl;
-	tcd->tcd_volume->tiles = (opj_tcd_tile_t *) opj_malloc(sizeof(opj_tcd_tile_t));
-	tcd->tile = tcd->tcd_volume->tiles;
-	tile = tcd->tile;
-	
-
-	/* p61 ISO/IEC IS15444-1 : 2002 */
-	/* curtileno --> raster scanned index of tiles */
-	/* p,q,r --> matricial index of tiles */
-	p = curtileno % cp->tw;	
-	q = curtileno / cp->tw;	
-	r = curtileno / (cp->tw * cp->th); /* extension to 3-D */
-
-	/* 4 borders of the tile rescale on the volume if necessary (B.3)*/
-	tile->x0 = int_max(cp->tx0 + p * cp->tdx, volume->x0);
-	tile->y0 = int_max(cp->ty0 + q * cp->tdy, volume->y0);
-	tile->z0 = int_max(cp->tz0 + r * cp->tdz, volume->z0);
-	tile->x1 = int_min(cp->tx0 + (p + 1) * cp->tdx, volume->x1);
-	tile->y1 = int_min(cp->ty0 + (q + 1) * cp->tdy, volume->y1);
-	tile->z1 = int_min(cp->tz0 + (r + 1) * cp->tdz, volume->z1);
-	tile->numcomps = volume->numcomps;
-
-	/* Modification of the RATE >> */
-	for (j = 0; j < tcp->numlayers; j++) {
-		if (tcp->rates[j] <= 1) {
-			tcp->rates[j] = 0;
-		} else {
-			float num = (float) (tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * (tile->z1 - tile->z0) * volume->comps[0].prec);
-			float den = (float) (8 * volume->comps[0].dx * volume->comps[0].dy * volume->comps[0].dz);
-			den = tcp->rates[j] * den;
-			tcp->rates[j] = (num + den - 1) / den;
-		}
-		/*tcp->rates[j] = tcp->rates[j] ? int_ceildiv(
-			tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * (tile->z1 - tile->z0) * volume->comps[0].prec,
-            (tcp->rates[j] * 8 * volume->comps[0].dx * volume->comps[0].dy * volume->comps[0].dz)) : 0;*/
-		if (tcp->rates[j]) {
-			if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
-				tcp->rates[j] = tcp->rates[j - 1] + 20;
-			} else if (!j && tcp->rates[j] < 30){
-				tcp->rates[j] = 30;
-			}
-		}
-	}
-	/* << Modification of the RATE */
-
-	tile->comps = (opj_tcd_tilecomp_t *) opj_malloc(volume->numcomps * sizeof(opj_tcd_tilecomp_t));
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tccp_t *tccp = &tcp->tccps[compno];
-		int res_max;
-		int prevnumbands = 0;
-
-		/* opj_tcd_tilecomp_t *tilec=&tile->comps[compno]; */
-		tcd->tilec = &tile->comps[compno];
-		tilec = tcd->tilec;
-
-		/* border of each tile component (global) (B.3) */
-		tilec->x0 = int_ceildiv(tile->x0, volume->comps[compno].dx);
-		tilec->y0 = int_ceildiv(tile->y0, volume->comps[compno].dy);
-		tilec->z0 = int_ceildiv(tile->z0, volume->comps[compno].dz);
-		tilec->x1 = int_ceildiv(tile->x1, volume->comps[compno].dx);
-		tilec->y1 = int_ceildiv(tile->y1, volume->comps[compno].dy);
-		tilec->z1 = int_ceildiv(tile->z1, volume->comps[compno].dz);
-
-		tilec->data = (int *) opj_malloc((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0) * (tilec->z1 - tilec->z0) * sizeof(int));
-		
-		res_max = 0;
-		for (i = 0;i < 3; i++){
-			tilec->numresolution[i] = tccp->numresolution[i];
-			//Greater of 3 resolutions contains all information
-			res_max = (tilec->numresolution[i] > res_max) ? tilec->numresolution[i] : res_max;
-		}
-		
-
-		tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(res_max * sizeof(opj_tcd_resolution_t));
-		for (resno = 0; resno < res_max; resno++) {
-			
-			int pdx, pdy, pdz;
-			int tlprcxstart, tlprcystart, tlprczstart;
-			int brprcxend, brprcyend, brprczend;
-			int tlcbgxstart, tlcbgystart, tlcbgzstart;
-			int brcbgxend, brcbgyend, brcbgzend;
-			int cbgwidthexpn, cbgheightexpn, cbglengthexpn;
-			int cblkwidthexpn, cblkheightexpn, cblklengthexpn;
-
-			int diff = tccp->numresolution[0] - tccp->numresolution[2]; 
-			int levelnox = tilec->numresolution[0] - 1 - resno; 
-			int levelnoy = tilec->numresolution[1] - 1 - resno;
-			int levelnoz = tilec->numresolution[2] - 1 - ((resno <= diff) ? 0 : (resno - diff));
-				if (levelnoz < 0) levelnoz = 0;
-
-			/* opj_tcd_resolution_t *res=&tilec->resolutions[resno]; */
-			tcd->res = &tilec->resolutions[resno];
-			res = tcd->res;
-			
-			/* border for each resolution level (global) (B.14)*/
-			res->x0 = int_ceildivpow2(tilec->x0, levelnox);
-			res->y0 = int_ceildivpow2(tilec->y0, levelnoy);
-			res->z0 = int_ceildivpow2(tilec->z0, levelnoz);
-			res->x1 = int_ceildivpow2(tilec->x1, levelnox);
-			res->y1 = int_ceildivpow2(tilec->y1, levelnoy);
-			res->z1 = int_ceildivpow2(tilec->z1, levelnoz);
-			//if (res->z1 < 0)fprintf(stdout,"Res: %d       %d/%d --> %d\n",resno,tilec->z1, levelnoz, int_ceildivpow2(tilec->z1, levelnoz));
-
-			res->numbands = (resno == 0) ? 1 : (resno <= diff) ? 3 : 7; /* --> 3D */
-
-			/* p. 30, table A-13, ISO/IEC IS154444-1 : 2002 */
-			if (tccp->csty & J3D_CCP_CSTY_PRT) {
-				pdx = tccp->prctsiz[0][resno];
-				pdy = tccp->prctsiz[1][resno];
-				pdz = tccp->prctsiz[2][resno];
-			} else {
-				pdx = 15;
-				pdy = 15;
-				pdz = 15;
-			}
-			
-			/* p. 66, B.16, ISO/IEC IS15444-1 : 2002  */
-			tlprcxstart = int_floordivpow2(res->x0, pdx) << pdx;
-			tlprcystart = int_floordivpow2(res->y0, pdy) << pdy;
-			tlprczstart = int_floordivpow2(res->z0, pdz) << pdz;
-			brprcxend = int_ceildivpow2(res->x1, pdx) << pdx;
-			brprcyend = int_ceildivpow2(res->y1, pdy) << pdy;
-			brprczend = int_ceildivpow2(res->z1, pdz) << pdz;
-			
-			res->prctno[0] = (brprcxend - tlprcxstart) >> pdx;
-			res->prctno[1] = (brprcyend - tlprcystart) >> pdy;
-			res->prctno[2] = (brprczend - tlprczstart) >> pdz;
-				if (res->prctno[2] == 0) res->prctno[2] = 1;
-				
-			/* p. 67, B.17 & B.18, ISO/IEC IS15444-1 : 2002  */
-			if (resno == 0) {
-				tlcbgxstart = tlprcxstart;
-				tlcbgystart = tlprcystart;
-				tlcbgzstart = tlprczstart;
-				brcbgxend = brprcxend;
-				brcbgyend = brprcyend;
-				brcbgzend = brprczend;
-				cbgwidthexpn = pdx;
-				cbgheightexpn = pdy;
-				cbglengthexpn = pdz;
-			} else {
-				tlcbgxstart = int_ceildivpow2(tlprcxstart, 1);
-				tlcbgystart = int_ceildivpow2(tlprcystart, 1);
-				tlcbgzstart = int_ceildivpow2(tlprczstart, 1);
-				brcbgxend = int_ceildivpow2(brprcxend, 1);
-				brcbgyend = int_ceildivpow2(brprcyend, 1);
-				brcbgzend = int_ceildivpow2(brprczend, 1);
-				cbgwidthexpn = pdx - 1;
-				cbgheightexpn = pdy - 1;
-				cbglengthexpn = pdz - 1;
-			}
-			
-			cblkwidthexpn = int_min(tccp->cblk[0], cbgwidthexpn); //6
-			cblkheightexpn = int_min(tccp->cblk[1], cbgheightexpn); //6
-			cblklengthexpn = int_min(tccp->cblk[2], cbglengthexpn); //6
-			
-			res->bands = (opj_tcd_band_t *) opj_malloc(res->numbands * sizeof(opj_tcd_band_t));
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				int x0b, y0b, z0b, i;
-				int gain, numbps;
-				opj_stepsize_t *ss = NULL;
-
-				tcd->band = &res->bands[bandno];
-				band = tcd->band;
-
-				band->bandno = (resno == 0) ? 0 : bandno + 1;
-				/* Bandno:	0 - LLL 	2 - LHL 
-							1 - HLL		3 - HHL
-							4 - LLH		6 - LHH
-							5 - HLH		7 - HHH		*/
-				x0b = (band->bandno == 1) || (band->bandno == 3) || (band->bandno == 5 ) || (band->bandno == 7 ) ? 1 : 0; 
-				y0b = (band->bandno == 2) || (band->bandno == 3) || (band->bandno == 6 ) || (band->bandno == 7 ) ? 1 : 0;
-				z0b = (band->bandno == 4) || (band->bandno == 5) || (band->bandno == 6 ) || (band->bandno == 7 ) ? 1 : 0; 
-				
-				/* p. 65, B.15, ISO/IEC IS15444-1 : 2002  */
-				if (band->bandno == 0) {
-					/* band border (global) */
-					band->x0 = int_ceildivpow2(tilec->x0, levelnox);
-					band->y0 = int_ceildivpow2(tilec->y0, levelnoy);
-					band->z0 = int_ceildivpow2(tilec->z0, levelnoz);
-					band->x1 = int_ceildivpow2(tilec->x1, levelnox);
-					band->y1 = int_ceildivpow2(tilec->y1, levelnoy);
-					band->z1 = int_ceildivpow2(tilec->z1, levelnoz);
-				} else {
-					band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelnox) * x0b, levelnox + 1);
-					band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelnoy) * y0b, levelnoy + 1);
-					band->z0 = int_ceildivpow2(tilec->z0 - (1 << levelnoz) * z0b, (resno <= diff) ? levelnoz : levelnoz + 1);
-					band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelnox) * x0b, levelnox + 1);
-					band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelnoy) * y0b, levelnoy + 1);
-					band->z1 = int_ceildivpow2(tilec->z1 - (1 << levelnoz) * z0b, (resno <= diff) ? levelnoz : levelnoz + 1);
-				}
-				
-				ss = &tccp->stepsizes[(resno == 0) ? 0 : (prevnumbands + bandno + 1)];
-				if (bandno == (res->numbands - 1)) 
-					prevnumbands += (resno == 0) ? 0 : res->numbands;
-				gain = dwt_getgain(band->bandno,tccp->reversible);					
-				numbps = volume->comps[compno].prec + gain;
- 				band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
-				band->numbps = ss->expn + tccp->numgbits - 1;	/* WHY -1 ? */
-				
-				band->precincts = (opj_tcd_precinct_t *) opj_malloc((res->prctno[0] * res->prctno[1] * res->prctno[2]) * sizeof(opj_tcd_precinct_t));
-				
-				for (i = 0; i < (res->prctno[0] * res->prctno[1] * res->prctno[2]); i++) {
-					band->precincts[i].imsbtree = NULL;
-					band->precincts[i].incltree = NULL;
-				}
-
-				for (precno = 0; precno < (res->prctno[0] * res->prctno[1] * res->prctno[2]); precno++) {
-					int tlcblkxstart, tlcblkystart, tlcblkzstart, brcblkxend, brcblkyend, brcblkzend;
-					int cbgxstart, cbgystart, cbgzstart, cbgxend, cbgyend, cbgzend;
-
-					cbgxstart = tlcbgxstart + (precno % res->prctno[0]) * (1 << cbgwidthexpn);
-					cbgystart = tlcbgystart + ((precno % (res->prctno[0] * res->prctno[1])) / res->prctno[0]) * (1 << cbgheightexpn);
-					cbgzstart = tlcbgzstart + (precno / (res->prctno[0] * res->prctno[1])) * (1 << cbglengthexpn);
-					cbgxend = cbgxstart + (1 << cbgwidthexpn);
-					cbgyend = cbgystart + (1 << cbgheightexpn);
-					cbgzend = cbgzstart + (1 << cbglengthexpn);
-					
-					tcd->prc = &band->precincts[precno];
-					prc = tcd->prc;
-
-					/* precinct size (global) */
-					prc->x0 = int_max(cbgxstart, band->x0);
-					prc->y0 = int_max(cbgystart, band->y0);
-					prc->z0 = int_max(cbgzstart, band->z0);
-					prc->x1 = int_min(cbgxend, band->x1);
-					prc->y1 = int_min(cbgyend, band->y1);
-					prc->z1 = int_min(cbgzend, band->z1);
-					
-					tlcblkxstart = int_floordivpow2(prc->x0, cblkwidthexpn) << cblkwidthexpn;
-					tlcblkystart = int_floordivpow2(prc->y0, cblkheightexpn) << cblkheightexpn;
-					tlcblkzstart = int_floordivpow2(prc->z0, cblklengthexpn) << cblklengthexpn;
-					brcblkxend = int_ceildivpow2(prc->x1, cblkwidthexpn) << cblkwidthexpn;
-					brcblkyend = int_ceildivpow2(prc->y1, cblkheightexpn) << cblkheightexpn;
-					brcblkzend = int_ceildivpow2(prc->z1, cblklengthexpn) << cblklengthexpn;
-					prc->cblkno[0] = (brcblkxend - tlcblkxstart) >> cblkwidthexpn;
-					prc->cblkno[1] = (brcblkyend - tlcblkystart) >> cblkheightexpn;
-					prc->cblkno[2] = (brcblkzend - tlcblkzstart) >> cblklengthexpn;
-					prc->cblkno[2] = (prc->cblkno[2] == 0) ? 1 : prc->cblkno[2];
-
-					prc->cblks = (opj_tcd_cblk_t *) opj_malloc((prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]) * sizeof(opj_tcd_cblk_t));
-					prc->incltree = tgt_create(prc->cblkno[0], prc->cblkno[1], prc->cblkno[2]);
-					prc->imsbtree = tgt_create(prc->cblkno[0], prc->cblkno[1], prc->cblkno[2]);
-					//tgt_tree_dump(stdout,prc->incltree);
-					for (cblkno = 0; cblkno < (prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]); cblkno++) {
-						int cblkxstart = tlcblkxstart + (cblkno % prc->cblkno[0]) * (1 << cblkwidthexpn);
-						int cblkystart = tlcblkystart + ((cblkno % (prc->cblkno[0] * prc->cblkno[1])) / prc->cblkno[0]) * (1 << cblkheightexpn);
-						int cblkzstart = tlcblkzstart + (cblkno / (prc->cblkno[0] * prc->cblkno[1])) * (1 << cblklengthexpn);
-						int cblkxend = cblkxstart + (1 << cblkwidthexpn);
-						int cblkyend = cblkystart + (1 << cblkheightexpn);
-						int cblkzend = cblkzstart + (1 << cblklengthexpn);
-						int prec = ((tilec->bpp > 16) ? 3 : ((tilec->bpp > 8) ? 2 : 1));
-						
-						tcd->cblk = &prc->cblks[cblkno];
-						cblk = tcd->cblk;
-
-						/* code-block size (global) */
-						cblk->x0 = int_max(cblkxstart, prc->x0);
-						cblk->y0 = int_max(cblkystart, prc->y0);
-						cblk->z0 = int_max(cblkzstart, prc->z0);
-						cblk->x1 = int_min(cblkxend, prc->x1);
-						cblk->y1 = int_min(cblkyend, prc->y1);
-						cblk->z1 = int_min(cblkzend, prc->z1);
-					}					
-				}
-			}
-		}
-	}
-	//tcd_dump(stdout, tcd, tcd->tcd_volume);
-
-}
-void tcd_init_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno) {
-	int compno, resno, bandno, precno, cblkno;
-	int j, p, q, r;
-
-	opj_tcd_tile_t		*tile = NULL;		/* pointer to tcd->tile */
-	opj_tcd_tilecomp_t	*tilec = NULL;		/* pointer to tcd->tilec */
-	opj_tcd_resolution_t	*res = NULL;	/* pointer to tcd->res */
-	opj_tcd_band_t		*band = NULL;		/* pointer to tcd->band */
-	opj_tcd_precinct_t	*prc = NULL;		/* pointer to tcd->prc */
-	opj_tcd_cblk_t		*cblk = NULL;		/* pointer to tcd->cblk */
-	opj_tcp_t *tcp = &cp->tcps[curtileno];
-
-	tcd->tile = tcd->tcd_volume->tiles;
-	tile = tcd->tile;
-
-	/* p61 ISO/IEC IS15444-1 : 2002 */
-	/* curtileno --> raster scanned index of tiles */
-	/* p,q,r --> matricial index of tiles */
-	p = curtileno % cp->tw;	
-	q = curtileno / cp->tw;	
-	r = curtileno / (cp->tw * cp->th); /* extension to 3-D */
-	
-	/* 4 borders of the tile rescale on the volume if necessary (B.3)*/
-	tile->x0 = int_max(cp->tx0 + p * cp->tdx, volume->x0);
-	tile->y0 = int_max(cp->ty0 + q * cp->tdy, volume->y0);
-	tile->z0 = int_max(cp->tz0 + r * cp->tdz, volume->z0);
-	tile->x1 = int_min(cp->tx0 + (p + 1) * cp->tdx, volume->x1);
-	tile->y1 = int_min(cp->ty0 + (q + 1) * cp->tdy, volume->y1);
-	tile->z1 = int_min(cp->tz0 + (r + 1) * cp->tdz, volume->z1);
-	tile->numcomps = volume->numcomps;
-
-	/* Modification of the RATE >> */
-	for (j = 0; j < tcp->numlayers; j++) {
-		if (tcp->rates[j] <= 1) {
-			tcp->rates[j] = 0;
-		} else {
-			float num = (float) (tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * (tile->z1 - tile->z0) * volume->comps[0].prec);
-			float den = (float) (8 * volume->comps[0].dx * volume->comps[0].dy * volume->comps[0].dz);
-			den = tcp->rates[j] * den;
-			tcp->rates[j] = (num + den - 1) / den;
-		}
-		/*tcp->rates[j] = tcp->rates[j] ? int_ceildiv(
-			tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * (tile->z1 - tile->z0) * volume->comps[0].prec,
-            (tcp->rates[j] * 8 * volume->comps[0].dx * volume->comps[0].dy * volume->comps[0].dz)) : 0;*/
-		if (tcp->rates[j]) {
-			if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
-				tcp->rates[j] = tcp->rates[j - 1] + 20;
-			} else if (!j && tcp->rates[j] < 30){
-				tcp->rates[j] = 30;
-			}
-		}
-	}
-	/* << Modification of the RATE */
-
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tccp_t *tccp = &tcp->tccps[compno];
-		int res_max, i;
-		int prevnumbands = 0;
-
-		/* opj_tcd_tilecomp_t *tilec=&tile->comps[compno]; */
-		tcd->tilec = &tile->comps[compno];
-		tilec = tcd->tilec;
-
-		/* border of each tile component (global) (B.3) */
-		tilec->x0 = int_ceildiv(tile->x0, volume->comps[compno].dx);
-		tilec->y0 = int_ceildiv(tile->y0, volume->comps[compno].dy);
-		tilec->z0 = int_ceildiv(tile->z0, volume->comps[compno].dz);
-		tilec->x1 = int_ceildiv(tile->x1, volume->comps[compno].dx);
-		tilec->y1 = int_ceildiv(tile->y1, volume->comps[compno].dy);
-		tilec->z1 = int_ceildiv(tile->z1, volume->comps[compno].dz);
-
-		tilec->data = (int *) opj_malloc((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0) * (tilec->z1 - tilec->z0) * sizeof(int));
-		
-		res_max = 0;
-		for (i = 0;i < 3; i++){
-			tilec->numresolution[i] = tccp->numresolution[i];
-			//Greater of 3 resolutions contains all information
-			res_max = (tilec->numresolution[i] > res_max) ? tilec->numresolution[i] : res_max;
-		}
-
-		tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(res_max * sizeof(opj_tcd_resolution_t));
-		for (resno = 0; resno < res_max; resno++) {
-			int pdx, pdy, pdz;
-			int tlprcxstart, tlprcystart, tlprczstart, brprcxend, brprcyend, brprczend;
-			int tlcbgxstart, tlcbgystart, tlcbgzstart, brcbgxend, brcbgyend, brcbgzend;
-			int cbgwidthexpn, cbgheightexpn, cbglengthexpn;
-			int cblkwidthexpn, cblkheightexpn, cblklengthexpn;
-			
-			int levelnox = tilec->numresolution[0] - 1 - resno; 
-			int levelnoy = tilec->numresolution[1] - 1 - resno;
-			int diff = tccp->numresolution[0] - tccp->numresolution[2]; 
-			int levelnoz = tilec->numresolution[2] - 1 - ((resno <= diff) ? 0 : (resno - diff));
-				if (levelnoz < 0) levelnoz = 0;
-
-			tcd->res = &tilec->resolutions[resno];
-			res = tcd->res;
-			
-			/* border for each resolution level (global) (B.14)*/
-			res->x0 = int_ceildivpow2(tilec->x0, levelnox);
-			res->y0 = int_ceildivpow2(tilec->y0, levelnoy);
-			res->z0 = int_ceildivpow2(tilec->z0, levelnoz);
-			res->x1 = int_ceildivpow2(tilec->x1, levelnox);
-			res->y1 = int_ceildivpow2(tilec->y1, levelnoy);
-			res->z1 = int_ceildivpow2(tilec->z1, levelnoz);
-
-			// res->numbands = resno == 0 ? 1 : 3; /* --> 2D */
-			res->numbands = (resno == 0) ? 1 : (resno <= diff) ? 3 : 7; /* --> 3D */
-
-			/* p. 30, table A-13, ISO/IEC IS154444-1 : 2002 */			
-			if (tccp->csty & J3D_CCP_CSTY_PRT) {
-				pdx = tccp->prctsiz[0][resno];
-				pdy = tccp->prctsiz[1][resno];
-				pdz = tccp->prctsiz[2][resno];
-			} else {
-				pdx = 15;
-				pdy = 15;
-				pdz = 15;
-			}
-			/* p. 66, B.16, ISO/IEC IS15444-1 : 2002  */
-			tlprcxstart = int_floordivpow2(res->x0, pdx) << pdx;
-			tlprcystart = int_floordivpow2(res->y0, pdy) << pdy;
-			tlprczstart = int_floordivpow2(res->z0, pdz) << pdz;
-			brprcxend = int_ceildivpow2(res->x1, pdx) << pdx;
-			brprcyend = int_ceildivpow2(res->y1, pdy) << pdy;
-			brprczend = int_ceildivpow2(res->z1, pdz) << pdz;
-			
-			res->prctno[0] = (brprcxend - tlprcxstart) >> pdx;
-			res->prctno[1] = (brprcyend - tlprcystart) >> pdy;
-			res->prctno[2] = (brprczend - tlprczstart) >> pdz;
-			if (res->prctno[2] == 0) res->prctno[2] = 1;
-
-			/* p. 67, B.17 & B.18, ISO/IEC IS15444-1 : 2002  */
-			if (resno == 0) {
-				tlcbgxstart = tlprcxstart;
-				tlcbgystart = tlprcystart;
-				tlcbgzstart = tlprczstart;
-				brcbgxend = brprcxend;
-				brcbgyend = brprcyend;
-				brcbgzend = brprczend;
-				cbgwidthexpn = pdx;
-				cbgheightexpn = pdy;
-				cbglengthexpn = pdz;
-			} else {
-				tlcbgxstart = int_ceildivpow2(tlprcxstart, 1);
-				tlcbgystart = int_ceildivpow2(tlprcystart, 1);
-				tlcbgzstart = int_ceildivpow2(tlprczstart, 1);
-				brcbgxend = int_ceildivpow2(brprcxend, 1);
-				brcbgyend = int_ceildivpow2(brprcyend, 1);
-				brcbgzend = int_ceildivpow2(brprczend, 1);
-				cbgwidthexpn = pdx - 1;
-				cbgheightexpn = pdy - 1;
-				cbglengthexpn = pdz - 1;
-			}
-			
-			cblkwidthexpn = int_min(tccp->cblk[0], cbgwidthexpn);
-			cblkheightexpn = int_min(tccp->cblk[1], cbgheightexpn);
-			cblklengthexpn = int_min(tccp->cblk[2], cbglengthexpn);
-			
-			res->bands = (opj_tcd_band_t *) opj_malloc(res->numbands * sizeof(opj_tcd_band_t));
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				int x0b, y0b, z0b;
-				int gain, numbps;
-				opj_stepsize_t *ss = NULL;
-
-				tcd->band = &res->bands[bandno];
-				band = tcd->band;
-
-				band->bandno = resno == 0 ? 0 : bandno + 1;
-				/* Bandno:	0 - LLL 	2 - LHL 
-							1 - HLL		3 - HHL
-							4 - LLH		6 - LHH
-							5 - HLH		7 - HHH		*/
-				x0b = (band->bandno == 1) || (band->bandno == 3) || (band->bandno == 5 ) || (band->bandno == 7 ) ? 1 : 0; 
-				y0b = (band->bandno == 2) || (band->bandno == 3) || (band->bandno == 6 ) || (band->bandno == 7 ) ? 1 : 0;
-				z0b = (band->bandno == 4) || (band->bandno == 5) || (band->bandno == 6 ) || (band->bandno == 7 ) ? 1 : 0; 
-				
-				/* p. 65, B.15, ISO/IEC IS15444-1 : 2002  */
-				if (band->bandno == 0) {
-					/* band border (global) */
-					band->x0 = int_ceildivpow2(tilec->x0, levelnox);
-					band->y0 = int_ceildivpow2(tilec->y0, levelnoy);
-					band->z0 = int_ceildivpow2(tilec->z0, levelnoz);
-					band->x1 = int_ceildivpow2(tilec->x1, levelnox);
-					band->y1 = int_ceildivpow2(tilec->y1, levelnoy);
-					band->z1 = int_ceildivpow2(tilec->z1, levelnoz);
-				} else {
-					band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelnox) * x0b, levelnox + 1);
-					band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelnoy) * y0b, levelnoy + 1);
-					band->z0 = int_ceildivpow2(tilec->z0 - (1 << levelnoz) * z0b, (resno <= diff) ? levelnoz : levelnoz + 1);
-					band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelnox) * x0b, levelnox + 1);
-					band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelnoy) * y0b, levelnoy + 1);
-					band->z1 = int_ceildivpow2(tilec->z1 - (1 << levelnoz) * z0b, (resno <= diff) ? levelnoz : levelnoz + 1);
-				}
-								
-				ss = &tccp->stepsizes[(resno == 0) ? 0 : (prevnumbands + bandno + 1)];
-				if (bandno == (res->numbands - 1)) 
-					prevnumbands += (resno == 0) ? 0 : res->numbands;
-				gain = dwt_getgain(band->bandno,tccp->reversible);					
-				numbps = volume->comps[compno].prec + gain;
-				
-				band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
-				band->numbps = ss->expn + tccp->numgbits - 1;	/* WHY -1 ? */
-				
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					int tlcblkxstart, tlcblkystart, tlcblkzstart, brcblkxend, brcblkyend, brcblkzend;
-
-					int cbgxstart = tlcbgxstart + (precno % res->prctno[0]) * (1 << cbgwidthexpn);
-					int cbgystart = tlcbgystart + ((precno / (res->prctno[0] * res->prctno[1])) / res->prctno[0]) * (1 << cbgheightexpn);
-					int cbgzstart = tlcbgzstart + (precno / (res->prctno[0] * res->prctno[1])) * (1 << cbglengthexpn);
-					int cbgxend = cbgxstart + (1 << cbgwidthexpn);
-					int cbgyend = cbgystart + (1 << cbgheightexpn);
-					int cbgzend = cbgzstart + (1 << cbglengthexpn);
-
-					/* opj_tcd_precinct_t *prc=&band->precincts[precno]; */
-					tcd->prc = &band->precincts[precno];
-					prc = tcd->prc;
-
-					/* precinct size (global) */
-					prc->x0 = int_max(cbgxstart, band->x0);
-					prc->y0 = int_max(cbgystart, band->y0);
-					prc->z0 = int_max(cbgzstart, band->z0);
-					prc->x1 = int_min(cbgxend, band->x1);
-					prc->y1 = int_min(cbgyend, band->y1);
-					prc->z1 = int_min(cbgzend, band->z1);
-
-					tlcblkxstart = int_floordivpow2(prc->x0, cblkwidthexpn) << cblkwidthexpn;
-					tlcblkystart = int_floordivpow2(prc->y0, cblkheightexpn) << cblkheightexpn;
-					tlcblkzstart = int_floordivpow2(prc->z0, cblklengthexpn) << cblklengthexpn;
-					brcblkxend = int_ceildivpow2(prc->x1, cblkwidthexpn) << cblkwidthexpn;
-					brcblkyend = int_ceildivpow2(prc->y1, cblkheightexpn) << cblkheightexpn;
-					brcblkzend = int_ceildivpow2(prc->z1, cblklengthexpn) << cblklengthexpn;
-					prc->cblkno[0] = (brcblkxend - tlcblkxstart) >> cblkwidthexpn;
-					prc->cblkno[1] = (brcblkyend - tlcblkystart) >> cblkheightexpn;
-					prc->cblkno[2] = (brcblkzend - tlcblkzstart) >> cblklengthexpn;
-					prc->cblkno[2] = (prc->cblkno[2] == 0) ? 1 : prc->cblkno[2];
-
-					opj_free(prc->cblks);
-					prc->cblks = (opj_tcd_cblk_t *) opj_malloc((prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]) * sizeof(opj_tcd_cblk_t));
-					prc->incltree = tgt_create(prc->cblkno[0], prc->cblkno[1], prc->cblkno[2]);
-					prc->imsbtree = tgt_create(prc->cblkno[0], prc->cblkno[1], prc->cblkno[2]);
-
-					for (cblkno = 0; cblkno < (prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]); cblkno++) {
-							int cblkxstart = tlcblkxstart + (cblkno % prc->cblkno[0]) * (1 << cblkwidthexpn);
-							int cblkystart = tlcblkystart + ((cblkno % (prc->cblkno[0] * prc->cblkno[1])) / prc->cblkno[0]) * (1 << cblkheightexpn);
-							int cblkzstart = tlcblkzstart + (cblkno / (prc->cblkno[0] * prc->cblkno[1])) * (1 << cblklengthexpn);
-							int cblkxend = cblkxstart + (1 << cblkwidthexpn);
-							int cblkyend = cblkystart + (1 << cblkheightexpn);
-							int cblkzend = cblkzstart + (1 << cblklengthexpn);
-							int prec = ((tilec->bpp > 16) ? 3 : ((tilec->bpp > 8) ? 2 : 1));
-
-							tcd->cblk = &prc->cblks[cblkno];
-							cblk = tcd->cblk;
-
-							/* code-block size (global) */
-							cblk->x0 = int_max(cblkxstart, prc->x0);
-							cblk->y0 = int_max(cblkystart, prc->y0);
-							cblk->z0 = int_max(cblkzstart, prc->z0);
-							cblk->x1 = int_min(cblkxend, prc->x1);
-							cblk->y1 = int_min(cblkyend, prc->y1);
-							cblk->z1 = int_min(cblkzend, prc->z1);
-					}
-				} /* precno */
-			} /* bandno */
-		} /* resno */
-	} /* compno */
-	//tcd_dump(stdout, tcd, tcd->tcd_volume);
-}
-
-
-void tcd_free_encode(opj_tcd_t *tcd) {
-	int tileno, compno, resno, bandno, precno;
-
-	opj_tcd_tile_t *tile = NULL;		/* pointer to tcd->tile		*/
-//	opj_tcd_slice_t *slice = NULL;		/* pointer to tcd->slice */
-	opj_tcd_tilecomp_t *tilec = NULL;	/* pointer to tcd->tilec	*/
-	opj_tcd_resolution_t *res = NULL;	/* pointer to tcd->res		*/
-	opj_tcd_band_t *band = NULL;		/* pointer to tcd->band		*/
-	opj_tcd_precinct_t *prc = NULL;		/* pointer to tcd->prc		*/
-
-	for (tileno = 0; tileno < 1; tileno++) {
-		tcd->tile = tcd->tcd_volume->tiles;
-		tile = tcd->tile;
-
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			tcd->tilec = &tile->comps[compno];
-			tilec = tcd->tilec;
-
-			for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-				tcd->res = &tilec->resolutions[resno];
-				res = tcd->res;
-
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					tcd->band = &res->bands[bandno];
-					band = tcd->band;
-
-					for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-						tcd->prc = &band->precincts[precno];
-						prc = tcd->prc;
-
-						if (prc->incltree != NULL) {
-                            tgt_destroy(prc->incltree);
-                            prc->incltree = NULL;
-						}
-						if (prc->imsbtree != NULL) {
-                            tgt_destroy(prc->imsbtree);
-                            prc->imsbtree = NULL;
-						}
-						opj_free(prc->cblks);
-						prc->cblks = NULL;
-					} /* for (precno */
-					opj_free(band->precincts);
-					band->precincts = NULL;
-				} /* for (bandno */
-			} /* for (resno */
-			opj_free(tilec->resolutions);
-			tilec->resolutions = NULL;
-		} /* for (compno */
-		opj_free(tile->comps);
-		tile->comps = NULL;
-	} /* for (tileno */
-	opj_free(tcd->tcd_volume->tiles);
-	tcd->tcd_volume->tiles = NULL;
-}
-
-/* ----------------------------------------------------------------------- */
-void tcd_malloc_decode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp) {
-	int tileno, compno, resno, bandno, precno, cblkno, res_max,
-		i, j, p, q, r;
-	unsigned int x0 = 0, y0 = 0, z0 = 0, 
-		x1 = 0, y1 = 0, z1 = 0, 
-		w, h, l;
-
-	tcd->volume = volume;
-	tcd->cp = cp;
-	tcd->tcd_volume->tw = cp->tw;
-	tcd->tcd_volume->th = cp->th;
-	tcd->tcd_volume->tl = cp->tl;
-	tcd->tcd_volume->tiles = (opj_tcd_tile_t *) opj_malloc(cp->tw * cp->th * cp->tl * sizeof(opj_tcd_tile_t));
-	
-	for (i = 0; i < cp->tileno_size; i++) {
-		opj_tcp_t *tcp = &(cp->tcps[cp->tileno[i]]);
-		opj_tcd_tile_t *tile = &(tcd->tcd_volume->tiles[cp->tileno[i]]);
-	
-		/* p61 ISO/IEC IS15444-1 : 2002 */
-		/* curtileno --> raster scanned index of tiles */
-		/* p,q,r --> matricial index of tiles */
-		tileno = cp->tileno[i];
-		p = tileno % cp->tw;	
-		q = tileno / cp->tw;	
-		r = tileno / (cp->tw * cp->th); /* extension to 3-D */
-
-		/* 4 borders of the tile rescale on the volume if necessary (B.3)*/
-		tile->x0 = int_max(cp->tx0 + p * cp->tdx, volume->x0);
-		tile->y0 = int_max(cp->ty0 + q * cp->tdy, volume->y0);
-		tile->z0 = int_max(cp->tz0 + r * cp->tdz, volume->z0);
-		tile->x1 = int_min(cp->tx0 + (p + 1) * cp->tdx, volume->x1);
-		tile->y1 = int_min(cp->ty0 + (q + 1) * cp->tdy, volume->y1);
-		tile->z1 = int_min(cp->tz0 + (r + 1) * cp->tdz, volume->z1);
-		tile->numcomps = volume->numcomps;		
-		
-		tile->comps = (opj_tcd_tilecomp_t *) opj_malloc(volume->numcomps * sizeof(opj_tcd_tilecomp_t));
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tccp_t *tccp = &tcp->tccps[compno];
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-			int prevnumbands = 0;
-
-			/* border of each tile component (global) */
-			tilec->x0 = int_ceildiv(tile->x0, volume->comps[compno].dx);
-			tilec->y0 = int_ceildiv(tile->y0, volume->comps[compno].dy);
-			tilec->z0 = int_ceildiv(tile->z0, volume->comps[compno].dz);
-			tilec->x1 = int_ceildiv(tile->x1, volume->comps[compno].dx);
-			tilec->y1 = int_ceildiv(tile->y1, volume->comps[compno].dy);
-			tilec->z1 = int_ceildiv(tile->z1, volume->comps[compno].dz);
-			
-			tilec->data = (int *) opj_malloc((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0) * (tilec->z1 - tilec->z0) * sizeof(int));
-
-			res_max = 0;
-			for (i = 0;i < 3; i++){
-				tilec->numresolution[i] = tccp->numresolution[i];
-				//Greater of 3 resolutions contains all information
-				res_max = (tilec->numresolution[i] > res_max) ? tilec->numresolution[i] : res_max;
-			}
-
-			tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(res_max * sizeof(opj_tcd_resolution_t));
-
-			for (resno = 0; resno < res_max; resno++) {
-				opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-				int pdx, pdy, pdz;
-				int tlprcxstart, tlprcystart, tlprczstart, brprcxend, brprcyend, brprczend;
-				int tlcbgxstart, tlcbgystart, tlcbgzstart, brcbgxend, brcbgyend, brcbgzend;
-				int cbgwidthexpn, cbgheightexpn, cbglengthexpn;
-				int cblkwidthexpn, cblkheightexpn, cblklengthexpn;
-				int levelnox = tilec->numresolution[0] - 1 - resno; 
-				int levelnoy = tilec->numresolution[1] - 1 - resno;
-				int diff = tccp->numresolution[0] - tccp->numresolution[2]; 
-				int levelnoz = tilec->numresolution[2] - 1 - ((resno <= diff) ? 0 : (resno - diff));
-					if (levelnoz < 0) levelnoz = 0;
-
-				/* border for each resolution level (global) */
-				res->x0 = int_ceildivpow2(tilec->x0, levelnox);
-				res->y0 = int_ceildivpow2(tilec->y0, levelnoy);
-				res->z0 = int_ceildivpow2(tilec->z0, levelnoz);
-				res->x1 = int_ceildivpow2(tilec->x1, levelnox);
-				res->y1 = int_ceildivpow2(tilec->y1, levelnoy);
-				res->z1 = int_ceildivpow2(tilec->z1, levelnoz);
-				res->numbands = (resno == 0) ? 1 : (resno <= diff) ? 3 : 7; /* --> 3D */
-				
-				/* p. 30, table A-13, ISO/IEC IS154444-1 : 2002 */
-				if (tccp->csty & J3D_CCP_CSTY_PRT) {
-					pdx = tccp->prctsiz[0][resno];
-					pdy = tccp->prctsiz[1][resno];
-					pdz = tccp->prctsiz[2][resno];
-				} else {
-					pdx = 15;
-					pdy = 15;
-					pdz = 15;
-				}
-				
-				/* p. 66, B.16, ISO/IEC IS15444-1 : 2002  */
-				tlprcxstart = int_floordivpow2(res->x0, pdx) << pdx;
-				tlprcystart = int_floordivpow2(res->y0, pdy) << pdy;
-				tlprczstart = int_floordivpow2(res->z0, pdz) << pdz;
-				brprcxend = int_ceildivpow2(res->x1, pdx) << pdx;
-				brprcyend = int_ceildivpow2(res->y1, pdy) << pdy;
-				brprczend = int_ceildivpow2(res->z1, pdz) << pdz;
-				
-				res->prctno[0] = (brprcxend - tlprcxstart) >> pdx;
-				res->prctno[1] = (brprcyend - tlprcystart) >> pdy;
-				res->prctno[2] = (brprczend - tlprczstart) >> pdz;
-				
-				/* p. 67, B.17 & B.18, ISO/IEC IS15444-1 : 2002  */
-				if (resno == 0) {
-					tlcbgxstart = tlprcxstart;//0
-					tlcbgystart = tlprcystart;
-					tlcbgzstart = tlprczstart;
-					brcbgxend = brprcxend;//1
-					brcbgyend = brprcyend;
-					brcbgzend = brprczend;
-					cbgwidthexpn = pdx; //15
-					cbgheightexpn = pdy;
-					cbglengthexpn = pdz;
-				} else {
-					tlcbgxstart = int_ceildivpow2(tlprcxstart, 1);
-					tlcbgystart = int_ceildivpow2(tlprcystart, 1);
-					tlcbgzstart = int_ceildivpow2(tlprczstart, 1);
-					brcbgxend = int_ceildivpow2(brprcxend, 1);
-					brcbgyend = int_ceildivpow2(brprcyend, 1);
-					brcbgzend = int_ceildivpow2(brprczend, 1);
-					cbgwidthexpn = pdx - 1;
-					cbgheightexpn = pdy - 1;
-					cbglengthexpn = pdz - 1;
-				}
-				
-				cblkwidthexpn = int_min(tccp->cblk[0], cbgwidthexpn); //6
-				cblkheightexpn = int_min(tccp->cblk[1], cbgheightexpn); //6
-				cblklengthexpn = int_min(tccp->cblk[2], cbglengthexpn); //6
-
-				res->bands = (opj_tcd_band_t *) opj_malloc(res->numbands * sizeof(opj_tcd_band_t));
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					int x0b, y0b, z0b;
-					int gain, numbps;
-					opj_stepsize_t *ss = NULL;
-
-					opj_tcd_band_t *band = &res->bands[bandno];
-					band->bandno = resno == 0 ? 0 : bandno + 1;
-					/* Bandno:	0 - LLL 	2 - LHL 
-								1 - HLL		3 - HHL
-								4 - LLH		6 - LHH
-								5 - HLH		7 - HHH		*/
-					x0b = (band->bandno == 1) || (band->bandno == 3) || (band->bandno == 5 ) || (band->bandno == 7 ) ? 1 : 0; 
-					y0b = (band->bandno == 2) || (band->bandno == 3) || (band->bandno == 6 ) || (band->bandno == 7 ) ? 1 : 0;
-					z0b = (band->bandno == 4) || (band->bandno == 5) || (band->bandno == 6 ) || (band->bandno == 7 ) ? 1 : 0; 
-					
-					/* p. 65, B.15, ISO/IEC IS15444-1 : 2002  */
-					if (band->bandno == 0) {
-						/* band border (global) */
-						band->x0 = int_ceildivpow2(tilec->x0, levelnox);
-						band->y0 = int_ceildivpow2(tilec->y0, levelnoy);
-						band->z0 = int_ceildivpow2(tilec->z0, levelnoz);
-						band->x1 = int_ceildivpow2(tilec->x1, levelnox);
-						band->y1 = int_ceildivpow2(tilec->y1, levelnoy);
-						band->z1 = int_ceildivpow2(tilec->z1, levelnoz);
-					} else {
-						band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelnox) * x0b, levelnox + 1);
-						band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelnoy) * y0b, levelnoy + 1);
-						band->z0 = int_ceildivpow2(tilec->z0 - (1 << levelnoz) * z0b, (resno <= diff) ? levelnoz : levelnoz + 1);
-						band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelnox) * x0b, levelnox + 1);
-						band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelnoy) * y0b, levelnoy + 1);
-						band->z1 = int_ceildivpow2(tilec->z1 - (1 << levelnoz) * z0b, (resno <= diff) ? levelnoz : levelnoz + 1);
-					}	
-
-					ss = &tccp->stepsizes[(resno == 0) ? 0 : (prevnumbands + bandno + 1)];
-					if (bandno == (res->numbands - 1)) 
-						prevnumbands += (resno == 0) ? 0 : res->numbands;
-					gain = dwt_getgain(band->bandno,tccp->reversible);					
-					numbps = volume->comps[compno].prec + gain;
-
-					band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
-					band->numbps = ss->expn + tccp->numgbits - 1;	/* WHY -1 ? */
-					
-					band->precincts = (opj_tcd_precinct_t *) opj_malloc(res->prctno[0] * res->prctno[1] * res->prctno[2] * sizeof(opj_tcd_precinct_t));
-					
-					for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-						int tlcblkxstart, tlcblkystart, tlcblkzstart, brcblkxend, brcblkyend, brcblkzend;
-
-						int cbgxstart = tlcbgxstart + (precno % res->prctno[0]) * (1 << cbgwidthexpn);
-						int cbgystart = tlcbgystart + (precno / res->prctno[0]) * (1 << cbgheightexpn);
-						int cbgzstart = tlcbgzstart + (precno / (res->prctno[0] * res->prctno[1])) * (1 << cbglengthexpn);
-						int cbgxend = cbgxstart + (1 << cbgwidthexpn);
-						int cbgyend = cbgystart + (1 << cbgheightexpn);
-						int cbgzend = cbgzstart + (1 << cbglengthexpn);
-
-						opj_tcd_precinct_t *prc = &band->precincts[precno];
-						/* precinct size (global) */
-						prc->x0 = int_max(cbgxstart, band->x0);
-						prc->y0 = int_max(cbgystart, band->y0);
-						prc->z0 = int_max(cbgzstart, band->z0);
-						prc->x1 = int_min(cbgxend, band->x1);
-						prc->y1 = int_min(cbgyend, band->y1);
-						prc->z1 = int_min(cbgzend, band->z1);
-
-						tlcblkxstart = int_floordivpow2(prc->x0, cblkwidthexpn) << cblkwidthexpn;
-						tlcblkystart = int_floordivpow2(prc->y0, cblkheightexpn) << cblkheightexpn;
-						tlcblkzstart = int_floordivpow2(prc->z0, cblklengthexpn) << cblklengthexpn;
-						brcblkxend = int_ceildivpow2(prc->x1, cblkwidthexpn) << cblkwidthexpn;
-						brcblkyend = int_ceildivpow2(prc->y1, cblkheightexpn) << cblkheightexpn;
-						brcblkzend = int_ceildivpow2(prc->z1, cblklengthexpn) << cblklengthexpn;
-						prc->cblkno[0] = (brcblkxend - tlcblkxstart) >> cblkwidthexpn;
-						prc->cblkno[1] = (brcblkyend - tlcblkystart) >> cblkheightexpn;
-						prc->cblkno[2] = (brcblkzend - tlcblkzstart) >> cblklengthexpn;
-						prc->cblkno[2] = (prc->cblkno[2] == 0) ? 1 : prc->cblkno[2];
-
-						prc->cblks = (opj_tcd_cblk_t *) opj_malloc((prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]) * sizeof(opj_tcd_cblk_t));
-						prc->incltree = tgt_create(prc->cblkno[0], prc->cblkno[1], prc->cblkno[2]);
-						prc->imsbtree = tgt_create(prc->cblkno[0], prc->cblkno[1], prc->cblkno[2]);
-						
-						for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-							int cblkxstart = tlcblkxstart + (cblkno % prc->cblkno[0]) * (1 << cblkwidthexpn);
-							int cblkystart = tlcblkystart + ((cblkno % (prc->cblkno[0] * prc->cblkno[1])) / prc->cblkno[0]) * (1 << cblkheightexpn);
-							int cblkzstart = tlcblkzstart + (cblkno / (prc->cblkno[0] * prc->cblkno[1])) * (1 << cblklengthexpn);
-							int cblkxend = cblkxstart + (1 << cblkwidthexpn);
-							int cblkyend = cblkystart + (1 << cblkheightexpn);
-							int cblkzend = cblkzstart + (1 << cblklengthexpn);
-							int prec = ((tilec->bpp > 16) ? 3 : ((tilec->bpp > 8) ? 2 : 1));
-							/* code-block size (global) */
-							opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-							
-							/* code-block size (global) */
-							cblk->x0 = int_max(cblkxstart, prc->x0);
-							cblk->y0 = int_max(cblkystart, prc->y0);
-							cblk->z0 = int_max(cblkzstart, prc->z0);
-							cblk->x1 = int_min(cblkxend, prc->x1);
-							cblk->y1 = int_min(cblkyend, prc->y1);
-							cblk->z1 = int_min(cblkzend, prc->z1);
-						}
-					} /* precno */
-				} /* bandno */
-			} /* resno */
-		} /* compno */
-	} /* i = 0..cp->tileno_size */
-
-	//tcd_dump(stdout, tcd, tcd->tcd_volume);
-
-	/* 
-	Allocate place to store the decoded data = final volume
-	Place limited by the tile really present in the codestream 
-	*/
-	
-	for (i = 0; i < volume->numcomps; i++) {
-		for (j = 0; j < cp->tileno_size; j++) {
-			tileno = cp->tileno[j];
-			x0 = (j == 0) ? tcd->tcd_volume->tiles[tileno].comps[i].x0 : int_min(x0,(unsigned int) tcd->tcd_volume->tiles[tileno].comps[i].x0);
-			y0 = (j == 0) ? tcd->tcd_volume->tiles[tileno].comps[i].y0 : int_min(y0,(unsigned int) tcd->tcd_volume->tiles[tileno].comps[i].y0);
-			z0 = (j == 0) ? tcd->tcd_volume->tiles[tileno].comps[i].z0 : int_min(z0,(unsigned int) tcd->tcd_volume->tiles[tileno].comps[i].z0);
-			x1 = (j == 0) ? tcd->tcd_volume->tiles[tileno].comps[i].x1 : int_max(x1,(unsigned int) tcd->tcd_volume->tiles[tileno].comps[i].x1);
-			y1 = (j == 0) ? tcd->tcd_volume->tiles[tileno].comps[i].y1 : int_max(y1,(unsigned int) tcd->tcd_volume->tiles[tileno].comps[i].y1);
-			z1 = (j == 0) ? tcd->tcd_volume->tiles[tileno].comps[i].z1 : int_max(z1,(unsigned int) tcd->tcd_volume->tiles[tileno].comps[i].z1);
-		}
-		
-		w = x1 - x0;
-		h = y1 - y0;
-		l = z1 - z0;
-		
-		volume->comps[i].data = (int *) opj_malloc(w * h * l * sizeof(int));
-		volume->comps[i].w = w;
-		volume->comps[i].h = h;
-		volume->comps[i].l = l;
-		volume->comps[i].x0 = x0;
-		volume->comps[i].y0 = y0;
-		volume->comps[i].z0 = z0;
-		volume->comps[i].bigendian = cp->bigendian;
-	}
-}
-
-void tcd_free_decode(opj_tcd_t *tcd) {
-	int tileno,compno,resno,bandno,precno;
-
-	opj_tcd_volume_t *tcd_volume = tcd->tcd_volume;
-	
-	for (tileno = 0; tileno < tcd_volume->tw * tcd_volume->th * tcd_volume->tl; tileno++) {
-		opj_tcd_tile_t *tile = &tcd_volume->tiles[tileno];
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-			for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-				opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					opj_tcd_band_t *band = &res->bands[bandno];
-					for (precno = 0; precno < res->prctno[1] * res->prctno[0] * res->prctno[2]; precno++) {
-						opj_tcd_precinct_t *prec = &band->precincts[precno];
-						if (prec->cblks != NULL) opj_free(prec->cblks);
-						if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
-                        if (prec->incltree != NULL) tgt_destroy(prec->incltree);
-						/*for (treeno = 0; treeno < prec->numtrees; treeno++){
-                            if (prec->imsbtree[treeno] != NULL) tgt_destroy(prec->imsbtree[treeno]);
-                            if (prec->incltree[treeno] != NULL) tgt_destroy(prec->incltree[treeno]);
-						}*/
-					}
-					if (band->precincts != NULL) opj_free(band->precincts);
-				}
-			}
-			if (tilec->resolutions != NULL) opj_free(tilec->resolutions);
-		}
-		if (tile->comps != NULL) opj_free(tile->comps);
-	}
-
-	if (tcd_volume->tiles != NULL) opj_free(tcd_volume->tiles);
-}
-
-
-
-/* ----------------------------------------------------------------------- */
-void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final) {
-	int compno, resno, bandno, precno, cblkno;
-	int value;			/*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolution[0]][3]; */
-	int matrice[10][10][3];
-	int i, j, k;
-
-	opj_cp_t *cp = tcd->cp;
-	opj_tcd_tile_t *tcd_tile = tcd->tcd_tile;
-	opj_tcp_t *tcd_tcp = tcd->tcp;
-
-	/*matrice=(int*)opj_malloc(tcd_tcp->numlayers*tcd_tile->comps[0].numresolution[0]*3*sizeof(int)); */
-	
-	for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-		for (i = 0; i < tcd_tcp->numlayers; i++) {
-			for (j = 0; j < tilec->numresolution[0]; j++) {
-				for (k = 0; k < 3; k++) {
-					matrice[i][j][k] =
-						(int) (cp->matrice[i * tilec->numresolution[0] * 3 + j * 3 + k] 
-						* (float) (tcd->volume->comps[compno].prec / 16.0));
-				}
-			}
-		}
-        
-		for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-					for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-						opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-						opj_tcd_layer_t *layer = &cblk->layers[layno];
-						int n;
-						int imsb = tcd->volume->comps[compno].prec - cblk->numbps;	/* number of bit-plan equal to zero */
-						/* Correction of the matrix of coefficient to include the IMSB information */
-						if (layno == 0) {
-							value = matrice[layno][resno][bandno];
-							if (imsb >= value) {
-								value = 0;
-							} else {
-								value -= imsb;
-							}
-						} else {
-							value =	matrice[layno][resno][bandno] -	matrice[layno - 1][resno][bandno];
-							if (imsb >= matrice[layno - 1][resno][bandno]) {
-								value -= (imsb - matrice[layno - 1][resno][bandno]);
-								if (value < 0) {
-									value = 0;
-								}
-							}
-						}
-						
-						if (layno == 0) {
-							cblk->numpassesinlayers = 0;
-						}
-						
-						n = cblk->numpassesinlayers;
-						if (cblk->numpassesinlayers == 0) {
-							if (value != 0) {
-								n = 3 * value - 2 + cblk->numpassesinlayers;
-							} else {
-								n = cblk->numpassesinlayers;
-							}
-						} else {
-							n = 3 * value + cblk->numpassesinlayers;
-						}
-						
-						layer->numpasses = n - cblk->numpassesinlayers;
-						
-						if (!layer->numpasses)
-							continue;
-						
-						if (cblk->numpassesinlayers == 0) {
-							layer->len = cblk->passes[n - 1].rate;
-							layer->data = cblk->data;
-						} else {
-							layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers - 1].rate;
-							layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
-						}
-						if (final)
-							cblk->numpassesinlayers = n;
-					}
-				}
-			}
-		}
-	}
-}
-
-void tcd_rateallocate_fixed(opj_tcd_t *tcd) {
-	int layno;
-	for (layno = 0; layno < tcd->tcp->numlayers; layno++) {
-		tcd_makelayer_fixed(tcd, layno, 1);
-	}
-}
-
-void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) {
-	int compno, resno, bandno, precno, cblkno, passno;
-	
-	opj_tcd_tile_t *tcd_tile = tcd->tcd_tile;
-
-	tcd_tile->distolayer[layno] = 0;	/* fixed_quality */
-	
-	for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-		for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-					for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-						opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-						opj_tcd_layer_t *layer = &cblk->layers[layno];
-						
-						int n;
-						if (layno == 0) {
-							cblk->numpassesinlayers = 0;
-						}
-						n = cblk->numpassesinlayers;
-						for (passno = cblk->numpassesinlayers; passno < cblk->totalpasses; passno++) {
-							int dr;
-							double dd;
-							opj_tcd_pass_t *pass = &cblk->passes[passno];
-							if (n == 0) {
-								dr = pass->rate;
-								dd = pass->distortiondec;
-							} else {
-								dr = pass->rate - cblk->passes[n - 1].rate;
-								dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
-							}
-							if (!dr) {
-								if (dd)
-									n = passno + 1;
-								continue;
-							}
-							if (dd / dr >= thresh){
-								n = passno + 1;
-							}
-						}
-						layer->numpasses = n - cblk->numpassesinlayers;
-						
-						if (!layer->numpasses) {
-							layer->disto = 0;
-							continue;
-						}
-						if (cblk->numpassesinlayers == 0) {
-							layer->len = cblk->passes[n - 1].rate;
-							layer->data = cblk->data;
-							layer->disto = cblk->passes[n - 1].distortiondec;
-						} else {
-							layer->len = cblk->passes[n - 1].rate -	cblk->passes[cblk->numpassesinlayers - 1].rate;
-							layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
-							layer->disto = cblk->passes[n - 1].distortiondec - cblk->passes[cblk->numpassesinlayers - 1].distortiondec;
-						}
-						
-						tcd_tile->distolayer[layno] += layer->disto;	/* fixed_quality */
-						
-						if (final)
-							cblk->numpassesinlayers = n;
-
-					//	fprintf(stdout,"MakeLayer : %d %f %d %d \n",layer->len, layer->disto, layer->numpasses, n);
-					}
-				}
-			}
-		}
-	}
-}
-
-bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_volume_info_t * volume_info) {
-	int compno, resno, bandno, precno, cblkno, passno, layno;
-	double min, max;
-	double cumdisto[100];	/* fixed_quality */
-	const double K = 1;		/* 1.1; // fixed_quality */
-	double maxSE = 0;
-
-	opj_cp_t *cp = tcd->cp;
-	opj_tcd_tile_t *tcd_tile = tcd->tcd_tile;
-	opj_tcp_t *tcd_tcp = tcd->tcp;
-
-	min = DBL_MAX;
-	max = 0;
-	
-	tcd_tile->nbpix = 0;		/* fixed_quality */
-	
-	for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-		tilec->nbpix = 0;
-		for (resno = 0; resno < tilec->numresolution[0]; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-				for (precno = 0; precno < res->prctno[0] * res->prctno[1] * res->prctno[2]; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-					for (cblkno = 0; cblkno < prc->cblkno[0] * prc->cblkno[1] * prc->cblkno[2]; cblkno++) {
-						opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
-						for (passno = 0; passno < cblk->totalpasses; passno++) {
-							opj_tcd_pass_t *pass = &cblk->passes[passno];
-							int dr;
-							double dd, rdslope;
-							if (passno == 0) {
-								dr = pass->rate;
-								dd = pass->distortiondec;
-							} else {
-								dr = pass->rate - cblk->passes[passno - 1].rate;
-								dd = pass->distortiondec - cblk->passes[passno - 1].distortiondec;
-							}
-							if (dr == 0) {
-								continue;
-							}
-							rdslope = dd / dr;
-							if (rdslope < min) {
-								min = rdslope;
-							}
-							if (rdslope > max) {
-								max = rdslope;
-							}
-
-						} /* passno */
-						
-						/* fixed_quality */
-						tcd_tile->nbpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0) * (cblk->z1 - cblk->z0));
-                        tilec->nbpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0) * (cblk->z1 - cblk->z0));
-					} /* cbklno */ 
-				} /* precno */
-			} /* bandno */
-		} /* resno */
-		
-		maxSE += (((double)(1 << tcd->volume->comps[compno].prec) - 1.0) 
-			* ((double)(1 << tcd->volume->comps[compno].prec) -1.0)) 
-			* ((double)(tilec->nbpix));
-	} /* compno */
-	
-	/* add antonin index */
-	if(volume_info && volume_info->index_on) {
-		opj_tile_info_t *info_TL = &volume_info->tile[tcd->tcd_tileno];
-		info_TL->nbpix = tcd_tile->nbpix;
-		info_TL->distotile = tcd_tile->distotile;
-		info_TL->thresh = (double *) opj_malloc(tcd_tcp->numlayers * sizeof(double));
-	}
-	/* dda */
-	
-	for (layno = 0; layno < tcd_tcp->numlayers; layno++) {
-		double lo = min;
-		double hi = max;
-		int success = 0;
-		int maxlen = tcd_tcp->rates[layno] ? int_min(((int) tcd_tcp->rates[layno]), len) : len;
-		double goodthresh;
-		double distotarget;		/* fixed_quality */
-		int i = 0;
-		
-        /* fixed_quality */
-		distotarget = tcd_tile->distotile - ((K * maxSE) / pow((float)10, tcd_tcp->distoratio[layno] / 10));
-        
-		if ((tcd_tcp->rates[layno]) || (cp->disto_alloc==0)) {
-			opj_t2_t *t2 = t2_create(tcd->cinfo, tcd->volume, cp);
-			int oldl = 0, oldoldl = 0;
-			for (i = 0; i < 128; i++) {
-				double thresh = (lo + hi) / 2;
-				int l = 0;
-				double distoachieved = 0;	/* fixed_quality -q */
-			
-				tcd_makelayer(tcd, layno, thresh, 0);
-		
-				if (cp->fixed_quality) {	/* fixed_quality -q */
-					distoachieved =	(layno == 0) ? tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno];
-					if (distoachieved < distotarget) {
-						hi = thresh; 
-						continue;
-					}
-					lo = thresh;
-				} else {		/* disto_alloc -r, fixed_alloc -f */
-					l = t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, volume_info);
-					//fprintf(stdout, "layno %d i %d len=%d max=%d \n",layno,i,l,maxlen);
-					if (l == -999) {
-						lo = thresh; 
-						continue;
-					} else if (l == oldl && oldl == oldoldl && tcd_tile->distolayer[layno] > 0.0 && i>32)
-						break;
-					hi = thresh;
-					oldoldl = oldl;
-					oldl = l;
-				}
-				success = 1;
-				goodthresh = thresh;
-			} 
-			t2_destroy(t2);
-		} else {
-			success = 1;
-			goodthresh = min;
-		}
-		if (!success) {
-			return false;
-		}
-		
-		if(volume_info && volume_info->index_on) {	/* Threshold for Marcela Index */
-			volume_info->tile[tcd->tcd_tileno].thresh[layno] = goodthresh;
-		}
-		tcd_makelayer(tcd, layno, goodthresh, 1);
-	        
-		/* fixed_quality */
-		cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno];	
-	}
-
-	return true;
-}
-
-/* ----------------------------------------------------------------------- */
-int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_volume_info_t * volume_info) {
-	int compno;
-	int l, i, npck = 0;
-	double encoding_time;
-	
-	opj_tcd_tile_t	*tile = NULL;
-	opj_tcp_t		*tcd_tcp = NULL;
-	opj_cp_t		*cp = NULL;
-
-	opj_tcp_t		*tcp = &tcd->cp->tcps[0];
-	opj_tccp_t		*tccp = &tcp->tccps[0];
-	opj_volume_t	*volume = tcd->volume;
-	opj_t2_t		*t2 = NULL;		/* T2 component */
-
-	tcd->tcd_tileno = tileno;			/* current encoded/decoded tile */
-	
-	tcd->tcd_tile = tcd->tcd_volume->tiles; /* tile information */
-	tile = tcd->tcd_tile;
-	
-	tcd->tcp = &tcd->cp->tcps[tileno];	/* coding/decoding params of tileno */	
-	tcd_tcp = tcd->tcp;
-	
-	cp = tcd->cp;		/* coding parameters */
-
-	/* INDEX >> */
-	if(volume_info && volume_info->index_on) {
-		opj_tcd_tilecomp_t *tilec_idx = &tile->comps[0];	/* based on component 0 */
-		for (i = 0; i < tilec_idx->numresolution[0]; i++) {
-			opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[i];
-
-			volume_info->tile[tileno].prctno[0][i] = res_idx->prctno[0];
-			volume_info->tile[tileno].prctno[1][i] = res_idx->prctno[1];
-			volume_info->tile[tileno].prctno[2][i] = res_idx->prctno[2];
-
-			npck += res_idx->prctno[0] * res_idx->prctno[1] * res_idx->prctno[2];
-
-			volume_info->tile[tileno].prctsiz[0][i] = tccp->prctsiz[0][i];
-			volume_info->tile[tileno].prctsiz[1][i] = tccp->prctsiz[1][i];
-			volume_info->tile[tileno].prctsiz[2][i] = tccp->prctsiz[2][i];
-		}
-		volume_info->tile[tileno].packet = (opj_packet_info_t *) opj_malloc(volume_info->comp * volume_info->layer * npck * sizeof(opj_packet_info_t));
-	}
-	/* << INDEX */
-	
-	/*---------------TILE-------------------*/
-	encoding_time = opj_clock();	/* time needed to encode a tile */
-	
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		int x, y, z;
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-		
-		int adjust;
-		int offset_x = int_ceildiv(volume->x0, volume->comps[compno].dx); //ceil(x0 / subsampling_dx)
-		int offset_y = int_ceildiv(volume->y0, volume->comps[compno].dy);
-		int offset_z = int_ceildiv(volume->z0, volume->comps[compno].dz);
-		
-		int tw = tilec->x1 - tilec->x0;
-		int w = int_ceildiv(volume->x1 - volume->x0, volume->comps[compno].dx);
-		int th = tilec->y1 - tilec->y0;
-		int h = int_ceildiv(volume->y1 - volume->y0, volume->comps[compno].dy);
-		int tl = tilec->z1 - tilec->z0;
-		int l = int_ceildiv(volume->z1 - volume->z0, volume->comps[compno].dz);
-
-		
-		
-		/* extract tile data from volume.comps[0].data to tile.comps[0].data */
-		//fprintf(stdout,"[INFO] Extract tile data\n");
-		if (tcd->cp->transform_format == TRF_3D_RLS || tcd->cp->transform_format == TRF_3D_LSE) {
-			adjust = 0;
-		} else {
-            adjust = volume->comps[compno].sgnd ? 0 : 1 << (volume->comps[compno].prec - 1); //sign=='+' --> 2^(prec-1)
-			if (volume->comps[compno].dcoffset != 0){
-				adjust += volume->comps[compno].dcoffset;
-				fprintf(stdout,"[INFO] DC Offset applied: DCO = %d -> adjust = %d\n",volume->comps[compno].dcoffset,adjust);
-			}
-		}		
-
-		if (tcd_tcp->tccps[compno].reversible == 1) { //IF perfect reconstruction (DWT.5-3)
-			for (z = tilec->z0; z < tilec->z1; z++) {
-				for (y = tilec->y0; y < tilec->y1; y++) {
-					/* start of the src tile scanline */
-					int *data = &volume->comps[compno].data[(tilec->x0 - offset_x) + (y - offset_y) * w + (z - offset_z) * w * h];
-					/* start of the dst tile scanline */
-					int *tile_data = &tilec->data[(y - tilec->y0) * tw + (z - tilec->z0) * tw * th];
-					for (x = tilec->x0; x < tilec->x1; x++) {
-						*tile_data++ = *data++ - adjust;
-					}
-				}
-			}
-		} else if (tcd_tcp->tccps[compno].reversible == 0) { //IF not (DWT.9-7)
-			for (z = tilec->z0; z < tilec->z1; z++) {
-				for (y = tilec->y0; y < tilec->y1; y++) {
-					/* start of the src tile scanline */
-					int *data = &volume->comps[compno].data[(tilec->x0 - offset_x) + (y - offset_y) * w + (z - offset_z) * w * h];
-					/* start of the dst tile scanline */
-					int *tile_data = &tilec->data[(y - tilec->y0) * tw + (z - tilec->z0) * tw * th];
-					for (x = tilec->x0; x < tilec->x1; x++) {
-						*tile_data++ = (*data++ - adjust) << 13;
-					}
-				}
-			}
-		}
-	
-	}
-
-	/*----------------MCT-------------------*/
-	if (tcd_tcp->mct) {
-		int samples = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0) * (tile->comps[0].z1 - tile->comps[0].z0);
-		fprintf(stdout,"[INFO] Tcd_encode_tile: mct\n");
-		if (tcd_tcp->tccps[0].reversible == 0) {
-			mct_encode_real(tile->comps[0].data, tile->comps[1].data, tile->comps[2].data, samples);
-		} else {
-			mct_encode(tile->comps[0].data, tile->comps[1].data, tile->comps[2].data, samples);
-		}
-	}
-	/*----------------TRANSFORM---------------------------------*/
-	fprintf(stdout,"[INFO] Tcd_encode_tile: Transform\n");
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-		dwt_encode(tilec, tcd_tcp->tccps[compno].dwtid);
-	} 
-
-	/*-------------------ENTROPY CODING-----------------------------*/
-	fprintf(stdout,"[INFO] Tcd_encode_tile: Entropy coding\n");
-	if ((cp->encoding_format == ENCOD_2EB)||(cp->encoding_format == ENCOD_3EB))
-	{
-		if (cp->encoding_format == ENCOD_2EB) {
-			opj_t1_t *t1 = NULL;
-			t1 = t1_create(tcd->cinfo);
-			t1_encode_cblks(t1, tile, tcd_tcp);
-			t1_destroy(t1);	
-		} else if (cp->encoding_format == ENCOD_3EB) {
-			opj_t1_3d_t *t1 = NULL;		
-			t1 = t1_3d_create(tcd->cinfo);
-			t1_3d_encode_cblks(t1, tile, tcd_tcp);
-			t1_3d_destroy(t1);	
-		}
-		/*-----------RATE-ALLOCATE------------------*/
-		/* INDEX */
-		if(volume_info) {
-			volume_info->index_write = 0;
-		}
-		if (cp->disto_alloc || cp->fixed_quality) {	
-   			fprintf(stdout,"[INFO] Tcd_encode_tile: Rate-allocate\n");
-			tcd_rateallocate(tcd, dest, len, volume_info);			/* Normal Rate/distortion allocation */
-		} else {/* fixed_alloc */
-    	    fprintf(stdout,"[INFO] Tcd_encode_tile: Rate-allocate fixed\n");
-            tcd_rateallocate_fixed(tcd);							/* Fixed layer allocation */
-		}
-
-		/*--------------TIER2------------------*/
-		/* INDEX */
-		if(volume_info) {
-			volume_info->index_write = 1;
-		}
-		fprintf(stdout,"[INFO] Tcd_encode_tile: Tier - 2\n");
-        t2 = t2_create(tcd->cinfo, volume, cp);
-		l = t2_encode_packets(t2, tileno, tile, tcd_tcp->numlayers, dest, len, volume_info);
-        t2_destroy(t2);
-	} else if ((cp->encoding_format == ENCOD_2GR)||(cp->encoding_format == ENCOD_3GR)) {
-		/*if(volume_info) {
-			volume_info->index_write = 1;
-		}
-		gr = golomb_create(tcd->cinfo, volume, cp);
-		l = golomb_encode(gr, tileno, tile, dest, len, volume_info);
-		golomb_destroy(gr);*/
-	}
-
-	
-	/*---------------CLEAN-------------------*/
-	fprintf(stdout,"[INFO] Tcd_encode_tile: %d bytes coded\n",l);
-	encoding_time = opj_clock() - encoding_time;
-	opj_event_msg(tcd->cinfo, EVT_INFO, "- tile encoded in %f s\n", encoding_time);
-	
-	/* cleaning memory */
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		tcd->tilec = &tile->comps[compno];
-		opj_free(tcd->tilec->data);
-	}
-	
-	if (l == -999){
-		fprintf(stdout,"[ERROR] Unable to perform T2 tier. Return -999.\n");
-		return 0;
-	}
-
-	return l;
-}
-
-
-bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno) {
-	int l, i;
-	int compno, eof = 0;
-	double tile_time, t1_time, dwt_time;
-
-	opj_tcd_tile_t *tile = NULL;
-	opj_t2_t *t2 = NULL;		/* T2 component */
-	
-	tcd->tcd_tileno = tileno;
-	tcd->tcd_tile = &(tcd->tcd_volume->tiles[tileno]);
-	tcd->tcp = &(tcd->cp->tcps[tileno]);
-	tile = tcd->tcd_tile;
-	
-	tile_time = opj_clock();	/* time needed to decode a tile */
-	opj_event_msg(tcd->cinfo, EVT_INFO, "tile %d / %d\n", tileno + 1, tcd->cp->tw * tcd->cp->th * tcd->cp->tl);
-
-	if ((tcd->cp->encoding_format == ENCOD_2EB) || (tcd->cp->encoding_format == ENCOD_3EB)) {
-		/*--------------TIER2------------------*/
-		t2 = t2_create(tcd->cinfo, tcd->volume, tcd->cp);
-		l = t2_decode_packets(t2, src, len, tileno, tile);
-		t2_destroy(t2);
-		opj_event_msg(tcd->cinfo, EVT_INFO, "Tcd_decode_tile: %d bytes decoded\n",l);
-		
-		if (l == -999) {
-			eof = 1;
-			opj_event_msg(tcd->cinfo, EVT_ERROR, "Tcd_decode_tile: incomplete bistream\n");
-		}
-	
-		/*------------------TIER1-----------------*/
-		opj_event_msg(tcd->cinfo, EVT_INFO, "Tcd_decode_tile: Entropy decoding %d \n",tcd->cp->encoding_format);
-		t1_time = opj_clock();	/* time needed to decode a tile */
-		if (tcd->cp->encoding_format == ENCOD_2EB) {
-			opj_t1_t *t1 = NULL;		/* T1 component */
-			t1 = t1_create(tcd->cinfo);
-			t1_decode_cblks(t1, tile, tcd->tcp);
-			t1_destroy(t1);
-		}else if (tcd->cp->encoding_format == ENCOD_3EB) {
-			opj_t1_3d_t *t1 = NULL;		/* T1 component */
-			t1 = t1_3d_create(tcd->cinfo);
-			t1_3d_decode_cblks(t1, tile, tcd->tcp);
-			t1_3d_destroy(t1);
-		}
-
-		t1_time = opj_clock() - t1_time;
-		#ifdef VERBOSE
-				opj_event_msg(tcd->cinfo, EVT_INFO, "- tier-1 took %f s\n", t1_time);
-		#endif
-	} else if ((tcd->cp->encoding_format == ENCOD_2GR)||(tcd->cp->encoding_format == ENCOD_3GR)) {
-		opj_event_msg(tcd->cinfo, EVT_INFO, "Tcd_decode_tile: Entropy decoding -- Does nothing :-D\n");
-		/*
-		gr = golomb_create(tcd->cinfo, tcd->volume, tcd->cp);
-		l = golomb_decode(gr, tileno, tile, src, len);
-		golomb_destroy(gr);
-		if (l == -999) {
-			eof = 1;
-			opj_event_msg(tcd->cinfo, EVT_ERROR, "Tcd_decode_tile: incomplete bistream\n");
-		}
-		*/
-	} 
-
-	/*----------------DWT---------------------*/
-	fprintf(stdout,"[INFO] Tcd_decode_tile: Inverse DWT\n");
-	dwt_time = opj_clock();	/* time needed to decode a tile */
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-		int stops[3], dwtid[3];
-	
-		for (i = 0; i < 3; i++) {
-			if (tcd->cp->reduce[i] != 0) 
-				tcd->volume->comps[compno].resno_decoded[i] = tile->comps[compno].numresolution[i] - tcd->cp->reduce[i] - 1;
-			stops[i] = tilec->numresolution[i] - 1 - tcd->volume->comps[compno].resno_decoded[i];
-			if (stops[i] < 0) stops[i]=0;
-			dwtid[i] = tcd->cp->tcps->tccps[compno].dwtid[i];
-		}
-		
-		dwt_decode(tilec, stops, dwtid);
-
-		for (i = 0; i < 3; i++) {
-			if (tile->comps[compno].numresolution[i] > 0) {
-				tcd->volume->comps[compno].factor[i] = tile->comps[compno].numresolution[i] - (tcd->volume->comps[compno].resno_decoded[i] + 1);
-				if ( (tcd->volume->comps[compno].factor[i]) < 0 )
-					tcd->volume->comps[compno].factor[i] = 0;
-			}
-		}
-	}
-	dwt_time = opj_clock() - dwt_time;
-	#ifdef VERBOSE
-			opj_event_msg(tcd->cinfo, EVT_INFO, "- dwt took %f s\n", dwt_time);
-	#endif
-
-	/*----------------MCT-------------------*/
-	
-	if (tcd->tcp->mct) {
-		if (tcd->tcp->tccps[0].reversible == 1) {
-			mct_decode(tile->comps[0].data, tile->comps[1].data, tile->comps[2].data, 
-				(tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0) * (tile->comps[0].z1 - tile->comps[0].z0));
-		} else {
-			mct_decode_real(tile->comps[0].data, tile->comps[1].data, tile->comps[2].data, 
-				(tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0)* (tile->comps[0].z1 - tile->comps[0].z0));
-		}
-	}
-	
-	/*---------------TILE-------------------*/
-	
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-		opj_tcd_resolution_t *res =	&tilec->resolutions[tcd->volume->comps[compno].resno_decoded[0]];
-		int adjust;
-		int minval = tcd->volume->comps[compno].sgnd ? -(1 << (tcd->volume->comps[compno].prec - 1)) : 0;
-		int maxval = tcd->volume->comps[compno].sgnd ? (1 << (tcd->volume->comps[compno].prec - 1)) - 1 : (1 << tcd->volume->comps[compno].prec) - 1;
-		
-		int tw = tilec->x1 - tilec->x0;
-		int w = tcd->volume->comps[compno].w;
-		int th = tilec->y1 - tilec->y0;
-		int h = tcd->volume->comps[compno].h;
-
-		int i, j, k;
-		int offset_x = int_ceildivpow2(tcd->volume->comps[compno].x0, tcd->volume->comps[compno].factor[0]);
-		int offset_y = int_ceildivpow2(tcd->volume->comps[compno].y0, tcd->volume->comps[compno].factor[1]);
-		int offset_z = int_ceildivpow2(tcd->volume->comps[compno].z0, tcd->volume->comps[compno].factor[2]);
-		
-		if (tcd->cp->transform_format == TRF_3D_RLS || tcd->cp->transform_format == TRF_3D_LSE) {
-			adjust = 0;
-		} else {
-            adjust = tcd->volume->comps[compno].sgnd ? 0 : 1 << (tcd->volume->comps[compno].prec - 1); //sign=='+' --> 2^(prec-1)
-			if (tcd->volume->comps[compno].dcoffset != 0){
-				adjust += tcd->volume->comps[compno].dcoffset;
-				fprintf(stdout,"[INFO] DC Offset applied: DCO = %d -> adjust = %d\n",tcd->volume->comps[compno].dcoffset,adjust);
-			}
-		}
-
-		for (k = res->z0; k < res->z1; k++) {
-			for (j = res->y0; j < res->y1; j++) {
-				for (i = res->x0; i < res->x1; i++) {
-					int v;
-					float tmp = (float)((tilec->data[i - res->x0 + (j - res->y0) * tw + (k - res->z0) * tw * th]) / 8192.0);
-
-					if (tcd->tcp->tccps[compno].reversible == 1) {
-						v = tilec->data[i - res->x0 + (j - res->y0) * tw + (k - res->z0) * tw * th];
-					} else {
-						int tmp2 = ((int) (floor(fabs(tmp)))) + ((int) floor(fabs(tmp*2))%2);
-						v = ((tmp < 0) ? -tmp2:tmp2);
-					}
-					v += adjust;
-					
-					tcd->volume->comps[compno].data[(i - offset_x) + (j - offset_y) * w + (k - offset_z) * w * h] = int_clamp(v, minval, maxval);
-				}
-			}
-		}
-	}
-	
-	tile_time = opj_clock() - tile_time;	/* time needed to decode a tile */
-	opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time);
-		
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_free(tcd->tcd_volume->tiles[tileno].comps[compno].data);
-		tcd->tcd_volume->tiles[tileno].comps[compno].data = NULL;
-	}
-	
-	if (eof) {
-		return false;
-	}
-	
-	return true;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.h
deleted file mode 100755
index 0de60b8..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tcd.h
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __TCD_H
-#define __TCD_H
-/**
- at file tcd.h
- at brief Implementation of a tile coder/decoder (TCD)
-
-The functions in TCD.C have for goal to encode or decode each tile independently from
-each other. The functions in TCD.C are used by some function in JP3D.C.
-*/
-
-/** @defgroup TCD TCD - Implementation of a tile coder/decoder */
-/*@{*/
-
-/**
-Tile coder/decoder: segment instance
-*/
-typedef struct opj_tcd_seg {
-/** Number of passes in the segment */
-	int numpasses;			
-/** Length of information */
-    int len;					
-/** Data */
-	unsigned char *data;		
-/** Number of passes posible for the segment */
-	int maxpasses;			
-/** Number of passes added to the segment */
-	int numnewpasses;		    
-/** New length after inclusion of segments */
-	int newlen;
-} opj_tcd_seg_t;
-
-/**
-Tile coder/decoder: pass instance
-*/
-typedef struct opj_tcd_pass {
-/** Rate obtained in the pass*/
-  int rate;					
-/** Distorsion obtained in the pass*/
-  double distortiondec;		
-  int term;
-/** Length of information */
-  int len;					
-} opj_tcd_pass_t;
-
-/**
-Tile coder/decoder: layer instance
-*/
-typedef struct opj_tcd_layer {
-/** Number of passes in the layer */
-	int numpasses;			
-/** Length of information */
-  int len;					
-/** Distortion within layer */
-  double disto;				/* add for index (Cfr. Marcela) */
-  unsigned char *data;		/* data */
-} opj_tcd_layer_t;
-
-/**
-Tile coder/decoder: codeblock instance
-*/
-typedef struct opj_tcd_cblk {
-/** Dimension of the code-blocks : left upper corner (x0, y0, z0) */
-  int x0, y0, z0;
-/** Dimension of the code-blocks : right low corner (x1,y1,z1) */
-  int x1, y1, z1;		
-/** Number of bits per simbol in codeblock */
-  int numbps;
-  int numlenbits;
-  int len;						/* length */
-/** Number of pass already done for the code-blocks */
-  int numpasses;				
-/** number of pass added to the code-blocks */
-  int numnewpasses;				
-/** Number of segments */
-  int numsegs;					
-/** Segments informations */
-  opj_tcd_seg_t segs[100];		
-/** Number of passes in the layer */
-  int numpassesinlayers;		
-/** Layer information */
-  opj_tcd_layer_t layers[100];	
-/** Total number of passes */
-  int totalpasses;				
-/** Information about the passes */
-  opj_tcd_pass_t passes[100];	
-/* Data */
-  unsigned char data[524288];		
-  //unsigned char *data;
-} opj_tcd_cblk_t;
-
-/**
-Tile coder/decoder: precint instance
-*/
-typedef struct opj_tcd_precinct {
-/** Dimension of the precint : left upper corner (x0, y0, z0) */
-  int x0, y0, z0;
-/** Dimension of the precint : right low corner (x1,y1,z1) */
-  int x1, y1, z1;
-/** Number of codeblocks in precinct in width and heigth and length*/
-  int cblkno[3];				
-/** Information about the codeblocks */
-  opj_tcd_cblk_t *cblks;		
-/** Inclusion tree */
-  opj_tgt_tree_t *incltree;		
-/** Missing MSBs tree */
-  opj_tgt_tree_t *imsbtree;		
-} opj_tcd_precinct_t;
-
-/**
-Tile coder/decoder: subband instance
-*/
-typedef struct opj_tcd_band {
-/** Dimension of the subband : left upper corner (x0, y0, z0) */
-  int x0, y0, z0;
-/** Dimension of the subband : right low corner (x1,y1,z1) */
-  int x1, y1, z1;
-/** Information about the precints */
-  opj_tcd_precinct_t *precincts;	/* precinct information */
-/** Number of bits per symbol in band */
-  int numbps;
-/** Quantization stepsize associated */
-  float stepsize;
-/** Band orientation (O->LLL,...,7->HHH) */
-  int bandno;
-} opj_tcd_band_t;
-
-/**
-Tile coder/decoder: resolution instance
-*/
-typedef struct opj_tcd_resolution {
-/** Dimension of the resolution level : left upper corner (x0, y0, z0) */
-  int x0, y0, z0;
-/** Dimension of the resolution level : right low corner (x1,y1,z1) */
-  int x1, y1, z1;
-/** Number of precints in each dimension for the resolution level */
-  int prctno[3];				
-/** Number of subbands for the resolution level */
-  int numbands;					
-/** Subband information */
-  opj_tcd_band_t *bands;		
-} opj_tcd_resolution_t;
-
-/**
-Tile coder/decoder: component instance
-*/
-typedef struct opj_tcd_tilecomp {
-/** Dimension of the component : left upper corner (x0, y0, z0) */
-  int x0, y0, z0;
-/** Dimension of the component : right low corner (x1,y1,z1) */
-  int x1, y1, z1;
-/** Number of resolutions level if DWT transform*/
-  int numresolution[3];					
-/** Resolution information */
-  opj_tcd_resolution_t *resolutions;	
-/** Data of the component */
-  int *data;					
-/** Fixed_quality related */
-  int nbpix;				
-/** Number of bits per voxel in component */
-  int bpp;
-} opj_tcd_tilecomp_t;
-
-/**
-Tile coder/decoder: tile instance
-*/
-typedef struct opj_tcd_tile {
-/** Dimension of the tile : left upper corner (x0, y0, z0) */
-  int x0, y0, z0;
-/** Dimension of the tile : right low corner (x1,y1,z1) */
-  int x1, y1, z1;
-/** Number of components in tile */
-  int numcomps;					
-/** Components information */
-  opj_tcd_tilecomp_t *comps;	
-/** Fixed_quality related : no of bytes of data*/
-  int nbpix;					
-/** Fixed_quality related : distortion achieved in tile */
-  double distotile;				
-/** Fixed_quality related : distortion achieved in each layer */
-  double distolayer[100];		
-} opj_tcd_tile_t;
-
-/**
-Tile coder/decoder: volume instance
-*/
-typedef struct opj_tcd_volume {
-/** Number of tiles in width and heigth and length */
-	int tw, th, tl;				
-/** Tiles information */
-  opj_tcd_tile_t *tiles;		
-} opj_tcd_volume_t;
-
-/**
-Tile coder/decoder
-*/
-typedef struct opj_tcd {
-/** Codec context */	
-	opj_common_ptr cinfo;			
-/** Volume information */	
-	opj_volume_t *volume;			
-/** Coding parameters */	
-	opj_cp_t *cp;					
-/** Coding/decoding parameters common to all tiles */	
-	opj_tcp_t *tcp;					
-/** Info on each volume tile */
-	opj_tcd_volume_t *tcd_volume;	
-/** Pointer to the current encoded/decoded tile */
-	opj_tcd_tile_t *tcd_tile;		
-/** Current encoded/decoded tile */
-	int tcd_tileno;					
-
-	/**@name working variables */
-	/*@{*/
-	opj_tcd_tile_t *tile;
-	opj_tcd_tilecomp_t *tilec;
-	opj_tcd_resolution_t *res;
-	opj_tcd_band_t *band;
-	opj_tcd_precinct_t *prc;
-	opj_tcd_cblk_t *cblk;
-	/*@}*/
-} opj_tcd_t;
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Dump the content of a tcd structure
-*/
-void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_volume_t *img);
-/**
-Create a new TCD handle
- at param cinfo Codec context info
- at return Returns a new TCD handle if successful returns NULL otherwise
-*/
-opj_tcd_t* tcd_create(opj_common_ptr cinfo);
-/**
-Destroy a previously created TCD handle
- at param tcd TCD handle to destroy
-*/
-void tcd_destroy(opj_tcd_t *tcd);
-/**
-Initialize the tile coder (allocate the memory) 
- at param tcd TCD handle
- at param volume Raw volume
- at param cp Coding parameters
- at param curtileno Number that identifies the tile that will be encoded
-*/
-void tcd_malloc_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno);
-/**
-Initialize the tile coder (reuses the memory allocated by tcd_malloc_encode)(for 3D-DWT)
- at param tcd TCD handle
- at param volume Raw volume
- at param cp Coding parameters
- at param curtileno Number that identifies the tile that will be encoded
-*/
-void tcd_init_encode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp, int curtileno);
-/**
-Free the memory allocated for encoding
- at param tcd TCD handle
-*/
-void tcd_free_encode(opj_tcd_t *tcd);
-/**
-Initialize the tile decoder
- at param tcd TCD handle
- at param volume Raw volume
- at param cp Coding parameters
-*/
-void tcd_malloc_decode(opj_tcd_t *tcd, opj_volume_t * volume, opj_cp_t * cp);
-
-void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final);
-void tcd_rateallocate_fixed(opj_tcd_t *tcd);
-void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final);
-bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_volume_info_t * volume_info);
-/**
-Encode a tile from the raw volume into a buffer
- at param tcd TCD handle
- at param tileno Number that identifies one of the tiles to be encoded
- at param dest Destination buffer
- at param len Length of destination buffer
- at param volume_info Creation of index file
- at return 
-*/
-int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_volume_info_t * volume_info);
-/**
-Decode a tile from a buffer into a raw volume
- at param tcd TCD handle
- at param src Source buffer
- at param len Length of source buffer
- at param tileno Number that identifies one of the tiles to be decoded
-*/
-bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno);
-/**
-Free the memory allocated for decoding
- at param tcd TCD handle
-*/
-void tcd_free_decode(opj_tcd_t *tcd);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __TCD_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.c
deleted file mode 100755
index 9398ea9..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* 
-==========================================================
-   Tag-tree coder interface
-==========================================================
-*/
-void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree){
-	int nodesno;
-
-	fprintf(fd, "TGT_TREE {\n");
-	fprintf(fd, "  numnodes: %d \n", tree->numnodes);	
-	fprintf(fd, "  numleafsh: %d, numleafsv: %d, numleafsz: %d,\n", tree->numleafsh, tree->numleafsv, tree->numleafsz);
-
-	for (nodesno = 0; nodesno < tree->numnodes; nodesno++) {
-		fprintf(fd, "tgt_node %d {\n", nodesno);
-		fprintf(fd, "  value: %d \n", tree->nodes[nodesno].value);
-		fprintf(fd, "  low: %d \n", tree->nodes[nodesno].low);
-		fprintf(fd, "  known: %d \n", tree->nodes[nodesno].known);
-		if (tree->nodes[nodesno].parent) {
-			fprintf(fd, "  parent.value: %d \n", tree->nodes[nodesno].parent->value);
-			fprintf(fd, "  parent.low: %d \n", tree->nodes[nodesno].parent->low);
-			fprintf(fd, "  parent.known: %d \n", tree->nodes[nodesno].parent->known);
-		}
-		fprintf(fd, "}\n");
-
-	}
-	fprintf(fd, "}\n");
-
-}
-
-
-opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz) {
-	
-	int nplh[32];
-	int nplv[32];
-	int nplz[32];
-	opj_tgt_node_t *node = NULL;
-	opj_tgt_node_t *parentnode = NULL;
-	opj_tgt_node_t *parentnode0 = NULL;
-	opj_tgt_tree_t *tree = NULL;
-	int i, j, k, p, p0;
-	int numlvls;
-	int n, z = 0;
-
-	tree = (opj_tgt_tree_t *) opj_malloc(sizeof(opj_tgt_tree_t));
-	if(!tree) 
-		return NULL;
-	tree->numleafsh = numleafsh;
-	tree->numleafsv = numleafsv;
-	tree->numleafsz = numleafsz;
-
-	numlvls = 0;
-	nplh[0] = numleafsh;
-	nplv[0] = numleafsv;
-	nplz[0] = numleafsz;
-	tree->numnodes = 0;
-	do {
-		n = nplh[numlvls] * nplv[numlvls] * nplz[numlvls]; 
-		nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
-		nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
-		nplz[numlvls + 1] = (nplz[numlvls] + 1) / 2;
-		tree->numnodes += n;
-		++numlvls;
-	} while (n > 1);
-
-	if (tree->numnodes == 0) {
-		opj_free(tree);
-		return NULL;
-	}
-
-	tree->nodes = (opj_tgt_node_t *) opj_malloc(tree->numnodes * sizeof(opj_tgt_node_t));
-	if(!tree->nodes) {
-		opj_free(tree);
-		return NULL;
-	}
-
-	node = tree->nodes;
-	parentnode = &tree->nodes[tree->numleafsh * tree->numleafsv * tree->numleafsz];
-	parentnode0 = parentnode;
-		
-	p = tree->numleafsh * tree->numleafsv * tree->numleafsz;
-	p0 = p;
-	n = 0;
-	//fprintf(stdout,"\nH %d V %d Z %d numlvls %d nodes %d\n",tree->numleafsh,tree->numleafsv,tree->numleafsz,numlvls,tree->numnodes);
-	for (i = 0; i < numlvls - 1; ++i) {
-		for (j = 0; j < nplv[i]; ++j) {
-			k = nplh[i]*nplz[i];
-			while (--k >= 0) {
-				node->parent = parentnode;		//fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);
-				++node;	++n;		
-				if (--k >= 0 && n < p) {
-					node->parent = parentnode;	//fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);
-					++node;	++n;	
-				}
-				if (nplz[i] != 1){ //2D operation vs 3D operation
-					if (--k >= 0 && n < p) {
-						node->parent = parentnode;	//fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);
-						++node;	++n;
-					}
-					if (--k >= 0 && n < p) {
-						node->parent = parentnode;	//fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);
-						++node;	++n;
-					}
-				}
-				++parentnode; ++p;
-			}
-			if ((j & 1) || j == nplv[i] - 1) {
-				parentnode0 = parentnode;			p0 = p;		//fprintf(stdout,"parent = node[%d] \n",p);
-			} else {
-				parentnode = parentnode0;			p = p0;		//fprintf(stdout,"parent = node[%d] \n",p);
-				parentnode0 += nplh[i]*nplz[i];		p0 += nplh[i]*nplz[i];
-			}
-		}
-	}
-	node->parent = 0;
-
-	
-	tgt_reset(tree);
-
-	return tree;
-}
-
-void tgt_destroy(opj_tgt_tree_t *tree) {
-	opj_free(tree->nodes);
-	opj_free(tree);
-}
-
-void tgt_reset(opj_tgt_tree_t *tree) {
-	int i;
-
-	if (NULL == tree)
-		return;
-	
-	for (i = 0; i < tree->numnodes; i++) {
-		tree->nodes[i].value = 999;
-		tree->nodes[i].low = 0;
-		tree->nodes[i].known = 0;
-	}
-}
-
-void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value) {
-	opj_tgt_node_t *node;
-	node = &tree->nodes[leafno];
-	while (node && node->value > value) {
-		node->value = value;
-		node = node->parent;
-	}
-}
-
-void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
-	opj_tgt_node_t *stk[31];
-	opj_tgt_node_t **stkptr;
-	opj_tgt_node_t *node;
-	int low;
-
-	stkptr = stk;
-	node = &tree->nodes[leafno];
-	while (node->parent) {
-		*stkptr++ = node;
-		node = node->parent;
-	}
-	
-	low = 0;
-	for (;;) {
-		if (low > node->low) {
-			node->low = low;
-		} else {
-			low = node->low;
-		}
-		
-		while (low < threshold) {
-			if (low >= node->value) {
-				if (!node->known) {
-					bio_write(bio, 1, 1);
-					node->known = 1;
-				}
-				break;
-			}
-			bio_write(bio, 0, 1);
-			++low;
-		}
-		
-		node->low = low;
-		if (stkptr == stk)
-			break;
-		node = *--stkptr;
-	}
-}
-
-int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
-	opj_tgt_node_t *stk[31];
-	opj_tgt_node_t **stkptr;
-	opj_tgt_node_t *node;
-	int low;
-
-	stkptr = stk;
-	node = &tree->nodes[leafno];
-	while (node->parent) {
-		*stkptr++ = node;
-		node = node->parent;
-	}
-	
-	low = 0;
-	for (;;) {
-		if (low > node->low) {
-			node->low = low;
-		} else {
-			low = node->low;
-		}
-		while (low < threshold && low < node->value) {
-			if (bio_read(bio, 1)) {
-				node->value = low;
-			} else {
-				++low;
-			}
-		}
-		node->low = low;
-		if (stkptr == stk) {
-			break;
-		}
-		node = *--stkptr;
-	}
-	
-	return (node->value < threshold) ? 1 : 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.h
deleted file mode 100755
index ad27f11..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/tgt.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TGT_H
-#define __TGT_H
-/**
- at file tgt.h
- at brief Implementation of a tag-tree coder (TGT)
-
-The functions in TGT.C have for goal to realize a tag-tree coder. The functions in TGT.C
-are used by some function in T2.C.
-*/
-
-/** @defgroup TGT TGT - Implementation of a tag-tree coder */
-/*@{*/
-
-/**
-Tag node
-*/
-typedef struct opj_tgt_node {
-/** Node parent reference */
-  struct opj_tgt_node *parent;
-/**  */
-  int value;
-/**  */
-  int low;
-/**  */
-  int known;
-} opj_tgt_node_t;
-
-/**
-Tag tree
-*/
-typedef struct opj_tgt_tree {
-/** Number of leaves from horizontal axis */
-  int numleafsh;
-/** Number of leaves from vertical axis */
-  int numleafsv;
-/** Number of leaves from axial axis */
-  int numleafsz;
-/** Number of nodes */
-  int numnodes;
-/** Reference to each node instance */
-  opj_tgt_node_t *nodes;
-} opj_tgt_tree_t;
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a tag-tree
- at param numleafsh Width of the array of leafs of the tree
- at param numleafsv Height of the array of leafs of the tree
- at param numleafsz Depth of the array of leafs of the tree
- at return Returns a new tag-tree if successful, returns NULL otherwise
-*/
-opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz);
-/**
-Destroy a tag-tree, liberating memory
- at param tree Tag-tree to destroy
-*/
-void tgt_destroy(opj_tgt_tree_t *tree);
-/**
-Reset a tag-tree (set all leaves to 0)
- at param tree Tag-tree to reset
-*/
-void tgt_reset(opj_tgt_tree_t *tree);
-/**
-Set the value of a leaf of a tag-tree
- at param tree Tag-tree to modify
- at param leafno Number that identifies the leaf to modify
- at param value New value of the leaf
-*/
-void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value);
-/**
-Encode the value of a leaf of the tag-tree up to a given threshold
- at param bio Pointer to a BIO handle
- at param tree Tag-tree to modify
- at param leafno Number that identifies the leaf to encode
- at param threshold Threshold to use when encoding value of the leaf
-*/
-void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold);
-/**
-Decode the value of a leaf of the tag-tree up to a given threshold
- at param bio Pointer to a BIO handle
- at param tree Tag-tree to decode
- at param leafno Number that identifies the leaf to decode
- at param threshold Threshold to use when decoding value of the leaf
- at return Returns 1 if the node's value < threshold, returns 0 otherwise
-*/
-int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold);
-
-/*@}*/
-/* ----------------------------------------------------------------------- */
-void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree);
-
-#endif /* __TGT_H */
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.c b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.c
deleted file mode 100755
index 9066e39..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
-	int compno;
-	opj_volume_t *volume = NULL;
-
-	volume = (opj_volume_t*)opj_malloc(sizeof(opj_volume_t));
-	if(volume) {
-		volume->color_space = clrspc;
-		volume->numcomps = numcmpts;
-		/* allocate memory for the per-component information */
-		volume->comps = (opj_volume_comp_t*)opj_malloc(volume->numcomps * sizeof(opj_volume_comp_t));
-		if(!volume->comps) {
-			opj_volume_destroy(volume);
-			return NULL;
-		}
-		/* create the individual volume components */
-		for(compno = 0; compno < numcmpts; compno++) {
-			opj_volume_comp_t *comp = &volume->comps[compno];
-			comp->dx = cmptparms[compno].dx;
-			comp->dy = cmptparms[compno].dy;
-			comp->dz = cmptparms[compno].dz;
-			comp->w = cmptparms[compno].w;
-			comp->h = cmptparms[compno].h;
-			comp->l = cmptparms[compno].l;
-			comp->x0 = cmptparms[compno].x0;
-			comp->y0 = cmptparms[compno].y0;
-			comp->z0 = cmptparms[compno].z0;
-			comp->prec = cmptparms[compno].prec;
-			comp->bpp = cmptparms[compno].bpp;
-			comp->sgnd = cmptparms[compno].sgnd;
-			comp->bigendian = cmptparms[compno].bigendian;
-			comp->dcoffset = cmptparms[compno].dcoffset;
-			comp->data = (int*)opj_malloc(comp->w * comp->h * comp->l * sizeof(int));
-			if(!comp->data) {
-				fprintf(stdout,"Unable to malloc comp->data (%d x %d x %d x bytes)",comp->w,comp->h,comp->l);
-				opj_volume_destroy(volume);
-				return NULL;
-			}
-			//fprintf(stdout,"%d %d %d %d %d %d %d %d %d", comp->w,comp->h, comp->l, comp->dx, comp->dy, comp->dz, comp->prec, comp->bpp, comp->sgnd);
-		}
-	}
-
-	return volume;
-}
-
-void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume) {
-	int i;
-	if(volume) {
-		if(volume->comps) {
-			/* volume components */
-			for(i = 0; i < volume->numcomps; i++) {
-				opj_volume_comp_t *volume_comp = &volume->comps[i];
-				if(volume_comp->data) {
-					opj_free(volume_comp->data);
-				}
-			}
-			opj_free(volume->comps);
-		}
-		opj_free(volume);
-	}
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.h b/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.h
deleted file mode 100755
index 737bde7..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/volume.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __VOLUME_H
-#define __VOLUME_H
-/**
- at file volume.h
- at brief Implementation of operations on volumes (VOLUME)
-
-The functions in VOLUME.C have for goal to realize operations on volumes.
-*/
-
-/** @defgroup VOLUME VOLUME - Implementation of operations on volumes */
-/*@{*/
-
-
-/*@}*/
-
-#endif /* __VOLUME_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/LPI_JP3D_VM.tcl b/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/LPI_JP3D_VM.tcl
deleted file mode 100755
index eb184de..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/LPI_JP3D_VM.tcl
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/sh
-# The next line is executed by /bin/sh, but not tcl \
-exec wish "$0" ${1+"$@"}
-
-namespace eval jp3dVM {
-
-    variable _progress 0
-    variable _afterid  ""
-    variable _status "Compute in progress..."
-    variable notebook
-    variable mainframe
-    variable dataout "Process execution information"
-    variable status
-    variable prgtext
-    variable prgindic
-
-    set pwd [pwd]
-    cd [file dirname [info script]]
-    variable VMDIR [pwd]
-    cd $pwd
-
-    foreach script {encoder.tcl decoder.tcl} {
-	namespace inscope :: source $VMDIR/$script
-    }
-}
-
-
-proc jp3dVM::create { } {
-    variable notebook
-    variable mainframe
-    variable dataout
-
-    bind all <F12> { catch {console show} }
-
-    # Menu description
-    set descmenu {
-        "&File" {} {} 0 {
-            {command "E&xit" {} "Exit BWidget jp3dVM" {} -command exit}
-        }
-        "&Options" {} {} 0 {
-            {command "&Encode" {} "Show encoder" {}
-                -command  {$jp3dVM::notebook raise [$jp3dVM::notebook page 0]}
-            }
-            {command "&Decode" {} "Show decoder" {}
-                -command  {$jp3dVM::notebook raise [$jp3dVM::notebook page 1]}
-            }
-        }
-	"&Help" {} {} 0 {
-            {command "&About authors..." {} "Show info about authors" {} 
-		-command {MessageDlg .msgdlg -parent . -title "About authors" -message " Copyright @ LPI-UVA 2006 " -type ok -icon info}}
-        }
-    }
-
-    set mainframe [MainFrame .mainframe \
-                       -menu         $descmenu \
-                       -textvariable jp3dVM::status \
-                       -progressvar  jp3dVM::prgindic]
-
-    $mainframe addindicator -text "JP3D Verification Model 1.0.0"
-
-    # NoteBook creation
-    set frame    [$mainframe getframe]
-    set notebook [NoteBook $frame.nb]
-
-    set logo [frame $frame.logo]
-    #creo imagen logo
-    image create photo LPIimg -file logoLPI.gif
-    set logoimg [Label $logo.logoimg -image LPIimg]
-    
-    set f0  [VMEncoder::create $notebook]
-    set f1  [VMDecoder::create $notebook]
-
-	set tfinfo [TitleFrame $frame.codinfo -text "Program Execution"]
-	set codinfo [$tfinfo getframe]
-	set sw [ScrolledWindow $codinfo.sw -relief sunken -borderwidth 2 -scrollbar both]
-	set sf [ScrollableFrame $codinfo.sf ]
-	$sw setwidget $sf
-	set subf [$sf getframe]
-	set labinfo [label $subf.labinfo -textvariable jp3dVM::dataout -justify left]
-
-	pack $labinfo -side left 
-	pack $sw 
-
-    $notebook compute_size
-    $notebook raise [$notebook page 0]
-
-    pack $logoimg -side left -fill x -expand yes 
-    pack $notebook -expand yes 
-    pack $logo $tfinfo -side left -expand yes 
-    pack $mainframe -fill both -expand yes
-    update idletasks
-}
-
-
-proc jp3dVM::main {} {
-    variable VMDIR
-
-    lappend ::auto_path [file dirname $VMDIR]
-    namespace inscope :: package require BWidget
-
-    option add *TitleFrame.l.font {helvetica 11 bold italic}
-
-    wm withdraw .
-    wm title . "JP3D Verification Model @ LPI"
-
-    jp3dVM::create
-    BWidget::place . 0 0 center
-    wm deiconify .
-    raise .
-    focus -force .
-}
-
-jp3dVM::main
-wm geom . [wm geom .]
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/README b/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/README
deleted file mode 100644
index f4e2e35..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/README
+++ /dev/null
@@ -1,13 +0,0 @@
-HOWTO USE THE TCL/TK APP IN 'jp3d/tcltk'
-----------------------------------------
-1. Download the 'BWidget-1.9.2'
-    http://www.sourceforge.net/projects/tcllib/
-
-2. Install it e.g. in '/usr/local/BWidget-1.9.2/'
-3. Add the lappend command in line 4
-  to jp3d/tcltk/LPI_JP3D_VM.tcl:
-
-#!/bin/sh
-# The next line is executed by /bin/sh, but not tcl \
-exec wish "$0" ${1+"$@"}
-lappend auto_path /usr/local/BWidget-1.9.2
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/Thumbs.db b/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/Thumbs.db
deleted file mode 100755
index 5d6ffdf..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/Thumbs.db and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/decoder.tcl b/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/decoder.tcl
deleted file mode 100755
index 6fadbb1..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/decoder.tcl
+++ /dev/null
@@ -1,272 +0,0 @@
-
-namespace eval VMDecoder {
-	variable var
-	variable JP3Ddecoder "../bin/jp3d_vm_dec.exe"
-	#variable JP3Ddecoder "jp3d_vm_dec.exe"
-}
-
-
-proc VMDecoder::create { nb } {
-	variable var
-
-	set frameD [$nb insert end VMDecoder -text "Decoder"]
-	set topfD	[frame $frameD.topfD]
-	set medfD	[frame $frameD.medfD]
-	set bottomfD	[frame $frameD.bottomfD]
-	set srcfD [TitleFrame $topfD.srcfD -text "Source"]
-	set dstfD [TitleFrame $topfD.dstfD -text "Destination"]
-	set paramfD [TitleFrame $medfD.paramfD -text "Decoding parameters"]
-	set infofD [TitleFrame $medfD.infofD -text "Distortion measures"]
-
-	set frame1 [$srcfD getframe]
-	_sourceD  $frame1
-	set frame2  [$dstfD getframe]
-	_destinationD  $frame2
-	set frame3  [$infofD getframe]
-	_originalD $frame3
-	set frame4  [$paramfD getframe]
-	_paramsD $frame4
-
-	set butD   [Button $bottomfD.butD -text "Decode!" \
-		   -command  "VMDecoder::_decode $frame1 $frame2 $frame3" \
-		   -helptext "Decoding trigger button"]
-	set butR   [Button $bottomfD.butR -text "Save info" \
-		   -command  "VMDecoder::_save $frame3" \
-		   -helptext "Save information"]
-	
-	pack $srcfD $dstfD -side left -fill both -padx 10 -ipadx 5 -expand yes
-	pack $topfD -pady 4 -fill x
-	
-	pack $paramfD $infofD -side left -fill both -padx 10 -pady 2 -ipadx 5 -expand yes
-	pack $medfD -pady 4 -fill x 
-
-	pack $butD $butR -side left -padx 4 -pady 5 -expand yes
-	pack $bottomfD -pady 4 -fill x
-
-return $frameD
-}
-
-
-proc fileDialogD {w ent operation} {
-
-	variable file
-	
-	if {$operation == "open"} {
-		#-----Type names---------Extension(s)---
-		set types {
-		{"JP3D Files"	   {.jp3d}	}
-		{"All files"		*}
-		}
-		set file [tk_getOpenFile -filetypes $types -parent $w ]
-	} elseif {$operation == "original"} {
-		#-----Type names---------Extension(s)---
-		set types {
-		{"BIN Raw Image Files"  {.bin}  }
-		{"PGX Raw Image Files"	{.pgx}	}
-		{"All files"		*}
-		}
-		set file [tk_getOpenFile -filetypes $types -parent $w ]
-	} else {
-		#-----Type names---------Extension(s)---
-		set types {
-		{"BIN Raw Image Files"  {.bin}  }
-		{"PGX Raw Image Files"	{.pgx}	}
-		{"All files"		*}
-		}
-		set file [tk_getSaveFile -filetypes $types -parent $w -initialfile Untitled -defaultextension "*.bin"]
-	}
-	if {[string compare $file ""]} {
-		$ent delete 0 end
-		$ent insert end $file
-		$ent xview moveto 1
-	}
-}
-
-proc VMDecoder::_sourceD { parent } {
-	
-	variable var
-	
-	set labsrcD [LabelFrame $parent.labsrcD -text "Select compressed file: " -side top \
-			-anchor w -relief flat -borderwidth 0]
-	set subsrcD [$labsrcD getframe]
-	set listD [entry $subsrcD.entrysrcD -width 40 -textvariable VMDecoder::var(sourceD)]
-	
-	set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
-	set subbrw [$labbrw getframe]
-	set butbrw [button $subbrw.butbrw -image [Bitmap::get open] \
-		-relief raised -borderwidth 1 -padx 1 -pady 1 \
-		-command "fileDialogD . $subsrcD.entrysrcD open"]
-	
-	pack $listD -side top
-	pack $butbrw -side top
-	pack $labsrcD $labbrw -side left -fill both -expand yes
-
-
-}
-
-proc VMDecoder::_destinationD { parent } {
-	
-	variable var
-	
-	set labdstD [LabelFrame $parent.labdstD -text "Save decompressed volume file(s) as: " -side top \
-			-anchor w -relief flat -borderwidth 0]
-	set subdstD [$labdstD getframe]
-	set listD [entry $subdstD.entrydstD -width 40 -textvariable VMDecoder::var(destinationD)]
-	
-	set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
-	set subbrw [$labbrw getframe]
-	set butbrw [button $subbrw.butbrw -image [Bitmap::get save] \
-		-relief raised -borderwidth 1 -padx 1 -pady 1 \
-		-command "fileDialogD . $subdstD.entrydstD save"]
-
-	pack $listD -side top
-	pack $butbrw -side top
-	pack $labdstD $labbrw -side left -fill both -expand yes
-}
-
-proc VMDecoder::_originalD { parent } {
-	
-	variable var
-	
-	set laborgD [LabelFrame $parent.laborgD -text "Select original file: " -side top \
-			-anchor w -relief flat -borderwidth 0]
-	set suborgD [$laborgD getframe]
-	set listorgD [entry $suborgD.entryorgD -width 30 -textvariable VMDecoder::var(originalD)]
-	
-	set labbrw2 [LabelFrame $parent.labbrw2 -side top -anchor w -relief flat -borderwidth 0]
-	set subbrw2 [$labbrw2 getframe]
-	set butbrw2 [button $subbrw2.butbrw2 -image [Bitmap::get open] \
-		-relief raised -borderwidth 1 -padx 1 -pady 1 \
-		-command "fileDialogD . $suborgD.entryorgD original"]
-	
-	set infoD [Label $parent.infoD -relief sunken -textvariable VMDecoder::var(decodinfo) -justify left]
-
-	pack $listorgD -side left -anchor n
-	pack $butbrw2 -side left -anchor n
-	pack $infoD -side bottom -anchor nw -pady 4 -ipadx 150 -ipady 20 -expand yes
-	pack $laborgD $labbrw2 -side left -fill both 
-
-
-}
-
-proc VMDecoder::_paramsD { parent } {
-	
-	variable var
-	
-	########### DECODING  #############
-	set labcod [LabelFrame $parent.labcod -side top -anchor w -relief sunken -borderwidth 1]
-	set subcod  [$labcod getframe]
-
-		set frameres [frame $subcod.frameres -borderwidth 1]
-		set labres [LabelEntry $frameres.labres -label "Resolutions to discard: " -labelwidth 20 -labelanchor w \
-                   -textvariable VMDecoder::var(resdiscard) -editable 1 \
-                   -helptext "Number of highest resolution levels to be discarded on each dimension" ]
-	set VMDecoder::var(resdiscard) "0,0,0"
-	
-		set framelayer [frame $subcod.framelayer -borderwidth 1]
-		set lablayer [LabelEntry $framelayer.lablayer -label "Layers to decode: " -labelwidth 20 -labelanchor w \
-                   -textvariable VMDecoder::var(layer) -editable 1 \
-                   -helptext "Maximum number of quality layers to decode" ]
-	set VMDecoder::var(layer) "All"
-
-	set framebe [frame $subcod.framebe -borderwidth 1]
-	set chkbe [checkbutton $framebe.chkbe -text "Write decoded file with BigEndian byte order" \
-		   -variable VMDecoder::var(be) -onvalue 1 -offvalue 0 ]
-
-		pack $labres -side left -padx 2 -anchor n
-		pack $lablayer -side left -padx 2 -anchor n
-		pack $chkbe -side left -padx 2 -anchor w
-		pack $frameres $framelayer $framebe -side top -anchor w
-
-	pack $subcod -anchor n
-	pack $labcod -side left -fill both -padx 4 -expand yes
-}
-
-
-proc VMDecoder::_decode { framesrc framedst frameinfo} {
-
-	variable var
-
-	set sourceD [$framesrc.labsrcD.f.entrysrcD get ]
-	set destinationD [$framedst.labdstD.f.entrydstD get ]
-	set originD [$frameinfo.laborgD.f.entryorgD get ]
-	set cond1 [string match *.pgx [string tolower $destinationD]]
-	set cond2 [string match *\**.pgx [string tolower $destinationD]]
-	set cond3 [string match *.bin [string tolower $destinationD]]
-	
-	#comprobamos datos son correctos
-	if {($cond1 == 1) && ($cond2 == 0)} {
-		set pgx "*.pgx"
-		set pattern [string range $destinationD 0 [expr [string length $destinationD]-5]]
-		set destinationD $pattern$img
-	} elseif {$sourceD == ""} {
-	  MessageDlg .msgdlg -parent . -message "Error : Source file is not defined !" -type ok -icon error 
-	} elseif {$destinationD == ""} {
-	  MessageDlg .msgdlg -parent . -message "Error : Destination file is not defined !" -type ok -icon error 
-	} else {
-
-		#creamos datain a partir de los parametros de entrada
-		#set dirJP3Ddecoder [mk_relativepath $VMDecoder::JP3Ddecoder]
-		set dirJP3Ddecoder $VMDecoder::JP3Ddecoder
-		set datain [concat " $dirJP3Ddecoder -i [mk_relativepath $sourceD] "]
-		set datain [concat " $datain -o [mk_relativepath $destinationD] "]
-		if {$originD != ""} {
-			set datain [concat " $datain -O [mk_relativepath $originD] "]
-			if {$cond3 == 1} {
-				set img ".img"
-				set pattern [string range $originD 0 [expr [string length $originD]-5]]
-				set pattern $pattern$img
-				if {[file exists $pattern]} {
-				  set datain [concat " $datain -m [mk_relativepath $pattern] "]
-				} else {
-				  MessageDlg .msgdlg -parent . -message "Error : IMG file associated to original BIN volume file not found in same directory !" -type ok -icon info 
-				}
-			}
-		}
-		if {$VMDecoder::var(resdiscard) != "0,0,0"} {
-			set datain [concat " $datain -r $VMDecoder::var(resdiscard) "]
-		}
-		if {$VMDecoder::var(layer) != "All" && $VMDecoder::var(layer) > 0} {
-			set datain [concat " $datain -l $VMDecoder::var(layer) "]
-		}
-		if {$VMDecoder::var(be) == 1} {
-			set datain [concat " $datain -BE"]
-		}
-		
-		set VMDecoder::var(progval) 10
-		ProgressDlg .progress -parent . -title "Wait..." \
-			-type         infinite \
-			-width        20 \
-			-textvariable "Compute in progress..."\
-			-variable     VMDecoder::progval \
-			-stop         "Stop" \
-			-command      {destroy .progress}
-
-		after 200 set VMDecoder::var(progval) 2
-
-		set fp [open "| $datain " r+] 
-		fconfigure $fp -buffering line 
-		set jp3dVM::dataout [concat "EXECUTED PROGRAM:\n\t$datain"]
-		while {-1 != [gets $fp tmp]} {
-			set jp3dVM::dataout [concat "$jp3dVM::dataout\n$tmp"]
-		}
-		close $fp
-		destroy .progress
-		set cond [string first "ERROR" $jp3dVM::dataout]
-		set cond2 [string first "PSNR" $jp3dVM::dataout]
-		set cond3 [string first "RESULT" $jp3dVM::dataout]
-		if {$cond != -1} {
-		   MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond-1] end] -type ok -icon error
-		} elseif {$cond3 != -1} {
-			if {$cond2 != -1} {
-				set VMDecoder::var(decodinfo) [string range $jp3dVM::dataout [expr $cond2-1] end]
-			}
-			MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond3-1] end] -type ok -icon info
-		}
-	}
-}
-
-proc VMDecoder::_save { frameinfo } {
-
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/encoder.tcl b/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/encoder.tcl
deleted file mode 100755
index dc174b7..0000000
--- a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/encoder.tcl
+++ /dev/null
@@ -1,470 +0,0 @@
-
-namespace eval VMEncoder {
-	variable var
-	variable JP3Dencoder "../bin/jp3d_vm_enc.exe"
-}
-
-proc VMEncoder::create { nb } {
-
-	set frame [$nb insert end VMEncoder -text "Encoder"]
-	set topf	[frame $frame.topf]
-	set midf	[frame $frame.midf]
-	set bottomf	[frame $frame.bottomf]
-	set srcf [TitleFrame $topf.srcf -text "Source"]
-	set dstf [TitleFrame $topf.dstf -text "Destination"]
-	set Tparf [TitleFrame $midf.parfT -text "Transform Parameters"]
-	set Cparf [TitleFrame $midf.parfC -text "Coding Parameters"]
-
-	set frame1 [$srcf getframe]
-		VMEncoder::_sourceE  $frame1
-	
-	set frame2  [$dstf getframe]
-		VMEncoder::_destinationE  $frame2
-	
-	set frame3  [$Tparf getframe]
-		VMEncoder::_transformE $frame3
-
-	set frame4  [$Cparf getframe]
-		VMEncoder::_codingE $frame4
-	
-	set butE  [Button $bottomf.butE -text "Encode!" \
-		   -command  "VMEncoder::_encode $frame1 $frame2" \
-		   -helptext "Encoding trigger button"]
-	set butR  [Button $bottomf.butR -text "Restore defaults" \
-		   -command  "VMEncoder::_reset $frame1 $frame2 $frame3 $frame4" \
-		   -helptext "Reset to default values"]
-
-	pack $srcf $dstf -side left -fill y -padx 4 -expand yes
-	pack $topf -pady 2 -fill x
-
-	pack $Tparf $Cparf -side left -fill both -padx 4 -expand yes
-	pack $midf -pady 2 -fill x
-	
-	pack $butE $butR -side left -padx 40 -pady 5 -fill y -expand yes
-	pack $bottomf -pady 2 -fill x
-
-	return $frame
-}
-
-proc VMEncoder::_sourceE { parent } {
-
-	variable var
-
-	set labsrc [LabelFrame $parent.labsrc -text "Select volume file to encode: " -side top \
-			-anchor w -relief flat -borderwidth 0]
-	set subsrc [$labsrc getframe]
-	set list [entry $subsrc.entrysrc -width 30 -textvariable VMDecoder::var(source)]
-	
-	set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
-	set subbrw [$labbrw getframe]
-	set butbrw [button $subbrw.butbrw -image [Bitmap::get open] \
-		-relief raised -borderwidth 1 -padx 1 -pady 1 \
-		-command "fileDialogE . $subsrc.entrysrc open"]
-	
-	pack $list -side top
-	pack $butbrw -side top
-	pack $labsrc $labbrw -side left -fill both -expand yes
-}
-
-proc VMEncoder::_destinationE { parent } {
-
-	variable var
-
-	set labdst [LabelFrame $parent.labdst -text "Save compressed volume as: " -side top \
-			-anchor w -relief flat -borderwidth 0]
-	set subdst [$labdst getframe]
-	set list [entry $subdst.entrydst -width 30 -textvariable VMDecoder::var(destination)]
-	
-	set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
-	set subbrw [$labbrw getframe]
-	set butbrw [button $subbrw.butbrw -image [Bitmap::get save] \
-		-relief raised -borderwidth 1 -padx 1 -pady 1 \
-		-command "fileDialogE . $subdst.entrydst save"]
-	
-	pack $list -side top
-	pack $butbrw -side top
-	pack $labdst $labbrw -side left -fill both -expand yes
-}
-
-proc VMEncoder::_codingE { parent } {
-
-	
-	########### CODING  #############
-	set labcod [LabelFrame $parent.labcod -side top -anchor w -relief sunken -borderwidth 1]
-	set subcod  [$labcod getframe]
-
-		set framerate [frame $subcod.framerate -borderwidth 1]
-		set labrate [LabelEntry $framerate.labrate -label "Rates: " -labelwidth 9 -labelanchor w \
-                   -textvariable VMEncoder::var(rate) -editable 1 \
-                   -helptext "Compression ratios for different layers (R1, R2, R3,...). If R=1, lossless coding" ]
-	set VMEncoder::var(rate) "1"
-
-		set framecblk [frame $subcod.framecblk -borderwidth 1]
-		set labcblk [LabelEntry $framecblk.labcblk -label "Codeblock: " -labelwidth 9 -labelanchor w \
-                   -textvariable VMEncoder::var(cblksize) -editable 1 \
-                   -helptext "Codeblock size (X, Y, Z)" ]
-	set VMEncoder::var(cblksize) "64,64,64"
-
-		set frametile [frame $subcod.frametile -borderwidth 1]
-		set labtile [LabelEntry $frametile.labtile -label "Tile size: " -labelwidth 9 -labelanchor w \
-                   -textvariable VMEncoder::var(tilesize) -editable 1 \
-                   -helptext "Tile size (X, Y, Z)" ]
-	set VMEncoder::var(tilesize) "512,512,512"
-
-		set framesop [frame $subcod.framesop -borderwidth 1]
-		set chksop [checkbutton $framesop.chksop -text "Write SOP marker" \
-			   -variable VMEncoder::var(sop) -onvalue 1 -offvalue 0 ]
-		set frameeph [frame $subcod.frameeph -borderwidth 1]
-		set chkeph [checkbutton $frameeph.chkeph -text "Write EPH marker" \
-			   -variable VMEncoder::var(eph) -onvalue 1 -offvalue 0 ]
-	
-		set framepoc [frame $subcod.framepoc -borderwidth 1]
-		set labpoc [label $framepoc.labpoc -text "Progression order: " ]
-		set progorder [ComboBox $framepoc.progorder \
-			   -text {Choose a progression order} \
-			   -width 10 \
-			   -textvariable VMEncoder::var(progorder) \
-			   -values {"LRCP" "RLCP" "RPCL" "PCRL" "CPRL"} \
-			   -helptext "Progression order"]
-		set VMEncoder::var(progorder) "LRCP"
-
-		pack $labrate -side left -padx 2 -anchor n
-		pack $labcblk -side left -padx 2 -anchor n
-		pack $labpoc $progorder -side left -padx 2 -anchor w
-		#pack $labtile -side left -padx 2 -anchor n
-		pack $chksop -side left -padx 2 -anchor w
-		pack $chkeph -side left -padx 2 -anchor w
-	########### ENTROPY CODING  #############
-	set labent [LabelFrame $parent.labent -text "Entropy Coding" -side top -anchor w -relief sunken -borderwidth 1]
-	set subent  [$labent getframe]
-		foreach entval {2EB 3EB} entropy {2D_EBCOT 3D_EBCOT} {
-			set rad [radiobutton $subent.$entval \
-				-text $entropy \
-				-variable VMEncoder::var(encoding) \
-				-command "disableGR $entval $labcblk $progorder $labrate $chksop $chkeph" \
-				-value $entval ]
-			pack $rad -anchor w
-		}
-		$subent.2EB select 
-
-	pack $subent -padx 2 -anchor n
-
-	pack $framerate $framecblk $framepoc $framesop $frameeph -side top -anchor w
-	pack $subcod -anchor n
-
-	pack $labent $labcod -side left -fill both -padx 4 -expand yes
-
-
-}
-
-proc VMEncoder::_transformE { parent } {
-
-	variable var
-
-	########### TRANSFORM  #############
-	set labtrf [LabelFrame $parent.labtrf -text "Transform" -side top -anchor w -relief sunken -borderwidth 1]
-	set subtrf  [$labtrf getframe]
-	set labres [LabelFrame $parent.labres -side top -anchor w -relief sunken -borderwidth 1]
-	set subres [$labres getframe]
-		
-		########### ATK #############
-		set frameatk [frame $subres.frameatk -borderwidth 1]
-		set labatk [label $frameatk.labatk -text "Wavelet kernel:  " -anchor w]
-		set atk [ComboBox $frameatk.atk \
-				-textvariable VMEncoder::var(atk) \
-				-width 20 \
-				-text {Choose a wavelet kernel} \
-				-editable false \
-				-values {"R5.3" "I9.7"} ]
-		set VMEncoder::var(atk) "R5.3"
-		pack $labatk $atk -side left -anchor w
-		########### RESOLUTIONS #############
-		set frameres1 [frame $subres.frameres1 -borderwidth 1]
-		set labresolution [label $frameres1.labresol -text "Resolutions: " -anchor w ]
-		set frameres2 [frame $subres.frameres2 -borderwidth 1]
-		set labresX [label $frameres2.labresX -text "  X" -anchor w ]
-		set labresY [label $frameres2.labresY -text "  Y" -anchor w ]
-		set labresZ [label $frameres2.labresZ -text "  Z" -anchor w ]
-		
-
-		set resX [SpinBox $frameres2.spinresX \
-				-range {1 6 1} -textvariable VMEncoder::var(resX) \
-				-helptext "Number of resolutions in X" \
-				-width 3 \
-				-editable false ]
- 		set resY [SpinBox $frameres2.spinresY \
-				-range {1 6 1} -textvariable VMEncoder::var(resY) \
-				-helptext "Number of resolutions in Y" \
-				-width 3 \
-				-editable false ]
-		set resZ [SpinBox $frameres2.spinresZ \
-				-range {1 6 1} -textvariable VMEncoder::var(resZ) \
-				-helptext "Number of resolutions in Z" \
-				-width 3 \
-				-editable false \
-				-state disabled ]
-		set VMEncoder::var(resX) 3
-		set VMEncoder::var(resY) 3
-		set VMEncoder::var(resZ) 3
-
-		########### TRF  #############
-		foreach trfval {2DWT 3DWT} trf {2D-DWT 3D-DWT} {
-			set rad [radiobutton $subtrf.$trfval -text $trf \
-					-variable VMEncoder::var(transform) \
-					-command "disable3RLS $trfval $atk $resX $resY $resZ"\
-					-value $trfval ]
-			pack $rad -anchor w
-		}
-		$subtrf.2DWT select
-		
-	pack $subtrf -side left -padx 2 -pady 4
-	
-		pack $labresolution -padx 2 -side left -anchor w
-		pack $labresX $resX -padx 2 -side left -anchor w
-		pack $labresY $resY -padx 2 -side left -anchor w
-		pack $labresZ $resZ -padx 2 -side left -anchor w
-
-		pack $frameres1 -side top -fill x
-		pack $frameres2 $frameatk -side top -padx 2 -pady 4 -anchor n
-
-	pack $subres -side left -padx 2 -pady 4
-	pack $labtrf $labres -side left -fill both -padx 4 -expand yes
-}
-
-
-proc VMEncoder::_encode { framesrc framedst } {
-
-	variable var
-
-	set source [$framesrc.labsrc.f.entrysrc get ]
-	set destination [$framedst.labdst.f.entrydst get ]
-	set cond1 [string match *.pgx [string tolower $source]]
-	set cond2 [string match *-*.pgx [string tolower $source]]
-	set cond3 [string match *.bin [string tolower $source]]
-
-	set img ".img"
-	set pattern [string range $source 0 [expr [string length $source]-5]]
-	set pattern $pattern$img
-	set exist [file exists $pattern]
-	
-	#comprobamos datos son correctos
-	if {($cond1 == 1) && ($cond2 == 0)} {
-	  MessageDlg .msgdlg -parent . -message "Info : Really want to encode an slice instead of a volume?.\n For a group of .pgx slices, name must contain a - denoting a sequential index!" -type ok -icon info
-	} 
-	
-	if {$source == ""} {
-	  MessageDlg .msgdlg -parent . -message "Error : Source file is not defined !" -type ok -icon error 
-	} elseif {$destination == ""} {
-	  MessageDlg .msgdlg -parent . -message "Error : Destination file is not defined !" -type ok -icon error 
-	} elseif { ($VMEncoder::var(transform) != "3RLS") && ($VMEncoder::var(atk) == "Choose a wavelet transformation kernel") } {
-	  MessageDlg .msgdlg -parent . -title "Info" -message "Please choose a wavelet transformation kernel"\
-			-type ok -icon warning
-	} elseif {($exist == 0) && ($cond1 == 0) && ($cond3 == 1)} {
-		  MessageDlg .msgdlg -parent . -message "Error : IMG file associated to BIN volume file not found in same directory !" -type ok -icon info 
-	} else {
-
-		#creamos datain a partir de los parametros de entrada
-#		set dirJP3Dencoder [mk_relativepath $VMEncoder::JP3Dencoder]
-		set dirJP3Dencoder $VMEncoder::JP3Dencoder
-		set datain [concat " $dirJP3Dencoder -i [mk_relativepath $source] "]
-		if {$cond3 == 1} {
-		   set datain [concat " $datain -m [mk_relativepath $pattern] "]
-		}
-		set datain [concat " $datain -o [mk_relativepath $destination] "]
-		if {$VMEncoder::var(encoding) != "2EB"} {
-			set datain [concat " $datain -C $VMEncoder::var(encoding) "]
-		}
-		if {$VMEncoder::var(transform) == "2DWT"} {
-			set datain [concat " $datain -n $VMEncoder::var(resX),$VMEncoder::var(resY) "]
-		} elseif {$VMEncoder::var(transform) == "3DWT"} {
-			set datain [concat " $datain -n $VMEncoder::var(resX),$VMEncoder::var(resY),$VMEncoder::var(resZ) "]
-		}
-		
-		set datain [concat " $datain -r $VMEncoder::var(rate) "]
-		
-		if {$VMEncoder::var(atk) == "I9.7"} {
-			set datain [concat " $datain -I "]
-		} 
-		if {$VMEncoder::var(sop) == 1} {
-			set datain [concat " $datain -SOP "]
-		}
-		if {$VMEncoder::var(eph) == 1} {
-			set datain [concat " $datain -EPH "]
-		}
-		if {$VMEncoder::var(progorder) != "LRCP"} {
-			set datain [concat " $datain -p $VMEncoder::var(progorder) "]
-		}
-		if {$VMEncoder::var(cblksize) != "64,64,64"} {
-			set datain [concat " $datain -b $VMEncoder::var(cblksize) "]
-		}
-
-		
-		#Making this work would be great !!! 
-		set VMEncoder::var(progval) 10
-		ProgressDlg .progress -parent . -title "Wait..." \
-			-type         infinite \
-			-width        20 \
-			-textvariable "Compute in progress..."\
-			-variable     VMEncoder::progval \
-			-stop         "Stop" \
-			-command      {destroy .progress}
-		after 200 set VMEncoder::var(progval) 2
-		set fp [open "| $datain " r+] 
-		fconfigure $fp -buffering line 
-		set jp3dVM::dataout [concat "EXECUTED PROGRAM:\n\t$datain"]
-		while {-1 != [gets $fp tmp]} {
-			set jp3dVM::dataout [concat "$jp3dVM::dataout\n$tmp"]
-		}
-		destroy .progress
-		set cond [string first "ERROR" $jp3dVM::dataout]
-		set cond2 [string first "RESULT" $jp3dVM::dataout]
-		if {$cond != -1} {
-		   MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond-1] end] -type ok -icon error
-		} elseif {$cond2 != -1} {
-		   MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond2+7] end] -type ok -icon info
-		   close $fp
-		} else {
-		   #Must do something with this !!! [pid $fp]
-  		   close $fp
-		}
-	}
-}
-
-proc VMEncoder::_reset { framesrc framedst frametrf framecod} {
-
-	variable var
-
-	#Restore defaults values
-	set VMEncoder::var(transform) 2DWT
-	set VMEncoder::var(encoding) 2EB
-	set VMEncoder::var(atk) "R5.3"
-	set VMEncoder::var(progorder) "LRCP"
-	set atk $frametrf.labres.f.frameatk.atk
-	set resX $frametrf.labres.f.frameres2.spinresX
-	set resY $frametrf.labres.f.frameres2.spinresY
-	set resZ $frametrf.labres.f.frameres2.spinresZ
-	disable3RLS 2DWT $atk $resX $resY $resZ 
-	set labcblk $framecod.labcod.f.framecblk.labcblk
-	set progorder $framecod.labcod.f.framepoc.progorder
-	set labrate $framecod.labcod.f.framerate.labrate
-	set chksop $framecod.labcod.f.framesop.chksop
-	set chkeph $framecod.labcod.f.frameeph.chkeph
-	disableGR 3EB $labcblk $progorder $labrate $chksop $chkeph
-
-	$framesrc.labsrc.f.entrysrc delete 0 end
-	$framedst.labdst.f.entrydst delete 0 end
-}
-
-proc fileDialogE {w ent operation} {
-
-	variable file
-	variable i j
-
-	if {$operation == "open"} {
-		set types {
-			{"Source Image Files"	{.pgx .bin}	}
-			{"All files"		*}
-		}
-		set file [tk_getOpenFile -filetypes $types -parent $w]
-		if {[string compare $file ""]} {
-			$ent delete 0 end
-			$ent insert end $file
-			$ent xview moveto 1
-		}
-	} else {
-		set types {
-			{"JP3D Files"		   {.jp3d}	}
-			{"JPEG2000 Files"	   {.j2k}	}
-			{"All files"		*}
-		}
-		set file [tk_getSaveFile -filetypes $types -parent $w \
-			-initialfile Untitled -defaultextension .jp3d]
-		if {[string compare $file ""]} {
-			$ent delete 0 end
-			$ent insert end $file
-			$ent xview moveto 1
-		}
-	}
-}
-
-proc mk_relativepath {abspath} {
-
-	set mydir [split [string trimleft [pwd] {/}] {/}]
-	set abspathcomps [split [string trimleft $abspath {/}] {/}]
-
-	set i 0
-	while {$i<[llength $mydir]} {
-		if {![string compare [lindex $abspathcomps $i] [lindex $mydir $i]]} {
-			incr i
-		} else {
-			break
-		}
-	}
-	set h [expr [llength $mydir]-$i]
-	set j [expr [llength $abspathcomps]-$i]
-
-	if {!$h} {
-		set relpath "./"
-	} else {
-		set relpath ""
-		while { $h > 0 } {
-			set relpath "../$relpath"
-			incr h -1
-		}
-	}
-
-	set h [llength $abspathcomps]
-	while { $h > $i } {
-		set relpath [concat $relpath[lindex $abspathcomps [expr [llength $abspathcomps]-$j]]/]
-		incr h -1
-		incr j -1
-	}
-	return [string trim $relpath {/}]
-}
-
-proc disable3RLS {flag atk resX resY resZ}  {
-
-	if {$flag == "3RLS"} {
-		$atk configure -state disabled
-		$resX configure -state disabled
-		$resY configure -state disabled
-		$resZ configure -state disabled
-	} elseif {$flag == "2DWT"} {
-		$atk configure -state normal
-		$resX configure -state normal
-		$resY configure -state normal
-		$resZ configure -state disabled
-	} elseif {$flag == "3DWT"} {
-		$atk configure -state normal
-		$resX configure -state normal
-		$resY configure -state normal
-		$resZ configure -state normal
-	}
-}
-
-proc disableGR {flag labcblk progorder labrate chksop chkeph} {
-	
-	if {$flag == "2EB"} {
-		$labcblk configure -state normal
-		$progorder configure -state normal
-		$labrate configure -state normal
-		$chksop configure -state normal
-		$chkeph configure -state normal
-		set VMEncoder::var(cblksize) "64,64,64"
-		set VMEncoder::var(tilesize) "512,512,512"
-	} elseif {$flag == "3EB"} {
-		$labcblk configure -state normal
-		$progorder configure -state normal
-		$labrate configure -state normal
-		$chksop configure -state normal
-		$chkeph configure -state normal
-		set VMEncoder::var(cblksize) "64,64,64"
-		set VMEncoder::var(tilesize) "512,512,512"
-	} else {
-		$labcblk configure -state disabled
-		$progorder configure -state disabled
-		$labrate configure -state disabled
-		$chksop configure -state disabled
-		$chkeph configure -state disabled
-	}
-}
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/logoLPI.gif b/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/logoLPI.gif
deleted file mode 100755
index df79515..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/jp3d/tcltk/logoLPI.gif and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/jpwl/CMakeLists.txt
deleted file mode 100755
index 13664d7..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/CMakeLists.txt
+++ /dev/null
@@ -1,107 +0,0 @@
-# Makefile for the main JPWL OpenJPEG codecs: JPWL_ j2k_to_image and JPWL_image_to_j2k
-
-add_definitions(-DUSE_JPWL)
-
-set(OPJ_SRCS
-../libopenjpeg/bio.c
-../libopenjpeg/cio.c
-../libopenjpeg/dwt.c
-../libopenjpeg/event.c
-../libopenjpeg/image.c
-../libopenjpeg/j2k.c
-../libopenjpeg/j2k_lib.c
-../libopenjpeg/jp2.c
-../libopenjpeg/jpt.c
-../libopenjpeg/mct.c
-../libopenjpeg/mqc.c
-../libopenjpeg/openjpeg.c
-../libopenjpeg/pi.c
-../libopenjpeg/raw.c
-../libopenjpeg/t1.c
-../libopenjpeg/t2.c
-../libopenjpeg/tcd.c
-../libopenjpeg/tgt.c
-)
-set(JPWL_SRCS crc.c jpwl.c jpwl_lib.c rs.c)
-
-set(common_SRCS "")
-# If not getopt was found then add it to the lib:
-if(DONT_HAVE_GETOPT)
-  set(common_SRCS ${OPENJPEG_SOURCE_DIR}/common/getopt.c)
-endif()
-
-# Build the library
-if(WIN32)
-  if(BUILD_SHARED_LIBS)
-    add_definitions(-DOPJ_EXPORTS)
-  else()
-    add_definitions(-DOPJ_STATIC)
-  endif()
-endif()
-add_library(${OPENJPEG_LIBRARY_NAME}_JPWL ${JPWL_SRCS} ${OPJ_SRCS})
-set_target_properties(${OPENJPEG_LIBRARY_NAME}_JPWL PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
-
-# Install library
-install(TARGETS ${OPENJPEG_LIBRARY_NAME}_JPWL
-  DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
-)
-
-# Build executables
-
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  ${OPENJPEG_SOURCE_DIR}/common
-  )
-
-if(LCMS_INCLUDE_DIR)
-  include_directories( ${LCMS_INCLUDE_DIR} )
-endif()
-if(PNG_FOUND)
-  include_directories(${PNG_INCLUDE_DIR})
-endif()
-if(TIFF_FOUND)
-  include_directories(${TIFF_INCLUDE_DIR})
-endif()
-
-
-add_executable(JPWL_j2k_to_image
-../codec/j2k_to_image.c
-../codec/convert.c
-../codec/index.c
-${OPENJPEG_SOURCE_DIR}/common/color.c
-${common_SRCS}
-)
-
-target_link_libraries(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL ${LCMS_LIB})
-if(PNG_FOUND)
-  target_link_libraries(JPWL_j2k_to_image ${PNG_LIBRARIES})
-endif()
-if(TIFF_FOUND)
-  target_link_libraries(JPWL_j2k_to_image ${TIFF_LIBRARIES})
-endif()
-if(UNIX)
-  target_link_libraries(JPWL_j2k_to_image m)
-endif()
-
-
-add_executable(JPWL_image_to_j2k
-../codec/convert.c
-../codec/index.c
-../codec/image_to_j2k.c
-${common_SRCS}
-)
-
-target_link_libraries(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL ${LCMS_LIB})
-if(PNG_FOUND)
-  target_link_libraries(JPWL_image_to_j2k ${PNG_LIBRARIES})
-endif()
-if(TIFF_FOUND)
-  target_link_libraries(JPWL_image_to_j2k ${TIFF_LIBRARIES})
-endif()
-if(UNIX)
-  target_link_libraries(JPWL_image_to_j2k m)
-endif()
-
-install(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image
-  DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Binaries
-)
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsp b/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsp
deleted file mode 100644
index dfc30d3..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsp
+++ /dev/null
@@ -1,127 +0,0 @@
-# Microsoft Developer Studio Project File - Name="JPWL_image_to_j2k" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=JPWL_image_to_j2k - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "JPWL_image_to_j2k.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "JPWL_image_to_j2k.mak" CFG="JPWL_image_to_j2k - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "JPWL_image_to_j2k - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "JPWL_image_to_j2k - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "JPWL_image_to_j2k - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /FR /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x80c /d "NDEBUG"
-# ADD RSC /l 0x80c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LibOpenJPEG_JPWL.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /libpath:"Release"
-
-!ELSEIF  "$(CFG)" == "JPWL_image_to_j2k - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /FR /FD /GZ /c
-# ADD BASE RSC /l 0x80c /d "_DEBUG"
-# ADD RSC /l 0x80c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LibOpenJPEG_JPWLd.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /pdbtype:sept /libpath:"Debug"
-
-!ENDIF 
-
-# Begin Target
-
-# Name "JPWL_image_to_j2k - Win32 Release"
-# Name "JPWL_image_to_j2k - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\codec\convert.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\compat\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\image_to_j2k.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\index.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\codec\convert.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\compat\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\index.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\openjpeg.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsw b/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsw
deleted file mode 100644
index 8487d5c..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_image_to_j2k.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "JPWL_image_to_j2k"=".\JPWL_image_to_j2k.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG_JPWL
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "LibOpenJPEG_JPWL"=".\LibOpenJPEG_JPWL.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsp b/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsp
deleted file mode 100644
index a64d80c..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsp
+++ /dev/null
@@ -1,135 +0,0 @@
-# Microsoft Developer Studio Project File - Name="JPWL_j2k_to_image" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=JPWL_j2k_to_image - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "JPWL_j2k_to_image.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "JPWL_j2k_to_image.mak" CFG="JPWL_j2k_to_image - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "JPWL_j2k_to_image - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "JPWL_j2k_to_image - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "JPWL_j2k_to_image - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x80c /d "NDEBUG"
-# ADD RSC /l 0x80c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "JPWL_j2k_to_image - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "JPWL_j2k_to_image___Win32_Debug"
-# PROP BASE Intermediate_Dir "JPWL_j2k_to_image___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x80c /d "_DEBUG"
-# ADD RSC /l 0x80c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /pdbtype:sept
-
-!ENDIF 
-
-# Begin Target
-
-# Name "JPWL_j2k_to_image - Win32 Release"
-# Name "JPWL_j2k_to_image - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\codec\convert.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\compat\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\index.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\j2k_to_image.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\codec\convert.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\crc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\compat\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\codec\index.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\jpwl.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rs.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsw b/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsw
deleted file mode 100644
index b964a6d..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/JPWL_j2k_to_image.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "JPWL_j2k_to_image"=".\JPWL_j2k_to_image.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG_JPWL
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "LibOpenJPEG_JPWL"=".\LibOpenJPEG_JPWL.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/LibOpenJPEG_JPWL.dsp b/Utilities/gdcmopenjpeg-v1/jpwl/LibOpenJPEG_JPWL.dsp
deleted file mode 100644
index d7bf793..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/LibOpenJPEG_JPWL.dsp
+++ /dev/null
@@ -1,282 +0,0 @@
-# Microsoft Developer Studio Project File - Name="LibOpenJPEG_JPWL" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=LibOpenJPEG_JPWL - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "LibOpenJPEG_JPWL.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "LibOpenJPEG_JPWL.mak" CFG="LibOpenJPEG_JPWL - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "LibOpenJPEG_JPWL - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "LibOpenJPEG_JPWL - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "LibOpenJPEG_JPWL - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "LibOpenJPEG_JPWL___Win32_Release"
-# PROP BASE Intermediate_Dir "LibOpenJPEG_JPWL___Win32_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x80c /d "NDEBUG"
-# ADD RSC /l 0x80c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF  "$(CFG)" == "LibOpenJPEG_JPWL - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "LibOpenJPEG_JPWL___Win32_Debug"
-# PROP BASE Intermediate_Dir "LibOpenJPEG_JPWL___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x80c /d "_DEBUG"
-# ADD RSC /l 0x80c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"Debug\LibOpenJPEG_JPWLd.lib"
-
-!ENDIF 
-
-# Begin Target
-
-# Name "LibOpenJPEG_JPWL - Win32 Release"
-# Name "LibOpenJPEG_JPWL - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\libopenjpeg\bio.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\cio.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\crc.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\dwt.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\event.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\image.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k_lib.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jp2.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jpt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\jpwl.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\jpwl_lib.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mct.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mqc.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\openjpeg.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\pi.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\raw.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\rs.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t1.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t2.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tcd.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tgt.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\libopenjpeg\bio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\cio.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\crc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\dwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\event.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\fix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\image.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\int.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k_lib.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jp2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jpt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\jpwl.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mct.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mqc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\openjpeg.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\opj_includes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\opj_malloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\pi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\raw.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t1.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tcd.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tgt.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/README.txt b/Utilities/gdcmopenjpeg-v1/jpwl/README.txt
deleted file mode 100644
index 66e9d5b..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/README.txt
+++ /dev/null
@@ -1,136 +0,0 @@
-===============================================================================
-	JPEG2000 Part 11 (ISO/IEC 15444-11 JPWL) Software
-
-
-
-		Version 20061213
-===============================================================================
-
-
-
-
-
-1. Scope
-=============
-
-This document describes the installation and use of the JPWL module in the framework of OpenJPEG library.
-
-This implementation has been developed from OpenJPEG implementation of JPEG2000 standard, and for this reason it is written in C language.
-
-If you find some bugs or if you have problems using the encoder/decoder, please send an e-mail to jpwl at diei.unipg.it
-
-
-2. Installing the code
-==========================
-
-The JPWL code is integrated with the standard OpenJPEG library and codecs: it is activated by setting the macro USE_JPWL to defined in the preprocessor configuration options of your preferred C compiler.
-
-2.1. Compiling the source code in Windows
--------------------------------------------
-
-The "jpwl" directory is already populated with a couple of Visual C++ 6.0 workspaces
-
- * JPWL_image_to_j2k.dsw - Creates the encoder with JPWL functionalities
- * JPWL_j2k_to_image.dsw - Creates the decoder with JPWL functionalities
-
-2.2. Compiling the source code in Unix-like systems
------------------------------------------------------
-
-Under linux, enter the jpwl directory and type "make clean" and "make".
-
-
-3. Running the JPWL software
-=========================
-
-The options available at the command line are exactly the same of the base OpenJPEG codecs. In addition, there is a "-W" switch that activates JPWL functionalities.
-
-3.1. JPWL Encoder
--------------------
-
--W           : adoption of JPWL (Part 11) capabilities (-W params)
-               The parameters can be written and repeated in any order:
-               [h<tile><=type>,s<tile><=method>,a=<addr>,z=<size>,g=<range>,...
-                ...,p<tile:pack><=type>]
-
-                 h selects the header error protection (EPB): 'type' can be
-                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
-                   if 'tile' is absent, it applies to main and tile headers
-                   if 'tile' is present, it applies from that tile
-                     onwards, up to the next h<tile> spec, or to the last tile
-                     in the codestream (max. 16 specs)
-
-                 p selects the packet error protection (EEP/UEP with EPBs)
-                  to be applied to raw data: 'type' can be
-                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
-                   if 'tile:pack' is absent, it starts from tile 0, packet 0
-                   if 'tile:pack' is present, it applies from that tile
-                     and that packet onwards, up to the next packet spec
-                     or to the last packet in the last tile in the codestream
-                     (max. 16 specs)
-
-                 s enables sensitivity data insertion (ESD): 'method' can be
-                   [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
-                    4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
-                   if 'tile' is absent, it applies to main header only
-                   if 'tile' is present, it applies from that tile
-                     onwards, up to the next s<tile> spec, or to the last tile
-                     in the codestream (max. 16 specs)
-
-                 g determines the addressing mode: <range> can be
-                   [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]
-
-                 a determines the size of data addressing: <addr> can be
-                   2/4 bytes (small/large codestreams). If not set, auto-mode
-
-                 z determines the size of sensitivity values: <size> can be
-                   1/2 bytes, for the transformed pseudo-floating point value
-
-                 ex.:
- h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,s0=6,s3=-1,a=0,g=1,z=1
-                 means
-                   predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,
-                   CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,
-                   UEP rs(78,32) for packets 0 to 23 of tile 0,
-                   UEP rs(56,32) for packets 24 to the last of tile 0,
-                   UEP rs default for packets of tile 1,
-                   no UEP for packets 0 to 19 of tile 3,
-                   UEP CRC-32 for packets 20 of tile 3 to last tile,
-                   relative sensitivity ESD for MH,
-                   TSE ESD from TPH 0 to TPH 2, byte range with automatic
-                   size of addresses and 1 byte for each sensitivity value
-
-                 ex.:
-                       h,s,p
-                 means
-                   default protection to headers (MH and TPHs) as well as
-                   data packets, one ESD in MH
-
-                 N.B.: use the following recommendations when specifying
-                       the JPWL parameters list
-                   - when you use UEP, always pair the 'p' option with 'h'
-
-3.2. JPWL Decoder
--------------------
-
-  -W <options>
-    Activates the JPWL correction capability, if the codestream complies.
-    Options can be a comma separated list of <param=val> tokens:
-    c, c=numcomps
-       numcomps is the number of expected components in the codestream
-       (search of first EPB rely upon this, default is 3)
-
-
-4. Known bugs and limitations
-===============================
-
-4.1. Bugs
------------
-
-* It is not possible to save a JPWL encoded codestream using the wrapped file format (i.e. JP2): only raw file format (i.e. J2K) is working
-
-4.2. Limitations
-------------------
-
-* When specifying an UEP protection, you need to activate even TPH protection for those tiles where there is a protection of the packets
-* RED insertion is not currently implemented at the decoder
-* JPWL at entropy coding level is not implemented
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/crc.c b/Utilities/gdcmopenjpeg-v1/jpwl/crc.c
deleted file mode 100644
index a54b657..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/crc.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-#include "crc.h"
-
-/**
- at file crc.c
- at brief Functions used to compute the 16- and 32-bit CRC of byte arrays
-
-*/
-
-/** file: CRC16.CPP
- *
- * CRC - Cyclic Redundancy Check (16-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned short),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC16 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- * 
- */
-const unsigned short CRC16_table[256] = {
-	0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 
-	0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 
-	0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 
-	0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
-	0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 
-	0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 
-	0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 
-	0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 
-	0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 
-	0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 
-	0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 
-	0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
-	0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 
-	0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 
-	0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 
-	0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 
-	0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 
-	0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
-	0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 
-	0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 
-	0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
-	0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 
-	0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 
-	0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 
-	0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 
-	0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 
-	0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 
-	0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 
-	0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 
-	0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 
-	0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 
-	0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-};
-
-void updateCRC16(unsigned short *crc, unsigned char data) {
-	*crc = CRC16_table[(*crc >> 8) & 0xFF] ^ (*crc << 8) ^ data;
-};
-
-
-/** file: CRC32.CPP
- *
- * CRC - Cyclic Redundancy Check (32-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned long),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC32 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- *
- */
-const unsigned long CRC32_table[256] = {
-	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
-	0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
-	0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
-	0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
-	0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
-	0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
-	0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
-	0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
-	0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
-	0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
-	0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
-	0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
-	0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
-	0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
-	0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
-	0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
-	0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
-	0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
-	0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
-	0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-	0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
-	0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
-	0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
-	0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
-	0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
-	0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
-	0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
-	0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
-	0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
-	0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
-	0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
-	0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
-	0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
-	0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
-	0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
-	0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
-	0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
-	0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
-	0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
-	0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-	0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
-	0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
-	0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-void updateCRC32(unsigned long *crc, unsigned char data) {
-	*crc = CRC32_table[(unsigned char) *crc ^ data] ^ ((*crc >> 8) & 0x00FFFFFF);
-};
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/crc.h b/Utilities/gdcmopenjpeg-v1/jpwl/crc.h
deleted file mode 100644
index 2d87168..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/crc.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-/**
- at file crc.h
- at brief Functions used to compute the 16- and 32-bit CRC of byte arrays
-
-*/
-
-#ifndef __CRC16_HEADER__
-#define __CRC16_HEADER__
-
-/** file: CRC16.HPP
- *
- * CRC - Cyclic Redundancy Check (16-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned short),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC16 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- * 
- */
-void updateCRC16(unsigned short *, unsigned char);
-
-#endif /* __CRC16_HEADER__ */
-
-
-#ifndef __CRC32_HEADER__
-#define __CRC32_HEADER__
-
-/** file: CRC32.HPP
- *
- * CRC - Cyclic Redundancy Check (32-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned short),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC32 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- *
- */
-void updateCRC32(unsigned long *, unsigned char);
-
-#endif /* __CRC32_HEADER__ */
-
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/jpwl.c b/Utilities/gdcmopenjpeg-v1/jpwl/jpwl.c
deleted file mode 100644
index 07ca796..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/jpwl.c
+++ /dev/null
@@ -1,1357 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "../libopenjpeg/opj_includes.h"
-
-#ifdef USE_JPWL
-
-/** @defgroup JPWL JPWL - JPEG-2000 Part11 (JPWL) codestream manager */
-/*@{*/
-
-/** @name Local static variables */
-/*@{*/
-
-/** number of JPWL prepared markers */
-static int jwmarker_num;
-/** properties of JPWL markers to insert */
-static jpwl_marker_t jwmarker[JPWL_MAX_NO_MARKERS]; 
-
-/*@}*/
-
-/*@}*/
-
-/** @name Local static functions */
-/*@{*/
-
-/** create an EPC marker segment
- at param j2k J2K compressor handle
- at param esd_on true if ESD is activated
- at param red_on true if RED is activated
- at param epb_on true if EPB is activated
- at param info_on true if informative techniques are activated
- at return returns the freshly created EPC
-*/
-jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, bool esd_on, bool red_on, bool epb_on, bool info_on);
-
-/*@}*/
-
-/** create an EPC marker segment
- at param j2k J2K compressor handle
- at param comps considered component (-1=average, 0/1/2/...=component no.)
- at param addrm addressing mode (0=packet, 1=byte range, 2=packet range, 3=reserved)
- at param ad_size size of addresses (2/4 bytes)
- at param senst sensitivity type
- at param se_size sensitivity values size (1/2 bytes)
- at param tileno tile where this ESD lies (-1 means MH)
- at param svalnum number of sensitivity values (if 0, they will be automatically filled)
- at param sensval pointer to an array of sensitivity values (if NULL, they will be automatically filled)
- at return returns the freshly created ESD
-*/
-jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comps, unsigned char addrm, unsigned char ad_size,
-								unsigned char senst, int se_size, int tileno,
-								unsigned long int svalnum, void *sensval);
-			
-/** this function is used to compare two JPWL markers based on
-their relevant wishlist position
- at param arg1 pointer to first marker
- at param arg2 pointer to second marker
- at return 1 if arg1>arg2, 0 if arg1=arg2, -1 if arg1<arg2
-*/
-int jpwl_markcomp(const void *arg1, const void *arg2);
-
-/** write an EPB MS to a buffer
- at param j2k J2K compressor handle
- at param epbmark pointer to the EPB MS
- at param buf pointer to the memory buffer
-*/
-void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf);
-
-/** write an EPC MS to a buffer
- at param j2k J2K compressor handle
- at param epcmark pointer to the EPC MS
- at param buf pointer to the memory buffer
-*/
-void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epcmark, unsigned char *buf);
-
-/** write an ESD MS to a buffer
- at param j2k J2K compressor handle
- at param esdmark pointer to the ESD MS
- at param buf pointer to the memory buffer
-*/
-void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
-
-/*-----------------------------------------------------------------*/
-
-void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
-
-	int mm;
-
-	/* let's reset some settings */
-
-	/* clear the existing markers */
-	for (mm = 0; mm < jwmarker_num; mm++) {
-
-		switch (jwmarker[mm].id) {
-
-		case J2K_MS_EPB:
-			opj_free(jwmarker[mm].m.epbmark);
-			break;
-
-		case J2K_MS_EPC:
-			opj_free(jwmarker[mm].m.epcmark);
-			break;
-
-		case J2K_MS_ESD:
-			opj_free(jwmarker[mm].m.esdmark);
-			break;
-
-		case J2K_MS_RED:
-			opj_free(jwmarker[mm].m.redmark);
-			break;
-
-		default:
-			break;
-		}
-	}
-
-	/* clear the marker structure array */
-	memset(jwmarker, 0, sizeof(jpwl_marker_t) * JPWL_MAX_NO_MARKERS);
-
-	/* no more markers in the list */
-	jwmarker_num = 0;
-
-	/* let's begin creating a marker list, according to user wishes */
-	jpwl_prepare_marks(j2k, cio, image);
-
-	/* now we dump the JPWL markers on the codestream */
-	jpwl_dump_marks(j2k, cio, image);
-
-	/* do not know exactly what is this for,
-	but it gets called during index creation */
-	j2k->pos_correction = 0;
-
-}
-
-void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
-
-	if (!cstr_info)
-		return;
-
-	/* expand the list? */
-	if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
-		cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
-		cstr_info->marker = opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
-	}
-
-	/* add the marker */
-	cstr_info->marker[cstr_info->marknum].type = type;
-	cstr_info->marker[cstr_info->marknum].pos = pos;
-	cstr_info->marker[cstr_info->marknum].len = len;
-	cstr_info->marknum++;
-
-}
-
-void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
-
-	unsigned short int socsiz_len = 0;
-	int ciopos = cio_tell(cio), soc_pos = j2k->cstr_info->main_head_start;
-	unsigned char *socp = NULL;
-
-	int tileno, acc_tpno, tpno, tilespec, hprot, sens, pprot, packspec, lastileno, packno;
-
-	jpwl_epb_ms_t *epb_mark;
-	jpwl_epc_ms_t *epc_mark;
-	jpwl_esd_ms_t *esd_mark;
-
-	/* find (SOC + SIZ) length */
-	/* I assume SIZ is always the first marker after SOC */
-	cio_seek(cio, soc_pos + 4);
-	socsiz_len = (unsigned short int) cio_read(cio, 2) + 4; /* add the 2 marks length itself */
-	cio_seek(cio, soc_pos + 0);
-	socp = cio_getbp(cio); /* pointer to SOC */
-
-	/* 
-	 EPC MS for Main Header: if we are here it's required
-	*/
-	/* create the EPC */
-	if ((epc_mark = jpwl_epc_create(
-			j2k,
-			j2k->cp->esd_on, /* is ESD present? */
-			j2k->cp->red_on, /* is RED present? */
-			j2k->cp->epb_on, /* is EPB present? */
-			false /* are informative techniques present? */
-		))) {
-
-		/* Add this marker to the 'insertanda' list */
-		if (epc_mark) {
-			jwmarker[jwmarker_num].id = J2K_MS_EPC; /* its type */
-			jwmarker[jwmarker_num].m.epcmark = epc_mark; /* the EPC */
-			jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
-			jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.1; /* not so first */
-			jwmarker[jwmarker_num].len = epc_mark->Lepc; /* its length */
-			jwmarker[jwmarker_num].len_ready = true; /* ready */
-			jwmarker[jwmarker_num].pos_ready = true; /* ready */
-			jwmarker[jwmarker_num].parms_ready = false; /* not ready */
-			jwmarker[jwmarker_num].data_ready = true; /* ready */
-			jwmarker_num++;
-		};
-
-		opj_event_msg(j2k->cinfo, EVT_INFO,
-			"MH  EPC : setting %s%s%s\n",
-			j2k->cp->esd_on ? "ESD, " : "",
-			j2k->cp->red_on ? "RED, " : "",
-			j2k->cp->epb_on ? "EPB, " : ""
-			);
-
-	} else {
-		/* ooops, problems */
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create MH EPC\n");				
-	};
-
-	/* 
-	 ESD MS for Main Header
-	*/
-	/* first of all, must MH have an ESD MS? */
-	if (j2k->cp->esd_on && (j2k->cp->sens_MH >= 0)) {
-
-		/* Create the ESD */
-		if ((esd_mark = jpwl_esd_create(
-			j2k, /* this encoder handle */
-			-1, /* we are averaging over all components */
-			(unsigned char) j2k->cp->sens_range, /* range method */
-			(unsigned char) j2k->cp->sens_addr, /* sensitivity addressing */
-			(unsigned char) j2k->cp->sens_MH, /* sensitivity method */
-			j2k->cp->sens_size, /* sensitivity size */
-			-1, /* this ESD is in main header */
-			0 /*j2k->cstr_info->num*/, /* number of packets in codestream */
-			NULL /*sensval*/ /* pointer to sensitivity data of packets */
-			))) {
-			
-			/* Add this marker to the 'insertanda' list */
-			if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-				jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
-				jwmarker[jwmarker_num].m.esdmark = esd_mark; /* the EPB */
-				jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* we choose to place it after SIZ */
-				jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
-				jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
-				jwmarker[jwmarker_num].len_ready = true; /* not ready, yet */
-				jwmarker[jwmarker_num].pos_ready = true; /* ready */
-				jwmarker[jwmarker_num].parms_ready = true; /* not ready */
-				jwmarker[jwmarker_num].data_ready = false; /* not ready */
-				jwmarker_num++;
-			}
-
-			opj_event_msg(j2k->cinfo, EVT_INFO,
-				"MH  ESDs: method %d\n",
-				j2k->cp->sens_MH
-				);
-
-		} else {
-			/* ooops, problems */
-			opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create MH ESD\n");				
-		};
-
-	}
-
-	/* 
-	 ESD MSs for Tile Part Headers 
-	*/
-	/* cycle through tiles */
-	sens = -1; /* default spec: no ESD */
-	tilespec = 0; /* first tile spec */
-	acc_tpno = 0;
-	for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
-
-		opj_event_msg(j2k->cinfo, EVT_INFO,
-			"Tile %d has %d tile part(s)\n",
-			tileno, j2k->cstr_info->tile[tileno].num_tps
-			);
-
-		/* for every tile part in the tile */
-		for (tpno = 0; tpno < j2k->cstr_info->tile[tileno].num_tps; tpno++, acc_tpno++) {
-	
-			int sot_len, Psot, Psotp, mm;
-			unsigned long sot_pos, post_sod_pos;
-
-			unsigned long int left_THmarks_len;
-
-			/******* sot_pos = j2k->cstr_info->tile[tileno].start_pos; */
-			sot_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos;
-			cio_seek(cio, sot_pos + 2); 
-			sot_len = cio_read(cio, 2); /* SOT Len */
-			cio_skip(cio, 2);
-			Psotp = cio_tell(cio);
-			Psot = cio_read(cio, 4); /* tile length */
-
-			/******* post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1; */
-			post_sod_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_end_header + 1;
-			left_THmarks_len = post_sod_pos - sot_pos;
-
-			/* add all the lengths of the markers which are len-ready and stay within SOT and SOD */
-			for (mm = 0; mm < jwmarker_num; mm++) {
-				if ((jwmarker[mm].pos >= sot_pos) && (jwmarker[mm].pos < post_sod_pos)) {
-					if (jwmarker[mm].len_ready)
-						left_THmarks_len += jwmarker[mm].len + 2;
-					else {
-						opj_event_msg(j2k->cinfo, EVT_ERROR, "MS %x in %f is not len-ready: could not set up TH EPB\n",
-							jwmarker[mm].id, jwmarker[mm].dpos);				
-						exit(1);
-					}
-				}
-			}
-
-			/******* if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->sens_TPH_tileno[tilespec] == tileno)) */
-			if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->sens_TPH_tileno[tilespec] == acc_tpno))
-				/* we got a specification from this tile onwards */
-				sens = j2k->cp->sens_TPH[tilespec++];
-		
-			/* must this TPH have an ESD MS? */
-			if (j2k->cp->esd_on && (sens >= 0)) {
-
-				/* Create the ESD */
-				if ((esd_mark = jpwl_esd_create(
-					j2k, /* this encoder handle */
-					-1, /* we are averaging over all components */
-					(unsigned char) j2k->cp->sens_range, /* range method */
-					(unsigned char) j2k->cp->sens_addr, /* sensitivity addressing size */
-					(unsigned char) sens, /* sensitivity method */
-					j2k->cp->sens_size, /* sensitivity value size */
-					tileno, /* this ESD is in a tile */
-					0, /* number of packets in codestream */
-					NULL /* pointer to sensitivity data of packets */
-					))) {
-					
-					/* Add this marker to the 'insertanda' list */
-					if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-						jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
-						jwmarker[jwmarker_num].m.esdmark = esd_mark; /* the EPB */
-						/****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
-						jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
-						jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
-						jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
-						jwmarker[jwmarker_num].len_ready = true; /* ready, yet */
-						jwmarker[jwmarker_num].pos_ready = true; /* ready */
-						jwmarker[jwmarker_num].parms_ready = true; /* not ready */
-						jwmarker[jwmarker_num].data_ready = false; /* ready */
-						jwmarker_num++;
-					}
-
-					/* update Psot of the tile  */
-					cio_seek(cio, Psotp);
-					cio_write(cio, Psot + esd_mark->Lesd + 2, 4);
-
-					opj_event_msg(j2k->cinfo, EVT_INFO,
-						/******* "TPH ESDs: tile %02d, method %d\n", */
-						"TPH ESDs: tile %02d, part %02d, method %d\n",
-						/******* tileno, */
-						tileno, tpno,
-						sens
-						);
-
-				} else {
-					/* ooops, problems */
-					/***** opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH ESD #%d\n", tileno); */
-					opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH ESD #%d,%d\n", tileno, tpno);
-				};
-
-			}
-			
-		}
-	
-	};
-
-	/* 
-	 EPB MS for Main Header
-	*/
-	/* first of all, must MH have an EPB MS? */
-	if (j2k->cp->epb_on && (j2k->cp->hprot_MH > 0)) {
-
-		int mm;
-
-		/* position of SOT */
-		unsigned int sot_pos = j2k->cstr_info->main_head_end + 1;
-
-		/* how much space is there between end of SIZ and beginning of SOT? */
-		int left_MHmarks_len = sot_pos - socsiz_len;
-
-		/* add all the lengths of the markers which are len-ready and stay within SOC and SOT */
-		for (mm = 0; mm < jwmarker_num; mm++) {
-			if ((jwmarker[mm].pos >=0) && (jwmarker[mm].pos < sot_pos)) {
-				if (jwmarker[mm].len_ready)
-					left_MHmarks_len += jwmarker[mm].len + 2;
-				else {
-					opj_event_msg(j2k->cinfo, EVT_ERROR, "MS %x in %f is not len-ready: could not set up MH EPB\n",
-						jwmarker[mm].id, jwmarker[mm].dpos);				
-					exit(1);
-				}
-			}
-		}
-
-		/* Create the EPB */
-		if ((epb_mark = jpwl_epb_create(
-			j2k, /* this encoder handle */
-			true, /* is it the latest? */
-			true, /* is it packed? not for now */
-			-1, /* we are in main header */
-			0, /* its index is 0 (first) */
-			j2k->cp->hprot_MH, /* protection type parameters of data */
-			socsiz_len, /* pre-data: only SOC+SIZ */
-			left_MHmarks_len /* post-data: from SOC to SOT, and all JPWL markers within */
-			))) {
-			
-			/* Add this marker to the 'insertanda' list */
-			if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-				jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
-				jwmarker[jwmarker_num].m.epbmark = epb_mark; /* the EPB */
-				jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
-				jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
-				jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
-				jwmarker[jwmarker_num].len_ready = true; /* ready */
-				jwmarker[jwmarker_num].pos_ready = true; /* ready */
-				jwmarker[jwmarker_num].parms_ready = true; /* ready */
-				jwmarker[jwmarker_num].data_ready = false; /* not ready */
-				jwmarker_num++;
-			}
-
-			opj_event_msg(j2k->cinfo, EVT_INFO,
-				"MH  EPB : prot. %d\n",
-				j2k->cp->hprot_MH
-				);
-
-		} else {
-			/* ooops, problems */
-			opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create MH EPB\n");				
-		};
-	}
-
-	/* 
-	 EPB MSs for Tile Parts
-	*/
-	/* cycle through TPHs */
-	hprot = j2k->cp->hprot_MH; /* default spec */
-	tilespec = 0; /* first tile spec */
-	lastileno = 0;
-	packspec = 0;
-	pprot = -1;
-	acc_tpno = 0;
-	for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
-
-		opj_event_msg(j2k->cinfo, EVT_INFO,
-			"Tile %d has %d tile part(s)\n",
-			tileno, j2k->cstr_info->tile[tileno].num_tps
-			);
-
-		/* for every tile part in the tile */
-		for (tpno = 0; tpno < j2k->cstr_info->tile[tileno].num_tps; tpno++, acc_tpno++) { 
-		
-			int sot_len, Psot, Psotp, mm, epb_index = 0, prot_len = 0;
-			unsigned long sot_pos, post_sod_pos;
-			unsigned long int left_THmarks_len/*, epbs_len = 0*/;
-			int startpack = 0, stoppack = j2k->cstr_info->packno;
-			int first_tp_pack, last_tp_pack;
-			jpwl_epb_ms_t *tph_epb = NULL;
-
-			/****** sot_pos = j2k->cstr_info->tile[tileno].start_pos; */
-			sot_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos;
-			cio_seek(cio, sot_pos + 2); 
-			sot_len = cio_read(cio, 2); /* SOT Len */
-			cio_skip(cio, 2);
-			Psotp = cio_tell(cio);
-			Psot = cio_read(cio, 4); /* tile length */
-
-			/* a-priori length of the data dwelling between SOT and SOD */
-			/****** post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1; */
-			post_sod_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_end_header + 1;
-			left_THmarks_len = post_sod_pos - (sot_pos + sot_len + 2);
-
-			/* add all the lengths of the JPWL markers which are len-ready and stay within SOT and SOD */
-			for (mm = 0; mm < jwmarker_num; mm++) {
-				if ((jwmarker[mm].pos >= sot_pos) && (jwmarker[mm].pos < post_sod_pos)) {
-					if (jwmarker[mm].len_ready)
-						left_THmarks_len += jwmarker[mm].len + 2;
-					else {
-						opj_event_msg(j2k->cinfo, EVT_ERROR, "MS %x in %f is not len-ready: could not set up TH EPB\n",
-							jwmarker[mm].id, jwmarker[mm].dpos);				
-						exit(1);
-					}
-				}
-			}
-
-			/****** if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->hprot_TPH_tileno[tilespec] == tileno)) */
-			if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->hprot_TPH_tileno[tilespec] == acc_tpno))
-				/* we got a specification from this tile part onwards */
-				hprot = j2k->cp->hprot_TPH[tilespec++];
-		
-			/* must this TPH have an EPB MS? */
-			if (j2k->cp->epb_on && (hprot > 0)) {
-
-				/* Create the EPB */
-				if ((epb_mark = jpwl_epb_create(
-					j2k, /* this encoder handle */
-					false, /* is it the latest? in TPH, no for now (if huge data size in TPH, we'd need more) */
-					true, /* is it packed? yes for now */
-					tileno, /* we are in TPH */
-					epb_index++, /* its index is 0 (first) */
-					hprot, /* protection type parameters of following data */
-					sot_len + 2, /* pre-data length: only SOT */
-					left_THmarks_len /* post-data length: from SOT end to SOD inclusive */
-					))) {
-					
-					/* Add this marker to the 'insertanda' list */
-					if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-						jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
-						jwmarker[jwmarker_num].m.epbmark = epb_mark; /* the EPB */
-						/****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
-						jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
-						jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
-						jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
-						jwmarker[jwmarker_num].len_ready = true; /* ready */
-						jwmarker[jwmarker_num].pos_ready = true; /* ready */
-						jwmarker[jwmarker_num].parms_ready = true; /* ready */
-						jwmarker[jwmarker_num].data_ready = false; /* not ready */
-						jwmarker_num++;
-					}
-
-					/* update Psot of the tile  */
-					Psot += epb_mark->Lepb + 2;
-
-					opj_event_msg(j2k->cinfo, EVT_INFO,
-						/***** "TPH EPB : tile %02d, prot. %d\n", */
-						"TPH EPB : tile %02d, part %02d, prot. %d\n",
-						/***** tileno, */
-						tileno, tpno,
-						hprot
-						);
-
-					/* save this TPH EPB address */
-					tph_epb = epb_mark;
-
-				} else {
-					/* ooops, problems */
-					/****** opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB #%d\n", tileno);	*/
-					opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB in #%d,d\n", tileno, tpno);
-				};
-
-			}				
-		
-			startpack = 0;
-			/* EPB MSs for UEP packet data protection in Tile Parts */
-			/****** for (packno = 0; packno < j2k->cstr_info->num; packno++) { */
-			/*first_tp_pack = (tpno > 0) ? (first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno - 1].tp_numpacks) : 0;*/
-			first_tp_pack = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pack;
-			last_tp_pack = first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks - 1;
-			for (packno = 0; packno < j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks; packno++) {
-
-				/******** if ((packspec < JPWL_MAX_NO_PACKSPECS) &&
-					(j2k->cp->pprot_tileno[packspec] == tileno) && (j2k->cp->pprot_packno[packspec] == packno)) { */
-				if ((packspec < JPWL_MAX_NO_PACKSPECS) &&
-					(j2k->cp->pprot_tileno[packspec] == acc_tpno) && (j2k->cp->pprot_packno[packspec] == packno)) {
-
-					/* we got a specification from this tile and packet onwards */
-					/* print the previous spec */
-					if (packno > 0) {
-						stoppack = packno - 1;				
-						opj_event_msg(j2k->cinfo, EVT_INFO,
-							/***** "UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n", */
-							"UEP EPBs: tile %02d, part %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
-							/***** tileno, */
-							tileno, tpno,
-							startpack,
-							stoppack,
-							/***** j2k->cstr_info->tile[tileno].packet[startpack].start_pos, */
-							j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos,
-							/***** j2k->cstr_info->tile[tileno].packet[stoppack].end_pos, */
-							j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos,
-							pprot);
-
-						/***** prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
-							j2k->cstr_info->tile[tileno].packet[startpack].start_pos; */
-						prot_len = j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos + 1 -
-							j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos;
-
-						/*
-						  particular case: if this is the last header and the last packet,
-						  then it is better to protect even the EOC marker
-						*/
-						/****** if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-							(stoppack == (j2k->cstr_info->num - 1))) */
-						if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-							(tpno == (j2k->cstr_info->tile[tileno].num_tps - 1)) &&
-							(stoppack == last_tp_pack))
-							/* add the EOC len */
-							prot_len += 2;
-
-						/* let's add the EPBs */
-						Psot += jpwl_epbs_add(
-							j2k, /* J2K handle */
-							jwmarker, /* pointer to JPWL markers list */
-							&jwmarker_num, /* pointer to the number of current markers */
-							false, /* latest */
-							true, /* packed */
-							false, /* inside MH */
-							&epb_index, /* pointer to EPB index */
-							pprot, /* protection type */
-							/****** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, */ /* position */
-							(double) (j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2) + 0.0001, /* position */
-							tileno, /* number of tile */
-							0, /* length of pre-data */
-							prot_len /*4000*/ /* length of post-data */
-							);
-					}
-
-					startpack = packno;
-					pprot = j2k->cp->pprot[packspec++];
-				}
-
-				//printf("Tile %02d, pack %02d ==> %d\n", tileno, packno, pprot);
-		
-			}
-
-			/* we are at the end: print the remaining spec */
-			stoppack = packno - 1;
-			if (pprot >= 0) {
-
-				opj_event_msg(j2k->cinfo, EVT_INFO,
-					/**** "UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n", */
-					"UEP EPBs: tile %02d, part %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
-					/**** tileno, */
-					tileno, tpno,
-					startpack,
-					stoppack,
-					/***** j2k->image_info->tile[tileno].packet[startpack].start_pos,
-					j2k->image_info->tile[tileno].packet[stoppack].end_pos, */
-					j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos,
-					j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos,
-					pprot);
-
-				/***** prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
-					j2k->cstr_info->tile[tileno].packet[startpack].start_pos; */
-				prot_len = j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos + 1 -
-					j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos;
-
-				/*
-				  particular case: if this is the last header and the last packet,
-				  then it is better to protect even the EOC marker
-				*/
-				/***** if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-					(stoppack == (j2k->cstr_info->num - 1))) */
-				if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-					(tpno == (j2k->cstr_info->tile[tileno].num_tps - 1)) &&
-					(stoppack == last_tp_pack))
-					/* add the EOC len */
-					prot_len += 2;
-
-				/* let's add the EPBs */
-				Psot += jpwl_epbs_add(
-							j2k, /* J2K handle */
-							jwmarker, /* pointer to JPWL markers list */
-							&jwmarker_num, /* pointer to the number of current markers */
-							true, /* latest */
-							true, /* packed */
-							false, /* inside MH */
-							&epb_index, /* pointer to EPB index */
-							pprot, /* protection type */
-							/***** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001,*/ /* position */
-							(double) (j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2) + 0.0001, /* position */
-							tileno, /* number of tile */
-							0, /* length of pre-data */
-							prot_len /*4000*/ /* length of post-data */
-							);
-			}
-
-			/* we can now check if the TPH EPB was really the last one */
-			if (tph_epb && (epb_index == 1)) {
-				/* set the TPH EPB to be the last one in current header */
-				tph_epb->Depb |= (unsigned char) ((true & 0x0001) << 6);
-				tph_epb = NULL;
-			}
-
-			/* write back Psot */
-			cio_seek(cio, Psotp);
-			cio_write(cio, Psot, 4);
-		
-		}
-
-	};
-
-	/* reset the position */
-	cio_seek(cio, ciopos);
-
-}
-
-void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
-
-	int mm;
-	unsigned long int old_size = j2k->cstr_info->codestream_size;
-	unsigned long int new_size = old_size;
-	int /*ciopos = cio_tell(cio),*/ soc_pos = j2k->cstr_info->main_head_start;
-	unsigned char *jpwl_buf, *orig_buf;
-	unsigned long int orig_pos;
-	double epbcoding_time = 0.0, esdcoding_time = 0.0;
-
-	/* Order JPWL markers according to their wishlist position */
-	qsort((void *) jwmarker, (size_t) jwmarker_num, sizeof (jpwl_marker_t), jpwl_markcomp);
-
-	/* compute markers total size */ 
-	for (mm = 0; mm < jwmarker_num; mm++) {
-		/*printf("%x, %d, %.10f, %d long\n", jwmarker[mm].id, jwmarker[mm].pos,
-			jwmarker[mm].dpos, jwmarker[mm].len);*/
-		new_size += jwmarker[mm].len + 2;
-	}
-
-	/* allocate a new buffer of proper size */
-	if (!(jpwl_buf = (unsigned char *) opj_malloc((size_t) (new_size + soc_pos) * sizeof(unsigned char)))) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for JPWL codestream buffer\n");
-		exit(1);
-	};
-
-	/* copy the jp2 part, if any */
-	orig_buf = jpwl_buf;
-	memcpy(jpwl_buf, cio->buffer, soc_pos);
-	jpwl_buf += soc_pos;
-
-	/* cycle through markers */
-	orig_pos = soc_pos + 0; /* start from the beginning */
-	cio_seek(cio, soc_pos + 0); /* rewind the original */
-	for (mm = 0; mm < jwmarker_num; mm++) {
-
-		/*
-		need to copy a piece of the original codestream
-		if there is such
-		*/
-		memcpy(jpwl_buf, cio_getbp(cio), jwmarker[mm].pos - orig_pos);
-		jpwl_buf += jwmarker[mm].pos - orig_pos;
-		orig_pos = jwmarker[mm].pos;
-		cio_seek(cio, orig_pos);
-
-		/*
-		then write down the marker
-		*/
-		switch (jwmarker[mm].id) {
-
-		case J2K_MS_EPB:
-			jpwl_epb_write(j2k, jwmarker[mm].m.epbmark, jpwl_buf);
-			break;
-
-		case J2K_MS_EPC:
-			jpwl_epc_write(j2k, jwmarker[mm].m.epcmark, jpwl_buf);
-			break;
-
-		case J2K_MS_ESD:
-			jpwl_esd_write(j2k, jwmarker[mm].m.esdmark, jpwl_buf);
-			break;
-
-		case J2K_MS_RED:
-			memset(jpwl_buf, 0, jwmarker[mm].len + 2); /* placeholder */
-			break;
-
-		default:
-			break;
-		};
-
-		/* we update the markers struct */
-		if (j2k->cstr_info)
-			j2k->cstr_info->marker[j2k->cstr_info->marknum - 1].pos = (jpwl_buf - orig_buf);
-		
-		/* we set the marker dpos to the new position in the JPWL codestream */
-		jwmarker[mm].dpos = (double) (jpwl_buf - orig_buf);
-
-		/* advance JPWL buffer position */
-		jpwl_buf += jwmarker[mm].len + 2;
-
-	}
-
-	/* finish remaining original codestream */
-	memcpy(jpwl_buf, cio_getbp(cio), old_size - (orig_pos - soc_pos));
-	jpwl_buf += old_size - (orig_pos - soc_pos);
-	cio_seek(cio, soc_pos + old_size);
-	
-	/*
-	update info file based on added markers
-	*/
-	if (!jpwl_update_info(j2k, jwmarker, jwmarker_num))
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not update OPJ cstr_info structure\n");
-
-	/* now we need to repass some markers and fill their data fields */
-	
-	/* first of all, DL and Pcrc in EPCs */ 
-	for (mm = 0; mm < jwmarker_num; mm++) {
-
-		/* find the EPCs */
-		if (jwmarker[mm].id == J2K_MS_EPC) {
-
-			int epc_pos = (int) jwmarker[mm].dpos, pp;
-			unsigned short int mycrc = 0x0000;
-
-			/* fix and fill the DL field */
-			jwmarker[mm].m.epcmark->DL = new_size;
-			orig_buf[epc_pos + 6] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 24);
-			orig_buf[epc_pos + 7] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 16);
-			orig_buf[epc_pos + 8] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 8);
-			orig_buf[epc_pos + 9] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 0);
-
-			/* compute the CRC field (excluding itself) */
-			for (pp = 0; pp < 4; pp++)
-				jpwl_updateCRC16(&mycrc, orig_buf[epc_pos + pp]);
-			for (pp = 6; pp < (jwmarker[mm].len + 2); pp++)
-				jpwl_updateCRC16(&mycrc, orig_buf[epc_pos + pp]);
-
-			/* fix and fill the CRC */
-			jwmarker[mm].m.epcmark->Pcrc = mycrc;
-			orig_buf[epc_pos + 4] = (unsigned char) (jwmarker[mm].m.epcmark->Pcrc >> 8);
-			orig_buf[epc_pos + 5] = (unsigned char) (jwmarker[mm].m.epcmark->Pcrc >> 0);
-
-		}
-	}
-
-	/* then, sensitivity data in ESDs */ 
-	esdcoding_time = opj_clock();
-	for (mm = 0; mm < jwmarker_num; mm++) {
-
-		/* find the ESDs */
-		if (jwmarker[mm].id == J2K_MS_ESD) {
-
-			/* remember that they are now in a new position (dpos) */
-			int esd_pos = (int) jwmarker[mm].dpos;
-
-			jpwl_esd_fill(j2k, jwmarker[mm].m.esdmark, &orig_buf[esd_pos]);
-		
-		}
-
-	}
-	esdcoding_time = opj_clock() - esdcoding_time;
-	if (j2k->cp->esd_on)
-		opj_event_msg(j2k->cinfo, EVT_INFO, "ESDs sensitivities computed in %f s\n", esdcoding_time);
-
-	/* finally, RS or CRC parity in EPBs */ 
-	epbcoding_time = opj_clock();
-	for (mm = 0; mm < jwmarker_num; mm++) {
-
-		/* find the EPBs */
-		if (jwmarker[mm].id == J2K_MS_EPB) {
-
-			/* remember that they are now in a new position (dpos) */
-			int nn, accum_len;
-
-			/* let's see how many EPBs are following this one, included itself */
-			/* for this to work, we suppose that the markers are correctly ordered */
-			/* and, overall, that they are in packed mode inside headers */
-			accum_len = 0;
-			for (nn = mm; (nn < jwmarker_num) && (jwmarker[nn].id == J2K_MS_EPB) &&
-				(jwmarker[nn].pos == jwmarker[mm].pos); nn++)
-				accum_len += jwmarker[nn].m.epbmark->Lepb + 2;
-
-			/* fill the current (first) EPB with post-data starting from the computed position */
-			jpwl_epb_fill(j2k, jwmarker[mm].m.epbmark, &orig_buf[(int) jwmarker[mm].dpos],
-				&orig_buf[(int) jwmarker[mm].dpos + accum_len]);
-		
-			/* fill the remaining EPBs in the header with post-data starting from the last position */
-			for (nn = mm + 1; (nn < jwmarker_num) && (jwmarker[nn].id == J2K_MS_EPB) &&
-				(jwmarker[nn].pos == jwmarker[mm].pos); nn++)
-				jpwl_epb_fill(j2k, jwmarker[nn].m.epbmark, &orig_buf[(int) jwmarker[nn].dpos], NULL);
-
-			/* skip all the processed EPBs */
-			mm = nn - 1;
-		}
-
-	}
-	epbcoding_time = opj_clock() - epbcoding_time;
-	if (j2k->cp->epb_on)
-		opj_event_msg(j2k->cinfo, EVT_INFO, "EPBs redundancy computed in %f s\n", epbcoding_time);
-
-	/* free original cio buffer and set it to the JPWL one */
-	opj_free(cio->buffer);
-	cio->cinfo = cio->cinfo; /* no change */
-	cio->openmode = cio->openmode; /* no change */
-	cio->buffer = orig_buf;
-	cio->length = new_size + soc_pos;
-	cio->start = cio->buffer;
-	cio->end = cio->buffer + cio->length;
-	cio->bp = cio->buffer;
-	cio_seek(cio, soc_pos + new_size);
-
-}
-
-
-void j2k_read_epc(opj_j2k_t *j2k) {
-	unsigned long int DL, Lepcp, Pcrcp, l;
-	unsigned short int Lepc, Pcrc = 0x0000;
-	unsigned char Pepc;	
-	opj_cio_t *cio = j2k->cio;
-	char *ans1;
-
-	/* Simply read the EPC parameters */
-	Lepcp = cio_tell(cio);
-	Lepc = cio_read(cio, 2);
-	Pcrcp = cio_tell(cio);
-	cio_skip(cio, 2); /* Pcrc */
-	DL = cio_read(cio, 4);
-	Pepc = cio_read(cio, 1);
-
-	/* compute Pcrc */
-	cio_seek(cio, Lepcp - 2);
-
-		/* Marker */
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-
-		/* Length */
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-
-		/* skip Pcrc */
-		cio_skip(cio, 2);
-
-		/* read all remaining */
-		for (l = 4; l < Lepc; l++)
-			jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-
-		/* check Pcrc with the result */
-		cio_seek(cio, Pcrcp);
-		ans1 = (Pcrc == (unsigned short int) cio_read(cio, 2)) ? "crc-ok" : "crc-ko";
-
-	/* now we write them to screen */
-	opj_event_msg(j2k->cinfo, EVT_INFO, 
-		"EPC(%u,%d): %s, DL=%d%s %s %s\n",
-		Lepcp - 2,
-		Lepc,
-		ans1,
-		DL, /* data length this EPC is referring to */
-		(Pepc & 0x10) ? ", esd" : "", /* ESD is present */
-		(Pepc & 0x20) ? ", red" : "", /* RED is present */
-		(Pepc & 0x40) ? ", epb" : ""); /* EPB is present */
-
-	cio_seek(cio, Lepcp + Lepc);  
-}
-
-void j2k_write_epc(opj_j2k_t *j2k) {
-
-	unsigned long int DL, Lepcp, Pcrcp, l;
-	unsigned short int Lepc, Pcrc;
-	unsigned char Pepc;	
-
-	opj_cio_t *cio = j2k->cio;
-
-	cio_write(cio, J2K_MS_EPC, 2);	/* EPC */
-	Lepcp = cio_tell(cio);
-	cio_skip(cio, 2);
-
-	/* CRC-16 word of the EPC */
-	Pcrc = 0x0000; /* initialize */
-	Pcrcp = cio_tell(cio);
-	cio_write(cio, Pcrc, 2); /* Pcrc placeholder*/
-
-	/* data length of the EPC protection domain */
-	DL = 0x00000000; /* we leave this set to 0, as if the information is not available */
-	cio_write(cio, DL, 4);   /* DL */
-
-	/* jpwl capabilities */
-	Pepc = 0x00;
-	cio_write(cio, Pepc, 1); /* Pepc */
-
-	/* ID section */
-	/* no ID's, as of now */
-
-	Lepc = (unsigned short) (cio_tell(cio) - Lepcp);
-	cio_seek(cio, Lepcp);
-	cio_write(cio, Lepc, 2); /* Lepc */
-
-	/* compute Pcrc */
-	cio_seek(cio, Lepcp - 2);
-
-		/* Marker */
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-
-		/* Length */
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-		jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-
-		/* skip Pcrc */
-		cio_skip(cio, 2);
-
-		/* read all remaining */
-		for (l = 4; l < Lepc; l++)
-			jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1)); 
-
-		/* fill Pcrc with the result */
-		cio_seek(cio, Pcrcp);
-		cio_write(cio, Pcrc, 2);
-
-	cio_seek(cio, Lepcp + Lepc);
-
-	/* marker struct update */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, Lepcp - 2, Lepc + 2);
-
-}
-
-void j2k_read_epb(opj_j2k_t *j2k) {
-	unsigned long int LDPepb, Pepb;
-	unsigned short int Lepb;
-	unsigned char Depb;
-	char str1[25] = "";
-	bool status;
-	static bool first_in_tph = true;
-	int type, pre_len, post_len;
-	static unsigned char *redund = NULL;
-	
-	opj_cio_t *cio = j2k->cio;
-
-	/* B/W = 45, RGB = 51 */
-	/*           SIZ   SIZ_FIELDS     SIZ_COMPS               FOLLOWING_MARKER */
-	int skipnum = 2  +     38     + 3 * j2k->cp->exp_comps  +         2;
-
-	if (j2k->cp->correct) {
-
-		/* go back to EPB marker value */
-		cio_seek(cio, cio_tell(cio) - 2);
-
-		/* we need to understand where we are */
-		if (j2k->state == J2K_STATE_MH) {
-			/* we are in MH */
-			type = 0; /* MH */
-			pre_len = skipnum; /* SOC+SIZ */
-			post_len = -1; /* auto */
-
-		} else if ((j2k->state == J2K_STATE_TPH) && first_in_tph) {
-			/* we are in TPH */
-			type = 1; /* TPH */
-			pre_len = 12; /* SOC+SIZ */
-			first_in_tph = false;
-			post_len = -1; /* auto */
-
-		} else {
-			/* we are elsewhere */
-			type = 2; /* other */
-			pre_len = 0; /* nada */
-			post_len = -1; /* auto */
-
-		}
-
-		/* call EPB corrector */
-		/*printf("before %x, ", redund);*/
-		status = jpwl_epb_correct(j2k,      /* J2K decompressor handle */
-								  cio->bp,  /* pointer to EPB in codestream buffer */
-								  type,     /* EPB type: MH */
-								  pre_len,  /* length of pre-data */
-								  post_len, /* length of post-data: -1 means auto */
-								  NULL,     /* do everything auto */
-								  &redund
-								 );
-		/*printf("after %x\n", redund);*/
-
-		/* Read the (possibly corrected) EPB parameters */
-		cio_skip(cio, 2);
-		Lepb = cio_read(cio, 2);
-		Depb = cio_read(cio, 1);
-		LDPepb = cio_read(cio, 4);
-		Pepb = cio_read(cio, 4);
-
-		if (!status) {
-
-			opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL correction could not be performed\n");
-
-			/* advance to EPB endpoint */
-			cio_skip(cio, Lepb + 2);  
-
-			return;
-		}
-
-		/* last in current header? */
-		if (Depb & 0x40) {
-			redund = NULL; /* reset the pointer to L4 buffer */
-			first_in_tph = true;
-		}
-
-		/* advance to EPB endpoint */
-		cio_skip(cio, Lepb - 11);  
-
-	} else {
-
-		/* Simply read the EPB parameters */
-		Lepb = cio_read(cio, 2);
-		Depb = cio_read(cio, 1);
-		LDPepb = cio_read(cio, 4);
-		Pepb = cio_read(cio, 4);
-
-		/* What does Pepb tells us about the protection method? */
-		if (((Pepb & 0xF0000000) >> 28) == 0)
-			sprintf(str1, "pred"); /* predefined */
-		else if (((Pepb & 0xF0000000) >> 28) == 1)
-			sprintf(str1, "crc-%lu", 16 * ((Pepb & 0x00000001) + 1)); /* CRC mode */
-		else if (((Pepb & 0xF0000000) >> 28) == 2)
-			sprintf(str1, "rs(%lu,32)", (Pepb & 0x0000FF00) >> 8); /* RS mode */
-		else if (Pepb == 0xFFFFFFFF)
-			sprintf(str1, "nometh"); /* RS mode */
-		else
-			sprintf(str1, "unknown"); /* unknown */
-
-		/* Now we write them to screen */
-		opj_event_msg(j2k->cinfo, EVT_INFO,
-			"EPB(%d): (%sl, %sp, %u), %lu, %s\n",
-			cio_tell(cio) - 13,
-			(Depb & 0x40) ? "" : "n", /* latest EPB or not? */
-			(Depb & 0x80) ? "" : "n", /* packed or unpacked EPB? */
-			(Depb & 0x3F), /* EPB index value */
-			LDPepb, /*length of the data protected by the EPB */
-			str1); /* protection method */
-
-		cio_skip(cio, Lepb - 11);  
-	}
-}
-
-void j2k_write_epb(opj_j2k_t *j2k) {
-	unsigned long int LDPepb, Pepb, Lepbp;
-	unsigned short int Lepb;
-	unsigned char Depb;
-
-	opj_cio_t *cio = j2k->cio;
-
-	cio_write(cio, J2K_MS_EPB, 2);	/* EPB */
-	Lepbp = cio_tell(cio);
-	cio_skip(cio, 2);
-
-	/* EPB style */
-	Depb = 0x00; /* test */
-	cio_write(cio, Depb, 1);   /* Depb */
-
-	/* length of the data to be protected by this EPB */
-	LDPepb = 0x00000000; /* test */
-	cio_write(cio, LDPepb, 4);   /* LDPepb */
-
-	/* next error correction tool */
-	Pepb = 0x00000000; /* test */
-	cio_write(cio, Pepb, 4);   /* Pepb */
-
-	/* EPB data */
-	/* no data, as of now */
-
-	Lepb = (unsigned short) (cio_tell(cio) - Lepbp);
-	cio_seek(cio, Lepbp);
-	cio_write(cio, Lepb, 2);		/* Lepb */
-
-	cio_seek(cio, Lepbp + Lepb);
-
-	/* marker struct update */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, Lepbp - 2, Lepb + 2);
-}
-
-void j2k_read_esd(opj_j2k_t *j2k) {
-	unsigned short int Lesd, Cesd;
-	unsigned char Pesd;
-
-	int cesdsize = (j2k->image->numcomps >= 257) ? 2 : 1;
-
-	char str1[4][4] = {"p", "br", "pr", "res"};
-	char str2[8][8] = {"res", "mse", "mse-r", "psnr", "psnr-i", "maxerr", "tse", "res"};
-	
-	opj_cio_t *cio = j2k->cio;
-
-	/* Simply read the ESD parameters */
-	Lesd = cio_read(cio, 2);
-	Cesd = cio_read(cio, cesdsize);
-	Pesd = cio_read(cio, 1);
-
-	/* Now we write them to screen */
-	opj_event_msg(j2k->cinfo, EVT_INFO,
-		"ESD(%d): c%d, %s, %s, %s, %s, %s\n",
-		cio_tell(cio) - (5 + cesdsize),
-		Cesd, /* component number for this ESD */
-		str1[(Pesd & (unsigned char) 0xC0) >> 6], /* addressing mode */
-		str2[(Pesd & (unsigned char) 0x38) >> 3], /* sensitivity type */
-		((Pesd & (unsigned char) 0x04) >> 2) ? "2Bs" : "1Bs",
-		((Pesd & (unsigned char) 0x02) >> 1) ? "4Ba" : "2Ba",
-		(Pesd & (unsigned char) 0x01) ? "avgc" : "");
-
-	cio_skip(cio, Lesd - (3 + cesdsize));  
-}
-
-void j2k_read_red(opj_j2k_t *j2k) {
-	unsigned short int Lred;
-	unsigned char Pred;
-	char str1[4][4] = {"p", "br", "pr", "res"};
-	
-	opj_cio_t *cio = j2k->cio;
-
-	/* Simply read the RED parameters */
-	Lred = cio_read(cio, 2);
-	Pred = cio_read(cio, 1);
-
-	/* Now we write them to screen */
-	opj_event_msg(j2k->cinfo, EVT_INFO,
-		"RED(%d): %s, %dc, %s, %s\n",
-		cio_tell(cio) - 5,
-		str1[(Pred & (unsigned char) 0xC0) >> 6], /* addressing mode */
-		(Pred & (unsigned char) 0x38) >> 3, /* corruption level */
-		((Pred & (unsigned char) 0x02) >> 1) ? "4Ba" : "2Ba", /* address range */
-		(Pred & (unsigned char) 0x01) ? "errs" : "free"); /* error free? */
-
-	cio_skip(cio, Lred - 3);  
-}
-
-bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno) {
-
-#ifdef oerhgierhgvhreit4u
-	/*
-	   we navigate through the tile and find possible invalid parameters:
-       this saves a lot of crashes!!!!!
-	 */
-	int compno, resno, precno, /*layno,*/ bandno, blockno;
-	int numprecincts, numblocks;
-
-	/* this is the selected tile */
-	opj_tcd_tile_t *tile = &(tcd->tcd_image->tiles[tileno]);
-
-	/* will keep the component */
-	opj_tcd_tilecomp_t *comp = NULL;
-
-	/* will keep the resolution */
-	opj_tcd_resolution_t *res;
-
-	/* will keep the subband */
-	opj_tcd_band_t *band; 
-
-	/* will keep the precinct */
-	opj_tcd_precinct_t *prec; 
-
-	/* will keep the codeblock */
-	opj_tcd_cblk_t *block;
-
-	/* check all tile components */
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		comp = &(tile->comps[compno]);
-
-		/* check all component resolutions */
-		for (resno = 0; resno < comp->numresolutions; resno++) {
-			res = &(comp->resolutions[resno]);
-			numprecincts = res->pw * res->ph;
-
-			/* check all the subbands */
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				band = &(res->bands[bandno]);
-
-				/* check all the precincts */
-				for (precno = 0; precno < numprecincts; precno++) {
-					prec = &(band->precincts[precno]);
-					numblocks = prec->ch * prec->cw;
-
-					/* check all the codeblocks */
-					for (blockno = 0; blockno < numblocks; blockno++) {
-						block = &(prec->cblks[blockno]);
-
-						/* x-origin is invalid */
-						if ((block->x0 < prec->x0) || (block->x0 > prec->x1)) {
-							opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-								"JPWL: wrong x-cord of block origin %d => x-prec is (%d, %d)\n",
-								block->x0, prec->x0, prec->x1);
-							if (!JPWL_ASSUME || JPWL_ASSUME)
-								return false;
-						};
-					}
-				}				
-			}
-		}
-	}
-
-#endif
-
-	return true;
-}
-
-/*@}*/
-
-#endif /* USE_JPWL */
-
-
-#ifdef USE_JPSEC
-
-/** @defgroup JPSEC JPSEC - JPEG-2000 Part 8 (JPSEC) codestream manager */
-/*@{*/
-
-
-/** @name Local static functions */
-/*@{*/
-
-void j2k_read_sec(opj_j2k_t *j2k) {
-	unsigned short int Lsec;
-	
-	opj_cio_t *cio = j2k->cio;
-
-	/* Simply read the SEC length */
-	Lsec = cio_read(cio, 2);
-
-	/* Now we write them to screen */
-	opj_event_msg(j2k->cinfo, EVT_INFO,
-		"SEC(%d)\n",
-		cio_tell(cio) - 2
-		);
-
-	cio_skip(cio, Lsec - 2);  
-}
-
-void j2k_write_sec(opj_j2k_t *j2k) {
-	unsigned short int Lsec = 24;
-	int i;
-
-	opj_cio_t *cio = j2k->cio;
-
-	cio_write(cio, J2K_MS_SEC, 2);	/* SEC */
-	cio_write(cio, Lsec, 2);
-
-	/* write dummy data */
-	for (i = 0; i < Lsec - 2; i++)
-		cio_write(cio, 0, 1);
-}
-
-void j2k_read_insec(opj_j2k_t *j2k) {
-	unsigned short int Linsec;
-	
-	opj_cio_t *cio = j2k->cio;
-
-	/* Simply read the INSEC length */
-	Linsec = cio_read(cio, 2);
-
-	/* Now we write them to screen */
-	opj_event_msg(j2k->cinfo, EVT_INFO,
-		"INSEC(%d)\n",
-		cio_tell(cio) - 2
-		);
-
-	cio_skip(cio, Linsec - 2);  
-}
-
-
-/*@}*/
-
-/*@}*/
-
-#endif /* USE_JPSEC */
-
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/jpwl.h b/Utilities/gdcmopenjpeg-v1/jpwl/jpwl.h
deleted file mode 100644
index a96840c..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/jpwl.h
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __JPWL_H
-#define __JPWL_H
-
-#ifdef USE_JPWL
-
-#include "crc.h"
-#include "rs.h"
-
-/**
- at file jpwl.h
- at brief The JPEG-2000 Part11 (JPWL) marker segments manager
-
-The functions in JPWL.C have for goal to read/write the markers added by JPWL.
-*/
-
-/** @defgroup JPWL JPWL - JPEG-2000 Part11 (JPWL) codestream manager */
-/*@{*/
-
-/**
-Assume a basic codestream structure, so you can resort better from uncorrected errors
-*/
-#define JPWL_ASSUME true
-
-/**
-EPB (Error Protection Block) Marker segment
-*/
-typedef struct jpwl_epb_ms {
-	/**@name Private fields set by epb_create */
-	/*@{*/
-	/** is the latest in header? */
-	bool latest;
-	/** is it in packed mode? */
-	bool packed;
-	/** TH where this marker has been placed (-1 means MH) */
-	int tileno;
-	/** index in current header (0-63) */
-	unsigned char index;
-	/** error protection method	[-1=absent 0=none 1=predefined 16=CRC-16 32=CRC-32 37-128=RS] */
-	int hprot;
-	/** message word length of pre-data */
-	int k_pre;
-	/** code word length of pre-data */
-	int n_pre;
-	/** length of pre-data */
-	int pre_len;
-	/** message word length of post-data */
-	int k_post;
-	/** code word length of post-data */
-	int n_post;
-	/** length of post-data */
-	int post_len;
-	/*@}*/
-	/**@name Marker segment fields */
-	/*@{*/
-	/** two bytes for the length of EPB MS, exluding the marker itself (11 to 65535 bytes) */
-	unsigned short int Lepb;
-	/** single byte for the style */
-	unsigned char Depb; 
-	/** four bytes, from 0 to 2^31-1 */
-	unsigned long int LDPepb;
-	/** four bytes, next error management method */
-	unsigned long int Pepb;
-	/** EPB data, variable size */
-	unsigned char *data;   
-	/*@}*/
-}	jpwl_epb_ms_t;
-
-/**
-EPC (Error Protection Capability) Marker segment
-*/
-typedef struct jpwl_epc_ms {
-	/** is ESD active? */
-	bool esd_on;
-	/** is RED active? */
-	bool red_on;
-	/** is EPB active? */
-	bool epb_on;
-	/** are informative techniques active? */
-	bool info_on;
-	/**@name Marker segment fields */
-	/*@{*/
-	/** two bytes for the length of EPC MS, exluding the marker itself (9 to 65535 bytes) */
-	unsigned short int Lepc;   
-	/** two bytes, CRC for the EPC, excluding Pcrc itself */
-	unsigned short int Pcrc;   
-	/** four bytes, the codestream length from SOC to EOC */
-	unsigned long int DL;     
-	/** one byte, signals JPWL techniques adoption */
-	unsigned char Pepc;	
-	/** EPC data, variable length */
-	unsigned char *data;	
-	/*@}*/
-}	jpwl_epc_ms_t;
-
-/**
-ESD (Error Sensitivity Descriptor) Marker segment
-*/
-typedef struct jpwl_esd_ms {
-	/** codestream addressing mode [0=packet, 1=byte range, 2=packet range, 3=reserved] */
-	unsigned char addrm;
-	/** size of codestream addresses [2/4 bytes] */
-	unsigned char ad_size;
-	/** type of sensitivity
-	[0=relative error, 1=MSE, 2=MSE reduction, 3=PSNR, 4=PSNR increment,
-	5=MAXERR (absolute peak error), 6=TSE (total squared error), 7=reserved */
-	unsigned char senst;
-	/** size of sensitivity data (1/2 bytes) */
-	unsigned char se_size;
-	/**@name Marker segment fields */
-	/*@{*/
-	/** two bytes for the length of ESD MS, exluding the marker itself (4 to 65535 bytes) */
-	unsigned short int Lesd;   
-	/** two bytes, component of error sensitivity */
-	unsigned short int Cesd;
-	/** one byte, signals JPWL techniques adoption */
-	unsigned char Pesd;	
-	/** ESD data, variable length */
-	unsigned char *data;	
-	/*@}*/
-	/**@name Fields set by esd_create (only internal use) */
-	/*@{*/
-	/** number of components in the image */
-	int numcomps;
-	/** tile where this marker has been placed (-1 means MH) */
-	int tileno;
-	/** number of sensitivity values */
-	unsigned long int svalnum;
-	/** size of a single sensitivity pair (address+value) */
-	size_t sensval_size;
-	/*@}*/
-}	jpwl_esd_ms_t;
-
-/**
-RED (Residual Error Descriptor) Marker segment
-*/
-typedef struct jpwl_red_ms {
-	/** two bytes for the length of RED MS, exluding the marker itself (3 to 65535 bytes) */
-	unsigned short int Lred;
-	/** one byte, signals JPWL techniques adoption */
-	unsigned char Pred;	
-	/** RED data, variable length */
-	unsigned char *data;	
-}	jpwl_red_ms_t;
-
-/**
-Structure used to store JPWL markers temporary position and readyness
-*/
-typedef struct jpwl_marker {
-	/** marker value (J2K_MS_EPC, etc.) */
-	int id;
-	/** union keeping the pointer to the real marker struct */
-	union jpwl_marks {
-		/** pointer to EPB marker */
-		jpwl_epb_ms_t *epbmark;
-		/** pointer to EPC marker */
-		jpwl_epc_ms_t *epcmark;
-		/** pointer to ESD marker */
-		jpwl_esd_ms_t *esdmark;
-		/** pointer to RED marker */
-		jpwl_red_ms_t *redmark;
-	} m;
-	/** position where the marker should go, in the pre-JPWL codestream */ 
-	unsigned long int pos;
-	/** same as before, only written as a double, so we can sort it better */
-	double dpos;
-	/** length of the marker segment (marker excluded) */
-	unsigned short int len;
-	/** the marker length is ready or not? */
-	bool len_ready;
-	/** the marker position is ready or not? */
-	bool pos_ready;
-	/** the marker parameters are ready or not? */
-	bool parms_ready;
-	/** are the written data ready or not */
-	bool data_ready;
-}	jpwl_marker_t;
-
-/**
-Encode according to JPWL specs
- at param j2k J2K handle
- at param cio codestream handle
- at param image image handle
-*/
-void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
-
-/**
-Prepare the list of JPWL markers, after the Part 1 codestream
-has been finalized (index struct is full)
- at param j2k J2K handle
- at param cio codestream handle
- at param image image handle
-*/
-void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
-
-/**
-Dump the list of JPWL markers, after it has been prepared
- at param j2k J2K handle
- at param cio codestream handle
- at param image image handle
-*/
-void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
-
-/**
-Read the EPC marker (Error Protection Capability)
- at param j2k J2K handle
-*/
-void j2k_read_epc(opj_j2k_t *j2k);
-
-/**
-Write the EPC marker (Error Protection Capability), BUT the DL field is always set to 0
-(this simplifies the management of EPBs and it is openly stated in the standard
-as a possible value, mening that the information is not available) and the informative techniques
-are not yet implemented
- at param j2k J2K handle
-*/
-void j2k_write_epc(opj_j2k_t *j2k);
-
-/**
-Read the EPB marker (Error Protection Block)
- at param j2k J2K handle
-*/
-void j2k_read_epb(opj_j2k_t *j2k);
-
-/**
-Write the EPB marker (Error Protection Block)
- at param j2k J2K handle
-*/
-void j2k_write_epb(opj_j2k_t *j2k);
-
-/**
-Read the ESD marker (Error Sensitivity Descriptor)
- at param j2k J2K handle
-*/
-void j2k_read_esd(opj_j2k_t *j2k);
-
-/**
-Read the RED marker (Residual Error Descriptor)
- at param j2k J2K handle
-*/
-void j2k_read_red(opj_j2k_t *j2k);
-
-/** create an EPB marker segment
- at param j2k J2K compressor handle
- at param latest it is the latest EPB in the header
- at param packed EPB is in packed style
- at param tileno tile number where the marker has been placed (-1 means MH)
- at param idx current EPB running index
- at param hprot applied protection type (-1/0,1,16,32,37-128)
- at param pre_len length of pre-protected data
- at param post_len length of post-protected data
- at return returns the freshly created EPB
-*/
-jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int tileno, int idx, int hprot,
-							   unsigned long int pre_len, unsigned long int post_len);
-
-/** add a number of EPB marker segments
- at param j2k J2K compressor handle
- at param jwmarker pointer to the JPWL markers list
- at param jwmarker_num pointer to the number of JPWL markers (gets updated)
- at param latest it is the latest group of EPBs in the header
- at param packed EPBs are in packed style
- at param insideMH it is in the MH
- at param idx pointer to the starting EPB running index (gets updated)
- at param hprot applied protection type (-1/0,1,16,32,37-128)
- at param place_pos place in original codestream where EPBs should go
- at param tileno tile number of these EPBs
- at param pre_len length of pre-protected data
- at param post_len length of post-protected data
- at return returns the length of all added markers
-*/
-int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-				  bool latest, bool packed, bool insideMH, int *idx, int hprot,
-				  double place_pos, int tileno,
-				  unsigned long int pre_len, unsigned long int post_len);
-
-/** add a number of ESD marker segments
- at param j2k J2K compressor handle
- at param jwmarker pointer to the JPWL markers list
- at param jwmarker_num pointer to the number of JPWL markers (gets updated)
- at param comps considered component (-1=average, 0/1/2/...=component no.)
- at param addrm addressing mode (0=packet, 1=byte range, 2=packet range, 3=reserved)
- at param ad_size size of addresses (2/4 bytes)
- at param senst sensitivity type
- at param se_size sensitivity values size (1/2 bytes)
- at param place_pos place in original codestream where EPBs should go
- at param tileno tile number of these EPBs
- at return returns the length of all added markers
-*/
-int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-				  int comps, unsigned char addrm, unsigned char ad_size,
-				  unsigned char senst, unsigned char se_size,
-				  double place_pos, int tileno);
-	
-/** updates the information structure by modifying the positions and lengths
- at param j2k J2K compressor handle
- at param jwmarker pointer to JPWL markers list
- at param jwmarker_num number of JPWL markers
- at return returns true in case of success
-*/			  
-bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num);
-
-
-bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
-
-bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf);
-
-void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
-
-/** corrects the data in the JPWL codestream
- at param j2k J2K compressor handle
- at return true if correction is performed correctly
-*/
-bool jpwl_correct(opj_j2k_t *j2k);
-
-/** corrects the data protected by an EPB
- at param j2k J2K compressor handle
- at param buffer pointer to the EPB position
- at param type type of EPB: 0=MH, 1=TPH, 2=other, 3=auto
- at param pre_len length of pre-data
- at param post_len length of post_data
- at param conn is a pointer to the length of all connected (packed) EPBs
- at param L4_bufp is a pointer to the buffer pointer of redundancy data
- at return returns true if correction could be succesfully performed
-*/
-bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
-					  unsigned char **L4_bufp);
-
-/** check that a tile and its children have valid data
- at param j2k J2K decompressor handle
- at param tcd Tile decompressor handle
- at param tileno number of the tile to check
-*/
-bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno);
-
-/** Macro functions for CRC computation */
-
-/**
-Computes the CRC-16, as stated in JPWL specs
- at param CRC two bytes containing the CRC value (must be initialized with 0x0000)
- at param DATA byte for which the CRC is computed; call this on every byte of the sequence
-and get the CRC at the end
-*/
-#define jpwl_updateCRC16(CRC, DATA) updateCRC16(CRC, DATA)
-
-/**
-Computes the CRC-32, as stated in JPWL specs
- at param CRC four bytes containing the CRC value (must be initialized with 0x00000000)
- at param DATA byte for which the CRC is computed; call this on every byte of the sequence
-and get the CRC at the end
-*/
-#define jpwl_updateCRC32(CRC, DATA) updateCRC32(CRC, DATA)
-
-/**
-Computes the minimum between two integers
- at param a first integer to compare
- at param b second integer to compare
- at return returns the minimum integer between a and b
-*/
-#ifndef min
-#define min(a,b)    (((a) < (b)) ? (a) : (b))
-#endif /* min */
-
-/*@}*/
-
-#endif /* USE_JPWL */
-
-#ifdef USE_JPSEC
-
-/** @defgroup JPSEC JPSEC - JPEG-2000 Part 8 (JPSEC) codestream manager */
-/*@{*/
-
-/**
-Read the SEC marker (SEcured Codestream)
- at param j2k J2K handle
-*/
-void j2k_read_sec(opj_j2k_t *j2k);
-
-/**
-Write the SEC marker (SEcured Codestream)
- at param j2k J2K handle
-*/
-void j2k_write_sec(opj_j2k_t *j2k);
-
-/**
-Read the INSEC marker (SEcured Codestream)
- at param j2k J2K handle
-*/
-void j2k_read_insec(opj_j2k_t *j2k);
-
-/*@}*/
-
-#endif /* USE_JPSEC */
-
-#endif /* __JPWL_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/jpwl_lib.c b/Utilities/gdcmopenjpeg-v1/jpwl/jpwl_lib.c
deleted file mode 100644
index 90391b0..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/jpwl_lib.c
+++ /dev/null
@@ -1,1796 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-#include "../libopenjpeg/opj_includes.h"
-#include <limits.h>
-
-/** Minimum and maximum values for the double->pfp conversion */
-#define MIN_V1 0.0
-#define MAX_V1 17293822569102704640.0
-#define MIN_V2 0.000030517578125
-#define MAX_V2 131040.0
-
-/** conversion between a double precision floating point
-number and the corresponding pseudo-floating point used 
-to represent sensitivity values
- at param V the double precision value
- at param bytes the number of bytes of the representation
- at return the pseudo-floating point value (cast accordingly)
-*/
-unsigned short int jpwl_double_to_pfp(double V, int bytes);
-
-/** conversion between a pseudo-floating point used 
-to represent sensitivity values and the corresponding
-double precision floating point number  
- at param em the pseudo-floating point value (cast accordingly)
- at param bytes the number of bytes of the representation
- at return the double precision value
-*/
-double jpwl_pfp_to_double(unsigned short int em, int bytes);
-
-	/*-------------------------------------------------------------*/
-
-int jpwl_markcomp(const void *arg1, const void *arg2)
-{
-   /* Compare the two markers' positions */
-   double diff = (((jpwl_marker_t *) arg1)->dpos - ((jpwl_marker_t *) arg2)->dpos);
-
-   if (diff == 0.0)
-	   return (0);
-   else if (diff < 0)
-	   return (-1);
-   else
-	   return (+1);
-}
-
-int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-				  bool latest, bool packed, bool insideMH, int *idx, int hprot,
-				  double place_pos, int tileno,
-				  unsigned long int pre_len, unsigned long int post_len) {
-
-	jpwl_epb_ms_t *epb_mark = NULL;
-
-	int k_pre, k_post, n_pre, n_post;
-	
-	unsigned long int L1, L2, dL4, max_postlen, epbs_len = 0;
-
-	/* We find RS(n,k) for EPB parms and pre-data, if any */
-	if (insideMH && (*idx == 0)) {
-		/* First EPB in MH */ 
-		k_pre = 64;
-		n_pre = 160;
-	} else if (!insideMH && (*idx == 0)) {
-		/* First EPB in TH */
-		k_pre = 25;
-		n_pre = 80;
-	} else {
-		/* Following EPBs in MH or TH */
-		k_pre = 13;
-		n_pre = 40;
-	};
-
-	/* Find lengths, Figs. B3 and B4 */
-	/* size of pre data: pre_buf(pre_len) + EPB(2) + Lepb(2) + Depb(1) + LDPepb(4) + Pepb(4) */
-	L1 = pre_len + 13;
-
-	/* size of pre-data redundancy */
-	/*   (redundancy per codeword)       *     (number of codewords, rounded up)   */
-	L2 = (n_pre - k_pre) * (unsigned long int) ceil((double) L1 / (double) k_pre);
-
-	/* Find protection type for post data and its associated redundancy field length*/
-	if ((hprot == 16) || (hprot == 32)) {
-		/* there is a CRC for post-data */
-		k_post = post_len;
-		n_post = post_len + (hprot >> 3);
-		/*L3 = hprot >> 3;*/ /* 2 (CRC-16) or 4 (CRC-32) bytes */
-
-	} else if ((hprot >= 37) && (hprot <= 128)) {
-		/* there is a RS for post-data */
-		k_post = 32;
-		n_post = hprot;
-
-	} else {
-		/* Use predefined codes */
-		n_post = n_pre;
-		k_post = k_pre;
-	};
-
-	/* Create the EPB(s) */
-	while (post_len > 0) {
-
-		/* maximum postlen in order to respect EPB size
-		(we use JPWL_MAXIMUM_EPB_ROOM instead of 65535 for keeping room for EPB parms)*/
-		/*      (message word size)    *            (number of containable parity words)  */
-		max_postlen = k_post * (unsigned long int) floor((double) JPWL_MAXIMUM_EPB_ROOM / (double) (n_post - k_post));
-
-		/* maximum postlen in order to respect EPB size */
-		if (*idx == 0)
-			/* (we use (JPWL_MAXIMUM_EPB_ROOM - L2) instead of 65535 for keeping room for EPB parms + pre-data) */
-			/*      (message word size)    *                   (number of containable parity words)  */
-			max_postlen = k_post * (unsigned long int) floor((double) (JPWL_MAXIMUM_EPB_ROOM - L2) / (double) (n_post - k_post));
-
-		else
-			/* (we use JPWL_MAXIMUM_EPB_ROOM instead of 65535 for keeping room for EPB parms) */
-			/*      (message word size)    *            (number of containable parity words)  */
-			max_postlen = k_post * (unsigned long int) floor((double) JPWL_MAXIMUM_EPB_ROOM / (double) (n_post - k_post));
-
-		/* null protection case */
-		/* the max post length can be as large as the LDPepb field can host */
-		if (hprot == 0)
-			max_postlen = INT_MAX;
-		
-		/* length to use */
-		dL4 = min(max_postlen, post_len);
-
-		if ((epb_mark = jpwl_epb_create(
-			j2k, /* this encoder handle */
-			latest ? (dL4 < max_postlen) : false, /* is it the latest? */
-			packed, /* is it packed? */
-			tileno, /* we are in TPH */
-			*idx, /* its index */
-			hprot, /* protection type parameters of following data */
-			0, /* pre-data: nothing for now */
-			dL4 /* post-data: the stub computed previously */
-			))) {
-			
-			/* Add this marker to the 'insertanda' list */
-			if (*jwmarker_num < JPWL_MAX_NO_MARKERS) {
-				jwmarker[*jwmarker_num].id = J2K_MS_EPB; /* its type */
-				jwmarker[*jwmarker_num].m.epbmark = epb_mark; /* the EPB */
-				jwmarker[*jwmarker_num].pos = (int) place_pos; /* after SOT */
-				jwmarker[*jwmarker_num].dpos = place_pos + 0.0000001 * (double)(*idx); /* not very first! */
-				jwmarker[*jwmarker_num].len = epb_mark->Lepb; /* its length */
-				jwmarker[*jwmarker_num].len_ready = true; /* ready */
-				jwmarker[*jwmarker_num].pos_ready = true; /* ready */
-				jwmarker[*jwmarker_num].parms_ready = true; /* ready */
-				jwmarker[*jwmarker_num].data_ready = false; /* not ready */
-				(*jwmarker_num)++;
-			}
-
-			/* increment epb index */
-			(*idx)++;
-
-			/* decrease postlen */
-			post_len -= dL4;
-
-			/* increase the total length of EPBs */
-			epbs_len += epb_mark->Lepb + 2;
-
-		} else {
-			/* ooops, problems */
-			opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB for UEP in tile %d\n", tileno);				
-		};
-	}
-
-	return epbs_len;
-}
-
-
-jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int tileno, int idx, int hprot,
-						  unsigned long int pre_len, unsigned long int post_len) {
-
-	jpwl_epb_ms_t *epb = NULL;
-	/*unsigned short int data_len = 0;*/
-	unsigned short int L2, L3;
-	unsigned long int L1, L4;
-	/*unsigned char *predata_in = NULL;*/
-
-	bool insideMH = (tileno == -1);
-
-	/* Alloc space */
-	if (!(epb = (jpwl_epb_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_epb_ms_t)))) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for one EPB MS\n");
-		return NULL;
-	};
-
-	/* We set RS(n,k) for EPB parms and pre-data, if any */
-	if (insideMH && (idx == 0)) {
-		/* First EPB in MH */ 
-		epb->k_pre = 64;
-		epb->n_pre = 160;
-	} else if (!insideMH && (idx == 0)) {
-		/* First EPB in TH */
-		epb->k_pre = 25;
-		epb->n_pre = 80;
-	} else {
-		/* Following EPBs in MH or TH */
-		epb->k_pre = 13;
-		epb->n_pre = 40;
-	};
-
-	/* Find lengths, Figs. B3 and B4 */
-	/* size of pre data: pre_buf(pre_len) + EPB(2) + Lepb(2) + Depb(1) + LDPepb(4) + Pepb(4) */
-	L1 = pre_len + 13;
-	epb->pre_len = pre_len;
-
-	/* size of pre-data redundancy */
-	/*   (redundancy per codeword)       *               (number of codewords, rounded up)   */
-	L2 = (epb->n_pre - epb->k_pre) * (unsigned short int) ceil((double) L1 / (double) epb->k_pre);
-
-	/* length of post-data */
-	L4 = post_len;
-	epb->post_len = post_len;
-
-	/* Find protection type for post data and its associated redundancy field length*/
-	if ((hprot == 16) || (hprot == 32)) {
-		/* there is a CRC for post-data */
-		epb->Pepb = 0x10000000 | ((unsigned long int) hprot >> 5); /* 0=CRC-16, 1=CRC-32 */
-		epb->k_post = post_len;
-		epb->n_post = post_len + (hprot >> 3);
-		/*L3 = hprot >> 3;*/ /* 2 (CRC-16) or 4 (CRC-32) bytes */
-
-	} else if ((hprot >= 37) && (hprot <= 128)) {
-		/* there is a RS for post-data */
-		epb->Pepb = 0x20000020 | (((unsigned long int) hprot & 0x000000FF) << 8);
-		epb->k_post = 32;
-		epb->n_post = hprot;
-
-	} else if (hprot == 1) {
-		/* Use predefined codes */
-		epb->Pepb = (unsigned long int) 0x00000000;
-		epb->n_post = epb->n_pre;
-		epb->k_post = epb->k_pre;
-	
-	} else if (hprot == 0) {
-		/* Placeholder EPB: only protects its parameters, no protection method */
-		epb->Pepb = (unsigned long int) 0xFFFFFFFF;
-		epb->n_post = 1;
-		epb->k_post = 1;
-	
-	} else {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Invalid protection value for EPB h = %d\n", hprot);				
-		return NULL;
-	}
-
-	epb->hprot = hprot;
-
-	/*   (redundancy per codeword)          *                (number of codewords, rounded up) */
-	L3 = (epb->n_post - epb->k_post) * (unsigned short int) ceil((double) L4 / (double) epb->k_post);
-
-	/* private fields */
-	epb->tileno = tileno;
-
-	/* Fill some fields of the EPB */
-
-	/* total length of the EPB MS (less the EPB marker itself): */
-	/* Lepb(2) + Depb(1) + LDPepb(4) + Pepb(4) + pre_redundancy + post-redundancy */
-	epb->Lepb = 11 + L2 + L3;
-
-	/* EPB style */
-	epb->Depb = ((packed & 0x0001) << 7) | ((latest & 0x0001) << 6) | (idx & 0x003F);
-
-	/* length of data protected by EPB: */
-	epb->LDPepb = L1 + L4;
-
-	return epb;
-}
-
-void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf) {
-
-	/* Marker */
-	*(buf++) = (unsigned char) (J2K_MS_EPB >> 8); 
-	*(buf++) = (unsigned char) (J2K_MS_EPB >> 0); 
-
-	/* Lepb */
-	*(buf++) = (unsigned char) (epb->Lepb >> 8); 
-	*(buf++) = (unsigned char) (epb->Lepb >> 0); 
-
-	/* Depb */
-	*(buf++) = (unsigned char) (epb->Depb >> 0); 
-
-	/* LDPepb */
-	*(buf++) = (unsigned char) (epb->LDPepb >> 24); 
-	*(buf++) = (unsigned char) (epb->LDPepb >> 16); 
-	*(buf++) = (unsigned char) (epb->LDPepb >> 8); 
-	*(buf++) = (unsigned char) (epb->LDPepb >> 0); 
-
-	/* Pepb */
-	*(buf++) = (unsigned char) (epb->Pepb >> 24); 
-	*(buf++) = (unsigned char) (epb->Pepb >> 16); 
-	*(buf++) = (unsigned char) (epb->Pepb >> 8); 
-	*(buf++) = (unsigned char) (epb->Pepb >> 0); 
-
-	/* Data */
-	/*memcpy(buf, epb->data, (size_t) epb->Lepb - 11);*/
-	memset(buf, 0, (size_t) epb->Lepb - 11);
-
-	/* update markers struct */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, -1, epb->Lepb + 2);
-
-};
-
-
-jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, bool esd_on, bool red_on, bool epb_on, bool info_on) {
-
-	jpwl_epc_ms_t *epc = NULL;
-
-	/* Alloc space */
-	if (!(epc = (jpwl_epc_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_epc_ms_t)))) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for EPC MS\n");
-		return NULL;
-	};
-
-	/* Set the EPC parameters */
-	epc->esd_on = esd_on;
-	epc->epb_on = epb_on;
-	epc->red_on = red_on;
-	epc->info_on = info_on;
-
-	/* Fill the EPC fields with default values */
-	epc->Lepc = 9;
-	epc->Pcrc = 0x0000;
-	epc->DL = 0x00000000;
-	epc->Pepc = ((j2k->cp->esd_on & 0x0001) << 4) | ((j2k->cp->red_on & 0x0001) << 5) |
-		((j2k->cp->epb_on & 0x0001) << 6) | ((j2k->cp->info_on & 0x0001) << 7);
-
-	return (epc);
-}
-
-bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf, unsigned char *post_buf) {
-
-	unsigned long int L1, L2, L3, L4;
-	int remaining;
-	unsigned long int P, NN_P;
-
-	/* Operating buffer */
-	static unsigned char codeword[NN], *parityword;
-
-	unsigned char *L1_buf, *L2_buf;
-	/* these ones are static, since we need to keep memory of
-	 the exact place from one call to the other */
-	static unsigned char *L3_buf, *L4_buf;
-
-	/* some consistency check */
-	if (!buf) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no operating buffer for EPBs\n");
-		return false;
-	}
-
-	if (!post_buf && !L4_buf) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no operating buffer for EPBs data\n");
-		return false;
-	}
-
-	/*
-	 * Compute parity bytes on pre-data, ALWAYS present (at least only for EPB parms)
-	 */
-
-	/* Initialize RS structures */
-	P = epb->n_pre - epb->k_pre;
-	NN_P = NN - P;
-	memset(codeword, 0, NN);
-	parityword = codeword + NN_P;
-	init_rs(NN_P);
-
-	/* pre-data begins pre_len bytes before of EPB buf */
-	L1_buf = buf - epb->pre_len;
-	L1 = epb->pre_len + 13;
-
-	/* redundancy for pre-data begins immediately after EPB parms */
-	L2_buf = buf + 13;
-	L2 = (epb->n_pre - epb->k_pre) * (unsigned short int) ceil((double) L1 / (double) epb->k_pre);
-
-	/* post-data
-	   the position of L4 buffer can be:
-	     1) passed as a parameter: in that case use it
-	     2) null: in that case use the previous (static) one
-	*/
-	if (post_buf)
-		L4_buf = post_buf;
-	L4 = epb->post_len;
-
-	/* post-data redundancy begins immediately after pre-data redundancy */
-	L3_buf = L2_buf + L2;
-	L3 = (epb->n_post - epb->k_post) * (unsigned short int) ceil((double) L4 / (double) epb->k_post);
-
-	/* let's check whether EPB length is sufficient to contain all these data */
-	if (epb->Lepb < (11 + L2 + L3))
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no room in EPB data field for writing redundancy data\n");
-	/*printf("Env. %d, nec. %d (%d + %d)\n", epb->Lepb - 11, L2 + L3, L2, L3);*/
-
-	/* Compute redundancy of pre-data message words */
-	remaining = L1;
-	while (remaining) {
-
-		/* copy message data into codeword buffer */
-		if (remaining < epb->k_pre) {
-			/* the last message word is zero-padded */
-			memset(codeword, 0, NN);
-			memcpy(codeword, L1_buf, remaining);
-			L1_buf += remaining;
-			remaining = 0;
-
-		} else {
-			memcpy(codeword, L1_buf, epb->k_pre);
-			L1_buf += epb->k_pre;
-			remaining -= epb->k_pre;
-
-		}
-
-		/* Encode the buffer and obtain parity bytes */
-		if (encode_rs(codeword, parityword))
-			opj_event_msg(j2k->cinfo, EVT_WARNING,
-				"Possible encoding error in codeword @ position #%d\n", (L1_buf - buf) / epb->k_pre);
-
-		/* copy parity bytes only in redundancy buffer */
-		memcpy(L2_buf, parityword, P); 
-
-		/* advance parity buffer */
-		L2_buf += P;
-	}
-
-	/*
-	 * Compute parity bytes on post-data, may be absent if there are no data
-	 */
-	/*printf("Hprot is %d (tileno=%d, k_pre=%d, n_pre=%d, k_post=%d, n_post=%d, pre_len=%d, post_len=%d)\n",
-		epb->hprot, epb->tileno, epb->k_pre, epb->n_pre, epb->k_post, epb->n_post, epb->pre_len,
-		epb->post_len);*/
-	if (epb->hprot < 0) {
-
-		/* there should be no EPB */
-		
-	} else if (epb->hprot == 0) {
-
-		/* no protection for the data */
-		/* advance anyway */
-		L4_buf += epb->post_len;
-
-	} else if (epb->hprot == 16) {
-
-		/* CRC-16 */
-		unsigned short int mycrc = 0x0000;
-
-		/* compute the CRC field (excluding itself) */
-		remaining = L4;
-		while (remaining--)
-			jpwl_updateCRC16(&mycrc, *(L4_buf++));
-
-		/* write the CRC field */
-		*(L3_buf++) = (unsigned char) (mycrc >> 8);
-		*(L3_buf++) = (unsigned char) (mycrc >> 0);
-
-	} else if (epb->hprot == 32) {
-
-		/* CRC-32 */
-		unsigned long int mycrc = 0x00000000;
-
-		/* compute the CRC field (excluding itself) */
-		remaining = L4;
-		while (remaining--)
-			jpwl_updateCRC32(&mycrc, *(L4_buf++));
-
-		/* write the CRC field */
-		*(L3_buf++) = (unsigned char) (mycrc >> 24);
-		*(L3_buf++) = (unsigned char) (mycrc >> 16);
-		*(L3_buf++) = (unsigned char) (mycrc >> 8);
-		*(L3_buf++) = (unsigned char) (mycrc >> 0);
-
-	} else {
-
-		/* RS */
-
-		/* Initialize RS structures */
-		P = epb->n_post - epb->k_post;
-		NN_P = NN - P;
-		memset(codeword, 0, NN);
-		parityword = codeword + NN_P;
-		init_rs(NN_P);
-
-		/* Compute redundancy of post-data message words */
-		remaining = L4;
-		while (remaining) {
-
-			/* copy message data into codeword buffer */
-			if (remaining < epb->k_post) {
-				/* the last message word is zero-padded */
-				memset(codeword, 0, NN);
-				memcpy(codeword, L4_buf, remaining);
-				L4_buf += remaining;
-				remaining = 0;
-
-			} else {
-				memcpy(codeword, L4_buf, epb->k_post);
-				L4_buf += epb->k_post;
-				remaining -= epb->k_post;
-
-			}
-
-			/* Encode the buffer and obtain parity bytes */
-			if (encode_rs(codeword, parityword))
-				opj_event_msg(j2k->cinfo, EVT_WARNING,
-					"Possible encoding error in codeword @ position #%d\n", (L4_buf - buf) / epb->k_post);
-
-			/* copy parity bytes only in redundancy buffer */
-			memcpy(L3_buf, parityword, P); 
-
-			/* advance parity buffer */
-			L3_buf += P;
-		}
-
-	}
-
-	return true;
-}
-
-
-bool jpwl_correct(opj_j2k_t *j2k) {
-
-	opj_cio_t *cio = j2k->cio;
-	bool status;
-	static bool mh_done = false;
-	int mark_pos, id, len, skips, sot_pos;
-	unsigned long int Psot = 0;
-
-	/* go back to marker position */
-	mark_pos = cio_tell(cio) - 2;
-	cio_seek(cio, mark_pos);
-
-	if ((j2k->state == J2K_STATE_MHSOC) && !mh_done) {
-
-		int mark_val = 0, skipnum = 0;
-
-		/*
-		  COLOR IMAGE
-		  first thing to do, if we are here, is to look whether
-		  51 (skipnum) positions ahead there is an EPB, in case of MH
-		*/
-		/*
-		  B/W IMAGE
-		  first thing to do, if we are here, is to look whether
-		  45 (skipnum) positions ahead there is an EPB, in case of MH
-		*/
-		/*       SIZ   SIZ_FIELDS     SIZ_COMPS               FOLLOWING_MARKER */
-		skipnum = 2  +     38     + 3 * j2k->cp->exp_comps  +         2;
-		if ((cio->bp + skipnum) < cio->end) {
-
-			cio_skip(cio, skipnum);
-
-			/* check that you are not going beyond the end of codestream */
-
-			/* call EPB corrector */
-			status = jpwl_epb_correct(j2k,     /* J2K decompressor handle */
-									  cio->bp, /* pointer to EPB in codestream buffer */
-									  0,       /* EPB type: MH */
-									  skipnum,      /* length of pre-data */
-									  -1,      /* length of post-data: -1 means auto */
-									  NULL,
-									  NULL
-									 );
-
-			/* read the marker value */
-			mark_val = (*(cio->bp) << 8) | *(cio->bp + 1);
-
-			if (status && (mark_val == J2K_MS_EPB)) {
-				/* we found it! */
-				mh_done = true;
-				return true;
-			}
-
-			/* Disable correction in case of missing or bad head EPB */
-			/* We can't do better! */
-			/* PATCHED: 2008-01-25 */
-			/* MOVED UP: 2008-02-01 */
-			if (!status) {
-				j2k->cp->correct = false;
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "Couldn't find the MH EPB: disabling JPWL\n");
-			}
-
-		}
-
-	}
-
-	if (true /*(j2k->state == J2K_STATE_TPHSOT) || (j2k->state == J2K_STATE_TPH)*/) {
-		/* else, look if 12 positions ahead there is an EPB, in case of TPH */
-		cio_seek(cio, mark_pos);
-		if ((cio->bp + 12) < cio->end) {
-
-			cio_skip(cio, 12);
-
-			/* call EPB corrector */
-			status = jpwl_epb_correct(j2k,     /* J2K decompressor handle */
-									  cio->bp, /* pointer to EPB in codestream buffer */
-									  1,       /* EPB type: TPH */
-									  12,      /* length of pre-data */
-									  -1,      /* length of post-data: -1 means auto */
-									  NULL,
-									  NULL
-									 );
-			if (status)
-				/* we found it! */
-				return true;
-		}
-	}
-
-	return false;
-
-	/* for now, don't use this code */
-
-	/* else, look if here is an EPB, in case of other */
-	if (mark_pos > 64) {
-		/* it cannot stay before the first MH EPB */
-		cio_seek(cio, mark_pos);
-		cio_skip(cio, 0);
-
-		/* call EPB corrector */
-		status = jpwl_epb_correct(j2k,     /* J2K decompressor handle */
-								  cio->bp, /* pointer to EPB in codestream buffer */
-								  2,       /* EPB type: TPH */
-								  0,       /* length of pre-data */
-								  -1,      /* length of post-data: -1 means auto */
-								  NULL,
-								  NULL
-								 );
-		if (status)
-			/* we found it! */
-			return true;
-	}
-
-	/* nope, no EPBs probably, or they are so damaged that we can give up */
-	return false;
-	
-	return true;
-
-	/* AN ATTEMPT OF PARSER */
-	/* NOT USED ACTUALLY    */
-
-	/* go to the beginning of the file */
-	cio_seek(cio, 0);
-
-	/* let's begin */
-	j2k->state = J2K_STATE_MHSOC;
-
-	/* cycle all over the markers */
-	while (cio_tell(cio) < cio->length) {
-
-		/* read the marker */
-		mark_pos = cio_tell(cio);
-		id = cio_read(cio, 2);
-
-		/* details */
-		printf("Marker@%d: %X\n", cio_tell(cio) - 2, id);
-
-		/* do an action in response to the read marker */
-		switch (id) {
-
-		/* short markers */
-
-			/* SOC */
-		case J2K_MS_SOC:
-			j2k->state = J2K_STATE_MHSIZ;
-			len = 0;
-			skips = 0;
-			break;
-
-			/* EOC */
-		case J2K_MS_EOC:
-			j2k->state = J2K_STATE_MT;
-			len = 0;
-			skips = 0;
-			break;
-
-			/* particular case of SOD */
-		case J2K_MS_SOD:
-			len = Psot - (mark_pos - sot_pos) - 2;
-			skips = len;
-			break;
-
-		/* long markers */
-
-			/* SOT */
-		case J2K_MS_SOT:
-			j2k->state = J2K_STATE_TPH;
-			sot_pos = mark_pos; /* position of SOT */
-			len = cio_read(cio, 2); /* read the length field */
-			cio_skip(cio, 2); /* this field is unnecessary */
-			Psot = cio_read(cio, 4); /* tile length */
-			skips = len - 8;
-			break;
-
-			/* remaining */
-		case J2K_MS_SIZ:
-			j2k->state = J2K_STATE_MH;
-			/* read the length field */
-			len = cio_read(cio, 2);
-			skips = len - 2;
-			break;
-
-			/* remaining */
-		default:
-			/* read the length field */
-			len = cio_read(cio, 2);
-			skips = len - 2;
-			break;
-
-		}
-
-		/* skip to marker's end */
-		cio_skip(cio, skips);	
-
-	}
-
-
-}
-
-bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
-					  unsigned char **L4_bufp) {
-
-	/* Operating buffer */
-	unsigned char codeword[NN], *parityword;
-
-	unsigned long int P, NN_P;
-	unsigned long int L1, L4;
-	int remaining, n_pre, k_pre, n_post, k_post;
-
-	int status, tt;
-
-	int orig_pos = cio_tell(j2k->cio);
-
-	unsigned char *L1_buf, *L2_buf;
-	unsigned char *L3_buf, *L4_buf;
-
-	unsigned long int LDPepb, Pepb;
-	unsigned short int Lepb;
-	unsigned char Depb;
-	char str1[25] = "";
-	int myconn, errnum = 0;
-	bool errflag = false;
-	
-	opj_cio_t *cio = j2k->cio;
-
-	/* check for common errors */
-	if (!buffer) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "The EPB pointer is a NULL buffer\n");
-		return false;
-	}
-	
-	/* set bignesses */
-	L1 = pre_len + 13;
-
-	/* pre-data correction */
-	switch (type) {
-
-	case 0:
-		/* MH EPB */
-		k_pre = 64;
-		n_pre = 160;
-		break;
-
-	case 1:
-		/* TPH EPB */
-		k_pre = 25;
-		n_pre = 80;
-		break;
-
-	case 2:
-		/* other EPBs */
-		k_pre = 13;
-		n_pre = 40;
-		break;
-
-	case 3:
-		/* automatic setup */
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Auto. setup not yet implemented\n");
-		return false;
-		break;
-
-	default:
-		/* unknown type */
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Unknown expected EPB type\n");
-		return false;
-		break;
-
-	}
-
-	/* Initialize RS structures */
-	P = n_pre - k_pre;
-	NN_P = NN - P;
-	tt = (int) floor((float) P / 2.0F); /* correction capability of the code */
-	memset(codeword, 0, NN);
-	parityword = codeword + NN_P;
-	init_rs(NN_P);
-
-	/* Correct pre-data message words */
-	L1_buf = buffer - pre_len;
-	L2_buf = buffer + 13;
-	remaining = L1;
-	while (remaining) {
- 
-		/* always zero-pad codewords */
-		/* (this is required, since after decoding the zeros in the long codeword
-		    could change, and keep unchanged in subsequent calls) */
-		memset(codeword, 0, NN);
-
-		/* copy codeword buffer into message bytes */
-		if (remaining < k_pre)
-			memcpy(codeword, L1_buf, remaining);
-		else
-			memcpy(codeword, L1_buf, k_pre);
-
-		/* copy redundancy buffer in parity bytes */
-		memcpy(parityword, L2_buf, P); 
-
-		/* Decode the buffer and possibly obtain corrected bytes */
-		status = eras_dec_rs(codeword, NULL, 0);
-		if (status == -1) {
-			/*if (conn == NULL)
-				opj_event_msg(j2k->cinfo, EVT_WARNING,
-					"Possible decoding error in codeword @ position #%d\n", (L1_buf - buffer) / k_pre);*/
-			errflag = true;
-			/* we can try to safely get out from the function:
-			  if we are here, either this is not an EPB or the first codeword
-			  is too damaged to be helpful */
-			/*return false;*/
-
-		} else if (status == 0) {
-			/*if (conn == NULL)
-				opj_event_msg(j2k->cinfo, EVT_INFO, "codeword is correctly decoded\n");*/
-
-		} else if (status <= tt) {
-			/* it has corrected 0 <= errs <= tt */
-			/*if (conn == NULL)
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "%d errors corrected in codeword\n", status);*/
-			errnum += status;
-
-		} else {
-			/*if (conn == NULL)
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "EPB correction capability exceeded\n");
-			return false;*/
-			errflag = true;
-		}
-
-
-		/* advance parity buffer */
-		if ((status >= 0) && (status <= tt))
-			/* copy back corrected parity only if all is OK */
-			memcpy(L2_buf, parityword, P);
-		L2_buf += P;
-
-		/* advance message buffer */
-		if (remaining < k_pre) {
-			if ((status >= 0) && (status <= tt))
-				/* copy back corrected data only if all is OK */
-				memcpy(L1_buf, codeword, remaining);
-			L1_buf += remaining;
-			remaining = 0;
-
-		} else {
-			if ((status >= 0) && (status <= tt))
-				/* copy back corrected data only if all is OK */
-				memcpy(L1_buf, codeword, k_pre);
-			L1_buf += k_pre;
-			remaining -= k_pre;
-
-		}
-	}
-
-	/* print summary */
-	if (!conn) {
-
-		/*if (errnum)
-			opj_event_msg(j2k->cinfo, EVT_INFO, "+ %d symbol errors corrected (Ps=%.1e)\n", errnum,
-				(float) errnum / ((float) n_pre * (float) L1 / (float) k_pre));*/
-		if (errflag) {
-			/*opj_event_msg(j2k->cinfo, EVT_INFO, "+ there were unrecoverable errors\n");*/
-			return false;
-		}
-
-	}
-
-	/* presumably, now, EPB parameters are correct */
-	/* let's get them */
-
-	/* Simply read the EPB parameters */
-	if (conn)
-		cio->bp = buffer;
-	cio_skip(cio, 2); /* the marker */
-	Lepb = cio_read(cio, 2);
-	Depb = cio_read(cio, 1);
-	LDPepb = cio_read(cio, 4);
-	Pepb = cio_read(cio, 4);
-
-	/* What does Pepb tells us about the protection method? */
-	if (((Pepb & 0xF0000000) >> 28) == 0)
-		sprintf(str1, "pred"); /* predefined */
-	else if (((Pepb & 0xF0000000) >> 28) == 1)
-		sprintf(str1, "crc-%lu", 16 * ((Pepb & 0x00000001) + 1)); /* CRC mode */
-	else if (((Pepb & 0xF0000000) >> 28) == 2)
-		sprintf(str1, "rs(%lu,32)", (Pepb & 0x0000FF00) >> 8); /* RS mode */
-	else if (Pepb == 0xFFFFFFFF)
-		sprintf(str1, "nometh"); /* RS mode */
-	else
-		sprintf(str1, "unknown"); /* unknown */
-
-	/* Now we write them to screen */
-	if (!conn && post_len)
-		opj_event_msg(j2k->cinfo, EVT_INFO,
-			"EPB(%d): (%sl, %sp, %u), %lu, %s\n",
-			cio_tell(cio) - 13,
-			(Depb & 0x40) ? "" : "n", /* latest EPB or not? */
-			(Depb & 0x80) ? "" : "n", /* packed or unpacked EPB? */
-			(Depb & 0x3F), /* EPB index value */
-			LDPepb, /*length of the data protected by the EPB */
-			str1); /* protection method */
-
-
-	/* well, we need to investigate how long is the connected length of packed EPBs */
-	myconn = Lepb + 2;
-	if ((Depb & 0x40) == 0) /* not latest in header */
-		jpwl_epb_correct(j2k,      /* J2K decompressor handle */
-					     buffer + Lepb + 2,   /* pointer to next EPB in codestream buffer */
-					     2,     /* EPB type: should be of other type */
-					     0,  /* only EPB fields */
-					     0, /* do not look after */
-						 &myconn,
-						 NULL
-					     );
-	if (conn)
-		*conn += myconn;
-
-	/*if (!conn)
-		printf("connected = %d\n", myconn);*/
-
-	/*cio_seek(j2k->cio, orig_pos);
-	return true;*/
-
-	/* post-data
-	   the position of L4 buffer is at the end of currently connected EPBs
-	*/
-	if (!(L4_bufp))
-		L4_buf = buffer + myconn;
-	else if (!(*L4_bufp))
-		L4_buf = buffer + myconn;
-	else
-		L4_buf = *L4_bufp;
-	if (post_len == -1) 
-		L4 = LDPepb - pre_len - 13;
-	else if (post_len == 0)
-		L4 = 0;
-	else
-		L4 = post_len;
-
-	L3_buf = L2_buf;
-
-	/* Do a further check here on the read parameters */
-	if (L4 > (unsigned long) cio_numbytesleft(j2k->cio))
-		/* overflow */
-		return false;
-
-	/* we are ready for decoding the remaining data */
-	if (((Pepb & 0xF0000000) >> 28) == 1) {
-		/* CRC here */
-		if ((16 * ((Pepb & 0x00000001) + 1)) == 16) {
-
-			/* CRC-16 */
-			unsigned short int mycrc = 0x0000, filecrc = 0x0000;
-
-			/* compute the CRC field */
-			remaining = L4;
-			while (remaining--)
-				jpwl_updateCRC16(&mycrc, *(L4_buf++));
-
-			/* read the CRC field */
-			filecrc = *(L3_buf++) << 8;
-			filecrc |= *(L3_buf++);
-
-			/* check the CRC field */
-			if (mycrc == filecrc) {
-				if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_INFO, "- CRC is OK\n");
-			} else {
-				if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_WARNING, "- CRC is KO (r=%d, c=%d)\n", filecrc, mycrc);
-				errflag = true;
-			}	
-		}
-
-		if ((16 * ((Pepb & 0x00000001) + 1)) == 32) {
-
-			/* CRC-32 */
-			unsigned long int mycrc = 0x00000000, filecrc = 0x00000000;
-
-			/* compute the CRC field */
-			remaining = L4;
-			while (remaining--)
-				jpwl_updateCRC32(&mycrc, *(L4_buf++));
-
-			/* read the CRC field */
-			filecrc = *(L3_buf++) << 24;
-			filecrc |= *(L3_buf++) << 16;
-			filecrc |= *(L3_buf++) << 8;
-			filecrc |= *(L3_buf++);
-
-			/* check the CRC field */
-			if (mycrc == filecrc) {
-				if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_INFO, "- CRC is OK\n");
-			} else {
-				if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_WARNING, "- CRC is KO (r=%d, c=%d)\n", filecrc, mycrc);
-				errflag = true;
-			}
-		}
-
-	} else if (Pepb == 0xFFFFFFFF) {
-		/* no method */
-
-		/* advance without doing anything */
-		remaining = L4;
-		while (remaining--)
-			L4_buf++;
-
-	} else if ((((Pepb & 0xF0000000) >> 28) == 2) || (((Pepb & 0xF0000000) >> 28) == 0)) {
-		/* RS coding here */
-
-		if (((Pepb & 0xF0000000) >> 28) == 0) {
-
-			k_post = k_pre;
-			n_post = n_pre;
-
-		} else {
-
-			k_post = 32;
-			n_post = (Pepb & 0x0000FF00) >> 8;
-		}
-
-		/* Initialize RS structures */
-		P = n_post - k_post;
-		NN_P = NN - P;
-		tt = (int) floor((float) P / 2.0F); /* again, correction capability */
-		memset(codeword, 0, NN);
-		parityword = codeword + NN_P;
-		init_rs(NN_P);
-
-		/* Correct post-data message words */
-		/*L4_buf = buffer + Lepb + 2;*/
-		L3_buf = L2_buf;
-		remaining = L4;
-		while (remaining) {
- 
-			/* always zero-pad codewords */
-			/* (this is required, since after decoding the zeros in the long codeword
-				could change, and keep unchanged in subsequent calls) */
-			memset(codeword, 0, NN);
-
-			/* copy codeword buffer into message bytes */
-			if (remaining < k_post)
-				memcpy(codeword, L4_buf, remaining);
-			else
-				memcpy(codeword, L4_buf, k_post);
-
-			/* copy redundancy buffer in parity bytes */
-			memcpy(parityword, L3_buf, P); 
-
-			/* Decode the buffer and possibly obtain corrected bytes */
-			status = eras_dec_rs(codeword, NULL, 0);
-			if (status == -1) {
-				/*if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_WARNING,
-						"Possible decoding error in codeword @ position #%d\n", (L4_buf - (buffer + Lepb + 2)) / k_post);*/
-				errflag = true;
-
-			} else if (status == 0) {
-				/*if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_INFO, "codeword is correctly decoded\n");*/
-
-			} else if (status <= tt) {
-				/*if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_WARNING, "%d errors corrected in codeword\n", status);*/
-				errnum += status;
-
-			} else {
-				/*if (conn == NULL)
-					opj_event_msg(j2k->cinfo, EVT_WARNING, "EPB correction capability exceeded\n");
-				return false;*/
-				errflag = true;
-			}
-
-
-			/* advance parity buffer */
-			if ((status >= 0) && (status <= tt))
-				/* copy back corrected data only if all is OK */
-				memcpy(L3_buf, parityword, P);
-			L3_buf += P;
-
-			/* advance message buffer */
-			if (remaining < k_post) {
-				if ((status >= 0) && (status <= tt))
-					/* copy back corrected data only if all is OK */
-					memcpy(L4_buf, codeword, remaining);
-				L4_buf += remaining;
-				remaining = 0;
-
-			} else {
-				if ((status >= 0) && (status <= tt))
-					/* copy back corrected data only if all is OK */
-					memcpy(L4_buf, codeword, k_post);
-				L4_buf += k_post;
-				remaining -= k_post;
-
-			}
-		}
-	}
-
-	/* give back the L4_buf address */
-	if (L4_bufp)
-		*L4_bufp = L4_buf;
-
-	/* print summary */
-	if (!conn) {
-
-		if (errnum)
-			opj_event_msg(j2k->cinfo, EVT_INFO, "- %d symbol errors corrected (Ps=%.1e)\n", errnum,
-				(float) errnum / (float) LDPepb);
-		if (errflag)
-			opj_event_msg(j2k->cinfo, EVT_INFO, "- there were unrecoverable errors\n");
-
-	}
-
-	cio_seek(j2k->cio, orig_pos);
-
-	return true;
-}
-
-void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf) {
-
-	/* Marker */
-	*(buf++) = (unsigned char) (J2K_MS_EPC >> 8); 
-	*(buf++) = (unsigned char) (J2K_MS_EPC >> 0); 
-
-	/* Lepc */
-	*(buf++) = (unsigned char) (epc->Lepc >> 8); 
-	*(buf++) = (unsigned char) (epc->Lepc >> 0); 
-
-	/* Pcrc */
-	*(buf++) = (unsigned char) (epc->Pcrc >> 8); 
-	*(buf++) = (unsigned char) (epc->Pcrc >> 0);
-
-	/* DL */
-	*(buf++) = (unsigned char) (epc->DL >> 24); 
-	*(buf++) = (unsigned char) (epc->DL >> 16); 
-	*(buf++) = (unsigned char) (epc->DL >> 8); 
-	*(buf++) = (unsigned char) (epc->DL >> 0); 
-
-	/* Pepc */
-	*(buf++) = (unsigned char) (epc->Pepc >> 0); 
-
-	/* Data */
-	/*memcpy(buf, epc->data, (size_t) epc->Lepc - 9);*/
-	memset(buf, 0, (size_t) epc->Lepc - 9);
-
-	/* update markers struct */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, -1, epc->Lepc + 2);
-
-};
-
-int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-				  int comps, unsigned char addrm, unsigned char ad_size,
-				  unsigned char senst, unsigned char se_size,
-				  double place_pos, int tileno) {
-
-	return 0;
-}
-
-jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, unsigned char ad_size,
-								unsigned char senst, unsigned char se_size, int tileno,
-								unsigned long int svalnum, void *sensval) {
-
-	jpwl_esd_ms_t *esd = NULL;
-
-	/* Alloc space */
-	if (!(esd = (jpwl_esd_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_esd_ms_t)))) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for ESD MS\n");
-		return NULL;
-	};
-
-	/* if relative sensitivity, activate byte range mode */
-	if (senst == 0)
-		addrm = 1;
-
-	/* size of sensval's ... */
-	if ((ad_size != 0) && (ad_size != 2) && (ad_size != 4)) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Address size %d for ESD MS is forbidden\n", ad_size);
-		return NULL;
-	}
-	if ((se_size != 1) && (se_size != 2)) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Sensitivity size %d for ESD MS is forbidden\n", se_size);
-		return NULL;
-	}
-	
-	/* ... depends on the addressing mode */
-	switch (addrm) {
-
-	/* packet mode */
-	case (0):
-		ad_size = 0; /* as per the standard */
-		esd->sensval_size = se_size; 
-		break;
-
-	/* byte range */
-	case (1):
-		/* auto sense address size */
-		if (ad_size == 0)
-			/* if there are more than 66% of (2^16 - 1) bytes, switch to 4 bytes
-			 (we keep space for possible EPBs being inserted) */
-			ad_size = (j2k->cstr_info->codestream_size > (1 * 65535 / 3)) ? 4 : 2;
-		esd->sensval_size = ad_size + ad_size + se_size; 
-		break;
-
-	/* packet range */
-	case (2):
-		/* auto sense address size */
-		if (ad_size == 0)
-			/* if there are more than 2^16 - 1 packets, switch to 4 bytes */
-			ad_size = (j2k->cstr_info->packno > 65535) ? 4 : 2;
-		esd->sensval_size = ad_size + ad_size + se_size; 
-		break;
-
-	case (3):
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Address mode %d for ESD MS is unimplemented\n", addrm);
-		return NULL;
-
-	default:
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Address mode %d for ESD MS is forbidden\n", addrm);
-		return NULL;
-	}
-
-	/* set or unset sensitivity values */
-	if (svalnum <= 0) {
-
-		switch (senst) {
-
-		/* just based on the portions of a codestream */
-		case (0):
-			/* MH + no. of THs + no. of packets */
-			svalnum = 1 + (j2k->cstr_info->tw * j2k->cstr_info->th) * (1 + j2k->cstr_info->packno);
-			break;
-
-		/* all the ones that are based on the packets */
-		default:
-			if (tileno < 0)
-				/* MH: all the packets and all the tiles info is written */
-				svalnum = j2k->cstr_info->tw * j2k->cstr_info->th * j2k->cstr_info->packno;
-			else
-				/* TPH: only that tile info is written */
-				svalnum = j2k->cstr_info->packno;
-			break;
-
-		}
-	}		
-
-	/* fill private fields */
-	esd->senst = senst;
-	esd->ad_size = ad_size;
-	esd->se_size = se_size;
-	esd->addrm = addrm;
-	esd->svalnum = svalnum;
-	esd->numcomps = j2k->image->numcomps;
-	esd->tileno = tileno;
-	
-	/* Set the ESD parameters */
-	/* length, excluding data field */
-	if (esd->numcomps < 257)
-		esd->Lesd = 4 + (unsigned short int) (esd->svalnum * esd->sensval_size);
-	else
-		esd->Lesd = 5 + (unsigned short int) (esd->svalnum * esd->sensval_size);
-
-	/* component data field */
-	if (comp >= 0)
-		esd->Cesd = comp;
-	else
-		/* we are averaging */
-		esd->Cesd = 0;
-
-	/* Pesd field */
-	esd->Pesd = 0x00;
-	esd->Pesd |= (esd->addrm & 0x03) << 6; /* addressing mode */
-	esd->Pesd |= (esd->senst & 0x07) << 3; /* sensitivity type */
-	esd->Pesd |= ((esd->se_size >> 1) & 0x01) << 2; /* sensitivity size */
-	esd->Pesd |= ((esd->ad_size >> 2) & 0x01) << 1; /* addressing size */
-	esd->Pesd |= (comp < 0) ? 0x01 : 0x00; /* averaging components */
-
-	/* if pointer to sensval is NULL, we can fill data field by ourselves */
-	if (!sensval) {
-
-		/* old code moved to jpwl_esd_fill() */
-		esd->data = NULL;
-
-	} else {
-			/* we set the data field as the sensitivity values poinnter passed to the function */
-			esd->data = (unsigned char *) sensval;
-	}
-
-	return (esd);
-}
-
-bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
-
-	int i;
-	unsigned long int vv;
-	unsigned long int addr1 = 0L, addr2 = 0L;
-	double dvalue = 0.0, Omax2, tmp, TSE = 0.0, MSE, oldMSE = 0.0, PSNR, oldPSNR = 0.0;
-	unsigned short int pfpvalue;
-	unsigned long int addrmask = 0x00000000;
-	bool doneMH = false, doneTPH = false;
-
-	/* sensitivity values in image info are as follows:
-		- for each tile, distotile is the starting distortion for that tile, sum of all components
-		- for each packet in a tile, disto is the distortion reduction caused by that packet to that tile
-		- the TSE for a single tile should be given by   distotile - sum(disto)  , for all components
-		- the MSE for a single tile is given by     TSE / nbpix    , for all components
-		- the PSNR for a single tile is given by   10*log10( Omax^2 / MSE)    , for all components
-		  (Omax is given by    2^bpp - 1    for unsigned images and by    2^(bpp - 1) - 1    for signed images
-	*/
-
-	/* browse all components and find Omax */
-	Omax2 = 0.0;
-	for (i = 0; i < j2k->image->numcomps; i++) {
-		tmp = pow(2.0, (double) (j2k->image->comps[i].sgnd ?
-			(j2k->image->comps[i].bpp - 1) : (j2k->image->comps[i].bpp))) - 1;
-		if (tmp > Omax2)
-			Omax2 = tmp;
-	}
-	Omax2 = Omax2 * Omax2;
-
-	/* if pointer of esd->data is not null, simply write down all the values byte by byte */
-	if (esd->data) {
-		for (i = 0; i < (int) esd->svalnum; i++)
-			*(buf++) = esd->data[i]; 
-		return true;
-	}
-
-	/* addressing mask */
-	if (esd->ad_size == 2)
-		addrmask = 0x0000FFFF; /* two bytes */
-	else
-		addrmask = 0xFFFFFFFF; /* four bytes */
-
-	/* set on precise point where sensitivity starts */
-	if (esd->numcomps < 257)
-		buf += 6;
-	else
-		buf += 7;
-
-	/* let's fill the data fields */
-	for (vv = (esd->tileno < 0) ? 0 : (j2k->cstr_info->packno * esd->tileno); vv < esd->svalnum; vv++) {
-
-		int thistile = vv / j2k->cstr_info->packno, thispacket = vv % j2k->cstr_info->packno;
-
-		/* skip for the hack some lines below */
-		if (thistile == j2k->cstr_info->tw * j2k->cstr_info->th)
-			break;
-
-		/* starting tile distortion */
-		if (thispacket == 0) {
-			TSE = j2k->cstr_info->tile[thistile].distotile;
-			oldMSE = TSE / j2k->cstr_info->tile[thistile].numpix;
-			oldPSNR = 10.0 * log10(Omax2 / oldMSE);
-		}
-
-		/* TSE */
-		TSE -= j2k->cstr_info->tile[thistile].packet[thispacket].disto;
-
-		/* MSE */
-		MSE = TSE / j2k->cstr_info->tile[thistile].numpix;
-
-		/* PSNR */
-		PSNR = 10.0 * log10(Omax2 / MSE);
-
-		/* fill the address range */
-		switch (esd->addrm) {
-
-		/* packet mode */
-		case (0):
-			/* nothing, there is none */
-			break;
-
-		/* byte range */
-		case (1):
-			/* start address of packet */
-			addr1 = (j2k->cstr_info->tile[thistile].packet[thispacket].start_pos) & addrmask;
-			/* end address of packet */
-			addr2 = (j2k->cstr_info->tile[thistile].packet[thispacket].end_pos) & addrmask;
-			break;
-
-		/* packet range */
-		case (2):
-			/* not implemented here */
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "Addressing mode packet_range is not implemented\n");
-			break;
-
-		/* unknown addressing method */
-		default:
-			/* not implemented here */
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "Unknown addressing mode\n");
-			break;
-
-		}
-
-		/* hack for writing relative sensitivity of MH and TPHs */
-		if ((esd->senst == 0) && (thispacket == 0)) {
-
-			/* possible MH */
-			if ((thistile == 0) && !doneMH) {
-				/* we have to manage MH addresses */
-				addr1 = 0; /* start of MH */
-				addr2 = j2k->cstr_info->main_head_end; /* end of MH */
-				/* set special dvalue for this MH */
-				dvalue = -10.0;
-				doneMH = true; /* don't come here anymore */
-				vv--; /* wrap back loop counter */
-
-			} else if (!doneTPH) {
-				/* we have to manage TPH addresses */
-				addr1 = j2k->cstr_info->tile[thistile].start_pos;
-				addr2 = j2k->cstr_info->tile[thistile].end_header;
-				/* set special dvalue for this TPH */
-				dvalue = -1.0;
-				doneTPH = true; /* don't come here till the next tile */
-				vv--; /* wrap back loop counter */
-			}
-
-		} else
-			doneTPH = false; /* reset TPH counter */
-
-		/* write the addresses to the buffer */
-		switch (esd->ad_size) {
-
-		case (0):
-			/* do nothing */
-			break;
-
-		case (2):
-			/* two bytes */
-			*(buf++) = (unsigned char) (addr1 >> 8); 
-			*(buf++) = (unsigned char) (addr1 >> 0); 
-			*(buf++) = (unsigned char) (addr2 >> 8); 
-			*(buf++) = (unsigned char) (addr2 >> 0); 
-			break;
-
-		case (4):
-			/* four bytes */
-			*(buf++) = (unsigned char) (addr1 >> 24); 
-			*(buf++) = (unsigned char) (addr1 >> 16); 
-			*(buf++) = (unsigned char) (addr1 >> 8); 
-			*(buf++) = (unsigned char) (addr1 >> 0); 
-			*(buf++) = (unsigned char) (addr2 >> 24); 
-			*(buf++) = (unsigned char) (addr2 >> 16); 
-			*(buf++) = (unsigned char) (addr2 >> 8); 
-			*(buf++) = (unsigned char) (addr2 >> 0); 
-			break;
-
-		default:
-			/* do nothing */
-			break;
-		}
-
-
-		/* let's fill the value field */
-		switch (esd->senst) {
-
-		/* relative sensitivity */
-		case (0):
-			/* we just write down the packet ordering */
-			if (dvalue == -10)
-				/* MH */
-				dvalue = MAX_V1 + 1000.0; /* this will cause pfpvalue set to 0xFFFF */
-			else if (dvalue == -1)
-				/* TPH */
-				dvalue = MAX_V1 + 1000.0; /* this will cause pfpvalue set to 0xFFFF */
-			else
-				/* packet: first is most important, and then in decreasing order
-				down to the last, which counts for 1 */
-				dvalue = jpwl_pfp_to_double((unsigned short) (j2k->cstr_info->packno - thispacket), esd->se_size);
-			break;
-
-		/* MSE */
-		case (1):
-			/* !!! WRONG: let's put here disto field of packets !!! */
-			dvalue = MSE;
-			break;
-
-		/* MSE reduction */
-		case (2):
-			dvalue = oldMSE - MSE;
-			oldMSE = MSE;
-			break;
-
-		/* PSNR */
-		case (3):
-			dvalue = PSNR;
-			break;
-
-		/* PSNR increase */
-		case (4):
-			dvalue = PSNR - oldPSNR;
-			oldPSNR = PSNR;
-			break;
-
-		/* MAXERR */
-		case (5):
-			dvalue = 0.0;
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "MAXERR sensitivity mode is not implemented\n");
-			break;
-
-		/* TSE */
-		case (6):
-			dvalue = TSE;
-			break;
-
-		/* reserved */
-		case (7):
-			dvalue = 0.0;
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "Reserved sensitivity mode is not implemented\n");
-			break;
-
-		default:
-			dvalue = 0.0;
-			break;
-		}
-
-		/* compute the pseudo-floating point value */
-		pfpvalue = jpwl_double_to_pfp(dvalue, esd->se_size);
-
-		/* write the pfp value to the buffer */
-		switch (esd->se_size) {
-
-		case (1):
-			/* one byte */
-			*(buf++) = (unsigned char) (pfpvalue >> 0); 
-			break;
-
-		case (2):
-			/* two bytes */
-			*(buf++) = (unsigned char) (pfpvalue >> 8); 
-			*(buf++) = (unsigned char) (pfpvalue >> 0); 
-			break;
-		}
-
-	}
-
-	return true;
-}
-
-void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
-
-	/* Marker */
-	*(buf++) = (unsigned char) (J2K_MS_ESD >> 8); 
-	*(buf++) = (unsigned char) (J2K_MS_ESD >> 0); 
-
-	/* Lesd */
-	*(buf++) = (unsigned char) (esd->Lesd >> 8); 
-	*(buf++) = (unsigned char) (esd->Lesd >> 0); 
-
-	/* Cesd */
-	if (esd->numcomps >= 257)
-		*(buf++) = (unsigned char) (esd->Cesd >> 8); 
-	*(buf++) = (unsigned char) (esd->Cesd >> 0); 
-
-	/* Pesd */
-	*(buf++) = (unsigned char) (esd->Pesd >> 0); 
-
-	/* Data */
-	if (esd->numcomps < 257)
-		memset(buf, 0xAA, (size_t) esd->Lesd - 4);
-		/*memcpy(buf, esd->data, (size_t) esd->Lesd - 4);*/
-	else
-		memset(buf, 0xAA, (size_t) esd->Lesd - 5);
-		/*memcpy(buf, esd->data, (size_t) esd->Lesd - 5);*/
-
-	/* update markers struct */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_ESD, -1, esd->Lesd + 2);
-
-}
-
-unsigned short int jpwl_double_to_pfp(double V, int bytes) {
-
-	unsigned short int em, e, m;
-
-	switch (bytes) {
-
-	case (1):
-
-		if (V < MIN_V1) {
-			e = 0x0000;
-			m = 0x0000;
-		} else if (V > MAX_V1) {
-			e = 0x000F;
-			m = 0x000F;
-		} else {
-			e = (unsigned short int) (floor(log(V) * 1.44269504088896) / 4.0);
-			m = (unsigned short int) (0.5 + (V / (pow(2.0, (double) (4 * e)))));
-		}
-		em = ((e & 0x000F) << 4) + (m & 0x000F);		
-		break;
-
-	case (2):
-
-		if (V < MIN_V2) {
-			e = 0x0000;
-			m = 0x0000;
-		} else if (V > MAX_V2) {
-			e = 0x001F;
-			m = 0x07FF;
-		} else {
-			e = (unsigned short int) floor(log(V) * 1.44269504088896) + 15;
-			m = (unsigned short int) (0.5 + 2048.0 * ((V / (pow(2.0, (double) e - 15.0))) - 1.0));
-		}
-		em = ((e & 0x001F) << 11) + (m & 0x07FF);
-		break;
-
-	default:
-
-		em = 0x0000;
-		break;
-	};
-
-	return em;
-}
-
-double jpwl_pfp_to_double(unsigned short int em, int bytes) {
-
-	double V;
-
-	switch (bytes) {
-
-	case 1:
-		V = (double) (em & 0x0F) * pow(2.0, (double) (em & 0xF0));
-		break;
-
-	case 2:
-
-		V = pow(2.0, (double) ((em & 0xF800) >> 11) - 15.0) * (1.0 + (double) (em & 0x07FF) / 2048.0);
-		break;
-
-	default:
-		V = 0.0;
-		break;
-
-	}
-
-	return V;
-
-}
-
-bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num) {
-
-	int mm;
-	unsigned long int addlen;
-
-	opj_codestream_info_t *info = j2k->cstr_info;
-	int tileno, tpno, packno, numtiles = info->th * info->tw, numpacks = info->packno;
-
-	if (!j2k || !jwmarker ) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "J2K handle or JPWL markers list badly allocated\n");
-		return false;
-	}
-
-	/* main_head_end: how many markers are there before? */
-	addlen = 0;
-	for (mm = 0; mm < jwmarker_num; mm++)
-		if (jwmarker[mm].pos < (unsigned long int) info->main_head_end)
-			addlen += jwmarker[mm].len + 2;
-	info->main_head_end += addlen;
-
-	/* codestream_size: always increment with all markers */
-	addlen = 0;
-	for (mm = 0; mm < jwmarker_num; mm++)
-		addlen += jwmarker[mm].len + 2;
-	info->codestream_size += addlen;
-
-	/* navigate through all the tiles */
-	for (tileno = 0; tileno < numtiles; tileno++) {
-
-		/* start_pos: increment with markers before SOT */
-		addlen = 0;
-		for (mm = 0; mm < jwmarker_num; mm++)
-			if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].start_pos)
-				addlen += jwmarker[mm].len + 2;
-		info->tile[tileno].start_pos += addlen;
-
-		/* end_header: increment with markers before of it */
-		addlen = 0;
-		for (mm = 0; mm < jwmarker_num; mm++)
-			if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].end_header)
-				addlen += jwmarker[mm].len + 2;
-		info->tile[tileno].end_header += addlen;
-
-		/* end_pos: increment with markers before the end of this tile */
-		/* code is disabled, since according to JPWL no markers can be beyond TPH */
-		addlen = 0;
-		for (mm = 0; mm < jwmarker_num; mm++)
-			if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].end_pos)
-				addlen += jwmarker[mm].len + 2;
-		info->tile[tileno].end_pos += addlen;
-
-		/* navigate through all the tile parts */
-		for (tpno = 0; tpno < info->tile[tileno].num_tps; tpno++) {
-
-			/* start_pos: increment with markers before SOT */
-			addlen = 0;
-			for (mm = 0; mm < jwmarker_num; mm++)
-				if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_start_pos)
-					addlen += jwmarker[mm].len + 2;
-			info->tile[tileno].tp[tpno].tp_start_pos += addlen;
-
-			/* end_header: increment with markers before of it */
-			addlen = 0;
-			for (mm = 0; mm < jwmarker_num; mm++)
-				if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_end_header)
-					addlen += jwmarker[mm].len + 2;
-			info->tile[tileno].tp[tpno].tp_end_header += addlen;
-
-			/* end_pos: increment with markers before the end of this tile part */
-			addlen = 0;
-			for (mm = 0; mm < jwmarker_num; mm++)
-				if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_end_pos)
-					addlen += jwmarker[mm].len + 2;
-			info->tile[tileno].tp[tpno].tp_end_pos += addlen;
-
-		}
-
-		/* navigate through all the packets in this tile */
-		for (packno = 0; packno < numpacks; packno++) {
-			
-			/* start_pos: increment with markers before the packet */
-			/* disabled for the same reason as before */
-			addlen = 0;
-			for (mm = 0; mm < jwmarker_num; mm++)
-				if (jwmarker[mm].pos <= (unsigned long int) info->tile[tileno].packet[packno].start_pos)
-					addlen += jwmarker[mm].len + 2;
-			info->tile[tileno].packet[packno].start_pos += addlen;
-
-			/* end_ph_pos: increment with markers before the packet */
-			/* disabled for the same reason as before */
-			/*addlen = 0;
-			for (mm = 0; mm < jwmarker_num; mm++)
-				if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].end_ph_pos)
-					addlen += jwmarker[mm].len + 2;*/
-			info->tile[tileno].packet[packno].end_ph_pos += addlen;
-
-			/* end_pos: increment if marker is before the end of packet */
-			/* disabled for the same reason as before */
-			/*addlen = 0;
-			for (mm = 0; mm < jwmarker_num; mm++)
-				if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].end_pos)
-					addlen += jwmarker[mm].len + 2;*/
-			info->tile[tileno].packet[packno].end_pos += addlen;
-
-		}
-	}
-
-	/* reorder the markers list */
-
-	return true;
-}
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/rs.c b/Utilities/gdcmopenjpeg-v1/jpwl/rs.c
deleted file mode 100644
index 419f083..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/rs.c
+++ /dev/null
@@ -1,594 +0,0 @@
- /*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-/**
- at file rs.c
- at brief Functions used to compute the Reed-Solomon parity and check of byte arrays
-
-*/
-
-/**
- * Reed-Solomon coding and decoding
- * Phil Karn (karn at ka9q.ampr.org) September 1996
- * 
- * This file is derived from the program "new_rs_erasures.c" by Robert
- * Morelos-Zaragoza (robert at spectra.eng.hawaii.edu) and Hari Thirumoorthy
- * (harit at spectra.eng.hawaii.edu), Aug 1995
- *
- * I've made changes to improve performance, clean up the code and make it
- * easier to follow. Data is now passed to the encoding and decoding functions
- * through arguments rather than in global arrays. The decode function returns
- * the number of corrected symbols, or -1 if the word is uncorrectable.
- *
- * This code supports a symbol size from 2 bits up to 16 bits,
- * implying a block size of 3 2-bit symbols (6 bits) up to 65535
- * 16-bit symbols (1,048,560 bits). The code parameters are set in rs.h.
- *
- * Note that if symbols larger than 8 bits are used, the type of each
- * data array element switches from unsigned char to unsigned int. The
- * caller must ensure that elements larger than the symbol range are
- * not passed to the encoder or decoder.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include "rs.h"
-
-/* This defines the type used to store an element of the Galois Field
- * used by the code. Make sure this is something larger than a char if
- * if anything larger than GF(256) is used.
- *
- * Note: unsigned char will work up to GF(256) but int seems to run
- * faster on the Pentium.
- */
-typedef int gf;
-
-/* Primitive polynomials - see Lin & Costello, Appendix A,
- * and  Lee & Messerschmitt, p. 453.
- */
-#if(MM == 2)/* Admittedly silly */
-int Pp[MM+1] = { 1, 1, 1 };
-
-#elif(MM == 3)
-/* 1 + x + x^3 */
-int Pp[MM+1] = { 1, 1, 0, 1 };
-
-#elif(MM == 4)
-/* 1 + x + x^4 */
-int Pp[MM+1] = { 1, 1, 0, 0, 1 };
-
-#elif(MM == 5)
-/* 1 + x^2 + x^5 */
-int Pp[MM+1] = { 1, 0, 1, 0, 0, 1 };
-
-#elif(MM == 6)
-/* 1 + x + x^6 */
-int Pp[MM+1] = { 1, 1, 0, 0, 0, 0, 1 };
-
-#elif(MM == 7)
-/* 1 + x^3 + x^7 */
-int Pp[MM+1] = { 1, 0, 0, 1, 0, 0, 0, 1 };
-
-#elif(MM == 8)
-/* 1+x^2+x^3+x^4+x^8 */
-int Pp[MM+1] = { 1, 0, 1, 1, 1, 0, 0, 0, 1 };
-
-#elif(MM == 9)
-/* 1+x^4+x^9 */
-int Pp[MM+1] = { 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
-
-#elif(MM == 10)
-/* 1+x^3+x^10 */
-int Pp[MM+1] = { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 11)
-/* 1+x^2+x^11 */
-int Pp[MM+1] = { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 12)
-/* 1+x+x^4+x^6+x^12 */
-int Pp[MM+1] = { 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 13)
-/* 1+x+x^3+x^4+x^13 */
-int Pp[MM+1] = { 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 14)
-/* 1+x+x^6+x^10+x^14 */
-int Pp[MM+1] = { 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 };
-
-#elif(MM == 15)
-/* 1+x+x^15 */
-int Pp[MM+1] = { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 16)
-/* 1+x+x^3+x^12+x^16 */
-int Pp[MM+1] = { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 };
-
-#else
-#error "MM must be in range 2-16"
-#endif
-
-/* Alpha exponent for the first root of the generator polynomial */
-#define B0	0  /* Different from the default 1 */
-
-/* index->polynomial form conversion table */
-gf Alpha_to[NN + 1];
-
-/* Polynomial->index form conversion table */
-gf Index_of[NN + 1];
-
-/* No legal value in index form represents zero, so
- * we need a special value for this purpose
- */
-#define A0	(NN)
-
-/* Generator polynomial g(x)
- * Degree of g(x) = 2*TT
- * has roots @**B0, @**(B0+1), ... ,@^(B0+2*TT-1)
- */
-/*gf Gg[NN - KK + 1];*/
-gf		Gg[NN - 1];
-
-/* Compute x % NN, where NN is 2**MM - 1,
- * without a slow divide
- */
-static /*inline*/ gf
-modnn(int x)
-{
-	while (x >= NN) {
-		x -= NN;
-		x = (x >> MM) + (x & NN);
-	}
-	return x;
-}
-
-/*#define	min(a,b)	((a) < (b) ? (a) : (b))*/
-
-#define	CLEAR(a,n) {\
-	int ci;\
-	for(ci=(n)-1;ci >=0;ci--)\
-		(a)[ci] = 0;\
-	}
-
-#define	COPY(a,b,n) {\
-	int ci;\
-	for(ci=(n)-1;ci >=0;ci--)\
-		(a)[ci] = (b)[ci];\
-	}
-#define	COPYDOWN(a,b,n) {\
-	int ci;\
-	for(ci=(n)-1;ci >=0;ci--)\
-		(a)[ci] = (b)[ci];\
-	}
-
-void init_rs(int k)
-{
-	KK = k;
-	if (KK >= NN) {
-		printf("KK must be less than 2**MM - 1\n");
-		exit(1);
-	}
-	
-	generate_gf();
-	gen_poly();
-}
-
-/* generate GF(2**m) from the irreducible polynomial p(X) in p[0]..p[m]
-   lookup tables:  index->polynomial form   alpha_to[] contains j=alpha**i;
-                   polynomial form -> index form  index_of[j=alpha**i] = i
-   alpha=2 is the primitive element of GF(2**m)
-   HARI's COMMENT: (4/13/94) alpha_to[] can be used as follows:
-        Let @ represent the primitive element commonly called "alpha" that
-   is the root of the primitive polynomial p(x). Then in GF(2^m), for any
-   0 <= i <= 2^m-2,
-        @^i = a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
-   where the binary vector (a(0),a(1),a(2),...,a(m-1)) is the representation
-   of the integer "alpha_to[i]" with a(0) being the LSB and a(m-1) the MSB. Thus for
-   example the polynomial representation of @^5 would be given by the binary
-   representation of the integer "alpha_to[5]".
-                   Similarily, index_of[] can be used as follows:
-        As above, let @ represent the primitive element of GF(2^m) that is
-   the root of the primitive polynomial p(x). In order to find the power
-   of @ (alpha) that has the polynomial representation
-        a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
-   we consider the integer "i" whose binary representation with a(0) being LSB
-   and a(m-1) MSB is (a(0),a(1),...,a(m-1)) and locate the entry
-   "index_of[i]". Now, @^index_of[i] is that element whose polynomial 
-    representation is (a(0),a(1),a(2),...,a(m-1)).
-   NOTE:
-        The element alpha_to[2^m-1] = 0 always signifying that the
-   representation of "@^infinity" = 0 is (0,0,0,...,0).
-        Similarily, the element index_of[0] = A0 always signifying
-   that the power of alpha which has the polynomial representation
-   (0,0,...,0) is "infinity".
- 
-*/
-
-void
-generate_gf(void)
-{
-	register int i, mask;
-
-	mask = 1;
-	Alpha_to[MM] = 0;
-	for (i = 0; i < MM; i++) {
-		Alpha_to[i] = mask;
-		Index_of[Alpha_to[i]] = i;
-		/* If Pp[i] == 1 then, term @^i occurs in poly-repr of @^MM */
-		if (Pp[i] != 0)
-			Alpha_to[MM] ^= mask;	/* Bit-wise EXOR operation */
-		mask <<= 1;	/* single left-shift */
-	}
-	Index_of[Alpha_to[MM]] = MM;
-	/*
-	 * Have obtained poly-repr of @^MM. Poly-repr of @^(i+1) is given by
-	 * poly-repr of @^i shifted left one-bit and accounting for any @^MM
-	 * term that may occur when poly-repr of @^i is shifted.
-	 */
-	mask >>= 1;
-	for (i = MM + 1; i < NN; i++) {
-		if (Alpha_to[i - 1] >= mask)
-			Alpha_to[i] = Alpha_to[MM] ^ ((Alpha_to[i - 1] ^ mask) << 1);
-		else
-			Alpha_to[i] = Alpha_to[i - 1] << 1;
-		Index_of[Alpha_to[i]] = i;
-	}
-	Index_of[0] = A0;
-	Alpha_to[NN] = 0;
-}
-
-
-/*
- * Obtain the generator polynomial of the TT-error correcting, length
- * NN=(2**MM -1) Reed Solomon code from the product of (X+@**(B0+i)), i = 0,
- * ... ,(2*TT-1)
- *
- * Examples:
- *
- * If B0 = 1, TT = 1. deg(g(x)) = 2*TT = 2.
- * g(x) = (x+@) (x+@**2)
- *
- * If B0 = 0, TT = 2. deg(g(x)) = 2*TT = 4.
- * g(x) = (x+1) (x+@) (x+@**2) (x+@**3)
- */
-void
-gen_poly(void)
-{
-	register int i, j;
-
-	Gg[0] = Alpha_to[B0];
-	Gg[1] = 1;		/* g(x) = (X+@**B0) initially */
-	for (i = 2; i <= NN - KK; i++) {
-		Gg[i] = 1;
-		/*
-		 * Below multiply (Gg[0]+Gg[1]*x + ... +Gg[i]x^i) by
-		 * (@**(B0+i-1) + x)
-		 */
-		for (j = i - 1; j > 0; j--)
-			if (Gg[j] != 0)
-				Gg[j] = Gg[j - 1] ^ Alpha_to[modnn((Index_of[Gg[j]]) + B0 + i - 1)];
-			else
-				Gg[j] = Gg[j - 1];
-		/* Gg[0] can never be zero */
-		Gg[0] = Alpha_to[modnn((Index_of[Gg[0]]) + B0 + i - 1)];
-	}
-	/* convert Gg[] to index form for quicker encoding */
-	for (i = 0; i <= NN - KK; i++)
-		Gg[i] = Index_of[Gg[i]];
-}
-
-
-/*
- * take the string of symbols in data[i], i=0..(k-1) and encode
- * systematically to produce NN-KK parity symbols in bb[0]..bb[NN-KK-1] data[]
- * is input and bb[] is output in polynomial form. Encoding is done by using
- * a feedback shift register with appropriate connections specified by the
- * elements of Gg[], which was generated above. Codeword is   c(X) =
- * data(X)*X**(NN-KK)+ b(X)
- */
-int
-encode_rs(dtype *data, dtype *bb)
-{
-	register int i, j;
-	gf feedback;
-
-	CLEAR(bb,NN-KK);
-	for (i = KK - 1; i >= 0; i--) {
-#if (MM != 8)
-		if(data[i] > NN)
-			return -1;	/* Illegal symbol */
-#endif
-		feedback = Index_of[data[i] ^ bb[NN - KK - 1]];
-		if (feedback != A0) {	/* feedback term is non-zero */
-			for (j = NN - KK - 1; j > 0; j--)
-				if (Gg[j] != A0)
-					bb[j] = bb[j - 1] ^ Alpha_to[modnn(Gg[j] + feedback)];
-				else
-					bb[j] = bb[j - 1];
-			bb[0] = Alpha_to[modnn(Gg[0] + feedback)];
-		} else {	/* feedback term is zero. encoder becomes a
-				 * single-byte shifter */
-			for (j = NN - KK - 1; j > 0; j--)
-				bb[j] = bb[j - 1];
-			bb[0] = 0;
-		}
-	}
-	return 0;
-}
-
-/*
- * Performs ERRORS+ERASURES decoding of RS codes. If decoding is successful,
- * writes the codeword into data[] itself. Otherwise data[] is unaltered.
- *
- * Return number of symbols corrected, or -1 if codeword is illegal
- * or uncorrectable.
- * 
- * First "no_eras" erasures are declared by the calling program. Then, the
- * maximum # of errors correctable is t_after_eras = floor((NN-KK-no_eras)/2).
- * If the number of channel errors is not greater than "t_after_eras" the
- * transmitted codeword will be recovered. Details of algorithm can be found
- * in R. Blahut's "Theory ... of Error-Correcting Codes".
- */
-int
-eras_dec_rs(dtype *data, int *eras_pos, int no_eras)
-{
-	int deg_lambda, el, deg_omega;
-	int i, j, r;
-	gf u,q,tmp,num1,num2,den,discr_r;
-	gf recd[NN];
-	/* Err+Eras Locator poly and syndrome poly */
-	/*gf lambda[NN-KK + 1], s[NN-KK + 1];	
-	gf b[NN-KK + 1], t[NN-KK + 1], omega[NN-KK + 1];
-	gf root[NN-KK], reg[NN-KK + 1], loc[NN-KK];*/
-	gf lambda[NN + 1], s[NN + 1];	
-	gf b[NN + 1], t[NN + 1], omega[NN + 1];
-	gf root[NN], reg[NN + 1], loc[NN];
-	int syn_error, count;
-
-	/* data[] is in polynomial form, copy and convert to index form */
-	for (i = NN-1; i >= 0; i--){
-#if (MM != 8)
-		if(data[i] > NN)
-			return -1;	/* Illegal symbol */
-#endif
-		recd[i] = Index_of[data[i]];
-	}
-	/* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
-	 * namely @**(B0+i), i = 0, ... ,(NN-KK-1)
-	 */
-	syn_error = 0;
-	for (i = 1; i <= NN-KK; i++) {
-		tmp = 0;
-		for (j = 0; j < NN; j++)
-			if (recd[j] != A0)	/* recd[j] in index form */
-				tmp ^= Alpha_to[modnn(recd[j] + (B0+i-1)*j)];
-		syn_error |= tmp;	/* set flag if non-zero syndrome =>
-					 * error */
-		/* store syndrome in index form  */
-		s[i] = Index_of[tmp];
-	}
-	if (!syn_error) {
-		/*
-		 * if syndrome is zero, data[] is a codeword and there are no
-		 * errors to correct. So return data[] unmodified
-		 */
-		return 0;
-	}
-	CLEAR(&lambda[1],NN-KK);
-	lambda[0] = 1;
-	if (no_eras > 0) {
-		/* Init lambda to be the erasure locator polynomial */
-		lambda[1] = Alpha_to[eras_pos[0]];
-		for (i = 1; i < no_eras; i++) {
-			u = eras_pos[i];
-			for (j = i+1; j > 0; j--) {
-				tmp = Index_of[lambda[j - 1]];
-				if(tmp != A0)
-					lambda[j] ^= Alpha_to[modnn(u + tmp)];
-			}
-		}
-#ifdef ERASURE_DEBUG
-		/* find roots of the erasure location polynomial */
-		for(i=1;i<=no_eras;i++)
-			reg[i] = Index_of[lambda[i]];
-		count = 0;
-		for (i = 1; i <= NN; i++) {
-			q = 1;
-			for (j = 1; j <= no_eras; j++)
-				if (reg[j] != A0) {
-					reg[j] = modnn(reg[j] + j);
-					q ^= Alpha_to[reg[j]];
-				}
-			if (!q) {
-				/* store root and error location
-				 * number indices
-				 */
-				root[count] = i;
-				loc[count] = NN - i;
-				count++;
-			}
-		}
-		if (count != no_eras) {
-			printf("\n lambda(x) is WRONG\n");
-			return -1;
-		}
-#ifndef NO_PRINT
-		printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n");
-		for (i = 0; i < count; i++)
-			printf("%d ", loc[i]);
-		printf("\n");
-#endif
-#endif
-	}
-	for(i=0;i<NN-KK+1;i++)
-		b[i] = Index_of[lambda[i]];
-
-	/*
-	 * Begin Berlekamp-Massey algorithm to determine error+erasure
-	 * locator polynomial
-	 */
-	r = no_eras;
-	el = no_eras;
-	while (++r <= NN-KK) {	/* r is the step number */
-		/* Compute discrepancy at the r-th step in poly-form */
-		discr_r = 0;
-		for (i = 0; i < r; i++){
-			if ((lambda[i] != 0) && (s[r - i] != A0)) {
-				discr_r ^= Alpha_to[modnn(Index_of[lambda[i]] + s[r - i])];
-			}
-		}
-		discr_r = Index_of[discr_r];	/* Index form */
-		if (discr_r == A0) {
-			/* 2 lines below: B(x) <-- x*B(x) */
-			COPYDOWN(&b[1],b,NN-KK);
-			b[0] = A0;
-		} else {
-			/* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
-			t[0] = lambda[0];
-			for (i = 0 ; i < NN-KK; i++) {
-				if(b[i] != A0)
-					t[i+1] = lambda[i+1] ^ Alpha_to[modnn(discr_r + b[i])];
-				else
-					t[i+1] = lambda[i+1];
-			}
-			if (2 * el <= r + no_eras - 1) {
-				el = r + no_eras - el;
-				/*
-				 * 2 lines below: B(x) <-- inv(discr_r) *
-				 * lambda(x)
-				 */
-				for (i = 0; i <= NN-KK; i++)
-					b[i] = (lambda[i] == 0) ? A0 : modnn(Index_of[lambda[i]] - discr_r + NN);
-			} else {
-				/* 2 lines below: B(x) <-- x*B(x) */
-				COPYDOWN(&b[1],b,NN-KK);
-				b[0] = A0;
-			}
-			COPY(lambda,t,NN-KK+1);
-		}
-	}
-
-	/* Convert lambda to index form and compute deg(lambda(x)) */
-	deg_lambda = 0;
-	for(i=0;i<NN-KK+1;i++){
-		lambda[i] = Index_of[lambda[i]];
-		if(lambda[i] != A0)
-			deg_lambda = i;
-	}
-	/*
-	 * Find roots of the error+erasure locator polynomial. By Chien
-	 * Search
-	 */
-	COPY(&reg[1],&lambda[1],NN-KK);
-	count = 0;		/* Number of roots of lambda(x) */
-	for (i = 1; i <= NN; i++) {
-		q = 1;
-		for (j = deg_lambda; j > 0; j--)
-			if (reg[j] != A0) {
-				reg[j] = modnn(reg[j] + j);
-				q ^= Alpha_to[reg[j]];
-			}
-		if (!q) {
-			/* store root (index-form) and error location number */
-			root[count] = i;
-			loc[count] = NN - i;
-			count++;
-		}
-	}
-
-#ifdef DEBUG
-	printf("\n Final error positions:\t");
-	for (i = 0; i < count; i++)
-		printf("%d ", loc[i]);
-	printf("\n");
-#endif
-	if (deg_lambda != count) {
-		/*
-		 * deg(lambda) unequal to number of roots => uncorrectable
-		 * error detected
-		 */
-		return -1;
-	}
-	/*
-	 * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
-	 * x**(NN-KK)). in index form. Also find deg(omega).
-	 */
-	deg_omega = 0;
-	for (i = 0; i < NN-KK;i++){
-		tmp = 0;
-		j = (deg_lambda < i) ? deg_lambda : i;
-		for(;j >= 0; j--){
-			if ((s[i + 1 - j] != A0) && (lambda[j] != A0))
-				tmp ^= Alpha_to[modnn(s[i + 1 - j] + lambda[j])];
-		}
-		if(tmp != 0)
-			deg_omega = i;
-		omega[i] = Index_of[tmp];
-	}
-	omega[NN-KK] = A0;
-
-	/*
-	 * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
-	 * inv(X(l))**(B0-1) and den = lambda_pr(inv(X(l))) all in poly-form
-	 */
-	for (j = count-1; j >=0; j--) {
-		num1 = 0;
-		for (i = deg_omega; i >= 0; i--) {
-			if (omega[i] != A0)
-				num1  ^= Alpha_to[modnn(omega[i] + i * root[j])];
-		}
-		num2 = Alpha_to[modnn(root[j] * (B0 - 1) + NN)];
-		den = 0;
-
-		/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
-		for (i = min(deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) {
-			if(lambda[i+1] != A0)
-				den ^= Alpha_to[modnn(lambda[i+1] + i * root[j])];
-		}
-		if (den == 0) {
-#ifdef DEBUG
-			printf("\n ERROR: denominator = 0\n");
-#endif
-			return -1;
-		}
-		/* Apply error to data */
-		if (num1 != 0) {
-			data[loc[j]] ^= Alpha_to[modnn(Index_of[num1] + Index_of[num2] + NN - Index_of[den])];
-		}
-	}
-	return count;
-}
-
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v1/jpwl/rs.h b/Utilities/gdcmopenjpeg-v1/jpwl/rs.h
deleted file mode 100644
index 6d2ed59..0000000
--- a/Utilities/gdcmopenjpeg-v1/jpwl/rs.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-/**
- at file rs.h
- at brief Functions used to compute Reed-Solomon parity and check of byte arrays
-
-*/
-
-#ifndef __RS_HEADER__
-#define __RS_HEADER__
-
-/** Global definitions for Reed-Solomon encoder/decoder
- * Phil Karn KA9Q, September 1996
- *
- * The parameters MM and KK specify the Reed-Solomon code parameters.
- *
- * Set MM to be the size of each code symbol in bits. The Reed-Solomon
- * block size will then be NN = 2**M - 1 symbols. Supported values are
- * defined in rs.c.
- *
- * Set KK to be the number of data symbols in each block, which must be
- * less than the block size. The code will then be able to correct up
- * to NN-KK erasures or (NN-KK)/2 errors, or combinations thereof with
- * each error counting as two erasures.
- */
-#define MM  8		/* RS code over GF(2**MM) - change to suit */
-//static int	KK;
-int	KK;
-
-/* Original code */
-/*#define KK  239*/		/* KK = number of information symbols */
-
-#define	NN ((1 << MM) - 1)
-
-#if (MM <= 8)
-typedef unsigned char dtype;
-#else
-typedef unsigned int dtype;
-#endif
-
-/** Initialization function */
-void init_rs(int);
-
-/** These two functions *must* be called in this order (e.g.,
- * by init_rs()) before any encoding/decoding
- */
-void generate_gf(void);	/* Generate Galois Field */
-void gen_poly(void);	/* Generate generator polynomial */
-
-/** Reed-Solomon encoding
- * data[] is the input block, parity symbols are placed in bb[]
- * bb[] may lie past the end of the data, e.g., for (255,223):
- *	encode_rs(&data[0],&data[223]);
- */
-int encode_rs(dtype data[], dtype bb[]);
-
-/** Reed-Solomon erasures-and-errors decoding
- * The received block goes into data[], and a list of zero-origin
- * erasure positions, if any, goes in eras_pos[] with a count in no_eras.
- *
- * The decoder corrects the symbols in place, if possible and returns
- * the number of corrected symbols. If the codeword is illegal or
- * uncorrectible, the data array is unchanged and -1 is returned
- */
-int eras_dec_rs(dtype data[], int eras_pos[], int no_eras);
-
-/**
-Computes the minimum between two integers
- at param a first integer to compare
- at param b second integer to compare
- at return returns the minimum integer between a and b
-*/
-#ifndef min
-#define min(a,b)    (((a) < (b)) ? (a) : (b))
-#endif /* min */
-
-#endif /* __RS_HEADER__ */
-
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg.pc.in b/Utilities/gdcmopenjpeg-v1/libopenjpeg.pc.in
deleted file mode 100644
index e75e2bd..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: openjpeg
-Description: JPEG2000 files library
-URL: http://code.google.com/p/openjpeg/
-Version: @VERSION@
-Libs: -L${libdir} -lopenjpeg
-Cflags: -I${includedir}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/libopenjpeg/CMakeLists.txt
deleted file mode 100644
index 5b7e009..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/CMakeLists.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-include_regular_expression("^.*$")
-# Defines the source code for the library
-set(OPENJPEG_SRCS
-  bio.c
-  cio.c
-  dwt.c
-  event.c
-  image.c
-  j2k.c
-  j2k_lib.c
-  jp2.c
-  jpt.c
-  mct.c
-  mqc.c
-  openjpeg.c
-  pi.c
-  raw.c
-  t1.c
-  t2.c
-  tcd.c
-  tgt.c
-)
-
-# Build the library
-if(WIN32)
-  if(BUILD_SHARED_LIBS)
-    add_definitions(-DOPJ_EXPORTS)
-  else()
-    add_definitions(-DOPJ_STATIC)
-  endif()
-endif()
-add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
-set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES
-  ${OPENJPEG_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")
-if(UNIX)
-  target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
-endif()
-
-
-# Install library
-if(NOT OPENJPEG_INSTALL_NO_LIBRARIES)
-  install(TARGETS ${OPENJPEG_LIBRARY_NAME}
-    EXPORT ${GDCM_TARGETS_NAME}
-    RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
-    LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
-    ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT DebugDevel
-    )
-endif()
-
-# Install includes files
-if(NOT OPENJPEG_INSTALL_NO_DEVELOPMENT)
-install(FILES openjpeg.h
-  #DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/${subdir} COMPONENT Headers
-  DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
-)
-#install(CODE
-#  "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_INCLUDE_DIR}/${subdir}/openjpeg.h \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_INCLUDE_DIR}/openjpeg.h)")
-
-# install man page of the library
-#install(
-#  FILES       ../doc/man/man3/libopenjpeg.3
-#  DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
-endif()
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.c
deleted file mode 100644
index 2ac262a..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* ----------------------------------------------------------------------- */
-
-opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) {
-	opj_cp_t *cp = NULL;
-	opj_cio_t *cio = (opj_cio_t*)opj_malloc(sizeof(opj_cio_t));
-	if(!cio) return NULL;
-	cio->cinfo = cinfo;
-	if(buffer && length) {
-		/* wrap a user buffer containing the encoded image */
-		cio->openmode = OPJ_STREAM_READ;
-		cio->buffer = buffer;
-		cio->length = length;
-	}
-	else if(!buffer && !length && cinfo) {
-		/* allocate a buffer for the encoded image */
-		cio->openmode = OPJ_STREAM_WRITE;
-		switch(cinfo->codec_format) {
-			case CODEC_J2K:
-				cp = ((opj_j2k_t*)cinfo->j2k_handle)->cp;
-				break;
-			case CODEC_JP2:
-				cp = ((opj_jp2_t*)cinfo->jp2_handle)->j2k->cp;
-				break;
-			default:
-				opj_free(cio);
-				return NULL;
-		}
-		cio->length = (unsigned int) (0.1625 * cp->img_size + 2000); /* 0.1625 = 1.3/8 and 2000 bytes as a minimum for headers */
-		cio->buffer = (unsigned char *)opj_malloc(cio->length);
-		if(!cio->buffer) {
-			opj_event_msg(cio->cinfo, EVT_ERROR, "Error allocating memory for compressed bitstream\n");
-			opj_free(cio);
-			return NULL;
-		}
-	}
-	else {
-		opj_free(cio);
-		return NULL;
-	}
-
-	/* Initialize byte IO */
-	cio->start = cio->buffer;
-	cio->end = cio->buffer + cio->length;
-	cio->bp = cio->buffer;
-
-	return cio;
-}
-
-void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) {
-	if(cio) {
-		if(cio->openmode == OPJ_STREAM_WRITE) {
-			/* destroy the allocated buffer */
-			opj_free(cio->buffer);
-		}
-		/* destroy the cio */
-		opj_free(cio);
-	}
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-/*
- * Get position in byte stream.
- */
-int OPJ_CALLCONV cio_tell(opj_cio_t *cio) {
-	return cio->bp - cio->start;
-}
-
-/*
- * Set position in byte stream.
- *
- * pos : position, in number of bytes, from the beginning of the stream
- */
-void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos) {
-	cio->bp = cio->start + pos;
-}
-
-/*
- * Number of bytes left before the end of the stream.
- */
-int cio_numbytesleft(opj_cio_t *cio) {
-	return cio->end - cio->bp;
-}
-
-/*
- * Get pointer to the current position in the stream.
- */
-unsigned char *cio_getbp(opj_cio_t *cio) {
-	return cio->bp;
-}
-
-/*
- * Write a byte.
- */
-bool cio_byteout(opj_cio_t *cio, unsigned char v) {
-	if (cio->bp >= cio->end) {
-		opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
-		return false;
-	}
-	*cio->bp++ = v;
-	return true;
-}
-
-/*
- * Read a byte.
- */
-unsigned char cio_bytein(opj_cio_t *cio) {
-	if (cio->bp >= cio->end) {
-		opj_event_msg(cio->cinfo, EVT_ERROR, "read error: passed the end of the codestream (start = %d, current = %d, end = %d\n", cio->start, cio->bp, cio->end);
-		return 0;
-	}
-	return *cio->bp++;
-}
-
-/*
- * Write some bytes.
- *
- * v : value to write
- * n : number of bytes to write
- */
-unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
-	int i;
-	for (i = n - 1; i >= 0; i--) {
-		if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
-			return 0;
-	}
-	return n;
-}
-
-/*
- * Read some bytes.
- *
- * n : number of bytes to read
- *
- * return : value of the n bytes read
- */
-unsigned int cio_read(opj_cio_t *cio, int n) {
-	int i;
-	unsigned int v;
-	v = 0;
-	for (i = n - 1; i >= 0; i--) {
-		v += cio_bytein(cio) << (i << 3);
-	}
-	return v;
-}
-
-/* 
- * Skip some bytes.
- *
- * n : number of bytes to skip
- */
-void cio_skip(opj_cio_t *cio, int n) {
-	cio->bp += n;
-}
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.h
deleted file mode 100644
index 580bf9c..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/cio.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __CIO_H
-#define __CIO_H
-/**
- at file cio.h
- at brief Implementation of a byte input-output process (CIO)
-
-The functions in CIO.C have for goal to realize a byte input / output process.
-*/
-
-/** @defgroup CIO CIO - byte input-output stream */
-/*@{*/
-
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Number of bytes left before the end of the stream
- at param cio CIO handle
- at return Returns the number of bytes before the end of the stream
-*/
-int cio_numbytesleft(opj_cio_t *cio);
-/**
-Get pointer to the current position in the stream
- at param cio CIO handle
- at return Returns a pointer to the current position
-*/
-unsigned char *cio_getbp(opj_cio_t *cio);
-/**
-Write some bytes
- at param cio CIO handle
- at param v Value to write
- at param n Number of bytes to write
- at return Returns the number of bytes written or 0 if an error occured
-*/
-unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n);
-/**
-Read some bytes
- at param cio CIO handle
- at param n Number of bytes to read
- at return Returns the value of the n bytes read
-*/
-unsigned int cio_read(opj_cio_t *cio, int n);
-/**
-Skip some bytes
- at param cio CIO handle
- at param n Number of bytes to skip
-*/
-void cio_skip(opj_cio_t *cio, int n);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __CIO_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/dwt.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/dwt.c
deleted file mode 100644
index a8d579f..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/dwt.c
+++ /dev/null
@@ -1,858 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Jonathan Ballard <dzonatas at dzonux.net>
- * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef __SSE__
-#include <xmmintrin.h>
-#endif
-
-#include "opj_includes.h"
-
-/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
-/*@{*/
-
-#define WS(i) v->mem[(i)*2]
-#define WD(i) v->mem[(1+(i)*2)]
-
-/** @name Local data structures */
-/*@{*/
-
-typedef struct dwt_local {
-	int* mem;
-	int dn;
-	int sn;
-	int cas;
-} dwt_t;
-
-typedef union {
-	float	f[4];
-} v4;
-
-typedef struct v4dwt_local {
-	v4*	wavelet ;
-	int		dn ;
-	int		sn ;
-	int		cas ;
-} v4dwt_t ;
-
-static const float dwt_alpha =  1.586134342f; //  12994
-static const float dwt_beta  =  0.052980118f; //    434
-static const float dwt_gamma = -0.882911075f; //  -7233
-static const float dwt_delta = -0.443506852f; //  -3633
-
-static const float K      = 1.230174105f; //  10078
-/* FIXME: What is this constant? */
-static const float c13318 = 1.625732422f;
-
-/*@}*/
-
-/**
-Virtual function type for wavelet transform in 1-D 
-*/
-typedef void (*DWT1DFN)(dwt_t* v);
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Forward lazy transform (horizontal)
-*/
-static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas);
-/**
-Forward lazy transform (vertical)
-*/
-static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas);
-/**
-Inverse lazy transform (horizontal)
-*/
-static void dwt_interleave_h(dwt_t* h, int *a);
-/**
-Inverse lazy transform (vertical)
-*/
-static void dwt_interleave_v(dwt_t* v, int *a, int x);
-/**
-Forward 5-3 wavelet transform in 1-D
-*/
-static void dwt_encode_1(int *a, int dn, int sn, int cas);
-/**
-Inverse 5-3 wavelet transform in 1-D
-*/
-static void dwt_decode_1(dwt_t *v);
-/**
-Forward 9-7 wavelet transform in 1-D
-*/
-static void dwt_encode_1_real(int *a, int dn, int sn, int cas);
-/**
-Explicit calculation of the Quantization Stepsizes 
-*/
-static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize);
-/**
-Inverse wavelet transform in 2-D.
-*/
-static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int i, DWT1DFN fn);
-
-/*@}*/
-
-/*@}*/
-
-#define S(i) a[(i)*2]
-#define D(i) a[(1+(i)*2)]
-#define S_(i) ((i)<0?S(0):((i)>=sn?S(sn-1):S(i)))
-#define D_(i) ((i)<0?D(0):((i)>=dn?D(dn-1):D(i)))
-/* new */
-#define SS_(i) ((i)<0?S(0):((i)>=dn?S(dn-1):S(i)))
-#define DD_(i) ((i)<0?D(0):((i)>=sn?D(sn-1):D(i)))
-
-/* <summary>                                                              */
-/* This table contains the norms of the 5-3 wavelets for different bands. */
-/* </summary>                                                             */
-static const double dwt_norms[4][10] = {
-	{1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
-	{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-	{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-	{.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
-};
-
-/* <summary>                                                              */
-/* This table contains the norms of the 9-7 wavelets for different bands. */
-/* </summary>                                                             */
-static const double dwt_norms_real[4][10] = {
-	{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
-	{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
-	{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
-	{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
-};
-
-/* 
-==========================================================
-   local functions
-==========================================================
-*/
-
-/* <summary>			                 */
-/* Forward lazy transform (horizontal).  */
-/* </summary>                            */ 
-static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas) {
-	int i;
-    for (i=0; i<sn; i++) b[i]=a[2*i+cas];
-    for (i=0; i<dn; i++) b[sn+i]=a[(2*i+1-cas)];
-}
-
-/* <summary>                             */  
-/* Forward lazy transform (vertical).    */
-/* </summary>                            */ 
-static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
-    int i;
-    for (i=0; i<sn; i++) b[i*x]=a[2*i+cas];
-    for (i=0; i<dn; i++) b[(sn+i)*x]=a[(2*i+1-cas)];
-}
-
-/* <summary>                             */
-/* Inverse lazy transform (horizontal).  */
-/* </summary>                            */
-static void dwt_interleave_h(dwt_t* h, int *a) {
-    int *ai = a;
-    int *bi = h->mem + h->cas;
-    int  i	= h->sn;
-    while( i-- ) {
-      *bi = *(ai++);
-	  bi += 2;
-    }
-    ai	= a + h->sn;
-    bi	= h->mem + 1 - h->cas;
-    i	= h->dn ;
-    while( i-- ) {
-      *bi = *(ai++);
-	  bi += 2;
-    }
-}
-
-/* <summary>                             */  
-/* Inverse lazy transform (vertical).    */
-/* </summary>                            */ 
-static void dwt_interleave_v(dwt_t* v, int *a, int x) {
-    int *ai = a;
-    int *bi = v->mem + v->cas;
-    int  i = v->sn;
-    while( i-- ) {
-      *bi = *ai;
-	  bi += 2;
-	  ai += x;
-    }
-    ai = a + (v->sn * x);
-    bi = v->mem + 1 - v->cas;
-    i = v->dn ;
-    while( i-- ) {
-      *bi = *ai;
-	  bi += 2;  
-	  ai += x;
-    }
-}
-
-
-/* <summary>                            */
-/* Forward 5-3 wavelet transform in 1-D. */
-/* </summary>                           */
-static void dwt_encode_1(int *a, int dn, int sn, int cas) {
-	int i;
-	
-	if (!cas) {
-		if ((dn > 0) || (sn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-			for (i = 0; i < dn; i++) D(i) -= (S_(i) + S_(i + 1)) >> 1;
-			for (i = 0; i < sn; i++) S(i) += (D_(i - 1) + D_(i) + 2) >> 2;
-		}
-	} else {
-		if (!sn && dn == 1)		    /* NEW :  CASE ONE ELEMENT */
-			S(0) *= 2;
-		else {
-			for (i = 0; i < dn; i++) S(i) -= (DD_(i) + DD_(i - 1)) >> 1;
-			for (i = 0; i < sn; i++) D(i) += (SS_(i) + SS_(i + 1) + 2) >> 2;
-		}
-	}
-}
-
-/* <summary>                            */
-/* Inverse 5-3 wavelet transform in 1-D. */
-/* </summary>                           */ 
-static void dwt_decode_1_(int *a, int dn, int sn, int cas) {
-	int i;
-	
-	if (!cas) {
-		if ((dn > 0) || (sn > 1)) { /* NEW :  CASE ONE ELEMENT */
-			for (i = 0; i < sn; i++) S(i) -= (D_(i - 1) + D_(i) + 2) >> 2;
-			for (i = 0; i < dn; i++) D(i) += (S_(i) + S_(i + 1)) >> 1;
-		}
-	} else {
-		if (!sn  && dn == 1)          /* NEW :  CASE ONE ELEMENT */
-			S(0) /= 2;
-		else {
-			for (i = 0; i < sn; i++) D(i) -= (SS_(i) + SS_(i + 1) + 2) >> 2;
-			for (i = 0; i < dn; i++) S(i) += (DD_(i) + DD_(i - 1)) >> 1;
-		}
-	}
-}
-
-/* <summary>                            */
-/* Inverse 5-3 wavelet transform in 1-D. */
-/* </summary>                           */ 
-static void dwt_decode_1(dwt_t *v) {
-	dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
-}
-
-/* <summary>                             */
-/* Forward 9-7 wavelet transform in 1-D. */
-/* </summary>                            */
-static void dwt_encode_1_real(int *a, int dn, int sn, int cas) {
-	int i;
-	if (!cas) {
-		if ((dn > 0) || (sn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-			for (i = 0; i < dn; i++)
-				D(i) -= fix_mul(S_(i) + S_(i + 1), 12993);
-			for (i = 0; i < sn; i++)
-				S(i) -= fix_mul(D_(i - 1) + D_(i), 434);
-			for (i = 0; i < dn; i++)
-				D(i) += fix_mul(S_(i) + S_(i + 1), 7233);
-			for (i = 0; i < sn; i++)
-				S(i) += fix_mul(D_(i - 1) + D_(i), 3633);
-			for (i = 0; i < dn; i++)
-				D(i) = fix_mul(D(i), 5038);	/*5038 */
-			for (i = 0; i < sn; i++)
-				S(i) = fix_mul(S(i), 6659);	/*6660 */
-		}
-	} else {
-		if ((sn > 0) || (dn > 1)) {	/* NEW :  CASE ONE ELEMENT */
-			for (i = 0; i < dn; i++)
-				S(i) -= fix_mul(DD_(i) + DD_(i - 1), 12993);
-			for (i = 0; i < sn; i++)
-				D(i) -= fix_mul(SS_(i) + SS_(i + 1), 434);
-			for (i = 0; i < dn; i++)
-				S(i) += fix_mul(DD_(i) + DD_(i - 1), 7233);
-			for (i = 0; i < sn; i++)
-				D(i) += fix_mul(SS_(i) + SS_(i + 1), 3633);
-			for (i = 0; i < dn; i++)
-				S(i) = fix_mul(S(i), 5038);	/*5038 */
-			for (i = 0; i < sn; i++)
-				D(i) = fix_mul(D(i), 6659);	/*6660 */
-		}
-	}
-}
-
-static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize) {
-	int p, n;
-	p = int_floorlog2(stepsize) - 13;
-	n = 11 - int_floorlog2(stepsize);
-	bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
-	bandno_stepsize->expn = numbps - p;
-}
-
-/* 
-==========================================================
-   DWT interface
-==========================================================
-*/
-
-/* <summary>                            */
-/* Forward 5-3 wavelet transform in 2-D. */
-/* </summary>                           */
-void dwt_encode(opj_tcd_tilecomp_t * tilec) {
-	int i, j, k;
-	int *a = NULL;
-	int *aj = NULL;
-	int *bj = NULL;
-	int w, l;
-	
-	w = tilec->x1-tilec->x0;
-	l = tilec->numresolutions-1;
-	a = tilec->data;
-	
-	for (i = 0; i < l; i++) {
-		int rw;			/* width of the resolution level computed                                                           */
-		int rh;			/* height of the resolution level computed                                                          */
-		int rw1;		/* width of the resolution level once lower than computed one                                       */
-		int rh1;		/* height of the resolution level once lower than computed one                                      */
-		int cas_col;	/* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
-		int cas_row;	/* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
-		int dn, sn;
-		
-		rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
-		rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
-		rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
-		rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
-		
-		cas_row = tilec->resolutions[l - i].x0 % 2;
-		cas_col = tilec->resolutions[l - i].y0 % 2;
-        
-		sn = rh1;
-		dn = rh - rh1;
-		bj = (int*)opj_malloc(rh * sizeof(int));
-		for (j = 0; j < rw; j++) {
-			aj = a + j;
-			for (k = 0; k < rh; k++)  bj[k] = aj[k*w];
-			dwt_encode_1(bj, dn, sn, cas_col);
-			dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
-		}
-		opj_free(bj);
-		
-		sn = rw1;
-		dn = rw - rw1;
-		bj = (int*)opj_malloc(rw * sizeof(int));
-		for (j = 0; j < rh; j++) {
-			aj = a + j * w;
-			for (k = 0; k < rw; k++)  bj[k] = aj[k];
-			dwt_encode_1(bj, dn, sn, cas_row);
-			dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
-		}
-		opj_free(bj);
-	}
-}
-
-
-/* <summary>                            */
-/* Inverse 5-3 wavelet transform in 2-D. */
-/* </summary>                           */
-void dwt_decode(opj_tcd_tilecomp_t* tilec, int numres) {
-	dwt_decode_tile(tilec, numres, &dwt_decode_1);
-}
-
-
-/* <summary>                          */
-/* Get gain of 5-3 wavelet transform. */
-/* </summary>                         */
-int dwt_getgain(int orient) {
-	if (orient == 0)
-		return 0;
-	if (orient == 1 || orient == 2)
-		return 1;
-	return 2;
-}
-
-/* <summary>                */
-/* Get norm of 5-3 wavelet. */
-/* </summary>               */
-double dwt_getnorm(int level, int orient) {
-	return dwt_norms[orient][level];
-}
-
-/* <summary>                             */
-/* Forward 9-7 wavelet transform in 2-D. */
-/* </summary>                            */
-
-void dwt_encode_real(opj_tcd_tilecomp_t * tilec) {
-	int i, j, k;
-	int *a = NULL;
-	int *aj = NULL;
-	int *bj = NULL;
-	int w, l;
-	
-	w = tilec->x1-tilec->x0;
-	l = tilec->numresolutions-1;
-	a = tilec->data;
-	
-	for (i = 0; i < l; i++) {
-		int rw;			/* width of the resolution level computed                                                     */
-		int rh;			/* height of the resolution level computed                                                    */
-		int rw1;		/* width of the resolution level once lower than computed one                                 */
-		int rh1;		/* height of the resolution level once lower than computed one                                */
-		int cas_col;	/* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
-		int cas_row;	/* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
-		int dn, sn;
-		
-		rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
-		rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
-		rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
-		rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
-		
-		cas_row = tilec->resolutions[l - i].x0 % 2;
-		cas_col = tilec->resolutions[l - i].y0 % 2;
-		
-		sn = rh1;
-		dn = rh - rh1;
-		bj = (int*)opj_malloc(rh * sizeof(int));
-		for (j = 0; j < rw; j++) {
-			aj = a + j;
-			for (k = 0; k < rh; k++)  bj[k] = aj[k*w];
-			dwt_encode_1_real(bj, dn, sn, cas_col);
-			dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
-		}
-		opj_free(bj);
-		
-		sn = rw1;
-		dn = rw - rw1;
-		bj = (int*)opj_malloc(rw * sizeof(int));
-		for (j = 0; j < rh; j++) {
-			aj = a + j * w;
-			for (k = 0; k < rw; k++)  bj[k] = aj[k];
-			dwt_encode_1_real(bj, dn, sn, cas_row);
-			dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
-		}
-		opj_free(bj);
-	}
-}
-
-
-/* <summary>                          */
-/* Get gain of 9-7 wavelet transform. */
-/* </summary>                         */
-int dwt_getgain_real(int orient) {
-	(void)orient;
-	return 0;
-}
-
-/* <summary>                */
-/* Get norm of 9-7 wavelet. */
-/* </summary>               */
-double dwt_getnorm_real(int level, int orient) {
-	return dwt_norms_real[orient][level];
-}
-
-void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec) {
-	int numbands, bandno;
-	numbands = 3 * tccp->numresolutions - 2;
-	for (bandno = 0; bandno < numbands; bandno++) {
-		double stepsize;
-		int resno, level, orient, gain;
-
-		resno = (bandno == 0) ? 0 : ((bandno - 1) / 3 + 1);
-		orient = (bandno == 0) ? 0 : ((bandno - 1) % 3 + 1);
-		level = tccp->numresolutions - 1 - resno;
-		gain = (tccp->qmfbid == 0) ? 0 : ((orient == 0) ? 0 : (((orient == 1) || (orient == 2)) ? 1 : 2));
-		if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
-			stepsize = 1.0;
-		} else {
-			double norm = dwt_norms_real[orient][level];
-			stepsize = (1 << (gain)) / norm;
-		}
-		dwt_encode_stepsize((int) floor(stepsize * 8192.0), prec + gain, &tccp->stepsizes[bandno]);
-	}
-}
-
-
-/* <summary>                             */
-/* Determine maximum computed resolution level for inverse wavelet transform */
-/* </summary>                            */
-static int dwt_decode_max_resolution(opj_tcd_resolution_t* restrict r, int i) {
-	int mr	= 1;
-	int w;
-	while( --i ) {
-		r++;
-		if( mr < ( w = r->x1 - r->x0 ) )
-			mr = w ;
-		if( mr < ( w = r->y1 - r->y0 ) )
-			mr = w ;
-	}
-	return mr ;
-}
-
-
-/* <summary>                            */
-/* Inverse wavelet transform in 2-D.     */
-/* </summary>                           */
-static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1D) {
-	dwt_t h;
-	dwt_t v;
-
-	opj_tcd_resolution_t* tr = tilec->resolutions;
-
-	int rw = tr->x1 - tr->x0;	/* width of the resolution level computed */
-	int rh = tr->y1 - tr->y0;	/* height of the resolution level computed */
-
-	int w = tilec->x1 - tilec->x0;
-
-	h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
-	v.mem = h.mem;
-
-	while( --numres) {
-		int * restrict tiledp = tilec->data;
-		int j;
-
-		++tr;
-		h.sn = rw;
-		v.sn = rh;
-
-		rw = tr->x1 - tr->x0;
-		rh = tr->y1 - tr->y0;
-
-		h.dn = rw - h.sn;
-		h.cas = tr->x0 % 2;
-
-		for(j = 0; j < rh; ++j) {
-			dwt_interleave_h(&h, &tiledp[j*w]);
-			(dwt_1D)(&h);
-			memcpy(&tiledp[j*w], h.mem, rw * sizeof(int));
-		}
-
-		v.dn = rh - v.sn;
-		v.cas = tr->y0 % 2;
-
-		for(j = 0; j < rw; ++j){
-			int k;
-			dwt_interleave_v(&v, &tiledp[j], w);
-			(dwt_1D)(&v);
-			for(k = 0; k < rh; ++k) {
-				tiledp[k * w + j] = v.mem[k];
-			}
-		}
-	}
-	opj_aligned_free(h.mem);
-}
-
-static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, int size){
-	float* restrict bi = (float*) (w->wavelet + w->cas);
-	int count = w->sn;
-	int i, k;
-	for(k = 0; k < 2; ++k){
-		if (count + 3 * x < size && ((int) a & 0x0f) == 0 && ((int) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
-			/* Fast code path */
-			for(i = 0; i < count; ++i){
-				int j = i;
-				bi[i*8    ] = a[j];
-				j += x;
-				bi[i*8 + 1] = a[j];
-				j += x;
-				bi[i*8 + 2] = a[j];
-				j += x;
-				bi[i*8 + 3] = a[j];
-			}
-		} else {
-			/* Slow code path */
-		for(i = 0; i < count; ++i){
-			int j = i;
-			bi[i*8    ] = a[j];
-			j += x;
-			if(j > size) continue;
-			bi[i*8 + 1] = a[j];
-			j += x;
-			if(j > size) continue;
-			bi[i*8 + 2] = a[j];
-			j += x;
-			if(j > size) continue;
-			bi[i*8 + 3] = a[j];
-		}
-		}
-		bi = (float*) (w->wavelet + 1 - w->cas);
-		a += w->sn;
-		size -= w->sn;
-		count = w->dn;
-	}
-}
-
-static void v4dwt_interleave_v(v4dwt_t* restrict v , float* restrict a , int x){
-	v4* restrict bi = v->wavelet + v->cas;
-	int i;
-	for(i = 0; i < v->sn; ++i){
-		memcpy(&bi[i*2], &a[i*x], 4 * sizeof(float));
-	}
-	a += v->sn * x;
-	bi = v->wavelet + 1 - v->cas;
-	for(i = 0; i < v->dn; ++i){
-		memcpy(&bi[i*2], &a[i*x], 4 * sizeof(float));
-	}
-}
-
-#ifdef __SSE__
-
-static void v4dwt_decode_step1_sse(v4* w, int count, const __m128 c){
-	__m128* restrict vw = (__m128*) w;
-	int i;
-	/* 4x unrolled loop */
-	for(i = 0; i < count >> 2; ++i){
-		*vw = _mm_mul_ps(*vw, c);
-		vw += 2;
-		*vw = _mm_mul_ps(*vw, c);
-		vw += 2;
-		*vw = _mm_mul_ps(*vw, c);
-		vw += 2;
-		*vw = _mm_mul_ps(*vw, c);
-		vw += 2;
-	}
-	count &= 3;
-	for(i = 0; i < count; ++i){
-		*vw = _mm_mul_ps(*vw, c);
-		vw += 2;
-	}
-}
-
-static void v4dwt_decode_step2_sse(v4* l, v4* w, int k, int m, __m128 c){
-	__m128* restrict vl = (__m128*) l;
-	__m128* restrict vw = (__m128*) w;
-	int i;
-	__m128 tmp1, tmp2, tmp3;
-	tmp1 = vl[0];
-	for(i = 0; i < m; ++i){
-		tmp2 = vw[-1];
-		tmp3 = vw[ 0];
-		vw[-1] = _mm_add_ps(tmp2, _mm_mul_ps(_mm_add_ps(tmp1, tmp3), c));
-		tmp1 = tmp3;
-		vw += 2;
-	}
-	vl = vw - 2;
-	if(m >= k){
-		return;
-	}
-	c = _mm_add_ps(c, c);
-	c = _mm_mul_ps(c, vl[0]);
-	for(; m < k; ++m){
-		__m128 tmp = vw[-1];
-		vw[-1] = _mm_add_ps(tmp, c);
-		vw += 2;
-	}
-}
-
-#else
-
-static void v4dwt_decode_step1(v4* w, int count, const float c){
-	float* restrict fw = (float*) w;
-	int i;
-	for(i = 0; i < count; ++i){
-		float tmp1 = fw[i*8    ];
-		float tmp2 = fw[i*8 + 1];
-		float tmp3 = fw[i*8 + 2];
-		float tmp4 = fw[i*8 + 3];
-		fw[i*8    ] = tmp1 * c;
-		fw[i*8 + 1] = tmp2 * c;
-		fw[i*8 + 2] = tmp3 * c;
-		fw[i*8 + 3] = tmp4 * c;
-	}
-}
-
-static void v4dwt_decode_step2(v4* l, v4* w, int k, int m, float c){
-	float* restrict fl = (float*) l;
-	float* restrict fw = (float*) w;
-	int i;
-	for(i = 0; i < m; ++i){
-		float tmp1_1 = fl[0];
-		float tmp1_2 = fl[1];
-		float tmp1_3 = fl[2];
-		float tmp1_4 = fl[3];
-		float tmp2_1 = fw[-4];
-		float tmp2_2 = fw[-3];
-		float tmp2_3 = fw[-2];
-		float tmp2_4 = fw[-1];
-		float tmp3_1 = fw[0];
-		float tmp3_2 = fw[1];
-		float tmp3_3 = fw[2];
-		float tmp3_4 = fw[3];
-		fw[-4] = tmp2_1 + ((tmp1_1 + tmp3_1) * c);
-		fw[-3] = tmp2_2 + ((tmp1_2 + tmp3_2) * c);
-		fw[-2] = tmp2_3 + ((tmp1_3 + tmp3_3) * c);
-		fw[-1] = tmp2_4 + ((tmp1_4 + tmp3_4) * c);
-		fl = fw;
-		fw += 8;
-	}
-	if(m < k){
-		float c1;
-		float c2;
-		float c3;
-		float c4;
-		c += c;
-		c1 = fl[0] * c;
-		c2 = fl[1] * c;
-		c3 = fl[2] * c;
-		c4 = fl[3] * c;
-		for(; m < k; ++m){
-			float tmp1 = fw[-4];
-			float tmp2 = fw[-3];
-			float tmp3 = fw[-2];
-			float tmp4 = fw[-1];
-			fw[-4] = tmp1 + c1;
-			fw[-3] = tmp2 + c2;
-			fw[-2] = tmp3 + c3;
-			fw[-1] = tmp4 + c4;
-			fw += 8;
-		}
-	}
-}
-
-#endif
-
-/* <summary>                             */
-/* Inverse 9-7 wavelet transform in 1-D. */
-/* </summary>                            */
-static void v4dwt_decode(v4dwt_t* restrict dwt){
-	int a, b;
-	if(dwt->cas == 0) {
-		if(!((dwt->dn > 0) || (dwt->sn > 1))){
-			return;
-		}
-		a = 0;
-		b = 1;
-	}else{
-		if(!((dwt->sn > 0) || (dwt->dn > 1))) {
-			return;
-		}
-		a = 1;
-		b = 0;
-	}
-#ifdef __SSE__
-	v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(K));
-	v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(c13318));
-	v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_delta));
-	v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_gamma));
-	v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_beta));
-	v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_alpha));
-#else
-	v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, K);
-	v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, c13318);
-	v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_delta);
-	v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_gamma);
-	v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_beta);
-	v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_alpha);
-#endif
-}
-
-/* <summary>                             */
-/* Inverse 9-7 wavelet transform in 2-D. */
-/* </summary>                            */
-void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){
-	v4dwt_t h;
-	v4dwt_t v;
-
-	opj_tcd_resolution_t* res = tilec->resolutions;
-
-	int rw = res->x1 - res->x0;	/* width of the resolution level computed */
-	int rh = res->y1 - res->y0;	/* height of the resolution level computed */
-
-	int w = tilec->x1 - tilec->x0;
-
-	h.wavelet = (v4*) opj_aligned_malloc((dwt_decode_max_resolution(res, numres)+5) * sizeof(v4));
-	v.wavelet = h.wavelet;
-
-	while( --numres) {
-		float * restrict aj = (float*) tilec->data;
-		int bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0);
-		int j;
-
-		h.sn = rw;
-		v.sn = rh;
-
-		++res;
-
-		rw = res->x1 - res->x0;	/* width of the resolution level computed */
-		rh = res->y1 - res->y0;	/* height of the resolution level computed */
-
-		h.dn = rw - h.sn;
-		h.cas = res->x0 % 2;
-
-		for(j = rh; j > 3; j -= 4){
-			int k;
-			v4dwt_interleave_h(&h, aj, w, bufsize);
-			v4dwt_decode(&h);
-				for(k = rw; --k >= 0;){
-					aj[k    ] = h.wavelet[k].f[0];
-					aj[k+w  ] = h.wavelet[k].f[1];
-					aj[k+w*2] = h.wavelet[k].f[2];
-					aj[k+w*3] = h.wavelet[k].f[3];
-				}
-			aj += w*4;
-			bufsize -= w*4;
-		}
-		if (rh & 0x03) {
-				int k;
-			j = rh & 0x03;
-			v4dwt_interleave_h(&h, aj, w, bufsize);
-			v4dwt_decode(&h);
-				for(k = rw; --k >= 0;){
-					switch(j) {
-						case 3: aj[k+w*2] = h.wavelet[k].f[2];
-						case 2: aj[k+w  ] = h.wavelet[k].f[1];
-						case 1: aj[k    ] = h.wavelet[k].f[0];
-					}
-				}
-			}
-
-		v.dn = rh - v.sn;
-		v.cas = res->y0 % 2;
-
-		aj = (float*) tilec->data;
-		for(j = rw; j > 3; j -= 4){
-			int k;
-			v4dwt_interleave_v(&v, aj, w);
-			v4dwt_decode(&v);
-				for(k = 0; k < rh; ++k){
-					memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(float));
-				}
-			aj += 4;
-		}
-		if (rw & 0x03){
-				int k;
-			j = rw & 0x03;
-			v4dwt_interleave_v(&v, aj, w);
-			v4dwt_decode(&v);
-				for(k = 0; k < rh; ++k){
-					memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(float));
-				}
-			}
-	}
-
-	opj_aligned_free(h.wavelet);
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/event.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/event.h
deleted file mode 100644
index 11910b0..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/event.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __EVENT_H
-#define __EVENT_H
-/**
- at file event.h
- at brief Implementation of a event callback system
-
-The functions in EVENT.C have for goal to send output messages (errors, warnings, debug) to the user.
-*/
-
-#define EVT_ERROR	1	/**< Error event type */
-#define EVT_WARNING	2	/**< Warning event type */
-#define EVT_INFO	4	/**< Debug event type */
-
-/** @defgroup EVENT EVENT - Implementation of a event callback system */
-/*@{*/
-
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Write formatted data to a string and send the string to a user callback. 
- at param cinfo Codec context info
- at param event_type Event type or callback to use to send the message
- at param fmt Format-control string (plus optionnal arguments)
- at return Returns true if successful, returns false otherwise
-*/
-bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __EVENT_H */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/fix.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/fix.h
deleted file mode 100644
index bcb2acb..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/fix.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __FIX_H
-#define __FIX_H
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define int64 __int64
-#else
-#define int64 long long
-#endif
-
-/**
- at file fix.h
- at brief Implementation of operations of specific multiplication (FIX)
-
-The functions in FIX.H have for goal to realize specific multiplication.
-*/
-
-/** @defgroup FIX FIX - Implementation of operations of specific multiplication */
-/*@{*/
-
-/**
-Multiply two fixed-precision rational numbers.
- at param a
- at param b
- at return Returns a * b
-*/
-static INLINE int fix_mul(int a, int b) {
-    int64 temp = (int64) a * (int64) b ;
-    temp += temp & 4096;
-    return (int) (temp >> 13) ;
-}
-
-/*@}*/
-
-#endif /* __FIX_H */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/image.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/image.c
deleted file mode 100644
index 30b7d13..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/image.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-opj_image_t* opj_image_create0(void) {
-	opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t));
-	return image;
-}
-
-opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
-	int compno;
-	opj_image_t *image = NULL;
-
-	image = (opj_image_t*) opj_calloc(1, sizeof(opj_image_t));
-	if(image) {
-		image->color_space = clrspc;
-		image->numcomps = numcmpts;
-		/* allocate memory for the per-component information */
-		image->comps = (opj_image_comp_t*)opj_malloc(image->numcomps * sizeof(opj_image_comp_t));
-		if(!image->comps) {
-			fprintf(stderr,"Unable to allocate memory for image.\n");
-			opj_image_destroy(image);
-			return NULL;
-		}
-		/* create the individual image components */
-		for(compno = 0; compno < numcmpts; compno++) {
-			opj_image_comp_t *comp = &image->comps[compno];
-			comp->dx = cmptparms[compno].dx;
-			comp->dy = cmptparms[compno].dy;
-			comp->w = cmptparms[compno].w;
-			comp->h = cmptparms[compno].h;
-			comp->x0 = cmptparms[compno].x0;
-			comp->y0 = cmptparms[compno].y0;
-			comp->prec = cmptparms[compno].prec;
-			comp->bpp = cmptparms[compno].bpp;
-			comp->sgnd = cmptparms[compno].sgnd;
-			comp->data = (int*) opj_calloc(comp->w * comp->h, sizeof(int));
-			if(!comp->data) {
-				fprintf(stderr,"Unable to allocate memory for image.\n");
-				opj_image_destroy(image);
-				return NULL;
-			}
-		}
-	}
-
-	return image;
-}
-
-void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
-	int i;
-	if(image) {
-		if(image->comps) {
-			/* image components */
-			for(i = 0; i < image->numcomps; i++) {
-				opj_image_comp_t *image_comp = &image->comps[i];
-				if(image_comp->data) {
-					opj_free(image_comp->data);
-				}
-			}
-			opj_free(image->comps);
-		}
-		opj_free(image);
-	}
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/image.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/image.h
deleted file mode 100644
index 04c362e..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/image.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __IMAGE_H
-#define __IMAGE_H
-/**
- at file image.h
- at brief Implementation of operations on images (IMAGE)
-
-The functions in IMAGE.C have for goal to realize operations on images.
-*/
-
-/** @defgroup IMAGE IMAGE - Implementation of operations on images */
-/*@{*/
-
-/**
-Create an empty image
- at todo this function should be removed
- at return returns an empty image if successful, returns NULL otherwise
-*/
-opj_image_t* opj_image_create0(void);
-
-/*@}*/
-
-#endif /* __IMAGE_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/int.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/int.h
deleted file mode 100644
index 4e5fe08..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/int.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __INT_H
-#define __INT_H
-/**
- at file int.h
- at brief Implementation of operations on integers (INT)
-
-The functions in INT.H have for goal to realize operations on integers.
-*/
-
-/** @defgroup INT INT - Implementation of operations on integers */
-/*@{*/
-
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Get the minimum of two integers
- at return Returns a if a < b else b
-*/
-static INLINE int int_min(int a, int b) {
-	return a < b ? a : b;
-}
-/**
-Get the maximum of two integers
- at return Returns a if a > b else b
-*/
-static INLINE int int_max(int a, int b) {
-	return (a > b) ? a : b;
-}
-/**
-Clamp an integer inside an interval
- at return
-<ul>
-<li>Returns a if (min < a < max)
-<li>Returns max if (a > max)
-<li>Returns min if (a < min) 
-</ul>
-*/
-static INLINE int int_clamp(int a, int min, int max) {
-	if (a < min)
-		return min;
-	if (a > max)
-		return max;
-	return a;
-}
-/**
- at return Get absolute value of integer
-*/
-static INLINE int int_abs(int a) {
-	return a < 0 ? -a : a;
-}
-/**
-Divide an integer and round upwards
- at return Returns a divided by b
-*/
-static INLINE int int_ceildiv(int a, int b) {
-	return (a + b - 1) / b;
-}
-/**
-Divide an integer by a power of 2 and round upwards
- at return Returns a divided by 2^b
-*/
-static INLINE int int_ceildivpow2(int a, int b) {
-	return (a + (1 << b) - 1) >> b;
-}
-/**
-Divide an integer by a power of 2 and round downwards
- at return Returns a divided by 2^b
-*/
-static INLINE int int_floordivpow2(int a, int b) {
-	return a >> b;
-}
-/**
-Get logarithm of an integer and round downwards
- at return Returns log2(a)
-*/
-static INLINE int int_floorlog2(int a) {
-	int l;
-	for (l = 0; a > 1; l++) {
-		a >>= 1;
-	}
-	return l;
-}
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.c
deleted file mode 100644
index de1c206..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.c
+++ /dev/null
@@ -1,2434 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Write the SOC marker (Start Of Codestream)
- at param j2k J2K handle
-*/
-static void j2k_write_soc(opj_j2k_t *j2k);
-/**
-Read the SOC marker (Start of Codestream)
- at param j2k J2K handle
-*/
-static void j2k_read_soc(opj_j2k_t *j2k);
-/**
-Write the SIZ marker (image and tile size)
- at param j2k J2K handle
-*/
-static void j2k_write_siz(opj_j2k_t *j2k);
-/**
-Read the SIZ marker (image and tile size)
- at param j2k J2K handle
-*/
-static void j2k_read_siz(opj_j2k_t *j2k);
-/**
-Write the COM marker (comment)
- at param j2k J2K handle
-*/
-static void j2k_write_com(opj_j2k_t *j2k);
-/**
-Read the COM marker (comment)
- at param j2k J2K handle
-*/
-static void j2k_read_com(opj_j2k_t *j2k);
-/**
-Write the value concerning the specified component in the marker COD and COC
- at param j2k J2K handle
- at param compno Number of the component concerned by the information written
-*/
-static void j2k_write_cox(opj_j2k_t *j2k, int compno);
-/**
-Read the value concerning the specified component in the marker COD and COC
- at param j2k J2K handle
- at param compno Number of the component concerned by the information read
-*/
-static void j2k_read_cox(opj_j2k_t *j2k, int compno);
-/**
-Write the COD marker (coding style default)
- at param j2k J2K handle
-*/
-static void j2k_write_cod(opj_j2k_t *j2k);
-/**
-Read the COD marker (coding style default)
- at param j2k J2K handle
-*/
-static void j2k_read_cod(opj_j2k_t *j2k);
-/**
-Write the COC marker (coding style component)
- at param j2k J2K handle
- at param compno Number of the component concerned by the information written
-*/
-static void j2k_write_coc(opj_j2k_t *j2k, int compno);
-/**
-Read the COC marker (coding style component)
- at param j2k J2K handle
-*/
-static void j2k_read_coc(opj_j2k_t *j2k);
-/**
-Write the value concerning the specified component in the marker QCD and QCC
- at param j2k J2K handle
- at param compno Number of the component concerned by the information written
-*/
-static void j2k_write_qcx(opj_j2k_t *j2k, int compno);
-/**
-Read the value concerning the specified component in the marker QCD and QCC
- at param j2k J2K handle
- at param compno Number of the component concern by the information read
- at param len Length of the information in the QCX part of the marker QCD/QCC
-*/
-static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len);
-/**
-Write the QCD marker (quantization default)
- at param j2k J2K handle
-*/
-static void j2k_write_qcd(opj_j2k_t *j2k);
-/**
-Read the QCD marker (quantization default)
- at param j2k J2K handle
-*/
-static void j2k_read_qcd(opj_j2k_t *j2k);
-/**
-Write the QCC marker (quantization component)
- at param j2k J2K handle
- at param compno Number of the component concerned by the information written
-*/
-static void j2k_write_qcc(opj_j2k_t *j2k, int compno);
-/**
-Read the QCC marker (quantization component)
- at param j2k J2K handle
-*/
-static void j2k_read_qcc(opj_j2k_t *j2k);
-/**
-Write the POC marker (progression order change)
- at param j2k J2K handle
-*/
-static void j2k_write_poc(opj_j2k_t *j2k);
-/**
-Read the POC marker (progression order change)
- at param j2k J2K handle
-*/
-static void j2k_read_poc(opj_j2k_t *j2k);
-/**
-Read the CRG marker (component registration)
- at param j2k J2K handle
-*/
-static void j2k_read_crg(opj_j2k_t *j2k);
-/**
-Read the TLM marker (tile-part lengths)
- at param j2k J2K handle
-*/
-static void j2k_read_tlm(opj_j2k_t *j2k);
-/**
-Read the PLM marker (packet length, main header)
- at param j2k J2K handle
-*/
-static void j2k_read_plm(opj_j2k_t *j2k);
-/**
-Read the PLT marker (packet length, tile-part header)
- at param j2k J2K handle
-*/
-static void j2k_read_plt(opj_j2k_t *j2k);
-/**
-Read the PPM marker (packet packet headers, main header)
- at param j2k J2K handle
-*/
-static void j2k_read_ppm(opj_j2k_t *j2k);
-/**
-Read the PPT marker (packet packet headers, tile-part header)
- at param j2k J2K handle
-*/
-static void j2k_read_ppt(opj_j2k_t *j2k);
-/**
-Write the TLM marker (Mainheader)
- at param j2k J2K handle
-*/
-static void j2k_write_tlm(opj_j2k_t *j2k);
-/**
-Write the SOT marker (start of tile-part)
- at param j2k J2K handle
-*/
-static void j2k_write_sot(opj_j2k_t *j2k);
-/**
-Read the SOT marker (start of tile-part)
- at param j2k J2K handle
-*/
-static void j2k_read_sot(opj_j2k_t *j2k);
-/**
-Write the SOD marker (start of data)
- at param j2k J2K handle
- at param tile_coder Pointer to a TCD handle
-*/
-static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder);
-/**
-Read the SOD marker (start of data)
- at param j2k J2K handle
-*/
-static void j2k_read_sod(opj_j2k_t *j2k);
-/**
-Write the RGN marker (region-of-interest)
- at param j2k J2K handle
- at param compno Number of the component concerned by the information written
- at param tileno Number of the tile concerned by the information written
-*/
-static void j2k_write_rgn(opj_j2k_t *j2k, int compno, int tileno);
-/**
-Read the RGN marker (region-of-interest)
- at param j2k J2K handle
-*/
-static void j2k_read_rgn(opj_j2k_t *j2k);
-/**
-Write the EOC marker (end of codestream)
- at param j2k J2K handle
-*/
-static void j2k_write_eoc(opj_j2k_t *j2k);
-/**
-Read the EOC marker (end of codestream)
- at param j2k J2K handle
-*/
-static void j2k_read_eoc(opj_j2k_t *j2k);
-/**
-Read an unknown marker
- at param j2k J2K handle
-*/
-static void j2k_read_unk(opj_j2k_t *j2k);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-typedef struct j2k_prog_order{
-	OPJ_PROG_ORDER enum_prog;
-	char str_prog[4];
-}j2k_prog_order_t;
-
-j2k_prog_order_t j2k_prog_order_list[] = {
-	{CPRL, "CPRL"},
-	{LRCP, "LRCP"},
-	{PCRL, "PCRL"},
-	{RLCP, "RLCP"},
-	{RPCL, "RPCL"},
-	{(OPJ_PROG_ORDER)-1, ""}
-};
-
-char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){
-	j2k_prog_order_t *po;
-	for(po = j2k_prog_order_list; po->enum_prog != -1; po++ ){
-		if(po->enum_prog == prg_order){
-			break;
-		}
-	}
-	return po->str_prog;
-}
-
-/* ----------------------------------------------------------------------- */
-static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){
-	char *prog;
-	int i;
-	int tpnum=1,tpend=0;
-	opj_tcp_t *tcp = &cp->tcps[tileno];
-	prog = j2k_convert_progression_order(tcp->prg);
-	
-	if(cp->tp_on == 1){
-		for(i=0;i<4;i++){
-			if(tpend!=1){
-				if( cp->tp_flag == prog[i] ){
-					tpend=1;cp->tp_pos=i;
-				}
-				switch(prog[i]){
-				case 'C':
-					tpnum= tpnum * tcp->pocs[pino].compE;
-					break;
-				case 'R':
-					tpnum= tpnum * tcp->pocs[pino].resE;
-					break;
-				case 'P':
-					tpnum= tpnum * tcp->pocs[pino].prcE;
-					break;
-				case 'L':
-					tpnum= tpnum * tcp->pocs[pino].layE;
-					break;
-				}
-			}
-		}
-	}else{
-		tpnum=1;
-	}
-	return tpnum;
-}
-
-/**	mem allocation for TLM marker*/
-int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t *j2k ){
-	int pino,tileno,totnum_tp=0;
-	j2k->cur_totnum_tp = (int *) opj_malloc(cp->tw * cp->th * sizeof(int));
-	for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-		int cur_totnum_tp = 0;
-		opj_tcp_t *tcp = &cp->tcps[tileno];
-		for(pino = 0; pino <= tcp->numpocs; pino++) {
-			int tp_num=0;
-			opj_pi_iterator_t *pi = pi_initialise_encode(image, cp, tileno,FINAL_PASS);
-			if(!pi) { return -1;}
-			tp_num = j2k_get_num_tp(cp,pino,tileno);
-			totnum_tp = totnum_tp + tp_num;
-			cur_totnum_tp = cur_totnum_tp + tp_num;
-			pi_destroy(pi, cp, tileno);
-		}
-		j2k->cur_totnum_tp[tileno] = cur_totnum_tp;
-		/* INDEX >> */
-		if (j2k->cstr_info) {
-			j2k->cstr_info->tile[tileno].num_tps = cur_totnum_tp;
-			j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(cur_totnum_tp * sizeof(opj_tp_info_t));
-		}
-		/* << INDEX */
-	}
-	return totnum_tp;
-}
-
-static void j2k_write_soc(opj_j2k_t *j2k) {
-	opj_cio_t *cio = j2k->cio;
-	cio_write(cio, J2K_MS_SOC, 2);
-
-/* UniPG>> */
-#ifdef USE_JPWL
-
-	/* update markers struct */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2);
-
-#endif /* USE_JPWL */
-/* <<UniPG */
-}
-
-static void j2k_read_soc(opj_j2k_t *j2k) {	
-	j2k->state = J2K_STATE_MHSIZ;
-	/* Index */
-	if (j2k->cstr_info) {
-		j2k->cstr_info->main_head_start = cio_tell(j2k->cio) - 2;
-		j2k->cstr_info->codestream_size = cio_numbytesleft(j2k->cio) + 2 - j2k->cstr_info->main_head_start;
-	}
-}
-
-static void j2k_write_siz(opj_j2k_t *j2k) {
-	int i;
-	int lenp, len;
-
-	opj_cio_t *cio = j2k->cio;
-	opj_image_t *image = j2k->image;
-	opj_cp_t *cp = j2k->cp;
-	
-	cio_write(cio, J2K_MS_SIZ, 2);	/* SIZ */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio, cp->rsiz, 2);			/* Rsiz (capabilities) */
-	cio_write(cio, image->x1, 4);	/* Xsiz */
-	cio_write(cio, image->y1, 4);	/* Ysiz */
-	cio_write(cio, image->x0, 4);	/* X0siz */
-	cio_write(cio, image->y0, 4);	/* Y0siz */
-	cio_write(cio, cp->tdx, 4);		/* XTsiz */
-	cio_write(cio, cp->tdy, 4);		/* YTsiz */
-	cio_write(cio, cp->tx0, 4);		/* XT0siz */
-	cio_write(cio, cp->ty0, 4);		/* YT0siz */
-	cio_write(cio, image->numcomps, 2);	/* Csiz */
-	for (i = 0; i < image->numcomps; i++) {
-		cio_write(cio, image->comps[i].prec - 1 + (image->comps[i].sgnd << 7), 1);	/* Ssiz_i */
-		cio_write(cio, image->comps[i].dx, 1);	/* XRsiz_i */
-		cio_write(cio, image->comps[i].dy, 1);	/* YRsiz_i */
-	}
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Lsiz */
-	cio_seek(cio, lenp + len);
-}
-
-static void j2k_read_siz(opj_j2k_t *j2k) {
-	int len, i;
-	
-	opj_cio_t *cio = j2k->cio;
-	opj_image_t *image = j2k->image;
-	opj_cp_t *cp = j2k->cp;
-	
-	len = cio_read(cio, 2);			/* Lsiz */
-	cio_read(cio, 2);				/* Rsiz (capabilities) */
-	image->x1 = cio_read(cio, 4);	/* Xsiz */
-	image->y1 = cio_read(cio, 4);	/* Ysiz */
-	image->x0 = cio_read(cio, 4);	/* X0siz */
-	image->y0 = cio_read(cio, 4);	/* Y0siz */
-	cp->tdx = cio_read(cio, 4);		/* XTsiz */
-	cp->tdy = cio_read(cio, 4);		/* YTsiz */
-	cp->tx0 = cio_read(cio, 4);		/* XT0siz */
-	cp->ty0 = cio_read(cio, 4);		/* YT0siz */
-	
-	if ((image->x0<0)||(image->x1<0)||(image->y0<0)||(image->y1<0)) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR,
-									"%s: invalid image size (x0:%d, x1:%d, y0:%d, y1:%d)\n",
-									image->x0,image->x1,image->y0,image->y1);
-		return;
-	}
-	
-	image->numcomps = cio_read(cio, 2);	/* Csiz */
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-		/* if JPWL is on, we check whether TX errors have damaged
-		  too much the SIZ parameters */
-		if (!(image->x1 * image->y1)) {
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"JPWL: bad image size (%d x %d)\n",
-				image->x1, image->y1);
-			if (!JPWL_ASSUME || JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-		}
-		if (image->numcomps != ((len - 38) / 3)) {
-			opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-				"JPWL: Csiz is %d => space in SIZ only for %d comps.!!!\n",
-				image->numcomps, ((len - 38) / 3));
-			if (!JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-			/* we try to correct */
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "- trying to adjust this\n");
-			if (image->numcomps < ((len - 38) / 3)) {
-				len = 38 + 3 * image->numcomps;
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "- setting Lsiz to %d => HYPOTHESIS!!!\n",
-					len);				
-			} else {
-				image->numcomps = ((len - 38) / 3);
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "- setting Csiz to %d => HYPOTHESIS!!!\n",
-					image->numcomps);				
-			}
-		}
-
-		/* update components number in the jpwl_exp_comps filed */
-		cp->exp_comps = image->numcomps;
-	}
-#endif /* USE_JPWL */
-
-	image->comps = (opj_image_comp_t*) opj_calloc(image->numcomps, sizeof(opj_image_comp_t));
-	for (i = 0; i < image->numcomps; i++) {
-		int tmp, w, h;
-		tmp = cio_read(cio, 1);		/* Ssiz_i */
-		image->comps[i].prec = (tmp & 0x7f) + 1;
-		image->comps[i].sgnd = tmp >> 7;
-		image->comps[i].dx = cio_read(cio, 1);	/* XRsiz_i */
-		image->comps[i].dy = cio_read(cio, 1);	/* YRsiz_i */
-		
-#ifdef USE_JPWL
-		if (j2k->cp->correct) {
-		/* if JPWL is on, we check whether TX errors have damaged
-			too much the SIZ parameters, again */
-			if (!(image->comps[i].dx * image->comps[i].dy)) {
-				opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-					"JPWL: bad XRsiz_%d/YRsiz_%d (%d x %d)\n",
-					i, i, image->comps[i].dx, image->comps[i].dy);
-				if (!JPWL_ASSUME) {
-					opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-					return;
-				}
-				/* we try to correct */
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "- trying to adjust them\n");
-				if (!image->comps[i].dx) {
-					image->comps[i].dx = 1;
-					opj_event_msg(j2k->cinfo, EVT_WARNING, "- setting XRsiz_%d to %d => HYPOTHESIS!!!\n",
-						i, image->comps[i].dx);
-				}
-				if (!image->comps[i].dy) {
-					image->comps[i].dy = 1;
-					opj_event_msg(j2k->cinfo, EVT_WARNING, "- setting YRsiz_%d to %d => HYPOTHESIS!!!\n",
-						i, image->comps[i].dy);
-				}
-			}
-			
-		}
-#endif /* USE_JPWL */
-
-		/* TODO: unused ? */
-		w = int_ceildiv(image->x1 - image->x0, image->comps[i].dx);
-		h = int_ceildiv(image->y1 - image->y0, image->comps[i].dy);
-
-		image->comps[i].resno_decoded = 0;	/* number of resolution decoded */
-		image->comps[i].factor = cp->reduce; /* reducing factor per component */
-	}
-	
-	cp->tw = int_ceildiv(image->x1 - cp->tx0, cp->tdx);
-	cp->th = int_ceildiv(image->y1 - cp->ty0, cp->tdy);
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-		/* if JPWL is on, we check whether TX errors have damaged
-		  too much the SIZ parameters */
-		if ((cp->tw < 1) || (cp->th < 1) || (cp->tw > cp->max_tiles) || (cp->th > cp->max_tiles)) {
-			opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-				"JPWL: bad number of tiles (%d x %d)\n",
-				cp->tw, cp->th);
-			if (!JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-			/* we try to correct */
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "- trying to adjust them\n");
-			if (cp->tw < 1) {
-				cp->tw= 1;
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "- setting %d tiles in x => HYPOTHESIS!!!\n",
-					cp->tw);
-			}
-			if (cp->tw > cp->max_tiles) {
-				cp->tw= 1;
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "- too large x, increase expectance of %d\n"
-					"- setting %d tiles in x => HYPOTHESIS!!!\n",
-					cp->max_tiles, cp->tw);
-			}
-			if (cp->th < 1) {
-				cp->th= 1;
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "- setting %d tiles in y => HYPOTHESIS!!!\n",
-					cp->th);
-			}
-			if (cp->th > cp->max_tiles) {
-				cp->th= 1;
-				opj_event_msg(j2k->cinfo, EVT_WARNING, "- too large y, increase expectance of %d to continue\n",
-					"- setting %d tiles in y => HYPOTHESIS!!!\n",
-					cp->max_tiles, cp->th);
-			}
-		}
-	}
-#endif /* USE_JPWL */
-
-	cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
-	cp->tileno = (int*) opj_malloc(cp->tw * cp->th * sizeof(int));
-	cp->tileno_size = 0;
-	
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-		if (!cp->tcps) {
-			opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-				"JPWL: could not alloc tcps field of cp\n");
-			if (!JPWL_ASSUME || JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-		}
-	}
-#endif /* USE_JPWL */
-
-	for (i = 0; i < cp->tw * cp->th; i++) {
-		cp->tcps[i].POC = 0;
-		cp->tcps[i].numpocs = 0;
-		cp->tcps[i].first = 1;
-	}
-	
-	/* Initialization for PPM marker */
-	cp->ppm = 0;
-	cp->ppm_data = NULL;
-	cp->ppm_data_first = NULL;
-	cp->ppm_previous = 0;
-	cp->ppm_store = 0;
-
-	j2k->default_tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(opj_tccp_t));
-	for (i = 0; i < cp->tw * cp->th; i++) {
-		cp->tcps[i].tccps = (opj_tccp_t*) opj_malloc(image->numcomps * sizeof(opj_tccp_t));
-	}	
-	j2k->tile_data = (unsigned char**) opj_calloc(cp->tw * cp->th, sizeof(unsigned char*));
-	j2k->tile_len = (int*) opj_calloc(cp->tw * cp->th, sizeof(int));
-	j2k->state = J2K_STATE_MH;
-
-	/* Index */
-	if (j2k->cstr_info) {
-		opj_codestream_info_t *cstr_info = j2k->cstr_info;
-		cstr_info->image_w = image->x1 - image->x0;
-		cstr_info->image_h = image->y1 - image->y0;
-		cstr_info->numcomps = image->numcomps;
-		cstr_info->tw = cp->tw;
-		cstr_info->th = cp->th;
-		cstr_info->tile_x = cp->tdx;	
-		cstr_info->tile_y = cp->tdy;	
-		cstr_info->tile_Ox = cp->tx0;	
-		cstr_info->tile_Oy = cp->ty0;			
-		cstr_info->tile = (opj_tile_info_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tile_info_t));		
-	}
-}
-
-static void j2k_write_com(opj_j2k_t *j2k) {
-	unsigned int i;
-	int lenp, len;
-
-	if(j2k->cp->comment) {
-		opj_cio_t *cio = j2k->cio;
-		char *comment = j2k->cp->comment;
-
-		cio_write(cio, J2K_MS_COM, 2);
-		lenp = cio_tell(cio);
-		cio_skip(cio, 2);
-		cio_write(cio, 1, 2);		/* General use (IS 8859-15:1999 (Latin) values) */
-		for (i = 0; i < strlen(comment); i++) {
-			cio_write(cio, comment[i], 1);
-		}
-		len = cio_tell(cio) - lenp;
-		cio_seek(cio, lenp);
-		cio_write(cio, len, 2);
-		cio_seek(cio, lenp + len);
-	}
-}
-
-static void j2k_read_com(opj_j2k_t *j2k) {
-	int len;
-	
-	opj_cio_t *cio = j2k->cio;
-
-	len = cio_read(cio, 2);
-	cio_skip(cio, len - 2);  
-}
-
-static void j2k_write_cox(opj_j2k_t *j2k, int compno) {
-	int i;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = &cp->tcps[j2k->curtileno];
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j2k->cio;
-	
-	cio_write(cio, tccp->numresolutions - 1, 1);	/* SPcox (D) */
-	cio_write(cio, tccp->cblkw - 2, 1);				/* SPcox (E) */
-	cio_write(cio, tccp->cblkh - 2, 1);				/* SPcox (F) */
-	cio_write(cio, tccp->cblksty, 1);				/* SPcox (G) */
-	cio_write(cio, tccp->qmfbid, 1);				/* SPcox (H) */
-	
-	if (tccp->csty & J2K_CCP_CSTY_PRT) {
-		for (i = 0; i < tccp->numresolutions; i++) {
-			cio_write(cio, tccp->prcw[i] + (tccp->prch[i] << 4), 1);	/* SPcox (I_i) */
-		}
-	}
-}
-
-static void j2k_read_cox(opj_j2k_t *j2k, int compno) {
-	int i;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = j2k->state == J2K_STATE_TPH ? &cp->tcps[j2k->curtileno] : j2k->default_tcp;
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j2k->cio;
-
-	tccp->numresolutions = cio_read(cio, 1) + 1;	/* SPcox (D) */
-
-	// If user wants to remove more resolutions than the codestream contains, return error
-	if (cp->reduce >= tccp->numresolutions) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number "
-					"of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
-		j2k->state |= J2K_STATE_ERR;
-	}
-
-	tccp->cblkw = cio_read(cio, 1) + 2;	/* SPcox (E) */
-	tccp->cblkh = cio_read(cio, 1) + 2;	/* SPcox (F) */
-	tccp->cblksty = cio_read(cio, 1);	/* SPcox (G) */
-	tccp->qmfbid = cio_read(cio, 1);	/* SPcox (H) */
-	if (tccp->csty & J2K_CP_CSTY_PRT) {
-		for (i = 0; i < tccp->numresolutions; i++) {
-			int tmp = cio_read(cio, 1);	/* SPcox (I_i) */
-			tccp->prcw[i] = tmp & 0xf;
-			tccp->prch[i] = tmp >> 4;
-		}
-	}
-
-	/* INDEX >> */
-	if(j2k->cstr_info && compno == 0) {
-		for (i = 0; i < tccp->numresolutions; i++) {
-			if (tccp->csty & J2K_CP_CSTY_PRT) {
-				j2k->cstr_info->tile[j2k->curtileno].pdx[i] = tccp->prcw[i];
-				j2k->cstr_info->tile[j2k->curtileno].pdy[i] = tccp->prch[i];
-			}
-			else {
-				j2k->cstr_info->tile[j2k->curtileno].pdx[i] = 15;
-				j2k->cstr_info->tile[j2k->curtileno].pdx[i] = 15;
-			}
-		}
-	}
-	/* << INDEX */
-}
-
-static void j2k_write_cod(opj_j2k_t *j2k) {
-	opj_cp_t *cp = NULL;
-	opj_tcp_t *tcp = NULL;
-	int lenp, len;
-
-	opj_cio_t *cio = j2k->cio;
-	
-	cio_write(cio, J2K_MS_COD, 2);	/* COD */
-	
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	
-	cp = j2k->cp;
-	tcp = &cp->tcps[j2k->curtileno];
-
-	cio_write(cio, tcp->csty, 1);		/* Scod */
-	cio_write(cio, tcp->prg, 1);		/* SGcod (A) */
-	cio_write(cio, tcp->numlayers, 2);	/* SGcod (B) */
-	cio_write(cio, tcp->mct, 1);		/* SGcod (C) */
-	
-	j2k_write_cox(j2k, 0);
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);		/* Lcod */
-	cio_seek(cio, lenp + len);
-}
-
-static void j2k_read_cod(opj_j2k_t *j2k) {
-	int len, i, pos;
-	
-	opj_cio_t *cio = j2k->cio;
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = j2k->state == J2K_STATE_TPH ? &cp->tcps[j2k->curtileno] : j2k->default_tcp;
-	opj_image_t *image = j2k->image;
-	
-	len = cio_read(cio, 2);				/* Lcod */
-	tcp->csty = cio_read(cio, 1);		/* Scod */
-	tcp->prg = (OPJ_PROG_ORDER)cio_read(cio, 1);		/* SGcod (A) */
-	tcp->numlayers = cio_read(cio, 2);	/* SGcod (B) */
-	tcp->mct = cio_read(cio, 1);		/* SGcod (C) */
-	
-	pos = cio_tell(cio);
-	for (i = 0; i < image->numcomps; i++) {
-		tcp->tccps[i].csty = tcp->csty & J2K_CP_CSTY_PRT;
-		cio_seek(cio, pos);
-		j2k_read_cox(j2k, i);
-	}
-
-	/* Index */
-	if (j2k->cstr_info) {
-		opj_codestream_info_t *cstr_info = j2k->cstr_info;
-		cstr_info->prog = tcp->prg;
-		cstr_info->numlayers = tcp->numlayers;
-		cstr_info->numdecompos = (int*) opj_malloc(image->numcomps * sizeof(int));
-		for (i = 0; i < image->numcomps; i++) {
-			cstr_info->numdecompos[i] = tcp->tccps[i].numresolutions - 1;
-		}
-	}
-}
-
-static void j2k_write_coc(opj_j2k_t *j2k, int compno) {
-	int lenp, len;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = &cp->tcps[j2k->curtileno];
-	opj_image_t *image = j2k->image;
-	opj_cio_t *cio = j2k->cio;
-	
-	cio_write(cio, J2K_MS_COC, 2);	/* COC */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio, compno, image->numcomps <= 256 ? 1 : 2);	/* Ccoc */
-	cio_write(cio, tcp->tccps[compno].csty, 1);	/* Scoc */
-	j2k_write_cox(j2k, compno);
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);			/* Lcoc */
-	cio_seek(cio, lenp + len);
-}
-
-static void j2k_read_coc(opj_j2k_t *j2k) {
-	int len, compno;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = j2k->state == J2K_STATE_TPH ? &cp->tcps[j2k->curtileno] : j2k->default_tcp;
-	opj_image_t *image = j2k->image;
-	opj_cio_t *cio = j2k->cio;
-	
-	len = cio_read(cio, 2);		/* Lcoc */
-	compno = cio_read(cio, image->numcomps <= 256 ? 1 : 2);	/* Ccoc */
-	tcp->tccps[compno].csty = cio_read(cio, 1);	/* Scoc */
-	j2k_read_cox(j2k, compno);
-}
-
-static void j2k_write_qcx(opj_j2k_t *j2k, int compno) {
-	int bandno, numbands;
-	int expn, mant;
-	
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = &cp->tcps[j2k->curtileno];
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j2k->cio;
-	
-	cio_write(cio, tccp->qntsty + (tccp->numgbits << 5), 1);	/* Sqcx */
-	numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
-	
-	for (bandno = 0; bandno < numbands; bandno++) {
-		expn = tccp->stepsizes[bandno].expn;
-		mant = tccp->stepsizes[bandno].mant;
-		
-		if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
-			cio_write(cio, expn << 3, 1);	/* SPqcx_i */
-		} else {
-			cio_write(cio, (expn << 11) + mant, 2);	/* SPqcx_i */
-		}
-	}
-}
-
-static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) {
-	int tmp;
-	int bandno, numbands;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = j2k->state == J2K_STATE_TPH ? &cp->tcps[j2k->curtileno] : j2k->default_tcp;
-	opj_tccp_t *tccp = &tcp->tccps[compno];
-	opj_cio_t *cio = j2k->cio;
-
-	tmp = cio_read(cio, 1);		/* Sqcx */
-	tccp->qntsty = tmp & 0x1f;
-	tccp->numgbits = tmp >> 5;
-	numbands = (tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 
-		1 : ((tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) ? len - 1 : (len - 1) / 2);
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-
-		/* if JPWL is on, we check whether there are too many subbands */
-		if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) {
-			opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-				"JPWL: bad number of subbands in Sqcx (%d)\n",
-				numbands);
-			if (!JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-			/* we try to correct */
-			numbands = 1;
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "- trying to adjust them\n"
-				"- setting number of bands to %d => HYPOTHESIS!!!\n",
-				numbands);
-		};
-
-	};
-#endif /* USE_JPWL */
-
-	for (bandno = 0; bandno < numbands; bandno++) {
-		int expn, mant;
-		if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
-			expn = cio_read(cio, 1) >> 3;	/* SPqcx_i */
-			mant = 0;
-		} else {
-			tmp = cio_read(cio, 2);	/* SPqcx_i */
-			expn = tmp >> 11;
-			mant = tmp & 0x7ff;
-		}
-		tccp->stepsizes[bandno].expn = expn;
-		tccp->stepsizes[bandno].mant = mant;
-	}
-	
-	/* Add Antonin : if scalar_derived -> compute other stepsizes */
-	if (tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) {
-		for (bandno = 1; bandno < J2K_MAXBANDS; bandno++) {
-			tccp->stepsizes[bandno].expn = 
-				((tccp->stepsizes[0].expn) - ((bandno - 1) / 3) > 0) ? 
-					(tccp->stepsizes[0].expn) - ((bandno - 1) / 3) : 0;
-			tccp->stepsizes[bandno].mant = tccp->stepsizes[0].mant;
-		}
-	}
-	/* ddA */
-}
-
-static void j2k_write_qcd(opj_j2k_t *j2k) {
-	int lenp, len;
-
-	opj_cio_t *cio = j2k->cio;
-	
-	cio_write(cio, J2K_MS_QCD, 2);	/* QCD */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	j2k_write_qcx(j2k, 0);
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);			/* Lqcd */
-	cio_seek(cio, lenp + len);
-}
-
-static void j2k_read_qcd(opj_j2k_t *j2k) {
-	int len, i, pos;
-
-	opj_cio_t *cio = j2k->cio;
-	opj_image_t *image = j2k->image;
-	
-	len = cio_read(cio, 2);		/* Lqcd */
-	pos = cio_tell(cio);
-	for (i = 0; i < image->numcomps; i++) {
-		cio_seek(cio, pos);
-		j2k_read_qcx(j2k, i, len - 2);
-	}
-}
-
-static void j2k_write_qcc(opj_j2k_t *j2k, int compno) {
-	int lenp, len;
-
-	opj_cio_t *cio = j2k->cio;
-	
-	cio_write(cio, J2K_MS_QCC, 2);	/* QCC */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);
-	cio_write(cio, compno, j2k->image->numcomps <= 256 ? 1 : 2);	/* Cqcc */
-	j2k_write_qcx(j2k, compno);
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);			/* Lqcc */
-	cio_seek(cio, lenp + len);
-}
-
-static void j2k_read_qcc(opj_j2k_t *j2k) {
-	int len, compno;
-	int numcomp = j2k->image->numcomps;
-	opj_cio_t *cio = j2k->cio;
-	
-	len = cio_read(cio, 2);	/* Lqcc */
-	compno = cio_read(cio, numcomp <= 256 ? 1 : 2);	/* Cqcc */
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-
-		static int backup_compno = 0;
-
-		/* compno is negative or larger than the number of components!!! */
-		if ((compno < 0) || (compno >= numcomp)) {
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"JPWL: bad component number in QCC (%d out of a maximum of %d)\n",
-				compno, numcomp);
-			if (!JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-			/* we try to correct */
-			compno = backup_compno % numcomp;
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "- trying to adjust this\n"
-				"- setting component number to %d\n",
-				compno);
-		}
-
-		/* keep your private count of tiles */
-		backup_compno++;
-	};
-#endif /* USE_JPWL */
-
-	j2k_read_qcx(j2k, compno, len - 2 - (numcomp <= 256 ? 1 : 2));
-}
-
-static void j2k_write_poc(opj_j2k_t *j2k) {
-	int len, numpchgs, i;
-
-	int numcomps = j2k->image->numcomps;
-	
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = &cp->tcps[j2k->curtileno];
-	opj_tccp_t *tccp = &tcp->tccps[0];
-	opj_cio_t *cio = j2k->cio;
-
-	numpchgs = 1 + tcp->numpocs;
-	cio_write(cio, J2K_MS_POC, 2);	/* POC  */
-	len = 2 + (5 + 2 * (numcomps <= 256 ? 1 : 2)) * numpchgs;
-	cio_write(cio, len, 2);		/* Lpoc */
-	for (i = 0; i < numpchgs; i++) {
-		opj_poc_t *poc = &tcp->pocs[i];
-		cio_write(cio, poc->resno0, 1);	/* RSpoc_i */
-		cio_write(cio, poc->compno0, (numcomps <= 256 ? 1 : 2));	/* CSpoc_i */
-		cio_write(cio, poc->layno1, 2);	/* LYEpoc_i */
-		poc->layno1 = int_min(poc->layno1, tcp->numlayers);
-		cio_write(cio, poc->resno1, 1);	/* REpoc_i */
-		poc->resno1 = int_min(poc->resno1, tccp->numresolutions);
-		cio_write(cio, poc->compno1, (numcomps <= 256 ? 1 : 2));	/* CEpoc_i */
-		poc->compno1 = int_min(poc->compno1, numcomps);
-		cio_write(cio, poc->prg, 1);	/* Ppoc_i */
-	}
-}
-
-static void j2k_read_poc(opj_j2k_t *j2k) {
-	int len, numpchgs, i, old_poc;
-
-	int numcomps = j2k->image->numcomps;
-	
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = j2k->state == J2K_STATE_TPH ? &cp->tcps[j2k->curtileno] : j2k->default_tcp;
-	opj_cio_t *cio = j2k->cio;
-	
-	old_poc = tcp->POC ? tcp->numpocs + 1 : 0;
-	tcp->POC = 1;
-	len = cio_read(cio, 2);		/* Lpoc */
-	numpchgs = (len - 2) / (5 + 2 * (numcomps <= 256 ? 1 : 2));
-	
-	for (i = old_poc; i < numpchgs + old_poc; i++) {
-		opj_poc_t *poc;
-		poc = &tcp->pocs[i];
-		poc->resno0 = cio_read(cio, 1);	/* RSpoc_i */
-		poc->compno0 = cio_read(cio, numcomps <= 256 ? 1 : 2);	/* CSpoc_i */
-		poc->layno1 = cio_read(cio, 2);    /* LYEpoc_i */
-		poc->resno1 = cio_read(cio, 1);    /* REpoc_i */
-		poc->compno1 = int_min(
-			cio_read(cio, numcomps <= 256 ? 1 : 2), (unsigned int) numcomps);	/* CEpoc_i */
-		poc->prg = (OPJ_PROG_ORDER)cio_read(cio, 1);	/* Ppoc_i */
-	}
-	
-	tcp->numpocs = numpchgs + old_poc - 1;
-}
-
-static void j2k_read_crg(opj_j2k_t *j2k) {
-	int len, i, Xcrg_i, Ycrg_i;
-	
-	opj_cio_t *cio = j2k->cio;
-	int numcomps = j2k->image->numcomps;
-	
-	len = cio_read(cio, 2);			/* Lcrg */
-	for (i = 0; i < numcomps; i++) {
-		Xcrg_i = cio_read(cio, 2);	/* Xcrg_i */
-		Ycrg_i = cio_read(cio, 2);	/* Ycrg_i */
-	}
-}
-
-static void j2k_read_tlm(opj_j2k_t *j2k) {
-	int len, Ztlm, Stlm, ST, SP, tile_tlm, i;
-	long int Ttlm_i, Ptlm_i;
-
-	opj_cio_t *cio = j2k->cio;
-	
-	len = cio_read(cio, 2);		/* Ltlm */
-	Ztlm = cio_read(cio, 1);	/* Ztlm */
-	Stlm = cio_read(cio, 1);	/* Stlm */
-	ST = ((Stlm >> 4) & 0x01) + ((Stlm >> 4) & 0x02);
-	SP = (Stlm >> 6) & 0x01;
-	tile_tlm = (len - 4) / ((SP + 1) * 2 + ST);
-	for (i = 0; i < tile_tlm; i++) {
-		Ttlm_i = cio_read(cio, ST);	/* Ttlm_i */
-		Ptlm_i = cio_read(cio, SP ? 4 : 2);	/* Ptlm_i */
-	}
-}
-
-static void j2k_read_plm(opj_j2k_t *j2k) {
-	int len, i, Zplm, Nplm, add, packet_len = 0;
-	
-	opj_cio_t *cio = j2k->cio;
-
-	len = cio_read(cio, 2);		/* Lplm */
-	Zplm = cio_read(cio, 1);	/* Zplm */
-	len -= 3;
-	while (len > 0) {
-		Nplm = cio_read(cio, 4);		/* Nplm */
-		len -= 4;
-		for (i = Nplm; i > 0; i--) {
-			add = cio_read(cio, 1);
-			len--;
-			packet_len = (packet_len << 7) + add;	/* Iplm_ij */
-			if ((add & 0x80) == 0) {
-				/* New packet */
-				packet_len = 0;
-			}
-			if (len <= 0)
-				break;
-		}
-	}
-}
-
-static void j2k_read_plt(opj_j2k_t *j2k) {
-	int len, i, Zplt, packet_len = 0, add;
-	
-	opj_cio_t *cio = j2k->cio;
-	
-	len = cio_read(cio, 2);		/* Lplt */
-	Zplt = cio_read(cio, 1);	/* Zplt */
-	for (i = len - 3; i > 0; i--) {
-		add = cio_read(cio, 1);
-		packet_len = (packet_len << 7) + add;	/* Iplt_i */
-		if ((add & 0x80) == 0) {
-			/* New packet */
-			packet_len = 0;
-		}
-	}
-}
-
-static void j2k_read_ppm(opj_j2k_t *j2k) {
-	int len, Z_ppm, i, j;
-	int N_ppm;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_cio_t *cio = j2k->cio;
-	
-	len = cio_read(cio, 2);
-	cp->ppm = 1;
-	
-	Z_ppm = cio_read(cio, 1);	/* Z_ppm */
-	len -= 3;
-	while (len > 0) {
-		if (cp->ppm_previous == 0) {
-			N_ppm = cio_read(cio, 4);	/* N_ppm */
-			len -= 4;
-		} else {
-			N_ppm = cp->ppm_previous;
-		}
-		j = cp->ppm_store;
-		if (Z_ppm == 0) {	/* First PPM marker */
-			cp->ppm_data = (unsigned char *) opj_malloc(N_ppm * sizeof(unsigned char));
-			cp->ppm_data_first = cp->ppm_data;
-			cp->ppm_len = N_ppm;
-		} else {			/* NON-first PPM marker */
-			cp->ppm_data = (unsigned char *) opj_realloc(cp->ppm_data, (N_ppm +	cp->ppm_store) * sizeof(unsigned char));
-
-#ifdef USE_JPWL
-			/* this memory allocation check could be done even in non-JPWL cases */
-			if (cp->correct) {
-				if (!cp->ppm_data) {
-					opj_event_msg(j2k->cinfo, EVT_ERROR,
-						"JPWL: failed memory allocation during PPM marker parsing (pos. %x)\n",
-						cio_tell(cio));
-					if (!JPWL_ASSUME || JPWL_ASSUME) {
-						opj_free(cp->ppm_data);
-						opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-						return;
-					}
-				}
-			}
-#endif
-
-			cp->ppm_data_first = cp->ppm_data;
-			cp->ppm_len = N_ppm + cp->ppm_store;
-		}
-		for (i = N_ppm; i > 0; i--) {	/* Read packet header */
-			cp->ppm_data[j] = cio_read(cio, 1);
-			j++;
-			len--;
-			if (len == 0)
-				break;			/* Case of non-finished packet header in present marker but finished in next one */
-		}
-		cp->ppm_previous = i - 1;
-		cp->ppm_store = j;
-	}
-}
-
-static void j2k_read_ppt(opj_j2k_t *j2k) {
-	int len, Z_ppt, i, j = 0;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = cp->tcps + j2k->curtileno;
-	opj_cio_t *cio = j2k->cio;
-
-	len = cio_read(cio, 2);
-	Z_ppt = cio_read(cio, 1);
-	tcp->ppt = 1;
-	if (Z_ppt == 0) {		/* First PPT marker */
-		tcp->ppt_data = (unsigned char *) opj_malloc((len - 3) * sizeof(unsigned char));
-		tcp->ppt_data_first = tcp->ppt_data;
-		tcp->ppt_store = 0;
-		tcp->ppt_len = len - 3;
-	} else {			/* NON-first PPT marker */
-		tcp->ppt_data =	(unsigned char *) opj_realloc(tcp->ppt_data, (len - 3 + tcp->ppt_store) * sizeof(unsigned char));
-		tcp->ppt_data_first = tcp->ppt_data;
-		tcp->ppt_len = len - 3 + tcp->ppt_store;
-	}
-	j = tcp->ppt_store;
-	for (i = len - 3; i > 0; i--) {
-		tcp->ppt_data[j] = cio_read(cio, 1);
-		j++;
-	}
-	tcp->ppt_store = j;
-}
-
-static void j2k_write_tlm(opj_j2k_t *j2k){
-	int lenp;
-	opj_cio_t *cio = j2k->cio;
-	j2k->tlm_start = cio_tell(cio);
-	cio_write(cio, J2K_MS_TLM, 2);/* TLM */
-	lenp = 4 + (5*j2k->totnum_tp);
-	cio_write(cio,lenp,2);				/* Ltlm */
-	cio_write(cio, 0,1);					/* Ztlm=0*/
-	cio_write(cio,80,1);					/* Stlm ST=1(8bits-255 tiles max),SP=1(Ptlm=32bits) */
-	cio_skip(cio,5*j2k->totnum_tp);
-}
-
-static void j2k_write_sot(opj_j2k_t *j2k) {
-	int lenp, len;
-
-	opj_cio_t *cio = j2k->cio;
-
-	j2k->sot_start = cio_tell(cio);
-	cio_write(cio, J2K_MS_SOT, 2);		/* SOT */
-	lenp = cio_tell(cio);
-	cio_skip(cio, 2);					/* Lsot (further) */
-	cio_write(cio, j2k->curtileno, 2);	/* Isot */
-	cio_skip(cio, 4);					/* Psot (further in j2k_write_sod) */
-	cio_write(cio, j2k->cur_tp_num , 1);	/* TPsot */
-	cio_write(cio, j2k->cur_totnum_tp[j2k->curtileno], 1);		/* TNsot */
-	len = cio_tell(cio) - lenp;
-	cio_seek(cio, lenp);
-	cio_write(cio, len, 2);				/* Lsot */
-	cio_seek(cio, lenp + len);
-
-	/* UniPG>> */
-#ifdef USE_JPWL
-	/* update markers struct */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2);
-#endif /* USE_JPWL */
-	/* <<UniPG */
-}
-
-static void j2k_read_sot(opj_j2k_t *j2k) {
-	int len, tileno, totlen, partno, numparts, i;
-	opj_tcp_t *tcp = NULL;
-	char status = 0;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_cio_t *cio = j2k->cio;
-
-	len = cio_read(cio, 2);
-	tileno = cio_read(cio, 2);
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-
-		static int backup_tileno = 0;
-
-		/* tileno is negative or larger than the number of tiles!!! */
-		if ((tileno < 0) || (tileno > (cp->tw * cp->th))) {
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"JPWL: bad tile number (%d out of a maximum of %d)\n",
-				tileno, (cp->tw * cp->th));
-			if (!JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-			/* we try to correct */
-			tileno = backup_tileno;
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "- trying to adjust this\n"
-				"- setting tile number to %d\n",
-				tileno);
-		}
-
-		/* keep your private count of tiles */
-		backup_tileno++;
-	};
-#endif /* USE_JPWL */
-	
-	if (cp->tileno_size == 0) {
-		cp->tileno[cp->tileno_size] = tileno;
-		cp->tileno_size++;
-	} else {
-		i = 0;
-		while (i < cp->tileno_size && status == 0) {
-			status = cp->tileno[i] == tileno ? 1 : 0;
-			i++;
-		}
-		if (status == 0) {
-			cp->tileno[cp->tileno_size] = tileno;
-			cp->tileno_size++;
-		}
-	}
-	
-	totlen = cio_read(cio, 4);
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-
-		/* totlen is negative or larger than the bytes left!!! */
-		if ((totlen < 0) || (totlen > (cio_numbytesleft(cio) + 8))) {
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"JPWL: bad tile byte size (%d bytes against %d bytes left)\n",
-				totlen, cio_numbytesleft(cio) + 8);
-			if (!JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-			/* we try to correct */
-			totlen = 0;
-			opj_event_msg(j2k->cinfo, EVT_WARNING, "- trying to adjust this\n"
-				"- setting Psot to %d => assuming it is the last tile\n",
-				totlen);
-		}
-
-	};
-#endif /* USE_JPWL */
-
-	if (!totlen)
-		totlen = cio_numbytesleft(cio) + 8;
-	
-	partno = cio_read(cio, 1);
-	numparts = cio_read(cio, 1);
-	
-	j2k->curtileno = tileno;
-	j2k->cur_tp_num = partno;
-	j2k->eot = cio_getbp(cio) - 12 + totlen;
-	j2k->state = J2K_STATE_TPH;
-	tcp = &cp->tcps[j2k->curtileno];
-
-	/* Index */
-	if (j2k->cstr_info) {
-		if (tcp->first) {
-			if (tileno == 0) 
-				j2k->cstr_info->main_head_end = cio_tell(cio) - 13;
-			j2k->cstr_info->tile[tileno].tileno = tileno;
-			j2k->cstr_info->tile[tileno].start_pos = cio_tell(cio) - 12;
-			j2k->cstr_info->tile[tileno].end_pos = j2k->cstr_info->tile[tileno].start_pos + totlen - 1;				
-			j2k->cstr_info->tile[tileno].num_tps = numparts;
-			if (numparts)
-				j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t));
-			else
-				j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10)
-		}
-		else {
-			j2k->cstr_info->tile[tileno].end_pos += totlen;
-		}		
-		j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = cio_tell(cio) - 12;
-		j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos = 
-			j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1;
-	}
-	
-	if (tcp->first == 1) {		
-		/* Initialization PPT */
-		opj_tccp_t *tmp = tcp->tccps;
-		memcpy(tcp, j2k->default_tcp, sizeof(opj_tcp_t));
-		tcp->ppt = 0;
-		tcp->ppt_data = NULL;
-		tcp->ppt_data_first = NULL;
-		tcp->tccps = tmp;
-
-		for (i = 0; i < j2k->image->numcomps; i++) {
-			tcp->tccps[i] = j2k->default_tcp->tccps[i];
-		}
-		cp->tcps[j2k->curtileno].first = 0;
-	}
-}
-
-static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
-	int l, layno;
-	int totlen;
-	opj_tcp_t *tcp = NULL;
-	opj_codestream_info_t *cstr_info = NULL;
-	
-	opj_tcd_t *tcd = (opj_tcd_t*)tile_coder;	/* cast is needed because of conflicts in header inclusions */
-	opj_cp_t *cp = j2k->cp;
-	opj_cio_t *cio = j2k->cio;
-
-	tcd->tp_num = j2k->tp_num ;
-	tcd->cur_tp_num = j2k->cur_tp_num;
-	
-	cio_write(cio, J2K_MS_SOD, 2);
-	if (j2k->curtileno == 0) {
-		j2k->sod_start = cio_tell(cio) + j2k->pos_correction;
-	}
-
-	/* INDEX >> */
-	cstr_info = j2k->cstr_info;
-	if (cstr_info) {
-		if (!j2k->cur_tp_num ) {
-			cstr_info->tile[j2k->curtileno].end_header = cio_tell(cio) + j2k->pos_correction - 1;
-			j2k->cstr_info->tile[j2k->curtileno].tileno = j2k->curtileno;
-		}
-		else{
-			if(cstr_info->tile[j2k->curtileno].packet[cstr_info->packno - 1].end_pos < cio_tell(cio))
-				cstr_info->tile[j2k->curtileno].packet[cstr_info->packno].start_pos = cio_tell(cio);
-		}
-		/* UniPG>> */
-#ifdef USE_JPWL
-		/* update markers struct */
-		j2k_add_marker(j2k->cstr_info, J2K_MS_SOD, j2k->sod_start, 2);
-#endif /* USE_JPWL */
-		/* <<UniPG */
-	}
-	/* << INDEX */
-	
-	tcp = &cp->tcps[j2k->curtileno];
-	for (layno = 0; layno < tcp->numlayers; layno++) {
-		if (tcp->rates[layno]>(j2k->sod_start / (cp->th * cp->tw))) {
-			tcp->rates[layno]-=(j2k->sod_start / (cp->th * cp->tw));
-		} else if (tcp->rates[layno]) {
-			tcp->rates[layno]=1;
-		}
-	}
-	if(j2k->cur_tp_num == 0){
-		tcd->tcd_image->tiles->packno = 0;
-		if(cstr_info)
-			cstr_info->packno = 0;
-	}
-	
-	l = tcd_encode_tile(tcd, j2k->curtileno, cio_getbp(cio), cio_numbytesleft(cio) - 2, cstr_info);
-	
-	/* Writing Psot in SOT marker */
-	totlen = cio_tell(cio) + l - j2k->sot_start;
-	cio_seek(cio, j2k->sot_start + 6);
-	cio_write(cio, totlen, 4);
-	cio_seek(cio, j2k->sot_start + totlen);
-	/* Writing Ttlm and Ptlm in TLM marker */
-	if(cp->cinema){
-		cio_seek(cio, j2k->tlm_start + 6 + (5*j2k->cur_tp_num));
-		cio_write(cio, j2k->curtileno, 1);
-		cio_write(cio, totlen, 4);
-	}
-	cio_seek(cio, j2k->sot_start + totlen);
-}
-
-static void j2k_read_sod(opj_j2k_t *j2k) {
-	int len, truncate = 0, i;
-	unsigned char *data = NULL, *data_ptr = NULL;
-
-	opj_cio_t *cio = j2k->cio;
-	int curtileno = j2k->curtileno;
-
-	/* Index */
-	if (j2k->cstr_info) {
-		j2k->cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_end_header =
-			cio_tell(cio) + j2k->pos_correction - 1;
-		if (j2k->cur_tp_num == 0)
-			j2k->cstr_info->tile[j2k->curtileno].end_header = cio_tell(cio) + j2k->pos_correction - 1;
-		j2k->cstr_info->packno = 0;
-	}
-	
-	len = int_min(j2k->eot - cio_getbp(cio), cio_numbytesleft(cio) + 1);
-
-	if (len == cio_numbytesleft(cio) + 1) {
-		truncate = 1;		/* Case of a truncate codestream */
-	}	
-
-	data = j2k->tile_data[curtileno];
-	data = (unsigned char*) opj_realloc(data, (j2k->tile_len[curtileno] + len) * sizeof(unsigned char));
-
-	data_ptr = data + j2k->tile_len[curtileno];
-	for (i = 0; i < len; i++) {
-		data_ptr[i] = cio_read(cio, 1);
-	}
-
-	j2k->tile_len[curtileno] += len;
-	j2k->tile_data[curtileno] = data;
-	
-	if (!truncate) {
-		j2k->state = J2K_STATE_TPHSOT;
-	} else {
-		j2k->state = J2K_STATE_NEOC;	/* RAJOUTE !! */
-	}
-	j2k->cur_tp_num++;
-}
-
-static void j2k_write_rgn(opj_j2k_t *j2k, int compno, int tileno) {
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = &cp->tcps[tileno];
-	opj_cio_t *cio = j2k->cio;
-	int numcomps = j2k->image->numcomps;
-	
-	cio_write(cio, J2K_MS_RGN, 2);						/* RGN  */
-	cio_write(cio, numcomps <= 256 ? 5 : 6, 2);			/* Lrgn */
-	cio_write(cio, compno, numcomps <= 256 ? 1 : 2);	/* Crgn */
-	cio_write(cio, 0, 1);								/* Srgn */
-	cio_write(cio, tcp->tccps[compno].roishift, 1);		/* SPrgn */
-}
-
-static void j2k_read_rgn(opj_j2k_t *j2k) {
-	int len, compno, roisty;
-
-	opj_cp_t *cp = j2k->cp;
-	opj_tcp_t *tcp = j2k->state == J2K_STATE_TPH ? &cp->tcps[j2k->curtileno] : j2k->default_tcp;
-	opj_cio_t *cio = j2k->cio;
-	int numcomps = j2k->image->numcomps;
-
-	len = cio_read(cio, 2);										/* Lrgn */
-	compno = cio_read(cio, numcomps <= 256 ? 1 : 2);			/* Crgn */
-	roisty = cio_read(cio, 1);									/* Srgn */
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-		/* totlen is negative or larger than the bytes left!!! */
-		if (compno >= numcomps) {
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"JPWL: bad component number in RGN (%d when there are only %d)\n",
-				compno, numcomps);
-			if (!JPWL_ASSUME || JPWL_ASSUME) {
-				opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-				return;
-			}
-		}
-	};
-#endif /* USE_JPWL */
-
-	tcp->tccps[compno].roishift = cio_read(cio, 1);				/* SPrgn */
-}
-
-static void j2k_write_eoc(opj_j2k_t *j2k) {
-	opj_cio_t *cio = j2k->cio;
-	/* opj_event_msg(j2k->cinfo, "%.8x: EOC\n", cio_tell(cio) + j2k->pos_correction); */
-	cio_write(cio, J2K_MS_EOC, 2);
-
-/* UniPG>> */
-#ifdef USE_JPWL
-	/* update markers struct */
-	j2k_add_marker(j2k->cstr_info, J2K_MS_EOC, cio_tell(cio) - 2, 2);
-#endif /* USE_JPWL */
-/* <<UniPG */
-}
-
-static void j2k_read_eoc(opj_j2k_t *j2k) {
-	int i, tileno;
-	bool success;
-
-	/* if packets should be decoded */
-	if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) {
-		opj_tcd_t *tcd = tcd_create(j2k->cinfo);
-		tcd_malloc_decode(tcd, j2k->image, j2k->cp);
-		for (i = 0; i < j2k->cp->tileno_size; i++) {
-			tcd_malloc_decode_tile(tcd, j2k->image, j2k->cp, i, j2k->cstr_info);
-			tileno = j2k->cp->tileno[i];
-			success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
-			opj_free(j2k->tile_data[tileno]);
-			j2k->tile_data[tileno] = NULL;
-			tcd_free_decode_tile(tcd, i);
-			if (success == false) {
-				j2k->state |= J2K_STATE_ERR;
-				break;
-			}
-		}
-		tcd_free_decode(tcd);
-		tcd_destroy(tcd);
-	}
-	/* if packets should not be decoded  */
-	else {
-		for (i = 0; i < j2k->cp->tileno_size; i++) {
-			tileno = j2k->cp->tileno[i];
-			opj_free(j2k->tile_data[tileno]);
-			j2k->tile_data[tileno] = NULL;
-		}
-	}	
-	if (j2k->state & J2K_STATE_ERR)
-		j2k->state = J2K_STATE_MT + J2K_STATE_ERR;
-	else
-		j2k->state = J2K_STATE_MT; 
-}
-
-typedef struct opj_dec_mstabent {
-	/** marker value */
-	int id;
-	/** value of the state when the marker can appear */
-	int states;
-	/** action linked to the marker */
-	void (*handler) (opj_j2k_t *j2k);
-} opj_dec_mstabent_t;
-
-opj_dec_mstabent_t j2k_dec_mstab[] = {
-  {J2K_MS_SOC, J2K_STATE_MHSOC, j2k_read_soc},
-  {J2K_MS_SOT, J2K_STATE_MH | J2K_STATE_TPHSOT, j2k_read_sot},
-  {J2K_MS_SOD, J2K_STATE_TPH, j2k_read_sod},
-  {J2K_MS_EOC, J2K_STATE_TPHSOT, j2k_read_eoc},
-  {J2K_MS_SIZ, J2K_STATE_MHSIZ, j2k_read_siz},
-  {J2K_MS_COD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_cod},
-  {J2K_MS_COC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_coc},
-  {J2K_MS_RGN, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_rgn},
-  {J2K_MS_QCD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_qcd},
-  {J2K_MS_QCC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_qcc},
-  {J2K_MS_POC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_poc},
-  {J2K_MS_TLM, J2K_STATE_MH, j2k_read_tlm},
-  {J2K_MS_PLM, J2K_STATE_MH, j2k_read_plm},
-  {J2K_MS_PLT, J2K_STATE_TPH, j2k_read_plt},
-  {J2K_MS_PPM, J2K_STATE_MH, j2k_read_ppm},
-  {J2K_MS_PPT, J2K_STATE_TPH, j2k_read_ppt},
-  {J2K_MS_SOP, 0, 0},
-  {J2K_MS_CRG, J2K_STATE_MH, j2k_read_crg},
-  {J2K_MS_COM, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_com},
-
-#ifdef USE_JPWL
-  {J2K_MS_EPC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epc},
-  {J2K_MS_EPB, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epb},
-  {J2K_MS_ESD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_esd},
-  {J2K_MS_RED, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_red},
-#endif /* USE_JPWL */
-#ifdef USE_JPSEC
-  {J2K_MS_SEC, J2K_STATE_MH, j2k_read_sec},
-  {J2K_MS_INSEC, 0, j2k_read_insec},
-#endif /* USE_JPSEC */
-
-  {0, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_unk}
-};
-
-static void j2k_read_unk(opj_j2k_t *j2k) {
-	opj_event_msg(j2k->cinfo, EVT_WARNING, "Unknown marker\n");
-
-#ifdef USE_JPWL
-	if (j2k->cp->correct) {
-		int m = 0, id, i;
-		int min_id = 0, min_dist = 17, cur_dist = 0, tmp_id;
-		cio_seek(j2k->cio, cio_tell(j2k->cio) - 2);
-		id = cio_read(j2k->cio, 2);
-		opj_event_msg(j2k->cinfo, EVT_ERROR,
-			"JPWL: really don't know this marker %x\n",
-			id);
-		if (!JPWL_ASSUME) {
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"- possible synch loss due to uncorrectable codestream errors => giving up\n");
-			return;
-		}
-		/* OK, activate this at your own risk!!! */
-		/* we look for the marker at the minimum hamming distance from this */
-		while (j2k_dec_mstab[m].id) {
-			
-			/* 1's where they differ */
-			tmp_id = j2k_dec_mstab[m].id ^ id;
-
-			/* compute the hamming distance between our id and the current */
-			cur_dist = 0;
-			for (i = 0; i < 16; i++) {
-				if ((tmp_id >> i) & 0x0001) {
-					cur_dist++;
-				}
-			}
-
-			/* if current distance is smaller, set the minimum */
-			if (cur_dist < min_dist) {
-				min_dist = cur_dist;
-				min_id = j2k_dec_mstab[m].id;
-			}
-			
-			/* jump to the next marker */
-			m++;
-		}
-
-		/* do we substitute the marker? */
-		if (min_dist < JPWL_MAXIMUM_HAMMING) {
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"- marker %x is at distance %d from the read %x\n",
-				min_id, min_dist, id);
-			opj_event_msg(j2k->cinfo, EVT_ERROR,
-				"- trying to substitute in place and crossing fingers!\n");
-			cio_seek(j2k->cio, cio_tell(j2k->cio) - 2);
-			cio_write(j2k->cio, min_id, 2);
-
-			/* rewind */
-			cio_seek(j2k->cio, cio_tell(j2k->cio) - 2);
-
-		}
-
-	};
-#endif /* USE_JPWL */
-
-}
-
-/**
-Read the lookup table containing all the marker, status and action
- at param id Marker value
-*/
-static opj_dec_mstabent_t *j2k_dec_mstab_lookup(int id) {
-	opj_dec_mstabent_t *e;
-	for (e = j2k_dec_mstab; e->id != 0; e++) {
-		if (e->id == id) {
-			break;
-		}
-	}
-	return e;
-}
-
-/* ----------------------------------------------------------------------- */
-/* J2K / JPT decoder interface                                             */
-/* ----------------------------------------------------------------------- */
-
-opj_j2k_t* j2k_create_decompress(opj_common_ptr cinfo) {
-	opj_j2k_t *j2k = (opj_j2k_t*) opj_calloc(1, sizeof(opj_j2k_t));
-	if(!j2k)
-		return NULL;
-
-	j2k->default_tcp = (opj_tcp_t*) opj_calloc(1, sizeof(opj_tcp_t));
-	if(!j2k->default_tcp) {
-		opj_free(j2k);
-		return NULL;
-	}
-
-	j2k->cinfo = cinfo;
-	j2k->tile_data = NULL;
-
-	return j2k;
-}
-
-void j2k_destroy_decompress(opj_j2k_t *j2k) {
-	int i = 0;
-
-	if(j2k->tile_len != NULL) {
-		opj_free(j2k->tile_len);
-	}
-	if(j2k->tile_data != NULL) {
-		opj_free(j2k->tile_data);
-	}
-	if(j2k->default_tcp != NULL) {
-		opj_tcp_t *default_tcp = j2k->default_tcp;
-		if(default_tcp->ppt_data_first != NULL) {
-			opj_free(default_tcp->ppt_data_first);
-		}
-		if(j2k->default_tcp->tccps != NULL) {
-			opj_free(j2k->default_tcp->tccps);
-		}
-		opj_free(j2k->default_tcp);
-	}
-	if(j2k->cp != NULL) {
-		opj_cp_t *cp = j2k->cp;
-		if(cp->tcps != NULL) {
-			for(i = 0; i < cp->tw * cp->th; i++) {
-				if(cp->tcps[i].ppt_data_first != NULL) {
-					opj_free(cp->tcps[i].ppt_data_first);
-				}
-				if(cp->tcps[i].tccps != NULL) {
-					opj_free(cp->tcps[i].tccps);
-				}
-			}
-			opj_free(cp->tcps);
-		}
-		if(cp->ppm_data_first != NULL) {
-			opj_free(cp->ppm_data_first);
-		}
-		if(cp->tileno != NULL) {
-			opj_free(cp->tileno);  
-		}
-		if(cp->comment != NULL) {
-			opj_free(cp->comment);
-		}
-
-		opj_free(cp);
-	}
-	opj_free(j2k);
-}
-
-void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters) {
-	if(j2k && parameters) {
-		/* create and initialize the coding parameters structure */
-		opj_cp_t *cp = (opj_cp_t*) opj_calloc(1, sizeof(opj_cp_t));
-		cp->reduce = parameters->cp_reduce;	
-		cp->layer = parameters->cp_layer;
-		cp->limit_decoding = parameters->cp_limit_decoding;
-
-#ifdef USE_JPWL
-		cp->correct = parameters->jpwl_correct;
-		cp->exp_comps = parameters->jpwl_exp_comps;
-		cp->max_tiles = parameters->jpwl_max_tiles;
-#endif /* USE_JPWL */
-
-
-		/* keep a link to cp so that we can destroy it later in j2k_destroy_decompress */
-		j2k->cp = cp;
-	}
-}
-
-opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info) {
-	opj_image_t *image = NULL;
-
-	opj_common_ptr cinfo = j2k->cinfo;	
-
-	j2k->cio = cio;
-	j2k->cstr_info = cstr_info;
-	if (cstr_info)
-		memset(cstr_info, 0, sizeof(opj_codestream_info_t));
-
-	/* create an empty image */
-	image = opj_image_create0();
-	j2k->image = image;
-
-	j2k->state = J2K_STATE_MHSOC;
-
-	for (;;) {
-		opj_dec_mstabent_t *e;
-		int id = cio_read(cio, 2);
-
-#ifdef USE_JPWL
-		/* we try to honor JPWL correction power */
-		if (j2k->cp->correct) {
-
-			int orig_pos = cio_tell(cio);
-			bool status;
-
-			/* call the corrector */
-			status = jpwl_correct(j2k);
-
-			/* go back to where you were */
-			cio_seek(cio, orig_pos - 2);
-
-			/* re-read the marker */
-			id = cio_read(cio, 2);
-
-			/* check whether it begins with ff */
-			if (id >> 8 != 0xff) {
-				opj_event_msg(cinfo, EVT_ERROR,
-					"JPWL: possible bad marker %x at %d\n",
-					id, cio_tell(cio) - 2);
-				if (!JPWL_ASSUME) {
-					opj_image_destroy(image);
-					opj_event_msg(cinfo, EVT_ERROR, "JPWL: giving up\n");
-					return 0;
-				}
-				/* we try to correct */
-				id = id | 0xff00;
-				cio_seek(cio, cio_tell(cio) - 2);
-				cio_write(cio, id, 2);
-				opj_event_msg(cinfo, EVT_WARNING, "- trying to adjust this\n"
-					"- setting marker to %x\n",
-					id);
-			}
-
-		}
-#endif /* USE_JPWL */
-
-		if (id >> 8 != 0xff) {
-			opj_image_destroy(image);
-			opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
-			return 0;
-		}
-		e = j2k_dec_mstab_lookup(id);
-		// Check if the marker is known
-		if (!(j2k->state & e->states)) {
-			opj_image_destroy(image);
-			opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id);
-			return 0;
-		}
-		// Check if the decoding is limited to the main header
-		if (e->id == J2K_MS_SOT && j2k->cp->limit_decoding == LIMIT_TO_MAIN_HEADER) {
-			opj_event_msg(cinfo, EVT_INFO, "Main Header decoded.\n");
-			return image;
-		}		
-
-		if (e->handler) {
-			(*e->handler)(j2k);
-		}
-		if (j2k->state & J2K_STATE_ERR) 
-			return NULL;	
-
-		if (j2k->state == J2K_STATE_MT) {
-			break;
-		}
-		if (j2k->state == J2K_STATE_NEOC) {
-			break;
-		}
-	}
-	if (j2k->state == J2K_STATE_NEOC) {
-		j2k_read_eoc(j2k);
-	}
-
-	if (j2k->state != J2K_STATE_MT) {
-		opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n");
-	}
-
-	return image;
-}
-
-/*
-* Read a JPT-stream and decode file
-*
-*/
-opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio,  opj_codestream_info_t *cstr_info) {
-	opj_image_t *image = NULL;
-	opj_jpt_msg_header_t header;
-	int position;
-
-	opj_common_ptr cinfo = j2k->cinfo;
-	
-	j2k->cio = cio;
-
-	/* create an empty image */
-	image = opj_image_create0();
-	j2k->image = image;
-
-	j2k->state = J2K_STATE_MHSOC;
-	
-	/* Initialize the header */
-	jpt_init_msg_header(&header);
-	/* Read the first header of the message */
-	jpt_read_msg_header(cinfo, cio, &header);
-	
-	position = cio_tell(cio);
-	if (header.Class_Id != 6) {	/* 6 : Main header data-bin message */
-		opj_image_destroy(image);
-		opj_event_msg(cinfo, EVT_ERROR, "[JPT-stream] : Expecting Main header first [class_Id %d] !\n", header.Class_Id);
-		return 0;
-	}
-	
-	for (;;) {
-		opj_dec_mstabent_t *e = NULL;
-		int id;
-		
-		if (!cio_numbytesleft(cio)) {
-			j2k_read_eoc(j2k);
-			return image;
-		}
-		/* data-bin read -> need to read a new header */
-		if ((unsigned int) (cio_tell(cio) - position) == header.Msg_length) {
-			jpt_read_msg_header(cinfo, cio, &header);
-			position = cio_tell(cio);
-			if (header.Class_Id != 4) {	/* 4 : Tile data-bin message */
-				opj_image_destroy(image);
-				opj_event_msg(cinfo, EVT_ERROR, "[JPT-stream] : Expecting Tile info !\n");
-				return 0;
-			}
-		}
-		
-		id = cio_read(cio, 2);
-		if (id >> 8 != 0xff) {
-			opj_image_destroy(image);
-			opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
-			return 0;
-		}
-		e = j2k_dec_mstab_lookup(id);
-		if (!(j2k->state & e->states)) {
-			opj_image_destroy(image);
-			opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id);
-			return 0;
-		}
-		if (e->handler) {
-			(*e->handler)(j2k);
-		}
-		if (j2k->state == J2K_STATE_MT) {
-			break;
-		}
-		if (j2k->state == J2K_STATE_NEOC) {
-			break;
-		}
-	}
-	if (j2k->state == J2K_STATE_NEOC) {
-		j2k_read_eoc(j2k);
-	}
-	
-	if (j2k->state != J2K_STATE_MT) {
-		opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n");
-	}
-
-	return image;
-}
-
-/* ----------------------------------------------------------------------- */
-/* J2K encoder interface                                                       */
-/* ----------------------------------------------------------------------- */
-
-opj_j2k_t* j2k_create_compress(opj_common_ptr cinfo) {
-	opj_j2k_t *j2k = (opj_j2k_t*) opj_calloc(1, sizeof(opj_j2k_t));
-	if(j2k) {
-		j2k->cinfo = cinfo;
-	}
-	return j2k;
-}
-
-void j2k_destroy_compress(opj_j2k_t *j2k) {
-	int tileno;
-
-	if(!j2k) return;
-	if(j2k->cp != NULL) {
-		opj_cp_t *cp = j2k->cp;
-
-		if(cp->comment) {
-			opj_free(cp->comment);
-		}
-		if(cp->matrice) {
-			opj_free(cp->matrice);
-		}
-		for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-			opj_free(cp->tcps[tileno].tccps);
-		}
-		opj_free(cp->tcps);
-		opj_free(cp);
-	}
-
-	opj_free(j2k);
-}
-
-void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image) {
-	int i, j, tileno, numpocs_tile;
-	opj_cp_t *cp = NULL;
-
-	if(!j2k || !parameters || ! image) {
-		return;
-	}
-
-	/* create and initialize the coding parameters structure */
-	cp = (opj_cp_t*) opj_calloc(1, sizeof(opj_cp_t));
-
-	/* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
-	j2k->cp = cp;
-
-	/* set default values for cp */
-	cp->tw = 1;
-	cp->th = 1;
-
-	/* 
-	copy user encoding parameters 
-	*/
-	cp->cinema = parameters->cp_cinema;
-	cp->max_comp_size =	parameters->max_comp_size;
-	cp->rsiz   = parameters->cp_rsiz;
-	cp->disto_alloc = parameters->cp_disto_alloc;
-	cp->fixed_alloc = parameters->cp_fixed_alloc;
-	cp->fixed_quality = parameters->cp_fixed_quality;
-
-	/* mod fixed_quality */
-	if(parameters->cp_matrice) {
-		size_t array_size = parameters->tcp_numlayers * parameters->numresolution * 3 * sizeof(int);
-		cp->matrice = (int *) opj_malloc(array_size);
-		memcpy(cp->matrice, parameters->cp_matrice, array_size);
-	}
-
-	/* tiles */
-	cp->tdx = parameters->cp_tdx;
-	cp->tdy = parameters->cp_tdy;
-
-	/* tile offset */
-	cp->tx0 = parameters->cp_tx0;
-	cp->ty0 = parameters->cp_ty0;
-
-	/* comment string */
-	if(parameters->cp_comment) {
-		cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) + 1);
-		if(cp->comment) {
-			strcpy(cp->comment, parameters->cp_comment);
-		}
-	}
-
-	/*
-	calculate other encoding parameters
-	*/
-
-	if (parameters->tile_size_on) {
-		cp->tw = int_ceildiv(image->x1 - cp->tx0, cp->tdx);
-		cp->th = int_ceildiv(image->y1 - cp->ty0, cp->tdy);
-	} else {
-		cp->tdx = image->x1 - cp->tx0;
-		cp->tdy = image->y1 - cp->ty0;
-	}
-
-	if(parameters->tp_on){
-		cp->tp_flag = parameters->tp_flag;
-		cp->tp_on = 1;
-	}
-	
-	cp->img_size = 0;
-	for(i=0;i<image->numcomps ;i++){
-	cp->img_size += (image->comps[i].w *image->comps[i].h * image->comps[i].prec);
-	}
-
-
-#ifdef USE_JPWL
-	/*
-	calculate JPWL encoding parameters
-	*/
-
-	if (parameters->jpwl_epc_on) {
-		int i;
-
-		/* set JPWL on */
-		cp->epc_on = true;
-		cp->info_on = false; /* no informative technique */
-
-		/* set EPB on */
-		if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) {
-			cp->epb_on = true;
-			
-			cp->hprot_MH = parameters->jpwl_hprot_MH;
-			for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-				cp->hprot_TPH_tileno[i] = parameters->jpwl_hprot_TPH_tileno[i];
-				cp->hprot_TPH[i] = parameters->jpwl_hprot_TPH[i];
-			}
-			/* if tile specs are not specified, copy MH specs */
-			if (cp->hprot_TPH[0] == -1) {
-				cp->hprot_TPH_tileno[0] = 0;
-				cp->hprot_TPH[0] = parameters->jpwl_hprot_MH;
-			}
-			for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
-				cp->pprot_tileno[i] = parameters->jpwl_pprot_tileno[i];
-				cp->pprot_packno[i] = parameters->jpwl_pprot_packno[i];
-				cp->pprot[i] = parameters->jpwl_pprot[i];
-			}
-		}
-
-		/* set ESD writing */
-		if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) {
-			cp->esd_on = true;
-
-			cp->sens_size = parameters->jpwl_sens_size;
-			cp->sens_addr = parameters->jpwl_sens_addr;
-			cp->sens_range = parameters->jpwl_sens_range;
-
-			cp->sens_MH = parameters->jpwl_sens_MH;
-			for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-				cp->sens_TPH_tileno[i] = parameters->jpwl_sens_TPH_tileno[i];
-				cp->sens_TPH[i] = parameters->jpwl_sens_TPH[i];
-			}
-		}
-
-		/* always set RED writing to false: we are at the encoder */
-		cp->red_on = false;
-
-	} else {
-		cp->epc_on = false;
-	}
-#endif /* USE_JPWL */
-
-
-	/* initialize the mutiple tiles */
-	/* ---------------------------- */
-	cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
-
-	for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-		opj_tcp_t *tcp = &cp->tcps[tileno];
-		tcp->numlayers = parameters->tcp_numlayers;
-		for (j = 0; j < tcp->numlayers; j++) {
-			if(cp->cinema){
-				if (cp->fixed_quality) {
-					tcp->distoratio[j] = parameters->tcp_distoratio[j];
-				}
-				tcp->rates[j] = parameters->tcp_rates[j];
-			}else{
-				if (cp->fixed_quality) {	/* add fixed_quality */
-					tcp->distoratio[j] = parameters->tcp_distoratio[j];
-				} else {
-					tcp->rates[j] = parameters->tcp_rates[j];
-				}
-			}
-		}
-		tcp->csty = parameters->csty;
-		tcp->prg = parameters->prog_order;
-		tcp->mct = parameters->tcp_mct; 
-
-		numpocs_tile = 0;
-		tcp->POC = 0;
-		if (parameters->numpocs) {
-			/* initialisation of POC */
-			tcp->POC = 1;
-			for (i = 0; i < parameters->numpocs; i++) {
-				if((tileno == parameters->POC[i].tile - 1) || (parameters->POC[i].tile == -1)) {
-					opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
-					tcp_poc->resno0		= parameters->POC[numpocs_tile].resno0;
-					tcp_poc->compno0	= parameters->POC[numpocs_tile].compno0;
-					tcp_poc->layno1		= parameters->POC[numpocs_tile].layno1;
-					tcp_poc->resno1		= parameters->POC[numpocs_tile].resno1;
-					tcp_poc->compno1	= parameters->POC[numpocs_tile].compno1;
-					tcp_poc->prg1		= parameters->POC[numpocs_tile].prg1;
-					tcp_poc->tile		= parameters->POC[numpocs_tile].tile;
-					numpocs_tile++;
-				}
-			}
-			tcp->numpocs = numpocs_tile -1 ;
-		}else{ 
-			tcp->numpocs = 0;
-		}
-
-		tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(opj_tccp_t));
-
-		for (i = 0; i < image->numcomps; i++) {
-			opj_tccp_t *tccp = &tcp->tccps[i];
-			tccp->csty = parameters->csty & 0x01;	/* 0 => one precinct || 1 => custom precinct  */
-			tccp->numresolutions = parameters->numresolution;
-			tccp->cblkw = int_floorlog2(parameters->cblockw_init);
-			tccp->cblkh = int_floorlog2(parameters->cblockh_init);
-			tccp->cblksty = parameters->mode;
-			tccp->qmfbid = parameters->irreversible ? 0 : 1;
-			tccp->qntsty = parameters->irreversible ? J2K_CCP_QNTSTY_SEQNT : J2K_CCP_QNTSTY_NOQNT;
-			tccp->numgbits = 2;
-			if (i == parameters->roi_compno) {
-				tccp->roishift = parameters->roi_shift;
-			} else {
-				tccp->roishift = 0;
-			}
-
-			if(parameters->cp_cinema)
-			{
-				//Precinct size for lowest frequency subband=128
-				tccp->prcw[0] = 7;
-				tccp->prch[0] = 7;
-				//Precinct size at all other resolutions = 256
-				for (j = 1; j < tccp->numresolutions; j++) {
-					tccp->prcw[j] = 8;
-					tccp->prch[j] = 8;
-				}
-			}else{
-				if (parameters->csty & J2K_CCP_CSTY_PRT) {
-					int p = 0;
-					for (j = tccp->numresolutions - 1; j >= 0; j--) {
-						if (p < parameters->res_spec) {
-							
-							if (parameters->prcw_init[p] < 1) {
-								tccp->prcw[j] = 1;
-							} else {
-								tccp->prcw[j] = int_floorlog2(parameters->prcw_init[p]);
-							}
-							
-							if (parameters->prch_init[p] < 1) {
-								tccp->prch[j] = 1;
-							}else {
-								tccp->prch[j] = int_floorlog2(parameters->prch_init[p]);
-							}
-
-						} else {
-							int res_spec = parameters->res_spec;
-							int size_prcw = parameters->prcw_init[res_spec - 1] >> (p - (res_spec - 1));
-							int size_prch = parameters->prch_init[res_spec - 1] >> (p - (res_spec - 1));
-							
-							if (size_prcw < 1) {
-								tccp->prcw[j] = 1;
-							} else {
-								tccp->prcw[j] = int_floorlog2(size_prcw);
-							}
-							
-							if (size_prch < 1) {
-								tccp->prch[j] = 1;
-							} else {
-								tccp->prch[j] = int_floorlog2(size_prch);
-							}
-						}
-						p++;
-						/*printf("\nsize precinct for level %d : %d,%d\n", j,tccp->prcw[j], tccp->prch[j]); */
-					}	//end for
-				} else {
-					for (j = 0; j < tccp->numresolutions; j++) {
-						tccp->prcw[j] = 15;
-						tccp->prch[j] = 15;
-					}
-				}
-			}
-
-			dwt_calc_explicit_stepsizes(tccp, image->comps[i].prec);
-		}
-	}
-}
-
-bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
-	int tileno, compno;
-	opj_cp_t *cp = NULL;
-
-	opj_tcd_t *tcd = NULL;	/* TCD component */
-
-	j2k->cio = cio;	
-	j2k->image = image;
-
-	cp = j2k->cp;
-
-	/* INDEX >> */
-	j2k->cstr_info = cstr_info;
-	if (cstr_info) {
-		int compno;
-		cstr_info->tile = (opj_tile_info_t *) opj_malloc(cp->tw * cp->th * sizeof(opj_tile_info_t));
-		cstr_info->image_w = image->x1 - image->x0;
-		cstr_info->image_h = image->y1 - image->y0;
-		cstr_info->prog = (&cp->tcps[0])->prg;
-		cstr_info->tw = cp->tw;
-		cstr_info->th = cp->th;
-		cstr_info->tile_x = cp->tdx;	/* new version parser */
-		cstr_info->tile_y = cp->tdy;	/* new version parser */
-		cstr_info->tile_Ox = cp->tx0;	/* new version parser */
-		cstr_info->tile_Oy = cp->ty0;	/* new version parser */
-		cstr_info->numcomps = image->numcomps;
-		cstr_info->numlayers = (&cp->tcps[0])->numlayers;
-		cstr_info->numdecompos = (int*) opj_malloc(image->numcomps * sizeof(int));
-		for (compno=0; compno < image->numcomps; compno++) {
-			cstr_info->numdecompos[compno] = (&cp->tcps[0])->tccps->numresolutions - 1;
-		}
-		cstr_info->D_max = 0.0;		/* ADD Marcela */
-		cstr_info->main_head_start = cio_tell(cio); /* position of SOC */
-		cstr_info->maxmarknum = 100;
-		cstr_info->marker = (opj_marker_info_t *) opj_malloc(cstr_info->maxmarknum * sizeof(opj_marker_info_t));
-		cstr_info->marknum = 0;
-	}
-	/* << INDEX */
-
-	j2k_write_soc(j2k);
-	j2k_write_siz(j2k);
-	j2k_write_cod(j2k);
-	j2k_write_qcd(j2k);
-
-	if(cp->cinema){
-		for (compno = 1; compno < image->numcomps; compno++) {
-			j2k_write_coc(j2k, compno);
-			j2k_write_qcc(j2k, compno);
-		}
-	}
-
-	for (compno = 0; compno < image->numcomps; compno++) {
-		opj_tcp_t *tcp = &cp->tcps[0];
-		if (tcp->tccps[compno].roishift)
-			j2k_write_rgn(j2k, compno, 0);
-	}
-	if (cp->comment != NULL) {
-		j2k_write_com(j2k);
-	}
-
-	j2k->totnum_tp = j2k_calculate_tp(cp,image->numcomps,image,j2k);
-	/* TLM Marker*/
-	if(cp->cinema){
-		j2k_write_tlm(j2k);
-		if (cp->cinema == CINEMA4K_24) {
-			j2k_write_poc(j2k);
-		}
-	}
-
-	/* uncomment only for testing JPSEC marker writing */
-	/* j2k_write_sec(j2k); */
-
-	/* INDEX >> */
-	if(cstr_info) {
-		cstr_info->main_head_end = cio_tell(cio) - 1;
-	}
-	/* << INDEX */
-	/**** Main Header ENDS here ***/
-
-	/* create the tile encoder */
-	tcd = tcd_create(j2k->cinfo);
-
-	/* encode each tile */
-	for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-		int pino;
-		int tilepartno=0;
-		/* UniPG>> */
-		int acc_pack_num = 0;
-		/* <<UniPG */
-
-
-		opj_tcp_t *tcp = &cp->tcps[tileno];
-		opj_event_msg(j2k->cinfo, EVT_INFO, "tile number %d / %d\n", tileno + 1, cp->tw * cp->th);
-
-		j2k->curtileno = tileno;
-		j2k->cur_tp_num = 0;
-		tcd->cur_totnum_tp = j2k->cur_totnum_tp[j2k->curtileno];
-		/* initialisation before tile encoding  */
-		if (tileno == 0) {
-			tcd_malloc_encode(tcd, image, cp, j2k->curtileno);
-		} else {
-			tcd_init_encode(tcd, image, cp, j2k->curtileno);
-		}
-
-		/* INDEX >> */
-		if(cstr_info) {
-			cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction;
-		}
-		/* << INDEX */
-
-		for(pino = 0; pino <= tcp->numpocs; pino++) {
-			int tot_num_tp;
-			tcd->cur_pino=pino;
-
-			/*Get number of tile parts*/
-			tot_num_tp = j2k_get_num_tp(cp,pino,tileno);
-			tcd->tp_pos = cp->tp_pos;
-
-			for(tilepartno = 0; tilepartno < tot_num_tp ; tilepartno++){
-				j2k->tp_num = tilepartno;
-				/* INDEX >> */
-				if(cstr_info)
-					cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_start_pos =
-					cio_tell(cio) + j2k->pos_correction;
-				/* << INDEX */
-				j2k_write_sot(j2k);
-
-				if(j2k->cur_tp_num == 0 && cp->cinema == 0){
-					for (compno = 1; compno < image->numcomps; compno++) {
-						j2k_write_coc(j2k, compno);
-						j2k_write_qcc(j2k, compno);
-					}
-					if (cp->tcps[tileno].numpocs) {
-						j2k_write_poc(j2k);
-					}
-				}
-
-				/* INDEX >> */
-				if(cstr_info)
-					cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_end_header =
-					cio_tell(cio) + j2k->pos_correction + 1;
-				/* << INDEX */
-
-				j2k_write_sod(j2k, tcd);
-
-				/* INDEX >> */
-				if(cstr_info) {
-					cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_end_pos =
-						cio_tell(cio) + j2k->pos_correction - 1;
-					cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_start_pack =
-						acc_pack_num;
-					cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_numpacks =
-						cstr_info->packno - acc_pack_num;
-					acc_pack_num = cstr_info->packno;
-				}
-				/* << INDEX */
-
-				j2k->cur_tp_num++;
-			}			
-		}
-		if(cstr_info) {
-			cstr_info->tile[j2k->curtileno].end_pos = cio_tell(cio) + j2k->pos_correction - 1;
-		}
-
-
-		/*
-		if (tile->PPT) { // BAD PPT !!! 
-		FILE *PPT_file;
-		int i;
-		PPT_file=fopen("PPT","rb");
-		fprintf(stderr,"%c%c%c%c",255,97,tile->len_ppt/256,tile->len_ppt%256);
-		for (i=0;i<tile->len_ppt;i++) {
-		unsigned char elmt;
-		fread(&elmt, 1, 1, PPT_file);
-		fwrite(&elmt,1,1,f);
-		}
-		fclose(PPT_file);
-		unlink("PPT");
-		}
-		*/
-
-	}
-
-	/* destroy the tile encoder */
-	tcd_free_encode(tcd);
-	tcd_destroy(tcd);
-
-	opj_free(j2k->cur_totnum_tp);
-
-	j2k_write_eoc(j2k);
-
-	if(cstr_info) {
-		cstr_info->codestream_size = cio_tell(cio) + j2k->pos_correction;
-		/* UniPG>> */
-		/* The following adjustment is done to adjust the codestream size */
-		/* if SOD is not at 0 in the buffer. Useful in case of JP2, where */
-		/* the first bunch of bytes is not in the codestream              */
-		cstr_info->codestream_size -= cstr_info->main_head_start;
-		/* <<UniPG */
-	}
-
-#ifdef USE_JPWL
-	/*
-	preparation of JPWL marker segments
-	*/
-	if(cp->epc_on) {
-
-		/* encode according to JPWL */
-		jpwl_encode(j2k, cio, image);
-
-	}
-#endif /* USE_JPWL */
-
-	return true;
-}
-
-
-
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.h
deleted file mode 100644
index 8fc8e6d..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k.h
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __J2K_H
-#define __J2K_H
-/**
- at file j2k.h
- at brief The JPEG-2000 Codestream Reader/Writer (J2K)
-
-The functions in J2K.C have for goal to read/write the several parts of the codestream: markers and data.
-*/
-
-/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
-/*@{*/
-
-#define J2K_CP_CSTY_PRT 0x01
-#define J2K_CP_CSTY_SOP 0x02
-#define J2K_CP_CSTY_EPH 0x04
-#define J2K_CCP_CSTY_PRT 0x01
-#define J2K_CCP_CBLKSTY_LAZY 0x01     /**< Selective arithmetic coding bypass */
-#define J2K_CCP_CBLKSTY_RESET 0x02    /**< Reset context probabilities on coding pass boundaries */
-#define J2K_CCP_CBLKSTY_TERMALL 0x04  /**< Termination on each coding pass */
-#define J2K_CCP_CBLKSTY_VSC 0x08      /**< Vertically stripe causal context */
-#define J2K_CCP_CBLKSTY_PTERM 0x10    /**< Predictable termination */
-#define J2K_CCP_CBLKSTY_SEGSYM 0x20   /**< Segmentation symbols are used */
-#define J2K_CCP_QNTSTY_NOQNT 0
-#define J2K_CCP_QNTSTY_SIQNT 1
-#define J2K_CCP_QNTSTY_SEQNT 2
-
-/* ----------------------------------------------------------------------- */
-
-#define J2K_MS_SOC 0xff4f	/**< SOC marker value */
-#define J2K_MS_SOT 0xff90	/**< SOT marker value */
-#define J2K_MS_SOD 0xff93	/**< SOD marker value */
-#define J2K_MS_EOC 0xffd9	/**< EOC marker value */
-#define J2K_MS_SIZ 0xff51	/**< SIZ marker value */
-#define J2K_MS_COD 0xff52	/**< COD marker value */
-#define J2K_MS_COC 0xff53	/**< COC marker value */
-#define J2K_MS_RGN 0xff5e	/**< RGN marker value */
-#define J2K_MS_QCD 0xff5c	/**< QCD marker value */
-#define J2K_MS_QCC 0xff5d	/**< QCC marker value */
-#define J2K_MS_POC 0xff5f	/**< POC marker value */
-#define J2K_MS_TLM 0xff55	/**< TLM marker value */
-#define J2K_MS_PLM 0xff57	/**< PLM marker value */
-#define J2K_MS_PLT 0xff58	/**< PLT marker value */
-#define J2K_MS_PPM 0xff60	/**< PPM marker value */
-#define J2K_MS_PPT 0xff61	/**< PPT marker value */
-#define J2K_MS_SOP 0xff91	/**< SOP marker value */
-#define J2K_MS_EPH 0xff92	/**< EPH marker value */
-#define J2K_MS_CRG 0xff63	/**< CRG marker value */
-#define J2K_MS_COM 0xff64	/**< COM marker value */
-/* UniPG>> */
-#ifdef USE_JPWL
-#define J2K_MS_EPC 0xff68	/**< EPC marker value (Part 11: JPEG 2000 for Wireless) */
-#define J2K_MS_EPB 0xff66	/**< EPB marker value (Part 11: JPEG 2000 for Wireless) */ 
-#define J2K_MS_ESD 0xff67	/**< ESD marker value (Part 11: JPEG 2000 for Wireless) */ 
-#define J2K_MS_RED 0xff69	/**< RED marker value (Part 11: JPEG 2000 for Wireless) */
-#endif /* USE_JPWL */
-#ifdef USE_JPSEC
-#define J2K_MS_SEC 0xff65    /**< SEC marker value (Part 8: Secure JPEG 2000) */
-#define J2K_MS_INSEC 0xff94  /**< INSEC marker value (Part 8: Secure JPEG 2000) */
-#endif /* USE_JPSEC */
-/* <<UniPG */
-
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Values that specify the status of the decoding process when decoding the main header. 
-These values may be combined with a | operator. 
-*/
-typedef enum J2K_STATUS {
-	J2K_STATE_MHSOC  = 0x0001, /**< a SOC marker is expected */
-	J2K_STATE_MHSIZ  = 0x0002, /**< a SIZ marker is expected */
-	J2K_STATE_MH     = 0x0004, /**< the decoding process is in the main header */
-	J2K_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */
-	J2K_STATE_TPH    = 0x0010, /**< the decoding process is in a tile part header */
-	J2K_STATE_MT     = 0x0020, /**< the EOC marker has just been read */
-	J2K_STATE_NEOC   = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
-	J2K_STATE_ERR    = 0x0080  /**< the decoding process has encountered an error */
-} J2K_STATUS;
-
-/* ----------------------------------------------------------------------- */
-
-/** 
-T2 encoding mode 
-*/
-typedef enum T2_MODE {
-	THRESH_CALC = 0,	/** Function called in Rate allocation process*/
-	FINAL_PASS = 1		/** Function called in Tier 2 process*/
-}J2K_T2_MODE;
-
-/**
-Quantization stepsize
-*/
-typedef struct opj_stepsize {
-	/** exponent */
-	int expn;
-	/** mantissa */
-	int mant;
-} opj_stepsize_t;
-
-/**
-Tile-component coding parameters
-*/
-typedef struct opj_tccp {
-	/** coding style */
-	int csty;
-	/** number of resolutions */
-	int numresolutions;
-	/** code-blocks width */
-	int cblkw;
-	/** code-blocks height */
-	int cblkh;
-	/** code-block coding style */
-	int cblksty;
-	/** discrete wavelet transform identifier */
-	int qmfbid;
-	/** quantisation style */
-	int qntsty;
-	/** stepsizes used for quantization */
-	opj_stepsize_t stepsizes[J2K_MAXBANDS];
-	/** number of guard bits */
-	int numgbits;
-	/** Region Of Interest shift */
-	int roishift;
-	/** precinct width */
-	int prcw[J2K_MAXRLVLS];
-	/** precinct height */
-	int prch[J2K_MAXRLVLS];	
-} opj_tccp_t;
-
-/**
-Tile coding parameters : 
-this structure is used to store coding/decoding parameters common to all
-tiles (information like COD, COC in main header)
-*/
-typedef struct opj_tcp {
-	/** 1 : first part-tile of a tile */
-	int first;
-	/** coding style */
-	int csty;
-	/** progression order */
-	OPJ_PROG_ORDER prg;
-	/** number of layers */
-	int numlayers;
-	/** multi-component transform identifier */
-	int mct;
-	/** rates of layers */
-	float rates[100];
-	/** number of progression order changes */
-	int numpocs;
-	/** indicates if a POC marker has been used O:NO, 1:YES */
-	int POC;
-	/** progression order changes */
-	opj_poc_t pocs[32];
-	/** packet header store there for futur use in t2_decode_packet */
-	unsigned char *ppt_data;
-	/** pointer remaining on the first byte of the first header if ppt is used */
-	unsigned char *ppt_data_first;
-	/** If ppt == 1 --> there was a PPT marker for the present tile */
-	int ppt;
-	/** used in case of multiple marker PPT (number of info already stored) */
-	int ppt_store;
-	/** ppmbug1 */
-	int ppt_len;
-	/** add fixed_quality */
-	float distoratio[100];
-	/** tile-component coding parameters */
-	opj_tccp_t *tccps;
-} opj_tcp_t;
-
-/**
-Coding parameters
-*/
-typedef struct opj_cp {
-	/** Digital cinema profile*/
-	OPJ_CINEMA_MODE cinema;
-	/** Maximum rate for each component. If == 0, component size limitation is not considered */
-	int max_comp_size;
-	/** Size of the image in bits*/
-	int img_size;
-	/** Rsiz*/
-	OPJ_RSIZ_CAPABILITIES rsiz;
-	/** Enabling Tile part generation*/
-	char tp_on;
-	/** Flag determining tile part generation*/
-	char tp_flag;
-	/** Position of tile part flag in progression order*/
-	int tp_pos;
-	/** allocation by rate/distortion */
-	int disto_alloc;
-	/** allocation by fixed layer */
-	int fixed_alloc;
-	/** add fixed_quality */
-	int fixed_quality;
-	/** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
-	int reduce;
-	/** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
-	int layer;
-	/** if == NO_LIMITATION, decode entire codestream; if == LIMIT_TO_MAIN_HEADER then only decode the main header */
-	OPJ_LIMIT_DECODING limit_decoding;
-	/** XTOsiz */
-	int tx0;
-	/** YTOsiz */
-	int ty0;
-	/** XTsiz */
-	int tdx;
-	/** YTsiz */
-	int tdy;
-	/** comment for coding */
-	char *comment;
-	/** number of tiles in width */
-	int tw;
-	/** number of tiles in heigth */
-	int th;
-	/** ID number of the tiles present in the codestream */
-	int *tileno;
-	/** size of the vector tileno */
-	int tileno_size;
-	/** packet header store there for futur use in t2_decode_packet */
-	unsigned char *ppm_data;
-	/** pointer remaining on the first byte of the first header if ppm is used */
-	unsigned char *ppm_data_first;
-	/** if ppm == 1 --> there was a PPM marker for the present tile */
-	int ppm;
-	/** use in case of multiple marker PPM (number of info already store) */
-	int ppm_store;
-	/** use in case of multiple marker PPM (case on non-finished previous info) */
-	int ppm_previous;
-	/** ppmbug1 */
-	int ppm_len;
-	/** tile coding parameters */
-	opj_tcp_t *tcps;
-	/** fixed layer */
-	int *matrice;
-/* UniPG>> */
-#ifdef USE_JPWL
-	/** enables writing of EPC in MH, thus activating JPWL */
-	bool epc_on;
-	/** enables writing of EPB, in case of activated JPWL */
-	bool epb_on;
-	/** enables writing of ESD, in case of activated JPWL */
-	bool esd_on;
-	/** enables writing of informative techniques of ESD, in case of activated JPWL */
-	bool info_on;
-	/** enables writing of RED, in case of activated JPWL */
-	bool red_on;
-	/** error protection method for MH (0,1,16,32,37-128) */
-	int hprot_MH;
-	/** tile number of header protection specification (>=0) */
-	int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-	/** error protection methods for TPHs (0,1,16,32,37-128) */
-	int hprot_TPH[JPWL_MAX_NO_TILESPECS];
-	/** tile number of packet protection specification (>=0) */
-	int pprot_tileno[JPWL_MAX_NO_PACKSPECS];
-	/** packet number of packet protection specification (>=0) */
-	int pprot_packno[JPWL_MAX_NO_PACKSPECS];
-	/** error protection methods for packets (0,1,16,32,37-128) */
-	int pprot[JPWL_MAX_NO_PACKSPECS];
-	/** enables writing of ESD, (0/2/4 bytes) */
-	int sens_size;
-	/** sensitivity addressing size (0=auto/2/4 bytes) */
-	int sens_addr;
-	/** sensitivity range (0-3) */
-	int sens_range;
-	/** sensitivity method for MH (-1,0-7) */
-	int sens_MH;
-	/** tile number of sensitivity specification (>=0) */
-	int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-	/** sensitivity methods for TPHs (-1,0-7) */
-	int sens_TPH[JPWL_MAX_NO_TILESPECS];
-	/** enables JPWL correction at the decoder */
-	bool correct;
-	/** expected number of components at the decoder */
-	int exp_comps;
-	/** maximum number of tiles at the decoder */
-	int max_tiles;
-#endif /* USE_JPWL */
-/* <<UniPG */
-} opj_cp_t;
-
-/**
-JPEG-2000 codestream reader/writer
-*/
-typedef struct opj_j2k {
-	/** codec context */
-	opj_common_ptr cinfo;
-
-	/** locate in which part of the codestream the decoder is (main header, tile header, end) */
-	int state;
-	/** number of the tile curently concern by coding/decoding */
-	int curtileno;
-	/** Tile part number*/
-	int tp_num;
-	/** Tilepart number currently coding*/
-	int cur_tp_num;
-	/** Total number of tileparts of the current tile*/
-	int *cur_totnum_tp;
-	/**
-	locate the start position of the TLM marker  
-	after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length. 
-	*/
-	int tlm_start;
-	/** Total num of tile parts in whole image = num tiles* num tileparts in each tile*/
-	/** used in TLMmarker*/
-	int totnum_tp;	
-	/** 
-	locate the position of the end of the tile in the codestream, 
-	used to detect a truncated codestream (in j2k_read_sod)
-	*/
-	unsigned char *eot;
-	/**
-	locate the start position of the SOT marker of the current coded tile:  
-	after encoding the tile, a jump (in j2k_write_sod) is done to the SOT marker to store the value of its length. 
-	*/
-	int sot_start;
-	int sod_start;
-	/**
-	as the J2K-file is written in several parts during encoding, 
-	it enables to make the right correction in position return by cio_tell
-	*/
-	int pos_correction;
-	/** array used to store the data of each tile */
-	unsigned char **tile_data;
-	/** array used to store the length of each tile */
-	int *tile_len;
-	/** 
-	decompression only : 
-	store decoding parameters common to all tiles (information like COD, COC in main header)
-	*/
-	opj_tcp_t *default_tcp;
-	/** pointer to the encoded / decoded image */
-	opj_image_t *image;
-	/** pointer to the coding parameters */
-	opj_cp_t *cp;
-	/** helper used to write the index file */
-	opj_codestream_info_t *cstr_info;
-	/** pointer to the byte i/o stream */
-	opj_cio_t *cio;
-} opj_j2k_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Creates a J2K decompression structure
- at param cinfo Codec context info
- at return Returns a handle to a J2K decompressor if successful, returns NULL otherwise
-*/
-opj_j2k_t* j2k_create_decompress(opj_common_ptr cinfo);
-/**
-Destroy a J2K decompressor handle
- at param j2k J2K decompressor handle to destroy
-*/
-void j2k_destroy_decompress(opj_j2k_t *j2k);
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in j2k->cp. 
- at param j2k J2K decompressor handle
- at param parameters decompression parameters
-*/
-void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
-/**
-Decode an image from a JPEG-2000 codestream
- at param j2k J2K decompressor handle
- at param cio Input buffer stream
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
-/**
-Decode an image form a JPT-stream (JPEG 2000, JPIP)
- at param j2k J2K decompressor handle
- at param cio Input buffer stream
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
-/**
-Creates a J2K compression structure
- at param cinfo Codec context info
- at return Returns a handle to a J2K compressor if successful, returns NULL otherwise
-*/
-opj_j2k_t* j2k_create_compress(opj_common_ptr cinfo);
-/**
-Destroy a J2K compressor handle
- at param j2k J2K compressor handle to destroy
-*/
-void j2k_destroy_compress(opj_j2k_t *j2k);
-/**
-Setup the encoder parameters using the current image and using user parameters. 
-Coding parameters are returned in j2k->cp. 
- at param j2k J2K compressor handle
- at param parameters compression parameters
- at param image input filled image
-*/
-void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image);
-/**
-Converts an enum type progression order to string type
-*/
-char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order);
-/**
-Encode an image into a JPEG-2000 codestream
- at param j2k J2K compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __J2K_H */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k_lib.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k_lib.h
deleted file mode 100644
index 7df4d36..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k_lib.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __J2K_LIB_H
-#define __J2K_LIB_H
-/**
- at file j2k_lib.h
- at brief Internal functions
-
-The functions in J2K_LIB.C are internal utilities mainly used for timing.
-*/
-
-/** @defgroup MISC MISC - Miscellaneous internal functions */
-/*@{*/
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Difference in successive opj_clock() calls tells you the elapsed time
- at return Returns time in seconds
-*/
-double opj_clock(void);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __J2K_LIB_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.c
deleted file mode 100644
index 20cf2e6..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.c
+++ /dev/null
@@ -1,1089 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "opj_includes.h"
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Read box headers
- at param cinfo Codec context info
- at param cio Input stream
- at param box
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
-/*static void jp2_write_url(opj_cio_t *cio, char *Idx_file);*/
-/**
-Read the IHDR box - Image Header box
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio);
-static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio);
-static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio);
-static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio);
-static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio);
-/**
-Write the FTYP box - File type box
- at param jp2 JP2 handle
- at param cio Output buffer stream
-*/
-static void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
-/**
-Read the FTYP box - File type box
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
-static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
-static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset);
-static void jp2_write_jp(opj_cio_t *cio);
-/**
-Read the JP box - JPEG 2000 signature
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio);
-/**
-Decode the structure of a JP2 file
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at param color Collector for profile, cdef and pclr data
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio,
-	opj_jp2_color_t *color);
-/**
-Apply collected palette data
- at param color Collector for profile, cdef and pclr data
- at param image 
-*/
-static void jp2_apply_pclr(opj_jp2_color_t *color, opj_image_t *image);
-/**
-Collect palette data
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at param box
- at param color Collector for profile, cdef and pclr data
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
-    opj_jp2_box_t *box, opj_jp2_color_t *color);
-/**
-Collect component mapping data
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at param box
- at param color Collector for profile, cdef and pclr data
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio,
-    opj_jp2_box_t *box, opj_jp2_color_t *color);
-/**
-Collect colour specification data
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at param box
- at param color Collector for profile, cdef and pclr data
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
-    opj_jp2_box_t *box, opj_jp2_color_t *color);
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box) {
-	box->init_pos = cio_tell(cio);
-	box->length = cio_read(cio, 4);
-	box->type = cio_read(cio, 4);
-	if (box->length == 1) {
-		if (cio_read(cio, 4) != 0) {
-			opj_event_msg(cinfo, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
-			return false;
-		}
-		box->length = cio_read(cio, 4);
-		if (box->length == 0) 
-			box->length = cio_numbytesleft(cio) + 12;
-	}
-	else if (box->length == 0) {
-		box->length = cio_numbytesleft(cio) + 8;
-	}
-	
-	return true;
-}
-
-#if 0
-static void jp2_write_url(opj_cio_t *cio, char *Idx_file) {
-	unsigned int i;
-	opj_jp2_box_t box;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_URL, 4);	/* DBTL */
-	cio_write(cio, 0, 1);		/* VERS */
-	cio_write(cio, 0, 3);		/* FLAG */
-
-	if(Idx_file) {
-		for (i = 0; i < strlen(Idx_file); i++) {
-			cio_write(cio, Idx_file[i], 1);
-		}
-	}
-
-	box.length = cio_tell(cio) - box.init_pos;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-}
-#endif
-
-static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) {
-	opj_jp2_box_t box;
-
-	opj_common_ptr cinfo = jp2->cinfo;
-
-	jp2_read_boxhdr(cinfo, cio, &box);
-	if (JP2_IHDR != box.type) {
-		opj_event_msg(cinfo, EVT_ERROR, "Expected IHDR Marker\n");
-		return false;
-	}
-
-	jp2->h = cio_read(cio, 4);			/* HEIGHT */
-	jp2->w = cio_read(cio, 4);			/* WIDTH */
-	jp2->numcomps = cio_read(cio, 2);	/* NC */
-	jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
-
-	jp2->bpc = cio_read(cio, 1);		/* BPC */
-
-	jp2->C = cio_read(cio, 1);			/* C */
-	jp2->UnkC = cio_read(cio, 1);		/* UnkC */
-	jp2->IPR = cio_read(cio, 1);		/* IPR */
-
-	if (cio_tell(cio) - box.init_pos != box.length) {
-		opj_event_msg(cinfo, EVT_ERROR, "Error with IHDR Box\n");
-		return false;
-	}
-
-	return true;
-}
-
-static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) {
-	opj_jp2_box_t box;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_IHDR, 4);		/* IHDR */
-
-	cio_write(cio, jp2->h, 4);			/* HEIGHT */
-	cio_write(cio, jp2->w, 4);			/* WIDTH */
-	cio_write(cio, jp2->numcomps, 2);	/* NC */
-
-	cio_write(cio, jp2->bpc, 1);		/* BPC */
-
-	cio_write(cio, jp2->C, 1);			/* C : Always 7 */
-	cio_write(cio, jp2->UnkC, 1);		/* UnkC, colorspace unknown */
-	cio_write(cio, jp2->IPR, 1);		/* IPR, no intellectual property */
-
-	box.length = cio_tell(cio) - box.init_pos;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-}
-
-static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) {
-	unsigned int i;
-	opj_jp2_box_t box;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_BPCC, 4);	/* BPCC */
-
-	for (i = 0; i < jp2->numcomps; i++) {
-		cio_write(cio, jp2->comps[i].bpcc, 1);
-	}
-
-	box.length = cio_tell(cio) - box.init_pos;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-}
-
-
-static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) {
-	unsigned int i;
-	opj_jp2_box_t box;
-
-	opj_common_ptr cinfo = jp2->cinfo;
-
-	jp2_read_boxhdr(cinfo, cio, &box);
-	if (JP2_BPCC != box.type) {
-		opj_event_msg(cinfo, EVT_ERROR, "Expected BPCC Marker\n");
-		return false;
-	}
-
-	for (i = 0; i < jp2->numcomps; i++) {
-		jp2->comps[i].bpcc = cio_read(cio, 1);
-	}
-
-	if (cio_tell(cio) - box.init_pos != box.length) {
-		opj_event_msg(cinfo, EVT_ERROR, "Error with BPCC Box\n");
-		return false;
-	}
-
-	return true;
-}
-
-static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) {
-	opj_jp2_box_t box;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_COLR, 4);		/* COLR */
-
-	cio_write(cio, jp2->meth, 1);		/* METH */
-	cio_write(cio, jp2->precedence, 1);	/* PRECEDENCE */
-	cio_write(cio, jp2->approx, 1);		/* APPROX */
-
-	if (jp2->meth == 1) {
-		cio_write(cio, jp2->enumcs, 4);	/* EnumCS */
-	} else {
-		cio_write(cio, 0, 1);			/* PROFILE (??) */
-	}
-
-	box.length = cio_tell(cio) - box.init_pos;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-}
-
-static void jp2_free_pclr(opj_jp2_color_t *color)
-{
-    opj_free(color->jp2_pclr->channel_sign);
-    opj_free(color->jp2_pclr->channel_size);
-    opj_free(color->jp2_pclr->entries);
-
-	if(color->jp2_pclr->cmap) opj_free(color->jp2_pclr->cmap);
-
-    opj_free(color->jp2_pclr); color->jp2_pclr = NULL;
-}
-
-static void free_color_data(opj_jp2_color_t *color)
-{
-	if(color->jp2_pclr)
-   {
-	jp2_free_pclr(color);
-   }
-	if(color->jp2_cdef) 
-   {
-	if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info);
-	opj_free(color->jp2_cdef);
-   }
-	if(color->icc_profile_buf) opj_free(color->icc_profile_buf);
-}
-
-static void jp2_apply_pclr(opj_jp2_color_t *color, opj_image_t *image)
-{
-	opj_image_comp_t *old_comps, *new_comps;
-	unsigned char *channel_size, *channel_sign;
-	unsigned int *entries;
-	opj_jp2_cmap_comp_t *cmap;
-	int *src, *dst;
-	unsigned int j, max;
-	unsigned short i, nr_channels, cmp, pcol;
-	int k, top_k;
-
-	channel_size = color->jp2_pclr->channel_size;
-	channel_sign = color->jp2_pclr->channel_sign;
-	entries = color->jp2_pclr->entries;
-	cmap = color->jp2_pclr->cmap;
-	nr_channels = color->jp2_pclr->nr_channels;
-
-	old_comps = image->comps;
-	new_comps = (opj_image_comp_t*)
-	 opj_malloc(nr_channels * sizeof(opj_image_comp_t));
-
-	for(i = 0; i < nr_channels; ++i)
-   {
-	pcol = cmap[i].pcol; cmp = cmap[i].cmp;
-
-	new_comps[pcol] = old_comps[cmp];
-
-	if(cmap[i].mtyp == 0) /* Direct use */
-  {
-	old_comps[cmp].data = NULL; continue;
-  }
-/* Palette mapping: */
-	new_comps[pcol].data = (int*)
-	 opj_malloc(old_comps[cmp].w * old_comps[cmp].h * sizeof(int));
-	new_comps[pcol].prec = channel_size[i];
-	new_comps[pcol].sgnd = channel_sign[i];
-   }
-	top_k = color->jp2_pclr->nr_entries - 1;
-
-	for(i = 0; i < nr_channels; ++i)
-   {
-/* Direct use: */
-	if(cmap[i].mtyp == 0) continue;
-
-/* Palette mapping: */
-	cmp = cmap[i].cmp; pcol = cmap[i].pcol;
-	src = old_comps[cmp].data; 
-	dst = new_comps[pcol].data;
-	max = new_comps[pcol].w * new_comps[pcol].h;
-
-	for(j = 0; j < max; ++j)
-  {
-/* The index */
-	if((k = src[j]) < 0) k = 0; else if(k > top_k) k = top_k;
-/* The colour */
-	dst[j] = entries[k * nr_channels + pcol];
-  }
-   }
-	max = image->numcomps;
-	for(i = 0; i < max; ++i)
-   {
-	if(old_comps[i].data) opj_free(old_comps[i].data);
-   }
-	opj_free(old_comps);
-	image->comps = new_comps;
-	image->numcomps = nr_channels;
-
-	jp2_free_pclr(color);
-
-}/* apply_pclr() */
-
-static bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio,
-	opj_jp2_box_t *box, opj_jp2_color_t *color)
-{
-	opj_jp2_pclr_t *jp2_pclr;
-	unsigned char *channel_size, *channel_sign;
-	unsigned int *entries;
-	unsigned short nr_entries, nr_channels;
-	unsigned short i, j;
-	unsigned char uc;
-
-/* Part 1, I.5.3.4: 'There shall be at most one Palette box inside
- * a JP2 Header box' :
-*/
-	if(color->jp2_pclr) return false;
-
-	nr_entries = cio_read(cio, 2); /* NE */
-	nr_channels = cio_read(cio, 1);/* NPC */
-
-	entries = (unsigned int*)
-	 opj_malloc(nr_channels * nr_entries * sizeof(unsigned int));
-	channel_size = (unsigned char*)opj_malloc(nr_channels);
-	channel_sign = (unsigned char*)opj_malloc(nr_channels);
-
-	jp2_pclr = (opj_jp2_pclr_t*)opj_malloc(sizeof(opj_jp2_pclr_t));
-	jp2_pclr->channel_sign = channel_sign;
-	jp2_pclr->channel_size = channel_size;
-	jp2_pclr->entries = entries;
-	jp2_pclr->nr_entries = nr_entries;
-	jp2_pclr->nr_channels = nr_channels;
-	jp2_pclr->cmap = NULL;
-
-	color->jp2_pclr = jp2_pclr;
-
-	for(i = 0; i < nr_channels; ++i)
-   {
-	uc = cio_read(cio, 1); /* Bi */
-	channel_size[i] = (uc & 0x7f) + 1;
-	channel_sign[i] = (uc & 0x80)?1:0;
-   }
-
-	for(j = 0; j < nr_entries; ++j)
-   {
-	for(i = 0; i < nr_channels; ++i)
-  {
-/* Cji */
-	*entries++ = cio_read(cio, channel_size[i]>>3);
-  }
-   }
-
-	return true;
-}/* jp2_read_pclr() */
-
-static bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio,
-	opj_jp2_box_t *box, opj_jp2_color_t *color)
-{
-	opj_jp2_cmap_comp_t *cmap;
-	unsigned short i, nr_channels;
-
-/* Need nr_channels: */
-	if(color->jp2_pclr == NULL) return false;
-
-/* Part 1, I.5.3.5: 'There shall be at most one Component Mapping box
- * inside a JP2 Header box' :
-*/
-	if(color->jp2_pclr->cmap) return false;
-
-	nr_channels = color->jp2_pclr->nr_channels;
-	cmap = (opj_jp2_cmap_comp_t*)
-	 opj_malloc(nr_channels * sizeof(opj_jp2_cmap_comp_t));
-
-	for(i = 0; i < nr_channels; ++i)
-   {
-	cmap[i].cmp = cio_read(cio, 2);
-	cmap[i].mtyp = cio_read(cio, 1);
-	cmap[i].pcol = cio_read(cio, 1);
-
-   }
-	color->jp2_pclr->cmap = cmap;
-
-	return true;
-}/* jp2_read_cmap() */
-
-static void jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color)
-{
-	opj_jp2_cdef_info_t *info;
-	int color_space;
-	unsigned short i, n, cn, typ, asoc, acn;
-
-	color_space = image->color_space;
-	info = color->jp2_cdef->info;
-	n = color->jp2_cdef->n;
-
-	for(i = 0; i < n; ++i)
-   {
-/* WATCH: acn = asoc - 1 ! */
-	if((asoc = info[i].asoc) == 0) continue;
-
-	cn = info[i].cn; typ = info[i].typ; acn = asoc - 1;
-
-	if(cn != acn)
-  {
-	opj_image_comp_t saved;
-
-	memcpy(&saved, &image->comps[cn], sizeof(opj_image_comp_t));
-	memcpy(&image->comps[cn], &image->comps[acn], sizeof(opj_image_comp_t));
-	memcpy(&image->comps[acn], &saved, sizeof(opj_image_comp_t));
-
-	info[i].asoc = cn + 1;
-	info[acn].asoc = info[acn].cn + 1;
-  }
-   }
-	if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info);
-
-	opj_free(color->jp2_cdef); color->jp2_cdef = NULL;
-
-}/* jp2_apply_cdef() */
-
-static bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio,
-	opj_jp2_box_t *box, opj_jp2_color_t *color)
-{
-	opj_jp2_cdef_info_t *info;
-	unsigned short i, n;
-
-/* Part 1, I.5.3.6: 'The shall be at most one Channel Definition box
- * inside a JP2 Header box.' 
-*/
-	if(color->jp2_cdef) return false;
-
-	if((n = cio_read(cio, 2)) == 0) return false; /* szukw000: FIXME */
-
-	info = (opj_jp2_cdef_info_t*)
-	 opj_malloc(n * sizeof(opj_jp2_cdef_info_t));
-
-	color->jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
-	color->jp2_cdef->info = info;
-	color->jp2_cdef->n = n;
-
-	for(i = 0; i < n; ++i)
-   {
-	info[i].cn = cio_read(cio, 2);
-	info[i].typ = cio_read(cio, 2);
-	info[i].asoc = cio_read(cio, 2);
-
-   }
-	return true;
-}/* jp2_read_cdef() */
-
-static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
-	opj_jp2_box_t *box, opj_jp2_color_t *color) 
-{
-	int skip_len;
-    opj_common_ptr cinfo;
-
-/* Part 1, I.5.3.3 : 'A conforming JP2 reader shall ignore all Colour
- * Specification boxes after the first.' 
-*/
-	if(color->jp2_has_colr) return false;
-
-	cinfo = jp2->cinfo;
-
-	jp2->meth = cio_read(cio, 1);		/* METH */
-	jp2->precedence = cio_read(cio, 1);	/* PRECEDENCE */
-	jp2->approx = cio_read(cio, 1);		/* APPROX */
-
-	if (jp2->meth == 1) 
-   {
-	jp2->enumcs = cio_read(cio, 4);	/* EnumCS */
-   } 
-	else 
-   {
-/* skip PROFILE */
-	skip_len = box->init_pos + box->length - cio_tell(cio);
-	if (skip_len < 0) 
-  {
-	opj_event_msg(cinfo, EVT_ERROR, "Error with COLR box size\n");
-	return false;
-  }
-	if(skip_len > 0)
-  {
-	unsigned char *start;
-
-	start = cio_getbp(cio);
-	color->icc_profile_buf = (unsigned char*)opj_malloc(skip_len);
-	color->icc_profile_len = skip_len;
-
-	cio_skip(cio, box->init_pos + box->length - cio_tell(cio));
-
-	memcpy(color->icc_profile_buf, start, skip_len);
-  }
-   }
-
-	if (cio_tell(cio) - box->init_pos != box->length) 
-   {
-	opj_event_msg(cinfo, EVT_ERROR, "Error with COLR Box\n");
-	return false;
-   }
-	color->jp2_has_colr = 1;
-
-	return true;
-}/* jp2_read_colr() */
-
-bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color) 
-{
-	opj_jp2_box_t box;
-	unsigned int jp2h_end;
-
-	opj_common_ptr cinfo = jp2->cinfo;
-
-	jp2_read_boxhdr(cinfo, cio, &box);
-	do 
-   {
-	if (JP2_JP2H != box.type) 
-  {
-	if (box.type == JP2_JP2C) 
- {
-	opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n");
-	return false;
- }
-	cio_skip(cio, box.length - 8);
-
-	if(cio->bp >= cio->end) return false;
-
-	jp2_read_boxhdr(cinfo, cio, &box);
-  }
-   } while(JP2_JP2H != box.type);
-
-	if (!jp2_read_ihdr(jp2, cio))
-		return false;
-	jp2h_end = box.init_pos + box.length;
-
-	if (jp2->bpc == 255) 
-   {
-	if (!jp2_read_bpcc(jp2, cio))
-		return false;
-   }
-	jp2_read_boxhdr(cinfo, cio, &box);
-
-	while(cio_tell(cio) < jp2h_end)
-   {
-	if(box.type == JP2_COLR)
-  {
-	if( !jp2_read_colr(jp2, cio, &box, color))
- {
-    cio_seek(cio, box.init_pos + 8);
-    cio_skip(cio, box.length - 8);
- }
-    jp2_read_boxhdr(cinfo, cio, &box);
-    continue;
-  }
-    if(box.type == JP2_CDEF)
-  {
-    if( !jp2_read_cdef(jp2, cio, &box, color))
- {
-    cio_seek(cio, box.init_pos + 8);
-    cio_skip(cio, box.length - 8);
- }
-    jp2_read_boxhdr(cinfo, cio, &box);
-    continue;
-  }
-    if(box.type == JP2_PCLR)
-  {
-    if( !jp2_read_pclr(jp2, cio, &box, color))
- {
-    cio_seek(cio, box.init_pos + 8);
-    cio_skip(cio, box.length - 8);
- }
-    jp2_read_boxhdr(cinfo, cio, &box);
-    continue;
-  }
-    if(box.type == JP2_CMAP)
-  {
-    if( !jp2_read_cmap(jp2, cio, &box, color))
- {
-    cio_seek(cio, box.init_pos + 8);
-    cio_skip(cio, box.length - 8);
- }
-    jp2_read_boxhdr(cinfo, cio, &box);
-    continue;
-  }
-	cio_seek(cio, box.init_pos + 8);
-	cio_skip(cio, box.length - 8);
-	jp2_read_boxhdr(cinfo, cio, &box);
-
-   }/* while(cio_tell(cio) < box_end) */
-
-	cio_seek(cio, jp2h_end);
-
-/* Part 1, I.5.3.3 : 'must contain at least one' */
-	return (color->jp2_has_colr == 1);
-
-}/* jp2_read_jp2h() */
-
-opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, 
-	opj_codestream_info_t *cstr_info) 
-{
-	opj_common_ptr cinfo;
-	opj_image_t *image = NULL;
-	opj_jp2_color_t color;
-
-	if(!jp2 || !cio) 
-   {
-	return NULL;
-   }
-	memset(&color, 0, sizeof(opj_jp2_color_t));
-	cinfo = jp2->cinfo;
-
-/* JP2 decoding */
-	if(!jp2_read_struct(jp2, cio, &color)) 
-   {
-	free_color_data(&color);
-	opj_event_msg(cinfo, EVT_ERROR, "Failed to decode jp2 structure\n");
-	return NULL;
-   }
-
-/* J2K decoding */
-	image = j2k_decode(jp2->j2k, cio, cstr_info);
-
-	if(!image) 
-   {
-	free_color_data(&color);
-	opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n");
-	return NULL;
-   }
-
-/* Set Image Color Space */
-	if (jp2->enumcs == 16)
-		image->color_space = CLRSPC_SRGB;
-	else if (jp2->enumcs == 17)
-		image->color_space = CLRSPC_GRAY;
-	else if (jp2->enumcs == 18)
-		image->color_space = CLRSPC_SYCC;
-	else
-		image->color_space = CLRSPC_UNKNOWN;
-
-	if(color.jp2_cdef)
-   {
-	jp2_apply_cdef(image, &color);
-   }
-	if(color.jp2_pclr)
-   {
-/* Part 1, I.5.3.4: Either both or none : */
-	if( !color.jp2_pclr->cmap) 
-	 jp2_free_pclr(&color);
-	else
-	 jp2_apply_pclr(&color, image);
-   }
-	if(color.icc_profile_buf)
-   {
-	image->icc_profile_buf = color.icc_profile_buf;
-	color.icc_profile_buf = NULL;
-	image->icc_profile_len = color.icc_profile_len;
-   }
-	return image;
-
-}/* jp2_decode() */
-
-
-void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) {
-	opj_jp2_box_t box;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_JP2H, 4);	/* JP2H */
-
-	jp2_write_ihdr(jp2, cio);
-
-	if (jp2->bpc == 255) {
-		jp2_write_bpcc(jp2, cio);
-	}
-	jp2_write_colr(jp2, cio);
-
-	box.length = cio_tell(cio) - box.init_pos;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-}
-
-static void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
-	unsigned int i;
-	opj_jp2_box_t box;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_FTYP, 4);		/* FTYP */
-
-	cio_write(cio, jp2->brand, 4);		/* BR */
-	cio_write(cio, jp2->minversion, 4);	/* MinV */
-
-	for (i = 0; i < jp2->numcl; i++) {
-		cio_write(cio, jp2->cl[i], 4);	/* CL */
-	}
-
-	box.length = cio_tell(cio) - box.init_pos;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-}
-
-static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
-	int i;
-	opj_jp2_box_t box;
-
-	opj_common_ptr cinfo = jp2->cinfo;
-
-	jp2_read_boxhdr(cinfo, cio, &box);
-
-	if (JP2_FTYP != box.type) {
-		opj_event_msg(cinfo, EVT_ERROR, "Expected FTYP Marker\n");
-		return false;
-	}
-
-	jp2->brand = cio_read(cio, 4);		/* BR */
-	jp2->minversion = cio_read(cio, 4);	/* MinV */
-	jp2->numcl = (box.length - 16) / 4;
-	jp2->cl = (unsigned int *) opj_malloc(jp2->numcl * sizeof(unsigned int));
-
-	for (i = 0; i < (int)jp2->numcl; i++) {
-		jp2->cl[i] = cio_read(cio, 4);	/* CLi */
-	}
-
-	if (cio_tell(cio) - box.init_pos != box.length) {
-		opj_event_msg(cinfo, EVT_ERROR, "Error with FTYP Box\n");
-		return false;
-	}
-
-	return true;
-}
-
-static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
-	unsigned int j2k_codestream_offset, j2k_codestream_length;
-	opj_jp2_box_t box;
-
-	opj_j2k_t *j2k = jp2->j2k;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_JP2C, 4);	/* JP2C */
-
-	/* J2K encoding */
-	j2k_codestream_offset = cio_tell(cio);
-	if(!j2k_encode(j2k, cio, image, cstr_info)) {
-		opj_event_msg(j2k->cinfo, EVT_ERROR, "Failed to encode image\n");
-		return 0;
-	}
-	j2k_codestream_length = cio_tell(cio) - j2k_codestream_offset;
-
-	jp2->j2k_codestream_offset = j2k_codestream_offset;
-	jp2->j2k_codestream_length = j2k_codestream_length;
-
-	box.length = 8 + jp2->j2k_codestream_length;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-
-	return box.length;
-}
-
-static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset) {
-	opj_jp2_box_t box;
-
-	opj_common_ptr cinfo = jp2->cinfo;
-
-	jp2_read_boxhdr(cinfo, cio, &box);
-	do {
-		if(JP2_JP2C != box.type) {
-			cio_skip(cio, box.length - 8);
-			jp2_read_boxhdr(cinfo, cio, &box);
-		}
-	} while(JP2_JP2C != box.type);
-
-	*j2k_codestream_offset = cio_tell(cio);
-	*j2k_codestream_length = box.length - 8;
-
-	return true;
-}
-
-static void jp2_write_jp(opj_cio_t *cio) {
-	opj_jp2_box_t box;
-
-	box.init_pos = cio_tell(cio);
-	cio_skip(cio, 4);
-	cio_write(cio, JP2_JP, 4);		/* JP2 signature */
-	cio_write(cio, 0x0d0a870a, 4);
-
-	box.length = cio_tell(cio) - box.init_pos;
-	cio_seek(cio, box.init_pos);
-	cio_write(cio, box.length, 4);	/* L */
-	cio_seek(cio, box.init_pos + box.length);
-}
-
-static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) {
-	opj_jp2_box_t box;
-
-	opj_common_ptr cinfo = jp2->cinfo;
-
-	jp2_read_boxhdr(cinfo, cio, &box);
-	if (JP2_JP != box.type) {
-		opj_event_msg(cinfo, EVT_ERROR, "Expected JP Marker\n");
-		return false;
-	}
-	if (0x0d0a870a != cio_read(cio, 4)) {
-		opj_event_msg(cinfo, EVT_ERROR, "Error with JP Marker\n");
-		return false;
-	}
-	if (cio_tell(cio) - box.init_pos != box.length) {
-		opj_event_msg(cinfo, EVT_ERROR, "Error with JP Box size\n");
-		return false;
-	}
-
-	return true;
-}
-
-
-static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio,
-	opj_jp2_color_t *color) {
-	if (!jp2_read_jp(jp2, cio))
-		return false;
-	if (!jp2_read_ftyp(jp2, cio))
-		return false;
-	if (!jp2_read_jp2h(jp2, cio, color))
-		return false;
-	if (!jp2_read_jp2c(jp2, cio, &jp2->j2k_codestream_length, &jp2->j2k_codestream_offset))
-		return false;
-	
-	return true;
-}
-
-/* ----------------------------------------------------------------------- */
-/* JP2 decoder interface                                             */
-/* ----------------------------------------------------------------------- */
-
-opj_jp2_t* jp2_create_decompress(opj_common_ptr cinfo) {
-	opj_jp2_t *jp2 = (opj_jp2_t*) opj_calloc(1, sizeof(opj_jp2_t));
-	if(jp2) {
-		jp2->cinfo = cinfo;
-		/* create the J2K codec */
-		jp2->j2k = j2k_create_decompress(cinfo);
-		if(jp2->j2k == NULL) {
-			jp2_destroy_decompress(jp2);
-			return NULL;
-		}
-	}
-	return jp2;
-}
-
-void jp2_destroy_decompress(opj_jp2_t *jp2) {
-	if(jp2) {
-		/* destroy the J2K codec */
-		j2k_destroy_decompress(jp2->j2k);
-
-		if(jp2->comps) {
-			opj_free(jp2->comps);
-		}
-		if(jp2->cl) {
-			opj_free(jp2->cl);
-		}
-		opj_free(jp2);
-	}
-}
-
-void jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters) {
-	/* setup the J2K codec */
-	j2k_setup_decoder(jp2->j2k, parameters);
-	/* further JP2 initializations go here */
-}
-
-/* ----------------------------------------------------------------------- */
-/* JP2 encoder interface                                             */
-/* ----------------------------------------------------------------------- */
-
-opj_jp2_t* jp2_create_compress(opj_common_ptr cinfo) {
-	opj_jp2_t *jp2 = (opj_jp2_t*)opj_malloc(sizeof(opj_jp2_t));
-	if(jp2) {
-		jp2->cinfo = cinfo;
-		/* create the J2K codec */
-		jp2->j2k = j2k_create_compress(cinfo);
-		if(jp2->j2k == NULL) {
-			jp2_destroy_compress(jp2);
-			return NULL;
-		}
-	}
-	return jp2;
-}
-
-void jp2_destroy_compress(opj_jp2_t *jp2) {
-	if(jp2) {
-		/* destroy the J2K codec */
-		j2k_destroy_compress(jp2->j2k);
-
-		if(jp2->comps) {
-			opj_free(jp2->comps);
-		}
-		if(jp2->cl) {
-			opj_free(jp2->cl);
-		}
-		opj_free(jp2);
-	}
-}
-
-void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_t *image) {
-	int i;
-	int depth_0, sign;
-
-	if(!jp2 || !parameters || !image)
-		return;
-
-	/* setup the J2K codec */
-	/* ------------------- */
-
-	/* Check if number of components respects standard */
-	if (image->numcomps < 1 || image->numcomps > 16384) {
-		opj_event_msg(jp2->cinfo, EVT_ERROR, "Invalid number of components specified while setting up JP2 encoder\n");
-		return;
-	}
-
-	j2k_setup_encoder(jp2->j2k, parameters, image);
-
-	/* setup the JP2 codec */
-	/* ------------------- */
-	
-	/* Profile box */
-
-	jp2->brand = JP2_JP2;	/* BR */
-	jp2->minversion = 0;	/* MinV */
-	jp2->numcl = 1;
-	jp2->cl = (unsigned int*) opj_malloc(jp2->numcl * sizeof(unsigned int));
-	jp2->cl[0] = JP2_JP2;	/* CL0 : JP2 */
-
-	/* Image Header box */
-
-	jp2->numcomps = image->numcomps;	/* NC */
-	jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
-	jp2->h = image->y1 - image->y0;		/* HEIGHT */
-	jp2->w = image->x1 - image->x0;		/* WIDTH */
-	/* BPC */
-	depth_0 = image->comps[0].prec - 1;
-	sign = image->comps[0].sgnd;
-	jp2->bpc = depth_0 + (sign << 7);
-	for (i = 1; i < image->numcomps; i++) {
-		int depth = image->comps[i].prec - 1;
-		sign = image->comps[i].sgnd;
-		if (depth_0 != depth)
-			jp2->bpc = 255;
-	}
-	jp2->C = 7;			/* C : Always 7 */
-	jp2->UnkC = 0;		/* UnkC, colorspace specified in colr box */
-	jp2->IPR = 0;		/* IPR, no intellectual property */
-	
-	/* BitsPerComponent box */
-
-	for (i = 0; i < image->numcomps; i++) {
-		jp2->comps[i].bpcc = image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
-	}
-
-	/* Colour Specification box */
-
-	if ((image->numcomps == 1 || image->numcomps == 3) && (jp2->bpc != 255)) {
-		jp2->meth = 1;	/* METH: Enumerated colourspace */
-	} else {
-		jp2->meth = 2;	/* METH: Restricted ICC profile */
-	}
-	if (jp2->meth == 1) {
-		if (image->color_space == 1)
-			jp2->enumcs = 16;	/* sRGB as defined by IEC 61966�2�1 */
-		else if (image->color_space == 2)
-			jp2->enumcs = 17;	/* greyscale */
-		else if (image->color_space == 3)
-			jp2->enumcs = 18;	/* YUV */
-	} else {
-		jp2->enumcs = 0;		/* PROFILE (??) */
-	}
-	jp2->precedence = 0;	/* PRECEDENCE */
-	jp2->approx = 0;		/* APPROX */
-
-}
-
-bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
-
-	/* JP2 encoding */
-
-	/* JPEG 2000 Signature box */
-	jp2_write_jp(cio);
-	/* File Type box */
-	jp2_write_ftyp(jp2, cio);
-	/* JP2 Header box */
-	jp2_write_jp2h(jp2, cio);
-
-	/* J2K encoding */
-
-	if(!jp2_write_jp2c(jp2, cio, image, cstr_info)) {
-		opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
-		return false;
-	}
-
-	return true;
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.h
deleted file mode 100644
index 9ad662c..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jp2.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __JP2_H
-#define __JP2_H
-/**
- at file jp2.h
- at brief The JPEG-2000 file format Reader/Writer (JP2)
-
-*/
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-#define JPIP_JPIP 0x6a706970
-
-#define JP2_JP   0x6a502020		/**< JPEG 2000 signature box */
-#define JP2_FTYP 0x66747970		/**< File type box */
-#define JP2_JP2H 0x6a703268		/**< JP2 header box */
-#define JP2_IHDR 0x69686472		/**< Image header box */
-#define JP2_COLR 0x636f6c72		/**< Colour specification box */
-#define JP2_JP2C 0x6a703263		/**< Contiguous codestream box */
-#define JP2_URL  0x75726c20		/**< URL box */
-#define JP2_DTBL 0x6474626c		/**< Data Reference box */
-#define JP2_BPCC 0x62706363		/**< Bits per component box */
-#define JP2_JP2  0x6a703220		/**< File type fields */
-#define JP2_PCLR 0x70636c72		/**< Palette box */
-#define JP2_CMAP 0x636d6170		/**< Component Mapping box */
-#define JP2_CDEF 0x63646566		/**< Channel Definition box */
-
-/* ----------------------------------------------------------------------- */
-/** 
-Channel description: channel index, type, assocation
-*/
-typedef struct opj_jp2_cdef_info
-{
-    unsigned short cn, typ, asoc;
-} opj_jp2_cdef_info_t;
-
-/** 
-Channel descriptions and number of descriptions
-*/
-typedef struct opj_jp2_cdef
-{
-    opj_jp2_cdef_info_t *info;
-    unsigned short n;
-} opj_jp2_cdef_t;
-
-/** 
-Component mappings: channel index, mapping type, palette index
-*/
-typedef struct opj_jp2_cmap_comp
-{
-    unsigned short cmp;
-    unsigned char mtyp, pcol;
-} opj_jp2_cmap_comp_t;
-
-/** 
-Palette data: table entries, palette columns
-*/
-typedef struct opj_jp2_pclr
-{
-    unsigned int *entries;
-    unsigned char *channel_sign;
-    unsigned char *channel_size;
-    opj_jp2_cmap_comp_t *cmap;
-    unsigned short nr_entries, nr_channels;
-} opj_jp2_pclr_t;
-
-/** 
-Collector for ICC profile, palette, component mapping, channel description 
-*/
-typedef struct opj_jp2_color
-{
-    unsigned char *icc_profile_buf;
-    int icc_profile_len;
-
-    opj_jp2_cdef_t *jp2_cdef;
-    opj_jp2_pclr_t *jp2_pclr;
-    unsigned char jp2_has_colr;
-} opj_jp2_color_t;
-
-/** 
-JP2 component
-*/
-typedef struct opj_jp2_comps {
-  int depth;		  
-  int sgnd;		   
-  int bpcc;
-} opj_jp2_comps_t;
-
-/**
-JPEG-2000 file format reader/writer
-*/
-typedef struct opj_jp2 {
-	/** codec context */
-	opj_common_ptr cinfo;
-	/** handle to the J2K codec  */
-	opj_j2k_t *j2k;
-	unsigned int w;
-	unsigned int h;
-	unsigned int numcomps;
-	unsigned int bpc;
-	unsigned int C;
-	unsigned int UnkC;
-	unsigned int IPR;
-	unsigned int meth;
-	unsigned int approx;
-	unsigned int enumcs;
-	unsigned int precedence;
-	unsigned int brand;
-	unsigned int minversion;
-	unsigned int numcl;
-	unsigned int *cl;
-	opj_jp2_comps_t *comps;
-	unsigned int j2k_codestream_offset;
-	unsigned int j2k_codestream_length;
-} opj_jp2_t;
-
-/**
-JP2 Box
-*/
-typedef struct opj_jp2_box {
-  int length;
-  int type;
-  int init_pos;
-} opj_jp2_box_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Write the JP2H box - JP2 Header box (used in MJ2)
- at param jp2 JP2 handle
- at param cio Output buffer stream
-*/
-void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio);
-/**
-Read the JP2H box - JP2 Header box (used in MJ2)
- at param jp2 JP2 handle
- at param cio Input buffer stream
- at param ext Collector for profile, cdef and pclr data
- at return Returns true if successful, returns false otherwise
-*/
-bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color);
-/**
-Creates a JP2 decompression structure
- at param cinfo Codec context info
- at return Returns a handle to a JP2 decompressor if successful, returns NULL otherwise
-*/
-opj_jp2_t* jp2_create_decompress(opj_common_ptr cinfo);
-/**
-Destroy a JP2 decompressor handle
- at param jp2 JP2 decompressor handle to destroy
-*/
-void jp2_destroy_decompress(opj_jp2_t *jp2);
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in jp2->j2k->cp. 
- at param jp2 JP2 decompressor handle
- at param parameters decompression parameters
-*/
-void jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
-/**
-Decode an image from a JPEG-2000 file stream
- at param jp2 JP2 decompressor handle
- at param cio Input buffer stream
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
-/**
-Creates a JP2 compression structure
- at param cinfo Codec context info
- at return Returns a handle to a JP2 compressor if successful, returns NULL otherwise
-*/
-opj_jp2_t* jp2_create_compress(opj_common_ptr cinfo);
-/**
-Destroy a JP2 compressor handle
- at param jp2 JP2 compressor handle to destroy
-*/
-void jp2_destroy_compress(opj_jp2_t *jp2);
-/**
-Setup the encoder parameters using the current image and using user parameters. 
-Coding parameters are returned in jp2->j2k->cp. 
- at param jp2 JP2 compressor handle
- at param parameters compression parameters
- at param image input filled image
-*/
-void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_t *image);
-/**
-Encode an image into a JPEG-2000 file stream
- at param jp2 JP2 compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __JP2_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.c
deleted file mode 100644
index a2566ea..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/*
- * Read the information contains in VBAS [JPP/JPT stream message header]
- * Store information (7 bits) in value
- *
- */
-unsigned int jpt_read_VBAS_info(opj_cio_t *cio, unsigned int value) {
-	unsigned char elmt;
-
-	elmt = cio_read(cio, 1);
-	while ((elmt >> 7) == 1) {
-		value = (value << 7);
-		value |= (elmt & 0x7f);
-		elmt = cio_read(cio, 1);
-	}
-	value = (value << 7);
-	value |= (elmt & 0x7f);
-
-	return value;
-}
-
-/*
- * Initialize the value of the message header structure 
- *
- */
-void jpt_init_msg_header(opj_jpt_msg_header_t * header) {
-	header->Id = 0;		/* In-class Identifier    */
-	header->last_byte = 0;	/* Last byte information  */
-	header->Class_Id = 0;		/* Class Identifier       */
-	header->CSn_Id = 0;		/* CSn : index identifier */
-	header->Msg_offset = 0;	/* Message offset         */
-	header->Msg_length = 0;	/* Message length         */
-	header->Layer_nb = 0;		/* Auxiliary for JPP case */
-}
-
-/*
- * Re-initialize the value of the message header structure
- *
- * Only parameters always present in message header
- *
- */
-void jpt_reinit_msg_header(opj_jpt_msg_header_t * header) {
-	header->Id = 0;		/* In-class Identifier    */
-	header->last_byte = 0;	/* Last byte information  */
-	header->Msg_offset = 0;	/* Message offset         */
-	header->Msg_length = 0;	/* Message length         */
-}
-
-/*
- * Read the message header for a JPP/JPT - stream
- *
- */
-void jpt_read_msg_header(opj_common_ptr cinfo, opj_cio_t *cio, opj_jpt_msg_header_t *header) {
-	unsigned char elmt, Class = 0, CSn = 0;
-	jpt_reinit_msg_header(header);
-
-	/* ------------- */
-	/* VBAS : Bin-ID */
-	/* ------------- */
-	elmt = cio_read(cio, 1);
-
-	/* See for Class and CSn */
-	switch ((elmt >> 5) & 0x03) {
-		case 0:
-			opj_event_msg(cinfo, EVT_ERROR, "Forbidden value encounter in message header !!\n");
-			break;
-		case 1:
-			Class = 0;
-			CSn = 0;
-			break;
-		case 2:
-			Class = 1;
-			CSn = 0;
-			break;
-		case 3:
-			Class = 1;
-			CSn = 1;
-			break;
-		default:
-			break;
-	}
-
-	/* see information on bits 'c' [p 10 : A.2.1 general, ISO/IEC FCD 15444-9] */
-	if (((elmt >> 4) & 0x01) == 1)
-		header->last_byte = 1;
-
-	/* In-class identifier */
-	header->Id |= (elmt & 0x0f);
-	if ((elmt >> 7) == 1)
-		header->Id = jpt_read_VBAS_info(cio, header->Id);
-
-	/* ------------ */
-	/* VBAS : Class */
-	/* ------------ */
-	if (Class == 1) {
-		header->Class_Id = 0;
-		header->Class_Id = jpt_read_VBAS_info(cio, header->Class_Id);
-	}
-
-	/* ---------- */
-	/* VBAS : CSn */
-	/* ---------- */
-	if (CSn == 1) {
-		header->CSn_Id = 0;
-		header->CSn_Id = jpt_read_VBAS_info(cio, header->CSn_Id);
-	}
-
-	/* ----------------- */
-	/* VBAS : Msg_offset */
-	/* ----------------- */
-	header->Msg_offset = jpt_read_VBAS_info(cio, header->Msg_offset);
-
-	/* ----------------- */
-	/* VBAS : Msg_length */
-	/* ----------------- */
-	header->Msg_length = jpt_read_VBAS_info(cio, header->Msg_length);
-
-	/* ---------- */
-	/* VBAS : Aux */
-	/* ---------- */
-	if ((header->Class_Id & 0x01) == 1) {
-		header->Layer_nb = 0;
-		header->Layer_nb = jpt_read_VBAS_info(cio, header->Layer_nb);
-	}
-}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.h
deleted file mode 100644
index eb01f98..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/jpt.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __JPT_H
-#define __JPT_H
-/**
- at file jpt.h
- at brief JPT-stream reader (JPEG 2000, JPIP)
-
-JPT-stream functions are implemented in J2K.C. 
-*/
-
-/**
-Message Header JPT stream structure
-*/
-typedef struct opj_jpt_msg_header {
-	/** In-class Identifier */
-	unsigned int Id;
-	/** Last byte information */
-	unsigned int last_byte;	
-	/** Class Identifier */
-	unsigned int Class_Id;	
-	/** CSn : index identifier */
-	unsigned int CSn_Id;
-	/** Message offset */
-	unsigned int Msg_offset;
-	/** Message length */
-	unsigned int Msg_length;
-	/** Auxiliary for JPP case */
-	unsigned int Layer_nb;
-} opj_jpt_msg_header_t;
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Initialize the value of the message header structure 
- at param header Message header structure
-*/
-void jpt_init_msg_header(opj_jpt_msg_header_t * header);
-
-/**
-Read the message header for a JPP/JPT - stream
- at param cinfo Codec context info
- at param cio CIO handle
- at param header Message header structure
-*/
-void jpt_read_msg_header(opj_common_ptr cinfo, opj_cio_t *cio, opj_jpt_msg_header_t *header);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mct.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/mct.c
deleted file mode 100644
index 870993b..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mct.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef __SSE__
-#include <xmmintrin.h>
-#endif
-
-#include "opj_includes.h"
-
-/* <summary> */
-/* This table contains the norms of the basis function of the reversible MCT. */
-/* </summary> */
-static const double mct_norms[3] = { 1.732, .8292, .8292 };
-
-/* <summary> */
-/* This table contains the norms of the basis function of the irreversible MCT. */
-/* </summary> */
-static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
-
-/* <summary> */
-/* Foward reversible MCT. */
-/* </summary> */
-void mct_encode(
-		int* restrict c0,
-		int* restrict c1,
-		int* restrict c2,
-		int n)
-{
-	int i;
-	for(i = 0; i < n; ++i) {
-		int r = c0[i];
-		int g = c1[i];
-		int b = c2[i];
-		int y = (r + (g * 2) + b) >> 2;
-		int u = b - g;
-		int v = r - g;
-		c0[i] = y;
-		c1[i] = u;
-		c2[i] = v;
-	}
-}
-
-/* <summary> */
-/* Inverse reversible MCT. */
-/* </summary> */
-void mct_decode(
-		int* restrict c0,
-		int* restrict c1, 
-		int* restrict c2, 
-		int n)
-{
-	int i;
-	for (i = 0; i < n; ++i) {
-		int y = c0[i];
-		int u = c1[i];
-		int v = c2[i];
-		int g = y - ((u + v) >> 2);
-		int r = v + g;
-		int b = u + g;
-		c0[i] = r;
-		c1[i] = g;
-		c2[i] = b;
-	}
-}
-
-/* <summary> */
-/* Get norm of basis function of reversible MCT. */
-/* </summary> */
-double mct_getnorm(int compno) {
-	return mct_norms[compno];
-}
-
-/* <summary> */
-/* Foward irreversible MCT. */
-/* </summary> */
-void mct_encode_real(
-		int* restrict c0,
-		int* restrict c1,
-		int* restrict c2,
-		int n)
-{
-	int i;
-	for(i = 0; i < n; ++i) {
-		int r = c0[i];
-		int g = c1[i];
-		int b = c2[i];
-		int y =  fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
-		int u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
-		int v =  fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
-		c0[i] = y;
-		c1[i] = u;
-		c2[i] = v;
-	}
-}
-
-/* <summary> */
-/* Inverse irreversible MCT. */
-/* </summary> */
-void mct_decode_real(
-		float* restrict c0,
-		float* restrict c1,
-		float* restrict c2,
-		int n)
-{
-	int i;
-#ifdef __SSE__
-	__m128 vrv, vgu, vgv, vbu;
-	vrv = _mm_set1_ps(1.402f);
-	vgu = _mm_set1_ps(0.34413f);
-	vgv = _mm_set1_ps(0.71414f);
-	vbu = _mm_set1_ps(1.772f);
-	for (i = 0; i < (n >> 3); ++i) {
-		__m128 vy, vu, vv;
-		__m128 vr, vg, vb;
-
-		vy = _mm_load_ps(c0);
-		vu = _mm_load_ps(c1);
-		vv = _mm_load_ps(c2);
-		vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv));
-		vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv));
-		vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu));
-		_mm_store_ps(c0, vr);
-		_mm_store_ps(c1, vg);
-		_mm_store_ps(c2, vb);
-		c0 += 4;
-		c1 += 4;
-		c2 += 4;
-
-		vy = _mm_load_ps(c0);
-		vu = _mm_load_ps(c1);
-		vv = _mm_load_ps(c2);
-		vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv));
-		vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv));
-		vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu));
-		_mm_store_ps(c0, vr);
-		_mm_store_ps(c1, vg);
-		_mm_store_ps(c2, vb);
-		c0 += 4;
-		c1 += 4;
-		c2 += 4;
-	}
-	n &= 7;
-#endif
-	for(i = 0; i < n; ++i) {
-		float y = c0[i];
-		float u = c1[i];
-		float v = c2[i];
-		float r = y + (v * 1.402f);
-		float g = y - (u * 0.34413f) - (v * (0.71414f));
-		float b = y + (u * 1.772f);
-		c0[i] = r;
-		c1[i] = g;
-		c2[i] = b;
-	}
-}
-
-/* <summary> */
-/* Get norm of basis function of irreversible MCT. */
-/* </summary> */
-double mct_getnorm_real(int compno) {
-	return mct_norms_real[compno];
-}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.c
deleted file mode 100644
index 6722b33..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef _WIN32
-#include <windows.h>
-#endif /* _WIN32 */
-
-#include "opj_config.h"
-#include "opj_includes.h"
-
-/* ---------------------------------------------------------------------- */
-#ifdef _WIN32
-#ifndef OPJ_STATIC
-BOOL APIENTRY
-DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
-	switch (ul_reason_for_call) {
-		case DLL_PROCESS_ATTACH :
-			break;
-		case DLL_PROCESS_DETACH :
-			break;
-		case DLL_THREAD_ATTACH :
-		case DLL_THREAD_DETACH :
-			break;
-    }
-
-    return TRUE;
-}
-#endif /* OPJ_STATIC */
-#endif /* _WIN32 */
-
-/* ---------------------------------------------------------------------- */
-
-
-const char* OPJ_CALLCONV opj_version(void) {
-    return PACKAGE_VERSION;
-}
-
-opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
-	opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_calloc(1, sizeof(opj_dinfo_t));
-	if(!dinfo) return NULL;
-	dinfo->is_decompressor = true;
-	switch(format) {
-		case CODEC_J2K:
-		case CODEC_JPT:
-			/* get a J2K decoder handle */
-			dinfo->j2k_handle = (void*)j2k_create_decompress((opj_common_ptr)dinfo);
-			if(!dinfo->j2k_handle) {
-				opj_free(dinfo);
-				return NULL;
-			}
-			break;
-		case CODEC_JP2:
-			/* get a JP2 decoder handle */
-			dinfo->jp2_handle = (void*)jp2_create_decompress((opj_common_ptr)dinfo);
-			if(!dinfo->jp2_handle) {
-				opj_free(dinfo);
-				return NULL;
-			}
-			break;
-		case CODEC_UNKNOWN:
-		default:
-			opj_free(dinfo);
-			return NULL;
-	}
-
-	dinfo->codec_format = format;
-
-	return dinfo;
-}
-
-void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
-	if(dinfo) {
-		/* destroy the codec */
-		switch(dinfo->codec_format) {
-			case CODEC_J2K:
-			case CODEC_JPT:
-				j2k_destroy_decompress((opj_j2k_t*)dinfo->j2k_handle);
-				break;
-			case CODEC_JP2:
-				jp2_destroy_decompress((opj_jp2_t*)dinfo->jp2_handle);
-				break;
-			case CODEC_UNKNOWN:
-			default:
-				break;
-		}
-		/* destroy the decompressor */
-		opj_free(dinfo);
-	}
-}
-
-void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
-	if(parameters) {
-		memset(parameters, 0, sizeof(opj_dparameters_t));
-		/* default decoding parameters */
-		parameters->cp_layer = 0;
-		parameters->cp_reduce = 0;
-		parameters->cp_limit_decoding = NO_LIMITATION;
-
-		parameters->decod_format = -1;
-		parameters->cod_format = -1;
-/* UniPG>> */
-#ifdef USE_JPWL
-		parameters->jpwl_correct = false;
-		parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
-		parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
-#endif /* USE_JPWL */
-/* <<UniPG */
-	}
-}
-
-void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
-	if(dinfo && parameters) {
-		switch(dinfo->codec_format) {
-			case CODEC_J2K:
-			case CODEC_JPT:
-				j2k_setup_decoder((opj_j2k_t*)dinfo->j2k_handle, parameters);
-				break;
-			case CODEC_JP2:
-				jp2_setup_decoder((opj_jp2_t*)dinfo->jp2_handle, parameters);
-				break;
-			case CODEC_UNKNOWN:
-			default:
-				break;
-		}
-	}
-}
-
-opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
-	return opj_decode_with_info(dinfo, cio, NULL);
-}
-
-opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info) {
-	if(dinfo && cio) {
-		switch(dinfo->codec_format) {
-			case CODEC_J2K:
-				return j2k_decode((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info);
-			case CODEC_JPT:
-				return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info);
-			case CODEC_JP2:
-				return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info);
-			case CODEC_UNKNOWN:
-			default:
-				break;
-		}
-	}
-	return NULL;
-}
-
-opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
-	opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_calloc(1, sizeof(opj_cinfo_t));
-	if(!cinfo) return NULL;
-	cinfo->is_decompressor = false;
-	switch(format) {
-		case CODEC_J2K:
-			/* get a J2K coder handle */
-			cinfo->j2k_handle = (void*)j2k_create_compress((opj_common_ptr)cinfo);
-			if(!cinfo->j2k_handle) {
-				opj_free(cinfo);
-				return NULL;
-			}
-			break;
-		case CODEC_JP2:
-			/* get a JP2 coder handle */
-			cinfo->jp2_handle = (void*)jp2_create_compress((opj_common_ptr)cinfo);
-			if(!cinfo->jp2_handle) {
-				opj_free(cinfo);
-				return NULL;
-			}
-			break;
-		case CODEC_JPT:
-		case CODEC_UNKNOWN:
-		default:
-			opj_free(cinfo);
-			return NULL;
-	}
-
-	cinfo->codec_format = format;
-
-	return cinfo;
-}
-
-void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
-	if(cinfo) {
-		/* destroy the codec */
-		switch(cinfo->codec_format) {
-			case CODEC_J2K:
-				j2k_destroy_compress((opj_j2k_t*)cinfo->j2k_handle);
-				break;
-			case CODEC_JP2:
-				jp2_destroy_compress((opj_jp2_t*)cinfo->jp2_handle);
-				break;
-			case CODEC_JPT:
-			case CODEC_UNKNOWN:
-			default:
-				break;
-		}
-		/* destroy the decompressor */
-		opj_free(cinfo);
-	}
-}
-
-void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
-	if(parameters) {
-		memset(parameters, 0, sizeof(opj_cparameters_t));
-		/* default coding parameters */
-		parameters->cp_cinema = OFF; 
-		parameters->max_comp_size = 0;
-		parameters->numresolution = 6;
-		parameters->cp_rsiz = STD_RSIZ;
-		parameters->cblockw_init = 64;
-		parameters->cblockh_init = 64;
-		parameters->prog_order = LRCP;
-		parameters->roi_compno = -1;		/* no ROI */
-		parameters->subsampling_dx = 1;
-		parameters->subsampling_dy = 1;
-		parameters->tp_on = 0;
-		parameters->decod_format = -1;
-		parameters->cod_format = -1;
-		parameters->tcp_rates[0] = 0;   
-		parameters->tcp_numlayers = 0;
-    parameters->cp_disto_alloc = 0;
-		parameters->cp_fixed_alloc = 0;
-		parameters->cp_fixed_quality = 0;
-
-/* UniPG>> */
-#ifdef USE_JPWL
-		parameters->jpwl_epc_on = false;
-		parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
-		{
-			int i;
-			for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-				parameters->jpwl_hprot_TPH_tileno[i] = -1; /* unassigned */
-				parameters->jpwl_hprot_TPH[i] = 0; /* absent */
-			}
-		};
-		{
-			int i;
-			for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
-				parameters->jpwl_pprot_tileno[i] = -1; /* unassigned */
-				parameters->jpwl_pprot_packno[i] = -1; /* unassigned */
-				parameters->jpwl_pprot[i] = 0; /* absent */
-			}
-		};
-		parameters->jpwl_sens_size = 0; /* 0 means no ESD */
-		parameters->jpwl_sens_addr = 0; /* 0 means auto */
-		parameters->jpwl_sens_range = 0; /* 0 means packet */
-		parameters->jpwl_sens_MH = -1; /* -1 means unassigned */
-		{
-			int i;
-			for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-				parameters->jpwl_sens_TPH_tileno[i] = -1; /* unassigned */
-				parameters->jpwl_sens_TPH[i] = -1; /* absent */
-			}
-		};
-#endif /* USE_JPWL */
-/* <<UniPG */
-	}
-}
-
-void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image) {
-	if(cinfo && parameters && image) {
-		switch(cinfo->codec_format) {
-			case CODEC_J2K:
-				j2k_setup_encoder((opj_j2k_t*)cinfo->j2k_handle, parameters, image);
-				break;
-			case CODEC_JP2:
-				jp2_setup_encoder((opj_jp2_t*)cinfo->jp2_handle, parameters, image);
-				break;
-			case CODEC_JPT:
-			case CODEC_UNKNOWN:
-			default:
-				break;
-		}
-	}
-}
-
-bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
-	if (index != NULL)
-		opj_event_msg((opj_common_ptr)cinfo, EVT_WARNING, "Set index to NULL when calling the opj_encode function.\n"
-		"To extract the index, use the opj_encode_with_info() function.\n"
-		"No index will be generated during this encoding\n");
-	return opj_encode_with_info(cinfo, cio, image, NULL);
-}
-
-bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
-	if(cinfo && cio && image) {
-		switch(cinfo->codec_format) {
-			case CODEC_J2K:
-				return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, cstr_info);
-			case CODEC_JP2:
-				return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info);
-			case CODEC_JPT:
-			case CODEC_UNKNOWN:
-			default:
-				break;
-		}
-	}
-	return false;
-}
-
-void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
-	if (cstr_info) {
-		int tileno;
-		for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
-			opj_tile_info_t *tile_info = &cstr_info->tile[tileno];
-			opj_free(tile_info->thresh);
-			opj_free(tile_info->packet);
-			opj_free(tile_info->tp);
-		}
-		opj_free(cstr_info->tile);
-		opj_free(cstr_info->marker);
-		opj_free(cstr_info->numdecompos);
-	}
-}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.h
deleted file mode 100644
index 6b17c64..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/openjpeg.h
+++ /dev/null
@@ -1,919 +0,0 @@
- /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPENJPEG_H
-#define OPENJPEG_H
-
-
-/* 
-==========================================================
-   Compiler directives
-==========================================================
-*/
-
-#if defined(OPJ_STATIC) || !defined(_WIN32)
-#if __GNUC__ >= 4
-#define OPJ_API    __attribute__ ((visibility ("default")))
-#else
-#define OPJ_API
-#endif
-#define OPJ_CALLCONV
-#else
-#define OPJ_CALLCONV __stdcall
-/*
-The following ifdef block is the standard way of creating macros which make exporting 
-from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
-symbol defined on the command line. this symbol should not be defined on any project
-that uses this DLL. This way any other project whose source files include this file see 
-OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
-defined with this macro as being exported.
-*/
-#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
-#define OPJ_API __declspec(dllexport)
-#else
-#define OPJ_API __declspec(dllimport)
-#endif /* OPJ_EXPORTS */
-#endif /* !OPJ_STATIC || !_WIN32 */
-
-#ifndef __cplusplus
-#if defined(HAVE_STDBOOL_H)
-/*
-The C language implementation does correctly provide the standard header
-file "stdbool.h".
- */
-#include <stdbool.h>
-#else
-/*
-The C language implementation does not provide the standard header file
-"stdbool.h" as required by ISO/IEC 9899:1999.  Try to compensate for this
-braindamage below.
-*/
-#if !defined(bool)
-#define	bool	int
-#endif
-#if !defined(true)
-#define true	1
-#endif
-#if !defined(false)
-#define	false	0
-#endif
-#endif
-#endif /* __cplusplus */
-
-/* 
-==========================================================
-   Useful constant definitions
-==========================================================
-*/
-
-#define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
-
-#define J2K_MAXRLVLS 33					/**< Number of maximum resolution level authorized */
-#define J2K_MAXBANDS (3*J2K_MAXRLVLS-2)	/**< Number of maximum sub-band linked to number of resolution level */
-
-/* UniPG>> */
-#define JPWL_MAX_NO_TILESPECS	16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
-#define JPWL_MAX_NO_PACKSPECS	16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
-#define JPWL_MAX_NO_MARKERS	512 /**< Maximum number of JPWL markers: increase at your will */
-#define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
-#define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
-#define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
-#define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
-#define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
-/* <<UniPG */
-
-/* 
-==========================================================
-   enum definitions
-==========================================================
-*/
-/** 
-Rsiz Capabilities
-*/
-typedef enum RSIZ_CAPABILITIES {
-	STD_RSIZ = 0,		/** Standard JPEG2000 profile*/
-	CINEMA2K = 3,		/** Profile name for a 2K image*/
-	CINEMA4K = 4		/** Profile name for a 4K image*/
-} OPJ_RSIZ_CAPABILITIES;
-
-/** 
-Digital cinema operation mode 
-*/
-typedef enum CINEMA_MODE {
-	OFF = 0,					/** Not Digital Cinema*/
-	CINEMA2K_24 = 1,	/** 2K Digital Cinema at 24 fps*/
-	CINEMA2K_48 = 2,	/** 2K Digital Cinema at 48 fps*/
-	CINEMA4K_24 = 3		/** 4K Digital Cinema at 24 fps*/
-}OPJ_CINEMA_MODE;
-
-/** 
-Progression order 
-*/
-typedef enum PROG_ORDER {
-	PROG_UNKNOWN = -1,	/**< place-holder */
-	LRCP = 0,		/**< layer-resolution-component-precinct order */
-	RLCP = 1,		/**< resolution-layer-component-precinct order */
-	RPCL = 2,		/**< resolution-precinct-component-layer order */
-	PCRL = 3,		/**< precinct-component-resolution-layer order */
-	CPRL = 4		/**< component-precinct-resolution-layer order */
-} OPJ_PROG_ORDER;
-
-/**
-Supported image color spaces
-*/
-typedef enum COLOR_SPACE {
-	CLRSPC_UNKNOWN = -1,	/**< not supported by the library */
-	CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ 
-	CLRSPC_SRGB = 1,		/**< sRGB */
-	CLRSPC_GRAY = 2,		/**< grayscale */
-	CLRSPC_SYCC = 3			/**< YUV */
-} OPJ_COLOR_SPACE;
-
-/**
-Supported codec
-*/
-typedef enum CODEC_FORMAT {
-	CODEC_UNKNOWN = -1,	/**< place-holder */
-	CODEC_J2K = 0,		/**< JPEG-2000 codestream : read/write */
-	CODEC_JPT = 1,		/**< JPT-stream (JPEG 2000, JPIP) : read only */
-	CODEC_JP2 = 2		/**< JPEG-2000 file format : read/write */
-} OPJ_CODEC_FORMAT;
-
-/** 
-Limit decoding to certain portions of the codestream. 
-*/
-typedef enum LIMIT_DECODING {
-	NO_LIMITATION = 0,				  /**< No limitation for the decoding. The entire codestream will de decoded */
-	LIMIT_TO_MAIN_HEADER = 1,		/**< The decoding is limited to the Main Header */
-	DECODE_ALL_BUT_PACKETS = 2	/**< Decode everything except the JPEG 2000 packets */
-} OPJ_LIMIT_DECODING;
-
-/* 
-==========================================================
-   event manager typedef definitions
-==========================================================
-*/
-
-/**
-Callback function prototype for events
- at param msg Event message
- at param client_data 
-*/
-typedef void (*opj_msg_callback) (const char *msg, void *client_data);
-
-/**
-Message handler object
-used for 
-<ul>
-<li>Error messages
-<li>Warning messages
-<li>Debugging messages
-</ul>
-*/
-typedef struct opj_event_mgr {
-	/** Error message callback if available, NULL otherwise */
-	opj_msg_callback error_handler;
-	/** Warning message callback if available, NULL otherwise */
-	opj_msg_callback warning_handler;
-	/** Debug message callback if available, NULL otherwise */
-	opj_msg_callback info_handler;
-} opj_event_mgr_t;
-
-
-/* 
-==========================================================
-   codec typedef definitions
-==========================================================
-*/
-
-/**
-Progression order changes
-*/
-typedef struct opj_poc {
-	/** Resolution num start, Component num start, given by POC */
-	int resno0, compno0;
-	/** Layer num end,Resolution num end, Component num end, given by POC */
-	int layno1, resno1, compno1;
-	/** Layer num start,Precinct num start, Precinct num end */
-	int layno0, precno0, precno1;
-	/** Progression order enum*/
-	OPJ_PROG_ORDER prg1,prg;
-	/** Progression order string*/
-	char progorder[5];
-	/** Tile number */
-	int tile;
-	/** Start and end values for Tile width and height*/
-	int tx0,tx1,ty0,ty1;
-	/** Start value, initialised in pi_initialise_encode*/
-	int layS, resS, compS, prcS;
-	/** End value, initialised in pi_initialise_encode */
-	int layE, resE, compE, prcE;
-	/** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
-	int txS,txE,tyS,tyE,dx,dy;
-	/** Temporary values for Tile parts, initialised in pi_create_encode */
-	int lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
-} opj_poc_t;
-
-/**
-Compression parameters
-*/
-typedef struct opj_cparameters {
-	/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
-	bool tile_size_on;
-	/** XTOsiz */
-	int cp_tx0;
-	/** YTOsiz */
-	int cp_ty0;
-	/** XTsiz */
-	int cp_tdx;
-	/** YTsiz */
-	int cp_tdy;
-	/** allocation by rate/distortion */
-	int cp_disto_alloc;
-	/** allocation by fixed layer */
-	int cp_fixed_alloc;
-	/** add fixed_quality */
-	int cp_fixed_quality;
-	/** fixed layer */
-	int *cp_matrice;
-	/** comment for coding */
-	char *cp_comment;
-	/** csty : coding style */
-	int csty;
-	/** progression order (default LRCP) */
-	OPJ_PROG_ORDER prog_order;
-	/** progression order changes */
-	opj_poc_t POC[32];
-	/** number of progression order changes (POC), default to 0 */
-	int numpocs;
-	/** number of layers */
-	int tcp_numlayers;
-	/** rates of layers */
-	float tcp_rates[100];
-	/** different psnr for successive layers */
-	float tcp_distoratio[100];
-	/** number of resolutions */
-	int numresolution;
-	/** initial code block width, default to 64 */
- 	int cblockw_init;
-	/** initial code block height, default to 64 */
-	int cblockh_init;
-	/** mode switch (cblk_style) */
-	int mode;
-	/** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
-	int irreversible;
-	/** region of interest: affected component in [0..3], -1 means no ROI */
-	int roi_compno;
-	/** region of interest: upshift value */
-	int roi_shift;
-	/* number of precinct size specifications */
-	int res_spec;
-	/** initial precinct width */
-	int prcw_init[J2K_MAXRLVLS];
-	/** initial precinct height */
-	int prch_init[J2K_MAXRLVLS];
-
-	/**@name command line encoder parameters (not used inside the library) */
-	/*@{*/
-	/** input file name */
-	char infile[OPJ_PATH_LEN];
-	/** output file name */
-	char outfile[OPJ_PATH_LEN];
-	/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
-	int index_on;
-	/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
-	char index[OPJ_PATH_LEN];
-	/** subimage encoding: origin image offset in x direction */
-	int image_offset_x0;
-	/** subimage encoding: origin image offset in y direction */
-	int image_offset_y0;
-	/** subsampling value for dx */
-	int subsampling_dx;
-	/** subsampling value for dy */
-	int subsampling_dy;
-	/** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
-	int decod_format;
-	/** output file format 0: J2K, 1: JP2, 2: JPT */
-	int cod_format;
-	/*@}*/
-
-/* UniPG>> */
-	/**@name JPWL encoding parameters */
-	/*@{*/
-	/** enables writing of EPC in MH, thus activating JPWL */
-	bool jpwl_epc_on;
-	/** error protection method for MH (0,1,16,32,37-128) */
-	int jpwl_hprot_MH;
-	/** tile number of header protection specification (>=0) */
-	int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-	/** error protection methods for TPHs (0,1,16,32,37-128) */
-	int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
-	/** tile number of packet protection specification (>=0) */
-	int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
-	/** packet number of packet protection specification (>=0) */
-	int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
-	/** error protection methods for packets (0,1,16,32,37-128) */
-	int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
-	/** enables writing of ESD, (0=no/1/2 bytes) */
-	int jpwl_sens_size;
-	/** sensitivity addressing size (0=auto/2/4 bytes) */
-	int jpwl_sens_addr;
-	/** sensitivity range (0-3) */
-	int jpwl_sens_range;
-	/** sensitivity method for MH (-1=no,0-7) */
-	int jpwl_sens_MH;
-	/** tile number of sensitivity specification (>=0) */
-	int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-	/** sensitivity methods for TPHs (-1=no,0-7) */
-	int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
-	/*@}*/
-/* <<UniPG */
-
-	/** Digital Cinema compliance 0-not compliant, 1-compliant*/
-	OPJ_CINEMA_MODE cp_cinema;
-	/** Maximum rate for each component. If == 0, component size limitation is not considered */
-	int max_comp_size;
-	/** Profile name*/
-	OPJ_RSIZ_CAPABILITIES cp_rsiz;
-	/** Tile part generation*/
-	char tp_on;
-	/** Flag for Tile part generation*/
-	char tp_flag;
-	/** MCT (multiple component transform) */
-	char tcp_mct;
-} opj_cparameters_t;
-
-/**
-Decompression parameters
-*/
-typedef struct opj_dparameters {
-	/** 
-	Set the number of highest resolution levels to be discarded. 
-	The image resolution is effectively divided by 2 to the power of the number of discarded levels. 
-	The reduce factor is limited by the smallest total number of decomposition levels among tiles.
-	if != 0, then original dimension divided by 2^(reduce); 
-	if == 0 or not used, image is decoded to the full resolution 
-	*/
-	int cp_reduce;
-	/** 
-	Set the maximum number of quality layers to decode. 
-	If there are less quality layers than the specified number, all the quality layers are decoded.
-	if != 0, then only the first "layer" layers are decoded; 
-	if == 0 or not used, all the quality layers are decoded 
-	*/
-	int cp_layer;
-
-	/**@name command line encoder parameters (not used inside the library) */
-	/*@{*/
-	/** input file name */
-	char infile[OPJ_PATH_LEN];
-	/** output file name */
-	char outfile[OPJ_PATH_LEN];
-	/** input file format 0: J2K, 1: JP2, 2: JPT */
-	int decod_format;
-	/** output file format 0: PGX, 1: PxM, 2: BMP */
-	int cod_format;
-	/*@}*/
-
-/* UniPG>> */
-	/**@name JPWL decoding parameters */
-	/*@{*/
-	/** activates the JPWL correction capabilities */
-	bool jpwl_correct;
-	/** expected number of components */
-	int jpwl_exp_comps;
-	/** maximum number of tiles */
-	int jpwl_max_tiles;
-	/*@}*/
-/* <<UniPG */
-
-	/** 
-	Specify whether the decoding should be done on the entire codestream, or be limited to the main header
-	Limiting the decoding to the main header makes it possible to extract the characteristics of the codestream
-	if == NO_LIMITATION, the entire codestream is decoded; 
-	if == LIMIT_TO_MAIN_HEADER, only the main header is decoded; 
-	*/
-	OPJ_LIMIT_DECODING cp_limit_decoding;
-
-} opj_dparameters_t;
-
-/** Common fields between JPEG-2000 compression and decompression master structs. */
-
-#define opj_common_fields \
-	opj_event_mgr_t *event_mgr;	/**< pointer to the event manager */\
-	void * client_data;			/**< Available for use by application */\
-	bool is_decompressor;		/**< So common code can tell which is which */\
-	OPJ_CODEC_FORMAT codec_format;	/**< selected codec */\
-	void *j2k_handle;			/**< pointer to the J2K codec */\
-	void *jp2_handle;			/**< pointer to the JP2 codec */\
-	void *mj2_handle			/**< pointer to the MJ2 codec */
-	
-/* Routines that are to be used by both halves of the library are declared
- * to receive a pointer to this structure.  There are no actual instances of
- * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
- */
-typedef struct opj_common_struct {
-  opj_common_fields;		/* Fields common to both master struct types */
-  /* Additional fields follow in an actual opj_cinfo_t or
-   * opj_dinfo_t.  All three structs must agree on these
-   * initial fields!  (This would be a lot cleaner in C++.)
-   */
-} opj_common_struct_t;
-
-typedef opj_common_struct_t * opj_common_ptr;
-
-/**
-Compression context info
-*/
-typedef struct opj_cinfo {
-	/** Fields shared with opj_dinfo_t */
-	opj_common_fields;	
-	/* other specific fields go here */
-} opj_cinfo_t;
-
-/**
-Decompression context info
-*/
-typedef struct opj_dinfo {
-	/** Fields shared with opj_cinfo_t */
-	opj_common_fields;	
-	/* other specific fields go here */
-} opj_dinfo_t;
-
-/* 
-==========================================================
-   I/O stream typedef definitions
-==========================================================
-*/
-
-/*
- * Stream open flags.
- */
-/** The stream was opened for reading. */
-#define OPJ_STREAM_READ	0x0001
-/** The stream was opened for writing. */
-#define OPJ_STREAM_WRITE 0x0002
-
-/**
-Byte input-output stream (CIO)
-*/
-typedef struct opj_cio {
-	/** codec context */
-	opj_common_ptr cinfo;
-
-	/** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
-	int openmode;
-	/** pointer to the start of the buffer */
-	unsigned char *buffer;
-	/** buffer size in bytes */
-	int length;
-
-	/** pointer to the start of the stream */
-	unsigned char *start;
-	/** pointer to the end of the stream */
-	unsigned char *end;
-	/** pointer to the current position */
-	unsigned char *bp;
-} opj_cio_t;
-
-/* 
-==========================================================
-   image typedef definitions
-==========================================================
-*/
-
-/**
-Defines a single image component
-*/
-typedef struct opj_image_comp {
-	/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
-	int dx;
-	/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-	int dy;
-	/** data width */
-	int w;
-	/** data height */
-	int h;
-	/** x component offset compared to the whole image */
-	int x0;
-	/** y component offset compared to the whole image */
-	int y0;
-	/** precision */
-	int prec;
-	/** image depth in bits */
-	int bpp;
-	/** signed (1) / unsigned (0) */
-	int sgnd;
-	/** number of decoded resolution */
-	int resno_decoded;
-	/** number of division by 2 of the out image compared to the original size of image */
-	int factor;
-	/** image component data */
-	int *data;
-} opj_image_comp_t;
-
-/** 
-Defines image data and characteristics
-*/
-typedef struct opj_image {
-	/** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
-	int x0;
-	/** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
-	int y0;
-	/** Xsiz: width of the reference grid */
-	int x1;
-	/** Ysiz: height of the reference grid */
-	int y1;
-	/** number of components in the image */
-	int numcomps;
-	/** color space: sRGB, Greyscale or YUV */
-	OPJ_COLOR_SPACE color_space;
-	/** image components */
-	opj_image_comp_t *comps;
-	/** 'restricted' ICC profile */
-	unsigned char *icc_profile_buf;
-	/** size of ICC profile */
-	int icc_profile_len;
-} opj_image_t;
-
-/**
-Component parameters structure used by the opj_image_create function
-*/
-typedef struct opj_image_comptparm {
-	/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
-	int dx;
-	/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-	int dy;
-	/** data width */
-	int w;
-	/** data height */
-	int h;
-	/** x component offset compared to the whole image */
-	int x0;
-	/** y component offset compared to the whole image */
-	int y0;
-	/** precision */
-	int prec;
-	/** image depth in bits */
-	int bpp;
-	/** signed (1) / unsigned (0) */
-	int sgnd;
-} opj_image_cmptparm_t;
-
-/* 
-==========================================================
-   Information on the JPEG 2000 codestream
-==========================================================
-*/
-
-/**
-Index structure : Information concerning a packet inside tile
-*/
-typedef struct opj_packet_info {
-	/** packet start position (including SOP marker if it exists) */
-	int start_pos;
-	/** end of packet header position (including EPH marker if it exists)*/
-	int end_ph_pos;
-	/** packet end position */
-	int end_pos;
-	/** packet distorsion */
-	double disto;
-} opj_packet_info_t;
-
-/**
-Index structure : Information concerning tile-parts
-*/
-typedef struct opj_tp_info {
-	/** start position of tile part */
-	int tp_start_pos;
-	/** end position of tile part header */
-	int tp_end_header;
-	/** end position of tile part */
-	int tp_end_pos;
-	/** start packet of tile part */
-	int tp_start_pack;
-	/** number of packets of tile part */
-	int tp_numpacks;
-} opj_tp_info_t;
-
-/**
-Index structure : information regarding tiles 
-*/
-typedef struct opj_tile_info {
-	/** value of thresh for each layer by tile cfr. Marcela   */
-	double *thresh;
-	/** number of tile */
-	int tileno;
-	/** start position */
-	int start_pos;
-	/** end position of the header */
-	int end_header;
-	/** end position */
-	int end_pos;
-	/** precinct number for each resolution level (width) */
-	int pw[33];
-	/** precinct number for each resolution level (height) */
-	int ph[33];
-	/** precinct size (in power of 2), in X for each resolution level */
-	int pdx[33];
-	/** precinct size (in power of 2), in Y for each resolution level */
-	int pdy[33];
-	/** information concerning packets inside tile */
-	opj_packet_info_t *packet;
-	/** add fixed_quality */
-	int numpix;
-	/** add fixed_quality */
-	double distotile;
-	/** number of tile parts */
-	int num_tps;
-	/** information concerning tile parts */
-	opj_tp_info_t *tp;
-} opj_tile_info_t;
-
-/* UniPG>> */
-/**
-Marker structure
-*/
-typedef struct opj_marker_info_t {
-	/** marker type */
-	unsigned short int type;
-	/** position in codestream */
-	int pos;
-	/** length, marker val included */
-	int len;
-} opj_marker_info_t;
-/* <<UniPG */
-
-/**
-Index structure of the codestream
-*/
-typedef struct opj_codestream_info {
-	/** maximum distortion reduction on the whole image (add for Marcela) */
-	double D_max;
-	/** packet number */
-	int packno;
-	/** writing the packet in the index with t2_encode_packets */
-	int index_write;
-	/** image width */
-	int image_w;
-	/** image height */
-	int image_h;
-	/** progression order */
-	OPJ_PROG_ORDER prog;
-	/** tile size in x */
-	int tile_x;
-	/** tile size in y */
-	int tile_y;
-	/** */
-	int tile_Ox;
-	/** */
-	int tile_Oy;
-	/** number of tiles in X */
-	int tw;
-	/** number of tiles in Y */
-	int th;
-	/** component numbers */
-	int numcomps;
-	/** number of layer */
-	int numlayers;
-	/** number of decomposition for each component */
-	int *numdecompos;
-/* UniPG>> */
-	/** number of markers */
-	int marknum;
-	/** list of markers */
-	opj_marker_info_t *marker;
-	/** actual size of markers array */
-	int maxmarknum;
-/* <<UniPG */
-	/** main header position */
-	int main_head_start;
-	/** main header position */
-	int main_head_end;
-	/** codestream's size */
-	int codestream_size;
-	/** information regarding tiles inside image */
-	opj_tile_info_t *tile;
-} opj_codestream_info_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* 
-==========================================================
-   openjpeg version
-==========================================================
-*/
-
-OPJ_API const char * OPJ_CALLCONV opj_version(void);
-
-/* 
-==========================================================
-   image functions definitions
-==========================================================
-*/
-
-/**
-Create an image
- at param numcmpts number of components
- at param cmptparms components parameters
- at param clrspc image color space
- at return returns a new image structure if successful, returns NULL otherwise
-*/
-OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
-
-/**
-Deallocate any resources associated with an image
- at param image image to be destroyed
-*/
-OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
-
-/* 
-==========================================================
-   stream functions definitions
-==========================================================
-*/
-
-/**
-Open and allocate a memory stream for read / write. 
-On reading, the user must provide a buffer containing encoded data. The buffer will be 
-wrapped by the returned CIO handle. 
-On writing, buffer parameters must be set to 0: a buffer will be allocated by the library 
-to contain encoded data. 
- at param cinfo Codec context info
- at param buffer Reading: buffer address. Writing: NULL
- at param length Reading: buffer length. Writing: 0
- at return Returns a CIO handle if successful, returns NULL otherwise
-*/
-OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
-
-/**
-Close and free a CIO handle
- at param cio CIO handle to free
-*/
-OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
-
-/**
-Get position in byte stream
- at param cio CIO handle
- at return Returns the position in bytes
-*/
-OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
-/**
-Set position in byte stream
- at param cio CIO handle
- at param pos Position, in number of bytes, from the beginning of the stream
-*/
-OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
-
-/* 
-==========================================================
-   event manager functions definitions
-==========================================================
-*/
-
-OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
-
-/* 
-==========================================================
-   codec functions definitions
-==========================================================
-*/
-/**
-Creates a J2K/JPT/JP2 decompression structure
- at param format Decoder to select
- at return Returns a handle to a decompressor if successful, returns NULL otherwise
-*/
-OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
-/**
-Destroy a decompressor handle
- at param dinfo decompressor handle to destroy
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
-/**
-Set decoding parameters to default values
- at param parameters Decompression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in j2k->cp. 
- at param dinfo decompressor handle
- at param parameters decompression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
-/**
-Decode an image from a JPEG-2000 codestream 
- at param dinfo decompressor handle
- at param cio Input buffer stream
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
-
-/**
-Decode an image from a JPEG-2000 codestream and extract the codestream information
- at param dinfo decompressor handle
- at param cio Input buffer stream
- at param cstr_info Codestream information structure if needed afterwards, NULL otherwise
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-OPJ_API opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
-/**
-Creates a J2K/JP2 compression structure
- at param format Coder to select
- at return Returns a handle to a compressor if successful, returns NULL otherwise
-*/
-OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
-/**
-Destroy a compressor handle
- at param cinfo compressor handle to destroy
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
-/**
-Set encoding parameters to default values, that means : 
-<ul>
-<li>Lossless
-<li>1 tile
-<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
-<li>Size of code-block : 64 x 64
-<li>Number of resolutions: 6
-<li>No SOP marker in the codestream
-<li>No EPH marker in the codestream
-<li>No sub-sampling in x or y direction
-<li>No mode switch activated
-<li>Progression order: LRCP
-<li>No index file
-<li>No ROI upshifted
-<li>No offset of the origin of the image
-<li>No offset of the origin of the tiles
-<li>Reversible DWT 5-3
-</ul>
- at param parameters Compression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
-/**
-Setup the encoder parameters using the current image and using user parameters. 
- at param cinfo Compressor handle
- at param parameters Compression parameters
- at param image Input filled image
-*/
-OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
-/**
-Encode an image into a JPEG-2000 codestream
- at param cinfo compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
- at return Returns true if successful, returns false otherwise
-*/
-OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
-/**
-Encode an image into a JPEG-2000 codestream and extract the codestream information
- at param cinfo compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param cstr_info Codestream information structure if needed afterwards, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
-/**
-Destroy Codestream information after compression or decompression
- at param cstr_info Codestream information structure
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPENJPEG_H */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/opj_includes.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/opj_includes.h
deleted file mode 100644
index 53739ab..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/opj_includes.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_INCLUDES_H
-#define OPJ_INCLUDES_H
-
-/*
- ==========================================================
-   Standard includes used by the library
- ==========================================================
-*/
-#include <memory.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <float.h>
-#include <time.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-
-/*
- ==========================================================
-   OpenJPEG interface
- ==========================================================
- */
-#include "openjpeg.h"
-
-/*
- ==========================================================
-   OpenJPEG modules
- ==========================================================
-*/
-
-/* Ignore GCC attributes if this is not GCC */
-#ifndef __GNUC__
-	#define __attribute__(x) /* __attribute__(x) */
-#endif
-
-/*
-The inline keyword is supported by C99 but not by C90. 
-Most compilers implement their own version of this keyword ... 
-*/
-#ifndef INLINE
-	#if defined(_MSC_VER)
-		#define INLINE __forceinline
-	#elif defined(__GNUC__)
-		#define INLINE __inline__
-	#elif defined(__MWERKS__)
-		#define INLINE inline
-	#else 
-		/* add other compilers here ... */
-		#define INLINE 
-	#endif /* defined(<Compiler>) */
-#endif /* INLINE */
-
-/* Are restricted pointers available? (C99) */
-#if (__STDC_VERSION__ != 199901L)
-	/* Not a C99 compiler */
-	#ifdef __GNUC__
-		#define restrict __restrict__
-	#else
-		#define restrict /* restrict */
-	#endif
-#endif
-
-/* MSVC and Borland C do not have lrintf */
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-static INLINE long lrintf(float f){
-#ifdef _M_X64
-    return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
-#else
-    int i;
- 
-    _asm{
-        fld f
-        fistp i
-    };
- 
-    return i;
-#endif
-}
-#endif
-
-#include "j2k_lib.h"
-#include "opj_malloc.h"
-#include "event.h"
-#include "cio.h"
-
-#include "image.h"
-#include "j2k.h"
-#include "jp2.h"
-#include "jpt.h"
-
-#include "mqc.h"
-#include "raw.h"
-#include "bio.h"
-#include "tgt.h"
-#include "pi.h"
-#include "tcd.h"
-#include "t1.h"
-#include "dwt.h"
-#include "t2.h"
-#include "mct.h"
-#include "int.h"
-#include "fix.h"
-
-/* JPWL>> */
-#ifdef USE_JPWL
-#include "../jpwl/jpwl.h"
-#endif /* USE_JPWL */
-/* <<JPWL */
-
-#endif /* OPJ_INCLUDES_H */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/opj_malloc.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/opj_malloc.h
deleted file mode 100644
index 64908f3..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/opj_malloc.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __OPJ_MALLOC_H
-#define __OPJ_MALLOC_H
-/**
- at file opj_malloc.h
- at brief Internal functions
-
-The functions in opj_malloc.h are internal utilities used for memory management.
-*/
-
-/** @defgroup MISC MISC - Miscellaneous internal functions */
-/*@{*/
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Allocate an uninitialized memory block
- at param size Bytes to allocate
- at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-#ifdef ALLOC_PERF_OPT
-void * OPJ_CALLCONV opj_malloc(size_t size);
-#else
-#define opj_malloc(size) malloc(size)
-#endif
-
-/**
-Allocate a memory block with elements initialized to 0
- at param num Blocks to allocate
- at param size Bytes per block to allocate
- at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-#ifdef ALLOC_PERF_OPT
-void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
-#else
-#define opj_calloc(num, size) calloc(num, size)
-#endif
-
-/**
-Allocate memory aligned to a 16 byte boundry
- at param size Bytes to allocate
- at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
-#ifdef _WIN32
-	/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
-	#ifdef __GNUC__
-		#include <mm_malloc.h>
-		#define HAVE_MM_MALLOC
-	#else /* MSVC, Intel C++ */
-		#include <malloc.h>
-		#ifdef _mm_malloc
-			#define HAVE_MM_MALLOC
-		#endif
-	#endif
-#else /* Not _WIN32 */
-	#if defined(__sun)
-		#define HAVE_MEMALIGN
-	/* Linux x86_64 and OSX always align allocations to 16 bytes */
-	#elif !defined(__amd64__) && !defined(__APPLE__)	
-		#define HAVE_MEMALIGN
-		#include <malloc.h>			
-	#endif
-#endif
-
-#define opj_aligned_malloc(size) malloc(size)
-#define opj_aligned_free(m) free(m)
-
-#ifdef HAVE_MM_MALLOC
-	#undef opj_aligned_malloc
-	#define opj_aligned_malloc(size) _mm_malloc(size, 16)
-	#undef opj_aligned_free
-	#define opj_aligned_free(m) _mm_free(m)
-#endif
-
-#ifdef HAVE_MEMALIGN
-	extern void* memalign(size_t, size_t);
-	#undef opj_aligned_malloc
-	#define opj_aligned_malloc(size) memalign(16, (size))
-	#undef opj_aligned_free
-	#define opj_aligned_free(m) free(m)
-#endif
-
-#ifdef HAVE_POSIX_MEMALIGN
-	#undef opj_aligned_malloc
-	extern int posix_memalign(void**, size_t, size_t);
-
-	static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
-		void* mem = NULL;
-		posix_memalign(&mem, 16, size);
-		return mem;
-	}
-	#undef opj_aligned_free
-	#define opj_aligned_free(m) free(m)
-#endif
-
-#ifdef ALLOC_PERF_OPT
-	#undef opj_aligned_malloc
-	#define opj_aligned_malloc(size) opj_malloc(size)
-	#undef opj_aligned_free
-	#define opj_aligned_free(m) opj_free(m)
-#endif
-
-/**
-Reallocate memory blocks.
- at param m Pointer to previously allocated memory block
- at param s New size in bytes
- at return Returns a void pointer to the reallocated (and possibly moved) memory block
-*/
-#ifdef ALLOC_PERF_OPT
-void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
-#else
-#define opj_realloc(m, s) realloc(m, s)
-#endif
-
-/**
-Deallocates or frees a memory block.
- at param m Previously allocated memory block to be freed
-*/
-#ifdef ALLOC_PERF_OPT
-void OPJ_CALLCONV opj_free(void * m);
-#else
-#define opj_free(m) free(m)
-#endif
-
-#ifdef __GNUC__
-#pragma GCC poison malloc calloc realloc free
-#endif
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __OPJ_MALLOC_H */
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.c
deleted file mode 100644
index 06e76af..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup PI PI - Implementation of a packet iterator */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Get next packet in layer-resolution-component-precinct order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_lrcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-layer-component-precinct order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_rlcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-precinct-component-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_rpcl(opj_pi_iterator_t * pi);
-/**
-Get next packet in precinct-component-resolution-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_pcrl(opj_pi_iterator_t * pi);
-/**
-Get next packet in component-precinct-resolution-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true 
-*/
-static bool pi_next_cprl(opj_pi_iterator_t * pi);
-
-/*@}*/
-
-/*@}*/
-
-/* 
-==========================================================
-   local functions
-==========================================================
-*/
-
-static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-	
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		res = &comp->resolutions[pi->resno];
-		goto LABEL_SKIP;
-	} else {
-		pi->first = 0;
-	}
-
-	for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-		for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
-		pi->resno++) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				if (pi->resno >= comp->numresolutions) {
-					continue;
-				}
-				res = &comp->resolutions[pi->resno];
-				if (!pi->tp_on){
-					pi->poc.precno1 = res->pw * res->ph;
-				}
-				for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
-					index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-					if (!pi->include[index]) {
-						pi->include[index] = 1;
-						return true;
-					}
-LABEL_SKIP:;
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		res = &comp->resolutions[pi->resno];
-		goto LABEL_SKIP;
-	} else {
-		pi->first = 0;
-	}
-
-	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-		for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				if (pi->resno >= comp->numresolutions) {
-					continue;
-				}
-				res = &comp->resolutions[pi->resno];
-				if(!pi->tp_on){
-					pi->poc.precno1 = res->pw * res->ph;
-				}
-				for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
-					index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-					if (!pi->include[index]) {
-						pi->include[index] = 1;
-						return true;
-					}
-LABEL_SKIP:;
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		goto LABEL_SKIP;
-	} else {
-		int compno, resno;
-		pi->first = 0;
-		pi->dx = 0;
-		pi->dy = 0;
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			comp = &pi->comps[compno];
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int dx, dy;
-				res = &comp->resolutions[resno];
-				dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-				dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-				pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-				pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-			}
-		}
-	}
-if (!pi->tp_on){
-			pi->poc.ty0 = pi->ty0;
-			pi->poc.tx0 = pi->tx0;
-			pi->poc.ty1 = pi->ty1;
-			pi->poc.tx1 = pi->tx1;
-		}
-	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-		for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-			for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-				for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-					int levelno;
-					int trx0, try0;
-					int trx1, try1;
-					int rpx, rpy;
-					int prci, prcj;
-					comp = &pi->comps[pi->compno];
-					if (pi->resno >= comp->numresolutions) {
-						continue;
-					}
-					res = &comp->resolutions[pi->resno];
-					levelno = comp->numresolutions - 1 - pi->resno;
-					trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-					try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-					trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
-					try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
-					rpx = res->pdx + levelno;
-					rpy = res->pdy + levelno;
-					if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
-						continue;	
-					}
-					if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
-						continue; 
-					}
-					
-					if ((res->pw==0)||(res->ph==0)) continue;
-					
-					if ((trx0==trx1)||(try0==try1)) continue;
-					
-					prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx) 
-						 - int_floordivpow2(trx0, res->pdx);
-					prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy) 
-						 - int_floordivpow2(try0, res->pdy);
-					pi->precno = prci + prcj * res->pw;
-					for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-						index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-						if (!pi->include[index]) {
-							pi->include[index] = 1;
-							return true;
-						}
-LABEL_SKIP:;
-					}
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		goto LABEL_SKIP;
-	} else {
-		int compno, resno;
-		pi->first = 0;
-		pi->dx = 0;
-		pi->dy = 0;
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			comp = &pi->comps[compno];
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int dx, dy;
-				res = &comp->resolutions[resno];
-				dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-				dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-				pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-				pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-			}
-		}
-	}
-	if (!pi->tp_on){
-			pi->poc.ty0 = pi->ty0;
-			pi->poc.tx0 = pi->tx0;
-			pi->poc.ty1 = pi->ty1;
-			pi->poc.tx1 = pi->tx1;
-		}
-	for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-		for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-				comp = &pi->comps[pi->compno];
-				for (pi->resno = pi->poc.resno0; pi->resno < int_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
-					int levelno;
-					int trx0, try0;
-					int trx1, try1;
-					int rpx, rpy;
-					int prci, prcj;
-					res = &comp->resolutions[pi->resno];
-					levelno = comp->numresolutions - 1 - pi->resno;
-					trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-					try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-					trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
-					try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
-					rpx = res->pdx + levelno;
-					rpy = res->pdy + levelno;
-					if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
-						continue;	
-					}
-					if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
-						continue; 
-					}
-					
-					if ((res->pw==0)||(res->ph==0)) continue;
-					
-					if ((trx0==trx1)||(try0==try1)) continue;
-					
-					prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx) 
-						 - int_floordivpow2(trx0, res->pdx);
-					prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy) 
-						 - int_floordivpow2(try0, res->pdy);
-					pi->precno = prci + prcj * res->pw;
-					for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-						index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-						if (!pi->include[index]) {
-							pi->include[index] = 1;
-							return true;
-						}	
-LABEL_SKIP:;
-					}
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-static bool pi_next_cprl(opj_pi_iterator_t * pi) {
-	opj_pi_comp_t *comp = NULL;
-	opj_pi_resolution_t *res = NULL;
-	long index = 0;
-
-	if (!pi->first) {
-		comp = &pi->comps[pi->compno];
-		goto LABEL_SKIP;
-	} else {
-		pi->first = 0;
-	}
-
-	for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-		int resno;
-		comp = &pi->comps[pi->compno];
-		pi->dx = 0;
-		pi->dy = 0;
-		for (resno = 0; resno < comp->numresolutions; resno++) {
-			int dx, dy;
-			res = &comp->resolutions[resno];
-			dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-			dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-			pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-			pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-		}
-		if (!pi->tp_on){
-			pi->poc.ty0 = pi->ty0;
-			pi->poc.tx0 = pi->tx0;
-			pi->poc.ty1 = pi->ty1;
-			pi->poc.tx1 = pi->tx1;
-		}
-		for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-			for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-				for (pi->resno = pi->poc.resno0; pi->resno < int_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
-					int levelno;
-					int trx0, try0;
-					int trx1, try1;
-					int rpx, rpy;
-					int prci, prcj;
-					res = &comp->resolutions[pi->resno];
-					levelno = comp->numresolutions - 1 - pi->resno;
-					trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-					try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-					trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
-					try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
-					rpx = res->pdx + levelno;
-					rpy = res->pdy + levelno;
-					if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
-						continue;	
-					}
-					if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
-						continue; 
-					}
-					
-					if ((res->pw==0)||(res->ph==0)) continue;
-					
-					if ((trx0==trx1)||(try0==try1)) continue;
-					
-					prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx) 
-						 - int_floordivpow2(trx0, res->pdx);
-					prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy) 
-						 - int_floordivpow2(try0, res->pdy);
-					pi->precno = prci + prcj * res->pw;
-					for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-						index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-						if (!pi->include[index]) {
-							pi->include[index] = 1;
-							return true;
-						}
-LABEL_SKIP:;
-					}
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
-/* 
-==========================================================
-   Packet iterator interface
-==========================================================
-*/
-
-opj_pi_iterator_t *pi_create_decode(opj_image_t *image, opj_cp_t *cp, int tileno) {
-	int p, q;
-	int compno, resno, pino;
-	opj_pi_iterator_t *pi = NULL;
-	opj_tcp_t *tcp = NULL;
-	opj_tccp_t *tccp = NULL;
-
-	tcp = &cp->tcps[tileno];
-
-	pi = (opj_pi_iterator_t*) opj_calloc((tcp->numpocs + 1), sizeof(opj_pi_iterator_t));
-	if(!pi) {
-		/* TODO: throw an error */
-		return NULL;
-	}
-
-	for (pino = 0; pino < tcp->numpocs + 1; pino++) {	/* change */
-		int maxres = 0;
-		int maxprec = 0;
-		p = tileno % cp->tw;
-		q = tileno / cp->tw;
-
-		pi[pino].tx0 = int_max(cp->tx0 + p * cp->tdx, image->x0);
-		pi[pino].ty0 = int_max(cp->ty0 + q * cp->tdy, image->y0);
-		pi[pino].tx1 = int_min(cp->tx0 + (p + 1) * cp->tdx, image->x1);
-		pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
-		pi[pino].numcomps = image->numcomps;
-
-		pi[pino].comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
-		if(!pi[pino].comps) {
-			/* TODO: throw an error */
-			pi_destroy(pi, cp, tileno);
-			return NULL;
-		}
-		
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			int tcx0, tcy0, tcx1, tcy1;
-			opj_pi_comp_t *comp = &pi[pino].comps[compno];
-			tccp = &tcp->tccps[compno];
-			comp->dx = image->comps[compno].dx;
-			comp->dy = image->comps[compno].dy;
-			comp->numresolutions = tccp->numresolutions;
-
-			comp->resolutions = (opj_pi_resolution_t*) opj_calloc(comp->numresolutions, sizeof(opj_pi_resolution_t));
-			if(!comp->resolutions) {
-				/* TODO: throw an error */
-				pi_destroy(pi, cp, tileno);
-				return NULL;
-			}
-
-			tcx0 = int_ceildiv(pi->tx0, comp->dx);
-			tcy0 = int_ceildiv(pi->ty0, comp->dy);
-			tcx1 = int_ceildiv(pi->tx1, comp->dx);
-			tcy1 = int_ceildiv(pi->ty1, comp->dy);
-			if (comp->numresolutions > maxres) {
-				maxres = comp->numresolutions;
-			}
-
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int levelno;
-				int rx0, ry0, rx1, ry1;
-				int px0, py0, px1, py1;
-				opj_pi_resolution_t *res = &comp->resolutions[resno];
-				if (tccp->csty & J2K_CCP_CSTY_PRT) {
-					res->pdx = tccp->prcw[resno];
-					res->pdy = tccp->prch[resno];
-				} else {
-					res->pdx = 15;
-					res->pdy = 15;
-				}
-				levelno = comp->numresolutions - 1 - resno;
-				rx0 = int_ceildivpow2(tcx0, levelno);
-				ry0 = int_ceildivpow2(tcy0, levelno);
-				rx1 = int_ceildivpow2(tcx1, levelno);
-				ry1 = int_ceildivpow2(tcy1, levelno);
-				px0 = int_floordivpow2(rx0, res->pdx) << res->pdx;
-				py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
-				px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
-				py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
-				res->pw = (rx0==rx1)?0:((px1 - px0) >> res->pdx);
-				res->ph = (ry0==ry1)?0:((py1 - py0) >> res->pdy);
-				
-				if (res->pw*res->ph > maxprec) {
-					maxprec = res->pw*res->ph;
-				}
-				
-			}
-		}
-		
-		tccp = &tcp->tccps[0];
-		pi[pino].step_p = 1;
-		pi[pino].step_c = maxprec * pi[pino].step_p;
-		pi[pino].step_r = image->numcomps * pi[pino].step_c;
-		pi[pino].step_l = maxres * pi[pino].step_r;
-		
-		if (pino == 0) {
-			pi[pino].include = (short int*) opj_calloc(image->numcomps * maxres * tcp->numlayers * maxprec, sizeof(short int));
-			if(!pi[pino].include) {
-				/* TODO: throw an error */
-				pi_destroy(pi, cp, tileno);
-				return NULL;
-			}
-		}
-		else {
-			pi[pino].include = pi[pino - 1].include;
-		}
-		
-		if (tcp->POC == 0) {
-			pi[pino].first = 1;
-			pi[pino].poc.resno0 = 0;
-			pi[pino].poc.compno0 = 0;
-			pi[pino].poc.layno1 = tcp->numlayers;
-			pi[pino].poc.resno1 = maxres;
-			pi[pino].poc.compno1 = image->numcomps;
-			pi[pino].poc.prg = tcp->prg;
-		} else {
-			pi[pino].first = 1;
-			pi[pino].poc.resno0 = tcp->pocs[pino].resno0;
-			pi[pino].poc.compno0 = tcp->pocs[pino].compno0;
-			pi[pino].poc.layno1 = tcp->pocs[pino].layno1;
-			pi[pino].poc.resno1 = tcp->pocs[pino].resno1;
-			pi[pino].poc.compno1 = tcp->pocs[pino].compno1;
-			pi[pino].poc.prg = tcp->pocs[pino].prg;
-		}
-		pi[pino].poc.layno0  = 0;
-		pi[pino].poc.precno0 = 0; 
-		pi[pino].poc.precno1 = maxprec;
-			
-	}
-	
-	return pi;
-}
-
-
-opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int tileno, J2K_T2_MODE t2_mode){ 
-	int p, q, pino;
-	int compno, resno;
-	int maxres = 0;
-	int maxprec = 0;
-	opj_pi_iterator_t *pi = NULL;
-	opj_tcp_t *tcp = NULL;
-	opj_tccp_t *tccp = NULL;
-	
-	tcp = &cp->tcps[tileno];
-
-	pi = (opj_pi_iterator_t*) opj_calloc((tcp->numpocs + 1), sizeof(opj_pi_iterator_t));
-	if(!pi) {	return NULL;}
-	pi->tp_on = cp->tp_on;
-
-	for(pino = 0;pino < tcp->numpocs+1 ; pino ++){
-		p = tileno % cp->tw;
-		q = tileno / cp->tw;
-
-		pi[pino].tx0 = int_max(cp->tx0 + p * cp->tdx, image->x0);
-		pi[pino].ty0 = int_max(cp->ty0 + q * cp->tdy, image->y0);
-		pi[pino].tx1 = int_min(cp->tx0 + (p + 1) * cp->tdx, image->x1);
-		pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
-		pi[pino].numcomps = image->numcomps;
-		
-		pi[pino].comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
-		if(!pi[pino].comps) {
-			pi_destroy(pi, cp, tileno);
-			return NULL;
-		}
-		
-		for (compno = 0; compno < pi[pino].numcomps; compno++) {
-			int tcx0, tcy0, tcx1, tcy1;
-			opj_pi_comp_t *comp = &pi[pino].comps[compno];
-			tccp = &tcp->tccps[compno];
-			comp->dx = image->comps[compno].dx;
-			comp->dy = image->comps[compno].dy;
-			comp->numresolutions = tccp->numresolutions;
-
-			comp->resolutions = (opj_pi_resolution_t*) opj_malloc(comp->numresolutions * sizeof(opj_pi_resolution_t));
-			if(!comp->resolutions) {
-				pi_destroy(pi, cp, tileno);
-				return NULL;
-			}
-
-			tcx0 = int_ceildiv(pi[pino].tx0, comp->dx);
-			tcy0 = int_ceildiv(pi[pino].ty0, comp->dy);
-			tcx1 = int_ceildiv(pi[pino].tx1, comp->dx);
-			tcy1 = int_ceildiv(pi[pino].ty1, comp->dy);
-			if (comp->numresolutions > maxres) {
-				maxres = comp->numresolutions;
-			}
-
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int levelno;
-				int rx0, ry0, rx1, ry1;
-				int px0, py0, px1, py1;
-				opj_pi_resolution_t *res = &comp->resolutions[resno];
-				if (tccp->csty & J2K_CCP_CSTY_PRT) {
-					res->pdx = tccp->prcw[resno];
-					res->pdy = tccp->prch[resno];
-				} else {
-					res->pdx = 15;
-					res->pdy = 15;
-				}
-				levelno = comp->numresolutions - 1 - resno;
-				rx0 = int_ceildivpow2(tcx0, levelno);
-				ry0 = int_ceildivpow2(tcy0, levelno);
-				rx1 = int_ceildivpow2(tcx1, levelno);
-				ry1 = int_ceildivpow2(tcy1, levelno);
-				px0 = int_floordivpow2(rx0, res->pdx) << res->pdx;
-				py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
-				px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
-				py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
-				res->pw = (rx0==rx1)?0:((px1 - px0) >> res->pdx);
-				res->ph = (ry0==ry1)?0:((py1 - py0) >> res->pdy);
-
-				if (res->pw*res->ph > maxprec) {
-					maxprec = res->pw * res->ph;
-				}
-			}
-		}
-		
-		tccp = &tcp->tccps[0];
-		pi[pino].step_p = 1;
-		pi[pino].step_c = maxprec * pi[pino].step_p;
-		pi[pino].step_r = image->numcomps * pi[pino].step_c;
-		pi[pino].step_l = maxres * pi[pino].step_r;
-		
-		for (compno = 0; compno < pi->numcomps; compno++) {
-			opj_pi_comp_t *comp = &pi->comps[compno];
-			for (resno = 0; resno < comp->numresolutions; resno++) {
-				int dx, dy;
-				opj_pi_resolution_t *res = &comp->resolutions[resno];
-				dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-				dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-				pi[pino].dx = !pi->dx ? dx : int_min(pi->dx, dx);
-				pi[pino].dy = !pi->dy ? dy : int_min(pi->dy, dy);
-			}
-		}
-
-		if (pino == 0) {
-			pi[pino].include = (short int*) opj_calloc(tcp->numlayers * pi[pino].step_l, sizeof(short int));
-			if(!pi[pino].include) {
-				pi_destroy(pi, cp, tileno);
-				return NULL;
-			}
-		}
-		else {
-			pi[pino].include = pi[pino - 1].include;
-		}
-		
-		/* Generation of boundaries for each prog flag*/
-			if(tcp->POC && ( cp->cinema || ((!cp->cinema) && (t2_mode == FINAL_PASS)))){
-				tcp->pocs[pino].compS= tcp->pocs[pino].compno0;
-				tcp->pocs[pino].compE= tcp->pocs[pino].compno1;
-				tcp->pocs[pino].resS = tcp->pocs[pino].resno0;
-				tcp->pocs[pino].resE = tcp->pocs[pino].resno1;
-				tcp->pocs[pino].layE = tcp->pocs[pino].layno1;
-				tcp->pocs[pino].prg  = tcp->pocs[pino].prg1;
-				if (pino > 0)
-					tcp->pocs[pino].layS = (tcp->pocs[pino].layE > tcp->pocs[pino - 1].layE) ? tcp->pocs[pino - 1].layE : 0;
-			}else {
-				tcp->pocs[pino].compS= 0;
-				tcp->pocs[pino].compE= image->numcomps;
-				tcp->pocs[pino].resS = 0;
-				tcp->pocs[pino].resE = maxres;
-				tcp->pocs[pino].layS = 0;
-				tcp->pocs[pino].layE = tcp->numlayers;
-				tcp->pocs[pino].prg  = tcp->prg;
-			}
-			tcp->pocs[pino].prcS = 0;
-			tcp->pocs[pino].prcE = maxprec;;
-			tcp->pocs[pino].txS = pi[pino].tx0;
-			tcp->pocs[pino].txE = pi[pino].tx1;
-			tcp->pocs[pino].tyS = pi[pino].ty0;
-			tcp->pocs[pino].tyE = pi[pino].ty1;
-			tcp->pocs[pino].dx = pi[pino].dx;
-			tcp->pocs[pino].dy = pi[pino].dy;
-		}
-			return pi;
-	}
-
-
-
-void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) {
-	int compno, pino;
-	opj_tcp_t *tcp = &cp->tcps[tileno];
-	if(pi) {
-		for (pino = 0; pino < tcp->numpocs + 1; pino++) {	
-			if(pi[pino].comps) {
-				for (compno = 0; compno < pi->numcomps; compno++) {
-					opj_pi_comp_t *comp = &pi[pino].comps[compno];
-					if(comp->resolutions) {
-						opj_free(comp->resolutions);
-					}
-				}
-				opj_free(pi[pino].comps);
-			}
-		}
-		if(pi->include) {
-			opj_free(pi->include);
-		}
-		opj_free(pi);
-	}
-}
-
-bool pi_next(opj_pi_iterator_t * pi) {
-	switch (pi->poc.prg) {
-		case LRCP:
-			return pi_next_lrcp(pi);
-		case RLCP:
-			return pi_next_rlcp(pi);
-		case RPCL:
-			return pi_next_rpcl(pi);
-		case PCRL:
-			return pi_next_pcrl(pi);
-		case CPRL:
-			return pi_next_cprl(pi);
-		case PROG_UNKNOWN:
-			return false;
-	}
-	
-	return false;
-}
-
-bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
-	char prog[4];
-	int i;
-	int incr_top=1,resetX=0;
-	opj_tcp_t *tcps =&cp->tcps[tileno];
-	opj_poc_t *tcp= &tcps->pocs[pino];
-
-	pi[pino].first = 1;
-	pi[pino].poc.prg = tcp->prg;
-
-	switch(tcp->prg){
-		case CPRL: strncpy(prog, "CPRL",4);
-			break;
-		case LRCP: strncpy(prog, "LRCP",4);
-			break;
-		case PCRL: strncpy(prog, "PCRL",4);
-			break;
-		case RLCP: strncpy(prog, "RLCP",4);
-			break;
-		case RPCL: strncpy(prog, "RPCL",4);
-			break;
-		case PROG_UNKNOWN: 
-			return true;
-	}
-
-	if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
-		pi[pino].poc.resno0 = tcp->resS;
-		pi[pino].poc.resno1 = tcp->resE;
-		pi[pino].poc.compno0 = tcp->compS;
-		pi[pino].poc.compno1 = tcp->compE;
-		pi[pino].poc.layno0 = tcp->layS;
-		pi[pino].poc.layno1 = tcp->layE;
-		pi[pino].poc.precno0 = tcp->prcS;
-		pi[pino].poc.precno1 = tcp->prcE;
-		pi[pino].poc.tx0 = tcp->txS;
-		pi[pino].poc.ty0 = tcp->tyS;
-		pi[pino].poc.tx1 = tcp->txE;
-		pi[pino].poc.ty1 = tcp->tyE;
-	}else {
-		if( tpnum < cur_totnum_tp){
-			for(i=3;i>=0;i--){
-				switch(prog[i]){
-				case 'C':
-					if (i > tppos){
-						pi[pino].poc.compno0 = tcp->compS;
-						pi[pino].poc.compno1 = tcp->compE;
-					}else{
-						if (tpnum == 0){
-							tcp->comp_t = tcp->compS;
-							pi[pino].poc.compno0 = tcp->comp_t;
-							pi[pino].poc.compno1 = tcp->comp_t+1;
-							tcp->comp_t+=1;
-						}else{
-							if (incr_top == 1){
-								if(tcp->comp_t ==tcp->compE){
-									tcp->comp_t = tcp->compS;
-									pi[pino].poc.compno0 = tcp->comp_t;
-									pi[pino].poc.compno1 = tcp->comp_t+1;
-									tcp->comp_t+=1;
-									incr_top=1;
-								}else{
-									pi[pino].poc.compno0 = tcp->comp_t;
-									pi[pino].poc.compno1 = tcp->comp_t+1;
-									tcp->comp_t+=1;
-									incr_top=0;
-								}
-							}else{
-								pi[pino].poc.compno0 = tcp->comp_t-1;
-								pi[pino].poc.compno1 = tcp->comp_t;
-							}
-						}
-					}
-					break;
-
-				case 'R':
-					if (i > tppos){
-						pi[pino].poc.resno0 = tcp->resS;
-						pi[pino].poc.resno1 = tcp->resE;
-					}else{
-						if (tpnum == 0){
-							tcp->res_t = tcp->resS;
-							pi[pino].poc.resno0 = tcp->res_t;
-							pi[pino].poc.resno1 = tcp->res_t+1;
-							tcp->res_t+=1;
-						}else{
-							if (incr_top == 1){
-								if(tcp->res_t==tcp->resE){
-									tcp->res_t = tcp->resS;
-									pi[pino].poc.resno0 = tcp->res_t;
-									pi[pino].poc.resno1 = tcp->res_t+1;
-									tcp->res_t+=1;
-									incr_top=1;
-								}else{
-									pi[pino].poc.resno0 = tcp->res_t;
-									pi[pino].poc.resno1 = tcp->res_t+1;
-									tcp->res_t+=1;
-									incr_top=0;
-								}
-							}else{
-								pi[pino].poc.resno0 = tcp->res_t - 1;
-								pi[pino].poc.resno1 = tcp->res_t;
-							}
-						}
-					}
-					break;
-
-				case 'L':
-					if (i > tppos){
-						pi[pino].poc.layno0 = tcp->layS;
-						pi[pino].poc.layno1 = tcp->layE;
-					}else{
-						if (tpnum == 0){
-							tcp->lay_t = tcp->layS;
-							pi[pino].poc.layno0 = tcp->lay_t;
-							pi[pino].poc.layno1 = tcp->lay_t+1;
-							tcp->lay_t+=1;
-						}else{
-							if (incr_top == 1){
-								if(tcp->lay_t == tcp->layE){
-									tcp->lay_t = tcp->layS;
-									pi[pino].poc.layno0 = tcp->lay_t;
-									pi[pino].poc.layno1 = tcp->lay_t+1;
-									tcp->lay_t+=1;
-									incr_top=1;
-								}else{
-									pi[pino].poc.layno0 = tcp->lay_t;
-									pi[pino].poc.layno1 = tcp->lay_t+1;
-									tcp->lay_t+=1;
-									incr_top=0;
-								}
-							}else{
-								pi[pino].poc.layno0 = tcp->lay_t - 1;
-								pi[pino].poc.layno1 = tcp->lay_t;
-							}
-						}
-					}
-					break;
-
-				case 'P':
-					switch(tcp->prg){
-						case LRCP:
-						case RLCP:
-							if (i > tppos){
-								pi[pino].poc.precno0 = tcp->prcS;
-								pi[pino].poc.precno1 = tcp->prcE;
-							}else{
-								if (tpnum == 0){
-									tcp->prc_t = tcp->prcS;
-									pi[pino].poc.precno0 = tcp->prc_t;
-									pi[pino].poc.precno1 = tcp->prc_t+1;
-									tcp->prc_t+=1; 
-								}else{
-									if (incr_top == 1){
-										if(tcp->prc_t == tcp->prcE){
-											tcp->prc_t = tcp->prcS;
-											pi[pino].poc.precno0 = tcp->prc_t;
-											pi[pino].poc.precno1 = tcp->prc_t+1;
-											tcp->prc_t+=1;
-											incr_top=1;
-										}else{
-											pi[pino].poc.precno0 = tcp->prc_t;
-											pi[pino].poc.precno1 = tcp->prc_t+1;
-											tcp->prc_t+=1;
-											incr_top=0;
-										}
-									}else{
-										pi[pino].poc.precno0 = tcp->prc_t - 1;
-										pi[pino].poc.precno1 = tcp->prc_t;
-									}
-								}
-							}
-						break;
-						default:
-							if (i > tppos){
-								pi[pino].poc.tx0 = tcp->txS;
-								pi[pino].poc.ty0 = tcp->tyS;
-								pi[pino].poc.tx1 = tcp->txE;
-								pi[pino].poc.ty1 = tcp->tyE;
-							}else{
-								if (tpnum == 0){
-									tcp->tx0_t = tcp->txS;
-									tcp->ty0_t = tcp->tyS;
-									pi[pino].poc.tx0 = tcp->tx0_t;
-									pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx);
-									pi[pino].poc.ty0 = tcp->ty0_t;
-									pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-									tcp->tx0_t = pi[pino].poc.tx1;
-									tcp->ty0_t = pi[pino].poc.ty1;
-								}else{
-									if (incr_top == 1){
-										if(tcp->tx0_t >= tcp->txE){
-											if(tcp->ty0_t >= tcp->tyE){
-												tcp->ty0_t = tcp->tyS;
-												pi[pino].poc.ty0 = tcp->ty0_t;
-												pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-												tcp->ty0_t = pi[pino].poc.ty1;
-												incr_top=1;resetX=1;
-											}else{
-												pi[pino].poc.ty0 = tcp->ty0_t;
-												pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-												tcp->ty0_t = pi[pino].poc.ty1;
-												incr_top=0;resetX=1;
-											}
-											if(resetX==1){
-												tcp->tx0_t = tcp->txS;
-												pi[pino].poc.tx0 = tcp->tx0_t;
-												pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx);
-												tcp->tx0_t = pi[pino].poc.tx1;
-											}
-										}else{
-											pi[pino].poc.tx0 = tcp->tx0_t;
-											pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx);
-											tcp->tx0_t = pi[pino].poc.tx1;
-											pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
-											pi[pino].poc.ty1 = tcp->ty0_t ;
-											incr_top=0;
-										}
-									}else{
-										pi[pino].poc.tx0 = tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx);
-										pi[pino].poc.tx1 = tcp->tx0_t ;
-										pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
-										pi[pino].poc.ty1 = tcp->ty0_t ;
-									}
-								}
-							}
-						break;
-						}
-						break;
-				}		
-			} 
-		}
-	}	
-	return false;
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.h
deleted file mode 100644
index 80febc5..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/pi.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PI_H
-#define __PI_H
-/**
- at file pi.h
- at brief Implementation of a packet iterator (PI)
-
-The functions in PI.C have for goal to realize a packet iterator that permits to get the next
-packet following the progression order and change of it. The functions in PI.C are used
-by some function in T2.C.
-*/
-
-/** @defgroup PI PI - Implementation of a packet iterator */
-/*@{*/
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_pi_resolution {
-  int pdx, pdy;
-  int pw, ph;
-} opj_pi_resolution_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_pi_comp {
-  int dx, dy;
-  /** number of resolution levels */
-  int numresolutions;
-  opj_pi_resolution_t *resolutions;
-} opj_pi_comp_t;
-
-/** 
-Packet iterator 
-*/
-typedef struct opj_pi_iterator {
-	/** Enabling Tile part generation*/
-	char tp_on;
-	/** precise if the packet has been already used (usefull for progression order change) */
-	short int *include;
-	/** layer step used to localize the packet in the include vector */
-	int step_l;
-	/** resolution step used to localize the packet in the include vector */
-	int step_r;	
-	/** component step used to localize the packet in the include vector */
-	int step_c;	
-	/** precinct step used to localize the packet in the include vector */
-	int step_p;	
-	/** component that identify the packet */
-	int compno;
-	/** resolution that identify the packet */
-	int resno;
-	/** precinct that identify the packet */
-	int precno;
-	/** layer that identify the packet */
-	int layno;   
-	/** 0 if the first packet */
-	int first;
-	/** progression order change information */
-	opj_poc_t poc;
-	/** number of components in the image */
-	int numcomps;
-	/** Components*/
-	opj_pi_comp_t *comps;
-	int tx0, ty0, tx1, ty1;
-	int x, y, dx, dy;
-} opj_pi_iterator_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a packet iterator for Encoder
- at param image Raw image for which the packets will be listed
- at param cp Coding parameters
- at param tileno Number that identifies the tile for which to list the packets
- at param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
- at return Returns a packet iterator that points to the first packet of the tile
- at see pi_destroy
-*/
-opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int tileno,J2K_T2_MODE t2_mode);
-/**
-Modify the packet iterator for enabling tile part generation
- at param pi Handle to the packet iterator generated in pi_initialise_encode  
- at param cp Coding parameters
- at param tileno Number that identifies the tile for which to list the packets
- at param pino Iterator index for pi
- at param tpnum Tile part number of the current tile
- at param tppos The position of the tile part flag in the progression order
- at param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
- at param cur_totnum_tp The total number of tile parts in the current tile
- at return Returns true if an error is detected 
-*/
-bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
-/**
-Create a packet iterator for Decoder
- at param image Raw image for which the packets will be listed
- at param cp Coding parameters
- at param tileno Number that identifies the tile for which to list the packets
- at return Returns a packet iterator that points to the first packet of the tile
- at see pi_destroy
-*/
-opj_pi_iterator_t *pi_create_decode(opj_image_t * image, opj_cp_t * cp, int tileno);
-
-/**
-Destroy a packet iterator
- at param pi Previously created packet iterator
- at param cp Coding parameters
- at param tileno Number that identifies the tile for which the packets were listed
- at see pi_create
-*/
-void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno);
-
-/**
-Modify the packet iterator to point to the next packet
- at param pi Packet iterator to modify
- at return Returns false if pi pointed to the last packet or else returns true 
-*/
-bool pi_next(opj_pi_iterator_t * pi);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __PI_H */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1.c
deleted file mode 100644
index 4930074..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1.c
+++ /dev/null
@@ -1,1581 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-#include "t1_luts.h"
-
-/** @defgroup T1 T1 - Implementation of the tier-1 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static INLINE char t1_getctxno_zc(int f, int orient);
-static char t1_getctxno_sc(int f);
-static INLINE int t1_getctxno_mag(int f);
-static char t1_getspb(int f);
-static short t1_getnmsedec_sig(int x, int bitpos);
-static short t1_getnmsedec_ref(int x, int bitpos);
-static void t1_updateflags(flag_t *flagsp, int s, int stride);
-/**
-Encode significant pass
-*/
-static void t1_enc_sigpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int bpno,
-		int one,
-		int *nmsedec,
-		char type,
-		int vsc);
-/**
-Decode significant pass
-*/
-static INLINE void t1_dec_sigpass_step_raw(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf,
-		int vsc);
-static INLINE void t1_dec_sigpass_step_mqc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf);
-static INLINE void t1_dec_sigpass_step_mqc_vsc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf,
-		int vsc);
-/**
-Encode significant pass
-*/
-static void t1_enc_sigpass(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int *nmsedec,
-		char type,
-		int cblksty);
-/**
-Decode significant pass
-*/
-static void t1_dec_sigpass_raw(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int cblksty);
-static void t1_dec_sigpass_mqc(
-		opj_t1_t *t1,
-		int bpno,
-		int orient);
-static void t1_dec_sigpass_mqc_vsc(
-		opj_t1_t *t1,
-		int bpno,
-		int orient);
-/**
-Encode refinement pass
-*/
-static void t1_enc_refpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int bpno,
-		int one,
-		int *nmsedec,
-		char type,
-		int vsc);
-/**
-Decode refinement pass
-*/
-static void INLINE t1_dec_refpass_step_raw(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int poshalf,
-		int neghalf,
-		int vsc);
-static void INLINE t1_dec_refpass_step_mqc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int poshalf,
-		int neghalf);
-static void INLINE t1_dec_refpass_step_mqc_vsc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int poshalf,
-		int neghalf,
-		int vsc);
-
-/**
-Encode refinement pass
-*/
-static void t1_enc_refpass(
-		opj_t1_t *t1,
-		int bpno,
-		int *nmsedec,
-		char type,
-		int cblksty);
-/**
-Decode refinement pass
-*/
-static void t1_dec_refpass_raw(
-		opj_t1_t *t1,
-		int bpno,
-		int cblksty);
-static void t1_dec_refpass_mqc(
-		opj_t1_t *t1,
-		int bpno);
-static void t1_dec_refpass_mqc_vsc(
-		opj_t1_t *t1,
-		int bpno);
-/**
-Encode clean-up pass
-*/
-static void t1_enc_clnpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int bpno,
-		int one,
-		int *nmsedec,
-		int partial,
-		int vsc);
-/**
-Decode clean-up pass
-*/
-static void t1_dec_clnpass_step_partial(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf);
-static void t1_dec_clnpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf);
-static void t1_dec_clnpass_step_vsc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf,
-		int partial,
-		int vsc);
-/**
-Encode clean-up pass
-*/
-static void t1_enc_clnpass(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int *nmsedec,
-		int cblksty);
-/**
-Decode clean-up pass
-*/
-static void t1_dec_clnpass(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int cblksty);
-static double t1_getwmsedec(
-		int nmsedec,
-		int compno,
-		int level,
-		int orient,
-		int bpno,
-		int qmfbid,
-		double stepsize,
-		int numcomps,
-		int mct);
-/**
-Encode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param compno Component number
- at param level
- at param qmfbid
- at param stepsize
- at param cblksty Code-block style
- at param numcomps
- at param mct
- at param tile
-*/
-static void t1_encode_cblk(
-		opj_t1_t *t1,
-		opj_tcd_cblk_enc_t* cblk,
-		int orient,
-		int compno,
-		int level,
-		int qmfbid,
-		double stepsize,
-		int cblksty,
-		int numcomps,
-		int mct,
-		opj_tcd_tile_t * tile);
-/**
-Decode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param roishift Region of interest shifting value
- at param cblksty Code-block style
-*/
-static void t1_decode_cblk(
-		opj_t1_t *t1,
-		opj_tcd_cblk_dec_t* cblk,
-		int orient,
-		int roishift,
-		int cblksty);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-static char t1_getctxno_zc(int f, int orient) {
-	return lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)];
-}
-
-static char t1_getctxno_sc(int f) {
-	return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
-}
-
-static int t1_getctxno_mag(int f) {
-	int tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG;
-	int tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1;
-	return (tmp2);
-}
-
-static char t1_getspb(int f) {
-	return lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
-}
-
-static short t1_getnmsedec_sig(int x, int bitpos) {
-	if (bitpos > T1_NMSEDEC_FRACBITS) {
-		return lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-	}
-	
-	return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static short t1_getnmsedec_ref(int x, int bitpos) {
-	if (bitpos > T1_NMSEDEC_FRACBITS) {
-		return lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-	}
-
-    return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static void t1_updateflags(flag_t *flagsp, int s, int stride) {
-	flag_t *np = flagsp - stride;
-	flag_t *sp = flagsp + stride;
-
-	static const flag_t mod[] = {
-		T1_SIG_S, T1_SIG_S|T1_SGN_S,
-		T1_SIG_E, T1_SIG_E|T1_SGN_E,
-		T1_SIG_W, T1_SIG_W|T1_SGN_W,
-		T1_SIG_N, T1_SIG_N|T1_SGN_N
-	};
-
-	np[-1] |= T1_SIG_SE;
-	np[0]  |= mod[s];
-	np[1]  |= T1_SIG_SW;
-
-	flagsp[-1] |= mod[s+2];
-	flagsp[0]  |= T1_SIG;
-	flagsp[1]  |= mod[s+4];
-
-	sp[-1] |= T1_SIG_NE;
-	sp[0]  |= mod[s+6];
-	sp[1]  |= T1_SIG_NW;
-}
-
-static void t1_enc_sigpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int bpno,
-		int one,
-		int *nmsedec,
-		char type,
-		int vsc)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-		v = int_abs(*datap) & one ? 1 : 0;
-		mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));	/* ESSAI */
-		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-			mqc_bypass_enc(mqc, v);
-		} else {
-			mqc_encode(mqc, v);
-		}
-		if (v) {
-			v = *datap < 0 ? 1 : 0;
-			*nmsedec +=	t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
-			mqc_setcurctx(mqc, t1_getctxno_sc(flag));	/* ESSAI */
-			if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-				mqc_bypass_enc(mqc, v);
-			} else {
-				mqc_encode(mqc, v ^ t1_getspb(flag));
-			}
-			t1_updateflags(flagsp, v, t1->flags_stride);
-		}
-		*flagsp |= T1_VISIT;
-	}
-}
-
-static INLINE void t1_dec_sigpass_step_raw(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf,
-		int vsc)
-{
-	int v, flag;
-	
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-			if (raw_decode(raw)) {
-				v = raw_decode(raw);	/* ESSAI */
-				*datap = v ? -oneplushalf : oneplushalf;
-				t1_updateflags(flagsp, v, t1->flags_stride);
-			}
-		*flagsp |= T1_VISIT;
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static INLINE void t1_dec_sigpass_step_mqc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = *flagsp;
-	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-			mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-			if (mqc_decode(mqc)) {
-				mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-				v = mqc_decode(mqc) ^ t1_getspb(flag);
-				*datap = v ? -oneplushalf : oneplushalf;
-				t1_updateflags(flagsp, v, t1->flags_stride);
-			}
-		*flagsp |= T1_VISIT;
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static INLINE void t1_dec_sigpass_step_mqc_vsc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf,
-		int vsc)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-		mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-		if (mqc_decode(mqc)) {
-			mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-			v = mqc_decode(mqc) ^ t1_getspb(flag);
-			*datap = v ? -oneplushalf : oneplushalf;
-			t1_updateflags(flagsp, v, t1->flags_stride);
-		}
-		*flagsp |= T1_VISIT;
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_enc_sigpass(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int *nmsedec,
-		char type,
-		int cblksty)
-{
-	int i, j, k, one, vsc;
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			for (j = k; j < k + 4 && j < t1->h; ++j) {
-				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-				t1_enc_sigpass_step(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						orient,
-						bpno,
-						one,
-						nmsedec,
-						type,
-						vsc);
-			}
-		}
-	}
-}
-
-static void t1_dec_sigpass_raw(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int cblksty)
-{
-	int i, j, k, one, half, oneplushalf, vsc;
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			for (j = k; j < k + 4 && j < t1->h; ++j) {
-				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-				t1_dec_sigpass_step_raw(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						orient,
-						oneplushalf,
-						vsc);
-			}
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_dec_sigpass_mqc(
-		opj_t1_t *t1,
-		int bpno,
-		int orient)
-{
-	int i, j, k, one, half, oneplushalf;
-	int *data1 = t1->data;
-	flag_t *flags1 = &t1->flags[1];
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	for (k = 0; k < (t1->h & ~3); k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			int *data2 = data1 + i;
-			flag_t *flags2 = flags1 + i;
-			flags2 += t1->flags_stride;
-			t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
-			data2 += t1->w;
-			flags2 += t1->flags_stride;
-			t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
-			data2 += t1->w;
-			flags2 += t1->flags_stride;
-			t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
-			data2 += t1->w;
-			flags2 += t1->flags_stride;
-			t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
-			data2 += t1->w;
-		}
-		data1 += t1->w << 2;
-		flags1 += t1->flags_stride << 2;
-	}
-	for (i = 0; i < t1->w; ++i) {
-		int *data2 = data1 + i;
-		flag_t *flags2 = flags1 + i;
-		for (j = k; j < t1->h; ++j) {
-			flags2 += t1->flags_stride;
-			t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
-			data2 += t1->w;
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_dec_sigpass_mqc_vsc(
-		opj_t1_t *t1,
-		int bpno,
-		int orient)
-{
-	int i, j, k, one, half, oneplushalf, vsc;
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			for (j = k; j < k + 4 && j < t1->h; ++j) {
-				vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0;
-				t1_dec_sigpass_step_mqc_vsc(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						orient,
-						oneplushalf,
-						vsc);
-			}
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_enc_refpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int bpno,
-		int one,
-		int *nmsedec,
-		char type,
-		int vsc)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-		*nmsedec += t1_getnmsedec_ref(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
-		v = int_abs(*datap) & one ? 1 : 0;
-		mqc_setcurctx(mqc, t1_getctxno_mag(flag));	/* ESSAI */
-		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
-			mqc_bypass_enc(mqc, v);
-		} else {
-			mqc_encode(mqc, v);
-		}
-		*flagsp |= T1_REFINE;
-	}
-}
-
-static INLINE void t1_dec_refpass_step_raw(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int poshalf,
-		int neghalf,
-		int vsc)
-{
-	int v, t, flag;
-	
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-			v = raw_decode(raw);
-		t = v ? poshalf : neghalf;
-		*datap += *datap < 0 ? -t : t;
-		*flagsp |= T1_REFINE;
-	}
-}				/* VSC and  BYPASS by Antonin  */
-
-static INLINE void t1_dec_refpass_step_mqc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int poshalf,
-		int neghalf)
-{
-	int v, t, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = *flagsp;
-	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-		mqc_setcurctx(mqc, t1_getctxno_mag(flag));	/* ESSAI */
-			v = mqc_decode(mqc);
-		t = v ? poshalf : neghalf;
-		*datap += *datap < 0 ? -t : t;
-		*flagsp |= T1_REFINE;
-		}
-}				/* VSC and  BYPASS by Antonin  */
-
-static INLINE void t1_dec_refpass_step_mqc_vsc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int poshalf,
-		int neghalf,
-		int vsc)
-{
-	int v, t, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-		mqc_setcurctx(mqc, t1_getctxno_mag(flag));	/* ESSAI */
-		v = mqc_decode(mqc);
-		t = v ? poshalf : neghalf;
-		*datap += *datap < 0 ? -t : t;
-		*flagsp |= T1_REFINE;
-	}
-}				/* VSC and  BYPASS by Antonin  */
-
-static void t1_enc_refpass(
-		opj_t1_t *t1,
-		int bpno,
-		int *nmsedec,
-		char type,
-		int cblksty)
-{
-	int i, j, k, one, vsc;
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			for (j = k; j < k + 4 && j < t1->h; ++j) {
-				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-				t1_enc_refpass_step(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						bpno,
-						one,
-						nmsedec,
-						type,
-						vsc);
-			}
-		}
-	}
-}
-
-static void t1_dec_refpass_raw(
-		opj_t1_t *t1,
-		int bpno,
-		int cblksty)
-{
-	int i, j, k, one, poshalf, neghalf;
-	int vsc;
-	one = 1 << bpno;
-	poshalf = one >> 1;
-	neghalf = bpno > 0 ? -poshalf : -1;
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			for (j = k; j < k + 4 && j < t1->h; ++j) {
-				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-				t1_dec_refpass_step_raw(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						poshalf,
-						neghalf,
-						vsc);
-			}
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_dec_refpass_mqc(
-		opj_t1_t *t1,
-		int bpno)
-{
-	int i, j, k, one, poshalf, neghalf;
-	int *data1 = t1->data;
-	flag_t *flags1 = &t1->flags[1];
-	one = 1 << bpno;
-	poshalf = one >> 1;
-	neghalf = bpno > 0 ? -poshalf : -1;
-	for (k = 0; k < (t1->h & ~3); k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			int *data2 = data1 + i;
-			flag_t *flags2 = flags1 + i;
-			flags2 += t1->flags_stride;
-			t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
-			data2 += t1->w;
-			flags2 += t1->flags_stride;
-			t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
-			data2 += t1->w;
-			flags2 += t1->flags_stride;
-			t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
-			data2 += t1->w;
-			flags2 += t1->flags_stride;
-			t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
-			data2 += t1->w;
-		}
-		data1 += t1->w << 2;
-		flags1 += t1->flags_stride << 2;
-	}
-	for (i = 0; i < t1->w; ++i) {
-		int *data2 = data1 + i;
-		flag_t *flags2 = flags1 + i;
-		for (j = k; j < t1->h; ++j) {
-			flags2 += t1->flags_stride;
-			t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
-			data2 += t1->w;
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_dec_refpass_mqc_vsc(
-		opj_t1_t *t1,
-		int bpno)
-{
-	int i, j, k, one, poshalf, neghalf;
-	int vsc;
-	one = 1 << bpno;
-	poshalf = one >> 1;
-	neghalf = bpno > 0 ? -poshalf : -1;
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			for (j = k; j < k + 4 && j < t1->h; ++j) {
-				vsc = ((j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-				t1_dec_refpass_step_mqc_vsc(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						poshalf,
-						neghalf,
-						vsc);
-			}
-		}
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_enc_clnpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int bpno,
-		int one,
-		int *nmsedec,
-		int partial,
-		int vsc)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if (partial) {
-		goto LABEL_PARTIAL;
-	}
-	if (!(*flagsp & (T1_SIG | T1_VISIT))) {
-		mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-		v = int_abs(*datap) & one ? 1 : 0;
-		mqc_encode(mqc, v);
-		if (v) {
-LABEL_PARTIAL:
-			*nmsedec += t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
-			mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-			v = *datap < 0 ? 1 : 0;
-			mqc_encode(mqc, v ^ t1_getspb(flag));
-			t1_updateflags(flagsp, v, t1->flags_stride);
-		}
-	}
-	*flagsp &= ~T1_VISIT;
-}
-
-static void t1_dec_clnpass_step_partial(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = *flagsp;
-	mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-	v = mqc_decode(mqc) ^ t1_getspb(flag);
-	*datap = v ? -oneplushalf : oneplushalf;
-	t1_updateflags(flagsp, v, t1->flags_stride);
-	*flagsp &= ~T1_VISIT;
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_dec_clnpass_step(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = *flagsp;
-	if (!(flag & (T1_SIG | T1_VISIT))) {
-		mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-		if (mqc_decode(mqc)) {
-			mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-			v = mqc_decode(mqc) ^ t1_getspb(flag);
-			*datap = v ? -oneplushalf : oneplushalf;
-			t1_updateflags(flagsp, v, t1->flags_stride);
-		}
-	}
-	*flagsp &= ~T1_VISIT;
-}				/* VSC and  BYPASS by Antonin */
-
-static void t1_dec_clnpass_step_vsc(
-		opj_t1_t *t1,
-		flag_t *flagsp,
-		int *datap,
-		int orient,
-		int oneplushalf,
-		int partial,
-		int vsc)
-{
-	int v, flag;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-	if (partial) {
-		goto LABEL_PARTIAL;
-	}
-	if (!(flag & (T1_SIG | T1_VISIT))) {
-		mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-		if (mqc_decode(mqc)) {
-LABEL_PARTIAL:
-			mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-			v = mqc_decode(mqc) ^ t1_getspb(flag);
-			*datap = v ? -oneplushalf : oneplushalf;
-			t1_updateflags(flagsp, v, t1->flags_stride);
-		}
-	}
-	*flagsp &= ~T1_VISIT;
-}
-
-static void t1_enc_clnpass(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int *nmsedec,
-		int cblksty)
-{
-	int i, j, k, one, agg, runlen, vsc;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	*nmsedec = 0;
-	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			if (k + 3 < t1->h) {
-				if (cblksty & J2K_CCP_CBLKSTY_VSC) {
-					agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| (MACRO_t1_flags(1 + k + 3,1 + i) 
-						& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |	T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-				} else {
-					agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-				}
-			} else {
-				agg = 0;
-			}
-			if (agg) {
-				for (runlen = 0; runlen < 4; ++runlen) {
-					if (int_abs(t1->data[((k + runlen)*t1->w) + i]) & one)
-						break;
-				}
-				mqc_setcurctx(mqc, T1_CTXNO_AGG);
-				mqc_encode(mqc, runlen != 4);
-				if (runlen == 4) {
-					continue;
-				}
-				mqc_setcurctx(mqc, T1_CTXNO_UNI);
-				mqc_encode(mqc, runlen >> 1);
-				mqc_encode(mqc, runlen & 1);
-			} else {
-				runlen = 0;
-			}
-			for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
-				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-				t1_enc_clnpass_step(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						orient,
-						bpno,
-						one,
-						nmsedec,
-						agg && (j == k + runlen),
-						vsc);
-			}
-		}
-	}
-}
-
-static void t1_dec_clnpass(
-		opj_t1_t *t1,
-		int bpno,
-		int orient,
-		int cblksty)
-{
-	int i, j, k, one, half, oneplushalf, agg, runlen, vsc;
-	int segsym = cblksty & J2K_CCP_CBLKSTY_SEGSYM;
-	
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-	
-	one = 1 << bpno;
-	half = one >> 1;
-	oneplushalf = one | half;
-	if (cblksty & J2K_CCP_CBLKSTY_VSC) {
-	for (k = 0; k < t1->h; k += 4) {
-		for (i = 0; i < t1->w; ++i) {
-			if (k + 3 < t1->h) {
-					agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-						|| (MACRO_t1_flags(1 + k + 3,1 + i) 
-						& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |	T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-				} else {
-				agg = 0;
-			}
-			if (agg) {
-				mqc_setcurctx(mqc, T1_CTXNO_AGG);
-				if (!mqc_decode(mqc)) {
-					continue;
-				}
-				mqc_setcurctx(mqc, T1_CTXNO_UNI);
-				runlen = mqc_decode(mqc);
-				runlen = (runlen << 1) | mqc_decode(mqc);
-			} else {
-				runlen = 0;
-			}
-			for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
-					vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0;
-					t1_dec_clnpass_step_vsc(
-						t1,
-						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
-						&t1->data[(j * t1->w) + i],
-						orient,
-						oneplushalf,
-						agg && (j == k + runlen),
-						vsc);
-			}
-		}
-	}
-	} else {
-		int *data1 = t1->data;
-		flag_t *flags1 = &t1->flags[1];
-		for (k = 0; k < (t1->h & ~3); k += 4) {
-			for (i = 0; i < t1->w; ++i) {
-				int *data2 = data1 + i;
-				flag_t *flags2 = flags1 + i;
-				agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-					|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-					|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-					|| MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-				if (agg) {
-					mqc_setcurctx(mqc, T1_CTXNO_AGG);
-					if (!mqc_decode(mqc)) {
-						continue;
-					}
-					mqc_setcurctx(mqc, T1_CTXNO_UNI);
-					runlen = mqc_decode(mqc);
-					runlen = (runlen << 1) | mqc_decode(mqc);
-					flags2 += runlen * t1->flags_stride;
-					data2 += runlen * t1->w;
-					for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
-						flags2 += t1->flags_stride;
-						if (agg && (j == k + runlen)) {
-							t1_dec_clnpass_step_partial(t1, flags2, data2, orient, oneplushalf);
-						} else {
-							t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
-						}
-						data2 += t1->w;
-					}
-				} else {
-					flags2 += t1->flags_stride;
-					t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
-					data2 += t1->w;
-					flags2 += t1->flags_stride;
-					t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
-					data2 += t1->w;
-					flags2 += t1->flags_stride;
-					t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
-					data2 += t1->w;
-					flags2 += t1->flags_stride;
-					t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
-					data2 += t1->w;
-				}
-			}
-			data1 += t1->w << 2;
-			flags1 += t1->flags_stride << 2;
-		}
-		for (i = 0; i < t1->w; ++i) {
-			int *data2 = data1 + i;
-			flag_t *flags2 = flags1 + i;
-			for (j = k; j < t1->h; ++j) {
-				flags2 += t1->flags_stride;
-				t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
-				data2 += t1->w;
-			}
-		}
-	}
-
-	if (segsym) {
-		int v = 0;
-		mqc_setcurctx(mqc, T1_CTXNO_UNI);
-		v = mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		v = (v << 1) | mqc_decode(mqc);
-		/*
-		if (v!=0xa) {
-			opj_event_msg(t1->cinfo, EVT_WARNING, "Bad segmentation symbol %x\n", v);
-		} 
-		*/
-	}
-}				/* VSC and  BYPASS by Antonin */
-
-
-/** mod fixed_quality */
-static double t1_getwmsedec(
-		int nmsedec,
-		int compno,
-		int level,
-		int orient,
-		int bpno,
-		int qmfbid,
-		double stepsize,
-		int numcomps,
-		int mct)
-{
-	double w1, w2, wmsedec;
-	if (qmfbid == 1) {
-		w1 = (mct && numcomps==3) ? mct_getnorm(compno) : 1.0;
-		w2 = dwt_getnorm(level, orient);
-	} else {			/* if (qmfbid == 0) */
-		w1 = (mct && numcomps==3) ? mct_getnorm_real(compno) : 1.0;
-		w2 = dwt_getnorm_real(level, orient);
-	}
-	wmsedec = w1 * w2 * stepsize * (1 << bpno);
-	wmsedec *= wmsedec * nmsedec / 8192.0;
-	
-	return wmsedec;
-}
-
-static bool allocate_buffers(
-		opj_t1_t *t1,
-		int w,
-		int h)
-{
-	int datasize=w * h;
-	int flagssize;
-
-	if(datasize > t1->datasize){
-		opj_aligned_free(t1->data);
-		t1->data = (int*) opj_aligned_malloc(datasize * sizeof(int));
-		if(!t1->data){
-			return false;
-		}
-		t1->datasize=datasize;
-	}
-	memset(t1->data,0,datasize * sizeof(int));
-
-	t1->flags_stride=w+2;
-	flagssize=t1->flags_stride * (h+2);
-
-	if(flagssize > t1->flagssize){
-		opj_aligned_free(t1->flags);
-		t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t));
-		if(!t1->flags){
-			return false;
-		}
-		t1->flagssize=flagssize;
-	}
-	memset(t1->flags,0,flagssize * sizeof(flag_t));
-
-	t1->w=w;
-	t1->h=h;
-
-	return true;
-}
-
-/** mod fixed_quality */
-static void t1_encode_cblk(
-		opj_t1_t *t1,
-		opj_tcd_cblk_enc_t* cblk,
-		int orient,
-		int compno,
-		int level,
-		int qmfbid,
-		double stepsize,
-		int cblksty,
-		int numcomps,
-		int mct,
-		opj_tcd_tile_t * tile)
-{
-	double cumwmsedec = 0.0;
-
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-
-	int passno, bpno, passtype;
-	int nmsedec = 0;
-	int i, max;
-	char type = T1_TYPE_MQ;
-	double tempwmsedec;
-
-	max = 0;
-	for (i = 0; i < t1->w * t1->h; ++i) {
-		int tmp = abs(t1->data[i]);
-		max = int_max(max, tmp);
-	}
-
-	cblk->numbps = max ? (int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
-	
-	bpno = cblk->numbps - 1;
-	passtype = 2;
-	
-	mqc_resetstates(mqc);
-	mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
-	mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-	mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-	mqc_init_enc(mqc, cblk->data);
-	
-	for (passno = 0; bpno >= 0; ++passno) {
-		opj_tcd_pass_t *pass = &cblk->passes[passno];
-		int correction = 3;
-		type = ((bpno < (cblk->numbps - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-		
-		switch (passtype) {
-			case 0:
-				t1_enc_sigpass(t1, bpno, orient, &nmsedec, type, cblksty);
-				break;
-			case 1:
-				t1_enc_refpass(t1, bpno, &nmsedec, type, cblksty);
-				break;
-			case 2:
-				t1_enc_clnpass(t1, bpno, orient, &nmsedec, cblksty);
-				/* code switch SEGMARK (i.e. SEGSYM) */
-				if (cblksty & J2K_CCP_CBLKSTY_SEGSYM)
-					mqc_segmark_enc(mqc);
-				break;
-		}
-		
-		/* fixed_quality */
-		tempwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps, mct);
-		cumwmsedec += tempwmsedec;
-		tile->distotile += tempwmsedec;
-		
-		/* Code switch "RESTART" (i.e. TERMALL) */
-		if ((cblksty & J2K_CCP_CBLKSTY_TERMALL)	&& !((passtype == 2) && (bpno - 1 < 0))) {
-			if (type == T1_TYPE_RAW) {
-				mqc_flush(mqc);
-				correction = 1;
-				/* correction = mqc_bypass_flush_enc(); */
-			} else {			/* correction = mqc_restart_enc(); */
-				mqc_flush(mqc);
-				correction = 1;
-			}
-			pass->term = 1;
-		} else {
-			if (((bpno < (cblk->numbps - 4) && (passtype > 0)) 
-				|| ((bpno == (cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) {
-				if (type == T1_TYPE_RAW) {
-					mqc_flush(mqc);
-					correction = 1;
-					/* correction = mqc_bypass_flush_enc(); */
-				} else {		/* correction = mqc_restart_enc(); */
-					mqc_flush(mqc);
-					correction = 1;
-				}
-				pass->term = 1;
-			} else {
-				pass->term = 0;
-			}
-		}
-		
-		if (++passtype == 3) {
-			passtype = 0;
-			bpno--;
-		}
-		
-		if (pass->term && bpno > 0) {
-			type = ((bpno < (cblk->numbps - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-			if (type == T1_TYPE_RAW)
-				mqc_bypass_init_enc(mqc);
-			else
-				mqc_restart_init_enc(mqc);
-		}
-		
-		pass->distortiondec = cumwmsedec;
-		pass->rate = mqc_numbytes(mqc) + correction;	/* FIXME */
-		
-		/* Code-switch "RESET" */
-		if (cblksty & J2K_CCP_CBLKSTY_RESET)
-			mqc_reset_enc(mqc);
-	}
-	
-	/* Code switch "ERTERM" (i.e. PTERM) */
-	if (cblksty & J2K_CCP_CBLKSTY_PTERM)
-		mqc_erterm_enc(mqc);
-	else /* Default coding */ if (!(cblksty & J2K_CCP_CBLKSTY_LAZY))
-		mqc_flush(mqc);
-	
-	cblk->totalpasses = passno;
-
-	for (passno = 0; passno<cblk->totalpasses; passno++) {
-		opj_tcd_pass_t *pass = &cblk->passes[passno];
-		if (pass->rate > mqc_numbytes(mqc))
-			pass->rate = mqc_numbytes(mqc);
-		/*Preventing generation of FF as last data byte of a pass*/
-		if((pass->rate>1) && (cblk->data[pass->rate - 1] == 0xFF)){
-			pass->rate--;
-		}
-		pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);		
-	}
-}
-
-static void t1_decode_cblk(
-		opj_t1_t *t1,
-		opj_tcd_cblk_dec_t* cblk,
-		int orient,
-		int roishift,
-		int cblksty)
-{
-	opj_raw_t *raw = t1->raw;	/* RAW component */
-	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
-
-	int bpno, passtype;
-	int segno, passno;
-	char type = T1_TYPE_MQ; /* BYPASS mode */
-
-	if(!allocate_buffers(
-				t1,
-				cblk->x1 - cblk->x0,
-				cblk->y1 - cblk->y0))
-	{
-		return;
-	}
-
-	bpno = roishift + cblk->numbps - 1;
-	passtype = 2;
-	
-	mqc_resetstates(mqc);
-	mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
-	mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-	mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-	
-	for (segno = 0; segno < cblk->numsegs; ++segno) {
-		opj_tcd_seg_t *seg = &cblk->segs[segno];
-		
-		/* BYPASS mode */
-		type = ((bpno <= (cblk->numbps - 1) - 4) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-		/* FIXME: slviewer gets here with a null pointer. Why? Partially downloaded and/or corrupt textures? */
-		if(seg->data == NULL){
-			continue;
-		}
-		if (type == T1_TYPE_RAW) {
-			raw_init_dec(raw, (*seg->data) + seg->dataindex, seg->len);
-		} else {
-			mqc_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len);
-		}
-		
-		for (passno = 0; passno < seg->numpasses; ++passno) {
-			switch (passtype) {
-				case 0:
-					if (type == T1_TYPE_RAW) {
-						t1_dec_sigpass_raw(t1, bpno+1, orient, cblksty);
-					} else {
-						if (cblksty & J2K_CCP_CBLKSTY_VSC) {
-							t1_dec_sigpass_mqc_vsc(t1, bpno+1, orient);
-						} else {
-							t1_dec_sigpass_mqc(t1, bpno+1, orient);
-						}
-					}
-					break;
-				case 1:
-					if (type == T1_TYPE_RAW) {
-						t1_dec_refpass_raw(t1, bpno+1, cblksty);
-					} else {
-						if (cblksty & J2K_CCP_CBLKSTY_VSC) {
-							t1_dec_refpass_mqc_vsc(t1, bpno+1);
-						} else {
-							t1_dec_refpass_mqc(t1, bpno+1);
-						}
-					}
-					break;
-				case 2:
-					t1_dec_clnpass(t1, bpno+1, orient, cblksty);
-					break;
-			}
-			
-			if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
-				mqc_resetstates(mqc);
-				mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);				
-				mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-				mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-			}
-			if (++passtype == 3) {
-				passtype = 0;
-				bpno--;
-			}
-		}
-	}
-}
-
-/* ----------------------------------------------------------------------- */
-
-opj_t1_t* t1_create(opj_common_ptr cinfo) {
-	opj_t1_t *t1 = (opj_t1_t*) opj_malloc(sizeof(opj_t1_t));
-	if(!t1)
-		return NULL;
-
-	t1->cinfo = cinfo;
-	/* create MQC and RAW handles */
-	t1->mqc = mqc_create();
-	t1->raw = raw_create();
-
-	t1->data=NULL;
-	t1->flags=NULL;
-	t1->datasize=0;
-	t1->flagssize=0;
-
-	return t1;
-}
-
-void t1_destroy(opj_t1_t *t1) {
-	if(t1) {
-		/* destroy MQC and RAW handles */
-		mqc_destroy(t1->mqc);
-		raw_destroy(t1->raw);
-		opj_aligned_free(t1->data);
-		opj_aligned_free(t1->flags);
-		opj_free(t1);
-	}
-}
-
-void t1_encode_cblks(
-		opj_t1_t *t1,
-		opj_tcd_tile_t *tile,
-		opj_tcp_t *tcp)
-{
-	int compno, resno, bandno, precno, cblkno;
-
-	tile->distotile = 0;		/* fixed_quality */
-
-	for (compno = 0; compno < tile->numcomps; ++compno) {
-		opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
-		opj_tccp_t* tccp = &tcp->tccps[compno];
-		int tile_w = tilec->x1 - tilec->x0;
-
-		for (resno = 0; resno < tilec->numresolutions; ++resno) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-			for (bandno = 0; bandno < res->numbands; ++bandno) {
-				opj_tcd_band_t* restrict band = &res->bands[bandno];
-
-				for (precno = 0; precno < res->pw * res->ph; ++precno) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-					for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
-						opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-						int* restrict datap;
-						int* restrict tiledp;
-						int cblk_w;
-						int cblk_h;
-						int i, j;
-
-						int x = cblk->x0 - band->x0;
-						int y = cblk->y0 - band->y0;
-						if (band->bandno & 1) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							x += pres->x1 - pres->x0;
-						}
-						if (band->bandno & 2) {
-							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-							y += pres->y1 - pres->y0;
-						}
-
-						if(!allocate_buffers(
-									t1,
-									cblk->x1 - cblk->x0,
-									cblk->y1 - cblk->y0))
-						{
-							return;
-						}
-
-						datap=t1->data;
-						cblk_w = t1->w;
-						cblk_h = t1->h;
-
-						tiledp=&tilec->data[(y * tile_w) + x];
-						if (tccp->qmfbid == 1) {
-							for (j = 0; j < cblk_h; ++j) {
-								for (i = 0; i < cblk_w; ++i) {
-									int tmp = tiledp[(j * tile_w) + i];
-									datap[(j * cblk_w) + i] = tmp << T1_NMSEDEC_FRACBITS;
-								}
-							}
-						} else {		/* if (tccp->qmfbid == 0) */
-							for (j = 0; j < cblk_h; ++j) {
-								for (i = 0; i < cblk_w; ++i) {
-									int tmp = tiledp[(j * tile_w) + i];
-									datap[(j * cblk_w) + i] =
-										fix_mul(
-										tmp,
-										8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (11 - T1_NMSEDEC_FRACBITS);
-								}
-							}
-						}
-
-						t1_encode_cblk(
-								t1,
-								cblk,
-								band->bandno,
-								compno,
-								tilec->numresolutions - 1 - resno,
-								tccp->qmfbid,
-								band->stepsize,
-								tccp->cblksty,
-								tile->numcomps,
-								tcp->mct,
-								tile);
-
-					} /* cblkno */
-				} /* precno */
-			} /* bandno */
-		} /* resno  */
-	} /* compno  */
-}
-
-void t1_decode_cblks(
-		opj_t1_t* t1,
-		opj_tcd_tilecomp_t* tilec,
-		opj_tccp_t* tccp)
-{
-	int resno, bandno, precno, cblkno;
-
-	int tile_w = tilec->x1 - tilec->x0;
-
-	for (resno = 0; resno < tilec->numresolutions; ++resno) {
-		opj_tcd_resolution_t* res = &tilec->resolutions[resno];
-
-		for (bandno = 0; bandno < res->numbands; ++bandno) {
-			opj_tcd_band_t* restrict band = &res->bands[bandno];
-
-			for (precno = 0; precno < res->pw * res->ph; ++precno) {
-				opj_tcd_precinct_t* precinct = &band->precincts[precno];
-
-				for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
-					opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
-					int* restrict datap;
-					int cblk_w, cblk_h;
-					int x, y;
-					int i, j;
-
-					t1_decode_cblk(
-							t1,
-							cblk,
-							band->bandno,
-							tccp->roishift,
-							tccp->cblksty);
-
-					x = cblk->x0 - band->x0;
-					y = cblk->y0 - band->y0;
-					if (band->bandno & 1) {
-						opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
-						x += pres->x1 - pres->x0;
-					}
-					if (band->bandno & 2) {
-						opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
-						y += pres->y1 - pres->y0;
-					}
-
-					datap=t1->data;
-					cblk_w = t1->w;
-					cblk_h = t1->h;
-
-					if (tccp->roishift) {
-						int thresh = 1 << tccp->roishift;
-						for (j = 0; j < cblk_h; ++j) {
-							for (i = 0; i < cblk_w; ++i) {
-								int val = datap[(j * cblk_w) + i];
-								int mag = abs(val);
-								if (mag >= thresh) {
-									mag >>= tccp->roishift;
-									datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;
-								}
-							}
-						}
-					}
-
-					if (tccp->qmfbid == 1) {
-						int* restrict tiledp = &tilec->data[(y * tile_w) + x];
-						for (j = 0; j < cblk_h; ++j) {
-							for (i = 0; i < cblk_w; ++i) {
-								int tmp = datap[(j * cblk_w) + i];
-								((int*)tiledp)[(j * tile_w) + i] = tmp / 2;
-							}
-						}
-					} else {		/* if (tccp->qmfbid == 0) */
-						float* restrict tiledp = (float*) &tilec->data[(y * tile_w) + x];
-						for (j = 0; j < cblk_h; ++j) {
-							float* restrict tiledp2 = tiledp;
-							for (i = 0; i < cblk_w; ++i) {
-								float tmp = *datap * band->stepsize;
-								*tiledp2 = tmp;
-								datap++;
-								tiledp2++;
-							}
-							tiledp += tile_w;
-						}
-					}
-					opj_free(cblk->data);
-					opj_free(cblk->segs);
-				} /* cblkno */
-				opj_free(precinct->cblks.dec);
-			} /* precno */
-		} /* bandno */
-	} /* resno */
-}
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t2.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/t2.c
deleted file mode 100644
index 550dde9..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t2.c
+++ /dev/null
@@ -1,795 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/** @defgroup T2 T2 - Implementation of a tier-2 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static void t2_putcommacode(opj_bio_t *bio, int n);
-static int t2_getcommacode(opj_bio_t *bio);
-/**
-Variable length code for signalling delta Zil (truncation point)
- at param bio Bit Input/Output component
- at param n delta Zil
-*/
-static void t2_putnumpasses(opj_bio_t *bio, int n);
-static int t2_getnumpasses(opj_bio_t *bio);
-/**
-Encode a packet of a tile to a destination buffer
- at param tile Tile for which to write the packets
- at param tcp Tile coding parameters
- at param pi Packet identity
- at param dest Destination buffer
- at param len Length of the destination buffer
- at param cstr_info Codestream information structure 
- at param tileno Number of the tile encoded
- at return 
-*/
-static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_codestream_info_t *cstr_info, int tileno);
-/**
- at param cblk
- at param index
- at param cblksty
- at param first
-*/
-static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first);
-/**
-Decode a packet of a tile from a source buffer
- at param t2 T2 handle
- at param src Source buffer
- at param len Length of the source buffer
- at param tile Tile for which to write the packets
- at param tcp Tile coding parameters
- at param pi Packet identity
- at param pack_info Packet information
- at return 
-*/
-static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, 
-														opj_tcp_t *tcp, opj_pi_iterator_t *pi, opj_packet_info_t *pack_info);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-/* #define RESTART 0x04 */
-
-static void t2_putcommacode(opj_bio_t *bio, int n) {
-	while (--n >= 0) {
-		bio_write(bio, 1, 1);
-	}
-	bio_write(bio, 0, 1);
-}
-
-static int t2_getcommacode(opj_bio_t *bio) {
-	int n;
-	for (n = 0; bio_read(bio, 1); n++) {
-		;
-	}
-	return n;
-}
-
-static void t2_putnumpasses(opj_bio_t *bio, int n) {
-	if (n == 1) {
-		bio_write(bio, 0, 1);
-	} else if (n == 2) {
-		bio_write(bio, 2, 2);
-	} else if (n <= 5) {
-		bio_write(bio, 0xc | (n - 3), 4);
-	} else if (n <= 36) {
-		bio_write(bio, 0x1e0 | (n - 6), 9);
-	} else if (n <= 164) {
-		bio_write(bio, 0xff80 | (n - 37), 16);
-	}
-}
-
-static int t2_getnumpasses(opj_bio_t *bio) {
-	int n;
-	if (!bio_read(bio, 1))
-		return 1;
-	if (!bio_read(bio, 1))
-		return 2;
-	if ((n = bio_read(bio, 2)) != 3)
-		return (3 + n);
-	if ((n = bio_read(bio, 5)) != 31)
-		return (6 + n);
-	return (37 + bio_read(bio, 7));
-}
-
-static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_iterator_t *pi, unsigned char *dest, int length, opj_codestream_info_t *cstr_info, int tileno) {
-	int bandno, cblkno;
-	unsigned char *c = dest;
-
-	int compno = pi->compno;	/* component value */
-	int resno  = pi->resno;		/* resolution level value */
-	int precno = pi->precno;	/* precinct value */
-	int layno  = pi->layno;		/* quality layer value */
-
-	opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-	opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-	
-	opj_bio_t *bio = NULL;	/* BIO component */
-	
-	/* <SOP 0xff91> */
-	if (tcp->csty & J2K_CP_CSTY_SOP) {
-		c[0] = 255;
-		c[1] = 145;
-		c[2] = 0;
-		c[3] = 4;
-		c[4] = (tile->packno % 65536) / 256;
-		c[5] = (tile->packno % 65536) % 256;
-		c += 6;
-	}
-	/* </SOP> */
-	
-	if (!layno) {
-		for (bandno = 0; bandno < res->numbands; bandno++) {
-			opj_tcd_band_t *band = &res->bands[bandno];
-			opj_tcd_precinct_t *prc = &band->precincts[precno];
-			tgt_reset(prc->incltree);
-			tgt_reset(prc->imsbtree);
-			for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-				opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-				cblk->numpasses = 0;
-				tgt_setvalue(prc->imsbtree, cblkno, band->numbps - cblk->numbps);
-			}
-		}
-	}
-	
-	bio = bio_create();
-	bio_init_enc(bio, c, length);
-	bio_write(bio, 1, 1);		/* Empty header bit */
-	
-	/* Writing Packet header */
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-			opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-			opj_tcd_layer_t *layer = &cblk->layers[layno];
-			if (!cblk->numpasses && layer->numpasses) {
-				tgt_setvalue(prc->incltree, cblkno, layno);
-			}
-		}
-		for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-			opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-			opj_tcd_layer_t *layer = &cblk->layers[layno];
-			int increment = 0;
-			int nump = 0;
-			int len = 0, passno;
-			/* cblk inclusion bits */
-			if (!cblk->numpasses) {
-				tgt_encode(bio, prc->incltree, cblkno, layno + 1);
-			} else {
-				bio_write(bio, layer->numpasses != 0, 1);
-			}
-			/* if cblk not included, go to the next cblk  */
-			if (!layer->numpasses) {
-				continue;
-			}
-			/* if first instance of cblk --> zero bit-planes information */
-			if (!cblk->numpasses) {
-				cblk->numlenbits = 3;
-				tgt_encode(bio, prc->imsbtree, cblkno, 999);
-			}
-			/* number of coding passes included */
-			t2_putnumpasses(bio, layer->numpasses);
-			
-			/* computation of the increase of the length indicator and insertion in the header     */
-			for (passno = cblk->numpasses; passno < cblk->numpasses + layer->numpasses; passno++) {
-				opj_tcd_pass_t *pass = &cblk->passes[passno];
-				nump++;
-				len += pass->len;
-				if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
-					increment = int_max(increment, int_floorlog2(len) + 1 - (cblk->numlenbits + int_floorlog2(nump)));
-					len = 0;
-					nump = 0;
-				}
-			}
-			t2_putcommacode(bio, increment);
-
-			/* computation of the new Length indicator */
-			cblk->numlenbits += increment;
-
-			/* insertion of the codeword segment length */
-			for (passno = cblk->numpasses; passno < cblk->numpasses + layer->numpasses; passno++) {
-				opj_tcd_pass_t *pass = &cblk->passes[passno];
-				nump++;
-				len += pass->len;
-				if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
-					bio_write(bio, len, cblk->numlenbits + int_floorlog2(nump));
-					len = 0;
-					nump = 0;
-				}
-			}
-		}
-	}
-
-	if (bio_flush(bio)) {
-		bio_destroy(bio);
-		return -999;		/* modified to eliminate longjmp !! */
-	}
-
-	c += bio_numbytes(bio);
-	bio_destroy(bio);
-	
-	/* <EPH 0xff92> */
-	if (tcp->csty & J2K_CP_CSTY_EPH) {
-		c[0] = 255;
-		c[1] = 146;
-		c += 2;
-	}
-	/* </EPH> */
-
-	/* << INDEX */
-	// End of packet header position. Currently only represents the distance to start of packet
-	// Will be updated later by incrementing with packet start value
-	if(cstr_info && cstr_info->index_write) {
-		opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
-		info_PK->end_ph_pos = (int)(c - dest);
-	}
-	/* INDEX >> */
-	
-	/* Writing the packet body */
-	
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-			opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-			opj_tcd_layer_t *layer = &cblk->layers[layno];
-			if (!layer->numpasses) {
-				continue;
-			}
-			if (c + layer->len > dest + length) {
-				return -999;
-			}
-			
-			memcpy(c, layer->data, layer->len);
-			cblk->numpasses += layer->numpasses;
-			c += layer->len;
-			/* << INDEX */ 
-			if(cstr_info && cstr_info->index_write) {
-				opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
-				info_PK->disto += layer->disto;
-				if (cstr_info->D_max < info_PK->disto) {
-					cstr_info->D_max = info_PK->disto;
-				}
-			}
-			/* INDEX >> */
-		}
-	}
-	
-	return (c - dest);
-}
-
-static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first) {
-	opj_tcd_seg_t* seg;
-	cblk->segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
-	seg = &cblk->segs[index];
-	seg->data = NULL;
-	seg->dataindex = 0;
-	seg->numpasses = 0;
-	seg->len = 0;
-	if (cblksty & J2K_CCP_CBLKSTY_TERMALL) {
-		seg->maxpasses = 1;
-	}
-	else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
-		if (first) {
-			seg->maxpasses = 10;
-		} else {
-			seg->maxpasses = (((seg - 1)->maxpasses == 1) || ((seg - 1)->maxpasses == 10)) ? 2 : 1;
-		}
-	} else {
-		seg->maxpasses = 109;
-	}
-}
-
-static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, 
-														opj_tcp_t *tcp, opj_pi_iterator_t *pi, opj_packet_info_t *pack_info) {
-	int bandno, cblkno;
-	unsigned char *c = src;
-
-	opj_cp_t *cp = t2->cp;
-
-	int compno = pi->compno;	/* component value */
-	int resno  = pi->resno;		/* resolution level value */
-	int precno = pi->precno;	/* precinct value */
-	int layno  = pi->layno;		/* quality layer value */
-
-	opj_tcd_resolution_t* res = &tile->comps[compno].resolutions[resno];
-
-	unsigned char *hd = NULL;
-	int present;
-	
-	opj_bio_t *bio = NULL;	/* BIO component */
-	
-	if (layno == 0) {
-		for (bandno = 0; bandno < res->numbands; bandno++) {
-			opj_tcd_band_t *band = &res->bands[bandno];
-			opj_tcd_precinct_t *prc = &band->precincts[precno];
-			
-			if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
-			
-			tgt_reset(prc->incltree);
-			tgt_reset(prc->imsbtree);
-			for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-				opj_tcd_cblk_dec_t* cblk = &prc->cblks.dec[cblkno];
-				cblk->numsegs = 0;
-			}
-		}
-	}
-	
-	/* SOP markers */
-	
-	if (tcp->csty & J2K_CP_CSTY_SOP) {
-		if ((*c) != 0xff || (*(c + 1) != 0x91)) {
-			opj_event_msg(t2->cinfo, EVT_WARNING, "Expected SOP marker\n");
-		} else {
-			c += 6;
-		}
-		
-		/** TODO : check the Nsop value */
-	}
-	
-	/* 
-	When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
-	This part deal with this caracteristic
-	step 1: Read packet header in the saved structure
-	step 2: Return to codestream for decoding 
-	*/
-
-	bio = bio_create();
-	
-	if (cp->ppm == 1) {		/* PPM */
-		hd = cp->ppm_data;
-		bio_init_dec(bio, hd, cp->ppm_len);
-	} else if (tcp->ppt == 1) {	/* PPT */
-		hd = tcp->ppt_data;
-		bio_init_dec(bio, hd, tcp->ppt_len);
-	} else {			/* Normal Case */
-		hd = c;
-		bio_init_dec(bio, hd, src+len-hd);
-	}
-	
-	present = bio_read(bio, 1);
-	
-	if (!present) {
-		bio_inalign(bio);
-		hd += bio_numbytes(bio);
-		bio_destroy(bio);
-		
-		/* EPH markers */
-		
-		if (tcp->csty & J2K_CP_CSTY_EPH) {
-			if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
-				printf("Error : expected EPH marker\n");
-			} else {
-				hd += 2;
-			}
-		}
-
-		/* << INDEX */
-		// End of packet header position. Currently only represents the distance to start of packet
-		// Will be updated later by incrementing with packet start value
-		if(pack_info) {
-			pack_info->end_ph_pos = (int)(c - src);
-		}
-		/* INDEX >> */
-		
-		if (cp->ppm == 1) {		/* PPM case */
-			cp->ppm_len += cp->ppm_data-hd;
-			cp->ppm_data = hd;
-			return (c - src);
-		}
-		if (tcp->ppt == 1) {	/* PPT case */
-			tcp->ppt_len+=tcp->ppt_data-hd;
-			tcp->ppt_data = hd;
-			return (c - src);
-		}
-		
-		return (hd - src);
-	}
-	
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		
-		if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
-		
-		for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-			int included, increment, n, segno;
-			opj_tcd_cblk_dec_t* cblk = &prc->cblks.dec[cblkno];
-			/* if cblk not yet included before --> inclusion tagtree */
-			if (!cblk->numsegs) {
-				included = tgt_decode(bio, prc->incltree, cblkno, layno + 1);
-				/* else one bit */
-			} else {
-				included = bio_read(bio, 1);
-			}
-			/* if cblk not included */
-			if (!included) {
-				cblk->numnewpasses = 0;
-				continue;
-			}
-			/* if cblk not yet included --> zero-bitplane tagtree */
-			if (!cblk->numsegs) {
-				int i, numimsbs;
-				for (i = 0; !tgt_decode(bio, prc->imsbtree, cblkno, i); i++) {
-					;
-				}
-				numimsbs = i - 1;
-				cblk->numbps = band->numbps - numimsbs;
-				cblk->numlenbits = 3;
-			}
-			/* number of coding passes */
-			cblk->numnewpasses = t2_getnumpasses(bio);
-			increment = t2_getcommacode(bio);
-			/* length indicator increment */
-			cblk->numlenbits += increment;
-			segno = 0;
-			if (!cblk->numsegs) {
-				t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1);
-			} else {
-				segno = cblk->numsegs - 1;
-				if (cblk->segs[segno].numpasses == cblk->segs[segno].maxpasses) {
-					++segno;
-					t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
-				}
-			}
-			n = cblk->numnewpasses;
-			
-			do {
-				cblk->segs[segno].numnewpasses = int_min(cblk->segs[segno].maxpasses - cblk->segs[segno].numpasses, n);
-				cblk->segs[segno].newlen = bio_read(bio, cblk->numlenbits + int_floorlog2(cblk->segs[segno].numnewpasses));
-				n -= cblk->segs[segno].numnewpasses;
-				if (n > 0) {
-					++segno;
-					t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
-				}
-			} while (n > 0);
-		}
-	}
-	
-	if (bio_inalign(bio)) {
-		bio_destroy(bio);
-		return -999;
-	}
-	
-	hd += bio_numbytes(bio);
-	bio_destroy(bio);
-	
-	/* EPH markers */
-	if (tcp->csty & J2K_CP_CSTY_EPH) {
-		if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
-			opj_event_msg(t2->cinfo, EVT_ERROR, "Expected EPH marker\n");
-			return -999;
-		} else {
-			hd += 2;
-		}
-	}
-
-	/* << INDEX */
-	// End of packet header position. Currently only represents the distance to start of packet
-	// Will be updated later by incrementing with packet start value
-	if(pack_info) {
-		pack_info->end_ph_pos = (int)(hd - src);
-	}
-	/* INDEX >> */
-	
-	if (cp->ppm==1) {
-		cp->ppm_len+=cp->ppm_data-hd;
-		cp->ppm_data = hd;
-	} else if (tcp->ppt == 1) {
-		tcp->ppt_len+=tcp->ppt_data-hd;
-		tcp->ppt_data = hd;
-	} else {
-		c=hd;
-	}
-	
-	for (bandno = 0; bandno < res->numbands; bandno++) {
-		opj_tcd_band_t *band = &res->bands[bandno];
-		opj_tcd_precinct_t *prc = &band->precincts[precno];
-		
-		if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
-		
-		for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-			opj_tcd_cblk_dec_t* cblk = &prc->cblks.dec[cblkno];
-			opj_tcd_seg_t *seg = NULL;
-			if (!cblk->numnewpasses)
-				continue;
-			if (!cblk->numsegs) {
-				seg = &cblk->segs[0];
-				cblk->numsegs++;
-				cblk->len = 0;
-			} else {
-				seg = &cblk->segs[cblk->numsegs - 1];
-				if (seg->numpasses == seg->maxpasses) {
-					seg++;
-					cblk->numsegs++;
-				}
-			}
-			
-			do {
-				if (c + seg->newlen > src + len) {
-					return -999;
-				}
-
-#ifdef USE_JPWL
-			/* we need here a j2k handle to verify if making a check to
-			the validity of cblocks parameters is selected from user (-W) */
-
-				/* let's check that we are not exceeding */
-				if ((cblk->len + seg->newlen) > 8192) {
-					opj_event_msg(t2->cinfo, EVT_WARNING,
-						"JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
-						seg->newlen, cblkno, precno, bandno, resno, compno);
-					if (!JPWL_ASSUME) {
-						opj_event_msg(t2->cinfo, EVT_ERROR, "JPWL: giving up\n");
-						return -999;
-					}
-					seg->newlen = 8192 - cblk->len;
-					opj_event_msg(t2->cinfo, EVT_WARNING, "      - truncating segment to %d\n", seg->newlen);
-					break;
-				};
-
-#endif /* USE_JPWL */
-				
-				cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char*));
-				memcpy(cblk->data + cblk->len, c, seg->newlen);
-				if (seg->numpasses == 0) {
-					seg->data = &cblk->data;
-					seg->dataindex = cblk->len;
-				}
-				c += seg->newlen;
-				cblk->len += seg->newlen;
-				seg->len += seg->newlen;
-				seg->numpasses += seg->numnewpasses;
-				cblk->numnewpasses -= seg->numnewpasses;
-				if (cblk->numnewpasses > 0) {
-					seg++;
-					cblk->numsegs++;
-				}
-			} while (cblk->numnewpasses > 0);
-		}
-	}
-	
-	return (c - src);
-}
-
-/* ----------------------------------------------------------------------- */
-
-int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_codestream_info_t *cstr_info,int tpnum, int tppos,int pino, J2K_T2_MODE t2_mode, int cur_totnum_tp){
-	unsigned char *c = dest;
-	int e = 0;
-	int compno;
-	opj_pi_iterator_t *pi = NULL;
-	int poc;
-	opj_image_t *image = t2->image;
-	opj_cp_t *cp = t2->cp;
-	opj_tcp_t *tcp = &cp->tcps[tileno];
-	int pocno = cp->cinema == CINEMA4K_24? 2: 1;
-	int maxcomp = cp->max_comp_size > 0 ? image->numcomps : 1;
-	
-	pi = pi_initialise_encode(image, cp, tileno, t2_mode);
-	if(!pi) {
-		/* TODO: throw an error */
-		return -999;
-	}
-	
-	if(t2_mode == THRESH_CALC ){ /* Calculating threshold */
-		for(compno = 0; compno < maxcomp; compno++ ){
-			for(poc = 0; poc < pocno ; poc++){
-				int comp_len = 0;
-				int tpnum = compno;
-				if (pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode,cur_totnum_tp)) {
-					opj_event_msg(t2->cinfo, EVT_ERROR, "Error initializing Packet Iterator\n");
-					pi_destroy(pi, cp, tileno);
-					return -999;
-				}
-				while (pi_next(&pi[poc])) {
-					if (pi[poc].layno < maxlayers) {
-						e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[poc], c, dest + len - c, cstr_info, tileno);
-						comp_len = comp_len + e;
-						if (e == -999) {
-							break;
-						} else {
-							c += e;
-						}
-					}
-				}
-				if (e == -999) break;
-				if (cp->max_comp_size){
-					if (comp_len > cp->max_comp_size){
-						e = -999;
-						break;
-					}
-				}
-			}
-			if (e == -999)  break;
-		}
-	}else{  /* t2_mode == FINAL_PASS  */
-		pi_create_encode(pi, cp,tileno,pino,tpnum,tppos,t2_mode,cur_totnum_tp);
-		while (pi_next(&pi[pino])) {
-			if (pi[pino].layno < maxlayers) {
-				e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[pino], c, dest + len - c, cstr_info, tileno);
-				if (e == -999) {
-					break;
-				} else {
-					c += e;
-				}
-				/* INDEX >> */
-				if(cstr_info) {
-					if(cstr_info->index_write) {
-						opj_tile_info_t *info_TL = &cstr_info->tile[tileno];
-						opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
-						if (!cstr_info->packno) {
-							info_PK->start_pos = info_TL->end_header + 1;
-						} else {
-							info_PK->start_pos = ((cp->tp_on | tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
-						}
-						info_PK->end_pos = info_PK->start_pos + e - 1;
-						info_PK->end_ph_pos += info_PK->start_pos - 1;	// End of packet header which now only represents the distance 
-																														// to start of packet is incremented by value of start of packet
-					}
-					
-					cstr_info->packno++;
-				}
-				/* << INDEX */
-				tile->packno++;
-			}
-		}
-	}
-	
-	pi_destroy(pi, cp, tileno);
-	
-	if (e == -999) {
-		return e;
-	}
-	
-  return (c - dest);
-}
-
-int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile, opj_codestream_info_t *cstr_info) {
-	unsigned char *c = src;
-	opj_pi_iterator_t *pi;
-	int pino, e = 0;
-	int n = 0, curtp = 0;
-	int tp_start_packno;
-
-	opj_image_t *image = t2->image;
-	opj_cp_t *cp = t2->cp;
-	
-	/* create a packet iterator */
-	pi = pi_create_decode(image, cp, tileno);
-	if(!pi) {
-		/* TODO: throw an error */
-		return -999;
-	}
-
-	tp_start_packno = 0;
-	
-	for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
-		while (pi_next(&pi[pino])) {
-			if ((cp->layer==0) || (cp->layer>=((pi[pino].layno)+1))) {
-				opj_packet_info_t *pack_info;
-				if (cstr_info)
-					pack_info = &cstr_info->tile[tileno].packet[cstr_info->packno];
-				else
-					pack_info = NULL;
-				e = t2_decode_packet(t2, c, src + len - c, tile, &cp->tcps[tileno], &pi[pino], pack_info);
-			} else {
-				e = 0;
-			}
-			if(e == -999)
-			{
-			pi_destroy(pi, cp, tileno);
-			return -999;
-			}
-			/* progression in resolution */
-			image->comps[pi[pino].compno].resno_decoded =	
-				(e > 0) ? 
-				int_max(pi[pino].resno, image->comps[pi[pino].compno].resno_decoded) 
-				: image->comps[pi[pino].compno].resno_decoded;
-			n++;
-
-			/* INDEX >> */
-			if(cstr_info) {
-				opj_tile_info_t *info_TL = &cstr_info->tile[tileno];
-				opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
-				if (!cstr_info->packno) {
-					info_PK->start_pos = info_TL->end_header + 1;
-				} else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ // New tile part
-					info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in previous tile-part
-					tp_start_packno = cstr_info->packno;
-					curtp++;
-					info_PK->start_pos = cstr_info->tile[tileno].tp[curtp].tp_end_header+1;
-				} else {
-					info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
-				}
-				info_PK->end_pos = info_PK->start_pos + e - 1;
-				info_PK->end_ph_pos += info_PK->start_pos - 1;	// End of packet header which now only represents the distance 
-																												// to start of packet is incremented by value of start of packet
-				cstr_info->packno++;
-			}
-			/* << INDEX */
-			
-			if (e == -999) {		/* ADD */
-				break;
-			} else {
-				c += e;
-			}			
-		}
-	}
-	/* INDEX >> */
-	if(cstr_info) {
-		cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in last tile-part
-	}
-	/* << INDEX */
-
-	/* don't forget to release pi */
-	pi_destroy(pi, cp, tileno);
-	
-	if (e == -999) {
-		return e;
-	}
-	
-	return (c - src);
-}
-
-/* ----------------------------------------------------------------------- */
-
-opj_t2_t* t2_create(opj_common_ptr cinfo, opj_image_t *image, opj_cp_t *cp) {
-	/* create the tcd structure */
-	opj_t2_t *t2 = (opj_t2_t*)opj_malloc(sizeof(opj_t2_t));
-	if(!t2) return NULL;
-	t2->cinfo = cinfo;
-	t2->image = image;
-	t2->cp = cp;
-
-	return t2;
-}
-
-void t2_destroy(opj_t2_t *t2) {
-	if(t2) {
-		opj_free(t2);
-	}
-}
-
-
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.c
deleted file mode 100644
index 7f154f4..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.c
+++ /dev/null
@@ -1,1516 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
-	int tileno, compno, resno, bandno, precno;//, cblkno;
-
-	fprintf(fd, "image {\n");
-	fprintf(fd, "  tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", 
-		img->tw, img->th, tcd->image->x0, tcd->image->x1, tcd->image->y0, tcd->image->y1);
-
-	for (tileno = 0; tileno < img->th * img->tw; tileno++) {
-		opj_tcd_tile_t *tile = &tcd->tcd_image->tiles[tileno];
-		fprintf(fd, "  tile {\n");
-		fprintf(fd, "    x0=%d, y0=%d, x1=%d, y1=%d, numcomps=%d\n",
-			tile->x0, tile->y0, tile->x1, tile->y1, tile->numcomps);
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-			fprintf(fd, "    tilec {\n");
-			fprintf(fd,
-				"      x0=%d, y0=%d, x1=%d, y1=%d, numresolutions=%d\n",
-				tilec->x0, tilec->y0, tilec->x1, tilec->y1, tilec->numresolutions);
-			for (resno = 0; resno < tilec->numresolutions; resno++) {
-				opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-				fprintf(fd, "\n   res {\n");
-				fprintf(fd,
-					"          x0=%d, y0=%d, x1=%d, y1=%d, pw=%d, ph=%d, numbands=%d\n",
-					res->x0, res->y0, res->x1, res->y1, res->pw, res->ph, res->numbands);
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					opj_tcd_band_t *band = &res->bands[bandno];
-					fprintf(fd, "        band {\n");
-					fprintf(fd,
-						"          x0=%d, y0=%d, x1=%d, y1=%d, stepsize=%f, numbps=%d\n",
-						band->x0, band->y0, band->x1, band->y1, band->stepsize, band->numbps);
-					for (precno = 0; precno < res->pw * res->ph; precno++) {
-						opj_tcd_precinct_t *prec = &band->precincts[precno];
-						fprintf(fd, "          prec {\n");
-						fprintf(fd,
-							"            x0=%d, y0=%d, x1=%d, y1=%d, cw=%d, ch=%d\n",
-							prec->x0, prec->y0, prec->x1, prec->y1, prec->cw, prec->ch);
-						/*
-						for (cblkno = 0; cblkno < prec->cw * prec->ch; cblkno++) {
-							opj_tcd_cblk_t *cblk = &prec->cblks[cblkno];
-							fprintf(fd, "            cblk {\n");
-							fprintf(fd,
-								"              x0=%d, y0=%d, x1=%d, y1=%d\n",
-								cblk->x0, cblk->y0, cblk->x1, cblk->y1);
-							fprintf(fd, "            }\n");
-						}
-						*/
-						fprintf(fd, "          }\n");
-					}
-					fprintf(fd, "        }\n");
-				}
-				fprintf(fd, "      }\n");
-			}
-			fprintf(fd, "    }\n");
-		}
-		fprintf(fd, "  }\n");
-	}
-	fprintf(fd, "}\n");
-}
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Create a new TCD handle
-*/
-opj_tcd_t* tcd_create(opj_common_ptr cinfo) {
-	/* create the tcd structure */
-	opj_tcd_t *tcd = (opj_tcd_t*)opj_malloc(sizeof(opj_tcd_t));
-	if(!tcd) return NULL;
-	tcd->cinfo = cinfo;
-	tcd->tcd_image = (opj_tcd_image_t*)opj_malloc(sizeof(opj_tcd_image_t));
-	if(!tcd->tcd_image) {
-		opj_free(tcd);
-		return NULL;
-	}
-
-	return tcd;
-}
-
-/**
-Destroy a previously created TCD handle
-*/
-void tcd_destroy(opj_tcd_t *tcd) {
-	if(tcd) {
-		opj_free(tcd->tcd_image);
-		opj_free(tcd);
-	}
-}
-
-/* ----------------------------------------------------------------------- */
-
-void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int curtileno) {
-	int tileno, compno, resno, bandno, precno, cblkno;
-
-	tcd->image = image;
-	tcd->cp = cp;
-	tcd->tcd_image->tw = cp->tw;
-	tcd->tcd_image->th = cp->th;
-	tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(sizeof(opj_tcd_tile_t));
-	
-	for (tileno = 0; tileno < 1; tileno++) {
-		opj_tcp_t *tcp = &cp->tcps[curtileno];
-		int j;
-
-		/* cfr p59 ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */
-		int p = curtileno % cp->tw;	/* si numerotation matricielle .. */
-		int q = curtileno / cp->tw;	/* .. coordonnees de la tile (q,p) q pour ligne et p pour colonne */
-
-		/* opj_tcd_tile_t *tile=&tcd->tcd_image->tiles[tileno]; */
-		opj_tcd_tile_t *tile = tcd->tcd_image->tiles;
-
-		/* 4 borders of the tile rescale on the image if necessary */
-		tile->x0 = int_max(cp->tx0 + p * cp->tdx, image->x0);
-		tile->y0 = int_max(cp->ty0 + q * cp->tdy, image->y0);
-		tile->x1 = int_min(cp->tx0 + (p + 1) * cp->tdx, image->x1);
-		tile->y1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
-		tile->numcomps = image->numcomps;
-		/* tile->PPT=image->PPT;  */
-
-		/* Modification of the RATE >> */
-		for (j = 0; j < tcp->numlayers; j++) {
-			tcp->rates[j] = tcp->rates[j] ? 
-				cp->tp_on ? 
-					(((float) (tile->numcomps 
-					* (tile->x1 - tile->x0) 
-					* (tile->y1 - tile->y0)
-					* image->comps[0].prec))
-					/(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)) - (((tcd->cur_totnum_tp - 1) * 14 )/ tcp->numlayers)
-					:
-				((float) (tile->numcomps 
-					* (tile->x1 - tile->x0) 
-					* (tile->y1 - tile->y0) 
-					* image->comps[0].prec))/ 
-					(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)
-					: 0;
-
-			if (tcp->rates[j]) {
-				if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
-					tcp->rates[j] = tcp->rates[j - 1] + 20;
-				} else {
-					if (!j && tcp->rates[j] < 30)
-						tcp->rates[j] = 30;
-				}
-				
-				if(j == (tcp->numlayers-1)){
-					tcp->rates[j] = tcp->rates[j]- 2;
-				}
-			}
-		}
-		/* << Modification of the RATE */
-		
-		tile->comps = (opj_tcd_tilecomp_t *) opj_malloc(image->numcomps * sizeof(opj_tcd_tilecomp_t));
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tccp_t *tccp = &tcp->tccps[compno];
-
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-
-			/* border of each tile component (global) */
-			tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
-			tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);
-			tilec->x1 = int_ceildiv(tile->x1, image->comps[compno].dx);
-			tilec->y1 = int_ceildiv(tile->y1, image->comps[compno].dy);
-			
-			tilec->data = (int *) opj_aligned_malloc((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0) * sizeof(int));
-			tilec->numresolutions = tccp->numresolutions;
-
-			tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(tilec->numresolutions * sizeof(opj_tcd_resolution_t));
-			
-			for (resno = 0; resno < tilec->numresolutions; resno++) {
-				int pdx, pdy;
-				int levelno = tilec->numresolutions - 1 - resno;
-				int tlprcxstart, tlprcystart, brprcxend, brprcyend;
-				int tlcbgxstart, tlcbgystart, brcbgxend, brcbgyend;
-				int cbgwidthexpn, cbgheightexpn;
-				int cblkwidthexpn, cblkheightexpn;
-
-				opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-				
-				/* border for each resolution level (global) */
-				res->x0 = int_ceildivpow2(tilec->x0, levelno);
-				res->y0 = int_ceildivpow2(tilec->y0, levelno);
-				res->x1 = int_ceildivpow2(tilec->x1, levelno);
-				res->y1 = int_ceildivpow2(tilec->y1, levelno);
-				
-				res->numbands = resno == 0 ? 1 : 3;
-				/* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */
-				if (tccp->csty & J2K_CCP_CSTY_PRT) {
-					pdx = tccp->prcw[resno];
-					pdy = tccp->prch[resno];
-				} else {
-					pdx = 15;
-					pdy = 15;
-				}
-				/* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000)  */
-				tlprcxstart = int_floordivpow2(res->x0, pdx) << pdx;
-				tlprcystart = int_floordivpow2(res->y0, pdy) << pdy;
-				
-				brprcxend = int_ceildivpow2(res->x1, pdx) << pdx;
-				brprcyend = int_ceildivpow2(res->y1, pdy) << pdy;
-				
-				res->pw = (brprcxend - tlprcxstart) >> pdx;
-				res->ph = (brprcyend - tlprcystart) >> pdy;
-				
-				if (resno == 0) {
-					tlcbgxstart = tlprcxstart;
-					tlcbgystart = tlprcystart;
-					brcbgxend = brprcxend;
-					brcbgyend = brprcyend;
-					cbgwidthexpn = pdx;
-					cbgheightexpn = pdy;
-				} else {
-					tlcbgxstart = int_ceildivpow2(tlprcxstart, 1);
-					tlcbgystart = int_ceildivpow2(tlprcystart, 1);
-					brcbgxend = int_ceildivpow2(brprcxend, 1);
-					brcbgyend = int_ceildivpow2(brprcyend, 1);
-					cbgwidthexpn = pdx - 1;
-					cbgheightexpn = pdy - 1;
-				}
-				
-				cblkwidthexpn = int_min(tccp->cblkw, cbgwidthexpn);
-				cblkheightexpn = int_min(tccp->cblkh, cbgheightexpn);
-				
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					int x0b, y0b, i;
-					int gain, numbps;
-					opj_stepsize_t *ss = NULL;
-
-					opj_tcd_band_t *band = &res->bands[bandno];
-
-					band->bandno = resno == 0 ? 0 : bandno + 1;
-					x0b = (band->bandno == 1) || (band->bandno == 3) ? 1 : 0;
-					y0b = (band->bandno == 2) || (band->bandno == 3) ? 1 : 0;
-					
-					if (band->bandno == 0) {
-						/* band border (global) */
-						band->x0 = int_ceildivpow2(tilec->x0, levelno);
-						band->y0 = int_ceildivpow2(tilec->y0, levelno);
-						band->x1 = int_ceildivpow2(tilec->x1, levelno);
-						band->y1 = int_ceildivpow2(tilec->y1, levelno);
-					} else {
-						/* band border (global) */
-						band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelno) * x0b, levelno + 1);
-						band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelno) * y0b, levelno + 1);
-						band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelno) * x0b, levelno + 1);
-						band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelno) * y0b, levelno + 1);
-					}
-					
-					ss = &tccp->stepsizes[resno == 0 ? 0 : 3 * (resno - 1) + bandno + 1];
-					gain = tccp->qmfbid == 0 ? dwt_getgain_real(band->bandno) : dwt_getgain(band->bandno);					
-					numbps = image->comps[compno].prec + gain;
-					
-					band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
-					band->numbps = ss->expn + tccp->numgbits - 1;	/* WHY -1 ? */
-					
-					band->precincts = (opj_tcd_precinct_t *) opj_malloc(3 * res->pw * res->ph * sizeof(opj_tcd_precinct_t));
-					
-					for (i = 0; i < res->pw * res->ph * 3; i++) {
-						band->precincts[i].imsbtree = NULL;
-						band->precincts[i].incltree = NULL;
-					}
-					
-					for (precno = 0; precno < res->pw * res->ph; precno++) {
-						int tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;
-
-						int cbgxstart = tlcbgxstart + (precno % res->pw) * (1 << cbgwidthexpn);
-						int cbgystart = tlcbgystart + (precno / res->pw) * (1 << cbgheightexpn);
-						int cbgxend = cbgxstart + (1 << cbgwidthexpn);
-						int cbgyend = cbgystart + (1 << cbgheightexpn);
-
-						opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-						/* precinct size (global) */
-						prc->x0 = int_max(cbgxstart, band->x0);
-						prc->y0 = int_max(cbgystart, band->y0);
-						prc->x1 = int_min(cbgxend, band->x1);
-						prc->y1 = int_min(cbgyend, band->y1);
-
-						tlcblkxstart = int_floordivpow2(prc->x0, cblkwidthexpn) << cblkwidthexpn;
-						tlcblkystart = int_floordivpow2(prc->y0, cblkheightexpn) << cblkheightexpn;
-						brcblkxend = int_ceildivpow2(prc->x1, cblkwidthexpn) << cblkwidthexpn;
-						brcblkyend = int_ceildivpow2(prc->y1, cblkheightexpn) << cblkheightexpn;
-						prc->cw = (brcblkxend - tlcblkxstart) >> cblkwidthexpn;
-						prc->ch = (brcblkyend - tlcblkystart) >> cblkheightexpn;
-
-						prc->cblks.enc = (opj_tcd_cblk_enc_t*) opj_calloc((prc->cw * prc->ch), sizeof(opj_tcd_cblk_enc_t));
-						prc->incltree = tgt_create(prc->cw, prc->ch);
-						prc->imsbtree = tgt_create(prc->cw, prc->ch);
-						
-						for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-							int cblkxstart = tlcblkxstart + (cblkno % prc->cw) * (1 << cblkwidthexpn);
-							int cblkystart = tlcblkystart + (cblkno / prc->cw) * (1 << cblkheightexpn);
-							int cblkxend = cblkxstart + (1 << cblkwidthexpn);
-							int cblkyend = cblkystart + (1 << cblkheightexpn);
-							
-							opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-
-							/* code-block size (global) */
-							cblk->x0 = int_max(cblkxstart, prc->x0);
-							cblk->y0 = int_max(cblkystart, prc->y0);
-							cblk->x1 = int_min(cblkxend, prc->x1);
-							cblk->y1 = int_min(cblkyend, prc->y1);
-							cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
-							/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
-							cblk->data += 2;
-							cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
-							cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	/* tcd_dump(stdout, tcd, &tcd->tcd_image); */
-}
-
-void tcd_free_encode(opj_tcd_t *tcd) {
-	int tileno, compno, resno, bandno, precno, cblkno;
-
-	for (tileno = 0; tileno < 1; tileno++) {
-		opj_tcd_tile_t *tile = tcd->tcd_image->tiles;
-
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-
-			for (resno = 0; resno < tilec->numresolutions; resno++) {
-				opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					opj_tcd_band_t *band = &res->bands[bandno];
-
-					for (precno = 0; precno < res->pw * res->ph; precno++) {
-						opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-						if (prc->incltree != NULL) {
-							tgt_destroy(prc->incltree);
-							prc->incltree = NULL;
-						}
-						if (prc->imsbtree != NULL) {
-							tgt_destroy(prc->imsbtree);	
-							prc->imsbtree = NULL;
-						}
-						for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-							opj_free(prc->cblks.enc[cblkno].data - 2);
-							opj_free(prc->cblks.enc[cblkno].layers);
-							opj_free(prc->cblks.enc[cblkno].passes);
-						}
-						opj_free(prc->cblks.enc);
-					} /* for (precno */
-					opj_free(band->precincts);
-					band->precincts = NULL;
-				} /* for (bandno */
-			} /* for (resno */
-			opj_free(tilec->resolutions);
-			tilec->resolutions = NULL;
-		} /* for (compno */
-		opj_free(tile->comps);
-		tile->comps = NULL;
-	} /* for (tileno */
-	opj_free(tcd->tcd_image->tiles);
-	tcd->tcd_image->tiles = NULL;
-}
-
-void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int curtileno) {
-	int tileno, compno, resno, bandno, precno, cblkno;
-
-	for (tileno = 0; tileno < 1; tileno++) {
-		opj_tcp_t *tcp = &cp->tcps[curtileno];
-		int j;
-		/* cfr p59 ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */
-		int p = curtileno % cp->tw;
-		int q = curtileno / cp->tw;
-
-		opj_tcd_tile_t *tile = tcd->tcd_image->tiles;
-		
-		/* 4 borders of the tile rescale on the image if necessary */
-		tile->x0 = int_max(cp->tx0 + p * cp->tdx, image->x0);
-		tile->y0 = int_max(cp->ty0 + q * cp->tdy, image->y0);
-		tile->x1 = int_min(cp->tx0 + (p + 1) * cp->tdx, image->x1);
-		tile->y1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
-		
-		tile->numcomps = image->numcomps;
-		/* tile->PPT=image->PPT; */
-
-		/* Modification of the RATE >> */
-		for (j = 0; j < tcp->numlayers; j++) {
-			tcp->rates[j] = tcp->rates[j] ? 
-				cp->tp_on ? 
-					(((float) (tile->numcomps 
-					* (tile->x1 - tile->x0) 
-					* (tile->y1 - tile->y0)
-					* image->comps[0].prec))
-					/(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)) - (((tcd->cur_totnum_tp - 1) * 14 )/ tcp->numlayers)
-					:
-				((float) (tile->numcomps 
-					* (tile->x1 - tile->x0) 
-					* (tile->y1 - tile->y0) 
-					* image->comps[0].prec))/ 
-					(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)
-					: 0;
-
-			if (tcp->rates[j]) {
-				if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
-					tcp->rates[j] = tcp->rates[j - 1] + 20;
-				} else {
-					if (!j && tcp->rates[j] < 30)
-						tcp->rates[j] = 30;
-				}
-			}
-		}
-		/* << Modification of the RATE */
-
-		/* tile->comps=(opj_tcd_tilecomp_t*)opj_realloc(tile->comps,image->numcomps*sizeof(opj_tcd_tilecomp_t)); */
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tccp_t *tccp = &tcp->tccps[compno];
-			
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-
-			/* border of each tile component (global) */
-			tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
-			tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);
-			tilec->x1 = int_ceildiv(tile->x1, image->comps[compno].dx);
-			tilec->y1 = int_ceildiv(tile->y1, image->comps[compno].dy);
-			
-			tilec->data = (int *) opj_aligned_malloc((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0) * sizeof(int));
-			tilec->numresolutions = tccp->numresolutions;
-			/* tilec->resolutions=(opj_tcd_resolution_t*)opj_realloc(tilec->resolutions,tilec->numresolutions*sizeof(opj_tcd_resolution_t)); */
-			for (resno = 0; resno < tilec->numresolutions; resno++) {
-				int pdx, pdy;
-
-				int levelno = tilec->numresolutions - 1 - resno;
-				int tlprcxstart, tlprcystart, brprcxend, brprcyend;
-				int tlcbgxstart, tlcbgystart, brcbgxend, brcbgyend;
-				int cbgwidthexpn, cbgheightexpn;
-				int cblkwidthexpn, cblkheightexpn;
-				
-				opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-				/* border for each resolution level (global) */
-				res->x0 = int_ceildivpow2(tilec->x0, levelno);
-				res->y0 = int_ceildivpow2(tilec->y0, levelno);
-				res->x1 = int_ceildivpow2(tilec->x1, levelno);
-				res->y1 = int_ceildivpow2(tilec->y1, levelno);	
-				res->numbands = resno == 0 ? 1 : 3;
-
-				/* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */
-				if (tccp->csty & J2K_CCP_CSTY_PRT) {
-					pdx = tccp->prcw[resno];
-					pdy = tccp->prch[resno];
-				} else {
-					pdx = 15;
-					pdy = 15;
-				}
-				/* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000)  */
-				tlprcxstart = int_floordivpow2(res->x0, pdx) << pdx;
-				tlprcystart = int_floordivpow2(res->y0, pdy) << pdy;
-				brprcxend = int_ceildivpow2(res->x1, pdx) << pdx;
-				brprcyend = int_ceildivpow2(res->y1, pdy) << pdy;
-				
-				res->pw = (brprcxend - tlprcxstart) >> pdx;
-				res->ph = (brprcyend - tlprcystart) >> pdy;
-				
-				if (resno == 0) {
-					tlcbgxstart = tlprcxstart;
-					tlcbgystart = tlprcystart;
-					brcbgxend = brprcxend;
-					brcbgyend = brprcyend;
-					cbgwidthexpn = pdx;
-					cbgheightexpn = pdy;
-				} else {
-					tlcbgxstart = int_ceildivpow2(tlprcxstart, 1);
-					tlcbgystart = int_ceildivpow2(tlprcystart, 1);
-					brcbgxend = int_ceildivpow2(brprcxend, 1);
-					brcbgyend = int_ceildivpow2(brprcyend, 1);
-					cbgwidthexpn = pdx - 1;
-					cbgheightexpn = pdy - 1;
-				}
-				
-				cblkwidthexpn = int_min(tccp->cblkw, cbgwidthexpn);
-				cblkheightexpn = int_min(tccp->cblkh, cbgheightexpn);
-				
-				for (bandno = 0; bandno < res->numbands; bandno++) {
-					int x0b, y0b;
-					int gain, numbps;
-					opj_stepsize_t *ss = NULL;
-
-					opj_tcd_band_t *band = &res->bands[bandno];
-
-					band->bandno = resno == 0 ? 0 : bandno + 1;
-					x0b = (band->bandno == 1) || (band->bandno == 3) ? 1 : 0;
-					y0b = (band->bandno == 2) || (band->bandno == 3) ? 1 : 0;
-					
-					if (band->bandno == 0) {
-						/* band border */
-						band->x0 = int_ceildivpow2(tilec->x0, levelno);
-						band->y0 = int_ceildivpow2(tilec->y0, levelno);
-						band->x1 = int_ceildivpow2(tilec->x1, levelno);
-						band->y1 = int_ceildivpow2(tilec->y1, levelno);
-					} else {
-						band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelno) * x0b, levelno + 1);
-						band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelno) * y0b, levelno + 1);
-						band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelno) * x0b, levelno + 1);
-						band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelno) * y0b, levelno + 1);
-					}
-					
-					ss = &tccp->stepsizes[resno == 0 ? 0 : 3 * (resno - 1) + bandno + 1];
-					gain = tccp->qmfbid == 0 ? dwt_getgain_real(band->bandno) : dwt_getgain(band->bandno);
-					numbps = image->comps[compno].prec + gain;
-					band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
-					band->numbps = ss->expn + tccp->numgbits - 1;	/* WHY -1 ? */
-					
-					for (precno = 0; precno < res->pw * res->ph; precno++) {
-						int tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;
-
-						int cbgxstart = tlcbgxstart + (precno % res->pw) * (1 << cbgwidthexpn);
-						int cbgystart = tlcbgystart + (precno / res->pw) * (1 << cbgheightexpn);
-						int cbgxend = cbgxstart + (1 << cbgwidthexpn);
-						int cbgyend = cbgystart + (1 << cbgheightexpn);
-						
-						opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-						/* precinct size (global) */
-						prc->x0 = int_max(cbgxstart, band->x0);
-						prc->y0 = int_max(cbgystart, band->y0);
-						prc->x1 = int_min(cbgxend, band->x1);
-						prc->y1 = int_min(cbgyend, band->y1);
-
-						tlcblkxstart = int_floordivpow2(prc->x0, cblkwidthexpn) << cblkwidthexpn;
-						tlcblkystart = int_floordivpow2(prc->y0, cblkheightexpn) << cblkheightexpn;
-						brcblkxend = int_ceildivpow2(prc->x1, cblkwidthexpn) << cblkwidthexpn;
-						brcblkyend = int_ceildivpow2(prc->y1, cblkheightexpn) << cblkheightexpn;
-						prc->cw = (brcblkxend - tlcblkxstart) >> cblkwidthexpn;
-						prc->ch = (brcblkyend - tlcblkystart) >> cblkheightexpn;
-
-						opj_free(prc->cblks.enc);
-						prc->cblks.enc = (opj_tcd_cblk_enc_t*) opj_calloc(prc->cw * prc->ch, sizeof(opj_tcd_cblk_enc_t));
-
-						if (prc->incltree != NULL) {
-							tgt_destroy(prc->incltree);
-						}
-						if (prc->imsbtree != NULL) {
-							tgt_destroy(prc->imsbtree);
-						}
-						
-						prc->incltree = tgt_create(prc->cw, prc->ch);
-						prc->imsbtree = tgt_create(prc->cw, prc->ch);
-
-						for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-							int cblkxstart = tlcblkxstart + (cblkno % prc->cw) * (1 << cblkwidthexpn);
-							int cblkystart = tlcblkystart + (cblkno / prc->cw) * (1 << cblkheightexpn);
-							int cblkxend = cblkxstart + (1 << cblkwidthexpn);
-							int cblkyend = cblkystart + (1 << cblkheightexpn);
-
-							opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-
-							/* code-block size (global) */
-							cblk->x0 = int_max(cblkxstart, prc->x0);
-							cblk->y0 = int_max(cblkystart, prc->y0);
-							cblk->x1 = int_min(cblkxend, prc->x1);
-							cblk->y1 = int_min(cblkyend, prc->y1);
-							cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
-							/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
-							cblk->data += 2;
-							cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
-							cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
-						}
-					} /* precno */
-				} /* bandno */
-			} /* resno */
-		} /* compno */
-	} /* tileno */
-
-	/* tcd_dump(stdout, tcd, &tcd->tcd_image); */
-}
-
-void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) {
-	int i, j, tileno, p, q;
-	unsigned int x0 = 0, y0 = 0, x1 = 0, y1 = 0, w, h;
-
-	tcd->image = image;
-	tcd->tcd_image->tw = cp->tw;
-	tcd->tcd_image->th = cp->th;
-	tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(cp->tw * cp->th * sizeof(opj_tcd_tile_t));
-
-	/* 
-	Allocate place to store the decoded data = final image
-	Place limited by the tile really present in the codestream 
-	*/
-
-	for (j = 0; j < cp->tileno_size; j++) {
-		opj_tcd_tile_t *tile;
-		
-		tileno = cp->tileno[j];		
-		tile = &(tcd->tcd_image->tiles[cp->tileno[tileno]]);		
-		tile->numcomps = image->numcomps;
-		tile->comps = (opj_tcd_tilecomp_t*) opj_calloc(image->numcomps, sizeof(opj_tcd_tilecomp_t));
-	}
-
-	for (i = 0; i < image->numcomps; i++) {
-		for (j = 0; j < cp->tileno_size; j++) {
-			opj_tcd_tile_t *tile;
-			opj_tcd_tilecomp_t *tilec;
-			
-			/* cfr p59 ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */
-			
-			tileno = cp->tileno[j];
-			
-			tile = &(tcd->tcd_image->tiles[cp->tileno[tileno]]);
-			tilec = &tile->comps[i];
-			
-			p = tileno % cp->tw;	/* si numerotation matricielle .. */
-			q = tileno / cp->tw;	/* .. coordonnees de la tile (q,p) q pour ligne et p pour colonne */
-			
-			/* 4 borders of the tile rescale on the image if necessary */
-			tile->x0 = int_max(cp->tx0 + p * cp->tdx, image->x0);
-			tile->y0 = int_max(cp->ty0 + q * cp->tdy, image->y0);
-			tile->x1 = int_min(cp->tx0 + (p + 1) * cp->tdx, image->x1);
-			tile->y1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
-
-			tilec->x0 = int_ceildiv(tile->x0, image->comps[i].dx);
-			tilec->y0 = int_ceildiv(tile->y0, image->comps[i].dy);
-			tilec->x1 = int_ceildiv(tile->x1, image->comps[i].dx);
-			tilec->y1 = int_ceildiv(tile->y1, image->comps[i].dy);
-
-			x0 = j == 0 ? tilec->x0 : int_min(x0, (unsigned int) tilec->x0);
-			y0 = j == 0 ? tilec->y0 : int_min(y0,	(unsigned int) tilec->x0);
-			x1 = j == 0 ? tilec->x1 : int_max(x1,	(unsigned int) tilec->x1);
-			y1 = j == 0 ? tilec->y1 : int_max(y1,	(unsigned int) tilec->y1);
-		}
-
-		w = int_ceildivpow2(x1 - x0, image->comps[i].factor);
-		h = int_ceildivpow2(y1 - y0, image->comps[i].factor);
-
-		image->comps[i].w = w;
-		image->comps[i].h = h;
-		image->comps[i].x0 = x0;
-		image->comps[i].y0 = y0;
-	}
-}
-
-void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int tileno, opj_codestream_info_t *cstr_info) {
-	int compno, resno, bandno, precno, cblkno;
-	opj_tcp_t *tcp;
-	opj_tcd_tile_t *tile;
-
-	tcd->cp = cp;
-	
-	tcp = &(cp->tcps[cp->tileno[tileno]]);
-	tile = &(tcd->tcd_image->tiles[cp->tileno[tileno]]);
-	
-	tileno = cp->tileno[tileno];
-	
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tccp_t *tccp = &tcp->tccps[compno];
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-		
-		/* border of each tile component (global) */
-		tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
-		tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);
-		tilec->x1 = int_ceildiv(tile->x1, image->comps[compno].dx);
-		tilec->y1 = int_ceildiv(tile->y1, image->comps[compno].dy);
-
-		tilec->numresolutions = tccp->numresolutions;
-		tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(tilec->numresolutions * sizeof(opj_tcd_resolution_t));
-		
-		for (resno = 0; resno < tilec->numresolutions; resno++) {
-			int pdx, pdy;
-			int levelno = tilec->numresolutions - 1 - resno;
-			int tlprcxstart, tlprcystart, brprcxend, brprcyend;
-			int tlcbgxstart, tlcbgystart, brcbgxend, brcbgyend;
-			int cbgwidthexpn, cbgheightexpn;
-			int cblkwidthexpn, cblkheightexpn;
-			
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			
-			/* border for each resolution level (global) */
-			res->x0 = int_ceildivpow2(tilec->x0, levelno);
-			res->y0 = int_ceildivpow2(tilec->y0, levelno);
-			res->x1 = int_ceildivpow2(tilec->x1, levelno);
-			res->y1 = int_ceildivpow2(tilec->y1, levelno);
-			res->numbands = resno == 0 ? 1 : 3;
-			
-			/* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */
-			if (tccp->csty & J2K_CCP_CSTY_PRT) {
-				pdx = tccp->prcw[resno];
-				pdy = tccp->prch[resno];
-			} else {
-				pdx = 15;
-				pdy = 15;
-			}			
-			
-			/* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000)  */
-			tlprcxstart = int_floordivpow2(res->x0, pdx) << pdx;
-			tlprcystart = int_floordivpow2(res->y0, pdy) << pdy;
-			brprcxend = int_ceildivpow2(res->x1, pdx) << pdx;
-			brprcyend = int_ceildivpow2(res->y1, pdy) << pdy;
-			
-			res->pw = (res->x0 == res->x1) ? 0 : ((brprcxend - tlprcxstart) >> pdx);
-			res->ph = (res->y0 == res->y1) ? 0 : ((brprcyend - tlprcystart) >> pdy);
-			
-			if (resno == 0) {
-				tlcbgxstart = tlprcxstart;
-				tlcbgystart = tlprcystart;
-				brcbgxend = brprcxend;
-				brcbgyend = brprcyend;
-				cbgwidthexpn = pdx;
-				cbgheightexpn = pdy;
-			} else {
-				tlcbgxstart = int_ceildivpow2(tlprcxstart, 1);
-				tlcbgystart = int_ceildivpow2(tlprcystart, 1);
-				brcbgxend = int_ceildivpow2(brprcxend, 1);
-				brcbgyend = int_ceildivpow2(brprcyend, 1);
-				cbgwidthexpn = pdx - 1;
-				cbgheightexpn = pdy - 1;
-			}
-			
-			cblkwidthexpn = int_min(tccp->cblkw, cbgwidthexpn);
-			cblkheightexpn = int_min(tccp->cblkh, cbgheightexpn);
-			
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				int x0b, y0b;
-				int gain, numbps;
-				opj_stepsize_t *ss = NULL;
-				
-				opj_tcd_band_t *band = &res->bands[bandno];
-				band->bandno = resno == 0 ? 0 : bandno + 1;
-				x0b = (band->bandno == 1) || (band->bandno == 3) ? 1 : 0;
-				y0b = (band->bandno == 2) || (band->bandno == 3) ? 1 : 0;
-				
-				if (band->bandno == 0) {
-					/* band border (global) */
-					band->x0 = int_ceildivpow2(tilec->x0, levelno);
-					band->y0 = int_ceildivpow2(tilec->y0, levelno);
-					band->x1 = int_ceildivpow2(tilec->x1, levelno);
-					band->y1 = int_ceildivpow2(tilec->y1, levelno);
-				} else {
-					/* band border (global) */
-					band->x0 = int_ceildivpow2(tilec->x0 - (1 << levelno) * x0b, levelno + 1);
-					band->y0 = int_ceildivpow2(tilec->y0 - (1 << levelno) * y0b, levelno + 1);
-					band->x1 = int_ceildivpow2(tilec->x1 - (1 << levelno) * x0b, levelno + 1);
-					band->y1 = int_ceildivpow2(tilec->y1 - (1 << levelno) * y0b, levelno + 1);
-				}
-				
-				ss = &tccp->stepsizes[resno == 0 ? 0 : 3 * (resno - 1) + bandno + 1];
-				gain = tccp->qmfbid == 0 ? dwt_getgain_real(band->bandno) : dwt_getgain(band->bandno);
-				numbps = image->comps[compno].prec + gain;
-				band->stepsize = (float)(((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn)) * 0.5);
-				band->numbps = ss->expn + tccp->numgbits - 1;	/* WHY -1 ? */
-				
-				band->precincts = (opj_tcd_precinct_t *) opj_malloc(res->pw * res->ph * sizeof(opj_tcd_precinct_t));
-				
-				for (precno = 0; precno < res->pw * res->ph; precno++) {
-					int tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;
-					int cbgxstart = tlcbgxstart + (precno % res->pw) * (1 << cbgwidthexpn);
-					int cbgystart = tlcbgystart + (precno / res->pw) * (1 << cbgheightexpn);
-					int cbgxend = cbgxstart + (1 << cbgwidthexpn);
-					int cbgyend = cbgystart + (1 << cbgheightexpn);
-					
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-					/* precinct size (global) */
-					prc->x0 = int_max(cbgxstart, band->x0);
-					prc->y0 = int_max(cbgystart, band->y0);
-					prc->x1 = int_min(cbgxend, band->x1);
-					prc->y1 = int_min(cbgyend, band->y1);
-					
-					tlcblkxstart = int_floordivpow2(prc->x0, cblkwidthexpn) << cblkwidthexpn;
-					tlcblkystart = int_floordivpow2(prc->y0, cblkheightexpn) << cblkheightexpn;
-					brcblkxend = int_ceildivpow2(prc->x1, cblkwidthexpn) << cblkwidthexpn;
-					brcblkyend = int_ceildivpow2(prc->y1, cblkheightexpn) << cblkheightexpn;
-					prc->cw = (brcblkxend - tlcblkxstart) >> cblkwidthexpn;
-					prc->ch = (brcblkyend - tlcblkystart) >> cblkheightexpn;
-
-					prc->cblks.dec = (opj_tcd_cblk_dec_t*) opj_malloc(prc->cw * prc->ch * sizeof(opj_tcd_cblk_dec_t));
-
-					prc->incltree = tgt_create(prc->cw, prc->ch);
-					prc->imsbtree = tgt_create(prc->cw, prc->ch);
-					
-					for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-						int cblkxstart = tlcblkxstart + (cblkno % prc->cw) * (1 << cblkwidthexpn);
-						int cblkystart = tlcblkystart + (cblkno / prc->cw) * (1 << cblkheightexpn);
-						int cblkxend = cblkxstart + (1 << cblkwidthexpn);
-						int cblkyend = cblkystart + (1 << cblkheightexpn);					
-
-						opj_tcd_cblk_dec_t* cblk = &prc->cblks.dec[cblkno];
-						cblk->data = NULL;
-						cblk->segs = NULL;
-						/* code-block size (global) */
-						cblk->x0 = int_max(cblkxstart, prc->x0);
-						cblk->y0 = int_max(cblkystart, prc->y0);
-						cblk->x1 = int_min(cblkxend, prc->x1);
-						cblk->y1 = int_min(cblkyend, prc->y1);
-						cblk->numsegs = 0;
-					}
-				} /* precno */
-			} /* bandno */
-		} /* resno */
-	} /* compno */
-	/* tcd_dump(stdout, tcd, &tcd->tcd_image); */
-}
-
-void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final) {
-	int compno, resno, bandno, precno, cblkno;
-	int value;			/*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3]; */
-	int matrice[10][10][3];
-	int i, j, k;
-
-	opj_cp_t *cp = tcd->cp;
-	opj_tcd_tile_t *tcd_tile = tcd->tcd_tile;
-	opj_tcp_t *tcd_tcp = tcd->tcp;
-
-	/*matrice=(int*)opj_malloc(tcd_tcp->numlayers*tcd_tile->comps[0].numresolutions*3*sizeof(int)); */
-	
-	for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-		for (i = 0; i < tcd_tcp->numlayers; i++) {
-			for (j = 0; j < tilec->numresolutions; j++) {
-				for (k = 0; k < 3; k++) {
-					matrice[i][j][k] =
-						(int) (cp->matrice[i * tilec->numresolutions * 3 + j * 3 + k] 
-						* (float) (tcd->image->comps[compno].prec / 16.0));
-				}
-			}
-		}
-        
-		for (resno = 0; resno < tilec->numresolutions; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-				for (precno = 0; precno < res->pw * res->ph; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-					for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-						opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
-						opj_tcd_layer_t *layer = &cblk->layers[layno];
-						int n;
-						int imsb = tcd->image->comps[compno].prec - cblk->numbps;	/* number of bit-plan equal to zero */
-						/* Correction of the matrix of coefficient to include the IMSB information */
-						if (layno == 0) {
-							value = matrice[layno][resno][bandno];
-							if (imsb >= value) {
-								value = 0;
-							} else {
-								value -= imsb;
-							}
-						} else {
-							value =	matrice[layno][resno][bandno] -	matrice[layno - 1][resno][bandno];
-							if (imsb >= matrice[layno - 1][resno][bandno]) {
-								value -= (imsb - matrice[layno - 1][resno][bandno]);
-								if (value < 0) {
-									value = 0;
-								}
-							}
-						}
-						
-						if (layno == 0) {
-							cblk->numpassesinlayers = 0;
-						}
-						
-						n = cblk->numpassesinlayers;
-						if (cblk->numpassesinlayers == 0) {
-							if (value != 0) {
-								n = 3 * value - 2 + cblk->numpassesinlayers;
-							} else {
-								n = cblk->numpassesinlayers;
-							}
-						} else {
-							n = 3 * value + cblk->numpassesinlayers;
-						}
-						
-						layer->numpasses = n - cblk->numpassesinlayers;
-						
-						if (!layer->numpasses)
-							continue;
-						
-						if (cblk->numpassesinlayers == 0) {
-							layer->len = cblk->passes[n - 1].rate;
-							layer->data = cblk->data;
-						} else {
-							layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers - 1].rate;
-							layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
-						}
-						if (final)
-							cblk->numpassesinlayers = n;
-					}
-				}
-			}
-		}
-	}
-}
-
-void tcd_rateallocate_fixed(opj_tcd_t *tcd) {
-	int layno;
-	for (layno = 0; layno < tcd->tcp->numlayers; layno++) {
-		tcd_makelayer_fixed(tcd, layno, 1);
-	}
-}
-
-void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) {
-	int compno, resno, bandno, precno, cblkno, passno;
-	
-	opj_tcd_tile_t *tcd_tile = tcd->tcd_tile;
-
-	tcd_tile->distolayer[layno] = 0;	/* fixed_quality */
-	
-	for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-		for (resno = 0; resno < tilec->numresolutions; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-				for (precno = 0; precno < res->pw * res->ph; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-					for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-						opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
-						opj_tcd_layer_t *layer = &cblk->layers[layno];
-						
-						int n;
-						if (layno == 0) {
-							cblk->numpassesinlayers = 0;
-						}
-						n = cblk->numpassesinlayers;
-						for (passno = cblk->numpassesinlayers; passno < cblk->totalpasses; passno++) {
-							int dr;
-							double dd;
-							opj_tcd_pass_t *pass = &cblk->passes[passno];
-							if (n == 0) {
-								dr = pass->rate;
-								dd = pass->distortiondec;
-							} else {
-								dr = pass->rate - cblk->passes[n - 1].rate;
-								dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
-							}
-							if (!dr) {
-								if (dd != 0)
-									n = passno + 1;
-								continue;
-							}
-							if (dd / dr >= thresh)
-								n = passno + 1;
-						}
-						layer->numpasses = n - cblk->numpassesinlayers;
-						
-						if (!layer->numpasses) {
-							layer->disto = 0;
-							continue;
-						}
-						if (cblk->numpassesinlayers == 0) {
-							layer->len = cblk->passes[n - 1].rate;
-							layer->data = cblk->data;
-							layer->disto = cblk->passes[n - 1].distortiondec;
-						} else {
-							layer->len = cblk->passes[n - 1].rate -	cblk->passes[cblk->numpassesinlayers - 1].rate;
-							layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
-							layer->disto = cblk->passes[n - 1].distortiondec - cblk->passes[cblk->numpassesinlayers - 1].distortiondec;
-						}
-						
-						tcd_tile->distolayer[layno] += layer->disto;	/* fixed_quality */
-						
-						if (final)
-							cblk->numpassesinlayers = n;
-					}
-				}
-			}
-		}
-	}
-}
-
-bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
-	int compno, resno, bandno, precno, cblkno, passno, layno;
-	double min, max;
-	double cumdisto[100];	/* fixed_quality */
-	const double K = 1;		/* 1.1; fixed_quality */
-	double maxSE = 0;
-
-	opj_cp_t *cp = tcd->cp;
-	opj_tcd_tile_t *tcd_tile = tcd->tcd_tile;
-	opj_tcp_t *tcd_tcp = tcd->tcp;
-
-	min = DBL_MAX;
-	max = 0;
-	
-	tcd_tile->numpix = 0;		/* fixed_quality */
-	
-	for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-		tilec->numpix = 0;
-
-		for (resno = 0; resno < tilec->numresolutions; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-
-				for (precno = 0; precno < res->pw * res->ph; precno++) {
-					opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-					for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-						opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
-
-						for (passno = 0; passno < cblk->totalpasses; passno++) {
-							opj_tcd_pass_t *pass = &cblk->passes[passno];
-							int dr;
-							double dd, rdslope;
-							if (passno == 0) {
-								dr = pass->rate;
-								dd = pass->distortiondec;
-							} else {
-								dr = pass->rate - cblk->passes[passno - 1].rate;
-								dd = pass->distortiondec - cblk->passes[passno - 1].distortiondec;
-							}
-							if (dr == 0) {
-								continue;
-							}
-							rdslope = dd / dr;
-							if (rdslope < min) {
-								min = rdslope;
-							}
-							if (rdslope > max) {
-								max = rdslope;
-							}
-						} /* passno */
-						
-						/* fixed_quality */
-						tcd_tile->numpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0));
-						tilec->numpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0));
-					} /* cbklno */
-				} /* precno */
-			} /* bandno */
-		} /* resno */
-		
-		maxSE += (((double)(1 << tcd->image->comps[compno].prec) - 1.0) 
-			* ((double)(1 << tcd->image->comps[compno].prec) -1.0)) 
-			* ((double)(tilec->numpix));
-	} /* compno */
-	
-	/* index file */
-	if(cstr_info) {
-		opj_tile_info_t *tile_info = &cstr_info->tile[tcd->tcd_tileno];
-		tile_info->numpix = tcd_tile->numpix;
-		tile_info->distotile = tcd_tile->distotile;
-		tile_info->thresh = (double *) opj_malloc(tcd_tcp->numlayers * sizeof(double));
-	}
-	
-	for (layno = 0; layno < tcd_tcp->numlayers; layno++) {
-		double lo = min;
-		double hi = max;
-		int success = 0;
-		int maxlen = tcd_tcp->rates[layno] ? int_min(((int) ceil(tcd_tcp->rates[layno])), len) : len;
-		double goodthresh = 0;
-		double stable_thresh = 0;
-		int i;
-		double distotarget;		/* fixed_quality */
-		
-		/* fixed_quality */
-		distotarget = tcd_tile->distotile - ((K * maxSE) / pow((float)10, tcd_tcp->distoratio[layno] / 10));
-        
-		/* Don't try to find an optimal threshold but rather take everything not included yet, if
-		  -r xx,yy,zz,0   (disto_alloc == 1 and rates == 0)
-		  -q xx,yy,zz,0	  (fixed_quality == 1 and distoratio == 0)
-		  ==> possible to have some lossy layers and the last layer for sure lossless */
-		if ( ((cp->disto_alloc==1) && (tcd_tcp->rates[layno]>0)) || ((cp->fixed_quality==1) && (tcd_tcp->distoratio[layno]>0))) {
-			opj_t2_t *t2 = t2_create(tcd->cinfo, tcd->image, cp);
-			double thresh = 0;
-
-			for (i = 0; i < 128; i++) {
-				int l = 0;
-				double distoachieved = 0;	/* fixed_quality */
-				thresh = (lo + hi) / 2;
-				
-				tcd_makelayer(tcd, layno, thresh, 0);
-				
-				if (cp->fixed_quality) {	/* fixed_quality */
-					if(cp->cinema){
-						l = t2_encode_packets(t2,tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC, tcd->cur_totnum_tp);
-						if (l == -999) {
-							lo = thresh;
-							continue;
-						}else{
-           		distoachieved =	layno == 0 ? 
-							tcd_tile->distolayer[0]	: cumdisto[layno - 1] + tcd_tile->distolayer[layno];
-							if (distoachieved < distotarget) {
-								hi=thresh; 
-								stable_thresh = thresh;
-								continue;
-							}else{
-								lo=thresh;
-							}
-						}
-					}else{
-						distoachieved =	(layno == 0) ? 
-							tcd_tile->distolayer[0]	: (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
-						if (distoachieved < distotarget) {
-							hi = thresh;
-							stable_thresh = thresh;
-							continue;
-						}
-						lo = thresh;
-					}
-				} else {
-					l = t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC, tcd->cur_totnum_tp);
-					/* TODO: what to do with l ??? seek / tell ??? */
-					/* opj_event_msg(tcd->cinfo, EVT_INFO, "rate alloc: len=%d, max=%d\n", l, maxlen); */
-					if (l == -999) {
-						lo = thresh;
-						continue;
-					}
-					hi = thresh;
-					stable_thresh = thresh;
-				}
-			}
-			success = 1;
-			goodthresh = stable_thresh == 0? thresh : stable_thresh;
-			t2_destroy(t2);
-		} else {
-			success = 1;
-			goodthresh = min;
-		}
-		
-		if (!success) {
-			return false;
-		}
-		
-		if(cstr_info) {	/* Threshold for Marcela Index */
-			cstr_info->tile[tcd->tcd_tileno].thresh[layno] = goodthresh;
-		}
-		tcd_makelayer(tcd, layno, goodthresh, 1);
-        
-		/* fixed_quality */
-		cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);	
-	}
-
-	return true;
-}
-
-int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
-	int compno;
-	int l, i, numpacks = 0;
-	opj_tcd_tile_t *tile = NULL;
-	opj_tcp_t *tcd_tcp = NULL;
-	opj_cp_t *cp = NULL;
-
-	opj_tcp_t *tcp = &tcd->cp->tcps[0];
-	opj_tccp_t *tccp = &tcp->tccps[0];
-	opj_image_t *image = tcd->image;
-	
-	opj_t1_t *t1 = NULL;		/* T1 component */
-	opj_t2_t *t2 = NULL;		/* T2 component */
-
-	tcd->tcd_tileno = tileno;
-	tcd->tcd_tile = tcd->tcd_image->tiles;
-	tcd->tcp = &tcd->cp->tcps[tileno];
-
-	tile = tcd->tcd_tile;
-	tcd_tcp = tcd->tcp;
-	cp = tcd->cp;
-
-	if(tcd->cur_tp_num == 0){
-		tcd->encoding_time = opj_clock();	/* time needed to encode a tile */
-		/* INDEX >> "Precinct_nb_X et Precinct_nb_Y" */
-		if(cstr_info) {
-			opj_tcd_tilecomp_t *tilec_idx = &tile->comps[0];	/* based on component 0 */
-			for (i = 0; i < tilec_idx->numresolutions; i++) {
-				opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[i];
-				
-				cstr_info->tile[tileno].pw[i] = res_idx->pw;
-				cstr_info->tile[tileno].ph[i] = res_idx->ph;
-				
-				numpacks += res_idx->pw * res_idx->ph;
-				
-				cstr_info->tile[tileno].pdx[i] = tccp->prcw[i];
-				cstr_info->tile[tileno].pdy[i] = tccp->prch[i];
-			}
-			cstr_info->tile[tileno].packet = (opj_packet_info_t*) opj_calloc(cstr_info->numcomps * cstr_info->numlayers * numpacks, sizeof(opj_packet_info_t));
-		}
-		/* << INDEX */
-		
-		/*---------------TILE-------------------*/
-		
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			int x, y;
-			
-			int adjust = image->comps[compno].sgnd ? 0 : 1 << (image->comps[compno].prec - 1);
-			int offset_x = int_ceildiv(image->x0, image->comps[compno].dx);
-			int offset_y = int_ceildiv(image->y0, image->comps[compno].dy);
-			
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-			int tw = tilec->x1 - tilec->x0;
-			int w = int_ceildiv(image->x1 - image->x0, image->comps[compno].dx);
-			
-			/* extract tile data */
-			
-			if (tcd_tcp->tccps[compno].qmfbid == 1) {
-				for (y = tilec->y0; y < tilec->y1; y++) {
-					/* start of the src tile scanline */
-					int *data = &image->comps[compno].data[(tilec->x0 - offset_x) + (y - offset_y) * w];
-					/* start of the dst tile scanline */
-					int *tile_data = &tilec->data[(y - tilec->y0) * tw];
-					for (x = tilec->x0; x < tilec->x1; x++) {
-						*tile_data++ = *data++ - adjust;
-					}
-				}
-			} else if (tcd_tcp->tccps[compno].qmfbid == 0) {
-				for (y = tilec->y0; y < tilec->y1; y++) {
-					/* start of the src tile scanline */
-					int *data = &image->comps[compno].data[(tilec->x0 - offset_x) + (y - offset_y) * w];
-					/* start of the dst tile scanline */
-					int *tile_data = &tilec->data[(y - tilec->y0) * tw];
-					for (x = tilec->x0; x < tilec->x1; x++) {
-						*tile_data++ = (*data++ - adjust) << 11;
-					}
-					
-				}
-			}
-		}
-		
-		/*----------------MCT-------------------*/
-		if (tcd_tcp->mct) {
-			int samples = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0);
-			if (tcd_tcp->tccps[0].qmfbid == 0) {
-				mct_encode_real(tile->comps[0].data, tile->comps[1].data, tile->comps[2].data, samples);
-			} else {
-				mct_encode(tile->comps[0].data, tile->comps[1].data, tile->comps[2].data, samples);
-			}
-		}
-		
-		/*----------------DWT---------------------*/
-		
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-			if (tcd_tcp->tccps[compno].qmfbid == 1) {
-				dwt_encode(tilec);
-			} else if (tcd_tcp->tccps[compno].qmfbid == 0) {
-				dwt_encode_real(tilec);
-			}
-		}
-		
-		/*------------------TIER1-----------------*/
-		t1 = t1_create(tcd->cinfo);
-		t1_encode_cblks(t1, tile, tcd_tcp);
-		t1_destroy(t1);
-		
-		/*-----------RATE-ALLOCATE------------------*/
-		
-		/* INDEX */
-		if(cstr_info) {
-			cstr_info->index_write = 0;
-		}
-		if (cp->disto_alloc || cp->fixed_quality) {	/* fixed_quality */
-			/* Normal Rate/distortion allocation */
-			tcd_rateallocate(tcd, dest, len, cstr_info);
-		} else {
-			/* Fixed layer allocation */
-			tcd_rateallocate_fixed(tcd);
-		}
-	}
-	/*--------------TIER2------------------*/
-
-	/* INDEX */
-	if(cstr_info) {
-		cstr_info->index_write = 1;
-	}
-
-	t2 = t2_create(tcd->cinfo, image, cp);
-	l = t2_encode_packets(t2,tileno, tile, tcd_tcp->numlayers, dest, len, cstr_info,tcd->tp_num,tcd->tp_pos,tcd->cur_pino,FINAL_PASS,tcd->cur_totnum_tp);
-	t2_destroy(t2);
-	
-	/*---------------CLEAN-------------------*/
-
-	
-	if(tcd->cur_tp_num == tcd->cur_totnum_tp - 1){
-		tcd->encoding_time = opj_clock() - tcd->encoding_time;
-		opj_event_msg(tcd->cinfo, EVT_INFO, "- tile encoded in %f s\n", tcd->encoding_time);
-
-		/* cleaning memory */
-		for (compno = 0; compno < tile->numcomps; compno++) {
-			opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-			opj_aligned_free(tilec->data);
-		}
-	}
-
-	return l;
-}
-
-bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
-	int l;
-	int compno;
-	int eof = 0;
-	double tile_time, t1_time, dwt_time;
-	opj_tcd_tile_t *tile = NULL;
-
-	opj_t1_t *t1 = NULL;		/* T1 component */
-	opj_t2_t *t2 = NULL;		/* T2 component */
-	
-	tcd->tcd_tileno = tileno;
-	tcd->tcd_tile = &(tcd->tcd_image->tiles[tileno]);
-	tcd->tcp = &(tcd->cp->tcps[tileno]);
-	tile = tcd->tcd_tile;
-	
-	tile_time = opj_clock();	/* time needed to decode a tile */
-	opj_event_msg(tcd->cinfo, EVT_INFO, "tile %d of %d\n", tileno + 1, tcd->cp->tw * tcd->cp->th);
-
-	/* INDEX >>  */
-	if(cstr_info) {
-		int resno, compno, numprec = 0;
-		for (compno = 0; compno < cstr_info->numcomps; compno++) {
-			opj_tcp_t *tcp = &tcd->cp->tcps[0];
-			opj_tccp_t *tccp = &tcp->tccps[compno];
-			opj_tcd_tilecomp_t *tilec_idx = &tile->comps[compno];	
-			for (resno = 0; resno < tilec_idx->numresolutions; resno++) {
-				opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno];
-				cstr_info->tile[tileno].pw[resno] = res_idx->pw;
-				cstr_info->tile[tileno].ph[resno] = res_idx->ph;
-				numprec += res_idx->pw * res_idx->ph;
-				if (tccp->csty & J2K_CP_CSTY_PRT) {
-					cstr_info->tile[tileno].pdx[resno] = tccp->prcw[resno];
-					cstr_info->tile[tileno].pdy[resno] = tccp->prch[resno];
-				}
-				else {
-					cstr_info->tile[tileno].pdx[resno] = 15;
-					cstr_info->tile[tileno].pdx[resno] = 15;
-				}
-			}
-		}
-		cstr_info->tile[tileno].packet = (opj_packet_info_t *) opj_malloc(cstr_info->numlayers * numprec * sizeof(opj_packet_info_t));
-		cstr_info->packno = 0;
-	}
-	/* << INDEX */
-	
-	/*--------------TIER2------------------*/
-	
-	t2 = t2_create(tcd->cinfo, tcd->image, tcd->cp);
-	l = t2_decode_packets(t2, src, len, tileno, tile, cstr_info);
-	t2_destroy(t2);
-
-	if (l == -999) {
-		eof = 1;
-		opj_event_msg(tcd->cinfo, EVT_ERROR, "tcd_decode: incomplete bistream\n");
-	}
-	
-	/*------------------TIER1-----------------*/
-	
-	t1_time = opj_clock();	/* time needed to decode a tile */
-	t1 = t1_create(tcd->cinfo);
-	for (compno = 0; compno < tile->numcomps; ++compno) {
-		opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
-		/* The +3 is headroom required by the vectorized DWT */
-		tilec->data = (int*) opj_aligned_malloc((((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0))+3) * sizeof(int));
-		t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
-	}
-	t1_destroy(t1);
-	t1_time = opj_clock() - t1_time;
-	opj_event_msg(tcd->cinfo, EVT_INFO, "- tiers-1 took %f s\n", t1_time);
-	
-	/*----------------DWT---------------------*/
-
-	dwt_time = opj_clock();	/* time needed to decode a tile */
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-		int numres2decode;
-
-		if (tcd->cp->reduce != 0) {
-			tcd->image->comps[compno].resno_decoded =
-				tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
-			if (tcd->image->comps[compno].resno_decoded < 0) {				
-				opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
-					" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
-				return false;
-			}
-		}
-
-		numres2decode = tcd->image->comps[compno].resno_decoded + 1;
-		if(numres2decode > 0){
-			if (tcd->tcp->tccps[compno].qmfbid == 1) {
-				dwt_decode(tilec, numres2decode);
-			} else {
-				dwt_decode_real(tilec, numres2decode);
-			}
-		}
-	}
-	dwt_time = opj_clock() - dwt_time;
-	opj_event_msg(tcd->cinfo, EVT_INFO, "- dwt took %f s\n", dwt_time);
-
-	/*----------------MCT-------------------*/
-
-	if (tcd->tcp->mct) {
-		int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0);
-		if (tcd->tcp->tccps[0].qmfbid == 1) {
-			mct_decode(
-					tile->comps[0].data,
-					tile->comps[1].data,
-					tile->comps[2].data, 
-					n);
-		} else {
-			mct_decode_real(
-					(float*)tile->comps[0].data,
-					(float*)tile->comps[1].data,
-					(float*)tile->comps[2].data, 
-					n);
-		}
-	}
-
-	/*---------------TILE-------------------*/
-
-	for (compno = 0; compno < tile->numcomps; ++compno) {
-		opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
-		opj_image_comp_t* imagec = &tcd->image->comps[compno];
-		opj_tcd_resolution_t* res = &tilec->resolutions[imagec->resno_decoded];
-		int adjust = imagec->sgnd ? 0 : 1 << (imagec->prec - 1);
-		int min = imagec->sgnd ? -(1 << (imagec->prec - 1)) : 0;
-		int max = imagec->sgnd ?  (1 << (imagec->prec - 1)) - 1 : (1 << imagec->prec) - 1;
-
-		int tw = tilec->x1 - tilec->x0;
-		int w = imagec->w;
-
-		int offset_x = int_ceildivpow2(imagec->x0, imagec->factor);
-		int offset_y = int_ceildivpow2(imagec->y0, imagec->factor);
-
-		int i, j;
-		if(!imagec->data){
-			imagec->data = (int*) opj_malloc(imagec->w * imagec->h * sizeof(int));
-		}
-		if(tcd->tcp->tccps[compno].qmfbid == 1) {
-			for(j = res->y0; j < res->y1; ++j) {
-				for(i = res->x0; i < res->x1; ++i) {
-					int v = tilec->data[i - res->x0 + (j - res->y0) * tw];
-					v += adjust;
-					imagec->data[(i - offset_x) + (j - offset_y) * w] = int_clamp(v, min, max);
-				}
-			}
-		}else{
-			for(j = res->y0; j < res->y1; ++j) {
-				for(i = res->x0; i < res->x1; ++i) {
-					float tmp = ((float*)tilec->data)[i - res->x0 + (j - res->y0) * tw];
-					int v = lrintf(tmp);
-					v += adjust;
-					imagec->data[(i - offset_x) + (j - offset_y) * w] = int_clamp(v, min, max);
-				}
-			}
-		}
-		opj_aligned_free(tilec->data);
-	}
-
-	tile_time = opj_clock() - tile_time;	/* time needed to decode a tile */
-	opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time);
-
-	if (eof) {
-		return false;
-	}
-	
-	return true;
-}
-
-void tcd_free_decode(opj_tcd_t *tcd) {
-	opj_tcd_image_t *tcd_image = tcd->tcd_image;	
-	opj_free(tcd_image->tiles);
-}
-
-void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
-	int compno,resno,bandno,precno;
-
-	opj_tcd_image_t *tcd_image = tcd->tcd_image;
-
-	opj_tcd_tile_t *tile = &tcd_image->tiles[tileno];
-	for (compno = 0; compno < tile->numcomps; compno++) {
-		opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-		for (resno = 0; resno < tilec->numresolutions; resno++) {
-			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-			for (bandno = 0; bandno < res->numbands; bandno++) {
-				opj_tcd_band_t *band = &res->bands[bandno];
-				for (precno = 0; precno < res->ph * res->pw; precno++) {
-					opj_tcd_precinct_t *prec = &band->precincts[precno];
-					if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
-					if (prec->incltree != NULL) tgt_destroy(prec->incltree);
-				}
-				opj_free(band->precincts);
-			}
-		}
-		opj_free(tilec->resolutions);
-	}
-	opj_free(tile->comps);
-}
-
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.h
deleted file mode 100644
index a533073..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tcd.h
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __TCD_H
-#define __TCD_H
-/**
- at file tcd.h
- at brief Implementation of a tile coder/decoder (TCD)
-
-The functions in TCD.C have for goal to encode or decode each tile independently from
-each other. The functions in TCD.C are used by some function in J2K.C.
-*/
-
-/** @defgroup TCD TCD - Implementation of a tile coder/decoder */
-/*@{*/
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_seg {
-  unsigned char** data;
-  int dataindex;
-  int numpasses;
-  int len;
-  int maxpasses;
-  int numnewpasses;
-  int newlen;
-} opj_tcd_seg_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_pass {
-  int rate;
-  double distortiondec;
-  int term, len;
-} opj_tcd_pass_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_layer {
-  int numpasses;		/* Number of passes in the layer */
-  int len;			/* len of information */
-  double disto;			/* add for index (Cfr. Marcela) */
-  unsigned char *data;		/* data */
-} opj_tcd_layer_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_cblk_enc {
-  unsigned char* data;	/* Data */
-  opj_tcd_layer_t* layers;	/* layer information */
-  opj_tcd_pass_t* passes;	/* information about the passes */
-  int x0, y0, x1, y1;		/* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
-  int numbps;
-  int numlenbits;
-  int numpasses;		/* number of pass already done for the code-blocks */
-  int numpassesinlayers;	/* number of passes in the layer */
-  int totalpasses;		/* total number of passes */
-} opj_tcd_cblk_enc_t;
-
-typedef struct opj_tcd_cblk_dec {
-  unsigned char* data;	/* Data */
-  opj_tcd_seg_t* segs;		/* segments informations */
-	int x0, y0, x1, y1;		/* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
-  int numbps;
-  int numlenbits;
-  int len;			/* length */
-  int numnewpasses;		/* number of pass added to the code-blocks */
-  int numsegs;			/* number of segments */
-} opj_tcd_cblk_dec_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_precinct {
-  int x0, y0, x1, y1;		/* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
-  int cw, ch;			/* number of precinct in width and heigth */
-  union{		/* code-blocks informations */
-	  opj_tcd_cblk_enc_t* enc;
-	  opj_tcd_cblk_dec_t* dec;
-  } cblks;
-  opj_tgt_tree_t *incltree;		/* inclusion tree */
-  opj_tgt_tree_t *imsbtree;		/* IMSB tree */
-} opj_tcd_precinct_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_band {
-  int x0, y0, x1, y1;		/* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
-  int bandno;
-  opj_tcd_precinct_t *precincts;	/* precinct information */
-  int numbps;
-  float stepsize;
-} opj_tcd_band_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_resolution {
-  int x0, y0, x1, y1;		/* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */
-  int pw, ph;
-  int numbands;			/* number sub-band for the resolution level */
-  opj_tcd_band_t bands[3];		/* subband information */
-} opj_tcd_resolution_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_tilecomp {
-  int x0, y0, x1, y1;		/* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
-  int numresolutions;		/* number of resolutions level */
-  opj_tcd_resolution_t *resolutions;	/* resolutions information */
-  int *data;			/* data of the component */
-  int numpix;			/* add fixed_quality */
-} opj_tcd_tilecomp_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_tile {
-  int x0, y0, x1, y1;		/* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */
-  int numcomps;			/* number of components in tile */
-  opj_tcd_tilecomp_t *comps;	/* Components information */
-  int numpix;			/* add fixed_quality */
-  double distotile;		/* add fixed_quality */
-  double distolayer[100];	/* add fixed_quality */
-  /** packet number */
-  int packno;
-} opj_tcd_tile_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_image {
-  int tw, th;			/* number of tiles in width and heigth */
-  opj_tcd_tile_t *tiles;		/* Tiles information */
-} opj_tcd_image_t;
-
-/**
-Tile coder/decoder
-*/
-typedef struct opj_tcd {
-	/** Position of the tilepart flag in Progression order*/
-	int tp_pos;
-	/** Tile part number*/
-	int tp_num;
-	/** Current tile part number*/
-	int cur_tp_num;
-	/** Total number of tileparts of the current tile*/
-	int cur_totnum_tp;
-	/** Current Packet iterator number */
-	int cur_pino;
-	/** codec context */
-	opj_common_ptr cinfo;
-
-	/** info on each image tile */
-	opj_tcd_image_t *tcd_image;
-	/** image */
-	opj_image_t *image;
-	/** coding parameters */
-	opj_cp_t *cp;
-	/** pointer to the current encoded/decoded tile */
-	opj_tcd_tile_t *tcd_tile;
-	/** coding/decoding parameters common to all tiles */
-	opj_tcp_t *tcp;
-	/** current encoded/decoded tile */
-	int tcd_tileno;
-	/** Time taken to encode a tile*/
-	double encoding_time;
-} opj_tcd_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Dump the content of a tcd structure
-*/
-void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);
-/**
-Create a new TCD handle
- at param cinfo Codec context info
- at return Returns a new TCD handle if successful returns NULL otherwise
-*/
-opj_tcd_t* tcd_create(opj_common_ptr cinfo);
-/**
-Destroy a previously created TCD handle
- at param tcd TCD handle to destroy
-*/
-void tcd_destroy(opj_tcd_t *tcd);
-/**
-Initialize the tile coder (allocate the memory)
- at param tcd TCD handle
- at param image Raw image
- at param cp Coding parameters
- at param curtileno Number that identifies the tile that will be encoded
-*/
-void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int curtileno);
-/**
-Free the memory allocated for encoding
- at param tcd TCD handle
-*/
-void tcd_free_encode(opj_tcd_t *tcd);
-/**
-Initialize the tile coder (reuses the memory allocated by tcd_malloc_encode)
- at param tcd TCD handle
- at param image Raw image
- at param cp Coding parameters
- at param curtileno Number that identifies the tile that will be encoded
-*/
-void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int curtileno);
-/**
-Initialize the tile decoder
- at param tcd TCD handle
- at param image Raw image
- at param cp Coding parameters
-*/
-void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp);
-void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int tileno, opj_codestream_info_t *cstr_info);
-void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final);
-void tcd_rateallocate_fixed(opj_tcd_t *tcd);
-void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final);
-bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
-/**
-Encode a tile from the raw image into a buffer
- at param tcd TCD handle
- at param tileno Number that identifies one of the tiles to be encoded
- at param dest Destination buffer
- at param len Length of destination buffer
- at param cstr_info Codestream information structure 
- at return 
-*/
-int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
-/**
-Decode a tile from a buffer into a raw image
- at param tcd TCD handle
- at param src Source buffer
- at param len Length of source buffer
- at param tileno Number that identifies one of the tiles to be decoded
- at param cstr_info Codestream information structure
-*/
-bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
-/**
-Free the memory allocated for decoding
- at param tcd TCD handle
-*/
-void tcd_free_decode(opj_tcd_t *tcd);
-void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __TCD_H */
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.c b/Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.c
deleted file mode 100644
index a5dbcd3..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-
-/* 
-==========================================================
-   Tag-tree coder interface
-==========================================================
-*/
-
-opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv) {
-	int nplh[32];
-	int nplv[32];
-	opj_tgt_node_t *node = NULL;
-	opj_tgt_node_t *parentnode = NULL;
-	opj_tgt_node_t *parentnode0 = NULL;
-	opj_tgt_tree_t *tree = NULL;
-	int i, j, k;
-	int numlvls;
-	int n;
-
-	tree = (opj_tgt_tree_t *) opj_malloc(sizeof(opj_tgt_tree_t));
-	if(!tree) return NULL;
-	tree->numleafsh = numleafsh;
-	tree->numleafsv = numleafsv;
-
-	numlvls = 0;
-	nplh[0] = numleafsh;
-	nplv[0] = numleafsv;
-	tree->numnodes = 0;
-	do {
-		n = nplh[numlvls] * nplv[numlvls];
-		nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
-		nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
-		tree->numnodes += n;
-		++numlvls;
-	} while (n > 1);
-	
-	/* ADD */
-	if (tree->numnodes == 0) {
-		opj_free(tree);
-		return NULL;
-	}
-
-	tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes, sizeof(opj_tgt_node_t));
-	if(!tree->nodes) {
-		opj_free(tree);
-		return NULL;
-	}
-
-	node = tree->nodes;
-	parentnode = &tree->nodes[tree->numleafsh * tree->numleafsv];
-	parentnode0 = parentnode;
-	
-	for (i = 0; i < numlvls - 1; ++i) {
-		for (j = 0; j < nplv[i]; ++j) {
-			k = nplh[i];
-			while (--k >= 0) {
-				node->parent = parentnode;
-				++node;
-				if (--k >= 0) {
-					node->parent = parentnode;
-					++node;
-				}
-				++parentnode;
-			}
-			if ((j & 1) || j == nplv[i] - 1) {
-				parentnode0 = parentnode;
-			} else {
-				parentnode = parentnode0;
-				parentnode0 += nplh[i];
-			}
-		}
-	}
-	node->parent = 0;
-	
-	tgt_reset(tree);
-	
-	return tree;
-}
-
-void tgt_destroy(opj_tgt_tree_t *tree) {
-	opj_free(tree->nodes);
-	opj_free(tree);
-}
-
-void tgt_reset(opj_tgt_tree_t *tree) {
-	int i;
-
-	if (NULL == tree)
-		return;
-	
-	for (i = 0; i < tree->numnodes; i++) {
-		tree->nodes[i].value = 999;
-		tree->nodes[i].low = 0;
-		tree->nodes[i].known = 0;
-	}
-}
-
-void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value) {
-	opj_tgt_node_t *node;
-	node = &tree->nodes[leafno];
-	while (node && node->value > value) {
-		node->value = value;
-		node = node->parent;
-	}
-}
-
-void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
-	opj_tgt_node_t *stk[31];
-	opj_tgt_node_t **stkptr;
-	opj_tgt_node_t *node;
-	int low;
-
-	stkptr = stk;
-	node = &tree->nodes[leafno];
-	while (node->parent) {
-		*stkptr++ = node;
-		node = node->parent;
-	}
-	
-	low = 0;
-	for (;;) {
-		if (low > node->low) {
-			node->low = low;
-		} else {
-			low = node->low;
-		}
-		
-		while (low < threshold) {
-			if (low >= node->value) {
-				if (!node->known) {
-					bio_write(bio, 1, 1);
-					node->known = 1;
-				}
-				break;
-			}
-			bio_write(bio, 0, 1);
-			++low;
-		}
-		
-		node->low = low;
-		if (stkptr == stk)
-			break;
-		node = *--stkptr;
-	}
-}
-
-int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
-	opj_tgt_node_t *stk[31];
-	opj_tgt_node_t **stkptr;
-	opj_tgt_node_t *node;
-	int low;
-
-	stkptr = stk;
-	node = &tree->nodes[leafno];
-	while (node->parent) {
-		*stkptr++ = node;
-		node = node->parent;
-	}
-	
-	low = 0;
-	for (;;) {
-		if (low > node->low) {
-			node->low = low;
-		} else {
-			low = node->low;
-		}
-		while (low < threshold && low < node->value) {
-			if (bio_read(bio, 1)) {
-				node->value = low;
-			} else {
-				++low;
-			}
-		}
-		node->low = low;
-		if (stkptr == stk) {
-			break;
-		}
-		node = *--stkptr;
-	}
-	
-	return (node->value < threshold) ? 1 : 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.h b/Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.h
deleted file mode 100644
index c08c8da..0000000
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/tgt.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TGT_H
-#define __TGT_H
-/**
- at file tgt.h
- at brief Implementation of a tag-tree coder (TGT)
-
-The functions in TGT.C have for goal to realize a tag-tree coder. The functions in TGT.C
-are used by some function in T2.C.
-*/
-
-/** @defgroup TGT TGT - Implementation of a tag-tree coder */
-/*@{*/
-
-/**
-Tag node
-*/
-typedef struct opj_tgt_node {
-  struct opj_tgt_node *parent;
-  int value;
-  int low;
-  int known;
-} opj_tgt_node_t;
-
-/**
-Tag tree
-*/
-typedef struct opj_tgt_tree {
-  int numleafsh;
-  int numleafsv;
-  int numnodes;
-  opj_tgt_node_t *nodes;
-} opj_tgt_tree_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a tag-tree
- at param numleafsh Width of the array of leafs of the tree
- at param numleafsv Height of the array of leafs of the tree
- at return Returns a new tag-tree if successful, returns NULL otherwise
-*/
-opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv);
-/**
-Destroy a tag-tree, liberating memory
- at param tree Tag-tree to destroy
-*/
-void tgt_destroy(opj_tgt_tree_t *tree);
-/**
-Reset a tag-tree (set all leaves to 0)
- at param tree Tag-tree to reset
-*/
-void tgt_reset(opj_tgt_tree_t *tree);
-/**
-Set the value of a leaf of a tag-tree
- at param tree Tag-tree to modify
- at param leafno Number that identifies the leaf to modify
- at param value New value of the leaf
-*/
-void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value);
-/**
-Encode the value of a leaf of the tag-tree up to a given threshold
- at param bio Pointer to a BIO handle
- at param tree Tag-tree to modify
- at param leafno Number that identifies the leaf to encode
- at param threshold Threshold to use when encoding value of the leaf
-*/
-void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold);
-/**
-Decode the value of a leaf of the tag-tree up to a given threshold
- at param bio Pointer to a BIO handle
- at param tree Tag-tree to decode
- at param leafno Number that identifies the leaf to decode
- at param threshold Threshold to use when decoding value of the leaf
- at return Returns 1 if the node's value < threshold, returns 0 otherwise
-*/
-int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __TGT_H */
diff --git a/Utilities/gdcmopenjpeg-v1/ltmain.sh b/Utilities/gdcmopenjpeg-v1/ltmain.sh
deleted file mode 100755
index be43f41..0000000
--- a/Utilities/gdcmopenjpeg-v1/ltmain.sh
+++ /dev/null
@@ -1,8750 +0,0 @@
-# Generated from ltmain.m4sh.
-
-# libtool (GNU libtool) 2.2.8
-# Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-# This is free software; see the source for copying conditions.  There is NO
-# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-# GNU Libtool is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
-#
-# GNU Libtool is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html,
-# or obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-# Usage: $progname [OPTION]... [MODE-ARG]...
-#
-# Provide generalized library-building support services.
-#
-#       --config             show all configuration variables
-#       --debug              enable verbose shell tracing
-#   -n, --dry-run            display commands without modifying any files
-#       --features           display basic configuration information and exit
-#       --mode=MODE          use operation mode MODE
-#       --preserve-dup-deps  don't remove duplicate dependency libraries
-#       --quiet, --silent    don't print informational messages
-#       --no-quiet, --no-silent
-#                            print informational messages (default)
-#       --tag=TAG            use configuration variables from tag TAG
-#   -v, --verbose            print more informational messages than default
-#       --no-verbose         don't print the extra informational messages
-#       --version            print version information
-#   -h, --help, --help-all   print short, long, or detailed help message
-#
-# MODE must be one of the following:
-#
-#         clean              remove files from the build directory
-#         compile            compile a source file into a libtool object
-#         execute            automatically set library path, then run a program
-#         finish             complete the installation of libtool libraries
-#         install            install libraries or executables
-#         link               create a library or an executable
-#         uninstall          remove libraries from an installed directory
-#
-# MODE-ARGS vary depending on the MODE.  When passed as first option,
-# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
-# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
-#
-# When reporting a bug, please describe a test case to reproduce it and
-# include the following information:
-#
-#         host-triplet:	$host
-#         shell:		$SHELL
-#         compiler:		$LTCC
-#         compiler flags:		$LTCFLAGS
-#         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.2.8
-#         automake:	$automake_version
-#         autoconf:	$autoconf_version
-#
-# Report bugs to <bug-libtool at gnu.org>.
-
-PROGRAM=libtool
-PACKAGE=libtool
-VERSION=2.2.8
-TIMESTAMP=""
-package_revision=1.3169
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
-
-# NLS nuisances: We save the old values to restore during execute mode.
-lt_user_locale=
-lt_safe_locale=
-for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
-do
-  eval "if test \"\${$lt_var+set}\" = set; then
-          save_$lt_var=\$$lt_var
-          $lt_var=C
-	  export $lt_var
-	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
-	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
-	fi"
-done
-LC_ALL=C
-LANGUAGE=C
-export LANGUAGE LC_ALL
-
-$lt_unset CDPATH
-
-
-
-
-
-
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
-
-
-
-: ${CP="cp -f"}
-test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
-: ${EGREP="grep -E"}
-: ${FGREP="grep -F"}
-: ${GREP="grep"}
-: ${LN_S="ln -s"}
-: ${MAKE="make"}
-: ${MKDIR="mkdir"}
-: ${MV="mv -f"}
-: ${RM="rm -f"}
-: ${SED="sed"}
-: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
-: ${Xsed="$SED -e 1s/^X//"}
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
-EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
-
-exit_status=$EXIT_SUCCESS
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
-
-dirname="s,/[^/]*$,,"
-basename="s,^.*/,,"
-
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-#   dirname:  Compute the dirname of FILE.  If nonempty,
-#             add APPEND to the result, otherwise set result
-#             to NONDIR_REPLACEMENT.
-#             value returned in "$func_dirname_result"
-#   basename: Compute filename of FILE.
-#             value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
-  # Extract subdirectory from the argument.
-  func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
-  if test "X$func_dirname_result" = "X${1}"; then
-    func_dirname_result="${3}"
-  else
-    func_dirname_result="$func_dirname_result${2}"
-  fi
-  func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
-}
-
-# Generated shell functions inserted here.
-
-# These SED scripts presuppose an absolute path with a trailing slash.
-pathcar='s,^/\([^/]*\).*$,\1,'
-pathcdr='s,^/[^/]*,,'
-removedotparts=':dotsl
-		s@/\./@/@g
-		t dotsl
-		s,/\.$,/,'
-collapseslashes='s@/\{1,\}@/@g'
-finalslash='s,/*$,/,'
-
-# func_normal_abspath PATH
-# Remove doubled-up and trailing slashes, "." path components,
-# and cancel out any ".." path components in PATH after making
-# it an absolute path.
-#             value returned in "$func_normal_abspath_result"
-func_normal_abspath ()
-{
-  # Start from root dir and reassemble the path.
-  func_normal_abspath_result=
-  func_normal_abspath_tpath=$1
-  func_normal_abspath_altnamespace=
-  case $func_normal_abspath_tpath in
-    "")
-      # Empty path, that just means $cwd.
-      func_stripname '' '/' "`pwd`"
-      func_normal_abspath_result=$func_stripname_result
-      return
-    ;;
-    # The next three entries are used to spot a run of precisely
-    # two leading slashes without using negated character classes;
-    # we take advantage of case's first-match behaviour.
-    ///*)
-      # Unusual form of absolute path, do nothing.
-    ;;
-    //*)
-      # Not necessarily an ordinary path; POSIX reserves leading '//'
-      # and for example Cygwin uses it to access remote file shares
-      # over CIFS/SMB, so we conserve a leading double slash if found.
-      func_normal_abspath_altnamespace=/
-    ;;
-    /*)
-      # Absolute path, do nothing.
-    ;;
-    *)
-      # Relative path, prepend $cwd.
-      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
-    ;;
-  esac
-  # Cancel out all the simple stuff to save iterations.  We also want
-  # the path to end with a slash for ease of parsing, so make sure
-  # there is one (and only one) here.
-  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
-  while :; do
-    # Processed it all yet?
-    if test "$func_normal_abspath_tpath" = / ; then
-      # If we ascended to the root using ".." the result may be empty now.
-      if test -z "$func_normal_abspath_result" ; then
-        func_normal_abspath_result=/
-      fi
-      break
-    fi
-    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcar"`
-    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcdr"`
-    # Figure out what to do with it
-    case $func_normal_abspath_tcomponent in
-      "")
-        # Trailing empty path component, ignore it.
-      ;;
-      ..)
-        # Parent dir; strip last assembled component from result.
-        func_dirname "$func_normal_abspath_result"
-        func_normal_abspath_result=$func_dirname_result
-      ;;
-      *)
-        # Actual path component, append it.
-        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
-      ;;
-    esac
-  done
-  # Restore leading double-slash if one was found on entry.
-  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
-}
-
-# func_relative_path SRCDIR DSTDIR
-# generates a relative path from SRCDIR to DSTDIR, with a trailing
-# slash if non-empty, suitable for immediately appending a filename
-# without needing to append a separator.
-#             value returned in "$func_relative_path_result"
-func_relative_path ()
-{
-  func_relative_path_result=
-  func_normal_abspath "$1"
-  func_relative_path_tlibdir=$func_normal_abspath_result
-  func_normal_abspath "$2"
-  func_relative_path_tbindir=$func_normal_abspath_result
-
-  # Ascend the tree starting from libdir
-  while :; do
-    # check if we have found a prefix of bindir
-    case $func_relative_path_tbindir in
-      $func_relative_path_tlibdir)
-        # found an exact match
-        func_relative_path_tcancelled=
-        break
-        ;;
-      $func_relative_path_tlibdir*)
-        # found a matching prefix
-        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
-        func_relative_path_tcancelled=$func_stripname_result
-        if test -z "$func_relative_path_result"; then
-          func_relative_path_result=.
-        fi
-        break
-        ;;
-      *)
-        func_dirname $func_relative_path_tlibdir
-        func_relative_path_tlibdir=${func_dirname_result}
-        if test "x$func_relative_path_tlibdir" = x ; then
-          # Have to descend all the way to the root!
-          func_relative_path_result=../$func_relative_path_result
-          func_relative_path_tcancelled=$func_relative_path_tbindir
-          break
-        fi
-        func_relative_path_result=../$func_relative_path_result
-        ;;
-    esac
-  done
-
-  # Now calculate path; take care to avoid doubling-up slashes.
-  func_stripname '' '/' "$func_relative_path_result"
-  func_relative_path_result=$func_stripname_result
-  func_stripname '/' '/' "$func_relative_path_tcancelled"
-  if test "x$func_stripname_result" != x ; then
-    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
-  fi
-
-  # Normalisation. If bindir is libdir, return empty string,
-  # else relative path ending with a slash; either way, target
-  # file name can be directly appended.
-  if test ! -z "$func_relative_path_result"; then
-    func_stripname './' '' "$func_relative_path_result/"
-    func_relative_path_result=$func_stripname_result
-  fi
-}
-
-# The name of this program:
-func_dirname_and_basename "$progpath"
-progname=$func_basename_result
-
-# Make sure we have an absolute path for reexecution:
-case $progpath in
-  [\\/]*|[A-Za-z]:\\*) ;;
-  *[\\/]*)
-     progdir=$func_dirname_result
-     progdir=`cd "$progdir" && pwd`
-     progpath="$progdir/$progname"
-     ;;
-  *)
-     save_IFS="$IFS"
-     IFS=:
-     for progdir in $PATH; do
-       IFS="$save_IFS"
-       test -x "$progdir/$progname" && break
-     done
-     IFS="$save_IFS"
-     test -n "$progdir" || progdir=`pwd`
-     progpath="$progdir/$progname"
-     ;;
-esac
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
-
-# Re-`\' parameter expansions in output of double_quote_subst that were
-# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
-# in input to double_quote_subst, that '$' was protected from expansion.
-# Since each input `\' is now two `\'s, look for any number of runs of
-# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
-bs='\\'
-bs2='\\\\'
-bs4='\\\\\\\\'
-dollar='\$'
-sed_double_backslash="\
-  s/$bs4/&\\
-/g
-  s/^$bs2$dollar/$bs&/
-  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
-  s/\n//g"
-
-# Standard options:
-opt_dry_run=false
-opt_help=false
-opt_quiet=false
-opt_verbose=false
-opt_warning=:
-
-# func_echo arg...
-# Echo program name prefixed message, along with the current mode
-# name if it has been set yet.
-func_echo ()
-{
-    $ECHO "$progname${mode+: }$mode: $*"
-}
-
-# func_verbose arg...
-# Echo program name prefixed message in verbose mode only.
-func_verbose ()
-{
-    $opt_verbose && func_echo ${1+"$@"}
-
-    # A bug in bash halts the script if the last line of a function
-    # fails when set -e is in force, so we need another command to
-    # work around that:
-    :
-}
-
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*"
-}
-
-# func_error arg...
-# Echo program name prefixed message to standard error.
-func_error ()
-{
-    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
-}
-
-# func_warning arg...
-# Echo program name prefixed warning message to standard error.
-func_warning ()
-{
-    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
-
-    # bash bug again:
-    :
-}
-
-# func_fatal_error arg...
-# Echo program name prefixed message to standard error, and exit.
-func_fatal_error ()
-{
-    func_error ${1+"$@"}
-    exit $EXIT_FAILURE
-}
-
-# func_fatal_help arg...
-# Echo program name prefixed message to standard error, followed by
-# a help hint, and exit.
-func_fatal_help ()
-{
-    func_error ${1+"$@"}
-    func_fatal_error "$help"
-}
-help="Try \`$progname --help' for more information."  ## default
-
-
-# func_grep expression filename
-# Check whether EXPRESSION matches any line of FILENAME, without output.
-func_grep ()
-{
-    $GREP "$1" "$2" >/dev/null 2>&1
-}
-
-
-# func_mkdir_p directory-path
-# Make sure the entire path to DIRECTORY-PATH is available.
-func_mkdir_p ()
-{
-    my_directory_path="$1"
-    my_dir_list=
-
-    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
-
-      # Protect directory names starting with `-'
-      case $my_directory_path in
-        -*) my_directory_path="./$my_directory_path" ;;
-      esac
-
-      # While some portion of DIR does not yet exist...
-      while test ! -d "$my_directory_path"; do
-        # ...make a list in topmost first order.  Use a colon delimited
-	# list incase some portion of path contains whitespace.
-        my_dir_list="$my_directory_path:$my_dir_list"
-
-        # If the last portion added has no slash in it, the list is done
-        case $my_directory_path in */*) ;; *) break ;; esac
-
-        # ...otherwise throw away the child directory and loop
-        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
-      done
-      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
-
-      save_mkdir_p_IFS="$IFS"; IFS=':'
-      for my_dir in $my_dir_list; do
-	IFS="$save_mkdir_p_IFS"
-        # mkdir can fail with a `File exist' error if two processes
-        # try to create one of the directories concurrently.  Don't
-        # stop in that case!
-        $MKDIR "$my_dir" 2>/dev/null || :
-      done
-      IFS="$save_mkdir_p_IFS"
-
-      # Bail out if we (or some other process) failed to create a directory.
-      test -d "$my_directory_path" || \
-        func_fatal_error "Failed to create \`$1'"
-    fi
-}
-
-
-# func_mktempdir [string]
-# Make a temporary directory that won't clash with other running
-# libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
-func_mktempdir ()
-{
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
-
-    if test "$opt_dry_run" = ":"; then
-      # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
-    else
-
-      # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
-
-      if test ! -d "$my_tmpdir"; then
-        # Failing that, at least try and use $RANDOM to avoid a race
-        my_tmpdir="${my_template}-${RANDOM-0}$$"
-
-        save_mktempdir_umask=`umask`
-        umask 0077
-        $MKDIR "$my_tmpdir"
-        umask $save_mktempdir_umask
-      fi
-
-      # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || \
-        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
-    fi
-
-    $ECHO "$my_tmpdir"
-}
-
-
-# func_quote_for_eval arg
-# Aesthetically quote ARG to be evaled later.
-# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
-# is double-quoted, suitable for a subsequent eval, whereas
-# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
-# which are still active within double quotes backslashified.
-func_quote_for_eval ()
-{
-    case $1 in
-      *[\\\`\"\$]*)
-	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
-      *)
-        func_quote_for_eval_unquoted_result="$1" ;;
-    esac
-
-    case $func_quote_for_eval_unquoted_result in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting, command substitution and and variable
-      # expansion for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
-        ;;
-      *)
-        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
-    esac
-}
-
-
-# func_quote_for_expand arg
-# Aesthetically quote ARG to be evaled later; same as above,
-# but do not quote variable references.
-func_quote_for_expand ()
-{
-    case $1 in
-      *[\\\`\"]*)
-	my_arg=`$ECHO "$1" | $SED \
-	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
-      *)
-        my_arg="$1" ;;
-    esac
-
-    case $my_arg in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting and command substitution for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        my_arg="\"$my_arg\""
-        ;;
-    esac
-
-    func_quote_for_expand_result="$my_arg"
-}
-
-
-# func_show_eval cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.
-func_show_eval ()
-{
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
-
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
-
-    if ${opt_dry_run-false}; then :; else
-      eval "$my_cmd"
-      my_status=$?
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
-}
-
-
-# func_show_eval_locale cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.  Use the saved locale for evaluation.
-func_show_eval_locale ()
-{
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
-
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
-
-    if ${opt_dry_run-false}; then :; else
-      eval "$lt_user_locale
-	    $my_cmd"
-      my_status=$?
-      eval "$lt_safe_locale"
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
-}
-
-
-
-# func_version
-# Echo version message to standard output and exit.
-func_version ()
-{
-    $SED -n '/(C)/!b go
-	:more
-	/\./!{
-	  N
-	  s/\n# //
-	  b more
-	}
-	:go
-	/^# '$PROGRAM' (GNU /,/# warranty; / {
-        s/^# //
-	s/^# *$//
-        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
-        p
-     }' < "$progpath"
-     exit $?
-}
-
-# func_usage
-# Echo short help message to standard output and exit.
-func_usage ()
-{
-    $SED -n '/^# Usage:/,/^#  *.*--help/ {
-        s/^# //
-	s/^# *$//
-	s/\$progname/'$progname'/
-	p
-    }' < "$progpath"
-    echo
-    $ECHO "run \`$progname --help | more' for full usage"
-    exit $?
-}
-
-# func_help [NOEXIT]
-# Echo long help message to standard output and exit,
-# unless 'noexit' is passed as argument.
-func_help ()
-{
-    $SED -n '/^# Usage:/,/# Report bugs to/ {
-        s/^# //
-	s/^# *$//
-	s*\$progname*'$progname'*
-	s*\$host*'"$host"'*
-	s*\$SHELL*'"$SHELL"'*
-	s*\$LTCC*'"$LTCC"'*
-	s*\$LTCFLAGS*'"$LTCFLAGS"'*
-	s*\$LD*'"$LD"'*
-	s/\$with_gnu_ld/'"$with_gnu_ld"'/
-	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
-	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
-	p
-     }' < "$progpath"
-    ret=$?
-    if test -z "$1"; then
-      exit $ret
-    fi
-}
-
-# func_missing_arg argname
-# Echo program name prefixed message to standard error and set global
-# exit_cmd.
-func_missing_arg ()
-{
-    func_error "missing argument for $1."
-    exit_cmd=exit
-}
-
-exit_cmd=:
-
-
-
-
-
-
-magic="%%%MAGIC variable%%%"
-magic_exe="%%%MAGIC EXE variable%%%"
-
-# Global variables.
-# $mode is unset
-nonopt=
-execute_dlfiles=
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-extracted_archives=
-extracted_serial=0
-
-opt_dry_run=false
-opt_duplicate_deps=false
-opt_silent=false
-opt_debug=:
-
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end.  This prevents here-documents from being
-# left over by shells.
-exec_cmd=
-
-# func_fatal_configuration arg...
-# Echo program name prefixed message to standard error, followed by
-# a configuration failure hint, and exit.
-func_fatal_configuration ()
-{
-    func_error ${1+"$@"}
-    func_error "See the $PACKAGE documentation for more information."
-    func_fatal_error "Fatal configuration error."
-}
-
-
-# func_config
-# Display the configuration for all the tags in this script.
-func_config ()
-{
-    re_begincf='^# ### BEGIN LIBTOOL'
-    re_endcf='^# ### END LIBTOOL'
-
-    # Default configuration.
-    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
-
-    # Now print the configurations for the tags.
-    for tagname in $taglist; do
-      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
-    done
-
-    exit $?
-}
-
-# func_features
-# Display the features supported by this script.
-func_features ()
-{
-    echo "host: $host"
-    if test "$build_libtool_libs" = yes; then
-      echo "enable shared libraries"
-    else
-      echo "disable shared libraries"
-    fi
-    if test "$build_old_libs" = yes; then
-      echo "enable static libraries"
-    else
-      echo "disable static libraries"
-    fi
-
-    exit $?
-}
-
-# func_enable_tag tagname
-# Verify that TAGNAME is valid, and either flag an error and exit, or
-# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
-# variable here.
-func_enable_tag ()
-{
-  # Global variable:
-  tagname="$1"
-
-  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
-  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
-  sed_extractcf="/$re_begincf/,/$re_endcf/p"
-
-  # Validate tagname.
-  case $tagname in
-    *[!-_A-Za-z0-9,/]*)
-      func_fatal_error "invalid tag name: $tagname"
-      ;;
-  esac
-
-  # Don't test for the "default" C tag, as we know it's
-  # there but not specially marked.
-  case $tagname in
-    CC) ;;
-    *)
-      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
-	taglist="$taglist $tagname"
-
-	# Evaluate the configuration.  Be careful to quote the path
-	# and the sed script, to avoid splitting on whitespace, but
-	# also don't use non-portable quotes within backquotes within
-	# quotes we have to do it in 2 steps:
-	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
-	eval "$extractedcf"
-      else
-	func_error "ignoring unknown tag $tagname"
-      fi
-      ;;
-  esac
-}
-
-# Parse options once, thoroughly.  This comes as soon as possible in
-# the script to make things like `libtool --version' happen quickly.
-{
-
-  # Shorthand for --mode=foo, only valid as the first argument
-  case $1 in
-  clean|clea|cle|cl)
-    shift; set dummy --mode clean ${1+"$@"}; shift
-    ;;
-  compile|compil|compi|comp|com|co|c)
-    shift; set dummy --mode compile ${1+"$@"}; shift
-    ;;
-  execute|execut|execu|exec|exe|ex|e)
-    shift; set dummy --mode execute ${1+"$@"}; shift
-    ;;
-  finish|finis|fini|fin|fi|f)
-    shift; set dummy --mode finish ${1+"$@"}; shift
-    ;;
-  install|instal|insta|inst|ins|in|i)
-    shift; set dummy --mode install ${1+"$@"}; shift
-    ;;
-  link|lin|li|l)
-    shift; set dummy --mode link ${1+"$@"}; shift
-    ;;
-  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
-    shift; set dummy --mode uninstall ${1+"$@"}; shift
-    ;;
-  esac
-
-  # Parse non-mode specific arguments:
-  while test "$#" -gt 0; do
-    opt="$1"
-    shift
-
-    case $opt in
-      --config)		func_config					;;
-
-      --debug)		preserve_args="$preserve_args $opt"
-			func_echo "enabling shell trace mode"
-			opt_debug='set -x'
-			$opt_debug
-			;;
-
-      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
-			execute_dlfiles="$execute_dlfiles $1"
-			shift
-			;;
-
-      --dry-run | -n)	opt_dry_run=:					;;
-      --features)       func_features					;;
-      --finish)		mode="finish"					;;
-
-      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
-			case $1 in
-			  # Valid mode arguments:
-			  clean)	;;
-			  compile)	;;
-			  execute)	;;
-			  finish)	;;
-			  install)	;;
-			  link)		;;
-			  relink)	;;
-			  uninstall)	;;
-
-			  # Catch anything else as an error
-			  *) func_error "invalid argument for $opt"
-			     exit_cmd=exit
-			     break
-			     ;;
-		        esac
-
-			mode="$1"
-			shift
-			;;
-
-      --preserve-dup-deps)
-			opt_duplicate_deps=:				;;
-
-      --quiet|--silent)	preserve_args="$preserve_args $opt"
-			opt_silent=:
-			opt_verbose=false
-			;;
-
-      --no-quiet|--no-silent)
-			preserve_args="$preserve_args $opt"
-			opt_silent=false
-			;;
-
-      --verbose| -v)	preserve_args="$preserve_args $opt"
-			opt_silent=false
-			opt_verbose=:
-			;;
-
-      --no-verbose)	preserve_args="$preserve_args $opt"
-			opt_verbose=false
-			;;
-
-      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
-			preserve_args="$preserve_args $opt $1"
-			func_enable_tag "$1"	# tagname is set here
-			shift
-			;;
-
-      # Separate optargs to long options:
-      -dlopen=*|--mode=*|--tag=*)
-			func_opt_split "$opt"
-			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
-			shift
-			;;
-
-      -\?|-h)		func_usage					;;
-      --help)		opt_help=:					;;
-      --help-all)	opt_help=': help-all'				;;
-      --version)	func_version					;;
-
-      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
-
-      *)		nonopt="$opt"
-			break
-			;;
-    esac
-  done
-
-
-  case $host in
-    *cygwin* | *mingw* | *pw32* | *cegcc*)
-      # don't eliminate duplications in $postdeps and $predeps
-      opt_duplicate_compiler_generated_deps=:
-      ;;
-    *)
-      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
-      ;;
-  esac
-
-  # Having warned about all mis-specified options, bail out if
-  # anything was wrong.
-  $exit_cmd $EXIT_FAILURE
-}
-
-# func_check_version_match
-# Ensure that we are using m4 macros, and libtool script from the same
-# release of libtool.
-func_check_version_match ()
-{
-  if test "$package_revision" != "$macro_revision"; then
-    if test "$VERSION" != "$macro_version"; then
-      if test -z "$macro_version"; then
-        cat >&2 <<_LT_EOF
-$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
-$progname: definition of this LT_INIT comes from an older release.
-$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
-$progname: and run autoconf again.
-_LT_EOF
-      else
-        cat >&2 <<_LT_EOF
-$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
-$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
-$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
-$progname: and run autoconf again.
-_LT_EOF
-      fi
-    else
-      cat >&2 <<_LT_EOF
-$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
-$progname: but the definition of this LT_INIT comes from revision $macro_revision.
-$progname: You should recreate aclocal.m4 with macros from revision $package_revision
-$progname: of $PACKAGE $VERSION and run autoconf again.
-_LT_EOF
-    fi
-
-    exit $EXIT_MISMATCH
-  fi
-}
-
-
-## ----------- ##
-##    Main.    ##
-## ----------- ##
-
-$opt_help || {
-  # Sanity checks first:
-  func_check_version_match
-
-  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
-    func_fatal_configuration "not configured to build any kind of library"
-  fi
-
-  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
-
-
-  # Darwin sucks
-  eval std_shrext=\"$shrext_cmds\"
-
-
-  # Only execute mode is allowed to have -dlopen flags.
-  if test -n "$execute_dlfiles" && test "$mode" != execute; then
-    func_error "unrecognized option \`-dlopen'"
-    $ECHO "$help" 1>&2
-    exit $EXIT_FAILURE
-  fi
-
-  # Change the help message to a mode-specific one.
-  generic_help="$help"
-  help="Try \`$progname --help --mode=$mode' for more information."
-}
-
-
-# func_lalib_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
-# This function is only a basic sanity check; it will hardly flush out
-# determined imposters.
-func_lalib_p ()
-{
-    test -f "$1" &&
-      $SED -e 4q "$1" 2>/dev/null \
-        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
-}
-
-# func_lalib_unsafe_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
-# This function implements the same check as func_lalib_p without
-# resorting to external programs.  To this end, it redirects stdin and
-# closes it afterwards, without saving the original file descriptor.
-# As a safety measure, use it only where a negative result would be
-# fatal anyway.  Works if `file' does not exist.
-func_lalib_unsafe_p ()
-{
-    lalib_p=no
-    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
-	for lalib_p_l in 1 2 3 4
-	do
-	    read lalib_p_line
-	    case "$lalib_p_line" in
-		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
-	    esac
-	done
-	exec 0<&5 5<&-
-    fi
-    test "$lalib_p" = yes
-}
-
-# func_ltwrapper_script_p file
-# True iff FILE is a libtool wrapper script
-# This function is only a basic sanity check; it will hardly flush out
-# determined imposters.
-func_ltwrapper_script_p ()
-{
-    func_lalib_p "$1"
-}
-
-# func_ltwrapper_executable_p file
-# True iff FILE is a libtool wrapper executable
-# This function is only a basic sanity check; it will hardly flush out
-# determined imposters.
-func_ltwrapper_executable_p ()
-{
-    func_ltwrapper_exec_suffix=
-    case $1 in
-    *.exe) ;;
-    *) func_ltwrapper_exec_suffix=.exe ;;
-    esac
-    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
-}
-
-# func_ltwrapper_scriptname file
-# Assumes file is an ltwrapper_executable
-# uses $file to determine the appropriate filename for a
-# temporary ltwrapper_script.
-func_ltwrapper_scriptname ()
-{
-    func_ltwrapper_scriptname_result=""
-    if func_ltwrapper_executable_p "$1"; then
-	func_dirname_and_basename "$1" "" "."
-	func_stripname '' '.exe' "$func_basename_result"
-	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
-    fi
-}
-
-# func_ltwrapper_p file
-# True iff FILE is a libtool wrapper script or wrapper executable
-# This function is only a basic sanity check; it will hardly flush out
-# determined imposters.
-func_ltwrapper_p ()
-{
-    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
-}
-
-
-# func_execute_cmds commands fail_cmd
-# Execute tilde-delimited COMMANDS.
-# If FAIL_CMD is given, eval that upon failure.
-# FAIL_CMD may read-access the current command in variable CMD!
-func_execute_cmds ()
-{
-    $opt_debug
-    save_ifs=$IFS; IFS='~'
-    for cmd in $1; do
-      IFS=$save_ifs
-      eval cmd=\"$cmd\"
-      func_show_eval "$cmd" "${2-:}"
-    done
-    IFS=$save_ifs
-}
-
-
-# func_source file
-# Source FILE, adding directory component if necessary.
-# Note that it is not necessary on cygwin/mingw to append a dot to
-# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
-# behavior happens only for exec(3), not for open(2)!  Also, sourcing
-# `FILE.' does not work on cygwin managed mounts.
-func_source ()
-{
-    $opt_debug
-    case $1 in
-    */* | *\\*)	. "$1" ;;
-    *)		. "./$1" ;;
-    esac
-}
-
-
-# func_infer_tag arg
-# Infer tagged configuration to use if any are available and
-# if one wasn't chosen via the "--tag" command line option.
-# Only attempt this if the compiler in the base compile
-# command doesn't match the default compiler.
-# arg is usually of the form 'gcc ...'
-func_infer_tag ()
-{
-    $opt_debug
-    if test -n "$available_tags" && test -z "$tagname"; then
-      CC_quoted=
-      for arg in $CC; do
-        func_quote_for_eval "$arg"
-	CC_quoted="$CC_quoted $func_quote_for_eval_result"
-      done
-      CC_expanded=`func_echo_all $CC`
-      CC_quoted_expanded=`func_echo_all $CC_quoted`
-      case $@ in
-      # Blanks in the command may have been stripped by the calling shell,
-      # but not from the CC environment variable when configure was run.
-      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
-      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
-      # Blanks at the start of $base_compile will cause this to fail
-      # if we don't check for them as well.
-      *)
-	for z in $available_tags; do
-	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
-	    # Evaluate the configuration.
-	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
-	    CC_quoted=
-	    for arg in $CC; do
-	      # Double-quote args containing other shell metacharacters.
-	      func_quote_for_eval "$arg"
-	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
-	    done
-	    CC_expanded=`func_echo_all $CC`
-	    CC_quoted_expanded=`func_echo_all $CC_quoted`
-	    case "$@ " in
-	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
-	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
-	      # The compiler in the base compile command matches
-	      # the one in the tagged configuration.
-	      # Assume this is the tagged configuration we want.
-	      tagname=$z
-	      break
-	      ;;
-	    esac
-	  fi
-	done
-	# If $tagname still isn't set, then no tagged configuration
-	# was found and let the user know that the "--tag" command
-	# line option must be used.
-	if test -z "$tagname"; then
-	  func_echo "unable to infer tagged configuration"
-	  func_fatal_error "specify a tag with \`--tag'"
-#	else
-#	  func_verbose "using $tagname tagged configuration"
-	fi
-	;;
-      esac
-    fi
-}
-
-
-
-# func_write_libtool_object output_name pic_name nonpic_name
-# Create a libtool object file (analogous to a ".la" file),
-# but don't create it if we're doing a dry run.
-func_write_libtool_object ()
-{
-    write_libobj=${1}
-    if test "$build_libtool_libs" = yes; then
-      write_lobj=\'${2}\'
-    else
-      write_lobj=none
-    fi
-
-    if test "$build_old_libs" = yes; then
-      write_oldobj=\'${3}\'
-    else
-      write_oldobj=none
-    fi
-
-    $opt_dry_run || {
-      cat >${write_libobj}T <<EOF
-# $write_libobj - a libtool object file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# Name of the PIC object.
-pic_object=$write_lobj
-
-# Name of the non-PIC object
-non_pic_object=$write_oldobj
-
-EOF
-      $MV "${write_libobj}T" "${write_libobj}"
-    }
-}
-
-# func_mode_compile arg...
-func_mode_compile ()
-{
-    $opt_debug
-    # Get the compilation command and the source file.
-    base_compile=
-    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
-    suppress_opt=yes
-    suppress_output=
-    arg_mode=normal
-    libobj=
-    later=
-    pie_flag=
-
-    for arg
-    do
-      case $arg_mode in
-      arg  )
-	# do not "continue".  Instead, add this to base_compile
-	lastarg="$arg"
-	arg_mode=normal
-	;;
-
-      target )
-	libobj="$arg"
-	arg_mode=normal
-	continue
-	;;
-
-      normal )
-	# Accept any command-line options.
-	case $arg in
-	-o)
-	  test -n "$libobj" && \
-	    func_fatal_error "you cannot specify \`-o' more than once"
-	  arg_mode=target
-	  continue
-	  ;;
-
-	-pie | -fpie | -fPIE)
-          pie_flag="$pie_flag $arg"
-	  continue
-	  ;;
-
-	-shared | -static | -prefer-pic | -prefer-non-pic)
-	  later="$later $arg"
-	  continue
-	  ;;
-
-	-no-suppress)
-	  suppress_opt=no
-	  continue
-	  ;;
-
-	-Xcompiler)
-	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
-	  continue      #  The current "srcfile" will either be retained or
-	  ;;            #  replaced later.  I would guess that would be a bug.
-
-	-Wc,*)
-	  func_stripname '-Wc,' '' "$arg"
-	  args=$func_stripname_result
-	  lastarg=
-	  save_ifs="$IFS"; IFS=','
-	  for arg in $args; do
-	    IFS="$save_ifs"
-	    func_quote_for_eval "$arg"
-	    lastarg="$lastarg $func_quote_for_eval_result"
-	  done
-	  IFS="$save_ifs"
-	  func_stripname ' ' '' "$lastarg"
-	  lastarg=$func_stripname_result
-
-	  # Add the arguments to base_compile.
-	  base_compile="$base_compile $lastarg"
-	  continue
-	  ;;
-
-	*)
-	  # Accept the current argument as the source file.
-	  # The previous "srcfile" becomes the current argument.
-	  #
-	  lastarg="$srcfile"
-	  srcfile="$arg"
-	  ;;
-	esac  #  case $arg
-	;;
-      esac    #  case $arg_mode
-
-      # Aesthetically quote the previous argument.
-      func_quote_for_eval "$lastarg"
-      base_compile="$base_compile $func_quote_for_eval_result"
-    done # for arg
-
-    case $arg_mode in
-    arg)
-      func_fatal_error "you must specify an argument for -Xcompile"
-      ;;
-    target)
-      func_fatal_error "you must specify a target with \`-o'"
-      ;;
-    *)
-      # Get the name of the library object.
-      test -z "$libobj" && {
-	func_basename "$srcfile"
-	libobj="$func_basename_result"
-      }
-      ;;
-    esac
-
-    # Recognize several different file suffixes.
-    # If the user specifies -o file.o, it is replaced with file.lo
-    case $libobj in
-    *.[cCFSifmso] | \
-    *.ada | *.adb | *.ads | *.asm | \
-    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
-    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
-      func_xform "$libobj"
-      libobj=$func_xform_result
-      ;;
-    esac
-
-    case $libobj in
-    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
-    *)
-      func_fatal_error "cannot determine name of library object from \`$libobj'"
-      ;;
-    esac
-
-    func_infer_tag $base_compile
-
-    for arg in $later; do
-      case $arg in
-      -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
-	build_old_libs=no
-	continue
-	;;
-
-      -static)
-	build_libtool_libs=no
-	build_old_libs=yes
-	continue
-	;;
-
-      -prefer-pic)
-	pic_mode=yes
-	continue
-	;;
-
-      -prefer-non-pic)
-	pic_mode=no
-	continue
-	;;
-      esac
-    done
-
-    func_quote_for_eval "$libobj"
-    test "X$libobj" != "X$func_quote_for_eval_result" \
-      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
-      && func_warning "libobj name \`$libobj' may not contain shell special characters."
-    func_dirname_and_basename "$obj" "/" ""
-    objname="$func_basename_result"
-    xdir="$func_dirname_result"
-    lobj=${xdir}$objdir/$objname
-
-    test -z "$base_compile" && \
-      func_fatal_help "you must specify a compilation command"
-
-    # Delete any leftover library objects.
-    if test "$build_old_libs" = yes; then
-      removelist="$obj $lobj $libobj ${libobj}T"
-    else
-      removelist="$lobj $libobj ${libobj}T"
-    fi
-
-    # On Cygwin there's no "real" PIC flag so we must build both object types
-    case $host_os in
-    cygwin* | mingw* | pw32* | os2* | cegcc*)
-      pic_mode=default
-      ;;
-    esac
-    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
-      # non-PIC code in shared libraries is not supported
-      pic_mode=default
-    fi
-
-    # Calculate the filename of the output object if compiler does
-    # not support -o with -c
-    if test "$compiler_c_o" = no; then
-      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
-      lockfile="$output_obj.lock"
-    else
-      output_obj=
-      need_locks=no
-      lockfile=
-    fi
-
-    # Lock this critical section if it is needed
-    # We use this script file to make the link, it avoids creating a new file
-    if test "$need_locks" = yes; then
-      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
-	func_echo "Waiting for $lockfile to be removed"
-	sleep 2
-      done
-    elif test "$need_locks" = warn; then
-      if test -f "$lockfile"; then
-	$ECHO "\
-*** ERROR, $lockfile exists and contains:
-`cat $lockfile 2>/dev/null`
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
-	$opt_dry_run || $RM $removelist
-	exit $EXIT_FAILURE
-      fi
-      removelist="$removelist $output_obj"
-      $ECHO "$srcfile" > "$lockfile"
-    fi
-
-    $opt_dry_run || $RM $removelist
-    removelist="$removelist $lockfile"
-    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
-
-    if test -n "$fix_srcfile_path"; then
-      eval srcfile=\"$fix_srcfile_path\"
-    fi
-    func_quote_for_eval "$srcfile"
-    qsrcfile=$func_quote_for_eval_result
-
-    # Only build a PIC object if we are building libtool libraries.
-    if test "$build_libtool_libs" = yes; then
-      # Without this assignment, base_compile gets emptied.
-      fbsd_hideous_sh_bug=$base_compile
-
-      if test "$pic_mode" != no; then
-	command="$base_compile $qsrcfile $pic_flag"
-      else
-	# Don't build PIC code
-	command="$base_compile $qsrcfile"
-      fi
-
-      func_mkdir_p "$xdir$objdir"
-
-      if test -z "$output_obj"; then
-	# Place PIC objects in $objdir
-	command="$command -o $lobj"
-      fi
-
-      func_show_eval_locale "$command"	\
-          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
-
-      if test "$need_locks" = warn &&
-	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
-	$ECHO "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
-	$opt_dry_run || $RM $removelist
-	exit $EXIT_FAILURE
-      fi
-
-      # Just move the object if needed, then go on to compile the next one
-      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
-	func_show_eval '$MV "$output_obj" "$lobj"' \
-	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
-      fi
-
-      # Allow error messages only from the first compilation.
-      if test "$suppress_opt" = yes; then
-	suppress_output=' >/dev/null 2>&1'
-      fi
-    fi
-
-    # Only build a position-dependent object if we build old libraries.
-    if test "$build_old_libs" = yes; then
-      if test "$pic_mode" != yes; then
-	# Don't build PIC code
-	command="$base_compile $qsrcfile$pie_flag"
-      else
-	command="$base_compile $qsrcfile $pic_flag"
-      fi
-      if test "$compiler_c_o" = yes; then
-	command="$command -o $obj"
-      fi
-
-      # Suppress compiler output if we already did a PIC compilation.
-      command="$command$suppress_output"
-      func_show_eval_locale "$command" \
-        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
-
-      if test "$need_locks" = warn &&
-	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
-	$ECHO "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
-	$opt_dry_run || $RM $removelist
-	exit $EXIT_FAILURE
-      fi
-
-      # Just move the object if needed
-      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
-	func_show_eval '$MV "$output_obj" "$obj"' \
-	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
-      fi
-    fi
-
-    $opt_dry_run || {
-      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
-
-      # Unlock the critical section if it was locked
-      if test "$need_locks" != no; then
-	removelist=$lockfile
-        $RM "$lockfile"
-      fi
-    }
-
-    exit $EXIT_SUCCESS
-}
-
-$opt_help || {
-  test "$mode" = compile && func_mode_compile ${1+"$@"}
-}
-
-func_mode_help ()
-{
-    # We need to display help for each of the modes.
-    case $mode in
-      "")
-        # Generic help is extracted from the usage comments
-        # at the start of this file.
-        func_help
-        ;;
-
-      clean)
-        $ECHO \
-"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
-
-Remove files from the build directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, object or program, all the files associated
-with it are deleted. Otherwise, only FILE itself is deleted using RM."
-        ;;
-
-      compile)
-      $ECHO \
-"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
-
-Compile a source file into a libtool library object.
-
-This mode accepts the following additional options:
-
-  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
-  -no-suppress      do not suppress compiler output for multiple passes
-  -prefer-pic       try to build PIC objects only
-  -prefer-non-pic   try to build non-PIC objects only
-  -shared           do not build a \`.o' file suitable for static linking
-  -static           only build a \`.o' file suitable for static linking
-  -Wc,FLAG          pass FLAG directly to the compiler
-
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
-from the given SOURCEFILE.
-
-The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
-        ;;
-
-      execute)
-        $ECHO \
-"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
-
-Automatically set library path, then run a program.
-
-This mode accepts the following additional options:
-
-  -dlopen FILE      add the directory containing FILE to the library path
-
-This mode sets the library path environment variable according to \`-dlopen'
-flags.
-
-If any of the ARGS are libtool executable wrappers, then they are translated
-into their corresponding uninstalled binary, and any of their required library
-directories are added to the library path.
-
-Then, COMMAND is executed, with ARGS as arguments."
-        ;;
-
-      finish)
-        $ECHO \
-"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
-
-Complete the installation of libtool libraries.
-
-Each LIBDIR is a directory that contains libtool libraries.
-
-The commands that this mode executes may require superuser privileges.  Use
-the \`--dry-run' option if you just want to see what would be executed."
-        ;;
-
-      install)
-        $ECHO \
-"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
-
-Install executables or libraries.
-
-INSTALL-COMMAND is the installation command.  The first component should be
-either the \`install' or \`cp' program.
-
-The following components of INSTALL-COMMAND are treated specially:
-
-  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
-
-The rest of the components are interpreted as arguments to that command (only
-BSD-compatible install options are recognized)."
-        ;;
-
-      link)
-        $ECHO \
-"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
-
-Link object files or libraries together to form another library, or to
-create an executable program.
-
-LINK-COMMAND is a command using the C compiler that you would use to create
-a program from several object files.
-
-The following components of LINK-COMMAND are treated specially:
-
-  -all-static       do not do any dynamic linking at all
-  -avoid-version    do not add a version suffix if possible
-  -bindir BINDIR    specify path to binaries directory (for systems where
-                    libraries must be found in the PATH setting at runtime)
-  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
-  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
-  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
-  -export-symbols SYMFILE
-                    try to export only the symbols listed in SYMFILE
-  -export-symbols-regex REGEX
-                    try to export only the symbols matching REGEX
-  -LLIBDIR          search LIBDIR for required installed libraries
-  -lNAME            OUTPUT-FILE requires the installed library libNAME
-  -module           build a library that can dlopened
-  -no-fast-install  disable the fast-install mode
-  -no-install       link a not-installable executable
-  -no-undefined     declare that a library does not refer to external symbols
-  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
-  -objectlist FILE  Use a list of object files found in FILE to specify objects
-  -precious-files-regex REGEX
-                    don't remove output files matching REGEX
-  -release RELEASE  specify package release information
-  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
-  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
-  -shared           only do dynamic linking of libtool libraries
-  -shrext SUFFIX    override the standard shared library file extension
-  -static           do not do any dynamic linking of uninstalled libtool libraries
-  -static-libtool-libs
-                    do not do any dynamic linking of libtool libraries
-  -version-info CURRENT[:REVISION[:AGE]]
-                    specify library version info [each variable defaults to 0]
-  -weak LIBNAME     declare that the target provides the LIBNAME interface
-  -Wc,FLAG
-  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
-  -Wl,FLAG
-  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
-  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
-
-All other options (arguments beginning with \`-') are ignored.
-
-Every other argument is treated as a filename.  Files ending in \`.la' are
-treated as uninstalled libtool libraries, other files are standard or library
-object files.
-
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
-required, except when creating a convenience library.
-
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
-
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
-is created, otherwise an executable program is created."
-        ;;
-
-      uninstall)
-        $ECHO \
-"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
-
-Remove libraries from an installation directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, all the files associated with it are deleted.
-Otherwise, only FILE itself is deleted using RM."
-        ;;
-
-      *)
-        func_fatal_help "invalid operation mode \`$mode'"
-        ;;
-    esac
-
-    echo
-    $ECHO "Try \`$progname --help' for more information about other modes."
-}
-
-# Now that we've collected a possible --mode arg, show help if necessary
-if $opt_help; then
-  if test "$opt_help" = :; then
-    func_mode_help
-  else
-    {
-      func_help noexit
-      for mode in compile link execute install finish uninstall clean; do
-	func_mode_help
-      done
-    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
-    {
-      func_help noexit
-      for mode in compile link execute install finish uninstall clean; do
-	echo
-	func_mode_help
-      done
-    } |
-    sed '1d
-      /^When reporting/,/^Report/{
-	H
-	d
-      }
-      $x
-      /information about other modes/d
-      /more detailed .*MODE/d
-      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
-  fi
-  exit $?
-fi
-
-
-# func_mode_execute arg...
-func_mode_execute ()
-{
-    $opt_debug
-    # The first argument is the command name.
-    cmd="$nonopt"
-    test -z "$cmd" && \
-      func_fatal_help "you must specify a COMMAND"
-
-    # Handle -dlopen flags immediately.
-    for file in $execute_dlfiles; do
-      test -f "$file" \
-	|| func_fatal_help "\`$file' is not a file"
-
-      dir=
-      case $file in
-      *.la)
-	# Check to see that this really is a libtool archive.
-	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$lib' is not a valid libtool archive"
-
-	# Read the libtool library.
-	dlname=
-	library_names=
-	func_source "$file"
-
-	# Skip this library if it cannot be dlopened.
-	if test -z "$dlname"; then
-	  # Warn if it was a shared library.
-	  test -n "$library_names" && \
-	    func_warning "\`$file' was not linked with \`-export-dynamic'"
-	  continue
-	fi
-
-	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
-
-	if test -f "$dir/$objdir/$dlname"; then
-	  dir="$dir/$objdir"
-	else
-	  if test ! -f "$dir/$dlname"; then
-	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
-	  fi
-	fi
-	;;
-
-      *.lo)
-	# Just add the directory containing the .lo file.
-	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
-	;;
-
-      *)
-	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
-	continue
-	;;
-      esac
-
-      # Get the absolute pathname.
-      absdir=`cd "$dir" && pwd`
-      test -n "$absdir" && dir="$absdir"
-
-      # Now add the directory to shlibpath_var.
-      if eval "test -z \"\$$shlibpath_var\""; then
-	eval "$shlibpath_var=\"\$dir\""
-      else
-	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
-      fi
-    done
-
-    # This variable tells wrapper scripts just to set shlibpath_var
-    # rather than running their programs.
-    libtool_execute_magic="$magic"
-
-    # Check if any of the arguments is a wrapper script.
-    args=
-    for file
-    do
-      case $file in
-      -* | *.la | *.lo ) ;;
-      *)
-	# Do a test to see if this is really a libtool program.
-	if func_ltwrapper_script_p "$file"; then
-	  func_source "$file"
-	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
-	elif func_ltwrapper_executable_p "$file"; then
-	  func_ltwrapper_scriptname "$file"
-	  func_source "$func_ltwrapper_scriptname_result"
-	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
-	fi
-	;;
-      esac
-      # Quote arguments (to preserve shell metacharacters).
-      func_quote_for_eval "$file"
-      args="$args $func_quote_for_eval_result"
-    done
-
-    if test "X$opt_dry_run" = Xfalse; then
-      if test -n "$shlibpath_var"; then
-	# Export the shlibpath_var.
-	eval "export $shlibpath_var"
-      fi
-
-      # Restore saved environment variables
-      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
-      do
-	eval "if test \"\${save_$lt_var+set}\" = set; then
-                $lt_var=\$save_$lt_var; export $lt_var
-	      else
-		$lt_unset $lt_var
-	      fi"
-      done
-
-      # Now prepare to actually exec the command.
-      exec_cmd="\$cmd$args"
-    else
-      # Display what would be done.
-      if test -n "$shlibpath_var"; then
-	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
-	echo "export $shlibpath_var"
-      fi
-      $ECHO "$cmd$args"
-      exit $EXIT_SUCCESS
-    fi
-}
-
-test "$mode" = execute && func_mode_execute ${1+"$@"}
-
-
-# func_mode_finish arg...
-func_mode_finish ()
-{
-    $opt_debug
-    libdirs="$nonopt"
-    admincmds=
-
-    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
-      for dir
-      do
-	libdirs="$libdirs $dir"
-      done
-
-      for libdir in $libdirs; do
-	if test -n "$finish_cmds"; then
-	  # Do each command in the finish commands.
-	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
-'"$cmd"'"'
-	fi
-	if test -n "$finish_eval"; then
-	  # Do the single finish_eval.
-	  eval cmds=\"$finish_eval\"
-	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
-       $cmds"
-	fi
-      done
-    fi
-
-    # Exit here if they wanted silent mode.
-    $opt_silent && exit $EXIT_SUCCESS
-
-    echo "----------------------------------------------------------------------"
-    echo "Libraries have been installed in:"
-    for libdir in $libdirs; do
-      $ECHO "   $libdir"
-    done
-    echo
-    echo "If you ever happen to want to link against installed libraries"
-    echo "in a given directory, LIBDIR, you must either use libtool, and"
-    echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
-    echo "flag during linking and do at least one of the following:"
-    if test -n "$shlibpath_var"; then
-      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
-      echo "     during execution"
-    fi
-    if test -n "$runpath_var"; then
-      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
-      echo "     during linking"
-    fi
-    if test -n "$hardcode_libdir_flag_spec"; then
-      libdir=LIBDIR
-      eval flag=\"$hardcode_libdir_flag_spec\"
-
-      $ECHO "   - use the \`$flag' linker flag"
-    fi
-    if test -n "$admincmds"; then
-      $ECHO "   - have your system administrator run these commands:$admincmds"
-    fi
-    if test -f /etc/ld.so.conf; then
-      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
-    fi
-    echo
-
-    echo "See any operating system documentation about shared libraries for"
-    case $host in
-      solaris2.[6789]|solaris2.1[0-9])
-        echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
-	echo "pages."
-	;;
-      *)
-        echo "more information, such as the ld(1) and ld.so(8) manual pages."
-        ;;
-    esac
-    echo "----------------------------------------------------------------------"
-    exit $EXIT_SUCCESS
-}
-
-test "$mode" = finish && func_mode_finish ${1+"$@"}
-
-
-# func_mode_install arg...
-func_mode_install ()
-{
-    $opt_debug
-    # There may be an optional sh(1) argument at the beginning of
-    # install_prog (especially on Windows NT).
-    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
-       # Allow the use of GNU shtool's install command.
-       case $nonopt in *shtool*) :;; *) false;; esac; then
-      # Aesthetically quote it.
-      func_quote_for_eval "$nonopt"
-      install_prog="$func_quote_for_eval_result "
-      arg=$1
-      shift
-    else
-      install_prog=
-      arg=$nonopt
-    fi
-
-    # The real first argument should be the name of the installation program.
-    # Aesthetically quote it.
-    func_quote_for_eval "$arg"
-    install_prog="$install_prog$func_quote_for_eval_result"
-    install_shared_prog=$install_prog
-    case " $install_prog " in
-      *[\\\ /]cp\ *) install_cp=: ;;
-      *) install_cp=false ;;
-    esac
-
-    # We need to accept at least all the BSD install flags.
-    dest=
-    files=
-    opts=
-    prev=
-    install_type=
-    isdir=no
-    stripme=
-    no_mode=:
-    for arg
-    do
-      arg2=
-      if test -n "$dest"; then
-	files="$files $dest"
-	dest=$arg
-	continue
-      fi
-
-      case $arg in
-      -d) isdir=yes ;;
-      -f)
-	if $install_cp; then :; else
-	  prev=$arg
-	fi
-	;;
-      -g | -m | -o)
-	prev=$arg
-	;;
-      -s)
-	stripme=" -s"
-	continue
-	;;
-      -*)
-	;;
-      *)
-	# If the previous option needed an argument, then skip it.
-	if test -n "$prev"; then
-	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
-	    arg2=$install_override_mode
-	    no_mode=false
-	  fi
-	  prev=
-	else
-	  dest=$arg
-	  continue
-	fi
-	;;
-      esac
-
-      # Aesthetically quote the argument.
-      func_quote_for_eval "$arg"
-      install_prog="$install_prog $func_quote_for_eval_result"
-      if test -n "$arg2"; then
-	func_quote_for_eval "$arg2"
-      fi
-      install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
-    done
-
-    test -z "$install_prog" && \
-      func_fatal_help "you must specify an install program"
-
-    test -n "$prev" && \
-      func_fatal_help "the \`$prev' option requires an argument"
-
-    if test -n "$install_override_mode" && $no_mode; then
-      if $install_cp; then :; else
-	func_quote_for_eval "$install_override_mode"
-	install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
-      fi
-    fi
-
-    if test -z "$files"; then
-      if test -z "$dest"; then
-	func_fatal_help "no file or destination specified"
-      else
-	func_fatal_help "you must specify a destination"
-      fi
-    fi
-
-    # Strip any trailing slash from the destination.
-    func_stripname '' '/' "$dest"
-    dest=$func_stripname_result
-
-    # Check to see that the destination is a directory.
-    test -d "$dest" && isdir=yes
-    if test "$isdir" = yes; then
-      destdir="$dest"
-      destname=
-    else
-      func_dirname_and_basename "$dest" "" "."
-      destdir="$func_dirname_result"
-      destname="$func_basename_result"
-
-      # Not a directory, so check to see that there is only one file specified.
-      set dummy $files; shift
-      test "$#" -gt 1 && \
-	func_fatal_help "\`$dest' is not a directory"
-    fi
-    case $destdir in
-    [\\/]* | [A-Za-z]:[\\/]*) ;;
-    *)
-      for file in $files; do
-	case $file in
-	*.lo) ;;
-	*)
-	  func_fatal_help "\`$destdir' must be an absolute directory name"
-	  ;;
-	esac
-      done
-      ;;
-    esac
-
-    # This variable tells wrapper scripts just to set variables rather
-    # than running their programs.
-    libtool_install_magic="$magic"
-
-    staticlibs=
-    future_libdirs=
-    current_libdirs=
-    for file in $files; do
-
-      # Do each installation.
-      case $file in
-      *.$libext)
-	# Do the static libraries later.
-	staticlibs="$staticlibs $file"
-	;;
-
-      *.la)
-	# Check to see that this really is a libtool archive.
-	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$file' is not a valid libtool archive"
-
-	library_names=
-	old_library=
-	relink_command=
-	func_source "$file"
-
-	# Add the libdir to current_libdirs if it is the destination.
-	if test "X$destdir" = "X$libdir"; then
-	  case "$current_libdirs " in
-	  *" $libdir "*) ;;
-	  *) current_libdirs="$current_libdirs $libdir" ;;
-	  esac
-	else
-	  # Note the libdir as a future libdir.
-	  case "$future_libdirs " in
-	  *" $libdir "*) ;;
-	  *) future_libdirs="$future_libdirs $libdir" ;;
-	  esac
-	fi
-
-	func_dirname "$file" "/" ""
-	dir="$func_dirname_result"
-	dir="$dir$objdir"
-
-	if test -n "$relink_command"; then
-	  # Determine the prefix the user has applied to our future dir.
-	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
-
-	  # Don't allow the user to place us outside of our expected
-	  # location b/c this prevents finding dependent libraries that
-	  # are installed to the same prefix.
-	  # At present, this check doesn't affect windows .dll's that
-	  # are installed into $libdir/../bin (currently, that works fine)
-	  # but it's something to keep an eye on.
-	  test "$inst_prefix_dir" = "$destdir" && \
-	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
-
-	  if test -n "$inst_prefix_dir"; then
-	    # Stick the inst_prefix_dir data into the link command.
-	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
-	  else
-	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
-	  fi
-
-	  func_warning "relinking \`$file'"
-	  func_show_eval "$relink_command" \
-	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
-	fi
-
-	# See the names of the shared library.
-	set dummy $library_names; shift
-	if test -n "$1"; then
-	  realname="$1"
-	  shift
-
-	  srcname="$realname"
-	  test -n "$relink_command" && srcname="$realname"T
-
-	  # Install the shared library and build the symlinks.
-	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
-	      'exit $?'
-	  tstripme="$stripme"
-	  case $host_os in
-	  cygwin* | mingw* | pw32* | cegcc*)
-	    case $realname in
-	    *.dll.a)
-	      tstripme=""
-	      ;;
-	    esac
-	    ;;
-	  esac
-	  if test -n "$tstripme" && test -n "$striplib"; then
-	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
-	  fi
-
-	  if test "$#" -gt 0; then
-	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
-	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
-	    # so we also need to try rm && ln -s.
-	    for linkname
-	    do
-	      test "$linkname" != "$realname" \
-		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
-	    done
-	  fi
-
-	  # Do each command in the postinstall commands.
-	  lib="$destdir/$realname"
-	  func_execute_cmds "$postinstall_cmds" 'exit $?'
-	fi
-
-	# Install the pseudo-library for information purposes.
-	func_basename "$file"
-	name="$func_basename_result"
-	instname="$dir/$name"i
-	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
-
-	# Maybe install the static library, too.
-	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
-	;;
-
-      *.lo)
-	# Install (i.e. copy) a libtool object.
-
-	# Figure out destination file name, if it wasn't already specified.
-	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
-	else
-	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
-	fi
-
-	# Deduce the name of the destination old-style object file.
-	case $destfile in
-	*.lo)
-	  func_lo2o "$destfile"
-	  staticdest=$func_lo2o_result
-	  ;;
-	*.$objext)
-	  staticdest="$destfile"
-	  destfile=
-	  ;;
-	*)
-	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
-	  ;;
-	esac
-
-	# Install the libtool object if requested.
-	test -n "$destfile" && \
-	  func_show_eval "$install_prog $file $destfile" 'exit $?'
-
-	# Install the old object if enabled.
-	if test "$build_old_libs" = yes; then
-	  # Deduce the name of the old-style object file.
-	  func_lo2o "$file"
-	  staticobj=$func_lo2o_result
-	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
-	fi
-	exit $EXIT_SUCCESS
-	;;
-
-      *)
-	# Figure out destination file name, if it wasn't already specified.
-	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
-	else
-	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
-	fi
-
-	# If the file is missing, and there is a .exe on the end, strip it
-	# because it is most likely a libtool script we actually want to
-	# install
-	stripped_ext=""
-	case $file in
-	  *.exe)
-	    if test ! -f "$file"; then
-	      func_stripname '' '.exe' "$file"
-	      file=$func_stripname_result
-	      stripped_ext=".exe"
-	    fi
-	    ;;
-	esac
-
-	# Do a test to see if this is really a libtool program.
-	case $host in
-	*cygwin* | *mingw*)
-	    if func_ltwrapper_executable_p "$file"; then
-	      func_ltwrapper_scriptname "$file"
-	      wrapper=$func_ltwrapper_scriptname_result
-	    else
-	      func_stripname '' '.exe' "$file"
-	      wrapper=$func_stripname_result
-	    fi
-	    ;;
-	*)
-	    wrapper=$file
-	    ;;
-	esac
-	if func_ltwrapper_script_p "$wrapper"; then
-	  notinst_deplibs=
-	  relink_command=
-
-	  func_source "$wrapper"
-
-	  # Check the variables that should have been set.
-	  test -z "$generated_by_libtool_version" && \
-	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
-
-	  finalize=yes
-	  for lib in $notinst_deplibs; do
-	    # Check to see that each library is installed.
-	    libdir=
-	    if test -f "$lib"; then
-	      func_source "$lib"
-	    fi
-	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
-	    if test -n "$libdir" && test ! -f "$libfile"; then
-	      func_warning "\`$lib' has not been installed in \`$libdir'"
-	      finalize=no
-	    fi
-	  done
-
-	  relink_command=
-	  func_source "$wrapper"
-
-	  outputname=
-	  if test "$fast_install" = no && test -n "$relink_command"; then
-	    $opt_dry_run || {
-	      if test "$finalize" = yes; then
-	        tmpdir=`func_mktempdir`
-		func_basename "$file$stripped_ext"
-		file="$func_basename_result"
-	        outputname="$tmpdir/$file"
-	        # Replace the output file specification.
-	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
-
-	        $opt_silent || {
-	          func_quote_for_expand "$relink_command"
-		  eval "func_echo $func_quote_for_expand_result"
-	        }
-	        if eval "$relink_command"; then :
-	          else
-		  func_error "error: relink \`$file' with the above command before installing it"
-		  $opt_dry_run || ${RM}r "$tmpdir"
-		  continue
-	        fi
-	        file="$outputname"
-	      else
-	        func_warning "cannot relink \`$file'"
-	      fi
-	    }
-	  else
-	    # Install the binary that we compiled earlier.
-	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
-	  fi
-	fi
-
-	# remove .exe since cygwin /usr/bin/install will append another
-	# one anyway
-	case $install_prog,$host in
-	*/usr/bin/install*,*cygwin*)
-	  case $file:$destfile in
-	  *.exe:*.exe)
-	    # this is ok
-	    ;;
-	  *.exe:*)
-	    destfile=$destfile.exe
-	    ;;
-	  *:*.exe)
-	    func_stripname '' '.exe' "$destfile"
-	    destfile=$func_stripname_result
-	    ;;
-	  esac
-	  ;;
-	esac
-	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
-	$opt_dry_run || if test -n "$outputname"; then
-	  ${RM}r "$tmpdir"
-	fi
-	;;
-      esac
-    done
-
-    for file in $staticlibs; do
-      func_basename "$file"
-      name="$func_basename_result"
-
-      # Set up the ranlib parameters.
-      oldlib="$destdir/$name"
-
-      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
-
-      if test -n "$stripme" && test -n "$old_striplib"; then
-	func_show_eval "$old_striplib $oldlib" 'exit $?'
-      fi
-
-      # Do each command in the postinstall commands.
-      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
-    done
-
-    test -n "$future_libdirs" && \
-      func_warning "remember to run \`$progname --finish$future_libdirs'"
-
-    if test -n "$current_libdirs"; then
-      # Maybe just do a dry run.
-      $opt_dry_run && current_libdirs=" -n$current_libdirs"
-      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
-    else
-      exit $EXIT_SUCCESS
-    fi
-}
-
-test "$mode" = install && func_mode_install ${1+"$@"}
-
-
-# func_generate_dlsyms outputname originator pic_p
-# Extract symbols from dlprefiles and create ${outputname}S.o with
-# a dlpreopen symbol table.
-func_generate_dlsyms ()
-{
-    $opt_debug
-    my_outputname="$1"
-    my_originator="$2"
-    my_pic_p="${3-no}"
-    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
-    my_dlsyms=
-
-    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-      if test -n "$NM" && test -n "$global_symbol_pipe"; then
-	my_dlsyms="${my_outputname}S.c"
-      else
-	func_error "not configured to extract global symbols from dlpreopened files"
-      fi
-    fi
-
-    if test -n "$my_dlsyms"; then
-      case $my_dlsyms in
-      "") ;;
-      *.c)
-	# Discover the nlist of each of the dlfiles.
-	nlist="$output_objdir/${my_outputname}.nm"
-
-	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
-
-	# Parse the name list into a source file.
-	func_verbose "creating $output_objdir/$my_dlsyms"
-
-	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
-/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
-/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
-
-#ifdef __cplusplus
-extern \"C\" {
-#endif
-
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
-#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
-#endif
-
-/* External symbol declarations for the compiler. */\
-"
-
-	if test "$dlself" = yes; then
-	  func_verbose "generating symbol list for \`$output'"
-
-	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
-
-	  # Add our own program objects to the symbol list.
-	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
-	  for progfile in $progfiles; do
-	    func_verbose "extracting global C symbols from \`$progfile'"
-	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
-	  done
-
-	  if test -n "$exclude_expsyms"; then
-	    $opt_dry_run || {
-	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
-	      eval '$MV "$nlist"T "$nlist"'
-	    }
-	  fi
-
-	  if test -n "$export_symbols_regex"; then
-	    $opt_dry_run || {
-	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
-	      eval '$MV "$nlist"T "$nlist"'
-	    }
-	  fi
-
-	  # Prepare the list of exported symbols
-	  if test -z "$export_symbols"; then
-	    export_symbols="$output_objdir/$outputname.exp"
-	    $opt_dry_run || {
-	      $RM $export_symbols
-	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
-	      case $host in
-	      *cygwin* | *mingw* | *cegcc* )
-                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
-	        ;;
-	      esac
-	    }
-	  else
-	    $opt_dry_run || {
-	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
-	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
-	      eval '$MV "$nlist"T "$nlist"'
-	      case $host in
-	        *cygwin* | *mingw* | *cegcc* )
-	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
-	          ;;
-	      esac
-	    }
-	  fi
-	fi
-
-	for dlprefile in $dlprefiles; do
-	  func_verbose "extracting global C symbols from \`$dlprefile'"
-	  func_basename "$dlprefile"
-	  name="$func_basename_result"
-	  $opt_dry_run || {
-	    eval '$ECHO ": $name " >> "$nlist"'
-	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
-	  }
-	done
-
-	$opt_dry_run || {
-	  # Make sure we have at least an empty file.
-	  test -f "$nlist" || : > "$nlist"
-
-	  if test -n "$exclude_expsyms"; then
-	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
-	    $MV "$nlist"T "$nlist"
-	  fi
-
-	  # Try sorting and uniquifying the output.
-	  if $GREP -v "^: " < "$nlist" |
-	      if sort -k 3 </dev/null >/dev/null 2>&1; then
-		sort -k 3
-	      else
-		sort +2
-	      fi |
-	      uniq > "$nlist"S; then
-	    :
-	  else
-	    $GREP -v "^: " < "$nlist" > "$nlist"S
-	  fi
-
-	  if test -f "$nlist"S; then
-	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
-	  else
-	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
-	  fi
-
-	  echo >> "$output_objdir/$my_dlsyms" "\
-
-/* The mapping between symbol names and symbols.  */
-typedef struct {
-  const char *name;
-  void *address;
-} lt_dlsymlist;
-"
-	  case $host in
-	  *cygwin* | *mingw* | *cegcc* )
-	    echo >> "$output_objdir/$my_dlsyms" "\
-/* DATA imports from DLLs on WIN32 con't be const, because
-   runtime relocations are performed -- see ld's documentation
-   on pseudo-relocs.  */"
-	    lt_dlsym_const= ;;
-	  *osf5*)
-	    echo >> "$output_objdir/$my_dlsyms" "\
-/* This system does not cope well with relocations in const data */"
-	    lt_dlsym_const= ;;
-	  *)
-	    lt_dlsym_const=const ;;
-	  esac
-
-	  echo >> "$output_objdir/$my_dlsyms" "\
-extern $lt_dlsym_const lt_dlsymlist
-lt_${my_prefix}_LTX_preloaded_symbols[];
-$lt_dlsym_const lt_dlsymlist
-lt_${my_prefix}_LTX_preloaded_symbols[] =
-{\
-  { \"$my_originator\", (void *) 0 },"
-
-	  case $need_lib_prefix in
-	  no)
-	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
-	    ;;
-	  *)
-	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
-	    ;;
-	  esac
-	  echo >> "$output_objdir/$my_dlsyms" "\
-  {0, (void *) 0}
-};
-
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
-  return lt_${my_prefix}_LTX_preloaded_symbols;
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif\
-"
-	} # !$opt_dry_run
-
-	pic_flag_for_symtable=
-	case "$compile_command " in
-	*" -static "*) ;;
-	*)
-	  case $host in
-	  # compiling the symbol table file with pic_flag works around
-	  # a FreeBSD bug that causes programs to crash when -lm is
-	  # linked before any other PIC object.  But we must not use
-	  # pic_flag when linking with -static.  The problem exists in
-	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
-	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
-	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
-	  *-*-hpux*)
-	    pic_flag_for_symtable=" $pic_flag"  ;;
-	  *)
-	    if test "X$my_pic_p" != Xno; then
-	      pic_flag_for_symtable=" $pic_flag"
-	    fi
-	    ;;
-	  esac
-	  ;;
-	esac
-	symtab_cflags=
-	for arg in $LTCFLAGS; do
-	  case $arg in
-	  -pie | -fpie | -fPIE) ;;
-	  *) symtab_cflags="$symtab_cflags $arg" ;;
-	  esac
-	done
-
-	# Now compile the dynamic symbol file.
-	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
-
-	# Clean up the generated files.
-	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
-
-	# Transform the symbol file into the correct name.
-	symfileobj="$output_objdir/${my_outputname}S.$objext"
-	case $host in
-	*cygwin* | *mingw* | *cegcc* )
-	  if test -f "$output_objdir/$my_outputname.def"; then
-	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
-	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
-	  else
-	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
-	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
-	  fi
-	  ;;
-	*)
-	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
-	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
-	  ;;
-	esac
-	;;
-      *)
-	func_fatal_error "unknown suffix for \`$my_dlsyms'"
-	;;
-      esac
-    else
-      # We keep going just in case the user didn't refer to
-      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
-      # really was required.
-
-      # Nullify the symbol file.
-      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
-      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
-    fi
-}
-
-# func_win32_libid arg
-# return the library type of file 'arg'
-#
-# Need a lot of goo to handle *both* DLLs and import libs
-# Has to be a shell function in order to 'eat' the argument
-# that is supplied when $file_magic_command is called.
-# Despite the name, also deal with 64 bit binaries.
-func_win32_libid ()
-{
-  $opt_debug
-  win32_libid_type="unknown"
-  win32_fileres=`file -L $1 2>/dev/null`
-  case $win32_fileres in
-  *ar\ archive\ import\ library*) # definitely import
-    win32_libid_type="x86 archive import"
-    ;;
-  *ar\ archive*) # could be an import, or static
-    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
-    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
-       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
-      win32_nmres=`eval $NM -f posix -A $1 |
-	$SED -n -e '
-	    1,100{
-		/ I /{
-		    s,.*,import,
-		    p
-		    q
-		}
-	    }'`
-      case $win32_nmres in
-      import*)  win32_libid_type="x86 archive import";;
-      *)        win32_libid_type="x86 archive static";;
-      esac
-    fi
-    ;;
-  *DLL*)
-    win32_libid_type="x86 DLL"
-    ;;
-  *executable*) # but shell scripts are "executable" too...
-    case $win32_fileres in
-    *MS\ Windows\ PE\ Intel*)
-      win32_libid_type="x86 DLL"
-      ;;
-    esac
-    ;;
-  esac
-  $ECHO "$win32_libid_type"
-}
-
-
-
-# func_extract_an_archive dir oldlib
-func_extract_an_archive ()
-{
-    $opt_debug
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-    if test "$lock_old_archive_extraction" = yes; then
-      lockfile=$f_ex_an_ar_oldlib.lock
-      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
-	func_echo "Waiting for $lockfile to be removed"
-	sleep 2
-      done
-    fi
-    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
-		   'stat=$?; rm -f "$lockfile"; exit $stat'
-    if test "$lock_old_archive_extraction" = yes; then
-      $opt_dry_run || rm -f "$lockfile"
-    fi
-    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
-     :
-    else
-      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
-    fi
-}
-
-
-# func_extract_archives gentop oldlib ...
-func_extract_archives ()
-{
-    $opt_debug
-    my_gentop="$1"; shift
-    my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
-
-    for my_xlib in $my_oldlibs; do
-      # Extract the objects.
-      case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
-	*) my_xabs=`pwd`"/$my_xlib" ;;
-      esac
-      func_basename "$my_xlib"
-      my_xlib="$func_basename_result"
-      my_xlib_u=$my_xlib
-      while :; do
-        case " $extracted_archives " in
-	*" $my_xlib_u "*)
-	  func_arith $extracted_serial + 1
-	  extracted_serial=$func_arith_result
-	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
-	*) break ;;
-	esac
-      done
-      extracted_archives="$extracted_archives $my_xlib_u"
-      my_xdir="$my_gentop/$my_xlib_u"
-
-      func_mkdir_p "$my_xdir"
-
-      case $host in
-      *-darwin*)
-	func_verbose "Extracting $my_xabs"
-	# Do not bother doing anything if just a dry run
-	$opt_dry_run || {
-	  darwin_orig_dir=`pwd`
-	  cd $my_xdir || exit $?
-	  darwin_archive=$my_xabs
-	  darwin_curdir=`pwd`
-	  darwin_base_archive=`basename "$darwin_archive"`
-	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
-	  if test -n "$darwin_arches"; then
-	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
-	    darwin_arch=
-	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
-	      cd "$darwin_curdir"
-	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
-	    done # $darwin_arches
-            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
-	    darwin_file=
-	    darwin_files=
-	    for darwin_file in $darwin_filelist; do
-	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
-	      $LIPO -create -output "$darwin_file" $darwin_files
-	    done # $darwin_filelist
-	    $RM -rf unfat-$$
-	    cd "$darwin_orig_dir"
-	  else
-	    cd $darwin_orig_dir
-	    func_extract_an_archive "$my_xdir" "$my_xabs"
-	  fi # $darwin_arches
-	} # !$opt_dry_run
-	;;
-      *)
-        func_extract_an_archive "$my_xdir" "$my_xabs"
-	;;
-      esac
-      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
-    done
-
-    func_extract_archives_result="$my_oldobjs"
-}
-
-
-# func_emit_wrapper [arg=no]
-#
-# Emit a libtool wrapper script on stdout.
-# Don't directly open a file because we may want to
-# incorporate the script contents within a cygwin/mingw
-# wrapper executable.  Must ONLY be called from within
-# func_mode_link because it depends on a number of variables
-# set therein.
-#
-# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
-# variable will take.  If 'yes', then the emitted script
-# will assume that the directory in which it is stored is
-# the $objdir directory.  This is a cygwin/mingw-specific
-# behavior.
-func_emit_wrapper ()
-{
-	func_emit_wrapper_arg1=${1-no}
-
-	$ECHO "\
-#! $SHELL
-
-# $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
-#
-# The $output program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-sed_quote_subst='$sed_quote_subst'
-
-# Be Bourne compatible
-if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '\${1+\"\$@\"}'='\"\$@\"'
-  setopt NO_GLOB_SUBST
-else
-  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-relink_command=\"$relink_command\"
-
-# This environment variable determines our operation mode.
-if test \"\$libtool_install_magic\" = \"$magic\"; then
-  # install mode needs the following variables:
-  generated_by_libtool_version='$macro_version'
-  notinst_deplibs='$notinst_deplibs'
-else
-  # When we are sourced in execute mode, \$file and \$ECHO are already set.
-  if test \"\$libtool_execute_magic\" != \"$magic\"; then
-    file=\"\$0\""
-
-    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
-    $ECHO "\
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-\$1
-_LTECHO_EOF'
-}
-    ECHO=\"$qECHO\"
-  fi
-
-# Very basic option parsing. These options are (a) specific to
-# the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
-# windows platforms, and (c) all begin with the string "--lt-"
-# (application programs are unlikely to have options which match
-# this pattern).
-#
-# There are only two supported options: --lt-debug and
-# --lt-dump-script. There is, deliberately, no --lt-help.
-#
-# The first argument to this parsing function should be the
-# script's $0 value, followed by "$@".
-lt_option_debug=
-func_parse_lt_options ()
-{
-  lt_script_arg0=\$0
-  shift
-  for lt_opt
-  do
-    case \"\$lt_opt\" in
-    --lt-debug) lt_option_debug=1 ;;
-    --lt-dump-script)
-        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
-        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
-        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
-        cat \"\$lt_dump_D/\$lt_dump_F\"
-        exit 0
-      ;;
-    --lt-*)
-        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
-        exit 1
-      ;;
-    esac
-  done
-
-  # Print the debug banner immediately:
-  if test -n \"\$lt_option_debug\"; then
-    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
-  fi
-}
-
-# Used when --lt-debug. Prints its arguments to stdout
-# (redirection is the responsibility of the caller)
-func_lt_dump_args ()
-{
-  lt_dump_args_N=1;
-  for lt_arg
-  do
-    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
-    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
-  done
-}
-
-# Core function for launching the target application
-func_exec_program_core ()
-{
-"
-  case $host in
-  # Backslashes separate directories on plain windows
-  *-*-mingw | *-*-os2* | *-cegcc*)
-    $ECHO "\
-      if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
-        func_lt_dump_args \${1+\"\$@\"} 1>&2
-      fi
-      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
-"
-    ;;
-
-  *)
-    $ECHO "\
-      if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
-        func_lt_dump_args \${1+\"\$@\"} 1>&2
-      fi
-      exec \"\$progdir/\$program\" \${1+\"\$@\"}
-"
-    ;;
-  esac
-  $ECHO "\
-      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
-      exit 1
-}
-
-# A function to encapsulate launching the target application
-# Strips options in the --lt-* namespace from \$@ and
-# launches target application with the remaining arguments.
-func_exec_program ()
-{
-  for lt_wr_arg
-  do
-    case \$lt_wr_arg in
-    --lt-*) ;;
-    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
-    esac
-    shift
-  done
-  func_exec_program_core \${1+\"\$@\"}
-}
-
-  # Parse options
-  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
-
-  # Find the directory that this script lives in.
-  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
-  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
-
-  # Follow symbolic links until we get to the real thisdir.
-  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
-  while test -n \"\$file\"; do
-    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
-
-    # If there was a directory component, then change thisdir.
-    if test \"x\$destdir\" != \"x\$file\"; then
-      case \"\$destdir\" in
-      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
-      *) thisdir=\"\$thisdir/\$destdir\" ;;
-      esac
-    fi
-
-    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
-    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
-  done
-
-  # Usually 'no', except on cygwin/mingw when embedded into
-  # the cwrapper.
-  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
-  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
-    # special case for '.'
-    if test \"\$thisdir\" = \".\"; then
-      thisdir=\`pwd\`
-    fi
-    # remove .libs from thisdir
-    case \"\$thisdir\" in
-    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
-    $objdir )   thisdir=. ;;
-    esac
-  fi
-
-  # Try to get the absolute directory name.
-  absdir=\`cd \"\$thisdir\" && pwd\`
-  test -n \"\$absdir\" && thisdir=\"\$absdir\"
-"
-
-	if test "$fast_install" = yes; then
-	  $ECHO "\
-  program=lt-'$outputname'$exeext
-  progdir=\"\$thisdir/$objdir\"
-
-  if test ! -f \"\$progdir/\$program\" ||
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
-       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
-
-    file=\"\$\$-\$program\"
-
-    if test ! -d \"\$progdir\"; then
-      $MKDIR \"\$progdir\"
-    else
-      $RM \"\$progdir/\$file\"
-    fi"
-
-	  $ECHO "\
-
-    # relink executable if necessary
-    if test -n \"\$relink_command\"; then
-      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
-      else
-	$ECHO \"\$relink_command_output\" >&2
-	$RM \"\$progdir/\$file\"
-	exit 1
-      fi
-    fi
-
-    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
-    { $RM \"\$progdir/\$program\";
-      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
-    $RM \"\$progdir/\$file\"
-  fi"
-	else
-	  $ECHO "\
-  program='$outputname'
-  progdir=\"\$thisdir/$objdir\"
-"
-	fi
-
-	$ECHO "\
-
-  if test -f \"\$progdir/\$program\"; then"
-
-	# Export our shlibpath_var if we have one.
-	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
-	  $ECHO "\
-    # Add our own library path to $shlibpath_var
-    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
-
-    # Some systems cannot cope with colon-terminated $shlibpath_var
-    # The second colon is a workaround for a bug in BeOS R4 sed
-    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
-
-    export $shlibpath_var
-"
-	fi
-
-	# fixup the dll searchpath if we need to.
-	if test -n "$dllsearchpath"; then
-	  $ECHO "\
-    # Add the dll search path components to the executable PATH
-    PATH=$dllsearchpath:\$PATH
-"
-	fi
-
-	$ECHO "\
-    if test \"\$libtool_execute_magic\" != \"$magic\"; then
-      # Run the actual program with our arguments.
-      func_exec_program \${1+\"\$@\"}
-    fi
-  else
-    # The program doesn't exist.
-    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
-    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
-    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
-    exit 1
-  fi
-fi\
-"
-}
-
-
-# func_to_host_path arg
-#
-# Convert paths to host format when used with build tools.
-# Intended for use with "native" mingw (where libtool itself
-# is running under the msys shell), or in the following cross-
-# build environments:
-#    $build          $host
-#    mingw (msys)    mingw  [e.g. native]
-#    cygwin          mingw
-#    *nix + wine     mingw
-# where wine is equipped with the `winepath' executable.
-# In the native mingw case, the (msys) shell automatically
-# converts paths for any non-msys applications it launches,
-# but that facility isn't available from inside the cwrapper.
-# Similar accommodations are necessary for $host mingw and
-# $build cygwin.  Calling this function does no harm for other
-# $host/$build combinations not listed above.
-#
-# ARG is the path (on $build) that should be converted to
-# the proper representation for $host. The result is stored
-# in $func_to_host_path_result.
-func_to_host_path ()
-{
-  func_to_host_path_result="$1"
-  if test -n "$1"; then
-    case $host in
-      *mingw* )
-        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-        case $build in
-          *mingw* ) # actually, msys
-            # awkward: cmd appends spaces to result
-            func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null |
-              $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
-            ;;
-          *cygwin* )
-            func_to_host_path_result=`cygpath -w "$1" |
-	      $SED -e "$lt_sed_naive_backslashify"`
-            ;;
-          * )
-            # Unfortunately, winepath does not exit with a non-zero
-            # error code, so we are forced to check the contents of
-            # stdout. On the other hand, if the command is not
-            # found, the shell will set an exit code of 127 and print
-            # *an error message* to stdout. So we must check for both
-            # error code of zero AND non-empty stdout, which explains
-            # the odd construction:
-            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
-            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
-              func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" |
-                $SED -e "$lt_sed_naive_backslashify"`
-            else
-              # Allow warning below.
-              func_to_host_path_result=
-            fi
-            ;;
-        esac
-        if test -z "$func_to_host_path_result" ; then
-          func_error "Could not determine host path corresponding to"
-          func_error "  \`$1'"
-          func_error "Continuing, but uninstalled executables may not work."
-          # Fallback:
-          func_to_host_path_result="$1"
-        fi
-        ;;
-    esac
-  fi
-}
-# end: func_to_host_path
-
-# func_to_host_pathlist arg
-#
-# Convert pathlists to host format when used with build tools.
-# See func_to_host_path(), above. This function supports the
-# following $build/$host combinations (but does no harm for
-# combinations not listed here):
-#    $build          $host
-#    mingw (msys)    mingw  [e.g. native]
-#    cygwin          mingw
-#    *nix + wine     mingw
-#
-# Path separators are also converted from $build format to
-# $host format. If ARG begins or ends with a path separator
-# character, it is preserved (but converted to $host format)
-# on output.
-#
-# ARG is a pathlist (on $build) that should be converted to
-# the proper representation on $host. The result is stored
-# in $func_to_host_pathlist_result.
-func_to_host_pathlist ()
-{
-  func_to_host_pathlist_result="$1"
-  if test -n "$1"; then
-    case $host in
-      *mingw* )
-        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-        # Remove leading and trailing path separator characters from
-        # ARG. msys behavior is inconsistent here, cygpath turns them
-        # into '.;' and ';.', and winepath ignores them completely.
-	func_stripname : : "$1"
-        func_to_host_pathlist_tmp1=$func_stripname_result
-        case $build in
-          *mingw* ) # Actually, msys.
-            # Awkward: cmd appends spaces to result.
-            func_to_host_pathlist_result=`
-	      ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null |
-	      $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
-            ;;
-          *cygwin* )
-            func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" |
-              $SED -e "$lt_sed_naive_backslashify"`
-            ;;
-          * )
-            # unfortunately, winepath doesn't convert pathlists
-            func_to_host_pathlist_result=""
-            func_to_host_pathlist_oldIFS=$IFS
-            IFS=:
-            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
-              IFS=$func_to_host_pathlist_oldIFS
-              if test -n "$func_to_host_pathlist_f" ; then
-                func_to_host_path "$func_to_host_pathlist_f"
-                if test -n "$func_to_host_path_result" ; then
-                  if test -z "$func_to_host_pathlist_result" ; then
-                    func_to_host_pathlist_result="$func_to_host_path_result"
-                  else
-                    func_append func_to_host_pathlist_result ";$func_to_host_path_result"
-                  fi
-                fi
-              fi
-            done
-            IFS=$func_to_host_pathlist_oldIFS
-            ;;
-        esac
-        if test -z "$func_to_host_pathlist_result"; then
-          func_error "Could not determine the host path(s) corresponding to"
-          func_error "  \`$1'"
-          func_error "Continuing, but uninstalled executables may not work."
-          # Fallback. This may break if $1 contains DOS-style drive
-          # specifications. The fix is not to complicate the expression
-          # below, but for the user to provide a working wine installation
-          # with winepath so that path translation in the cross-to-mingw
-          # case works properly.
-          lt_replace_pathsep_nix_to_dos="s|:|;|g"
-          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
-            $SED -e "$lt_replace_pathsep_nix_to_dos"`
-        fi
-        # Now, add the leading and trailing path separators back
-        case "$1" in
-          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
-            ;;
-        esac
-        case "$1" in
-          *: ) func_append func_to_host_pathlist_result ";"
-            ;;
-        esac
-        ;;
-    esac
-  fi
-}
-# end: func_to_host_pathlist
-
-# func_emit_cwrapperexe_src
-# emit the source code for a wrapper executable on stdout
-# Must ONLY be called from within func_mode_link because
-# it depends on a number of variable set therein.
-func_emit_cwrapperexe_src ()
-{
-	cat <<EOF
-
-/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
-   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
-
-   The $output program cannot be directly executed until all the libtool
-   libraries that it depends on are installed.
-
-   This wrapper executable should never be moved out of the build directory.
-   If it is, it will not operate correctly.
-*/
-EOF
-	    cat <<"EOF"
-#ifdef _MSC_VER
-# define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef _MSC_VER
-# include <direct.h>
-# include <process.h>
-# include <io.h>
-#else
-# include <unistd.h>
-# include <stdint.h>
-# ifdef __CYGWIN__
-#  include <io.h>
-# endif
-#endif
-#include <malloc.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-/* declarations of non-ANSI functions */
-#if defined(__MINGW32__)
-# ifdef __STRICT_ANSI__
-int _putenv (const char *);
-# endif
-#elif defined(__CYGWIN__)
-# ifdef __STRICT_ANSI__
-char *realpath (const char *, char *);
-int putenv (char *);
-int setenv (const char *, const char *, int);
-# endif
-/* #elif defined (other platforms) ... */
-#endif
-
-/* portability defines, excluding path handling macros */
-#if defined(_MSC_VER)
-# define setmode _setmode
-# define stat    _stat
-# define chmod   _chmod
-# define getcwd  _getcwd
-# define putenv  _putenv
-# define S_IXUSR _S_IEXEC
-# ifndef _INTPTR_T_DEFINED
-#  define _INTPTR_T_DEFINED
-#  define intptr_t int
-# endif
-#elif defined(__MINGW32__)
-# define setmode _setmode
-# define stat    _stat
-# define chmod   _chmod
-# define getcwd  _getcwd
-# define putenv  _putenv
-#elif defined(__CYGWIN__)
-# define HAVE_SETENV
-# define FOPEN_WB "wb"
-/* #elif defined (other platforms) ... */
-#endif
-
-#if defined(PATH_MAX)
-# define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
-# define LT_PATHMAX MAXPATHLEN
-#else
-# define LT_PATHMAX 1024
-#endif
-
-#ifndef S_IXOTH
-# define S_IXOTH 0
-#endif
-#ifndef S_IXGRP
-# define S_IXGRP 0
-#endif
-
-/* path handling portability macros */
-#ifndef DIR_SEPARATOR
-# define DIR_SEPARATOR '/'
-# define PATH_SEPARATOR ':'
-#endif
-
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
-# define HAVE_DOS_BASED_FILE_SYSTEM
-# define FOPEN_WB "wb"
-# ifndef DIR_SEPARATOR_2
-#  define DIR_SEPARATOR_2 '\\'
-# endif
-# ifndef PATH_SEPARATOR_2
-#  define PATH_SEPARATOR_2 ';'
-# endif
-#endif
-
-#ifndef DIR_SEPARATOR_2
-# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
-#else /* DIR_SEPARATOR_2 */
-# define IS_DIR_SEPARATOR(ch) \
-	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
-#endif /* DIR_SEPARATOR_2 */
-
-#ifndef PATH_SEPARATOR_2
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
-#else /* PATH_SEPARATOR_2 */
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
-#endif /* PATH_SEPARATOR_2 */
-
-#ifndef FOPEN_WB
-# define FOPEN_WB "w"
-#endif
-#ifndef _O_BINARY
-# define _O_BINARY 0
-#endif
-
-#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
-#define XFREE(stale) do { \
-  if (stale) { free ((void *) stale); stale = 0; } \
-} while (0)
-
-#if defined(LT_DEBUGWRAPPER)
-static int lt_debug = 1;
-#else
-static int lt_debug = 0;
-#endif
-
-const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
-
-void *xmalloc (size_t num);
-char *xstrdup (const char *string);
-const char *base_name (const char *name);
-char *find_executable (const char *wrapper);
-char *chase_symlinks (const char *pathspec);
-int make_executable (const char *path);
-int check_executable (const char *path);
-char *strendzap (char *str, const char *pat);
-void lt_debugprintf (const char *file, int line, const char *fmt, ...);
-void lt_fatal (const char *file, int line, const char *message, ...);
-static const char *nonnull (const char *s);
-static const char *nonempty (const char *s);
-void lt_setenv (const char *name, const char *value);
-char *lt_extend_str (const char *orig_value, const char *add, int to_end);
-void lt_update_exe_path (const char *name, const char *value);
-void lt_update_lib_path (const char *name, const char *value);
-char **prepare_spawn (char **argv);
-void lt_dump_script (FILE *f);
-EOF
-
-	    cat <<EOF
-const char * MAGIC_EXE = "$magic_exe";
-const char * LIB_PATH_VARNAME = "$shlibpath_var";
-EOF
-
-	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
-              func_to_host_pathlist "$temp_rpath"
-	      cat <<EOF
-const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
-EOF
-	    else
-	      cat <<"EOF"
-const char * LIB_PATH_VALUE   = "";
-EOF
-	    fi
-
-	    if test -n "$dllsearchpath"; then
-              func_to_host_pathlist "$dllsearchpath:"
-	      cat <<EOF
-const char * EXE_PATH_VARNAME = "PATH";
-const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
-EOF
-	    else
-	      cat <<"EOF"
-const char * EXE_PATH_VARNAME = "";
-const char * EXE_PATH_VALUE   = "";
-EOF
-	    fi
-
-	    if test "$fast_install" = yes; then
-	      cat <<EOF
-const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
-EOF
-	    else
-	      cat <<EOF
-const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
-EOF
-	    fi
-
-
-	    cat <<"EOF"
-
-#define LTWRAPPER_OPTION_PREFIX         "--lt-"
-
-static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
-static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
-static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
-
-int
-main (int argc, char *argv[])
-{
-  char **newargz;
-  int  newargc;
-  char *tmp_pathspec;
-  char *actual_cwrapper_path;
-  char *actual_cwrapper_name;
-  char *target_name;
-  char *lt_argv_zero;
-  intptr_t rval = 127;
-
-  int i;
-
-  program_name = (char *) xstrdup (base_name (argv[0]));
-  newargz = XMALLOC (char *, argc + 1);
-
-  /* very simple arg parsing; don't want to rely on getopt
-   * also, copy all non cwrapper options to newargz, except
-   * argz[0], which is handled differently
-   */
-  newargc=0;
-  for (i = 1; i < argc; i++)
-    {
-      if (strcmp (argv[i], dumpscript_opt) == 0)
-	{
-EOF
-	    case "$host" in
-	      *mingw* | *cygwin* )
-		# make stdout use "unix" line endings
-		echo "          setmode(1,_O_BINARY);"
-		;;
-	      esac
-
-	    cat <<"EOF"
-	  lt_dump_script (stdout);
-	  return 0;
-	}
-      if (strcmp (argv[i], debug_opt) == 0)
-	{
-          lt_debug = 1;
-          continue;
-	}
-      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
-        {
-          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
-             namespace, but it is not one of the ones we know about and
-             have already dealt with, above (inluding dump-script), then
-             report an error. Otherwise, targets might begin to believe
-             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
-             namespace. The first time any user complains about this, we'll
-             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
-             or a configure.ac-settable value.
-           */
-          lt_fatal (__FILE__, __LINE__,
-		    "unrecognized %s option: '%s'",
-                    ltwrapper_option_prefix, argv[i]);
-        }
-      /* otherwise ... */
-      newargz[++newargc] = xstrdup (argv[i]);
-    }
-  newargz[++newargc] = NULL;
-
-EOF
-	    cat <<EOF
-  /* The GNU banner must be the first non-error debug message */
-  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
-EOF
-	    cat <<"EOF"
-  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
-  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
-
-  tmp_pathspec = find_executable (argv[0]);
-  if (tmp_pathspec == NULL)
-    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
-  lt_debugprintf (__FILE__, __LINE__,
-                  "(main) found exe (before symlink chase) at: %s\n",
-		  tmp_pathspec);
-
-  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
-  lt_debugprintf (__FILE__, __LINE__,
-                  "(main) found exe (after symlink chase) at: %s\n",
-		  actual_cwrapper_path);
-  XFREE (tmp_pathspec);
-
-  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
-  strendzap (actual_cwrapper_path, actual_cwrapper_name);
-
-  /* wrapper name transforms */
-  strendzap (actual_cwrapper_name, ".exe");
-  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
-  XFREE (actual_cwrapper_name);
-  actual_cwrapper_name = tmp_pathspec;
-  tmp_pathspec = 0;
-
-  /* target_name transforms -- use actual target program name; might have lt- prefix */
-  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
-  strendzap (target_name, ".exe");
-  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
-  XFREE (target_name);
-  target_name = tmp_pathspec;
-  tmp_pathspec = 0;
-
-  lt_debugprintf (__FILE__, __LINE__,
-		  "(main) libtool target name: %s\n",
-		  target_name);
-EOF
-
-	    cat <<EOF
-  newargz[0] =
-    XMALLOC (char, (strlen (actual_cwrapper_path) +
-		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
-  strcpy (newargz[0], actual_cwrapper_path);
-  strcat (newargz[0], "$objdir");
-  strcat (newargz[0], "/");
-EOF
-
-	    cat <<"EOF"
-  /* stop here, and copy so we don't have to do this twice */
-  tmp_pathspec = xstrdup (newargz[0]);
-
-  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
-  strcat (newargz[0], actual_cwrapper_name);
-
-  /* DO want the lt- prefix here if it exists, so use target_name */
-  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
-  XFREE (tmp_pathspec);
-  tmp_pathspec = NULL;
-EOF
-
-	    case $host_os in
-	      mingw*)
-	    cat <<"EOF"
-  {
-    char* p;
-    while ((p = strchr (newargz[0], '\\')) != NULL)
-      {
-	*p = '/';
-      }
-    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
-      {
-	*p = '/';
-      }
-  }
-EOF
-	    ;;
-	    esac
-
-	    cat <<"EOF"
-  XFREE (target_name);
-  XFREE (actual_cwrapper_path);
-  XFREE (actual_cwrapper_name);
-
-  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
-  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
-  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
-  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
-
-  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
-		  nonnull (lt_argv_zero));
-  for (i = 0; i < newargc; i++)
-    {
-      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
-		      i, nonnull (newargz[i]));
-    }
-
-EOF
-
-	    case $host_os in
-	      mingw*)
-		cat <<"EOF"
-  /* execv doesn't actually work on mingw as expected on unix */
-  newargz = prepare_spawn (newargz);
-  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
-  if (rval == -1)
-    {
-      /* failed to start process */
-      lt_debugprintf (__FILE__, __LINE__,
-		      "(main) failed to launch target \"%s\": %s\n",
-		      lt_argv_zero, nonnull (strerror (errno)));
-      return 127;
-    }
-  return rval;
-EOF
-		;;
-	      *)
-		cat <<"EOF"
-  execv (lt_argv_zero, newargz);
-  return rval; /* =127, but avoids unused variable warning */
-EOF
-		;;
-	    esac
-
-	    cat <<"EOF"
-}
-
-void *
-xmalloc (size_t num)
-{
-  void *p = (void *) malloc (num);
-  if (!p)
-    lt_fatal (__FILE__, __LINE__, "memory exhausted");
-
-  return p;
-}
-
-char *
-xstrdup (const char *string)
-{
-  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
-			  string) : NULL;
-}
-
-const char *
-base_name (const char *name)
-{
-  const char *base;
-
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  /* Skip over the disk name in MSDOS pathnames. */
-  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
-    name += 2;
-#endif
-
-  for (base = name; *name; name++)
-    if (IS_DIR_SEPARATOR (*name))
-      base = name + 1;
-  return base;
-}
-
-int
-check_executable (const char *path)
-{
-  struct stat st;
-
-  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
-                  nonempty (path));
-  if ((!path) || (!*path))
-    return 0;
-
-  if ((stat (path, &st) >= 0)
-      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
-    return 1;
-  else
-    return 0;
-}
-
-int
-make_executable (const char *path)
-{
-  int rval = 0;
-  struct stat st;
-
-  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
-                  nonempty (path));
-  if ((!path) || (!*path))
-    return 0;
-
-  if (stat (path, &st) >= 0)
-    {
-      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
-    }
-  return rval;
-}
-
-/* Searches for the full path of the wrapper.  Returns
-   newly allocated full path name if found, NULL otherwise
-   Does not chase symlinks, even on platforms that support them.
-*/
-char *
-find_executable (const char *wrapper)
-{
-  int has_slash = 0;
-  const char *p;
-  const char *p_next;
-  /* static buffer for getcwd */
-  char tmp[LT_PATHMAX + 1];
-  int tmp_len;
-  char *concat_name;
-
-  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
-                  nonempty (wrapper));
-
-  if ((wrapper == NULL) || (*wrapper == '\0'))
-    return NULL;
-
-  /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
-    {
-      concat_name = xstrdup (wrapper);
-      if (check_executable (concat_name))
-	return concat_name;
-      XFREE (concat_name);
-    }
-  else
-    {
-#endif
-      if (IS_DIR_SEPARATOR (wrapper[0]))
-	{
-	  concat_name = xstrdup (wrapper);
-	  if (check_executable (concat_name))
-	    return concat_name;
-	  XFREE (concat_name);
-	}
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-    }
-#endif
-
-  for (p = wrapper; *p; p++)
-    if (*p == '/')
-      {
-	has_slash = 1;
-	break;
-      }
-  if (!has_slash)
-    {
-      /* no slashes; search PATH */
-      const char *path = getenv ("PATH");
-      if (path != NULL)
-	{
-	  for (p = path; *p; p = p_next)
-	    {
-	      const char *q;
-	      size_t p_len;
-	      for (q = p; *q; q++)
-		if (IS_PATH_SEPARATOR (*q))
-		  break;
-	      p_len = q - p;
-	      p_next = (*q == '\0' ? q : q + 1);
-	      if (p_len == 0)
-		{
-		  /* empty path: current directory */
-		  if (getcwd (tmp, LT_PATHMAX) == NULL)
-		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
-                              nonnull (strerror (errno)));
-		  tmp_len = strlen (tmp);
-		  concat_name =
-		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
-		  memcpy (concat_name, tmp, tmp_len);
-		  concat_name[tmp_len] = '/';
-		  strcpy (concat_name + tmp_len + 1, wrapper);
-		}
-	      else
-		{
-		  concat_name =
-		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
-		  memcpy (concat_name, p, p_len);
-		  concat_name[p_len] = '/';
-		  strcpy (concat_name + p_len + 1, wrapper);
-		}
-	      if (check_executable (concat_name))
-		return concat_name;
-	      XFREE (concat_name);
-	    }
-	}
-      /* not found in PATH; assume curdir */
-    }
-  /* Relative path | not found in path: prepend cwd */
-  if (getcwd (tmp, LT_PATHMAX) == NULL)
-    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
-              nonnull (strerror (errno)));
-  tmp_len = strlen (tmp);
-  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
-  memcpy (concat_name, tmp, tmp_len);
-  concat_name[tmp_len] = '/';
-  strcpy (concat_name + tmp_len + 1, wrapper);
-
-  if (check_executable (concat_name))
-    return concat_name;
-  XFREE (concat_name);
-  return NULL;
-}
-
-char *
-chase_symlinks (const char *pathspec)
-{
-#ifndef S_ISLNK
-  return xstrdup (pathspec);
-#else
-  char buf[LT_PATHMAX];
-  struct stat s;
-  char *tmp_pathspec = xstrdup (pathspec);
-  char *p;
-  int has_symlinks = 0;
-  while (strlen (tmp_pathspec) && !has_symlinks)
-    {
-      lt_debugprintf (__FILE__, __LINE__,
-		      "checking path component for symlinks: %s\n",
-		      tmp_pathspec);
-      if (lstat (tmp_pathspec, &s) == 0)
-	{
-	  if (S_ISLNK (s.st_mode) != 0)
-	    {
-	      has_symlinks = 1;
-	      break;
-	    }
-
-	  /* search backwards for last DIR_SEPARATOR */
-	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
-	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
-	    p--;
-	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
-	    {
-	      /* no more DIR_SEPARATORS left */
-	      break;
-	    }
-	  *p = '\0';
-	}
-      else
-	{
-	  lt_fatal (__FILE__, __LINE__,
-		    "error accessing file \"%s\": %s",
-		    tmp_pathspec, nonnull (strerror (errno)));
-	}
-    }
-  XFREE (tmp_pathspec);
-
-  if (!has_symlinks)
-    {
-      return xstrdup (pathspec);
-    }
-
-  tmp_pathspec = realpath (pathspec, buf);
-  if (tmp_pathspec == 0)
-    {
-      lt_fatal (__FILE__, __LINE__,
-		"could not follow symlinks for %s", pathspec);
-    }
-  return xstrdup (tmp_pathspec);
-#endif
-}
-
-char *
-strendzap (char *str, const char *pat)
-{
-  size_t len, patlen;
-
-  assert (str != NULL);
-  assert (pat != NULL);
-
-  len = strlen (str);
-  patlen = strlen (pat);
-
-  if (patlen <= len)
-    {
-      str += len - patlen;
-      if (strcmp (str, pat) == 0)
-	*str = '\0';
-    }
-  return str;
-}
-
-void
-lt_debugprintf (const char *file, int line, const char *fmt, ...)
-{
-  va_list args;
-  if (lt_debug)
-    {
-      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
-      va_start (args, fmt);
-      (void) vfprintf (stderr, fmt, args);
-      va_end (args);
-    }
-}
-
-static void
-lt_error_core (int exit_status, const char *file,
-	       int line, const char *mode,
-	       const char *message, va_list ap)
-{
-  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
-  vfprintf (stderr, message, ap);
-  fprintf (stderr, ".\n");
-
-  if (exit_status >= 0)
-    exit (exit_status);
-}
-
-void
-lt_fatal (const char *file, int line, const char *message, ...)
-{
-  va_list ap;
-  va_start (ap, message);
-  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
-  va_end (ap);
-}
-
-static const char *
-nonnull (const char *s)
-{
-  return s ? s : "(null)";
-}
-
-static const char *
-nonempty (const char *s)
-{
-  return (s && !*s) ? "(empty)" : nonnull (s);
-}
-
-void
-lt_setenv (const char *name, const char *value)
-{
-  lt_debugprintf (__FILE__, __LINE__,
-		  "(lt_setenv) setting '%s' to '%s'\n",
-                  nonnull (name), nonnull (value));
-  {
-#ifdef HAVE_SETENV
-    /* always make a copy, for consistency with !HAVE_SETENV */
-    char *str = xstrdup (value);
-    setenv (name, str, 1);
-#else
-    int len = strlen (name) + 1 + strlen (value) + 1;
-    char *str = XMALLOC (char, len);
-    sprintf (str, "%s=%s", name, value);
-    if (putenv (str) != EXIT_SUCCESS)
-      {
-        XFREE (str);
-      }
-#endif
-  }
-}
-
-char *
-lt_extend_str (const char *orig_value, const char *add, int to_end)
-{
-  char *new_value;
-  if (orig_value && *orig_value)
-    {
-      int orig_value_len = strlen (orig_value);
-      int add_len = strlen (add);
-      new_value = XMALLOC (char, add_len + orig_value_len + 1);
-      if (to_end)
-        {
-          strcpy (new_value, orig_value);
-          strcpy (new_value + orig_value_len, add);
-        }
-      else
-        {
-          strcpy (new_value, add);
-          strcpy (new_value + add_len, orig_value);
-        }
-    }
-  else
-    {
-      new_value = xstrdup (add);
-    }
-  return new_value;
-}
-
-void
-lt_update_exe_path (const char *name, const char *value)
-{
-  lt_debugprintf (__FILE__, __LINE__,
-		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
-                  nonnull (name), nonnull (value));
-
-  if (name && *name && value && *value)
-    {
-      char *new_value = lt_extend_str (getenv (name), value, 0);
-      /* some systems can't cope with a ':'-terminated path #' */
-      int len = strlen (new_value);
-      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
-        {
-          new_value[len-1] = '\0';
-        }
-      lt_setenv (name, new_value);
-      XFREE (new_value);
-    }
-}
-
-void
-lt_update_lib_path (const char *name, const char *value)
-{
-  lt_debugprintf (__FILE__, __LINE__,
-		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
-                  nonnull (name), nonnull (value));
-
-  if (name && *name && value && *value)
-    {
-      char *new_value = lt_extend_str (getenv (name), value, 0);
-      lt_setenv (name, new_value);
-      XFREE (new_value);
-    }
-}
-
-EOF
-	    case $host_os in
-	      mingw*)
-		cat <<"EOF"
-
-/* Prepares an argument vector before calling spawn().
-   Note that spawn() does not by itself call the command interpreter
-     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
-      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-         GetVersionEx(&v);
-         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
-      }) ? "cmd.exe" : "command.com").
-   Instead it simply concatenates the arguments, separated by ' ', and calls
-   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
-   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
-   special way:
-   - Space and tab are interpreted as delimiters. They are not treated as
-     delimiters if they are surrounded by double quotes: "...".
-   - Unescaped double quotes are removed from the input. Their only effect is
-     that within double quotes, space and tab are treated like normal
-     characters.
-   - Backslashes not followed by double quotes are not special.
-   - But 2*n+1 backslashes followed by a double quote become
-     n backslashes followed by a double quote (n >= 0):
-       \" -> "
-       \\\" -> \"
-       \\\\\" -> \\"
- */
-#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
-#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
-char **
-prepare_spawn (char **argv)
-{
-  size_t argc;
-  char **new_argv;
-  size_t i;
-
-  /* Count number of arguments.  */
-  for (argc = 0; argv[argc] != NULL; argc++)
-    ;
-
-  /* Allocate new argument vector.  */
-  new_argv = XMALLOC (char *, argc + 1);
-
-  /* Put quoted arguments into the new argument vector.  */
-  for (i = 0; i < argc; i++)
-    {
-      const char *string = argv[i];
-
-      if (string[0] == '\0')
-	new_argv[i] = xstrdup ("\"\"");
-      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
-	{
-	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
-	  size_t length;
-	  unsigned int backslashes;
-	  const char *s;
-	  char *quoted_string;
-	  char *p;
-
-	  length = 0;
-	  backslashes = 0;
-	  if (quote_around)
-	    length++;
-	  for (s = string; *s != '\0'; s++)
-	    {
-	      char c = *s;
-	      if (c == '"')
-		length += backslashes + 1;
-	      length++;
-	      if (c == '\\')
-		backslashes++;
-	      else
-		backslashes = 0;
-	    }
-	  if (quote_around)
-	    length += backslashes + 1;
-
-	  quoted_string = XMALLOC (char, length + 1);
-
-	  p = quoted_string;
-	  backslashes = 0;
-	  if (quote_around)
-	    *p++ = '"';
-	  for (s = string; *s != '\0'; s++)
-	    {
-	      char c = *s;
-	      if (c == '"')
-		{
-		  unsigned int j;
-		  for (j = backslashes + 1; j > 0; j--)
-		    *p++ = '\\';
-		}
-	      *p++ = c;
-	      if (c == '\\')
-		backslashes++;
-	      else
-		backslashes = 0;
-	    }
-	  if (quote_around)
-	    {
-	      unsigned int j;
-	      for (j = backslashes; j > 0; j--)
-		*p++ = '\\';
-	      *p++ = '"';
-	    }
-	  *p = '\0';
-
-	  new_argv[i] = quoted_string;
-	}
-      else
-	new_argv[i] = (char *) string;
-    }
-  new_argv[argc] = NULL;
-
-  return new_argv;
-}
-EOF
-		;;
-	    esac
-
-            cat <<"EOF"
-void lt_dump_script (FILE* f)
-{
-EOF
-	    func_emit_wrapper yes |
-              $SED -e 's/\([\\"]\)/\\\1/g' \
-	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
-
-            cat <<"EOF"
-}
-EOF
-}
-# end: func_emit_cwrapperexe_src
-
-# func_win32_import_lib_p ARG
-# True if ARG is an import lib, as indicated by $file_magic_cmd
-func_win32_import_lib_p ()
-{
-    $opt_debug
-    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
-    *import*) : ;;
-    *) false ;;
-    esac
-}
-
-# func_mode_link arg...
-func_mode_link ()
-{
-    $opt_debug
-    case $host in
-    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-      # It is impossible to link a dll without this setting, and
-      # we shouldn't force the makefile maintainer to figure out
-      # which system we are compiling for in order to pass an extra
-      # flag for every libtool invocation.
-      # allow_undefined=no
-
-      # FIXME: Unfortunately, there are problems with the above when trying
-      # to make a dll which has undefined symbols, in which case not
-      # even a static library is built.  For now, we need to specify
-      # -no-undefined on the libtool link line when we can be certain
-      # that all symbols are satisfied, otherwise we get a static library.
-      allow_undefined=yes
-      ;;
-    *)
-      allow_undefined=yes
-      ;;
-    esac
-    libtool_args=$nonopt
-    base_compile="$nonopt $@"
-    compile_command=$nonopt
-    finalize_command=$nonopt
-
-    compile_rpath=
-    finalize_rpath=
-    compile_shlibpath=
-    finalize_shlibpath=
-    convenience=
-    old_convenience=
-    deplibs=
-    old_deplibs=
-    compiler_flags=
-    linker_flags=
-    dllsearchpath=
-    lib_search_path=`pwd`
-    inst_prefix_dir=
-    new_inherited_linker_flags=
-
-    avoid_version=no
-    bindir=
-    dlfiles=
-    dlprefiles=
-    dlself=no
-    export_dynamic=no
-    export_symbols=
-    export_symbols_regex=
-    generated=
-    libobjs=
-    ltlibs=
-    module=no
-    no_install=no
-    objs=
-    non_pic_objects=
-    precious_files_regex=
-    prefer_static_libs=no
-    preload=no
-    prev=
-    prevarg=
-    release=
-    rpath=
-    xrpath=
-    perm_rpath=
-    temp_rpath=
-    thread_safe=no
-    vinfo=
-    vinfo_number=no
-    weak_libs=
-    single_module="${wl}-single_module"
-    func_infer_tag $base_compile
-
-    # We need to know -static, to get the right output filenames.
-    for arg
-    do
-      case $arg in
-      -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
-	build_old_libs=no
-	break
-	;;
-      -all-static | -static | -static-libtool-libs)
-	case $arg in
-	-all-static)
-	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
-	    func_warning "complete static linking is impossible in this configuration"
-	  fi
-	  if test -n "$link_static_flag"; then
-	    dlopen_self=$dlopen_self_static
-	  fi
-	  prefer_static_libs=yes
-	  ;;
-	-static)
-	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
-	    dlopen_self=$dlopen_self_static
-	  fi
-	  prefer_static_libs=built
-	  ;;
-	-static-libtool-libs)
-	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
-	    dlopen_self=$dlopen_self_static
-	  fi
-	  prefer_static_libs=yes
-	  ;;
-	esac
-	build_libtool_libs=no
-	build_old_libs=yes
-	break
-	;;
-      esac
-    done
-
-    # See if our shared archives depend on static archives.
-    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
-
-    # Go through the arguments, transforming them on the way.
-    while test "$#" -gt 0; do
-      arg="$1"
-      shift
-      func_quote_for_eval "$arg"
-      qarg=$func_quote_for_eval_unquoted_result
-      func_append libtool_args " $func_quote_for_eval_result"
-
-      # If the previous option needs an argument, assign it.
-      if test -n "$prev"; then
-	case $prev in
-	output)
-	  func_append compile_command " @OUTPUT@"
-	  func_append finalize_command " @OUTPUT@"
-	  ;;
-	esac
-
-	case $prev in
-	bindir)
-	  bindir="$arg"
-	  prev=
-	  continue
-	  ;;
-	dlfiles|dlprefiles)
-	  if test "$preload" = no; then
-	    # Add the symbol object into the linking commands.
-	    func_append compile_command " @SYMFILE@"
-	    func_append finalize_command " @SYMFILE@"
-	    preload=yes
-	  fi
-	  case $arg in
-	  *.la | *.lo) ;;  # We handle these cases below.
-	  force)
-	    if test "$dlself" = no; then
-	      dlself=needless
-	      export_dynamic=yes
-	    fi
-	    prev=
-	    continue
-	    ;;
-	  self)
-	    if test "$prev" = dlprefiles; then
-	      dlself=yes
-	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
-	      dlself=yes
-	    else
-	      dlself=needless
-	      export_dynamic=yes
-	    fi
-	    prev=
-	    continue
-	    ;;
-	  *)
-	    if test "$prev" = dlfiles; then
-	      dlfiles="$dlfiles $arg"
-	    else
-	      dlprefiles="$dlprefiles $arg"
-	    fi
-	    prev=
-	    continue
-	    ;;
-	  esac
-	  ;;
-	expsyms)
-	  export_symbols="$arg"
-	  test -f "$arg" \
-	    || func_fatal_error "symbol file \`$arg' does not exist"
-	  prev=
-	  continue
-	  ;;
-	expsyms_regex)
-	  export_symbols_regex="$arg"
-	  prev=
-	  continue
-	  ;;
-	framework)
-	  case $host in
-	    *-*-darwin*)
-	      case "$deplibs " in
-		*" $qarg.ltframework "*) ;;
-		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
-		   ;;
-	      esac
-	      ;;
-	  esac
-	  prev=
-	  continue
-	  ;;
-	inst_prefix)
-	  inst_prefix_dir="$arg"
-	  prev=
-	  continue
-	  ;;
-	objectlist)
-	  if test -f "$arg"; then
-	    save_arg=$arg
-	    moreargs=
-	    for fil in `cat "$save_arg"`
-	    do
-#	      moreargs="$moreargs $fil"
-	      arg=$fil
-	      # A libtool-controlled object.
-
-	      # Check to see that this really is a libtool object.
-	      if func_lalib_unsafe_p "$arg"; then
-		pic_object=
-		non_pic_object=
-
-		# Read the .lo file
-		func_source "$arg"
-
-		if test -z "$pic_object" ||
-		   test -z "$non_pic_object" ||
-		   test "$pic_object" = none &&
-		   test "$non_pic_object" = none; then
-		  func_fatal_error "cannot find name of object for \`$arg'"
-		fi
-
-		# Extract subdirectory from the argument.
-		func_dirname "$arg" "/" ""
-		xdir="$func_dirname_result"
-
-		if test "$pic_object" != none; then
-		  # Prepend the subdirectory the object is found in.
-		  pic_object="$xdir$pic_object"
-
-		  if test "$prev" = dlfiles; then
-		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
-		      dlfiles="$dlfiles $pic_object"
-		      prev=
-		      continue
-		    else
-		      # If libtool objects are unsupported, then we need to preload.
-		      prev=dlprefiles
-		    fi
-		  fi
-
-		  # CHECK ME:  I think I busted this.  -Ossama
-		  if test "$prev" = dlprefiles; then
-		    # Preload the old-style object.
-		    dlprefiles="$dlprefiles $pic_object"
-		    prev=
-		  fi
-
-		  # A PIC object.
-		  func_append libobjs " $pic_object"
-		  arg="$pic_object"
-		fi
-
-		# Non-PIC object.
-		if test "$non_pic_object" != none; then
-		  # Prepend the subdirectory the object is found in.
-		  non_pic_object="$xdir$non_pic_object"
-
-		  # A standard non-PIC object
-		  func_append non_pic_objects " $non_pic_object"
-		  if test -z "$pic_object" || test "$pic_object" = none ; then
-		    arg="$non_pic_object"
-		  fi
-		else
-		  # If the PIC object exists, use it instead.
-		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
-		  func_append non_pic_objects " $non_pic_object"
-		fi
-	      else
-		# Only an error if not doing a dry-run.
-		if $opt_dry_run; then
-		  # Extract subdirectory from the argument.
-		  func_dirname "$arg" "/" ""
-		  xdir="$func_dirname_result"
-
-		  func_lo2o "$arg"
-		  pic_object=$xdir$objdir/$func_lo2o_result
-		  non_pic_object=$xdir$func_lo2o_result
-		  func_append libobjs " $pic_object"
-		  func_append non_pic_objects " $non_pic_object"
-	        else
-		  func_fatal_error "\`$arg' is not a valid libtool object"
-		fi
-	      fi
-	    done
-	  else
-	    func_fatal_error "link input file \`$arg' does not exist"
-	  fi
-	  arg=$save_arg
-	  prev=
-	  continue
-	  ;;
-	precious_regex)
-	  precious_files_regex="$arg"
-	  prev=
-	  continue
-	  ;;
-	release)
-	  release="-$arg"
-	  prev=
-	  continue
-	  ;;
-	rpath | xrpath)
-	  # We need an absolute path.
-	  case $arg in
-	  [\\/]* | [A-Za-z]:[\\/]*) ;;
-	  *)
-	    func_fatal_error "only absolute run-paths are allowed"
-	    ;;
-	  esac
-	  if test "$prev" = rpath; then
-	    case "$rpath " in
-	    *" $arg "*) ;;
-	    *) rpath="$rpath $arg" ;;
-	    esac
-	  else
-	    case "$xrpath " in
-	    *" $arg "*) ;;
-	    *) xrpath="$xrpath $arg" ;;
-	    esac
-	  fi
-	  prev=
-	  continue
-	  ;;
-	shrext)
-	  shrext_cmds="$arg"
-	  prev=
-	  continue
-	  ;;
-	weak)
-	  weak_libs="$weak_libs $arg"
-	  prev=
-	  continue
-	  ;;
-	xcclinker)
-	  linker_flags="$linker_flags $qarg"
-	  compiler_flags="$compiler_flags $qarg"
-	  prev=
-	  func_append compile_command " $qarg"
-	  func_append finalize_command " $qarg"
-	  continue
-	  ;;
-	xcompiler)
-	  compiler_flags="$compiler_flags $qarg"
-	  prev=
-	  func_append compile_command " $qarg"
-	  func_append finalize_command " $qarg"
-	  continue
-	  ;;
-	xlinker)
-	  linker_flags="$linker_flags $qarg"
-	  compiler_flags="$compiler_flags $wl$qarg"
-	  prev=
-	  func_append compile_command " $wl$qarg"
-	  func_append finalize_command " $wl$qarg"
-	  continue
-	  ;;
-	*)
-	  eval "$prev=\"\$arg\""
-	  prev=
-	  continue
-	  ;;
-	esac
-      fi # test -n "$prev"
-
-      prevarg="$arg"
-
-      case $arg in
-      -all-static)
-	if test -n "$link_static_flag"; then
-	  # See comment for -static flag below, for more details.
-	  func_append compile_command " $link_static_flag"
-	  func_append finalize_command " $link_static_flag"
-	fi
-	continue
-	;;
-
-      -allow-undefined)
-	# FIXME: remove this flag sometime in the future.
-	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
-	;;
-
-      -avoid-version)
-	avoid_version=yes
-	continue
-	;;
-
-      -bindir)
-	prev=bindir
-	continue
-	;;
-
-      -dlopen)
-	prev=dlfiles
-	continue
-	;;
-
-      -dlpreopen)
-	prev=dlprefiles
-	continue
-	;;
-
-      -export-dynamic)
-	export_dynamic=yes
-	continue
-	;;
-
-      -export-symbols | -export-symbols-regex)
-	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
-	  func_fatal_error "more than one -exported-symbols argument is not allowed"
-	fi
-	if test "X$arg" = "X-export-symbols"; then
-	  prev=expsyms
-	else
-	  prev=expsyms_regex
-	fi
-	continue
-	;;
-
-      -framework)
-	prev=framework
-	continue
-	;;
-
-      -inst-prefix-dir)
-	prev=inst_prefix
-	continue
-	;;
-
-      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
-      # so, if we see these flags be careful not to treat them like -L
-      -L[A-Z][A-Z]*:*)
-	case $with_gcc/$host in
-	no/*-*-irix* | /*-*-irix*)
-	  func_append compile_command " $arg"
-	  func_append finalize_command " $arg"
-	  ;;
-	esac
-	continue
-	;;
-
-      -L*)
-	func_stripname '-L' '' "$arg"
-	dir=$func_stripname_result
-	if test -z "$dir"; then
-	  if test "$#" -gt 0; then
-	    func_fatal_error "require no space between \`-L' and \`$1'"
-	  else
-	    func_fatal_error "need path for \`-L' option"
-	  fi
-	fi
-	# We need an absolute path.
-	case $dir in
-	[\\/]* | [A-Za-z]:[\\/]*) ;;
-	*)
-	  absdir=`cd "$dir" && pwd`
-	  test -z "$absdir" && \
-	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
-	  dir="$absdir"
-	  ;;
-	esac
-	case "$deplibs " in
-	*" -L$dir "*) ;;
-	*)
-	  deplibs="$deplibs -L$dir"
-	  lib_search_path="$lib_search_path $dir"
-	  ;;
-	esac
-	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
-	  case :$dllsearchpath: in
-	  *":$dir:"*) ;;
-	  ::) dllsearchpath=$dir;;
-	  *) dllsearchpath="$dllsearchpath:$dir";;
-	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  ::) dllsearchpath=$testbindir;;
-	  *) dllsearchpath="$dllsearchpath:$testbindir";;
-	  esac
-	  ;;
-	esac
-	continue
-	;;
-
-      -l*)
-	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
-	  case $host in
-	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
-	    # These systems don't actually have a C or math library (as such)
-	    continue
-	    ;;
-	  *-*-os2*)
-	    # These systems don't actually have a C library (as such)
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
-	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  *-*-rhapsody* | *-*-darwin1.[012])
-	    # Rhapsody C and math libraries are in the System framework
-	    deplibs="$deplibs System.ltframework"
-	    continue
-	    ;;
-	  *-*-sco3.2v5* | *-*-sco5v6*)
-	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  esac
-	elif test "X$arg" = "X-lc_r"; then
-	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
-	   # Do not include libc_r directly, use -pthread flag.
-	   continue
-	   ;;
-	 esac
-	fi
-	deplibs="$deplibs $arg"
-	continue
-	;;
-
-      -module)
-	module=yes
-	continue
-	;;
-
-      # Tru64 UNIX uses -model [arg] to determine the layout of C++
-      # classes, name mangling, and exception handling.
-      # Darwin uses the -arch flag to determine output architecture.
-      -model|-arch|-isysroot)
-	compiler_flags="$compiler_flags $arg"
-	func_append compile_command " $arg"
-	func_append finalize_command " $arg"
-	prev=xcompiler
-	continue
-	;;
-
-      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
-	compiler_flags="$compiler_flags $arg"
-	func_append compile_command " $arg"
-	func_append finalize_command " $arg"
-	case "$new_inherited_linker_flags " in
-	    *" $arg "*) ;;
-	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
-	esac
-	continue
-	;;
-
-      -multi_module)
-	single_module="${wl}-multi_module"
-	continue
-	;;
-
-      -no-fast-install)
-	fast_install=no
-	continue
-	;;
-
-      -no-install)
-	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
-	  # The PATH hackery in wrapper scripts is required on Windows
-	  # and Darwin in order for the loader to find any dlls it needs.
-	  func_warning "\`-no-install' is ignored for $host"
-	  func_warning "assuming \`-no-fast-install' instead"
-	  fast_install=no
-	  ;;
-	*) no_install=yes ;;
-	esac
-	continue
-	;;
-
-      -no-undefined)
-	allow_undefined=no
-	continue
-	;;
-
-      -objectlist)
-	prev=objectlist
-	continue
-	;;
-
-      -o) prev=output ;;
-
-      -precious-files-regex)
-	prev=precious_regex
-	continue
-	;;
-
-      -release)
-	prev=release
-	continue
-	;;
-
-      -rpath)
-	prev=rpath
-	continue
-	;;
-
-      -R)
-	prev=xrpath
-	continue
-	;;
-
-      -R*)
-	func_stripname '-R' '' "$arg"
-	dir=$func_stripname_result
-	# We need an absolute path.
-	case $dir in
-	[\\/]* | [A-Za-z]:[\\/]*) ;;
-	*)
-	  func_fatal_error "only absolute run-paths are allowed"
-	  ;;
-	esac
-	case "$xrpath " in
-	*" $dir "*) ;;
-	*) xrpath="$xrpath $dir" ;;
-	esac
-	continue
-	;;
-
-      -shared)
-	# The effects of -shared are defined in a previous loop.
-	continue
-	;;
-
-      -shrext)
-	prev=shrext
-	continue
-	;;
-
-      -static | -static-libtool-libs)
-	# The effects of -static are defined in a previous loop.
-	# We used to do the same as -all-static on platforms that
-	# didn't have a PIC flag, but the assumption that the effects
-	# would be equivalent was wrong.  It would break on at least
-	# Digital Unix and AIX.
-	continue
-	;;
-
-      -thread-safe)
-	thread_safe=yes
-	continue
-	;;
-
-      -version-info)
-	prev=vinfo
-	continue
-	;;
-
-      -version-number)
-	prev=vinfo
-	vinfo_number=yes
-	continue
-	;;
-
-      -weak)
-        prev=weak
-	continue
-	;;
-
-      -Wc,*)
-	func_stripname '-Wc,' '' "$arg"
-	args=$func_stripname_result
-	arg=
-	save_ifs="$IFS"; IFS=','
-	for flag in $args; do
-	  IFS="$save_ifs"
-          func_quote_for_eval "$flag"
-	  arg="$arg $func_quote_for_eval_result"
-	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
-	done
-	IFS="$save_ifs"
-	func_stripname ' ' '' "$arg"
-	arg=$func_stripname_result
-	;;
-
-      -Wl,*)
-	func_stripname '-Wl,' '' "$arg"
-	args=$func_stripname_result
-	arg=
-	save_ifs="$IFS"; IFS=','
-	for flag in $args; do
-	  IFS="$save_ifs"
-          func_quote_for_eval "$flag"
-	  arg="$arg $wl$func_quote_for_eval_result"
-	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
-	  linker_flags="$linker_flags $func_quote_for_eval_result"
-	done
-	IFS="$save_ifs"
-	func_stripname ' ' '' "$arg"
-	arg=$func_stripname_result
-	;;
-
-      -Xcompiler)
-	prev=xcompiler
-	continue
-	;;
-
-      -Xlinker)
-	prev=xlinker
-	continue
-	;;
-
-      -XCClinker)
-	prev=xcclinker
-	continue
-	;;
-
-      # -msg_* for osf cc
-      -msg_*)
-	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
-	;;
-
-      # Flags to be passed through unchanged, with rationale:
-      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
-      # -r[0-9][0-9]*        specify processor for the SGI compiler
-      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
-      # +DA*, +DD*           enable 64-bit mode for the HP compiler
-      # -q*                  compiler args for the IBM compiler
-      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
-      # -F/path              path to uninstalled frameworks, gcc on darwin
-      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
-      # @file                GCC response files
-      # -tp=*                Portland pgcc target processor selection
-      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
-      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*)
-        func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
-        func_append compile_command " $arg"
-        func_append finalize_command " $arg"
-        compiler_flags="$compiler_flags $arg"
-        continue
-        ;;
-
-      # Some other compiler flag.
-      -* | +*)
-        func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
-	;;
-
-      *.$objext)
-	# A standard object.
-	objs="$objs $arg"
-	;;
-
-      *.lo)
-	# A libtool-controlled object.
-
-	# Check to see that this really is a libtool object.
-	if func_lalib_unsafe_p "$arg"; then
-	  pic_object=
-	  non_pic_object=
-
-	  # Read the .lo file
-	  func_source "$arg"
-
-	  if test -z "$pic_object" ||
-	     test -z "$non_pic_object" ||
-	     test "$pic_object" = none &&
-	     test "$non_pic_object" = none; then
-	    func_fatal_error "cannot find name of object for \`$arg'"
-	  fi
-
-	  # Extract subdirectory from the argument.
-	  func_dirname "$arg" "/" ""
-	  xdir="$func_dirname_result"
-
-	  if test "$pic_object" != none; then
-	    # Prepend the subdirectory the object is found in.
-	    pic_object="$xdir$pic_object"
-
-	    if test "$prev" = dlfiles; then
-	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
-		dlfiles="$dlfiles $pic_object"
-		prev=
-		continue
-	      else
-		# If libtool objects are unsupported, then we need to preload.
-		prev=dlprefiles
-	      fi
-	    fi
-
-	    # CHECK ME:  I think I busted this.  -Ossama
-	    if test "$prev" = dlprefiles; then
-	      # Preload the old-style object.
-	      dlprefiles="$dlprefiles $pic_object"
-	      prev=
-	    fi
-
-	    # A PIC object.
-	    func_append libobjs " $pic_object"
-	    arg="$pic_object"
-	  fi
-
-	  # Non-PIC object.
-	  if test "$non_pic_object" != none; then
-	    # Prepend the subdirectory the object is found in.
-	    non_pic_object="$xdir$non_pic_object"
-
-	    # A standard non-PIC object
-	    func_append non_pic_objects " $non_pic_object"
-	    if test -z "$pic_object" || test "$pic_object" = none ; then
-	      arg="$non_pic_object"
-	    fi
-	  else
-	    # If the PIC object exists, use it instead.
-	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
-	    func_append non_pic_objects " $non_pic_object"
-	  fi
-	else
-	  # Only an error if not doing a dry-run.
-	  if $opt_dry_run; then
-	    # Extract subdirectory from the argument.
-	    func_dirname "$arg" "/" ""
-	    xdir="$func_dirname_result"
-
-	    func_lo2o "$arg"
-	    pic_object=$xdir$objdir/$func_lo2o_result
-	    non_pic_object=$xdir$func_lo2o_result
-	    func_append libobjs " $pic_object"
-	    func_append non_pic_objects " $non_pic_object"
-	  else
-	    func_fatal_error "\`$arg' is not a valid libtool object"
-	  fi
-	fi
-	;;
-
-      *.$libext)
-	# An archive.
-	deplibs="$deplibs $arg"
-	old_deplibs="$old_deplibs $arg"
-	continue
-	;;
-
-      *.la)
-	# A libtool-controlled library.
-
-	if test "$prev" = dlfiles; then
-	  # This library was specified with -dlopen.
-	  dlfiles="$dlfiles $arg"
-	  prev=
-	elif test "$prev" = dlprefiles; then
-	  # The library was specified with -dlpreopen.
-	  dlprefiles="$dlprefiles $arg"
-	  prev=
-	else
-	  deplibs="$deplibs $arg"
-	fi
-	continue
-	;;
-
-      # Some other compiler argument.
-      *)
-	# Unknown arguments in both finalize_command and compile_command need
-	# to be aesthetically quoted because they are evaled later.
-	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
-	;;
-      esac # arg
-
-      # Now actually substitute the argument into the commands.
-      if test -n "$arg"; then
-	func_append compile_command " $arg"
-	func_append finalize_command " $arg"
-      fi
-    done # argument parsing loop
-
-    test -n "$prev" && \
-      func_fatal_help "the \`$prevarg' option requires an argument"
-
-    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
-      eval arg=\"$export_dynamic_flag_spec\"
-      func_append compile_command " $arg"
-      func_append finalize_command " $arg"
-    fi
-
-    oldlibs=
-    # calculate the name of the file, without its directory
-    func_basename "$output"
-    outputname="$func_basename_result"
-    libobjs_save="$libobjs"
-
-    if test -n "$shlibpath_var"; then
-      # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
-    else
-      shlib_search_path=
-    fi
-    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
-    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
-
-    func_dirname "$output" "/" ""
-    output_objdir="$func_dirname_result$objdir"
-    # Create the object directory.
-    func_mkdir_p "$output_objdir"
-
-    # Determine the type of output
-    case $output in
-    "")
-      func_fatal_help "you must specify an output file"
-      ;;
-    *.$libext) linkmode=oldlib ;;
-    *.lo | *.$objext) linkmode=obj ;;
-    *.la) linkmode=lib ;;
-    *) linkmode=prog ;; # Anything else should be a program.
-    esac
-
-    specialdeplibs=
-
-    libs=
-    # Find all interdependent deplibs by searching for libraries
-    # that are linked more than once (e.g. -la -lb -la)
-    for deplib in $deplibs; do
-      if $opt_duplicate_deps ; then
-	case "$libs " in
-	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	esac
-      fi
-      libs="$libs $deplib"
-    done
-
-    if test "$linkmode" = lib; then
-      libs="$predeps $libs $compiler_lib_search_path $postdeps"
-
-      # Compute libraries that are listed more than once in $predeps
-      # $postdeps and mark them as special (i.e., whose duplicates are
-      # not to be eliminated).
-      pre_post_deps=
-      if $opt_duplicate_compiler_generated_deps; then
-	for pre_post_dep in $predeps $postdeps; do
-	  case "$pre_post_deps " in
-	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
-	  esac
-	  pre_post_deps="$pre_post_deps $pre_post_dep"
-	done
-      fi
-      pre_post_deps=
-    fi
-
-    deplibs=
-    newdependency_libs=
-    newlib_search_path=
-    need_relink=no # whether we're linking any uninstalled libtool libraries
-    notinst_deplibs= # not-installed libtool libraries
-    notinst_path= # paths that contain not-installed libtool libraries
-
-    case $linkmode in
-    lib)
-	passes="conv dlpreopen link"
-	for file in $dlfiles $dlprefiles; do
-	  case $file in
-	  *.la) ;;
-	  *)
-	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
-	    ;;
-	  esac
-	done
-	;;
-    prog)
-	compile_deplibs=
-	finalize_deplibs=
-	alldeplibs=no
-	newdlfiles=
-	newdlprefiles=
-	passes="conv scan dlopen dlpreopen link"
-	;;
-    *)  passes="conv"
-	;;
-    esac
-
-    for pass in $passes; do
-      # The preopen pass in lib mode reverses $deplibs; put it back here
-      # so that -L comes before libs that need it for instance...
-      if test "$linkmode,$pass" = "lib,link"; then
-	## FIXME: Find the place where the list is rebuilt in the wrong
-	##        order, and fix it there properly
-        tmp_deplibs=
-	for deplib in $deplibs; do
-	  tmp_deplibs="$deplib $tmp_deplibs"
-	done
-	deplibs="$tmp_deplibs"
-      fi
-
-      if test "$linkmode,$pass" = "lib,link" ||
-	 test "$linkmode,$pass" = "prog,scan"; then
-	libs="$deplibs"
-	deplibs=
-      fi
-      if test "$linkmode" = prog; then
-	case $pass in
-	dlopen) libs="$dlfiles" ;;
-	dlpreopen) libs="$dlprefiles" ;;
-	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
-	esac
-      fi
-      if test "$linkmode,$pass" = "lib,dlpreopen"; then
-	# Collect and forward deplibs of preopened libtool libs
-	for lib in $dlprefiles; do
-	  # Ignore non-libtool-libs
-	  dependency_libs=
-	  case $lib in
-	  *.la)	func_source "$lib" ;;
-	  esac
-
-	  # Collect preopened libtool deplibs, except any this library
-	  # has declared as weak libs
-	  for deplib in $dependency_libs; do
-	    func_basename "$deplib"
-            deplib_base=$func_basename_result
-	    case " $weak_libs " in
-	    *" $deplib_base "*) ;;
-	    *) deplibs="$deplibs $deplib" ;;
-	    esac
-	  done
-	done
-	libs="$dlprefiles"
-      fi
-      if test "$pass" = dlopen; then
-	# Collect dlpreopened libraries
-	save_deplibs="$deplibs"
-	deplibs=
-      fi
-
-      for deplib in $libs; do
-	lib=
-	found=no
-	case $deplib in
-	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
-	  if test "$linkmode,$pass" = "prog,link"; then
-	    compile_deplibs="$deplib $compile_deplibs"
-	    finalize_deplibs="$deplib $finalize_deplibs"
-	  else
-	    compiler_flags="$compiler_flags $deplib"
-	    if test "$linkmode" = lib ; then
-		case "$new_inherited_linker_flags " in
-		    *" $deplib "*) ;;
-		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
-		esac
-	    fi
-	  fi
-	  continue
-	  ;;
-	-l*)
-	  if test "$linkmode" != lib && test "$linkmode" != prog; then
-	    func_warning "\`-l' is ignored for archives/objects"
-	    continue
-	  fi
-	  func_stripname '-l' '' "$deplib"
-	  name=$func_stripname_result
-	  if test "$linkmode" = lib; then
-	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
-	  else
-	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
-	  fi
-	  for searchdir in $searchdirs; do
-	    for search_ext in .la $std_shrext .so .a; do
-	      # Search the libtool library
-	      lib="$searchdir/lib${name}${search_ext}"
-	      if test -f "$lib"; then
-		if test "$search_ext" = ".la"; then
-		  found=yes
-		else
-		  found=no
-		fi
-		break 2
-	      fi
-	    done
-	  done
-	  if test "$found" != yes; then
-	    # deplib doesn't seem to be a libtool library
-	    if test "$linkmode,$pass" = "prog,link"; then
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      deplibs="$deplib $deplibs"
-	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    continue
-	  else # deplib is a libtool library
-	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
-	    # We need to do some special things here, and not later.
-	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	      case " $predeps $postdeps " in
-	      *" $deplib "*)
-		if func_lalib_p "$lib"; then
-		  library_names=
-		  old_library=
-		  func_source "$lib"
-		  for l in $old_library $library_names; do
-		    ll="$l"
-		  done
-		  if test "X$ll" = "X$old_library" ; then # only static version available
-		    found=no
-		    func_dirname "$lib" "" "."
-		    ladir="$func_dirname_result"
-		    lib=$ladir/$old_library
-		    if test "$linkmode,$pass" = "prog,link"; then
-		      compile_deplibs="$deplib $compile_deplibs"
-		      finalize_deplibs="$deplib $finalize_deplibs"
-		    else
-		      deplibs="$deplib $deplibs"
-		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-		    fi
-		    continue
-		  fi
-		fi
-		;;
-	      *) ;;
-	      esac
-	    fi
-	  fi
-	  ;; # -l
-	*.ltframework)
-	  if test "$linkmode,$pass" = "prog,link"; then
-	    compile_deplibs="$deplib $compile_deplibs"
-	    finalize_deplibs="$deplib $finalize_deplibs"
-	  else
-	    deplibs="$deplib $deplibs"
-	    if test "$linkmode" = lib ; then
-		case "$new_inherited_linker_flags " in
-		    *" $deplib "*) ;;
-		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
-		esac
-	    fi
-	  fi
-	  continue
-	  ;;
-	-L*)
-	  case $linkmode in
-	  lib)
-	    deplibs="$deplib $deplibs"
-	    test "$pass" = conv && continue
-	    newdependency_libs="$deplib $newdependency_libs"
-	    func_stripname '-L' '' "$deplib"
-	    newlib_search_path="$newlib_search_path $func_stripname_result"
-	    ;;
-	  prog)
-	    if test "$pass" = conv; then
-	      deplibs="$deplib $deplibs"
-	      continue
-	    fi
-	    if test "$pass" = scan; then
-	      deplibs="$deplib $deplibs"
-	    else
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    fi
-	    func_stripname '-L' '' "$deplib"
-	    newlib_search_path="$newlib_search_path $func_stripname_result"
-	    ;;
-	  *)
-	    func_warning "\`-L' is ignored for archives/objects"
-	    ;;
-	  esac # linkmode
-	  continue
-	  ;; # -L
-	-R*)
-	  if test "$pass" = link; then
-	    func_stripname '-R' '' "$deplib"
-	    dir=$func_stripname_result
-	    # Make sure the xrpath contains only unique directories.
-	    case "$xrpath " in
-	    *" $dir "*) ;;
-	    *) xrpath="$xrpath $dir" ;;
-	    esac
-	  fi
-	  deplibs="$deplib $deplibs"
-	  continue
-	  ;;
-	*.la) lib="$deplib" ;;
-	*.$libext)
-	  if test "$pass" = conv; then
-	    deplibs="$deplib $deplibs"
-	    continue
-	  fi
-	  case $linkmode in
-	  lib)
-	    # Linking convenience modules into shared libraries is allowed,
-	    # but linking other static libraries is non-portable.
-	    case " $dlpreconveniencelibs " in
-	    *" $deplib "*) ;;
-	    *)
-	      valid_a_lib=no
-	      case $deplibs_check_method in
-		match_pattern*)
-		  set dummy $deplibs_check_method; shift
-		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
-		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
-		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		    valid_a_lib=yes
-		  fi
-		;;
-		pass_all)
-		  valid_a_lib=yes
-		;;
-	      esac
-	      if test "$valid_a_lib" != yes; then
-		echo
-		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
-		echo "*** I have the capability to make that library automatically link in when"
-		echo "*** you link to this library.  But I can only do this if you have a"
-		echo "*** shared version of the library, which you do not appear to have"
-		echo "*** because the file extensions .$libext of this argument makes me believe"
-		echo "*** that it is just a static archive that I should not use here."
-	      else
-		echo
-		$ECHO "*** Warning: Linking the shared library $output against the"
-		$ECHO "*** static library $deplib is not portable!"
-		deplibs="$deplib $deplibs"
-	      fi
-	      ;;
-	    esac
-	    continue
-	    ;;
-	  prog)
-	    if test "$pass" != link; then
-	      deplibs="$deplib $deplibs"
-	    else
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    fi
-	    continue
-	    ;;
-	  esac # linkmode
-	  ;; # *.$libext
-	*.lo | *.$objext)
-	  if test "$pass" = conv; then
-	    deplibs="$deplib $deplibs"
-	  elif test "$linkmode" = prog; then
-	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
-	      # If there is no dlopen support or we're linking statically,
-	      # we need to preload.
-	      newdlprefiles="$newdlprefiles $deplib"
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      newdlfiles="$newdlfiles $deplib"
-	    fi
-	  fi
-	  continue
-	  ;;
-	%DEPLIBS%)
-	  alldeplibs=yes
-	  continue
-	  ;;
-	esac # case $deplib
-
-	if test "$found" = yes || test -f "$lib"; then :
-	else
-	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
-	fi
-
-	# Check to see that this really is a libtool archive.
-	func_lalib_unsafe_p "$lib" \
-	  || func_fatal_error "\`$lib' is not a valid libtool archive"
-
-	func_dirname "$lib" "" "."
-	ladir="$func_dirname_result"
-
-	dlname=
-	dlopen=
-	dlpreopen=
-	libdir=
-	library_names=
-	old_library=
-	inherited_linker_flags=
-	# If the library was installed with an old release of libtool,
-	# it will not redefine variables installed, or shouldnotlink
-	installed=yes
-	shouldnotlink=no
-	avoidtemprpath=
-
-
-	# Read the .la file
-	func_source "$lib"
-
-	# Convert "-framework foo" to "foo.ltframework"
-	if test -n "$inherited_linker_flags"; then
-	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
-	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
-	    case " $new_inherited_linker_flags " in
-	      *" $tmp_inherited_linker_flag "*) ;;
-	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
-	    esac
-	  done
-	fi
-	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	if test "$linkmode,$pass" = "lib,link" ||
-	   test "$linkmode,$pass" = "prog,scan" ||
-	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
-	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
-	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
-	fi
-
-	if test "$pass" = conv; then
-	  # Only check for convenience libraries
-	  deplibs="$lib $deplibs"
-	  if test -z "$libdir"; then
-	    if test -z "$old_library"; then
-	      func_fatal_error "cannot find name of link library for \`$lib'"
-	    fi
-	    # It is a libtool convenience library, so add in its objects.
-	    convenience="$convenience $ladir/$objdir/$old_library"
-	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
-	    func_fatal_error "\`$lib' is not a convenience library"
-	  fi
-	  tmp_libs=
-	  for deplib in $dependency_libs; do
-	    deplibs="$deplib $deplibs"
-	    if $opt_duplicate_deps ; then
-	      case "$tmp_libs " in
-	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	      esac
-	    fi
-	    tmp_libs="$tmp_libs $deplib"
-	  done
-	  continue
-	fi # $pass = conv
-
-
-	# Get the name of the library we link against.
-	linklib=
-	for l in $old_library $library_names; do
-	  linklib="$l"
-	done
-	if test -z "$linklib"; then
-	  func_fatal_error "cannot find name of link library for \`$lib'"
-	fi
-
-	# This library was specified with -dlopen.
-	if test "$pass" = dlopen; then
-	  if test -z "$libdir"; then
-	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
-	  fi
-	  if test -z "$dlname" ||
-	     test "$dlopen_support" != yes ||
-	     test "$build_libtool_libs" = no; then
-	    # If there is no dlname, no dlopen support or we're linking
-	    # statically, we need to preload.  We also need to preload any
-	    # dependent libraries so libltdl's deplib preloader doesn't
-	    # bomb out in the load deplibs phase.
-	    dlprefiles="$dlprefiles $lib $dependency_libs"
-	  else
-	    newdlfiles="$newdlfiles $lib"
-	  fi
-	  continue
-	fi # $pass = dlopen
-
-	# We need an absolute path.
-	case $ladir in
-	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
-	*)
-	  abs_ladir=`cd "$ladir" && pwd`
-	  if test -z "$abs_ladir"; then
-	    func_warning "cannot determine absolute directory name of \`$ladir'"
-	    func_warning "passing it literally to the linker, although it might fail"
-	    abs_ladir="$ladir"
-	  fi
-	  ;;
-	esac
-	func_basename "$lib"
-	laname="$func_basename_result"
-
-	# Find the relevant object directory and library name.
-	if test "X$installed" = Xyes; then
-	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    func_warning "library \`$lib' was moved."
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    libdir="$abs_ladir"
-	  else
-	    dir="$libdir"
-	    absdir="$libdir"
-	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
-	else
-	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    # Remove this search path later
-	    notinst_path="$notinst_path $abs_ladir"
-	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
-	    # Remove this search path later
-	    notinst_path="$notinst_path $abs_ladir"
-	  fi
-	fi # $installed = yes
-	func_stripname 'lib' '.la' "$laname"
-	name=$func_stripname_result
-
-	# This library was specified with -dlpreopen.
-	if test "$pass" = dlpreopen; then
-	  if test -z "$libdir" && test "$linkmode" = prog; then
-	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
-	  fi
-	  # Prefer using a static library (so that no silly _DYNAMIC symbols
-	  # are required to link).
-	  if test -n "$old_library"; then
-	    newdlprefiles="$newdlprefiles $dir/$old_library"
-	    # Keep a list of preopened convenience libraries to check
-	    # that they are being used correctly in the link pass.
-	    test -z "$libdir" && \
-		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
-	  # Otherwise, use the dlname, so that lt_dlopen finds it.
-	  elif test -n "$dlname"; then
-	    newdlprefiles="$newdlprefiles $dir/$dlname"
-	  else
-	    newdlprefiles="$newdlprefiles $dir/$linklib"
-	  fi
-	fi # $pass = dlpreopen
-
-	if test -z "$libdir"; then
-	  # Link the convenience library
-	  if test "$linkmode" = lib; then
-	    deplibs="$dir/$old_library $deplibs"
-	  elif test "$linkmode,$pass" = "prog,link"; then
-	    compile_deplibs="$dir/$old_library $compile_deplibs"
-	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
-	  else
-	    deplibs="$lib $deplibs" # used for prog,scan pass
-	  fi
-	  continue
-	fi
-
-
-	if test "$linkmode" = prog && test "$pass" != link; then
-	  newlib_search_path="$newlib_search_path $ladir"
-	  deplibs="$lib $deplibs"
-
-	  linkalldeplibs=no
-	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
-	     test "$build_libtool_libs" = no; then
-	    linkalldeplibs=yes
-	  fi
-
-	  tmp_libs=
-	  for deplib in $dependency_libs; do
-	    case $deplib in
-	    -L*) func_stripname '-L' '' "$deplib"
-	         newlib_search_path="$newlib_search_path $func_stripname_result"
-		 ;;
-	    esac
-	    # Need to link against all dependency_libs?
-	    if test "$linkalldeplibs" = yes; then
-	      deplibs="$deplib $deplibs"
-	    else
-	      # Need to hardcode shared library paths
-	      # or/and link against static libraries
-	      newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    if $opt_duplicate_deps ; then
-	      case "$tmp_libs " in
-	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	      esac
-	    fi
-	    tmp_libs="$tmp_libs $deplib"
-	  done # for deplib
-	  continue
-	fi # $linkmode = prog...
-
-	if test "$linkmode,$pass" = "prog,link"; then
-	  if test -n "$library_names" &&
-	     { { test "$prefer_static_libs" = no ||
-	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
-	       test -z "$old_library"; }; then
-	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
-	      # Make sure the rpath contains only unique directories.
-	      case "$temp_rpath:" in
-	      *"$absdir:"*) ;;
-	      *) temp_rpath="$temp_rpath$absdir:" ;;
-	      esac
-	    fi
-
-	    # Hardcode the library path.
-	    # Skip directories that are in the system default run-time
-	    # search path.
-	    case " $sys_lib_dlsearch_path " in
-	    *" $absdir "*) ;;
-	    *)
-	      case "$compile_rpath " in
-	      *" $absdir "*) ;;
-	      *) compile_rpath="$compile_rpath $absdir"
-	      esac
-	      ;;
-	    esac
-	    case " $sys_lib_dlsearch_path " in
-	    *" $libdir "*) ;;
-	    *)
-	      case "$finalize_rpath " in
-	      *" $libdir "*) ;;
-	      *) finalize_rpath="$finalize_rpath $libdir"
-	      esac
-	      ;;
-	    esac
-	  fi # $linkmode,$pass = prog,link...
-
-	  if test "$alldeplibs" = yes &&
-	     { test "$deplibs_check_method" = pass_all ||
-	       { test "$build_libtool_libs" = yes &&
-		 test -n "$library_names"; }; }; then
-	    # We only need to search for static libraries
-	    continue
-	  fi
-	fi
-
-	link_static=no # Whether the deplib will be linked statically
-	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes; then
-	  use_static_libs=no
-	fi
-	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
-	  case $host in
-	  *cygwin* | *mingw* | *cegcc*)
-	      # No point in relinking DLLs because paths are not encoded
-	      notinst_deplibs="$notinst_deplibs $lib"
-	      need_relink=no
-	    ;;
-	  *)
-	    if test "$installed" = no; then
-	      notinst_deplibs="$notinst_deplibs $lib"
-	      need_relink=yes
-	    fi
-	    ;;
-	  esac
-	  # This is a shared library
-
-	  # Warn about portability, can't link against -module's on some
-	  # systems (darwin).  Don't bleat about dlopened modules though!
-	  dlopenmodule=""
-	  for dlpremoduletest in $dlprefiles; do
-	    if test "X$dlpremoduletest" = "X$lib"; then
-	      dlopenmodule="$dlpremoduletest"
-	      break
-	    fi
-	  done
-	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
-	    echo
-	    if test "$linkmode" = prog; then
-	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
-	    else
-	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
-	    fi
-	    $ECHO "*** $linklib is not portable!"
-	  fi
-	  if test "$linkmode" = lib &&
-	     test "$hardcode_into_libs" = yes; then
-	    # Hardcode the library path.
-	    # Skip directories that are in the system default run-time
-	    # search path.
-	    case " $sys_lib_dlsearch_path " in
-	    *" $absdir "*) ;;
-	    *)
-	      case "$compile_rpath " in
-	      *" $absdir "*) ;;
-	      *) compile_rpath="$compile_rpath $absdir"
-	      esac
-	      ;;
-	    esac
-	    case " $sys_lib_dlsearch_path " in
-	    *" $libdir "*) ;;
-	    *)
-	      case "$finalize_rpath " in
-	      *" $libdir "*) ;;
-	      *) finalize_rpath="$finalize_rpath $libdir"
-	      esac
-	      ;;
-	    esac
-	  fi
-
-	  if test -n "$old_archive_from_expsyms_cmds"; then
-	    # figure out the soname
-	    set dummy $library_names
-	    shift
-	    realname="$1"
-	    shift
-	    libname=`eval "\\$ECHO \"$libname_spec\""`
-	    # use dlname if we got it. it's perfectly good, no?
-	    if test -n "$dlname"; then
-	      soname="$dlname"
-	    elif test -n "$soname_spec"; then
-	      # bleh windows
-	      case $host in
-	      *cygwin* | mingw* | *cegcc*)
-	        func_arith $current - $age
-		major=$func_arith_result
-		versuffix="-$major"
-		;;
-	      esac
-	      eval soname=\"$soname_spec\"
-	    else
-	      soname="$realname"
-	    fi
-
-	    # Make a new name for the extract_expsyms_cmds to use
-	    soroot="$soname"
-	    func_basename "$soroot"
-	    soname="$func_basename_result"
-	    func_stripname 'lib' '.dll' "$soname"
-	    newlib=libimp-$func_stripname_result.a
-
-	    # If the library has no export list, then create one now
-	    if test -f "$output_objdir/$soname-def"; then :
-	    else
-	      func_verbose "extracting exported symbol list from \`$soname'"
-	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
-	    fi
-
-	    # Create $newlib
-	    if test -f "$output_objdir/$newlib"; then :; else
-	      func_verbose "generating import library for \`$soname'"
-	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
-	    fi
-	    # make sure the library variables are pointing to the new library
-	    dir=$output_objdir
-	    linklib=$newlib
-	  fi # test -n "$old_archive_from_expsyms_cmds"
-
-	  if test "$linkmode" = prog || test "$mode" != relink; then
-	    add_shlibpath=
-	    add_dir=
-	    add=
-	    lib_linked=yes
-	    case $hardcode_action in
-	    immediate | unsupported)
-	      if test "$hardcode_direct" = no; then
-		add="$dir/$linklib"
-		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
-		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
-		  *-*-darwin* )
-		    # if the lib is a (non-dlopened) module then we can not
-		    # link against it, someone is ignoring the earlier warnings
-		    if /usr/bin/file -L $add 2> /dev/null |
-			 $GREP ": [^:]* bundle" >/dev/null ; then
-		      if test "X$dlopenmodule" != "X$lib"; then
-			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
-			if test -z "$old_library" ; then
-			  echo
-			  echo "*** And there doesn't seem to be a static archive available"
-			  echo "*** The link will probably fail, sorry"
-			else
-			  add="$dir/$old_library"
-			fi
-		      elif test -n "$old_library"; then
-			add="$dir/$old_library"
-		      fi
-		    fi
-		esac
-	      elif test "$hardcode_minus_L" = no; then
-		case $host in
-		*-*-sunos*) add_shlibpath="$dir" ;;
-		esac
-		add_dir="-L$dir"
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = no; then
-		add_shlibpath="$dir"
-		add="-l$name"
-	      else
-		lib_linked=no
-	      fi
-	      ;;
-	    relink)
-	      if test "$hardcode_direct" = yes &&
-	         test "$hardcode_direct_absolute" = no; then
-		add="$dir/$linklib"
-	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$dir"
-		# Try looking first in the location we're being installed to.
-		if test -n "$inst_prefix_dir"; then
-		  case $libdir in
-		    [\\/]*)
-		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
-		      ;;
-		  esac
-		fi
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = yes; then
-		add_shlibpath="$dir"
-		add="-l$name"
-	      else
-		lib_linked=no
-	      fi
-	      ;;
-	    *) lib_linked=no ;;
-	    esac
-
-	    if test "$lib_linked" != yes; then
-	      func_fatal_configuration "unsupported hardcode properties"
-	    fi
-
-	    if test -n "$add_shlibpath"; then
-	      case :$compile_shlibpath: in
-	      *":$add_shlibpath:"*) ;;
-	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
-	      esac
-	    fi
-	    if test "$linkmode" = prog; then
-	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
-	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
-	    else
-	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
-	      test -n "$add" && deplibs="$add $deplibs"
-	      if test "$hardcode_direct" != yes &&
-		 test "$hardcode_minus_L" != yes &&
-		 test "$hardcode_shlibpath_var" = yes; then
-		case :$finalize_shlibpath: in
-		*":$libdir:"*) ;;
-		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
-		esac
-	      fi
-	    fi
-	  fi
-
-	  if test "$linkmode" = prog || test "$mode" = relink; then
-	    add_shlibpath=
-	    add_dir=
-	    add=
-	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes &&
-	       test "$hardcode_direct_absolute" = no; then
-	      add="$libdir/$linklib"
-	    elif test "$hardcode_minus_L" = yes; then
-	      add_dir="-L$libdir"
-	      add="-l$name"
-	    elif test "$hardcode_shlibpath_var" = yes; then
-	      case :$finalize_shlibpath: in
-	      *":$libdir:"*) ;;
-	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
-	      esac
-	      add="-l$name"
-	    elif test "$hardcode_automatic" = yes; then
-	      if test -n "$inst_prefix_dir" &&
-		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
-		add="$inst_prefix_dir$libdir/$linklib"
-	      else
-		add="$libdir/$linklib"
-	      fi
-	    else
-	      # We cannot seem to hardcode it, guess we'll fake it.
-	      add_dir="-L$libdir"
-	      # Try looking first in the location we're being installed to.
-	      if test -n "$inst_prefix_dir"; then
-		case $libdir in
-		  [\\/]*)
-		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
-		    ;;
-		esac
-	      fi
-	      add="-l$name"
-	    fi
-
-	    if test "$linkmode" = prog; then
-	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
-	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
-	    else
-	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
-	      test -n "$add" && deplibs="$add $deplibs"
-	    fi
-	  fi
-	elif test "$linkmode" = prog; then
-	  # Here we assume that one of hardcode_direct or hardcode_minus_L
-	  # is not unsupported.  This is valid on all known static and
-	  # shared platforms.
-	  if test "$hardcode_direct" != unsupported; then
-	    test -n "$old_library" && linklib="$old_library"
-	    compile_deplibs="$dir/$linklib $compile_deplibs"
-	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
-	  else
-	    compile_deplibs="-l$name -L$dir $compile_deplibs"
-	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
-	  fi
-	elif test "$build_libtool_libs" = yes; then
-	  # Not a shared library
-	  if test "$deplibs_check_method" != pass_all; then
-	    # We're trying link a shared library against a static one
-	    # but the system doesn't support it.
-
-	    # Just print a warning and add the library to dependency_libs so
-	    # that the program can be linked against the static library.
-	    echo
-	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
-	    echo "*** I have the capability to make that library automatically link in when"
-	    echo "*** you link to this library.  But I can only do this if you have a"
-	    echo "*** shared version of the library, which you do not appear to have."
-	    if test "$module" = yes; then
-	      echo "*** But as you try to build a module library, libtool will still create "
-	      echo "*** a static module, that should work as long as the dlopening application"
-	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
-	      if test -z "$global_symbol_pipe"; then
-		echo
-		echo "*** However, this would only work if libtool was able to extract symbol"
-		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
-		echo "*** not find such a program.  So, this module is probably useless."
-		echo "*** \`nm' from GNU binutils and a full rebuild may help."
-	      fi
-	      if test "$build_old_libs" = no; then
-		build_libtool_libs=module
-		build_old_libs=yes
-	      else
-		build_libtool_libs=no
-	      fi
-	    fi
-	  else
-	    deplibs="$dir/$old_library $deplibs"
-	    link_static=yes
-	  fi
-	fi # link shared/static library?
-
-	if test "$linkmode" = lib; then
-	  if test -n "$dependency_libs" &&
-	     { test "$hardcode_into_libs" != yes ||
-	       test "$build_old_libs" = yes ||
-	       test "$link_static" = yes; }; then
-	    # Extract -R from dependency_libs
-	    temp_deplibs=
-	    for libdir in $dependency_libs; do
-	      case $libdir in
-	      -R*) func_stripname '-R' '' "$libdir"
-	           temp_xrpath=$func_stripname_result
-		   case " $xrpath " in
-		   *" $temp_xrpath "*) ;;
-		   *) xrpath="$xrpath $temp_xrpath";;
-		   esac;;
-	      *) temp_deplibs="$temp_deplibs $libdir";;
-	      esac
-	    done
-	    dependency_libs="$temp_deplibs"
-	  fi
-
-	  newlib_search_path="$newlib_search_path $absdir"
-	  # Link against this library
-	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
-	  # ... and its dependency_libs
-	  tmp_libs=
-	  for deplib in $dependency_libs; do
-	    newdependency_libs="$deplib $newdependency_libs"
-	    if $opt_duplicate_deps ; then
-	      case "$tmp_libs " in
-	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	      esac
-	    fi
-	    tmp_libs="$tmp_libs $deplib"
-	  done
-
-	  if test "$link_all_deplibs" != no; then
-	    # Add the search paths of all dependency libraries
-	    for deplib in $dependency_libs; do
-	      path=
-	      case $deplib in
-	      -L*) path="$deplib" ;;
-	      *.la)
-	        func_dirname "$deplib" "" "."
-		dir="$func_dirname_result"
-		# We need an absolute path.
-		case $dir in
-		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
-		*)
-		  absdir=`cd "$dir" && pwd`
-		  if test -z "$absdir"; then
-		    func_warning "cannot determine absolute directory name of \`$dir'"
-		    absdir="$dir"
-		  fi
-		  ;;
-		esac
-		if $GREP "^installed=no" $deplib > /dev/null; then
-		case $host in
-		*-*-darwin*)
-		  depdepl=
-		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
-		  if test -n "$deplibrary_names" ; then
-		    for tmp in $deplibrary_names ; do
-		      depdepl=$tmp
-		    done
-		    if test -f "$absdir/$objdir/$depdepl" ; then
-		      depdepl="$absdir/$objdir/$depdepl"
-		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
-                      if test -z "$darwin_install_name"; then
-                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
-                      fi
-		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
-		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
-		      path=
-		    fi
-		  fi
-		  ;;
-		*)
-		  path="-L$absdir/$objdir"
-		  ;;
-		esac
-		else
-		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
-		  test -z "$libdir" && \
-		    func_fatal_error "\`$deplib' is not a valid libtool archive"
-		  test "$absdir" != "$libdir" && \
-		    func_warning "\`$deplib' seems to be moved"
-
-		  path="-L$absdir"
-		fi
-		;;
-	      esac
-	      case " $deplibs " in
-	      *" $path "*) ;;
-	      *) deplibs="$path $deplibs" ;;
-	      esac
-	    done
-	  fi # link_all_deplibs != no
-	fi # linkmode = lib
-      done # for deplib in $libs
-      if test "$pass" = link; then
-	if test "$linkmode" = "prog"; then
-	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
-	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
-	else
-	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	fi
-      fi
-      dependency_libs="$newdependency_libs"
-      if test "$pass" = dlpreopen; then
-	# Link the dlpreopened libraries before other libraries
-	for deplib in $save_deplibs; do
-	  deplibs="$deplib $deplibs"
-	done
-      fi
-      if test "$pass" != dlopen; then
-	if test "$pass" != conv; then
-	  # Make sure lib_search_path contains only unique directories.
-	  lib_search_path=
-	  for dir in $newlib_search_path; do
-	    case "$lib_search_path " in
-	    *" $dir "*) ;;
-	    *) lib_search_path="$lib_search_path $dir" ;;
-	    esac
-	  done
-	  newlib_search_path=
-	fi
-
-	if test "$linkmode,$pass" != "prog,link"; then
-	  vars="deplibs"
-	else
-	  vars="compile_deplibs finalize_deplibs"
-	fi
-	for var in $vars dependency_libs; do
-	  # Add libraries to $var in reverse order
-	  eval tmp_libs=\"\$$var\"
-	  new_libs=
-	  for deplib in $tmp_libs; do
-	    # FIXME: Pedantically, this is the right thing to do, so
-	    #        that some nasty dependency loop isn't accidentally
-	    #        broken:
-	    #new_libs="$deplib $new_libs"
-	    # Pragmatically, this seems to cause very few problems in
-	    # practice:
-	    case $deplib in
-	    -L*) new_libs="$deplib $new_libs" ;;
-	    -R*) ;;
-	    *)
-	      # And here is the reason: when a library appears more
-	      # than once as an explicit dependence of a library, or
-	      # is implicitly linked in more than once by the
-	      # compiler, it is considered special, and multiple
-	      # occurrences thereof are not removed.  Compare this
-	      # with having the same library being listed as a
-	      # dependency of multiple other libraries: in this case,
-	      # we know (pedantically, we assume) the library does not
-	      # need to be listed more than once, so we keep only the
-	      # last copy.  This is not always right, but it is rare
-	      # enough that we require users that really mean to play
-	      # such unportable linking tricks to link the library
-	      # using -Wl,-lname, so that libtool does not consider it
-	      # for duplicate removal.
-	      case " $specialdeplibs " in
-	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
-	      *)
-		case " $new_libs " in
-		*" $deplib "*) ;;
-		*) new_libs="$deplib $new_libs" ;;
-		esac
-		;;
-	      esac
-	      ;;
-	    esac
-	  done
-	  tmp_libs=
-	  for deplib in $new_libs; do
-	    case $deplib in
-	    -L*)
-	      case " $tmp_libs " in
-	      *" $deplib "*) ;;
-	      *) tmp_libs="$tmp_libs $deplib" ;;
-	      esac
-	      ;;
-	    *) tmp_libs="$tmp_libs $deplib" ;;
-	    esac
-	  done
-	  eval $var=\"$tmp_libs\"
-	done # for var
-      fi
-      # Last step: remove runtime libs from dependency_libs
-      # (they stay in deplibs)
-      tmp_libs=
-      for i in $dependency_libs ; do
-	case " $predeps $postdeps $compiler_lib_search_path " in
-	*" $i "*)
-	  i=""
-	  ;;
-	esac
-	if test -n "$i" ; then
-	  tmp_libs="$tmp_libs $i"
-	fi
-      done
-      dependency_libs=$tmp_libs
-    done # for pass
-    if test "$linkmode" = prog; then
-      dlfiles="$newdlfiles"
-    fi
-    if test "$linkmode" = prog || test "$linkmode" = lib; then
-      dlprefiles="$newdlprefiles"
-    fi
-
-    case $linkmode in
-    oldlib)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for archives"
-      fi
-
-      case " $deplibs" in
-      *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for archives" ;;
-      esac
-
-      test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for archives"
-
-      test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for archives"
-
-      test -n "$vinfo" && \
-	func_warning "\`-version-info/-version-number' is ignored for archives"
-
-      test -n "$release" && \
-	func_warning "\`-release' is ignored for archives"
-
-      test -n "$export_symbols$export_symbols_regex" && \
-	func_warning "\`-export-symbols' is ignored for archives"
-
-      # Now set the variables for building old libraries.
-      build_libtool_libs=no
-      oldlibs="$output"
-      objs="$objs$old_deplibs"
-      ;;
-
-    lib)
-      # Make sure we only generate libraries of the form `libNAME.la'.
-      case $outputname in
-      lib*)
-	func_stripname 'lib' '.la' "$outputname"
-	name=$func_stripname_result
-	eval shared_ext=\"$shrext_cmds\"
-	eval libname=\"$libname_spec\"
-	;;
-      *)
-	test "$module" = no && \
-	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
-
-	if test "$need_lib_prefix" != no; then
-	  # Add the "lib" prefix for modules if required
-	  func_stripname '' '.la' "$outputname"
-	  name=$func_stripname_result
-	  eval shared_ext=\"$shrext_cmds\"
-	  eval libname=\"$libname_spec\"
-	else
-	  func_stripname '' '.la' "$outputname"
-	  libname=$func_stripname_result
-	fi
-	;;
-      esac
-
-      if test -n "$objs"; then
-	if test "$deplibs_check_method" != pass_all; then
-	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
-	else
-	  echo
-	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
-	  $ECHO "*** objects $objs is not portable!"
-	  libobjs="$libobjs $objs"
-	fi
-      fi
-
-      test "$dlself" != no && \
-	func_warning "\`-dlopen self' is ignored for libtool libraries"
-
-      set dummy $rpath
-      shift
-      test "$#" -gt 1 && \
-	func_warning "ignoring multiple \`-rpath's for a libtool library"
-
-      install_libdir="$1"
-
-      oldlibs=
-      if test -z "$rpath"; then
-	if test "$build_libtool_libs" = yes; then
-	  # Building a libtool convenience library.
-	  # Some compilers have problems with a `.al' extension so
-	  # convenience libraries should have the same extension an
-	  # archive normally would.
-	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
-	  build_libtool_libs=convenience
-	  build_old_libs=yes
-	fi
-
-	test -n "$vinfo" && \
-	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
-
-	test -n "$release" && \
-	  func_warning "\`-release' is ignored for convenience libraries"
-      else
-
-	# Parse the version information argument.
-	save_ifs="$IFS"; IFS=':'
-	set dummy $vinfo 0 0 0
-	shift
-	IFS="$save_ifs"
-
-	test -n "$7" && \
-	  func_fatal_help "too many parameters to \`-version-info'"
-
-	# convert absolute version numbers to libtool ages
-	# this retains compatibility with .la files and attempts
-	# to make the code below a bit more comprehensible
-
-	case $vinfo_number in
-	yes)
-	  number_major="$1"
-	  number_minor="$2"
-	  number_revision="$3"
-	  #
-	  # There are really only two kinds -- those that
-	  # use the current revision as the major version
-	  # and those that subtract age and use age as
-	  # a minor version.  But, then there is irix
-	  # which has an extra 1 added just for fun
-	  #
-	  case $version_type in
-	  darwin|linux|osf|windows|none)
-	    func_arith $number_major + $number_minor
-	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_revision"
-	    ;;
-	  freebsd-aout|freebsd-elf|qnx|sunos)
-	    current="$number_major"
-	    revision="$number_minor"
-	    age="0"
-	    ;;
-	  irix|nonstopux)
-	    func_arith $number_major + $number_minor
-	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_minor"
-	    lt_irix_increment=no
-	    ;;
-	  esac
-	  ;;
-	no)
-	  current="$1"
-	  revision="$2"
-	  age="$3"
-	  ;;
-	esac
-
-	# Check that each of the things are valid numbers.
-	case $current in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
-	*)
-	  func_error "CURRENT \`$current' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
-	  ;;
-	esac
-
-	case $revision in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
-	*)
-	  func_error "REVISION \`$revision' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
-	  ;;
-	esac
-
-	case $age in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
-	*)
-	  func_error "AGE \`$age' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
-	  ;;
-	esac
-
-	if test "$age" -gt "$current"; then
-	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
-	  func_fatal_error "\`$vinfo' is not valid version information"
-	fi
-
-	# Calculate the version variables.
-	major=
-	versuffix=
-	verstring=
-	case $version_type in
-	none) ;;
-
-	darwin)
-	  # Like Linux, but with the current version available in
-	  # verstring for coding it into the library header
-	  func_arith $current - $age
-	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
-	  # Darwin ld doesn't like 0 for these options...
-	  func_arith $current + 1
-	  minor_current=$func_arith_result
-	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
-	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
-	  ;;
-
-	freebsd-aout)
-	  major=".$current"
-	  versuffix=".$current.$revision";
-	  ;;
-
-	freebsd-elf)
-	  major=".$current"
-	  versuffix=".$current"
-	  ;;
-
-	irix | nonstopux)
-	  if test "X$lt_irix_increment" = "Xno"; then
-	    func_arith $current - $age
-	  else
-	    func_arith $current - $age + 1
-	  fi
-	  major=$func_arith_result
-
-	  case $version_type in
-	    nonstopux) verstring_prefix=nonstopux ;;
-	    *)         verstring_prefix=sgi ;;
-	  esac
-	  verstring="$verstring_prefix$major.$revision"
-
-	  # Add in all the interfaces that we are compatible with.
-	  loop=$revision
-	  while test "$loop" -ne 0; do
-	    func_arith $revision - $loop
-	    iface=$func_arith_result
-	    func_arith $loop - 1
-	    loop=$func_arith_result
-	    verstring="$verstring_prefix$major.$iface:$verstring"
-	  done
-
-	  # Before this point, $major must not contain `.'.
-	  major=.$major
-	  versuffix="$major.$revision"
-	  ;;
-
-	linux)
-	  func_arith $current - $age
-	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
-	  ;;
-
-	osf)
-	  func_arith $current - $age
-	  major=.$func_arith_result
-	  versuffix=".$current.$age.$revision"
-	  verstring="$current.$age.$revision"
-
-	  # Add in all the interfaces that we are compatible with.
-	  loop=$age
-	  while test "$loop" -ne 0; do
-	    func_arith $current - $loop
-	    iface=$func_arith_result
-	    func_arith $loop - 1
-	    loop=$func_arith_result
-	    verstring="$verstring:${iface}.0"
-	  done
-
-	  # Make executables depend on our current version.
-	  verstring="$verstring:${current}.0"
-	  ;;
-
-	qnx)
-	  major=".$current"
-	  versuffix=".$current"
-	  ;;
-
-	sunos)
-	  major=".$current"
-	  versuffix=".$current.$revision"
-	  ;;
-
-	windows)
-	  # Use '-' rather than '.', since we only want one
-	  # extension on DOS 8.3 filesystems.
-	  func_arith $current - $age
-	  major=$func_arith_result
-	  versuffix="-$major"
-	  ;;
-
-	*)
-	  func_fatal_configuration "unknown library version type \`$version_type'"
-	  ;;
-	esac
-
-	# Clear the version info if we defaulted, and they specified a release.
-	if test -z "$vinfo" && test -n "$release"; then
-	  major=
-	  case $version_type in
-	  darwin)
-	    # we can't check for "0.0" in archive_cmds due to quoting
-	    # problems, so we reset it completely
-	    verstring=
-	    ;;
-	  *)
-	    verstring="0.0"
-	    ;;
-	  esac
-	  if test "$need_version" = no; then
-	    versuffix=
-	  else
-	    versuffix=".0.0"
-	  fi
-	fi
-
-	# Remove version info from name if versioning should be avoided
-	if test "$avoid_version" = yes && test "$need_version" = no; then
-	  major=
-	  versuffix=
-	  verstring=""
-	fi
-
-	# Check to see if the archive will have undefined symbols.
-	if test "$allow_undefined" = yes; then
-	  if test "$allow_undefined_flag" = unsupported; then
-	    func_warning "undefined symbols not allowed in $host shared libraries"
-	    build_libtool_libs=no
-	    build_old_libs=yes
-	  fi
-	else
-	  # Don't allow undefined symbols.
-	  allow_undefined_flag="$no_undefined_flag"
-	fi
-
-      fi
-
-      func_generate_dlsyms "$libname" "$libname" "yes"
-      libobjs="$libobjs $symfileobj"
-      test "X$libobjs" = "X " && libobjs=
-
-      if test "$mode" != relink; then
-	# Remove our outputs, but don't remove object files since they
-	# may have been created when compiling PIC objects.
-	removelist=
-	tempremovelist=`$ECHO "$output_objdir/*"`
-	for p in $tempremovelist; do
-	  case $p in
-	    *.$objext | *.gcno)
-	       ;;
-	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
-	       if test "X$precious_files_regex" != "X"; then
-		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
-		 then
-		   continue
-		 fi
-	       fi
-	       removelist="$removelist $p"
-	       ;;
-	    *) ;;
-	  esac
-	done
-	test -n "$removelist" && \
-	  func_show_eval "${RM}r \$removelist"
-      fi
-
-      # Now set the variables for building old libraries.
-      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
-	oldlibs="$oldlibs $output_objdir/$libname.$libext"
-
-	# Transform .lo files to .o files.
-	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
-      fi
-
-      # Eliminate all temporary directories.
-      #for path in $notinst_path; do
-      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
-      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
-      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
-      #done
-
-      if test -n "$xrpath"; then
-	# If the user specified any rpath flags, then add them.
-	temp_xrpath=
-	for libdir in $xrpath; do
-	  temp_xrpath="$temp_xrpath -R$libdir"
-	  case "$finalize_rpath " in
-	  *" $libdir "*) ;;
-	  *) finalize_rpath="$finalize_rpath $libdir" ;;
-	  esac
-	done
-	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
-	  dependency_libs="$temp_xrpath $dependency_libs"
-	fi
-      fi
-
-      # Make sure dlfiles contains only unique files that won't be dlpreopened
-      old_dlfiles="$dlfiles"
-      dlfiles=
-      for lib in $old_dlfiles; do
-	case " $dlprefiles $dlfiles " in
-	*" $lib "*) ;;
-	*) dlfiles="$dlfiles $lib" ;;
-	esac
-      done
-
-      # Make sure dlprefiles contains only unique files
-      old_dlprefiles="$dlprefiles"
-      dlprefiles=
-      for lib in $old_dlprefiles; do
-	case "$dlprefiles " in
-	*" $lib "*) ;;
-	*) dlprefiles="$dlprefiles $lib" ;;
-	esac
-      done
-
-      if test "$build_libtool_libs" = yes; then
-	if test -n "$rpath"; then
-	  case $host in
-	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
-	    # these systems don't actually have a c library (as such)!
-	    ;;
-	  *-*-rhapsody* | *-*-darwin1.[012])
-	    # Rhapsody C library is in the System framework
-	    deplibs="$deplibs System.ltframework"
-	    ;;
-	  *-*-netbsd*)
-	    # Don't link with libc until the a.out ld.so is fixed.
-	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
-	    # Do not include libc due to us having libc/libc_r.
-	    ;;
-	  *-*-sco3.2v5* | *-*-sco5v6*)
-	    # Causes problems with __ctype
-	    ;;
-	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-	    # Compiler inserts libc in the correct place for threads to work
-	    ;;
-	  *)
-	    # Add libc to deplibs on all other systems if necessary.
-	    if test "$build_libtool_need_lc" = "yes"; then
-	      deplibs="$deplibs -lc"
-	    fi
-	    ;;
-	  esac
-	fi
-
-	# Transform deplibs into only deplibs that can be linked in shared.
-	name_save=$name
-	libname_save=$libname
-	release_save=$release
-	versuffix_save=$versuffix
-	major_save=$major
-	# I'm not sure if I'm treating the release correctly.  I think
-	# release should show up in the -l (ie -lgmp5) so we don't want to
-	# add it in twice.  Is that correct?
-	release=""
-	versuffix=""
-	major=""
-	newdeplibs=
-	droppeddeps=no
-	case $deplibs_check_method in
-	pass_all)
-	  # Don't check for shared/static.  Everything works.
-	  # This might be a little naive.  We might want to check
-	  # whether the library exists or not.  But this is on
-	  # osf3 & osf4 and I'm not really sure... Just
-	  # implementing what was already the behavior.
-	  newdeplibs=$deplibs
-	  ;;
-	test_compile)
-	  # This code stresses the "libraries are programs" paradigm to its
-	  # limits. Maybe even breaks it.  We compile a program, linking it
-	  # against the deplibs as a proxy for the library.  Then we can check
-	  # whether they linked in statically or dynamically with ldd.
-	  $opt_dry_run || $RM conftest.c
-	  cat > conftest.c <<EOF
-	  int main() { return 0; }
-EOF
-	  $opt_dry_run || $RM conftest
-	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
-	    ldd_output=`ldd conftest`
-	    for i in $deplibs; do
-	      case $i in
-	      -l*)
-		func_stripname -l '' "$i"
-		name=$func_stripname_result
-		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		  case " $predeps $postdeps " in
-		  *" $i "*)
-		    newdeplibs="$newdeplibs $i"
-		    i=""
-		    ;;
-		  esac
-		fi
-		if test -n "$i" ; then
-		  libname=`eval "\\$ECHO \"$libname_spec\""`
-		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
-		  set dummy $deplib_matches; shift
-		  deplib_match=$1
-		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
-		    newdeplibs="$newdeplibs $i"
-		  else
-		    droppeddeps=yes
-		    echo
-		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
-		    echo "*** I have the capability to make that library automatically link in when"
-		    echo "*** you link to this library.  But I can only do this if you have a"
-		    echo "*** shared version of the library, which I believe you do not have"
-		    echo "*** because a test_compile did reveal that the linker did not use it for"
-		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
-		  fi
-		fi
-		;;
-	      *)
-		newdeplibs="$newdeplibs $i"
-		;;
-	      esac
-	    done
-	  else
-	    # Error occurred in the first compile.  Let's try to salvage
-	    # the situation: Compile a separate program for each library.
-	    for i in $deplibs; do
-	      case $i in
-	      -l*)
-		func_stripname -l '' "$i"
-		name=$func_stripname_result
-		$opt_dry_run || $RM conftest
-		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
-		  ldd_output=`ldd conftest`
-		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		    case " $predeps $postdeps " in
-		    *" $i "*)
-		      newdeplibs="$newdeplibs $i"
-		      i=""
-		      ;;
-		    esac
-		  fi
-		  if test -n "$i" ; then
-		    libname=`eval "\\$ECHO \"$libname_spec\""`
-		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
-		    set dummy $deplib_matches; shift
-		    deplib_match=$1
-		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
-		      newdeplibs="$newdeplibs $i"
-		    else
-		      droppeddeps=yes
-		      echo
-		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
-		      echo "*** I have the capability to make that library automatically link in when"
-		      echo "*** you link to this library.  But I can only do this if you have a"
-		      echo "*** shared version of the library, which you do not appear to have"
-		      echo "*** because a test_compile did reveal that the linker did not use this one"
-		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
-		    fi
-		  fi
-		else
-		  droppeddeps=yes
-		  echo
-		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
-		  echo "*** make it link in!  You will probably need to install it or some"
-		  echo "*** library that it depends on before this library will be fully"
-		  echo "*** functional.  Installing it before continuing would be even better."
-		fi
-		;;
-	      *)
-		newdeplibs="$newdeplibs $i"
-		;;
-	      esac
-	    done
-	  fi
-	  ;;
-	file_magic*)
-	  set dummy $deplibs_check_method; shift
-	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
-	  for a_deplib in $deplibs; do
-	    case $a_deplib in
-	    -l*)
-	      func_stripname -l '' "$a_deplib"
-	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		case " $predeps $postdeps " in
-		*" $a_deplib "*)
-		  newdeplibs="$newdeplibs $a_deplib"
-		  a_deplib=""
-		  ;;
-		esac
-	      fi
-	      if test -n "$a_deplib" ; then
-		libname=`eval "\\$ECHO \"$libname_spec\""`
-		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
-		  for potent_lib in $potential_libs; do
-		      # Follow soft links.
-		      if ls -lLd "$potent_lib" 2>/dev/null |
-			 $GREP " -> " >/dev/null; then
-			continue
-		      fi
-		      # The statement above tries to avoid entering an
-		      # endless loop below, in case of cyclic links.
-		      # We might still enter an endless loop, since a link
-		      # loop can be closed while we follow links,
-		      # but so what?
-		      potlib="$potent_lib"
-		      while test -h "$potlib" 2>/dev/null; do
-			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
-			case $potliblink in
-			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
-			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
-			esac
-		      done
-		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
-			 $SED -e 10q |
-			 $EGREP "$file_magic_regex" > /dev/null; then
-			newdeplibs="$newdeplibs $a_deplib"
-			a_deplib=""
-			break 2
-		      fi
-		  done
-		done
-	      fi
-	      if test -n "$a_deplib" ; then
-		droppeddeps=yes
-		echo
-		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
-		echo "*** I have the capability to make that library automatically link in when"
-		echo "*** you link to this library.  But I can only do this if you have a"
-		echo "*** shared version of the library, which you do not appear to have"
-		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
-		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
-		else
-		  $ECHO "*** with $libname and none of the candidates passed a file format test"
-		  $ECHO "*** using a file magic. Last file checked: $potlib"
-		fi
-	      fi
-	      ;;
-	    *)
-	      # Add a -L argument.
-	      newdeplibs="$newdeplibs $a_deplib"
-	      ;;
-	    esac
-	  done # Gone through all deplibs.
-	  ;;
-	match_pattern*)
-	  set dummy $deplibs_check_method; shift
-	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
-	  for a_deplib in $deplibs; do
-	    case $a_deplib in
-	    -l*)
-	      func_stripname -l '' "$a_deplib"
-	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		case " $predeps $postdeps " in
-		*" $a_deplib "*)
-		  newdeplibs="$newdeplibs $a_deplib"
-		  a_deplib=""
-		  ;;
-		esac
-	      fi
-	      if test -n "$a_deplib" ; then
-		libname=`eval "\\$ECHO \"$libname_spec\""`
-		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
-		  for potent_lib in $potential_libs; do
-		    potlib="$potent_lib" # see symlink-check above in file_magic test
-		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
-		       $EGREP "$match_pattern_regex" > /dev/null; then
-		      newdeplibs="$newdeplibs $a_deplib"
-		      a_deplib=""
-		      break 2
-		    fi
-		  done
-		done
-	      fi
-	      if test -n "$a_deplib" ; then
-		droppeddeps=yes
-		echo
-		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
-		echo "*** I have the capability to make that library automatically link in when"
-		echo "*** you link to this library.  But I can only do this if you have a"
-		echo "*** shared version of the library, which you do not appear to have"
-		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
-		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
-		else
-		  $ECHO "*** with $libname and none of the candidates passed a file format test"
-		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
-		fi
-	      fi
-	      ;;
-	    *)
-	      # Add a -L argument.
-	      newdeplibs="$newdeplibs $a_deplib"
-	      ;;
-	    esac
-	  done # Gone through all deplibs.
-	  ;;
-	none | unknown | *)
-	  newdeplibs=""
-	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
-	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	    for i in $predeps $postdeps ; do
-	      # can't use Xsed below, because $i might contain '/'
-	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
-	    done
-	  fi
-	  case $tmp_deplibs in
-	  *[!\	\ ]*)
-	    echo
-	    if test "X$deplibs_check_method" = "Xnone"; then
-	      echo "*** Warning: inter-library dependencies are not supported in this platform."
-	    else
-	      echo "*** Warning: inter-library dependencies are not known to be supported."
-	    fi
-	    echo "*** All declared inter-library dependencies are being dropped."
-	    droppeddeps=yes
-	    ;;
-	  esac
-	  ;;
-	esac
-	versuffix=$versuffix_save
-	major=$major_save
-	release=$release_save
-	libname=$libname_save
-	name=$name_save
-
-	case $host in
-	*-*-rhapsody* | *-*-darwin1.[012])
-	  # On Rhapsody replace the C library with the System framework
-	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
-	  ;;
-	esac
-
-	if test "$droppeddeps" = yes; then
-	  if test "$module" = yes; then
-	    echo
-	    echo "*** Warning: libtool could not satisfy all declared inter-library"
-	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
-	    echo "*** a static module, that should work as long as the dlopening"
-	    echo "*** application is linked with the -dlopen flag."
-	    if test -z "$global_symbol_pipe"; then
-	      echo
-	      echo "*** However, this would only work if libtool was able to extract symbol"
-	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
-	      echo "*** not find such a program.  So, this module is probably useless."
-	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
-	    fi
-	    if test "$build_old_libs" = no; then
-	      oldlibs="$output_objdir/$libname.$libext"
-	      build_libtool_libs=module
-	      build_old_libs=yes
-	    else
-	      build_libtool_libs=no
-	    fi
-	  else
-	    echo "*** The inter-library dependencies that have been dropped here will be"
-	    echo "*** automatically added whenever a program is linked with this library"
-	    echo "*** or is declared to -dlopen it."
-
-	    if test "$allow_undefined" = no; then
-	      echo
-	      echo "*** Since this library must not contain undefined symbols,"
-	      echo "*** because either the platform does not support them or"
-	      echo "*** it was explicitly requested with -no-undefined,"
-	      echo "*** libtool will only create a static version of it."
-	      if test "$build_old_libs" = no; then
-		oldlibs="$output_objdir/$libname.$libext"
-		build_libtool_libs=module
-		build_old_libs=yes
-	      else
-		build_libtool_libs=no
-	      fi
-	    fi
-	  fi
-	fi
-	# Done checking deplibs!
-	deplibs=$newdeplibs
-      fi
-      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
-      case $host in
-	*-*-darwin*)
-	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	  ;;
-      esac
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-	case " $new_libs " in
-	*" -L$path/$objdir "*) ;;
-	*)
-	  case " $deplibs " in
-	  *" -L$path/$objdir "*)
-	    new_libs="$new_libs -L$path/$objdir" ;;
-	  esac
-	  ;;
-	esac
-      done
-      for deplib in $deplibs; do
-	case $deplib in
-	-L*)
-	  case " $new_libs " in
-	  *" $deplib "*) ;;
-	  *) new_libs="$new_libs $deplib" ;;
-	  esac
-	  ;;
-	*) new_libs="$new_libs $deplib" ;;
-	esac
-      done
-      deplibs="$new_libs"
-
-      # All the library-specific variables (install_libdir is set above).
-      library_names=
-      old_library=
-      dlname=
-
-      # Test again, we may have decided not to build it any more
-      if test "$build_libtool_libs" = yes; then
-	if test "$hardcode_into_libs" = yes; then
-	  # Hardcode the library paths
-	  hardcode_libdirs=
-	  dep_rpath=
-	  rpath="$finalize_rpath"
-	  test "$mode" != relink && rpath="$compile_rpath$rpath"
-	  for libdir in $rpath; do
-	    if test -n "$hardcode_libdir_flag_spec"; then
-	      if test -n "$hardcode_libdir_separator"; then
-		if test -z "$hardcode_libdirs"; then
-		  hardcode_libdirs="$libdir"
-		else
-		  # Just accumulate the unique libdirs.
-		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
-		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
-		    ;;
-		  *)
-		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
-		    ;;
-		  esac
-		fi
-	      else
-		eval flag=\"$hardcode_libdir_flag_spec\"
-		dep_rpath="$dep_rpath $flag"
-	      fi
-	    elif test -n "$runpath_var"; then
-	      case "$perm_rpath " in
-	      *" $libdir "*) ;;
-	      *) perm_rpath="$perm_rpath $libdir" ;;
-	      esac
-	    fi
-	  done
-	  # Substitute the hardcoded libdirs into the rpath.
-	  if test -n "$hardcode_libdir_separator" &&
-	     test -n "$hardcode_libdirs"; then
-	    libdir="$hardcode_libdirs"
-	    if test -n "$hardcode_libdir_flag_spec_ld"; then
-	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
-	    else
-	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
-	    fi
-	  fi
-	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
-	    # We should set the runpath_var.
-	    rpath=
-	    for dir in $perm_rpath; do
-	      rpath="$rpath$dir:"
-	    done
-	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
-	  fi
-	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
-	fi
-
-	shlibpath="$finalize_shlibpath"
-	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
-	if test -n "$shlibpath"; then
-	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
-	fi
-
-	# Get the real and link names of the library.
-	eval shared_ext=\"$shrext_cmds\"
-	eval library_names=\"$library_names_spec\"
-	set dummy $library_names
-	shift
-	realname="$1"
-	shift
-
-	if test -n "$soname_spec"; then
-	  eval soname=\"$soname_spec\"
-	else
-	  soname="$realname"
-	fi
-	if test -z "$dlname"; then
-	  dlname=$soname
-	fi
-
-	lib="$output_objdir/$realname"
-	linknames=
-	for link
-	do
-	  linknames="$linknames $link"
-	done
-
-	# Use standard objects if they are pic
-	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
-	test "X$libobjs" = "X " && libobjs=
-
-	delfiles=
-	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
-	  export_symbols="$output_objdir/$libname.uexp"
-	  delfiles="$delfiles $export_symbols"
-	fi
-
-	orig_export_symbols=
-	case $host_os in
-	cygwin* | mingw* | cegcc*)
-	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
-	    # exporting using user supplied symfile
-	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
-	      # and it's NOT already a .def file. Must figure out
-	      # which of the given symbols are data symbols and tag
-	      # them as such. So, trigger use of export_symbols_cmds.
-	      # export_symbols gets reassigned inside the "prepare
-	      # the list of exported symbols" if statement, so the
-	      # include_expsyms logic still works.
-	      orig_export_symbols="$export_symbols"
-	      export_symbols=
-	      always_export_symbols=yes
-	    fi
-	  fi
-	  ;;
-	esac
-
-	# Prepare the list of exported symbols
-	if test -z "$export_symbols"; then
-	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
-	    func_verbose "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
-	    $opt_dry_run || $RM $export_symbols
-	    cmds=$export_symbols_cmds
-	    save_ifs="$IFS"; IFS='~'
-	    for cmd in $cmds; do
-	      IFS="$save_ifs"
-	      eval cmd=\"$cmd\"
-	      func_len " $cmd"
-	      len=$func_len_result
-	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
-		func_show_eval "$cmd" 'exit $?'
-		skipped_export=false
-	      else
-		# The command line is too long to execute in one step.
-		func_verbose "using reloadable object file for export list..."
-		skipped_export=:
-		# Break out early, otherwise skipped_export may be
-		# set to false by a later but shorter cmd.
-		break
-	      fi
-	    done
-	    IFS="$save_ifs"
-	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
-	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
-	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
-	    fi
-	  fi
-	fi
-
-	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  tmp_export_symbols="$export_symbols"
-	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
-	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
-	fi
-
-	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
-	  # The given exports_symbols file has to be filtered, so filter it.
-	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
-	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	  # 's' commands which not all seds can handle. GNU sed should be fine
-	  # though. Also, the filter scales superlinearly with the number of
-	  # global variables. join(1) would be nice here, but unfortunately
-	  # isn't a blessed tool.
-	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
-	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
-	  export_symbols=$output_objdir/$libname.def
-	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
-	fi
-
-	tmp_deplibs=
-	for test_deplib in $deplibs; do
-	  case " $convenience " in
-	  *" $test_deplib "*) ;;
-	  *)
-	    tmp_deplibs="$tmp_deplibs $test_deplib"
-	    ;;
-	  esac
-	done
-	deplibs="$tmp_deplibs"
-
-	if test -n "$convenience"; then
-	  if test -n "$whole_archive_flag_spec" &&
-	    test "$compiler_needs_object" = yes &&
-	    test -z "$libobjs"; then
-	    # extract the archives, so we have objects to list.
-	    # TODO: could optimize this to just extract one archive.
-	    whole_archive_flag_spec=
-	  fi
-	  if test -n "$whole_archive_flag_spec"; then
-	    save_libobjs=$libobjs
-	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
-	    test "X$libobjs" = "X " && libobjs=
-	  else
-	    gentop="$output_objdir/${outputname}x"
-	    generated="$generated $gentop"
-
-	    func_extract_archives $gentop $convenience
-	    libobjs="$libobjs $func_extract_archives_result"
-	    test "X$libobjs" = "X " && libobjs=
-	  fi
-	fi
-
-	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
-	  eval flag=\"$thread_safe_flag_spec\"
-	  linker_flags="$linker_flags $flag"
-	fi
-
-	# Make a backup of the uninstalled library when relinking
-	if test "$mode" = relink; then
-	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
-	fi
-
-	# Do each of the archive commands.
-	if test "$module" = yes && test -n "$module_cmds" ; then
-	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
-	    eval test_cmds=\"$module_expsym_cmds\"
-	    cmds=$module_expsym_cmds
-	  else
-	    eval test_cmds=\"$module_cmds\"
-	    cmds=$module_cmds
-	  fi
-	else
-	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-	    eval test_cmds=\"$archive_expsym_cmds\"
-	    cmds=$archive_expsym_cmds
-	  else
-	    eval test_cmds=\"$archive_cmds\"
-	    cmds=$archive_cmds
-	  fi
-	fi
-
-	if test "X$skipped_export" != "X:" &&
-	   func_len " $test_cmds" &&
-	   len=$func_len_result &&
-	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
-	  :
-	else
-	  # The command line is too long to link in one step, link piecewise
-	  # or, if using GNU ld and skipped_export is not :, use a linker
-	  # script.
-
-	  # Save the value of $output and $libobjs because we want to
-	  # use them later.  If we have whole_archive_flag_spec, we
-	  # want to use save_libobjs as it was before
-	  # whole_archive_flag_spec was expanded, because we can't
-	  # assume the linker understands whole_archive_flag_spec.
-	  # This may have to be revisited, in case too many
-	  # convenience libraries get linked in and end up exceeding
-	  # the spec.
-	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
-	    save_libobjs=$libobjs
-	  fi
-	  save_output=$output
-	  func_basename "$output"
-	  output_la=$func_basename_result
-
-	  # Clear the reloadable object creation command queue and
-	  # initialize k to one.
-	  test_cmds=
-	  concat_cmds=
-	  objlist=
-	  last_robj=
-	  k=1
-
-	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
-	    output=${output_objdir}/${output_la}.lnkscript
-	    func_verbose "creating GNU ld script: $output"
-	    echo 'INPUT (' > $output
-	    for obj in $save_libobjs
-	    do
-	      $ECHO "$obj" >> $output
-	    done
-	    echo ')' >> $output
-	    delfiles="$delfiles $output"
-	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
-	    output=${output_objdir}/${output_la}.lnk
-	    func_verbose "creating linker input file list: $output"
-	    : > $output
-	    set x $save_libobjs
-	    shift
-	    firstobj=
-	    if test "$compiler_needs_object" = yes; then
-	      firstobj="$1 "
-	      shift
-	    fi
-	    for obj
-	    do
-	      $ECHO "$obj" >> $output
-	    done
-	    delfiles="$delfiles $output"
-	    output=$firstobj\"$file_list_spec$output\"
-	  else
-	    if test -n "$save_libobjs"; then
-	      func_verbose "creating reloadable object files..."
-	      output=$output_objdir/$output_la-${k}.$objext
-	      eval test_cmds=\"$reload_cmds\"
-	      func_len " $test_cmds"
-	      len0=$func_len_result
-	      len=$len0
-
-	      # Loop over the list of objects to be linked.
-	      for obj in $save_libobjs
-	      do
-		func_len " $obj"
-		func_arith $len + $func_len_result
-		len=$func_arith_result
-		if test "X$objlist" = X ||
-		   test "$len" -lt "$max_cmd_len"; then
-		  func_append objlist " $obj"
-		else
-		  # The command $test_cmds is almost too long, add a
-		  # command to the queue.
-		  if test "$k" -eq 1 ; then
-		    # The first file doesn't have a previous command to add.
-		    reload_objs=$objlist
-		    eval concat_cmds=\"$reload_cmds\"
-		  else
-		    # All subsequent reloadable object files will link in
-		    # the last one created.
-		    reload_objs="$objlist $last_robj"
-		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
-		  fi
-		  last_robj=$output_objdir/$output_la-${k}.$objext
-		  func_arith $k + 1
-		  k=$func_arith_result
-		  output=$output_objdir/$output_la-${k}.$objext
-		  objlist=" $obj"
-		  func_len " $last_robj"
-		  func_arith $len0 + $func_len_result
-		  len=$func_arith_result
-		fi
-	      done
-	      # Handle the remaining objects by creating one last
-	      # reloadable object file.  All subsequent reloadable object
-	      # files will link in the last one created.
-	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      reload_objs="$objlist $last_robj"
-	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
-	      if test -n "$last_robj"; then
-	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
-	      fi
-	      delfiles="$delfiles $output"
-
-	    else
-	      output=
-	    fi
-
-	    if ${skipped_export-false}; then
-	      func_verbose "generating symbol list for \`$libname.la'"
-	      export_symbols="$output_objdir/$libname.exp"
-	      $opt_dry_run || $RM $export_symbols
-	      libobjs=$output
-	      # Append the command to create the export file.
-	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
-	      if test -n "$last_robj"; then
-		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
-	      fi
-	    fi
-
-	    test -n "$save_libobjs" &&
-	      func_verbose "creating a temporary reloadable object file: $output"
-
-	    # Loop through the commands generated above and execute them.
-	    save_ifs="$IFS"; IFS='~'
-	    for cmd in $concat_cmds; do
-	      IFS="$save_ifs"
-	      $opt_silent || {
-		  func_quote_for_expand "$cmd"
-		  eval "func_echo $func_quote_for_expand_result"
-	      }
-	      $opt_dry_run || eval "$cmd" || {
-		lt_exit=$?
-
-		# Restore the uninstalled library and exit
-		if test "$mode" = relink; then
-		  ( cd "$output_objdir" && \
-		    $RM "${realname}T" && \
-		    $MV "${realname}U" "$realname" )
-		fi
-
-		exit $lt_exit
-	      }
-	    done
-	    IFS="$save_ifs"
-
-	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
-	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
-	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
-	    fi
-	  fi
-
-          if ${skipped_export-false}; then
-	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	      tmp_export_symbols="$export_symbols"
-	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
-	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
-	    fi
-
-	    if test -n "$orig_export_symbols"; then
-	      # The given exports_symbols file has to be filtered, so filter it.
-	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
-	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	      # 's' commands which not all seds can handle. GNU sed should be fine
-	      # though. Also, the filter scales superlinearly with the number of
-	      # global variables. join(1) would be nice here, but unfortunately
-	      # isn't a blessed tool.
-	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
-	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
-	      export_symbols=$output_objdir/$libname.def
-	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
-	    fi
-	  fi
-
-	  libobjs=$output
-	  # Restore the value of output.
-	  output=$save_output
-
-	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
-	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
-	    test "X$libobjs" = "X " && libobjs=
-	  fi
-	  # Expand the library linking commands again to reset the
-	  # value of $libobjs for piecewise linking.
-
-	  # Do each of the archive commands.
-	  if test "$module" = yes && test -n "$module_cmds" ; then
-	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
-	      cmds=$module_expsym_cmds
-	    else
-	      cmds=$module_cmds
-	    fi
-	  else
-	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-	      cmds=$archive_expsym_cmds
-	    else
-	      cmds=$archive_cmds
-	    fi
-	  fi
-	fi
-
-	if test -n "$delfiles"; then
-	  # Append the command to remove temporary files to $cmds.
-	  eval cmds=\"\$cmds~\$RM $delfiles\"
-	fi
-
-	# Add any objects from preloaded convenience libraries
-	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
-	  generated="$generated $gentop"
-
-	  func_extract_archives $gentop $dlprefiles
-	  libobjs="$libobjs $func_extract_archives_result"
-	  test "X$libobjs" = "X " && libobjs=
-	fi
-
-	save_ifs="$IFS"; IFS='~'
-	for cmd in $cmds; do
-	  IFS="$save_ifs"
-	  eval cmd=\"$cmd\"
-	  $opt_silent || {
-	    func_quote_for_expand "$cmd"
-	    eval "func_echo $func_quote_for_expand_result"
-	  }
-	  $opt_dry_run || eval "$cmd" || {
-	    lt_exit=$?
-
-	    # Restore the uninstalled library and exit
-	    if test "$mode" = relink; then
-	      ( cd "$output_objdir" && \
-	        $RM "${realname}T" && \
-		$MV "${realname}U" "$realname" )
-	    fi
-
-	    exit $lt_exit
-	  }
-	done
-	IFS="$save_ifs"
-
-	# Restore the uninstalled library and exit
-	if test "$mode" = relink; then
-	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
-
-	  if test -n "$convenience"; then
-	    if test -z "$whole_archive_flag_spec"; then
-	      func_show_eval '${RM}r "$gentop"'
-	    fi
-	  fi
-
-	  exit $EXIT_SUCCESS
-	fi
-
-	# Create links to the real library.
-	for linkname in $linknames; do
-	  if test "$realname" != "$linkname"; then
-	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
-	  fi
-	done
-
-	# If -module or -export-dynamic was specified, set the dlname.
-	if test "$module" = yes || test "$export_dynamic" = yes; then
-	  # On all known operating systems, these are identical.
-	  dlname="$soname"
-	fi
-      fi
-      ;;
-
-    obj)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for objects"
-      fi
-
-      case " $deplibs" in
-      *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for objects" ;;
-      esac
-
-      test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for objects"
-
-      test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for objects"
-
-      test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for objects"
-
-      test -n "$release" && \
-	func_warning "\`-release' is ignored for objects"
-
-      case $output in
-      *.lo)
-	test -n "$objs$old_deplibs" && \
-	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
-
-	libobj=$output
-	func_lo2o "$libobj"
-	obj=$func_lo2o_result
-	;;
-      *)
-	libobj=
-	obj="$output"
-	;;
-      esac
-
-      # Delete the old objects.
-      $opt_dry_run || $RM $obj $libobj
-
-      # Objects from convenience libraries.  This assumes
-      # single-version convenience libraries.  Whenever we create
-      # different ones for PIC/non-PIC, this we'll have to duplicate
-      # the extraction.
-      reload_conv_objs=
-      gentop=
-      # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec and hope we can get by with
-      # turning comma into space..
-      wl=
-
-      if test -n "$convenience"; then
-	if test -n "$whole_archive_flag_spec"; then
-	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
-	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
-	else
-	  gentop="$output_objdir/${obj}x"
-	  generated="$generated $gentop"
-
-	  func_extract_archives $gentop $convenience
-	  reload_conv_objs="$reload_objs $func_extract_archives_result"
-	fi
-      fi
-
-      # Create the old-style object.
-      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
-
-      output="$obj"
-      func_execute_cmds "$reload_cmds" 'exit $?'
-
-      # Exit if we aren't doing a library object file.
-      if test -z "$libobj"; then
-	if test -n "$gentop"; then
-	  func_show_eval '${RM}r "$gentop"'
-	fi
-
-	exit $EXIT_SUCCESS
-      fi
-
-      if test "$build_libtool_libs" != yes; then
-	if test -n "$gentop"; then
-	  func_show_eval '${RM}r "$gentop"'
-	fi
-
-	# Create an invalid libtool object if no PIC, so that we don't
-	# accidentally link it into a program.
-	# $show "echo timestamp > $libobj"
-	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
-	exit $EXIT_SUCCESS
-      fi
-
-      if test -n "$pic_flag" || test "$pic_mode" != default; then
-	# Only do commands if we really have different PIC objects.
-	reload_objs="$libobjs $reload_conv_objs"
-	output="$libobj"
-	func_execute_cmds "$reload_cmds" 'exit $?'
-      fi
-
-      if test -n "$gentop"; then
-	func_show_eval '${RM}r "$gentop"'
-      fi
-
-      exit $EXIT_SUCCESS
-      ;;
-
-    prog)
-      case $host in
-	*cygwin*) func_stripname '' '.exe' "$output"
-	          output=$func_stripname_result.exe;;
-      esac
-      test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for programs"
-
-      test -n "$release" && \
-	func_warning "\`-release' is ignored for programs"
-
-      test "$preload" = yes \
-        && test "$dlopen_support" = unknown \
-	&& test "$dlopen_self" = unknown \
-	&& test "$dlopen_self_static" = unknown && \
-	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
-
-      case $host in
-      *-*-rhapsody* | *-*-darwin1.[012])
-	# On Rhapsody replace the C library is the System framework
-	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
-	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
-	;;
-      esac
-
-      case $host in
-      *-*-darwin*)
-	# Don't allow lazy linking, it breaks C++ global constructors
-	# But is supposedly fixed on 10.4 or later (yay!).
-	if test "$tagname" = CXX ; then
-	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
-	    10.[0123])
-	      compile_command="$compile_command ${wl}-bind_at_load"
-	      finalize_command="$finalize_command ${wl}-bind_at_load"
-	    ;;
-	  esac
-	fi
-	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
-	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	;;
-      esac
-
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-	case " $new_libs " in
-	*" -L$path/$objdir "*) ;;
-	*)
-	  case " $compile_deplibs " in
-	  *" -L$path/$objdir "*)
-	    new_libs="$new_libs -L$path/$objdir" ;;
-	  esac
-	  ;;
-	esac
-      done
-      for deplib in $compile_deplibs; do
-	case $deplib in
-	-L*)
-	  case " $new_libs " in
-	  *" $deplib "*) ;;
-	  *) new_libs="$new_libs $deplib" ;;
-	  esac
-	  ;;
-	*) new_libs="$new_libs $deplib" ;;
-	esac
-      done
-      compile_deplibs="$new_libs"
-
-
-      compile_command="$compile_command $compile_deplibs"
-      finalize_command="$finalize_command $finalize_deplibs"
-
-      if test -n "$rpath$xrpath"; then
-	# If the user specified any rpath flags, then add them.
-	for libdir in $rpath $xrpath; do
-	  # This is the magic to use -rpath.
-	  case "$finalize_rpath " in
-	  *" $libdir "*) ;;
-	  *) finalize_rpath="$finalize_rpath $libdir" ;;
-	  esac
-	done
-      fi
-
-      # Now hardcode the library paths
-      rpath=
-      hardcode_libdirs=
-      for libdir in $compile_rpath $finalize_rpath; do
-	if test -n "$hardcode_libdir_flag_spec"; then
-	  if test -n "$hardcode_libdir_separator"; then
-	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
-	    else
-	      # Just accumulate the unique libdirs.
-	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
-	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
-		;;
-	      *)
-		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
-		;;
-	      esac
-	    fi
-	  else
-	    eval flag=\"$hardcode_libdir_flag_spec\"
-	    rpath="$rpath $flag"
-	  fi
-	elif test -n "$runpath_var"; then
-	  case "$perm_rpath " in
-	  *" $libdir "*) ;;
-	  *) perm_rpath="$perm_rpath $libdir" ;;
-	  esac
-	fi
-	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
-	  case :$dllsearchpath: in
-	  *":$libdir:"*) ;;
-	  ::) dllsearchpath=$libdir;;
-	  *) dllsearchpath="$dllsearchpath:$libdir";;
-	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  ::) dllsearchpath=$testbindir;;
-	  *) dllsearchpath="$dllsearchpath:$testbindir";;
-	  esac
-	  ;;
-	esac
-      done
-      # Substitute the hardcoded libdirs into the rpath.
-      if test -n "$hardcode_libdir_separator" &&
-	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
-	eval rpath=\" $hardcode_libdir_flag_spec\"
-      fi
-      compile_rpath="$rpath"
-
-      rpath=
-      hardcode_libdirs=
-      for libdir in $finalize_rpath; do
-	if test -n "$hardcode_libdir_flag_spec"; then
-	  if test -n "$hardcode_libdir_separator"; then
-	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
-	    else
-	      # Just accumulate the unique libdirs.
-	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
-	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
-		;;
-	      *)
-		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
-		;;
-	      esac
-	    fi
-	  else
-	    eval flag=\"$hardcode_libdir_flag_spec\"
-	    rpath="$rpath $flag"
-	  fi
-	elif test -n "$runpath_var"; then
-	  case "$finalize_perm_rpath " in
-	  *" $libdir "*) ;;
-	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
-	  esac
-	fi
-      done
-      # Substitute the hardcoded libdirs into the rpath.
-      if test -n "$hardcode_libdir_separator" &&
-	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
-	eval rpath=\" $hardcode_libdir_flag_spec\"
-      fi
-      finalize_rpath="$rpath"
-
-      if test -n "$libobjs" && test "$build_old_libs" = yes; then
-	# Transform all the library objects into standard objects.
-	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
-	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
-      fi
-
-      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
-
-      # template prelinking step
-      if test -n "$prelink_cmds"; then
-	func_execute_cmds "$prelink_cmds" 'exit $?'
-      fi
-
-      wrappers_required=yes
-      case $host in
-      *cegcc* | *mingw32ce*)
-        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
-        wrappers_required=no
-        ;;
-      *cygwin* | *mingw* )
-        if test "$build_libtool_libs" != yes; then
-          wrappers_required=no
-        fi
-        ;;
-      *)
-        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
-          wrappers_required=no
-        fi
-        ;;
-      esac
-      if test "$wrappers_required" = no; then
-	# Replace the output file specification.
-	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
-	link_command="$compile_command$compile_rpath"
-
-	# We have no uninstalled library dependencies, so finalize right now.
-	exit_status=0
-	func_show_eval "$link_command" 'exit_status=$?'
-
-	# Delete the generated files.
-	if test -f "$output_objdir/${outputname}S.${objext}"; then
-	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
-	fi
-
-	exit $exit_status
-      fi
-
-      if test -n "$compile_shlibpath$finalize_shlibpath"; then
-	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
-      fi
-      if test -n "$finalize_shlibpath"; then
-	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
-      fi
-
-      compile_var=
-      finalize_var=
-      if test -n "$runpath_var"; then
-	if test -n "$perm_rpath"; then
-	  # We should set the runpath_var.
-	  rpath=
-	  for dir in $perm_rpath; do
-	    rpath="$rpath$dir:"
-	  done
-	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
-	fi
-	if test -n "$finalize_perm_rpath"; then
-	  # We should set the runpath_var.
-	  rpath=
-	  for dir in $finalize_perm_rpath; do
-	    rpath="$rpath$dir:"
-	  done
-	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
-	fi
-      fi
-
-      if test "$no_install" = yes; then
-	# We don't need to create a wrapper script.
-	link_command="$compile_var$compile_command$compile_rpath"
-	# Replace the output file specification.
-	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
-	# Delete the old output file.
-	$opt_dry_run || $RM $output
-	# Link the executable and exit
-	func_show_eval "$link_command" 'exit $?'
-	exit $EXIT_SUCCESS
-      fi
-
-      if test "$hardcode_action" = relink; then
-	# Fast installation is not supported
-	link_command="$compile_var$compile_command$compile_rpath"
-	relink_command="$finalize_var$finalize_command$finalize_rpath"
-
-	func_warning "this platform does not like uninstalled shared libraries"
-	func_warning "\`$output' will be relinked during installation"
-      else
-	if test "$fast_install" != no; then
-	  link_command="$finalize_var$compile_command$finalize_rpath"
-	  if test "$fast_install" = yes; then
-	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
-	  else
-	    # fast_install is set to needless
-	    relink_command=
-	  fi
-	else
-	  link_command="$compile_var$compile_command$compile_rpath"
-	  relink_command="$finalize_var$finalize_command$finalize_rpath"
-	fi
-      fi
-
-      # Replace the output file specification.
-      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
-
-      # Delete the old output files.
-      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
-
-      func_show_eval "$link_command" 'exit $?'
-
-      # Now create the wrapper script.
-      func_verbose "creating $output"
-
-      # Quote the relink command for shipping.
-      if test -n "$relink_command"; then
-	# Preserve any variables that may affect compiler behavior
-	for var in $variables_saved_for_relink; do
-	  if eval test -z \"\${$var+set}\"; then
-	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
-	  elif eval var_value=\$$var; test -z "$var_value"; then
-	    relink_command="$var=; export $var; $relink_command"
-	  else
-	    func_quote_for_eval "$var_value"
-	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
-	  fi
-	done
-	relink_command="(cd `pwd`; $relink_command)"
-	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
-      fi
-
-      # Only actually do things if not in dry run mode.
-      $opt_dry_run || {
-	# win32 will think the script is a binary if it has
-	# a .exe suffix, so we strip it off here.
-	case $output in
-	  *.exe) func_stripname '' '.exe' "$output"
-	         output=$func_stripname_result ;;
-	esac
-	# test for cygwin because mv fails w/o .exe extensions
-	case $host in
-	  *cygwin*)
-	    exeext=.exe
-	    func_stripname '' '.exe' "$outputname"
-	    outputname=$func_stripname_result ;;
-	  *) exeext= ;;
-	esac
-	case $host in
-	  *cygwin* | *mingw* )
-	    func_dirname_and_basename "$output" "" "."
-	    output_name=$func_basename_result
-	    output_path=$func_dirname_result
-	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
-	    cwrapper="$output_path/$output_name.exe"
-	    $RM $cwrappersource $cwrapper
-	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
-
-	    func_emit_cwrapperexe_src > $cwrappersource
-
-	    # The wrapper executable is built using the $host compiler,
-	    # because it contains $host paths and files. If cross-
-	    # compiling, it, like the target executable, must be
-	    # executed on the $host or under an emulation environment.
-	    $opt_dry_run || {
-	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
-	      $STRIP $cwrapper
-	    }
-
-	    # Now, create the wrapper script for func_source use:
-	    func_ltwrapper_scriptname $cwrapper
-	    $RM $func_ltwrapper_scriptname_result
-	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
-	    $opt_dry_run || {
-	      # note: this script will not be executed, so do not chmod.
-	      if test "x$build" = "x$host" ; then
-		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
-	      else
-		func_emit_wrapper no > $func_ltwrapper_scriptname_result
-	      fi
-	    }
-	  ;;
-	  * )
-	    $RM $output
-	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
-
-	    func_emit_wrapper no > $output
-	    chmod +x $output
-	  ;;
-	esac
-      }
-      exit $EXIT_SUCCESS
-      ;;
-    esac
-
-    # See if we need to build an old-fashioned archive.
-    for oldlib in $oldlibs; do
-
-      if test "$build_libtool_libs" = convenience; then
-	oldobjs="$libobjs_save $symfileobj"
-	addlibs="$convenience"
-	build_libtool_libs=no
-      else
-	if test "$build_libtool_libs" = module; then
-	  oldobjs="$libobjs_save"
-	  build_libtool_libs=no
-	else
-	  oldobjs="$old_deplibs $non_pic_objects"
-	  if test "$preload" = yes && test -f "$symfileobj"; then
-	    oldobjs="$oldobjs $symfileobj"
-	  fi
-	fi
-	addlibs="$old_convenience"
-      fi
-
-      if test -n "$addlibs"; then
-	gentop="$output_objdir/${outputname}x"
-	generated="$generated $gentop"
-
-	func_extract_archives $gentop $addlibs
-	oldobjs="$oldobjs $func_extract_archives_result"
-      fi
-
-      # Do each command in the archive commands.
-      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
-	cmds=$old_archive_from_new_cmds
-      else
-
-	# Add any objects from preloaded convenience libraries
-	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
-	  generated="$generated $gentop"
-
-	  func_extract_archives $gentop $dlprefiles
-	  oldobjs="$oldobjs $func_extract_archives_result"
-	fi
-
-	# POSIX demands no paths to be encoded in archives.  We have
-	# to avoid creating archives with duplicate basenames if we
-	# might have to extract them afterwards, e.g., when creating a
-	# static archive out of a convenience library, or when linking
-	# the entirety of a libtool archive into another (currently
-	# not supported by libtool).
-	if (for obj in $oldobjs
-	    do
-	      func_basename "$obj"
-	      $ECHO "$func_basename_result"
-	    done | sort | sort -uc >/dev/null 2>&1); then
-	  :
-	else
-	  echo "copying selected object files to avoid basename conflicts..."
-	  gentop="$output_objdir/${outputname}x"
-	  generated="$generated $gentop"
-	  func_mkdir_p "$gentop"
-	  save_oldobjs=$oldobjs
-	  oldobjs=
-	  counter=1
-	  for obj in $save_oldobjs
-	  do
-	    func_basename "$obj"
-	    objbase="$func_basename_result"
-	    case " $oldobjs " in
-	    " ") oldobjs=$obj ;;
-	    *[\ /]"$objbase "*)
-	      while :; do
-		# Make sure we don't pick an alternate name that also
-		# overlaps.
-		newobj=lt$counter-$objbase
-		func_arith $counter + 1
-		counter=$func_arith_result
-		case " $oldobjs " in
-		*[\ /]"$newobj "*) ;;
-		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
-		esac
-	      done
-	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
-	      oldobjs="$oldobjs $gentop/$newobj"
-	      ;;
-	    *) oldobjs="$oldobjs $obj" ;;
-	    esac
-	  done
-	fi
-	eval cmds=\"$old_archive_cmds\"
-
-	func_len " $cmds"
-	len=$func_len_result
-	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
-	  cmds=$old_archive_cmds
-	else
-	  # the command line is too long to link in one step, link in parts
-	  func_verbose "using piecewise archive linking..."
-	  save_RANLIB=$RANLIB
-	  RANLIB=:
-	  objlist=
-	  concat_cmds=
-	  save_oldobjs=$oldobjs
-	  oldobjs=
-	  # Is there a better way of finding the last object in the list?
-	  for obj in $save_oldobjs
-	  do
-	    last_oldobj=$obj
-	  done
-	  eval test_cmds=\"$old_archive_cmds\"
-	  func_len " $test_cmds"
-	  len0=$func_len_result
-	  len=$len0
-	  for obj in $save_oldobjs
-	  do
-	    func_len " $obj"
-	    func_arith $len + $func_len_result
-	    len=$func_arith_result
-	    func_append objlist " $obj"
-	    if test "$len" -lt "$max_cmd_len"; then
-	      :
-	    else
-	      # the above command should be used before it gets too long
-	      oldobjs=$objlist
-	      if test "$obj" = "$last_oldobj" ; then
-		RANLIB=$save_RANLIB
-	      fi
-	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
-	      objlist=
-	      len=$len0
-	    fi
-	  done
-	  RANLIB=$save_RANLIB
-	  oldobjs=$objlist
-	  if test "X$oldobjs" = "X" ; then
-	    eval cmds=\"\$concat_cmds\"
-	  else
-	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
-	  fi
-	fi
-      fi
-      func_execute_cmds "$cmds" 'exit $?'
-    done
-
-    test -n "$generated" && \
-      func_show_eval "${RM}r$generated"
-
-    # Now create the libtool archive.
-    case $output in
-    *.la)
-      old_library=
-      test "$build_old_libs" = yes && old_library="$libname.$libext"
-      func_verbose "creating $output"
-
-      # Preserve any variables that may affect compiler behavior
-      for var in $variables_saved_for_relink; do
-	if eval test -z \"\${$var+set}\"; then
-	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
-	elif eval var_value=\$$var; test -z "$var_value"; then
-	  relink_command="$var=; export $var; $relink_command"
-	else
-	  func_quote_for_eval "$var_value"
-	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
-	fi
-      done
-      # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
-      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
-      if test "$hardcode_automatic" = yes ; then
-	relink_command=
-      fi
-
-      # Only create the output if not a dry run.
-      $opt_dry_run || {
-	for installed in no yes; do
-	  if test "$installed" = yes; then
-	    if test -z "$install_libdir"; then
-	      break
-	    fi
-	    output="$output_objdir/$outputname"i
-	    # Replace all uninstalled libtool libraries with the installed ones
-	    newdependency_libs=
-	    for deplib in $dependency_libs; do
-	      case $deplib in
-	      *.la)
-		func_basename "$deplib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
-		test -z "$libdir" && \
-		  func_fatal_error "\`$deplib' is not a valid libtool archive"
-		newdependency_libs="$newdependency_libs $libdir/$name"
-		;;
-	      *) newdependency_libs="$newdependency_libs $deplib" ;;
-	      esac
-	    done
-	    dependency_libs="$newdependency_libs"
-	    newdlfiles=
-
-	    for lib in $dlfiles; do
-	      case $lib in
-	      *.la)
-	        func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
-		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
-		newdlfiles="$newdlfiles $libdir/$name"
-		;;
-	      *) newdlfiles="$newdlfiles $lib" ;;
-	      esac
-	    done
-	    dlfiles="$newdlfiles"
-	    newdlprefiles=
-	    for lib in $dlprefiles; do
-	      case $lib in
-	      *.la)
-		# Only pass preopened files to the pseudo-archive (for
-		# eventual linking with the app. that links it) if we
-		# didn't already link the preopened objects directly into
-		# the library:
-		func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
-		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
-		newdlprefiles="$newdlprefiles $libdir/$name"
-		;;
-	      esac
-	    done
-	    dlprefiles="$newdlprefiles"
-	  else
-	    newdlfiles=
-	    for lib in $dlfiles; do
-	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
-		*) abs=`pwd`"/$lib" ;;
-	      esac
-	      newdlfiles="$newdlfiles $abs"
-	    done
-	    dlfiles="$newdlfiles"
-	    newdlprefiles=
-	    for lib in $dlprefiles; do
-	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
-		*) abs=`pwd`"/$lib" ;;
-	      esac
-	      newdlprefiles="$newdlprefiles $abs"
-	    done
-	    dlprefiles="$newdlprefiles"
-	  fi
-	  $RM $output
-	  # place dlname in correct position for cygwin
-	  # In fact, it would be nice if we could use this code for all target
-	  # systems that can't hard-code library paths into their executables
-	  # and that have no shared library path variable independent of PATH,
-	  # but it turns out we can't easily determine that from inspecting
-	  # libtool variables, so we have to hard-code the OSs to which it
-	  # applies here; at the moment, that means platforms that use the PE
-	  # object format with DLL files.  See the long comment at the top of
-	  # tests/bindir.at for full details.
-	  tdlname=$dlname
-	  case $host,$output,$installed,$module,$dlname in
-	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
-	      # If a -bindir argument was supplied, place the dll there.
-	      if test "x$bindir" != x ;
-	      then
-		func_relative_path "$install_libdir" "$bindir"
-		tdlname=$func_relative_path_result$dlname
-	      else
-		# Otherwise fall back on heuristic.
-		tdlname=../bin/$dlname
-	      fi
-	      ;;
-	  esac
-	  $ECHO > $output "\
-# $outputname - a libtool library file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# The name that we can dlopen(3).
-dlname='$tdlname'
-
-# Names of this library.
-library_names='$library_names'
-
-# The name of the static archive.
-old_library='$old_library'
-
-# Linker flags that can not go in dependency_libs.
-inherited_linker_flags='$new_inherited_linker_flags'
-
-# Libraries that this one depends upon.
-dependency_libs='$dependency_libs'
-
-# Names of additional weak libraries provided by this library
-weak_library_names='$weak_libs'
-
-# Version information for $libname.
-current=$current
-age=$age
-revision=$revision
-
-# Is this an already installed library?
-installed=$installed
-
-# Should we warn about portability when linking against -modules?
-shouldnotlink=$module
-
-# Files to dlopen/dlpreopen
-dlopen='$dlfiles'
-dlpreopen='$dlprefiles'
-
-# Directory that this library needs to be installed in:
-libdir='$install_libdir'"
-	  if test "$installed" = no && test "$need_relink" = yes; then
-	    $ECHO >> $output "\
-relink_command=\"$relink_command\""
-	  fi
-	done
-      }
-
-      # Do a symbolic link so that the libtool archive can be found in
-      # LD_LIBRARY_PATH before the program is installed.
-      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
-      ;;
-    esac
-    exit $EXIT_SUCCESS
-}
-
-{ test "$mode" = link || test "$mode" = relink; } &&
-    func_mode_link ${1+"$@"}
-
-
-# func_mode_uninstall arg...
-func_mode_uninstall ()
-{
-    $opt_debug
-    RM="$nonopt"
-    files=
-    rmforce=
-    exit_status=0
-
-    # This variable tells wrapper scripts just to set variables rather
-    # than running their programs.
-    libtool_install_magic="$magic"
-
-    for arg
-    do
-      case $arg in
-      -f) RM="$RM $arg"; rmforce=yes ;;
-      -*) RM="$RM $arg" ;;
-      *) files="$files $arg" ;;
-      esac
-    done
-
-    test -z "$RM" && \
-      func_fatal_help "you must specify an RM program"
-
-    rmdirs=
-
-    origobjdir="$objdir"
-    for file in $files; do
-      func_dirname "$file" "" "."
-      dir="$func_dirname_result"
-      if test "X$dir" = X.; then
-	objdir="$origobjdir"
-      else
-	objdir="$dir/$origobjdir"
-      fi
-      func_basename "$file"
-      name="$func_basename_result"
-      test "$mode" = uninstall && objdir="$dir"
-
-      # Remember objdir for removal later, being careful to avoid duplicates
-      if test "$mode" = clean; then
-	case " $rmdirs " in
-	  *" $objdir "*) ;;
-	  *) rmdirs="$rmdirs $objdir" ;;
-	esac
-      fi
-
-      # Don't error if the file doesn't exist and rm -f was used.
-      if { test -L "$file"; } >/dev/null 2>&1 ||
-	 { test -h "$file"; } >/dev/null 2>&1 ||
-	 test -f "$file"; then
-	:
-      elif test -d "$file"; then
-	exit_status=1
-	continue
-      elif test "$rmforce" = yes; then
-	continue
-      fi
-
-      rmfiles="$file"
-
-      case $name in
-      *.la)
-	# Possibly a libtool archive, so verify it.
-	if func_lalib_p "$file"; then
-	  func_source $dir/$name
-
-	  # Delete the libtool libraries and symlinks.
-	  for n in $library_names; do
-	    rmfiles="$rmfiles $objdir/$n"
-	  done
-	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
-
-	  case "$mode" in
-	  clean)
-	    case "  $library_names " in
-	    # "  " in the beginning catches empty $dlname
-	    *" $dlname "*) ;;
-	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
-	    esac
-	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
-	    ;;
-	  uninstall)
-	    if test -n "$library_names"; then
-	      # Do each command in the postuninstall commands.
-	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
-	    fi
-
-	    if test -n "$old_library"; then
-	      # Do each command in the old_postuninstall commands.
-	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
-	    fi
-	    # FIXME: should reinstall the best remaining shared library.
-	    ;;
-	  esac
-	fi
-	;;
-
-      *.lo)
-	# Possibly a libtool object, so verify it.
-	if func_lalib_p "$file"; then
-
-	  # Read the .lo file
-	  func_source $dir/$name
-
-	  # Add PIC object to the list of files to remove.
-	  if test -n "$pic_object" &&
-	     test "$pic_object" != none; then
-	    rmfiles="$rmfiles $dir/$pic_object"
-	  fi
-
-	  # Add non-PIC object to the list of files to remove.
-	  if test -n "$non_pic_object" &&
-	     test "$non_pic_object" != none; then
-	    rmfiles="$rmfiles $dir/$non_pic_object"
-	  fi
-	fi
-	;;
-
-      *)
-	if test "$mode" = clean ; then
-	  noexename=$name
-	  case $file in
-	  *.exe)
-	    func_stripname '' '.exe' "$file"
-	    file=$func_stripname_result
-	    func_stripname '' '.exe' "$name"
-	    noexename=$func_stripname_result
-	    # $file with .exe has already been added to rmfiles,
-	    # add $file without .exe
-	    rmfiles="$rmfiles $file"
-	    ;;
-	  esac
-	  # Do a test to see if this is a libtool program.
-	  if func_ltwrapper_p "$file"; then
-	    if func_ltwrapper_executable_p "$file"; then
-	      func_ltwrapper_scriptname "$file"
-	      relink_command=
-	      func_source $func_ltwrapper_scriptname_result
-	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
-	    else
-	      relink_command=
-	      func_source $dir/$noexename
-	    fi
-
-	    # note $name still contains .exe if it was in $file originally
-	    # as does the version of $file that was added into $rmfiles
-	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
-	    if test "$fast_install" = yes && test -n "$relink_command"; then
-	      rmfiles="$rmfiles $objdir/lt-$name"
-	    fi
-	    if test "X$noexename" != "X$name" ; then
-	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
-	    fi
-	  fi
-	fi
-	;;
-      esac
-      func_show_eval "$RM $rmfiles" 'exit_status=1'
-    done
-    objdir="$origobjdir"
-
-    # Try to remove the ${objdir}s in the directories where we deleted files
-    for dir in $rmdirs; do
-      if test -d "$dir"; then
-	func_show_eval "rmdir $dir >/dev/null 2>&1"
-      fi
-    done
-
-    exit $exit_status
-}
-
-{ test "$mode" = uninstall || test "$mode" = clean; } &&
-    func_mode_uninstall ${1+"$@"}
-
-test -z "$mode" && {
-  help="$generic_help"
-  func_fatal_help "you must specify a MODE"
-}
-
-test -z "$exec_cmd" && \
-  func_fatal_help "invalid operation mode \`$mode'"
-
-if test -n "$exec_cmd"; then
-  eval exec "$exec_cmd"
-  exit $EXIT_FAILURE
-fi
-
-exit $exit_status
-
-
-# The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries.  Given conflicting
-# choices, we go for a static library, that is the most portable,
-# since we can't tell whether shared libraries were disabled because
-# the user asked for that or because the platform doesn't support
-# them.  This is particularly important on AIX, because we don't
-# support having both static and shared libraries enabled at the same
-# time on that platform, so we default to a shared-only configuration.
-# If a disable-shared tag is given, we'll fallback to a static-only
-# configuration.  But we'll never go from static-only to shared-only.
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-build_libtool_libs=no
-build_old_libs=yes
-# ### END LIBTOOL TAG CONFIG: disable-shared
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-static
-build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
-# ### END LIBTOOL TAG CONFIG: disable-static
-
-# Local Variables:
-# mode:shell-script
-# sh-indentation:2
-# End:
-# vi:sw=2
-
diff --git a/Utilities/gdcmopenjpeg-v1/missing b/Utilities/gdcmopenjpeg-v1/missing
deleted file mode 100755
index 28055d2..0000000
--- a/Utilities/gdcmopenjpeg-v1/missing
+++ /dev/null
@@ -1,376 +0,0 @@
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-
-scriptversion=2009-04-28.21; # UTC
-
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
-# 2008, 2009 Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-if test $# -eq 0; then
-  echo 1>&2 "Try \`$0 --help' for more information"
-  exit 1
-fi
-
-run=:
-sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
-sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
-  configure_ac=configure.ac
-else
-  configure_ac=configure.in
-fi
-
-msg="missing on your system"
-
-case $1 in
---run)
-  # Try to run requested program, and just exit if it succeeds.
-  run=
-  shift
-  "$@" && exit 0
-  # Exit code 63 means version mismatch.  This often happens
-  # when the user try to use an ancient version of a tool on
-  # a file that requires a minimum version.  In this case we
-  # we should proceed has if the program had been absent, or
-  # if --run hadn't been passed.
-  if test $? = 63; then
-    run=:
-    msg="probably too old"
-  fi
-  ;;
-
-  -h|--h|--he|--hel|--help)
-    echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
-  -h, --help      display this help and exit
-  -v, --version   output version information and exit
-  --run           try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
-  aclocal      touch file \`aclocal.m4'
-  autoconf     touch file \`configure'
-  autoheader   touch file \`config.h.in'
-  autom4te     touch the output file, or create a stub one
-  automake     touch all \`Makefile.in' files
-  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
-  flex         create \`lex.yy.c', if possible, from existing .c
-  help2man     touch the output file
-  lex          create \`lex.yy.c', if possible, from existing .c
-  makeinfo     touch the output file
-  tar          try tar, gnutar, gtar, then tar without non-portable flags
-  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
-
-Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
-\`g' are ignored when checking the name.
-
-Send bug reports to <bug-automake at gnu.org>."
-    exit $?
-    ;;
-
-  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
-    echo "missing $scriptversion (GNU Automake)"
-    exit $?
-    ;;
-
-  -*)
-    echo 1>&2 "$0: Unknown \`$1' option"
-    echo 1>&2 "Try \`$0 --help' for more information"
-    exit 1
-    ;;
-
-esac
-
-# normalize program name to check for.
-program=`echo "$1" | sed '
-  s/^gnu-//; t
-  s/^gnu//; t
-  s/^g//; t'`
-
-# Now exit if we have it, but it failed.  Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program).  This is about non-GNU programs, so use $1 not
-# $program.
-case $1 in
-  lex*|yacc*)
-    # Not GNU programs, they don't have --version.
-    ;;
-
-  tar*)
-    if test -n "$run"; then
-       echo 1>&2 "ERROR: \`tar' requires --run"
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       exit 1
-    fi
-    ;;
-
-  *)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       # Could not run --version or --help.  This is probably someone
-       # running `$TOOL --version' or `$TOOL --help' to check whether
-       # $TOOL exists and not knowing $TOOL uses missing.
-       exit 1
-    fi
-    ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case $program in
-  aclocal*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
-         to install the \`Automake' and \`Perl' packages.  Grab them from
-         any GNU archive site."
-    touch aclocal.m4
-    ;;
-
-  autoconf*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`${configure_ac}'.  You might want to install the
-         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
-         archive site."
-    touch configure
-    ;;
-
-  autoheader*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
-         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
-         from any GNU archive site."
-    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
-    test -z "$files" && files="config.h"
-    touch_files=
-    for f in $files; do
-      case $f in
-      *:*) touch_files="$touch_files "`echo "$f" |
-				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
-      *) touch_files="$touch_files $f.in";;
-      esac
-    done
-    touch $touch_files
-    ;;
-
-  automake*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
-         You might want to install the \`Automake' and \`Perl' packages.
-         Grab them from any GNU archive site."
-    find . -type f -name Makefile.am -print |
-	   sed 's/\.am$/.in/' |
-	   while read f; do touch "$f"; done
-    ;;
-
-  autom4te*)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.
-         You can get \`$1' as part of \`Autoconf' from any GNU
-         archive site."
-
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -f "$file"; then
-	touch $file
-    else
-	test -z "$file" || exec >$file
-	echo "#! /bin/sh"
-	echo "# Created by GNU Automake missing as a replacement of"
-	echo "#  $ $@"
-	echo "exit 0"
-	chmod +x $file
-	exit 1
-    fi
-    ;;
-
-  bison*|yacc*)
-    echo 1>&2 "\
-WARNING: \`$1' $msg.  You should only need it if
-         you modified a \`.y' file.  You may need the \`Bison' package
-         in order for those modifications to take effect.  You can get
-         \`Bison' from any GNU archive site."
-    rm -f y.tab.c y.tab.h
-    if test $# -ne 1; then
-        eval LASTARG="\${$#}"
-	case $LASTARG in
-	*.y)
-	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
-	    if test -f "$SRCFILE"; then
-	         cp "$SRCFILE" y.tab.c
-	    fi
-	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
-	    if test -f "$SRCFILE"; then
-	         cp "$SRCFILE" y.tab.h
-	    fi
-	  ;;
-	esac
-    fi
-    if test ! -f y.tab.h; then
-	echo >y.tab.h
-    fi
-    if test ! -f y.tab.c; then
-	echo 'main() { return 0; }' >y.tab.c
-    fi
-    ;;
-
-  lex*|flex*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.l' file.  You may need the \`Flex' package
-         in order for those modifications to take effect.  You can get
-         \`Flex' from any GNU archive site."
-    rm -f lex.yy.c
-    if test $# -ne 1; then
-        eval LASTARG="\${$#}"
-	case $LASTARG in
-	*.l)
-	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
-	    if test -f "$SRCFILE"; then
-	         cp "$SRCFILE" lex.yy.c
-	    fi
-	  ;;
-	esac
-    fi
-    if test ! -f lex.yy.c; then
-	echo 'main() { return 0; }' >lex.yy.c
-    fi
-    ;;
-
-  help2man*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-	 you modified a dependency of a manual page.  You may need the
-	 \`Help2man' package in order for those modifications to take
-	 effect.  You can get \`Help2man' from any GNU archive site."
-
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -f "$file"; then
-	touch $file
-    else
-	test -z "$file" || exec >$file
-	echo ".ab help2man is required to generate this page"
-	exit $?
-    fi
-    ;;
-
-  makeinfo*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.texi' or \`.texinfo' file, or any other file
-         indirectly affecting the aspect of the manual.  The spurious
-         call might also be the consequence of using a buggy \`make' (AIX,
-         DU, IRIX).  You might want to install the \`Texinfo' package or
-         the \`GNU make' package.  Grab either from any GNU archive site."
-    # The file to touch is that specified with -o ...
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -z "$file"; then
-      # ... or it is the one specified with @setfilename ...
-      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
-      file=`sed -n '
-	/^@setfilename/{
-	  s/.* \([^ ]*\) *$/\1/
-	  p
-	  q
-	}' $infile`
-      # ... or it is derived from the source name (dir/f.texi becomes f.info)
-      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
-    fi
-    # If the file does not exist, the user really needs makeinfo;
-    # let's fail without touching anything.
-    test -f $file || exit 1
-    touch $file
-    ;;
-
-  tar*)
-    shift
-
-    # We have already tried tar in the generic part.
-    # Look for gnutar/gtar before invocation to avoid ugly error
-    # messages.
-    if (gnutar --version > /dev/null 2>&1); then
-       gnutar "$@" && exit 0
-    fi
-    if (gtar --version > /dev/null 2>&1); then
-       gtar "$@" && exit 0
-    fi
-    firstarg="$1"
-    if shift; then
-	case $firstarg in
-	*o*)
-	    firstarg=`echo "$firstarg" | sed s/o//`
-	    tar "$firstarg" "$@" && exit 0
-	    ;;
-	esac
-	case $firstarg in
-	*h*)
-	    firstarg=`echo "$firstarg" | sed s/h//`
-	    tar "$firstarg" "$@" && exit 0
-	    ;;
-	esac
-    fi
-
-    echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
-         You may want to install GNU tar or Free paxutils, or check the
-         command line arguments."
-    exit 1
-    ;;
-
-  *)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.  Check the \`README' file,
-         it often tells you about the needed prerequisites for installing
-         this package.  You may also peek at any GNU archive site, in case
-         some other package would contain this missing \`$1' program."
-    exit 1
-    ;;
-esac
-
-exit 0
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/CMakeLists.txt b/Utilities/gdcmopenjpeg-v1/mj2/CMakeLists.txt
deleted file mode 100644
index eb5cca3..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/CMakeLists.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-# Makefile for the MJ2 codecs of the OpenJPEG library: frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2 and wrap_j2k_in_mj2
-
-set(common_SRCS "")
-if(DONT_HAVE_GETOPT)
-  set(common_SRCS ${OPENJPEG_SOURCE_DIR}/common/getopt.c)
-endif()
-
-# While mj2 executables do not use the API correctly, we do not link with the library but rather compile the sources files.
-set(OPJ_SRCS
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/bio.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/cio.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/dwt.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/event.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/image.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/j2k.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/j2k_lib.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/jp2.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/jpt.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/mct.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/mqc.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/openjpeg.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/pi.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/raw.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/t1.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/t2.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/tcd.c
-${OPENJPEG_SOURCE_DIR}/libopenjpeg/tgt.c
-)
-
-set(MJ2_SRCS mj2.c mj2_convert.c)
-
-if(WIN32)
-  add_definitions(-DOPJ_STATIC)
-endif()
-
-# Headers file are located here:
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  ${OPENJPEG_SOURCE_DIR}/common
-  ${LCMS_INCLUDE_DIR}
-  )
-
-add_executable(frames_to_mj2
-  frames_to_mj2.c
-  ${common_SRCS}
-  ${OPJ_SRCS}
-  ${MJ2_SRCS}
-  )
-target_link_libraries(frames_to_mj2 ${LCMS_LIB})
-if(UNIX)
-  target_link_libraries(frames_to_mj2 m)
-endif()
-
-add_executable(mj2_to_frames
-    mj2_to_frames.c
-    ${common_SRCS}
-    ${OPJ_SRCS}
-    ${MJ2_SRCS}
-    ${OPENJPEG_SOURCE_DIR}/common/color.c
-    )
-target_link_libraries(mj2_to_frames ${LCMS_LIB})
-if(UNIX)
-  target_link_libraries(mj2_to_frames m)
-endif()
-
-add_executable(extract_j2k_from_mj2
-    extract_j2k_from_mj2.c
-    ${OPJ_SRCS}
-    ${MJ2_SRCS}
-    )
-target_link_libraries(extract_j2k_from_mj2 ${LCMS_LIB})
-if(UNIX)
-  target_link_libraries(extract_j2k_from_mj2 m)
-endif()
-
-add_executable(wrap_j2k_in_mj2
-    wrap_j2k_in_mj2.c
-    ${OPJ_SRCS}
-    ${MJ2_SRCS}
-    )
-target_link_libraries(wrap_j2k_in_mj2 ${LCMS_LIB})
-if(UNIX)
-  target_link_libraries(wrap_j2k_in_mj2 m)
-endif()
-
-install(TARGETS frames_to_mj2 mj2_to_frames extract_j2k_from_mj2 wrap_j2k_in_mj2
-	DESTINATION bin)
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsp b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsp
deleted file mode 100644
index b4870fd..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsp
+++ /dev/null
@@ -1,196 +0,0 @@
-# Microsoft Developer Studio Project File - Name="MJ2_Extractor" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=MJ2_Extractor - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "MJ2_Extractor.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "MJ2_Extractor.mak" CFG="MJ2_Extractor - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "MJ2_Extractor - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "MJ2_Extractor - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "MJ2_Extractor - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "MJ2_Extractor - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "MJ2_Extractor___Win32_Debug"
-# PROP BASE Intermediate_Dir "MJ2_Extractor___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "MJ2_Extractor___Win32_Debug"
-# PROP Intermediate_Dir "MJ2_Extractor___Win32_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MT /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF 
-
-# Begin Target
-
-# Name "MJ2_Extractor - Win32 Release"
-# Name "MJ2_Extractor - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\extract_j2k_from_mj2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\mj2.h
-# End Source File
-# End Group
-# Begin Group "OpenJPEG Header Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\libopenjpeg\bio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\cio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\dwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\event.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\fix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\image.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\int.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k_lib.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jp2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jpt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mct.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mqc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\openjpeg.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\opj_includes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\pi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\raw.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t1.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tcd.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tgt.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsw b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsw
deleted file mode 100644
index 1ee72c6..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "LibOpenJPEG"="..\LibOpenJPEG.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "MJ2_Extractor"=".\MJ2_Extractor.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.sln b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.sln
deleted file mode 100644
index 63a3b72..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.sln
+++ /dev/null
@@ -1,29 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MJ2_Extractor", "MJ2_Extractor.vcproj", "{BCBEB12A-B691-4B14-9DC5-193BCD01183D}"
-	ProjectSection(ProjectDependencies) = postProject
-		{4F27AA53-4181-4A1A-8238-3931B0A41048} = {4F27AA53-4181-4A1A-8238-3931B0A41048}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOpenJPEG", "..\LibOpenJPEG.vcproj", "{4F27AA53-4181-4A1A-8238-3931B0A41048}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{BCBEB12A-B691-4B14-9DC5-193BCD01183D}.Debug|Win32.ActiveCfg = Debug|Win32
-		{BCBEB12A-B691-4B14-9DC5-193BCD01183D}.Debug|Win32.Build.0 = Debug|Win32
-		{BCBEB12A-B691-4B14-9DC5-193BCD01183D}.Release|Win32.ActiveCfg = Release|Win32
-		{BCBEB12A-B691-4B14-9DC5-193BCD01183D}.Release|Win32.Build.0 = Release|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Debug|Win32.ActiveCfg = Debug|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Debug|Win32.Build.0 = Debug|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Release|Win32.ActiveCfg = Release|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.vcproj b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.vcproj
deleted file mode 100644
index 3c6e9a6..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Extractor.vcproj
+++ /dev/null
@@ -1,354 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="MJ2_Extractor"
-	ProjectGUID="{BCBEB12A-B691-4B14-9DC5-193BCD01183D}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/MJ2_Extractor.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/MJ2_Extractor.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
-				OutputFile=".\Release/MJ2_Extractor.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="libc"
-				ProgramDatabaseFile=".\Release/MJ2_Extractor.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/MJ2_Extractor.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\MJ2_Extractor___Win32_Debug"
-			IntermediateDirectory=".\MJ2_Extractor___Win32_Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\MJ2_Extractor___Win32_Debug/MJ2_Extractor.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="0"
-				PrecompiledHeaderFile=".\MJ2_Extractor___Win32_Debug/MJ2_Extractor.pch"
-				AssemblerListingLocation=".\MJ2_Extractor___Win32_Debug/"
-				ObjectFile=".\MJ2_Extractor___Win32_Debug/"
-				ProgramDataBaseFileName=".\MJ2_Extractor___Win32_Debug/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\MJ2_Extractor___Win32_Debug/MJ2_Extractor.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="libcmt"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\MJ2_Extractor___Win32_Debug/MJ2_Extractor.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\MJ2_Extractor___Win32_Debug/MJ2_Extractor.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-			>
-			<File
-				RelativePath="extract_j2k_from_mj2.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="mj2.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl"
-			>
-			<File
-				RelativePath="mj2.h"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="OpenJPEG Header Files"
-			>
-			<File
-				RelativePath="..\libopenjpeg\bio.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\cio.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\dwt.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\event.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\fix.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\image.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\int.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\j2k.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\j2k_lib.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\jp2.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\jpt.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\mct.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\mqc.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\openjpeg.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\opj_includes.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\pi.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\raw.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\t1.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\t2.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\tcd.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\tgt.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsp b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsp
deleted file mode 100644
index 724f608..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsp
+++ /dev/null
@@ -1,195 +0,0 @@
-# Microsoft Developer Studio Project File - Name="MJ2_Wrapper" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=MJ2_Wrapper - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "MJ2_Wrapper.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "MJ2_Wrapper.mak" CFG="MJ2_Wrapper - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "MJ2_Wrapper - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "MJ2_Wrapper - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "MJ2_Wrapper - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "MJ2_Wrapper - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "MJ2_Wrapper___Win32_Debug"
-# PROP BASE Intermediate_Dir "MJ2_Wrapper___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "MJ2_Wrapper___Win32_Debug"
-# PROP Intermediate_Dir "MJ2_Wrapper___Win32_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MT /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF 
-
-# Begin Target
-
-# Name "MJ2_Wrapper - Win32 Release"
-# Name "MJ2_Wrapper - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\mj2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\wrap_j2k_in_mj2.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\mj2.h
-# End Source File
-# End Group
-# Begin Group "OpenJPEG Header Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\libopenjpeg\bio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\cio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\dwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\event.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\fix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\image.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\int.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k_lib.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jp2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jpt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mct.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mqc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\openjpeg.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\opj_includes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\pi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\raw.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t1.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tcd.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tgt.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsw b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsw
deleted file mode 100644
index ae5a701..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "LibOpenJPEG"="..\LibOpenJPEG.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "MJ2_Wrapper"=".\MJ2_Wrapper.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.sln b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.sln
deleted file mode 100644
index 850c305..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.sln
+++ /dev/null
@@ -1,29 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MJ2_Wrapper", "MJ2_Wrapper.vcproj", "{87C98B26-E658-4992-8810-201C3CE67011}"
-	ProjectSection(ProjectDependencies) = postProject
-		{4F27AA53-4181-4A1A-8238-3931B0A41048} = {4F27AA53-4181-4A1A-8238-3931B0A41048}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOpenJPEG", "..\LibOpenJPEG.vcproj", "{4F27AA53-4181-4A1A-8238-3931B0A41048}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{87C98B26-E658-4992-8810-201C3CE67011}.Debug|Win32.ActiveCfg = Debug|Win32
-		{87C98B26-E658-4992-8810-201C3CE67011}.Debug|Win32.Build.0 = Debug|Win32
-		{87C98B26-E658-4992-8810-201C3CE67011}.Release|Win32.ActiveCfg = Release|Win32
-		{87C98B26-E658-4992-8810-201C3CE67011}.Release|Win32.Build.0 = Release|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Debug|Win32.ActiveCfg = Debug|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Debug|Win32.Build.0 = Debug|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Release|Win32.ActiveCfg = Release|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.vcproj b/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.vcproj
deleted file mode 100644
index 2c0f5c2..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/MJ2_Wrapper.vcproj
+++ /dev/null
@@ -1,353 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="MJ2_Wrapper"
-	ProjectGUID="{87C98B26-E658-4992-8810-201C3CE67011}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/MJ2_Wrapper.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/MJ2_Wrapper.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Release/MJ2_Wrapper.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				ProgramDatabaseFile=".\Release/MJ2_Wrapper.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/MJ2_Wrapper.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\MJ2_Wrapper___Win32_Debug"
-			IntermediateDirectory=".\MJ2_Wrapper___Win32_Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\MJ2_Wrapper___Win32_Debug/MJ2_Wrapper.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="0"
-				PrecompiledHeaderFile=".\MJ2_Wrapper___Win32_Debug/MJ2_Wrapper.pch"
-				AssemblerListingLocation=".\MJ2_Wrapper___Win32_Debug/"
-				ObjectFile=".\MJ2_Wrapper___Win32_Debug/"
-				ProgramDataBaseFileName=".\MJ2_Wrapper___Win32_Debug/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\MJ2_Wrapper___Win32_Debug/MJ2_Wrapper.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="libcmtd"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\MJ2_Wrapper___Win32_Debug/MJ2_Wrapper.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\MJ2_Wrapper___Win32_Debug/MJ2_Wrapper.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-			>
-			<File
-				RelativePath="mj2.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="wrap_j2k_in_mj2.c"
-				>
-				<FileConfiguration
-					Name="Release|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						PreprocessorDefinitions=""
-					/>
-				</FileConfiguration>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl"
-			>
-			<File
-				RelativePath="mj2.h"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="OpenJPEG Header Files"
-			>
-			<File
-				RelativePath="..\libopenjpeg\bio.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\cio.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\dwt.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\event.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\fix.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\image.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\int.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\j2k.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\j2k_lib.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\jp2.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\jpt.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\mct.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\mqc.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\openjpeg.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\opj_includes.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\pi.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\raw.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\t1.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\t2.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\tcd.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\tgt.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/extract_j2k_from_mj2.c b/Utilities/gdcmopenjpeg-v1/mj2/extract_j2k_from_mj2.c
deleted file mode 100644
index 5c1441a..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/extract_j2k_from_mj2.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "openjpeg.h"
-#include "../libopenjpeg/j2k.h"
-#include "../libopenjpeg/jp2.h"
-#include "mj2.h"
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-int main(int argc, char *argv[]) {
-	opj_dinfo_t* dinfo; 
-	opj_event_mgr_t event_mgr;		/* event manager */
-  int tnum;
-  unsigned int snum;
-  opj_mj2_t *movie;
-  mj2_tk_t *track;
-  mj2_sample_t *sample;
-  unsigned char* frame_codestream;
-  FILE *file, *outfile;
-  char outfilename[50];
-	mj2_dparameters_t parameters;
-
-  if (argc != 3) {
-    printf("Usage: %s mj2filename output_location\n",argv[0]); 
-    printf("Example: %s foreman.mj2 output/foreman\n",argv[0]);
-    return 1;
-  }
-  
-  file = fopen(argv[1], "rb");
-  
-  if (!file) {
-    fprintf(stderr, "failed to open %s for reading\n", argv[1]);
-    return 1;
-  }
-
-	/*
-	configure the event callbacks (not required)
-	setting of each callback is optionnal
-	*/
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* get a MJ2 decompressor handle */
-	dinfo = mj2_create_decompress();
-
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);		
-
-	/* setup the decoder decoding parameters using user parameters */
-	movie = (opj_mj2_t*) dinfo->mj2_handle;
-	mj2_setup_decoder((opj_mj2_t*)dinfo->mj2_handle, &parameters);
-
-  if (mj2_read_struct(file, movie)) // Creating the movie structure
-    return 1;
-
-  // Decode first video track 
-  tnum = 0;
-  while (movie->tk[tnum].track_type != 0)
-    tnum ++;
-
-  track = &movie->tk[tnum];
-
-  fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
-
-  for (snum=0; snum < track->num_samples; snum++)
-  {
-    sample = &track->sample[snum];
-    frame_codestream = (unsigned char*) malloc (sample->sample_size-8); // Skipping JP2C marker
-    fseek(file,sample->offset+8,SEEK_SET);
-    fread(frame_codestream,sample->sample_size-8,1, file);  // Assuming that jp and ftyp markers size do
-
-    sprintf(outfilename,"%s_%05d.j2k",argv[2],snum);
-    outfile = fopen(outfilename, "wb");
-    if (!outfile) {
-      fprintf(stderr, "failed to open %s for writing\n",outfilename);
-      return 1;
-    }
-    fwrite(frame_codestream,sample->sample_size-8,1,outfile);
-    fclose(outfile);
-    free(frame_codestream);
-    }
-  fclose(file);
-  fprintf(stdout, "%d frames correctly extracted\n", snum);
-	
-	/* free remaining structures */
-	if(dinfo) {
-		mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
-	}
-	
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.c b/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.c
deleted file mode 100644
index 6b1fd53..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.c
+++ /dev/null
@@ -1,806 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2002-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "openjpeg.h"
-#include "../libopenjpeg/j2k_lib.h"
-#include "../libopenjpeg/j2k.h"
-#include "../libopenjpeg/jp2.h"
-#include "../libopenjpeg/cio.h"
-#include "mj2.h"
-#include "mj2_convert.h"
-#include "getopt.h"
-
-/**
-Size of memory first allocated for MOOV box
-*/
-#define TEMP_BUF 10000 
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-void help_display()
-{
-  fprintf(stdout,"HELP for frames_to_mj2\n----\n\n");
-  fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-  
-  
-  fprintf(stdout,"List of parameters for the MJ2 encoder:\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"REMARKS:\n");
-  fprintf(stdout,"---------\n");
-  fprintf(stdout,"\n");
-  fprintf
-    (stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
-  fprintf
-    (stdout,"COD and QCD never appear in the tile_header.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"By default:\n");
-  fprintf(stdout,"------------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout," * Lossless\n");
-  fprintf(stdout," * 1 tile\n");
-  fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
-  fprintf(stdout," * Size of code-block : 64 x 64\n");
-  fprintf(stdout," * Number of resolutions: 6\n");
-  fprintf(stdout," * No SOP marker in the codestream\n");
-  fprintf(stdout," * No EPH marker in the codestream\n");
-  fprintf(stdout," * No sub-sampling in x or y direction\n");
-  fprintf(stdout," * No mode switch activated\n");
-  fprintf(stdout," * Progression order: LRCP\n");
-  fprintf(stdout," * No index file\n");
-  fprintf(stdout," * No ROI upshifted\n");
-  fprintf(stdout," * No offset of the origin of the image\n");
-  fprintf(stdout," * No offset of the origin of the tiles\n");
-  fprintf(stdout," * Reversible DWT 5-3\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Parameters:\n");
-  fprintf(stdout,"------------\n");
-  fprintf(stdout,"\n");
-  fprintf
-    (stdout,"Required Parameters (except with -h):\n");
-  fprintf
-    (stdout,"-i           : source file  (-i source.yuv) \n");
-  fprintf
-    (stdout,"-o           : destination file (-o dest.mj2) \n");
-  fprintf
-    (stdout,"Optional Parameters:\n");
-  fprintf(stdout,"-h           : display the help information \n");
-  fprintf(stdout,"-r           : different compression ratios for successive layers (-r 20,10,5)\n ");
-  fprintf(stdout,"	         - The rate specified for each quality level is the desired \n");
-  fprintf(stdout,"	           compression factor.\n");
-  fprintf(stdout,"		   Example: -r 20,10,1 means quality 1: compress 20x, \n");
-  fprintf(stdout,"		     quality 2: compress 10x and quality 3: compress lossless\n");
-  fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-  
-  fprintf(stdout,"-q           : different psnr for successive layers (-q 30,40,50) \n ");
-  
-  fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-  
-  fprintf(stdout,"-n           : number of resolutions (-n 3) \n");
-  fprintf(stdout,"-b           : size of code block (-b 32,32) \n");
-  fprintf(stdout,"-c           : size of precinct (-c 128,128) \n");
-  fprintf(stdout,"-t           : size of tile (-t 512,512) \n");
-  fprintf
-    (stdout,"-p           : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
-  fprintf
-    (stdout,"-s           : subsampling factor (-s 2,2) [-s X,Y] \n");
-  fprintf(stdout,"	     Remark: subsampling bigger than 2 can produce error\n");
-  fprintf
-    (stdout,"-SOP         : write SOP marker before each packet \n");
-  fprintf
-    (stdout,"-EPH         : write EPH marker after each header packet \n");
-  fprintf
-    (stdout,"-M           : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
-  fprintf
-    (stdout,"                 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
-  fprintf
-    (stdout,"                 Indicate multiple modes by adding their values. \n");
-  fprintf
-    (stdout,"                 ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
-  fprintf
-    (stdout,"-ROI         : c=%%d,U=%%d : quantization indices upshifted \n");
-  fprintf
-    (stdout,"               for component c=%%d [%%d = 0,1,2]\n");
-  fprintf
-    (stdout,"               with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
-  fprintf
-    (stdout,"-d           : offset of the origin of the image (-d 150,300) \n");
-  fprintf
-    (stdout,"-T           : offset of the origin of the tiles (-T 100,75) \n");
-  fprintf(stdout,"-I           : use the irreversible DWT 9-7 (-I) \n");
-  fprintf(stdout,"-W           : image width, height and the dx and dy subsampling \n");
-  fprintf(stdout,"               of the Cb and Cr components for YUV files \n");
-  fprintf(stdout,"               (default is '352,288,2,2' for CIF format's 352x288 and 4:2:0)\n");
-  fprintf(stdout,"-F           : video frame rate (set to 25 by default)\n");
-  
-  fprintf(stdout,"\n");
-  fprintf(stdout,"IMPORTANT:\n");
-  fprintf(stdout,"-----------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The index file has the structure below:\n");
-  fprintf(stdout,"---------------------------------------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Image_height Image_width\n");
-  fprintf(stdout,"progression order\n");
-  fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
-  fprintf(stdout,"Components_nb\n");
-  fprintf(stdout,"Layers_nb\n");
-  fprintf(stdout,"decomposition_levels\n");
-  fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
-  fprintf(stdout,"   [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
-  fprintf(stdout,"Main_header_end_position\n");
-  fprintf(stdout,"Codestream_size\n");
-  fprintf(stdout,"Tile_0 start_pos end_Theader end_pos TotalDisto NumPix MaxMSE\n");
-  fprintf(stdout,"Tile_1   ''           ''        ''        ''       ''    ''\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"Tile_Nt   ''           ''        ''        ''       ''    ''\n");
-  fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"Tpacket_Np ''   ''    ''   ''    ''       ''       ''     ''\n");
-  
-  fprintf(stdout,"MaxDisto\n");
-  
-  fprintf(stdout,"TotalDisto\n\n");
-}
-
-int give_progression(char progression[4])
-{
-  if (progression[0] == 'L' && progression[1] == 'R'
-    && progression[2] == 'C' && progression[3] == 'P') {
-    return 0;
-  } else {
-    if (progression[0] == 'R' && progression[1] == 'L'
-      && progression[2] == 'C' && progression[3] == 'P') {
-      return 1;
-    } else {
-      if (progression[0] == 'R' && progression[1] == 'P'
-				&& progression[2] == 'C' && progression[3] == 'L') {
-				return 2;
-      } else {
-				if (progression[0] == 'P' && progression[1] == 'C'
-					&& progression[2] == 'R' && progression[3] == 'L') {
-					return 3;
-				} else {
-					if (progression[0] == 'C' && progression[1] == 'P'
-						&& progression[2] == 'R' && progression[3] == 'L') {
-						return 4;
-					} else {
-						return -1;
-					}
-				}
-      }
-    }
-  }
-}
-
-
-
-
-int main(int argc, char **argv)
-{
-	mj2_cparameters_t mj2_parameters;	/* MJ2 compression parameters */
-	opj_cparameters_t *j2k_parameters;	/* J2K compression parameters */
-	opj_event_mgr_t event_mgr;		/* event manager */
-	opj_cio_t *cio;
-	int value;
-  opj_mj2_t *movie;
-	opj_image_t *img;
-  int i, j;
-  char *s, S1, S2, S3;
-  unsigned char *buf;
-  int x1, y1,  len;
-  long mdat_initpos, offset;
-  FILE *mj2file;
-  int sampleno;  
-	opj_cinfo_t* cinfo;
-  bool bSuccess;
-	int numframes;
-	double total_time = 0;	
-
-  /* default value */
-  /* ------------- */
-  mj2_parameters.Dim[0] = 0;
-  mj2_parameters.Dim[1] = 0;
-  mj2_parameters.w = 352;			// CIF default value
-  mj2_parameters.h = 288;			// CIF default value
-  mj2_parameters.CbCr_subsampling_dx = 2;	// CIF default value
-  mj2_parameters.CbCr_subsampling_dy = 2;	// CIF default value
-  mj2_parameters.frame_rate = 25;	  
-	/*
-	configure the event callbacks (not required)
-	setting of each callback is optionnal
-	*/
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = NULL;
-    
-	/* set J2K encoding parameters to default values */
-	opj_set_default_encoder_parameters(&mj2_parameters.j2k_parameters);
-	j2k_parameters = &mj2_parameters.j2k_parameters;
-
-	/* Create comment for codestream */
-	if(j2k_parameters->cp_comment == NULL) {
-    const char comment[] = "Created by OpenJPEG version ";
-		const size_t clen = strlen(comment);
-    const char *version = opj_version();
-		j2k_parameters->cp_comment = (char*)malloc(clen+strlen(version)+1);
-		sprintf(j2k_parameters->cp_comment,"%s%s", comment, version);
-	}
-
-	mj2_parameters.decod_format = 0;
-	mj2_parameters.cod_format = 0;
-
-  while (1) {
-    int c = getopt(argc, argv,
-      "i:o:r:q:f:t:n:c:b:p:s:d:P:S:E:M:R:T:C:I:W:F:h");
-    if (c == -1)
-      break;
-    switch (c) {
-    case 'i':			/* IN fill */
-			{
-				char *infile = optarg;
-				s = optarg;
-				while (*s) {
-					s++;
-				}
-				s--;
-				S3 = *s;
-				s--;
-				S2 = *s;
-				s--;
-				S1 = *s;
-				
-				if ((S1 == 'y' && S2 == 'u' && S3 == 'v')
-					|| (S1 == 'Y' && S2 == 'U' && S3 == 'V')) {
-					mj2_parameters.decod_format = YUV_DFMT;				
-				}
-				else {
-					fprintf(stderr,
-						"!! Unrecognized format for infile : %c%c%c [accept only *.yuv] !!\n\n",
-						S1, S2, S3);
-					return 1;
-				}
-				strncpy(mj2_parameters.infile, infile, sizeof(mj2_parameters.infile)-1);
-			}
-      break;
-      /* ----------------------------------------------------- */
-    case 'o':			/* OUT fill */
-			{
-				char *outfile = optarg;
-				while (*outfile) {
-					outfile++;
-				}
-				outfile--;
-				S3 = *outfile;
-				outfile--;
-				S2 = *outfile;
-				outfile--;
-				S1 = *outfile;
-				
-				outfile = optarg;
-				
-				if ((S1 == 'm' && S2 == 'j' && S3 == '2')
-					|| (S1 == 'M' && S2 == 'J' && S3 == '2'))
-					mj2_parameters.cod_format = MJ2_CFMT;
-				else {
-					fprintf(stderr,
-						"Unknown output format image *.%c%c%c [only *.mj2]!! \n",
-						S1, S2, S3);
-					return 1;
-				}
-				strncpy(mj2_parameters.outfile, outfile, sizeof(mj2_parameters.outfile)-1);      
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 'r':			/* rates rates/distorsion */
-			{
-				float rate;
-				s = optarg;
-				while (sscanf(s, "%f", &rate) == 1) {
-					j2k_parameters->tcp_rates[j2k_parameters->tcp_numlayers] = rate * 2;
-					j2k_parameters->tcp_numlayers++;
-					while (*s && *s != ',') {
-						s++;
-					}
-					if (!*s)
-						break;
-					s++;
-				}
-				j2k_parameters->cp_disto_alloc = 1;
-			}
-      break;
-      /* ----------------------------------------------------- */
-    case 'q':			/* add fixed_quality */
-      s = optarg;
-			while (sscanf(s, "%f", &j2k_parameters->tcp_distoratio[j2k_parameters->tcp_numlayers]) == 1) {
-				j2k_parameters->tcp_numlayers++;
-				while (*s && *s != ',') {
-					s++;
-				}
-				if (!*s)
-					break;
-				s++;
-			}
-			j2k_parameters->cp_fixed_quality = 1;
-      break;
-      /* dda */
-      /* ----------------------------------------------------- */
-    case 'f':			/* mod fixed_quality (before : -q) */
-			{
-				int *row = NULL, *col = NULL;
-				int numlayers = 0, numresolution = 0, matrix_width = 0;
-				
-				s = optarg;
-				sscanf(s, "%d", &numlayers);
-				s++;
-				if (numlayers > 9)
-					s++;
-				
-				j2k_parameters->tcp_numlayers = numlayers;
-				numresolution = j2k_parameters->numresolution;
-				matrix_width = numresolution * 3;
-				j2k_parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
-				s = s + 2;
-				
-				for (i = 0; i < numlayers; i++) {
-					row = &j2k_parameters->cp_matrice[i * matrix_width];
-					col = row;
-					j2k_parameters->tcp_rates[i] = 1;
-					sscanf(s, "%d,", &col[0]);
-					s += 2;
-					if (col[0] > 9)
-						s++;
-					col[1] = 0;
-					col[2] = 0;
-					for (j = 1; j < numresolution; j++) {
-						col += 3;
-						sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
-						s += 6;
-						if (col[0] > 9)
-							s++;
-						if (col[1] > 9)
-							s++;
-						if (col[2] > 9)
-							s++;
-					}
-					if (i < numlayers - 1)
-						s++;
-				}
-				j2k_parameters->cp_fixed_alloc = 1;
-			}
-			break;
-      /* ----------------------------------------------------- */
-    case 't':			/* tiles */
-      sscanf(optarg, "%d,%d", &j2k_parameters->cp_tdx, &j2k_parameters->cp_tdy);
-			j2k_parameters->tile_size_on = true;
-      break;
-      /* ----------------------------------------------------- */
-    case 'n':			/* resolution */
-      sscanf(optarg, "%d", &j2k_parameters->numresolution);
-      break;
-      /* ----------------------------------------------------- */
-    case 'c':			/* precinct dimension */
-			{
-				char sep;
-				int res_spec = 0;
-
-				char *s = optarg;
-				do {
-					sep = 0;
-					sscanf(s, "[%d,%d]%c", &j2k_parameters->prcw_init[res_spec],
-                                 &j2k_parameters->prch_init[res_spec], &sep);
-					j2k_parameters->csty |= 0x01;
-					res_spec++;
-					s = strpbrk(s, "]") + 2;
-				}
-				while (sep == ',');
-				j2k_parameters->res_spec = res_spec;
-			}
-			break;
-
-      /* ----------------------------------------------------- */
-    case 'b':			/* code-block dimension */
-			{
-				int cblockw_init = 0, cblockh_init = 0;
-				sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
-				if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
-					|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
-					fprintf(stderr,
-						"!! Size of code_block error (option -b) !!\n\nRestriction :\n"
-            "    * width*height<=4096\n    * 4<=width,height<= 1024\n\n");
-					return 1;
-				}
-				j2k_parameters->cblockw_init = cblockw_init;
-				j2k_parameters->cblockh_init = cblockh_init;
-			}
-			break;
-      /* ----------------------------------------------------- */
-    case 'p':			/* progression order */
-			{
-				char progression[4];
-				
-				strncpy(progression, optarg, 4);
-				j2k_parameters->prog_order = give_progression(progression);
-				if (j2k_parameters->prog_order == -1) {
-					fprintf(stderr, "Unrecognized progression order "
-            "[LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
-					return 1;
-				}
-			}
-			break;
-      /* ----------------------------------------------------- */
-    case 's':			/* subsampling factor */
-      {
-				if (sscanf(optarg, "%d,%d", &j2k_parameters->subsampling_dx,
-                                    &j2k_parameters->subsampling_dy) != 2) {
-					fprintf(stderr,	"'-s' sub-sampling argument error !  [-s dx,dy]\n");
-					return 1;
-				}
-			}
-			break;
-      /* ----------------------------------------------------- */
-    case 'd':			/* coordonnate of the reference grid */
-      {
-				if (sscanf(optarg, "%d,%d", &j2k_parameters->image_offset_x0,
-                                    &j2k_parameters->image_offset_y0) != 2) {
-					fprintf(stderr,	"-d 'coordonnate of the reference grid' argument "
-            "error !! [-d x0,y0]\n");
-					return 1;
-				}
-			}
-			break;
-      /* ----------------------------------------------------- */
-    case 'h':			/* Display an help description */
-      help_display();
-      return 0;
-      break;
-      /* ----------------------------------------------------- */
-    case 'P':			/* POC */
-      {
-				int numpocs = 0;		/* number of progression order change (POC) default 0 */
-				opj_poc_t *POC = NULL;	/* POC : used in case of Progression order change */
-
-				char *s = optarg;
-				POC = j2k_parameters->POC;
-
-				while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
-					&POC[numpocs].resno0, &POC[numpocs].compno0,
-					&POC[numpocs].layno1, &POC[numpocs].resno1,
-					&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
-					POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
-					numpocs++;
-					while (*s && *s != '/') {
-						s++;
-					}
-					if (!*s) {
-						break;
-					}
-					s++;
-				}
-				j2k_parameters->numpocs = numpocs;
-			}
-			break;
-      /* ------------------------------------------------------ */
-    case 'S':			/* SOP marker */
-      j2k_parameters->csty |= 0x02;
-      break;
-      /* ------------------------------------------------------ */
-    case 'E':			/* EPH marker */
-      j2k_parameters->csty |= 0x04;
-      break;
-      /* ------------------------------------------------------ */
-    case 'M':			/* Mode switch pas tous au point !! */
-      if (sscanf(optarg, "%d", &value) == 1) {
-				for (i = 0; i <= 5; i++) {
-					int cache = value & (1 << i);
-					if (cache)
-						j2k_parameters->mode |= (1 << i);
-				}
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'R':			/* ROI */
-      {
-				if (sscanf(optarg, "OI:c=%d,U=%d", &j2k_parameters->roi_compno,
-                                           &j2k_parameters->roi_shift) != 2) {
-					fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
-					return 1;
-				}
-			}
-			break;
-      /* ------------------------------------------------------ */
-    case 'T':			/* Tile offset */
-			{
-				if (sscanf(optarg, "%d,%d", &j2k_parameters->cp_tx0, &j2k_parameters->cp_ty0) != 2) {
-					fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
-					return 1;
-				}
-			}
-			break;
-      /* ------------------------------------------------------ */
-    case 'C':			/* Add a comment */
-			{
-				j2k_parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
-				if(j2k_parameters->cp_comment) {
-					strcpy(j2k_parameters->cp_comment, optarg);
-				}
-			}
-			break;
-      /* ------------------------------------------------------ */
-    case 'I':			/* reversible or not */
-			{
-				j2k_parameters->irreversible = 1;
-			}
-			break;
-      /* ------------------------------------------------------ */
-    case 'W':			/* Width and Height and Cb and Cr subsampling in case of YUV format files */
-      if (sscanf
-				(optarg, "%d,%d,%d,%d", &mj2_parameters.w, &mj2_parameters.h, &mj2_parameters.CbCr_subsampling_dx,
-				&mj2_parameters.CbCr_subsampling_dy) != 4) {
-				fprintf(stderr, "-W argument error");
-				return 1;
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'F':			/* Video frame rate */
-      if (sscanf(optarg, "%d", &mj2_parameters.frame_rate) != 1) {
-				fprintf(stderr, "-F argument error");
-				return 1;
-      }
-      break;
-      /* ------------------------------------------------------ */
-    default:
-      return 1;
-    }
-  }
-    
-  /* Error messages */
-  /* -------------- */
-	if (!mj2_parameters.cod_format || !mj2_parameters.decod_format) {
-    fprintf(stderr,
-      "Usage: %s -i yuv-file -o mj2-file (+ options)\n",argv[0]);
-    return 1;
-  }
-  
-	if ((j2k_parameters->cp_disto_alloc || j2k_parameters->cp_fixed_alloc || j2k_parameters->cp_fixed_quality)
-		&& (!(j2k_parameters->cp_disto_alloc ^ j2k_parameters->cp_fixed_alloc ^ j2k_parameters->cp_fixed_quality))) {
-		fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
-		return 1;
-	}				/* mod fixed_quality */
-
-	/* if no rate entered, lossless by default */
-	if (j2k_parameters->tcp_numlayers == 0) {
-		j2k_parameters->tcp_rates[0] = 0;	/* MOD antonin : losslessbug */
-		j2k_parameters->tcp_numlayers++;
-		j2k_parameters->cp_disto_alloc = 1;
-	}
-
-	if((j2k_parameters->cp_tx0 > j2k_parameters->image_offset_x0) || (j2k_parameters->cp_ty0 > j2k_parameters->image_offset_y0)) {
-		fprintf(stderr,
-			"Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
-			j2k_parameters->cp_tx0, j2k_parameters->image_offset_x0, j2k_parameters->cp_ty0, j2k_parameters->image_offset_y0);
-		return 1;
-	}
-
-	for (i = 0; i < j2k_parameters->numpocs; i++) {
-		if (j2k_parameters->POC[i].prg == -1) {
-			fprintf(stderr,
-				"Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
-				i + 1);
-		}
-	}
-  
-  if (j2k_parameters->cp_tdx > mj2_parameters.Dim[0] || j2k_parameters->cp_tdy > mj2_parameters.Dim[1]) {
-    fprintf(stderr,
-      "Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
-      j2k_parameters->cp_tdx, mj2_parameters.Dim[0], j2k_parameters->cp_tdy, mj2_parameters.Dim[1]);
-    return 1;
-  }
-    
-  /* to respect profile - 0 */
-  /* ---------------------- */
-  
-  x1 = !mj2_parameters.Dim[0] ? (mj2_parameters.w - 1) * j2k_parameters->subsampling_dx 
-		+ 1 : mj2_parameters.Dim[0] + (mj2_parameters.w - 1) * j2k_parameters->subsampling_dx + 1;
-  y1 = !mj2_parameters.Dim[1] ? (mj2_parameters.h - 1) * j2k_parameters->subsampling_dy 
-		+ 1 : mj2_parameters.Dim[1] + (mj2_parameters.h - 1) * j2k_parameters->subsampling_dy + 1;   
-  mj2_parameters.numcomps = 3;			/* Because YUV files only have 3 components */ 
-  mj2_parameters.prec = 8;			/* Because in YUV files, components have 8-bit depth */
-
-	j2k_parameters->tcp_mct = 0;
-    
-  mj2file = fopen(mj2_parameters.outfile, "wb");
-  
-  if (!mj2file) {
-    fprintf(stderr, "failed to open %s for writing\n", argv[2]);
-    return 1;
-  }
-    
-	/* get a MJ2 decompressor handle */
-	cinfo = mj2_create_compress();
-	movie = (opj_mj2_t*)cinfo->mj2_handle;
-	
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
-
-	/* setup encoder parameters */
-	mj2_setup_encoder(movie, &mj2_parameters);   
-  
-  movie->tk[0].num_samples = yuv_num_frames(&movie->tk[0],mj2_parameters.infile); 
-  if (movie->tk[0].num_samples == -1) {
-		return 1;
-  }
-  
-  // One sample per chunk
-  movie->tk[0].chunk = (mj2_chunk_t*) malloc(movie->tk[0].num_samples * sizeof(mj2_chunk_t));     
-  movie->tk[0].sample = (mj2_sample_t*) malloc(movie->tk[0].num_samples * sizeof(mj2_sample_t));
-  
-  if (mj2_init_stdmovie(movie)) {
-    fprintf(stderr, "Error with movie initialization");
-    return 1;
-  };    
-  
-  // Writing JP, FTYP and MDAT boxes 
-  buf = (unsigned char*) malloc (300 * sizeof(unsigned char)); // Assuming that the JP and FTYP
-  // boxes won't be longer than 300 bytes
-	cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, 300);
-  mj2_write_jp(cio);
-  mj2_write_ftyp(movie, cio);
-  mdat_initpos = cio_tell(cio);
-  cio_skip(cio, 4);
-  cio_write(cio, MJ2_MDAT, 4);	
-  fwrite(buf,cio_tell(cio),1,mj2file);
-  offset = cio_tell(cio);
-  opj_cio_close(cio);
-  free(buf);
-
-  for (i = 0; i < movie->num_stk + movie->num_htk + movie->num_vtk; i++) {
-    if (movie->tk[i].track_type != 0) {
-      fprintf(stderr, "Unable to write sound or hint tracks\n");
-    } else {
-      mj2_tk_t *tk;
-			int buflen = 0;
-      
-      tk = &movie->tk[i];     
-      tk->num_chunks = tk->num_samples;
-			numframes = tk->num_samples;
-
-      fprintf(stderr, "Video Track number %d\n", i + 1);
-			
-			img = mj2_image_create(tk, j2k_parameters);          
-			buflen = 2 * (tk->w * tk->h * 8);
-			buf = (unsigned char *) malloc(buflen*sizeof(unsigned char));	
-
-      for (sampleno = 0; sampleno < numframes; sampleno++) {		
-				double init_time = opj_clock();
-				double elapsed_time;
-				if (yuvtoimage(tk, img, sampleno, j2k_parameters, mj2_parameters.infile)) {
-					fprintf(stderr, "Error with frame number %d in YUV file\n", sampleno);
-					return 1;
-				}
-
-				/* setup the encoder parameters using the current image and user parameters */
-				opj_setup_encoder(cinfo, j2k_parameters, img);
-
-				cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, buflen);
-								
-				cio_skip(cio, 4);
-				cio_write(cio, JP2_JP2C, 4);	// JP2C
-
-				/* encode the image */
-				bSuccess = opj_encode(cinfo, cio, img, NULL);
-				if (!bSuccess) {
-					opj_cio_close(cio);
-					fprintf(stderr, "failed to encode image\n");
-					return 1;
-				}
-
-				len = cio_tell(cio) - 8;
-				cio_seek(cio, 0);
-				cio_write(cio, len+8,4);
-				opj_cio_close(cio);
-				tk->sample[sampleno].sample_size = len+8;				
-				tk->sample[sampleno].offset = offset;
-				tk->chunk[sampleno].offset = offset;	// There is one sample per chunk 
-				fwrite(buf, 1, len+8, mj2file);				
-				offset += len+8;				
-				elapsed_time = opj_clock()-init_time;
-				fprintf(stderr, "Frame number %d/%d encoded in %.2f mseconds\n", sampleno + 1, numframes, elapsed_time*1000);
-				total_time += elapsed_time;
-
-      }
-			/* free buffer data */
-			free(buf);
-			/* free image data */
-			opj_image_destroy(img);
-    }
-  }
-  
-  fseek(mj2file, mdat_initpos, SEEK_SET);
-	
-  buf = (unsigned char*) malloc(4*sizeof(unsigned char));
-
-	// Init a cio to write box length variable in a little endian way 
-	cio = opj_cio_open(NULL, buf, 4);
-  cio_write(cio, offset - mdat_initpos, 4);
-  fwrite(buf, 4, 1, mj2file);
-  fseek(mj2file,0,SEEK_END);
-  free(buf);
-
-  // Writing MOOV box 
-	buf = (unsigned char*) malloc ((TEMP_BUF+numframes*20) * sizeof(unsigned char));
-	cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+numframes*20));
-	mj2_write_moov(movie, cio);
-  fwrite(buf,cio_tell(cio),1,mj2file);
-  free(buf);
-
-	fprintf(stdout,"Total encoding time: %.2f s for %d frames (%.1f fps)\n", total_time, numframes, (float)numframes/total_time);
-  
-  // Ending program 
-  
-  fclose(mj2file);
-	/* free remaining compression structures */
-	mj2_destroy_compress(movie);
-	free(cinfo);
-	/* free user parameters structure */
-  if(j2k_parameters->cp_comment) free(j2k_parameters->cp_comment);
-	if(j2k_parameters->cp_matrice) free(j2k_parameters->cp_matrice);
-	opj_cio_close(cio);
-
-  return 0;
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsp b/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsp
deleted file mode 100644
index c1da267..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsp
+++ /dev/null
@@ -1,212 +0,0 @@
-# Microsoft Developer Studio Project File - Name="frames_to_mj2" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=frames_to_mj2 - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "frames_to_mj2.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "frames_to_mj2.mak" CFG="frames_to_mj2 - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "frames_to_mj2 - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "frames_to_mj2 - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "frames_to_mj2 - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# SUBTRACT LINK32 /pdb:none /incremental:yes /debug
-
-!ELSEIF  "$(CFG)" == "frames_to_mj2 - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "frames_to_mj2___Win32_Debug0"
-# PROP BASE Intermediate_Dir "frames_to_mj2___Win32_Debug0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "frames_to_mj2___Win32_Debug0"
-# PROP Intermediate_Dir "frames_to_mj2___Win32_Debug0"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MT /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF 
-
-# Begin Target
-
-# Name "frames_to_mj2 - Win32 Release"
-# Name "frames_to_mj2 - Win32 Debug"
-# Begin Group "MJ2"
-
-# PROP Default_Filter ""
-# Begin Group "MJ2 Header Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\mj2.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_convert.h
-# End Source File
-# End Group
-# Begin Group "MJ2 Source Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\frames_to_mj2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\compat\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_convert.c
-# End Source File
-# End Group
-# End Group
-# Begin Group "Libopenjpeg Header files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\libopenjpeg\bio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\cio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\dwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\event.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\fix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\image.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\int.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\j2k_lib.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jp2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\jpt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mct.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\mqc.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\openjpeg.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\opj_includes.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\pi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\raw.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t1.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\t2.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tcd.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libopenjpeg\tgt.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsw b/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsw
deleted file mode 100644
index 92c5fc1..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "frames_to_mj2"=".\frames_to_mj2.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "LibOpenJPEG"="..\LibOpenJPEG.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.sln b/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.sln
deleted file mode 100644
index f62e33d..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.sln and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.vcproj b/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.vcproj
deleted file mode 100644
index 92e8eac..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/frames_to_mj2.vcproj
+++ /dev/null
@@ -1,406 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="frames_to_mj2"
-	ProjectGUID="{4C7685BB-E216-488C-8675-FF5A54FEDDDD}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/frames_to_mj2.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="2"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/frames_to_mj2.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Release/frames_to_mj2.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="LIBC"
-				ProgramDatabaseFile=".\Release/frames_to_mj2.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/frames_to_mj2.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\frames_to_mj2___Win32_Debug0"
-			IntermediateDirectory=".\frames_to_mj2___Win32_Debug0"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\frames_to_mj2___Win32_Debug0/frames_to_mj2.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="0"
-				PrecompiledHeaderFile=".\frames_to_mj2___Win32_Debug0/frames_to_mj2.pch"
-				AssemblerListingLocation=".\frames_to_mj2___Win32_Debug0/"
-				ObjectFile=".\frames_to_mj2___Win32_Debug0/"
-				ProgramDataBaseFileName=".\frames_to_mj2___Win32_Debug0/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\frames_to_mj2___Win32_Debug0/frames_to_mj2.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="LIBC,LIBCMT"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\frames_to_mj2___Win32_Debug0/frames_to_mj2.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\frames_to_mj2___Win32_Debug0/frames_to_mj2.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="MJ2"
-			>
-			<Filter
-				Name="MJ2 Header Files"
-				>
-				<File
-					RelativePath="mj2.h"
-					>
-				</File>
-				<File
-					RelativePath="mj2_convert.h"
-					>
-				</File>
-			</Filter>
-			<Filter
-				Name="MJ2 Source Files"
-				>
-				<File
-					RelativePath="frames_to_mj2.c"
-					>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="compat\getopt.c"
-					>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2.c"
-					>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2_convert.c"
-					>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-			</Filter>
-		</Filter>
-		<Filter
-			Name="Libopenjpeg Header files"
-			>
-			<File
-				RelativePath="..\libopenjpeg\bio.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\cio.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\dwt.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\event.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\fix.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\image.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\int.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\j2k.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\j2k_lib.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\jp2.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\jpt.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\mct.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\mqc.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\openjpeg.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\opj_includes.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\pi.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\raw.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\t1.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\t2.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\tcd.h"
-				>
-			</File>
-			<File
-				RelativePath="..\libopenjpeg\tgt.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/meta_out.c b/Utilities/gdcmopenjpeg-v1/mj2/meta_out.c
deleted file mode 100644
index ff80b5e..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/meta_out.c
+++ /dev/null
@@ -1,2181 +0,0 @@
-/* meta_out.c */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Callable from mj2_to_metadata */
-/* Contributed to Open JPEG by Glenn Pearson, contract software developer, U.S. National Library of Medicine.
-
-The base code in this file was developed by the author as part of a video archiving
-project for the U.S. National Library of Medicine, Bethesda, MD. 
-It is the policy of NLM (and U.S. government) to not assert copyright.
-
-A non-exclusive copy of this code has been contributed to the Open JPEG project.
-Except for copyright, inclusion of the code within Open JPEG for distribution and use
-can be bound by the Open JPEG open-source license and disclaimer, expressed elsewhere.
-*/
-
-#include <windows.h> /* for time functions */
-
-#include "../libopenjpeg/opj_includes.h"
-#include "mj2.h"
-
-#include <time.h>
-#include "meta_out.h"
-
-static BOOL notes = TRUE;
-static BOOL sampletables = FALSE;
-static BOOL raw = TRUE;
-static BOOL derived = TRUE;
-
-opj_tcp_t *j2k_default_tcp;
-
-/* Forwards */
-int xml_write_overall_header(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr);
-int xml_write_moov(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr);
-
-void uint_to_chars(unsigned int value, char* buf);
-
-void xml_write_trak(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum, unsigned int sampleframe, opj_event_mgr_t *event_mgr);
-void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-
-void UnixTimeToFileTime(time_t t, LPFILETIME pft);
-void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst);
-void xml_time_out(FILE* xmlout, time_t t);
-
-void int16_to_3packedchars(short int value, char* buf);
-
-void xml_write_moov_udta(FILE* xmlout, opj_mj2_t * movie);
-void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie);
-void xml_write_uuid(FILE* xmlout, opj_mj2_t * movie);
-
-int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int snum, opj_event_mgr_t *event_mgr);
-
-void xml_out_frame_siz(FILE* xmlout, opj_image_t *img, opj_cp_t *cp);
-void xml_out_frame_cod(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_coc(FILE* xmlout, opj_tcp_t *tcp, int numcomps); /* opj_image_t *img); */
-BOOL same_component_style(opj_tccp_t *tccp1, opj_tccp_t *tccp2);
-void xml_out_frame_qcd(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_qcc(FILE* xmlout, opj_tcp_t *tcp, int numcomps); /* opj_image_t *img); */
-BOOL same_component_quantization(opj_tccp_t *tccp1, opj_tccp_t *tccp2);
-void xml_out_frame_rgn(FILE* xmlout, opj_tcp_t *tcp, int numcomps);/* opj_image_t *img);*/
-void xml_out_frame_poc(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_ppm(FILE* xmlout, opj_cp_t *cp);
-void xml_out_frame_ppt(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_tlm(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* NO-OP.  TLM NOT SAVED IN DATA STRUCTURE */
-void xml_out_frame_plm(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE.  opt in main; can be used in conjunction with PLT */
-void xml_out_frame_plt(FILE* xmlout, opj_tcp_t *tcp); /* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE.  opt in main; can be used in conjunction with PLT */
-void xml_out_frame_crg(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* opt in main; */
-void xml_out_frame_com(FILE* xmlout, opj_tcp_t *tcp); /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */ /* opt in main; */
-void xml_out_dump_hex(FILE* xmlout, char *data, int data_len, char* s);
-void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len, char* s);
-void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct);
-#ifdef NOTYET
-/* Shown with cp, extended, as data structure... but it could be a new different one */
-void xml_out_frame_jp2i(FILE* xmlout, opj_cp_t *cp);/* IntellectualProperty 'jp2i' (no restrictions on location) */
-void xml_out_frame_xml(FILE* xmlout, opj_cp_t *cp); /* XML 'xml\040' (0x786d6c20).  Can appear multiply */
-void xml_out_frame_uuid(FILE* xmlout, opj_cp_t *cp); /* UUID 'uuid' (top level only) */
-void xml_out_frame_uinf(FILE* xmlout, opj_cp_t *cp); /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */
-void xml_out_frame_unknown_type(FILE* xmlout, opj_cp_t *cp);
-#endif
-
-
-void xml_write_init(BOOL n, BOOL t, BOOL r, BOOL d)
-{
-  /* Init file globals */
-  notes = n;
-  sampletables = t;
-  raw = r;
-  derived = d;
-}
-
-int xml_write_struct(FILE* file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, char* stringDTD, opj_event_mgr_t *event_mgr) {
-
-  if(stringDTD != NULL)
-  {
-    fprintf(xmlout,"<?xml version=\"1.0\" standalone=\"no\"?>\n");
-	/* stringDTD is known to start with "SYSTEM " or "PUBLIC " */
-	/* typical: SYSTEM mj2_to_metadata.dtd */
-	stringDTD[6] = '\0'; /* Break into two strings at space, so quotes can be inserted. */
-    fprintf(xmlout,"<!DOCTYPE MJ2_File %s \"%s\">\n", stringDTD, stringDTD+7); 
-	stringDTD[6] = ' '; /* restore for sake of debugger or memory allocator */
-  } else
-    fprintf(xmlout,"<?xml version=\"1.0\" standalone=\"yes\"?>\n");    
-
-  fprintf(xmlout, "<MJ2_File>\n");
-  xml_write_overall_header(file, xmlout, movie, sampleframe, event_mgr);
-  fprintf(xmlout, "</MJ2_File>");
-  return 0;
-}
-
-/* ------------- */
-
-int xml_write_overall_header(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr)
-{
-  int i;
-  char buf[5];
-  buf[4] = '\0';
-
-  fprintf(xmlout,   "  <JP2 BoxType=\"jP[space][space]\" Signature=\"0x0d0a870a\" />\n");
-  // Called after structure initialized by mj2_read_ftyp
-  fprintf(xmlout,   "  <FileType BoxType=\"ftyp\">\n");
-  uint_to_chars(movie->brand, buf);
-  fprintf(xmlout,   "    <Brand>%s</Brand>\n", buf);    /* 4 character; BR              */
-  fprintf(xmlout,   "    <MinorVersion>%u</MinorVersion>\n", movie->minversion);    /* 4 char; MinV            */
-  fprintf(xmlout,   "    <CompatibilityList Count=\"%d\">\n",movie->num_cl);
-  for (i = movie->num_cl - 1; i > -1; i--) /* read routine stored in reverse order, so let's undo damage */
-  {
-    uint_to_chars(movie->cl[i], buf);
-    fprintf(xmlout, "      <CompatibleBrand>%s</CompatibleBrand>\n", buf);    /*4 characters, each CLi */
-  }
-  fprintf(xmlout,   "    </CompatibilityList>\n");
-  fprintf(xmlout,   "  </FileType>\n");
-  xml_write_moov(file, xmlout, movie, sampleframe, event_mgr);
-  // To come?              <mdat>  // This is the container for media data that can also be accessed through track structures,
-                                   // so is redundant, and simply not of interest as metadata
-  //                       <moof>  // Allows incremental build up of movie.  Probably not in Simple Profile
-  xml_write_free_and_skip(xmlout, movie); /* NO OP so far */ /* May be a place where user squirrels metadata */
-  xml_write_uuid(xmlout, movie); /* NO OP so far */ /* May be a place where user squirrels metadata */
-  return 0;
-}
-
-/* ------------- */
-
-int xml_write_moov(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr)
-{
-  unsigned int tnum;
-  mj2_tk_t *track;
-
-  fprintf(xmlout,   "  <MovieBox BoxType=\"moov\">\n");
-  fprintf(xmlout,   "    <MovieHeader BoxType=\"mvhd\">\n");
-  fprintf(xmlout,   "      <CreationTime>\n");
-  if(raw)
-    fprintf(xmlout, "        <InSeconds>%u</InSeconds>\n", movie->creation_time);
-  if(notes)
-    fprintf(xmlout, "        <!-- Seconds since start of Jan. 1, 1904 UTC (Greenwich) -->\n");
-  /*  2082844800 = seconds between 1/1/04 and 1/1/70 */
-  /* There's still a time zone offset problem not solved... but spec is ambigous as to whether stored time
-     should be local or UTC */
-  if(derived) {
-    fprintf(xmlout, "        <AsLocalTime>"); 
-                             xml_time_out(xmlout, movie->creation_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,   "      </CreationTime>\n");
-  fprintf(xmlout,   "      <ModificationTime>\n");
-  if(raw)
-    fprintf(xmlout, "        <InSeconds>%u</InSeconds>\n", movie->modification_time);
-  if(derived) {
-    fprintf(xmlout, "        <AsLocalTime>"); 
-                             xml_time_out(xmlout, movie->modification_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,   "      </ModificationTime>\n");
-  fprintf(xmlout,   "      <Timescale>%d</Timescale>\n", movie->timescale);
-  if(notes)
-    fprintf(xmlout, "      <!-- Timescale defines time units in one second -->\n");
-  fprintf(xmlout,   "      <Rate>\n");        /* Rate to play presentation  (default = 0x00010000)          */
-  if(notes) {
-    fprintf(xmlout, "      <!-- Rate to play presentation is stored as fixed-point binary 16.16 value. Decimal value is approximation. -->\n");
-    fprintf(xmlout, "      <!-- Rate is expressed relative to normal (default) value of 0x00010000 (1.0) -->\n");
-  }
-  if(raw)
-    fprintf(xmlout, "        <AsHex>0x%08x</AsHex>\n", movie->rate);
-  if(derived)
-    fprintf(xmlout, "        <AsDecimal>%12.6f</AsDecimal>\n", (double)movie->rate/(double)0x00010000);
-  fprintf(xmlout,   "      </Rate>\n");
-  fprintf(xmlout,   "      <Duration>\n");
-  if(raw)
-    fprintf(xmlout, "        <InTimeUnits>%u</InTimeUnits>\n", movie->duration);
-  if(derived)
-    fprintf(xmlout, "        <InSeconds>%12.3f</InSeconds>\n", (double)movie->duration/(double)movie->timescale);    // Make this double later to get fractional seconds
-  fprintf(xmlout,   "      </Duration>\n");
-#ifdef CURRENTSTRUCT
-  movie->volume = movie->volume << 8;
-#endif
-  fprintf(xmlout,   "      <Volume>\n");
-  if(notes) {
-    fprintf(xmlout, "      <!-- Audio volume stored as fixed-point binary 8.8 value. Decimal value is approximation. -->\n");
-    fprintf(xmlout, "      <!-- Full, normal (default) value is 0x0100 (1.0) -->\n");
-  }
-  if(raw)
-    fprintf(xmlout, "        <AsHex>0x%04x</AsHex>\n", movie->volume);
-  if(derived)
-    fprintf(xmlout, "        <AsDecimal>%6.3f</AsDecimal>\n", (double)movie->volume/(double)0x0100);
-  fprintf(xmlout,   "      </Volume>\n");
-#ifdef CURRENTSTRUCT
-  if(notes)
-    fprintf(xmlout, "      <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-  movie->volume = movie->volume >> 8;
-#endif
-  /* Transformation matrix for video                            */
-  fprintf(xmlout,   "      <TransformationMatrix>\n");
-  if(notes) {
-    fprintf(xmlout, "      <!-- 3 x 3 Video Transformation Matrix {a,b,u,c,d,v,x,y,w}.  Required: u=0, v=0, w=1 -->\n");
-    fprintf(xmlout, "      <!-- Maps decompressed point (p,q) to rendered point (ap + cq + x, bp + dq + y) -->\n");
-    fprintf(xmlout, "      <!-- Stored as Fixed Point Hex: all are binary 16.16, except u,v,w are 2.30 -->\n");
-    fprintf(xmlout, "      <!-- Unity = 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 -->\n");
-  }
-  fprintf(xmlout,   "        <TMa>0x%08x</TMa>\n", movie->trans_matrix[0]);    
-  fprintf(xmlout,   "        <TMb>0x%08x</TMb>\n", movie->trans_matrix[1]);    
-  fprintf(xmlout,   "        <TMu>0x%08x</TMu>\n", movie->trans_matrix[2]);    
-  fprintf(xmlout,   "        <TMc>0x%08x</TMc>\n", movie->trans_matrix[3]);    
-  fprintf(xmlout,   "        <TMd>0x%08x</TMd>\n", movie->trans_matrix[4]);    
-  fprintf(xmlout,   "        <TMv>0x%08x</TMv>\n", movie->trans_matrix[5]);    
-  fprintf(xmlout,   "        <TMx>0x%08x</TMx>\n", movie->trans_matrix[6]);    
-  fprintf(xmlout,   "        <TMy>0x%08x</TMy>\n", movie->trans_matrix[7]);    
-  fprintf(xmlout,   "        <TMw>0x%08x</TMw>\n", movie->trans_matrix[8]);
-  fprintf(xmlout,   "      </TransformationMatrix>\n");
-  fprintf(xmlout,   "    </MovieHeader>\n");
-  
-  fprintf(xmlout,   "    <Statistics>\n");
-  fprintf(xmlout,   "      <TracksFound>\n");
-  fprintf(xmlout,   "        <Video>%d</Video>\n", movie->num_vtk);
-  fprintf(xmlout,   "        <Audio>%d</Audio>\n", movie->num_stk);
-  fprintf(xmlout,   "        <Hint>%d</Hint>\n", movie->num_htk);
-  if(notes)
-    fprintf(xmlout, "        <!-- Hint tracks for streaming video are not part of MJ2, but are a defined extension. -->\n");
-  /* See Part 3 Amend 2 Section 4.2 for relation of MJ2 to Part 12 Sections 7 and 10 hints */
-  fprintf(xmlout,   "      </TracksFound>\n");
-  fprintf(xmlout,   "    </Statistics>\n");
-  /* Idea for the future:  It would be possible to add code to verify that the file values:
-    1) are legal and self-consistent
-	2) comply with particular JP2 and/or MJ2 profiles.
-	This could be reported here as additional XML elements */
-
-  // Find first video track 
-  tnum = 0;
-  while (movie->tk[tnum].track_type != 0)
-    tnum ++;
-
-  track = &(movie->tk[tnum]);
-  // For now, output info on first video track
-  xml_write_trak(file, xmlout, track, tnum, sampleframe, event_mgr);
-
-  // to come:                <MovieExtends mvek> // possibly not in Simple Profile
-  xml_write_moov_udta(xmlout, movie); /* NO OP so far */ /* <UserDataBox udta> contains <CopyrightBox cprt> */
-  fprintf(xmlout,   "  </MovieBox>\n");
-  return 0;
-}
-
-/* --------------- */
-
-void uint_to_chars(unsigned int value, char* buf)
-{
-	/* buf is at least char[5] */
-    int i;
-    for (i = 3; i >= 0; i--)
-    {
-        buf[i] = (value & 0x000000ff);
-        value = (value >> 8);
-    }
-	buf[4] = '\0'; /* Precautionary */
-}
-
-/* ------------- */
-
-/* WINDOWS SPECIFIC */
-
-void UnixTimeToFileTime(time_t t, LPFILETIME pft)
-{
-  /* Windows specific.  From MS Q167296 */
-  /* 'time_t' represents seconds since midnight January 1, 1970 UTC (coordinated universal time). */
-  /* 64-bit FILETIME structure represents the number of 100-nanosecond intervals since January 1, 1601 UTC (coordinate universal time). */
-  LONGLONG ll; /* LONGLONG is a 64-bit value. */
-  ll = Int32x32To64(t, 10000000) + 116444736000000000;
-  pft->dwLowDateTime = (DWORD)ll;
-  /* pft->dwLowDateTime = (DWORD)(0x00000000ffffffff & ll); */
-  pft->dwHighDateTime = (DWORD)(ll >> 32);
-} 
-// Once the UNIX time is converted to a FILETIME structure,
-// other Win32 time formats can be easily obtained by using Win32 functions such
-// as FileTimeToSystemTime() and FileTimeToDosDateTime().
-
-/* ------------- */
-
-void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
-{
-  /* Windows specific */
-  FILETIME ft;
-  UnixTimeToFileTime(t, &ft);
-  FileTimeToLocalFileTime( &ft, &ft ); /* Adjust from UTC to local time zone */
-  FileTimeToSystemTime(&ft, pst);
-}
-
-/* ------------- */
-
-void xml_time_out(FILE* xmlout, time_t t)
-{
-  /* Windows specific */
-  SYSTEMTIME st;
-  char szLocalDate[255], szLocalTime[255];
-  UnixTimeToSystemTime( t, &st );
-  GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szLocalDate, 255 );
-  GetTimeFormat( LOCALE_USER_DEFAULT, 0, &st, NULL, szLocalTime, 255 );
-  fprintf(xmlout, "%s %s", szLocalDate, szLocalTime ); 
-}
-
-/* END WINDOWS SPECIFIC */
-
-/* ------------- */
-
-void xml_write_moov_udta(FILE* xmlout, opj_mj2_t * movie) {
-  /* Compare with xml_write_udta */
-#ifdef NOTYET
-  /* NO-OP so far.  Optional UserData 'udta' (zero or one in moov or each trak)
-     can contain multiple Copyright 'cprt' with different language codes */
-  /* There may be nested non-standard boxes within udta */
-  IMAGINE movie->udta, movie->copyright_count, movie->copyright_language[i] (array of 16bit ints), movie->copyright_notice[i] (array of buffers)
-  PROBABLY ALSO NEED movie->udta_len or special handler for non-standard boxes
-  char buf[5];
-  int i;
-
-  if(movie->udta != 1)
-	  return; /* Not present */
-
-  fprintf(xmlout,    "    <UserData BoxType=\"udta\">\n");
-  for(i = 0; i < movie->copyright_count; i++) {
-    fprintf(xmlout,  "      <Copyright BoxType=\"cprt\"> Instance=\"%d\">\n", i+1);
-    int16_to_3packedchars((short int)movie->copyright_languages[i], buf);
-    fprintf(xmlout,  "        <Language>%s</Language>\n", buf);    /* 3 chars */
-    fprintf(xmlout,  "        <Notice>%s</Notice>\n",movie->copyright_notices[i]);
-    fprintf(xmlout,  "      </Copyright>\n", i+1);
-  }
-  /* TO DO: Non-standard boxes */
-  fprintf(xmlout,    "    </UserData>\n");
-#endif
-}
-
-void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie) {
-#ifdef NOTYET
-  /* NO-OP so far.  There can be zero or more instances of free and/or skip
-     at the top level of the file.  This may be a place where the user squirrel's metadata.
-	 Let's assume unstructured, and do a dump */
-  IMAGINE movie->free_and_skip, movie->free_and_skip_count, movie->free_and_skip_content[i] (array of buffers),
-	  movie->free_and_skip_len[i] (array of ints), movie->is_skip[i] (array of BOOL)
-  int i;
-
-  if(movie->free_and_skip != 1)
-	  return; /* Not present */
-
-  for(i = 0; i < movie->free_and_skip_count; i++) {
-    if(movie->is_skip[i])
-      fprintf(xmlout,    "  <Skip BoxType=\"skip\">\n");
-	else
-      fprintf(xmlout,    "  <Free BoxType=\"free\">\n");
-
-    xml_out_dump_hex_and_ascii(xmlout, movie->free_and_skip_contents[i], movie->free_and_skip_len[i]);
-
-    if(movie->is_skip[i])
-      fprintf(xmlout,    "  </Skip>\n");
-	else
-      fprintf(xmlout,    "  </Free>\n");
-  }
-#endif
-}
-
-void xml_write_uuid(FILE* xmlout, opj_mj2_t * movie) {
-/* Univeral Unique IDs of 16 bytes.  */
-#ifdef NOTYET
-  /* NO-OP so far.  There can be zero or more instances of private uuid boxes in a file.
-     This function supports the top level of the file, but uuid may be elsewhere [not yet supported].
-	 This may be a place where the user squirrel's metadata.  Let's assume unstructured, and do a dump */
-  IMAGINE movie->uuid, movie->uuid_count, movie->uuid_content[i] (array of buffers),
-	  movie->uuid_len[i] (array of ints), movie->uuid_type[i] (array of 17-byte (16+null termination) buffers)
-  int i;
-
-  if(movie->uuid != 1)
-	  return; /* Not present */
-
-  for(i = 0; i < movie->uuid_count; i++) {
-    fprintf(xmlout,    "  <PrivateExtension BoxType=\"uuid\" UUID=\"%s\">\n", movie->uuid_type[i]);
-	// See Part III section 5.2.1, 6.1, 6.2
-    xml_out_dump_hex_and_ascii(xmlout, movie->uuid_contents[i], movie->uuid_len[i]);
-    fprintf(xmlout,    "  </PrivateExtension>\n");
-  }
-#endif
-}
-
-/* ------------- */
-
-void xml_write_trak(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum, unsigned int sampleframe, opj_event_mgr_t *event_mgr)
-{
-  fprintf(xmlout,    "    <Track BoxType=\"trak\" Instance=\"%d\">\n", tnum);
-  xml_write_tkhd(file, xmlout, track, tnum);
-  // TO DO: TrackReferenceContainer 'tref'  just used in hint track
-  // TO DO: EditListContainer 'edts', contains EditList 'elst' with media-time, segment-duration, media-rate
-  xml_write_mdia(file, xmlout, track, tnum);
-  xml_write_udta(file, xmlout, track, tnum); // NO-OP so far.  Optional UserData 'udta', can contain multiple Copyright 'cprt'
-
-  if(track->track_type==0) { /* Only do for visual track */
-	/* sampleframe is from user option -f.  1 = first frame */
-    /* sampleframe of 0 is a user requests: no jp2 header */
-	/* Treat out-of-bounds values in the same way */
-	if(sampleframe > 0 && sampleframe <= track->num_samples) 
-    {
-      mj2_sample_t *sample;
-      unsigned int snum;
-
-      snum = sampleframe-1;
-      // Someday maybe do a smart range scan... for (snum=0; snum < track->num_samples; snum++){
-      //  fprintf(stdout,"Frame %d: ",snum+1);
-      sample = &track->sample[snum];
-	  if(xml_out_frame(file, xmlout, sample, snum, event_mgr))
-	    return; /* Not great error handling here */
-    }
-  }
-  fprintf(xmlout,    "    </Track>\n");
-}
-
-/* ------------- */
-
-void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum)
-{
-  fprintf(xmlout,    "      <TrackHeader BoxType=\"tkhd\">\n");
-  if(notes) {
-    fprintf(xmlout,  "      <!-- Not shown here: CreationTime, ModificationTime, Duration. -->\n");
-    fprintf(xmlout,  "      <!-- These 3 fields are reported under MediaHeader below.   When reading these 3, -->\n");
-    fprintf(xmlout,  "      <!-- m2j_to_metadata currently doesn't distinguish between TrackHeader and MediaHeader source. -->\n");
-    fprintf(xmlout,  "      <!-- If both found, value read from MediaHeader is used. -->\n");
-  }
-  fprintf(xmlout,    "        <TrackID>%u</TrackID>\n", track->track_ID);
-  if(track->track_type==0) /* For visual track */
-  {
-    fprintf(xmlout,  "        <TrackLayer>%d</TrackLayer>\n", track->layer);
-    if(notes)
-      fprintf(xmlout,"        <!-- front-to-back ordering of video tracks. 0 = normal, -1 is closer, etc. -->\n");
-  }
-  if(track->track_type!=0) /* volume irrelevant for visual track */
-  {
-#ifdef CURRENTSTRUCT
-    track->volume = track->volume << 8;
-#endif
-    fprintf(xmlout,  "        <Volume>\n");
-	if(notes) {
-      fprintf(xmlout,"          <!-- Track audio volume stored as fixed-point binary 8.8 value. Decimal value is approximation. -->\n");
-      fprintf(xmlout,"          <!-- Full, normal (default) value is 0x0100 (1.0) -->\n");
-	}
-	if(raw)
-      fprintf(xmlout,"          <AsHex>0x%04x</AsHex>\n", track->volume);
-	if(derived)
-      fprintf(xmlout,"          <AsDecimal>%6.3f</AsDecimal>\n", (double)track->volume/(double)0x0100);
-    fprintf(xmlout,  "        </Volume>\n");
-#ifdef CURRENTSTRUCT
-  if(notes)
-    fprintf(xmlout,  "        <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-	track->volume = track->volume >> 8;
-#endif
-  }
-  if(track->track_type==0)
-  {
-    /* Transformation matrix for video                            */
-    fprintf(xmlout,  "        <TransformationMatrix>\n");
-	if(notes) {
-      fprintf(xmlout,"          <!-- Comments about matrix in MovieHeader apply here as well. -->\n");
-      fprintf(xmlout,"          <!-- This matrix is applied before MovieHeader one. -->\n");
-	}
-    fprintf(xmlout,  "          <TMa>0x%08x</TMa>\n", track->trans_matrix[0]);    
-    fprintf(xmlout,  "          <TMb>0x%08x</TMb>\n", track->trans_matrix[1]);    
-    fprintf(xmlout,  "          <TMu>0x%08x</TMu>\n", track->trans_matrix[2]);    
-    fprintf(xmlout,  "          <TMc>0x%08x</TMc>\n", track->trans_matrix[3]);    
-    fprintf(xmlout,  "          <TMd>0x%08x</TMd>\n", track->trans_matrix[4]);    
-    fprintf(xmlout,  "          <TMv>0x%08x</TMv>\n", track->trans_matrix[5]);    
-    fprintf(xmlout,  "          <TMx>0x%08x</TMx>\n", track->trans_matrix[6]);    
-    fprintf(xmlout,  "          <TMy>0x%08x</TMy>\n", track->trans_matrix[7]);    
-    fprintf(xmlout,  "          <TMw>0x%08x</TMw>\n", track->trans_matrix[8]);
-    fprintf(xmlout,  "        </TransformationMatrix>\n");
-  }
-#ifdef CURRENTSTRUCT
-  track->w = track->w << 16;
-  track->h = track->h << 16;
-#endif
-  if(notes) {
-    fprintf(xmlout,  "        <!-- Width and Height in pixels are for the presentation; frames will be scaled to this. -->\n");
-    fprintf(xmlout,  "        <!-- Both stored as fixed-point binary 16.16 values. Decimal values are approximations. -->\n");
-  }
-  fprintf(xmlout,    "        <Width>\n");
-  if(raw)
-    fprintf(xmlout,  "          <AsHex>0x%08x</AsHex>\n", track->w);
-  if(derived)
-    fprintf(xmlout,  "          <AsDecimal>%12.6f</AsDecimal>\n", (double)track->w/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-  fprintf(xmlout,    "        </Width>\n");
-  fprintf(xmlout,    "        <Height>\n");
-  if(raw)
-    fprintf(xmlout,  "          <AsHex>0x%08x</AsHex>\n", track->h);
-  if(derived)
-    fprintf(xmlout,  "          <AsDecimal>%12.6f</AsDecimal>\n", (double)track->h/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-  fprintf(xmlout,    "        </Height>\n");
-#ifdef CURRENTSTRUCT
-  if(notes) {
-    fprintf(xmlout,  "        <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-    fprintf(xmlout,  "        <!-- Also, width and height values shown here will actually be those read from track's <VisualSampleEntry> if given. -->\n");
-  }
-  track->w = track->w >> 16;
-  track->h = track->h >> 16;
-#endif
-  fprintf(xmlout,    "      </TrackHeader>\n");
-}
-
-/* ------------- */
-
-void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum) {
-  /* NO-OP so far.  Optional UserData 'udta' (zero or one in moov or each trak)
-     can contain multiple Copyright 'cprt' with different language codes */
-  /* There may be nested non-standard boxes within udta */
-#ifdef NOTYET
-  IMAGINE track->udta, track->copyright_count, track->copyright_language[i] (array of 16bit ints), track->copyright_notice[i] (array of buffers)
-  PROBABLY ALSO NEED track->udta_len or special handler for non-standard boxes
-  char buf[5];
-  int i;
-
-  if(track->udta != 1)
-	  return; /* Not present */
-
-  fprintf(xmlout,    "      <UserData BoxType=\"udta\">\n");
-  for(i = 0; i < track->copyright_count; i++) {
-    fprintf(xmlout,  "        <Copyright BoxType=\"cprt\"> Instance=\"%d\">\n", i+1);
-    int16_to_3packedchars((short int)track->copyright_languages[i], buf);
-    fprintf(xmlout,  "          <Language>%s</Language>\n", buf);    /* 3 chars */
-    fprintf(xmlout,  "          <Notice>%s</Notice>\n",track->copyright_notices[i]);
-    fprintf(xmlout,  "        </Copyright>\n", i+1);
-  }
-  /* TO DO: Non-standard boxes */
-  fprintf(xmlout,    "      </UserData>\n");
-#endif
-}
-
-/* ------------- */
-
-void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum)
-{
-  char buf[5];
-  int i, k;
-  buf[4] = '\0';
-
-  fprintf(xmlout,    "      <Media BoxType=\"mdia\">\n");
-  fprintf(xmlout,    "        <MediaHeader BoxType=\"mdhd\">\n");
-  fprintf(xmlout,    "          <CreationTime>\n");
-  if(raw)
-    fprintf(xmlout,  "            <InSeconds>%u</InSeconds>\n", track->creation_time);
-  if(notes)
-    fprintf(xmlout,  "            <!-- Seconds since start of Jan. 1, 1904 UTC (Greenwich) -->\n");
-  /*  2082844800 = seconds between 1/1/04 and 1/1/70 */
-  /* There's still a time zone offset problem not solved... but spec is ambigous as to whether stored time
-     should be local or UTC */
-  if(derived) {
-    fprintf(xmlout,  "            <AsLocalTime>"); 
-                                xml_time_out(xmlout, track->creation_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,    "          </CreationTime>\n");
-  fprintf(xmlout,    "          <ModificationTime>\n");
-  if(raw)
-    fprintf(xmlout,  "            <InSeconds>%u</InSeconds>\n", track->modification_time);
-  if(derived) {
-    fprintf(xmlout,  "            <AsLocalTime>"); 
-                                xml_time_out(xmlout, track->modification_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,    "          </ModificationTime>\n");
-  fprintf(xmlout,    "          <Timescale>%d</Timescale>\n", track->timescale);
-  if(notes)
-    fprintf(xmlout,  "          <!-- Timescale defines time units in one second -->\n");
-  fprintf(xmlout,    "          <Duration>\n");
-  if(raw)
-    fprintf(xmlout,  "            <InTimeUnits>%u</InTimeUnits>\n", track->duration);
-  if(derived)
-    fprintf(xmlout,  "            <InSeconds>%12.3f</InSeconds>\n", (double)track->duration/(double)track->timescale);    // Make this double later to get fractional seconds
-  fprintf(xmlout,    "          </Duration>\n");
-  int16_to_3packedchars((short int)track->language, buf);
-  fprintf(xmlout,    "          <Language>%s</Language>\n", buf);    /* 3 chars */
-  fprintf(xmlout,    "        </MediaHeader>\n");
-  fprintf(xmlout,    "        <HandlerReference BoxType=\"hdlr\">\n");
-  switch(track->track_type)
-  {
-  case 0:
-    fprintf(xmlout,  "          <HandlerType Code=\"vide\">video media track</HandlerType>\n"); break;
-  case 1:
-    fprintf(xmlout,  "          <HandlerType Code=\"soun\">Sound</HandlerType>\n"); break;
-  case 2:
-    fprintf(xmlout,  "          <HandlerType Code=\"hint\">Hint</HandlerType>\n"); break;
-  }
-  if(notes) {
-    fprintf(xmlout,  "          <!-- String value shown is not actually read from file. -->\n");
-    fprintf(xmlout,  "          <!-- Shown value is one used for our encode. -->\n");
-  }
-  fprintf(xmlout,    "        </HandlerReference>\n");
-  fprintf(xmlout,    "        <MediaInfoContainer BoxType=\"minf\">\n");
-  switch(track->track_type)
-  {
-  case 0:
-    fprintf(xmlout,  "          <VideoMediaHeader BoxType=\"vmhd\">\n");
-    fprintf(xmlout,  "            <GraphicsMode>0x%02x</GraphicsMode>\n", track->graphicsmode);
-	if(notes) {
-      fprintf(xmlout,"            <!-- Enumerated values of graphics mode: -->\n");
-      fprintf(xmlout,"            <!--  0x00 = copy (over existing image); -->\n");
-      fprintf(xmlout,"            <!--  0x24 = transparent; 'blue-screen' this image using opcolor; -->\n");
-      fprintf(xmlout,"            <!--  0x100 = alpha; alpha-blend this image -->\n");
-/*    fprintf(xmlout,"            <!--  0x101 = whitealpha; alpha-blend this image, which has been blended with white; -->\n"); This was evidently dropped upon amendment */
-      fprintf(xmlout,"            <!--  0x102 = pre-multiplied black alpha; image has been already been alpha-blended with black. -->\n");
-      fprintf(xmlout,"            <!--  0x110 = component alpha; blend alpha channel(s) and color channels individually. -->\n");
-	}
-    fprintf(xmlout,  "            <Opcolor>\n");
-    fprintf(xmlout,  "              <Red>0x%02x</Red>\n", track->opcolor[0]);
-    fprintf(xmlout,  "              <Green>0x%02x</Green>\n",track->opcolor[1]);
-    fprintf(xmlout,  "              <Blue>0x%02x</Blue>\n",track->opcolor[2]);
-    fprintf(xmlout,  "            </Opcolor>\n");
-    fprintf(xmlout,  "          </VideoMediaHeader>\n");
-    break;
-  case 1:
-    fprintf(xmlout,  "          <SoundMediaHeader BoxType=\"smhd\">\n");
-#ifdef CURRENTSTRUCT
-	track->balance = track->balance << 8;
-#endif
-    fprintf(xmlout,  "            <Balance>\n");
-	if(notes) {
-      fprintf(xmlout,"              <!-- Track audio balance fixes mono track in stereo space. -->\n");
-      fprintf(xmlout,"              <!-- Stored as fixed-point binary 8.8 value. Decimal value is approximation. -->\n");
-      fprintf(xmlout,"              <!-- 0.0 = center, -1.0 = full left, 1.0 = full right -->\n");
-	}
-	if(raw)
-      fprintf(xmlout,"              <AsHex>0x%04x</AsHex>\n", track->balance);
-    if(derived)
-	  fprintf(xmlout,"              <AsDecimal>%6.3f</AsDecimal>\n", (double)track->balance/(double)0x0100);
-    fprintf(xmlout,  "            </Balance>\n");
-#ifdef CURRENTSTRUCT
-    if(notes)
-	  fprintf(xmlout,"            <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-	track->balance = track->balance >> 8;
-#endif
-    fprintf(xmlout,  "          </SoundMediaHeader>\n");
-    break;
-  case 2:
-    fprintf(xmlout,  "          <HintMediaHeader BoxType=\"hmhd\">\n");
-    fprintf(xmlout,  "            <MaxPDU_Size>%d</MaxPDU_Size>\n", track->maxPDUsize);
-    if(notes)
-      fprintf(xmlout,"            <!-- Size in bytes of largest PDU in this hint stream. -->\n");
-    fprintf(xmlout,  "            <AvgPDU_Size>%d</AvgPDU_Size>\n", track->avgPDUsize);
-    if(notes)
-      fprintf(xmlout,"            <!-- Average size in bytes of a PDU over the entire presentation. -->\n");
-    fprintf(xmlout,  "            <MaxBitRate>%d</MaxBitRate>\n", track->maxbitrate);
-    if(notes)
-      fprintf(xmlout,"            <!-- Maximum rate in bits per second over any window of 1 second. -->\n");
-    fprintf(xmlout,  "            <AvgBitRate>%d</AvgBitRate>\n", track->avgbitrate);
-    if(notes)
-      fprintf(xmlout,"            <!-- Averate rate in bits per second over the entire presentation. -->\n");
-    fprintf(xmlout,  "            <SlidingAvgBit>%d</SlidingAvgBitRate>\n", track->slidingavgbitrate);
-    if(notes)
-      fprintf(xmlout,"            <!-- Maximum rate in bits per second over any window of one minute. -->\n");
-    fprintf(xmlout,  "          </HintMediaHeader>\n");
-    break;
-  }
-  fprintf(xmlout,    "          <DataInfo BoxType=\"dinf\">\n");
-  fprintf(xmlout,    "            <DataReference BoxType=\"dref\"  URL_Count=\"%d\" URN_Count=\"%d\">\n", track->num_url, track->num_urn); // table w. flags, URLs, URNs
-  // Data structure does not distinguish between single URL, single URN, or DREF table or URLs & URNs.
-  // We could infer those, but for now just present everything as a DREF table.
-  if(notes)
-    fprintf(xmlout,  "              <!-- No entries here mean that file is self-contained, as required by Simple Profile. -->\n");
-  for(k = 0; k < track->num_url; k++) {
-    fprintf(xmlout,  "            <DataEntryUrlBox BoxType=\"url[space]\">\n"); // table w. flags, URLs, URNs
-    if(notes)
-      fprintf(xmlout,"              <!-- Only the first 16 bytes of URL location are recorded in mj2_to_metadata data structure. -->\n");
-    for(i = 0; i < 4; i++) {
-      uint_to_chars(track->url[track->num_url].location[i], buf);
-    fprintf(xmlout,  "              <Location>%s</Location>\n");
-    }
-    fprintf(xmlout,  "            </DataEntryUrlBox>\n"); // table w. flags, URLs, URNs
-  }
-  for(k = 0; k < track->num_urn; k++) {
-    fprintf(xmlout,"            <DataEntryUrnBox BoxType=\"urn[space]\">\n"); // table w. flags, URLs, URNs
-    // Only the first 16 bytes are recorded in the data structure currently.
-    if(notes)
-      fprintf(xmlout,"              <!-- Only the first 16 bytes each of URN name and optional location are recorded in mj2_to_metadata data structure. -->\n");
-    fprintf(xmlout,  "              <Name>");
-    for(i = 0; i < 4; i++) {
-      uint_to_chars(track->urn[track->num_urn].name[i], buf);
-      fprintf(xmlout,"%s", buf);
-    }
-    fprintf(xmlout,  "</Name>\n");
-    fprintf(xmlout,  "              <Location>");
-    for(i = 0; i < 4; i++) {
-      uint_to_chars(track->urn[track->num_urn].location[i], buf);
-      fprintf(xmlout,"%s");
-    }
-    fprintf(xmlout,  "</Location>\n");
-    fprintf(xmlout,  "            </DataEntryUrnBox>\n");
-  }
-  fprintf(xmlout,    "            </DataReference>\n");
-  fprintf(xmlout,    "          </DataInfo>\n");
-
-  xml_write_stbl(file, xmlout, track, tnum); /* SampleTable */
-
-  fprintf(xmlout,    "        </MediaInfoContainer>\n");  
-  fprintf(xmlout,    "      </Media>\n");
-}
-
-/* ------------- */
-
-void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum)
-{
-  char buf[5], buf33[33];
-  int i, len;
-  buf[4] = '\0';
-
-  fprintf(xmlout,      "          <SampleTable BoxType=\"stbl\">\n");
-  if(notes)
-    fprintf(xmlout,    "            <!-- What follows are specific instances of generic SampleDescription BoxType=\"stsd\" -->\n");
-  switch(track->track_type)
-  {
-  case 0:
-    // There could be multiple instances of this, but "entry_count" is just a local at read-time.
-    // And it's used wrong, too, as count of just visual type, when it's really all 3 types.
-    // This is referred to as "smj2" within mj2.c
-    fprintf(xmlout,    "            <VisualSampleEntry BoxType=\"mjp2\">\n");
-	if(notes) {
-      fprintf(xmlout,  "            <!-- If multiple instances of this box, only first is shown here. -->\n");
-	  fprintf(xmlout,  "            <!-- Width and Height are in pixels.  Unlike the Track Header, there is no fractional part. -->\n");
-	  fprintf(xmlout,  "            <!-- In mj2_to_metadata implementation, the values are not represented separately from Track Header's values. -->\n");
-	}
-	/* No shifting required.  If CURRENTSTRUCT gets changed, then may need to revisit treatment of these */
-    fprintf(xmlout,    "              <WidthAsInteger>%d</WidthAsInteger>\n", track->w);
-    fprintf(xmlout,    "              <HeightAsInteger>%d</HeightAsInteger>\n", track->h);
-// Horizresolution and vertresolution don't require shifting, already stored right in CURRENTSTRUCT
-    if(notes) {
-      fprintf(xmlout,  "              <!-- Resolutions are in pixels per inch, for the highest-resolution component (typically luminance). -->\n");
-      fprintf(xmlout,  "              <!-- Both stored as fixed-point binary 16.16 values. Decimal values are approximations. -->\n");
-      fprintf(xmlout,  "              <!-- Typical value for both resolutions is 0x00480000  (72.0) -->\n");
-	}
-    fprintf(xmlout,    "              <HorizontalRes>\n");
-	if(raw)
-      fprintf(xmlout,  "                <AsHex>0x%08x</AsHex>\n", track->horizresolution);
-	if(derived)
-      fprintf(xmlout,  "                <AsDecimal>%12.6f</AsDecimal>\n", (double)track->horizresolution/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-    fprintf(xmlout,    "              </HorizontalRes>\n");
-    fprintf(xmlout,    "              <VerticalRes>\n");
-	if(raw)
-      fprintf(xmlout,  "                <AsHex>0x%08x</AsHex>\n", track->vertresolution);
-	if(derived)
-      fprintf(xmlout,  "                <AsDecimal>%12.6f</AsDecimal>\n", (double)track->vertresolution/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-    fprintf(xmlout,    "              </VerticalRes>\n");
-
-    buf33[0] = '\0';
-    for(i = 0; i < 8; i++) {
-      uint_to_chars((unsigned int)track->compressorname[i], buf);
-      strcat(buf33, buf); /* This loads up (4 * 8) + 1 chars, but trailing ones are usually junk */
-    }
-    len = (int)buf33[0]; /* First byte has string length in bytes.  There may be garbage beyond it. */
-    buf33[len+1] = '\0'; /* Suppress it */
-    fprintf(xmlout,    "              <CompressorName>%s</CompressorName>\n", buf33+1); /* Start beyond first byte */
-	if(notes) {
-      fprintf(xmlout,  "              <!-- Compressor name for debugging.  Standard restricts max length to 31 bytes. -->\n");
-      fprintf(xmlout,  "              <!-- Usually blank or \"Motion JPEG2000\" -->\n");
-	}
-    fprintf(xmlout,    "              <Depth>0x%02x</Depth>\n",track->depth);
-	if(notes) {
-      fprintf(xmlout,  "              <!-- Depth is: -->\n");
-      fprintf(xmlout,  "              <!--   0x20: alpha channels present (color or grayscale) -->\n");
-      fprintf(xmlout,  "              <!--   0x28: grayscale without alpha -->\n");
-      fprintf(xmlout,  "              <!--   0x18: color without alpha -->\n");
-	}
-
-    xml_out_frame_jp2h(xmlout, &(track->jp2_struct));  /* JP2 Header */
-    
-  /* Following subboxes are optional */
-    fprintf(xmlout,    "              <FieldCoding BoxType=\"fiel\">\n");
-    fprintf(xmlout,    "                <FieldCount>%d</FieldCount>\n", (unsigned int)track->fieldcount); /* uchar as 1 byte uint */
-    if(notes)
-      fprintf(xmlout,  "                <!-- Must be either 1 or 2 -->\n");
-    fprintf(xmlout,    "                <FieldOrder>%d</FieldOrder>\n", (unsigned int)track->fieldorder); /* uchar as 1 byte uint */
-	if(notes) {
-      fprintf(xmlout,  "                <!-- When FieldCount=2, FieldOrder means: -->\n");
-      fprintf(xmlout,  "                <!--   0: Field coding unknown -->\n");
-      fprintf(xmlout,  "                <!--   1: Field with topmost line is stored first in sample; fields are in temporal order -->\n");
-      fprintf(xmlout,  "                <!--   6: Field with topmost line is stored second in sample; fields are in temporal order -->\n");
-      fprintf(xmlout,  "                <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->\n");
-      fprintf(xmlout,  "                <!-- Current implementation doesn't retain whether box was actually present. -->\n");
-	}
-    fprintf(xmlout,    "              </FieldCoding>\n");
-
-    fprintf(xmlout,    "              <MJP2_Profile BoxType=\"jp2p\" Count=\"%d\">\n",track->num_br);
-    for (i = 0; i < track->num_br; i++) /* read routine stored in reverse order, so let's undo damage */
-    {
-      uint_to_chars(track->br[i], buf);
-      fprintf(xmlout,  "                <CompatibleBrand>%s</CompatibleBrand>\n", buf);    /*4 characters, each CLi */
-    }
-    fprintf(xmlout,    "              </MJP2_Profile>\n");
-
-    fprintf(xmlout,    "              <MJP2_Prefix BoxType=\"jp2x\" Count=\"%d\">\n",track->num_jp2x);
-    for (i = 0; i < track->num_jp2x; i++)
-    { // We'll probably need better formatting than this
-      fprintf(xmlout,  "                <Data>0x%02x</Data>\n", track->jp2xdata[i]);    /* Each entry is single byte */
-    }
-    fprintf(xmlout,    "              </MJP2_Prefix>\n");
-
-    fprintf(xmlout,    "              <MJP2_SubSampling BoxType=\"jsub\">\n"); /* These values are all 1 byte */
-    if(notes)
-	  fprintf(xmlout,  "              <!-- Typical subsample value is 2 for 4:2:0 -->\n");
-    fprintf(xmlout,    "                <HorizontalSub>%d</HorizontalSub>\n", track->hsub);
-    fprintf(xmlout,    "                <VerticalSub>%d</VerticalSub>\n", track->vsub);
-    fprintf(xmlout,    "                <HorizontalOffset>%d</HorizontalOffset>\n", track->hoff);
-    fprintf(xmlout,    "                <VerticalOffset>%d</VerticalOffset>\n", track->voff);
-	if(notes) {
-	  fprintf(xmlout,  "                <!-- Typical {horizontal, vertical} chroma offset values: -->\n");
-	  fprintf(xmlout,  "                <!-- 4:2:2 format (CCIR601, H.262, MPEG2, MPEG4, recom. Exif): {0, 0} -->\n");
-	  fprintf(xmlout,  "                <!-- 4:2:2 format (JFIF):                                      {1, 0} -->\n");
-	  fprintf(xmlout,  "                <!-- 4:2:0 format (H.262, MPEG2, MPEG4):                       {0, 1} -->\n");
-	  fprintf(xmlout,  "                <!-- 4:2:0 format (MPEG1, H.261, JFIF, recom. Exif):           {1, 1} -->\n");
-	}
-    fprintf(xmlout,    "              </MJP2_SubSampling>\n"); /* These values are all 1 byte */
-
-    fprintf(xmlout,    "              <MJP2_OriginalFormat BoxType=\"orfo\">\n"); /* Part III Appx. 2 */
-    fprintf(xmlout,    "                <OriginalFieldCount>%u</OriginalFieldCount>\n", (unsigned int)track->or_fieldcount); /* uchar as 1-byte uint */
-    if(notes)
-      fprintf(xmlout,  "                <!-- In original material before encoding.  Must be either 1 or 2 -->\n");
-    fprintf(xmlout,    "                <OriginalFieldOrder>%u</OriginalFieldOrder>\n", (unsigned int)track->or_fieldorder); /* uchar as 1-byte uint */
-	if(notes) {
-      fprintf(xmlout,  "                <!-- When FieldCount=2, FieldOrder means: -->\n");
-      fprintf(xmlout,  "                <!--   0: Field coding unknown -->\n");
-      fprintf(xmlout,  "                <!--   11: Topmost line came from the earlier field; -->\n");
-      fprintf(xmlout,  "                <!--   16:  Topmost line came form the later field. -->\n");
-      fprintf(xmlout,  "                <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->\n");
-      fprintf(xmlout,  "                <!-- Current implementation doesn't retain whether box was actually present. -->\n");
-	}
-    fprintf(xmlout,    "              </MJP2_OriginalFormat>\n");
-    fprintf(xmlout,    "            </VisualSampleEntry>\n");
-    break;
-  case 1: case 2:
-    if(notes)
-      fprintf(xmlout,  "            <!-- mj2_to_metadata's data structure doesn't record this currently. -->\n"); break;
-  }
-  fprintf(xmlout,      "            <TimeToSample BoxType=\"stts\">\n");  
-  fprintf(xmlout,      "              <SampleStatistics>\n");  
-  fprintf(xmlout,      "                <TotalSamples>%d</TotalSamples>\n", track->num_samples);
-  if(notes)
-    fprintf(xmlout,    "                <!-- For video, gives the total frames in the track, by summing all entries in the Sample Table -->\n");
-  fprintf(xmlout,      "              </SampleStatistics>\n"); 
-  fprintf(xmlout,      "              <SampleEntries EntryCount=\"%d\">\n", track->num_tts);
-  for (i = 0; i < track->num_tts; i++) {
-    fprintf(xmlout,    "                <Table Entry=\"%u\" SampleCount=\"%d\" SampleDelta=\"%u\" />\n",
-                                      i+1, track->tts[i].sample_count, track->tts[i].sample_delta);
-  }
-  fprintf(xmlout,      "              </SampleEntries>\n");
-  fprintf(xmlout,      "            </TimeToSample>\n");
-
-  fprintf(xmlout,      "            <SampleToChunk BoxType=\"stsc\" Count=\"%d\">\n", track->num_samplestochunk);
-  for (i = 0; i < track->num_samplestochunk; i++) {
-    fprintf(xmlout,    "              <FirstChunk>%u</FirstChunk>\n",track->sampletochunk[i].first_chunk); /* 4 bytes */
-    fprintf(xmlout,    "              <SamplesPerChunk>%u</SamplesPerChunk>\n",track->sampletochunk[i].samples_per_chunk); /* 4 bytes */
-    fprintf(xmlout,    "              <SampleDescrIndex>%u</SampleDescrIndex>\n",track->sampletochunk[i].sample_descr_idx); /* 4 bytes */
-  }
-  fprintf(xmlout,      "            </SampleToChunk>\n");
-  // After reading this info in, track->num_chunks is calculated and a decompressed table established internally.
-
-  fprintf(xmlout,      "            <SampleSize BoxType=\"stsz\">\n");
-  if(track->same_sample_size) {
-    // all values in track->sample[i].sample_size are equal.  Grab the first one.
-    fprintf(xmlout,    "              <Sample_Size>%u</Sample_Size>\n", track->sample[0].sample_size);
-	if(notes) {
-      fprintf(xmlout,  "              <!-- Non-zero value means all samples have that size. -->\n");
-	  fprintf(xmlout,  "              <!-- So <Sample_Count> (aka Entry_Count in std.) has no meaning, is suppressed from this output, and no table follows. -->\n");
-	}
-  } else {
-    fprintf(xmlout,    "              <Sample_Size>0</Sample_Size>\n");
-    if(notes)
-	  if(sampletables)
-        fprintf(xmlout,"              <!-- Zero value means samples have different sizes, given in table next of length Sample_Count (aka Entry_Count in std). -->\n");
-	  else
-        fprintf(xmlout,"              <!-- Zero value means samples have different sizes, given in table (not shown) of length Sample_Count (aka Entry_Count in std). -->\n");
-	fprintf(xmlout,    "              <Sample_Count>%u</Sample_Count>\n", track->num_samples);
-	if(sampletables)
-     for (i = 0; i < (int)track->num_samples; i++) {
-      fprintf(xmlout,  "              <EntrySize Num=\"%u\">%u</EntrySize>\n", i+1, track->sample[i].sample_size);
-     }
-  }  
-  fprintf(xmlout,      "            </SampleSize>\n");
-
-  fprintf(xmlout,      "            <ChunkOffset BoxType=\"stco\">\n");
-  // Structure not yet - Variant ChunkLargeOffset 'co64'
-  fprintf(xmlout,      "              <EntryCount>%u</EntryCount>\n", track->num_chunks);
-  if(notes) {
-    fprintf(xmlout,    "              <!-- For this implementation, EntryCount shown is one calculated during file read of <SampleToChunk> data. -->\n");
-    fprintf(xmlout,    "              <!-- Implementation will report failure during file read of <ChunkOffset> data if read entry-count disagrees. -->\n");
-  }
-  if(sampletables)
-    for (i = 0; i < (int)track->num_chunks; i++)
-      fprintf(xmlout,  "              <Chunk_Offset Num=\"%d\">%u</Chunk_Offset>\n", i+1, track->chunk[i].offset);
-  fprintf(xmlout,      "            </ChunkOffset>\n");
-
-  fprintf(xmlout,      "          </SampleTable>\n");
-}
-
-/* ------------- */
-
-int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int snum, opj_event_mgr_t *event_mgr)
-{
-	opj_dparameters_t parameters;	/* decompression parameters */
-  opj_image_t *img;
-  opj_cp_t *cp;
-  int i;
-  int numcomps;
-  unsigned char* frame_codestream;
-	opj_dinfo_t* dinfo = NULL;	/* handle to a decompressor */
-	opj_cio_t *cio = NULL;	
-	opj_j2k_t *j2k;
-
-	/* JPEG 2000 compressed image data */
-
-	/* get a decoder handle */
-	dinfo = opj_create_decompress(CODEC_J2K);
-
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)dinfo, event_mgr, stderr);
-
-	/* setup the decoder decoding parameters using the current image and user parameters */
-	parameters.cp_limit_decoding = DECODE_ALL_BUT_PACKETS;
-	opj_setup_decoder(dinfo, &parameters);	
-
-  frame_codestream = (unsigned char*) malloc (sample->sample_size-8); /* Skipping JP2C marker */
-  if(frame_codestream == NULL)
-	  return 1;
-
-  fseek(file,sample->offset+8,SEEK_SET);
-  fread(frame_codestream,sample->sample_size-8,1, file);  /* Assuming that jp and ftyp markers size do */
-
-	/* open a byte stream */
-	cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
-
-  /* Decode J2K to image: */
-	img = opj_decode(dinfo, cio);
-  if (!img) {
-		fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-		opj_destroy_decompress(dinfo);
-		opj_cio_close(cio);
-		return 1;
-	}
-
-	j2k = (opj_j2k_t*)dinfo->j2k_handle;
-	j2k_default_tcp = j2k->default_tcp;
-	cp = j2k->cp;
-
-  numcomps = img->numcomps;
-  /*  Alignments:        "      <       To help maintain xml pretty-printing */  
-  fprintf(xmlout,      "      <JP2_Frame Num=\"%d\">\n", snum+1);
-  fprintf(xmlout,      "        <MainHeader>\n");
-  /* There can be multiple codestreams; a particular image is entirely within a single codestream */
-  /* TO DO:  A frame can be represented by two I-guess-contigious codestreams if its interleaved. */
-  fprintf(xmlout,      "          <StartOfCodestream Marker=\"SOC\" />\n");
-  /* "cp" stands for "coding parameter"; "tcp" is tile coding parameters, "tccp" is tile-component coding parameters */
-  xml_out_frame_siz(xmlout, img, cp); /* reqd in main */
-  xml_out_frame_cod(xmlout, j2k_default_tcp); /* reqd in main */
-  xml_out_frame_coc(xmlout, j2k_default_tcp, numcomps); /* opt in main, at most 1 per component */
-  xml_out_frame_qcd(xmlout, j2k_default_tcp); /* reqd in main */
-  xml_out_frame_qcc(xmlout, j2k_default_tcp, numcomps);	/* opt in main, at most 1 per component */
-  xml_out_frame_rgn(xmlout, j2k_default_tcp, numcomps); /* opt, at most 1 per component */
-  xml_out_frame_poc(xmlout, j2k_default_tcp); /*  opt (but reqd in main or tile for any progression order changes) */
-  /* Next four get j2k_default_tcp passed globally: */
-#ifdef SUPPRESS_FOR_NOW
-  xml_out_frame_ppm(xmlout, cp); /* opt (but either PPM or PPT [distributed in tile headers] or codestream packet header reqd) */
-#endif
-  xml_out_frame_tlm(xmlout); /* NO-OP.  TLM NOT SAVED IN DATA STRUCTURE */ /* opt */
-  xml_out_frame_plm(xmlout); /* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE */ /* opt in main; can be used in conjunction with PLT */
-  xml_out_frame_crg(xmlout); /* NO-OP.  CRG NOT SAVED IN DATA STRUCTURE */ /* opt in main; */
-  xml_out_frame_com(xmlout, j2k_default_tcp); /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */ /* opt in main; */
-
-  fprintf(xmlout,      "        </MainHeader>\n");
-
-  /*	TO DO: all the tile headers (sigh)  */
-  fprintf(xmlout,      "        <TilePartHeaders Count=\"%d\">\n", cp->tileno_size);		/* size of the vector tileno */
-  for(i = 0; i < cp->tileno_size; i++) { /* I think cp->tileno_size will be same number as (cp->tw * cp->th) or as global j2k_curtileno */
-    // Standard seems to use zero-based # for tile-part.
-    fprintf(xmlout,    "          <TilePartHeader Num=\"%d\" ID=\"%d\">\n", i, cp->tileno[i]);			/* ID number of the tiles present in the codestream */
-    fprintf(xmlout,    "            <StartOfTilePart Marker=\"SOT\" />\n");
-	/* All markers in tile-part headers (between SOT and SOD) are optional, unless structure requires. */
-    if(i == 0) {
-      xml_out_frame_cod(xmlout, &(cp->tcps[i])); /* No more than 1 per tile */
-      xml_out_frame_coc(xmlout, &(cp->tcps[i]), numcomps); /* No more than 1 per component */
-      xml_out_frame_qcd(xmlout, &(cp->tcps[i])); /* No more than 1 per tile */
-      xml_out_frame_qcc(xmlout, &(cp->tcps[i]), numcomps);	/* No more than 1 per component */
-      xml_out_frame_rgn(xmlout, &(cp->tcps[i]), numcomps); /* No more than 1 per component */
-    }
-    xml_out_frame_poc(xmlout, &(cp->tcps[i])); /* Reqd only if any progression order changes different from main POC */
-#ifdef SUPPRESS_FOR_NOW
-    xml_out_frame_ppt(xmlout, &(cp->tcps[i])); /* Either PPT [distributed in tile headers] or PPM or codestream packet header reqd. */
-#endif
-    xml_out_frame_plt(xmlout, &(cp->tcps[i])); /* NO-OP.  PLT NOT SAVED IN DATA STRUCTURE */ /* Can be used in conjunction with main's PLM */
-    xml_out_frame_com(xmlout, &(cp->tcps[i])); /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */
-    /* opj_tcp_t * cp->tcps; "tile coding parameters" */
-    /* Maybe not: fprintf(xmlout,  "        <>%d</>, cp->matrice[i];			*/ /* Fixed layer    */
-    fprintf(xmlout,    "            <StartOfData Marker=\"SOD\" />\n");
-    if(notes)
-      fprintf(xmlout,  "            <!-- Tile-part bitstream, not shown, follows tile-part header and SOD marker. -->\n");
-    fprintf(xmlout,    "          </TilePartHeader>\n");
-  }
-  fprintf(xmlout,      "        </TilePartHeaders>\n");		/* size of the vector tileno */
-
-#ifdef NOTYET
-  IMAGINE the cp object has data to support the following... but we could use an new different data structure instead
-  /* I'm unclear if the span of the original fread(frame_codestream...) included the following items if they're trailing. */
-  /* ALSO TO DO, BUT DATA STRUCTURE DOESN'T HANDLE YET: boxes (anywhere in file except before the Filetype box): */
-  xml_out_frame_jp2i(xmlout, &cp); /* IntellectualProperty 'jp2i' (no restrictions on location) */
-  xml_out_frame_xml(xmlout, &cp); /* XML 'xml\040' (0x786d6c20).  Can appear multiply */
-  xml_out_frame_uuid(xmlout, &cp); /* UUID 'uuid' (top level only) */
-  xml_out_frame_uinf(xmlout, &cp); /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */
-#endif
-
-  fprintf(xmlout,      "      </JP2_Frame>\n");
-
-  /* Extra commentary: */
-  if(notes) {
-    fprintf(xmlout,    "      <!-- Given the number and size of components, mj2_to_frame would try to convert this -->\n");
-    if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2) 
-      && (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1)) 
-      || (img->numcomps == 1)) {
-      fprintf(xmlout,  "      <!-- file to a YUV movie in the normal manner. -->\n");
-    }
-    else if ((img->numcomps == 3) && 
-      (img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
-	  (img->comps[2].dx == 1))  {// If YUV 4:4:4 input --> to bmp
-	  fprintf(xmlout,  "      <!-- YUV 4:4:4 file to a series of .bmp files. -->\n");
-    }
-    else {
-	  fprintf(xmlout,  "      <!-- file whose image component dimension are unknown, to a series of .j2k files. -->\n");
-    }
-  }
-
-	opj_destroy_decompress(dinfo);
-	opj_cio_close(cio);
-  free(frame_codestream);
-
-  return 0;
-}
-
-/* ------------- */
-
-void int16_to_3packedchars(short int value, char* buf)
-{
-    /* This is to retrieve the 3-letter ASCII language code */
-    /* Each char is packed into 5 bits, as difference from 0x60 */
-    int i;
-    for (i = 2; i >= 0; i--)
-    {
-        buf[i] = (value & 0x001f) + 0x60;
-        value = (value >>5);
-    }
-    buf[3] = '\0';
-}
-
-/* ------------- */
-
-void xml_out_frame_siz(FILE* xmlout, opj_image_t *img, opj_cp_t *cp)
-{
-  opj_image_comp_t *comp;
-  int i;
-
-  fprintf(xmlout,    "          <ImageAndFileSize Marker=\"SIZ\">\n");
-  // This is similar to j2k.c's j2k_dump_image.
-  // Not of interest: Lsiz, Rsiz
-  fprintf(xmlout,    "            <Xsiz>%d</Xsiz>\n", img->x1);
-  fprintf(xmlout,    "            <Ysiz>%d</Ysiz>\n", img->y1);
-  if(notes)
-    fprintf(xmlout,  "            <!-- Xsiz, Ysiz is the size of the reference grid. -->\n");
-  fprintf(xmlout,    "            <XOsiz>%d</XOsiz>\n", img->x0);
-  fprintf(xmlout,    "            <YOsiz>%d</YOsiz>\n", img->y0);
-  if(notes)
-    fprintf(xmlout,  "            <!-- XOsiz, YOsiz are offsets from grid origin to image origin. -->\n");
-  fprintf(xmlout,    "            <XTsiz>%d</XTsiz>\n", cp->tdx);
-  fprintf(xmlout,    "            <YTsiz>%d</YTsiz>\n", cp->tdy);
-  if(notes)
-    fprintf(xmlout,  "            <!-- XTsiz, YTsiz is the size of one tile with respect to the grid. -->\n");
-  fprintf(xmlout,    "            <XTOsiz>%d</XTOsiz>\n", cp->tx0);
-  fprintf(xmlout,    "            <YTOsiz>%d</YTOsiz>\n", cp->ty0);
-  if(notes)
-    fprintf(xmlout,  "            <!-- XTOsiz, YTOsiz are offsets from grid origin to first tile origin. -->\n");
-  fprintf(xmlout,    "            <Csiz>%d</Csiz>\n", img->numcomps);
-  if(notes) {
-    fprintf(xmlout,  "            <!-- Csiz is the number of components in the image. -->\n");
-    fprintf(xmlout,  "            <!-- For image components next: -->\n");
-    fprintf(xmlout,  "            <!--   XRsiz, YRsiz denote pixel-sample-spacing on the grid, per Part I Annex B. -->\n");
-    //fprintf(xmlout,"            <!--   XO, YO is offset of the component compared to the whole image. -->\n");
-    fprintf(xmlout,  "            <!--   Bits per pixel (bpp) is the pixel depth. -->\n");
-    fprintf(xmlout,  "            <!--   WidthOfData and HeightOfData are calculated values, e.g.: w = roundup((Xsiz - XOsiz)/ XRsiz) -->\n");
-  }
-
-  for (i = 0; i < img->numcomps; i++) {/* image-components */
-    comp = &(img->comps[i]);
-    fprintf(xmlout,  "            <Component Num=\"%d\">\n", i+1);
-    fprintf(xmlout,  "              <Ssiz>\n");
-	if(raw)
-      fprintf(xmlout,"                <AsHex>0x%02x</AsHex>\n", (comp->sgnd << 7) & (comp->prec - 1));
-	if(derived) {
-      fprintf(xmlout,"                <Signed>%d</Signed>\n", comp->sgnd);
-      fprintf(xmlout,"                <PrecisionInBits>%d</PrecisionInBits>\n", comp->prec);
-	}
-    fprintf(xmlout,  "              </Ssiz>\n");
-    fprintf(xmlout,  "              <XRsiz>%d</XRsiz>\n", comp->dx);
-    fprintf(xmlout,  "              <YRsiz>%d</YRsiz>\n", comp->dy);
-    fprintf(xmlout,  "              <WidthOfData>%d</WidthOfData>\n", comp->w);
-    fprintf(xmlout,  "              <HeightOfData>%d</HeightOfData>\n", comp->h);
-    /* Rest of these aren't calculated when SIZ is read:
-    fprintf(xmlout,  "              <XO>%d</XO>\n", comp->x0);
-    fprintf(xmlout,  "              <YO>%d</YO>\n", comp->y0);
-	if(notes)
-	  fprintf(xmlout,"              <!--  XO, YO is offset of the component compared to the whole image. -->\n");
-    fprintf(xmlout,  "              <BitsPerPixel>%d</BitsPerPixel>\n", comp->bpp);
-    fprintf(xmlout,  "              <NumberOfDecodedResolution>%d</NumberOfDecodedResolution>\n", comp->resno_decoded); */
-    // SUPPRESS: n/a to mj2_to_metadata.  fprintf(xmlout,"        <Factor>%d</Factor\n", comp->factor);
-    /* factor = number of division by 2 of the out image  compare to the original size of image */
-    // TO DO comp->data:  int *data;			/* image-component data      */
-
-    fprintf(xmlout,  "            </Component>\n");
-  }
-  fprintf(xmlout,    "          </ImageAndFileSize>\n");
-}
-
-/* ------------- */
-
-void xml_out_frame_cod(FILE* xmlout, opj_tcp_t *tcp)
-{
-/* Could be called with tcp = &j2k_default_tcp;
-/* Or, for tile-part header, with &j2k_cp->tcps[j2k_curtileno]
-/*  Alignment for main:"          < < < <   To help maintain xml pretty-printing */  
-/*  Alignment for tile:"            < < <   To help maintain xml pretty-printing */  
-  opj_tccp_t *tccp;
-  int i;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-  tccp = &(tcp->tccps[0]);
-
-  fprintf(xmlout,      "%s<CodingStyleDefault Marker=\"COD\">\n",s); /* Required in main header */
-  /* Not retained or of interest: Lcod */
-  fprintf(xmlout,      "%s  <Scod>0x%02x</Scod>\n", s, tcp->csty); /* 1 byte */
-  if(notes) {
-    fprintf(xmlout,    "%s  <!-- For Scod, specific bits mean (where bit 0 is lowest or rightmost): -->\n",s);
-    fprintf(xmlout,    "%s  <!-- bit 0: Defines entropy coder precincts -->\n",s);
-    fprintf(xmlout,    "%s  <!--        0 = (PPx=15, PPy=15); 1 = precincts defined below. -->\n",s);
-    fprintf(xmlout,    "%s  <!-- bit 1: 1 = SOP marker may be used; 0 = not. -->\n",s);
-    fprintf(xmlout,    "%s  <!-- bit 2: 1 = EPH marker may be used; 0 = not. -->\n",s);
-  }
-  fprintf(xmlout,      "%s  <SGcod>\n",s);
-  fprintf(xmlout,      "%s    <ProgressionOrder>%d</ProgressionOrder>\n", s, tcp->prg); /* 1 byte, SGcod (A) */
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- Defined Progression Order Values are: -->\n",s);
-    fprintf(xmlout,    "%s    <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->\n",s);
-    fprintf(xmlout,    "%s    <!-- where L = \"layer\", R = \"resolution level\", C = \"component\", P = \"position\". -->\n",s);
-  }
-  fprintf(xmlout,      "%s    <NumberOfLayers>%d</NumberOfLayers>\n", s, tcp->numlayers); /* 2 bytes, SGcod (B) */
-  fprintf(xmlout,      "%s    <MultipleComponentTransformation>%d</MultipleComponentTransformation>\n", s, tcp->mct); /* 1 byte, SGcod (C).  More or less boolean */
-  if(notes)
-    fprintf(xmlout,    "%s    <!-- For MCT, 0 = none, 1 = transform first 3 components for efficiency, per Part I Annex G -->\n",s);
-  fprintf(xmlout,      "%s  </SGcod>\n",s);
-  /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-  fprintf(xmlout,      "%s  <SPcod>\n",s);
-  /* Internal data structure tccp defines separate defaults for each component, but they all get the same values */
-  /* So we only have to report the first component's values here. */
-  /* Compare j2k_read_cox(...) */
-  fprintf(xmlout,      "%s    <NumberOfDecompositionLevels>%d</NumberOfDecompositionLevels>\n", s, tccp->numresolutions - 1);	/* 1 byte, SPcox (D) */
-  fprintf(xmlout,      "%s    <CodeblockWidth>%d</CodeblockWidth>\n", s, tccp->cblkw - 2);	/* 1 byte, SPcox (E) */
-  fprintf(xmlout,      "%s    <CodeblockHeight>%d</CodeblockHeight>\n", s, tccp->cblkh - 2);	/* 1 byte, SPcox (F) */
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- CBW and CBH are non-negative, and summed cannot exceed 8 -->\n",s);
-    fprintf(xmlout,    "%s    <!-- Codeblock dimension is 2^(value + 2) -->\n", s);
-  }
-  fprintf(xmlout,      "%s    <CodeblockStyle>0x%02x</CodeblockStyle>\n", s, tccp->cblksty);	/* 1 byte, SPcox (G) */
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- For CodeblockStyle, bits mean (with value 1=feature on, 0=off): -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 0: Selective arithmetic coding bypass. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 1: Reset context probabilities on coding pass boundaries. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 2: Termination on each coding pass. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 3: Vertically causal context. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 4: Predictable termination. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 5: Segmentation symbols are used. -->\n",s);
-  }
-  fprintf(xmlout,      "%s    <Transformation>%d</Transformation>\n", s, tccp->qmfbid);	/* 1 byte, SPcox (H) */
-  if(notes)
-    fprintf(xmlout,    "%s    <!-- For Transformation, 0=\"9-7 irreversible filter\", 1=\"5-3 reversible filter\" -->\n",s);
-  if (tccp->csty & J2K_CP_CSTY_PRT) {
-    fprintf(xmlout,    "%s    <PrecinctSize>\n",s); /* 1 byte, SPcox (I_i) */
-    if(notes)
-      fprintf(xmlout,  "%s    <!-- These are size exponents PPx and PPy. May be zero only for first level (aka N(L)LL subband)-->\n",s);
-    for (i = 0; i < tccp->numresolutions; i++) {	
-      fprintf(xmlout,  "%s      <PrecinctHeightAndWidth  ResolutionLevel=\"%d\">\n", s, i);
-	  if(raw)
-        fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->prch[i] << 4) | tccp->prcw[i]);	/* packed into 1 byte, SPcox (G) */
-	  if(derived) {
-        fprintf(xmlout,"%s        <WidthAsDecimal>%d</WidthAsDecimal>\n", s, tccp->prcw[i]);
-        fprintf(xmlout,"%s        <HeightAsDecimal>%d</HeightAsDecimal>\n", s, tccp->prch[i]);
-	  }
-      fprintf(xmlout,  "%s      </PrecinctHeightAndWidth>\n", s, i);
-    }
-    fprintf(xmlout,    "%s    </PrecinctSize>\n",s); /* 1 byte, SPcox (I_i) */
-  }
-  fprintf(xmlout,      "%s  </SPcod>\n",s);
-  fprintf(xmlout,      "%s</CodingStyleDefault>\n",s);
-}
-
-/* ------------- */
-
-void xml_out_frame_coc(FILE* xmlout, opj_tcp_t *tcp, int numcomps) /* Optional in main & tile-part headers */
-{
-/* Uses global j2k_default_tcp */
-  opj_tccp_t *tccp, *firstcomp_tccp;
-  int i, compno;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  firstcomp_tccp = &(tcp->tccps[0]);
-    /* Internal data structure tccp defines separate defaults for each component, set from main */
-	/* default, then selectively overwritten. */
-    /* Compare j2k_read_cox(...) */
-  /* We don't really know which was the default, and which were not */
-  /* Let's pretend that [0] is the default and all others are not */
-  if(notes) {
-    fprintf(xmlout,    "%s<!-- mj2_to_metadata implementation always reports component[0] as using default COD, -->\n", s);
-    if(tcp == j2k_default_tcp)
-      fprintf(xmlout,  "%s<!-- and any other component, with main-header style values different from [0], as COC. -->\n", s);
-    else
-      fprintf(xmlout,  "%s<!-- and any other component, with tile-part-header style values different from [0], as COC. -->\n", s);
-  }
-  for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */
-  {
-    tccp = &tcp->tccps[compno];
-    if(same_component_style(firstcomp_tccp, tccp))
-		continue;
-
-/*  Alignments:          "      < < < < <   To help maintain xml pretty-printing */  
-    fprintf(xmlout,      "%s<CodingStyleComponent Marker=\"COC\">\n", s); /* Optional in main header, at most 1 per component */
-    if(notes)
-      fprintf(xmlout,    "%s  <!-- See Ccoc below for zero-based component number. -->\n", s);
-    /* Overrides the main COD for the specific component */
-    /* Not retained or of interest: Lcod */
-    fprintf(xmlout,      "%s  <Scoc>0x%02x</Scoc>\n", s, tccp->csty); /* 1 byte */
-	if(notes) {
-	  fprintf(xmlout,    "%s  <!-- Scoc defines entropy coder precincts: -->\n", s);
-      fprintf(xmlout,    "%s  <!--   0 = maximum, namely (PPx=15, PPy=15); 1 = precincts defined below. -->\n", s);
-	}
-    fprintf(xmlout,      "%s  <Ccoc>%d</Ccoc>\n", s, compno); /* 1 or 2 bytes */
-    /* Unfortunately compo isn't retained in j2k_read_coc:  compno = cio_read(j2k_img->numcomps <= 256 ? 1 : 2);	/* Ccoc */
-    /*if(j2k_img_numcomps <=256)
-	  component is 1 byte
-    else
-      compno is 2 byte */
-
-    /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-    fprintf(xmlout,      "%s  <SPcoc>\n", s);
-    fprintf(xmlout,      "%s    <NumberOfDecompositionLevels>%d</NumberOfDecompositionLevels>\n", s, tccp->numresolutions - 1);	/* 1 byte, SPcox (D) */
-    fprintf(xmlout,      "%s    <CodeblockWidth>%d</CodeblockWidth>\n", s, tccp->cblkw - 2);	/* 1 byte, SPcox (E) */
-    fprintf(xmlout,      "%s    <CodeblockHeight>%d</CodeblockHeight>\n", s, tccp->cblkh - 2);	/* 1 byte, SPcox (F) */
-	if(notes) {
-      fprintf(xmlout,    "%s    <!-- CBW and CBH are non-negative, and summed cannot exceed 8 -->\n", s);
-      fprintf(xmlout,    "%s    <!-- Codeblock dimension is 2^(value + 2) -->\n", s);
-	}
-    fprintf(xmlout,      "%s    <CodeblockStyle>0x%02x</CodeblockStyle>\n", s, tccp->cblksty);	/* 1 byte, SPcox (G) */
-	if(notes) {
-      fprintf(xmlout,    "%s    <!-- For CodeblockStyle, bits mean (with value 1=feature on, 0=off): -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 0: Selective arithmetic coding bypass. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 1: Reset context probabilities on coding pass boundaries. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 2: Termination on each coding pass. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 3: Vertically causal context. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 4: Predictable termination. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 5: Segmentation symbols are used. -->\n", s);
-	}
-    fprintf(xmlout,      "%s    <Transformation>%d</Transformation>\n", s, tccp->qmfbid);	/* 1 byte, SPcox (H) */
-    if(notes)
-      fprintf(xmlout,    "%s    <!-- For Transformation, 0=\"9-7 irreversible filter\", 1=\"5-3 reversible filter\" -->\n", s);
-    if (tccp->csty & J2K_CP_CSTY_PRT) {
-      fprintf(xmlout,    "%s    <PrecinctSize>\n", s); /* 1 byte, SPcox (I_i) */
-      if(notes)
-        fprintf(xmlout,  "%s      <!-- These are size exponents PPx and PPy. May be zero only for first level (aka N(L)LL subband)-->\n", s);
-      for (i = 0; i < tccp->numresolutions-1; i++) { /* subtract 1 to get # of decomposition levels */	
-        fprintf(xmlout,  "%s      <PrecinctHeightAndWidth  ResolutionLevel=\"%d\">\n", s, i);
-		if(raw)
-          fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->prch[i] << 4) | tccp->prcw[i]);	/* packed into 1 byte, SPcox (G) */
-		if(derived) {
-          fprintf(xmlout,"%s        <WidthAsDecimal>%d</WidthAsDecimal>\n", s, tccp->prcw[i]);
-          fprintf(xmlout,"%s        <HeightAsDecimal>%d</HeightAsDecimal>\n", s, tccp->prch[i]);
-		}
-        fprintf(xmlout,  "%s      </PrecinctHeightAndWidth>\n", s, i);
-      }
-      fprintf(xmlout,    "%s    </PrecinctSize>\n", s); /* 1 byte, SPcox (I_i) */
-    }
-    fprintf(xmlout,      "%s  </SPcoc>\n", s);
-    fprintf(xmlout,      "%s</CodingStyleComponent>\n", s);
-  }
-}
-
-/* ------------- */
-
-BOOL same_component_style(opj_tccp_t *tccp1, opj_tccp_t *tccp2)
-{
-  int i;
-
-  if(tccp1->numresolutions != tccp2->numresolutions)
-	  return FALSE;
-  if(tccp1->cblkw != tccp2->cblkw)
-	  return FALSE;
-  if(tccp1->cblkh != tccp2->cblkh)
-	  return FALSE;
-  if(tccp1->cblksty != tccp2->cblksty)
-	  return FALSE;
-  if(tccp1->csty != tccp2->csty)
-	  return FALSE;
-  
-  if (tccp1->csty & J2K_CP_CSTY_PRT) {
-      for (i = 0; i < tccp1->numresolutions; i++) {	
-         if(tccp1->prcw[i] != tccp2->prcw[i] || tccp1->prch[i] != tccp2->prch[i])
-			 return FALSE;
-      }
-  }
-  return TRUE;
-}
-
-/* ------------- */
-
-void xml_out_frame_qcd(FILE* xmlout, opj_tcp_t *tcp)
-{
-  /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-  opj_tccp_t *tccp;
-  int bandno, numbands;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  /* Compare j2k_read_qcx */
-  fprintf(xmlout,      "%s<QuantizationDefault Marker=\"QCD\">\n", s); /* Required in main header, single occurrence */
-  tccp = &(tcp->tccps[0]);
-  /* Not retained or of interest: Lqcd */
-  fprintf(xmlout,      "%s  <Sqcd>\n", s);		/* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "%s  <!-- Default quantization style for all components. -->\n", s);
-  if(raw)
-    fprintf(xmlout,    "%s    <AsHex>0x%02x</AsHex>\n", s, (tccp->numgbits) << 5 | tccp->qntsty);
-  if(derived)
-    fprintf(xmlout,    "%s    <QuantizationStyle>%d</QuantizationStyle>\n", s, tccp->qntsty);
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- Quantization style (in Sqcd's low 5 bits) may be: -->\n", s);
-    fprintf(xmlout,    "%s    <!--   0 = No quantization. SPqcd size = 8 bits-->\n", s);
-    fprintf(xmlout,    "%s    <!--   1 = Scalar derived (values signaled for N(L)LL subband only). Use Eq. E.5. SPqcd size = 16. -->\n", s);
-    fprintf(xmlout,    "%s    <!--   2 = Scalar expounded (values signaled for each subband). SPqcd size = 16. -->\n", s);
-  }
-  if(derived)
-    fprintf(xmlout,    "%s    <NumberOfGuardBits>%d</NumberOfGuardBits>\n", s,	tccp->numgbits);
-  if(notes)
-    fprintf(xmlout,    "%s    <!-- 0-7 guard bits allowed (stored in Sqcd's high 3 bits) -->\n", s);
-  fprintf(xmlout,      "%s  </Sqcd>\n", s);
-	  
-  /* Problem: numbands in some cases is calculated from len, which is not retained or available here at this time */
-  /* So we'll just dump all internal values */
-  /* We could calculate it, but I'm having trouble believing the length equations in the standard */
-  
-  fprintf(xmlout,      "%s  <SPqcd>\n", s);
-  switch(tccp->qntsty) {
-  case J2K_CCP_QNTSTY_NOQNT: /* no quantization */
-    /* This is what standard says, but I don't believe it: len = 4 + (3*decomp); */
-    numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */
-	/* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-    /* Instead look for first zero exponent, quit there.  Adequate? */
-    fprintf(xmlout,    "%s    <ReversibleStepSizeValue>\n", s);
-	if(notes) {
-      fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-	  fprintf(xmlout,  "%s    <!-- until an exponent with zero value is reached. -->\n", s);
-	  fprintf(xmlout,  "%s    <!-- Exponent epsilon(b) of reversible dynamic range. -->\n", s);
-	  fprintf(xmlout,  "%s    <!-- Hex value is as stored, in high-order 5 bits. -->\n", s);
-	}
-    for (bandno = 0; bandno < numbands; bandno++) {
-      if(tccp->stepsizes[bandno].expn == 0)
-        break; /* Remove when we have real numbands */
-      fprintf(xmlout,  "%s      <DynamicRangeExponent Subband=\"%d\">\n", s, bandno);
-	  if(raw)
-        fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, tccp->stepsizes[bandno].expn << 3);
-	  if(derived)
-        fprintf(xmlout,"%s        <AsDecimal>%d</AsDecimal>\n", s, tccp->stepsizes[bandno].expn);
-      fprintf(xmlout,  "%s      </DynamicRangeExponent>\n", s);
-    }
-    fprintf(xmlout,    "%s    </ReversibleStepSizeValue>\n", s);
-    break;
-  case J2K_CCP_QNTSTY_SIQNT:  /* scalar quantization derived */
-    /* This is what standard says.  Should I believe it:: len = 5;
-    /* numbands = 1; */
-    fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-    if(notes)
-      fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-    fprintf(xmlout,    "%s      <QuantizationValues Subband=\"0\">\n", s);
-    if(notes)
-      fprintf(xmlout,  "%s      <!-- For N(L)LL subband: >\n", s);
-	if(raw)
-      fprintf(xmlout,  "%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[0].expn << 11) | tccp->stepsizes[0].mant);
-	if(derived) {
-      fprintf(xmlout,  "%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[0].expn);
-      fprintf(xmlout,  "%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[0].mant);
-	}
-    fprintf(xmlout,    "%s      </QuantizationValues>\n", s);
-	if(notes) {
-      fprintf(xmlout,  "%s      <!-- Exponents for subbands beyond 0 are not from header, but calculated per Eq. E.5 -->\n", s);
-      fprintf(xmlout,  "%s      <!-- The mantissa for all subbands is the same, given by the value above. -->\n", s);
-      fprintf(xmlout,  "%s      <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-	  fprintf(xmlout,  "%s      <!-- until a subband with exponent of zero value is reached. -->\n", s);
-	}
-
-    for (bandno = 1; bandno < J2K_MAXBANDS; bandno++) {
-      if(tccp->stepsizes[bandno].expn == 0)
-        break;
-
-      fprintf(xmlout,  "%s      <CalculatedExponent Subband=\"%d\">%d</CalculatedExponent>\n", s, bandno, tccp->stepsizes[bandno].expn);
-    }
-
-    fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-    break;
-
-  default: /* J2K_CCP_QNTSTY_SEQNT */ /* scalar quantization expounded */
-    /* This is what standard says, but should I believe it: len = 5 + 6*decomp; */
-    numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/
-	/* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-    fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-	if(notes) {
-      fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-      fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-      fprintf(xmlout,  "%s    <!-- until a subband with mantissa and exponent of zero values is reached. -->\n", s);
-    }
-    for (bandno = 0; bandno < numbands; bandno++) {
-      if(tccp->stepsizes[bandno].expn == 0 && tccp->stepsizes[bandno].mant == 0)
-        break; /* Remove when we have real numbands */
-
-      fprintf(xmlout,  "%s      <QuantizationValues Subband=\"%d\">\n", s, bandno);
-	  if(raw)
-        fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[bandno].expn << 11) | tccp->stepsizes[bandno].mant);
-	  if(derived) {
-        fprintf(xmlout,"%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[bandno].expn);
-        fprintf(xmlout,"%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[bandno].mant);
-	  }
-      fprintf(xmlout,  "%s      </QuantizationValues>\n", s);
-    }
-    fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-    break;
-  } /* switch */
-  fprintf(xmlout,      "%s  </SPqcd>\n", s);
-  fprintf(xmlout,      "%s</QuantizationDefault>\n", s);
-
-/*  Alignments:        "    < < < < <   To help maintain xml pretty-printing */  
-}
-
-/* ------------- */
-
-void xml_out_frame_qcc(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
-{
-/* Uses global j2k_default_tcp */
-  /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-  opj_tccp_t *tccp, *firstcomp_tccp;
-  int bandno, numbands;
-  int compno;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  firstcomp_tccp = &(tcp->tccps[0]);
-    /* Internal data structure tccp defines separate defaults for each component, set from main */
-	/* default, then selectively overwritten. */
-    /* Compare j2k_read_qcx(...) */
-  /* We don't really know which was the default, and which were not */
-  /* Let's pretend that [0] is the default and all others are not */
-  if(notes) {
-    fprintf(xmlout,      "%s<!-- mj2_to_metadata implementation always reports component[0] as using default QCD, -->\n", s);
-    if(tcp == j2k_default_tcp)
-      fprintf(xmlout,    "%s<!-- and any other component, with main-header quantization values different from [0], as QCC. -->\n", s);
-    else
-      fprintf(xmlout,    "%s<!-- and any other component, with tile-part-header quantization values different from [0], as QCC. -->\n", s);
-  }
-  for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */
-  {
-    tccp = &(tcp->tccps[compno]);
-    if(same_component_quantization(firstcomp_tccp, tccp))
-		continue;
-
-    /* Compare j2k_read_qcx */
-    fprintf(xmlout,      "%s<QuantizationComponent Marker=\"QCC\" Component=\"%d\">\n", s, compno); /* Required in main header, single occurrence */
-    tccp = &j2k_default_tcp->tccps[0];
-    /* Not retained or perhaps of interest: Lqcd   It maybe can be calculated.  */
-    fprintf(xmlout,      "%s  <Sqcc>\n", s);		/* 1 byte */
-    if(notes)
-      fprintf(xmlout,    "%s  <!-- Quantization style for this component. -->\n", s);
-	if(raw)
-      fprintf(xmlout,    "%s    <AsHex>0x%02x</AsHex>\n", s, (tccp->numgbits) << 5 | tccp->qntsty);
-	if(derived)
-      fprintf(xmlout,    "%s    <QuantizationStyle>%d</QuantizationStyle>\n", s, tccp->qntsty);
-	if(notes) {
-      fprintf(xmlout,    "%s    <!-- Quantization style (in Sqcc's low 5 bits) may be: -->\n", s);
-      fprintf(xmlout,    "%s    <!--   0 = No quantization. SPqcc size = 8 bits-->\n", s);
-      fprintf(xmlout,    "%s    <!--   1 = Scalar derived (values signaled for N(L)LL subband only). Use Eq. E.5. SPqcc size = 16. -->\n", s);
-      fprintf(xmlout,    "%s    <!--   2 = Scalar expounded (values signaled for each subband). SPqcc size = 16. -->\n", s);
-	}
-	if(derived)
-      fprintf(xmlout,    "%s    <NumberOfGuardBits>%d</NumberOfGuardBits>\n", s,	tccp->numgbits);
-    if(notes)
-      fprintf(xmlout,    "%s    <!-- 0-7 guard bits allowed (stored in Sqcc's high 3 bits) -->\n", s);
-    fprintf(xmlout,      "%s  </Sqcc>\n", s);
-	  
-    /* Problem: numbands in some cases is calculated from len, which is not retained or available here at this time */
-    /* So we'll just dump all internal values */
-    fprintf(xmlout,      "%s  <SPqcc>\n", s);
-    switch(tccp->qntsty) {
-    case J2K_CCP_QNTSTY_NOQNT:
-      numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */
-	  /* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-
-      /* Instead look for first zero exponent, quit there.  Adequate? */
-      fprintf(xmlout,    "%s    <ReversibleStepSizeValue>\n", s);
-	  if(notes) {
-        fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-	    fprintf(xmlout,  "%s    <!-- until an exponent with zero value is reached. -->\n", s);
-	    fprintf(xmlout,  "%s    <!-- Exponent epsilon(b) of reversible dynamic range. -->\n", s);
-	    fprintf(xmlout,  "%s    <!-- Hex value is as stored, in high-order 5 bits. -->\n", s);
-	  }
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp->stepsizes[bandno].expn == 0)
-          break; /* Remove this once we have real numbands */
-        fprintf(xmlout,  "%s      <Exponent Subband=\"%d\">\n", s, bandno);
-		if(raw)
-          fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, tccp->stepsizes[bandno].expn << 3);
-		if(derived)
-          fprintf(xmlout,"%s        <AsDecimal>%d</AsDecimal>\n", s, tccp->stepsizes[bandno].expn);
-        fprintf(xmlout,  "%s      </Exponent>\n", s);
-      }
-      fprintf(xmlout,    "%s    </ReversibleStepSizeValue>\n", s);
-      break;
-    case J2K_CCP_QNTSTY_SIQNT:
-      /* numbands = 1; */
-      fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-      if(notes)
-        fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-      fprintf(xmlout,    "%s      <QuantizationValuesForSubband0>\n", s);
-      if(notes)
-        fprintf(xmlout,  "%s      <!-- For N(L)LL subband: >\n", s);
-	  if(raw)
-        fprintf(xmlout,  "%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[0].expn << 11) | tccp->stepsizes[0].mant);
-	  if(derived) {
-        fprintf(xmlout,  "%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[0].expn);
-        fprintf(xmlout,  "%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[0].mant);
-	  }
-      fprintf(xmlout,    "%s      </QuantizationValuesForSubband0>\n", s);
-	  if(notes) {
-        fprintf(xmlout,  "%s      <!-- Exponents for subbands beyond 0 are not from header, but calculated per Eq. E.5 -->\n", s);
-        fprintf(xmlout,  "%s      <!-- The mantissa for all subbands is the same, given by the value above. -->\n", s);
-        fprintf(xmlout,  "%s      <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-	    fprintf(xmlout,  "%s      <!-- until a subband with exponent of zero value is reached. -->\n", s);
-        }
-
-      for (bandno = 1; bandno < J2K_MAXBANDS; bandno++) {
-        if(tccp->stepsizes[bandno].expn == 0)
-          break;
-
-        fprintf(xmlout,  "%s      <CalculatedExponent Subband=\"%d\">%d</CalculatedExponent>\n", s, bandno, tccp->stepsizes[bandno].expn);
-      }
-      fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-      break;
-
-    default: /* J2K_CCP_QNTSTY_SEQNT */
-      numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/
-	  /* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-      fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-      if(notes) {
-        fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-        fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-	    fprintf(xmlout,  "%s    <!-- until a subband with mantissa and exponent of zero values is reached. -->\n", s);
-	  }
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp->stepsizes[bandno].expn == 0 && tccp->stepsizes[bandno].mant == 0)
-			break; /* Remove this once we have real numbands count */
-        fprintf(xmlout,  "%s      <QuantizationValues Subband=\"%d\">\n", s, bandno);
-		if(raw)
-          fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[bandno].expn << 11) | tccp->stepsizes[bandno].mant);
-		if(derived) {
-          fprintf(xmlout,"%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[bandno].expn);
-          fprintf(xmlout,"%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[bandno].mant);
-		}
-        fprintf(xmlout,  "%s      </QuantizationValues>\n", s);
-      }
-      fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-      break;
-    } /* switch */
-    fprintf(xmlout,      "%s  </SPqcc>\n", s);
-    fprintf(xmlout,      "%s</QuantizationComponent>\n", s);
-  }
-/*  Alignments:          "    < < < < <   To help maintain xml pretty-printing */  
-}
-
-/* ------------- */
-
-BOOL same_component_quantization(opj_tccp_t *tccp1, opj_tccp_t *tccp2)
-{
-  int bandno, numbands;
-
-  if(tccp1->qntsty != tccp2->qntsty)
-	  return FALSE;
-  if(tccp1->numgbits != tccp2->numgbits)
-	  return FALSE;
-
-  switch(tccp1->qntsty) {
-    case J2K_CCP_QNTSTY_NOQNT:
-      numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */
-      /* Instead look for first zero exponent, quit there.  Adequate? */
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp1->stepsizes[bandno].expn == 0)
-          break;
-        if(tccp1->stepsizes[bandno].expn != tccp2->stepsizes[bandno].expn)
-         return FALSE;
-      }
-      break;
-    case J2K_CCP_QNTSTY_SIQNT:
-      /* numbands = 1; */
-      if(tccp1->stepsizes[0].expn != tccp2->stepsizes[0].expn || tccp1->stepsizes[0].mant != tccp2->stepsizes[0].mant)
-        return FALSE;
-	  /* Don't need to check remainder, since they are calculated from [0] */
-      break;
-
-    default: /* J2K_CCP_QNTSTY_SEQNT */
-      numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/
-	  /* This comparison may cause us problems with trailing junk values. */
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp1->stepsizes[bandno].expn != tccp2->stepsizes[bandno].expn || tccp1->stepsizes[bandno].mant != tccp2->stepsizes[bandno].mant);
-          return FALSE;
-      }
-      break;
-    } /* switch */
-  return TRUE;
-}
-
-/* ------------- */
-
-void xml_out_frame_rgn(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
-{
-  int compno, SPrgn;
-  /* MJ2 files can have regions of interest if hybridized with JPX Part II */
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  for(compno = 0; compno < numcomps; compno++) {
-    SPrgn = tcp->tccps[compno].roishift;	/* 1 byte; SPrgn */
-    if(SPrgn == 0)
-		continue; /* Yet another kludge */
-
-    fprintf(xmlout,    "%s<RegionOfInterest Marker=\"RGN\">\n", s); /* Optional in main header, at most 1 per component */
-    if(notes)
-      fprintf(xmlout,  "%s<!-- See Crgn below for zero-based component number. -->\n", s);
-    /* Not retained or of interest: Lrgd */
-    fprintf(xmlout,    "%s  <Srgn>0</Srgn>\n", s); /* 1 byte */
-    if(notes)
-	  fprintf(xmlout,  "%s  <!-- Srgn is ROI style.  Only style=0 defined: Implicit ROI (max. shift) -->\n", s);
-    fprintf(xmlout,    "%s  <Crgn>%d</Crgn>\n", s, compno); /* 1 or 2 bytes */
-    fprintf(xmlout,    "%s  <SPrgn>%d</SPrgn>\n", s, SPrgn); /* 1 byte */
-    if(notes)
-      fprintf(xmlout,  "%s  <!-- SPrgn is implicit ROI shift, i.e., binary shifting of ROI coefficients above background. -->\n", s);
-    fprintf(xmlout,    "</RegionOfInterest\n", s); /* Optional in main header, at most 1 per component */
-  }
-}
-
-/* ------------- */
-
-void xml_out_frame_poc(FILE* xmlout, opj_tcp_t *tcp) { /* Progression Order Change */
-  /* Compare j2k_read_poc() */
-  int i;
-  opj_poc_t *poc;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-  
-  if(tcp->POC != 1)
-	  return; /* Not present */
-
-  fprintf(xmlout,    "%s<ProgressionOrderChange Marker=\"POC\">\n", s); /* Optional in main header, at most 1 per component */
-  /* j2k_read_poc seems to allow accumulation of default pocs from multiple POC segments, but does
-  the spec really allow that? */
-  /* 2 bytes, not retained; Lpoc */
-  /* I probably didn't get this dump precisely right. */
-  for (i = 0; i < tcp->numpocs; i++) {
-    poc = &tcp->pocs[i];
-    fprintf(xmlout,  "%s  <Progression Num=\"%d\">\n", s, i+1);
-    fprintf(xmlout,  "%S    <RSpoc>%d</RSpoc>\n", s, poc->resno0);	/* 1 byte, RSpoc_i */
-    if(notes)
-	  fprintf(xmlout,"%s    <!-- Resolution level index (inclusive) for progression start. Range: 0 to 33 -->\n", s);
-    fprintf(xmlout,  "%s    <CSpoc>%d</CSpoc>\n", s, poc->compno0);/* j2k_img->numcomps <= 256 ? 1 byte : 2 bytes; CSpoc_i */
-    if(notes)
-      fprintf(xmlout,"%s    <!-- Component index (inclusive) for progression start. -->\n", s);
-    fprintf(xmlout,  "%s    <LYEpoc>%d</LYEpoc>\n", s, poc->layno1); /* int_min(cio_read(2), tcp->numlayers);	/* 2 bytes; LYEpoc_i */
-    if(notes)
-      fprintf(xmlout,"%s    <!-- Layer index (exclusive) for progression end. -->\n", s);
-    fprintf(xmlout,  "%s    <REpoc>%d</REpoc>\n", s, poc->resno1); /*int_min(cio_read(1), tccp->numresolutions);	/* REpoc_i */
-    if(notes)
-      fprintf(xmlout,"%s    <!-- Resolution level index (exclusive) for progression end. Range: RSpoc to 33 -->\n", s);
-    fprintf(xmlout,  "%s    <CEpoc>%d</CEpoc>\n", s, poc->compno1); /* int_min(cio_read(j2k_img->numcomps <= 256 ? 1 : 2), j2k_img->numcomps);	/* CEpoc_i */
-    if(notes)
-	  fprintf(xmlout,"%s    <!-- Component index (exclusive) for progression end.  Minimum: CSpoc -->\n", s);
-    fprintf(xmlout,  "%s    <Ppoc>%d</Ppoc>\n", s, poc->prg); /* 1 byte Ppoc_i */
-	if(notes) {
-      fprintf(xmlout,"%s    <!-- Defined Progression Order Values are: -->\n", s);
-      fprintf(xmlout,"%s    <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->\n", s);
-      fprintf(xmlout,"%s    <!-- where L = \"layer\", R = \"resolution level\", C = \"component\", P = \"position\". -->\n", s);
-	}
-    fprintf(xmlout,  "%s  </Progression>\n", s);
-  }
-  fprintf(xmlout,    "%s</ProgressionOrderChange\n", s);
-}
-
-/* ------------- */
-
-#ifdef SUPPRESS_FOR_NOW
-/* Suppress PPM and PPT since we're not showing data from the third option, namely within the codestream, and
-that's evidently what frames_to_mj2 uses.  And a hex dump isn't so useful anyway */
-
-void xml_out_frame_ppm(FILE *xmlout, opj_cp_t *cp) { /* For main header, not tile-part (which uses PPT instead). */
-/* Either the PPM or PPT is required if the packet headers are not distributed in the bit stream */
-/* Use of PPM and PPT are mutually exclusive. */
-/* Compare j2k_read_ppm() */
-  int j;
-  
-  if(cp->ppm != 1)
-	  return; /* Not present */
-/* Main header uses indent of 10 spaces */
-  fprintf(xmlout,    "          <PackedPacketHeadersMainHeader Marker=\"PPM\">\n"); /* Optional in main header, but if not, must be in PPT or codestream */
-  /* 2 bytes Lppm not saved */
-  if(notes) {
-    fprintf(xmlout,  "          <!-- If there are multiple PPM marker segments in the main header, -->\n");
-    fprintf(xmlout,  "          <!-- this mj2_to_metadata implementation will report them as a single consolidated PPM header. -->\n");
-    fprintf(xmlout,  "          <!-- The implementation can't currently segregate by tile-part. -->\n");
-    fprintf(xmlout,  "          <!-- TO DO? further map the packet headers to xml. -->\n");
-  }
- 
-  /* 1 byte, not retained ; Zppm is sequence # of this PPM header */
-  /* 4 bytes, possibly overwritten multiple times in j2k_cp->ppm_previous: Nppm */
-  /* Use j symbol for index instead of i, to make comparable with j2k_read_ppm */
-  /* Not real clear whether to use ppm->store or ppm_len as upper bound */
-  fprintf(xmlout,    "            <PackedData>\n");
-  xml_out_dump_hex(xmlout, cp->ppm_data, cp->ppm_len);
-  /* Dump packet headers 1 byte at a time: lppm[i][j] */
-  fprintf(xmlout,    "            </PackedData>\n");
-  fprintf(xmlout,    "          </PackedPacketHeadersMainHeader>\n"); /* Optional in main header, but if not, must be in PPT or codestream */
-}
-
-/* ------------- */
-
-void xml_out_frame_ppt(FILE *xmlout, opj_tcp_t *tcp) { /* For tile-part header, not main (which uses PPM instead). */
-/* Either the PPM or PPT is required if the packet headers are not distributed in the bit stream */
-/* Use of PPM and PPT are mutually exclusive. */
-/* Compare j2k_read_ppt() */
-  int j;
-  
-  if(tcp->ppt != 1)
-	  return; /* Not present */
-
-  /* Tile-part indents are 12 spaces */
-  fprintf(xmlout,    "            <PackedPacketHeadersTilePartHeader Marker=\"PPT\">\n"); /* Optional in main header, but if not, must be in PPT or codestream */
-  /* 2 bytes Lppm not saved */
-  if(notes) {
-    fprintf(xmlout,  "            <!-- If there are multiple PPT marker segments in the tile-part header, -->\n");
-    fprintf(xmlout,  "            <!-- this mj2_to_metadata implementation will report them as a single consolidated PPT header. -->\n");
-    fprintf(xmlout,  "            <!-- The implementation can't currently segregate by tile-part. -->\n");
-    fprintf(xmlout,  "            <!-- TO DO? further map the packet headers to xml. -->\n");
-  }
- 
-  /* 1 byte, not retained ; Zppt is sequence # of this PPT header */
-  /* 4 bytes, possibly overwritten multiple times in j2k_cp->ppt_previous: Nppt */
-  /* Use j symbol for index instead of i, to make comparable with j2k_read_ppt */
-  /* Not real clear whether to use ppt->store or ppt_len as upper bound */
-  fprintf(xmlout,    "              <PackedData>\n");
-  xml_out_dump_hex(xmlout, tcp->ppt_data, tcp->ppt_len);
-  /* Dump packet headers 1 byte at a time: lppt[i][j] */
-  fprintf(xmlout,    "              </PackedData>\n");
-  fprintf(xmlout,    "            </PackedPacketHeadersTileHeader>\n"); /* Optional in tile-part header, but if not, must be in PPM or codestream */
-}
-#endif SUPPRESS_FOR_NOW
-
-/* ------------- */
-
-void xml_out_frame_tlm(FILE* xmlout) { /* opt, main header only.  May be multiple. */
-/* Compare j2k_read_tlm()... which doesn't retain anything! */
-/* Plan:  Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
-/* Main header indents are 10 spaces */
-}
-
-/* ------------- */
-
-void xml_out_frame_plm(FILE* xmlout) { /* opt, main header only; can be used in conjunction with tile-part's PLT */
-/* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE */
-	/* Compare j2k_read_plm()... which doesn't retain anything! */
-/* Plan:  Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
-/* Main header indents are 10 spaces */
-}
-
-/* ------------- */
-
-void xml_out_frame_plt(FILE* xmlout, opj_tcp_t *tcp) { /* opt, tile-part headers only; can be used in conjunction with main header's PLM */
-/* NO-OP.  PLT NOT SAVED IN DATA STRUCTURE */
-	/* Compare j2k_read_plt()... which doesn't retain anything! */
-/* Tile-part header indents are 12 spaces */
-}
-
-/* ------------- */
-
-void xml_out_frame_crg(FILE* xmlout) { /* NO-OP.  CRG NOT SAVED IN DATA STRUCTURE */ /* opt, main header only; */
-/* Compare j2k_read_crg()... which doesn't retain anything! */
-/* Plan:  Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
-#ifdef NOTYET
-  THIS PSEUDOCODE IMAGINES THESE EXIST: j2k_default_tcp->crg, j2k_default_tcp->crg_i, j2k_default_tcp->crg_xcrg*, j2k_default_tcp->crg_ycrg* 
-  (POSSIBLY DON'T NEED crg_i, CAN GET NUMBER OR COMPONENTS FROM ELSEWHERE)
-  if(j2k_default_tcp->crg != 1 || j2k_default_tcp->crg_i == 0)
-	  return; /* Not present */
-
-/* Main header indents are 10 spaces */
-  fprintf(xmlout,    "          <ComponentRegistration Marker=\"RG\" Count=\"%d\">\n", j2k_default_tcp->crg_i);
-  if(notes) {
-    fprintf(xmlout,  "          <!-- Fine tuning of registration of components with respect to each other, -->\n");
-    fprintf(xmlout,  "          <!-- not required but potentially helpful for decoder. -->\n");
-    fprintf(xmlout,  "          <!-- These supplementary fractional offsets are in units of 1/65536 of the horizontal -->\n");
-    fprintf(xmlout,  "          <!-- or vertical separation (e.g., XRsiz[i] or YRsiz[i] for component i). -->\n");
-  }
-  /* This isn't the most compact form of table, but is OK when number of components is small, as is likely. */
-  for (i = 0; i < j2k_default_tcp->crg_i; i++) {
-    fprintf(xmlout,  "            <Component Num=\"%d\">\n", i+1);
-    fprintf(xmlout,  "              <Xcrg>\n");
-	if(raw)
-      fprintf(xmlout,"                <AsNumerator>%d</AsNumerator>\n", j2k_default_tcp->crg_xcrg[i]);
-	if(derived) {
-	  /* Calculate n * 100%/65536; 4 digits after decimal point is sufficiently accurate */
-      fprintf(xmlout,"                <AsPercentage>%.4f</AsPercentage>\n", ((double)j2k_default_tcp->crg_xcrg[i])/655.36);
-	  /* We could do another calculation that include XRsiz[i]; maybe later. */
-	}
-    fprintf(xmlout,  "              </Xcrg>\n");
-    fprintf(xmlout,  "              <Ycrg>\n");
-	if(raw)
-      fprintf(xmlout,"                <AsNumerator>%d</AsNumerator>\n", j2k_default_tcp->crg_ycrg[i]);
-	if(derived) {
-      fprintf(xmlout,"                <AsPercentage>%f</AsPercentage>\n", ((double)j2k_default_tcp->crg_ycrg[i])/655.36);
-	}
-    fprintf(xmlout,  "              </Ycrg>\n");
-    fprintf(xmlout,  "            </Component>\n");
-  }
-
-  fprintf(xmlout,    "          </ComponentRegistration>\n");
-
-#endif
-}
-
-/* ------------- */
-
-/* Regrettably from a metadata point of view, j2k_read_com() skips over any comments in main header or tile-part-header */
-void xml_out_frame_com(FILE* xmlout, opj_tcp_t *tcp) { /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */ /* opt in main or tile-part headers; */
-/* Compare j2k_read_com()... which doesn't retain anything! */
-#ifdef NOTYET
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == &j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-  THIS PSEUDOCODE IMAGINES THESE EXIST: tcp->com, tcp->com_len, tcp->com_data array 
-  if(tcp->com != 1)
-	  return; /* Not present */
-
-  fprintf(xmlout,    "%s<Comment Marker=\"COM\">\n", s); /* Optional in main or tile-part header */
-  xml_out_dump_hex_and_ascii(tcp->com_data, tcp->com_len, s);
-  fprintf(xmlout,    "%s</Comment>\n", s);
-#endif
-}
-
-void xml_out_dump_hex(FILE* xmlout, char *data, int data_len, char* s) {
-  /* s is a string of spaces for indent */
-  int i;
-  
-  /* This is called when raw is true, or there is no appropriate derived form */
-  fprintf(xmlout,    "%s<AsHex>\n", s);
-  fprintf(xmlout,    "%s  ", s); /* Inadequate for pretty printing */
-  for (i = 0; i < data_len; i++) {	/* Dump packet headers */
-    fprintf(xmlout,  "%02x", data[i]);
-  }
-  fprintf(xmlout,    "%s</AsHex>\n", s);
-}
-
-/* Define this as an even number: */
-#define BYTES_PER_DUMP_LINE 40
-/* Current total width for Hex and ASCII is : 11 spaces lead + (3 * BPDL) + 2 spaces + BPDL */
-void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len, char* s) {
-  /* s is a string of spaces for indent */
-  int i,j;
-  
-  if(raw)
-    xml_out_dump_hex(xmlout, data, data_len, s);
-
-  if(derived) {
-    fprintf(xmlout,  "%s<AsHexAndASCII>\n", s);
-	for (i = 0; i < data_len; ) {
-      fprintf(xmlout,"%s ", s); /* Additional leading space added in loop */
-	  /* First column: hex */
-      for (j = 0; j < BYTES_PER_DUMP_LINE; j++)	/* Dump bytes */
-        fprintf(xmlout," %02x", data[i+j]);
-      /* Space between columns... */ fprintf(xmlout,  "  ");
-	  /* Second column: ASCII */
-	  for (j = 0; j < BYTES_PER_DUMP_LINE; j++, i++) {
-	    if(isprint((int)data[i]) && i < data_len)
-          fprintf(xmlout,"%c", data[i]);
-	    else
-	      fprintf(xmlout," ");
-      }
-      /* If we also wanted to output UCS-2 Unicode as a third column, then entire document
-      must use fwprintf.  Forget about it for now.  As it stands, if data is UCS-2 format but still
-      the ASCII set, then we'll be able to read every other byte as ASCII in column 2.  If
-      data is UTF-8 format but still ASCII, then we'll be able to read every byte as ASCII
-      in column 2. */
-    }
-    fprintf(xmlout,  "%s</AsHexAndASCII>\n", s);
-  }
-}
-
-
-/* ------------- */
-
-void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct) {  /* JP2 Header */
-/* Compare jp2_read_jp2h(opj_jp2_t * jp2_struct) */
-  int i;
-
-  fprintf(xmlout,      "              <JP2Header BoxType=\"jp2h\">\n");
-
-/* Compare jp2_read_ihdr(jp2_struct)) */
-  fprintf(xmlout,      "                <ImageHeader BoxType=\"ihdr\">\n");
-  fprintf(xmlout,      "                  <HEIGHT>%d</HEIGHT>\n", jp2_struct->h); /* 4 bytes */
-  fprintf(xmlout,      "                  <WIDTH>%d</WIDTH>\n", jp2_struct->w); /* 4 bytes */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- HEIGHT here, if 2 fields per image, is of total deinterlaced height. -->\n");
-  fprintf(xmlout,      "                  <NC>%d</NC>\n", jp2_struct->numcomps); /* 2 bytes */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- NC is number of components -->\n"); /* 2 bytes */
-  fprintf(xmlout,      "                  <BPC>\n"); /* 1 byte */
-  if(jp2_struct->bpc == 255) {
-    fprintf(xmlout,    "                    <AsHex>0x%02x</AsHex>\n", jp2_struct->bpc); /* 1 byte */
-    if(notes)
-      fprintf(xmlout,  "                    <!-- BPC = 0xff means bits per pixel varies with component; see table below. -->\n");
-  } else { /* Not 0xff */
-    if(raw) {
-      fprintf(xmlout,  "                    <AsHex>0x%02x</AsHex>\n", jp2_struct->bpc); /* 1 byte */
-      if(notes)
-        fprintf(xmlout,"                    <!-- BPC = 0xff means bits per pixel varies with component; see table below. -->\n");
-	}
-    if(derived) {
-      fprintf(xmlout,  "                    <BitsPerPixel>%d</BitsPerPixel>\n", jp2_struct->bpc & 0x7f);
-      fprintf(xmlout,  "                    <Signed>%d</Signed>\n", jp2_struct->bpc >> 7);
-	}
-  }
-  fprintf(xmlout,      "                  </BPC>\n");
-  fprintf(xmlout,      "                  <C>%d</C>\n", jp2_struct->C); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- C is compression type.  Only \"7\" is allowed to date. -->\n"); /* 2 bytes */
-  fprintf(xmlout,      "                  <UnkC>%d</UnkC>\n", jp2_struct->UnkC); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- Colourspace Unknown. 1 = unknown, 0 = known (e.g., colourspace spec is accurate) -->\n"); /* 1 byte */
-  fprintf(xmlout,      "                  <IPR>%d</IPR>\n", jp2_struct->IPR); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- IPR is 1 if frame contains an Intellectual Property box; 0 otherwise. -->\n"); /* 2 bytes */
-  fprintf(xmlout,      "                </ImageHeader>\n");
-
-  if (jp2_struct->bpc == 255)
-  {
-    fprintf(xmlout,    "                <BitsPerComponent BoxType=\"bpcc\">\n");
-    if(notes)
-      fprintf(xmlout,  "                <!-- Pixel depth (range 1 to 38) is low 7 bits of hex value + 1 -->\n");
-	/* Bits per pixel varies with components */
-    /* Compare jp2_read_bpcc(jp2_struct) */
-	for (i = 0; i < (int)jp2_struct->numcomps; i++) {
-	  if(raw)
-        fprintf(xmlout,"                  <AsHex>0x%02x</AsHex>\n", jp2_struct->comps[i].bpcc); /* 1 byte */
-	  if(derived) {
-        fprintf(xmlout,"                  <BitsPerPixel>%d</BitsPerPixel>\n", (jp2_struct->comps[i].bpcc & 0x7f)+1);
-        fprintf(xmlout,"                  <Signed>%d</Signed>\n", jp2_struct->comps[i].bpcc >> 7);
-	  }
-	}
-    fprintf(xmlout,    "                </BitsPerComponent>\n");
-  }
-
-  /* Compare jp2_read_colr(jp2_struct) */
-  fprintf(xmlout,      "                <ColourSpecification BoxType=\"colr\">\n");
-  fprintf(xmlout,      "                  <METH>%d</METH>\n", jp2_struct->meth); /* 1 byte */
-  if(notes) {
-    fprintf(xmlout,    "                  <!-- Valid values of specification method so far: -->\n");
-    fprintf(xmlout,    "                  <!--   1 = Enumerated colourspace, in EnumCS field -->\n");
-    fprintf(xmlout,    "                  <!--   2 = Restricted ICC Profile, in PROFILE field -->\n");
-  }
-  fprintf(xmlout,      "                  <PREC>%d</PREC>\n", jp2_struct->precedence); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- 0 is only valid value of precedence so far. -->\n");
-  fprintf(xmlout,      "                  <APPROX>%d</APPROX>\n", jp2_struct->approx); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- 0 is only valid value of colourspace approximation so far. -->\n");
-
-  if (jp2_struct->meth == 1) {
-    fprintf(xmlout,    "                  <EnumCS>%d</EnumCS>\n", jp2_struct->enumcs); /* 4 bytes */
-	if(notes) {
-	  fprintf(xmlout,  "                  <!-- Valid values of enumerated MJ2 colourspace so far: -->\n");
-	  fprintf(xmlout,  "                  <!--   16: sRGB as defined by IEC 61966-2-1. -->\n");
-	  fprintf(xmlout,  "                  <!--   17: greyscale (related to sRGB). -->\n");
-	  fprintf(xmlout,  "                  <!--   18: sRGB YCC (from JPEG 2000 Part II). -->\n");
-	  fprintf(xmlout,  "                  <!-- (Additional JPX values are defined in Part II). -->\n");
-	}
-  }
-  else
-    if(notes)
-      fprintf(xmlout,  "                  <!-- PROFILE is not handled by current OpenJPEG implementation. -->\n");
-    /* only 1 byte is read and nothing stored */
-  fprintf(xmlout,      "                </ColourSpecification>\n");
-
-  /* TO DO?  No OpenJPEG support.
-  Palette 'pclr'
-  ComponentMapping 'cmap'
-  ChannelDefinition 'cdef'
-  Resolution 'res'
-  */
-  fprintf(xmlout,      "              </JP2Header>\n");
-}
-/* ------------- */
-
-#ifdef NOTYET
-IMAGE these use cp structure, extended... but we could use a new data structure instead
-void xml_out_frame_jp2i(FILE* xmlout, opj_cp_t *cp) {
-  /* IntellectualProperty 'jp2i' (no restrictions on location) */
-  int i;
-  IMAGE cp->jp2i, cp->jp2i_count, cp->jp2i_data (array of chars), cp->cp2i_len (array of ints)
-  if(cp->jp2i != 1)
-	  return; /* Not present */
-
-  for(i = 0; i < cp->jp2i_count; i++)
-  {
-    fprintf(xmlout,      "            <IntellectualProperty BoxType=\"jp2i\">\n");
-  /* I think this can be anything, including binary, so do a dump */
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. */
-    xml_out_dump_hex_and_ascii(xmlout, cp->jp2i_data[i], cp->jp2i_len[i]);
-    fprintf(xmlout,      "            </IntellectualProperty>\n");
-  }
-}
-
-void xml_out_frame_xml(FILE* xmlout, opj_cp_t *cp) {
-  /* XML 'xml\040' (0x786d6c20).  Can appear multiply, before or after jp2c codestreams */
-  IMAGE cp->xml, cp->xml_count, cp->xml_data (array of chars)
-  MAYBE WE DON'T NEED cp->xml_len (array of ints) IF WE ASSUME xml_data IS NULL-TERMINATED.
-  ASSUME ASSUME EACH LINE IS ENDED BY \n.
-  int i;
-  if(cp->xml != 1)
-	  return; /* Not present */
-
-  for(i = 0; i < cp->xml_count; i++)
-  {
-    fprintf(xmlout,      "            <TextFormXML BoxType=\"xml[space]" Instance=\"%d\">\n", i+1);
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. Being lazy, didn't indent here. */
-    fprintf(xmlout,cp->xml_data[i]); /* May be multiple lines */ /* Could check if this is well-formed */
-    fprintf(xmlout,      "            </TextFormXML>\n");
-  }
-}
-
-void xml_out_frame_uuid(FILE* xmlout, opj_cp_t *cp) {
-	/* UUID 'uuid' (top level only) */
-	/* Part I 1.7.2 says: may appear multiply in JP2 file, anywhere except before File Type box */
-	/* Part III 5.2.1 says: Private extensions shall be achieved through the 'uuid' type. */
-	/* A UUID is a 16-byte value.  There is a conventional string representation for it:
-	   "0x12345678-9ABC-DEF0-1234-567890ABCDEF".  Let's assume that is what is stored in uuid_value */
-
-	/* Part III 6.1 Any other MJ2 box type could be alternatively written as a 'uuid' box, with value given
-	   as : 0xXXXXXXXX-0011-0010-8000-00AA00389B71, where the Xs are the boxtype in hex.  However,
-	   such a file is "not compliant; systems may choose to read [such] objects ... as equivalent to the box of
-	   the same type, or not."  Here, we choose not to. */
-  int i;
-  IMAGE cp->uuid, cp->uuid_count, cp->uuid_value (array of uuids... let's say fixed-length strings) cp->uuid_data (array of char buffers), cp->uuid_len (array of ints)
-  if(cp->juuid != 1)
-	  return; /* Not present */
-
-  for(i = 0; i < cp->uuid_count; i++)
-  {
-    fprintf(xmlout,      "            <UniversalUniqueID BoxType=\"uuid\">
-	fprintf(xmlout,      "              <UUID>%s</UUDI>\n", cp->uuid_value[i]);
-	fprintf(xmlout,      "              <Data>\n");
-  /* I think this can be anything, including binary, so do a dump */
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. */
-    xml_out_dump_hex_and_ascii(xmlout, cp->uuid_data[i], cp->uuid_len[i]);
-	fprintf(xmlout,      "              </Data>\n");
-    fprintf(xmlout,      "            </UniversalUniqueID>\n");
-  }
-}
-
-void xml_out_frame_uinf(FILE* xmlout, opj_cp_t *cp) {
-	/* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */
-	/* Part I 1.7.3 says: may appear multiply in JP2 file, anywhere at the top level except before File Type box */
-	/* So there may be multiple ulst's, and each can have multiple UUIDs listed (with a single URL) */
-	/* This is not quite as vendor-specific as UUIDs, or at least is meant to be generally readable */
-	/* Assume UUIDs stored in canonical string format */
-  int i, j;
-  IMAGE cp->uinf, cp->uinf_count, cp->uinf_ulst_nu (array of ints)
-    cp->uinf_uuid (2 dimensional array of uuids... let's say fixed-length strings),
-    cp->uinf_url (array of char buffers)
-
-  if(cp->uinf != 1)
-	  return; /* Not present */
-
-  for(i = 0; i < cp->uuid_count; i++)
-  {
-    fprintf(xmlout,      "            <UUIDInfo BoxType=\"uinf\">\n");
-    fprintf(xmlout,      "              <UUIDList BoxType=\"ulst\" Count=\"%d\">\n",cp->cp->uinf_ulst_nu[i]);
-	for(j = 0; j < cp->uinf_ulst_nu[i];  j++)
-	  fprintf(xmlout,    "              <ID Instance=\"%s\">%s</ID>\n", cp->uuif_uuid[i][j], j+1);
-    fprintf(xmlout,      "              </UUIDList>\n");
-	fprintf(xmlout,      "              <DataEntryURL>\n");
-	/* Could add VERS and FLAG here */
-	fprintf(xmlout,      "                <LOC>\n");
-    fprintf(xmlout,      "                  %s",cp->uinf_url[i]); /* Probably single line, so indent works */ /* In theory, could check if this is well-formed, or good live link */
-	fprintf(xmlout,      "                </LOC>\n");
-	fprintf(xmlout,      "              </DataEntryURL>\n");
-    fprintf(xmlout,      "            </UUIDInfo>\n");
-  }
-}
-
-IMAGE these use cp structure, extended... but we could use a new data structure instead
-void xml_out_frame_unknown_type(FILE* xmlout, opj_cp_t *cp) {
-  /* Part III 5.2.1 says "Type fields not defined here are reserved.  Private extensions
-     shall be acieved through the 'uuid' type." [This implies an unknown
-     type would be an error, but then...] "Boxes not explicitly defined in this standard,
-	 or otherwise unrecognized by a reader, may be ignored."
-	 Also, it says  "the following types are not and will not be used, or used only in
-	 their existing sense, in future versions of this specification, to avoid conflict
-	 with existing content using earlier pre-standard versions of this format:
-	   clip, crgn, matt, kmat, pnot, ctab, load, imap;
-	   track reference types tmcd, chap, sync,scpt, ssrc"
-	 [But good luck figuring out the mapping.]
-	 Part III Amend. 2 4.1 is stronger: "All these specifications [of this family, e.g.,
-	 JP2 Part I, ISO Base format (Part 12) leading to MP4, Quicktime, and possibly including
-	 MJ2] require that readers ignore objects that are unrecognizable to them".
-	 */
-  int i;
-  IMAGE cp->unknown_type, cp->unknown_type_count, cp->unknown_type_boxtype (array of buf[5]s), cp->unknown_type_data (array of chars), cp->unknown_type_len (array of ints)
-  if(cp->unknown_type != 1)
-	  return; /* Not present */
-
-  for(i = 0; i < cp->unknown_type_count; i++)
-  {
-    fprintf(xmlout,      "            <UnknownType BoxType=\"%s\">\n", cp->unknown_type_boxtype[i]);
-    /* Can be anything, including binary, so do a dump */
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. */
-    xml_out_dump_hex_and_ascii(xmlout, cp->unknown_type_data[i], cp->unknown_type_len[i]);
-    fprintf(xmlout,      "            </UnknownType>\n");
-  }
-}
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/meta_out.h b/Utilities/gdcmopenjpeg-v1/mj2/meta_out.h
deleted file mode 100644
index 293316d..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/meta_out.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* meta_out.h */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Callable from mj2_to_metadata */
-/* Contributed to Open JPEG by Glenn Pearson, U.S. National Library of Medicine */
-
-#define BOOL int
-#define FALSE 0
-#define TRUE 1
-
-void xml_write_init(BOOL n, BOOL t, BOOL r, BOOL d);
-
-int xml_write_struct(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, char* stringDTD, opj_event_mgr_t *event_mgr);
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2.c b/Utilities/gdcmopenjpeg-v1/mj2/mj2.c
deleted file mode 100644
index 01ee90c..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2.c
+++ /dev/null
@@ -1,2911 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "../libopenjpeg/opj_includes.h"
-#include "mj2.h"
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Read box headers
- at param cinfo Codec context info
- at param cio Input stream
- at param box
- at return Returns true if successful, returns false otherwise
-*/
-/*-- UNUSED
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
---*/
-/*
-* 
-* Read box headers
-*
-*/
-
-int mj2_read_boxhdr(mj2_box_t * box, opj_cio_t *cio)
-{
-  box->init_pos = cio_tell(cio);
-  box->length = cio_read(cio, 4);
-  box->type = cio_read(cio, 4);
-  if (box->length == 1) {
-    if (cio_read(cio, 4) != 0) {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Cannot handle box sizes higher than 2^32\n");
-      return 1;
-    };
-    box->length = cio_read(cio, 4);
-    if (box->length == 0) 
-      box->length = cio_numbytesleft(cio) + 12;
-  }
-  else if (box->length == 0) {
-    box->length = cio_numbytesleft(cio) + 8;
-  }
-  return 0;
-}
-
-/*
-* 
-* Initialisation of a Standard Movie, given a simple movie structure defined by the user 
-* The movie will have one sample per chunk
-* 
-* Arguments: opj_mj2_t * movie
-* Several variables of "movie" must be defined in order to enable a correct execution of 
-* this function:
-*   - The number of tracks of each type (movie->num_vtk, movie->num_stk, movie->num_htk)
-*   - The memory for each must be allocated (movie->tk)
-*   - For each track:
-*	  The track type (tk->track_type)
-*	  The number of sample (tk->num_samples)
-*	  The sample rate (tk->sample_rate)
-*
-*/
-
-int mj2_init_stdmovie(opj_mj2_t * movie)
-{
-  int i;
-  unsigned int j;
-  time_t ltime;
-	
-  movie->brand = MJ2_MJ2;
-  movie->minversion = 0;
-  movie->num_cl = 2;
-  movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
-
-  movie->cl[0] = MJ2_MJ2;
-  movie->cl[1] = MJ2_MJ2S;
-  time(&ltime);			/* Time since 1/1/70 */
-  movie->creation_time = (unsigned int) ltime + 2082844800;	/* Seconds between 1/1/04 and 1/1/70 */
-  movie->timescale = 1000;
-	
-  movie->rate = 1 << 16;		/* Rate to play presentation  (default = 0x00010000)          */
-  movie->volume = 1 << 8;		/* Movie volume (default = 0x0100)                            */
-  movie->trans_matrix[0] = 0x00010000;	/* Transformation matrix for video                            */
-  movie->trans_matrix[1] = 0;	/* Unity is { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 }  */
-  movie->trans_matrix[2] = 0;
-  movie->trans_matrix[3] = 0;
-  movie->trans_matrix[4] = 0x00010000;
-  movie->trans_matrix[5] = 0;
-  movie->trans_matrix[6] = 0;
-  movie->trans_matrix[7] = 0;
-  movie->trans_matrix[8] = 0x40000000;
-  movie->next_tk_id = 1;
-	
-  for (i = 0; i < movie->num_htk + movie->num_stk + movie->num_vtk; i++) {
-    mj2_tk_t *tk = &movie->tk[i];
-    movie->next_tk_id++;
-    tk->jp2_struct.comps = NULL;
-    tk->jp2_struct.cl = NULL;
-    
-    if (tk->track_type == 0) {
-      if (tk->num_samples == 0)
-				return 1;
-			
-      tk->Dim[0] = 0;
-      tk->Dim[1] = 0;
-			
-      tk->timescale = 1000;	/* Timescale = 1 ms                                          */
-			
-      tk->chunk[0].num_samples = 1;
-      tk->chunk[0].sample_descr_idx = 1;
-			
-      tk->same_sample_size = 0;
-			
-      tk->num_samplestochunk = 1;	/* One sample per chunk                                      */
-		tk->sampletochunk = (mj2_sampletochunk_t*) opj_malloc(tk->num_samplestochunk * sizeof(mj2_sampletochunk_t));
-      tk->sampletochunk[0].first_chunk = 1;
-      tk->sampletochunk[0].samples_per_chunk = 1;
-      tk->sampletochunk[0].sample_descr_idx = 1;
-      
-      if (tk->sample_rate == 0) {
-				opj_event_msg(tk->cinfo, EVT_ERROR,
-					"Error while initializing MJ2 movie: Sample rate of track %d must be different from zero\n",
-					tk->track_ID);
-				return 1;
-      }
-			
-      for (j = 0; j < tk->num_samples; j++) {
-				tk->sample[j].sample_delta = tk->timescale / tk->sample_rate;
-      }
-			
-      tk->num_tts = 1;
-		tk->tts = (mj2_tts_t*) opj_malloc(tk->num_tts * sizeof(mj2_tts_t));
-      tk->tts[0].sample_count = tk->num_samples;
-      tk->tts[0].sample_delta = tk->timescale / tk->sample_rate;
-			
-      tk->horizresolution = 0x00480000;	/* Horizontal resolution (typically 72)                       */
-      tk->vertresolution = 0x00480000;	/* Vertical resolution (typically 72)                         */
-      tk->compressorname[0] = 0x0f4d6f74;	/* Compressor Name[]: Motion JPEG2000                         */
-      tk->compressorname[1] = 0x696f6e20;
-      tk->compressorname[2] = 0x4a504547;
-      tk->compressorname[3] = 0x32303030;
-      tk->compressorname[4] = 0x00120000;
-      tk->compressorname[5] = 0;
-      tk->compressorname[6] = 0x00000042;
-      tk->compressorname[7] = 0x000000DC;
-      tk->num_url = 0;		/* Number of URL                                              */
-      tk->num_urn = 0;		/* Number of URN                                              */
-      tk->graphicsmode = 0;	/* Graphicsmode                                               */
-      tk->opcolor[0] = 0;	/* OpColor                                                    */
-      tk->opcolor[1] = 0;	/* OpColor                                                    */
-      tk->opcolor[2] = 0;	/* OpColor                                                    */
-      tk->creation_time = movie->creation_time;	/* Seconds between 1/1/04 and 1/1/70          */
-      tk->language = 0;		/* Language (undefined)					      */
-      tk->layer = 0;
-      tk->volume = 1 << 8;		/* Movie volume (default = 0x0100) */
-      tk->trans_matrix[0] = 0x00010000;	/* Transformation matrix for track */
-      tk->trans_matrix[1] = 0;	/* Unity is { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 }  */
-      tk->trans_matrix[2] = 0;
-      tk->trans_matrix[3] = 0;
-      tk->trans_matrix[4] = 0x00010000;
-      tk->trans_matrix[5] = 0;
-      tk->trans_matrix[6] = 0;
-      tk->trans_matrix[7] = 0;
-      tk->trans_matrix[8] = 0x40000000;
-      tk->fieldcount = 1;
-      tk->fieldorder = 0;
-      tk->or_fieldcount = 1;
-      tk->or_fieldorder = 0;
-      tk->num_br = 2;
-		tk->br = (unsigned int*) opj_malloc(tk->num_br * sizeof(unsigned int));
-      tk->br[0] = MJ2_JP2;
-      tk->br[1] = MJ2_J2P0;
-      tk->num_jp2x = 0;
-      tk->hsub = 2;		/* 4:2:0                                                      */
-      tk->vsub = 2;		/* 4:2:0                                                      */
-      tk->hoff = 0;
-      tk->voff = 0;
-      tk->visual_w = tk->w << 16;
-      tk->visual_h = tk->h << 16;
-    }
-    else {
-      tk->num_br = 0;
-      tk->jp2xdata = NULL;
-    }
-  }
-  return 0;
-}
-
-/*
-* Time To Sample box Decompact
-*
-*/
-void mj2_tts_decompact(mj2_tk_t * tk)
-{
-  int i, j;
-  tk->num_samples = 0;
-  for (i = 0; i < tk->num_tts; i++) {
-    tk->num_samples += tk->tts[i].sample_count;
-  }
-
-  tk->sample = (mj2_sample_t*) opj_malloc(tk->num_samples * sizeof(mj2_sample_t));
-
-  for (i = 0; i < tk->num_tts; i++) {
-    for (j = 0; j < tk->tts[i].sample_count; j++) {
-      tk->sample[j].sample_delta = tk->tts[i].sample_delta;
-    }
-  }
-}
-
-/*
-* Sample To Chunk box Decompact
-*
-*/
-void mj2_stsc_decompact(mj2_tk_t * tk)
-{
-  int j, i;
-  unsigned int k;
-  int sampleno=0;
-  
-  if (tk->num_samplestochunk == 1) {
-    tk->num_chunks =
-      (unsigned int) ceil((double) tk->num_samples /
-      (double) tk->sampletochunk[0].samples_per_chunk);
-	 tk->chunk = (mj2_chunk_t*) opj_malloc(tk->num_chunks * sizeof(mj2_chunk_t));
-    for (k = 0; k < tk->num_chunks; k++) {
-      tk->chunk[k].num_samples = tk->sampletochunk[0].samples_per_chunk;
-    }
-    
-  } else {
-    tk->chunk = (mj2_chunk_t*) opj_malloc(tk->num_samples * sizeof(mj2_chunk_t));
-    tk->num_chunks = 0;
-    for (i = 0; i < tk->num_samplestochunk -1 ; i++) {
-      for (j = tk->sampletochunk[i].first_chunk - 1;
-      j < tk->sampletochunk[i + 1].first_chunk - 1; j++) {
-				tk->chunk[j].num_samples = tk->sampletochunk[i].samples_per_chunk;
-				tk->num_chunks++;
-				sampleno += tk->chunk[j].num_samples;
-      }
-    }
-    tk->num_chunks += (int)(tk->num_samples  - sampleno) / tk->sampletochunk[tk->num_samplestochunk - 1].samples_per_chunk;
-    for (k = tk->sampletochunk[tk->num_samplestochunk - 1].first_chunk - 1;
-    k < tk->num_chunks; k++) {
-      tk->chunk[k].num_samples =
-				tk->sampletochunk[tk->num_samplestochunk - 1].samples_per_chunk;
-    }
-    tk->chunk = (mj2_chunk_t*)
-	 opj_realloc(tk->chunk, tk->num_chunks * sizeof(mj2_chunk_t));
-  }
-  
-}
-
-
-/*
-* Chunk offset box Decompact
-*
-*/
-void mj2_stco_decompact(mj2_tk_t * tk)
-{
-  int j;
-  unsigned int i;
-  int k = 0;
-  int intra_chunk_offset;
-	
-  for (i = 0; i < tk->num_chunks; i++) {
-    intra_chunk_offset = 0;
-    for (j = 0; j < tk->chunk[i].num_samples; j++) {
-      tk->sample[k].offset = intra_chunk_offset + tk->chunk[i].offset;
-      intra_chunk_offset += tk->sample[k].sample_size;
-      k++;
-    }
-  }
-}
-
-/*
-* Write the JP box
-*
-* JP Signature box
-*
-*/
-void mj2_write_jp(opj_cio_t *cio)
-{
-  mj2_box_t box;
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-	
-  cio_write(cio, MJ2_JP, 4);		/* JP */
-  cio_write(cio, 0x0d0a870a, 4);	/* 0x0d0a870a required in a JP box */
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JP box
-*
-* JPEG 2000 signature
-*
-*/
-int mj2_read_jp(opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JP != box.type) {	/* Check Marker */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JP Marker\n");
-    return 1;
-  }
-  if (0x0d0a870a != cio_read(cio, 4)) {	/* read the 0x0d0a870a required in a JP box */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP Marker\n");
-    return 1;
-  }
-  if (cio_tell(cio) - box.init_pos != box.length) {	/* Check box length */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP Box size \n");
-    return 1;
-  }
-  return 0;
-	
-}
-
-/*
-* Write the FTYP box
-*
-* File type box
-*
-*/
-void mj2_write_ftyp(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-	
-  cio_write(cio, MJ2_FTYP, 4);	/* FTYP       */
-  cio_write(cio, movie->brand, 4);	/* BR         */
-  cio_write(cio, movie->minversion, 4);	/* MinV       */
-	
-  for (i = 0; i < movie->num_cl; i++)
-    cio_write(cio, movie->cl[i], 4);	/* CL         */
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* Length     */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the FTYP box
-*
-* File type box
-*
-*/
-int mj2_read_ftyp(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);	/* Box Size */
-  if (MJ2_FTYP != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected FTYP Marker\n");
-    return 1;
-  }
-	
-  movie->brand = cio_read(cio, 4);	/* BR              */
-  movie->minversion = cio_read(cio, 4);	/* MinV            */
-  movie->num_cl = (box.length - 16) / 4;
-  movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
-
-  for (i = movie->num_cl - 1; i > -1; i--)
-    movie->cl[i] = cio_read(cio, 4);	/* CLi */
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with FTYP Box\n");
-    return 1;
-  }
-  return 0;
-}
-
-
-/*
-* Write the STCO box
-*
-* Chunk Offset Box
-*
-*/
-void mj2_write_stco(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STCO, 4);	/* STCO       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, tk->num_chunks, 4);	/* Entry Count */
-	
-  for (i = 0; i < tk->num_chunks; i++) {
-    cio_write(cio, tk->chunk[i].offset, 4);	/* Entry offset */
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STCO box
-*
-* Chunk Offset Box
-*
-*/
-int mj2_read_stco(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  unsigned int i;
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);	/* Box Size */
-  if (MJ2_STCO != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STCO Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STCO box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STCO box. Expected flag 0\n");
-    return 1;
-  }
-	
-	
-  if (cio_read(cio, 4) != tk->num_chunks) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, 
-			"Error in STCO box: expecting same amount of entry-count as chunks \n");
-  } else {
-    for (i = 0; i < tk->num_chunks; i++) {
-      tk->chunk[i].offset = cio_read(cio, 4);	/* Entry offset */
-    }
-  }
-	
-  mj2_stco_decompact(tk);
-	
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STCO Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the STSZ box
-*
-* Sample size box
-*
-*/
-void mj2_write_stsz(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STSZ, 4);	/* STSZ       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  if (tk->same_sample_size == 1) {	/* If they all have the same size */
-    cio_write(cio, tk->sample[0].sample_size, 4);	/* Size */
-		
-    cio_write(cio, 1, 4);		/* Entry count = 1 */
-  }
-	
-  else {
-    cio_write(cio, 0, 4);		/* Sample Size = 0 becase they all have different sizes */
-		
-    cio_write(cio, tk->num_samples, 4);	/* Sample Count */
-		
-    for (i = 0; i < tk->num_samples; i++) {
-      cio_write(cio, tk->sample[i].sample_size, 4);
-    }
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STSZ box
-*
-* Sample size box
-*
-*/
-int mj2_read_stsz(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int sample_size;
-  unsigned int i;
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);	/* Box Size */
-  if (MJ2_STSZ != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STSZ Marker\n");
-    return 1;
-  }
-	
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STSZ box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STSZ box. Expected flag 0\n");
-    return 1;
-  }
-	
-  sample_size = cio_read(cio, 4);
-	
-  if (sample_size != 0) {	/* Samples do have the same size */
-    tk->same_sample_size = 1;
-    for (i = 0; i < tk->num_samples; i++) {
-      tk->sample[i].sample_size = sample_size;
-    }
-    cio_skip(cio,4);		/* Sample count = 1 */
-  } else {
-    tk->same_sample_size = 0;
-    if (tk->num_samples != cio_read(cio, 4)) {	/* Sample count */
-      opj_event_msg(cio->cinfo, EVT_ERROR,
-				"Error in STSZ box. Expected that sample-count is number of samples in track\n");
-      return 1;
-    }
-    for (i = 0; i < tk->num_samples; i++) {
-      tk->sample[i].sample_size = cio_read(cio, 4);	/* Sample Size */
-    }
-		
-    if (cio_tell(cio) - box.init_pos != box.length) {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STSZ Box size\n");
-      return 1;
-    }
-  }
-  return 0;
-	
-}
-
-/*
-* Write the STSC box
-*
-* Sample to Chunk
-*
-*/
-void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STSC, 4);	/* STSC       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, tk->num_samplestochunk, 4);	/* Entry Count */
-	
-  for (i = 0; i < tk->num_samplestochunk; i++) {
-    cio_write(cio, tk->sampletochunk[i].first_chunk, 4);	/* First Chunk */
-    cio_write(cio, tk->sampletochunk[i].samples_per_chunk, 4);	/* Samples per chunk */
-    cio_write(cio, tk->sampletochunk[i].sample_descr_idx, 4);	/* Samples description index */
-  }
-	
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STSC box
-*
-* Sample to Chunk
-*
-*/
-int mj2_read_stsc(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);	/* Box Size */
-  if (MJ2_STSC != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STSC Marker\n");
-    return 1;
-  }
-	
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STSC box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STSC box. Expected flag 0\n");
-    return 1;
-  }
-	
-  tk->num_samplestochunk = cio_read(cio, 4);
-
-  tk->sampletochunk = (mj2_sampletochunk_t*) opj_malloc(tk->num_samplestochunk * sizeof(mj2_sampletochunk_t));
-
-  for (i = 0; i < tk->num_samplestochunk; i++) {
-    tk->sampletochunk[i].first_chunk = cio_read(cio, 4);
-    tk->sampletochunk[i].samples_per_chunk = cio_read(cio, 4);
-    tk->sampletochunk[i].sample_descr_idx = cio_read(cio, 4);
-  }
-	
-  mj2_stsc_decompact(tk);	/* decompact sample to chunk box */
-	
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STSC Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the STTS box
-*
-* Time to Sample Box
-*
-*/
-void mj2_write_stts(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  int i;
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STTS, 4);	/* STTS       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, tk->num_tts, 4);	/* entry_count */
-  for (i = 0; i < tk->num_tts; i++) {
-    cio_write(cio, tk->tts[i].sample_count, 4);	/* Sample-count */
-    cio_write(cio, tk->tts[i].sample_delta, 4);	/* Sample-Delta */
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STTS box
-*
-* 
-*
-*/
-int mj2_read_stts(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_STTS != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STTS Marker\n");
-    return 1;
-  }
-	
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STTS box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STTS box. Expected flag 0\n");
-    return 1;
-  }
-	
-  tk->num_tts = cio_read(cio, 4);
-
-  tk->tts = (mj2_tts_t*) opj_malloc(tk->num_tts * sizeof(mj2_tts_t));
-
-  for (i = 0; i < tk->num_tts; i++) {
-    tk->tts[i].sample_count = cio_read(cio, 4);
-    tk->tts[i].sample_delta = cio_read(cio, 4);
-  }
-	
-  mj2_tts_decompact(tk);
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STTS Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the FIEL box
-*
-* Field coding Box
-*
-*/
-void mj2_write_fiel(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_FIEL, 4);	/* STTS       */
-	
-  cio_write(cio, tk->fieldcount, 1);	/* Field count */
-  cio_write(cio, tk->fieldorder, 1);	/* Field order */
-	
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the FIEL box
-*
-* Field coding Box
-*
-*/
-int mj2_read_fiel(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_FIEL != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected FIEL Marker\n");
-    return 1;
-  }
-	
-	
-  tk->fieldcount = cio_read(cio, 1);
-  tk->fieldorder = cio_read(cio, 1);
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with FIEL Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the ORFO box
-*
-* Original Format Box
-*
-*/
-void mj2_write_orfo(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_ORFO, 4);
-	
-  cio_write(cio, tk->or_fieldcount, 1);	/* Original Field count */
-  cio_write(cio, tk->or_fieldorder, 1);	/* Original Field order */
-	
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the ORFO box
-*
-* Original Format Box
-*
-*/
-int mj2_read_orfo(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_ORFO != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected ORFO Marker\n");
-    return 1;
-  }
-	
-	
-  tk->or_fieldcount = cio_read(cio, 1);
-  tk->or_fieldorder = cio_read(cio, 1);
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with ORFO Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the JP2P box
-*
-* MJP2 Profile Box
-*
-*/
-void mj2_write_jp2p(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  int i;
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_JP2P, 4);
-	
-  cio_write(cio, 0, 4);		/* Version 0, flags =0 */
-	
-  for (i = 0; i < tk->num_br; i++) {
-    cio_write(cio, tk->br[i], 4);
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JP2P box
-*
-* MJP2 Profile Box
-*
-*/
-int mj2_read_jp2p(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JP2P != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JP2P Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in JP2P box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in JP2P box. Expected flag 0\n");
-    return 1;
-  }
-	
-	
-  tk->num_br = (box.length - 12) / 4;
-  tk->br = (unsigned int*) opj_malloc(tk->num_br * sizeof(unsigned int));
-
-  for (i = 0; i < tk->num_br; i++) {
-    tk->br[i] = cio_read(cio, 4);
-  }
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP2P Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the JP2X box
-*
-* MJP2 Prefix Box
-*
-*/
-void mj2_write_jp2x(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  int i;
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_JP2X, 4);
-	
-  for (i = 0; i < tk->num_jp2x; i++) {
-    cio_write(cio, tk->jp2xdata[i], 1);
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JP2X box
-*
-* MJP2 Prefix Box
-*
-*/
-int mj2_read_jp2x(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  unsigned int i;
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JP2X != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JP2X Marker\n");
-    return 1;
-  }
-	
-	
-  tk->num_jp2x = (box.length - 8);
-  tk->jp2xdata = (unsigned char*) opj_malloc(tk->num_jp2x * sizeof(unsigned char));
-
-  for (i = 0; i < tk->num_jp2x; i++) {
-    tk->jp2xdata[i] = cio_read(cio, 1);
-  }
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP2X Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the JSUB box
-*
-* MJP2 Subsampling Box
-*
-*/
-void mj2_write_jsub(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_JSUB, 4);
-	
-  cio_write(cio, tk->hsub, 1);
-  cio_write(cio, tk->vsub, 1);
-  cio_write(cio, tk->hoff, 1);
-  cio_write(cio, tk->voff, 1);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JSUB box
-*
-* MJP2 Subsampling Box
-*
-*/
-int mj2_read_jsub(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JSUB != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JSUB Marker\n");
-    return 1;
-  }
-	
-  tk->hsub = cio_read(cio, 1);
-  tk->vsub = cio_read(cio, 1);
-  tk->hoff = cio_read(cio, 1);;
-  tk->voff = cio_read(cio, 1);
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JSUB Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the SMJ2 box
-*
-* Visual Sample Entry Description
-*
-*/
-void mj2_write_smj2(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MJ2, 4);	/* MJ2       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, 1, 4);
-	
-  cio_write(cio, 0, 2);		/* Pre-defined */
-	
-  cio_write(cio, 0, 2);		/* Reserved */
-	
-  cio_write(cio, 0, 4);		/* Pre-defined */
-  cio_write(cio, 0, 4);		/* Pre-defined */
-  cio_write(cio, 0, 4);		/* Pre-defined */
-	
-  cio_write(cio, tk->w, 2);		/* Width  */
-  cio_write(cio, tk->h, 2);		/* Height */
-	
-  cio_write(cio, tk->horizresolution, 4);	/* Horizontal resolution */
-  cio_write(cio, tk->vertresolution, 4);	/* Vertical resolution   */
-	
-  cio_write(cio, 0, 4);		/* Reserved */
-	
-  cio_write(cio, 1, 2);		/* Pre-defined = 1 */
-	
-  cio_write(cio, tk->compressorname[0], 4);	/* Compressor Name */
-  cio_write(cio, tk->compressorname[1], 4);
-  cio_write(cio, tk->compressorname[2], 4);
-  cio_write(cio, tk->compressorname[3], 4);
-  cio_write(cio, tk->compressorname[4], 4);
-  cio_write(cio, tk->compressorname[5], 4);
-  cio_write(cio, tk->compressorname[6], 4);
-  cio_write(cio, tk->compressorname[7], 4);
-	
-  cio_write(cio, tk->depth, 2);	/* Depth */
-	
-  cio_write(cio, 0xffff, 2);		/* Pre-defined = -1 */
-	
-  jp2_write_jp2h(&tk->jp2_struct, cio);
-	
-  mj2_write_fiel(tk, cio);
-	
-  if (tk->num_br != 0)
-    mj2_write_jp2p(tk, cio);
-  if (tk->num_jp2x != 0)
-    mj2_write_jp2x(tk, cio);
-	
-  mj2_write_jsub(tk, cio);
-  mj2_write_orfo(tk, cio);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the SMJ2 box
-*
-* Visual Sample Entry Description
-*
-*/
-int mj2_read_smj2(opj_image_t * img, mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  mj2_box_t box2;
-  int i;
-  opj_jp2_color_t color;
-	
-  mj2_read_boxhdr(&box, cio);
-	
-  if (MJ2_MJ2 != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error in SMJ2 box: Expected MJ2 Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in MJP2 box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in MJP2 box. Expected flag 0\n");
-    return 1;
-  }
-	
-  cio_skip(cio,4);
-	
-  cio_skip(cio,2);			/* Pre-defined */
-	
-  cio_skip(cio,2);			/* Reserved */
-	
-  cio_skip(cio,4);			/* Pre-defined */
-  cio_skip(cio,4);			/* Pre-defined */
-  cio_skip(cio,4);			/* Pre-defined */
-	
-  tk->w = cio_read(cio, 2);		/* Width  */
-  tk->h = cio_read(cio, 2);		/* Height */
-	
-  tk->horizresolution = cio_read(cio, 4);	/* Horizontal resolution */
-  tk->vertresolution = cio_read(cio, 4);	/* Vertical resolution   */
-	
-  cio_skip(cio,4);			/* Reserved */
-	
-  cio_skip(cio,2);			/* Pre-defined = 1 */
-	
-  tk->compressorname[0] = cio_read(cio, 4);	/* Compressor Name */
-  tk->compressorname[1] = cio_read(cio, 4);
-  tk->compressorname[2] = cio_read(cio, 4);
-  tk->compressorname[3] = cio_read(cio, 4);
-  tk->compressorname[4] = cio_read(cio, 4);
-  tk->compressorname[5] = cio_read(cio, 4);
-  tk->compressorname[6] = cio_read(cio, 4);
-  tk->compressorname[7] = cio_read(cio, 4);
-	
-  tk->depth = cio_read(cio, 2);	/* Depth */
-	
-  /* Init std value */
-  tk->num_jp2x = 0;
-  tk->fieldcount = 1;
-  tk->fieldorder = 0;
-  tk->or_fieldcount = 1;
-  tk->or_fieldorder = 0;
-	
-  cio_skip(cio,2);			/* Pre-defined = -1 */
-  memset(&color, 0, sizeof(opj_jp2_color_t));
-	
-  if (!jp2_read_jp2h(&tk->jp2_struct, cio, &color)) {
-		opj_event_msg(tk->cinfo, EVT_ERROR, "Error reading JP2H Box\n");
-    return 1;
-  }
-
-  tk->jp2_struct.comps = (opj_jp2_comps_t*) opj_malloc(tk->jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
-  tk->jp2_struct.cl = (unsigned int*) opj_malloc(sizeof(unsigned int));
-
-  tk->num_br = 0;
-  tk->num_jp2x = 0;
-	
-  for (i = 0; cio_tell(cio) - box.init_pos < box.length; i++) {
-    mj2_read_boxhdr(&box2, cio);
-    cio_seek(cio, box2.init_pos);
-    switch (box2.type) {
-    case MJ2_FIEL:
-      if (mj2_read_fiel(tk, cio))
-				return 1;
-      break;
-			
-    case MJ2_JP2P:
-      if (mj2_read_jp2p(tk, cio))
-				return 1;
-      break;
-			
-    case MJ2_JP2X:
-      if (mj2_read_jp2x(tk, cio))
-				return 1;
-      break;
-			
-    case MJ2_JSUB:
-      if (mj2_read_jsub(tk, cio))
-				return 1;
-      break;
-			
-    case MJ2_ORFO:
-      if (mj2_read_orfo(tk, cio))
-				return 1;
-      break;
-			
-    default:
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MJP2 Box size\n");
-      return 1;
-      break;
-			
-    }
-  }
-  return 0;
-}
-
-
-/*
-* Write the STSD box
-*
-* Sample Description
-*
-*/
-void mj2_write_stsd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STSD, 4);	/* STSD       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, 1, 4);		/* entry_count = 1 (considering same JP2 headerboxes) */
-	
-  if (tk->track_type == 0) {
-    mj2_write_smj2(tk, cio);
-  } else if (tk->track_type == 1) {
-    // Not implemented
-  }
-  if (tk->track_type == 2) {
-    // Not implemented
-  }
-	
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STSD box
-*
-* Sample Description
-*
-*/
-int mj2_read_stsd(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  int i;
-  int entry_count, len_2skip;
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-	
-  if (MJ2_STSD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STSD Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STSD box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STSD box. Expected flag 0\n");
-    return 1;
-  }
-	
-  entry_count = cio_read(cio, 4);
-	
-  if (tk->track_type == 0) {
-    for (i = 0; i < entry_count; i++) {
-      if (mj2_read_smj2(img, tk, cio))
-				return 1;
-    }
-  } else if (tk->track_type == 1) {
-    len_2skip = cio_read(cio, 4);	// Not implemented -> skipping box
-    cio_skip(cio,len_2skip - 4);
-  } else if (tk->track_type == 2) {
-    len_2skip = cio_read(cio, 4);	// Not implemented -> skipping box
-    cio_skip(cio,len_2skip - 4);
-  }
-	
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STSD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the STBL box
-*
-* Sample table box box
-*
-*/
-void mj2_write_stbl(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STBL, 4);	/* STBL       */
-	
-  mj2_write_stsd(tk, cio);
-  mj2_write_stts(tk, cio);
-  mj2_write_stsc(tk, cio);
-  mj2_write_stsz(tk, cio);
-  mj2_write_stco(tk, cio);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STBL box
-*
-* Sample table box box
-*
-*/
-int mj2_read_stbl(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_STBL != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STBL Marker\n");
-    return 1;
-  }
-	
-  if (mj2_read_stsd(tk, img, cio))
-    return 1;
-  if (mj2_read_stts(tk, cio))
-    return 1;
-  if (mj2_read_stsc(tk, cio))
-    return 1;
-  if (mj2_read_stsz(tk, cio))
-    return 1;
-  if (mj2_read_stco(tk, cio))
-    return 1;
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STBL Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the URL box
-*
-* URL box
-*
-*/
-void mj2_write_url(mj2_tk_t * tk, int url_num, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_URL, 4);	/* URL       */
-	
-  if (url_num == 0)
-    cio_write(cio, 1, 4);		/* Version = 0, flags = 1 because stored in same file */
-  else {
-    cio_write(cio, 0, 4);		/* Version = 0, flags =  0 */
-    cio_write(cio, tk->url[url_num - 1].location[0], 4);
-    cio_write(cio, tk->url[url_num - 1].location[1], 4);
-    cio_write(cio, tk->url[url_num - 1].location[2], 4);
-    cio_write(cio, tk->url[url_num - 1].location[3], 4);
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the URL box
-*
-* URL box
-*
-*/
-int mj2_read_url(mj2_tk_t * tk, int urn_num, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_URL != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected URL Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in URL box\n");
-    return 1;
-  }
-	
-  if (1 != cio_read(cio, 3)) {	/* If flags = 1 --> media data in file */
-    tk->url[urn_num].location[0] = cio_read(cio, 4);
-    tk->url[urn_num].location[1] = cio_read(cio, 4);
-    tk->url[urn_num].location[2] = cio_read(cio, 4);
-    tk->url[urn_num].location[3] = cio_read(cio, 4);
-  } else {
-    tk->num_url--;
-  }
-	
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with URL Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the URN box
-*
-* URN box
-*
-*/
-void mj2_write_urn(mj2_tk_t * tk, int urn_num, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_URN, 4);	/* URN       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags =  0 */
-	
-  cio_write(cio, tk->urn[urn_num].name[0], 4);
-  cio_write(cio, tk->urn[urn_num].name[1], 4);
-  cio_write(cio, tk->urn[urn_num].name[2], 4);
-  cio_write(cio, tk->urn[urn_num].name[3], 4);
-  cio_write(cio, tk->urn[urn_num].location[0], 4);
-  cio_write(cio, tk->urn[urn_num].location[1], 4);
-  cio_write(cio, tk->urn[urn_num].location[2], 4);
-  cio_write(cio, tk->urn[urn_num].location[3], 4);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the URN box
-*
-* URN box
-*
-*/
-int mj2_read_urn(mj2_tk_t * tk, int urn_num, opj_cio_t *cio)
-{
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_URN != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected URN Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in URN box\n");
-    return 1;
-  }
-	
-  if (1 != cio_read(cio, 3)) {	/* If flags = 1 --> media data in file */
-    tk->urn[urn_num].name[0] = cio_read(cio, 4);
-    tk->urn[urn_num].name[1] = cio_read(cio, 4);
-    tk->urn[urn_num].name[2] = cio_read(cio, 4);
-    tk->urn[urn_num].name[3] = cio_read(cio, 4);
-    tk->urn[urn_num].location[0] = cio_read(cio, 4);
-    tk->urn[urn_num].location[1] = cio_read(cio, 4);
-    tk->urn[urn_num].location[2] = cio_read(cio, 4);
-    tk->urn[urn_num].location[3] = cio_read(cio, 4);
-  }
-	
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with URN Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-
-/*
-* Write the DREF box
-*
-* Data reference box
-*
-*/
-void mj2_write_dref(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_DREF, 4);	/* DREF       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  if (tk->num_url + tk->num_urn == 0) {	/* Media data in same file */
-    cio_write(cio, 1, 4);		/* entry_count = 1 */
-    mj2_write_url(tk, 0, cio);
-  } else {
-    cio_write(cio, tk->num_url + tk->num_urn, 4);	/* entry_count */
-		
-    for (i = 0; i < tk->num_url; i++)
-      mj2_write_url(tk, i + 1, cio);
-		
-    for (i = 0; i < tk->num_urn; i++)
-      mj2_write_urn(tk, i, cio);
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the DREF box
-*
-* Data reference box
-*
-*/
-int mj2_read_dref(mj2_tk_t * tk, opj_cio_t *cio)
-{
-	
-  int i;
-  int entry_count, marker;
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_DREF != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected DREF Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in DREF box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in DREF box. Expected flag 0\n");
-    return 1;
-  }
-	
-  entry_count = cio_read(cio, 4);
-  tk->num_url = 0;
-  tk->num_urn = 0;
-	
-  for (i = 0; i < entry_count; i++) {
-    cio_skip(cio,4);
-    marker = cio_read(cio, 4);
-    if (marker == MJ2_URL) {
-      cio_skip(cio,-8);
-      tk->num_url++;
-      if (mj2_read_url(tk, tk->num_url, cio))
-				return 1;
-    } else if (marker == MJ2_URN) {
-      cio_skip(cio,-8);
-      tk->num_urn++;
-      if (mj2_read_urn(tk, tk->num_urn, cio))
-				return 1;
-    } else {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with in DREF box. Expected URN or URL box\n");
-      return 1;
-    }
-		
-  }
-	
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with DREF Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the DINF box
-*
-* Data information box
-*
-*/
-void mj2_write_dinf(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_DINF, 4);	/* DINF       */
-	
-  mj2_write_dref(tk, cio);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the DINF box
-*
-* Data information box
-*
-*/
-int mj2_read_dinf(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_DINF != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected DINF Marker\n");
-    return 1;
-  }
-	
-  if (mj2_read_dref(tk, cio))
-    return 1;
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with DINF Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the VMHD box
-*
-* Video Media information box
-*
-*/
-void mj2_write_vmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_VMHD, 4);	/* VMHD       */
-	
-  cio_write(cio, 1, 4);		/* Version = 0, flags = 1 */
-	
-  cio_write(cio, tk->graphicsmode, 2);
-  cio_write(cio, tk->opcolor[0], 2);
-  cio_write(cio, tk->opcolor[1], 2);
-  cio_write(cio, tk->opcolor[2], 2);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the VMHD box
-*
-* Video Media information box
-*
-*/
-int mj2_read_vmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_VMHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected VMHD Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in VMHD box\n");
-    return 1;
-  }
-	
-  if (1 != cio_read(cio, 3)) {	/* Flags = 1  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in VMHD box. Expected flag 1\n");
-    return 1;
-  }
-	
-  tk->track_type = 0;
-  tk->graphicsmode = cio_read(cio, 2);
-  tk->opcolor[0] = cio_read(cio, 2);
-  tk->opcolor[1] = cio_read(cio, 2);
-  tk->opcolor[2] = cio_read(cio, 2);
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with VMHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the SMHD box
-*
-* Sound Media information box
-*
-*/
-void mj2_write_smhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_SMHD, 4);	/* SMHD       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, tk->balance, 2);
-	
-  cio_write(cio, 0, 2);		/* Reserved */
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the SMHD box
-*
-* Sound Media information box
-*
-*/
-int mj2_read_smhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_SMHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected SMHD Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in SMHD box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in SMHD box. Expected flag 0\n");
-    return 1;
-  }
-	
-  tk->track_type = 1;
-  tk->balance = cio_read(cio, 2);
-	
-  /* Init variables to zero to avoid problems when freeeing memory
-  The values will possibly be overidded when decoding the track structure */
-  tk->num_br = 0;
-  tk->num_url = 0;
-  tk->num_urn = 0;
-  tk->num_chunks = 0;
-  tk->num_tts = 0;
-  tk->num_samplestochunk = 0;
-  tk->num_samples = 0;
-	
-  cio_skip(cio,2);			/* Reserved */
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with SMHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the HMHD box
-*
-* Hint Media information box
-*
-*/
-void mj2_write_hmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_HMHD, 4);	/* HMHD       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, tk->maxPDUsize, 2);
-  cio_write(cio, tk->avgPDUsize, 2);
-  cio_write(cio, tk->maxbitrate, 4);
-  cio_write(cio, tk->avgbitrate, 4);
-  cio_write(cio, tk->slidingavgbitrate, 4);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the HMHD box
-*
-* Hint Media information box
-*
-*/
-int mj2_read_hmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_HMHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected HMHD Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in HMHD box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in HMHD box. Expected flag 0\n");
-    return 1;
-  }
-	
-  tk->track_type = 2;
-  tk->maxPDUsize = cio_read(cio, 2);
-  tk->avgPDUsize = cio_read(cio, 2);
-  tk->maxbitrate = cio_read(cio, 4);
-  tk->avgbitrate = cio_read(cio, 4);
-  tk->slidingavgbitrate = cio_read(cio, 4);
-	
-  /* Init variables to zero to avoid problems when freeeing memory
-  The values will possibly be overidded when decoding the track structure */
-  tk->num_br = 0;
-  tk->num_url = 0;
-  tk->num_urn = 0;
-  tk->num_chunks = 0;
-  tk->num_tts = 0;
-  tk->num_samplestochunk = 0;
-  tk->num_samples = 0;
-	
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with HMHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MINF box
-*
-* Media information box
-*
-*/
-void mj2_write_minf(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MINF, 4);	/* MINF       */
-	
-  if (tk->track_type == 0) {
-    mj2_write_vmhd(tk, cio);
-  } else if (tk->track_type == 1) {
-    mj2_write_smhd(tk, cio);
-  } else if (tk->track_type == 2) {
-    mj2_write_hmhd(tk, cio);
-  }
-	
-  mj2_write_dinf(tk, cio);
-  mj2_write_stbl(tk, cio);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MINF box
-*
-* Media information box
-*
-*/
-int mj2_read_minf(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-	
-  unsigned int box_type;
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MINF != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MINF Marker\n");
-    return 1;
-  }
-	
-  cio_skip(cio,4);
-  box_type = cio_read(cio, 4);
-  cio_skip(cio,-8);
-	
-  if (box_type == MJ2_VMHD) {
-    if (mj2_read_vmhd(tk, cio))
-      return 1;
-  } else if (box_type == MJ2_SMHD) {
-    if (mj2_read_smhd(tk, cio))
-      return 1;
-  } else if (box_type == MJ2_HMHD) {
-    if (mj2_read_hmhd(tk, cio))
-      return 1;
-  } else {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error in MINF box expected vmhd, smhd or hmhd\n");
-    return 1;
-  }
-	
-  if (mj2_read_dinf(tk, cio))
-    return 1;
-	
-  if (mj2_read_stbl(tk, img, cio))
-    return 1;
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MINF Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the HDLR box
-*
-* Handler reference box
-*
-*/
-void mj2_write_hdlr(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_HDLR, 4);	/* HDLR       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, 0, 4);		/* Predefine */
-	
-  tk->name = 0;			/* The track name is immediately determined by the track type */
-	
-  if (tk->track_type == 0) {
-    tk->handler_type = 0x76696465;	/* Handler type: vide */
-    cio_write(cio, tk->handler_type, 4);
-		
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);		/* Reserved */
-		
-    cio_write(cio, 0x76696465, 4);
-    cio_write(cio, 0x6F206d65, 4);
-    cio_write(cio, 0x64696120, 4);
-    cio_write(cio, 0x74726163, 4);
-    cio_write(cio, 0x6b00, 2);	/* String: video media track */
-  } else if (tk->track_type == 1) {
-    tk->handler_type = 0x736F756E;	/* Handler type: soun */
-    cio_write(cio, tk->handler_type, 4);
-		
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);		/* Reserved */
-		
-    cio_write(cio, 0x536F756E, 4);
-    cio_write(cio, 0x6400, 2);	/* String: Sound */
-  } else if (tk->track_type == 2) {
-    tk->handler_type = 0x68696E74;	/* Handler type: hint */
-    cio_write(cio, tk->handler_type, 4);
-		
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);		/* Reserved */
-		
-    cio_write(cio, 0x48696E74, 4);
-    cio_write(cio, 0, 2);		/* String: Hint */
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the HDLR box
-*
-* Handler reference box
-*
-*/
-int mj2_read_hdlr(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_HDLR != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected HDLR Marker\n");
-    return 1;
-  }
-	
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in HDLR box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in HDLR box. Expected flag 0\n");
-    return 1;
-  }
-	
-  cio_skip(cio,4);			/* Reserved */
-	
-  tk->handler_type = cio_read(cio, 4);
-  cio_skip(cio,12);			/* Reserved */
-	
-  tk->name_size = box.length - 32;
-
-  tk->name = (char*) opj_malloc(tk->name_size * sizeof(char));
-  for (i = 0; i < tk->name_size; i++) {
-    tk->name[i] = cio_read(cio, 1);	/* Name */
-  }
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with HDLR Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MDHD box
-*
-* Media Header Box
-*
-*/
-void mj2_write_mdhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-  time_t ltime;
-  unsigned int modification_time;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MDHD, 4);	/* MDHD       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  cio_write(cio, tk->creation_time, 4);	/* Creation Time */
-	
-  time(&ltime);			/* Time since 1/1/70 */
-  modification_time = (unsigned int)ltime + 2082844800;	/* Seoonds between 1/1/04 and 1/1/70 */
-	
-  cio_write(cio, modification_time, 4);	/* Modification Time */
-	
-  cio_write(cio, tk->timescale, 4);	/* Timescale */
-	
-  tk->duration = 0;
-	
-  for (i = 0; i < tk->num_samples; i++)
-    tk->duration += tk->sample[i].sample_delta;
-	
-  cio_write(cio, tk->duration, 4);	/* Duration */
-	
-  cio_write(cio, tk->language, 2);	/* Language */
-	
-  cio_write(cio, 0, 2);		/* Predefined */
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MDHD box
-*
-* Media Header Box
-*
-*/
-int mj2_read_mdhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (!(MJ2_MHDR == box.type || MJ2_MDHD == box.type)) {	// Kakadu writes MHDR instead of MDHD
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MDHD Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in MDHD box\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 3)) {	/* Flags = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in MDHD box. Expected flag 0\n");
-    return 1;
-  }
-	
-	
-  tk->creation_time = cio_read(cio, 4);	/* Creation Time */
-	
-  tk->modification_time = cio_read(cio, 4);	/* Modification Time */
-	
-  tk->timescale = cio_read(cio, 4);	/* Timescale */
-	
-  tk->duration = cio_read(cio, 4);	/* Duration */
-	
-  tk->language = cio_read(cio, 2);	/* Language */
-	
-  cio_skip(cio,2);			/* Predefined */
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MDHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MDIA box
-*
-* Media box
-*
-*/
-void mj2_write_mdia(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MDIA, 4);	/* MDIA       */
-	
-  mj2_write_mdhd(tk, cio);
-  mj2_write_hdlr(tk, cio);
-  mj2_write_minf(tk, cio);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MDIA box
-*
-* Media box
-*
-*/
-int mj2_read_mdia(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MDIA != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MDIA Marker\n");
-    return 1;
-  }
-	
-  if (mj2_read_mdhd(tk, cio))
-    return 1;
-  if (mj2_read_hdlr(tk, cio))
-    return 1;
-  if (mj2_read_minf(tk, img, cio))
-    return 1;
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MDIA Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the TKHD box
-*
-* Track Header box
-*
-*/
-void mj2_write_tkhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-  time_t ltime;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-	
-  cio_write(cio, MJ2_TKHD, 4);	/* TKHD       */
-	
-  cio_write(cio, 3, 4);		/* Version=0, flags=3 */
-	
-  time(&ltime);			/* Time since 1/1/70 */
-  tk->modification_time = (unsigned int)ltime + 2082844800;	/* Seoonds between 1/1/04 and 1/1/70 */
-	
-  cio_write(cio, tk->creation_time, 4);	/* Creation Time */
-	
-  cio_write(cio, tk->modification_time, 4);	/* Modification Time */
-	
-  cio_write(cio, tk->track_ID, 4);	/* Track ID */
-	
-  cio_write(cio, 0, 4);		/* Reserved */
-	
-  tk->duration = 0;
-	
-  for (i = 0; i < tk->num_samples; i++)
-    tk->duration += tk->sample[i].sample_delta;
-	
-  cio_write(cio, tk->duration, 4);	/* Duration */
-	
-  cio_write(cio, 0, 4);		/* Reserved */
-  cio_write(cio, 0, 4);		/* Reserved */
-	
-  cio_write(cio, tk->layer, 2);	/* Layer    */
-	
-  cio_write(cio, 0, 2);		/* Predefined */
-	
-  cio_write(cio, tk->volume, 2);	/* Volume       */
-	
-  cio_write(cio, 0, 2);		/* Reserved */
-	
-  cio_write(cio, tk->trans_matrix[0], 4);	/* Transformation matrix for track */
-  cio_write(cio, tk->trans_matrix[1], 4);
-  cio_write(cio, tk->trans_matrix[2], 4);
-  cio_write(cio, tk->trans_matrix[3], 4);
-  cio_write(cio, tk->trans_matrix[4], 4);
-  cio_write(cio, tk->trans_matrix[5], 4);
-  cio_write(cio, tk->trans_matrix[6], 4);
-  cio_write(cio, tk->trans_matrix[7], 4);
-  cio_write(cio, tk->trans_matrix[8], 4);
-	
-  cio_write(cio, tk->visual_w, 4);	/* Video Visual Width  */
-	
-  cio_write(cio, tk->visual_h, 4);	/* Video Visual Height */
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the TKHD box
-*
-* Track Header box
-*
-*/
-int mj2_read_tkhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int flag;
-	
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-	
-  if (MJ2_TKHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected TKHD Marker\n");
-    return 1;
-  }
-	
-  if (0 != cio_read(cio, 1)) {	/* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in TKHD box\n");
-    return 1;
-  }
-	
-  flag = cio_read(cio, 3);
-	
-  if (!(flag == 1 || flag == 2 || flag == 3 || flag == 4)) {	/* Flags = 1,2,3 or 4 */
-    opj_event_msg(cio->cinfo, EVT_ERROR,
-			"Error with flag in TKHD box: Expected flag 1,2,3 or 4\n");
-    return 1;
-  }
-	
-  tk->creation_time = cio_read(cio, 4);	/* Creation Time */
-	
-  tk->modification_time = cio_read(cio, 4);	/* Modification Time */
-	
-  tk->track_ID = cio_read(cio, 4);	/* Track ID */
-	
-  cio_skip(cio,4);			/* Reserved */
-	
-  tk->duration = cio_read(cio, 4);	/* Duration */
-	
-  cio_skip(cio,8);			/* Reserved */
-	
-  tk->layer = cio_read(cio, 2);	/* Layer    */
-	
-  cio_read(cio, 2);			/* Predefined */
-	
-  tk->volume = cio_read(cio, 2);	/* Volume       */
-	
-  cio_skip(cio,2);			/* Reserved */
-	
-  tk->trans_matrix[0] = cio_read(cio, 4);	/* Transformation matrix for track */
-  tk->trans_matrix[1] = cio_read(cio, 4);
-  tk->trans_matrix[2] = cio_read(cio, 4);
-  tk->trans_matrix[3] = cio_read(cio, 4);
-  tk->trans_matrix[4] = cio_read(cio, 4);
-  tk->trans_matrix[5] = cio_read(cio, 4);
-  tk->trans_matrix[6] = cio_read(cio, 4);
-  tk->trans_matrix[7] = cio_read(cio, 4);
-  tk->trans_matrix[8] = cio_read(cio, 4);
-	
-  tk->visual_w = cio_read(cio, 4);	/* Video Visual Width  */
-	
-  tk->visual_h = cio_read(cio, 4);	/* Video Visual Height */
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with TKHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the TRAK box
-*
-* Track box
-*
-*/
-void mj2_write_trak(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-	
-  cio_write(cio, MJ2_TRAK, 4);	/* TRAK       */
-	
-  mj2_write_tkhd(tk, cio);
-  mj2_write_mdia(tk, cio);
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the TRAK box
-*
-* Track box
-*
-*/
-int mj2_read_trak(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_TRAK != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected TRAK Marker\n");
-    return 1;
-  }
-  if (mj2_read_tkhd(tk, cio))
-    return 1;
-  if (mj2_read_mdia(tk, img, cio))
-    return 1;
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with TRAK Box\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MVHD box
-*
-* Movie header Box
-*
-*/
-void mj2_write_mvhd(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-  unsigned j;
-  time_t ltime;
-  int max_tk_num = 0;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MVHD, 4);	/* MVHD       */
-	
-  cio_write(cio, 0, 4);		/* Version = 0, flags = 0 */
-	
-  time(&ltime);			/* Time since 1/1/70 */
-  movie->modification_time = (unsigned int)ltime + 2082844800;	/* Seoonds between 1/1/04 and 1/1/70 */
-	
-  cio_write(cio, movie->creation_time, 4);	/* Creation Time */
-	
-  cio_write(cio, movie->modification_time, 4);	/* Modification Time */
-	
-  cio_write(cio, movie->timescale, 4);	/* Timescale */
-	
-  movie->duration = 0;
-	
-  for (i = 0; i < (movie->num_stk + movie->num_htk + movie->num_vtk); i++) {
-    mj2_tk_t *tk = &movie->tk[i];
-		
-    for (j = 0; j < tk->num_samples; j++) {
-      movie->duration += tk->sample[j].sample_delta;
-    }
-  }
-	
-  cio_write(cio, movie->duration, 4);
-	
-  cio_write(cio, movie->rate, 4);	/* Rate to play presentation    */
-	
-  cio_write(cio, movie->volume, 2);	/* Volume       */
-	
-  cio_write(cio, 0, 2);		/* Reserved */
-  cio_write(cio, 0, 4);		/* Reserved */
-  cio_write(cio, 0, 4);		/* Reserved */
-	
-  cio_write(cio, movie->trans_matrix[0], 4);	/* Transformation matrix for video */
-  cio_write(cio, movie->trans_matrix[1], 4);
-  cio_write(cio, movie->trans_matrix[2], 4);
-  cio_write(cio, movie->trans_matrix[3], 4);
-  cio_write(cio, movie->trans_matrix[4], 4);
-  cio_write(cio, movie->trans_matrix[5], 4);
-  cio_write(cio, movie->trans_matrix[6], 4);
-  cio_write(cio, movie->trans_matrix[7], 4);
-  cio_write(cio, movie->trans_matrix[8], 4);
-	
-  cio_write(cio, 0, 4);		/* Pre-defined */
-  cio_write(cio, 0, 4);		/* Pre-defined */
-  cio_write(cio, 0, 4);		/* Pre-defined */
-  cio_write(cio, 0, 4);		/* Pre-defined */
-  cio_write(cio, 0, 4);		/* Pre-defined */
-  cio_write(cio, 0, 4);		/* Pre-defined */
-	
-	
-  for (i = 0; i < movie->num_htk + movie->num_stk + movie->num_vtk; i++) {
-    if (max_tk_num < movie->tk[i].track_ID)
-      max_tk_num = movie->tk[i].track_ID;
-  }
-	
-  movie->next_tk_id = max_tk_num + 1;
-	
-  cio_write(cio, movie->next_tk_id, 4);	/* ID of Next track to be added */
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MVHD box
-*
-* Movie header Box
-*
-*/
-int mj2_read_mvhd(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  mj2_box_t box;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MVHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MVHD Marker\n");
-    return 1;
-  }
-	
-	
-  if (0 != cio_read(cio, 4)) {	/* Version = 0, flags = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in MVHD box\n");
-  }
-	
-  movie->creation_time = cio_read(cio, 4);	/* Creation Time */
-	
-  movie->modification_time = cio_read(cio, 4);	/* Modification Time */
-	
-  movie->timescale = cio_read(cio, 4);	/* Timescale */
-	
-  movie->duration = cio_read(cio, 4);	/* Duration */
-	
-  movie->rate = cio_read(cio, 4);		/* Rate to play presentation    */
-	
-  movie->volume = cio_read(cio, 2);		/* Volume       */
-	
-  cio_skip(cio,10);				/* Reserved */
-	
-  movie->trans_matrix[0] = cio_read(cio, 4);	/* Transformation matrix for video */
-  movie->trans_matrix[1] = cio_read(cio, 4);
-  movie->trans_matrix[2] = cio_read(cio, 4);
-  movie->trans_matrix[3] = cio_read(cio, 4);
-  movie->trans_matrix[4] = cio_read(cio, 4);
-  movie->trans_matrix[5] = cio_read(cio, 4);
-  movie->trans_matrix[6] = cio_read(cio, 4);
-  movie->trans_matrix[7] = cio_read(cio, 4);
-  movie->trans_matrix[8] = cio_read(cio, 4);
-	
-  cio_skip(cio,24);			/* Pre-defined */
-	
-  movie->next_tk_id = cio_read(cio, 4);	/* ID of Next track to be added */
-	
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MVHD Box Size\n");
-    return 1;
-  }
-  return 0;
-}
-
-
-/*
-* Write the MOOV box
-*
-* Movie Box
-*
-*/
-void mj2_write_moov(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-	
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MOOV, 4);	/* MOOV       */
-	
-  mj2_write_mvhd(movie, cio);
-	
-  for (i = 0; i < (movie->num_stk + movie->num_htk + movie->num_vtk); i++) {
-    mj2_write_trak(&movie->tk[i], cio);
-  }
-	
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);	/* L          */
-  cio_seek(cio, box.init_pos + box.length);	
-}
-
-/*
-* Read the MOOV box
-*
-* Movie Box
-*
-*/
-int mj2_read_moov(opj_mj2_t * movie, opj_image_t * img, opj_cio_t *cio)
-{
-  unsigned int i;
-  mj2_box_t box;
-  mj2_box_t box2;
-	
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MOOV != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MOOV Marker\n");
-    return 1;
-  }
-	
-  if (mj2_read_mvhd(movie, cio))
-    return 1;
-
-  movie->tk = (mj2_tk_t*) opj_malloc((movie->next_tk_id - 1) * sizeof(mj2_tk_t));
-
-  for (i = 0; cio_tell(cio) - box.init_pos < box.length; i++) {
-		mj2_tk_t *tk = &movie->tk[i];
-		tk->cinfo = movie->cinfo;
-    mj2_read_boxhdr(&box2, cio);
-    if (box2.type == MJ2_TRAK) {
-      cio_seek(cio, box2.init_pos);
-      if (mj2_read_trak(tk, img, cio))
-				return 1;
-			
-      if (tk->track_type == 0) {
-				movie->num_vtk++;
-      } else if (tk->track_type == 1) {
-				movie->num_stk++;
-      } else if (tk->track_type == 2) {
-				movie->num_htk++;
-      }
-    } else if (box2.type == MJ2_MVEX) {
-      cio_seek(cio, box2.init_pos);
-      cio_skip(cio,box2.length);
-      i--;
-    } else {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MOOV Box: Expected TRAK or MVEX box\n");
-      return 1;
-    }
-  }
-  return 0;
-}
-
-int mj2_read_struct(FILE *file, opj_mj2_t *movie) {
-  mj2_box_t box;
-  opj_image_t img;
-  unsigned char * src;
-  int fsresult;
-  int foffset;
-	opj_cio_t *cio;
-	
-	/* open a byte stream for reading */	
-	src = (unsigned char*) opj_malloc(300 * sizeof(unsigned char));	
-
-	/* Assuming that jp and ftyp markers size do
-     not exceed 300 bytes */
-  fread(src,300,1, file);  
-  
-  cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, 300);
-  
-  if (mj2_read_jp(cio))
-    return 1;
-  if (mj2_read_ftyp(movie, cio))
-    return 1;
-	
-  fsresult = fseek(file,cio_tell(cio),SEEK_SET);
-  if( fsresult ) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read data after FTYP box\n" );
-    return 1;
-  }
-	
-  foffset = cio_tell(cio);
-  
-  box.type = 0;
-  
-  fread(src,30,1,file);
-  cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, 300);
-  mj2_read_boxhdr(&box, cio);
-  
-  while(box.type != MJ2_MOOV) {
-    
-    switch(box.type)
-    {
-    case MJ2_MDAT:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-				opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MDAT box\n" );
-				return 1;
-      }
-      foffset += box.length;
-      break;
-      
-    case MJ2_MOOF:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-				opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MOOF box\n" );
-				return 1;
-      }
-      foffset += box.length;
-      break;      
-    case MJ2_FREE:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-				opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read FREE box\n" );
-				return 1;
-      }
-      foffset += box.length;
-      break;      
-    case MJ2_SKIP:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-				opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read SKIP box\n" );
-				return 1;
-      }
-      foffset += box.length;
-      break;      
-    default:
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Unknown box in MJ2 stream\n");
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-				opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read end of unknown box\n"); 
-				return 1;
-      }      
-      foffset += box.length;
-      break;
-    }
-    fsresult = fread(src,8,1,file);
-    if (fsresult != 1) {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "MOOV box not found in file\n"); 
-      return 1;
-    }
-		cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, 8);    		
-    mj2_read_boxhdr(&box, cio);
-  }	
-
-  fseek(file,foffset,SEEK_SET);
-  src = (unsigned char*)opj_realloc(src,box.length);
-  fsresult = fread(src,box.length,1,file);
-  if (fsresult != 1) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MOOV box\n"); 
-    return 1;
-  }
-	
-	cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, box.length);
-  
-  if (mj2_read_moov(movie, &img, cio))
-    return 1;
-
-  opj_free(src);
-  return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-/* MJ2 decoder interface															                     */
-/* ----------------------------------------------------------------------- */
-
-opj_dinfo_t* mj2_create_decompress() {
-	opj_mj2_t* mj2;
-	opj_dinfo_t *dinfo = (opj_dinfo_t*) opj_calloc(1, sizeof(opj_dinfo_t));
-	if(!dinfo) return NULL;
-
-	dinfo->is_decompressor = true;	
-
-	mj2 = (opj_mj2_t*) opj_calloc(1, sizeof(opj_mj2_t));
-	dinfo->mj2_handle = mj2;
-	if(mj2) {
-		mj2->cinfo = (opj_common_ptr)dinfo;
-	}
-	mj2->j2k = j2k_create_decompress((opj_common_ptr)dinfo);
-	dinfo->j2k_handle = mj2->j2k;
-
-	return dinfo;
-}
-
-void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters) {
-	movie->num_vtk=0;
-  movie->num_stk=0;
-  movie->num_htk=0;	
-
-	/* setup the J2K decoder parameters */
-	j2k_setup_decoder((opj_j2k_t*)movie->cinfo->j2k_handle, 
-		&mj2_parameters->j2k_parameters);
-
-}
-
-void mj2_destroy_decompress(opj_mj2_t *movie) {
-	if(movie) {
-		int i;
-		mj2_tk_t *tk=NULL;
-
-		if (movie->cinfo->j2k_handle) 
-			j2k_destroy_compress(movie->j2k);
-		
-		if (movie->num_cl != 0)
-			opj_free(movie->cl);
-		
-		for (i = 0; i < movie->num_vtk + movie->num_stk + movie->num_htk; i++) {
-			tk = &movie->tk[i];
-			if (tk->name_size != 0)
-				opj_free(tk->name);
-			if (tk->track_type == 0)  {// Video track
-				if (tk->jp2_struct.comps != 0)
-					opj_free(tk->jp2_struct.comps);
-				if (tk->jp2_struct.cl != 0)
-					opj_free(tk->jp2_struct.cl);
-				if (tk->num_jp2x != 0)
-					opj_free(tk->jp2xdata);
-				
-			}
-			if (tk->num_url != 0)
-				opj_free(tk->url);
-			if (tk->num_urn != 0)
-				opj_free(tk->urn);
-			if (tk->num_br != 0)
-				opj_free(tk->br);
-			if (tk->num_tts != 0)
-				opj_free(tk->tts);
-			if (tk->num_chunks != 0)
-				opj_free(tk->chunk);
-			if (tk->num_samplestochunk != 0)
-				opj_free(tk->sampletochunk);
-			if (tk->num_samples != 0)
-				opj_free(tk->sample);
-		}
-		
-		opj_free(movie->tk);
-	}	
-	opj_free(movie);
-}
-
-/* ----------------------------------------------------------------------- */
-/* MJ2 encoder interface															                     */
-/* ----------------------------------------------------------------------- */
-
-
-opj_cinfo_t* mj2_create_compress() {
-	opj_mj2_t* mj2;
-	opj_cinfo_t *cinfo = (opj_cinfo_t*) opj_calloc(1, sizeof(opj_cinfo_t));
-	if(!cinfo) return NULL;
-
-	mj2 = (opj_mj2_t*) opj_calloc(1, sizeof(opj_mj2_t));
-	cinfo->mj2_handle = mj2;
-	if(mj2) {
-		mj2->cinfo = (opj_common_ptr)cinfo;
-	}
-
-	mj2->j2k = j2k_create_compress(mj2->cinfo);
-	cinfo->j2k_handle = mj2->j2k;
-
-	return cinfo;
-}
-
-void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
-	if(movie && parameters) {
-		opj_jp2_t *jp2_struct;
-			
-		movie->num_htk = 0;	  // No hint tracks
-		movie->num_stk = 0;	  // No sound tracks
-		movie->num_vtk = 1;	  // One video track  
-
-		movie->brand = MJ2_MJ2;  // One brand: MJ2
-		movie->num_cl = 2;	  // Two compatible brands: MJ2 and MJ2S
-		movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
-		movie->cl[0] = MJ2_MJ2;
-		movie->cl[1] = MJ2_MJ2S;
-		movie->minversion = 0;	  // Minimum version: 0		
-
-		movie->tk = (mj2_tk_t*) opj_malloc(sizeof(mj2_tk_t)); //Memory allocation for the video track
-		movie->tk[0].track_ID = 1;	  // Track ID = 1 
-		movie->tk[0].track_type = 0;	  // Video track
-		movie->tk[0].Dim[0] = parameters->Dim[0];
-		movie->tk[0].Dim[1] = parameters->Dim[1];
-		movie->tk[0].w = parameters->w;
-		movie->tk[0].h = parameters->h;
-		movie->tk[0].CbCr_subsampling_dx = parameters->CbCr_subsampling_dx;
-		movie->tk[0].CbCr_subsampling_dy = parameters->CbCr_subsampling_dy;
-		movie->tk[0].sample_rate = parameters->frame_rate;
-		movie->tk[0].name_size = 0;
-		movie->tk[0].chunk = (mj2_chunk_t*) opj_malloc(sizeof(mj2_chunk_t));  
-		movie->tk[0].sample = (mj2_sample_t*) opj_malloc(sizeof(mj2_sample_t));
-
-		jp2_struct = &movie->tk[0].jp2_struct;
-		jp2_struct->numcomps = 3;	// NC  		
-		jp2_struct->comps = (opj_jp2_comps_t*) opj_malloc(jp2_struct->numcomps * sizeof(opj_jp2_comps_t));
-		jp2_struct->precedence = 0;   /* PRECEDENCE*/
-		jp2_struct->approx = 0;   /* APPROX*/		
-		jp2_struct->brand = JP2_JP2;	/* BR         */
-		jp2_struct->minversion = 0;	/* MinV       */
-		jp2_struct->numcl = 1;
-		jp2_struct->cl = (unsigned int*) opj_malloc(jp2_struct->numcl * sizeof(unsigned int));
-		jp2_struct->cl[0] = JP2_JP2;	/* CL0 : JP2  */		
-		jp2_struct->C = 7;      /* C : Always 7*/
-		jp2_struct->UnkC = 0;      /* UnkC, colorspace specified in colr box*/
-		jp2_struct->IPR = 0;      /* IPR, no intellectual property*/						
-		jp2_struct->w = parameters->w;
-		jp2_struct->h = parameters->h;
-		jp2_struct->bpc = 7;  
-		jp2_struct->meth = 1;
-		jp2_struct->enumcs = 18;  // YUV
-  }
-}
-
-void mj2_destroy_compress(opj_mj2_t *movie) {
-	if(movie) {
-		int i;
-		mj2_tk_t *tk=NULL;
-
-		if (movie->cinfo->j2k_handle) {
-			j2k_destroy_compress(movie->j2k);
-		}
-		
-		if (movie->num_cl != 0)
-			opj_free(movie->cl);
-		
-		for (i = 0; i < movie->num_vtk + movie->num_stk + movie->num_htk; i++) {
-			tk = &movie->tk[i];
-			if (tk->name_size != 0)
-				opj_free(tk->name);
-			if (tk->track_type == 0)  {// Video track
-				if (tk->jp2_struct.comps != 0)
-					opj_free(tk->jp2_struct.comps);
-				if (tk->jp2_struct.cl != 0)
-					opj_free(tk->jp2_struct.cl);
-				if (tk->num_jp2x != 0)
-					opj_free(tk->jp2xdata);
-				
-			}
-			if (tk->num_url != 0)
-				opj_free(tk->url);
-			if (tk->num_urn != 0)
-				opj_free(tk->urn);
-			if (tk->num_br != 0)
-				opj_free(tk->br);
-			if (tk->num_tts != 0)
-				opj_free(tk->tts);
-			if (tk->num_chunks != 0)
-				opj_free(tk->chunk);
-			if (tk->num_samplestochunk != 0)
-				opj_free(tk->sampletochunk);
-			if (tk->num_samples != 0)
-				opj_free(tk->sample);
-		}
-		
-		opj_free(movie->tk);
-	}	
-	opj_free(movie);
-}
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2.h b/Utilities/gdcmopenjpeg-v1/mj2/mj2.h
deleted file mode 100644
index 97cf8ed..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2.h
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2003-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MJ2_H
-#define __MJ2_H
-/**
- at file mj2.h
- at brief The Motion JPEG 2000 file format Reader/Writer (MJ22)
-
-*/
-
-/** @defgroup MJ2 MJ2 - Motion JPEG 2000 file format reader/writer */
-/*@{*/
-
-#define MJ2_JP    0x6a502020
-#define MJ2_FTYP  0x66747970
-#define MJ2_MJ2   0x6d6a7032
-#define MJ2_MJ2S  0x6d6a3273
-#define MJ2_MDAT  0x6d646174
-#define MJ2_MOOV  0x6d6f6f76
-#define MJ2_MVHD  0x6d766864
-#define MJ2_TRAK  0x7472616b
-#define MJ2_TKHD  0x746b6864
-#define MJ2_MDIA  0x6d646961
-#define MJ2_MDHD  0x6d646864
-#define MJ2_MHDR  0x6d686472
-#define MJ2_HDLR  0x68646C72
-#define MJ2_MINF  0x6d696e66
-#define MJ2_VMHD  0x766d6864
-#define MJ2_SMHD  0x736d6864
-#define MJ2_HMHD  0x686d6864
-#define MJ2_DINF  0x64696e66
-#define MJ2_DREF  0x64726566
-#define MJ2_URL   0x75726c20
-#define MJ2_URN   0x75726e20
-#define MJ2_STBL  0x7374626c
-#define MJ2_STSD  0x73747364
-#define MJ2_STTS  0x73747473
-#define MJ2_STSC  0x73747363
-#define MJ2_STSZ  0x7374737a
-#define MJ2_STCO  0x7374636f
-#define MJ2_MOOF  0x6d6f6f66
-#define MJ2_FREE  0x66726565
-#define MJ2_SKIP  0x736b6970
-#define MJ2_JP2C  0x6a703263
-#define MJ2_FIEL  0x6669656c
-#define MJ2_JP2P  0x6a703270
-#define MJ2_JP2X  0x6a703278
-#define MJ2_JSUB  0x6a737562
-#define MJ2_ORFO  0x6f72666f
-#define MJ2_MVEX  0x6d766578
-#define MJ2_JP2   0x6a703220
-#define MJ2_J2P0  0x4a325030
-
-/**
-Decompressed format used in parameters
-YUV = 0
-*/
-#define YUV_DFMT 1 
-
-/**
-Compressed format used in parameters
-MJ2 = 0
-*/
-#define MJ2_CFMT 2
-
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Time To Sample
-*/
-typedef struct mj2_tts {
-  int sample_count;
-  int sample_delta;
-} mj2_tts_t;
-
-/**
-Chunk
-*/
-typedef struct mj2_chunk {		
-  int num_samples;
-  int sample_descr_idx;
-  int offset;
-} mj2_chunk_t;
-
-/**
-Sample to chunk
-*/
-typedef struct mj2_sampletochunk {		
-  int first_chunk;
-  int samples_per_chunk;
-  int sample_descr_idx;
-} mj2_sampletochunk_t;
-
-/**
-Sample
-*/
-typedef struct mj2_sample {		
-  unsigned int sample_size;
-  unsigned int offset;
-  unsigned int sample_delta;
-} mj2_sample_t;
-
-/**
-URL
-*/
-typedef struct mj2_url {
-  int location[4];
-} mj2_url_t;
-
-/**
-URN
-*/
-typedef struct mj2_urn {		
-  int name[2];
-  int location[4];
-} mj2_urn_t;
-
-/**
-Video Track Parameters
-*/
-typedef struct mj2_tk {
-	/** codec context */
-	opj_common_ptr cinfo;
-  int track_ID;
-  int track_type;
-  unsigned int creation_time;
-  unsigned int modification_time;
-  int duration;
-  int timescale;
-  int layer;
-  int volume;
-  int language;
-  int balance;
-  int maxPDUsize;
-  int avgPDUsize;
-  int maxbitrate;
-  int avgbitrate;
-  int slidingavgbitrate;
-  int graphicsmode;
-  int opcolor[3];
-  int num_url;
-  mj2_url_t *url;
-  int num_urn;
-  mj2_urn_t *urn;
-  int Dim[2];
-  int w;
-  int h;
-  int visual_w;
-  int visual_h;
-  int CbCr_subsampling_dx;
-  int CbCr_subsampling_dy;
-  int sample_rate;
-  int sample_description;
-  int horizresolution;
-  int vertresolution;
-  int compressorname[8];
-  int depth;
-  unsigned char fieldcount;
-  unsigned char fieldorder;
-  unsigned char or_fieldcount;
-  unsigned char or_fieldorder;
-  int num_br;
-  unsigned int *br;
-  unsigned char num_jp2x;
-  unsigned char *jp2xdata;
-  unsigned char hsub;
-  unsigned char vsub;
-  unsigned char hoff;
-  unsigned char voff;
-  int trans_matrix[9];
-	/** Number of samples */
-  unsigned int num_samples;	
-  int transorm;
-  int handler_type;
-  int name_size;
-  unsigned char same_sample_size;
-  int num_tts;
-	/** Time to sample    */
-  mj2_tts_t *tts;		
-  unsigned int num_chunks;
-  mj2_chunk_t *chunk;
-  int num_samplestochunk;
-  mj2_sampletochunk_t *sampletochunk;
-  char *name;
-  opj_jp2_t jp2_struct;
-	/** Sample parameters */
-  mj2_sample_t *sample;		
-} mj2_tk_t;			
-
-/**
-MJ2 box
-*/
-typedef struct mj2_box {
-  int length;
-  int type;
-  int init_pos;
-} mj2_box_t;
-
-/**
-MJ2 Movie
-*/
-typedef struct opj_mj2 {		
-	/** codec context */
-	opj_common_ptr cinfo;
-	/** handle to the J2K codec  */
-	opj_j2k_t *j2k;
-  unsigned int brand;
-  unsigned int minversion;
-  int num_cl;
-  unsigned int *cl;
-  unsigned int creation_time;
-  unsigned int modification_time;
-  int timescale;
-  unsigned int duration;
-  int rate;
-  int num_vtk;
-  int num_stk;
-  int num_htk;
-  int volume;
-  int trans_matrix[9];
-  int next_tk_id;
-	/** Track Parameters  */
-  mj2_tk_t *tk;			
-} opj_mj2_t;
-
-/**
-Decompression parameters
-*/
-typedef struct mj2_dparameters {
-	/**@name command line encoder parameters (not used inside the library) */
-	/*@{*/
-	/** input file name */
-	char infile[OPJ_PATH_LEN];
-	/** output file name */
-	char outfile[OPJ_PATH_LEN];	
-	/** J2K decompression parameters */
-	opj_dparameters_t j2k_parameters;	
-} mj2_dparameters_t;
-
-/**
-Compression parameters
-*/
-typedef struct mj2_cparameters {
-	/**@name command line encoder parameters (not used inside the library) */
-	/*@{*/
-	/** J2K compression parameters */
-	opj_cparameters_t j2k_parameters;	
-	/** input file name */
-	char infile[OPJ_PATH_LEN];
-	/** output file name */
-	char outfile[OPJ_PATH_LEN];	
-	/** input file format 0:MJ2 */
-	int decod_format;
-	/** output file format 0:YUV */
-	int cod_format;
-	/** Portion of the image coded */
-	int Dim[2];
-	/** YUV Frame width */
-	int w;
-	/** YUV Frame height */
-	int h;
-	/*   Sample rate of YUV 4:4:4, 4:2:2 or 4:2:0 */
-	int CbCr_subsampling_dx;	
-	/*   Sample rate of YUV 4:4:4, 4:2:2 or 4:2:0 */
-  int CbCr_subsampling_dy;	
-	/*   Video Frame Rate  */
-  int frame_rate;		
-	/*   In YUV files, numcomps always considered as 3 */
-  int numcomps;			
-	/*   In YUV files, precision always considered as 8 */
-  int prec;		
-} mj2_cparameters_t;
-
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Write the JP box 
-*/
-void mj2_write_jp(opj_cio_t *cio);
-/**
-Write the FTYP box
- at param movie MJ2 movie
- at param cio Output buffer stream
-*/
-void mj2_write_ftyp(opj_mj2_t *movie, opj_cio_t *cio);
-/**
-Creates an MJ2 decompression structure
- at return Returns a handle to a MJ2 decompressor if successful, returns NULL otherwise
-*/
-opj_dinfo_t* mj2_create_decompress();
-/**
-Destroy a MJ2 decompressor handle
- at param movie MJ2 decompressor handle to destroy
-*/
-void mj2_destroy_decompress(opj_mj2_t *movie);
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in mj2->j2k->cp. 
- at param movie MJ2 decompressor handle
- at param parameters decompression parameters
-*/
-void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters);
-/**
-Decode an image from a JPEG-2000 file stream
- at param movie MJ2 decompressor handle
- at param cio Input buffer stream
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-opj_image_t* mj2_decode(opj_mj2_t *movie, opj_cio_t *cio);
-/**
-Creates a MJ2 compression structure
- at return Returns a handle to a MJ2 compressor if successful, returns NULL otherwise
-*/
-opj_cinfo_t* mj2_create_compress();
-/**
-Destroy a MJ2 compressor handle
- at param movie MJ2 compressor handle to destroy
-*/
-void mj2_destroy_compress(opj_mj2_t *movie);
-/**
-Setup the encoder parameters using the current image and using user parameters. 
-Coding parameters are returned in mj2->j2k->cp. 
- at param movie MJ2 compressor handle
- at param parameters compression parameters
-*/
-void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters);
-/**
-Encode an image into a JPEG-2000 file stream
- at param movie MJ2 compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param index Name of the index file if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-bool mj2_encode(opj_mj2_t *movie, opj_cio_t *cio, opj_image_t *image, char *index);
-
-/**
-Init a Standard MJ2 movie
- at param movie MJ2 Movie
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int mj2_init_stdmovie(opj_mj2_t *movie);
-/**
-Read the structure of an MJ2 file
- at param File MJ2 input File
- at param movie J2 movie structure 
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int mj2_read_struct(FILE *file, opj_mj2_t *mj2);
-/**
-Write the the MOOV box to an output buffer stream
- at param movie MJ2 movie structure 
- at param cio Output buffer stream
-*/
-void mj2_write_moov(opj_mj2_t *movie, opj_cio_t *cio);
-
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __MJ2_H */
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.c b/Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.c
deleted file mode 100644
index 3f4c2e7..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
-* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
-* Copyright (c) 2002-2007, Professor Benoit Macq
-* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "../libopenjpeg/opj_includes.h"
-#include "mj2.h"
-
-/*  -----------------------	      */
-/*				      */
-/*				      */
-/*  Count the number of frames	      */
-/*  in a YUV file		      */
-/*				      */
-/*  -----------------------	      */
-
-int yuv_num_frames(mj2_tk_t * tk, char *infile)
-{
-  int numimages, frame_size;
-  long end_of_f;
-	FILE *f;
-
-  f = fopen(infile,"rb");
-  if (!f) {  
-    fprintf(stderr, "failed to open %s for reading\n",infile);
-    return -1;
-  }
-	
-  frame_size = (int) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy)));	/* Calculate frame size */
-	
-  fseek(f, 0, SEEK_END);
-  end_of_f = ftell(f);		/* Calculate file size */
-	
-  if (end_of_f < frame_size) {
-    fprintf(stderr,
-			"YUV does not contains any frame of %d x %d size\n", tk->w,
-			tk->h);
-    return -1;
-  }
-	
-  numimages = end_of_f / frame_size;	/* Calculate number of images */
-	fclose(f);
-
-  return numimages;
-}
-
-//  -----------------------
-//
-//
-//  YUV to IMAGE
-//
-//  -----------------------
-
-opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
-{
-	opj_image_cmptparm_t cmptparm[3];
-	opj_image_t * img;
-	int i;
-	int numcomps = 3;
-	int subsampling_dx = parameters->subsampling_dx;
-	int subsampling_dy = parameters->subsampling_dy;
-
-	/* initialize image components */
-	memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-	for(i = 0; i < numcomps; i++) {
-		cmptparm[i].prec = 8;
-		cmptparm[i].bpp = 8;
-		cmptparm[i].sgnd = 0;		
-		cmptparm[i].dx = i ? subsampling_dx * tk->CbCr_subsampling_dx : subsampling_dx;
-		cmptparm[i].dy = i ? subsampling_dy * tk->CbCr_subsampling_dy : subsampling_dy;
-		cmptparm[i].w = tk->w;
-		cmptparm[i].h = tk->h;
-	}
-	/* create the image */
-	img = opj_image_create(numcomps, cmptparm, CLRSPC_SRGB);
-	return img;
-}
-
-char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile)
-{
-  int i, compno;
-  int offset;
-  long end_of_f, position;
-	int numcomps = 3;
-	int subsampling_dx = parameters->subsampling_dx;
-	int subsampling_dy = parameters->subsampling_dy;
-	FILE *yuvfile;
-	
-  yuvfile = fopen(infile,"rb");
-  if (!yuvfile) {  
-    fprintf(stderr, "failed to open %s for readings\n",parameters->infile);
-    return 1;
-  }
-
-  offset = (int) ((double) (frame_num * tk->w * tk->h) * (1.0 +
-		1.0 * (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy)));
-  fseek(yuvfile, 0, SEEK_END);
-  end_of_f = ftell(yuvfile);
-  fseek(yuvfile, sizeof(unsigned char) * offset, SEEK_SET);
-  position = ftell(yuvfile);
-  if (position >= end_of_f) {
-    fprintf(stderr, "Cannot reach frame number %d in yuv file !!\n",
-			frame_num);
-		fclose(yuvfile);
-    return 1;
-  }
-	
-  img->x0 = tk->Dim[0];
-  img->y0 = tk->Dim[1];
-  img->x1 = !tk->Dim[0] ? (tk->w - 1) * subsampling_dx + 1 : tk->Dim[0] +
-    (tk->w - 1) * subsampling_dx + 1;
-  img->y1 = !tk->Dim[1] ? (tk->h - 1) * subsampling_dy + 1 : tk->Dim[1] +
-    (tk->h - 1) * subsampling_dy + 1;
-	
-	for(compno = 0; compno < numcomps; compno++) {
-		for (i = 0; i < (tk->w * tk->h / (img->comps[compno].dx * img->comps[compno].dy))
-			&& !feof(yuvfile); i++) {
-			if (!fread(&img->comps[compno].data[i], 1, 1, yuvfile)) {
-				fprintf(stderr, "Error reading %s file !!\n", infile);				
-				return 1;
-			}
-		}
-	}
-	fclose(yuvfile);
-	
-  return 0;
-}
-
-
-
-//  -----------------------
-//
-//
-//  IMAGE to YUV
-//
-//  -----------------------
-
-
-bool imagetoyuv(opj_image_t * img, char *outfile)
-{
-  FILE *f;
-  int i;
-  
-  if (img->numcomps == 3) {
-    if (img->comps[0].dx != img->comps[1].dx / 2
-      || img->comps[1].dx != img->comps[2].dx) {
-      fprintf(stderr,
-				"Error with the input image components size: cannot create yuv file)\n");
-      return false;
-    }
-  } else if (!(img->numcomps == 1)) {
-    fprintf(stderr,
-      "Error with the number of image components(must be one or three)\n");
-    return false;
-  }
-  
-  f = fopen(outfile, "a+b");
-  if (!f) {
-    fprintf(stderr, "failed to open %s for writing\n", outfile);
-    return false;
-  }
-  
-  
-  for (i = 0; i < (img->comps[0].w * img->comps[0].h); i++) {
-    unsigned char y;
-    y = img->comps[0].data[i];
-    fwrite(&y, 1, 1, f);
-  }
-  
-  
-  if (img->numcomps == 3) {
-    for (i = 0; i < (img->comps[1].w * img->comps[1].h); i++) {
-      unsigned char cb;
-      cb = img->comps[1].data[i];
-      fwrite(&cb, 1, 1, f);
-    }
-    
-    
-    for (i = 0; i < (img->comps[2].w * img->comps[2].h); i++) {
-      unsigned char cr;
-      cr = img->comps[2].data[i];
-      fwrite(&cr, 1, 1, f);
-    }
-  } else if (img->numcomps == 1) {
-    for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
-      unsigned char cb = 125;
-      fwrite(&cb, 1, 1, f);
-    }
-    
-    
-    for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
-      unsigned char cr = 125;
-      fwrite(&cr, 1, 1, f);
-    }
-  }  
-  fclose(f);
-  return true;
-}
-
-//  -----------------------
-//
-//
-//  IMAGE to BMP
-//
-//  -----------------------
-
-int imagetobmp(opj_image_t * img, char *outfile) {
-  int w,wr,h,hr,i,pad;
-  FILE *f;
-  
-  if (img->numcomps == 3 && img->comps[0].dx == img->comps[1].dx
-    && img->comps[1].dx == img->comps[2].dx
-    && img->comps[0].dy == img->comps[1].dy
-    && img->comps[1].dy == img->comps[2].dy
-    && img->comps[0].prec == img->comps[1].prec
-    && img->comps[1].prec == img->comps[2].prec) {
-    /* -->> -->> -->> -->>
-    
-      24 bits color
-      
-    <<-- <<-- <<-- <<-- */
-    
-    f = fopen(outfile, "wb");
-    if (!f) {
-      fprintf(stderr, "failed to open %s for writing\n", outfile);
-      return 1;
-    }   
-    
-    w = img->comps[0].w;
-    wr = int_ceildivpow2(img->comps[0].w, img->comps[0].factor);
-    
-    h = img->comps[0].h;
-    hr = int_ceildivpow2(img->comps[0].h, img->comps[0].factor);
-    
-    fprintf(f, "BM");
-    
-    /* FILE HEADER */
-    /* ------------- */
-    fprintf(f, "%c%c%c%c",
-      (unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) +
-      54) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
-      >> 8) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
-      >> 16) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
-      >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,
-      ((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
-    
-    /* INFO HEADER   */
-    /* ------------- */
-    fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
-      ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
-      (unsigned char) ((wr) >> 8) & 0xff,
-      (unsigned char) ((wr) >> 16) & 0xff,
-      (unsigned char) ((wr) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
-      (unsigned char) ((hr) >> 8) & 0xff,
-      (unsigned char) ((hr) >> 16) & 0xff,
-      (unsigned char) ((hr) >> 24) & 0xff);
-    fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
-    fprintf(f, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c",
-      (unsigned char) (3 * hr * wr +
-      3 * hr * (wr % 2)) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
-      8) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
-      16) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
-      24) & 0xff);
-    fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
-      ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
-      ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    
-    for (i = 0; i < wr * hr; i++) {
-      unsigned char R, G, B;
-      /* a modifier */
-      // R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
-      // G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
-      // B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
-      fprintf(f, "%c%c%c", B, G, R);
-      
-      if ((i + 1) % wr == 0) {
-				for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--)	/* ADD */
-					fprintf(f, "%c", 0);
-      }
-    }
-    fclose(f);
-  }
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.h b/Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.h
deleted file mode 100644
index 78e6c47..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_convert.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2002-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-#include "mj2.h"
-
-#ifndef __MJ2_CONVERT_H
-#define __MJ2_CONVERT_H
-
-int imagetoyuv(opj_image_t * img, char *outfile);
-
-int imagetobmp(opj_image_t * img, char *outfile);
-
-opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters);
-
-char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile);
-
-int yuv_num_frames(mj2_tk_t * tk, char *infile);
-
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.c b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.c
deleted file mode 100644
index 63869ea..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2002-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "opj_config.h"
-#include "openjpeg.h"
-#include "../libopenjpeg/j2k_lib.h"
-#include "../libopenjpeg/j2k.h"
-#include "../libopenjpeg/jp2.h"
-#include "mj2.h"
-#include "mj2_convert.h"
-
-#ifdef HAVE_LIBLCMS2
-#include <lcms2.h>
-#endif
-#ifdef HAVE_LIBLCMS1
-#include <lcms.h>
-#endif
-#include "color.h"
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-int main(int argc, char *argv[]) {
-	mj2_dparameters_t mj2_parameters;			/* decompression parameters */
-	opj_dinfo_t* dinfo; 
-	opj_event_mgr_t event_mgr;		/* event manager */	
-	opj_cio_t *cio = NULL;
-  unsigned int tnum, snum;
-  opj_mj2_t *movie;
-  mj2_tk_t *track;
-  mj2_sample_t *sample;
-  unsigned char* frame_codestream;
-  FILE *file, *outfile;
-  char outfilename[50];
-  opj_image_t *img = NULL;
-	unsigned int max_codstrm_size = 0;
-	double total_time = 0;
-	unsigned int numframes = 0;
-			
-  if (argc != 3) {
-    printf("Usage: %s inputfile.mj2 outputfile.yuv\n",argv[0]); 
-    return 1;
-  }
-  
-  file = fopen(argv[1], "rb");
-  
-  if (!file) {
-    fprintf(stderr, "failed to open %s for reading\n", argv[1]);
-    return 1;
-  }
-	
-  // Checking output file
-  outfile = fopen(argv[2], "w");
-  if (!file) {
-    fprintf(stderr, "failed to open %s for writing\n", argv[2]);
-    return 1;
-  }
-  fclose(outfile);
-	
-	/*
-	configure the event callbacks (not required)
-	setting of each callback is optionnal
-	*/
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = NULL;
-	
-	/* get a MJ2 decompressor handle */
-	dinfo = mj2_create_decompress();
-	movie = (opj_mj2_t*)dinfo->mj2_handle;
-	
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);		
-
-	/* set J2K decoding parameters to default values */
-	opj_set_default_decoder_parameters(&mj2_parameters.j2k_parameters);
-	
-	/* setup the decoder decoding parameters using user parameters */
-	mj2_setup_decoder((opj_mj2_t*)dinfo->mj2_handle, &mj2_parameters);
-			
-  if (mj2_read_struct(file, movie)) // Creating the movie structure
-    return 1;	
-	
-  // Decode first video track 
-	for (tnum=0; tnum < (unsigned int)(movie->num_htk + movie->num_stk + movie->num_vtk); tnum++) {
-		if (movie->tk[tnum].track_type == 0) 
-			break;
-	}
-	
-	if (movie->tk[tnum].track_type != 0) {
-		printf("Error. Movie does not contain any video track\n");
-		return 1;
-	}
-	
-  track = &movie->tk[tnum];
-	
-  // Output info on first video tracl
-  fprintf(stdout,"The first video track contains %d frames.\nWidth: %d, Height: %d \n\n",
-    track->num_samples, track->w, track->h);
-	
-	max_codstrm_size = track->sample[0].sample_size-8;
-	frame_codestream = (unsigned char*) malloc(max_codstrm_size * sizeof(unsigned char)); 
-
-	numframes = track->num_samples;
-	
-  for (snum=0; snum < numframes; snum++)
-  {
-		double init_time = opj_clock();
-		double elapsed_time;
-
-    sample = &track->sample[snum];
-		if (sample->sample_size-8 > max_codstrm_size) {
-			max_codstrm_size =  sample->sample_size-8;
-			if ((frame_codestream = (unsigned char*)
-				realloc(frame_codestream, max_codstrm_size)) == NULL) {
-				printf("Error reallocation memory\n");
-				return 1;
-			}; 		
-		}
-    fseek(file,sample->offset+8,SEEK_SET);
-    fread(frame_codestream, sample->sample_size-8, 1, file);  // Assuming that jp and ftyp markers size do
-		
-		/* open a byte stream */
-		cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
-		
-		img = opj_decode(dinfo, cio); // Decode J2K to image
-
-#ifdef WANT_SYCC_TO_RGB
-	if(img->color_space == CLRSPC_SYCC)
-  {
-	color_sycc_to_rgb(img);
-  }
-#endif
-
-	if(img->icc_profile_buf)
-  {
-#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-	color_apply_icc_profile(img);
-#endif
-
-	free(img->icc_profile_buf);
-	img->icc_profile_buf = NULL; img->icc_profile_len = 0;
-  }
-
-    if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2) 
-      && (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1)) 
-      || (img->numcomps == 1)) {
-      
-      if (!imagetoyuv(img, argv[2]))	// Convert image to YUV
-				return 1;
-    }
-    else if ((img->numcomps == 3) && 
-      (img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
-      (img->comps[2].dx == 1))// If YUV 4:4:4 input --> to bmp
-    {
-      fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
-      sprintf(outfilename,"output_%d.bmp",snum);
-      if (imagetobmp(img, outfilename))	// Convert image to BMP
-				return 1;
-      
-    }
-    else {
-      fprintf(stdout,"Image component dimensions are unknown. Unable to output image\n");
-      fprintf(stdout,"The frames will be output in a j2k file (output_1.j2k, ...)\n");
-			
-      sprintf(outfilename,"output_%d.j2k",snum);
-      outfile = fopen(outfilename, "wb");
-      if (!outfile) {
-				fprintf(stderr, "failed to open %s for writing\n",outfilename);
-				return 1;
-      }
-      fwrite(frame_codestream,sample->sample_size-8,1,outfile);
-      fclose(outfile);
-    }
-		/* close the byte stream */
-		opj_cio_close(cio);	
-		/* free image data structure */
-		opj_image_destroy(img);
-		elapsed_time = opj_clock()-init_time;
-		fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds\n", snum + 1, numframes, elapsed_time*1000);
-		total_time += elapsed_time;
-
-  }
-	
-	free(frame_codestream);	
-  fclose(file);	
-
-	/* free remaining structures */
-	if(dinfo) {
-		mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
-	}
-	free(dinfo);
-	
-	fprintf(stdout, "%d frame(s) correctly decompressed\n", snum);
-	fprintf(stdout,"Total decoding time: %.2f seconds (%.1f fps)\n", total_time, (float)numframes/total_time);
-		
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsp b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsp
deleted file mode 100644
index 5b5bad6..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsp
+++ /dev/null
@@ -1,159 +0,0 @@
-# Microsoft Developer Studio Project File - Name="mj2_to_frames" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=mj2_to_frames - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "mj2_to_frames.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "mj2_to_frames.mak" CFG="mj2_to_frames - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "mj2_to_frames - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "mj2_to_frames - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "mj2_to_frames - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "mj2_to_frames - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "mj2_to_frames___Win32_Debug0"
-# PROP BASE Intermediate_Dir "mj2_to_frames___Win32_Debug0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "mj2_to_frames___Win32_Debug0"
-# PROP Intermediate_Dir "mj2_to_frames___Win32_Debug0"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MT /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /GZ /c
-# SUBTRACT CPP /X
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmtd" /pdbtype:sept
-
-!ENDIF 
-
-# Begin Target
-
-# Name "mj2_to_frames - Win32 Release"
-# Name "mj2_to_frames - Win32 Debug"
-# Begin Group "MJ2"
-
-# PROP Default_Filter ""
-# Begin Group "MJ2 Header Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\compat\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_convert.h
-# End Source File
-# End Group
-# Begin Group "MJ2 Source Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\compat\getopt.c
-
-!IF  "$(CFG)" == "mj2_to_frames - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "mj2_to_frames - Win32 Debug"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2.c
-
-!IF  "$(CFG)" == "mj2_to_frames - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "mj2_to_frames - Win32 Debug"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_convert.c
-
-!IF  "$(CFG)" == "mj2_to_frames - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "mj2_to_frames - Win32 Debug"
-
-!ENDIF 
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_to_frames.c
-
-!IF  "$(CFG)" == "mj2_to_frames - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "mj2_to_frames - Win32 Debug"
-
-!ENDIF 
-
-# End Source File
-# End Group
-# End Group
-# Begin Group "OpenJPEG Headers"
-
-# PROP Default_Filter ""
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsw b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsw
deleted file mode 100644
index 897121c..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "LibOpenJPEG"="..\LibOpenJPEG.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "mj2_to_frames"=".\mj2_to_frames.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.sln b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.sln
deleted file mode 100644
index e54e17a..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.sln
+++ /dev/null
@@ -1,29 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mj2_to_frames", "mj2_to_frames.vcproj", "{64325EAD-A083-4C8E-B852-71006428881D}"
-	ProjectSection(ProjectDependencies) = postProject
-		{4F27AA53-4181-4A1A-8238-3931B0A41048} = {4F27AA53-4181-4A1A-8238-3931B0A41048}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOpenJPEG", "..\LibOpenJPEG.vcproj", "{4F27AA53-4181-4A1A-8238-3931B0A41048}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{64325EAD-A083-4C8E-B852-71006428881D}.Debug|Win32.ActiveCfg = Debug|Win32
-		{64325EAD-A083-4C8E-B852-71006428881D}.Debug|Win32.Build.0 = Debug|Win32
-		{64325EAD-A083-4C8E-B852-71006428881D}.Release|Win32.ActiveCfg = Release|Win32
-		{64325EAD-A083-4C8E-B852-71006428881D}.Release|Win32.Build.0 = Release|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Debug|Win32.ActiveCfg = Debug|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Debug|Win32.Build.0 = Debug|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Release|Win32.ActiveCfg = Release|Win32
-		{4F27AA53-4181-4A1A-8238-3931B0A41048}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.vcproj b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.vcproj
deleted file mode 100644
index 5ac797a..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_frames.vcproj
+++ /dev/null
@@ -1,324 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="mj2_to_frames"
-	ProjectGUID="{64325EAD-A083-4C8E-B852-71006428881D}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\mj2_to_frames___Win32_Debug0"
-			IntermediateDirectory=".\mj2_to_frames___Win32_Debug0"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\mj2_to_frames___Win32_Debug0/mj2_to_frames.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="0"
-				PrecompiledHeaderFile=".\mj2_to_frames___Win32_Debug0/mj2_to_frames.pch"
-				AssemblerListingLocation=".\mj2_to_frames___Win32_Debug0/"
-				ObjectFile=".\mj2_to_frames___Win32_Debug0/"
-				ProgramDataBaseFileName=".\mj2_to_frames___Win32_Debug0/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib odbccp32.lib libcmtd.lib"
-				OutputFile=".\mj2_to_frames___Win32_Debug0/mj2_to_frames.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="LIBCMT"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\mj2_to_frames___Win32_Debug0/mj2_to_frames.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\mj2_to_frames___Win32_Debug0/mj2_to_frames.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/mj2_to_frames.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/mj2_to_frames.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Release/mj2_to_frames.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				ProgramDatabaseFile=".\Release/mj2_to_frames.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/mj2_to_frames.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="MJ2"
-			>
-			<Filter
-				Name="MJ2 Header Files"
-				>
-				<File
-					RelativePath="compat\getopt.h"
-					>
-				</File>
-				<File
-					RelativePath="mj2.h"
-					>
-				</File>
-				<File
-					RelativePath="mj2_convert.h"
-					>
-				</File>
-			</Filter>
-			<Filter
-				Name="MJ2 Source Files"
-				>
-				<File
-					RelativePath="compat\getopt.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2_convert.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2_to_frames.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-			</Filter>
-		</Filter>
-		<Filter
-			Name="OpenJPEG Headers"
-			>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.c b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.c
deleted file mode 100644
index 90be620..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/* mj2_to_metadata.c */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Contributed to Open JPEG by Glenn Pearson, contract software developer, U.S. National Library of Medicine.
-
-The base code in this file was developed by the author as part of a video archiving
-project for the U.S. National Library of Medicine, Bethesda, MD. 
-It is the policy of NLM (and U.S. government) to not assert copyright.
-
-A non-exclusive copy of this code has been contributed to the Open JPEG project.
-Except for copyright, inclusion of the code within Open JPEG for distribution and use
-can be bound by the Open JPEG open-source license and disclaimer, expressed elsewhere.
-*/
-
-#include "../libopenjpeg/opj_includes.h"
-#include "mj2.h"
-
-#include "mj2_to_metadata.h"
-#include <string.h>
-#include "getopt.h"
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-
-/* ------------- */
-
-void help_display()
-{
-  /*             "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
-  fprintf(stdout,"                Help for the 'mj2_to_metadata' Program\n");
-  fprintf(stdout,"                ======================================\n");
-  fprintf(stdout,"The -h option displays this information on screen.\n\n");
-  
-  fprintf(stdout,"mj2_to_metadata generates an XML file from a Motion JPEG 2000 file.\n");
-  fprintf(stdout,"The generated XML shows the structural, but not (yet) curatorial,\n");
-  fprintf(stdout,"metadata from the movie header and from the JPEG 2000 image and tile\n");
-  fprintf(stdout,"headers of a sample frame.  Excluded: low-level packed-bits image data.\n\n");
-
-  fprintf(stdout,"By Default\n");
-  fprintf(stdout,"----------\n");
-  fprintf(stdout,"The metadata includes the jp2 image and tile headers of the first frame.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Metadata values are shown in 'raw' form (e.g., hexidecimal) as stored in the\n");
-  fprintf(stdout,"file, and, if apt, in a 'derived' form that is more quickly grasped.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Notes explaining the XML are embedded as terse comments.  These include\n");
-  fprintf(stdout,"   meaning of non-obvious tag abbreviations;\n");
-  fprintf(stdout,"   range and precision of valid values;\n");
-  fprintf(stdout,"   interpretations of values, such as enumerations; and\n");
-  fprintf(stdout,"   current implementation limitations.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The sample-size and chunk-offset tables, each with 1 row per frame, are not reported.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The file is self-contained and no verification (e.g., against a DTD) is requested.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Required Parameters (except with -h)\n");
-  fprintf(stdout,"------------------------------------\n");
-  fprintf(stdout,"[Caution: file strings that contain spaces should be wrapped with quotes.]\n");
-  fprintf(stdout,"-i input.mj2  : where 'input' is any source file name or path.\n");
-  fprintf(stdout,"                MJ2 files created with 'frames_to_mj2' are supported so far.\n");
-  fprintf(stdout,"                These are silent, single-track, 'MJ2 Simple Profile' videos.\n");
-  fprintf(stdout,"-o output.xml : where 'output' is any destination file name or path.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Optional Parameters\n");
-  fprintf(stdout,"-------------------\n");
-  fprintf(stdout,"-h            : Display this help information.\n");
-  fprintf(stdout,"-n            : Suppress all mj2_to_metadata notes.\n");
-  fprintf(stdout,"-t            : Include sample-size and chunk-offset tables.\n");
-  fprintf(stdout,"-f n          : where n > 0.  Include jp2 header info for frame n [default=1].\n");
-  fprintf(stdout,"-f 0          : No jp2 header info.\n");
-  fprintf(stdout,"-r            : Suppress all 'raw' data for which a 'derived' form exists.\n");
-  fprintf(stdout,"-d            : Suppress all 'derived' data.\n");
-  fprintf(stdout,"                (If both -r and -d given, -r will be ignored.)\n");
-  fprintf(stdout,"-v string     : Verify against the DTD file located by the string.\n");
-  fprintf(stdout,"                Prepend quoted 'string' with either SYSTEM or PUBLIC keyword.\n");
-  fprintf(stdout,"                Thus, for the distributed DTD placed in the same directory as\n");
-  fprintf(stdout,"                the output file: -v \"SYSTEM mj2_to_metadata.dtd\"\n");
-  fprintf(stdout,"                \"PUBLIC\" is used with an access protocol (e.g., http:) + URL.\n");
-  /* More to come */
-  fprintf(stdout,"\n");
-  /*             "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
-}
-
-/* ------------- */
-
-int main(int argc, char *argv[]) {
-
-	opj_dinfo_t* dinfo; 
-	opj_event_mgr_t event_mgr;		/* event manager */
-
-  FILE *file, *xmlout;
-/*  char xmloutname[50]; */
-  opj_mj2_t *movie;
-
-  char* infile = 0;
-  char* outfile = 0;
-  char* s, S1, S2, S3;
-  int len;
-  unsigned int sampleframe = 1; /* First frame */
-  char* stringDTD = NULL;
-  BOOL notes = TRUE;
-  BOOL sampletables = FALSE;
-  BOOL raw = TRUE;
-  BOOL derived = TRUE;
-	mj2_dparameters_t parameters;
-
-  while (TRUE) {
-	/* ':' after letter means it takes an argument */
-    int c = getopt(argc, argv, "i:o:f:v:hntrd");
-	/* FUTURE:  Reserve 'p' for pruning file (which will probably make -t redundant) */
-    if (c == -1)
-      break;
-    switch (c) {
-    case 'i':			/* IN file */
-      infile = optarg;
-      s = optarg;
-      while (*s) { s++; } /* Run to filename end */
-      s--;
-      S3 = *s;
-      s--;
-      S2 = *s;
-      s--;
-      S1 = *s;
-      
-      if ((S1 == 'm' && S2 == 'j' && S3 == '2')
-      || (S1 == 'M' && S2 == 'J' && S3 == '2')) {
-       break;
-      }
-      fprintf(stderr, "Input file name must have .mj2 extension, not .%c%c%c.\n", S1, S2, S3);
-      return 1;
-
-      /* ----------------------------------------------------- */
-    case 'o':			/* OUT file */
-      outfile = optarg;
-      while (*outfile) { outfile++; } /* Run to filename end */
-      outfile--;
-      S3 = *outfile;
-      outfile--;
-      S2 = *outfile;
-      outfile--;
-      S1 = *outfile;
-      
-      outfile = optarg;
-      
-      if ((S1 == 'x' && S2 == 'm' && S3 == 'l')
-	  || (S1 == 'X' && S2 == 'M' && S3 == 'L'))
-        break;
-    
-      fprintf(stderr,
-	  "Output file name must have .xml extension, not .%c%c%c\n", S1, S2, S3);
-	  return 1;
-
-      /* ----------------------------------------------------- */
-    case 'f':			/* Choose sample frame.  0 = none */
-      sscanf(optarg, "%u", &sampleframe);
-      break;
-
-      /* ----------------------------------------------------- */
-    case 'v':			/* Verification by DTD. */
-      stringDTD = optarg;
-	  /* We will not insist upon last 3 chars being "dtd", since non-file
-	  access protocol may be used. */
-	  if(strchr(stringDTD,'"') != NULL) {
-        fprintf(stderr, "-D's string must not contain any embedded double-quote characters.\n");
-	    return 1;
-	  }
-
-      if (strncmp(stringDTD,"PUBLIC ",7) == 0 || strncmp(stringDTD,"SYSTEM ",7) == 0)
-        break;
-    
-      fprintf(stderr, "-D's string must start with \"PUBLIC \" or \"SYSTEM \"\n");
-	  return 1;
-
-    /* ----------------------------------------------------- */
-    case 'n':			/* Suppress comments */
-      notes = FALSE;
-      break;
-
-    /* ----------------------------------------------------- */
-    case 't':			/* Show sample size and chunk offset tables */
-      sampletables = TRUE;
-      break;
-
-    /* ----------------------------------------------------- */
-    case 'h':			/* Display an help description */
-      help_display();
-      return 0;
-
-    /* ----------------------------------------------------- */
-    case 'r':			/* Suppress raw data */
-      raw = FALSE;
-      break;
-
-    /* ----------------------------------------------------- */
-    case 'd':			/* Suppress derived data */
-      derived = FALSE;
-      break;
-
-   /* ----------------------------------------------------- */
-    default:
-      return 1;
-    } /* switch */
-  } /* while */
-
-  if(!raw && !derived)
-	  raw = TRUE; /* At least one of 'raw' and 'derived' must be true */
-
-    /* Error messages */
-  /* -------------- */
-  if (!infile || !outfile) {
-    fprintf(stderr,"Correct usage: mj2_to_metadata -i mj2-file -o xml-file (plus options)\n");
-    return 1;
-  }
-
-/* was:
-  if (argc != 3) {
-    printf("Bad syntax: Usage: MJ2_to_metadata inputfile.mj2 outputfile.xml\n"); 
-    printf("Example: MJ2_to_metadata foreman.mj2 foreman.xml\n");
-    return 1;
-  }
-*/
-  len = strlen(infile);
-  if(infile[0] == ' ')
-  {
-    infile++; /* There may be a leading blank if user put space after -i */
-  }
-  
-  file = fopen(infile, "rb"); /* was: argv[1] */
-  
-  if (!file) {
-    fprintf(stderr, "Failed to open %s for reading.\n", infile); /* was: argv[1] */
-    return 1;
-  }
-
-  len = strlen(outfile);
-  if(outfile[0] == ' ')
-  {
-    outfile++; /* There may be a leading blank if user put space after -o */
-  }
-
-  // Checking output file
-  xmlout = fopen(outfile, "w"); /* was: argv[2] */
-  if (!xmlout) {
-    fprintf(stderr, "Failed to open %s for writing.\n", outfile); /* was: argv[2] */
-    return 1;
-  }
-  // Leave it open
-
-	/*
-	configure the event callbacks (not required)
-	setting of each callback is optionnal
-	*/
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* get a MJ2 decompressor handle */
-	dinfo = mj2_create_decompress();
-
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);		
-
-	/* setup the decoder decoding parameters using user parameters */
-	movie = (opj_mj2_t*) dinfo->mj2_handle;
-	mj2_setup_decoder(dinfo->mj2_handle, &parameters);
-
-  if (mj2_read_struct(file, movie)) // Creating the movie structure
-  {
-    fclose(xmlout);
-    return 1;
-  }
-
-  xml_write_init(notes, sampletables, raw, derived);
-  xml_write_struct(file, xmlout, movie, sampleframe, stringDTD, &event_mgr);
-  fclose(xmlout);
-
-	fprintf(stderr,"Metadata correctly extracted to XML file \n");;	
-
-	/* free remaining structures */
-	if(dinfo) {
-		mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
-	}
-
-  return 0;
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsp b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsp
deleted file mode 100644
index 7b4e20f..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsp
+++ /dev/null
@@ -1,140 +0,0 @@
-# Microsoft Developer Studio Project File - Name="mj2_to_metadata" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=mj2_to_metadata - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "mj2_to_metadata.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "mj2_to_metadata.mak" CFG="mj2_to_metadata - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "mj2_to_metadata - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "mj2_to_metadata - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "mj2_to_metadata - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmtd"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "mj2_to_metadata - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "mj2_to_metadata___Win32_Debug0"
-# PROP BASE Intermediate_Dir "mj2_to_metadata___Win32_Debug0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "mj2_to_metadata___Win32_Debug0"
-# PROP Intermediate_Dir "mj2_to_metadata___Win32_Debug0"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmtd" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF 
-
-# Begin Target
-
-# Name "mj2_to_metadata - Win32 Release"
-# Name "mj2_to_metadata - Win32 Debug"
-# Begin Group "MJ2"
-
-# PROP Default_Filter ""
-# Begin Group "MJ2 Header Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\compat\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\meta_out.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_convert.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_to_metadata.h
-# End Source File
-# End Group
-# Begin Group "MJ2 Source Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\compat\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\meta_out.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_convert.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mj2_to_metadata.c
-# End Source File
-# End Group
-# End Group
-# End Target
-# End Project
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsw b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsw
deleted file mode 100644
index f28254b..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dsw
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "LibOpenJPEG"="..\LibOpenJPEG.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "mj2_to_metadata"=".\mj2_to_metadata.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name LibOpenJPEG
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dtd b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dtd
deleted file mode 100644
index 249de1a..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.dtd
+++ /dev/null
@@ -1,425 +0,0 @@
-<!--
-Preliminary DTD for Open JPEG "mj2_to_metadata" function.
-Last revised: April 20, 2005
-Author:  Glenn Pearson, at U.S. National Library of Medicine.
-See mj2_to_metadata.c regarding copyright, license, disclaimer status.
-
-While the vocabulary of this DTD is based on the relevant portions of the
-ISO/IEC JPEG 200 standard, the detailed representation is the author's own.
-It is neither an ISO/IEC nor NLM official or consensus representation.
-Furthermore, it deviates from a pure representation of the ISO/IEC standard
-in these aspects:
-
-  - it is incomplete in a number of ways (which to some extent may be
-    addressed over time);
-  - it has extensions for "derived" data and "statistics";
-  - it is more flexible.  That is, some elements are marked as optional
-    not because they are optional in an MJ2 file, but because reporting
-    of them is optional based on current or projected mj2_to_metadata
-    command-line flags.
--->
-<!ELEMENT MJ2_File (JP2?, FileType?, MovieBox?)>
-<!ELEMENT JP2 EMPTY>
-<!ATTLIST JP2 BoxType CDATA #FIXED "jP[space][space]">
-<!ATTLIST JP2 Signature CDATA #FIXED "0x0d0a870a">
-<!ELEMENT FileType (Brand, MinorVersion, CompatibilityList)>
-<!ATTLIST FileType BoxType CDATA #FIXED "ftyp">
-<!ELEMENT Brand (#PCDATA)> <!-- 4 characters max -->
-<!ELEMENT MinorVersion (#PCDATA)> <!-- 4 chararcters max -->
-<!ELEMENT CompatibilityList (CompatibleBrand)*>
-<!ATTLIST CompatibilityList Count CDATA #REQUIRED>  <!-- Count >= 0 -->
-<!ELEMENT CompatibleBrand (#PCDATA)> <!-- 4 characters max -->
-<!ELEMENT MovieBox (MovieHeader, Statistics?, Track*)>
-<!ATTLIST MovieBox BoxType CDATA #FIXED "moov">
-<!ELEMENT MovieHeader (CreationTime, ModificationTime, Timescale, Rate, Duration, Volume, TransformationMatrix)>
-<!ATTLIST MovieHeader BoxType CDATA #FIXED "mvhd">
-<!ELEMENT CreationTime (InSeconds?,AsLocalTime?)>
-<!ELEMENT InSeconds (#PCDATA)>
-<!ELEMENT AsLocalTime (#PCDATA)>
-<!ELEMENT ModificationTime (InSeconds?,AsLocalTime?)>
-<!ELEMENT Timescale (#PCDATA)> <!-- Timescale defines time units in one second -->
-<!ELEMENT Rate (AsHex | (AsHex, AsDecimal) | AsDecimal)>  <!-- Decimal is Approximation; Optional on input. -->
-<!ELEMENT AsHex (#PCDATA)>
-<!ELEMENT AsDecimal (#PCDATA)> 
-<!ELEMENT Duration (InTimeUnits | (InTimeUnits, InSeconds) | InSeconds)>  <!-- InSeconds Optional on input. -->
-<!ELEMENT InTimeUnits (#PCDATA)>
-<!ELEMENT Volume (AsHex | (AsHex, AsDecimal) | AsDecimal)>   <!-- hex default = 0x0100 -->
-<!-- Fixed 8.8 value of audio volume.  Full, normal value is 1.0 (0x0100) -->
-<!ELEMENT TransformationMatrix (TMa,TMb,TMu,TMc,TMd,TMv,TMx,TMy,TMw)> <!-- for video -->
-<!-- 3 x 3 Video Transformation Matrix {a,b,u,c,d,v,x,y,w}.  Required: u=0, v=0, w=1 -->
-<!-- Maps decompressed point (p,q) to rendered point (ap + cq + x, bp + dq + y) -->
-<!-- Stored as Fixed Point Hex: all are 16.16, except u,v,w are 2.30 -->
-<!-- Unity = 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 -->
-<!ELEMENT TMa (#PCDATA)>    
-<!ELEMENT TMb (#PCDATA)>  
-<!ELEMENT TMu (#PCDATA)> <!--Always "0x00000000" -->
-<!ELEMENT TMc (#PCDATA)>
-<!ELEMENT TMd (#PCDATA)>
-<!ELEMENT TMv (#PCDATA)> <!--Always "0x00000000" -->
-<!ELEMENT TMx (#PCDATA)>
-<!ELEMENT TMy (#PCDATA)>
-<!ELEMENT TMw (#PCDATA)> <!--Always "0x40000000" -->
-
-<!ELEMENT Statistics (TracksFound)>
-<!ELEMENT TracksFound (Video,Audio,Hint)>
-<!ELEMENT Video (#PCDATA)>
-<!ELEMENT Audio (#PCDATA)>
-<!ELEMENT Hint (#PCDATA)>
- 
-
-<!-- For now, output info on at most one video track -->
-
-
-<!ELEMENT Track (TrackHeader, TrackReferenceContainer?, EditListContainer?, Media, JP2_Frame?)>  <!-- JP2_Frame is mj2_to_metadata extension -->
-<!ATTLIST Track BoxType CDATA #FIXED "trak">
-<!ATTLIST Track Instance CDATA #REQUIRED>
-<!ELEMENT TrackHeader (TrackID, TrackLayer?, Volume?, TransformationMatrix?, Width?, Height?)>
-<!ATTLIST TrackHeader BoxType CDATA #FIXED "tkhd">
-<!-- Not shown here: CreationTime, ModificationTime, Duration. -->
-<!-- These 3 fields are reported under MediaHeader below.   When reading these 3, -->
-<!-- m2j_to_metadata currently doesn't distinguish between TrackHeader and MediaHeader source. -->
-<!-- If both found, value read from MediaHeader is used. -->
-<!ELEMENT TrackID (#PCDATA)>
-<!ELEMENT TrackLayer (#PCDATA)>  <!-- front-to-back ordering of video tracks. 0 = normal, -1 is closer, etc. -->
-<!-- "Volume" element described above; here it is for particular audio track.  Full, normal (default = 0x0100) -->
-<!-- "TransformationMatrix" element described above; matrix here is applied before MovieHeader one. -->
-<!ELEMENT Width (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!ELEMENT Height (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!-- AsHex, AsDecimal already defined above -->
- <!-- Width and Height are for the presentation; frames will be scaled to this -->
-<!-- /TrackHeader -->
-<!ELEMENT TrackReferenceContainer ANY>  <!-- TO DO: TrackReferenceContainer 'tref'  just used in hint track -->
-<!ELEMENT EditListContainer ANY>  <!-- TO DO: EditListContainer 'edts', contains EditList 'elst' with media-time, segment-duration, media-rate -->
-<!ELEMENT Media (MediaHeader, HandlerReference,MediaInfoContainer)>
-<!ATTLIST Media BoxType CDATA #FIXED "mdia">
-<!ELEMENT MediaHeader (CreationTime,ModificationTime,Timescale,Duration,Language)>
-<!ATTLIST MediaHeader BoxType CDATA #FIXED "mdhd">
-<!-- Elements already defined above: CreationTime, ModificationTime, Timescale, Duration -->
-<!ELEMENT Language (#PCDATA)> <!-- 3 chars max.  There's an enumeration available -->
-<!ELEMENT HandlerReference (HandlerType)>
-<!ATTLIST HandlerReference BoxType CDATA #FIXED "hdlr">
-<!ELEMENT HandlerType (#PCDATA)>
-<!ATTLIST HandlerType Code ( vide | soun | hint ) "vide">
-
-<!-- make the media headers multiple? -->
-<!ELEMENT MediaInfoContainer ((VideoMediaHeader | SoundMediaHeader | HintMediaHeader), DataInfo, SampleTable)>
-<!ATTLIST MediaInfoContainer BoxType CDATA #FIXED "minf">
-<!ELEMENT VideoMediaHeader (GraphicsMode, Opcolor)>
-<!ATTLIST VideoMediaHeader BoxType CDATA #FIXED "vmhd">
-<!ELEMENT GraphicsMode (#PCDATA)>
-          <!-- Enumerated values of graphics mode: -->
-          <!--  0x00 = copy (over existing image); -->
-          <!--  0x24 = transparent; 'blue-screen' this image using opcolor; -->
-          <!--  0x100 = alpha; alpha-blend this image -->
-          <!--  0x101 = whitealpha; alpha-blend this image, which has been blended with white; -->
-          <!--  0x102 = blackalpha; alpha-blend this image, which has been blended with black. -->
-<!ELEMENT Opcolor (Red,Green,Blue)>
-<!ELEMENT Red (#PCDATA)>
-<!ELEMENT Green (#PCDATA)>
-<!ELEMENT Blue (#PCDATA)>
-<!ELEMENT SoundMediaHeader (Balance)>
-<!ATTLIST SoundMediaHeader BoxType CDATA #FIXED "smhd">
-<!ELEMENT Balance (#PCDATA)>
-          <!-- Fixed Point 8.8, fixes mono track in stereo space. -->
-          <!-- 0.0 = center, -1.0 = full left, 1.0 = full right -->
-<!ELEMENT HintMediaHeader (MaxPDU_Size, AvgPDU_Size, MaxBitRate, AvgBitRate, SlidingAvgBitRate)>
-<!ATTLIST HintMediaHeader BoxType CDATA #FIXED "hmhd">
-<!ELEMENT MaxPDU_Size (#PCDATA)>
-          <!-- Size in bytes of largest PDU in this hint stream. -->
-<!ELEMENT AvgPDU_Size (#PCDATA)>
-           <!-- Average size in bytes of a PDU over the entire presentation. -->
-<!ELEMENT MaxBitRate (#PCDATA)>
-          <!-- Maximum rate in bits per second over any window of 1 second. -->
-<!ELEMENT AvgBitRate (#PCDATA)>
-          <!-- Averate rate in bits per second over the entire presentation. -->
-<!ELEMENT SlidingAvgBit (#PCDATA)>
-          <!-- Maximum rate in bits per second over any window of one minute. -->
- 
-<!ELEMENT DataInfo (DataReference)>
-<!ATTLIST DataInfo BoxType CDATA #FIXED "dinf">
-<!ELEMENT DataReference (DataEntryUrlBox | DataEntryUrnBox )*>
-<!ATTLIST DataReference BoxType CDATA #FIXED "dref">
-<!ATTLIST DataReference URL_Count CDATA #REQUIRED>
-<!ATTLIST DataReference URN_Count CDATA #REQUIRED> <!-- table w. flags, URLs, URNs -->
-<!--  // Data structure does not distinguish between single URL, single URN, or DREF table or URLs & URNs.
-  // We could infer those, but for now just present everything as a DREF table.
--->
-              <!-- No entries here mean that file is self-contained, as required by Simple Profile. -->
-
-<!ELEMENT DataEntryUrlBox (Location)>
-<!ATTLIST DataEntryUrlBox BoxType CDATA #FIXED "url[space]"> <!-- table w. flags, URLs, URNs -->
-            <!-- Only the first 16 bytes of URL location are recorded in mj2_to_metadata data structure. -->
-<!ELEMENT DataEntryUrnBox (Name, Location?)>
-<!ATTLIST DataEntryUrnBox BoxType CDATA #FIXED "urn[space]\">
-            <!-- Only the first 16 bytes each of URN name and optional location are recorded in mj2_to_metadata data structure. -->
-
-<!ELEMENT SampleTable (VisualSampleEntry,TimeToSample,SampleToChunk,SampleSize,ChunkOffset)>  <!-- structure doesn't do non-visual sample entry yet -->
-<!ATTLIST SampleTable BoxType CDATA #FIXED "stbl">  <!-- to add: entry count -->
-            <!-- Next are instances of generic SampleDescription BoxType=\"stsd\" -->
- 
-    <!-- There could be multiple instances of this, but "entry_count" is just a local at read-time.
-       And it's used wrong, too, as count of just visual type, when it's really all 3 types.
-       This is referred to as "smj2" within mj2.c -->
-<!ELEMENT VisualSampleEntry (WidthAsInteger, HeightAsInteger, HorizontalRes, VerticalRes, CompressorName, Depth, JP2Header?, FieldCoding?, MJP2_Profile?, MJP2_Prefix?, MJP2_SubSampling?, MJP2_OriginalFormat?)>
-<!ATTLIST VisualSampleEntry BoxType CDATA #FIXED "mjp2">
-          <!-- If multiple instances of this, only first is shown here. -->
-<!ELEMENT WidthAsInteger (#PCDATA)>
-<!ELEMENT HeightAsInteger (#PCDATA)>
-<!ELEMENT HorizontalRes (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!ELEMENT VerticalRes (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!-- Typical value for both resolution is 72 (0x00480000) -->
-<!ELEMENT CompressorName (#PCDATA)>
-          <!-- Compressor name for debugging.  Standard restricts max length to 31 bytes. -->
-          <!-- Usually blank or \"Motion JPEG2000\" -->
-<!ELEMENT Depth (#PCDATA)>
-          <!-- Depth is: -->
-          <!--   0x20: alpha channels present (color or grayscale) -->
-          <!--   0x28: grayscale without alpha -->
-          <!--   0x18: color without alpha -->
-
-<!-- TODO somewhere: tk->jp2_struct.numcomps -->
-<!ELEMENT JP2Header (ImageHeader, ColourSpecification)>
-<!ATTLIST JP2Header BoxType CDATA #FIXED "jp2h">
-<!ELEMENT ImageHeader (HEIGHT, WIDTH, NC, BPC, C, UnkC, IPR)>
-<!ATTLIST ImageHeader BoxType CDATA #FIXED "ihdr">
-<!ELEMENT HEIGHT (#PCDATA)>  <!-- If 2 fields/frame, total deinterlaced height -->
-<!ELEMENT WIDTH (#PCDATA)>
-<!ELEMENT NC (#PCDATA)>  <!-- number of components -->
-<!ELEMENT BPC (AsHex | (AsHex,BitsPerPixel,Signed) | (BitsPerPixel,Signed))>
-<!ELEMENT BitsPerPixel (#PCDATA)>
-<!ELEMENT Signed (#PCDATA)>
-<!ELEMENT C (#PCDATA)>  <!-- Compression type.  Only "7" defined -->
-<!ELEMENT UnkC (#PCDATA)>  <!-- Colourspace Unknown. 1 = unknown, 0 = known -->
-<!ELEMENT IPR (#PCDATA)>  <!-- 1 = frame has Intellectual Prop. box; otherwise 0 -->
-<!ELEMENT ColourSpecification (METH, PREC, APPROX, EnumCS)>
-<!ATTLIST ColourSpecification BoxType CDATA #FIXED "colr">
-<!ELEMENT METH (#PCDATA)>  <!-- 1 = EnumCS field; 2 = PROFILE field (not yet generated) -->
-<!ELEMENT PREC (#PCDATA)> <!-- precedence must be 0 so far -->
-<!ELEMENT APPROX (#PCDATA)>  <!-- colourspace approximation must be 0 so far -->
-<!ELEMENT EnumCS (#PCDATA)> <!-- Valid enumerated MJ2 colourspaces: 16 (sRGB), 17 (grey sRGB), 18 (YCC) -->
-
-<!-- Following subboxes are optional -->
-<!ELEMENT FieldCoding (FieldCount, FieldOrder)>
-<!ATTLIST FieldCoding BoxType CDATA #FIXED "fiel">
-<!ELEMENT FieldCount (#PCDATA)>
-            <!-- Must be either 1 or 2 -->
-<!ELEMENT FieldOrder (#PCDATA)>
-            <!-- When FieldCount=2, FieldOrder means: -->
-            <!--   0: Field coding unknown -->
-            <!--   1: Field with topmost line is stored first in sample; fields are in temporal order -->
-            <!--   6: Field with topmost line is stored second in sample; fields are in temporal order -->
-            <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->
-            <!-- Current implementation doesn't retain whether box was actually present. -->
-
-<!ELEMENT MJP2_Profile (CompatibleBrand*)>
-<!ATTLIST MJP2_Profile BoxType CDATA #FIXED "jp2p">
-<!ATTLIST MJP2_Profile Count CDATA #REQUIRED>
-
-<!ELEMENT MJP2_Prefix (Data*)>
-<!ATTLIST MJP2_Prefix BoxType CDATA #FIXED "jp2x">
-<!ATTLIST MJP2_Prefix Count CDATA #REQUIRED>
-<!-- We'll probably need better formatting than this  -->
-<!ELEMENT Data (#PCDATA)>    <!-- Multiple. Each entry is single byte -->
-
-<!ELEMENT MJP2_SubSampling (HorizontalSub, VerticalSub, HorizontalOffset, VerticalOffset)>
-<!ATTLIST MJP2_SubSampling BoxType CDATA #FIXED "jsub">
-<!-- These values are all 1 byte -->
-            <!-- Typical subsample value is 2 for 4:2:0 -->
-<!ELEMENT HorizontalSub (#PCDATA)>
-<!ELEMENT VerticalSub (#PCDATA)>
-<!ELEMENT HorizontalOffset (#PCDATA)>
-<!ELEMENT VerticalOffset (#PCDATA)>
-
-<!ELEMENT MJP2_OriginalFormat (OriginalFieldCount, OriginalFieldOrder)>
-<!ATTLIST MJP2_OriginalFormat BoxType CDATA #FIXED "orfo"> <!-- Part III Appx. 2 -->
-<!ELEMENT OriginalFieldCount (#PCDATA)>
-            <!-- In original material before encoding.  Must be either 1 or 2 -->
-<!ELEMENT OriginalFieldOrder (#PCDATA)>
-            <!-- When FieldCount=2, FieldOrder means: -->
-            <!--   0: Field coding unknown -->
-            <!--   11: Topmost line came from the earlier field; -->
-            <!--   16:  Topmost line came form the later field. -->
-            <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->
-            <!-- Current implementation doesn't retain whether box was actually present. -->
-
-
-            <!-- mj2_to_metadata's data structure doesn't record Audio and Hint sample data currently. -->
-
-<!-- Within SampleTable: -->
-<!ELEMENT TimeToSample (SampleStatistics, SampleEntries)>
-<!ATTLIST TimeToSample BoxType CDATA #FIXED "stts">  
-<!ELEMENT SampleStatistics (TotalSamples)>  <!-- Not part of standard -->  
-<!ELEMENT TotalSamples (#PCDATA)>
-                <!-- For video, gives the total frames in the track, by summing all entries in the Sample Table -->
-
-<!ELEMENT SampleEntries (Table*)>
-<!ATTLIST SampleEntries EntryCount CDATA #REQUIRED>
-<!ELEMENT Table EMPTY> <!-- Multiple.  Attributes have values -->
-<!ATTLIST Table Entry CDATA #REQUIRED>
-<!ATTLIST Table SampleCount CDATA #REQUIRED>
-<!ATTLIST Table SampleDelta CDATA #REQUIRED>
-
-<!-- Within SampleTable: -->
-<!ELEMENT SampleToChunk (FirstChunk,SamplesPerChunk,SampleDescrIndex)>
-<!ATTLIST SampleToChunk BoxType CDATA #FIXED "stsc">
-<!ATTLIST SampleToChunk Count CDATA #REQUIRED>
-<!ELEMENT FirstChunk (#PCDATA)>
-<!ELEMENT SamplesPerChunk (#PCDATA)>
-<!ELEMENT SampleDescrIndex (#PCDATA)>
-<!ELEMENT SampleSize (Sample_Size,Sample_Count,EntrySize*)>
-<!ATTLIST SampleSize BoxType CDATA #FIXED "stsz">
-<!ELEMENT Sample_Size (#PCDATA)>
-<!ELEMENT Sample_Count (#PCDATA)>
-<!ELEMENT EntrySize (#PCDATA)>  <!-- appears multiply, but only with mj2_to_metadata option -t -->
-<!ATTLIST EntrySize Num CDATA #REQUIRED>
-<!ELEMENT ChunkOffset (EntryCount, Chunk_Offset*)>
-<!ATTLIST ChunkOffset BoxType CDATA #FIXED "stco">
-<!ELEMENT EntryCount (#PCDATA)>
-<!ELEMENT Chunk_Offset (#PCDATA)>  <!-- appears multiply, but only with mj2_to_metadata option -t -->
-<!ATTLIST Chunk_Offset Num CDATA #REQUIRED>
-<!-- </SampleTable> </MediaInfoContainer> </Media> -->
-
-<!-- TO DO: optional UserData 'udat', can contain multiple Copyright 'cprt' -->
-
-
-<!-- Optional, and only for Visual Track: given individual frame -->
-<!ELEMENT JP2_Frame (MainHeader, TilePartHeaders)>
-<!ATTLIST JP2_Frame Num CDATA #REQUIRED>
-<!ELEMENT MainHeader (StartOfCodestream,ImageAndFileSize,CodingStyleDefault,QuantizationDefault,QuantizationComponent*,RegionOfInterest?,ProgressionOrderChange*)>
-<!ELEMENT StartOfCodestream EMPTY>
-<!ATTLIST StartOfCodestream Marker CDATA #FIXED "SOC">
-<!ELEMENT ImageAndFileSize (Xsiz,Ysiz,XOsiz,YOsiz,XTsiz,YTsiz,XTOsiz,YTOsiz,Csiz,Component+)>
-<!ATTLIST ImageAndFileSize Marker CDATA #FIXED "SIZ">
-<!ELEMENT Xsiz (#PCDATA)>
-<!ELEMENT Ysiz (#PCDATA)>  <!-- Xsiz, Ysiz is the size of the reference grid. -->
-<!ELEMENT XOsiz (#PCDATA)>
-<!ELEMENT YOsiz (#PCDATA)>  <!-- XOsiz, YOsiz are offsets from grid origin to image origin. -->
-<!ELEMENT XTsiz (#PCDATA)>
-<!ELEMENT YTsiz (#PCDATA)>  <!-- XTsiz, YTsiz is the size of one tile with respect to the grid. -->
-<!ELEMENT XTOsiz (#PCDATA)>
-<!ELEMENT YTOsiz (#PCDATA)> <!-- XTOsiz, YTOsiz are offsets from grid origin to first tile origin. -->
-<!ELEMENT Csiz (#PCDATA)>  <!-- Csiz is the number of components in the image. -->
-<!-- For image components next -->
-<!ELEMENT Component (Ssiz,XRsiz,YRsiz,WidthOfData,HeightOfData)>
-<!ATTLIST Component Num CDATA #REQUIRED>
-<!ELEMENT Ssiz (AsHex | (AsHex,Signed,PrecisionInBits) | (Signed,PrecisionInBits))>
-<!-- Signed already defined -->
-<!ELEMENT PrecisionInBits (#PCDATA)>  <!--   Bits per pixel (bpp) or pixel depth. -->
-<!ELEMENT XRsiz (#PCDATA)>
-<!ELEMENT YRsiz (#PCDATA)> <!-- XRsiz, YRsiz denote pixel-sample-spacing on the grid, per Part I Annex B. -->
-<!ELEMENT WidthOfData (#PCDATA)>
-<!ELEMENT HeightOfData (#PCDATA)>  <!-- WidthOfData and HeightOfData are calculated values, e.g.: w = roundup((Xsiz - XOsiz)/ XRsiz) -->
-<!-- -->
-<!ELEMENT CodingStyleDefault (Scod,SGcod,SPcod)>
-<!ATTLIST CodingStyleDefault Marker CDATA #FIXED "COD">
-<!ELEMENT Scod (#PCDATA)>
-          <!-- For Scod, specific bits mean (where bit 0 is lowest or rightmost): -->
-          <!-- bit 0: Defines entropy coder precincts -->
-          <!--        0 = (PPx=15, PPy=15); 1 = precincts defined below. -->
-          <!-- bit 1: 1 = SOP marker may be used; 0 = not. -->
-          <!-- bit 2: 1 = EPH marker may be used; 0 = not. -->
-<!ELEMENT SGcod (ProgressionOrder,NumberOfLayers,MultipleComponentTransformation)>
-<!ELEMENT ProgressionOrder (#PCDATA)>
-            <!-- Defined Progression Order Values are: -->
-            <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->
-            <!-- where L = "layer", R = "resolution level", C = "component", P = "position". -->
-<!ELEMENT NumberOfLayers (#PCDATA)>
-<!ELEMENT MultipleComponentTransformation (#PCDATA)>
-            <!-- For MCT, 0 = none, 1 = transform first 3 components for efficiency, per Part I Annex G -->
-<!ELEMENT SPcod (NumberOfDecompositionLevels,CodeblockWidth,CodeblockHeight,CodeblockStyle,Transformation)>
-<!ELEMENT NumberOfDecompositionLevels (#PCDATA)>
-<!ELEMENT CodeblockWidth (#PCDATA)>   <!-- CBW and CBH are non-negative, and summed cannot exceed 8 -->
-<!ELEMENT CodeblockHeight (#PCDATA)>  <!-- Codeblock dimension is 2^(value + 2) -->
-<!ELEMENT CodeblockStyle (#PCDATA)>
-            <!-- For CodeblockStyle, bits mean (with value 1=feature on, 0=off): -->
-            <!-- bit 0: Selective arithmetic coding bypass. -->
-            <!-- bit 1: Reset context probabilities on coding pass boundaries. -->
-            <!-- bit 2: Termination on each coding pass. -->
-            <!-- bit 3: Vertically causal context. -->
-            <!-- bit 4: Predictable termination. -->
-            <!-- bit 5: Segmentation symbols are used. -->
-<!ELEMENT Transformation (#PCDATA)> <!-- For Transformation, 0="9-7 irreversible filter", 1="5-3 reversible filter" -->
-        <!-- mj2_to_metadata implementation always reports component[0] as using default COD, -->
-        <!-- and any other component, with main-header style values different from [0], as COC. -->
-<!ELEMENT QuantizationDefault (Sqcd,SPqcd)>
-<!ATTLIST QuantizationDefault Marker CDATA #FIXED "QCD">
-<!ELEMENT Sqcd (AsHex | (AsHex,QuantizationStyle,NumberOfGuardBits) | (QuantizationStyle,NumberOfGuardBits))>
-<!ELEMENT QuantizationStyle (#PCDATA)>  <!-- Default quantization style for all components. -->
-            <!-- Quantization style (in Sqcd's low 5 bits) may be: -->
-            <!--   0 = No quantization. SPqcd size = 8 bits-->
-            <!--   1 = Scalar derived (values signaled for N(L)LL subband only). Use Eq. E.5. SPqcd size = 16. -->
-            <!--   2 = Scalar expounded (values signaled for each subband). SPqcd size = 16. -->
-<!ELEMENT NumberOfGuardBits (#PCDATA)>  <!-- 0-7 guard bits allowed (stored in Sqcd's high 3 bits) -->
-<!ELEMENT SPqcd (ReversibleStepSizeValue | QuantizationStepSizeValues )>  <!-- TO DO: Irreversible choices -->
-<!ELEMENT ReversibleStepSizeValue (DynamicRangeExponent+)>
-            <!-- Current mj2_to_metadata implementation dumps entire internal table, -->
-            <!-- until an exponent with zero value is reached. -->
-            <!-- Exponent epsilon(b) of reversible dynamic range. -->
-            <!-- Hex value is as stored, in high-order 5 bits. -->
-<!ELEMENT DynamicRangeExponent (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!ATTLIST DynamicRangeExponent Subband CDATA #REQUIRED>
-<!ELEMENT QuantizationStepSizeValues (QuantizationValues+, CalculatedExponent*)>  <!-- Calculated exponents iff only subband 0 reported -->
-<!ELEMENT QuantizationValues (AsHex | (AsHex,Exponent,Mantissa) | (Exponent,Mantissa))>
-<!ATTLIST QuantizationValues Subband CDATA #REQUIRED>
-<!ELEMENT Exponent (#PCDATA)>
-<!ELEMENT Mantissa (#PCDATA)>
-<!ELEMENT CalculatedExponent (#PCDATA)>
-<!ATTLIST CalculatedExponent Subband CDATA #REQUIRED>
-<!-- /QuantizationDefault -->
-        <!-- mj2_to_metadata implementation always reports component[0] as using default QCD, -->
-        <!-- and any other component, with main-header quantization values different from [0], as QCC. -->
-<!ELEMENT QuantizationComponent (Sqcc,SPqcc)>
-<!ATTLIST QuantizationComponent Marker CDATA #FIXED "QCC">
-<!ATTLIST QuantizationComponent Component CDATA #REQUIRED>
-<!ELEMENT Sqcc (AsHex | (AsHex,QuantizationStyle,NumberOfGuardBits) | (QuantizationStyle,NumberOfGuardBits))>
-<!ELEMENT SPqcc (ReversibleStepSizeValue | QuantizationStepSizeValues )>  <!-- TO DO: Irreversible choices -->
-<!-- /QuantizationComponent -->
-<!-- Don't know if MJ2 files can have regions of interest.  Assume yes -->
-<!ELEMENT RegionOfInterest (Srgn,Crgn,Sprgn)> <!-- Optional in main header, at most 1 per component -->
-<!ATTLIST RegionOfInterest Marker CDATA #FIXED "RGN">
-<!ELEMENT Srgn (#PCDATA)>  <!-- ROI style.  Only style=0 defined: Implicit ROI (max. shift) -->
-<!ELEMENT Crgn (#PCDATA)>  <!-- Zero-based component number. -->
-<!ELEMENT SPrgn (#PCDATA)> <!-- Implicit ROI shift, i.e., binary shifting of ROI coefficients above background. -->
-<!-- </RegionOfInterest> -->
-<!ELEMENT ProgressionOrderChange (Progression+)> <!-- Optional in main header, at most 1 per component (but impl allows more?) -->
-<!ATTLIST ProgressionOrderChange Marker CDATA #REQUIRED>
-<!ELEMENT Progression (RSpoc,CSpoc,LYEpoc,REpoc,CEpoc,Ppoc)>
-<!ATTLIST Progression Num CDATA #REQUIRED>
-<!ELEMENT RSpoc (#PCDATA)> <!-- Resolution level index (inclusive) for progression start. Range: 0 to 33 -->
-<!ELEMENT CSpoc (#PCDATA)> <!-- Component index (inclusive) for progression start. -->
-<!ELEMENT LYEpoc (#PCDATA)> <!-- Layer index (exclusive) for progression end. -->
-<!ELEMENT REpoc (#PCDATA)> <!-- Resolution level index (exclusive) for progression end. Range: RSpoc to 33 -->
-<!ELEMENT CEpoc (#PCDATA)> <!-- Component index (exclusive) for progression end.  Minimum: CSpoc -->
-<!ELEMENT Ppoc (#PCDATA)> <!-- Defined Progression Order Values are: -->
-                          <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->
-                          <!-- where L = "layer", R = "resolution level", C = "component", P = "position". -->
-<!-- </Progression>, </ProgressionOrderChange -->
-<!-- /MainHeader -->
-<!ELEMENT TilePartHeaders (TilePartHeader+)>
-<!ATTLIST TilePartHeaders Count CDATA #REQUIRED>
-<!ELEMENT TilePartHeader (StartOfTilePart,CodingStyleDefault,QuantizationDefault,QuantizationComponent*,RegionOfInterest?,ProgressionOrderChange*,StartOfData)>
-<!ATTLIST TilePartHeader Num CDATA #REQUIRED>
-<!ATTLIST TilePartHeader ID CDATA #REQUIRED>
-<!ELEMENT StartOfTilePart EMPTY>
-<!ATTLIST StartOfTilePart Marker CDATA #FIXED "SOT">
-<!-- CodingStyleDefault, QuantizationDefault, QuantizationComponent already defined -->
-        <!-- mj2_to_metadata implementation always reports component[0] as using default QCD, -->
-        <!-- and any other component, with tile-part-header quantization values different from [0], as QCC. -->
-<!ELEMENT StartOfData EMPTY> <!-- always empty for now -->
-<!ATTLIST StartOfData Marker CDATA #FIXED "SOD">
-          <!-- Tile-part bitstream, not shown, follows tile-part header and SOD marker. -->
-<!-- /TilePartHeader, /TilePartHeaders, /JP2_Frame -->
-<!-- </Track> -->
-
-<!-- to come:
-  <MovieExtends mvek> // possibly not in Simple Profile
-  <UserDataBox udat> contains <CopyrightBox cprt>
-  -->
-<!-- /MovieBox -->
-<!-- To come:
-  <mdat>
-  <moof>  // probably not in Simple Profile
-  <free>
-  <skip>
-  -->
-<!-- </MJ2_File> -->
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.h b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.h
deleted file mode 100644
index f4c3491..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* mj2_to_metadata.h */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Contributed to Open JPEG by Glenn Pearson, U.S. National Library of Medicine */
-
-#define BOOL int
-#define FALSE 0
-#define TRUE 1
-
-#include "meta_out.h"
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.sln b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.sln
deleted file mode 100644
index 32b926d..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.sln
+++ /dev/null
@@ -1,29 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mj2_to_metadata", "mj2_to_metadata.vcproj", "{69BE42AB-E7CE-4DA1-BBD2-39FEA2C91E0B}"
-	ProjectSection(ProjectDependencies) = postProject
-		{0B1B7713-35B6-40A7-9BFF-A7D0EB06A8BD} = {0B1B7713-35B6-40A7-9BFF-A7D0EB06A8BD}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOpenJPEG", "..\LibOpenJPEG.vcproj", "{0B1B7713-35B6-40A7-9BFF-A7D0EB06A8BD}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{69BE42AB-E7CE-4DA1-BBD2-39FEA2C91E0B}.Debug|Win32.ActiveCfg = Debug|Win32
-		{69BE42AB-E7CE-4DA1-BBD2-39FEA2C91E0B}.Debug|Win32.Build.0 = Debug|Win32
-		{69BE42AB-E7CE-4DA1-BBD2-39FEA2C91E0B}.Release|Win32.ActiveCfg = Release|Win32
-		{69BE42AB-E7CE-4DA1-BBD2-39FEA2C91E0B}.Release|Win32.Build.0 = Release|Win32
-		{0B1B7713-35B6-40A7-9BFF-A7D0EB06A8BD}.Debug|Win32.ActiveCfg = Debug|Win32
-		{0B1B7713-35B6-40A7-9BFF-A7D0EB06A8BD}.Debug|Win32.Build.0 = Debug|Win32
-		{0B1B7713-35B6-40A7-9BFF-A7D0EB06A8BD}.Release|Win32.ActiveCfg = Release|Win32
-		{0B1B7713-35B6-40A7-9BFF-A7D0EB06A8BD}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.vcproj b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.vcproj
deleted file mode 100644
index 4207365..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata.vcproj
+++ /dev/null
@@ -1,349 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="mj2_to_metadata"
-	ProjectGUID="{69BE42AB-E7CE-4DA1-BBD2-39FEA2C91E0B}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\mj2_to_metadata___Win32_Debug0"
-			IntermediateDirectory=".\mj2_to_metadata___Win32_Debug0"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.pch"
-				AssemblerListingLocation=".\mj2_to_metadata___Win32_Debug0/"
-				ObjectFile=".\mj2_to_metadata___Win32_Debug0/"
-				ProgramDataBaseFileName=".\mj2_to_metadata___Win32_Debug0/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="LIBCMT"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\Release"
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\Release/mj2_to_metadata.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="../libopenjpeg"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/mj2_to_metadata.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="2057"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile=".\Release/mj2_to_metadata.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				IgnoreDefaultLibraryNames="libcmtd"
-				ProgramDatabaseFile=".\Release/mj2_to_metadata.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\Release/mj2_to_metadata.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="MJ2"
-			>
-			<Filter
-				Name="MJ2 Header Files"
-				>
-				<File
-					RelativePath="compat\getopt.h"
-					>
-				</File>
-				<File
-					RelativePath="meta_out.h"
-					>
-				</File>
-				<File
-					RelativePath="mj2.h"
-					>
-				</File>
-				<File
-					RelativePath="mj2_convert.h"
-					>
-				</File>
-				<File
-					RelativePath="mj2_to_metadata.h"
-					>
-				</File>
-			</Filter>
-			<Filter
-				Name="MJ2 Source Files"
-				>
-				<File
-					RelativePath="compat\getopt.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="meta_out.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2_convert.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath="mj2_to_metadata.c"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							AdditionalIncludeDirectories=""
-							PreprocessorDefinitions=""
-						/>
-					</FileConfiguration>
-				</File>
-			</Filter>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata_Notes.doc b/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata_Notes.doc
deleted file mode 100644
index 05ccec2..0000000
Binary files a/Utilities/gdcmopenjpeg-v1/mj2/mj2_to_metadata_Notes.doc and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/readme.txt b/Utilities/gdcmopenjpeg-v1/mj2/readme.txt
deleted file mode 100644
index 9419d2a..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/readme.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Attention : the motion jpeg 2000 files currently only work with OpenJPEG v0.97 that you can find here : 
-
-http://www.openjpeg.org/openjpeg_v097.tar.gz
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v1/mj2/wrap_j2k_in_mj2.c b/Utilities/gdcmopenjpeg-v1/mj2/wrap_j2k_in_mj2.c
deleted file mode 100644
index 77b4959..0000000
--- a/Utilities/gdcmopenjpeg-v1/mj2/wrap_j2k_in_mj2.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "openjpeg.h"
-#include "../libopenjpeg/j2k.h"
-#include "../libopenjpeg/jp2.h"
-#include "../libopenjpeg/cio.h"
-#include "mj2.h"
-
-static int int_ceildiv(int a, int b) {
-	return (a + b - 1) / b;
-}
-
-/**
-Size of memory first allocated for MOOV box
-*/
-#define TEMP_BUF 10000 
-
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-	FILE *stream = (FILE*)client_data;
-	fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-
-static void read_siz_marker(FILE *file, opj_image_t *image)
-{
-  int len,i;
-  char buf, buf2[2];
-  unsigned char *siz_buffer;
-	opj_cio_t *cio;
-  
-  fseek(file, 0, SEEK_SET);
-  do {
-    fread(&buf,1,1, file);
-    if (buf==(char)0xff)
-      fread(&buf,1,1, file);
-  }
-  while (!(buf==(char)0x51));
-  
-  fread(buf2,2,1,file);		/* Lsiz                */
-  len = ((buf2[0])<<8) + buf2[1];
-  
-  siz_buffer = (unsigned char*) malloc(len * sizeof(unsigned char));
-  fread(siz_buffer,len, 1, file);
-	cio = opj_cio_open(NULL, siz_buffer, len);
-  
-  cio_read(cio, 2);			/* Rsiz (capabilities) */
-  image->x1 = cio_read(cio, 4);	/* Xsiz                */
-  image->y1 = cio_read(cio, 4);	/* Ysiz                */
-  image->x0 = cio_read(cio, 4);	/* X0siz               */
-  image->y0 = cio_read(cio, 4);	/* Y0siz               */
-  cio_skip(cio, 16);			/* XTsiz, YTsiz, XT0siz, YT0siz        */
-  
-  image->numcomps = cio_read(cio,2);	/* Csiz                */
-  image->comps =
-    (opj_image_comp_t *) malloc(image->numcomps * sizeof(opj_image_comp_t));
-	
-  for (i = 0; i < image->numcomps; i++) {
-    int tmp;
-    tmp = cio_read(cio,1);		/* Ssiz_i          */
-    image->comps[i].prec = (tmp & 0x7f) + 1;
-    image->comps[i].sgnd = tmp >> 7;
-    image->comps[i].dx = cio_read(cio,1);	/* XRsiz_i         */
-    image->comps[i].dy = cio_read(cio,1);	/* YRsiz_i         */
-    image->comps[i].resno_decoded = 0;	/* number of resolution decoded */
-    image->comps[i].factor = 0;	/* reducing factor by component */
-  }
-  fseek(file, 0, SEEK_SET);
-	opj_cio_close(cio);
-  free(siz_buffer);
-}
-
-static void setparams(opj_mj2_t *movie, opj_image_t *image) {
-  int i, depth_0, depth, sign;
-  
-  movie->tk[0].sample_rate = 25;
-  movie->tk[0].w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
-  movie->tk[0].h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
-  mj2_init_stdmovie(movie);
-  
-  movie->tk[0].depth = image->comps[0].prec;
-	
-  if (image->numcomps==3) {
-    if ((image->comps[0].dx == 1) 
-	&& (image->comps[1].dx == 1) 
-	&& (image->comps[2].dx == 1)) 
-      movie->tk[0].CbCr_subsampling_dx = 1;
-    else 
-	if ((image->comps[0].dx == 1) 
-	&& (image->comps[1].dx == 2) 
-	&& (image->comps[2].dx == 2))
-      movie->tk[0].CbCr_subsampling_dx = 2;
-    else
-      fprintf(stderr,"Image component sizes are incoherent\n");
-    
-    if ((image->comps[0].dy == 1) 
-	&& (image->comps[1].dy == 1) 
-	&& (image->comps[2].dy == 1)) 
-      movie->tk[0].CbCr_subsampling_dy = 1;
-    else 
-	if ((image->comps[0].dy == 1) 
-	&& (image->comps[1].dy == 2) 
-	&& (image->comps[2].dy == 2))
-      movie->tk[0].CbCr_subsampling_dy = 2;
-    else
-      fprintf(stderr,"Image component sizes are incoherent\n");
-  }
-  
-  movie->tk[0].sample_rate = 25;
-  
-  movie->tk[0].jp2_struct.numcomps = image->numcomps;	// NC  
-	
-	/* Init Standard jp2 structure */
-	
-	movie->tk[0].jp2_struct.comps =
-    (opj_jp2_comps_t *) malloc(movie->tk[0].jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
-  movie->tk[0].jp2_struct.precedence = 0;   /* PRECEDENCE*/
-  movie->tk[0].jp2_struct.approx = 0;   /* APPROX*/
-  movie->tk[0].jp2_struct.brand = JP2_JP2;	/* BR         */
-  movie->tk[0].jp2_struct.minversion = 0;	/* MinV       */
-  movie->tk[0].jp2_struct.numcl = 1;
-  movie->tk[0].jp2_struct.cl = (unsigned int *) malloc(movie->tk[0].jp2_struct.numcl * sizeof(int));
-  movie->tk[0].jp2_struct.cl[0] = JP2_JP2;	/* CL0 : JP2  */
-  movie->tk[0].jp2_struct.C = 7;      /* C : Always 7*/
-  movie->tk[0].jp2_struct.UnkC = 0;      /* UnkC, colorspace specified in colr box*/
-  movie->tk[0].jp2_struct.IPR = 0;      /* IPR, no intellectual property*/
-  movie->tk[0].jp2_struct.w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
-  movie->tk[0].jp2_struct.h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
-  
-  depth_0 = image->comps[0].prec - 1;
-  sign = image->comps[0].sgnd;
-  movie->tk[0].jp2_struct.bpc = depth_0 + (sign << 7);
-  
-  for (i = 1; i < image->numcomps; i++) {
-    depth = image->comps[i].prec - 1;
-    sign = image->comps[i].sgnd;
-    if (depth_0 != depth)
-      movie->tk[0].jp2_struct.bpc = 255;
-  }
-  
-  for (i = 0; i < image->numcomps; i++)
-    movie->tk[0].jp2_struct.comps[i].bpcc =
-    image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
-  
-  if ((image->numcomps == 1 || image->numcomps == 3)
-    && (movie->tk[0].jp2_struct.bpc != 255))
-    movie->tk[0].jp2_struct.meth = 1;
-  else
-    movie->tk[0].jp2_struct.meth = 2;
-	
-    if (image->numcomps == 1)
-     movie->tk[0].jp2_struct.enumcs = 17;  // Grayscale
-  
-    else   
-	if ((image->comps[0].dx == 1) 
-	&& (image->comps[1].dx == 1) 
-	&& (image->comps[2].dx == 1) 
-    && (image->comps[0].dy == 1) 
-	&& (image->comps[1].dy == 1) 
-	&& (image->comps[2].dy == 1)) 
-     movie->tk[0].jp2_struct.enumcs = 16;    // RGB
-  
-    else   
-	if ((image->comps[0].dx == 1) 
-	&& (image->comps[1].dx == 2) 
-	&& (image->comps[2].dx == 2) 
-    && (image->comps[0].dy == 1) 
-	&& (image->comps[1].dy == 2) 
-	&& (image->comps[2].dy == 2)) 
-     movie->tk[0].jp2_struct.enumcs = 18;  // YUV
-  
-  else
-    movie->tk[0].jp2_struct.enumcs = 0;	// Unkown profile */
-}
-
-int main(int argc, char *argv[]) {
-	opj_cinfo_t* cinfo; 
-	opj_event_mgr_t event_mgr;		/* event manager */  
-  unsigned int snum;
-  opj_mj2_t *movie;
-  mj2_sample_t *sample;
-  unsigned char* frame_codestream;
-  FILE *mj2file, *j2kfile;
-  char j2kfilename[50];
-  unsigned char *buf;
-  int offset, mdat_initpos;
-  opj_image_t img;
- 	opj_cio_t *cio;
-	mj2_cparameters_t parameters;
-	
-  if (argc != 3) {
-    printf("Usage: %s source_location mj2_filename\n",argv[0]);
-    printf("Example: %s input/input output.mj2\n",argv[0]);
-    return 1;
-  }
-  
-  mj2file = fopen(argv[2], "wb");
-  
-  if (!mj2file) {
-    fprintf(stderr, "failed to open %s for writing\n", argv[2]);
-    return 1;
-  }
-
-	/*
-	configure the event callbacks (not required)
-	setting of each callback is optionnal
-	*/
-	memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-	event_mgr.error_handler = error_callback;
-	event_mgr.warning_handler = warning_callback;
-	event_mgr.info_handler = info_callback;
-
-	/* get a MJ2 decompressor handle */
-	cinfo = mj2_create_compress();
-
-	/* catch events using our callbacks and give a local context */
-	opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);	
-	
-	/* setup the decoder encoding parameters using user parameters */
-	movie = (opj_mj2_t*) cinfo->mj2_handle;
-	mj2_setup_encoder((opj_mj2_t*)cinfo->mj2_handle, &parameters);
-
-  
-	/* Writing JP, FTYP and MDAT boxes 
-	Assuming that the JP and FTYP boxes won't be longer than 300 bytes */
-	
-  buf = (unsigned char*) malloc (300 * sizeof(unsigned char)); 
-  cio = opj_cio_open(movie->cinfo, buf, 300);
-  mj2_write_jp(cio);
-  mj2_write_ftyp(movie, cio);
-  mdat_initpos = cio_tell(cio);
-  cio_skip(cio, 4);
-  cio_write(cio,MJ2_MDAT, 4);	
-  fwrite(buf,cio_tell(cio),1,mj2file);
-  free(buf);
-	
-  // Insert each j2k codestream in a JP2C box  
-  snum=0;
-  offset = 0;  
-  while(1)
-  {
-    sample = &movie->tk[0].sample[snum];
-    sprintf(j2kfilename,"%s_%05d.j2k",argv[1],snum);
-    j2kfile = fopen(j2kfilename, "rb");
-    if (!j2kfile) {
-      if (snum==0) {  // Could not open a single codestream
-				fprintf(stderr, "failed to open %s for reading\n",j2kfilename);
-				return 1;
-      }
-      else {	      // Tried to open a inexistant codestream
-				fprintf(stdout,"%d frames are being added to the MJ2 file\n",snum);
-				break;
-      }
-    }
-
-    // Calculating offset for samples and chunks
-    offset += cio_tell(cio);     
-    sample->offset = offset;
-    movie->tk[0].chunk[snum].offset = offset;  // There will be one sample per chunk
-    
-    // Calculating sample size
-    fseek(j2kfile,0,SEEK_END);	
-    sample->sample_size = ftell(j2kfile) + 8; // Sample size is codestream + JP2C box header
-    fseek(j2kfile,0,SEEK_SET);
-    
-    // Reading siz marker of j2k image for the first codestream
-    if (snum==0)	      
-      read_siz_marker(j2kfile, &img);
-    
-    // Writing JP2C box header			    
-    frame_codestream = (unsigned char*) malloc (sample->sample_size+8); 
-		cio = opj_cio_open(movie->cinfo, frame_codestream, sample->sample_size);    
-    cio_write(cio,sample->sample_size, 4);  // Sample size
-    cio_write(cio,JP2_JP2C, 4);	// JP2C
-    
-    // Writing codestream from J2K file to MJ2 file
-    fread(frame_codestream+8,sample->sample_size-8,1,j2kfile);
-    fwrite(frame_codestream,sample->sample_size,1,mj2file);
-    cio_skip(cio, sample->sample_size-8);
-    
-    // Ending loop
-    fclose(j2kfile);
-    snum++;
-    movie->tk[0].sample = (mj2_sample_t*)
-		realloc(movie->tk[0].sample, (snum+1) * sizeof(mj2_sample_t));
-    movie->tk[0].chunk = (mj2_chunk_t*)
-		realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
-    free(frame_codestream);
-  }
-  
-  // Writing the MDAT box length in header
-  offset += cio_tell(cio);
-  buf = (unsigned char*) malloc (4 * sizeof(unsigned char));
-	cio = opj_cio_open(movie->cinfo, buf, 4);
-  cio_write(cio,offset-mdat_initpos,4); 
-  fseek(mj2file,(long)mdat_initpos,SEEK_SET);
-  fwrite(buf,4,1,mj2file);
-  fseek(mj2file,0,SEEK_END);
-  free(buf);
-	
-  // Setting movie parameters
-  movie->tk[0].num_samples=snum;
-  movie->tk[0].num_chunks=snum;
-  setparams(movie, &img);
-	
-  // Writing MOOV box 
-	buf = (unsigned char*) malloc ((TEMP_BUF+snum*20) * sizeof(unsigned char));
-	cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20));
-	mj2_write_moov(movie, cio);
-  fwrite(buf,cio_tell(cio),1,mj2file);
-	
-  // Ending program
-  fclose(mj2file);
-  free(img.comps);
-  opj_cio_close(cio);
-  mj2_destroy_compress(movie);
-	
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v1/openjpeg_mangle.h.in b/Utilities/gdcmopenjpeg-v1/openjpeg_mangle.h.in
deleted file mode 100644
index c3e4044..0000000
--- a/Utilities/gdcmopenjpeg-v1/openjpeg_mangle.h.in
+++ /dev/null
@@ -1,151 +0,0 @@
-/* This file was generated by CMake http://www.cmake.org */
-
-#ifndef @MANGLE_PREFIX at _mangle_h
-#define @MANGLE_PREFIX at _mangle_h
-
-/*
- * This header file mangles all symbols exported from the openjpeg library.
- * It is included in all files while building the openjpeg library.  Due to
- * namespace pollution, no openjpeg headers should be included in .h files in
- * GDCM.
- *
- * The following command was used to obtain the symbol list:
- *
- * nm lib at MANGLE_PREFIX@.a | grep " [RT] "
- */
-
-#define bio_create                         @MANGLE_PREFIX at _bio_create
-#define bio_destroy                        @MANGLE_PREFIX at _bio_destroy
-#define bio_flush                          @MANGLE_PREFIX at _bio_flush
-#define bio_inalign                        @MANGLE_PREFIX at _bio_inalign
-#define bio_init_dec                       @MANGLE_PREFIX at _bio_init_dec
-#define bio_init_enc                       @MANGLE_PREFIX at _bio_init_enc
-#define bio_numbytes                       @MANGLE_PREFIX at _bio_numbytes
-#define bio_read                           @MANGLE_PREFIX at _bio_read
-#define bio_write                          @MANGLE_PREFIX at _bio_write
-#define cio_bytein                         @MANGLE_PREFIX at _cio_bytein
-#define cio_byteout                        @MANGLE_PREFIX at _cio_byteout
-#define cio_getbp                          @MANGLE_PREFIX at _cio_getbp
-#define cio_numbytesleft                   @MANGLE_PREFIX at _cio_numbytesleft
-#define cio_read                           @MANGLE_PREFIX at _cio_read
-#define cio_seek                           @MANGLE_PREFIX at _cio_seek
-#define cio_skip                           @MANGLE_PREFIX at _cio_skip
-#define cio_tell                           @MANGLE_PREFIX at _cio_tell
-#define cio_write                          @MANGLE_PREFIX at _cio_write
-#define opj_cio_close                      @MANGLE_PREFIX at _opj_cio_close
-#define opj_cio_open                       @MANGLE_PREFIX at _opj_cio_open
-#define dwt_calc_explicit_stepsizes        @MANGLE_PREFIX at _dwt_calc_explicit_stepsizes
-#define dwt_decode                         @MANGLE_PREFIX at _dwt_decode
-#define dwt_decode_real                    @MANGLE_PREFIX at _dwt_decode_real
-#define dwt_encode                         @MANGLE_PREFIX at _dwt_encode
-#define dwt_encode_real                    @MANGLE_PREFIX at _dwt_encode_real
-#define dwt_getgain                        @MANGLE_PREFIX at _dwt_getgain
-#define dwt_getgain_real                   @MANGLE_PREFIX at _dwt_getgain_real
-#define dwt_getnorm                        @MANGLE_PREFIX at _dwt_getnorm
-#define dwt_getnorm_real                   @MANGLE_PREFIX at _dwt_getnorm_real
-#define opj_event_msg                      @MANGLE_PREFIX at _opj_event_msg
-#define opj_set_event_mgr                  @MANGLE_PREFIX at _opj_set_event_mgr
-#define opj_image_create                   @MANGLE_PREFIX at _opj_image_create
-#define opj_image_create0                  @MANGLE_PREFIX at _opj_image_create0
-#define opj_image_destroy                  @MANGLE_PREFIX at _opj_image_destroy
-#define j2k_create_compress                @MANGLE_PREFIX at _j2k_create_compress
-#define j2k_create_decompress              @MANGLE_PREFIX at _j2k_create_decompress
-#define j2k_decode                         @MANGLE_PREFIX at _j2k_decode
-#define j2k_decode_jpt_stream              @MANGLE_PREFIX at _j2k_decode_jpt_stream
-#define j2k_destroy_compress               @MANGLE_PREFIX at _j2k_destroy_compress
-#define j2k_destroy_decompress             @MANGLE_PREFIX at _j2k_destroy_decompress
-#define j2k_dump_cp                        @MANGLE_PREFIX at _j2k_dump_cp
-#define j2k_dump_image                     @MANGLE_PREFIX at _j2k_dump_image
-#define j2k_encode                         @MANGLE_PREFIX at _j2k_encode
-#define j2k_setup_decoder                  @MANGLE_PREFIX at _j2k_setup_decoder
-#define j2k_setup_encoder                  @MANGLE_PREFIX at _j2k_setup_encoder
-#define opj_clock                          @MANGLE_PREFIX at _opj_clock
-#define opj_free                           @MANGLE_PREFIX at _opj_free
-#define opj_malloc                         @MANGLE_PREFIX at _opj_malloc
-#define opj_realloc                        @MANGLE_PREFIX at _opj_realloc
-#define jp2_create_compress                @MANGLE_PREFIX at _jp2_create_compress
-#define jp2_create_decompress              @MANGLE_PREFIX at _jp2_create_decompress
-#define jp2_decode                         @MANGLE_PREFIX at _jp2_decode
-#define jp2_destroy_compress               @MANGLE_PREFIX at _jp2_destroy_compress
-#define jp2_destroy_decompress             @MANGLE_PREFIX at _jp2_destroy_decompress
-#define jp2_encode                         @MANGLE_PREFIX at _jp2_encode
-#define jp2_setup_decoder                  @MANGLE_PREFIX at _jp2_setup_decoder
-#define jp2_setup_encoder                  @MANGLE_PREFIX at _jp2_setup_encoder
-#define jpt_init_msg_header                @MANGLE_PREFIX at _jpt_init_msg_header
-#define jpt_read_msg_header                @MANGLE_PREFIX at _jpt_read_msg_header
-#define jpt_read_VBAS_info                 @MANGLE_PREFIX at _jpt_read_VBAS_info
-#define jpt_reinit_msg_header              @MANGLE_PREFIX at _jpt_reinit_msg_header
-#define mct_decode                         @MANGLE_PREFIX at _mct_decode
-#define mct_decode_real                    @MANGLE_PREFIX at _mct_decode_real
-#define mct_encode                         @MANGLE_PREFIX at _mct_encode
-#define mct_encode_real                    @MANGLE_PREFIX at _mct_encode_real
-#define mct_getnorm                        @MANGLE_PREFIX at _mct_getnorm
-#define mct_getnorm_real                   @MANGLE_PREFIX at _mct_getnorm_real
-#define mqc_bypass_enc                     @MANGLE_PREFIX at _mqc_bypass_enc
-#define mqc_bypass_flush_enc               @MANGLE_PREFIX at _mqc_bypass_flush_enc
-#define mqc_bypass_init_enc                @MANGLE_PREFIX at _mqc_bypass_init_enc
-#define mqc_create                         @MANGLE_PREFIX at _mqc_create
-#define mqc_decode                         @MANGLE_PREFIX at _mqc_decode
-#define mqc_destroy                        @MANGLE_PREFIX at _mqc_destroy
-#define mqc_encode                         @MANGLE_PREFIX at _mqc_encode
-#define mqc_erterm_enc                     @MANGLE_PREFIX at _mqc_erterm_enc
-#define mqc_flush                          @MANGLE_PREFIX at _mqc_flush
-#define mqc_init_dec                       @MANGLE_PREFIX at _mqc_init_dec
-#define mqc_init_enc                       @MANGLE_PREFIX at _mqc_init_enc
-#define mqc_numbytes                       @MANGLE_PREFIX at _mqc_numbytes
-#define mqc_reset_enc                      @MANGLE_PREFIX at _mqc_reset_enc
-#define mqc_resetstates                    @MANGLE_PREFIX at _mqc_resetstates
-#define mqc_restart_enc                    @MANGLE_PREFIX at _mqc_restart_enc
-#define mqc_restart_init_enc               @MANGLE_PREFIX at _mqc_restart_init_enc
-#define mqc_segmark_enc                    @MANGLE_PREFIX at _mqc_segmark_enc
-#define mqc_setcurctx                      @MANGLE_PREFIX at _mqc_setcurctx
-#define mqc_setstate                       @MANGLE_PREFIX at _mqc_setstate
-#define opj_create_compress                @MANGLE_PREFIX at _opj_create_compress
-#define opj_create_decompress              @MANGLE_PREFIX at _opj_create_decompress
-#define opj_decode                         @MANGLE_PREFIX at _opj_decode
-#define opj_destroy_compress               @MANGLE_PREFIX at _opj_destroy_compress
-#define opj_destroy_decompress             @MANGLE_PREFIX at _opj_destroy_decompress
-#define opj_encode                         @MANGLE_PREFIX at _opj_encode
-#define opj_set_default_decoder_parameters @MANGLE_PREFIX at _opj_set_default_decoder_parameters
-#define opj_set_default_encoder_parameters @MANGLE_PREFIX at _opj_set_default_encoder_parameters
-#define opj_setup_decoder                  @MANGLE_PREFIX at _opj_setup_decoder
-#define opj_setup_encoder                  @MANGLE_PREFIX at _opj_setup_encoder
-#define opj_version                        @MANGLE_PREFIX at _opj_version
-#define pi_create                          @MANGLE_PREFIX at _pi_create
-#define pi_destroy                         @MANGLE_PREFIX at _pi_destroy
-#define pi_next                            @MANGLE_PREFIX at _pi_next
-#define raw_create                         @MANGLE_PREFIX at _raw_create
-#define raw_decode                         @MANGLE_PREFIX at _raw_decode
-#define raw_destroy                        @MANGLE_PREFIX at _raw_destroy
-#define raw_init_dec                       @MANGLE_PREFIX at _raw_init_dec
-#define raw_numbytes                       @MANGLE_PREFIX at _raw_numbytes
-#define t1_create                          @MANGLE_PREFIX at _t1_create
-#define t1_decode_cblks                    @MANGLE_PREFIX at _t1_decode_cblks
-#define t1_destroy                         @MANGLE_PREFIX at _t1_destroy
-#define t1_encode_cblks                    @MANGLE_PREFIX at _t1_encode_cblks
-#define t2_create                          @MANGLE_PREFIX at _t2_create
-#define t2_decode_packets                  @MANGLE_PREFIX at _t2_decode_packets
-#define t2_destroy                         @MANGLE_PREFIX at _t2_destroy
-#define t2_encode_packets                  @MANGLE_PREFIX at _t2_encode_packets
-#define tcd_create                         @MANGLE_PREFIX at _tcd_create
-#define tcd_decode_tile                    @MANGLE_PREFIX at _tcd_decode_tile
-#define tcd_destroy                        @MANGLE_PREFIX at _tcd_destroy
-#define tcd_dump                           @MANGLE_PREFIX at _tcd_dump
-#define tcd_encode_tile                    @MANGLE_PREFIX at _tcd_encode_tile
-#define tcd_free_decode                    @MANGLE_PREFIX at _tcd_free_decode
-#define tcd_free_encode                    @MANGLE_PREFIX at _tcd_free_encode
-#define tcd_init_encode                    @MANGLE_PREFIX at _tcd_init_encode
-#define tcd_makelayer                      @MANGLE_PREFIX at _tcd_makelayer
-#define tcd_makelayer_fixed                @MANGLE_PREFIX at _tcd_makelayer_fixed
-#define tcd_malloc_decode                  @MANGLE_PREFIX at _tcd_malloc_decode
-#define tcd_malloc_encode                  @MANGLE_PREFIX at _tcd_malloc_encode
-#define tcd_rateallocate                   @MANGLE_PREFIX at _tcd_rateallocate
-#define tcd_rateallocate_fixed             @MANGLE_PREFIX at _tcd_rateallocate_fixed
-#define tgt_create                         @MANGLE_PREFIX at _tgt_create
-#define tgt_decode                         @MANGLE_PREFIX at _tgt_decode
-#define tgt_destroy                        @MANGLE_PREFIX at _tgt_destroy
-#define tgt_encode                         @MANGLE_PREFIX at _tgt_encode
-#define tgt_reset                          @MANGLE_PREFIX at _tgt_reset
-#define tgt_setvalue                       @MANGLE_PREFIX at _tgt_setvalue
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v1/opj_config.h.in b/Utilities/gdcmopenjpeg-v1/opj_config.h.in
deleted file mode 100644
index f4d5dfb..0000000
--- a/Utilities/gdcmopenjpeg-v1/opj_config.h.in
+++ /dev/null
@@ -1,104 +0,0 @@
-/* opj_config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define if building universal (internal helper macro) */
-#undef AC_APPLE_UNIVERSAL_BUILD
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
-#undef HAVE_FSEEKO
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `lcms' library (-llcms). */
-#undef HAVE_LIBLCMS
-
-/* define to 1 if you have lcms version 1.x */
-#undef HAVE_LIBLCMS1
-
-/* define to 1 if you have lcms version 2.x */
-#undef HAVE_LIBLCMS2
-
-/* define to 1 if you have libpng */
-#undef HAVE_LIBPNG
-
-/* define to 1 if you have libtiff */
-#undef HAVE_LIBTIFF
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
-   significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-#  define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-#  undef WORDS_BIGENDIAN
-# endif
-#endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
-/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
-#undef _LARGEFILE_SOURCE
-
-/* Define for large files, on AIX-style hosts. */
-#undef _LARGE_FILES
diff --git a/Utilities/gdcmopenjpeg-v1/opj_config.h.in.user b/Utilities/gdcmopenjpeg-v1/opj_config.h.in.user
deleted file mode 100644
index f86ccce..0000000
--- a/Utilities/gdcmopenjpeg-v1/opj_config.h.in.user
+++ /dev/null
@@ -1,41 +0,0 @@
-/* If you want to build the library manually without using
- * 'configure' or 'CMake'
- * then copy this file 
- * 'opj_config.h.in.user' 
- *       to
- * 'opj_config.h'
- * 
- * Open 'opj_config.h' and change the file contents
- * if you want to define something because you know you have 
- * BOTH installed the library AND the header file(s).
- * Then e.g. write
-#define HAVE_LIBPNG 1
- *  
- *
- * The file 'opj_config.h' will be included in some source files.
- * ==== YOU CAN NOT COMPILE WITHOUT IT. ====
- * === DO NOT FOREGET TO CHANGE 'config.nix' APPROPRIATELY. ====
-*/
-
-/* DO NOT DEFINE BOTH VERSIONS OF LCMS */
-/* define to 1 if you have both liblcms and lcms.h installed */
-#undef HAVE_LIBLCMS1
-/* #define HAVE_LIBLCMS1 1 */
-
-/* define to 1 if you have both liblcms2 and lcms2.h installed */
-#undef HAVE_LIBLCMS2
-/* #define HAVE_LIBLCMS2 1 */
-
-/* define to 1 if you have both libpng and png.h installed */
-#undef HAVE_LIBPNG
-/* #define HAVE_LIBPNG 1 */
-
-/* define to 1 if you have both libtiff and tiff.h installed */
-#undef HAVE_LIBTIFF
-/* #define HAVE_LIBTIFF 1 */
-
-/*---------------- DO NOT CHANGE BELOW THIS LINE ----------------*/
-#define PACKAGE_URL "http://www.openjpeg.org/"
-#define PACKAGE_BUGREPORT "http://code.google.com/p/openjpeg/"
-
-#define PACKAGE_VERSION "1.4.0"
diff --git a/Utilities/gdcmopenjpeg-v1/opj_configh.cmake.in b/Utilities/gdcmopenjpeg-v1/opj_configh.cmake.in
deleted file mode 100644
index 589d866..0000000
--- a/Utilities/gdcmopenjpeg-v1/opj_configh.cmake.in
+++ /dev/null
@@ -1,31 +0,0 @@
-/* create config.h for CMake */
-/*
- * here is where system comupted values get stored these values should only
- * change when the target compile platform changes
- */
-
-/* what byte order */
-#ifndef __OPJ_CONFIGURE_H
-#define __OPJ_CONFIGURE_H
-
-#cmakedefine CMAKE_WORDS_BIGENDIAN
-#ifdef CMAKE_WORDS_BIGENDIAN
-        #define OPJ_BIG_ENDIAN
-#else
-        #define OPJ_LITTLE_ENDIAN
-#endif
-
-#define PACKAGE_VERSION "@PACKAGE_VERSION@"
-
-#cmakedefine HAVE_INTTYPES_H
-#cmakedefine HAVE_MEMORY_H
-#cmakedefine HAVE_STDINT_H
-#cmakedefine HAVE_STDLIB_H
-#cmakedefine HAVE_STRINGS_H
-#cmakedefine HAVE_STRING_H
-#cmakedefine HAVE_SYS_STAT_H
-#cmakedefine HAVE_SYS_TYPES_H
-#cmakedefine HAVE_UNISTD_H
-
-
-#endif /* __OPJ_CONFIGURE_H */
diff --git a/Utilities/gdcmopenjpeg-v2/.NoDartCoverage b/Utilities/gdcmopenjpeg-v2/.NoDartCoverage
deleted file mode 100644
index 3c99729..0000000
--- a/Utilities/gdcmopenjpeg-v2/.NoDartCoverage
+++ /dev/null
@@ -1 +0,0 @@
-# do not do coverage in this directory
diff --git a/Utilities/gdcmopenjpeg-v2/CMake/CTestCustom.cmake.in b/Utilities/gdcmopenjpeg-v2/CMake/CTestCustom.cmake.in
deleted file mode 100644
index 6deac7e..0000000
--- a/Utilities/gdcmopenjpeg-v2/CMake/CTestCustom.cmake.in
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# For further details regarding this file,
-# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
-#
-
-set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS   50)
-set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 50)
-
-set(CTEST_CUSTOM_COVERAGE_EXCLUDE
- ${CTEST_CUSTOM_COVERAGE_EXCLUDE}
-
- # Exclude files from the Testing directories
- ".*/Testing/.*"
- )
-
-set(CTEST_CUSTOM_WARNING_EXCEPTION
-  ${CTEST_CUSTOM_WARNING_EXCEPTION}
-
-  # Suppress warning caused by intentional messages about deprecation
-  ".*warning,.* is deprecated"
-)
diff --git a/Utilities/gdcmopenjpeg-v2/CMake/FindFreeImage.cmake b/Utilities/gdcmopenjpeg-v2/CMake/FindFreeImage.cmake
deleted file mode 100644
index 3c8bcb4..0000000
--- a/Utilities/gdcmopenjpeg-v2/CMake/FindFreeImage.cmake
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Try to find the FreeImage library and include path.
-# Once done this will define
-#
-# FREEIMAGE_FOUND
-# FREEIMAGE_INCLUDE_PATH
-# FREEIMAGE_LIBRARY
-#
-
-if (WIN32)
-	find_path( FREEIMAGE_INCLUDE_PATH FreeImage.h
-		${OPENJPEG_SOURCE_DIR}/libs/FreeImage
-		DOC "The directory where FreeImage.h resides")
-	find_library( FREEIMAGE_LIBRARY
-		NAMES FreeImage freeimage freeimage.s
-		PATHS
-		${OPENJPEG_SOURCE_DIR}/libs/FreeImage
-		DOC "The FreeImage library")
-else ()
-	find_path( FREEIMAGE_INCLUDE_PATH FreeImage.h
-		/usr/include
-		/usr/local/include
-		/sw/include
-		/opt/local/include
-		DOC "The directory where FreeImage.h resides")
-	find_library( FREEIMAGE_LIBRARY
-		NAMES FreeImage freeimage
-		PATHS
-		/usr/lib64
-		/usr/lib
-		/usr/local/lib64
-		/usr/local/lib
-		/sw/lib
-		/opt/local/lib
-		DOC "The FreeImage library")
-endif ()
-
-set(FREEIMAGE_LIBRARIES ${FREEIMAGE_LIBRARY})
-
-if (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
-	set( FREEIMAGE_FOUND TRUE CACHE BOOL "Set to TRUE if GLEW is found, FALSE otherwise")
-else ()
-	set( FREEIMAGE_FOUND FALSE CACHE BOOL "Set to TRUE if GLEW is found, FALSE otherwise")
-endif ()
-
-mark_as_advanced(
-	FREEIMAGE_FOUND
-	FREEIMAGE_LIBRARY
-	FREEIMAGE_LIBRARIES
-	FREEIMAGE_INCLUDE_PATH)
diff --git a/Utilities/gdcmopenjpeg-v2/CMake/Free_CMakeImport.cmake b/Utilities/gdcmopenjpeg-v2/CMake/Free_CMakeImport.cmake
deleted file mode 100644
index 37f1ee6..0000000
--- a/Utilities/gdcmopenjpeg-v2/CMake/Free_CMakeImport.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-set(CMAKE_MODULE_PATH "${OPENJPEG_SOURCE_DIR}/CMake")
-find_package(FreeImage REQUIRED)
-add_definitions ( -DFREEIMAGE_LIB )
diff --git a/Utilities/gdcmopenjpeg-v2/CMake/OpenJPEGConfig.cmake.in b/Utilities/gdcmopenjpeg-v2/CMake/OpenJPEGConfig.cmake.in
deleted file mode 100644
index ce4a7c8..0000000
--- a/Utilities/gdcmopenjpeg-v2/CMake/OpenJPEGConfig.cmake.in
+++ /dev/null
@@ -1,48 +0,0 @@
-#-----------------------------------------------------------------------------
-#
-# OPENJPEGConfig.cmake - CMake configuration file for external projects.
-#
-# This file is configured by OPENJPEG and used by the UseOPENJPEG.cmake
-# module to load OPENJPEG's settings for an external project.
- at OPENJPEG_CONFIG_INSTALL_ONLY@
-# The OPENJPEG version number.
-set(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
-set(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
-set(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
-
-# The libraries.
-set(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
-
-# The CMake macros dir.
-set(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
-
-# The configuration options.
-set(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
-
-# The "use" file.
-set(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
-
-get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
-  # This is an install tree
-  include(${SELF_DIR}/OpenJPEGTargets.cmake)
-  get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
-  set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
-  set(OPENJPEG_LIBRARIES openjpeg)
-
-else()
-  if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
-    # This is a build tree
-    set( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
-
-    include(${SELF_DIR}/OpenJPEGExports.cmake)
-
-  else()
-    message(FATAL_ERROR "ooops")
-  endif()
-endif()
-
-set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
-
-# Backward compatible part:
-set(OPENJPEG_FOUND       TRUE)
diff --git a/Utilities/gdcmopenjpeg-v2/CMake/mymachine_openjpeg.cmake b/Utilities/gdcmopenjpeg-v2/CMake/mymachine_openjpeg.cmake
deleted file mode 100644
index 2a50d6f..0000000
--- a/Utilities/gdcmopenjpeg-v2/CMake/mymachine_openjpeg.cmake
+++ /dev/null
@@ -1,50 +0,0 @@
-cmake_minimum_required(VERSION 2.8.7)
-# simply copy this file anywhere on your system and execute like this:
-# ctest -S mymachine_openjpeg.cmake -V
-# This will retrieve/compile/run tests/upload to cdash OpenJPEG
-# results will be available at: http://my.cdash.org/index.php?project=OPENJPEG
-
-# Begin User inputs:
-set( CTEST_SITE             "mymachine" ) # generally the output of hostname
-set( CTEST_DASHBOARD_ROOT   "/tmp" ) # writable path
-set( CTEST_CMAKE_GENERATOR  "Unix Makefiles" ) # What is your compilation apps ?
-set( CTEST_BUILD_CONFIGURATION  Debug) # What type of build do you want ?
-set( ENV{CFLAGS} "-Wall" ) # just for fun...
-
-# For testing we need to define the path to J2KP4files
-#  wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
-#  unzip j2kp4files_v1_5.zip
-set( CACHE_CONTENTS "
-BUILD_TESTING:BOOL=TRUE
-JPEG2000_CONFORMANCE_DATA_ROOT:PATH=${CTEST_SOURCE_DIRECTORY}/J2KP4files" )
-# End User inputs:
-
-# You do not need to change anything after that:
-# 1. openjpeg specific:
-set( CTEST_PROJECT_NAME         "OPENJPEG" )
-set( CTEST_SOURCE_NAME          OpenJPEG)
-set( CTEST_BUILD_NAME           "${CMAKE_SYSTEM}-${CTEST_CMAKE_GENERATOR}-${CTEST_BUILD_CONFIGURATION}")
-set( CTEST_BINARY_NAME          "${CTEST_SOURCE_NAME}-${CTEST_BUILD_NAME}")
-
-# 2. cdash/openjpeg specific:
-# svn checkout http://openjpeg.googlecode.com/svn/trunk/ openjpeg-read-only
-set( CTEST_SVN_URL          "http://openjpeg.googlecode.com/svn/")
-set( CTEST_UPDATE_COMMAND   "svn")
-#set( CTEST_CHECKOUT_COMMAND "${CTEST_UPDATE_COMMAND} co ${CTEST_SVN_URL}/trunk ${CTEST_SOURCE_NAME}")
-set( CTEST_CHECKOUT_COMMAND "${CTEST_UPDATE_COMMAND} co ${CTEST_SVN_URL}/branches/v2 ${CTEST_SOURCE_NAME}")
-
-# 3. cmake specific:
-set( CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}")
-set( CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}")
-set( CTEST_NOTES_FILES      "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
-
-ctest_empty_binary_directory( "${CTEST_BINARY_DIRECTORY}" )
-file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${CACHE_CONTENTS}")
-
-# Perform the Nightly build
-ctest_start(Nightly)
-ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}")
-ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}")
-ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}")
-ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}")
-ctest_submit()
diff --git a/Utilities/gdcmopenjpeg-v2/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/CMakeLists.txt
deleted file mode 100644
index 6c6a329..0000000
--- a/Utilities/gdcmopenjpeg-v2/CMakeLists.txt
+++ /dev/null
@@ -1,195 +0,0 @@
-# Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
-# Written by Mathieu Malaterre
-
-# This CMake project will by default create a library called openjpeg
-# But if you want to use this project within your own (CMake) project
-# you will eventually like to prefix the library to avoid linking confusion
-# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
-# e.g.:
-# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
-cmake_minimum_required(VERSION 2.8.7)
-
-if(NOT OPENJPEG_NAMESPACE)
-  set(OPENJPEG_NAMESPACE "OPENJPEG")
-  set(OPENJPEG_STANDALONE 1)
-endif()
-# In all cases:
-string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
-
-project(${OPENJPEG_NAMESPACE} C)
-
-# Do full dependency headers.
-include_regular_expression("^.*$")
-
-#-----------------------------------------------------------------------------
-# OPENJPEG version number, useful for packaging and doxygen doc:
-set(OPENJPEG_VERSION_MAJOR 2)
-set(OPENJPEG_VERSION_MINOR 0)
-set(OPENJPEG_VERSION_BUILD 0)
-set(OPENJPEG_VERSION
-  "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
-
-# This setting of SOVERSION assumes that any API change
-# will increment either the minor or major version number of openjpeg
-set(OPENJPEG_LIBRARY_PROPERTIES
-  VERSION   "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
-  SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
-)
-# You will also need to define a value for the following variables:
-# OPENJPEG_INSTALL_BIN_DIR          - binary dir (executables)
-# OPENJPEG_INSTALL_LIB_DIR          - library dir (libs)
-# OPENJPEG_INSTALL_DATA_DIR         - share dir (say, examples, data, etc)
-# OPENJPEG_INSTALL_INCLUDE_DIR      - include dir (headers)
-
-# --------------------------------------------------------------------------
-# Install directories
-
-string(TOLOWER ${PROJECT_NAME} projectname)
-set(subdir "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
-
-if(NOT OPENJPEG_INSTALL_BIN_DIR)
-  set(OPENJPEG_INSTALL_BIN_DIR "bin")
-endif()
-
-if(NOT OPENJPEG_INSTALL_LIB_DIR)
-  set(OPENJPEG_INSTALL_LIB_DIR "lib")
-endif()
-
-if(NOT OPENJPEG_INSTALL_DATA_DIR)
-  set(OPENJPEG_INSTALL_DATA_DIR "share/${subdir}")
-endif()
-
-if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
-  set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${subdir}")
-endif()
-
-if(NOT OPENJPEG_INSTALL_DOC_DIR)
-  set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${subdir}")
-endif()
-
-if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
-  set(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${subdir}
-    CACHE INTERNAL "")
-endif()
-
-#-----------------------------------------------------------------------------
-# Test for some required system information.
-include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
-
-#-----------------------------------------------------------------------------
-# Setup file for setting custom ctest vars
-configure_file(
-  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CTestCustom.cmake.in
-  ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
-  @ONLY
-  )
-
-#-----------------------------------------------------------------------------
-# OpenJPEG build configuration options.
-#option(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
-#option(ENABLE_PROFILING "Enable profiling for the library" OFF)
-
-#-----------------------------------------------------------------------------
-#set (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
-#set (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
-#mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
-
-
-#-----------------------------------------------------------------------------
-# For the codec...
-#option(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
-
-
-# configure name mangling to allow multiple libraries to coexist
-# peacefully
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
-set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
-               ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
-               @ONLY)
-endif()
-
-#-----------------------------------------------------------------------------
-# Configure files with settings for use by the build.
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/opj_configure.h.in
-               ${CMAKE_CURRENT_BINARY_DIR}/opj_configure.h)
-
-if(NOT OPENJPEG_INSTALL_NO_DEVELOPMENT)
-  install(FILES
-      ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
-      ${CMAKE_CURRENT_BINARY_DIR}/opj_configure.h
-    DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
-  )
-endif()
-
-
-#-----------------------------------------------------------------------------
-# Always build the library
-include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-subdirs(
-  libopenjpeg
-  )
-#-----------------------------------------------------------------------------
-# Build example only if requested
-if(BUILD_EXAMPLES)
-  # subdirs(codec)
-endif()
-
-#-----------------------------------------------------------------------------
-# For the documentation
-option(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
-mark_as_advanced(BUILD_DOCUMENTATION)
-if(BUILD_DOCUMENTATION)
-  subdirs(doc)
-endif()
-
-#-----------------------------------------------------------------------------
-# For openjpeg team if they ever want CDash+CMake
-option(BUILD_TESTING "Build the tests." OFF)
-if(BUILD_TESTING)
-  enable_testing()
-  include(CTest)
-endif()
-
-#if(BUILD_TESTING)
-#set(CMAKE_MODULE_PATH "${OPENJPEG_SOURCE_DIR}/CMake")
-#find_package(FreeImage REQUIRED)
-#include_directories( ${FREEIMAGE_INCLUDE_PATH} )
-#
-#  subdirs(
-#    test_V2_tile_handling
-#    test_Free_image_V2_tile_handling
-#  )
-#endif()
-
-# Adding test with dataset from:
-# http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
-# -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
-# http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
-#-----------------------------------------------------------------------------
-# Adding JPEG2000_CONFORMANCE_DATA_ROOT
-find_path(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
-  ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
-  $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
-)
-mark_as_advanced(JPEG2000_CONFORMANCE_DATA_ROOT)
-
-#-----------------------------------------------------------------------------
-# Compiler specific flags:
-#if(CMAKE_COMPILER_IS_GNUCC)
-#  # For all builds, make sure openjpeg is std99 compliant:
-#  # set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
-#  # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
-#  set(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
-#endif()
-
-# install all targets referenced as OPENJPEGTargets
-install(EXPORT ${GDCM_TARGETS_NAME} DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
-configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
-  ${CMAKE_CURRENT_BINARY_DIR}/OpenJPEGConfig.cmake
-  @ONLY
-)
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenJPEGConfig.cmake
-  DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
-)
-
diff --git a/Utilities/gdcmopenjpeg-v2/CTestConfig.cmake b/Utilities/gdcmopenjpeg-v2/CTestConfig.cmake
deleted file mode 100644
index 6d3866e..0000000
--- a/Utilities/gdcmopenjpeg-v2/CTestConfig.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-set(CTEST_PROJECT_NAME "OPENJPEG")
-set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC")
-
-set(CTEST_DROP_METHOD "http")
-set(CTEST_DROP_SITE "my.cdash.org")
-set(CTEST_DROP_LOCATION "/submit.php?project=OPENJPEG")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Utilities/gdcmopenjpeg-v2/README.cmake b/Utilities/gdcmopenjpeg-v2/README.cmake
deleted file mode 100644
index 94f6e90..0000000
--- a/Utilities/gdcmopenjpeg-v2/README.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-Basic instructions on how to build using CMake (CMake 2.4.5 or newer is required)
-
-  svn co http://www.openjpeg.org/svn/trunk
-  cd trunk
-  mkdir bin
-  cd bin
-  cmake .. -DBUILD_EXAMPLES:BOOL=ON
-  make
-  ./bin/j2k_to_image
diff --git a/Utilities/gdcmopenjpeg-v2/README.linux b/Utilities/gdcmopenjpeg-v2/README.linux
deleted file mode 100644
index 8dc8415..0000000
--- a/Utilities/gdcmopenjpeg-v2/README.linux
+++ /dev/null
@@ -1,33 +0,0 @@
-Release Notes
---------------
-This version of the library has been tested under the following OS:
-- RedHat Linux 9.0
-
-You should be able to link progams with the -lopenjpeg option after the library is compiled and installed.
-You can also statically link with libopenjpeg.a.
-If you use a really old version of gcc and it chokes on the CRs in the file, you can type 'make dos2unix'
-to run all of the files through dos2unix which converts CRLF to LF.  This no longer appears to be required
-for RedHat 7.3 or 9.
-
-Please let us know how this works for you under other Linux distributions or any other *nix.
-
-Installation
-------------
-Note: You will need to have root privileges in order to install the library in
-/usr/include and /usr/lib directories.
-The installation process is as simple as this :
-1) Enter the OpenJPEG directory
-2) Build the distribution :
-make
-make install
-3) Clean all files produced during the build process
-make clean
-
-Simple codec compilation
-------------------------
-Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and use one of the following commands to build an encoder and decoder respectively:
-
-gcc convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-gcc convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-
-You should add '-L..' to those lines if you did not use the 'install' target (and the 'clean' target neither...).
diff --git a/Utilities/gdcmopenjpeg-v2/README.msvc b/Utilities/gdcmopenjpeg-v2/README.msvc
deleted file mode 100644
index 7c33121..0000000
--- a/Utilities/gdcmopenjpeg-v2/README.msvc
+++ /dev/null
@@ -1,36 +0,0 @@
-How to compile the library under MS VC++ 6.0
---------------------------------------------
-
-The library comes in two versions :
-- a static library that can be linked against any C/C++ program
-- a Dynamic Link Library (Windows DLL) that can be used in any C/C++ program and in most interpreted languages (e.g. VB, C#, ...).
-
-In order to compile the library version *or* the DLL version, you will have to :
-
-1) Open the MSVC workspace named LibOpenJPEG.dsw
-2) Set the choosen target as the active project, that means :
- a) Go to the Menu 'Build -> Set Active Configuration'
- b) Choose one of the following configuration :
- - DllOpenJPEG - Win32 Release => creates a DLL in release mode named OpenJPEG.dll
- - DllOpenJPEG - Win32 Debug => creates a DLL in debug mode named OpenJPEGd.dll
- - LibOpenJPEG - Win32 Release => creates a static library in release mode named LibOpenJPEG.lib
- - LibOpenJPEG - Win32 Debug => creates a static library in debug mode named LibOpenJPEGd.lib
-3) Build the project : Menu -> Build -> Rebuild All
-
-The build process will create a directory named 'dist' that will contain all you need in order to use the library.
-
-Simple codec compilation
-------------------------
-
-Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and use one of the following projects to build an encoder and decoder respectively:
-- image_to_j2k.dsw
-- j2k_to_image.dsw
-
-IMPORTANT NOTE :
-----------------
-
-The encoder and decoder samples are configured to use the static version of the library. A link to the LibOpenJPEG static project is included in these projects so that you can build both a codec and the library in a single pass.
-
-However, you MUST NOTE that in order to use LibOpenJPEG as a static library in your program, you NEED to add the following compiler directive to your project : OPJ_STATIC
-Look at the menu 'Project -> Settings -> C/C++ tab -> preprocessor definition' to see how this is configured.
-When using OpenJPEG as a DLL, this compiler directive MUST NOT be used.
diff --git a/Utilities/gdcmopenjpeg-v2/README.osx b/Utilities/gdcmopenjpeg-v2/README.osx
deleted file mode 100644
index d4eebc2..0000000
--- a/Utilities/gdcmopenjpeg-v2/README.osx
+++ /dev/null
@@ -1,26 +0,0 @@
-Release Notes
---------------
-This version of the library has been tested under OSX 10.3 using gcc 3.3.
-
-While the makefiles will make a .dylib and a .a, it is recommended to simply staticly link with the .a file.
-
-Installation
-------------
-Note: You will need to have root privileges in order to install the library in
-/usr/include and /usr/lib directories.
-The installation process is as simple as this :
-1) Enter the OpenJPEG directory
-2) Build the distribution :
-make osx
-make osxinstall
-3) Clean all files produced during the build process
-make osxclean
-
-Simple codec compilation
-------------------------
-Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively:
-
-gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-
-You should add '-L..' to those lines if you did not use the 'install' target (and the 'clean' target neither...).
diff --git a/Utilities/gdcmopenjpeg-v2/README.v2 b/Utilities/gdcmopenjpeg-v2/README.v2
deleted file mode 100644
index 5ec6246..0000000
--- a/Utilities/gdcmopenjpeg-v2/README.v2
+++ /dev/null
@@ -1,25 +0,0 @@
-Preliminary notes
------------------
-
-The Version 2 of openjpeg has been currently added as a branch on the repository.
-
-All the trunk has been copied and files that needed to change have been patched. In comparison with the trunk, the 'jp3d' directory has been removed because it's based on a modified version of libopenjpeg version 1 and there is no plan to make it reach the version 2 status. Idem with the 'indexer_JPIP', which is obsolete and should be rewritten from scratch.
-
-At the time of the branch creation, the following files and directories have been updated (or added) for version 2 :
-* libopenjpeg/
-* codec/
-* test_Free_image_V2_tile_handling/ : a test program that uses libopenjpeg v2 and libfreeimage (see libs) to implement a basic codec.
-* test_V2_tile_handling/ : a test program that generates a random image and (de)compresses it with libopenjpeg v2.
-* CMakeLists.txt
-* Free_CMakeImport.cmake
-* opj_configure.h.in
-
-Other files and directories from the trunk (project files, jpwl/, OPJViewer/, ...) have also been copied in the branch and should be modified progressively to comply with v2. Check the Changelog for updates on this topic.
-
-Enjoy v2 and feel free to contribute !
-
-
-Instructions to compile v2
---------------------------
-
-to be added.
diff --git a/Utilities/gdcmopenjpeg-v2/codec/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/codec/CMakeLists.txt
deleted file mode 100644
index 8a9b83c..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/CMakeLists.txt
+++ /dev/null
@@ -1,94 +0,0 @@
-# Build the demo app, small examples
-
-# First thing define the common source:
-set(common_SRCS
-  convert.c
-  index.c
-)
-
-# Then check if getopt is present:
-include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-set(DONT_HAVE_GETOPT 1)
-if(UNIX) #I am pretty sure only *nix sys have this anyway
-  CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
-  # Seems like we need the contrary:
-  if(CMAKE_HAVE_GETOPT_H)
-    set(DONT_HAVE_GETOPT 0)
-  endif()
-endif()
-
-# If not getopt was found then add it to the lib:
-if(DONT_HAVE_GETOPT)
-  add_definitions(-DDONT_HAVE_GETOPT)
-  set(common_SRCS
-    ${common_SRCS}
-    compat/getopt.c
-  )
-endif()
-
-# Headers file are located here:
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  )
-
-# Do the proper thing when building static...if only there was configured
-# headers or def files instead
-if(NOT BUILD_SHARED_LIBS)
-  add_definitions(-DOPJ_STATIC)
-endif()
-
-find_package(TIFF REQUIRED)
-find_package(PNG REQUIRED)
-include_directories( ${PNG_INCLUDE_DIR} )
-include_directories( ${TIFF_INCLUDE_DIR} )
-
-# Loop over all executables:
-foreach(exe j2k_to_image image_to_j2k j2k_dump)
-  add_executable(${exe} ${exe}.c ${common_SRCS})
-  target_link_libraries(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES} ${PNG_LIBRARIES})
-  add_test(NAME ${exe} COMMAND ${exe})
-  # calling those exe without option will make them fail always:
-  set_tests_properties(${exe} PROPERTIES WILL_FAIL TRUE)
-  # On unix you need to link to the math library:
-  if(UNIX)
-    target_link_libraries(${exe} m)
-  endif()
-  # Install exe
-  install(TARGETS ${exe}
-    EXPORT ${GDCM_TARGETS_NAME}
-    DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
-  )
-endforeach()
-
-if(BUILD_TESTING)
-# Do testing here, once we know the examples are being built:
-file(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
-  "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
-  "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
-  "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
-  )
-
-foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
-  get_filename_component(filename_temp ${filename} NAME)
-  get_filename_component(filename_ext ${filename} EXT)
-  execute_process(COMMAND j2k_dump -i ${filename}
-    OUTPUT_VARIABLE dump_success
-    OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump
-    ERROR_QUIET
-  )
-  if(dump_success)
-  file(READ ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump numcomp_file)
-  string(REGEX REPLACE ".*numcomps=([0-9]+).*" "\\1"
-    numcomps "${numcomp_file}")
-  #message( "found:${output_variable} for ${filename_temp}" )
-  endif()
-  add_test(NAME dump-${filename_temp} COMMAND j2k_dump -i ${filename})
-  foreach(codec_type ppm pgx bmp tif raw tga png)
-    add_test(NAME j2i-${filename_temp}-${codec_type} COMMAND j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
-    add_test(NAME i2j-${filename_temp}-${codec_type} COMMAND image_to_j2k -i ${filename_temp}.${codec_type} -o ${filename_temp}.${codec_type}${filename_ext})
-    #if(UNIX)
-    #  add_test(cmp-${filename_temp}-${codec_type} cmp ${filename} ${filename_temp}.${codec_type}${filename_ext})
-    #endif()
-  endforeach()
-endforeach()
-endif()
diff --git a/Utilities/gdcmopenjpeg-v2/codec/Makefile b/Utilities/gdcmopenjpeg-v2/codec/Makefile
deleted file mode 100644
index 14487a5..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# Makefile for the main OpenJPEG codecs: j2k_to_image and image_to_j2k
-
-CFLAGS = -O3 -lstdc++ # -g -p -pg
-
-all: j2k_to_image image_to_j2k
-
-j2k_to_image: j2k_to_image.c ../libopenjpeg.a
-	gcc $(CFLAGS) compat/getopt.c index.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-
-image_to_j2k: image_to_j2k.c ../libopenjpeg.a
-	gcc $(CFLAGS) compat/getopt.c index.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
-
-clean:
-	rm -f j2k_to_image image_to_j2k
diff --git a/Utilities/gdcmopenjpeg-v2/codec/compat/getopt.c b/Utilities/gdcmopenjpeg-v2/codec/compat/getopt.c
deleted file mode 100644
index aa98905..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/compat/getopt.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 1987, 1993, 1994
- *  The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *  This product includes software developed by the University of
- *  California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* last review : october 29th, 2002 */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getopt.c  8.3 (Berkeley) 4/27/95";
-#endif        /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int opterr = 1,      /* if error message should be printed */
- optind = 1,      /* index into parent argv vector */
- optopt,      /* character checked for validity */
- optreset;      /* reset getopt */
-const char *optarg;      /* argument associated with option */
-
-typedef struct option
-{
-  const char *name;
-  int has_arg;
-  int *flag;
-  int val;
-}option_t;
-
-#define  BADCH  (int)'?'
-#define  BADARG  (int)':'
-#define  EMSG  ""
-
-
-
-/*
- * getopt --
- *  Parse argc/argv argument vector.
- */
-int getopt(int nargc, char *const *nargv, const char *ostr) {
-#  define __progname nargv[0]
-  static const char *place = EMSG;  /* option letter processing */
-  char *oli;      /* option letter list index */
-
-  if (optreset || !*place) {  /* update scanning pointer */
-    optreset = 0;
-    if (optind >= nargc || *(place = nargv[optind]) != '-') {
-      place = EMSG;
-      return (-1);
-    }
-    if (place[1] && *++place == '-') {  /* found "--" */
-      ++optind;
-      place = EMSG;
-      return (-1);
-    }
-  }        /* option letter okay? */
-  if ((optopt = (int) *place++) == (int) ':' ||
-      !(oli = strchr(ostr, optopt))) {
-    /*
-     * if the user didn't specify '-' as an option,
-     * assume it means -1.
-     */
-    if (optopt == (int) '-')
-      return (-1);
-    if (!*place)
-      ++optind;
-    if (opterr && *ostr != ':') {
-      fprintf(stderr,
-         "%s: illegal option -- %c\n", __progname, optopt);
-      return (BADCH);
-    }
-  }
-  if (*++oli != ':') {    /* don't need argument */
-    optarg = NULL;
-    if (!*place)
-      ++optind;
-  } else {      /* need an argument */
-    if (*place)      /* no white space */
-      optarg = place;
-    else if (nargc <= ++optind) {  /* no arg */
-      place = EMSG;
-      if (*ostr == ':')
-  return (BADARG);
-      if (opterr) {
-        fprintf(stderr,
-           "%s: option requires an argument -- %c\n",
-           __progname, optopt);
-        return (BADCH);
-      }
-    } else      /* white space */
-      optarg = nargv[optind];
-    place = EMSG;
-    ++optind;
-  }
-  return (optopt);    /* dump back option letter */
-}
-
-
-int getopt_long(int argc, char * const argv[], const char *optstring,
-struct option *longopts, int totlen) {
-  static int lastidx,lastofs;
-  char *tmp;
-  int i,len;
-  char param = 1;
-
-again:
-  if (optind>argc || !argv[optind] || *argv[optind]!='-')
-    return -1;
-
-  if (argv[optind][0]=='-' && argv[optind][1]==0) {
-    if(optind >= (argc - 1)){ /* no more input parameters */
-      param = 0;
-    }
-    else{ /* more input parameters */
-      if(argv[optind + 1][0] == '-'){
-        param = 0; /* Missing parameter after '-' */
-      }
-      else{
-        param = 2;
-      }
-    }
-  }
-
-  if (param == 0) {
-    ++optind;
-    return (BADCH);
-  }
-
-  if (argv[optind][0]=='-') {  /* long option */
-    char* arg=argv[optind]+1;
-    const struct option* o;
-    o=longopts;
-    len=sizeof(longopts[0]);
-
-    if (param > 1){
-      arg = argv[optind+1];
-      optind++;
-    }
-    else
-      arg = argv[optind]+1;
-
-    if(strlen(arg)>1){
-      for (i=0;i<totlen;i=i+len,o++) {
-        if (!strcmp(o->name,arg)) {  /* match */
-          if (o->has_arg == 0) {
-            if ((argv[optind+1])&&(!(argv[optind+1][0]=='-'))){
-              fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[optind+1]);
-              ++optind;
-            }
-          }else{
-            optarg=argv[optind+1];
-            if(optarg){
-              if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
-                if (opterr) {
-                  fprintf(stderr,"%s: option requires an argument\n",arg);
-                  return (BADCH);
-                }
-              }
-            }
-            if (!optarg && o->has_arg==1) {  /* no argument there */
-              if (opterr) {
-                fprintf(stderr,"%s: option requires an argument \n",arg);
-                return (BADCH);
-              }
-            }
-            ++optind;
-          }
-          ++optind;
-          if (o->flag)
-            *(o->flag)=o->val;
-          else
-            return o->val;
-          return 0;
-        }
-      }//(end for)String not found in the list
-      fprintf(stderr,"Invalid option %s\n",arg);
-      ++optind;
-      return (BADCH);
-    }else{ /*Single character input parameter*/
-      if (*optstring==':') return ':';
-      if (lastidx!=optind) {
-        lastidx=optind; lastofs=0;
-      }
-      optopt=argv[optind][lastofs+1];
-      if ((tmp=strchr(optstring,optopt))) {/*Found input parameter in list*/
-        if (*tmp==0) {  /* apparently, we looked for \0, i.e. end of argument */
-          ++optind;
-          goto again;
-        }
-        if (tmp[1]==':') {  /* argument expected */
-          if (tmp[2]==':' || argv[optind][lastofs+2]) {  /* "-foo", return "oo" as optarg */
-            if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
-            goto found;
-          }
-          optarg=argv[optind+1];
-          if(optarg){
-            if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
-              if (opterr) {
-                fprintf(stderr,"%s: option requires an argument\n",arg);
-                return (BADCH);
-              }
-            }
-          }
-          if (!optarg) {  /* missing argument */
-            if (opterr) {
-              fprintf(stderr,"%s: option requires an argument\n",arg);
-              return (BADCH);
-            }
-          }
-          ++optind;
-        }else {/*Argument not expected*/
-          ++lastofs;
-          return optopt;
-        }
-found:
-        ++optind;
-        return optopt;
-      }  else {  /* not found */
-        fprintf(stderr,"Invalid option %s\n",arg);
-        ++optind;
-        return (BADCH);
-      }//end of not found
-
-    }// end of single character
-  }//end '-'
-  fprintf(stderr,"Invalid option\n");
-  ++optind;
-  return (BADCH);;
-}//end function
diff --git a/Utilities/gdcmopenjpeg-v2/codec/compat/getopt.h b/Utilities/gdcmopenjpeg-v2/codec/compat/getopt.h
deleted file mode 100644
index 94a8c10..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/compat/getopt.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* last review : october 29th, 2002 */
-
-#ifndef _GETOPT_H_
-#define _GETOPT_H_
-
-typedef struct option
-{
-  const char *name;
-  int has_arg;
-  int *flag;
-  int val;
-}option_t;
-
-#define  NO_ARG  0
-#define REQ_ARG  1
-#define OPT_ARG  2
-
-extern int opterr;
-extern int optind;
-extern int optopt;
-extern int optreset;
-extern char *optarg;
-
-extern int getopt(int nargc, char *const *nargv, const char *ostr);
-extern int getopt_long(int argc, char * const argv[], const char *optstring,
-      const struct option *longopts, int totlen);
-
-
-#endif        /* _GETOPT_H_ */
diff --git a/Utilities/gdcmopenjpeg-v2/codec/convert.c b/Utilities/gdcmopenjpeg-v2/codec/convert.c
deleted file mode 100644
index 82f3104..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/convert.c
+++ /dev/null
@@ -1,2519 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef WIN32
-#include "../libs/libtiff/tiffio.h"
-#include "../libs/libpng/png.h"
-#else
-#include <tiffio.h>
-#include <png.h>
-#endif /* WIN32 */
-#include "openjpeg.h"
-#include "convert.h"
-
-/*
- * Get logarithm of an integer and round downwards.
- *
- * log2(a)
- */
-static int int_floorlog2(int a) {
-  int l;
-  for (l = 0; a > 1; l++) {
-    a >>= 1;
-  }
-  return l;
-}
-
-/*
- * Divide an integer by a power of 2 and round upwards.
- *
- * a divided by 2^b
- */
-static int int_ceildivpow2(int a, int b) {
-  return (a + (1 << b) - 1) >> b;
-}
-
-/*
- * Divide an integer and round upwards.
- *
- * a divided by b
- */
-static int int_ceildiv(int a, int b) {
-  return (a + b - 1) / b;
-}
-
-
-/* -->> -->> -->> -->>
-
-  TGA IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-// TGA header definition.
-#pragma pack(push,1) // Pack structure byte aligned
-typedef struct tga_header
-{
-    uint8   id_length;              /* Image id field length    */
-    uint8   colour_map_type;        /* Colour map type          */
-    uint8   image_type;             /* Image type               */
-    /*
-    ** Colour map specification
-    */
-    uint16  colour_map_index;       /* First entry index        */
-    uint16  colour_map_length;      /* Colour map length        */
-    uint8   colour_map_entry_size;  /* Colour map entry size    */
-    /*
-    ** Image specification
-    */
-    uint16  x_origin;               /* x origin of image        */
-    uint16  y_origin;               /* u origin of image        */
-    uint16  image_width;            /* Image width              */
-    uint16  image_height;           /* Image height             */
-    uint8   pixel_depth;            /* Pixel depth              */
-    uint8   image_desc;             /* Image descriptor         */
-} tga_header;
-#pragma pack(pop) // Return to normal structure packing alignment.
-
-int tga_readheader(FILE *fp, uint32 *bits_per_pixel, uint32 *width, uint32 *height, int *flip_image)
-{
-  int palette_size;
-  tga_header tga ;
-
-  if (!bits_per_pixel || !width || !height || !flip_image)
-    return 0;
-
-  // Read TGA header
-  fread((uint8*)&tga, sizeof(tga_header), 1, fp);
-
-  *bits_per_pixel = tga.pixel_depth;
-
-  *width  = tga.image_width;
-  *height = tga.image_height ;
-
-  // Ignore tga identifier, if present ...
-  if (tga.id_length)
-  {
-    uint8 *id = (uint8 *) malloc(tga.id_length);
-    fread(id, tga.id_length, 1, fp);
-    free(id);
-  }
-
-  // Test for compressed formats ... not yet supported ...
-  // Note :-  9 - RLE encoded palettized.
-  //         10 - RLE encoded RGB.
-  if (tga.image_type > 8)
-  {
-    fprintf(stderr, "Sorry, compressed tga files are not currently supported.\n");
-    return 0 ;
-  }
-
-  *flip_image = !(tga.image_desc & 32);
-
-  // Palettized formats are not yet supported, skip over the palette, if present ...
-  palette_size = tga.colour_map_length * (tga.colour_map_entry_size/8);
-
-  if (palette_size>0)
-  {
-    fprintf(stderr, "File contains a palette - not yet supported.");
-    fseek(fp, palette_size, SEEK_CUR);
-  }
-  return 1;
-}
-
-int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, bool flip_image)
-{
-  tga_header tga;
-
-  if (!bits_per_pixel || !width || !height)
-    return 0;
-
-  memset(&tga, 0, sizeof(tga_header));
-
-  tga.pixel_depth = bits_per_pixel;
-  tga.image_width  = width;
-  tga.image_height = height;
-  tga.image_type = 2; // Uncompressed.
-  tga.image_desc = 8; // 8 bits per component.
-
-  if (flip_image)
-    tga.image_desc |= 32;
-
-  // Write TGA header
-  fwrite((uint8*)&tga, sizeof(tga_header), 1, fp);
-
-  return 1;
-}
-
-opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
-  FILE *f;
-  opj_image_t *image;
-  uint32 image_width, image_height, pixel_bit_depth;
-  uint32 x, y;
-  int flip_image=0;
-  opj_image_cmptparm_t cmptparm[4];  /* maximum 4 components */
-  int numcomps;
-  OPJ_COLOR_SPACE color_space;
-  bool mono ;
-  bool save_alpha;
-  int subsampling_dx, subsampling_dy;
-  int i;
-
-  f = fopen(filename, "rb");
-  if (!f) {
-    fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-    return 0;
-  }
-
-  if (!tga_readheader(f, &pixel_bit_depth, &image_width, &image_height, &flip_image))
-    return NULL;
-
-  // We currently only support 24 & 32 bit tga's ...
-  if (!((pixel_bit_depth == 24) || (pixel_bit_depth == 32)))
-    return NULL;
-
-  /* initialize image components */
-  memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
-
-  mono = (pixel_bit_depth == 8) || (pixel_bit_depth == 16);  // Mono with & without alpha.
-  save_alpha = (pixel_bit_depth == 16) || (pixel_bit_depth == 32); // Mono with alpha, or RGB with alpha
-
-  if (mono) {
-    color_space = CLRSPC_GRAY;
-    numcomps = save_alpha ? 2 : 1;
-  }
-  else {
-    numcomps = save_alpha ? 4 : 3;
-    color_space = CLRSPC_SRGB;
-  }
-
-  subsampling_dx = parameters->subsampling_dx;
-  subsampling_dy = parameters->subsampling_dy;
-
-  for (i = 0; i < numcomps; i++) {
-    cmptparm[i].prec = 8;
-    cmptparm[i].bpp = 8;
-    cmptparm[i].sgnd = 0;
-    cmptparm[i].dx = subsampling_dx;
-    cmptparm[i].dy = subsampling_dy;
-    cmptparm[i].w = image_width;
-    cmptparm[i].h = image_height;
-  }
-
-  /* create the image */
-  image = opj_image_create(numcomps, &cmptparm[0], color_space);
-
-  if (!image)
-    return NULL;
-
-  /* set image offset and reference grid */
-  image->x0 = parameters->image_offset_x0;
-  image->y0 = parameters->image_offset_y0;
-  image->x1 =  !image->x0 ? (image_width - 1) * subsampling_dx + 1 : image->x0 + (image_width - 1) * subsampling_dx + 1;
-  image->y1 =  !image->y0 ? (image_height - 1) * subsampling_dy + 1 : image->y0 + (image_height - 1) * subsampling_dy + 1;
-
-  /* set image data */
-  for (y=0; y < image_height; y++)
-  {
-    int index;
-
-    if (flip_image)
-      index = (image_height-y-1)*image_width;
-    else
-      index = y*image_width;
-
-    if (numcomps==3)
-    {
-      for (x=0;x<image_width;x++)
-      {
-        uint8 r,g,b;
-        fread(&b, 1, 1, f);
-        fread(&g, 1, 1, f);
-        fread(&r, 1, 1, f);
-
-        image->comps[0].data[index]=r;
-        image->comps[1].data[index]=g;
-        image->comps[2].data[index]=b;
-        index++;
-      }
-    }
-    else if (numcomps==4)
-    {
-      for (x=0;x<image_width;x++)
-      {
-        uint8 r,g,b,a;
-        fread(&b, 1, 1, f);
-        fread(&g, 1, 1, f);
-        fread(&r, 1, 1, f);
-        fread(&a, 1, 1, f);
-
-        image->comps[0].data[index]=r;
-        image->comps[1].data[index]=g;
-        image->comps[2].data[index]=b;
-        image->comps[3].data[index]=a;
-        index++;
-      }
-    }
-    else {
-      fprintf(stderr, "Currently unsupported bit depth : %s\n", filename);
-    }
-  }
-  return image;
-}
-
-int imagetotga(opj_image_t * image, const char *outfile) {
-  int width, height, bpp, x, y;
-  bool write_alpha;
-  unsigned int i;
-  uint32 alpha_channel;
-  float r,g,b,a;
-  uint8 value;
-  float scale;
-  FILE *fdest;
-
-  fdest = fopen(outfile, "wb");
-  if (!fdest) {
-    fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-    return 1;
-  }
-
-  for (i = 0; i < image->numcomps-1; i++)  {
-    if ((image->comps[0].dx != image->comps[i+1].dx)
-      ||(image->comps[0].dy != image->comps[i+1].dy)
-      ||(image->comps[0].prec != image->comps[i+1].prec))  {
-      fprintf(stderr, "Unable to create a tga file with such J2K image charateristics.");
-      return 1;
-   }
-  }
-
-  width = image->comps[0].w;
-  height = image->comps[0].h;
-
-  // Mono with alpha, or RGB with alpha.
-  write_alpha = (image->numcomps==2) || (image->numcomps==4);
-
-  // Write TGA header
-  bpp = write_alpha ? 32 : 24;
-  if (!tga_writeheader(fdest, bpp, width , height, true))
-    return 1;
-
-  alpha_channel = image->numcomps-1;
-
-  scale = 255.0f / (float)((1<<image->comps[0].prec)-1);
-
-  for (y=0; y < height; y++) {
-    uint32 index=y*width;
-
-    for (x=0; x < width; x++, index++)  {
-      r = (float)(image->comps[0].data[index]);
-
-      if (image->numcomps>2) {
-        g = (float)(image->comps[1].data[index]);
-        b = (float)(image->comps[2].data[index]);
-      }
-      else  {// Greyscale ...
-        g = r;
-        b = r;
-      }
-
-      // TGA format writes BGR ...
-      value = (uint8)(b*scale);
-      fwrite(&value,1,1,fdest);
-
-      value = (uint8)(g*scale);
-      fwrite(&value,1,1,fdest);
-
-      value = (uint8)(r*scale);
-      fwrite(&value,1,1,fdest);
-
-      if (write_alpha) {
-        a = (float)(image->comps[alpha_channel].data[index]);
-        value = (uint8)(a*scale);
-        fwrite(&value,1,1,fdest);
-      }
-    }
-  }
-
-  return 0;
-}
-
-/* -->> -->> -->> -->>
-
-  BMP IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-/* WORD defines a two byte word */
-typedef unsigned short int WORD;
-
-/* DWORD defines a four byte word */
-typedef unsigned long int DWORD;
-
-typedef struct {
-  WORD bfType;      /* 'BM' for Bitmap (19776) */
-  DWORD bfSize;      /* Size of the file        */
-  WORD bfReserved1;    /* Reserved : 0            */
-  WORD bfReserved2;    /* Reserved : 0            */
-  DWORD bfOffBits;    /* Offset                  */
-} BITMAPFILEHEADER_t;
-
-typedef struct {
-  DWORD biSize;      /* Size of the structure in bytes */
-  DWORD biWidth;    /* Width of the image in pixels */
-  DWORD biHeight;    /* Heigth of the image in pixels */
-  WORD biPlanes;    /* 1 */
-  WORD biBitCount;    /* Number of color bits by pixels */
-  DWORD biCompression;    /* Type of encoding 0: none 1: RLE8 2: RLE4 */
-  DWORD biSizeImage;    /* Size of the image in bytes */
-  DWORD biXpelsPerMeter;  /* Horizontal (X) resolution in pixels/meter */
-  DWORD biYpelsPerMeter;  /* Vertical (Y) resolution in pixels/meter */
-  DWORD biClrUsed;    /* Number of color used in the image (0: ALL) */
-  DWORD biClrImportant;    /* Number of important color (0: ALL) */
-} BITMAPINFOHEADER_t;
-
-opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters) {
-  int subsampling_dx = parameters->subsampling_dx;
-  int subsampling_dy = parameters->subsampling_dy;
-
-  int i, numcomps, w, h;
-  OPJ_COLOR_SPACE color_space;
-  opj_image_cmptparm_t cmptparm[3];  /* maximum of 3 components */
-  opj_image_t * image = NULL;
-
-  FILE *IN;
-  BITMAPFILEHEADER_t File_h;
-  BITMAPINFOHEADER_t Info_h;
-  unsigned char *RGB;
-  unsigned char *table_R, *table_G, *table_B;
-  unsigned int j, PAD = 0;
-
-  int x, y, index;
-  int gray_scale = 1, not_end_file = 1;
-
-  unsigned int line = 0, col = 0;
-  unsigned char v, v2;
-  DWORD W, H;
-
-  IN = fopen(filename, "rb");
-  if (!IN) {
-    fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-    return 0;
-  }
-
-  File_h.bfType = getc(IN);
-  File_h.bfType = (getc(IN) << 8) + File_h.bfType;
-
-  if (File_h.bfType != 19778) {
-    fprintf(stderr,"Error, not a BMP file!\n");
-    return 0;
-  } else {
-    /* FILE HEADER */
-    /* ------------- */
-    File_h.bfSize = getc(IN);
-    File_h.bfSize = (getc(IN) << 8) + File_h.bfSize;
-    File_h.bfSize = (getc(IN) << 16) + File_h.bfSize;
-    File_h.bfSize = (getc(IN) << 24) + File_h.bfSize;
-
-    File_h.bfReserved1 = getc(IN);
-    File_h.bfReserved1 = (getc(IN) << 8) + File_h.bfReserved1;
-
-    File_h.bfReserved2 = getc(IN);
-    File_h.bfReserved2 = (getc(IN) << 8) + File_h.bfReserved2;
-
-    File_h.bfOffBits = getc(IN);
-    File_h.bfOffBits = (getc(IN) << 8) + File_h.bfOffBits;
-    File_h.bfOffBits = (getc(IN) << 16) + File_h.bfOffBits;
-    File_h.bfOffBits = (getc(IN) << 24) + File_h.bfOffBits;
-
-    /* INFO HEADER */
-    /* ------------- */
-
-    Info_h.biSize = getc(IN);
-    Info_h.biSize = (getc(IN) << 8) + Info_h.biSize;
-    Info_h.biSize = (getc(IN) << 16) + Info_h.biSize;
-    Info_h.biSize = (getc(IN) << 24) + Info_h.biSize;
-
-    Info_h.biWidth = getc(IN);
-    Info_h.biWidth = (getc(IN) << 8) + Info_h.biWidth;
-    Info_h.biWidth = (getc(IN) << 16) + Info_h.biWidth;
-    Info_h.biWidth = (getc(IN) << 24) + Info_h.biWidth;
-    w = Info_h.biWidth;
-
-    Info_h.biHeight = getc(IN);
-    Info_h.biHeight = (getc(IN) << 8) + Info_h.biHeight;
-    Info_h.biHeight = (getc(IN) << 16) + Info_h.biHeight;
-    Info_h.biHeight = (getc(IN) << 24) + Info_h.biHeight;
-    h = Info_h.biHeight;
-
-    Info_h.biPlanes = getc(IN);
-    Info_h.biPlanes = (getc(IN) << 8) + Info_h.biPlanes;
-
-    Info_h.biBitCount = getc(IN);
-    Info_h.biBitCount = (getc(IN) << 8) + Info_h.biBitCount;
-
-    Info_h.biCompression = getc(IN);
-    Info_h.biCompression = (getc(IN) << 8) + Info_h.biCompression;
-    Info_h.biCompression = (getc(IN) << 16) + Info_h.biCompression;
-    Info_h.biCompression = (getc(IN) << 24) + Info_h.biCompression;
-
-    Info_h.biSizeImage = getc(IN);
-    Info_h.biSizeImage = (getc(IN) << 8) + Info_h.biSizeImage;
-    Info_h.biSizeImage = (getc(IN) << 16) + Info_h.biSizeImage;
-    Info_h.biSizeImage = (getc(IN) << 24) + Info_h.biSizeImage;
-
-    Info_h.biXpelsPerMeter = getc(IN);
-    Info_h.biXpelsPerMeter = (getc(IN) << 8) + Info_h.biXpelsPerMeter;
-    Info_h.biXpelsPerMeter = (getc(IN) << 16) + Info_h.biXpelsPerMeter;
-    Info_h.biXpelsPerMeter = (getc(IN) << 24) + Info_h.biXpelsPerMeter;
-
-    Info_h.biYpelsPerMeter = getc(IN);
-    Info_h.biYpelsPerMeter = (getc(IN) << 8) + Info_h.biYpelsPerMeter;
-    Info_h.biYpelsPerMeter = (getc(IN) << 16) + Info_h.biYpelsPerMeter;
-    Info_h.biYpelsPerMeter = (getc(IN) << 24) + Info_h.biYpelsPerMeter;
-
-    Info_h.biClrUsed = getc(IN);
-    Info_h.biClrUsed = (getc(IN) << 8) + Info_h.biClrUsed;
-    Info_h.biClrUsed = (getc(IN) << 16) + Info_h.biClrUsed;
-    Info_h.biClrUsed = (getc(IN) << 24) + Info_h.biClrUsed;
-
-    Info_h.biClrImportant = getc(IN);
-    Info_h.biClrImportant = (getc(IN) << 8) + Info_h.biClrImportant;
-    Info_h.biClrImportant = (getc(IN) << 16) + Info_h.biClrImportant;
-    Info_h.biClrImportant = (getc(IN) << 24) + Info_h.biClrImportant;
-
-    /* Read the data and store them in the OUT file */
-
-    if (Info_h.biBitCount == 24) {
-      numcomps = 3;
-      color_space = CLRSPC_SRGB;
-      /* initialize image components */
-      memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-      for(i = 0; i < numcomps; i++) {
-        cmptparm[i].prec = 8;
-        cmptparm[i].bpp = 8;
-        cmptparm[i].sgnd = 0;
-        cmptparm[i].dx = subsampling_dx;
-        cmptparm[i].dy = subsampling_dy;
-        cmptparm[i].w = w;
-        cmptparm[i].h = h;
-      }
-      /* create the image */
-      image = opj_image_create(numcomps, &cmptparm[0], color_space);
-      if(!image) {
-        fclose(IN);
-        return NULL;
-      }
-
-      /* set image offset and reference grid */
-      image->x0 = parameters->image_offset_x0;
-      image->y0 = parameters->image_offset_y0;
-      image->x1 =  !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-      image->y1 =  !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-      /* set image data */
-
-      /* Place the cursor at the beginning of the image information */
-      fseek(IN, 0, SEEK_SET);
-      fseek(IN, File_h.bfOffBits, SEEK_SET);
-
-      W = Info_h.biWidth;
-      H = Info_h.biHeight;
-
-      /* PAD = 4 - (3 * W) % 4; */
-      /* PAD = (PAD == 4) ? 0 : PAD; */
-      PAD = (3 * W) % 4 ? 4 - (3 * W) % 4 : 0;
-
-      RGB = (unsigned char *) malloc((3 * W + PAD) * H * sizeof(unsigned char));
-
-      fread(RGB, sizeof(unsigned char), (3 * W + PAD) * H, IN);
-
-      index = 0;
-
-      for(y = 0; y < (int)H; y++) {
-        unsigned char *scanline = RGB + (3 * W + PAD) * (H - 1 - y);
-        for(x = 0; x < (int)W; x++) {
-          unsigned char *pixel = &scanline[3 * x];
-          image->comps[0].data[index] = pixel[2];  /* R */
-          image->comps[1].data[index] = pixel[1];  /* G */
-          image->comps[2].data[index] = pixel[0];  /* B */
-          index++;
-        }
-      }
-
-      free(RGB);
-
-    } else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) {
-      table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
-      table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
-      table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
-
-      for (j = 0; j < Info_h.biClrUsed; j++) {
-        table_B[j] = getc(IN);
-        table_G[j] = getc(IN);
-        table_R[j] = getc(IN);
-        getc(IN);
-        if (table_R[j] != table_G[j] && table_R[j] != table_B[j] && table_G[j] != table_B[j])
-          gray_scale = 0;
-      }
-
-      /* Place the cursor at the beginning of the image information */
-      fseek(IN, 0, SEEK_SET);
-      fseek(IN, File_h.bfOffBits, SEEK_SET);
-
-      W = Info_h.biWidth;
-      H = Info_h.biHeight;
-      if (Info_h.biWidth % 2)
-        W++;
-
-      numcomps = gray_scale ? 1 : 3;
-      color_space = gray_scale ? CLRSPC_GRAY : CLRSPC_SRGB;
-      /* initialize image components */
-      memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-      for(i = 0; i < numcomps; i++) {
-        cmptparm[i].prec = 8;
-        cmptparm[i].bpp = 8;
-        cmptparm[i].sgnd = 0;
-        cmptparm[i].dx = subsampling_dx;
-        cmptparm[i].dy = subsampling_dy;
-        cmptparm[i].w = w;
-        cmptparm[i].h = h;
-      }
-      /* create the image */
-      image = opj_image_create(numcomps, &cmptparm[0], color_space);
-      if(!image) {
-        fclose(IN);
-        return NULL;
-      }
-
-      /* set image offset and reference grid */
-      image->x0 = parameters->image_offset_x0;
-      image->y0 = parameters->image_offset_y0;
-      image->x1 =  !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-      image->y1 =  !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-      /* set image data */
-
-      RGB = (unsigned char *) malloc(W * H * sizeof(unsigned char));
-
-      fread(RGB, sizeof(unsigned char), W * H, IN);
-      if (gray_scale) {
-        index = 0;
-        for (j = 0; j < W * H; j++) {
-          if ((j % W < W - 1 && Info_h.biWidth % 2) || !(Info_h.biWidth % 2)) {
-            image->comps[0].data[index] = table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]];
-            index++;
-          }
-        }
-
-      } else {
-        index = 0;
-        for (j = 0; j < W * H; j++) {
-          if ((j % W < W - 1 && Info_h.biWidth % 2) || !(Info_h.biWidth % 2)) {
-            unsigned char pixel_index = RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)];
-            image->comps[0].data[index] = table_R[pixel_index];
-            image->comps[1].data[index] = table_G[pixel_index];
-            image->comps[2].data[index] = table_B[pixel_index];
-            index++;
-          }
-        }
-      }
-      free(RGB);
-      free(table_R);
-      free(table_G);
-      free(table_B);
-    } else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) {
-      table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
-      table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
-      table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
-
-      for (j = 0; j < Info_h.biClrUsed; j++) {
-        table_B[j] = getc(IN);
-        table_G[j] = getc(IN);
-        table_R[j] = getc(IN);
-        getc(IN);
-        if (table_R[j] != table_G[j] && table_R[j] != table_B[j] && table_G[j] != table_B[j])
-          gray_scale = 0;
-      }
-
-      numcomps = gray_scale ? 1 : 3;
-      color_space = gray_scale ? CLRSPC_GRAY : CLRSPC_SRGB;
-      /* initialize image components */
-      memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-      for(i = 0; i < numcomps; i++) {
-        cmptparm[i].prec = 8;
-        cmptparm[i].bpp = 8;
-        cmptparm[i].sgnd = 0;
-        cmptparm[i].dx = subsampling_dx;
-        cmptparm[i].dy = subsampling_dy;
-        cmptparm[i].w = w;
-        cmptparm[i].h = h;
-      }
-      /* create the image */
-      image = opj_image_create(numcomps, &cmptparm[0], color_space);
-      if(!image) {
-        fclose(IN);
-        return NULL;
-      }
-
-      /* set image offset and reference grid */
-      image->x0 = parameters->image_offset_x0;
-      image->y0 = parameters->image_offset_y0;
-      image->x1 =  !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-      image->y1 =  !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-      /* set image data */
-
-      /* Place the cursor at the beginning of the image information */
-      fseek(IN, 0, SEEK_SET);
-      fseek(IN, File_h.bfOffBits, SEEK_SET);
-
-      RGB = (unsigned char *) malloc(Info_h.biWidth * Info_h.biHeight * sizeof(unsigned char));
-
-      while (not_end_file) {
-        v = getc(IN);
-        if (v) {
-          v2 = getc(IN);
-          for (i = 0; i < (int) v; i++) {
-            RGB[line * Info_h.biWidth + col] = v2;
-            col++;
-          }
-        } else {
-          v = getc(IN);
-          switch (v) {
-            case 0:
-              col = 0;
-              line++;
-              break;
-            case 1:
-              line++;
-              not_end_file = 0;
-              break;
-            case 2:
-              fprintf(stderr,"No Delta supported\n");
-              opj_image_destroy(image);
-              fclose(IN);
-              return NULL;
-            default:
-              for (i = 0; i < v; i++) {
-                v2 = getc(IN);
-                RGB[line * Info_h.biWidth + col] = v2;
-                col++;
-              }
-              if (v % 2)
-                v2 = getc(IN);
-              break;
-          }
-        }
-      }
-      if (gray_scale) {
-        index = 0;
-        for (line = 0; line < Info_h.biHeight; line++) {
-          for (col = 0; col < Info_h.biWidth; col++) {
-            image->comps[0].data[index] = table_R[(int)RGB[(Info_h.biHeight - line - 1) * Info_h.biWidth + col]];
-            index++;
-          }
-        }
-      } else {
-        index = 0;
-        for (line = 0; line < Info_h.biHeight; line++) {
-          for (col = 0; col < Info_h.biWidth; col++) {
-            unsigned char pixel_index = (int)RGB[(Info_h.biHeight - line - 1) * Info_h.biWidth + col];
-            image->comps[0].data[index] = table_R[pixel_index];
-            image->comps[1].data[index] = table_G[pixel_index];
-            image->comps[2].data[index] = table_B[pixel_index];
-            index++;
-          }
-        }
-      }
-      free(RGB);
-      free(table_R);
-      free(table_G);
-      free(table_B);
-  } else {
-    fprintf(stderr,
-      "Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n", Info_h.biBitCount);
-  }
-  fclose(IN);
- }
-
- return image;
-}
-
-int imagetobmp(opj_image_t * image, const char *outfile) {
-  int w, h;
-  int i, pad;
-  FILE *fdest = NULL;
-  int adjustR, adjustG, adjustB;
-
-  if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
-    && image->comps[1].dx == image->comps[2].dx
-    && image->comps[0].dy == image->comps[1].dy
-    && image->comps[1].dy == image->comps[2].dy
-    && image->comps[0].prec == image->comps[1].prec
-    && image->comps[1].prec == image->comps[2].prec) {
-
-    /* -->> -->> -->> -->>
-    24 bits color
-    <<-- <<-- <<-- <<-- */
-
-    fdest = fopen(outfile, "wb");
-    if (!fdest) {
-      fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-      return 1;
-    }
-
-    w = image->comps[0].w;
-    h = image->comps[0].h;
-
-    fprintf(fdest, "BM");
-
-    /* FILE HEADER */
-    /* ------------- */
-    fprintf(fdest, "%c%c%c%c",
-      (unsigned char) (h * w * 3 + 3 * h * (w % 2) + 54) & 0xff,
-      (unsigned char) ((h * w * 3 + 3 * h * (w % 2) + 54)  >> 8) & 0xff,
-      (unsigned char) ((h * w * 3 + 3 * h * (w % 2) + 54)  >> 16) & 0xff,
-      (unsigned char) ((h * w * 3 + 3 * h * (w % 2) + 54)  >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
-
-    /* INFO HEADER   */
-    /* ------------- */
-    fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,  ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (unsigned char) ((w) & 0xff),
-      (unsigned char) ((w) >> 8) & 0xff,
-      (unsigned char) ((w) >> 16) & 0xff,
-      (unsigned char) ((w) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (unsigned char) ((h) & 0xff),
-      (unsigned char) ((h) >> 8) & 0xff,
-      (unsigned char) ((h) >> 16) & 0xff,
-      (unsigned char) ((h) >> 24) & 0xff);
-    fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
-    fprintf(fdest, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (unsigned char) (3 * h * w + 3 * h * (w % 2)) & 0xff,
-      (unsigned char) ((h * w * 3 + 3 * h * (w % 2)) >> 8) & 0xff,
-      (unsigned char) ((h * w * 3 + 3 * h * (w % 2)) >> 16) & 0xff,
-      (unsigned char) ((h * w * 3 + 3 * h * (w % 2)) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,  ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-
-    if (image->comps[0].prec > 8) {
-      adjustR = image->comps[0].prec - 8;
-      printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
-    }
-    else
-      adjustR = 0;
-    if (image->comps[1].prec > 8) {
-      adjustG = image->comps[1].prec - 8;
-      printf("BMP CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
-    }
-    else
-      adjustG = 0;
-    if (image->comps[2].prec > 8) {
-      adjustB = image->comps[2].prec - 8;
-      printf("BMP CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
-    }
-    else
-      adjustB = 0;
-
-    for (i = 0; i < w * h; i++) {
-      unsigned char rc, gc, bc;
-      int r, g, b;
-
-      r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-      rc = (unsigned char) ((r >> adjustR)+((r >> (adjustR-1))%2));
-      g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
-      gc = (unsigned char) ((g >> adjustG)+((g >> (adjustG-1))%2));
-      b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
-      bc = (unsigned char) ((b >> adjustB)+((b >> (adjustB-1))%2));
-
-      fprintf(fdest, "%c%c%c", bc, gc, rc);
-
-      if ((i + 1) % w == 0) {
-        for (pad = (3 * w) % 4 ? 4 - (3 * w) % 4 : 0; pad > 0; pad--)  /* ADD */
-          fprintf(fdest, "%c", 0);
-      }
-    }
-    fclose(fdest);
-  } else {      /* Gray-scale */
-
-    /* -->> -->> -->> -->>
-    8 bits non code (Gray scale)
-    <<-- <<-- <<-- <<-- */
-
-    fdest = fopen(outfile, "wb");
-    w = image->comps[0].w;
-    h = image->comps[0].h;
-
-    fprintf(fdest, "BM");
-
-    /* FILE HEADER */
-    /* ------------- */
-    fprintf(fdest, "%c%c%c%c", (unsigned char) (h * w + 54 + 1024 + h * (w % 2)) & 0xff,
-      (unsigned char) ((h * w + 54 + 1024 + h * (w % 2)) >> 8) & 0xff,
-      (unsigned char) ((h * w + 54 + 1024 + h * (w % 2)) >> 16) & 0xff,
-      (unsigned char) ((h * w + 54 + 1024 + w * (w % 2)) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (54 + 1024) & 0xff, ((54 + 1024) >> 8) & 0xff,
-      ((54 + 1024) >> 16) & 0xff,
-      ((54 + 1024) >> 24) & 0xff);
-
-    /* INFO HEADER */
-    /* ------------- */
-    fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,  ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (unsigned char) ((w) & 0xff),
-      (unsigned char) ((w) >> 8) & 0xff,
-      (unsigned char) ((w) >> 16) & 0xff,
-      (unsigned char) ((w) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (unsigned char) ((h) & 0xff),
-      (unsigned char) ((h) >> 8) & 0xff,
-      (unsigned char) ((h) >> 16) & 0xff,
-      (unsigned char) ((h) >> 24) & 0xff);
-    fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
-    fprintf(fdest, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (unsigned char) (h * w + h * (w % 2)) & 0xff,
-      (unsigned char) ((h * w + h * (w % 2)) >> 8) &  0xff,
-      (unsigned char) ((h * w + h * (w % 2)) >> 16) &  0xff,
-      (unsigned char) ((h * w + h * (w % 2)) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,  ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,  ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
-    fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
-
-    if (image->comps[0].prec > 8) {
-      adjustR = image->comps[0].prec - 8;
-      printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
-    }
-
-    for (i = 0; i < 256; i++) {
-      fprintf(fdest, "%c%c%c%c", i, i, i, 0);
-    }
-
-    for (i = 0; i < w * h; i++) {
-      unsigned char rc;
-      int r;
-
-      r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-      rc = (unsigned char) ((r >> adjustR)+((r >> (adjustR-1))%2));
-
-      fprintf(fdest, "%c", rc);
-
-      if ((i + 1) % w == 0) {
-        for (pad = w % 4 ? 4 - w % 4 : 0; pad > 0; pad--)  /* ADD */
-          fprintf(fdest, "%c", 0);
-      }
-    }
-    fclose(fdest);
-  }
-
-  return 0;
-}
-
-/* -->> -->> -->> -->>
-
-PGX IMAGE FORMAT
-
-<<-- <<-- <<-- <<-- */
-
-
-unsigned char readuchar(FILE * f)
-{
-  unsigned char c1;
-  fread(&c1, 1, 1, f);
-  return c1;
-}
-
-unsigned short readushort(FILE * f, int bigendian)
-{
-  unsigned char c1, c2;
-  fread(&c1, 1, 1, f);
-  fread(&c2, 1, 1, f);
-  if (bigendian)
-    return (c1 << 8) + c2;
-  else
-    return (c2 << 8) + c1;
-}
-
-unsigned int readuint(FILE * f, int bigendian)
-{
-  unsigned char c1, c2, c3, c4;
-  fread(&c1, 1, 1, f);
-  fread(&c2, 1, 1, f);
-  fread(&c3, 1, 1, f);
-  fread(&c4, 1, 1, f);
-  if (bigendian)
-    return (c1 << 24) + (c2 << 16) + (c3 << 8) + c4;
-  else
-    return (c4 << 24) + (c3 << 16) + (c2 << 8) + c1;
-}
-
-opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) {
-  FILE *f = NULL;
-  int w, h, prec;
-  int i, numcomps, max;
-  OPJ_COLOR_SPACE color_space;
-  opj_image_cmptparm_t cmptparm;  /* maximum of 1 component  */
-  opj_image_t * image = NULL;
-
-  char endian1,endian2,sign;
-  char signtmp[32];
-
-  char temp[32];
-  int bigendian;
-  opj_image_comp_t *comp = NULL;
-
-  numcomps = 1;
-  color_space = CLRSPC_GRAY;
-
-  memset(&cmptparm, 0, sizeof(opj_image_cmptparm_t));
-
-  max = 0;
-
-  f = fopen(filename, "rb");
-  if (!f) {
-    fprintf(stderr, "Failed to open %s for reading !\n", filename);
-    return NULL;
-  }
-
-  fseek(f, 0, SEEK_SET);
-  fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h);
-
-  i=0;
-  sign='+';
-  while (signtmp[i]!='\0') {
-    if (signtmp[i]=='-') sign='-';
-    i++;
-  }
-
-  fgetc(f);
-  if (endian1=='M' && endian2=='L') {
-    bigendian = 1;
-  } else if (endian2=='M' && endian1=='L') {
-    bigendian = 0;
-  } else {
-    fprintf(stderr, "Bad pgx header, please check input file\n");
-    return NULL;
-  }
-
-  /* initialize image component */
-
-  cmptparm.x0 = parameters->image_offset_x0;
-  cmptparm.y0 = parameters->image_offset_y0;
-  cmptparm.w = !cmptparm.x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm.x0 + (w - 1) * parameters->subsampling_dx + 1;
-  cmptparm.h = !cmptparm.y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm.y0 + (h - 1) * parameters->subsampling_dy + 1;
-
-  if (sign == '-') {
-    cmptparm.sgnd = 1;
-  } else {
-    cmptparm.sgnd = 0;
-  }
-  cmptparm.prec = prec;
-  cmptparm.bpp = prec;
-  cmptparm.dx = parameters->subsampling_dx;
-  cmptparm.dy = parameters->subsampling_dy;
-
-  /* create the image */
-  image = opj_image_create(numcomps, &cmptparm, color_space);
-  if(!image) {
-    fclose(f);
-    return NULL;
-  }
-  /* set image offset and reference grid */
-  image->x0 = cmptparm.x0;
-  image->y0 = cmptparm.x0;
-  image->x1 = cmptparm.w;
-  image->y1 = cmptparm.h;
-
-  /* set image data */
-
-  comp = &image->comps[0];
-
-  for (i = 0; i < w * h; i++) {
-    int v;
-    if (comp->prec <= 8) {
-      if (!comp->sgnd) {
-        v = readuchar(f);
-      } else {
-        v = (char) readuchar(f);
-      }
-    } else if (comp->prec <= 16) {
-      if (!comp->sgnd) {
-        v = readushort(f, bigendian);
-      } else {
-        v = (short) readushort(f, bigendian);
-      }
-    } else {
-      if (!comp->sgnd) {
-        v = readuint(f, bigendian);
-      } else {
-        v = (int) readuint(f, bigendian);
-      }
-    }
-    if (v > max)
-      max = v;
-    comp->data[i] = v;
-  }
-  fclose(f);
-  //comp->bpp = int_floorlog2(max) + 1;
-
-  return image;
-}
-
-int imagetopgx(opj_image_t * image, const char *outfile) {
-  int w, h;
-  int i, j;
-  unsigned int compno;
-  FILE *fdest = NULL;
-
-  for (compno = 0; compno < image->numcomps; compno++) {
-    opj_image_comp_t *comp = &image->comps[compno];
-    char bname[256]; /* buffer for name */
-    char *name = bname; /* pointer */
-    int nbytes = 0;
-    const size_t olen = strlen(outfile);
-    const size_t dotpos = olen - 4;
-    const size_t total = dotpos + 1 + 1 + 4; /* '-' + '[1-3]' + '.pgx' */
-    if( outfile[dotpos] != '.' ) {
-      /* `pgx` was recognized but there is no dot at expected position */
-      fprintf(stderr, "ERROR -> Impossible happen." );
-      return 1;
-      }
-    if( total > 256 ) {
-      name = (char*)malloc(total+1);
-      }
-    strncpy(name, outfile, dotpos);
-    if (image->numcomps > 1) {
-      sprintf(name+dotpos, "-%d.pgx", compno);
-    } else {
-      strcpy(name+dotpos, ".pgx");
-    }
-    fdest = fopen(name, "wb");
-    if (!fdest) {
-      fprintf(stderr, "ERROR -> failed to open %s for writing\n", name);
-      return 1;
-    }
-    /* dont need name anymore */
-    if( total > 256 ) {
-      free(name);
-      }
-
-    w = image->comps[compno].w;
-    h = image->comps[compno].h;
-
-    fprintf(fdest, "PG ML %c %d %d %d\n", comp->sgnd ? '-' : '+', comp->prec, w, h);
-    if (comp->prec <= 8) {
-      nbytes = 1;
-    } else if (comp->prec <= 16) {
-      nbytes = 2;
-    } else {
-      nbytes = 4;
-    }
-    for (i = 0; i < w * h; i++) {
-      int v = image->comps[compno].data[i];
-      for (j = nbytes - 1; j >= 0; j--) {
-        char byte = (char) (v >> (j * 8));
-        fwrite(&byte, 1, 1, fdest);
-      }
-    }
-    fclose(fdest);
-  }
-
-  return 0;
-}
-
-/* -->> -->> -->> -->>
-
-PNM IMAGE FORMAT
-
-<<-- <<-- <<-- <<-- */
-
-opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) {
-  int subsampling_dx = parameters->subsampling_dx;
-  int subsampling_dy = parameters->subsampling_dy;
-
-  FILE *f = NULL;
-  int i, compno, numcomps, w, h;
-  OPJ_COLOR_SPACE color_space;
-  opj_image_cmptparm_t cmptparm[3];  /* maximum of 3 components */
-  opj_image_t * image = NULL;
-  char value;
-
-  f = fopen(filename, "rb");
-  if (!f) {
-    fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-    return 0;
-  }
-
-  if (fgetc(f) != 'P')
-    return 0;
-  value = fgetc(f);
-
-    switch(value) {
-      case '2':  /* greyscale image type */
-      case '5':
-        numcomps = 1;
-        color_space = CLRSPC_GRAY;
-        break;
-
-      case '3':  /* RGB image type */
-      case '6':
-        numcomps = 3;
-        color_space = CLRSPC_SRGB;
-        break;
-
-      default:
-        fclose(f);
-        return NULL;
-    }
-
-    fgetc(f);
-
-    /* skip comments */
-    while(fgetc(f) == '#') while(fgetc(f) != '\n');
-
-    fseek(f, -1, SEEK_CUR);
-    fscanf(f, "%d %d\n255", &w, &h);
-    fgetc(f);  /* <cr><lf> */
-
-  /* initialize image components */
-  memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-  for(i = 0; i < numcomps; i++) {
-    cmptparm[i].prec = 8;
-    cmptparm[i].bpp = 8;
-    cmptparm[i].sgnd = 0;
-    cmptparm[i].dx = subsampling_dx;
-    cmptparm[i].dy = subsampling_dy;
-    cmptparm[i].w = w;
-    cmptparm[i].h = h;
-  }
-  /* create the image */
-  image = opj_image_create(numcomps, &cmptparm[0], color_space);
-  if(!image) {
-    fclose(f);
-    return NULL;
-  }
-
-  /* set image offset and reference grid */
-  image->x0 = parameters->image_offset_x0;
-  image->y0 = parameters->image_offset_y0;
-  image->x1 = parameters->image_offset_x0 + (w - 1) *  subsampling_dx + 1;
-  image->y1 = parameters->image_offset_y0 + (h - 1) *  subsampling_dy + 1;
-
-  /* set image data */
-
-  if ((value == '2') || (value == '3')) {  /* ASCII */
-    for (i = 0; i < w * h; i++) {
-      for(compno = 0; compno < numcomps; compno++) {
-        unsigned int index = 0;
-        fscanf(f, "%u", &index);
-        /* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
-        image->comps[compno].data[i] = index;
-      }
-    }
-  } else if ((value == '5') || (value == '6')) {  /* BINARY */
-    for (i = 0; i < w * h; i++) {
-      for(compno = 0; compno < numcomps; compno++) {
-        unsigned char index = 0;
-        fread(&index, 1, 1, f);
-        /* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
-        image->comps[compno].data[i] = index;
-      }
-    }
-  }
-
-  fclose(f);
-
-  return image;
-}
-
-int imagetopnm(opj_image_t * image, const char *outfile) {
-  int w, wr, h, hr, max;
-  int i;
-  unsigned int compno;
-  int adjustR, adjustG, adjustB, adjustX;
-  FILE *fdest = NULL;
-  char S2;
-  const char *tmp = outfile;
-
-  while (*tmp) {
-    tmp++;
-  }
-  tmp--;
-  tmp--;
-  S2 = *tmp;
-
-  if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
-    && image->comps[1].dx == image->comps[2].dx
-    && image->comps[0].dy == image->comps[1].dy
-    && image->comps[1].dy == image->comps[2].dy
-    && image->comps[0].prec == image->comps[1].prec
-    && image->comps[1].prec == image->comps[2].prec
-    && S2 !='g' && S2 !='G') {
-
-    fdest = fopen(outfile, "wb");
-    if (!fdest) {
-      fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-      return 1;
-    }
-
-    w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
-    wr = image->comps[0].w;
-
-    h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
-    hr = image->comps[0].h;
-
-    max = image->comps[0].prec > 8 ? 255 : (1 << image->comps[0].prec) - 1;
-
-    image->comps[0].x0 = int_ceildivpow2(image->comps[0].x0 - int_ceildiv(image->x0, image->comps[0].dx), image->comps[0].factor);
-    image->comps[0].y0 = int_ceildivpow2(image->comps[0].y0 -  int_ceildiv(image->y0, image->comps[0].dy), image->comps[0].factor);
-
-    fprintf(fdest, "P6\n%d %d\n%d\n", wr, hr, max);
-
-    if (image->comps[0].prec > 8) {
-      adjustR = image->comps[0].prec - 8;
-      printf("PNM CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
-    }
-    else
-      adjustR = 0;
-    if (image->comps[1].prec > 8) {
-      adjustG = image->comps[1].prec - 8;
-      printf("PNM CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
-    }
-    else
-      adjustG = 0;
-    if (image->comps[2].prec > 8) {
-      adjustB = image->comps[2].prec - 8;
-      printf("PNM CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
-    }
-    else
-      adjustB = 0;
-
-
-    for (i = 0; i < wr * hr; i++) {
-      int r, g, b;
-      unsigned char rc,gc,bc;
-      r = image->comps[0].data[i];
-      r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-      rc = (unsigned char) ((r >> adjustR)+((r >> (adjustR-1))%2));
-
-      g = image->comps[1].data[i];
-      g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
-      gc = (unsigned char) ((g >> adjustG)+((g >> (adjustG-1))%2));
-
-      b = image->comps[2].data[i];
-      b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
-      bc = (unsigned char) ((b >> adjustB)+((b >> (adjustB-1))%2));
-
-      fprintf(fdest, "%c%c%c", rc, gc, bc);
-    }
-    fclose(fdest);
-
-  } else {
-    unsigned int ncomp=(S2=='g' || S2=='G')?1:image->numcomps;
-    if (image->numcomps > ncomp) {
-      fprintf(stderr,"WARNING -> [PGM files] Only the first component\n");
-      fprintf(stderr,"           is written to the file\n");
-    }
-    for (compno = 0; compno < ncomp; compno++) {
-      char name[256];
-      if (ncomp > 1) {
-        sprintf(name, "%d.%s", compno, outfile);
-      } else {
-        sprintf(name, "%s", outfile);
-      }
-
-      fdest = fopen(name, "wb");
-      if (!fdest) {
-        fprintf(stderr, "ERROR -> failed to open %s for writing\n", name);
-        return 1;
-      }
-
-      w = int_ceildiv(image->x1 - image->x0, image->comps[compno].dx);
-      wr = image->comps[compno].w;
-
-      h = int_ceildiv(image->y1 - image->y0, image->comps[compno].dy);
-      hr = image->comps[compno].h;
-
-      max = image->comps[compno].prec > 8 ? 255 : (1 << image->comps[compno].prec) - 1;
-
-      image->comps[compno].x0 = int_ceildivpow2(image->comps[compno].x0 - int_ceildiv(image->x0, image->comps[compno].dx), image->comps[compno].factor);
-      image->comps[compno].y0 = int_ceildivpow2(image->comps[compno].y0 - int_ceildiv(image->y0, image->comps[compno].dy), image->comps[compno].factor);
-
-      fprintf(fdest, "P5\n%d %d\n%d\n", wr, hr, max);
-
-      if (image->comps[compno].prec > 8) {
-        adjustX = image->comps[0].prec - 8;
-        printf("PNM CONVERSION: Truncating component %d from %d bits to 8 bits\n",compno, image->comps[compno].prec);
-      }
-      else
-        adjustX = 0;
-
-      for (i = 0; i < wr * hr; i++) {
-        int l;
-        unsigned char lc;
-        l = image->comps[compno].data[i];
-        l += (image->comps[compno].sgnd ? 1 << (image->comps[compno].prec - 1) : 0);
-        lc = (unsigned char) ((l >> adjustX)+((l >> (adjustX-1))%2));
-        fprintf(fdest, "%c", lc);
-      }
-      fclose(fdest);
-    }
-  }
-
-  return 0;
-}
-
-/* -->> -->> -->> -->>
-
-  TIFF IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-typedef struct tiff_infoheader{
-  DWORD tiWidth;  // Width of Image in pixel
-  DWORD tiHeight; // Height of Image in pixel
-  DWORD tiPhoto;  // Photometric
-  WORD  tiBps;  // Bits per sample
-  WORD  tiSf;    // Sample Format
-  WORD  tiSpp;  // Sample per pixel 1-bilevel,gray scale , 2- RGB
-  WORD  tiPC;  // Planar config (1-Interleaved, 2-Planarcomp)
-}tiff_infoheader_t;
-
-int imagetotif(opj_image_t * image, const char *outfile) {
-  int width, height, imgsize;
-  int bps,index,adjust = 0;
-  int last_i=0;
-  TIFF *tif;
-  tdata_t buf;
-  tstrip_t strip;
-  tsize_t strip_size;
-
-  if (image->numcomps == 3 && image->comps[0].dx == image->comps[1].dx
-    && image->comps[1].dx == image->comps[2].dx
-    && image->comps[0].dy == image->comps[1].dy
-    && image->comps[1].dy == image->comps[2].dy
-    && image->comps[0].prec == image->comps[1].prec
-    && image->comps[1].prec == image->comps[2].prec) {
-
-      /* -->> -->> -->>
-      RGB color
-      <<-- <<-- <<-- */
-
-      tif = TIFFOpen(outfile, "wb");
-      if (!tif) {
-        fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-        return 1;
-      }
-
-      width  = image->comps[0].w;
-      height  = image->comps[0].h;
-      imgsize = width * height ;
-      bps    = image->comps[0].prec;
-      /* Set tags */
-      TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
-      TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
-      TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
-      TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
-      TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
-      TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
-      TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
-      TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
-
-      /* Get a buffer for the data */
-      strip_size=TIFFStripSize(tif);
-      buf = _TIFFmalloc(strip_size);
-      index=0;
-      adjust = image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0;
-      for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-        unsigned char *dat8;
-        int i, ssize;
-        ssize = TIFFStripSize(tif);
-        dat8 = (unsigned char*)buf;
-        if (image->comps[0].prec == 8){
-          for (i=0; i<ssize-2; i+=3) {  // 8 bits per pixel
-            int r = 0,g = 0,b = 0;
-            if(index < imgsize){
-              r = image->comps[0].data[index];
-              g = image->comps[1].data[index];
-              b = image->comps[2].data[index];
-              if (image->comps[0].sgnd){
-                r += adjust;
-                g += adjust;
-                b += adjust;
-              }
-              dat8[i+0] = r ;  // R
-              dat8[i+1] = g ;  // G
-              dat8[i+2] = b ;  // B
-              index++;
-              last_i = i+3;
-            }else
-              break;
-          }
-          if(last_i < ssize){
-            for (i=last_i; i<ssize; i+=3) {  // 8 bits per pixel
-              int r = 0,g = 0,b = 0;
-              if(index < imgsize){
-                r = image->comps[0].data[index];
-                g = image->comps[1].data[index];
-                b = image->comps[2].data[index];
-                if (image->comps[0].sgnd){
-                  r += adjust;
-                  g += adjust;
-                  b += adjust;
-                }
-                dat8[i+0] = r ;  // R
-                if(i+1 <ssize) dat8[i+1] = g ;  else break;// G
-                if(i+2 <ssize) dat8[i+2] = b ;  else break;// B
-                index++;
-              }else
-                break;
-            }
-          }
-        }else if (image->comps[0].prec == 12){
-          for (i=0; i<ssize-8; i+=9) {  // 12 bits per pixel
-            int r = 0,g = 0,b = 0;
-            int r1 = 0,g1 = 0,b1 = 0;
-            if((index < imgsize)&(index+1 < imgsize)){
-              r  = image->comps[0].data[index];
-              g  = image->comps[1].data[index];
-              b  = image->comps[2].data[index];
-              r1 = image->comps[0].data[index+1];
-              g1 = image->comps[1].data[index+1];
-              b1 = image->comps[2].data[index+1];
-              if (image->comps[0].sgnd){
-                r  += adjust;
-                g  += adjust;
-                b  += adjust;
-                r1 += adjust;
-                g1 += adjust;
-                b1 += adjust;
-              }
-              dat8[i+0] = (r >> 4);
-              dat8[i+1] = ((r & 0x0f) << 4 )|((g >> 8)& 0x0f);
-              dat8[i+2] = g ;
-              dat8[i+3] = (b >> 4);
-              dat8[i+4] = ((b & 0x0f) << 4 )|((r1 >> 8)& 0x0f);
-              dat8[i+5] = r1;
-              dat8[i+6] = (g1 >> 4);
-              dat8[i+7] = ((g1 & 0x0f)<< 4 )|((b1 >> 8)& 0x0f);
-              dat8[i+8] = b1;
-              index+=2;
-              last_i = i+9;
-            }else
-              break;
-          }
-          if(last_i < ssize){
-            for (i= last_i; i<ssize; i+=9) {  // 12 bits per pixel
-              int r = 0,g = 0,b = 0;
-              int r1 = 0,g1 = 0,b1 = 0;
-              if((index < imgsize)&(index+1 < imgsize)){
-                r  = image->comps[0].data[index];
-                g  = image->comps[1].data[index];
-                b  = image->comps[2].data[index];
-                r1 = image->comps[0].data[index+1];
-                g1 = image->comps[1].data[index+1];
-                b1 = image->comps[2].data[index+1];
-                if (image->comps[0].sgnd){
-                  r  += adjust;
-                  g  += adjust;
-                  b  += adjust;
-                  r1 += adjust;
-                  g1 += adjust;
-                  b1 += adjust;
-                }
-                dat8[i+0] = (r >> 4);
-                if(i+1 <ssize) dat8[i+1] = ((r & 0x0f) << 4 )|((g >> 8)& 0x0f); else break;
-                if(i+2 <ssize) dat8[i+2] = g ;      else break;
-                if(i+3 <ssize) dat8[i+3] = (b >> 4);  else break;
-                if(i+4 <ssize) dat8[i+4] = ((b & 0x0f) << 4 )|((r1 >> 8)& 0x0f);else break;
-                if(i+5 <ssize) dat8[i+5] = r1;      else break;
-                if(i+6 <ssize) dat8[i+6] = (g1 >> 4);  else break;
-                if(i+7 <ssize) dat8[i+7] = ((g1 & 0x0f)<< 4 )|((b1 >> 8)& 0x0f);else break;
-                if(i+8 <ssize) dat8[i+8] = b1;      else break;
-                index+=2;
-              }else
-                break;
-            }
-          }
-        }else if (image->comps[0].prec == 16){
-          for (i=0 ; i<ssize-5 ; i+=6) {  // 16 bits per pixel
-            int r = 0,g = 0,b = 0;
-            if(index < imgsize){
-              r = image->comps[0].data[index];
-              g = image->comps[1].data[index];
-              b = image->comps[2].data[index];
-              if (image->comps[0].sgnd){
-              r += adjust;
-              g += adjust;
-              b += adjust;
-              }
-              dat8[i+0] =  r;//LSB
-              dat8[i+1] = (r >> 8);//MSB
-              dat8[i+2] =  g;
-              dat8[i+3] = (g >> 8);
-              dat8[i+4] =  b;
-              dat8[i+5] = (b >> 8);
-              index++;
-              last_i = i+6;
-            }else
-              break;
-          }
-          if(last_i < ssize){
-            for (i=0 ; i<ssize ; i+=6) {  // 16 bits per pixel
-              int r = 0,g = 0,b = 0;
-              if(index < imgsize){
-                r = image->comps[0].data[index];
-                g = image->comps[1].data[index];
-                b = image->comps[2].data[index];
-                if (image->comps[0].sgnd){
-                  r += adjust;
-                  g += adjust;
-                  b += adjust;
-                }
-                dat8[i+0] =  r;//LSB
-                if(i+1 <ssize) dat8[i+1] = (r >> 8);else break;//MSB
-                if(i+2 <ssize) dat8[i+2] =  g;    else break;
-                if(i+3 <ssize) dat8[i+3] = (g >> 8);else break;
-                if(i+4 <ssize) dat8[i+4] =  b;    else break;
-                if(i+5 <ssize) dat8[i+5] = (b >> 8);else break;
-                index++;
-              }else
-                break;
-            }
-          }
-        }else{
-          fprintf(stderr,"Bits=%d, Only 8,12,16 bits implemented\n",image->comps[0].prec);
-          fprintf(stderr,"Aborting\n");
-          return 1;
-        }
-        TIFFWriteEncodedStrip(tif, strip, buf, strip_size);
-      }
-      _TIFFfree(buf);
-      TIFFClose(tif);
-    }else if (image->numcomps == 1){
-      /* -->> -->> -->>
-      Black and White
-      <<-- <<-- <<-- */
-
-      tif = TIFFOpen(outfile, "wb");
-      if (!tif) {
-        fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
-        return 1;
-      }
-
-      width  = image->comps[0].w;
-      height  = image->comps[0].h;
-      imgsize = width * height;
-      bps    = image->comps[0].prec;
-
-      /* Set tags */
-      TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
-      TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
-      TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
-      TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
-      TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
-      TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
-      TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
-      TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
-
-      /* Get a buffer for the data */
-      strip_size = TIFFStripSize(tif);
-      buf = _TIFFmalloc(strip_size);
-      index = 0;
-      for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-        unsigned char *dat8;
-        int i;
-        dat8 = (unsigned char*)buf;
-        if (image->comps[0].prec == 8){
-          for (i=0; i<TIFFStripSize(tif); i+=1) {  // 8 bits per pixel
-            if(index < imgsize){
-              int r = 0;
-              r = image->comps[0].data[index];
-              if (image->comps[0].sgnd){
-                r  += adjust;
-              }
-              dat8[i+0] = r;
-              index++;
-            }else
-              break;
-          }
-        }else if (image->comps[0].prec == 12){
-          for (i = 0; i<TIFFStripSize(tif); i+=3) {  // 12 bits per pixel
-            if(index < imgsize){
-              int r = 0, r1 = 0;
-              r  = image->comps[0].data[index];
-              r1 = image->comps[0].data[index+1];
-              if (image->comps[0].sgnd){
-                r  += adjust;
-                r1 += adjust;
-              }
-              dat8[i+0] = (r >> 4);
-              dat8[i+1] = ((r & 0x0f) << 4 )|((r1 >> 8)& 0x0f);
-              dat8[i+2] = r1 ;
-              index+=2;
-            }else
-              break;
-          }
-        }else if (image->comps[0].prec == 16){
-          for (i=0; i<TIFFStripSize(tif); i+=2) {  // 16 bits per pixel
-            if(index < imgsize){
-              int r = 0;
-              r = image->comps[0].data[index];
-              if (image->comps[0].sgnd){
-                r  += adjust;
-              }
-              dat8[i+0] = r;
-              dat8[i+1] = r >> 8;
-              index++;
-            }else
-              break;
-          }
-        }else{
-          fprintf(stderr,"TIFF file creation. Bits=%d, Only 8,12,16 bits implemented\n",image->comps[0].prec);
-          fprintf(stderr,"Aborting\n");
-          return 1;
-        }
-        TIFFWriteEncodedStrip(tif, strip, buf, strip_size);
-      }
-      _TIFFfree(buf);
-      TIFFClose(tif);
-    }else{
-      fprintf(stderr,"TIFF file creation. Bad color format. Only RGB & Grayscale has been implemented\n");
-      fprintf(stderr,"Aborting\n");
-      return 1;
-    }
-    return 0;
-}
-
-opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
-{
-  int subsampling_dx = parameters->subsampling_dx;
-  int subsampling_dy = parameters->subsampling_dy;
-  TIFF *tif;
-  tiff_infoheader_t Info;
-  tdata_t buf;
-  tstrip_t strip;
-  tsize_t strip_size;
-  int j, numcomps, w, h,index;
-  OPJ_COLOR_SPACE color_space;
-  opj_image_cmptparm_t cmptparm[3];
-  opj_image_t * image = NULL;
-  int imgsize = 0;
-
-  tif = TIFFOpen(filename, "r");
-
-  if (!tif) {
-    fprintf(stderr, "Failed to open %s for reading\n", filename);
-    return 0;
-  }
-
-  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &Info.tiWidth);
-  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &Info.tiHeight);
-  TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &Info.tiBps);
-  TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &Info.tiSf);
-  TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &Info.tiSpp);
-  Info.tiPhoto = 0;
-  TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &Info.tiPhoto);
-  TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &Info.tiPC);
-  w= Info.tiWidth;
-  h= Info.tiHeight;
-
-  if (Info.tiPhoto == 2) {
-    /* -->> -->> -->>
-    RGB color
-    <<-- <<-- <<-- */
-
-    numcomps = 3;
-    color_space = CLRSPC_SRGB;
-    /* initialize image components*/
-    memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-    for(j = 0; j < numcomps; j++) {
-      if (parameters->cp_cinema) {
-        cmptparm[j].prec = 12;
-        cmptparm[j].bpp = 12;
-      }else{
-        cmptparm[j].prec = Info.tiBps;
-        cmptparm[j].bpp = Info.tiBps;
-      }
-      cmptparm[j].sgnd = 0;
-      cmptparm[j].dx = subsampling_dx;
-      cmptparm[j].dy = subsampling_dy;
-      cmptparm[j].w = w;
-      cmptparm[j].h = h;
-    }
-    /* create the image*/
-    image = opj_image_create(numcomps, &cmptparm[0], color_space);
-    if(!image) {
-      TIFFClose(tif);
-      return NULL;
-    }
-
-    /* set image offset and reference grid */
-    image->x0 = parameters->image_offset_x0;
-    image->y0 = parameters->image_offset_y0;
-    image->x1 =  !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-    image->y1 =  !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-    buf = _TIFFmalloc(TIFFStripSize(tif));
-    strip_size=0;
-    strip_size=TIFFStripSize(tif);
-    index = 0;
-    imgsize = image->comps[0].w * image->comps[0].h ;
-    /* Read the Image components*/
-    for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-      unsigned char *dat8;
-      int i, ssize;
-      ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
-      dat8 = (unsigned char*)buf;
-
-      if (Info.tiBps==12){
-        for (i=0; i<ssize; i+=9) {  /*12 bits per pixel*/
-          if((index < imgsize)&(index+1 < imgsize)){
-            image->comps[0].data[index]   = ( dat8[i+0]<<4 )    |(dat8[i+1]>>4);
-            image->comps[1].data[index]   = ((dat8[i+1]& 0x0f)<< 8)  | dat8[i+2];
-            image->comps[2].data[index]   = ( dat8[i+3]<<4)      |(dat8[i+4]>>4);
-            image->comps[0].data[index+1] = ((dat8[i+4]& 0x0f)<< 8)  | dat8[i+5];
-            image->comps[1].data[index+1] = ( dat8[i+6] <<4)    |(dat8[i+7]>>4);
-            image->comps[2].data[index+1] = ((dat8[i+7]& 0x0f)<< 8)  | dat8[i+8];
-            index+=2;
-          }else
-            break;
-        }
-      }
-      else if( Info.tiBps==16){
-        for (i=0; i<ssize; i+=6) {  /* 16 bits per pixel */
-          if(index < imgsize){
-            image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0]; // R
-            image->comps[1].data[index] = ( dat8[i+3] << 8 ) | dat8[i+2]; // G
-            image->comps[2].data[index] = ( dat8[i+5] << 8 ) | dat8[i+4]; // B
-            if(parameters->cp_cinema){/* Rounding to 12 bits*/
-              image->comps[0].data[index] = (image->comps[0].data[index] + 0x08) >> 4 ;
-              image->comps[1].data[index] = (image->comps[1].data[index] + 0x08) >> 4 ;
-              image->comps[2].data[index] = (image->comps[2].data[index] + 0x08) >> 4 ;
-            }
-            index++;
-          }else
-            break;
-        }
-      }
-      else if ( Info.tiBps==8){
-        for (i=0; i<ssize; i+=3) {  /* 8 bits per pixel */
-          if(index < imgsize){
-            image->comps[0].data[index] = dat8[i+0];// R
-            image->comps[1].data[index] = dat8[i+1];// G
-            image->comps[2].data[index] = dat8[i+2];// B
-            if(parameters->cp_cinema){/* Rounding to 12 bits*/
-              image->comps[0].data[index] = image->comps[0].data[index] << 4 ;
-              image->comps[1].data[index] = image->comps[1].data[index] << 4 ;
-              image->comps[2].data[index] = image->comps[2].data[index] << 4 ;
-            }
-            index++;
-          }else
-            break;
-        }
-      }
-      else{
-        fprintf(stderr,"TIFF file creation. Bits=%d, Only 8,12,16 bits implemented\n",Info.tiBps);
-        fprintf(stderr,"Aborting\n");
-        return NULL;
-      }
-    }
-
-    _TIFFfree(buf);
-    TIFFClose(tif);
-  }else if(Info.tiPhoto == 1) {
-    /* -->> -->> -->>
-    Black and White
-    <<-- <<-- <<-- */
-
-    numcomps = 1;
-    color_space = CLRSPC_GRAY;
-    /* initialize image components*/
-    memset(&cmptparm[0], 0, sizeof(opj_image_cmptparm_t));
-    cmptparm[0].prec = Info.tiBps;
-    cmptparm[0].bpp = Info.tiBps;
-    cmptparm[0].sgnd = 0;
-    cmptparm[0].dx = subsampling_dx;
-    cmptparm[0].dy = subsampling_dy;
-    cmptparm[0].w = w;
-    cmptparm[0].h = h;
-
-    /* create the image*/
-    image = opj_image_create(numcomps, &cmptparm[0], color_space);
-    if(!image) {
-      TIFFClose(tif);
-      return NULL;
-    }
-    /* set image offset and reference grid */
-    image->x0 = parameters->image_offset_x0;
-    image->y0 = parameters->image_offset_y0;
-    image->x1 =  !image->x0 ? (w - 1) * subsampling_dx + 1 : image->x0 + (w - 1) * subsampling_dx + 1;
-    image->y1 =  !image->y0 ? (h - 1) * subsampling_dy + 1 : image->y0 + (h - 1) * subsampling_dy + 1;
-
-    buf = _TIFFmalloc(TIFFStripSize(tif));
-    strip_size = 0;
-    strip_size = TIFFStripSize(tif);
-    index = 0;
-    imgsize = image->comps[0].w * image->comps[0].h ;
-    /* Read the Image components*/
-    for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
-      unsigned char *dat8;
-      int i, ssize;
-      ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
-      dat8 = (unsigned char*)buf;
-
-      if (Info.tiBps==12){
-        for (i=0; i<ssize; i+=3) {  /* 12 bits per pixel*/
-          if(index < imgsize){
-            image->comps[0].data[index]   = ( dat8[i+0]<<4 )    |(dat8[i+1]>>4) ;
-            image->comps[0].data[index+1] = ((dat8[i+1]& 0x0f)<< 8)  | dat8[i+2];
-            index+=2;
-          }else
-            break;
-        }
-      }
-      else if( Info.tiBps==16){
-        for (i=0; i<ssize; i+=2) {  /* 16 bits per pixel */
-          if(index < imgsize){
-            image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0];
-            index++;
-          }else
-            break;
-        }
-      }
-      else if ( Info.tiBps==8){
-        for (i=0; i<ssize; i+=1) {  /* 8 bits per pixel */
-          if(index < imgsize){
-            image->comps[0].data[index] = dat8[i+0];
-            index++;
-          }else
-            break;
-        }
-      }
-      else{
-        fprintf(stderr,"TIFF file creation. Bits=%d, Only 8,12,16 bits implemented\n",Info.tiBps);
-        fprintf(stderr,"Aborting\n");
-        return NULL;
-      }
-    }
-
-    _TIFFfree(buf);
-    TIFFClose(tif);
-  }else{
-    fprintf(stderr,"TIFF file creation. Bad color format. Only RGB & Grayscale has been implemented\n");
-    fprintf(stderr,"Aborting\n");
-    return NULL;
-  }
-  return image;
-}
-
-/* -->> -->> -->> -->>
-
-  RAW IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
-  int subsampling_dx = parameters->subsampling_dx;
-  int subsampling_dy = parameters->subsampling_dy;
-
-  FILE *f = NULL;
-  int i, compno, numcomps, w, h;
-  OPJ_COLOR_SPACE color_space;
-  opj_image_cmptparm_t *cmptparm;
-  opj_image_t * image = NULL;
-  unsigned short ch;
-
-  if((! (raw_cp->rawWidth & raw_cp->rawHeight & raw_cp->rawComp & raw_cp->rawBitDepth)) == 0)
-  {
-    fprintf(stderr,"\nError: invalid raw image parameters\n");
-    fprintf(stderr,"Please use the Format option -F:\n");
-    fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-    fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-    fprintf(stderr,"Aborting\n");
-    return NULL;
-  }
-
-  f = fopen(filename, "rb");
-  if (!f) {
-    fprintf(stderr, "Failed to open %s for reading !!\n", filename);
-    fprintf(stderr,"Aborting\n");
-    return NULL;
-  }
-  numcomps = raw_cp->rawComp;
-  color_space = CLRSPC_SRGB;
-  w = raw_cp->rawWidth;
-  h = raw_cp->rawHeight;
-  cmptparm = (opj_image_cmptparm_t*) malloc(numcomps * sizeof(opj_image_cmptparm_t));
-
-  /* initialize image components */
-  memset(&cmptparm[0], 0, numcomps * sizeof(opj_image_cmptparm_t));
-  for(i = 0; i < numcomps; i++) {
-    cmptparm[i].prec = raw_cp->rawBitDepth;
-    cmptparm[i].bpp = raw_cp->rawBitDepth;
-    cmptparm[i].sgnd = raw_cp->rawSigned;
-    cmptparm[i].dx = subsampling_dx;
-    cmptparm[i].dy = subsampling_dy;
-    cmptparm[i].w = w;
-    cmptparm[i].h = h;
-  }
-  /* create the image */
-  image = opj_image_create(numcomps, &cmptparm[0], color_space);
-  if(!image) {
-    fclose(f);
-    return NULL;
-  }
-  /* set image offset and reference grid */
-  image->x0 = parameters->image_offset_x0;
-  image->y0 = parameters->image_offset_y0;
-  image->x1 = parameters->image_offset_x0 + (w - 1) *  subsampling_dx + 1;
-  image->y1 = parameters->image_offset_y0 + (h - 1) *  subsampling_dy + 1;
-
-  if(raw_cp->rawBitDepth <= 8)
-  {
-    unsigned char value = 0;
-    for(compno = 0; compno < numcomps; compno++) {
-      for (i = 0; i < w * h; i++) {
-        if (!fread(&value, 1, 1, f)) {
-          fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
-          return NULL;
-        }
-        image->comps[compno].data[i] = raw_cp->rawSigned?(char)value:value;
-      }
-    }
-  }
-  else if(raw_cp->rawBitDepth <= 16)
-  {
-    unsigned short value;
-    for(compno = 0; compno < numcomps; compno++) {
-      for (i = 0; i < w * h; i++) {
-        unsigned char temp;
-        if (!fread(&temp, 1, 1, f)) {
-          fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
-          return NULL;
-        }
-        value = temp << 8;
-        if (!fread(&temp, 1, 1, f)) {
-          fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
-          return NULL;
-        }
-        value += temp;
-        image->comps[compno].data[i] = raw_cp->rawSigned?(short)value:value;
-      }
-    }
-  }
-  else {
-    fprintf(stderr,"OpenJPEG cannot encode raw components with bit depth higher than 16 bits.\n");
-    return NULL;
-  }
-
-  if (fread(&ch, 1, 1, f)) {
-    fprintf(stderr,"Warning. End of raw file not reached... processing anyway\n");
-  }
-  fclose(f);
-
-  return image;
-}
-
-int imagetoraw(opj_image_t * image, const char *outfile)
-{
-  FILE *rawFile = NULL;
-  unsigned int compno;
-  int w, h;
-  int line, row;
-  int *ptr;
-
-  if((image->numcomps * image->x1 * image->y1) == 0)
-  {
-    fprintf(stderr,"\nError: invalid raw image parameters\n");
-    return 1;
-  }
-
-  rawFile = fopen(outfile, "wb");
-  if (!rawFile) {
-    fprintf(stderr, "Failed to open %s for writing !!\n", outfile);
-    return 1;
-  }
-
-  fprintf(stdout,"Raw image characteristics: %d components\n", image->numcomps);
-
-  for(compno = 0; compno < image->numcomps; compno++)
-  {
-    fprintf(stdout,"Component %d characteristics: %dx%dx%d %s\n", compno, image->comps[compno].w,
-      image->comps[compno].h, image->comps[compno].prec, image->comps[compno].sgnd==1 ? "signed": "unsigned");
-
-    w = image->comps[compno].w;
-    h = image->comps[compno].h;
-
-    if(image->comps[compno].prec <= 8)
-    {
-      if(image->comps[compno].sgnd == 1)
-      {
-        signed char curr;
-        int mask = (1 << image->comps[compno].prec) - 1;
-        ptr = image->comps[compno].data;
-        for (line = 0; line < h; line++) {
-          for(row = 0; row < w; row++)  {
-            curr = (signed char) (*ptr & mask);
-            fwrite(&curr, sizeof(signed char), 1, rawFile);
-            ptr++;
-          }
-        }
-      }
-      else if(image->comps[compno].sgnd == 0)
-      {
-        unsigned char curr;
-        int mask = (1 << image->comps[compno].prec) - 1;
-        ptr = image->comps[compno].data;
-        for (line = 0; line < h; line++) {
-          for(row = 0; row < w; row++)  {
-            curr = (unsigned char) (*ptr & mask);
-            fwrite(&curr, sizeof(unsigned char), 1, rawFile);
-            ptr++;
-          }
-        }
-      }
-    }
-    else if(image->comps[compno].prec <= 16)
-    {
-      if(image->comps[compno].sgnd == 1)
-      {
-        signed short int curr;
-        int mask = (1 << image->comps[compno].prec) - 1;
-        ptr = image->comps[compno].data;
-        for (line = 0; line < h; line++) {
-          for(row = 0; row < w; row++)  {
-            unsigned char temp;
-            curr = (signed short int) (*ptr & mask);
-            temp = curr >> 8;
-            fwrite(&temp, 1, 1, rawFile);
-            temp = curr;
-            fwrite(&temp, 1, 1, rawFile);
-            ptr++;
-          }
-        }
-      }
-      else if(image->comps[compno].sgnd == 0)
-      {
-        unsigned short int curr;
-        int mask = (1 << image->comps[compno].prec) - 1;
-        ptr = image->comps[compno].data;
-        for (line = 0; line < h; line++) {
-          for(row = 0; row < w; row++)  {
-            unsigned char temp;
-            curr = (unsigned short int) (*ptr & mask);
-            temp = curr >> 8;
-            fwrite(&temp, 1, 1, rawFile);
-            temp = curr;
-            fwrite(&temp, 1, 1, rawFile);
-            ptr++;
-          }
-        }
-      }
-    }
-    else if (image->comps[compno].prec <= 32)
-    {
-      fprintf(stderr,"More than 16 bits per component no handled yet\n");
-      return 1;
-    }
-    else
-    {
-      fprintf(stderr,"Error: invalid precision: %d\n", image->comps[compno].prec);
-      return 1;
-    }
-  }
-  fclose(rawFile);
-  return 0;
-}
-
-opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
-#ifdef WIN32
-{
-  printf("Error. PNG format is not yet handled under windows\n");
-  return NULL;
-}
-#else
-{
-    png_bytep row;
-    png_structp png;
-    png_infop info;
-    double gamma, display_exponent;
-    int bit_depth, interlace_type, compression_type, filter_type;
-    int unit, pass, nr_passes;
-    png_uint_32 resx, resy;
-    unsigned int i, max, src_w;
-    png_uint_32 width, height;
-    int color_type, has_alpha;
-    unsigned char *png_buf, *s;
-    FILE *reader;
-/* j2k: */
-    opj_image_t *image;
-    opj_image_cmptparm_t cmptparm[4];
-    int sub_dx, sub_dy;
-    unsigned int nr_comp;
-    int *r, *g, *b, *a;
-
-    if ((reader = fopen(read_idf, "rb")) == NULL) {
-  fprintf(stderr, "pngtoimage: can not open %s\n", read_idf);
-  return NULL;
-    }
-    nr_passes = 0;
-    png_buf = NULL;
-
-/* libpng-VERSION/example.c:
- * PC : screen_gamma = 2.2;
- * Mac: screen_gamma = 1.7 or 1.0;
-*/
-    display_exponent = 2.2;
-
-    if ((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
-              NULL, NULL, NULL)) == NULL)
-  goto fin;
-    if ((info = png_create_info_struct(png)) == NULL)
-  goto fin;
-
-    if (setjmp(png_jmpbuf(png)))
-  goto fin;
-
-    png_init_io(png, reader);
-    png_read_info(png, info);
-
-    png_get_IHDR(png, info, &width, &height,
-     &bit_depth, &color_type, &interlace_type,
-     &compression_type, &filter_type);
-
-    if (color_type == PNG_COLOR_TYPE_PALETTE)
-  png_set_expand(png);
-    else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
-  png_set_expand(png);
-
-    if (png_get_valid(png, info, PNG_INFO_tRNS))
-  png_set_expand(png);
-
-    if (bit_depth == 16)
-  png_set_strip_16(png);
-
-/* GRAY => RGB; GRAY_ALPHA => RGBA
-*/
-    if (color_type == PNG_COLOR_TYPE_GRAY
-  || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
-  png_set_gray_to_rgb(png);
-  color_type =
-      (color_type == PNG_COLOR_TYPE_GRAY ? PNG_COLOR_TYPE_RGB :
-       PNG_COLOR_TYPE_RGB_ALPHA);
-    }
-    if (!png_get_gAMA(png, info, &gamma))
-  gamma = 0.45455;
-
-    png_set_gamma(png, display_exponent, gamma);
-
-    nr_passes = png_set_interlace_handling(png);
-
-    png_read_update_info(png, info);
-
-    png_get_pHYs(png, info, &resx, &resy, &unit);
-
-    color_type = png_get_color_type(png, info);
-
-    has_alpha = (color_type == PNG_COLOR_TYPE_RGB_ALPHA);
-
-    if (has_alpha)
-  nr_comp = 4;
-    else
-  nr_comp = 3;
-
-    src_w = width * nr_comp;
-    png_buf = (unsigned char *) malloc(src_w * height);
-
-    if (nr_passes == 0)
-  nr_passes = 1;
-
-    for (pass = 0; pass < nr_passes; pass++) {
-  s = png_buf;
-
-  for (i = 0; i < height; i++) {
-/* libpng.3:
- * If you want the "sparkle" effect, just call png_read_rows() as
- * normal, with the third parameter NULL.
-*/
-      png_read_rows(png, &s, NULL, 1);
-
-      s += src_w;
-  }
-    }
-    memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t));
-
-    sub_dx = params->subsampling_dx;
-    sub_dy = params->subsampling_dy;
-
-    for (i = 0; i < nr_comp; ++i) {
-  cmptparm[i].prec = 8;
-  cmptparm[i].bpp = 8;
-  cmptparm[i].sgnd = 0;
-  cmptparm[i].dx = sub_dx;
-  cmptparm[i].dy = sub_dy;
-  cmptparm[i].w = width;
-  cmptparm[i].h = height;
-    }
-
-    image = opj_image_create(nr_comp, &cmptparm[0], CLRSPC_SRGB);
-
-    if (image == NULL)
-  goto fin;
-
-    image->x0 = params->image_offset_x0;
-    image->y0 = params->image_offset_y0;
-    image->x1 =
-  params->image_offset_x0 + (width - 1) * sub_dx + 1 + image->x0;
-    image->y1 =
-  params->image_offset_y0 + (height - 1) * sub_dy + 1 + image->y0;
-
-    r = image->comps[0].data;
-    g = image->comps[1].data;
-    b = image->comps[2].data;
-    a = image->comps[3].data;
-    s = png_buf;
-
-    max = width * height;
-
-    for (i = 0; i < max; ++i) {
-  *r++ = *s++;
-  *g++ = *s++;
-  *b++ = *s++;
-
-  if (has_alpha)
-      *a++ = *s++;
-    }
-
-  fin:
-    if (png)
-  png_destroy_read_struct(&png, &info, NULL);
-    if (png_buf)
-  free(png_buf);
-
-    fclose(reader);
-
-    return image;
-
-}        /* pngtoimage() */
-#endif
-
-int imagetopng(opj_image_t * image, const char *write_idf)
-#ifdef WIN32
-{
-  printf("Error. PNG format is not yet handled under windows\n");
-  return -1;
-}
-#else
-{
-    FILE *writer;
-    png_structp png_ptr;
-    png_infop info_ptr;
-    int *rs, *gs, *bs, *as;
-    unsigned char *row_buf, *d;
-    int fails, mono, graya, rgb, rgba;
-    int width, height, nr_colors, color_type;
-    int bit_depth, adjust, x, y;
-    png_color_8 sig_bit;
-
-    writer = fopen(write_idf, "wb");
-
-    if (writer == NULL)
-  return 1;
-
-    info_ptr = NULL;
-    fails = 1;
-
-/* Create and initialize the png_struct with the desired error handler
- * functions.  If you want to use the default stderr and longjump method,
- * you can supply NULL for the last three parameters.  We also check that
- * the library version is compatible with the one used at compile time,
- * in case we are using dynamically linked libraries.  REQUIRED.
-*/
-    png_ptr =
-  png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
-
-    if (png_ptr == NULL)
-  goto fin;
-
-/* Allocate/initialize the image information data.  REQUIRED
-*/
-    info_ptr = png_create_info_struct(png_ptr);
-
-    if (info_ptr == NULL)
-  goto fin;
-
-/* Set error handling.  REQUIRED if you are not supplying your own
- * error handling functions in the png_create_write_struct() call.
-*/
-    if (setjmp(png_jmpbuf(png_ptr)))
-  goto fin;
-
-/* I/O initialization functions is REQUIRED
-*/
-    png_init_io(png_ptr, writer);
-
-/* Set the image information here.  Width and height are up to 2^31,
- * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
- * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
- * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
- * or PNG_COLOR_TYPE_RGB_ALPHA.  interlace is either PNG_INTERLACE_NONE or
- * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
- * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
- * REQUIRED
-*/
-    png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
-
-    mono = graya = rgb = rgba = adjust = 0;
-
-    nr_colors = image->numcomps;
-    width = image->comps[0].w;
-    height = image->comps[0].h;
-    rs = image->comps[0].data;
-
-    if (nr_colors == 2) {
-  graya = 1;
-  color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
-  sig_bit.gray = image->comps[0].prec;
-  bit_depth = image->comps[0].prec;
-  as = image->comps[1].data;
-    } else if (nr_colors == 3) {
-  rgb = 1;
-  color_type = PNG_COLOR_TYPE_RGB;
-  sig_bit.red = image->comps[0].prec;
-  sig_bit.green = image->comps[1].prec;
-  sig_bit.blue = image->comps[2].prec;
-  bit_depth = image->comps[0].prec;
-  gs = image->comps[1].data;
-  bs = image->comps[2].data;
-  if (image->comps[0].sgnd)
-      adjust = 1 << (image->comps[0].prec - 1);
-    } else if (nr_colors == 4) {
-  rgb = rgba = 1;
-  color_type = PNG_COLOR_TYPE_RGB_ALPHA;
-  sig_bit.red = image->comps[0].prec;
-  sig_bit.green = image->comps[1].prec;
-  sig_bit.blue = image->comps[2].prec;
-  sig_bit.alpha = image->comps[3].prec;
-  bit_depth = image->comps[0].prec;
-  gs = image->comps[1].data;
-  bs = image->comps[2].data;
-  as = image->comps[3].data;
-  if (image->comps[0].sgnd)
-      adjust = 1 << (image->comps[0].prec - 1);
-    } else {
-  mono = 1;
-  color_type = PNG_COLOR_TYPE_GRAY;
-  sig_bit.gray = image->comps[0].prec;
-  bit_depth = image->comps[0].prec;
-    }
-    png_set_sBIT(png_ptr, info_ptr, &sig_bit);
-
-    png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
-     color_type,
-     PNG_INTERLACE_NONE,
-     PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
-#ifdef HIDDEN_CODE
-/* Optional gamma chunk is strongly suggested if you have any guess
- * as to the correct gamma of the image.
-*/
-
-    if (gamma > 0.0) {
-  png_set_gAMA(png_ptr, info_ptr, gamma);
-    }
-#endif        /* HIDDEN_CODE */
-#ifdef HIDDEN_CODE
-    if (have_bg) {
-  png_color_16 background;
-
-  background.red = bg_red;
-  background.green = bg_green;
-  background.blue = bg_blue;
-
-  png_set_bKGD(png_ptr, info_ptr, &background);
-    }
-#endif        /* HIDDEN_CODE */
-    png_write_info(png_ptr, info_ptr);
-
-    png_set_packing(png_ptr);
-
-    row_buf = (unsigned char *) malloc(width * nr_colors);
-
-    for (y = 0; y < height; ++y) {
-  d = row_buf;
-
-  for (x = 0; x < width; ++x) {
-      if (mono) {
-    *d++ = (unsigned char) *rs++;
-      }
-      if (graya) {
-    *d++ = (unsigned char) *rs++;
-    *d++ = (unsigned char) *as++;
-      } else if (rgb) {
-    *d++ = (unsigned char) (*rs++ + adjust);
-    *d++ = (unsigned char) (*gs++ + adjust);
-    *d++ = (unsigned char) (*bs++ + adjust);
-
-    if (rgba)
-        *d++ = (unsigned char) (*as++ + adjust);
-      }
-  }      /* for(x) */
-
-  png_write_row(png_ptr, row_buf);
-
-    }        /* for(y) */
-
-    png_write_end(png_ptr, info_ptr);
-
-    fails = 0;
-
-  fin:
-
-    if (png_ptr) {
-  png_destroy_write_struct(&png_ptr, &info_ptr);
-    }
-    fclose(writer);
-
-    return fails;
-}
-#endif
diff --git a/Utilities/gdcmopenjpeg-v2/codec/convert.h b/Utilities/gdcmopenjpeg-v2/codec/convert.h
deleted file mode 100644
index 7d8670a..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/convert.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __J2K_CONVERT_H
-#define __J2K_CONVERT_H
-
-/**@name RAW image encoding parameters */
-/*@{*/
-typedef struct raw_cparameters {
-  /** width of the raw image */
-  int rawWidth;
-  /** height of the raw image */
-  int rawHeight;
-  /** components of the raw image */
-  int rawComp;
-  /** bit depth of the raw image */
-  int rawBitDepth;
-  /** signed/unsigned raw image */
-  bool rawSigned;
-  /*@}*/
-} raw_cparameters_t;
-
-/* TGA conversion */
-opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetotga(opj_image_t * image, const char *outfile);
-
-/* BMP conversion */
-opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetobmp(opj_image_t *image, const char *outfile);
-
-/* TIFF to image conversion*/
-opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetotif(opj_image_t *image, const char *outfile);
-/**
-Load a single image component encoded in PGX file format
- at param filename Name of the PGX file to load
- at param parameters *List ?*
- at return Returns a greyscale image if successful, returns NULL otherwise
-*/
-opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetopgx(opj_image_t *image, const char *outfile);
-
-opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
-int imagetopnm(opj_image_t *image, const char *outfile);
-
-/* RAW conversion */
-int imagetoraw(opj_image_t * image, const char *outfile);
-opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
-
-#endif /* __J2K_CONVERT_H */
-
diff --git a/Utilities/gdcmopenjpeg-v2/codec/dirent.h b/Utilities/gdcmopenjpeg-v2/codec/dirent.h
deleted file mode 100644
index b0539fb..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/dirent.h
+++ /dev/null
@@ -1,677 +0,0 @@
-
-/*
- * uce-dirent.h - operating system independent dirent implementation
- *
- * Copyright (C) 1998-2002  Toni Ronkko
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * ``Software''), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * May 28 1998, Toni Ronkko <tronkko at messi.uku.fi>
- *
- * $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
- *
- * $Log: uce-dirent.h,v $
- * Revision 1.7  2002/05/13 10:48:35  tr
- * embedded some source code directly to the header so that no source
- * modules need to be included in the MS Visual C project using the
- * interface, removed all the dependencies to other headers of the `uce'
- * library so that the header can be made public
- *
- * Revision 1.6  2002/04/12 16:22:04  tr
- * Unified Compiling Environment (UCE) replaced `std' library
- *
- * Revision 1.5  2001/07/20 16:33:40  tr
- * moved to `std' library and re-named defines accordingly
- *
- * Revision 1.4  2001/07/10 16:47:18  tronkko
- * revised comments
- *
- * Revision 1.3  2001/01/11 13:16:43  tr
- * using ``uce-machine.h'' for finding out defines such as `FREEBSD'
- *
- * Revision 1.2  2000/10/08 16:00:41  tr
- * copy of FreeBSD man page
- *
- * Revision 1.1  2000/07/10 05:53:16  tr
- * Initial revision
- *
- * Revision 1.2  1998/07/19 18:29:14  tr
- * Added error reporting capabilities and some asserts.
- *
- * Revision 1.1  1998/07/04 16:27:51  tr
- * Initial revision
- *
- *
- * MSVC 1.0 scans automatic dependencies incorrectly when your project
- * contains this very header.  The problem is that MSVC cannot handle
- * include directives inside #if..#endif block those are never entered.
- * Since this header ought to compile in many different operating systems,
- * there had to be several conditional blocks that are compiled only in
- * operating systems for what they were designed for.  MSVC 1.0 cannot
- * handle inclusion of sys/dir.h in a part that is compiled only in Apollo
- * operating system.  To fix the problem you need to insert DIR.H into
- * SYSINCL.DAT located in MSVC\BIN directory and restart visual C++.
- * Consult manuals for more informaton about the problem.
- *
- * Since many UNIX systems have dirent.h we assume to have one also.
- * However, if your UNIX system does not have dirent.h you can download one
- * for example at: http://ftp.uni-mannheim.de/ftp/GNU/dirent/dirent.tar.gz.
- * You can also see if you have one of dirent.h, direct.h, dir.h, ndir.h,
- * sys/dir.h and sys/ndir.h somewhere.  Try defining HAVE_DIRENT_H,
- * HAVE_DIRECT_H, HAVE_DIR_H, HAVE_NDIR_H, HAVE_SYS_DIR_H and
- * HAVE_SYS_NDIR_H according to the files found.
- */
-#ifndef DIRENT_H
-#define DIRENT_H
-#define DIRENT_H_INCLUDED
-
-/* find out platform */
-#if defined(MSDOS)                             /* MS-DOS */
-#elif defined(__MSDOS__)                       /* Turbo C/Borland */
-# define MSDOS
-#elif defined(__DOS__)                         /* Watcom */
-# define MSDOS
-#endif
-
-#if defined(WIN32)                             /* MS-Windows */
-#elif defined(__NT__)                          /* Watcom */
-# define WIN32
-#elif defined(_WIN32)                          /* Microsoft */
-# define WIN32
-#elif defined(__WIN32__)                       /* Borland */
-# define WIN32
-#endif
-
-/*
- * See what kind of dirent interface we have unless autoconf has already
- * determinated that.
- */
-#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
-# if defined(_MSC_VER)                         /* Microsoft C/C++ */
-    /* no dirent.h */
-# elif defined(__BORLANDC__)                   /* Borland C/C++ */
-#   define HAVE_DIRENT_H
-#   define VOID_CLOSEDIR
-# elif defined(__TURBOC__)                     /* Borland Turbo C */
-    /* no dirent.h */
-# elif defined(__WATCOMC__)                    /* Watcom C/C++ */
-#   define HAVE_DIRECT_H
-# elif defined(__apollo)                       /* Apollo */
-#   define HAVE_SYS_DIR_H
-# elif defined(__hpux)                         /* HP-UX */
-#   define HAVE_DIRENT_H
-# elif (defined(__alpha) || defined(__alpha__)) && !defined(__linux__)  /* Alpha OSF1 */
-#   error "not implemented"
-# elif defined(__sgi)                          /* Silicon Graphics */
-#   define HAVE_DIRENT_H
-# elif defined(sun) || defined(_sun)           /* Sun Solaris */
-#   define HAVE_DIRENT_H
-# elif defined(__FreeBSD__)                    /* FreeBSD */
-#   define HAVE_DIRENT_H
-# elif defined(__linux__)                      /* Linux */
-#   define HAVE_DIRENT_H
-# elif defined(__GNUC__)                       /* GNU C/C++ */
-#   define HAVE_DIRENT_H
-# else
-#   error "not implemented"
-# endif
-#endif
-
-/* include proper interface headers */
-#if defined(HAVE_DIRENT_H)
-# include <dirent.h>
-# ifdef FREEBSD
-#   define NAMLEN(dp) ((int)((dp)->d_namlen))
-# else
-#   define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
-# endif
-
-#elif defined(HAVE_NDIR_H)
-# include <ndir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_DIRECT_H)
-# include <direct.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_DIR_H)
-# include <dir.h>
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(HAVE_SYS_DIR_H)
-# include <sys/types.h>
-# include <sys/dir.h>
-# ifndef dirent
-#   define dirent direct
-# endif
-# define NAMLEN(dp) ((int)((dp)->d_namlen))
-
-#elif defined(MSDOS) || defined(WIN32)
-
-  /* figure out type of underlaying directory interface to be used */
-# if defined(WIN32)
-#   define DIRENT_WIN32_INTERFACE
-# elif defined(MSDOS)
-#   define DIRENT_MSDOS_INTERFACE
-# else
-#   error "missing native dirent interface"
-# endif
-
-  /*** WIN32 specifics ***/
-# if defined(DIRENT_WIN32_INTERFACE)
-#   include <windows.h>
-#   if !defined(DIRENT_MAXNAMLEN)
-#     define DIRENT_MAXNAMLEN (MAX_PATH)
-#   endif
-
-
-  /*** MS-DOS specifics ***/
-# elif defined(DIRENT_MSDOS_INTERFACE)
-#   include <dos.h>
-
-    /* Borland defines file length macros in dir.h */
-#   if defined(__BORLANDC__)
-#     include <dir.h>
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
-#     endif
-#     if !defined(_find_t)
-#       define _find_t find_t
-#     endif
-
-    /* Turbo C defines ffblk structure in dir.h */
-#   elif defined(__TURBOC__)
-#     include <dir.h>
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
-#     endif
-#     define DIRENT_USE_FFBLK
-
-    /* MSVC */
-#   elif defined(_MSC_VER)
-#     if !defined(DIRENT_MAXNAMLEN)
-#       define DIRENT_MAXNAMLEN (12)
-#     endif
-
-    /* Watcom */
-#   elif defined(__WATCOMC__)
-#     if !defined(DIRENT_MAXNAMLEN)
-#       if defined(__OS2__) || defined(__NT__)
-#         define DIRENT_MAXNAMLEN (255)
-#       else
-#         define DIRENT_MAXNAMLEN (12)
-#       endif
-#     endif
-
-#   endif
-# endif
-
-  /*** generic MS-DOS and MS-Windows stuff ***/
-# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
-#   define NAME_MAX DIRENT_MAXNAMLEN
-# endif
-# if NAME_MAX < DIRENT_MAXNAMLEN
-#   error "assertion failed: NAME_MAX >= DIRENT_MAXNAMLEN"
-# endif
-
-
-  /*
-   * Substitute for real dirent structure.  Note that `d_name' field is a
-   * true character array although we have it copied in the implementation
-   * dependent data.  We could save some memory if we had declared `d_name'
-   * as a pointer refering the name within implementation dependent data.
-   * We have not done that since some code may rely on sizeof(d_name) to be
-   * something other than four.  Besides, directory entries are typically so
-   * small that it takes virtually no time to copy them from place to place.
-   */
-  typedef struct dirent {
-    char d_name[NAME_MAX + 1];
-
-    /*** Operating system specific part ***/
-# if defined(DIRENT_WIN32_INTERFACE)       /*WIN32*/
-    WIN32_FIND_DATA data;
-# elif defined(DIRENT_MSDOS_INTERFACE)     /*MSDOS*/
-#   if defined(DIRENT_USE_FFBLK)
-    struct ffblk data;
-#   else
-    struct _find_t data;
-#   endif
-# endif
-  } dirent;
-
-  /* DIR substitute structure containing directory name.  The name is
-   * essential for the operation of ``rewinndir'' function. */
-  typedef struct DIR {
-    char          *dirname;                    /* directory being scanned */
-    dirent        current;                     /* current entry */
-    int           dirent_filled;               /* is current un-processed? */
-
-  /*** Operating system specific part ***/
-#  if defined(DIRENT_WIN32_INTERFACE)
-    HANDLE        search_handle;
-#  elif defined(DIRENT_MSDOS_INTERFACE)
-#  endif
-  } DIR;
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/* supply prototypes for dirent functions */
-static DIR *opendir (const char *dirname);
-static struct dirent *readdir (DIR *dirp);
-static int closedir (DIR *dirp);
-static void rewinddir (DIR *dirp);
-
-/*
- * Implement dirent interface as static functions so that the user does not
- * need to change his project in any way to use dirent function.  With this
- * it is sufficient to include this very header from source modules using
- * dirent functions and the functions will be pulled in automatically.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-
-/* use ffblk instead of _find_t if requested */
-#if defined(DIRENT_USE_FFBLK)
-# define _A_ARCH   (FA_ARCH)
-# define _A_HIDDEN (FA_HIDDEN)
-# define _A_NORMAL (0)
-# define _A_RDONLY (FA_RDONLY)
-# define _A_SUBDIR (FA_DIREC)
-# define _A_SYSTEM (FA_SYSTEM)
-# define _A_VOLID  (FA_LABEL)
-# define _dos_findnext(dest) findnext(dest)
-# define _dos_findfirst(name,flags,dest) findfirst(name,dest,flags)
-#endif
-
-static int _initdir (DIR *p);
-static const char *_getdirname (const struct dirent *dp);
-static void _setdirname (struct DIR *dirp);
-
-/*
- * <function name="opendir">
- * <intro>open directory stream for reading
- * <syntax>DIR *opendir (const char *dirname);
- *
- * <desc>Open named directory stream for read and return pointer to the
- * internal working area that is used for retrieving individual directory
- * entries.  The internal working area has no fields of your interest.
- *
- * <ret>Returns a pointer to the internal working area or NULL in case the
- * directory stream could not be opened.  Global `errno' variable will set
- * in case of error as follows:
- *
- * <table>
- * [EACESS  |Permission denied.
- * [EMFILE  |Too many open files used by the process.
- * [ENFILE  |Too many open files in system.
- * [ENOENT  |Directory does not exist.
- * [ENOMEM  |Insufficient memory.
- * [ENOTDIR |dirname does not refer to directory.  This value is not
- *           reliable on MS-DOS and MS-Windows platforms.  Many
- *           implementations return ENOENT even when the name refers to a
- *           file.]
- * </table>
- * </function>
- */
-static DIR *opendir(const char *dirname)
-{
-  DIR *dirp;
-  assert (dirname != NULL);
-
-  dirp = (DIR*)malloc (sizeof (struct DIR));
-  if (dirp != NULL) {
-    char *p;
-
-    /* allocate room for directory name */
-    dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
-    if (dirp->dirname == NULL) {
-      /* failed to duplicate directory name.  errno set by malloc() */
-      free (dirp);
-      return NULL;
-    }
-    /* Copy directory name while appending directory separator and "*.*".
-     * Directory separator is not appended if the name already ends with
-     * drive or directory separator.  Directory separator is assumed to be
-     * '/' or '\' and drive separator is assumed to be ':'. */
-    strcpy (dirp->dirname, dirname);
-    p = strchr (dirp->dirname, '\0');
-    if (dirp->dirname < p  &&
-        *(p - 1) != '\\'  &&  *(p - 1) != '/'  &&  *(p - 1) != ':')
-    {
-      strcpy (p++, "\\");
-    }
-# ifdef DIRENT_WIN32_INTERFACE
-    strcpy (p, "*"); /*scan files with and without extension in win32*/
-# else
-    strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
-# endif
-
-    /* open stream */
-    if (_initdir (dirp) == 0) {
-      /* initialization failed */
-      free (dirp->dirname);
-      free (dirp);
-      return NULL;
-    }
-  }
-  return dirp;
-}
-
-
-/*
- * <function name="readdir">
- * <intro>read a directory entry
- * <syntax>struct dirent *readdir (DIR *dirp);
- *
- * <desc>Read individual directory entry and return pointer to a structure
- * containing the name of the entry.  Individual directory entries returned
- * include normal files, sub-directories, pseudo-directories "." and ".."
- * and also volume labels, hidden files and system files in MS-DOS and
- * MS-Windows.   You might want to use stat(2) function to determinate which
- * one are you dealing with.  Many dirent implementations already contain
- * equivalent information in dirent structure but you cannot depend on
- * this.
- *
- * The dirent structure contains several system dependent fields that
- * generally have no interest to you.  The only interesting one is char
- * d_name[] that is also portable across different systems.  The d_name
- * field contains the name of the directory entry without leading path.
- * While d_name is portable across different systems the actual storage
- * capacity of d_name varies from system to system and there is no portable
- * way to find out it at compile time as different systems define the
- * capacity of d_name with different macros and some systems do not define
- * capacity at all (besides actual declaration of the field). If you really
- * need to find out storage capacity of d_name then you might want to try
- * NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
- * there are many MS-DOS and MS-Windows implementations those do not define
- * it.  There are also systems that declare d_name as "char d_name[1]" and
- * then allocate suitable amount of memory at run-time.  Thanks to Alain
- * Decamps (Alain.Decamps at advalvas.be) for pointing it out to me.
- *
- * This all leads to the fact that it is difficult to allocate space
- * for the directory names when the very same program is being compiled on
- * number of operating systems.  Therefore I suggest that you always
- * allocate space for directory names dynamically.
- *
- * <ret>
- * Returns a pointer to a structure containing name of the directory entry
- * in `d_name' field or NULL if there was an error.  In case of an error the
- * global `errno' variable will set as follows:
- *
- * <table>
- * [EBADF  |dir parameter refers to an invalid directory stream.  This value
- *          is not set reliably on all implementations.]
- * </table>
- * </function>
- */
-static struct dirent *
-readdir (DIR *dirp)
-{
-  assert(dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return NULL;
-  }
-
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle == INVALID_HANDLE_VALUE) {
-    /* directory stream was opened/rewound incorrectly or it ended normally */
-    errno = EBADF;
-    return NULL;
-  }
-#endif
-
-  if (dirp->dirent_filled != 0) {
-    /*
-     * Directory entry has already been retrieved and there is no need to
-     * retrieve a new one.  Directory entry will be retrieved in advance
-     * when the user calls readdir function for the first time.  This is so
-     * because real dirent has separate functions for opening and reading
-     * the stream whereas Win32 and DOS dirents open the stream
-     * automatically when we retrieve the first file.  Therefore, we have to
-     * save the first file when opening the stream and later we have to
-     * return the saved entry when the user tries to read the first entry.
-     */
-    dirp->dirent_filled = 0;
-  } else {
-    /* fill in entry and return that */
-#if defined(DIRENT_WIN32_INTERFACE)
-    if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
-      /* Last file has been processed or an error occured */
-      FindClose (dirp->search_handle);
-      dirp->search_handle = INVALID_HANDLE_VALUE;
-      errno = ENOENT;
-      return NULL;
-    }
-
-# elif defined(DIRENT_MSDOS_INTERFACE)
-    if (_dos_findnext (&dirp->current.data) != 0) {
-      /* _dos_findnext and findnext will set errno to ENOENT when no
-       * more entries could be retrieved. */
-      return NULL;
-    }
-# endif
-
-    _setdirname (dirp);
-    assert (dirp->dirent_filled == 0);
-  }
-  return &dirp->current;
-}
-
-
-/*
- * <function name="closedir">
- * <intro>close directory stream.
- * <syntax>int closedir (DIR *dirp);
- *
- * <desc>Close directory stream opened by the `opendir' function.  Close of
- * directory stream invalidates the DIR structure as well as previously read
- * dirent entry.
- *
- * <ret>The function typically returns 0 on success and -1 on failure but
- * the function may be declared to return void on same systems.  At least
- * Borland C/C++ and some UNIX implementations use void as a return type.
- * The dirent wrapper tries to define VOID_CLOSEDIR whenever closedir is
- * known to return nothing.  The very same definition is made by the GNU
- * autoconf if you happen to use it.
- *
- * The global `errno' variable will set to EBADF in case of error.
- * </function>
- */
-static int
-closedir (DIR *dirp)
-{
-  int retcode = 0;
-
-  /* make sure that dirp points to legal structure */
-  assert (dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return -1;
-  }
-
-  /* free directory name and search handles */
-  if (dirp->dirname != NULL) free (dirp->dirname);
-
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle != INVALID_HANDLE_VALUE) {
-    if (FindClose (dirp->search_handle) == FALSE) {
-      /* Unknown error */
-      retcode = -1;
-      errno = EBADF;
-    }
-  }
-#endif
-
-  /* clear dirp structure to make sure that it cannot be used anymore*/
-  memset (dirp, 0, sizeof (*dirp));
-# if defined(DIRENT_WIN32_INTERFACE)
-  dirp->search_handle = INVALID_HANDLE_VALUE;
-# endif
-
-  free (dirp);
-  return retcode;
-}
-
-
-/*
- * <function name="rewinddir">
- * <intro>rewind directory stream to the beginning
- * <syntax>void rewinddir (DIR *dirp);
- *
- * <desc>Rewind directory stream to the beginning so that the next call of
- * readdir() returns the very first directory entry again.  However, note
- * that next call of readdir() may not return the same directory entry as it
- * did in first time.  The directory stream may have been affected by newly
- * created files.
- *
- * Almost every dirent implementation ensure that rewinddir will update
- * the directory stream to reflect any changes made to the directory entries
- * since the previous ``opendir'' or ``rewinddir'' call.  Keep an eye on
- * this if your program depends on the feature.  I know at least one dirent
- * implementation where you are required to close and re-open the stream to
- * see the changes.
- *
- * <ret>Returns nothing.  If something went wrong while rewinding, you will
- * notice it later when you try to retrieve the first directory entry.
- */
-static void
-rewinddir (DIR *dirp)
-{
-  /* make sure that dirp is legal */
-  assert (dirp != NULL);
-  if (dirp == NULL) {
-    errno = EBADF;
-    return;
-  }
-  assert (dirp->dirname != NULL);
-
-  /* close previous stream */
-#if defined(DIRENT_WIN32_INTERFACE)
-  if (dirp->search_handle != INVALID_HANDLE_VALUE) {
-    if (FindClose (dirp->search_handle) == FALSE) {
-      /* Unknown error */
-      errno = EBADF;
-    }
-  }
-#endif
-
-  /* re-open previous stream */
-  if (_initdir (dirp) == 0) {
-    /* initialization failed but we cannot deal with error.  User will notice
-     * error later when she tries to retrieve first directory enty. */
-    /*EMPTY*/;
-  }
-}
-
-
-/*
- * Open native directory stream object and retrieve first file.
- * Be sure to close previous stream before opening new one.
- */
-static int
-_initdir (DIR *dirp)
-{
-  assert (dirp != NULL);
-  assert (dirp->dirname != NULL);
-  dirp->dirent_filled = 0;
-
-# if defined(DIRENT_WIN32_INTERFACE)
-  /* Open stream and retrieve first file */
-  dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
-  if (dirp->search_handle == INVALID_HANDLE_VALUE) {
-    /* something went wrong but we don't know what.  GetLastError() could
-     * give us more information about the error, but then we should map
-     * the error code into errno. */
-    errno = ENOENT;
-    return 0;
-  }
-
-# elif defined(DIRENT_MSDOS_INTERFACE)
-  if (_dos_findfirst (dirp->dirname,
-          _A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
-          &dirp->current.data) != 0)
-  {
-    /* _dos_findfirst and findfirst will set errno to ENOENT when no
-     * more entries could be retrieved. */
-    return 0;
-  }
-# endif
-
-  /* initialize DIR and it's first entry */
-  _setdirname (dirp);
-  dirp->dirent_filled = 1;
-  return 1;
-}
-
-
-/*
- * Return implementation dependent name of the current directory entry.
- */
-static const char *
-_getdirname (const struct dirent *dp)
-{
-#if defined(DIRENT_WIN32_INTERFACE)
-  return dp->data.cFileName;
-
-#elif defined(DIRENT_USE_FFBLK)
-  return dp->data.ff_name;
-
-#else
-  return dp->data.name;
-#endif
-}
-
-
-/*
- * Copy name of implementation dependent directory entry to the d_name field.
- */
-static void
-_setdirname (struct DIR *dirp) {
-  /* make sure that d_name is long enough */
-  assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
-
-  strncpy (dirp->current.d_name,
-      _getdirname (&dirp->current),
-      NAME_MAX);
-  dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
-}
-
-# ifdef __cplusplus
-}
-# endif
-# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
-
-#else
-# error "missing dirent interface"
-#endif
-
-
-#endif /*DIRENT_H*/
diff --git a/Utilities/gdcmopenjpeg-v2/codec/image_to_j2k.c b/Utilities/gdcmopenjpeg-v2/codec/image_to_j2k.c
deleted file mode 100644
index 02a19ed..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/image_to_j2k.c
+++ /dev/null
@@ -1,1797 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#define USE_OPJ_DEPRECATED
-#include "openjpeg.h"
-#include "compat/getopt.h"
-#include "convert.h"
-#include "dirent.h"
-#include "index.h"
-
-#ifndef WIN32
-#include <strings.h>
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#endif
-
-/* ----------------------------------------------------------------------- */
-
-#define J2K_CFMT 0
-#define JP2_CFMT 1
-#define JPT_CFMT 2
-
-#define PXM_DFMT 10
-#define PGX_DFMT 11
-#define BMP_DFMT 12
-#define YUV_DFMT 13
-#define TIF_DFMT 14
-#define RAW_DFMT 15
-#define TGA_DFMT 16
-#define PNG_DFMT 17
-/* ----------------------------------------------------------------------- */
-#define CINEMA_24_CS 1302083  /*Codestream length for 24fps*/
-#define CINEMA_48_CS 651041    /*Codestream length for 48fps*/
-#define COMP_24_CS 1041666    /*Maximum size per color component for 2K & 4K @ 24fps*/
-#define COMP_48_CS 520833    /*Maximum size per color component for 2K @ 48fps*/
-
-typedef struct dircnt{
-  /** Buffer for holding images read from Directory*/
-  char *filename_buf;
-  /** Pointer to the buffer*/
-  char **filename;
-}dircnt_t;
-
-typedef struct img_folder{
-  /** The directory path of the folder containing input images*/
-  char *imgdirpath;
-  /** Output format*/
-  char *out_format;
-  /** Enable option*/
-  char set_imgdir;
-  /** Enable Cod Format for output*/
-  char set_out_format;
-  /** User specified rate stored in case of cinema option*/
-  float *rates;
-}img_fol_t;
-
-void encode_help_display() {
-  fprintf(stdout,"HELP\n----\n\n");
-  fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-/* UniPG>> */
-  fprintf(stdout,"List of parameters for the JPEG 2000 "
-#ifdef USE_JPWL
-    "+ JPWL "
-#endif /* USE_JPWL */
-    "encoder:\n");
-/* <<UniPG */
-  fprintf(stdout,"\n");
-  fprintf(stdout,"REMARKS:\n");
-  fprintf(stdout,"---------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
-  fprintf(stdout,"COD and QCD never appear in the tile_header.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"By default:\n");
-  fprintf(stdout,"------------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout," * Lossless\n");
-  fprintf(stdout," * 1 tile\n");
-  fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
-  fprintf(stdout," * Size of code-block : 64 x 64\n");
-  fprintf(stdout," * Number of resolutions: 6\n");
-  fprintf(stdout," * No SOP marker in the codestream\n");
-  fprintf(stdout," * No EPH marker in the codestream\n");
-  fprintf(stdout," * No sub-sampling in x or y direction\n");
-  fprintf(stdout," * No mode switch activated\n");
-  fprintf(stdout," * Progression order: LRCP\n");
-  fprintf(stdout," * No index file\n");
-  fprintf(stdout," * No ROI upshifted\n");
-  fprintf(stdout," * No offset of the origin of the image\n");
-  fprintf(stdout," * No offset of the origin of the tiles\n");
-  fprintf(stdout," * Reversible DWT 5-3\n");
-/* UniPG>> */
-#ifdef USE_JPWL
-  fprintf(stdout," * No JPWL protection\n");
-#endif /* USE_JPWL */
-/* <<UniPG */
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Parameters:\n");
-  fprintf(stdout,"------------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Required Parameters (except with -h):\n");
-  fprintf(stdout,"One of the two options -ImgDir or -i must be used\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-ImgDir      : Image file Directory path (example ../Images) \n");
-  fprintf(stdout,"    When using this option -OutFor must be used\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-OutFor \n");
-  fprintf(stdout,"    REQUIRED only if -ImgDir is used\n");
-  fprintf(stdout,"    Need to specify only format without filename <BMP>  \n");
-  fprintf(stdout,"    Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA formats\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-i           : source file  (-i source.pnm also *.pgm, *.ppm, *.bmp, *.tif, *.raw, *.tga) \n");
-  fprintf(stdout,"    When using this option -o must be used\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-o           : destination file (-o dest.j2k or .jp2) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Optional Parameters:\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-h           : display the help information \n ");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-cinema2K    : Digital Cinema 2K profile compliant codestream for 2K resolution.(-cinema2k 24 or 48) \n");
-  fprintf(stdout,"    Need to specify the frames per second for a 2K resolution. Only 24 or 48 fps is allowed\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-cinema4K    : Digital Cinema 4K profile compliant codestream for 4K resolution \n");
-  fprintf(stdout,"    Frames per second not required. Default value is 24fps\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-r           : different compression ratios for successive layers (-r 20,10,5)\n ");
-  fprintf(stdout,"           - The rate specified for each quality level is the desired \n");
-  fprintf(stdout,"             compression factor.\n");
-  fprintf(stdout,"       Example: -r 20,10,1 means quality 1: compress 20x, \n");
-  fprintf(stdout,"         quality 2: compress 10x and quality 3: compress lossless\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-  fprintf(stdout,"\n");
-
-  fprintf(stdout,"-q           : different psnr for successive layers (-q 30,40,50) \n ");
-
-  fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-n           : number of resolutions (-n 3) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-b           : size of code block (-b 32,32) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-c           : size of precinct (-c 128,128) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-t           : size of tile (-t 512,512) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-p           : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-s           : subsampling factor (-s 2,2) [-s X,Y] \n");
-  fprintf(stdout,"       Remark: subsampling bigger than 2 can produce error\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-POC         : Progression order change (-POC T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL) \n");
-  fprintf(stdout,"      Example: T1=0,0,1,5,3,CPRL \n");
-  fprintf(stdout,"       : Ttilenumber=Resolution num start,Component num start,Layer num end,Resolution num end,Component num end,Progression order\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-SOP         : write SOP marker before each packet \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-EPH         : write EPH marker after each header packet \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-M           : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
-  fprintf(stdout,"                 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
-  fprintf(stdout,"                 Indicate multiple modes by adding their values. \n");
-  fprintf(stdout,"                 ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-x           : create an index file *.Idx (-x index_name.Idx) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-ROI         : c=%%d,U=%%d : quantization indices upshifted \n");
-  fprintf(stdout,"               for component c=%%d [%%d = 0,1,2]\n");
-  fprintf(stdout,"               with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI c=0,U=25) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-d           : offset of the origin of the image (-d 150,300) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-T           : offset of the origin of the tiles (-T 100,75) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-I           : use the irreversible DWT 9-7 (-I) \n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"-F           : characteristics of the raw input image\n");
-  fprintf(stdout,"               -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-  fprintf(stdout,"               Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-  fprintf(stdout,"-m           : use array-based MCT, values are coma separated, line by line\n");
-  fprintf(stdout,"         no specific separators between lines, no space allowed between values\n");
-  fprintf(stdout,"\n");
-/* UniPG>> */
-#ifdef USE_JPWL
-  fprintf(stdout,"-W           : adoption of JPWL (Part 11) capabilities (-W params)\n");
-  fprintf(stdout,"               The parameters can be written and repeated in any order:\n");
-  fprintf(stdout,"               [h<tilepart><=type>,s<tilepart><=method>,a=<addr>,...\n");
-  fprintf(stdout,"                ...,z=<size>,g=<range>,p<tilepart:pack><=type>]\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 h selects the header error protection (EPB): 'type' can be\n");
-  fprintf(stdout,"                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
-  fprintf(stdout,"                   if 'tilepart' is absent, it is for main and tile headers\n");
-  fprintf(stdout,"                   if 'tilepart' is present, it applies from that tile\n");
-  fprintf(stdout,"                     onwards, up to the next h<> spec, or to the last tilepart\n");
-  fprintf(stdout,"                     in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 p selects the packet error protection (EEP/UEP with EPBs)\n");
-  fprintf(stdout,"                  to be applied to raw data: 'type' can be\n");
-  fprintf(stdout,"                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
-  fprintf(stdout,"                   if 'tilepart:pack' is absent, it is from tile 0, packet 0\n");
-  fprintf(stdout,"                   if 'tilepart:pack' is present, it applies from that tile\n");
-  fprintf(stdout,"                     and that packet onwards, up to the next packet spec\n");
-  fprintf(stdout,"                     or to the last packet in the last tilepart in the stream\n");
-  fprintf(stdout,"                     (max. %d specs)\n", JPWL_MAX_NO_PACKSPECS);
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 s enables sensitivity data insertion (ESD): 'method' can be\n");
-  fprintf(stdout,"                   [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR\n");
-  fprintf(stdout,"                    4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]\n");
-  fprintf(stdout,"                   if 'tilepart' is absent, it is for main header only\n");
-  fprintf(stdout,"                   if 'tilepart' is present, it applies from that tile\n");
-  fprintf(stdout,"                     onwards, up to the next s<> spec, or to the last tilepart\n");
-  fprintf(stdout,"                     in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 g determines the addressing mode: <range> can be\n");
-  fprintf(stdout,"                   [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 a determines the size of data addressing: <addr> can be\n");
-  fprintf(stdout,"                   2/4 bytes (small/large codestreams). If not set, auto-mode\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 z determines the size of sensitivity values: <size> can be\n");
-  fprintf(stdout,"                   1/2 bytes, for the transformed pseudo-floating point value\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 ex.:\n");
-  fprintf(stdout,"                   h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,\n");
-  fprintf(stdout,"                     s0=6,s3=-1,a=0,g=1,z=1\n");
-  fprintf(stdout,"                 means\n");
-  fprintf(stdout,"                   predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,\n");
-  fprintf(stdout,"                   CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,\n");
-  fprintf(stdout,"                   UEP rs(78,32) for packets 0 to 23 of tile 0,\n");
-  fprintf(stdout,"                   UEP rs(56,32) for packs. 24 to the last of tilepart 0,\n");
-  fprintf(stdout,"                   UEP rs default for packets of tilepart 1,\n");
-  fprintf(stdout,"                   no UEP for packets 0 to 19 of tilepart 3,\n");
-  fprintf(stdout,"                   UEP CRC-32 for packs. 20 of tilepart 3 to last tilepart,\n");
-  fprintf(stdout,"                   relative sensitivity ESD for MH,\n");
-  fprintf(stdout,"                   TSE ESD from TPH 0 to TPH 2, byte range with automatic\n");
-  fprintf(stdout,"                   size of addresses and 1 byte for each sensitivity value\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 ex.:\n");
-  fprintf(stdout,"                       h,s,p\n");
-  fprintf(stdout,"                 means\n");
-  fprintf(stdout,"                   default protection to headers (MH and TPHs) as well as\n");
-  fprintf(stdout,"                   data packets, one ESD in MH\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"                 N.B.: use the following recommendations when specifying\n");
-  fprintf(stdout,"                       the JPWL parameters list\n");
-  fprintf(stdout,"                   - when you use UEP, always pair the 'p' option with 'h'\n");
-  fprintf(stdout,"                 \n");
-#endif /* USE_JPWL */
-/* <<UniPG */
-  fprintf(stdout,"IMPORTANT:\n");
-  fprintf(stdout,"-----------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The index file has the structure below:\n");
-  fprintf(stdout,"---------------------------------------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Image_height Image_width\n");
-  fprintf(stdout,"progression order\n");
-  fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
-  fprintf(stdout,"Tiles_nb_X Tiles_nb_Y\n");
-  fprintf(stdout,"Components_nb\n");
-  fprintf(stdout,"Layers_nb\n");
-  fprintf(stdout,"decomposition_levels\n");
-  fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
-  fprintf(stdout,"   [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
-  fprintf(stdout,"Main_header_start_position\n");
-  fprintf(stdout,"Main_header_end_position\n");
-  fprintf(stdout,"Codestream_size\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"INFO ON TILES\n");
-  fprintf(stdout,"tileno start_pos end_hd end_tile nbparts disto nbpix disto/nbpix\n");
-  fprintf(stdout,"Tile_0 start_pos end_Theader end_pos NumParts TotalDisto NumPix MaxMSE\n");
-  fprintf(stdout,"Tile_1   ''           ''        ''        ''       ''    ''      ''\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"Tile_Nt   ''           ''        ''        ''       ''    ''     ''\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"TILE 0 DETAILS\n");
-  fprintf(stdout,"part_nb tileno num_packs start_pos end_tph_pos end_pos\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"Progression_string\n");
-  fprintf(stdout,"pack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");
-  fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"Tpacket_Np ''   ''    ''   ''    ''       ''       ''     ''\n");
-
-  fprintf(stdout,"MaxDisto\n");
-
-  fprintf(stdout,"TotalDisto\n\n");
-}
-
-OPJ_PROG_ORDER give_progression(char progression[4]) {
-  if(strncmp(progression, "LRCP", 4) == 0) {
-    return LRCP;
-  }
-  if(strncmp(progression, "RLCP", 4) == 0) {
-    return RLCP;
-  }
-  if(strncmp(progression, "RPCL", 4) == 0) {
-    return RPCL;
-  }
-  if(strncmp(progression, "PCRL", 4) == 0) {
-    return PCRL;
-  }
-  if(strncmp(progression, "CPRL", 4) == 0) {
-    return CPRL;
-  }
-
-  return PROG_UNKNOWN;
-}
-
-int get_num_images(char *imgdirpath){
-  DIR *dir;
-  struct dirent* content;
-  int num_images = 0;
-
-  /*Reading the input images from given input directory*/
-
-  dir= opendir(imgdirpath);
-  if(!dir){
-    fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-    return 0;
-  }
-
-  num_images=0;
-  while((content=readdir(dir))!=NULL){
-    if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-      continue;
-    num_images++;
-  }
-  return num_images;
-}
-
-int load_images(dircnt_t *dirptr, char *imgdirpath){
-  DIR *dir;
-  struct dirent* content;
-  int i = 0;
-
-  /*Reading the input images from given input directory*/
-
-  dir= opendir(imgdirpath);
-  if(!dir){
-    fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-    return 1;
-  }else  {
-    fprintf(stderr,"Folder opened successfully\n");
-  }
-
-  while((content=readdir(dir))!=NULL){
-    if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-      continue;
-
-    strcpy(dirptr->filename[i],content->d_name);
-    i++;
-  }
-  return 0;
-}
-
-int get_file_format(char *filename) {
-  unsigned int i;
-  static const char *extension[] = {
-    "pgx", "pnm", "pgm", "ppm", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "j2c", "jpc"
-    };
-  static const int format[] = {
-    PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, J2K_CFMT, J2K_CFMT
-    };
-  char * ext = strrchr(filename, '.');
-  if (ext == NULL)
-    return -1;
-  ext++;
-  for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
-    if(_strnicmp(ext, extension[i], 3) == 0) {
-      return format[i];
-    }
-  }
-  return -1;
-}
-
-char * get_file_name(char *name){
-  char *fname;
-  fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char));
-  fname= strtok(name,".");
-  return fname;
-}
-
-char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters){
-  char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
-  char *temp_p, temp1[OPJ_PATH_LEN]="";
-
-  strcpy(image_filename,dirptr->filename[imageno]);
-  fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
-  parameters->decod_format = get_file_format(image_filename);
-  if (parameters->decod_format == -1)
-    return 1;
-  sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
-  strncpy(parameters->infile, infilename, sizeof(infilename));
-
-  //Set output file
-  strcpy(temp_ofname,get_file_name(image_filename));
-  while((temp_p = strtok(NULL,".")) != NULL){
-    strcat(temp_ofname,temp1);
-    sprintf(temp1,".%s",temp_p);
-  }
-  if(img_fol->set_out_format==1){
-    sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
-    strncpy(parameters->outfile, outfilename, sizeof(outfilename));
-  }
- return 0;
-}
-
-static int initialise_4K_poc(opj_poc_t *POC, int numres){
-  POC[0].tile  = 1;
-  POC[0].resno0  = 0;
-  POC[0].compno0 = 0;
-  POC[0].layno1  = 1;
-  POC[0].resno1  = numres-1;
-  POC[0].compno1 = 3;
-  POC[0].prg1 = CPRL;
-  POC[1].tile  = 1;
-  POC[1].resno0  = numres-1;
-  POC[1].compno0 = 0;
-  POC[1].layno1  = 1;
-  POC[1].resno1  = numres;
-  POC[1].compno1 = 3;
-  POC[1].prg1 = CPRL;
-  return 2;
-}
-
-void cinema_parameters(opj_cparameters_t *parameters){
-  parameters->tile_size_on = false;
-  parameters->cp_tdx=1;
-  parameters->cp_tdy=1;
-
-  /*Tile part*/
-  parameters->tp_flag = 'C';
-  parameters->tp_on = 1;
-
-  /*Tile and Image shall be at (0,0)*/
-  parameters->cp_tx0 = 0;
-  parameters->cp_ty0 = 0;
-  parameters->image_offset_x0 = 0;
-  parameters->image_offset_y0 = 0;
-
-  /*Codeblock size= 32*32*/
-  parameters->cblockw_init = 32;
-  parameters->cblockh_init = 32;
-  parameters->csty |= 0x01;
-
-  /*The progression order shall be CPRL*/
-  parameters->prog_order = CPRL;
-
-  /* No ROI */
-  parameters->roi_compno = -1;
-
-  parameters->subsampling_dx = 1;    parameters->subsampling_dy = 1;
-
-  /* 9-7 transform */
-  parameters->irreversible = 1;
-
-}
-
-void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
-  int i;
-  float temp_rate;
-
-  switch (parameters->cp_cinema){
-  case CINEMA2K_24:
-  case CINEMA2K_48:
-    if(parameters->numresolution > 6){
-      parameters->numresolution = 6;
-    }
-    if (!((image->comps[0].w == 2048) | (image->comps[0].h == 1080))){
-      fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
-        "(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
-        image->comps[0].w,image->comps[0].h);
-      parameters->cp_rsiz = STD_RSIZ;
-    }
-  break;
-
-  case CINEMA4K_24:
-    if(parameters->numresolution < 1){
-        parameters->numresolution = 1;
-      }else if(parameters->numresolution > 7){
-        parameters->numresolution = 7;
-      }
-    if (!((image->comps[0].w == 4096) | (image->comps[0].h == 2160))){
-      fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
-        "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
-        image->comps[0].w,image->comps[0].h);
-      parameters->cp_rsiz = STD_RSIZ;
-    }
-    parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution);
-    break;
-  default :
-    break;
-  }
-
-  switch (parameters->cp_cinema){
-    case CINEMA2K_24:
-    case CINEMA4K_24:
-      for(i=0 ; i<parameters->tcp_numlayers ; i++){
-        temp_rate = 0 ;
-        if (img_fol->rates[i]== 0){
-          parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-          (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-        }else{
-          temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-            (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
-          if (temp_rate > CINEMA_24_CS ){
-            parameters->tcp_rates[i]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-            (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-          }else{
-            parameters->tcp_rates[i]= img_fol->rates[i];
-          }
-        }
-      }
-      parameters->max_comp_size = COMP_24_CS;
-      break;
-
-    case CINEMA2K_48:
-      for(i=0 ; i<parameters->tcp_numlayers ; i++){
-        temp_rate = 0 ;
-        if (img_fol->rates[i]== 0){
-          parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-          (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-        }else{
-          temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-            (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
-          if (temp_rate > CINEMA_48_CS ){
-            parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
-            (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
-          }else{
-            parameters->tcp_rates[i]= img_fol->rates[i];
-          }
-        }
-      }
-      parameters->max_comp_size = COMP_48_CS;
-      break;
-    default:
-      break;
-  }
-  parameters->cp_disto_alloc = 1;
-}
-
-/* ------------------------------------------------------------------------------------ */
-
-int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
-                          img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
-  int i, j,totlen;
-  option_t long_option[]={
-    {"cinema2K",REQ_ARG, NULL ,'w'},
-    {"cinema4K",NO_ARG, NULL ,'y'},
-    {"ImgDir",REQ_ARG, NULL ,'z'},
-    {"TP",REQ_ARG, NULL ,'v'},
-    {"SOP",NO_ARG, NULL ,'S'},
-    {"EPH",NO_ARG, NULL ,'E'},
-    {"OutFor",REQ_ARG, NULL ,'O'},
-    {"POC",REQ_ARG, NULL ,'P'},
-    {"ROI",REQ_ARG, NULL ,'R'},
-  };
-
-  /* parse the command line */
-  const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:m:"
-#ifdef USE_JPWL
-    "W:"
-#endif /* USE_JPWL */
-    ;
-
-  totlen=sizeof(long_option);
-  img_fol->set_out_format=0;
-  raw_cp->rawWidth = 0;
-
-  while (1) {
-    int c = getopt_long(argc, argv, optlist,long_option,totlen);
-    if (c == -1)
-      break;
-    switch (c) {
-      case 'i':      /* input file */
-      {
-        char *infile = optarg;
-        parameters->decod_format = get_file_format(infile);
-        switch(parameters->decod_format) {
-          case PGX_DFMT:
-          case PXM_DFMT:
-          case BMP_DFMT:
-          case TIF_DFMT:
-          case RAW_DFMT:
-          case TGA_DFMT:
-          case PNG_DFMT:
-            break;
-          default:
-            fprintf(stderr,
-              "!! Unrecognized format for infile : %s "
-              "[accept only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga] !!\n\n",
-              infile);
-            return 1;
-        }
-        strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'o':      /* output file */
-      {
-        char *outfile = optarg;
-        parameters->cod_format = get_file_format(outfile);
-        switch(parameters->cod_format) {
-          case J2K_CFMT:
-          case JP2_CFMT:
-            break;
-          default:
-            fprintf(stderr, "Unknown output format image %s [only *.j2k, *.j2c or *.jp2]!! \n", outfile);
-            return 1;
-        }
-        strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-      case 'O':      /* output format */
-        {
-          char outformat[50];
-          char *of = optarg;
-          sprintf(outformat,".%s",of);
-          img_fol->set_out_format = 1;
-          parameters->cod_format = get_file_format(outformat);
-          switch(parameters->cod_format) {
-            case J2K_CFMT:
-            case JP2_CFMT:
-              img_fol->out_format = optarg;
-              break;
-            default:
-              fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
-              return 1;
-          }
-        }
-        break;
-
-
-        /* ----------------------------------------------------- */
-
-
-      case 'r':      /* rates rates/distorsion */
-      {
-        char *s = optarg;
-        parameters->tcp_numlayers = 0;
-        while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
-          parameters->tcp_numlayers++;
-          while (*s && *s != ',') {
-            s++;
-          }
-          if (!*s)
-            break;
-          s++;
-        }
-        parameters->cp_disto_alloc = 1;
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-
-      case 'F':      /* Raw image format parameters */
-      {
-        char signo;
-        char *s = optarg;
-        if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
-          if (signo == 's') {
-            raw_cp->rawSigned = true;
-            fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Signed\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
-          }
-          else if (signo == 'u') {
-            raw_cp->rawSigned = false;
-            fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Unsigned\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
-          }
-          else {
-            fprintf(stderr,"\nError: invalid raw image parameters: Unknown sign of raw file\n");
-            fprintf(stderr,"Please use the Format option -F:\n");
-            fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-            fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-            fprintf(stderr,"Aborting\n");
-          }
-        }
-        else {
-          fprintf(stderr,"\nError: invalid raw image parameters\n");
-          fprintf(stderr,"Please use the Format option -F:\n");
-          fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-            fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-          fprintf(stderr,"Aborting\n");
-          return 1;
-        }
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'q':      /* add fixed_quality */
-      {
-        char *s = optarg;
-        while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
-          parameters->tcp_numlayers++;
-          while (*s && *s != ',') {
-            s++;
-          }
-          if (!*s)
-            break;
-          s++;
-        }
-        parameters->cp_fixed_quality = 1;
-      }
-      break;
-
-        /* dda */
-        /* ----------------------------------------------------- */
-
-      case 'f':      /* mod fixed_quality (before : -q) */
-      {
-        int *row = NULL, *col = NULL;
-        int numlayers = 0, numresolution = 0, matrix_width = 0;
-
-        char *s = optarg;
-        sscanf(s, "%d", &numlayers);
-        s++;
-        if (numlayers > 9)
-          s++;
-
-        parameters->tcp_numlayers = numlayers;
-        numresolution = parameters->numresolution;
-        matrix_width = numresolution * 3;
-        parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
-        s = s + 2;
-
-        for (i = 0; i < numlayers; i++) {
-          row = &parameters->cp_matrice[i * matrix_width];
-          col = row;
-          parameters->tcp_rates[i] = 1;
-          sscanf(s, "%d,", &col[0]);
-          s += 2;
-          if (col[0] > 9)
-            s++;
-          col[1] = 0;
-          col[2] = 0;
-          for (j = 1; j < numresolution; j++) {
-            col += 3;
-            sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
-            s += 6;
-            if (col[0] > 9)
-              s++;
-            if (col[1] > 9)
-              s++;
-            if (col[2] > 9)
-              s++;
-          }
-          if (i < numlayers - 1)
-            s++;
-        }
-        parameters->cp_fixed_alloc = 1;
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 't':      /* tiles */
-      {
-        sscanf(optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy);
-        parameters->tile_size_on = true;
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'n':      /* resolution */
-      {
-        sscanf(optarg, "%d", &parameters->numresolution);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-      case 'c':      /* precinct dimension */
-      {
-        char sep;
-        int res_spec = 0;
-
-        char *s = optarg;
-        do {
-          sep = 0;
-          sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
-                                 &parameters->prch_init[res_spec], &sep);
-          parameters->csty |= 0x01;
-          res_spec++;
-          s = strpbrk(s, "]") + 2;
-        }
-        while (sep == ',');
-        parameters->res_spec = res_spec;
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'b':      /* code-block dimension */
-      {
-        int cblockw_init = 0, cblockh_init = 0;
-        sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
-        if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
-          || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
-          fprintf(stderr,
-            "!! Size of code_block error (option -b) !!\n\nRestriction :\n"
-            "    * width*height<=4096\n    * 4<=width,height<= 1024\n\n");
-          return 1;
-        }
-        parameters->cblockw_init = cblockw_init;
-        parameters->cblockh_init = cblockh_init;
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'x':      /* creation of index file */
-      {
-        char *index = optarg;
-        strncpy(indexfilename, index, OPJ_PATH_LEN);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'p':      /* progression order */
-      {
-        char progression[4];
-
-        strncpy(progression, optarg, 4);
-        parameters->prog_order = give_progression(progression);
-        if (parameters->prog_order == -1) {
-          fprintf(stderr, "Unrecognized progression order "
-            "[LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
-          return 1;
-        }
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 's':      /* subsampling factor */
-      {
-        if (sscanf(optarg, "%d,%d", &parameters->subsampling_dx,
-                                    &parameters->subsampling_dy) != 2) {
-          fprintf(stderr,  "'-s' sub-sampling argument error !  [-s dx,dy]\n");
-          return 1;
-        }
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'd':      /* coordonnate of the reference grid */
-      {
-        if (sscanf(optarg, "%d,%d", &parameters->image_offset_x0,
-                                    &parameters->image_offset_y0) != 2) {
-          fprintf(stderr,  "-d 'coordonnate of the reference grid' argument "
-            "error !! [-d x0,y0]\n");
-          return 1;
-        }
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'h':      /* display an help description */
-        encode_help_display();
-        return 1;
-
-        /* ----------------------------------------------------- */
-
-      case 'P':      /* POC */
-      {
-        int numpocs = 0;    /* number of progression order change (POC) default 0 */
-        opj_poc_t *POC = NULL;  /* POC : used in case of Progression order change */
-
-        char *s = optarg;
-        POC = parameters->POC;
-
-        while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
-          &POC[numpocs].resno0, &POC[numpocs].compno0,
-          &POC[numpocs].layno1, &POC[numpocs].resno1,
-          &POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
-          POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
-          numpocs++;
-          while (*s && *s != '/') {
-            s++;
-          }
-          if (!*s) {
-            break;
-          }
-          s++;
-        }
-        parameters->numpocs = numpocs;
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'S':      /* SOP marker */
-      {
-        parameters->csty |= 0x02;
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'E':      /* EPH marker */
-      {
-        parameters->csty |= 0x04;
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'M':      /* Mode switch pas tous au point !! */
-      {
-        int value = 0;
-        if (sscanf(optarg, "%d", &value) == 1) {
-          for (i = 0; i <= 5; i++) {
-            int cache = value & (1 << i);
-            if (cache)
-              parameters->mode |= (1 << i);
-          }
-        }
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'R':      /* ROI */
-      {
-        if (sscanf(optarg, "c=%d,U=%d", &parameters->roi_compno,
-                                           &parameters->roi_shift) != 2) {
-          fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
-          return 1;
-        }
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'T':      /* Tile offset */
-      {
-        if (sscanf(optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) {
-          fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
-          return 1;
-        }
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'C':      /* add a comment */
-      {
-        parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
-        if(parameters->cp_comment) {
-          strcpy(parameters->cp_comment, optarg);
-        }
-      }
-      break;
-
-
-        /* ------------------------------------------------------ */
-
-      case 'I':      /* reversible or not */
-      {
-        parameters->irreversible = 1;
-      }
-      break;
-
-      /* ------------------------------------------------------ */
-
-      case 'v':      /* Tile part generation*/
-      {
-        parameters->tp_flag = optarg[0];
-        parameters->tp_on = 1;
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'z':      /* Image Directory path */
-      {
-        img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
-        strcpy(img_fol->imgdirpath,optarg);
-        img_fol->set_imgdir=1;
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'w':      /* Digital Cinema 2K profile compliance*/
-      {
-        int fps=0;
-        sscanf(optarg,"%d",&fps);
-        if(fps == 24){
-          parameters->cp_cinema = CINEMA2K_24;
-        }else if(fps == 48 ){
-          parameters->cp_cinema = CINEMA2K_48;
-        }else {
-          fprintf(stderr,"Incorrect value!! must be 24 or 48\n");
-          return 1;
-        }
-        fprintf(stdout,"CINEMA 2K compliant codestream\n");
-        parameters->cp_rsiz = CINEMA2K;
-
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-      case 'y':      /* Digital Cinema 4K profile compliance*/
-      {
-        parameters->cp_cinema = CINEMA4K_24;
-        fprintf(stdout,"CINEMA 4K compliant codestream\n");
-        parameters->cp_rsiz = CINEMA4K;
-      }
-      break;
-
-      case 'm':      /* output file */
-      {
-        char *lFilename = optarg;
-        char * lMatrix;
-        char *lCurrentPtr ;
-        int lNbComp = 0;
-        int lTotalComp;
-        int lMctComp;
-        float * lCurrentDoublePtr;
-        float * lSpace;
-        int * l_int_ptr;
-        int i;
-        int lStrLen;
-
-        FILE * lFile = fopen(lFilename,"r");
-        if
-          (lFile == NULL)
-        {
-          return 1;
-        }
-        fseek(lFile,0,SEEK_END);
-        lStrLen = ftell(lFile);
-        fseek(lFile,0,SEEK_SET);
-        lMatrix = (char *) malloc(lStrLen + 1);
-        fread(lMatrix,lStrLen,1,lFile);
-        fclose(lFile);
-        lMatrix[lStrLen] = 0;
-        lCurrentPtr = lMatrix;
-
-        // replace ',' by 0
-        while
-          (*lCurrentPtr != 0 )
-        {
-          if
-            (*lCurrentPtr == ' ')
-          {
-            *lCurrentPtr = 0;
-            ++lNbComp;
-          }
-          ++lCurrentPtr;
-        }
-        ++lNbComp;
-        lCurrentPtr = lMatrix;
-
-        lNbComp = (int) (sqrt(4*lNbComp + 1)/2. - 0.5);
-        lMctComp = lNbComp * lNbComp;
-        lTotalComp = lMctComp + lNbComp;
-        lSpace = (float *) malloc(lTotalComp * sizeof(float));
-        lCurrentDoublePtr = lSpace;
-        for
-          (i=0;i<lMctComp;++i)
-        {
-          lStrLen = strlen(lCurrentPtr) + 1;
-          *lCurrentDoublePtr++ = (float) atof(lCurrentPtr);
-          lCurrentPtr += lStrLen;
-        }
-        l_int_ptr = (int*) lCurrentDoublePtr;
-        for
-          (i=0;i<lNbComp;++i)
-        {
-          lStrLen = strlen(lCurrentPtr) + 1;
-          *l_int_ptr++ = atoi(lCurrentPtr);
-          lCurrentPtr += lStrLen;
-        }
-        opj_set_MCT(parameters,lSpace,(int *)(lSpace + lMctComp), lNbComp);
-        free(lSpace);
-        free(lMatrix);
-      }
-      break;
-
-        /* ------------------------------------------------------ */
-
-/* UniPG>> */
-#ifdef USE_JPWL
-        /* ------------------------------------------------------ */
-
-      case 'W':      /* JPWL capabilities switched on */
-      {
-        char *token = NULL;
-        int hprot, pprot, sens, addr, size, range;
-
-        /* we need to enable indexing */
-        if (!indexfilename || !*indexfilename) {
-          strncpy(indexfilename, JPWL_PRIVATEINDEX_NAME, OPJ_PATH_LEN);
-        }
-
-        /* search for different protection methods */
-
-        /* break the option in comma points and parse the result */
-        token = strtok(optarg, ",");
-        while(token != NULL) {
-
-          /* search header error protection method */
-          if (*token == 'h') {
-
-            static int tile = 0, tilespec = 0, lasttileno = 0;
-
-            hprot = 1; /* predefined method */
-
-            if(sscanf(token, "h=%d", &hprot) == 1) {
-              /* Main header, specified */
-              if (!((hprot == 0) || (hprot == 1) || (hprot == 16) || (hprot == 32) ||
-                ((hprot >= 37) && (hprot <= 128)))) {
-                fprintf(stderr, "ERROR -> invalid main header protection method h = %d\n", hprot);
-                return 1;
-              }
-              parameters->jpwl_hprot_MH = hprot;
-
-            } else if(sscanf(token, "h%d=%d", &tile, &hprot) == 2) {
-              /* Tile part header, specified */
-              if (!((hprot == 0) || (hprot == 1) || (hprot == 16) || (hprot == 32) ||
-                ((hprot >= 37) && (hprot <= 128)))) {
-                fprintf(stderr, "ERROR -> invalid tile part header protection method h = %d\n", hprot);
-                return 1;
-              }
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
-                return 1;
-              }
-              if (tilespec < JPWL_MAX_NO_TILESPECS) {
-                parameters->jpwl_hprot_TPH_tileno[tilespec] = lasttileno = tile;
-                parameters->jpwl_hprot_TPH[tilespec++] = hprot;
-              }
-
-            } else if(sscanf(token, "h%d", &tile) == 1) {
-              /* Tile part header, unspecified */
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
-                return 1;
-              }
-              if (tilespec < JPWL_MAX_NO_TILESPECS) {
-                parameters->jpwl_hprot_TPH_tileno[tilespec] = lasttileno = tile;
-                parameters->jpwl_hprot_TPH[tilespec++] = hprot;
-              }
-
-
-            } else if (!strcmp(token, "h")) {
-              /* Main header, unspecified */
-              parameters->jpwl_hprot_MH = hprot;
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid protection method selection = %s\n", token);
-              return 1;
-            };
-
-          }
-
-          /* search packet error protection method */
-          if (*token == 'p') {
-
-            static int pack = 0, tile = 0, packspec = 0;
-
-            pprot = 1; /* predefined method */
-
-            if (sscanf(token, "p=%d", &pprot) == 1) {
-              /* Method for all tiles and all packets */
-              if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-                ((pprot >= 37) && (pprot <= 128)))) {
-                fprintf(stderr, "ERROR -> invalid default packet protection method p = %d\n", pprot);
-                return 1;
-              }
-              parameters->jpwl_pprot_tileno[0] = 0;
-              parameters->jpwl_pprot_packno[0] = 0;
-              parameters->jpwl_pprot[0] = pprot;
-
-            } else if (sscanf(token, "p%d=%d", &tile, &pprot) == 2) {
-              /* method specified from that tile on */
-              if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-                ((pprot >= 37) && (pprot <= 128)))) {
-                fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
-                return 1;
-              }
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-                return 1;
-              }
-              if (packspec < JPWL_MAX_NO_PACKSPECS) {
-                parameters->jpwl_pprot_tileno[packspec] = tile;
-                parameters->jpwl_pprot_packno[packspec] = 0;
-                parameters->jpwl_pprot[packspec++] = pprot;
-              }
-
-            } else if (sscanf(token, "p%d:%d=%d", &tile, &pack, &pprot) == 3) {
-              /* method fully specified from that tile and that packet on */
-              if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-                ((pprot >= 37) && (pprot <= 128)))) {
-                fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
-                return 1;
-              }
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-                return 1;
-              }
-              if (pack < 0) {
-                fprintf(stderr, "ERROR -> invalid packet number on protection method p = %d\n", pack);
-                return 1;
-              }
-              if (packspec < JPWL_MAX_NO_PACKSPECS) {
-                parameters->jpwl_pprot_tileno[packspec] = tile;
-                parameters->jpwl_pprot_packno[packspec] = pack;
-                parameters->jpwl_pprot[packspec++] = pprot;
-              }
-
-            } else if (sscanf(token, "p%d:%d", &tile, &pack) == 2) {
-              /* default method from that tile and that packet on */
-              if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
-                ((pprot >= 37) && (pprot <= 128)))) {
-                fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
-                return 1;
-              }
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-                return 1;
-              }
-              if (pack < 0) {
-                fprintf(stderr, "ERROR -> invalid packet number on protection method p = %d\n", pack);
-                return 1;
-              }
-              if (packspec < JPWL_MAX_NO_PACKSPECS) {
-                parameters->jpwl_pprot_tileno[packspec] = tile;
-                parameters->jpwl_pprot_packno[packspec] = pack;
-                parameters->jpwl_pprot[packspec++] = pprot;
-              }
-
-            } else if (sscanf(token, "p%d", &tile) == 1) {
-              /* default from a tile on */
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
-                return 1;
-              }
-              if (packspec < JPWL_MAX_NO_PACKSPECS) {
-                parameters->jpwl_pprot_tileno[packspec] = tile;
-                parameters->jpwl_pprot_packno[packspec] = 0;
-                parameters->jpwl_pprot[packspec++] = pprot;
-              }
-
-
-            } else if (!strcmp(token, "p")) {
-              /* all default */
-              parameters->jpwl_pprot_tileno[0] = 0;
-              parameters->jpwl_pprot_packno[0] = 0;
-              parameters->jpwl_pprot[0] = pprot;
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid protection method selection = %s\n", token);
-              return 1;
-            };
-
-          }
-
-          /* search sensitivity method */
-          if (*token == 's') {
-
-            static int tile = 0, tilespec = 0, lasttileno = 0;
-
-            sens = 0; /* predefined: relative error */
-
-            if(sscanf(token, "s=%d", &sens) == 1) {
-              /* Main header, specified */
-              if ((sens < -1) || (sens > 7)) {
-                fprintf(stderr, "ERROR -> invalid main header sensitivity method s = %d\n", sens);
-                return 1;
-              }
-              parameters->jpwl_sens_MH = sens;
-
-            } else if(sscanf(token, "s%d=%d", &tile, &sens) == 2) {
-              /* Tile part header, specified */
-              if ((sens < -1) || (sens > 7)) {
-                fprintf(stderr, "ERROR -> invalid tile part header sensitivity method s = %d\n", sens);
-                return 1;
-              }
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
-                return 1;
-              }
-              if (tilespec < JPWL_MAX_NO_TILESPECS) {
-                parameters->jpwl_sens_TPH_tileno[tilespec] = lasttileno = tile;
-                parameters->jpwl_sens_TPH[tilespec++] = sens;
-              }
-
-            } else if(sscanf(token, "s%d", &tile) == 1) {
-              /* Tile part header, unspecified */
-              if (tile < 0) {
-                fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
-                return 1;
-              }
-              if (tilespec < JPWL_MAX_NO_TILESPECS) {
-                parameters->jpwl_sens_TPH_tileno[tilespec] = lasttileno = tile;
-                parameters->jpwl_sens_TPH[tilespec++] = hprot;
-              }
-
-            } else if (!strcmp(token, "s")) {
-              /* Main header, unspecified */
-              parameters->jpwl_sens_MH = sens;
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid sensitivity method selection = %s\n", token);
-              return 1;
-            };
-
-            parameters->jpwl_sens_size = 2; /* 2 bytes for default size */
-          }
-
-          /* search addressing size */
-          if (*token == 'a') {
-
-
-            addr = 0; /* predefined: auto */
-
-            if(sscanf(token, "a=%d", &addr) == 1) {
-              /* Specified */
-              if ((addr != 0) && (addr != 2) && (addr != 4)) {
-                fprintf(stderr, "ERROR -> invalid addressing size a = %d\n", addr);
-                return 1;
-              }
-              parameters->jpwl_sens_addr = addr;
-
-            } else if (!strcmp(token, "a")) {
-              /* default */
-              parameters->jpwl_sens_addr = addr; /* auto for default size */
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid addressing selection = %s\n", token);
-              return 1;
-            };
-
-          }
-
-          /* search sensitivity size */
-          if (*token == 'z') {
-
-
-            size = 1; /* predefined: 1 byte */
-
-            if(sscanf(token, "z=%d", &size) == 1) {
-              /* Specified */
-              if ((size != 0) && (size != 1) && (size != 2)) {
-                fprintf(stderr, "ERROR -> invalid sensitivity size z = %d\n", size);
-                return 1;
-              }
-              parameters->jpwl_sens_size = size;
-
-            } else if (!strcmp(token, "a")) {
-              /* default */
-              parameters->jpwl_sens_size = size; /* 1 for default size */
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid size selection = %s\n", token);
-              return 1;
-            };
-
-          }
-
-          /* search range method */
-          if (*token == 'g') {
-
-
-            range = 0; /* predefined: 0 (packet) */
-
-            if(sscanf(token, "g=%d", &range) == 1) {
-              /* Specified */
-              if ((range < 0) || (range > 3)) {
-                fprintf(stderr, "ERROR -> invalid sensitivity range method g = %d\n", range);
-                return 1;
-              }
-              parameters->jpwl_sens_range = range;
-
-            } else if (!strcmp(token, "g")) {
-              /* default */
-              parameters->jpwl_sens_range = range;
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid range selection = %s\n", token);
-              return 1;
-            };
-
-          }
-
-          /* next token or bust */
-          token = strtok(NULL, ",");
-        };
-
-
-        /* some info */
-        fprintf(stdout, "Info: JPWL capabilities enabled\n");
-        parameters->jpwl_epc_on = true;
-
-      }
-      break;
-#endif /* USE_JPWL */
-/* <<UniPG */
-
-        /* ------------------------------------------------------ */
-
-      default:
-        fprintf(stderr, "ERROR -> Command line not valid\n");
-        return 1;
-    }
-  }
-
-  /* check for possible errors */
-  if (parameters->cp_cinema){
-    if(parameters->tcp_numlayers > 1){
-      parameters->cp_rsiz = STD_RSIZ;
-       fprintf(stdout,"Warning: DC profiles do not allow more than one quality layer. The codestream created will not be compliant with the DC profile\n");
-    }
-  }
-  if(img_fol->set_imgdir == 1){
-    if(!(parameters->infile[0] == 0)){
-      fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
-      return 1;
-    }
-    if(img_fol->set_out_format == 0){
-      fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
-      fprintf(stderr, "Only one format allowed! Valid formats are j2k and jp2!!\n");
-      return 1;
-    }
-    if(!((parameters->outfile[0] == 0))){
-      fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
-      fprintf(stderr, "Specify OutputFormat using -OutFor<FORMAT> !!\n");
-      return 1;
-    }
-  }else{
-    if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
-      fprintf(stderr, "Error: One of the options; -i or -ImgDir must be specified\n");
-      fprintf(stderr, "Error: When using -i; -o must be used\n");
-      fprintf(stderr, "usage: image_to_j2k -i image-file -o j2k/jp2-file (+ options)\n");
-      return 1;
-    }
-  }
-
-  if (parameters->decod_format == RAW_DFMT && raw_cp->rawWidth == 0) {
-      fprintf(stderr,"\nError: invalid raw image parameters\n");
-      fprintf(stderr,"Please use the Format option -F:\n");
-      fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
-            fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
-      fprintf(stderr,"Aborting\n");
-      return 1;
-  }
-
-  if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality)
-    && (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_alloc ^ parameters->cp_fixed_quality))) {
-    fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
-    return 1;
-  }        /* mod fixed_quality */
-
-  /* if no rate entered, lossless by default */
-  if (parameters->tcp_numlayers == 0) {
-    parameters->tcp_rates[0] = 0;  /* MOD antonin : losslessbug */
-    parameters->tcp_numlayers++;
-    parameters->cp_disto_alloc = 1;
-  }
-
-  if((parameters->cp_tx0 > parameters->image_offset_x0) || (parameters->cp_ty0 > parameters->image_offset_y0)) {
-    fprintf(stderr,
-      "Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
-      parameters->cp_tx0, parameters->image_offset_x0, parameters->cp_ty0, parameters->image_offset_y0);
-    return 1;
-  }
-
-  for (i = 0; i < parameters->numpocs; i++) {
-    if (parameters->POC[i].prg == -1) {
-      fprintf(stderr,
-        "Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
-        i + 1);
-    }
-  }
-
-  return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char **argv) {
-  bool bSuccess;
-  opj_cparameters_t parameters;  /* compression parameters */
-  img_fol_t img_fol;
-  opj_image_t *image = NULL;
-  int i,num_images;
-  int imageno;
-  dircnt_t *dirptr;
-  raw_cparameters_t raw_cp;
-  opj_codestream_info_t cstr_info;    /* Codestream information structure */
-  char indexfilename[OPJ_PATH_LEN];  /* index file name */
-  opj_stream_t *cio = 00;
-  opj_codec_t* cinfo = 00;
-  FILE *f = NULL;
-
-  /*
-  configure the event callbacks (not required)
-  setting of each callback is optionnal
-  */
-  /* set encoding parameters to default values */
-  opj_set_default_encoder_parameters(&parameters);
-
-  /* Initialize indexfilename and img_fol */
-  *indexfilename = 0;
-  memset(&img_fol,0,sizeof(img_fol_t));
-
-  /* parse input and get user encoding parameters */
-  if(parse_cmdline_encoder(argc, argv, &parameters,&img_fol, &raw_cp, indexfilename) == 1) {
-    return 1;
-  }
-
-  if (parameters.cp_cinema){
-    img_fol.rates = (float*)malloc(parameters.tcp_numlayers * sizeof(float));
-    for(i=0; i< parameters.tcp_numlayers; i++){
-      img_fol.rates[i] = parameters.tcp_rates[i];
-    }
-    cinema_parameters(&parameters);
-  }
-
-  /* Create comment for codestream */
-  if(parameters.cp_comment == NULL) {
-    const char comment[] = "Created by OpenJPEG version ";
-    const size_t clen = strlen(comment);
-    const char *version = opj_version();
-/* UniPG>> */
-#ifdef USE_JPWL
-    parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
-    sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
-#else
-    parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
-    sprintf(parameters.cp_comment,"%s%s", comment, version);
-#endif
-/* <<UniPG */
-  }
-
-  /* Read directory if necessary */
-  if(img_fol.set_imgdir==1){
-    num_images=get_num_images(img_fol.imgdirpath);
-    dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
-    if(dirptr){
-      dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char));  // Stores at max 10 image file names
-      dirptr->filename = (char**) malloc(num_images*sizeof(char*));
-      if(!dirptr->filename_buf){
-        return 0;
-      }
-      for(i=0;i<num_images;i++){
-        dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
-      }
-    }
-    if(load_images(dirptr,img_fol.imgdirpath)==1){
-      return 0;
-    }
-    if (num_images==0){
-      fprintf(stdout,"Folder is empty\n");
-      return 0;
-    }
-  }else{
-    num_images=1;
-  }
-  /*Encoding image one by one*/
-  for(imageno=0;imageno<num_images;imageno++)  {
-    image = NULL;
-    fprintf(stderr,"\n");
-
-    if(img_fol.set_imgdir==1){
-      if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
-        fprintf(stderr,"skipping file...\n");
-        continue;
-      }
-    }
-    switch(parameters.decod_format) {
-      case PGX_DFMT:
-        break;
-      case PXM_DFMT:
-        break;
-      case BMP_DFMT:
-        break;
-      case TIF_DFMT:
-        break;
-      case RAW_DFMT:
-        break;
-      case TGA_DFMT:
-        break;
-      case PNG_DFMT:
-        break;
-      default:
-        fprintf(stderr,"skipping file...\n");
-        continue;
-    }
-
-      /* decode the source image */
-      /* ----------------------- */
-
-      switch (parameters.decod_format) {
-        case PGX_DFMT:
-          image = pgxtoimage(parameters.infile, &parameters);
-          if (!image) {
-            fprintf(stderr, "Unable to load pgx file\n");
-            return 1;
-          }
-          break;
-
-        case PXM_DFMT:
-          image = pnmtoimage(parameters.infile, &parameters);
-          if (!image) {
-            fprintf(stderr, "Unable to load pnm file\n");
-            return 1;
-          }
-          break;
-
-        case BMP_DFMT:
-          image = bmptoimage(parameters.infile, &parameters);
-          if (!image) {
-            fprintf(stderr, "Unable to load bmp file\n");
-            return 1;
-          }
-          break;
-
-        case TIF_DFMT:
-          image = tiftoimage(parameters.infile, &parameters);
-          if (!image) {
-            fprintf(stderr, "Unable to load tiff file\n");
-            return 1;
-          }
-        break;
-
-        case RAW_DFMT:
-          image = rawtoimage(parameters.infile, &parameters, &raw_cp);
-          if (!image) {
-            fprintf(stderr, "Unable to load raw file\n");
-            return 1;
-          }
-        break;
-
-        case TGA_DFMT:
-          image = tgatoimage(parameters.infile, &parameters);
-          if (!image) {
-            fprintf(stderr, "Unable to load tga file\n");
-            return 1;
-          }
-        break;
-
-        case PNG_DFMT:
-          image = pngtoimage(parameters.infile, &parameters);
-          if (!image) {
-            fprintf(stderr, "Unable to load png file\n");
-            return 1;
-          }
-          break;
-    }
-      /* Decide if MCT should be used */
-      parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
-
-      if(parameters.cp_cinema){
-        cinema_setup_encoder(&parameters,image,&img_fol);
-      }
-
-      /* encode the destination image */
-      /* ---------------------------- */
-
-
-      cinfo = parameters.cod_format == J2K_CFMT ? opj_create_compress(CODEC_J2K) : opj_create_compress(CODEC_JP2);
-      opj_setup_encoder(cinfo, &parameters, image);
-      f = fopen(parameters.outfile, "wb");
-      if
-        (! f)
-      {
-        fprintf(stderr, "failed to encode image\n");
-        return 1;
-      }
-      /* open a byte stream for writing */
-      /* allocate memory for all tiles */
-      cio = opj_stream_create_default_file_stream(f,false);
-      if
-        (! cio)
-      {
-        return 1;
-      }
-      /* encode the image */
-      /*if (*indexfilename)          // If need to extract codestream information
-        bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
-        else*/
-      bSuccess = opj_start_compress(cinfo,image,cio);
-      bSuccess = bSuccess && opj_encode(cinfo, cio);
-      bSuccess = bSuccess && opj_end_compress(cinfo, cio);
-
-      if
-        (!bSuccess)
-      {
-        opj_stream_destroy(cio);
-        fclose(f);
-        fprintf(stderr, "failed to encode image\n");
-        return 1;
-      }
-
-      fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
-      /* close and free the byte stream */
-      opj_stream_destroy(cio);
-      fclose(f);
-
-      /* Write the index to disk */
-      if (*indexfilename) {
-        bSuccess = write_index_file(&cstr_info, indexfilename);
-        if (bSuccess) {
-          fprintf(stderr, "Failed to output index file\n");
-        }
-      }
-
-      /* free remaining compression structures */
-      opj_destroy_codec(cinfo);
-      if (*indexfilename)
-        opj_destroy_cstr_info(&cstr_info);
-
-      /* free image data */
-      opj_image_destroy(image);
-  }
-
-  /* free user parameters structure */
-  if(parameters.cp_comment) free(parameters.cp_comment);
-  if(parameters.cp_matrice) free(parameters.cp_matrice);
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/codec/index.c b/Utilities/gdcmopenjpeg-v2/codec/index.c
deleted file mode 100644
index dd14596..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/index.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include "openjpeg.h"
-#include "index.h"
-
-/* ------------------------------------------------------------------------------------ */
-
-/**
-Write a structured index to a file
- at param cstr_info Codestream information
- at param index Index filename
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
-  int tileno, compno, layno, resno, precno, pack_nb, x, y;
-  FILE *stream = NULL;
-  double total_disto = 0;
-/* UniPG>> */
-  int tilepartno;
-  char disto_on, numpix_on;
-
-#ifdef USE_JPWL
-  if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
-    return 0;
-#endif /* USE_JPWL */
-/* <<UniPG */
-
-  if (!cstr_info)
-    return 1;
-
-  stream = fopen(index, "w");
-  if (!stream) {
-    fprintf(stderr, "failed to open index file [%s] for writing\n", index);
-    return 1;
-  }
-
-  if (cstr_info->tile[0].distotile)
-    disto_on = 1;
-  else
-    disto_on = 0;
-
-  if (cstr_info->tile[0].numpix)
-    numpix_on = 1;
-  else
-    numpix_on = 0;
-
-  fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
-  fprintf(stream, "%d\n", cstr_info->prog);
-  fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
-  fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
-  fprintf(stream, "%d\n", cstr_info->numcomps);
-  fprintf(stream, "%d\n", cstr_info->numlayers);
-  fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
-
-  for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
-    fprintf(stream, "[%d,%d] ",
-      (1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno]));  /* based on tile 0 and component 0 */
-  }
-
-  fprintf(stream, "\n");
-/* UniPG>> */
-  fprintf(stream, "%d\n", cstr_info->main_head_start);
-/* <<UniPG */
-  fprintf(stream, "%d\n", cstr_info->main_head_end);
-  fprintf(stream, "%d\n", cstr_info->codestream_size);
-
-  fprintf(stream, "\nINFO ON TILES\n");
-  fprintf(stream, "tileno start_pos  end_hd  end_tile   nbparts");
-  if (disto_on)
-    fprintf(stream,"         disto");
-  if (numpix_on)
-    fprintf(stream,"     nbpix");
-  if (disto_on && numpix_on)
-    fprintf(stream,"  disto/nbpix");
-  fprintf(stream, "\n");
-
-  for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
-    fprintf(stream, "%4d %9d %9d %9d %9d",
-      cstr_info->tile[tileno].tileno,
-      cstr_info->tile[tileno].start_pos,
-      cstr_info->tile[tileno].end_header,
-      cstr_info->tile[tileno].end_pos,
-      cstr_info->tile[tileno].num_tps);
-    if (disto_on)
-      fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
-    if (numpix_on)
-      fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
-    if (disto_on && numpix_on)
-      fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
-    fprintf(stream, "\n");
-  }
-
-  for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
-    int start_pos, end_ph_pos, end_pos;
-    double disto = 0;
-    int max_numdecompos = 0;
-    pack_nb = 0;
-
-    for (compno = 0; compno < cstr_info->numcomps; compno++) {
-      if (max_numdecompos < cstr_info->numdecompos[compno])
-        max_numdecompos = cstr_info->numdecompos[compno];
-    }
-
-    fprintf(stream, "\nTILE %d DETAILS\n", tileno);
-    fprintf(stream, "part_nb tileno  start_pack num_packs  start_pos end_tph_pos   end_pos\n");
-    for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
-      fprintf(stream, "%4d %9d   %9d %9d  %9d %11d %9d\n",
-        tilepartno, tileno,
-        cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
-        cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
-        cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
-        cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
-        cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
-        );
-
-    if (cstr_info->prog == LRCP) {  /* LRCP */
-      fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
-      if (disto_on)
-        fprintf(stream, " disto");
-      fprintf(stream,"\n");
-
-      for (layno = 0; layno < cstr_info->numlayers; layno++) {
-        for (resno = 0; resno < max_numdecompos + 1; resno++) {
-          for (compno = 0; compno < cstr_info->numcomps; compno++) {
-            int prec_max;
-            if (resno > cstr_info->numdecompos[compno])
-              break;
-            prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-            for (precno = 0; precno < prec_max; precno++) {
-              start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-              end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-              end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-              disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-              fprintf(stream, "%4d %6d %7d %5d %6d  %6d    %6d     %6d %7d",
-                pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
-              if (disto_on)
-                fprintf(stream, " %8e", disto);
-              fprintf(stream, "\n");
-              total_disto += disto;
-              pack_nb++;
-            }
-          }
-        }
-      }
-    } /* LRCP */
-
-    else if (cstr_info->prog == RLCP) {  /* RLCP */
-      fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
-      if (disto_on)
-        fprintf(stream, " disto");
-      fprintf(stream,"\n");
-
-      for (resno = 0; resno < max_numdecompos + 1; resno++) {
-        for (layno = 0; layno < cstr_info->numlayers; layno++) {
-          for (compno = 0; compno < cstr_info->numcomps; compno++) {
-            int prec_max;
-            if (resno > cstr_info->numdecompos[compno])
-              break;
-            prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-            for (precno = 0; precno < prec_max; precno++) {
-              start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-              end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-              end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-              disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-              fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d   %9d %7d",
-                pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
-              if (disto_on)
-                fprintf(stream, " %8e", disto);
-              fprintf(stream, "\n");
-              total_disto += disto;
-              pack_nb++;
-            }
-          }
-        }
-      }
-    } /* RLCP */
-
-    else if (cstr_info->prog == RPCL) {  /* RPCL */
-
-      fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
-      if (disto_on)
-        fprintf(stream, " disto");
-      fprintf(stream,"\n");
-
-      for (resno = 0; resno < max_numdecompos + 1; resno++) {
-        int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-        for (precno = 0; precno < numprec; precno++) {
-          /* I suppose components have same XRsiz, YRsiz */
-          int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
-          int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
-          int x1 = x0 + cstr_info->tile_x;
-          int y1 = y0 + cstr_info->tile_y;
-          for (compno = 0; compno < cstr_info->numcomps; compno++) {
-            int pcnx = cstr_info->tile[tileno].pw[resno];
-            int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
-            int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
-            int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-            int precno_y = (int) floor( (float)precno/(float)pcnx );
-            if (resno > cstr_info->numdecompos[compno])
-              break;
-            for(y = y0; y < y1; y++) {
-              if (precno_y*pcy == y ) {
-                for (x = x0; x < x1; x++) {
-                  if (precno_x*pcx == x ) {
-                    for (layno = 0; layno < cstr_info->numlayers; layno++) {
-                      start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-                      end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-                      end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-                      disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-                      fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d   %9d %7d",
-                        pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
-                      if (disto_on)
-                        fprintf(stream, " %8e", disto);
-                      fprintf(stream, "\n");
-                      total_disto += disto;
-                      pack_nb++;
-                    }
-                  }
-                }/* x = x0..x1 */
-              }
-            }  /* y = y0..y1 */
-          } /* precno */
-        } /* compno */
-      } /* resno */
-    } /* RPCL */
-
-    else if (cstr_info->prog == PCRL) {  /* PCRL */
-      /* I suppose components have same XRsiz, YRsiz */
-      int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
-      int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
-      int x1 = x0 + cstr_info->tile_x;
-      int y1 = y0 + cstr_info->tile_y;
-
-      // Count the maximum number of precincts
-      int max_numprec = 0;
-      for (resno = 0; resno < max_numdecompos + 1; resno++) {
-        int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-        if (numprec > max_numprec)
-          max_numprec = numprec;
-      }
-
-      fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
-      if (disto_on)
-        fprintf(stream, " disto");
-      fprintf(stream,"\n");
-
-      for (precno = 0; precno < max_numprec; precno++) {
-        for (compno = 0; compno < cstr_info->numcomps; compno++) {
-          for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
-            int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-            int pcnx = cstr_info->tile[tileno].pw[resno];
-            int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
-            int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
-            int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-            int precno_y = (int) floor( (float)precno/(float)pcnx );
-            if (precno >= numprec)
-              continue;
-            for(y = y0; y < y1; y++) {
-              if (precno_y*pcy == y ) {
-                for (x = x0; x < x1; x++) {
-                  if (precno_x*pcx == x ) {
-                    for (layno = 0; layno < cstr_info->numlayers; layno++) {
-                      start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-                      end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-                      end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-                      disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-                      fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d   %9d %7d",
-                        pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
-                      if (disto_on)
-                        fprintf(stream, " %8e", disto);
-                      fprintf(stream, "\n");
-                      total_disto += disto;
-                      pack_nb++;
-                    }
-                  }
-                }/* x = x0..x1 */
-              }
-            }  /* y = y0..y1 */
-          } /* resno */
-        } /* compno */
-      } /* precno */
-    } /* PCRL */
-
-    else {  /* CPRL */
-      // Count the maximum number of precincts
-      int max_numprec = 0;
-      for (resno = 0; resno < max_numdecompos + 1; resno++) {
-        int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-        if (numprec > max_numprec)
-          max_numprec = numprec;
-      }
-
-      fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
-      if (disto_on)
-        fprintf(stream, " disto");
-      fprintf(stream,"\n");
-
-      for (compno = 0; compno < cstr_info->numcomps; compno++) {
-        /* I suppose components have same XRsiz, YRsiz */
-        int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
-        int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
-        int x1 = x0 + cstr_info->tile_x;
-        int y1 = y0 + cstr_info->tile_y;
-
-        for (precno = 0; precno < max_numprec; precno++) {
-          for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
-            int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
-            int pcnx = cstr_info->tile[tileno].pw[resno];
-            int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
-            int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
-            int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
-            int precno_y = (int) floor( (float)precno/(float)pcnx );
-            if (precno >= numprec)
-              continue;
-
-            for(y = y0; y < y1; y++) {
-              if (precno_y*pcy == y ) {
-                for (x = x0; x < x1; x++) {
-                  if (precno_x*pcx == x ) {
-                    for (layno = 0; layno < cstr_info->numlayers; layno++) {
-                      start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
-                      end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
-                      end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
-                      disto = cstr_info->tile[tileno].packet[pack_nb].disto;
-                      fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d   %9d %7d",
-                        pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
-                      if (disto_on)
-                        fprintf(stream, " %8e", disto);
-                      fprintf(stream, "\n");
-                      total_disto += disto;
-                      pack_nb++;
-                    }
-                  }
-                }/* x = x0..x1 */
-              }
-            } /* y = y0..y1 */
-          } /* resno */
-        } /* precno */
-      } /* compno */
-    } /* CPRL */
-  } /* tileno */
-
-  if (disto_on) {
-    fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
-    fprintf(stream, "%.8e\n", total_disto);  /* SE totale */
-  }
-/* UniPG>> */
-  /* print the markers' list */
-  if (cstr_info->marknum) {
-    fprintf(stream, "\nMARKER LIST\n");
-    fprintf(stream, "%d\n", cstr_info->marknum);
-    fprintf(stream, "type\tstart_pos    length\n");
-    for (x = 0; x < cstr_info->marknum; x++)
-      fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
-  }
-/* <<UniPG */
-  fclose(stream);
-
-  fprintf(stderr,"Generated index file %s\n", index);
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/codec/j2k_dump.c b/Utilities/gdcmopenjpeg-v2/codec/j2k_dump.c
deleted file mode 100644
index 6f66e15..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/j2k_dump.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#define USE_OPJ_DEPRECATED
-#include "openjpeg.h"
-#include "j2k.h"
-#include "jp2.h"
-#include "compat/getopt.h"
-#include "convert.h"
-#include "dirent.h"
-#include "index.h"
-
-#ifndef WIN32
-#include <strings.h>
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#endif
-
-/* ----------------------------------------------------------------------- */
-
-#define J2K_CFMT 0
-#define JP2_CFMT 1
-#define JPT_CFMT 2
-
-#define PXM_DFMT 10
-#define PGX_DFMT 11
-#define BMP_DFMT 12
-#define YUV_DFMT 13
-#define TIF_DFMT 14
-#define RAW_DFMT 15
-#define TGA_DFMT 16
-
-/* ----------------------------------------------------------------------- */
-
-typedef struct dircnt{
-  /** Buffer for holding images read from Directory*/
-  char *filename_buf;
-  /** Pointer to the buffer*/
-  char **filename;
-}dircnt_t;
-
-
-typedef struct img_folder{
-  /** The directory path of the folder containing input images*/
-  char *imgdirpath;
-  /** Output format*/
-  const char *out_format;
-  /** Enable option*/
-  char set_imgdir;
-  /** Enable Cod Format for output*/
-  char set_out_format;
-
-}img_fol_t;
-
-void decode_help_display() {
-  fprintf(stdout,"HELP\n----\n\n");
-  fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-/* UniPG>> */
-  fprintf(stdout,"List of parameters for the JPEG 2000 "
-#ifdef USE_JPWL
-    "+ JPWL "
-#endif /* USE_JPWL */
-    "decoder:\n");
-/* <<UniPG */
-  fprintf(stdout,"\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"  -ImgDir \n");
-  fprintf(stdout,"  Image file Directory path \n");
-  fprintf(stdout,"  -i <compressed file>\n");
-  fprintf(stdout,"    REQUIRED only if an Input image directory not specified\n");
-  fprintf(stdout,"    Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
-  fprintf(stdout,"    is identified based on its suffix.\n");
-  fprintf(stdout,"\n");
-}
-
-/* -------------------------------------------------------------------------- */
-
-int get_num_images(char *imgdirpath){
-  DIR *dir;
-  struct dirent* content;
-  int num_images = 0;
-
-  /*Reading the input images from given input directory*/
-
-  dir= opendir(imgdirpath);
-  if(!dir){
-    fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-    return 0;
-  }
-
-  while((content=readdir(dir))!=NULL){
-    if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-      continue;
-    num_images++;
-  }
-  return num_images;
-}
-
-int load_images(dircnt_t *dirptr, char *imgdirpath){
-  DIR *dir;
-  struct dirent* content;
-  int i = 0;
-
-  /*Reading the input images from given input directory*/
-
-  dir= opendir(imgdirpath);
-  if(!dir){
-    fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-    return 1;
-  }else  {
-    fprintf(stderr,"Folder opened successfully\n");
-  }
-
-  while((content=readdir(dir))!=NULL){
-    if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-      continue;
-
-    strcpy(dirptr->filename[i],content->d_name);
-    i++;
-  }
-  return 0;
-}
-
-int get_file_format(char *filename) {
-  unsigned int i;
-  static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "j2k", "jp2", "jpt", "j2c", "jpc" };
-  static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
-  char * ext = strrchr(filename, '.');
-  if (ext == NULL)
-    return -1;
-  ext++;
-  if(ext) {
-    for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
-      if(_strnicmp(ext, extension[i], 3) == 0) {
-        return format[i];
-      }
-    }
-  }
-
-  return -1;
-}
-
-char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
-  char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
-  char *temp_p, temp1[OPJ_PATH_LEN]="";
-
-  strcpy(image_filename,dirptr->filename[imageno]);
-  fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
-  parameters->decod_format = get_file_format(image_filename);
-  if (parameters->decod_format == -1)
-    return 1;
-  sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
-  strncpy(parameters->infile, infilename, sizeof(infilename));
-
-  //Set output file
-  strcpy(temp_ofname,strtok(image_filename,"."));
-  while((temp_p = strtok(NULL,".")) != NULL){
-    strcat(temp_ofname,temp1);
-    sprintf(temp1,".%s",temp_p);
-  }
-  if(img_fol->set_out_format==1){
-    sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
-    strncpy(parameters->outfile, outfilename, sizeof(outfilename));
-  }
-  return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
-  /* parse the command line */
-  int totlen;
-  option_t long_option[]={
-    {"ImgDir",REQ_ARG, NULL ,'y'},
-  };
-
-  const char optlist[] = "i:h";
-  totlen=sizeof(long_option);
-  img_fol->set_out_format = 0;
-  while (1) {
-    int c = getopt_long(argc, argv,optlist,long_option,totlen);
-    if (c == -1)
-      break;
-    switch (c) {
-      case 'i':      /* input file */
-      {
-        char *infile = optarg;
-        parameters->decod_format = get_file_format(infile);
-        switch(parameters->decod_format) {
-          case J2K_CFMT:
-          case JP2_CFMT:
-          case JPT_CFMT:
-            break;
-          default:
-            fprintf(stderr,
-              "!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
-              infile);
-            return 1;
-        }
-        strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'h':       /* display an help description */
-        decode_help_display();
-        return 1;
-
-        /* ------------------------------------------------------ */
-
-      case 'y':      /* Image Directory path */
-        {
-          img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
-          strcpy(img_fol->imgdirpath,optarg);
-          img_fol->set_imgdir=1;
-        }
-        break;
-
-        /* ----------------------------------------------------- */
-
-      default:
-        fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
-        break;
-    }
-  }
-
-  /* check for possible errors */
-  if(img_fol->set_imgdir==1){
-    if(!(parameters->infile[0]==0)){
-      fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
-      return 1;
-    }
-    if(img_fol->set_out_format == 0){
-      fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
-      fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
-      return 1;
-    }
-    if(!((parameters->outfile[0] == 0))){
-      fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
-      return 1;
-    }
-  }else{
-    if((parameters->infile[0] == 0) ) {
-      fprintf(stderr, "Error: One of the options -i or -ImgDir must be specified\n");
-      fprintf(stderr, "usage: image_to_j2k -i *.j2k/jp2/j2c (+ options)\n");
-      return 1;
-    }
-  }
-
-  return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char *argv[])
-{
-  int ret;
-  opj_dparameters_t parameters;  /* decompression parameters */
-  img_fol_t img_fol;
-  opj_image_t *image = NULL;
-  FILE *fsrc = NULL;
-  bool bResult;
-  int num_images;
-  int i,imageno;
-  dircnt_t *dirptr;
-  opj_codec_t* dinfo = NULL;  /* handle to a decompressor */
-  opj_stream_t *cio = NULL;
-  opj_codestream_info_t cstr_info;  /* Codestream information structure */
-  char indexfilename[OPJ_PATH_LEN];  /* index file name */
-  OPJ_INT32 l_tile_x0,l_tile_y0;
-  OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
-
-  /* configure the event callbacks (not required) */
-
-  /* set decoding parameters to default values */
-  opj_set_default_decoder_parameters(&parameters);
-
-  /* Initialize indexfilename and img_fol */
-  *indexfilename = 0;
-  memset(&img_fol,0,sizeof(img_fol_t));
-
-  /* parse input and get user encoding parameters */
-  if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol, indexfilename) == 1) {
-    return EXIT_FAILURE;
-  }
-
-  /* Initialize reading of directory */
-  if(img_fol.set_imgdir==1){
-    num_images=get_num_images(img_fol.imgdirpath);
-
-    dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
-    if(dirptr){
-      dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char));  // Stores at max 10 image file names
-      dirptr->filename = (char**) malloc(num_images*sizeof(char*));
-
-      if(!dirptr->filename_buf){
-        return EXIT_FAILURE;
-      }
-      for(i=0;i<num_images;i++){
-        dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
-      }
-    }
-    if(load_images(dirptr,img_fol.imgdirpath)==1){
-      return EXIT_FAILURE;
-    }
-    if (num_images==0){
-      fprintf(stdout,"Folder is empty\n");
-      return EXIT_FAILURE;
-    }
-  }else{
-    num_images=1;
-  }
-
-  /*Encoding image one by one*/
-  for(imageno = 0; imageno < num_images ; imageno++)
-  {
-    image = NULL;
-    fprintf(stderr,"\n");
-
-    if(img_fol.set_imgdir==1){
-      if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
-        fprintf(stderr,"skipping file...\n");
-        continue;
-      }
-    }
-
-    /* read the input file and put it in memory */
-    /* ---------------------------------------- */
-    fsrc = fopen(parameters.infile, "rb");
-    if (!fsrc) {
-      fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
-      return EXIT_FAILURE;
-    }
-    cio = opj_stream_create_default_file_stream(fsrc,true);
-    /* decode the code-stream */
-    /* ---------------------- */
-
-    switch (parameters.decod_format)
-    {
-      case J2K_CFMT:
-      {
-        /* JPEG-2000 codestream */
-
-        /* get a decoder handle */
-        dinfo = opj_create_decompress(CODEC_J2K);
-        break;
-      }
-      case JP2_CFMT:
-      {
-        /* JPEG 2000 compressed image data */
-        /* get a decoder handle */
-        dinfo = opj_create_decompress(CODEC_JP2);
-        break;
-      }
-      case JPT_CFMT:
-      {
-        /* JPEG 2000, JPIP */
-        /* get a decoder handle */
-        dinfo = opj_create_decompress(CODEC_JPT);
-        break;
-      }
-      default:
-        fprintf(stderr, "skipping file..\n");
-        opj_stream_destroy(cio);
-        continue;
-    }
-    /* catch events using our callbacks and give a local context */
-
-    /* setup the decoder decoding parameters using user parameters */
-    opj_setup_decoder(dinfo, &parameters);
-
-    /* decode the stream and fill the image structure */
-    /*    if (*indexfilename)        // If need to extract codestream information
-        image = opj_decode_with_info(dinfo, cio, &cstr_info);
-      else
-      */
-    bResult = opj_read_header(
-      dinfo,
-      &image,
-      &l_tile_x0,
-      &l_tile_y0,
-      &l_tile_width,
-      &l_tile_height,
-      &l_nb_tiles_x,
-      &l_nb_tiles_y,
-      cio);
-    //image = opj_decode(dinfo, cio);
-    //bResult = bResult && (image != 00);
-    //bResult = bResult && opj_end_decompress(dinfo,cio);
-    //if
-    //  (!image)
-    //{
-    //  fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-    //  opj_destroy_codec(dinfo);
-    //  opj_stream_destroy(cio);
-    //  fclose(fsrc);
-    //  return EXIT_FAILURE;
-    //}
-    /* dump image */
-    if(!image)
-      {
-      fprintf(stderr, "ERROR -> j2k_to_image: failed to read header\n");
-      return EXIT_FAILURE;
-      }
-    j2k_dump_image(stdout, image);
-
-    /* dump cp */
-    //j2k_dump_cp(stdout, image, dinfo->m_codec);
-
-    /* close the byte stream */
-    opj_stream_destroy(cio);
-    fclose(fsrc);
-    /* Write the index to disk */
-    if (*indexfilename) {
-      char bSuccess;
-      bSuccess = write_index_file(&cstr_info, indexfilename);
-      if (bSuccess) {
-        fprintf(stderr, "Failed to output index file\n");
-        ret = EXIT_FAILURE;
-      }
-    }
-
-    /* free remaining structures */
-    if (dinfo) {
-      opj_destroy_codec(dinfo);
-    }
-    /* free codestream information structure */
-    if (*indexfilename)
-      opj_destroy_cstr_info(&cstr_info);
-    /* free image data structure */
-    opj_image_destroy(image);
-
-  }
-
-  return ret;
-}
-//end main
diff --git a/Utilities/gdcmopenjpeg-v2/codec/j2k_to_image.c b/Utilities/gdcmopenjpeg-v2/codec/j2k_to_image.c
deleted file mode 100644
index 2d1635e..0000000
--- a/Utilities/gdcmopenjpeg-v2/codec/j2k_to_image.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#define USE_OPJ_DEPRECATED
-#include "openjpeg.h"
-#include "compat/getopt.h"
-#include "convert.h"
-#include "dirent.h"
-#include "index.h"
-
-#ifndef WIN32
-#include <strings.h>
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#endif
-
-/* ----------------------------------------------------------------------- */
-
-#define J2K_CFMT 0
-#define JP2_CFMT 1
-#define JPT_CFMT 2
-
-#define PXM_DFMT 10
-#define PGX_DFMT 11
-#define BMP_DFMT 12
-#define YUV_DFMT 13
-#define TIF_DFMT 14
-#define RAW_DFMT 15
-#define TGA_DFMT 16
-#define PNG_DFMT 17
-/* ----------------------------------------------------------------------- */
-
-typedef struct dircnt{
-  /** Buffer for holding images read from Directory*/
-  char *filename_buf;
-  /** Pointer to the buffer*/
-  char **filename;
-}dircnt_t;
-
-
-typedef struct img_folder{
-  /** The directory path of the folder containing input images*/
-  char *imgdirpath;
-  /** Output format*/
-  const char *out_format;
-  /** Enable option*/
-  char set_imgdir;
-  /** Enable Cod Format for output*/
-  char set_out_format;
-
-}img_fol_t;
-
-void decode_help_display() {
-  fprintf(stdout,"HELP\n----\n\n");
-  fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-/* UniPG>> */
-  fprintf(stdout,"List of parameters for the JPEG 2000 "
-#ifdef USE_JPWL
-    "+ JPWL "
-#endif /* USE_JPWL */
-    "decoder:\n");
-/* <<UniPG */
-  fprintf(stdout,"\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"  -ImgDir \n");
-  fprintf(stdout,"  Image file Directory path \n");
-  fprintf(stdout,"  -OutFor \n");
-  fprintf(stdout,"    REQUIRED only if -ImgDir is used\n");
-  fprintf(stdout,"    Need to specify only format without filename <BMP>  \n");
-  fprintf(stdout,"    Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA formats\n");
-  fprintf(stdout,"  -i <compressed file>\n");
-  fprintf(stdout,"    REQUIRED only if an Input image directory not specified\n");
-  fprintf(stdout,"    Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
-  fprintf(stdout,"    is identified based on its suffix.\n");
-  fprintf(stdout,"  -o <decompressed file>\n");
-  fprintf(stdout,"    REQUIRED\n");
-  fprintf(stdout,"    Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA files\n");
-  fprintf(stdout,"    Binary data is written to the file (not ascii). If a PGX\n");
-  fprintf(stdout,"    filename is given, there will be as many output files as there are\n");
-  fprintf(stdout,"    components: an indice starting from 0 will then be appended to the\n");
-  fprintf(stdout,"    output filename, just before the \"pgx\" extension. If a PGM filename\n");
-  fprintf(stdout,"    is given and there are more than one component, only the first component\n");
-  fprintf(stdout,"    will be written to the file.\n");
-  fprintf(stdout,"  -r <reduce factor>\n");
-  fprintf(stdout,"    Set the number of highest resolution levels to be discarded. The\n");
-  fprintf(stdout,"    image resolution is effectively divided by 2 to the power of the\n");
-  fprintf(stdout,"    number of discarded levels. The reduce factor is limited by the\n");
-  fprintf(stdout,"    smallest total number of decomposition levels among tiles.\n");
-  fprintf(stdout,"  -l <number of quality layers to decode>\n");
-  fprintf(stdout,"    Set the maximum number of quality layers to decode. If there are\n");
-  fprintf(stdout,"    less quality layers than the specified number, all the quality layers\n");
-  fprintf(stdout,"    are decoded.\n");
-  fprintf(stdout,"  -x  \n");
-  fprintf(stdout,"    Create an index file *.Idx (-x index_name.Idx) \n");
-  fprintf(stdout,"\n");
-/* UniPG>> */
-#ifdef USE_JPWL
-  fprintf(stdout,"  -W <options>\n");
-  fprintf(stdout,"    Activates the JPWL correction capability, if the codestream complies.\n");
-  fprintf(stdout,"    Options can be a comma separated list of <param=val> tokens:\n");
-  fprintf(stdout,"    c, c=numcomps\n");
-  fprintf(stdout,"       numcomps is the number of expected components in the codestream\n");
-  fprintf(stdout,"       (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
-#endif /* USE_JPWL */
-/* <<UniPG */
-  fprintf(stdout,"\n");
-}
-
-/* -------------------------------------------------------------------------- */
-
-int get_num_images(char *imgdirpath){
-  DIR *dir;
-  struct dirent* content;
-  int num_images = 0;
-
-  /*Reading the input images from given input directory*/
-
-  dir= opendir(imgdirpath);
-  if(!dir){
-    fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-    return 0;
-  }
-
-  while((content=readdir(dir))!=NULL){
-    if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-      continue;
-    num_images++;
-  }
-  return num_images;
-}
-
-int load_images(dircnt_t *dirptr, char *imgdirpath){
-  DIR *dir;
-  struct dirent* content;
-  int i = 0;
-
-  /*Reading the input images from given input directory*/
-
-  dir= opendir(imgdirpath);
-  if(!dir){
-    fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
-    return 1;
-  }else  {
-    fprintf(stderr,"Folder opened successfully\n");
-  }
-
-  while((content=readdir(dir))!=NULL){
-    if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
-      continue;
-
-    strcpy(dirptr->filename[i],content->d_name);
-    i++;
-  }
-  return 0;
-}
-
-int get_file_format(char *filename) {
-  unsigned int i;
-  static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
-  static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
-  char * ext = strrchr(filename, '.');
-  if (ext == NULL)
-    return -1;
-  ext++;
-  if(ext) {
-    for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
-      if(_strnicmp(ext, extension[i], 3) == 0) {
-        return format[i];
-      }
-    }
-  }
-
-  return -1;
-}
-
-char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
-  char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
-  char *temp_p, temp1[OPJ_PATH_LEN]="";
-
-  strcpy(image_filename,dirptr->filename[imageno]);
-  fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
-  parameters->decod_format = get_file_format(image_filename);
-  if (parameters->decod_format == -1)
-    return 1;
-  sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
-  strncpy(parameters->infile, infilename, sizeof(infilename));
-
-  //Set output file
-  strcpy(temp_ofname,strtok(image_filename,"."));
-  while((temp_p = strtok(NULL,".")) != NULL){
-    strcat(temp_ofname,temp1);
-    sprintf(temp1,".%s",temp_p);
-  }
-  if(img_fol->set_out_format==1){
-    sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
-    strncpy(parameters->outfile, outfilename, sizeof(outfilename));
-  }
-  return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
-  /* parse the command line */
-  int totlen;
-  option_t long_option[]={
-    {"ImgDir",REQ_ARG, NULL ,'y'},
-    {"OutFor",REQ_ARG, NULL ,'O'},
-  };
-
-  const char optlist[] = "i:o:r:l:hx:"
-
-/* UniPG>> */
-#ifdef USE_JPWL
-          "W:"
-#endif /* USE_JPWL */
-/* <<UniPG */
-          ;
-  totlen=sizeof(long_option);
-  img_fol->set_out_format = 0;
-  while (1) {
-    int c = getopt_long(argc, argv,optlist,long_option,totlen);
-    if (c == -1)
-      break;
-    switch (c) {
-      case 'i':      /* input file */
-      {
-        char *infile = optarg;
-        parameters->decod_format = get_file_format(infile);
-        switch(parameters->decod_format) {
-          case J2K_CFMT:
-          case JP2_CFMT:
-          case JPT_CFMT:
-            break;
-          default:
-            fprintf(stderr,
-              "!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
-              infile);
-            return 1;
-        }
-        strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'o':      /* output file */
-      {
-        char *outfile = optarg;
-        parameters->cod_format = get_file_format(outfile);
-        switch(parameters->cod_format) {
-          case PGX_DFMT:
-          case PXM_DFMT:
-          case BMP_DFMT:
-          case TIF_DFMT:
-          case RAW_DFMT:
-          case TGA_DFMT:
-          case PNG_DFMT:
-            break;
-          default:
-            fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
-            return 1;
-        }
-        strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'O':      /* output format */
-      {
-        char outformat[50];
-        char *of = optarg;
-        sprintf(outformat,".%s",of);
-        img_fol->set_out_format = 1;
-        parameters->cod_format = get_file_format(outformat);
-        switch(parameters->cod_format) {
-          case PGX_DFMT:
-            img_fol->out_format = "pgx";
-            break;
-          case PXM_DFMT:
-            img_fol->out_format = "ppm";
-            break;
-          case BMP_DFMT:
-            img_fol->out_format = "bmp";
-            break;
-          case TIF_DFMT:
-            img_fol->out_format = "tif";
-            break;
-          case RAW_DFMT:
-            img_fol->out_format = "raw";
-            break;
-          case TGA_DFMT:
-            img_fol->out_format = "raw";
-            break;
-          case PNG_DFMT:
-            img_fol->out_format = "png";
-            break;
-          default:
-            fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
-            return 1;
-            break;
-        }
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-
-      case 'r':    /* reduce option */
-      {
-        sscanf(optarg, "%d", &parameters->cp_reduce);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-
-      case 'l':    /* layering option */
-      {
-        sscanf(optarg, "%d", &parameters->cp_layer);
-      }
-      break;
-
-        /* ----------------------------------------------------- */
-
-      case 'h':       /* display an help description */
-        decode_help_display();
-        return 1;
-
-        /* ------------------------------------------------------ */
-
-      case 'y':      /* Image Directory path */
-        {
-          img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
-          strcpy(img_fol->imgdirpath,optarg);
-          img_fol->set_imgdir=1;
-        }
-        break;
-        /* ----------------------------------------------------- */
-      case 'x':      /* Creation of index file */
-        {
-          char *index = optarg;
-          strncpy(indexfilename, index, OPJ_PATH_LEN);
-        }
-        break;
-        /* ----------------------------------------------------- */
-        /* UniPG>> */
-#ifdef USE_JPWL
-
-      case 'W':       /* activate JPWL correction */
-      {
-        char *token = NULL;
-
-        token = strtok(optarg, ",");
-        while(token != NULL) {
-
-          /* search expected number of components */
-          if (*token == 'c') {
-
-            static int compno;
-
-            compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
-
-            if(sscanf(token, "c=%d", &compno) == 1) {
-              /* Specified */
-              if ((compno < 1) || (compno > 256)) {
-                fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
-                return 1;
-              }
-              parameters->jpwl_exp_comps = compno;
-
-            } else if (!strcmp(token, "c")) {
-              /* default */
-              parameters->jpwl_exp_comps = compno; /* auto for default size */
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
-              return 1;
-            };
-          }
-
-          /* search maximum number of tiles */
-          if (*token == 't') {
-
-            static int tileno;
-
-            tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
-
-            if(sscanf(token, "t=%d", &tileno) == 1) {
-              /* Specified */
-              if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
-                fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
-                return 1;
-              }
-              parameters->jpwl_max_tiles = tileno;
-
-            } else if (!strcmp(token, "t")) {
-              /* default */
-              parameters->jpwl_max_tiles = tileno; /* auto for default size */
-
-            } else {
-              fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
-              return 1;
-            };
-          }
-
-          /* next token or bust */
-          token = strtok(NULL, ",");
-        };
-        parameters->jpwl_correct = true;
-        fprintf(stdout, "JPWL correction capability activated\n");
-        fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
-      }
-      break;
-#endif /* USE_JPWL */
-/* <<UniPG */
-
-        /* ----------------------------------------------------- */
-
-      default:
-        fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
-        break;
-    }
-  }
-
-  /* check for possible errors */
-  if(img_fol->set_imgdir==1){
-    if(!(parameters->infile[0]==0)){
-      fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
-      return 1;
-    }
-    if(img_fol->set_out_format == 0){
-      fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
-      fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
-      return 1;
-    }
-    if(!((parameters->outfile[0] == 0))){
-      fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
-      return 1;
-    }
-  }else{
-    if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
-      fprintf(stderr, "Error: One of the options -i or -ImgDir must be specified\n");
-      fprintf(stderr, "Error: When using -i, -o must be used\n");
-      fprintf(stderr, "usage: image_to_j2k -i *.j2k/jp2/j2c -o *.pgm/ppm/pnm/pgx/bmp/tif/raw/tga(+ options)\n");
-      return 1;
-    }
-  }
-
-  return 0;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main(int argc, char **argv)
-{
-  int ret;
-  opj_dparameters_t parameters;  /* decompression parameters */
-  img_fol_t img_fol;
-  opj_image_t *image = NULL;
-  FILE *fsrc = NULL;
-  bool bResult;
-  int num_images;
-  int i,imageno;
-  dircnt_t *dirptr;
-  opj_codec_t* dinfo = NULL;  /* handle to a decompressor */
-  opj_stream_t *cio = NULL;
-  opj_codestream_info_t cstr_info;  /* Codestream information structure */
-  char indexfilename[OPJ_PATH_LEN];  /* index file name */
-  OPJ_INT32 l_tile_x0,l_tile_y0;
-  OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
-
-  /* configure the event callbacks (not required) */
-
-  /* set decoding parameters to default values */
-  opj_set_default_decoder_parameters(&parameters);
-
-  /* Initialize indexfilename and img_fol */
-  *indexfilename = 0;
-  memset(&img_fol,0,sizeof(img_fol_t));
-
-  /* parse input and get user encoding parameters */
-  if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol, indexfilename) == 1) {
-    return EXIT_FAILURE;
-  }
-
-  /* Initialize reading of directory */
-  if(img_fol.set_imgdir==1){
-    num_images=get_num_images(img_fol.imgdirpath);
-
-    dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
-    if(dirptr){
-      dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char));  // Stores at max 10 image file names
-      dirptr->filename = (char**) malloc(num_images*sizeof(char*));
-
-      if(!dirptr->filename_buf){
-        return EXIT_FAILURE;
-      }
-      for(i=0;i<num_images;i++){
-        dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
-      }
-    }
-    if(load_images(dirptr,img_fol.imgdirpath)==1){
-      return EXIT_FAILURE;
-    }
-    if (num_images==0){
-      fprintf(stdout,"Folder is empty\n");
-      return EXIT_FAILURE;
-    }
-  }else{
-    num_images=1;
-  }
-
-  /*Encoding image one by one*/
-  for(imageno = 0; imageno < num_images ; imageno++)
-  {
-    image = NULL;
-    fprintf(stderr,"\n");
-
-    if(img_fol.set_imgdir==1){
-      if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
-        fprintf(stderr,"skipping file...\n");
-        continue;
-      }
-    }
-
-    /* read the input file and put it in memory */
-    /* ---------------------------------------- */
-    fsrc = fopen(parameters.infile, "rb");
-    if
-      (!fsrc)
-    {
-      fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
-      return EXIT_FAILURE;
-    }
-    cio = opj_stream_create_default_file_stream(fsrc,true);
-    /* decode the code-stream */
-    /* ---------------------- */
-
-    switch
-      (parameters.decod_format)
-    {
-      case J2K_CFMT:
-      {
-        /* JPEG-2000 codestream */
-
-        /* get a decoder handle */
-        dinfo = opj_create_decompress(CODEC_J2K);
-        break;
-      }
-      case JP2_CFMT:
-      {
-        /* JPEG 2000 compressed image data */
-        /* get a decoder handle */
-        dinfo = opj_create_decompress(CODEC_JP2);
-        break;
-      }
-      case JPT_CFMT:
-      {
-        /* JPEG 2000, JPIP */
-        /* get a decoder handle */
-        dinfo = opj_create_decompress(CODEC_JPT);
-        break;
-      }
-      default:
-        fprintf(stderr, "skipping file..\n");
-        opj_stream_destroy(cio);
-        continue;
-    }
-    /* catch events using our callbacks and give a local context */
-
-    /* setup the decoder decoding parameters using user parameters */
-    opj_setup_decoder(dinfo, &parameters);
-
-    /* decode the stream and fill the image structure */
-    /*    if (*indexfilename)        // If need to extract codestream information
-        image = opj_decode_with_info(dinfo, cio, &cstr_info);
-      else
-      */
-    bResult = opj_read_header(
-      dinfo,
-      &image,
-      &l_tile_x0,
-      &l_tile_y0,
-      &l_tile_width,
-      &l_tile_height,
-      &l_nb_tiles_x,
-      &l_nb_tiles_y,
-      cio);
-    image = opj_decode(dinfo, cio);
-    bResult = bResult && (image != 00);
-    bResult = bResult && opj_end_decompress(dinfo,cio);
-    if
-      (!image)
-    {
-      fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-      opj_destroy_codec(dinfo);
-      opj_stream_destroy(cio);
-      fclose(fsrc);
-      return EXIT_FAILURE;
-    }
-
-    /* close the byte stream */
-    opj_stream_destroy(cio);
-    fclose(fsrc);
-    /* Write the index to disk */
-    if (*indexfilename) {
-      char bSuccess;
-      bSuccess = write_index_file(&cstr_info, indexfilename);
-      if (bSuccess) {
-        fprintf(stderr, "Failed to output index file\n");
-        ret = EXIT_FAILURE;
-      }
-    }
-
-    /* create output image */
-    /* ------------------- */
-    switch (parameters.cod_format) {
-    case PXM_DFMT:      /* PNM PGM PPM */
-      if (imagetopnm(image, parameters.outfile)) {
-        fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-        ret = EXIT_FAILURE;
-      }
-      else {
-        fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-        ret = EXIT_SUCCESS;
-      }
-      break;
-
-    case PGX_DFMT:      /* PGX */
-      if(imagetopgx(image, parameters.outfile)){
-        fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-        ret = EXIT_FAILURE;
-      }
-      else {
-        fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-        ret = EXIT_SUCCESS;
-      }
-      break;
-
-    case BMP_DFMT:      /* BMP */
-      if(imagetobmp(image, parameters.outfile)){
-        fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-        ret = EXIT_FAILURE;
-      }
-      else {
-        fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-        ret = EXIT_SUCCESS;
-      }
-      break;
-
-    case TIF_DFMT:      /* TIFF */
-      if(imagetotif(image, parameters.outfile)){
-        fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
-        ret = EXIT_FAILURE;
-      }
-      else {
-        fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
-        ret = EXIT_SUCCESS;
-      }
-      break;
-
-    case RAW_DFMT:      /* RAW */
-      if(imagetoraw(image, parameters.outfile)){
-        fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
-        ret = EXIT_FAILURE;
-      }
-      else {
-        fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
-        ret = EXIT_SUCCESS;
-      }
-      break;
-
-    case TGA_DFMT:      /* TGA */
-      if(imagetotga(image, parameters.outfile)){
-        fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
-        ret = EXIT_FAILURE;
-      }
-      else {
-        fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
-        ret = EXIT_SUCCESS;
-      }
-      break;
-
-    case PNG_DFMT:      /* PNG */
-      if(imagetopng(image, parameters.outfile)){
-        fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
-      }
-      else {
-        fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
-      }
-      break;
-
-    }
-
-    /* free remaining structures */
-    if
-      (dinfo)
-    {
-      opj_destroy_codec(dinfo);
-    }
-    /* free codestream information structure */
-    if (*indexfilename)
-      opj_destroy_cstr_info(&cstr_info);
-    /* free image data structure */
-    opj_image_destroy(image);
-
-  }
-  return ret;
-}
-//end main
diff --git a/Utilities/gdcmopenjpeg-v2/doc/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/doc/CMakeLists.txt
deleted file mode 100644
index f3dce22..0000000
--- a/Utilities/gdcmopenjpeg-v2/doc/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-find_package(Doxygen REQUIRED)
-
-# The Doxyfile.dox is poorly defined and produce output
-# in the source dir
-add_custom_target(doxygen
-# By default doxygen target is added to the 'all' target. Project is small
-# thus running doxygen is not too time consuming
-  ALL
-  ${DOXYGEN}
-  ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox
-  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
diff --git a/Utilities/gdcmopenjpeg-v2/doc/Doxyfile.dox b/Utilities/gdcmopenjpeg-v2/doc/Doxyfile.dox
deleted file mode 100644
index f0aa478..0000000
--- a/Utilities/gdcmopenjpeg-v2/doc/Doxyfile.dox
+++ /dev/null
@@ -1,234 +0,0 @@
-# Doxyfile 1.4.2
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME           = OpenJPEG
-PROJECT_NUMBER         = 
-OUTPUT_DIRECTORY       = ../
-CREATE_SUBDIRS         = NO
-OUTPUT_LANGUAGE        = English
-USE_WINDOWS_ENCODING   = YES
-BRIEF_MEMBER_DESC      = YES
-REPEAT_BRIEF           = YES
-ABBREVIATE_BRIEF       = "The $name class" \
-                         "The $name widget" \
-                         "The $name file" \
-                         is \
-                         provides \
-                         specifies \
-                         contains \
-                         represents \
-                         a \
-                         an \
-                         the
-ALWAYS_DETAILED_SEC    = NO
-INLINE_INHERITED_MEMB  = NO
-FULL_PATH_NAMES        = NO
-STRIP_FROM_PATH        = C://
-STRIP_FROM_INC_PATH    = 
-SHORT_NAMES            = NO
-JAVADOC_AUTOBRIEF      = YES
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP         = YES
-INHERIT_DOCS           = YES
-DISTRIBUTE_GROUP_DOC   = NO
-SEPARATE_MEMBER_PAGES  = NO
-TAB_SIZE               = 8
-ALIASES                = 
-OPTIMIZE_OUTPUT_FOR_C  = YES
-OPTIMIZE_OUTPUT_JAVA   = NO
-SUBGROUPING            = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL            = YES
-EXTRACT_PRIVATE        = YES
-EXTRACT_STATIC         = YES
-EXTRACT_LOCAL_CLASSES  = YES
-EXTRACT_LOCAL_METHODS  = NO
-HIDE_UNDOC_MEMBERS     = NO
-HIDE_UNDOC_CLASSES     = NO
-HIDE_FRIEND_COMPOUNDS  = NO
-HIDE_IN_BODY_DOCS      = NO
-INTERNAL_DOCS          = NO
-CASE_SENSE_NAMES       = NO
-HIDE_SCOPE_NAMES       = NO
-SHOW_INCLUDE_FILES     = YES
-INLINE_INFO            = YES
-SORT_MEMBER_DOCS       = YES
-SORT_BRIEF_DOCS        = NO
-SORT_BY_SCOPE_NAME     = NO
-GENERATE_TODOLIST      = YES
-GENERATE_TESTLIST      = YES
-GENERATE_BUGLIST       = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS       = 
-MAX_INITIALIZER_LINES  = 30
-SHOW_USED_FILES        = YES
-SHOW_DIRECTORIES       = NO
-FILE_VERSION_FILTER    = 
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET                  = NO
-WARNINGS               = YES
-WARN_IF_UNDOCUMENTED   = YES
-WARN_IF_DOC_ERROR      = YES
-WARN_NO_PARAMDOC       = NO
-WARN_FORMAT            = "$file:$line: $text"
-WARN_LOGFILE           = 
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT                  = ../libopenjpeg \
-						 ../jpwl
-FILE_PATTERNS          = *.h \
-                         *.c
-RECURSIVE              = NO
-EXCLUDE                = 
-EXCLUDE_SYMLINKS       = NO
-EXCLUDE_PATTERNS       = 
-EXAMPLE_PATH           = 
-EXAMPLE_PATTERNS       = *
-EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = 
-INPUT_FILTER           = 
-FILTER_PATTERNS        = 
-FILTER_SOURCE_FILES    = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER         = NO
-INLINE_SOURCES         = NO
-STRIP_CODE_COMMENTS    = YES
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION    = YES
-VERBATIM_HEADERS       = YES
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX     = NO
-COLS_IN_ALPHA_INDEX    = 5
-IGNORE_PREFIX          = 
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML          = YES
-HTML_OUTPUT            = ./html
-HTML_FILE_EXTENSION    = .html
-HTML_HEADER            = 
-HTML_FOOTER            = 
-HTML_STYLESHEET        = 
-HTML_ALIGN_MEMBERS     = YES
-GENERATE_HTMLHELP      = NO
-CHM_FILE               = 
-HHC_LOCATION           = 
-GENERATE_CHI           = NO
-BINARY_TOC             = NO
-TOC_EXPAND             = NO
-DISABLE_INDEX          = NO
-ENUM_VALUES_PER_LINE   = 4
-GENERATE_TREEVIEW      = NO
-TREEVIEW_WIDTH         = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX         = NO
-LATEX_OUTPUT           = latex
-LATEX_CMD_NAME         = latex
-MAKEINDEX_CMD_NAME     = makeindex
-COMPACT_LATEX          = NO
-PAPER_TYPE             = a4wide
-EXTRA_PACKAGES         = 
-LATEX_HEADER           = 
-PDF_HYPERLINKS         = NO
-USE_PDFLATEX           = NO
-LATEX_BATCHMODE        = NO
-LATEX_HIDE_INDICES     = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF           = NO
-RTF_OUTPUT             = rtf
-COMPACT_RTF            = NO
-RTF_HYPERLINKS         = NO
-RTF_STYLESHEET_FILE    = 
-RTF_EXTENSIONS_FILE    = 
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN           = NO
-MAN_OUTPUT             = man
-MAN_EXTENSION          = .3
-MAN_LINKS              = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML           = NO
-XML_OUTPUT             = xml
-XML_SCHEMA             = 
-XML_DTD                = 
-XML_PROGRAMLISTING     = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF   = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD       = NO
-PERLMOD_LATEX          = NO
-PERLMOD_PRETTY         = YES
-PERLMOD_MAKEVAR_PREFIX = 
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING   = YES
-MACRO_EXPANSION        = NO
-EXPAND_ONLY_PREDEF     = NO
-SEARCH_INCLUDES        = YES
-INCLUDE_PATH           = 
-INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = USE_JPWL \
-                         USE_JPSEC
-EXPAND_AS_DEFINED      = 
-SKIP_FUNCTION_MACROS   = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references   
-#---------------------------------------------------------------------------
-TAGFILES               = 
-GENERATE_TAGFILE       = 
-ALLEXTERNALS           = NO
-EXTERNAL_GROUPS        = YES
-PERL_PATH              = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS         = YES
-HIDE_UNDOC_RELATIONS   = YES
-HAVE_DOT               = NO
-CLASS_GRAPH            = YES
-COLLABORATION_GRAPH    = YES
-GROUP_GRAPHS           = YES
-UML_LOOK               = NO
-TEMPLATE_RELATIONS     = NO
-INCLUDE_GRAPH          = YES
-INCLUDED_BY_GRAPH      = YES
-CALL_GRAPH             = NO
-GRAPHICAL_HIERARCHY    = YES
-DIRECTORY_GRAPH        = YES
-DOT_IMAGE_FORMAT       = png
-DOT_PATH               = 
-DOTFILE_DIRS           = 
-MAX_DOT_GRAPH_WIDTH    = 1024
-MAX_DOT_GRAPH_HEIGHT   = 1024
-MAX_DOT_GRAPH_DEPTH    = 1000
-DOT_TRANSPARENT        = NO
-DOT_MULTI_TARGETS      = NO
-GENERATE_LEGEND        = YES
-DOT_CLEANUP            = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine   
-#---------------------------------------------------------------------------
-SEARCHENGINE           = NO
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/jpwl/CMakeLists.txt
deleted file mode 100644
index 015df01..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Makefile for the main JPWL OpenJPEG codecs: JPWL_ j2k_to_image and JPWL_image_to_j2k
-
-add_definitions(-DUSE_JPWL)
-
-set(OPJ_SRCS
-../libopenjpeg/bio.c
-../libopenjpeg/cio.c
-../libopenjpeg/dwt.c
-../libopenjpeg/event.c
-../libopenjpeg/image.c
-../libopenjpeg/j2k.c
-../libopenjpeg/j2k_lib.c
-../libopenjpeg/jp2.c
-../libopenjpeg/jpt.c
-../libopenjpeg/mct.c
-../libopenjpeg/mqc.c
-../libopenjpeg/openjpeg.c
-../libopenjpeg/pi.c
-../libopenjpeg/raw.c
-../libopenjpeg/t1.c
-../libopenjpeg/t2.c
-../libopenjpeg/tcd.c
-../libopenjpeg/tgt.c
-)
-set(JPWL_SRCS crc.c jpwl.c jpwl_lib.c rs.c)
-
-add_library(openjpeg_JPWL ${JPWL_SRCS} ${OPJ_SRCS})
-
-# Do the proper thing when building static...if only there was configured
-# headers or def files instead
-#if(NOT BUILD_SHARED_LIBS)
-#  add_definitions(-DOPJ_STATIC)
-#endif()
-
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  )
-
-find_package(TIFF REQUIRED)
-
-add_executable(JPWL_j2k_to_image
-../codec/convert.c ../codec/j2k_to_image.c
-)
-target_link_libraries(JPWL_j2k_to_image openjpeg_JPWL ${TIFF_LIBRARIES})
-if(UNIX)
-  target_link_libraries(JPWL_j2k_to_image m)
-endif()
-
-add_executable(JPWL_image_to_j2k
-../codec/convert.c ../codec/image_to_j2k.c)
-target_link_libraries(JPWL_image_to_j2k openjpeg_JPWL ${TIFF_LIBRARIES})
-if(UNIX)
-  target_link_libraries(JPWL_image_to_j2k m)
-endif()
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/README.txt b/Utilities/gdcmopenjpeg-v2/jpwl/README.txt
deleted file mode 100644
index e289e9e..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/README.txt
+++ /dev/null
@@ -1,136 +0,0 @@
-===============================================================================
-	JPEG2000 Part 11 (ISO/IEC 15444-11 JPWL) Software
-
-
-
-		Version 20061213
-===============================================================================
-
-
-
-
-
-1. Scope
-=============
-
-This document describes the installation and use of the JPWL module in the framework of OpenJPEG library.
-
-This implementation has been developed from OpenJPEG implementation of JPEG2000 standard, and for this reason it is written in C language.
-
-If you find some bugs or if you have problems using the encoder/decoder, please send an e-mail to jpwl at diei.unipg.it
-
-
-2. Installing the code
-==========================
-
-The JPWL code is integrated with the standard OpenJPEG library and codecs: it is activated by setting the macro USE_JPWL to defined in the preprocessor configuration options of your preferred C compiler.
-
-2.1. Compiling the source code in Windows
--------------------------------------------
-
-The "jpwl" directory is already populated with a couple of Visual C++ 6.0 workspaces
-
- * JPWL_image_to_j2k.dsw - Creates the encoder with JPWL functionalities
- * JPWL_j2k_to_image.dsw - Creates the decoder with JPWL functionalities
-
-2.2. Compiling the source code in Unix-like systems
------------------------------------------------------
-
-Under linux, enter the jpwl directory and type "make clean" and "make".
-
-
-3. Running the JPWL software
-=========================
-
-The options available at the command line are exactly the same of the base OpenJPEG codecs. In addition, there is a "-W" switch that activates JPWL functionalities.
-
-3.1. JPWL Encoder
--------------------
-
--W           : adoption of JPWL (Part 11) capabilities (-W params)
-               The parameters can be written and repeated in any order:
-               [h<tile><=type>,s<tile><=method>,a=<addr>,z=<size>,g=<range>,...
-                ...,p<tile:pack><=type>]
-
-                 h selects the header error protection (EPB): 'type' can be
-                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
-                   if 'tile' is absent, it applies to main and tile headers
-                   if 'tile' is present, it applies from that tile
-                     onwards, up to the next h<tile> spec, or to the last tile
-                     in the codestream (max. 16 specs)
-
-                 p selects the packet error protection (EEP/UEP with EPBs)
-                  to be applied to raw data: 'type' can be
-                   [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
-                   if 'tile:pack' is absent, it starts from tile 0, packet 0
-                   if 'tile:pack' is present, it applies from that tile
-                     and that packet onwards, up to the next packet spec
-                     or to the last packet in the last tile in the codestream
-                     (max. 16 specs)
-
-                 s enables sensitivity data insertion (ESD): 'method' can be
-                   [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
-                    4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
-                   if 'tile' is absent, it applies to main header only
-                   if 'tile' is present, it applies from that tile
-                     onwards, up to the next s<tile> spec, or to the last tile
-                     in the codestream (max. 16 specs)
-
-                 g determines the addressing mode: <range> can be
-                   [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]
-
-                 a determines the size of data addressing: <addr> can be
-                   2/4 bytes (small/large codestreams). If not set, auto-mode
-
-                 z determines the size of sensitivity values: <size> can be
-                   1/2 bytes, for the transformed pseudo-floating point value
-
-                 ex.:
- h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,s0=6,s3=-1,a=0,g=1,z=1
-                 means
-                   predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,
-                   CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,
-                   UEP rs(78,32) for packets 0 to 23 of tile 0,
-                   UEP rs(56,32) for packets 24 to the last of tile 0,
-                   UEP rs default for packets of tile 1,
-                   no UEP for packets 0 to 19 of tile 3,
-                   UEP CRC-32 for packets 20 of tile 3 to last tile,
-                   relative sensitivity ESD for MH,
-                   TSE ESD from TPH 0 to TPH 2, byte range with automatic
-                   size of addresses and 1 byte for each sensitivity value
-
-                 ex.:
-                       h,s,p
-                 means
-                   default protection to headers (MH and TPHs) as well as
-                   data packets, one ESD in MH
-
-                 N.B.: use the following recommendations when specifying
-                       the JPWL parameters list
-                   - when you use UEP, always pair the 'p' option with 'h'
-
-3.2. JPWL Decoder
--------------------
-
-  -W <options>
-    Activates the JPWL correction capability, if the codestream complies.
-    Options can be a comma separated list of <param=val> tokens:
-    c, c=numcomps
-       numcomps is the number of expected components in the codestream
-       (search of first EPB rely upon this, default is 3)
-
-
-4. Known bugs and limitations
-===============================
-
-4.1. Bugs
------------
-
-* It is not possible to save a JPWL encoded codestream using the wrapped file format (i.e. JP2): only raw file format (i.e. J2K) is working
-
-4.2. Limitations
-------------------
-
-* When specifying an UEP protection, you need to activate even TPH protection for those tiles where there is a protection of the packets
-* RED insertion is not currently implemented at the decoder
-* JPWL at entropy coding level is not implemented
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/crc.c b/Utilities/gdcmopenjpeg-v2/jpwl/crc.c
deleted file mode 100644
index 4761317..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/crc.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-#include "crc.h"
-
-/**
- at file crc.c
- at brief Functions used to compute the 16- and 32-bit CRC of byte arrays
-
-*/
-
-/** file: CRC16.CPP
- *
- * CRC - Cyclic Redundancy Check (16-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned short),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC16 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- *
- */
-const unsigned short CRC16_table[256] = {
-  0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
-  0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
-  0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
-  0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
-  0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
-  0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
-  0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
-  0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
-  0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
-  0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
-  0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
-  0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
-  0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
-  0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
-  0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
-  0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
-  0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
-  0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
-  0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
-  0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
-  0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
-  0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
-  0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
-  0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
-  0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
-  0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
-  0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
-  0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
-  0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
-  0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
-  0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
-  0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-};
-
-void updateCRC16(unsigned short *crc, unsigned char data) {
-  *crc = CRC16_table[(*crc >> 8) & 0xFF] ^ (*crc << 8) ^ data;
-};
-
-
-/** file: CRC32.CPP
- *
- * CRC - Cyclic Redundancy Check (32-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned long),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC32 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- *
- */
-const unsigned long CRC32_table[256] = {
-  0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
-  0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
-  0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
-  0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
-  0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
-  0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
-  0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
-  0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
-  0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
-  0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
-  0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
-  0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
-  0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
-  0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
-  0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
-  0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
-  0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
-  0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
-  0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
-  0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-  0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
-  0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
-  0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
-  0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
-  0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
-  0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
-  0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
-  0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
-  0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
-  0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
-  0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
-  0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
-  0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
-  0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
-  0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
-  0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
-  0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
-  0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
-  0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
-  0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-  0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
-  0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
-  0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-void updateCRC32(unsigned long *crc, unsigned char data) {
-  *crc = CRC32_table[(unsigned char) *crc ^ data] ^ ((*crc >> 8) & 0x00FFFFFF);
-};
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/crc.h b/Utilities/gdcmopenjpeg-v2/jpwl/crc.h
deleted file mode 100644
index 4d51119..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/crc.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-/**
- at file crc.h
- at brief Functions used to compute the 16- and 32-bit CRC of byte arrays
-
-*/
-
-#ifndef __CRC16_HEADER__
-#define __CRC16_HEADER__
-
-/** file: CRC16.HPP
- *
- * CRC - Cyclic Redundancy Check (16-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned short),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC16 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- *
- */
-void updateCRC16(unsigned short *, unsigned char);
-
-#endif /* __CRC16_HEADER__ */
-
-
-#ifndef __CRC32_HEADER__
-#define __CRC32_HEADER__
-
-/** file: CRC32.HPP
- *
- * CRC - Cyclic Redundancy Check (32-bit)
- *
- * A CRC-checksum is used to be sure, the data hasn't changed or is false.
- * To create a CRC-checksum, initialise a check-variable (unsigned short),
- * and set this to zero. Than call for every byte in the file (e.g.) the
- * procedure updateCRC32 with this check-variable as the first parameter,
- * and the byte as the second. At the end, the check-variable contains the
- * CRC-checksum.
- *
- * implemented by Michael Neumann, 14.06.1998
- *
- */
-void updateCRC32(unsigned long *, unsigned char);
-
-#endif /* __CRC32_HEADER__ */
-
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/jpwl.c b/Utilities/gdcmopenjpeg-v2/jpwl/jpwl.c
deleted file mode 100644
index 6595dd5..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/jpwl.c
+++ /dev/null
@@ -1,1356 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "../libopenjpeg/opj_includes.h"
-
-#ifdef USE_JPWL
-
-/** @defgroup JPWL JPWL - JPEG-2000 Part11 (JPWL) codestream manager */
-/*@{*/
-
-/** @name Local static variables */
-/*@{*/
-
-/** number of JPWL prepared markers */
-static int jwmarker_num;
-/** properties of JPWL markers to insert */
-static jpwl_marker_t jwmarker[JPWL_MAX_NO_MARKERS];
-
-/*@}*/
-
-/*@}*/
-
-/** @name Local static functions */
-/*@{*/
-
-/** create an EPC marker segment
- at param j2k J2K compressor handle
- at param esd_on true if ESD is activated
- at param red_on true if RED is activated
- at param epb_on true if EPB is activated
- at param info_on true if informative techniques are activated
- at return returns the freshly created EPC
-*/
-jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, bool esd_on, bool red_on, bool epb_on, bool info_on);
-
-/*@}*/
-
-/** create an EPC marker segment
- at param j2k J2K compressor handle
- at param comps considered component (-1=average, 0/1/2/...=component no.)
- at param addrm addressing mode (0=packet, 1=byte range, 2=packet range, 3=reserved)
- at param ad_size size of addresses (2/4 bytes)
- at param senst sensitivity type
- at param se_size sensitivity values size (1/2 bytes)
- at param tileno tile where this ESD lies (-1 means MH)
- at param svalnum number of sensitivity values (if 0, they will be automatically filled)
- at param sensval pointer to an array of sensitivity values (if NULL, they will be automatically filled)
- at return returns the freshly created ESD
-*/
-jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comps, unsigned char addrm, unsigned char ad_size,
-                unsigned char senst, int se_size, int tileno,
-                unsigned long int svalnum, void *sensval);
-
-/** this function is used to compare two JPWL markers based on
-their relevant wishlist position
- at param arg1 pointer to first marker
- at param arg2 pointer to second marker
- at return 1 if arg1>arg2, 0 if arg1=arg2, -1 if arg1<arg2
-*/
-int jpwl_markcomp(const void *arg1, const void *arg2);
-
-/** write an EPB MS to a buffer
- at param j2k J2K compressor handle
- at param epbmark pointer to the EPB MS
- at param buf pointer to the memory buffer
-*/
-void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf);
-
-/** write an EPC MS to a buffer
- at param j2k J2K compressor handle
- at param epcmark pointer to the EPC MS
- at param buf pointer to the memory buffer
-*/
-void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epcmark, unsigned char *buf);
-
-/** write an ESD MS to a buffer
- at param j2k J2K compressor handle
- at param esdmark pointer to the ESD MS
- at param buf pointer to the memory buffer
-*/
-void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
-
-/*-----------------------------------------------------------------*/
-
-void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
-
-  int mm;
-
-  /* let's reset some settings */
-
-  /* clear the existing markers */
-  for (mm = 0; mm < jwmarker_num; mm++) {
-
-    switch (jwmarker[mm].id) {
-
-    case J2K_MS_EPB:
-      opj_free(jwmarker[mm].m.epbmark);
-      break;
-
-    case J2K_MS_EPC:
-      opj_free(jwmarker[mm].m.epcmark);
-      break;
-
-    case J2K_MS_ESD:
-      opj_free(jwmarker[mm].m.esdmark);
-      break;
-
-    case J2K_MS_RED:
-      opj_free(jwmarker[mm].m.redmark);
-      break;
-
-    default:
-      break;
-    }
-  }
-
-  /* clear the marker structure array */
-  memset(jwmarker, 0, sizeof(jpwl_marker_t) * JPWL_MAX_NO_MARKERS);
-
-  /* no more markers in the list */
-  jwmarker_num = 0;
-
-  /* let's begin creating a marker list, according to user wishes */
-  jpwl_prepare_marks(j2k, cio, image);
-
-  /* now we dump the JPWL markers on the codestream */
-  jpwl_dump_marks(j2k, cio, image);
-
-  /* do not know exactly what is this for,
-  but it gets called during index creation */
-  j2k->pos_correction = 0;
-
-}
-
-void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
-
-  if (!cstr_info)
-    return;
-
-  /* expand the list? */
-  if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
-    cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
-    cstr_info->marker = opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
-  }
-
-  /* add the marker */
-  cstr_info->marker[cstr_info->marknum].type = type;
-  cstr_info->marker[cstr_info->marknum].pos = pos;
-  cstr_info->marker[cstr_info->marknum].len = len;
-  cstr_info->marknum++;
-
-}
-
-void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
-
-  unsigned short int socsiz_len = 0;
-  int ciopos = cio_tell(cio), soc_pos = j2k->cstr_info->main_head_start;
-  unsigned char *socp = NULL;
-
-  int tileno, acc_tpno, tpno, tilespec, hprot, sens, pprot, packspec, lastileno, packno;
-
-  jpwl_epb_ms_t *epb_mark;
-  jpwl_epc_ms_t *epc_mark;
-  jpwl_esd_ms_t *esd_mark;
-
-  /* find (SOC + SIZ) length */
-  /* I assume SIZ is always the first marker after SOC */
-  cio_seek(cio, soc_pos + 4);
-  socsiz_len = (unsigned short int) cio_read(cio, 2) + 4; /* add the 2 marks length itself */
-  cio_seek(cio, soc_pos + 0);
-  socp = cio_getbp(cio); /* pointer to SOC */
-
-  /*
-   EPC MS for Main Header: if we are here it's required
-  */
-  /* create the EPC */
-  if ((epc_mark = jpwl_epc_create(
-      j2k,
-      j2k->cp->esd_on, /* is ESD present? */
-      j2k->cp->red_on, /* is RED present? */
-      j2k->cp->epb_on, /* is EPB present? */
-      false /* are informative techniques present? */
-    ))) {
-
-    /* Add this marker to the 'insertanda' list */
-    if (epc_mark) {
-      jwmarker[jwmarker_num].id = J2K_MS_EPC; /* its type */
-      jwmarker[jwmarker_num].m.epcmark = epc_mark; /* the EPC */
-      jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
-      jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.1; /* not so first */
-      jwmarker[jwmarker_num].len = epc_mark->Lepc; /* its length */
-      jwmarker[jwmarker_num].len_ready = true; /* ready */
-      jwmarker[jwmarker_num].pos_ready = true; /* ready */
-      jwmarker[jwmarker_num].parms_ready = false; /* not ready */
-      jwmarker[jwmarker_num].data_ready = true; /* ready */
-      jwmarker_num++;
-    };
-
-    opj_event_msg(j2k->cinfo, EVT_INFO,
-      "MH  EPC : setting %s%s%s\n",
-      j2k->cp->esd_on ? "ESD, " : "",
-      j2k->cp->red_on ? "RED, " : "",
-      j2k->cp->epb_on ? "EPB, " : ""
-      );
-
-  } else {
-    /* ooops, problems */
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create MH EPC\n");
-  };
-
-  /*
-   ESD MS for Main Header
-  */
-  /* first of all, must MH have an ESD MS? */
-  if (j2k->cp->esd_on && (j2k->cp->sens_MH >= 0)) {
-
-    /* Create the ESD */
-    if ((esd_mark = jpwl_esd_create(
-      j2k, /* this encoder handle */
-      -1, /* we are averaging over all components */
-      (unsigned char) j2k->cp->sens_range, /* range method */
-      (unsigned char) j2k->cp->sens_addr, /* sensitivity addressing */
-      (unsigned char) j2k->cp->sens_MH, /* sensitivity method */
-      j2k->cp->sens_size, /* sensitivity size */
-      -1, /* this ESD is in main header */
-      0 /*j2k->cstr_info->num*/, /* number of packets in codestream */
-      NULL /*sensval*/ /* pointer to sensitivity data of packets */
-      ))) {
-
-      /* Add this marker to the 'insertanda' list */
-      if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-        jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
-        jwmarker[jwmarker_num].m.esdmark = esd_mark; /* the EPB */
-        jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* we choose to place it after SIZ */
-        jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
-        jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
-        jwmarker[jwmarker_num].len_ready = true; /* not ready, yet */
-        jwmarker[jwmarker_num].pos_ready = true; /* ready */
-        jwmarker[jwmarker_num].parms_ready = true; /* not ready */
-        jwmarker[jwmarker_num].data_ready = false; /* not ready */
-        jwmarker_num++;
-      }
-
-      opj_event_msg(j2k->cinfo, EVT_INFO,
-        "MH  ESDs: method %d\n",
-        j2k->cp->sens_MH
-        );
-
-    } else {
-      /* ooops, problems */
-      opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create MH ESD\n");
-    };
-
-  }
-
-  /*
-   ESD MSs for Tile Part Headers
-  */
-  /* cycle through tiles */
-  sens = -1; /* default spec: no ESD */
-  tilespec = 0; /* first tile spec */
-  acc_tpno = 0;
-  for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
-
-    opj_event_msg(j2k->cinfo, EVT_INFO,
-      "Tile %d has %d tile part(s)\n",
-      tileno, j2k->cstr_info->tile[tileno].num_tps
-      );
-
-    /* for every tile part in the tile */
-    for (tpno = 0; tpno < j2k->cstr_info->tile[tileno].num_tps; tpno++, acc_tpno++) {
-
-      int sot_len, Psot, Psotp, mm;
-      unsigned long sot_pos, post_sod_pos;
-
-      unsigned long int left_THmarks_len;
-
-      /******* sot_pos = j2k->cstr_info->tile[tileno].start_pos; */
-      sot_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos;
-      cio_seek(cio, sot_pos + 2);
-      sot_len = cio_read(cio, 2); /* SOT Len */
-      cio_skip(cio, 2);
-      Psotp = cio_tell(cio);
-      Psot = cio_read(cio, 4); /* tile length */
-
-      /******* post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1; */
-      post_sod_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_end_header + 1;
-      left_THmarks_len = post_sod_pos - sot_pos;
-
-      /* add all the lengths of the markers which are len-ready and stay within SOT and SOD */
-      for (mm = 0; mm < jwmarker_num; mm++) {
-        if ((jwmarker[mm].pos >= sot_pos) && (jwmarker[mm].pos < post_sod_pos)) {
-          if (jwmarker[mm].len_ready)
-            left_THmarks_len += jwmarker[mm].len + 2;
-          else {
-            opj_event_msg(j2k->cinfo, EVT_ERROR, "MS %x in %f is not len-ready: could not set up TH EPB\n",
-              jwmarker[mm].id, jwmarker[mm].dpos);
-            exit(1);
-          }
-        }
-      }
-
-      /******* if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->sens_TPH_tileno[tilespec] == tileno)) */
-      if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->sens_TPH_tileno[tilespec] == acc_tpno))
-        /* we got a specification from this tile onwards */
-        sens = j2k->cp->sens_TPH[tilespec++];
-
-      /* must this TPH have an ESD MS? */
-      if (j2k->cp->esd_on && (sens >= 0)) {
-
-        /* Create the ESD */
-        if ((esd_mark = jpwl_esd_create(
-          j2k, /* this encoder handle */
-          -1, /* we are averaging over all components */
-          (unsigned char) j2k->cp->sens_range, /* range method */
-          (unsigned char) j2k->cp->sens_addr, /* sensitivity addressing size */
-          (unsigned char) sens, /* sensitivity method */
-          j2k->cp->sens_size, /* sensitivity value size */
-          tileno, /* this ESD is in a tile */
-          0, /* number of packets in codestream */
-          NULL /* pointer to sensitivity data of packets */
-          ))) {
-
-          /* Add this marker to the 'insertanda' list */
-          if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-            jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
-            jwmarker[jwmarker_num].m.esdmark = esd_mark; /* the EPB */
-            /****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
-            jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
-            jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
-            jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
-            jwmarker[jwmarker_num].len_ready = true; /* ready, yet */
-            jwmarker[jwmarker_num].pos_ready = true; /* ready */
-            jwmarker[jwmarker_num].parms_ready = true; /* not ready */
-            jwmarker[jwmarker_num].data_ready = false; /* ready */
-            jwmarker_num++;
-          }
-
-          /* update Psot of the tile  */
-          cio_seek(cio, Psotp);
-          cio_write(cio, Psot + esd_mark->Lesd + 2, 4);
-
-          opj_event_msg(j2k->cinfo, EVT_INFO,
-            /******* "TPH ESDs: tile %02d, method %d\n", */
-            "TPH ESDs: tile %02d, part %02d, method %d\n",
-            /******* tileno, */
-            tileno, tpno,
-            sens
-            );
-
-        } else {
-          /* ooops, problems */
-          /***** opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH ESD #%d\n", tileno); */
-          opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH ESD #%d,%d\n", tileno, tpno);
-        };
-
-      }
-
-    }
-
-  };
-
-  /*
-   EPB MS for Main Header
-  */
-  /* first of all, must MH have an EPB MS? */
-  if (j2k->cp->epb_on && (j2k->cp->hprot_MH > 0)) {
-
-    int mm;
-
-    /* position of SOT */
-    unsigned int sot_pos = j2k->cstr_info->main_head_end + 1;
-
-    /* how much space is there between end of SIZ and beginning of SOT? */
-    int left_MHmarks_len = sot_pos - socsiz_len;
-
-    /* add all the lengths of the markers which are len-ready and stay within SOC and SOT */
-    for (mm = 0; mm < jwmarker_num; mm++) {
-      if ((jwmarker[mm].pos >=0) && (jwmarker[mm].pos < sot_pos)) {
-        if (jwmarker[mm].len_ready)
-          left_MHmarks_len += jwmarker[mm].len + 2;
-        else {
-          opj_event_msg(j2k->cinfo, EVT_ERROR, "MS %x in %f is not len-ready: could not set up MH EPB\n",
-            jwmarker[mm].id, jwmarker[mm].dpos);
-          exit(1);
-        }
-      }
-    }
-
-    /* Create the EPB */
-    if ((epb_mark = jpwl_epb_create(
-      j2k, /* this encoder handle */
-      true, /* is it the latest? */
-      true, /* is it packed? not for now */
-      -1, /* we are in main header */
-      0, /* its index is 0 (first) */
-      j2k->cp->hprot_MH, /* protection type parameters of data */
-      socsiz_len, /* pre-data: only SOC+SIZ */
-      left_MHmarks_len /* post-data: from SOC to SOT, and all JPWL markers within */
-      ))) {
-
-      /* Add this marker to the 'insertanda' list */
-      if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-        jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
-        jwmarker[jwmarker_num].m.epbmark = epb_mark; /* the EPB */
-        jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
-        jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
-        jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
-        jwmarker[jwmarker_num].len_ready = true; /* ready */
-        jwmarker[jwmarker_num].pos_ready = true; /* ready */
-        jwmarker[jwmarker_num].parms_ready = true; /* ready */
-        jwmarker[jwmarker_num].data_ready = false; /* not ready */
-        jwmarker_num++;
-      }
-
-      opj_event_msg(j2k->cinfo, EVT_INFO,
-        "MH  EPB : prot. %d\n",
-        j2k->cp->hprot_MH
-        );
-
-    } else {
-      /* ooops, problems */
-      opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create MH EPB\n");
-    };
-  }
-
-  /*
-   EPB MSs for Tile Parts
-  */
-  /* cycle through TPHs */
-  hprot = j2k->cp->hprot_MH; /* default spec */
-  tilespec = 0; /* first tile spec */
-  lastileno = 0;
-  packspec = 0;
-  pprot = -1;
-  acc_tpno = 0;
-  for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
-
-    opj_event_msg(j2k->cinfo, EVT_INFO,
-      "Tile %d has %d tile part(s)\n",
-      tileno, j2k->cstr_info->tile[tileno].num_tps
-      );
-
-    /* for every tile part in the tile */
-    for (tpno = 0; tpno < j2k->cstr_info->tile[tileno].num_tps; tpno++, acc_tpno++) {
-
-      int sot_len, Psot, Psotp, mm, epb_index = 0, prot_len = 0;
-      unsigned long sot_pos, post_sod_pos;
-      unsigned long int left_THmarks_len/*, epbs_len = 0*/;
-      int startpack = 0, stoppack = j2k->cstr_info->packno;
-      int first_tp_pack, last_tp_pack;
-      jpwl_epb_ms_t *tph_epb = NULL;
-
-      /****** sot_pos = j2k->cstr_info->tile[tileno].start_pos; */
-      sot_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos;
-      cio_seek(cio, sot_pos + 2);
-      sot_len = cio_read(cio, 2); /* SOT Len */
-      cio_skip(cio, 2);
-      Psotp = cio_tell(cio);
-      Psot = cio_read(cio, 4); /* tile length */
-
-      /* a-priori length of the data dwelling between SOT and SOD */
-      /****** post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1; */
-      post_sod_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_end_header + 1;
-      left_THmarks_len = post_sod_pos - (sot_pos + sot_len + 2);
-
-      /* add all the lengths of the JPWL markers which are len-ready and stay within SOT and SOD */
-      for (mm = 0; mm < jwmarker_num; mm++) {
-        if ((jwmarker[mm].pos >= sot_pos) && (jwmarker[mm].pos < post_sod_pos)) {
-          if (jwmarker[mm].len_ready)
-            left_THmarks_len += jwmarker[mm].len + 2;
-          else {
-            opj_event_msg(j2k->cinfo, EVT_ERROR, "MS %x in %f is not len-ready: could not set up TH EPB\n",
-              jwmarker[mm].id, jwmarker[mm].dpos);
-            exit(1);
-          }
-        }
-      }
-
-      /****** if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->hprot_TPH_tileno[tilespec] == tileno)) */
-      if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->hprot_TPH_tileno[tilespec] == acc_tpno))
-        /* we got a specification from this tile part onwards */
-        hprot = j2k->cp->hprot_TPH[tilespec++];
-
-      /* must this TPH have an EPB MS? */
-      if (j2k->cp->epb_on && (hprot > 0)) {
-
-        /* Create the EPB */
-        if ((epb_mark = jpwl_epb_create(
-          j2k, /* this encoder handle */
-          false, /* is it the latest? in TPH, no for now (if huge data size in TPH, we'd need more) */
-          true, /* is it packed? yes for now */
-          tileno, /* we are in TPH */
-          epb_index++, /* its index is 0 (first) */
-          hprot, /* protection type parameters of following data */
-          sot_len + 2, /* pre-data length: only SOT */
-          left_THmarks_len /* post-data length: from SOT end to SOD inclusive */
-          ))) {
-
-          /* Add this marker to the 'insertanda' list */
-          if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
-            jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
-            jwmarker[jwmarker_num].m.epbmark = epb_mark; /* the EPB */
-            /****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
-            jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
-            jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
-            jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
-            jwmarker[jwmarker_num].len_ready = true; /* ready */
-            jwmarker[jwmarker_num].pos_ready = true; /* ready */
-            jwmarker[jwmarker_num].parms_ready = true; /* ready */
-            jwmarker[jwmarker_num].data_ready = false; /* not ready */
-            jwmarker_num++;
-          }
-
-          /* update Psot of the tile  */
-          Psot += epb_mark->Lepb + 2;
-
-          opj_event_msg(j2k->cinfo, EVT_INFO,
-            /***** "TPH EPB : tile %02d, prot. %d\n", */
-            "TPH EPB : tile %02d, part %02d, prot. %d\n",
-            /***** tileno, */
-            tileno, tpno,
-            hprot
-            );
-
-          /* save this TPH EPB address */
-          tph_epb = epb_mark;
-
-        } else {
-          /* ooops, problems */
-          /****** opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB #%d\n", tileno);  */
-          opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB in #%d,d\n", tileno, tpno);
-        };
-
-      }
-
-      startpack = 0;
-      /* EPB MSs for UEP packet data protection in Tile Parts */
-      /****** for (packno = 0; packno < j2k->cstr_info->num; packno++) { */
-      /*first_tp_pack = (tpno > 0) ? (first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno - 1].tp_numpacks) : 0;*/
-      first_tp_pack = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pack;
-      last_tp_pack = first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks - 1;
-      for (packno = 0; packno < j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks; packno++) {
-
-        /******** if ((packspec < JPWL_MAX_NO_PACKSPECS) &&
-          (j2k->cp->pprot_tileno[packspec] == tileno) && (j2k->cp->pprot_packno[packspec] == packno)) { */
-        if ((packspec < JPWL_MAX_NO_PACKSPECS) &&
-          (j2k->cp->pprot_tileno[packspec] == acc_tpno) && (j2k->cp->pprot_packno[packspec] == packno)) {
-
-          /* we got a specification from this tile and packet onwards */
-          /* print the previous spec */
-          if (packno > 0) {
-            stoppack = packno - 1;
-            opj_event_msg(j2k->cinfo, EVT_INFO,
-              /***** "UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n", */
-              "UEP EPBs: tile %02d, part %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
-              /***** tileno, */
-              tileno, tpno,
-              startpack,
-              stoppack,
-              /***** j2k->cstr_info->tile[tileno].packet[startpack].start_pos, */
-              j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos,
-              /***** j2k->cstr_info->tile[tileno].packet[stoppack].end_pos, */
-              j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos,
-              pprot);
-
-            /***** prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
-              j2k->cstr_info->tile[tileno].packet[startpack].start_pos; */
-            prot_len = j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos + 1 -
-              j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos;
-
-            /*
-              particular case: if this is the last header and the last packet,
-              then it is better to protect even the EOC marker
-            */
-            /****** if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-              (stoppack == (j2k->cstr_info->num - 1))) */
-            if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-              (tpno == (j2k->cstr_info->tile[tileno].num_tps - 1)) &&
-              (stoppack == last_tp_pack))
-              /* add the EOC len */
-              prot_len += 2;
-
-            /* let's add the EPBs */
-            Psot += jpwl_epbs_add(
-              j2k, /* J2K handle */
-              jwmarker, /* pointer to JPWL markers list */
-              &jwmarker_num, /* pointer to the number of current markers */
-              false, /* latest */
-              true, /* packed */
-              false, /* inside MH */
-              &epb_index, /* pointer to EPB index */
-              pprot, /* protection type */
-              /****** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, */ /* position */
-              (double) (j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2) + 0.0001, /* position */
-              tileno, /* number of tile */
-              0, /* length of pre-data */
-              prot_len /*4000*/ /* length of post-data */
-              );
-          }
-
-          startpack = packno;
-          pprot = j2k->cp->pprot[packspec++];
-        }
-
-        //printf("Tile %02d, pack %02d ==> %d\n", tileno, packno, pprot);
-
-      }
-
-      /* we are at the end: print the remaining spec */
-      stoppack = packno - 1;
-      if (pprot >= 0) {
-
-        opj_event_msg(j2k->cinfo, EVT_INFO,
-          /**** "UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n", */
-          "UEP EPBs: tile %02d, part %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
-          /**** tileno, */
-          tileno, tpno,
-          startpack,
-          stoppack,
-          /***** j2k->image_info->tile[tileno].packet[startpack].start_pos,
-          j2k->image_info->tile[tileno].packet[stoppack].end_pos, */
-          j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos,
-          j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos,
-          pprot);
-
-        /***** prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
-          j2k->cstr_info->tile[tileno].packet[startpack].start_pos; */
-        prot_len = j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos + 1 -
-          j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos;
-
-        /*
-          particular case: if this is the last header and the last packet,
-          then it is better to protect even the EOC marker
-        */
-        /***** if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-          (stoppack == (j2k->cstr_info->num - 1))) */
-        if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
-          (tpno == (j2k->cstr_info->tile[tileno].num_tps - 1)) &&
-          (stoppack == last_tp_pack))
-          /* add the EOC len */
-          prot_len += 2;
-
-        /* let's add the EPBs */
-        Psot += jpwl_epbs_add(
-              j2k, /* J2K handle */
-              jwmarker, /* pointer to JPWL markers list */
-              &jwmarker_num, /* pointer to the number of current markers */
-              true, /* latest */
-              true, /* packed */
-              false, /* inside MH */
-              &epb_index, /* pointer to EPB index */
-              pprot, /* protection type */
-              /***** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001,*/ /* position */
-              (double) (j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2) + 0.0001, /* position */
-              tileno, /* number of tile */
-              0, /* length of pre-data */
-              prot_len /*4000*/ /* length of post-data */
-              );
-      }
-
-      /* we can now check if the TPH EPB was really the last one */
-      if (tph_epb && (epb_index == 1)) {
-        /* set the TPH EPB to be the last one in current header */
-        tph_epb->Depb |= (unsigned char) ((true & 0x0001) << 6);
-        tph_epb = NULL;
-      }
-
-      /* write back Psot */
-      cio_seek(cio, Psotp);
-      cio_write(cio, Psot, 4);
-
-    }
-
-  };
-
-  /* reset the position */
-  cio_seek(cio, ciopos);
-
-}
-
-void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
-
-  int mm;
-  unsigned long int old_size = j2k->cstr_info->codestream_size;
-  unsigned long int new_size = old_size;
-  int /*ciopos = cio_tell(cio),*/ soc_pos = j2k->cstr_info->main_head_start;
-  unsigned char *jpwl_buf, *orig_buf;
-  unsigned long int orig_pos;
-  double epbcoding_time = 0.0, esdcoding_time = 0.0;
-
-  /* Order JPWL markers according to their wishlist position */
-  qsort((void *) jwmarker, (size_t) jwmarker_num, sizeof (jpwl_marker_t), jpwl_markcomp);
-
-  /* compute markers total size */
-  for (mm = 0; mm < jwmarker_num; mm++) {
-    /*printf("%x, %d, %.10f, %d long\n", jwmarker[mm].id, jwmarker[mm].pos,
-      jwmarker[mm].dpos, jwmarker[mm].len);*/
-    new_size += jwmarker[mm].len + 2;
-  }
-
-  /* allocate a new buffer of proper size */
-  if (!(jpwl_buf = (unsigned char *) opj_malloc((size_t) (new_size + soc_pos) * sizeof(unsigned char)))) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for JPWL codestream buffer\n");
-    exit(1);
-  };
-
-  /* copy the jp2 part, if any */
-  orig_buf = jpwl_buf;
-  memcpy(jpwl_buf, cio->buffer, soc_pos);
-  jpwl_buf += soc_pos;
-
-  /* cycle through markers */
-  orig_pos = soc_pos + 0; /* start from the beginning */
-  cio_seek(cio, soc_pos + 0); /* rewind the original */
-  for (mm = 0; mm < jwmarker_num; mm++) {
-
-    /*
-    need to copy a piece of the original codestream
-    if there is such
-    */
-    memcpy(jpwl_buf, cio_getbp(cio), jwmarker[mm].pos - orig_pos);
-    jpwl_buf += jwmarker[mm].pos - orig_pos;
-    orig_pos = jwmarker[mm].pos;
-    cio_seek(cio, orig_pos);
-
-    /*
-    then write down the marker
-    */
-    switch (jwmarker[mm].id) {
-
-    case J2K_MS_EPB:
-      jpwl_epb_write(j2k, jwmarker[mm].m.epbmark, jpwl_buf);
-      break;
-
-    case J2K_MS_EPC:
-      jpwl_epc_write(j2k, jwmarker[mm].m.epcmark, jpwl_buf);
-      break;
-
-    case J2K_MS_ESD:
-      jpwl_esd_write(j2k, jwmarker[mm].m.esdmark, jpwl_buf);
-      break;
-
-    case J2K_MS_RED:
-      memset(jpwl_buf, 0, jwmarker[mm].len + 2); /* placeholder */
-      break;
-
-    default:
-      break;
-    };
-
-    /* we update the markers struct */
-    if (j2k->cstr_info)
-      j2k->cstr_info->marker[j2k->cstr_info->marknum - 1].pos = (jpwl_buf - orig_buf);
-
-    /* we set the marker dpos to the new position in the JPWL codestream */
-    jwmarker[mm].dpos = (double) (jpwl_buf - orig_buf);
-
-    /* advance JPWL buffer position */
-    jpwl_buf += jwmarker[mm].len + 2;
-
-  }
-
-  /* finish remaining original codestream */
-  memcpy(jpwl_buf, cio_getbp(cio), old_size - (orig_pos - soc_pos));
-  jpwl_buf += old_size - (orig_pos - soc_pos);
-  cio_seek(cio, soc_pos + old_size);
-
-  /*
-  update info file based on added markers
-  */
-  if (!jpwl_update_info(j2k, jwmarker, jwmarker_num))
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not update OPJ cstr_info structure\n");
-
-  /* now we need to repass some markers and fill their data fields */
-
-  /* first of all, DL and Pcrc in EPCs */
-  for (mm = 0; mm < jwmarker_num; mm++) {
-
-    /* find the EPCs */
-    if (jwmarker[mm].id == J2K_MS_EPC) {
-
-      int epc_pos = (int) jwmarker[mm].dpos, pp;
-      unsigned short int mycrc = 0x0000;
-
-      /* fix and fill the DL field */
-      jwmarker[mm].m.epcmark->DL = new_size;
-      orig_buf[epc_pos + 6] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 24);
-      orig_buf[epc_pos + 7] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 16);
-      orig_buf[epc_pos + 8] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 8);
-      orig_buf[epc_pos + 9] = (unsigned char) (jwmarker[mm].m.epcmark->DL >> 0);
-
-      /* compute the CRC field (excluding itself) */
-      for (pp = 0; pp < 4; pp++)
-        jpwl_updateCRC16(&mycrc, orig_buf[epc_pos + pp]);
-      for (pp = 6; pp < (jwmarker[mm].len + 2); pp++)
-        jpwl_updateCRC16(&mycrc, orig_buf[epc_pos + pp]);
-
-      /* fix and fill the CRC */
-      jwmarker[mm].m.epcmark->Pcrc = mycrc;
-      orig_buf[epc_pos + 4] = (unsigned char) (jwmarker[mm].m.epcmark->Pcrc >> 8);
-      orig_buf[epc_pos + 5] = (unsigned char) (jwmarker[mm].m.epcmark->Pcrc >> 0);
-
-    }
-  }
-
-  /* then, sensitivity data in ESDs */
-  esdcoding_time = opj_clock();
-  for (mm = 0; mm < jwmarker_num; mm++) {
-
-    /* find the ESDs */
-    if (jwmarker[mm].id == J2K_MS_ESD) {
-
-      /* remember that they are now in a new position (dpos) */
-      int esd_pos = (int) jwmarker[mm].dpos;
-
-      jpwl_esd_fill(j2k, jwmarker[mm].m.esdmark, &orig_buf[esd_pos]);
-
-    }
-
-  }
-  esdcoding_time = opj_clock() - esdcoding_time;
-  if (j2k->cp->esd_on)
-    opj_event_msg(j2k->cinfo, EVT_INFO, "ESDs sensitivities computed in %f s\n", esdcoding_time);
-
-  /* finally, RS or CRC parity in EPBs */
-  epbcoding_time = opj_clock();
-  for (mm = 0; mm < jwmarker_num; mm++) {
-
-    /* find the EPBs */
-    if (jwmarker[mm].id == J2K_MS_EPB) {
-
-      /* remember that they are now in a new position (dpos) */
-      int nn, accum_len;
-
-      /* let's see how many EPBs are following this one, included itself */
-      /* for this to work, we suppose that the markers are correctly ordered */
-      /* and, overall, that they are in packed mode inside headers */
-      accum_len = 0;
-      for (nn = mm; (nn < jwmarker_num) && (jwmarker[nn].id == J2K_MS_EPB) &&
-        (jwmarker[nn].pos == jwmarker[mm].pos); nn++)
-        accum_len += jwmarker[nn].m.epbmark->Lepb + 2;
-
-      /* fill the current (first) EPB with post-data starting from the computed position */
-      jpwl_epb_fill(j2k, jwmarker[mm].m.epbmark, &orig_buf[(int) jwmarker[mm].dpos],
-        &orig_buf[(int) jwmarker[mm].dpos + accum_len]);
-
-      /* fill the remaining EPBs in the header with post-data starting from the last position */
-      for (nn = mm + 1; (nn < jwmarker_num) && (jwmarker[nn].id == J2K_MS_EPB) &&
-        (jwmarker[nn].pos == jwmarker[mm].pos); nn++)
-        jpwl_epb_fill(j2k, jwmarker[nn].m.epbmark, &orig_buf[(int) jwmarker[nn].dpos], NULL);
-
-      /* skip all the processed EPBs */
-      mm = nn - 1;
-    }
-
-  }
-  epbcoding_time = opj_clock() - epbcoding_time;
-  if (j2k->cp->epb_on)
-    opj_event_msg(j2k->cinfo, EVT_INFO, "EPBs redundancy computed in %f s\n", epbcoding_time);
-
-  /* free original cio buffer and set it to the JPWL one */
-  opj_free(cio->buffer);
-  cio->cinfo = cio->cinfo; /* no change */
-  cio->openmode = cio->openmode; /* no change */
-  cio->buffer = orig_buf;
-  cio->length = new_size + soc_pos;
-  cio->start = cio->buffer;
-  cio->end = cio->buffer + cio->length;
-  cio->bp = cio->buffer;
-  cio_seek(cio, soc_pos + new_size);
-
-}
-
-
-void j2k_read_epc(opj_j2k_t *j2k) {
-  unsigned long int DL, Lepcp, Pcrcp, l;
-  unsigned short int Lepc, Pcrc = 0x0000;
-  unsigned char Pepc;
-  opj_cio_t *cio = j2k->cio;
-  char *ans1;
-
-  /* Simply read the EPC parameters */
-  Lepcp = cio_tell(cio);
-  Lepc = cio_read(cio, 2);
-  Pcrcp = cio_tell(cio);
-  cio_skip(cio, 2); /* Pcrc */
-  DL = cio_read(cio, 4);
-  Pepc = cio_read(cio, 1);
-
-  /* compute Pcrc */
-  cio_seek(cio, Lepcp - 2);
-
-    /* Marker */
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-
-    /* Length */
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-
-    /* skip Pcrc */
-    cio_skip(cio, 2);
-
-    /* read all remaining */
-    for (l = 4; l < Lepc; l++)
-      jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-
-    /* check Pcrc with the result */
-    cio_seek(cio, Pcrcp);
-    ans1 = (Pcrc == (unsigned short int) cio_read(cio, 2)) ? "crc-ok" : "crc-ko";
-
-  /* now we write them to screen */
-  opj_event_msg(j2k->cinfo, EVT_INFO,
-    "EPC(%u,%d): %s, DL=%d%s %s %s\n",
-    Lepcp - 2,
-    Lepc,
-    ans1,
-    DL, /* data length this EPC is referring to */
-    (Pepc & 0x10) ? ", esd" : "", /* ESD is present */
-    (Pepc & 0x20) ? ", red" : "", /* RED is present */
-    (Pepc & 0x40) ? ", epb" : ""); /* EPB is present */
-
-  cio_seek(cio, Lepcp + Lepc);
-}
-
-void j2k_write_epc(opj_j2k_t *j2k) {
-
-  unsigned long int DL, Lepcp, Pcrcp, l;
-  unsigned short int Lepc, Pcrc;
-  unsigned char Pepc;
-
-  opj_cio_t *cio = j2k->cio;
-
-  cio_write(cio, J2K_MS_EPC, 2);  /* EPC */
-  Lepcp = cio_tell(cio);
-  cio_skip(cio, 2);
-
-  /* CRC-16 word of the EPC */
-  Pcrc = 0x0000; /* initialize */
-  Pcrcp = cio_tell(cio);
-  cio_write(cio, Pcrc, 2); /* Pcrc placeholder*/
-
-  /* data length of the EPC protection domain */
-  DL = 0x00000000; /* we leave this set to 0, as if the information is not available */
-  cio_write(cio, DL, 4);   /* DL */
-
-  /* jpwl capabilities */
-  Pepc = 0x00;
-  cio_write(cio, Pepc, 1); /* Pepc */
-
-  /* ID section */
-  /* no ID's, as of now */
-
-  Lepc = (unsigned short) (cio_tell(cio) - Lepcp);
-  cio_seek(cio, Lepcp);
-  cio_write(cio, Lepc, 2); /* Lepc */
-
-  /* compute Pcrc */
-  cio_seek(cio, Lepcp - 2);
-
-    /* Marker */
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-
-    /* Length */
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-    jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-
-    /* skip Pcrc */
-    cio_skip(cio, 2);
-
-    /* read all remaining */
-    for (l = 4; l < Lepc; l++)
-      jpwl_updateCRC16(&Pcrc, (unsigned char) cio_read(cio, 1));
-
-    /* fill Pcrc with the result */
-    cio_seek(cio, Pcrcp);
-    cio_write(cio, Pcrc, 2);
-
-  cio_seek(cio, Lepcp + Lepc);
-
-  /* marker struct update */
-  j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, Lepcp - 2, Lepc + 2);
-
-}
-
-void j2k_read_epb(opj_j2k_t *j2k) {
-  unsigned long int LDPepb, Pepb;
-  unsigned short int Lepb;
-  unsigned char Depb;
-  char str1[25] = "";
-  bool status;
-  static bool first_in_tph = true;
-  int type, pre_len, post_len;
-  static unsigned char *redund = NULL;
-
-  opj_cio_t *cio = j2k->cio;
-
-  /* B/W = 45, RGB = 51 */
-  /*           SIZ   SIZ_FIELDS     SIZ_COMPS               FOLLOWING_MARKER */
-  int skipnum = 2  +     38     + 3 * j2k->cp->exp_comps  +         2;
-
-  if (j2k->cp->correct) {
-
-    /* go back to EPB marker value */
-    cio_seek(cio, cio_tell(cio) - 2);
-
-    /* we need to understand where we are */
-    if (j2k->state == J2K_STATE_MH) {
-      /* we are in MH */
-      type = 0; /* MH */
-      pre_len = skipnum; /* SOC+SIZ */
-      post_len = -1; /* auto */
-
-    } else if ((j2k->state == J2K_STATE_TPH) && first_in_tph) {
-      /* we are in TPH */
-      type = 1; /* TPH */
-      pre_len = 12; /* SOC+SIZ */
-      first_in_tph = false;
-      post_len = -1; /* auto */
-
-    } else {
-      /* we are elsewhere */
-      type = 2; /* other */
-      pre_len = 0; /* nada */
-      post_len = -1; /* auto */
-
-    }
-
-    /* call EPB corrector */
-    /*printf("before %x, ", redund);*/
-    status = jpwl_epb_correct(j2k,      /* J2K decompressor handle */
-                  cio->bp,  /* pointer to EPB in codestream buffer */
-                  type,     /* EPB type: MH */
-                  pre_len,  /* length of pre-data */
-                  post_len, /* length of post-data: -1 means auto */
-                  NULL,     /* do everything auto */
-                  &redund
-                 );
-    /*printf("after %x\n", redund);*/
-
-    /* Read the (possibly corrected) EPB parameters */
-    cio_skip(cio, 2);
-    Lepb = cio_read(cio, 2);
-    Depb = cio_read(cio, 1);
-    LDPepb = cio_read(cio, 4);
-    Pepb = cio_read(cio, 4);
-
-    if (!status) {
-
-      opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL correction could not be performed\n");
-
-      /* advance to EPB endpoint */
-      cio_skip(cio, Lepb + 2);
-
-      return;
-    }
-
-    /* last in current header? */
-    if (Depb & 0x40) {
-      redund = NULL; /* reset the pointer to L4 buffer */
-      first_in_tph = true;
-    }
-
-    /* advance to EPB endpoint */
-    cio_skip(cio, Lepb - 11);
-
-  } else {
-
-    /* Simply read the EPB parameters */
-    Lepb = cio_read(cio, 2);
-    Depb = cio_read(cio, 1);
-    LDPepb = cio_read(cio, 4);
-    Pepb = cio_read(cio, 4);
-
-    /* What does Pepb tells us about the protection method? */
-    if (((Pepb & 0xF0000000) >> 28) == 0)
-      sprintf(str1, "pred"); /* predefined */
-    else if (((Pepb & 0xF0000000) >> 28) == 1)
-      sprintf(str1, "crc-%lu", 16 * ((Pepb & 0x00000001) + 1)); /* CRC mode */
-    else if (((Pepb & 0xF0000000) >> 28) == 2)
-      sprintf(str1, "rs(%lu,32)", (Pepb & 0x0000FF00) >> 8); /* RS mode */
-    else if (Pepb == 0xFFFFFFFF)
-      sprintf(str1, "nometh"); /* RS mode */
-    else
-      sprintf(str1, "unknown"); /* unknown */
-
-    /* Now we write them to screen */
-    opj_event_msg(j2k->cinfo, EVT_INFO,
-      "EPB(%d): (%sl, %sp, %u), %lu, %s\n",
-      cio_tell(cio) - 13,
-      (Depb & 0x40) ? "" : "n", /* latest EPB or not? */
-      (Depb & 0x80) ? "" : "n", /* packed or unpacked EPB? */
-      (Depb & 0x3F), /* EPB index value */
-      LDPepb, /*length of the data protected by the EPB */
-      str1); /* protection method */
-
-    cio_skip(cio, Lepb - 11);
-  }
-}
-
-void j2k_write_epb(opj_j2k_t *j2k) {
-  unsigned long int LDPepb, Pepb, Lepbp;
-  unsigned short int Lepb;
-  unsigned char Depb;
-
-  opj_cio_t *cio = j2k->cio;
-
-  cio_write(cio, J2K_MS_EPB, 2);  /* EPB */
-  Lepbp = cio_tell(cio);
-  cio_skip(cio, 2);
-
-  /* EPB style */
-  Depb = 0x00; /* test */
-  cio_write(cio, Depb, 1);   /* Depb */
-
-  /* length of the data to be protected by this EPB */
-  LDPepb = 0x00000000; /* test */
-  cio_write(cio, LDPepb, 4);   /* LDPepb */
-
-  /* next error correction tool */
-  Pepb = 0x00000000; /* test */
-  cio_write(cio, Pepb, 4);   /* Pepb */
-
-  /* EPB data */
-  /* no data, as of now */
-
-  Lepb = (unsigned short) (cio_tell(cio) - Lepbp);
-  cio_seek(cio, Lepbp);
-  cio_write(cio, Lepb, 2);    /* Lepb */
-
-  cio_seek(cio, Lepbp + Lepb);
-
-  /* marker struct update */
-  j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, Lepbp - 2, Lepb + 2);
-}
-
-void j2k_read_esd(opj_j2k_t *j2k) {
-  unsigned short int Lesd, Cesd;
-  unsigned char Pesd;
-
-  int cesdsize = (j2k->image->numcomps >= 257) ? 2 : 1;
-
-  char str1[4][4] = {"p", "br", "pr", "res"};
-  char str2[8][8] = {"res", "mse", "mse-r", "psnr", "psnr-i", "maxerr", "tse", "res"};
-
-  opj_cio_t *cio = j2k->cio;
-
-  /* Simply read the ESD parameters */
-  Lesd = cio_read(cio, 2);
-  Cesd = cio_read(cio, cesdsize);
-  Pesd = cio_read(cio, 1);
-
-  /* Now we write them to screen */
-  opj_event_msg(j2k->cinfo, EVT_INFO,
-    "ESD(%d): c%d, %s, %s, %s, %s, %s\n",
-    cio_tell(cio) - (5 + cesdsize),
-    Cesd, /* component number for this ESD */
-    str1[(Pesd & (unsigned char) 0xC0) >> 6], /* addressing mode */
-    str2[(Pesd & (unsigned char) 0x38) >> 3], /* sensitivity type */
-    ((Pesd & (unsigned char) 0x04) >> 2) ? "2Bs" : "1Bs",
-    ((Pesd & (unsigned char) 0x02) >> 1) ? "4Ba" : "2Ba",
-    (Pesd & (unsigned char) 0x01) ? "avgc" : "");
-
-  cio_skip(cio, Lesd - (3 + cesdsize));
-}
-
-void j2k_read_red(opj_j2k_t *j2k) {
-  unsigned short int Lred;
-  unsigned char Pred;
-  char str1[4][4] = {"p", "br", "pr", "res"};
-
-  opj_cio_t *cio = j2k->cio;
-
-  /* Simply read the RED parameters */
-  Lred = cio_read(cio, 2);
-  Pred = cio_read(cio, 1);
-
-  /* Now we write them to screen */
-  opj_event_msg(j2k->cinfo, EVT_INFO,
-    "RED(%d): %s, %dc, %s, %s\n",
-    cio_tell(cio) - 5,
-    str1[(Pred & (unsigned char) 0xC0) >> 6], /* addressing mode */
-    (Pred & (unsigned char) 0x38) >> 3, /* corruption level */
-    ((Pred & (unsigned char) 0x02) >> 1) ? "4Ba" : "2Ba", /* address range */
-    (Pred & (unsigned char) 0x01) ? "errs" : "free"); /* error free? */
-
-  cio_skip(cio, Lred - 3);
-}
-
-bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno) {
-
-#ifdef oerhgierhgvhreit4u
-  /*
-     we navigate through the tile and find possible invalid parameters:
-       this saves a lot of crashes!!!!!
-   */
-  int compno, resno, precno, /*layno,*/ bandno, blockno;
-  int numprecincts, numblocks;
-
-  /* this is the selected tile */
-  opj_tcd_tile_t *tile = &(tcd->tcd_image->tiles[tileno]);
-
-  /* will keep the component */
-  opj_tcd_tilecomp_t *comp = NULL;
-
-  /* will keep the resolution */
-  opj_tcd_resolution_t *res;
-
-  /* will keep the subband */
-  opj_tcd_band_t *band;
-
-  /* will keep the precinct */
-  opj_tcd_precinct_t *prec;
-
-  /* will keep the codeblock */
-  opj_tcd_cblk_t *block;
-
-  /* check all tile components */
-  for (compno = 0; compno < tile->numcomps; compno++) {
-    comp = &(tile->comps[compno]);
-
-    /* check all component resolutions */
-    for (resno = 0; resno < comp->numresolutions; resno++) {
-      res = &(comp->resolutions[resno]);
-      numprecincts = res->pw * res->ph;
-
-      /* check all the subbands */
-      for (bandno = 0; bandno < res->numbands; bandno++) {
-        band = &(res->bands[bandno]);
-
-        /* check all the precincts */
-        for (precno = 0; precno < numprecincts; precno++) {
-          prec = &(band->precincts[precno]);
-          numblocks = prec->ch * prec->cw;
-
-          /* check all the codeblocks */
-          for (blockno = 0; blockno < numblocks; blockno++) {
-            block = &(prec->cblks[blockno]);
-
-            /* x-origin is invalid */
-            if ((block->x0 < prec->x0) || (block->x0 > prec->x1)) {
-              opj_event_msg(j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-                "JPWL: wrong x-cord of block origin %d => x-prec is (%d, %d)\n",
-                block->x0, prec->x0, prec->x1);
-              if (!JPWL_ASSUME || JPWL_ASSUME)
-                return false;
-            };
-          }
-        }
-      }
-    }
-  }
-
-#endif
-
-  return true;
-}
-
-/*@}*/
-
-#endif /* USE_JPWL */
-
-
-#ifdef USE_JPSEC
-
-/** @defgroup JPSEC JPSEC - JPEG-2000 Part 8 (JPSEC) codestream manager */
-/*@{*/
-
-
-/** @name Local static functions */
-/*@{*/
-
-void j2k_read_sec(opj_j2k_t *j2k) {
-  unsigned short int Lsec;
-
-  opj_cio_t *cio = j2k->cio;
-
-  /* Simply read the SEC length */
-  Lsec = cio_read(cio, 2);
-
-  /* Now we write them to screen */
-  opj_event_msg(j2k->cinfo, EVT_INFO,
-    "SEC(%d)\n",
-    cio_tell(cio) - 2
-    );
-
-  cio_skip(cio, Lsec - 2);
-}
-
-void j2k_write_sec(opj_j2k_t *j2k) {
-  unsigned short int Lsec = 24;
-  int i;
-
-  opj_cio_t *cio = j2k->cio;
-
-  cio_write(cio, J2K_MS_SEC, 2);  /* SEC */
-  cio_write(cio, Lsec, 2);
-
-  /* write dummy data */
-  for (i = 0; i < Lsec - 2; i++)
-    cio_write(cio, 0, 1);
-}
-
-void j2k_read_insec(opj_j2k_t *j2k) {
-  unsigned short int Linsec;
-
-  opj_cio_t *cio = j2k->cio;
-
-  /* Simply read the INSEC length */
-  Linsec = cio_read(cio, 2);
-
-  /* Now we write them to screen */
-  opj_event_msg(j2k->cinfo, EVT_INFO,
-    "INSEC(%d)\n",
-    cio_tell(cio) - 2
-    );
-
-  cio_skip(cio, Linsec - 2);
-}
-
-
-/*@}*/
-
-/*@}*/
-
-#endif /* USE_JPSEC */
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/jpwl.h b/Utilities/gdcmopenjpeg-v2/jpwl/jpwl.h
deleted file mode 100644
index f273e5b..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/jpwl.h
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __JPWL_H
-#define __JPWL_H
-
-#ifdef USE_JPWL
-
-#include "crc.h"
-#include "rs.h"
-
-/**
- at file jpwl.h
- at brief The JPEG-2000 Part11 (JPWL) marker segments manager
-
-The functions in JPWL.C have for goal to read/write the markers added by JPWL.
-*/
-
-/** @defgroup JPWL JPWL - JPEG-2000 Part11 (JPWL) codestream manager */
-/*@{*/
-
-/**
-Assume a basic codestream structure, so you can resort better from uncorrected errors
-*/
-#define JPWL_ASSUME true
-
-/**
-EPB (Error Protection Block) Marker segment
-*/
-typedef struct jpwl_epb_ms {
-  /**@name Private fields set by epb_create */
-  /*@{*/
-  /** is the latest in header? */
-  bool latest;
-  /** is it in packed mode? */
-  bool packed;
-  /** TH where this marker has been placed (-1 means MH) */
-  int tileno;
-  /** index in current header (0-63) */
-  unsigned char index;
-  /** error protection method  [-1=absent 0=none 1=predefined 16=CRC-16 32=CRC-32 37-128=RS] */
-  int hprot;
-  /** message word length of pre-data */
-  int k_pre;
-  /** code word length of pre-data */
-  int n_pre;
-  /** length of pre-data */
-  int pre_len;
-  /** message word length of post-data */
-  int k_post;
-  /** code word length of post-data */
-  int n_post;
-  /** length of post-data */
-  int post_len;
-  /*@}*/
-  /**@name Marker segment fields */
-  /*@{*/
-  /** two bytes for the length of EPB MS, exluding the marker itself (11 to 65535 bytes) */
-  unsigned short int Lepb;
-  /** single byte for the style */
-  unsigned char Depb;
-  /** four bytes, from 0 to 2^31-1 */
-  unsigned long int LDPepb;
-  /** four bytes, next error management method */
-  unsigned long int Pepb;
-  /** EPB data, variable size */
-  unsigned char *data;
-  /*@}*/
-}  jpwl_epb_ms_t;
-
-/**
-EPC (Error Protection Capability) Marker segment
-*/
-typedef struct jpwl_epc_ms {
-  /** is ESD active? */
-  bool esd_on;
-  /** is RED active? */
-  bool red_on;
-  /** is EPB active? */
-  bool epb_on;
-  /** are informative techniques active? */
-  bool info_on;
-  /**@name Marker segment fields */
-  /*@{*/
-  /** two bytes for the length of EPC MS, exluding the marker itself (9 to 65535 bytes) */
-  unsigned short int Lepc;
-  /** two bytes, CRC for the EPC, excluding Pcrc itself */
-  unsigned short int Pcrc;
-  /** four bytes, the codestream length from SOC to EOC */
-  unsigned long int DL;
-  /** one byte, signals JPWL techniques adoption */
-  unsigned char Pepc;
-  /** EPC data, variable length */
-  unsigned char *data;
-  /*@}*/
-}  jpwl_epc_ms_t;
-
-/**
-ESD (Error Sensitivity Descriptor) Marker segment
-*/
-typedef struct jpwl_esd_ms {
-  /** codestream addressing mode [0=packet, 1=byte range, 2=packet range, 3=reserved] */
-  unsigned char addrm;
-  /** size of codestream addresses [2/4 bytes] */
-  unsigned char ad_size;
-  /** type of sensitivity
-  [0=relative error, 1=MSE, 2=MSE reduction, 3=PSNR, 4=PSNR increment,
-  5=MAXERR (absolute peak error), 6=TSE (total squared error), 7=reserved */
-  unsigned char senst;
-  /** size of sensitivity data (1/2 bytes) */
-  unsigned char se_size;
-  /**@name Marker segment fields */
-  /*@{*/
-  /** two bytes for the length of ESD MS, exluding the marker itself (4 to 65535 bytes) */
-  unsigned short int Lesd;
-  /** two bytes, component of error sensitivity */
-  unsigned short int Cesd;
-  /** one byte, signals JPWL techniques adoption */
-  unsigned char Pesd;
-  /** ESD data, variable length */
-  unsigned char *data;
-  /*@}*/
-  /**@name Fields set by esd_create (only internal use) */
-  /*@{*/
-  /** number of components in the image */
-  int numcomps;
-  /** tile where this marker has been placed (-1 means MH) */
-  int tileno;
-  /** number of sensitivity values */
-  unsigned long int svalnum;
-  /** size of a single sensitivity pair (address+value) */
-  size_t sensval_size;
-  /*@}*/
-}  jpwl_esd_ms_t;
-
-/**
-RED (Residual Error Descriptor) Marker segment
-*/
-typedef struct jpwl_red_ms {
-  /** two bytes for the length of RED MS, exluding the marker itself (3 to 65535 bytes) */
-  unsigned short int Lred;
-  /** one byte, signals JPWL techniques adoption */
-  unsigned char Pred;
-  /** RED data, variable length */
-  unsigned char *data;
-}  jpwl_red_ms_t;
-
-/**
-Structure used to store JPWL markers temporary position and readyness
-*/
-typedef struct jpwl_marker {
-  /** marker value (J2K_MS_EPC, etc.) */
-  int id;
-  /** union keeping the pointer to the real marker struct */
-  union jpwl_marks {
-    /** pointer to EPB marker */
-    jpwl_epb_ms_t *epbmark;
-    /** pointer to EPC marker */
-    jpwl_epc_ms_t *epcmark;
-    /** pointer to ESD marker */
-    jpwl_esd_ms_t *esdmark;
-    /** pointer to RED marker */
-    jpwl_red_ms_t *redmark;
-  } m;
-  /** position where the marker should go, in the pre-JPWL codestream */
-  unsigned long int pos;
-  /** same as before, only written as a double, so we can sort it better */
-  double dpos;
-  /** length of the marker segment (marker excluded) */
-  unsigned short int len;
-  /** the marker length is ready or not? */
-  bool len_ready;
-  /** the marker position is ready or not? */
-  bool pos_ready;
-  /** the marker parameters are ready or not? */
-  bool parms_ready;
-  /** are the written data ready or not */
-  bool data_ready;
-}  jpwl_marker_t;
-
-/**
-Encode according to JPWL specs
- at param j2k J2K handle
- at param cio codestream handle
- at param image image handle
-*/
-void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
-
-/**
-Prepare the list of JPWL markers, after the Part 1 codestream
-has been finalized (index struct is full)
- at param j2k J2K handle
- at param cio codestream handle
- at param image image handle
-*/
-void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
-
-/**
-Dump the list of JPWL markers, after it has been prepared
- at param j2k J2K handle
- at param cio codestream handle
- at param image image handle
-*/
-void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
-
-/**
-Read the EPC marker (Error Protection Capability)
- at param j2k J2K handle
-*/
-void j2k_read_epc(opj_j2k_t *j2k);
-
-/**
-Write the EPC marker (Error Protection Capability), BUT the DL field is always set to 0
-(this simplifies the management of EPBs and it is openly stated in the standard
-as a possible value, mening that the information is not available) and the informative techniques
-are not yet implemented
- at param j2k J2K handle
-*/
-void j2k_write_epc(opj_j2k_t *j2k);
-
-/**
-Read the EPB marker (Error Protection Block)
- at param j2k J2K handle
-*/
-void j2k_read_epb(opj_j2k_t *j2k);
-
-/**
-Write the EPB marker (Error Protection Block)
- at param j2k J2K handle
-*/
-void j2k_write_epb(opj_j2k_t *j2k);
-
-/**
-Read the ESD marker (Error Sensitivity Descriptor)
- at param j2k J2K handle
-*/
-void j2k_read_esd(opj_j2k_t *j2k);
-
-/**
-Read the RED marker (Residual Error Descriptor)
- at param j2k J2K handle
-*/
-void j2k_read_red(opj_j2k_t *j2k);
-
-/** create an EPB marker segment
- at param j2k J2K compressor handle
- at param latest it is the latest EPB in the header
- at param packed EPB is in packed style
- at param tileno tile number where the marker has been placed (-1 means MH)
- at param idx current EPB running index
- at param hprot applied protection type (-1/0,1,16,32,37-128)
- at param pre_len length of pre-protected data
- at param post_len length of post-protected data
- at return returns the freshly created EPB
-*/
-jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int tileno, int idx, int hprot,
-                 unsigned long int pre_len, unsigned long int post_len);
-
-/** add a number of EPB marker segments
- at param j2k J2K compressor handle
- at param jwmarker pointer to the JPWL markers list
- at param jwmarker_num pointer to the number of JPWL markers (gets updated)
- at param latest it is the latest group of EPBs in the header
- at param packed EPBs are in packed style
- at param insideMH it is in the MH
- at param idx pointer to the starting EPB running index (gets updated)
- at param hprot applied protection type (-1/0,1,16,32,37-128)
- at param place_pos place in original codestream where EPBs should go
- at param tileno tile number of these EPBs
- at param pre_len length of pre-protected data
- at param post_len length of post-protected data
- at return returns the length of all added markers
-*/
-int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-          bool latest, bool packed, bool insideMH, int *idx, int hprot,
-          double place_pos, int tileno,
-          unsigned long int pre_len, unsigned long int post_len);
-
-/** add a number of ESD marker segments
- at param j2k J2K compressor handle
- at param jwmarker pointer to the JPWL markers list
- at param jwmarker_num pointer to the number of JPWL markers (gets updated)
- at param comps considered component (-1=average, 0/1/2/...=component no.)
- at param addrm addressing mode (0=packet, 1=byte range, 2=packet range, 3=reserved)
- at param ad_size size of addresses (2/4 bytes)
- at param senst sensitivity type
- at param se_size sensitivity values size (1/2 bytes)
- at param place_pos place in original codestream where EPBs should go
- at param tileno tile number of these EPBs
- at return returns the length of all added markers
-*/
-int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-          int comps, unsigned char addrm, unsigned char ad_size,
-          unsigned char senst, unsigned char se_size,
-          double place_pos, int tileno);
-
-/** updates the information structure by modifying the positions and lengths
- at param j2k J2K compressor handle
- at param jwmarker pointer to JPWL markers list
- at param jwmarker_num number of JPWL markers
- at return returns true in case of success
-*/
-bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num);
-
-
-bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
-
-bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf);
-
-void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
-
-/** corrects the data in the JPWL codestream
- at param j2k J2K compressor handle
- at return true if correction is performed correctly
-*/
-bool jpwl_correct(opj_j2k_t *j2k);
-
-/** corrects the data protected by an EPB
- at param j2k J2K compressor handle
- at param buffer pointer to the EPB position
- at param type type of EPB: 0=MH, 1=TPH, 2=other, 3=auto
- at param pre_len length of pre-data
- at param post_len length of post_data
- at param conn is a pointer to the length of all connected (packed) EPBs
- at param L4_bufp is a pointer to the buffer pointer of redundancy data
- at return returns true if correction could be succesfully performed
-*/
-bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
-            unsigned char **L4_bufp);
-
-/** check that a tile and its children have valid data
- at param j2k J2K decompressor handle
- at param tcd Tile decompressor handle
- at param tileno number of the tile to check
-*/
-bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno);
-
-/** Macro functions for CRC computation */
-
-/**
-Computes the CRC-16, as stated in JPWL specs
- at param CRC two bytes containing the CRC value (must be initialized with 0x0000)
- at param DATA byte for which the CRC is computed; call this on every byte of the sequence
-and get the CRC at the end
-*/
-#define jpwl_updateCRC16(CRC, DATA) updateCRC16(CRC, DATA)
-
-/**
-Computes the CRC-32, as stated in JPWL specs
- at param CRC four bytes containing the CRC value (must be initialized with 0x00000000)
- at param DATA byte for which the CRC is computed; call this on every byte of the sequence
-and get the CRC at the end
-*/
-#define jpwl_updateCRC32(CRC, DATA) updateCRC32(CRC, DATA)
-
-/**
-Computes the minimum between two integers
- at param a first integer to compare
- at param b second integer to compare
- at return returns the minimum integer between a and b
-*/
-#ifndef min
-#define min(a,b)    (((a) < (b)) ? (a) : (b))
-#endif /* min */
-
-/*@}*/
-
-#endif /* USE_JPWL */
-
-#ifdef USE_JPSEC
-
-/** @defgroup JPSEC JPSEC - JPEG-2000 Part 8 (JPSEC) codestream manager */
-/*@{*/
-
-/**
-Read the SEC marker (SEcured Codestream)
- at param j2k J2K handle
-*/
-void j2k_read_sec(opj_j2k_t *j2k);
-
-/**
-Write the SEC marker (SEcured Codestream)
- at param j2k J2K handle
-*/
-void j2k_write_sec(opj_j2k_t *j2k);
-
-/**
-Read the INSEC marker (SEcured Codestream)
- at param j2k J2K handle
-*/
-void j2k_read_insec(opj_j2k_t *j2k);
-
-/*@}*/
-
-#endif /* USE_JPSEC */
-
-#endif /* __JPWL_H */
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/jpwl_lib.c b/Utilities/gdcmopenjpeg-v2/jpwl/jpwl_lib.c
deleted file mode 100644
index 4c34343..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/jpwl_lib.c
+++ /dev/null
@@ -1,1796 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-#include "../libopenjpeg/opj_includes.h"
-#include <limits.h>
-
-/** Minimum and maximum values for the double->pfp conversion */
-#define MIN_V1 0.0
-#define MAX_V1 17293822569102704640.0
-#define MIN_V2 0.000030517578125
-#define MAX_V2 131040.0
-
-/** conversion between a double precision floating point
-number and the corresponding pseudo-floating point used
-to represent sensitivity values
- at param V the double precision value
- at param bytes the number of bytes of the representation
- at return the pseudo-floating point value (cast accordingly)
-*/
-unsigned short int jpwl_double_to_pfp(double V, int bytes);
-
-/** conversion between a pseudo-floating point used
-to represent sensitivity values and the corresponding
-double precision floating point number
- at param em the pseudo-floating point value (cast accordingly)
- at param bytes the number of bytes of the representation
- at return the double precision value
-*/
-double jpwl_pfp_to_double(unsigned short int em, int bytes);
-
-  /*-------------------------------------------------------------*/
-
-int jpwl_markcomp(const void *arg1, const void *arg2)
-{
-   /* Compare the two markers' positions */
-   double diff = (((jpwl_marker_t *) arg1)->dpos - ((jpwl_marker_t *) arg2)->dpos);
-
-   if (diff == 0.0)
-     return (0);
-   else if (diff < 0)
-     return (-1);
-   else
-     return (+1);
-}
-
-int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-          bool latest, bool packed, bool insideMH, int *idx, int hprot,
-          double place_pos, int tileno,
-          unsigned long int pre_len, unsigned long int post_len) {
-
-  jpwl_epb_ms_t *epb_mark = NULL;
-
-  int k_pre, k_post, n_pre, n_post;
-
-  unsigned long int L1, L2, dL4, max_postlen, epbs_len = 0;
-
-  /* We find RS(n,k) for EPB parms and pre-data, if any */
-  if (insideMH && (*idx == 0)) {
-    /* First EPB in MH */
-    k_pre = 64;
-    n_pre = 160;
-  } else if (!insideMH && (*idx == 0)) {
-    /* First EPB in TH */
-    k_pre = 25;
-    n_pre = 80;
-  } else {
-    /* Following EPBs in MH or TH */
-    k_pre = 13;
-    n_pre = 40;
-  };
-
-  /* Find lengths, Figs. B3 and B4 */
-  /* size of pre data: pre_buf(pre_len) + EPB(2) + Lepb(2) + Depb(1) + LDPepb(4) + Pepb(4) */
-  L1 = pre_len + 13;
-
-  /* size of pre-data redundancy */
-  /*   (redundancy per codeword)       *     (number of codewords, rounded up)   */
-  L2 = (n_pre - k_pre) * (unsigned long int) ceil((double) L1 / (double) k_pre);
-
-  /* Find protection type for post data and its associated redundancy field length*/
-  if ((hprot == 16) || (hprot == 32)) {
-    /* there is a CRC for post-data */
-    k_post = post_len;
-    n_post = post_len + (hprot >> 3);
-    /*L3 = hprot >> 3;*/ /* 2 (CRC-16) or 4 (CRC-32) bytes */
-
-  } else if ((hprot >= 37) && (hprot <= 128)) {
-    /* there is a RS for post-data */
-    k_post = 32;
-    n_post = hprot;
-
-  } else {
-    /* Use predefined codes */
-    n_post = n_pre;
-    k_post = k_pre;
-  };
-
-  /* Create the EPB(s) */
-  while (post_len > 0) {
-
-    /* maximum postlen in order to respect EPB size
-    (we use JPWL_MAXIMUM_EPB_ROOM instead of 65535 for keeping room for EPB parms)*/
-    /*      (message word size)    *            (number of containable parity words)  */
-    max_postlen = k_post * (unsigned long int) floor((double) JPWL_MAXIMUM_EPB_ROOM / (double) (n_post - k_post));
-
-    /* maximum postlen in order to respect EPB size */
-    if (*idx == 0)
-      /* (we use (JPWL_MAXIMUM_EPB_ROOM - L2) instead of 65535 for keeping room for EPB parms + pre-data) */
-      /*      (message word size)    *                   (number of containable parity words)  */
-      max_postlen = k_post * (unsigned long int) floor((double) (JPWL_MAXIMUM_EPB_ROOM - L2) / (double) (n_post - k_post));
-
-    else
-      /* (we use JPWL_MAXIMUM_EPB_ROOM instead of 65535 for keeping room for EPB parms) */
-      /*      (message word size)    *            (number of containable parity words)  */
-      max_postlen = k_post * (unsigned long int) floor((double) JPWL_MAXIMUM_EPB_ROOM / (double) (n_post - k_post));
-
-    /* null protection case */
-    /* the max post length can be as large as the LDPepb field can host */
-    if (hprot == 0)
-      max_postlen = INT_MAX;
-
-    /* length to use */
-    dL4 = min(max_postlen, post_len);
-
-    if ((epb_mark = jpwl_epb_create(
-      j2k, /* this encoder handle */
-      latest ? (dL4 < max_postlen) : false, /* is it the latest? */
-      packed, /* is it packed? */
-      tileno, /* we are in TPH */
-      *idx, /* its index */
-      hprot, /* protection type parameters of following data */
-      0, /* pre-data: nothing for now */
-      dL4 /* post-data: the stub computed previously */
-      ))) {
-
-      /* Add this marker to the 'insertanda' list */
-      if (*jwmarker_num < JPWL_MAX_NO_MARKERS) {
-        jwmarker[*jwmarker_num].id = J2K_MS_EPB; /* its type */
-        jwmarker[*jwmarker_num].m.epbmark = epb_mark; /* the EPB */
-        jwmarker[*jwmarker_num].pos = (int) place_pos; /* after SOT */
-        jwmarker[*jwmarker_num].dpos = place_pos + 0.0000001 * (double)(*idx); /* not very first! */
-        jwmarker[*jwmarker_num].len = epb_mark->Lepb; /* its length */
-        jwmarker[*jwmarker_num].len_ready = true; /* ready */
-        jwmarker[*jwmarker_num].pos_ready = true; /* ready */
-        jwmarker[*jwmarker_num].parms_ready = true; /* ready */
-        jwmarker[*jwmarker_num].data_ready = false; /* not ready */
-        (*jwmarker_num)++;
-      }
-
-      /* increment epb index */
-      (*idx)++;
-
-      /* decrease postlen */
-      post_len -= dL4;
-
-      /* increase the total length of EPBs */
-      epbs_len += epb_mark->Lepb + 2;
-
-    } else {
-      /* ooops, problems */
-      opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB for UEP in tile %d\n", tileno);
-    };
-  }
-
-  return epbs_len;
-}
-
-
-jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int tileno, int idx, int hprot,
-              unsigned long int pre_len, unsigned long int post_len) {
-
-  jpwl_epb_ms_t *epb = NULL;
-  /*unsigned short int data_len = 0;*/
-  unsigned short int L2, L3;
-  unsigned long int L1, L4;
-  /*unsigned char *predata_in = NULL;*/
-
-  bool insideMH = (tileno == -1);
-
-  /* Alloc space */
-  if (!(epb = (jpwl_epb_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_epb_ms_t)))) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for one EPB MS\n");
-    return NULL;
-  };
-
-  /* We set RS(n,k) for EPB parms and pre-data, if any */
-  if (insideMH && (idx == 0)) {
-    /* First EPB in MH */
-    epb->k_pre = 64;
-    epb->n_pre = 160;
-  } else if (!insideMH && (idx == 0)) {
-    /* First EPB in TH */
-    epb->k_pre = 25;
-    epb->n_pre = 80;
-  } else {
-    /* Following EPBs in MH or TH */
-    epb->k_pre = 13;
-    epb->n_pre = 40;
-  };
-
-  /* Find lengths, Figs. B3 and B4 */
-  /* size of pre data: pre_buf(pre_len) + EPB(2) + Lepb(2) + Depb(1) + LDPepb(4) + Pepb(4) */
-  L1 = pre_len + 13;
-  epb->pre_len = pre_len;
-
-  /* size of pre-data redundancy */
-  /*   (redundancy per codeword)       *               (number of codewords, rounded up)   */
-  L2 = (epb->n_pre - epb->k_pre) * (unsigned short int) ceil((double) L1 / (double) epb->k_pre);
-
-  /* length of post-data */
-  L4 = post_len;
-  epb->post_len = post_len;
-
-  /* Find protection type for post data and its associated redundancy field length*/
-  if ((hprot == 16) || (hprot == 32)) {
-    /* there is a CRC for post-data */
-    epb->Pepb = 0x10000000 | ((unsigned long int) hprot >> 5); /* 0=CRC-16, 1=CRC-32 */
-    epb->k_post = post_len;
-    epb->n_post = post_len + (hprot >> 3);
-    /*L3 = hprot >> 3;*/ /* 2 (CRC-16) or 4 (CRC-32) bytes */
-
-  } else if ((hprot >= 37) && (hprot <= 128)) {
-    /* there is a RS for post-data */
-    epb->Pepb = 0x20000020 | (((unsigned long int) hprot & 0x000000FF) << 8);
-    epb->k_post = 32;
-    epb->n_post = hprot;
-
-  } else if (hprot == 1) {
-    /* Use predefined codes */
-    epb->Pepb = (unsigned long int) 0x00000000;
-    epb->n_post = epb->n_pre;
-    epb->k_post = epb->k_pre;
-
-  } else if (hprot == 0) {
-    /* Placeholder EPB: only protects its parameters, no protection method */
-    epb->Pepb = (unsigned long int) 0xFFFFFFFF;
-    epb->n_post = 1;
-    epb->k_post = 1;
-
-  } else {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Invalid protection value for EPB h = %d\n", hprot);
-    return NULL;
-  }
-
-  epb->hprot = hprot;
-
-  /*   (redundancy per codeword)          *                (number of codewords, rounded up) */
-  L3 = (epb->n_post - epb->k_post) * (unsigned short int) ceil((double) L4 / (double) epb->k_post);
-
-  /* private fields */
-  epb->tileno = tileno;
-
-  /* Fill some fields of the EPB */
-
-  /* total length of the EPB MS (less the EPB marker itself): */
-  /* Lepb(2) + Depb(1) + LDPepb(4) + Pepb(4) + pre_redundancy + post-redundancy */
-  epb->Lepb = 11 + L2 + L3;
-
-  /* EPB style */
-  epb->Depb = ((packed & 0x0001) << 7) | ((latest & 0x0001) << 6) | (idx & 0x003F);
-
-  /* length of data protected by EPB: */
-  epb->LDPepb = L1 + L4;
-
-  return epb;
-}
-
-void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf) {
-
-  /* Marker */
-  *(buf++) = (unsigned char) (J2K_MS_EPB >> 8);
-  *(buf++) = (unsigned char) (J2K_MS_EPB >> 0);
-
-  /* Lepb */
-  *(buf++) = (unsigned char) (epb->Lepb >> 8);
-  *(buf++) = (unsigned char) (epb->Lepb >> 0);
-
-  /* Depb */
-  *(buf++) = (unsigned char) (epb->Depb >> 0);
-
-  /* LDPepb */
-  *(buf++) = (unsigned char) (epb->LDPepb >> 24);
-  *(buf++) = (unsigned char) (epb->LDPepb >> 16);
-  *(buf++) = (unsigned char) (epb->LDPepb >> 8);
-  *(buf++) = (unsigned char) (epb->LDPepb >> 0);
-
-  /* Pepb */
-  *(buf++) = (unsigned char) (epb->Pepb >> 24);
-  *(buf++) = (unsigned char) (epb->Pepb >> 16);
-  *(buf++) = (unsigned char) (epb->Pepb >> 8);
-  *(buf++) = (unsigned char) (epb->Pepb >> 0);
-
-  /* Data */
-  /*memcpy(buf, epb->data, (size_t) epb->Lepb - 11);*/
-  memset(buf, 0, (size_t) epb->Lepb - 11);
-
-  /* update markers struct */
-  j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, -1, epb->Lepb + 2);
-
-};
-
-
-jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, bool esd_on, bool red_on, bool epb_on, bool info_on) {
-
-  jpwl_epc_ms_t *epc = NULL;
-
-  /* Alloc space */
-  if (!(epc = (jpwl_epc_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_epc_ms_t)))) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for EPC MS\n");
-    return NULL;
-  };
-
-  /* Set the EPC parameters */
-  epc->esd_on = esd_on;
-  epc->epb_on = epb_on;
-  epc->red_on = red_on;
-  epc->info_on = info_on;
-
-  /* Fill the EPC fields with default values */
-  epc->Lepc = 9;
-  epc->Pcrc = 0x0000;
-  epc->DL = 0x00000000;
-  epc->Pepc = ((j2k->cp->esd_on & 0x0001) << 4) | ((j2k->cp->red_on & 0x0001) << 5) |
-    ((j2k->cp->epb_on & 0x0001) << 6) | ((j2k->cp->info_on & 0x0001) << 7);
-
-  return (epc);
-}
-
-bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf, unsigned char *post_buf) {
-
-  unsigned long int L1, L2, L3, L4;
-  int remaining;
-  unsigned long int P, NN_P;
-
-  /* Operating buffer */
-  static unsigned char codeword[NN], *parityword;
-
-  unsigned char *L1_buf, *L2_buf;
-  /* these ones are static, since we need to keep memory of
-   the exact place from one call to the other */
-  static unsigned char *L3_buf, *L4_buf;
-
-  /* some consistency check */
-  if (!buf) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no operating buffer for EPBs\n");
-    return false;
-  }
-
-  if (!post_buf && !L4_buf) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no operating buffer for EPBs data\n");
-    return false;
-  }
-
-  /*
-   * Compute parity bytes on pre-data, ALWAYS present (at least only for EPB parms)
-   */
-
-  /* Initialize RS structures */
-  P = epb->n_pre - epb->k_pre;
-  NN_P = NN - P;
-  memset(codeword, 0, NN);
-  parityword = codeword + NN_P;
-  init_rs(NN_P);
-
-  /* pre-data begins pre_len bytes before of EPB buf */
-  L1_buf = buf - epb->pre_len;
-  L1 = epb->pre_len + 13;
-
-  /* redundancy for pre-data begins immediately after EPB parms */
-  L2_buf = buf + 13;
-  L2 = (epb->n_pre - epb->k_pre) * (unsigned short int) ceil((double) L1 / (double) epb->k_pre);
-
-  /* post-data
-     the position of L4 buffer can be:
-       1) passed as a parameter: in that case use it
-       2) null: in that case use the previous (static) one
-  */
-  if (post_buf)
-    L4_buf = post_buf;
-  L4 = epb->post_len;
-
-  /* post-data redundancy begins immediately after pre-data redundancy */
-  L3_buf = L2_buf + L2;
-  L3 = (epb->n_post - epb->k_post) * (unsigned short int) ceil((double) L4 / (double) epb->k_post);
-
-  /* let's check whether EPB length is sufficient to contain all these data */
-  if (epb->Lepb < (11 + L2 + L3))
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "There is no room in EPB data field for writing redundancy data\n");
-  /*printf("Env. %d, nec. %d (%d + %d)\n", epb->Lepb - 11, L2 + L3, L2, L3);*/
-
-  /* Compute redundancy of pre-data message words */
-  remaining = L1;
-  while (remaining) {
-
-    /* copy message data into codeword buffer */
-    if (remaining < epb->k_pre) {
-      /* the last message word is zero-padded */
-      memset(codeword, 0, NN);
-      memcpy(codeword, L1_buf, remaining);
-      L1_buf += remaining;
-      remaining = 0;
-
-    } else {
-      memcpy(codeword, L1_buf, epb->k_pre);
-      L1_buf += epb->k_pre;
-      remaining -= epb->k_pre;
-
-    }
-
-    /* Encode the buffer and obtain parity bytes */
-    if (encode_rs(codeword, parityword))
-      opj_event_msg(j2k->cinfo, EVT_WARNING,
-        "Possible encoding error in codeword @ position #%d\n", (L1_buf - buf) / epb->k_pre);
-
-    /* copy parity bytes only in redundancy buffer */
-    memcpy(L2_buf, parityword, P);
-
-    /* advance parity buffer */
-    L2_buf += P;
-  }
-
-  /*
-   * Compute parity bytes on post-data, may be absent if there are no data
-   */
-  /*printf("Hprot is %d (tileno=%d, k_pre=%d, n_pre=%d, k_post=%d, n_post=%d, pre_len=%d, post_len=%d)\n",
-    epb->hprot, epb->tileno, epb->k_pre, epb->n_pre, epb->k_post, epb->n_post, epb->pre_len,
-    epb->post_len);*/
-  if (epb->hprot < 0) {
-
-    /* there should be no EPB */
-
-  } else if (epb->hprot == 0) {
-
-    /* no protection for the data */
-    /* advance anyway */
-    L4_buf += epb->post_len;
-
-  } else if (epb->hprot == 16) {
-
-    /* CRC-16 */
-    unsigned short int mycrc = 0x0000;
-
-    /* compute the CRC field (excluding itself) */
-    remaining = L4;
-    while (remaining--)
-      jpwl_updateCRC16(&mycrc, *(L4_buf++));
-
-    /* write the CRC field */
-    *(L3_buf++) = (unsigned char) (mycrc >> 8);
-    *(L3_buf++) = (unsigned char) (mycrc >> 0);
-
-  } else if (epb->hprot == 32) {
-
-    /* CRC-32 */
-    unsigned long int mycrc = 0x00000000;
-
-    /* compute the CRC field (excluding itself) */
-    remaining = L4;
-    while (remaining--)
-      jpwl_updateCRC32(&mycrc, *(L4_buf++));
-
-    /* write the CRC field */
-    *(L3_buf++) = (unsigned char) (mycrc >> 24);
-    *(L3_buf++) = (unsigned char) (mycrc >> 16);
-    *(L3_buf++) = (unsigned char) (mycrc >> 8);
-    *(L3_buf++) = (unsigned char) (mycrc >> 0);
-
-  } else {
-
-    /* RS */
-
-    /* Initialize RS structures */
-    P = epb->n_post - epb->k_post;
-    NN_P = NN - P;
-    memset(codeword, 0, NN);
-    parityword = codeword + NN_P;
-    init_rs(NN_P);
-
-    /* Compute redundancy of post-data message words */
-    remaining = L4;
-    while (remaining) {
-
-      /* copy message data into codeword buffer */
-      if (remaining < epb->k_post) {
-        /* the last message word is zero-padded */
-        memset(codeword, 0, NN);
-        memcpy(codeword, L4_buf, remaining);
-        L4_buf += remaining;
-        remaining = 0;
-
-      } else {
-        memcpy(codeword, L4_buf, epb->k_post);
-        L4_buf += epb->k_post;
-        remaining -= epb->k_post;
-
-      }
-
-      /* Encode the buffer and obtain parity bytes */
-      if (encode_rs(codeword, parityword))
-        opj_event_msg(j2k->cinfo, EVT_WARNING,
-          "Possible encoding error in codeword @ position #%d\n", (L4_buf - buf) / epb->k_post);
-
-      /* copy parity bytes only in redundancy buffer */
-      memcpy(L3_buf, parityword, P);
-
-      /* advance parity buffer */
-      L3_buf += P;
-    }
-
-  }
-
-  return true;
-}
-
-
-bool jpwl_correct(opj_j2k_t *j2k) {
-
-  opj_cio_t *cio = j2k->cio;
-  bool status;
-  static bool mh_done = false;
-  int mark_pos, id, len, skips, sot_pos;
-  unsigned long int Psot = 0;
-
-  /* go back to marker position */
-  mark_pos = cio_tell(cio) - 2;
-  cio_seek(cio, mark_pos);
-
-  if ((j2k->state == J2K_STATE_MHSOC) && !mh_done) {
-
-    int mark_val = 0, skipnum = 0;
-
-    /*
-      COLOR IMAGE
-      first thing to do, if we are here, is to look whether
-      51 (skipnum) positions ahead there is an EPB, in case of MH
-    */
-    /*
-      B/W IMAGE
-      first thing to do, if we are here, is to look whether
-      45 (skipnum) positions ahead there is an EPB, in case of MH
-    */
-    /*       SIZ   SIZ_FIELDS     SIZ_COMPS               FOLLOWING_MARKER */
-    skipnum = 2  +     38     + 3 * j2k->cp->exp_comps  +         2;
-    if ((cio->bp + skipnum) < cio->end) {
-
-      cio_skip(cio, skipnum);
-
-      /* check that you are not going beyond the end of codestream */
-
-      /* call EPB corrector */
-      status = jpwl_epb_correct(j2k,     /* J2K decompressor handle */
-                    cio->bp, /* pointer to EPB in codestream buffer */
-                    0,       /* EPB type: MH */
-                    skipnum,      /* length of pre-data */
-                    -1,      /* length of post-data: -1 means auto */
-                    NULL,
-                    NULL
-                   );
-
-      /* read the marker value */
-      mark_val = (*(cio->bp) << 8) | *(cio->bp + 1);
-
-      if (status && (mark_val == J2K_MS_EPB)) {
-        /* we found it! */
-        mh_done = true;
-        return true;
-      }
-
-      /* Disable correction in case of missing or bad head EPB */
-      /* We can't do better! */
-      /* PATCHED: 2008-01-25 */
-      /* MOVED UP: 2008-02-01 */
-      if (!status) {
-        j2k->cp->correct = false;
-        opj_event_msg(j2k->cinfo, EVT_WARNING, "Couldn't find the MH EPB: disabling JPWL\n");
-      }
-
-    }
-
-  }
-
-  if (true /*(j2k->state == J2K_STATE_TPHSOT) || (j2k->state == J2K_STATE_TPH)*/) {
-    /* else, look if 12 positions ahead there is an EPB, in case of TPH */
-    cio_seek(cio, mark_pos);
-    if ((cio->bp + 12) < cio->end) {
-
-      cio_skip(cio, 12);
-
-      /* call EPB corrector */
-      status = jpwl_epb_correct(j2k,     /* J2K decompressor handle */
-                    cio->bp, /* pointer to EPB in codestream buffer */
-                    1,       /* EPB type: TPH */
-                    12,      /* length of pre-data */
-                    -1,      /* length of post-data: -1 means auto */
-                    NULL,
-                    NULL
-                   );
-      if (status)
-        /* we found it! */
-        return true;
-    }
-  }
-
-  return false;
-
-  /* for now, don't use this code */
-
-  /* else, look if here is an EPB, in case of other */
-  if (mark_pos > 64) {
-    /* it cannot stay before the first MH EPB */
-    cio_seek(cio, mark_pos);
-    cio_skip(cio, 0);
-
-    /* call EPB corrector */
-    status = jpwl_epb_correct(j2k,     /* J2K decompressor handle */
-                  cio->bp, /* pointer to EPB in codestream buffer */
-                  2,       /* EPB type: TPH */
-                  0,       /* length of pre-data */
-                  -1,      /* length of post-data: -1 means auto */
-                  NULL,
-                  NULL
-                 );
-    if (status)
-      /* we found it! */
-      return true;
-  }
-
-  /* nope, no EPBs probably, or they are so damaged that we can give up */
-  return false;
-
-  return true;
-
-  /* AN ATTEMPT OF PARSER */
-  /* NOT USED ACTUALLY    */
-
-  /* go to the beginning of the file */
-  cio_seek(cio, 0);
-
-  /* let's begin */
-  j2k->state = J2K_STATE_MHSOC;
-
-  /* cycle all over the markers */
-  while (cio_tell(cio) < cio->length) {
-
-    /* read the marker */
-    mark_pos = cio_tell(cio);
-    id = cio_read(cio, 2);
-
-    /* details */
-    printf("Marker@%d: %X\n", cio_tell(cio) - 2, id);
-
-    /* do an action in response to the read marker */
-    switch (id) {
-
-    /* short markers */
-
-      /* SOC */
-    case J2K_MS_SOC:
-      j2k->state = J2K_STATE_MHSIZ;
-      len = 0;
-      skips = 0;
-      break;
-
-      /* EOC */
-    case J2K_MS_EOC:
-      j2k->state = J2K_STATE_MT;
-      len = 0;
-      skips = 0;
-      break;
-
-      /* particular case of SOD */
-    case J2K_MS_SOD:
-      len = Psot - (mark_pos - sot_pos) - 2;
-      skips = len;
-      break;
-
-    /* long markers */
-
-      /* SOT */
-    case J2K_MS_SOT:
-      j2k->state = J2K_STATE_TPH;
-      sot_pos = mark_pos; /* position of SOT */
-      len = cio_read(cio, 2); /* read the length field */
-      cio_skip(cio, 2); /* this field is unnecessary */
-      Psot = cio_read(cio, 4); /* tile length */
-      skips = len - 8;
-      break;
-
-      /* remaining */
-    case J2K_MS_SIZ:
-      j2k->state = J2K_STATE_MH;
-      /* read the length field */
-      len = cio_read(cio, 2);
-      skips = len - 2;
-      break;
-
-      /* remaining */
-    default:
-      /* read the length field */
-      len = cio_read(cio, 2);
-      skips = len - 2;
-      break;
-
-    }
-
-    /* skip to marker's end */
-    cio_skip(cio, skips);
-
-  }
-
-
-}
-
-bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
-            unsigned char **L4_bufp) {
-
-  /* Operating buffer */
-  unsigned char codeword[NN], *parityword;
-
-  unsigned long int P, NN_P;
-  unsigned long int L1, L4;
-  int remaining, n_pre, k_pre, n_post, k_post;
-
-  int status, tt;
-
-  int orig_pos = cio_tell(j2k->cio);
-
-  unsigned char *L1_buf, *L2_buf;
-  unsigned char *L3_buf, *L4_buf;
-
-  unsigned long int LDPepb, Pepb;
-  unsigned short int Lepb;
-  unsigned char Depb;
-  char str1[25] = "";
-  int myconn, errnum = 0;
-  bool errflag = false;
-
-  opj_cio_t *cio = j2k->cio;
-
-  /* check for common errors */
-  if (!buffer) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "The EPB pointer is a NULL buffer\n");
-    return false;
-  }
-
-  /* set bignesses */
-  L1 = pre_len + 13;
-
-  /* pre-data correction */
-  switch (type) {
-
-  case 0:
-    /* MH EPB */
-    k_pre = 64;
-    n_pre = 160;
-    break;
-
-  case 1:
-    /* TPH EPB */
-    k_pre = 25;
-    n_pre = 80;
-    break;
-
-  case 2:
-    /* other EPBs */
-    k_pre = 13;
-    n_pre = 40;
-    break;
-
-  case 3:
-    /* automatic setup */
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Auto. setup not yet implemented\n");
-    return false;
-    break;
-
-  default:
-    /* unknown type */
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Unknown expected EPB type\n");
-    return false;
-    break;
-
-  }
-
-  /* Initialize RS structures */
-  P = n_pre - k_pre;
-  NN_P = NN - P;
-  tt = (int) floor((float) P / 2.0F); /* correction capability of the code */
-  memset(codeword, 0, NN);
-  parityword = codeword + NN_P;
-  init_rs(NN_P);
-
-  /* Correct pre-data message words */
-  L1_buf = buffer - pre_len;
-  L2_buf = buffer + 13;
-  remaining = L1;
-  while (remaining) {
-
-    /* always zero-pad codewords */
-    /* (this is required, since after decoding the zeros in the long codeword
-        could change, and keep unchanged in subsequent calls) */
-    memset(codeword, 0, NN);
-
-    /* copy codeword buffer into message bytes */
-    if (remaining < k_pre)
-      memcpy(codeword, L1_buf, remaining);
-    else
-      memcpy(codeword, L1_buf, k_pre);
-
-    /* copy redundancy buffer in parity bytes */
-    memcpy(parityword, L2_buf, P);
-
-    /* Decode the buffer and possibly obtain corrected bytes */
-    status = eras_dec_rs(codeword, NULL, 0);
-    if (status == -1) {
-      /*if (conn == NULL)
-        opj_event_msg(j2k->cinfo, EVT_WARNING,
-          "Possible decoding error in codeword @ position #%d\n", (L1_buf - buffer) / k_pre);*/
-      errflag = true;
-      /* we can try to safely get out from the function:
-        if we are here, either this is not an EPB or the first codeword
-        is too damaged to be helpful */
-      /*return false;*/
-
-    } else if (status == 0) {
-      /*if (conn == NULL)
-        opj_event_msg(j2k->cinfo, EVT_INFO, "codeword is correctly decoded\n");*/
-
-    } else if (status <= tt) {
-      /* it has corrected 0 <= errs <= tt */
-      /*if (conn == NULL)
-        opj_event_msg(j2k->cinfo, EVT_WARNING, "%d errors corrected in codeword\n", status);*/
-      errnum += status;
-
-    } else {
-      /*if (conn == NULL)
-        opj_event_msg(j2k->cinfo, EVT_WARNING, "EPB correction capability exceeded\n");
-      return false;*/
-      errflag = true;
-    }
-
-
-    /* advance parity buffer */
-    if ((status >= 0) && (status <= tt))
-      /* copy back corrected parity only if all is OK */
-      memcpy(L2_buf, parityword, P);
-    L2_buf += P;
-
-    /* advance message buffer */
-    if (remaining < k_pre) {
-      if ((status >= 0) && (status <= tt))
-        /* copy back corrected data only if all is OK */
-        memcpy(L1_buf, codeword, remaining);
-      L1_buf += remaining;
-      remaining = 0;
-
-    } else {
-      if ((status >= 0) && (status <= tt))
-        /* copy back corrected data only if all is OK */
-        memcpy(L1_buf, codeword, k_pre);
-      L1_buf += k_pre;
-      remaining -= k_pre;
-
-    }
-  }
-
-  /* print summary */
-  if (!conn) {
-
-    /*if (errnum)
-      opj_event_msg(j2k->cinfo, EVT_INFO, "+ %d symbol errors corrected (Ps=%.1e)\n", errnum,
-        (float) errnum / ((float) n_pre * (float) L1 / (float) k_pre));*/
-    if (errflag) {
-      /*opj_event_msg(j2k->cinfo, EVT_INFO, "+ there were unrecoverable errors\n");*/
-      return false;
-    }
-
-  }
-
-  /* presumably, now, EPB parameters are correct */
-  /* let's get them */
-
-  /* Simply read the EPB parameters */
-  if (conn)
-    cio->bp = buffer;
-  cio_skip(cio, 2); /* the marker */
-  Lepb = cio_read(cio, 2);
-  Depb = cio_read(cio, 1);
-  LDPepb = cio_read(cio, 4);
-  Pepb = cio_read(cio, 4);
-
-  /* What does Pepb tells us about the protection method? */
-  if (((Pepb & 0xF0000000) >> 28) == 0)
-    sprintf(str1, "pred"); /* predefined */
-  else if (((Pepb & 0xF0000000) >> 28) == 1)
-    sprintf(str1, "crc-%lu", 16 * ((Pepb & 0x00000001) + 1)); /* CRC mode */
-  else if (((Pepb & 0xF0000000) >> 28) == 2)
-    sprintf(str1, "rs(%lu,32)", (Pepb & 0x0000FF00) >> 8); /* RS mode */
-  else if (Pepb == 0xFFFFFFFF)
-    sprintf(str1, "nometh"); /* RS mode */
-  else
-    sprintf(str1, "unknown"); /* unknown */
-
-  /* Now we write them to screen */
-  if (!conn && post_len)
-    opj_event_msg(j2k->cinfo, EVT_INFO,
-      "EPB(%d): (%sl, %sp, %u), %lu, %s\n",
-      cio_tell(cio) - 13,
-      (Depb & 0x40) ? "" : "n", /* latest EPB or not? */
-      (Depb & 0x80) ? "" : "n", /* packed or unpacked EPB? */
-      (Depb & 0x3F), /* EPB index value */
-      LDPepb, /*length of the data protected by the EPB */
-      str1); /* protection method */
-
-
-  /* well, we need to investigate how long is the connected length of packed EPBs */
-  myconn = Lepb + 2;
-  if ((Depb & 0x40) == 0) /* not latest in header */
-    jpwl_epb_correct(j2k,      /* J2K decompressor handle */
-               buffer + Lepb + 2,   /* pointer to next EPB in codestream buffer */
-               2,     /* EPB type: should be of other type */
-               0,  /* only EPB fields */
-               0, /* do not look after */
-             &myconn,
-             NULL
-               );
-  if (conn)
-    *conn += myconn;
-
-  /*if (!conn)
-    printf("connected = %d\n", myconn);*/
-
-  /*cio_seek(j2k->cio, orig_pos);
-  return true;*/
-
-  /* post-data
-     the position of L4 buffer is at the end of currently connected EPBs
-  */
-  if (!(L4_bufp))
-    L4_buf = buffer + myconn;
-  else if (!(*L4_bufp))
-    L4_buf = buffer + myconn;
-  else
-    L4_buf = *L4_bufp;
-  if (post_len == -1)
-    L4 = LDPepb - pre_len - 13;
-  else if (post_len == 0)
-    L4 = 0;
-  else
-    L4 = post_len;
-
-  L3_buf = L2_buf;
-
-  /* Do a further check here on the read parameters */
-  if (L4 > (unsigned long) cio_numbytesleft(j2k->cio))
-    /* overflow */
-    return false;
-
-  /* we are ready for decoding the remaining data */
-  if (((Pepb & 0xF0000000) >> 28) == 1) {
-    /* CRC here */
-    if ((16 * ((Pepb & 0x00000001) + 1)) == 16) {
-
-      /* CRC-16 */
-      unsigned short int mycrc = 0x0000, filecrc = 0x0000;
-
-      /* compute the CRC field */
-      remaining = L4;
-      while (remaining--)
-        jpwl_updateCRC16(&mycrc, *(L4_buf++));
-
-      /* read the CRC field */
-      filecrc = *(L3_buf++) << 8;
-      filecrc |= *(L3_buf++);
-
-      /* check the CRC field */
-      if (mycrc == filecrc) {
-        if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_INFO, "- CRC is OK\n");
-      } else {
-        if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_WARNING, "- CRC is KO (r=%d, c=%d)\n", filecrc, mycrc);
-        errflag = true;
-      }
-    }
-
-    if ((16 * ((Pepb & 0x00000001) + 1)) == 32) {
-
-      /* CRC-32 */
-      unsigned long int mycrc = 0x00000000, filecrc = 0x00000000;
-
-      /* compute the CRC field */
-      remaining = L4;
-      while (remaining--)
-        jpwl_updateCRC32(&mycrc, *(L4_buf++));
-
-      /* read the CRC field */
-      filecrc = *(L3_buf++) << 24;
-      filecrc |= *(L3_buf++) << 16;
-      filecrc |= *(L3_buf++) << 8;
-      filecrc |= *(L3_buf++);
-
-      /* check the CRC field */
-      if (mycrc == filecrc) {
-        if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_INFO, "- CRC is OK\n");
-      } else {
-        if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_WARNING, "- CRC is KO (r=%d, c=%d)\n", filecrc, mycrc);
-        errflag = true;
-      }
-    }
-
-  } else if (Pepb == 0xFFFFFFFF) {
-    /* no method */
-
-    /* advance without doing anything */
-    remaining = L4;
-    while (remaining--)
-      L4_buf++;
-
-  } else if ((((Pepb & 0xF0000000) >> 28) == 2) || (((Pepb & 0xF0000000) >> 28) == 0)) {
-    /* RS coding here */
-
-    if (((Pepb & 0xF0000000) >> 28) == 0) {
-
-      k_post = k_pre;
-      n_post = n_pre;
-
-    } else {
-
-      k_post = 32;
-      n_post = (Pepb & 0x0000FF00) >> 8;
-    }
-
-    /* Initialize RS structures */
-    P = n_post - k_post;
-    NN_P = NN - P;
-    tt = (int) floor((float) P / 2.0F); /* again, correction capability */
-    memset(codeword, 0, NN);
-    parityword = codeword + NN_P;
-    init_rs(NN_P);
-
-    /* Correct post-data message words */
-    /*L4_buf = buffer + Lepb + 2;*/
-    L3_buf = L2_buf;
-    remaining = L4;
-    while (remaining) {
-
-      /* always zero-pad codewords */
-      /* (this is required, since after decoding the zeros in the long codeword
-        could change, and keep unchanged in subsequent calls) */
-      memset(codeword, 0, NN);
-
-      /* copy codeword buffer into message bytes */
-      if (remaining < k_post)
-        memcpy(codeword, L4_buf, remaining);
-      else
-        memcpy(codeword, L4_buf, k_post);
-
-      /* copy redundancy buffer in parity bytes */
-      memcpy(parityword, L3_buf, P);
-
-      /* Decode the buffer and possibly obtain corrected bytes */
-      status = eras_dec_rs(codeword, NULL, 0);
-      if (status == -1) {
-        /*if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_WARNING,
-            "Possible decoding error in codeword @ position #%d\n", (L4_buf - (buffer + Lepb + 2)) / k_post);*/
-        errflag = true;
-
-      } else if (status == 0) {
-        /*if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_INFO, "codeword is correctly decoded\n");*/
-
-      } else if (status <= tt) {
-        /*if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_WARNING, "%d errors corrected in codeword\n", status);*/
-        errnum += status;
-
-      } else {
-        /*if (conn == NULL)
-          opj_event_msg(j2k->cinfo, EVT_WARNING, "EPB correction capability exceeded\n");
-        return false;*/
-        errflag = true;
-      }
-
-
-      /* advance parity buffer */
-      if ((status >= 0) && (status <= tt))
-        /* copy back corrected data only if all is OK */
-        memcpy(L3_buf, parityword, P);
-      L3_buf += P;
-
-      /* advance message buffer */
-      if (remaining < k_post) {
-        if ((status >= 0) && (status <= tt))
-          /* copy back corrected data only if all is OK */
-          memcpy(L4_buf, codeword, remaining);
-        L4_buf += remaining;
-        remaining = 0;
-
-      } else {
-        if ((status >= 0) && (status <= tt))
-          /* copy back corrected data only if all is OK */
-          memcpy(L4_buf, codeword, k_post);
-        L4_buf += k_post;
-        remaining -= k_post;
-
-      }
-    }
-  }
-
-  /* give back the L4_buf address */
-  if (L4_bufp)
-    *L4_bufp = L4_buf;
-
-  /* print summary */
-  if (!conn) {
-
-    if (errnum)
-      opj_event_msg(j2k->cinfo, EVT_INFO, "- %d symbol errors corrected (Ps=%.1e)\n", errnum,
-        (float) errnum / (float) LDPepb);
-    if (errflag)
-      opj_event_msg(j2k->cinfo, EVT_INFO, "- there were unrecoverable errors\n");
-
-  }
-
-  cio_seek(j2k->cio, orig_pos);
-
-  return true;
-}
-
-void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf) {
-
-  /* Marker */
-  *(buf++) = (unsigned char) (J2K_MS_EPC >> 8);
-  *(buf++) = (unsigned char) (J2K_MS_EPC >> 0);
-
-  /* Lepc */
-  *(buf++) = (unsigned char) (epc->Lepc >> 8);
-  *(buf++) = (unsigned char) (epc->Lepc >> 0);
-
-  /* Pcrc */
-  *(buf++) = (unsigned char) (epc->Pcrc >> 8);
-  *(buf++) = (unsigned char) (epc->Pcrc >> 0);
-
-  /* DL */
-  *(buf++) = (unsigned char) (epc->DL >> 24);
-  *(buf++) = (unsigned char) (epc->DL >> 16);
-  *(buf++) = (unsigned char) (epc->DL >> 8);
-  *(buf++) = (unsigned char) (epc->DL >> 0);
-
-  /* Pepc */
-  *(buf++) = (unsigned char) (epc->Pepc >> 0);
-
-  /* Data */
-  /*memcpy(buf, epc->data, (size_t) epc->Lepc - 9);*/
-  memset(buf, 0, (size_t) epc->Lepc - 9);
-
-  /* update markers struct */
-  j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, -1, epc->Lepc + 2);
-
-};
-
-int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
-          int comps, unsigned char addrm, unsigned char ad_size,
-          unsigned char senst, unsigned char se_size,
-          double place_pos, int tileno) {
-
-  return 0;
-}
-
-jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, unsigned char ad_size,
-                unsigned char senst, unsigned char se_size, int tileno,
-                unsigned long int svalnum, void *sensval) {
-
-  jpwl_esd_ms_t *esd = NULL;
-
-  /* Alloc space */
-  if (!(esd = (jpwl_esd_ms_t *) opj_malloc((size_t) 1 * sizeof (jpwl_esd_ms_t)))) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for ESD MS\n");
-    return NULL;
-  };
-
-  /* if relative sensitivity, activate byte range mode */
-  if (senst == 0)
-    addrm = 1;
-
-  /* size of sensval's ... */
-  if ((ad_size != 0) && (ad_size != 2) && (ad_size != 4)) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Address size %d for ESD MS is forbidden\n", ad_size);
-    return NULL;
-  }
-  if ((se_size != 1) && (se_size != 2)) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Sensitivity size %d for ESD MS is forbidden\n", se_size);
-    return NULL;
-  }
-
-  /* ... depends on the addressing mode */
-  switch (addrm) {
-
-  /* packet mode */
-  case (0):
-    ad_size = 0; /* as per the standard */
-    esd->sensval_size = se_size;
-    break;
-
-  /* byte range */
-  case (1):
-    /* auto sense address size */
-    if (ad_size == 0)
-      /* if there are more than 66% of (2^16 - 1) bytes, switch to 4 bytes
-       (we keep space for possible EPBs being inserted) */
-      ad_size = (j2k->cstr_info->codestream_size > (1 * 65535 / 3)) ? 4 : 2;
-    esd->sensval_size = ad_size + ad_size + se_size;
-    break;
-
-  /* packet range */
-  case (2):
-    /* auto sense address size */
-    if (ad_size == 0)
-      /* if there are more than 2^16 - 1 packets, switch to 4 bytes */
-      ad_size = (j2k->cstr_info->packno > 65535) ? 4 : 2;
-    esd->sensval_size = ad_size + ad_size + se_size;
-    break;
-
-  case (3):
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Address mode %d for ESD MS is unimplemented\n", addrm);
-    return NULL;
-
-  default:
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "Address mode %d for ESD MS is forbidden\n", addrm);
-    return NULL;
-  }
-
-  /* set or unset sensitivity values */
-  if (svalnum <= 0) {
-
-    switch (senst) {
-
-    /* just based on the portions of a codestream */
-    case (0):
-      /* MH + no. of THs + no. of packets */
-      svalnum = 1 + (j2k->cstr_info->tw * j2k->cstr_info->th) * (1 + j2k->cstr_info->packno);
-      break;
-
-    /* all the ones that are based on the packets */
-    default:
-      if (tileno < 0)
-        /* MH: all the packets and all the tiles info is written */
-        svalnum = j2k->cstr_info->tw * j2k->cstr_info->th * j2k->cstr_info->packno;
-      else
-        /* TPH: only that tile info is written */
-        svalnum = j2k->cstr_info->packno;
-      break;
-
-    }
-  }
-
-  /* fill private fields */
-  esd->senst = senst;
-  esd->ad_size = ad_size;
-  esd->se_size = se_size;
-  esd->addrm = addrm;
-  esd->svalnum = svalnum;
-  esd->numcomps = j2k->image->numcomps;
-  esd->tileno = tileno;
-
-  /* Set the ESD parameters */
-  /* length, excluding data field */
-  if (esd->numcomps < 257)
-    esd->Lesd = 4 + (unsigned short int) (esd->svalnum * esd->sensval_size);
-  else
-    esd->Lesd = 5 + (unsigned short int) (esd->svalnum * esd->sensval_size);
-
-  /* component data field */
-  if (comp >= 0)
-    esd->Cesd = comp;
-  else
-    /* we are averaging */
-    esd->Cesd = 0;
-
-  /* Pesd field */
-  esd->Pesd = 0x00;
-  esd->Pesd |= (esd->addrm & 0x03) << 6; /* addressing mode */
-  esd->Pesd |= (esd->senst & 0x07) << 3; /* sensitivity type */
-  esd->Pesd |= ((esd->se_size >> 1) & 0x01) << 2; /* sensitivity size */
-  esd->Pesd |= ((esd->ad_size >> 2) & 0x01) << 1; /* addressing size */
-  esd->Pesd |= (comp < 0) ? 0x01 : 0x00; /* averaging components */
-
-  /* if pointer to sensval is NULL, we can fill data field by ourselves */
-  if (!sensval) {
-
-    /* old code moved to jpwl_esd_fill() */
-    esd->data = NULL;
-
-  } else {
-      /* we set the data field as the sensitivity values poinnter passed to the function */
-      esd->data = (unsigned char *) sensval;
-  }
-
-  return (esd);
-}
-
-bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
-
-  int i;
-  unsigned long int vv;
-  unsigned long int addr1 = 0L, addr2 = 0L;
-  double dvalue = 0.0, Omax2, tmp, TSE = 0.0, MSE, oldMSE = 0.0, PSNR, oldPSNR = 0.0;
-  unsigned short int pfpvalue;
-  unsigned long int addrmask = 0x00000000;
-  bool doneMH = false, doneTPH = false;
-
-  /* sensitivity values in image info are as follows:
-    - for each tile, distotile is the starting distortion for that tile, sum of all components
-    - for each packet in a tile, disto is the distortion reduction caused by that packet to that tile
-    - the TSE for a single tile should be given by   distotile - sum(disto)  , for all components
-    - the MSE for a single tile is given by     TSE / nbpix    , for all components
-    - the PSNR for a single tile is given by   10*log10( Omax^2 / MSE)    , for all components
-      (Omax is given by    2^bpp - 1    for unsigned images and by    2^(bpp - 1) - 1    for signed images
-  */
-
-  /* browse all components and find Omax */
-  Omax2 = 0.0;
-  for (i = 0; i < j2k->image->numcomps; i++) {
-    tmp = pow(2.0, (double) (j2k->image->comps[i].sgnd ?
-      (j2k->image->comps[i].bpp - 1) : (j2k->image->comps[i].bpp))) - 1;
-    if (tmp > Omax2)
-      Omax2 = tmp;
-  }
-  Omax2 = Omax2 * Omax2;
-
-  /* if pointer of esd->data is not null, simply write down all the values byte by byte */
-  if (esd->data) {
-    for (i = 0; i < (int) esd->svalnum; i++)
-      *(buf++) = esd->data[i];
-    return true;
-  }
-
-  /* addressing mask */
-  if (esd->ad_size == 2)
-    addrmask = 0x0000FFFF; /* two bytes */
-  else
-    addrmask = 0xFFFFFFFF; /* four bytes */
-
-  /* set on precise point where sensitivity starts */
-  if (esd->numcomps < 257)
-    buf += 6;
-  else
-    buf += 7;
-
-  /* let's fill the data fields */
-  for (vv = (esd->tileno < 0) ? 0 : (j2k->cstr_info->packno * esd->tileno); vv < esd->svalnum; vv++) {
-
-    int thistile = vv / j2k->cstr_info->packno, thispacket = vv % j2k->cstr_info->packno;
-
-    /* skip for the hack some lines below */
-    if (thistile == j2k->cstr_info->tw * j2k->cstr_info->th)
-      break;
-
-    /* starting tile distortion */
-    if (thispacket == 0) {
-      TSE = j2k->cstr_info->tile[thistile].distotile;
-      oldMSE = TSE / j2k->cstr_info->tile[thistile].numpix;
-      oldPSNR = 10.0 * log10(Omax2 / oldMSE);
-    }
-
-    /* TSE */
-    TSE -= j2k->cstr_info->tile[thistile].packet[thispacket].disto;
-
-    /* MSE */
-    MSE = TSE / j2k->cstr_info->tile[thistile].numpix;
-
-    /* PSNR */
-    PSNR = 10.0 * log10(Omax2 / MSE);
-
-    /* fill the address range */
-    switch (esd->addrm) {
-
-    /* packet mode */
-    case (0):
-      /* nothing, there is none */
-      break;
-
-    /* byte range */
-    case (1):
-      /* start address of packet */
-      addr1 = (j2k->cstr_info->tile[thistile].packet[thispacket].start_pos) & addrmask;
-      /* end address of packet */
-      addr2 = (j2k->cstr_info->tile[thistile].packet[thispacket].end_pos) & addrmask;
-      break;
-
-    /* packet range */
-    case (2):
-      /* not implemented here */
-      opj_event_msg(j2k->cinfo, EVT_WARNING, "Addressing mode packet_range is not implemented\n");
-      break;
-
-    /* unknown addressing method */
-    default:
-      /* not implemented here */
-      opj_event_msg(j2k->cinfo, EVT_WARNING, "Unknown addressing mode\n");
-      break;
-
-    }
-
-    /* hack for writing relative sensitivity of MH and TPHs */
-    if ((esd->senst == 0) && (thispacket == 0)) {
-
-      /* possible MH */
-      if ((thistile == 0) && !doneMH) {
-        /* we have to manage MH addresses */
-        addr1 = 0; /* start of MH */
-        addr2 = j2k->cstr_info->main_head_end; /* end of MH */
-        /* set special dvalue for this MH */
-        dvalue = -10.0;
-        doneMH = true; /* don't come here anymore */
-        vv--; /* wrap back loop counter */
-
-      } else if (!doneTPH) {
-        /* we have to manage TPH addresses */
-        addr1 = j2k->cstr_info->tile[thistile].start_pos;
-        addr2 = j2k->cstr_info->tile[thistile].end_header;
-        /* set special dvalue for this TPH */
-        dvalue = -1.0;
-        doneTPH = true; /* don't come here till the next tile */
-        vv--; /* wrap back loop counter */
-      }
-
-    } else
-      doneTPH = false; /* reset TPH counter */
-
-    /* write the addresses to the buffer */
-    switch (esd->ad_size) {
-
-    case (0):
-      /* do nothing */
-      break;
-
-    case (2):
-      /* two bytes */
-      *(buf++) = (unsigned char) (addr1 >> 8);
-      *(buf++) = (unsigned char) (addr1 >> 0);
-      *(buf++) = (unsigned char) (addr2 >> 8);
-      *(buf++) = (unsigned char) (addr2 >> 0);
-      break;
-
-    case (4):
-      /* four bytes */
-      *(buf++) = (unsigned char) (addr1 >> 24);
-      *(buf++) = (unsigned char) (addr1 >> 16);
-      *(buf++) = (unsigned char) (addr1 >> 8);
-      *(buf++) = (unsigned char) (addr1 >> 0);
-      *(buf++) = (unsigned char) (addr2 >> 24);
-      *(buf++) = (unsigned char) (addr2 >> 16);
-      *(buf++) = (unsigned char) (addr2 >> 8);
-      *(buf++) = (unsigned char) (addr2 >> 0);
-      break;
-
-    default:
-      /* do nothing */
-      break;
-    }
-
-
-    /* let's fill the value field */
-    switch (esd->senst) {
-
-    /* relative sensitivity */
-    case (0):
-      /* we just write down the packet ordering */
-      if (dvalue == -10)
-        /* MH */
-        dvalue = MAX_V1 + 1000.0; /* this will cause pfpvalue set to 0xFFFF */
-      else if (dvalue == -1)
-        /* TPH */
-        dvalue = MAX_V1 + 1000.0; /* this will cause pfpvalue set to 0xFFFF */
-      else
-        /* packet: first is most important, and then in decreasing order
-        down to the last, which counts for 1 */
-        dvalue = jpwl_pfp_to_double((unsigned short) (j2k->cstr_info->packno - thispacket), esd->se_size);
-      break;
-
-    /* MSE */
-    case (1):
-      /* !!! WRONG: let's put here disto field of packets !!! */
-      dvalue = MSE;
-      break;
-
-    /* MSE reduction */
-    case (2):
-      dvalue = oldMSE - MSE;
-      oldMSE = MSE;
-      break;
-
-    /* PSNR */
-    case (3):
-      dvalue = PSNR;
-      break;
-
-    /* PSNR increase */
-    case (4):
-      dvalue = PSNR - oldPSNR;
-      oldPSNR = PSNR;
-      break;
-
-    /* MAXERR */
-    case (5):
-      dvalue = 0.0;
-      opj_event_msg(j2k->cinfo, EVT_WARNING, "MAXERR sensitivity mode is not implemented\n");
-      break;
-
-    /* TSE */
-    case (6):
-      dvalue = TSE;
-      break;
-
-    /* reserved */
-    case (7):
-      dvalue = 0.0;
-      opj_event_msg(j2k->cinfo, EVT_WARNING, "Reserved sensitivity mode is not implemented\n");
-      break;
-
-    default:
-      dvalue = 0.0;
-      break;
-    }
-
-    /* compute the pseudo-floating point value */
-    pfpvalue = jpwl_double_to_pfp(dvalue, esd->se_size);
-
-    /* write the pfp value to the buffer */
-    switch (esd->se_size) {
-
-    case (1):
-      /* one byte */
-      *(buf++) = (unsigned char) (pfpvalue >> 0);
-      break;
-
-    case (2):
-      /* two bytes */
-      *(buf++) = (unsigned char) (pfpvalue >> 8);
-      *(buf++) = (unsigned char) (pfpvalue >> 0);
-      break;
-    }
-
-  }
-
-  return true;
-}
-
-void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
-
-  /* Marker */
-  *(buf++) = (unsigned char) (J2K_MS_ESD >> 8);
-  *(buf++) = (unsigned char) (J2K_MS_ESD >> 0);
-
-  /* Lesd */
-  *(buf++) = (unsigned char) (esd->Lesd >> 8);
-  *(buf++) = (unsigned char) (esd->Lesd >> 0);
-
-  /* Cesd */
-  if (esd->numcomps >= 257)
-    *(buf++) = (unsigned char) (esd->Cesd >> 8);
-  *(buf++) = (unsigned char) (esd->Cesd >> 0);
-
-  /* Pesd */
-  *(buf++) = (unsigned char) (esd->Pesd >> 0);
-
-  /* Data */
-  if (esd->numcomps < 257)
-    memset(buf, 0xAA, (size_t) esd->Lesd - 4);
-    /*memcpy(buf, esd->data, (size_t) esd->Lesd - 4);*/
-  else
-    memset(buf, 0xAA, (size_t) esd->Lesd - 5);
-    /*memcpy(buf, esd->data, (size_t) esd->Lesd - 5);*/
-
-  /* update markers struct */
-  j2k_add_marker(j2k->cstr_info, J2K_MS_ESD, -1, esd->Lesd + 2);
-
-}
-
-unsigned short int jpwl_double_to_pfp(double V, int bytes) {
-
-  unsigned short int em, e, m;
-
-  switch (bytes) {
-
-  case (1):
-
-    if (V < MIN_V1) {
-      e = 0x0000;
-      m = 0x0000;
-    } else if (V > MAX_V1) {
-      e = 0x000F;
-      m = 0x000F;
-    } else {
-      e = (unsigned short int) (floor(log(V) * 1.44269504088896) / 4.0);
-      m = (unsigned short int) (0.5 + (V / (pow(2.0, (double) (4 * e)))));
-    }
-    em = ((e & 0x000F) << 4) + (m & 0x000F);
-    break;
-
-  case (2):
-
-    if (V < MIN_V2) {
-      e = 0x0000;
-      m = 0x0000;
-    } else if (V > MAX_V2) {
-      e = 0x001F;
-      m = 0x07FF;
-    } else {
-      e = (unsigned short int) floor(log(V) * 1.44269504088896) + 15;
-      m = (unsigned short int) (0.5 + 2048.0 * ((V / (pow(2.0, (double) e - 15.0))) - 1.0));
-    }
-    em = ((e & 0x001F) << 11) + (m & 0x07FF);
-    break;
-
-  default:
-
-    em = 0x0000;
-    break;
-  };
-
-  return em;
-}
-
-double jpwl_pfp_to_double(unsigned short int em, int bytes) {
-
-  double V;
-
-  switch (bytes) {
-
-  case 1:
-    V = (double) (em & 0x0F) * pow(2.0, (double) (em & 0xF0));
-    break;
-
-  case 2:
-
-    V = pow(2.0, (double) ((em & 0xF800) >> 11) - 15.0) * (1.0 + (double) (em & 0x07FF) / 2048.0);
-    break;
-
-  default:
-    V = 0.0;
-    break;
-
-  }
-
-  return V;
-
-}
-
-bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num) {
-
-  int mm;
-  unsigned long int addlen;
-
-  opj_codestream_info_t *info = j2k->cstr_info;
-  int tileno, tpno, packno, numtiles = info->th * info->tw, numpacks = info->packno;
-
-  if (!j2k || !jwmarker ) {
-    opj_event_msg(j2k->cinfo, EVT_ERROR, "J2K handle or JPWL markers list badly allocated\n");
-    return false;
-  }
-
-  /* main_head_end: how many markers are there before? */
-  addlen = 0;
-  for (mm = 0; mm < jwmarker_num; mm++)
-    if (jwmarker[mm].pos < (unsigned long int) info->main_head_end)
-      addlen += jwmarker[mm].len + 2;
-  info->main_head_end += addlen;
-
-  /* codestream_size: always increment with all markers */
-  addlen = 0;
-  for (mm = 0; mm < jwmarker_num; mm++)
-    addlen += jwmarker[mm].len + 2;
-  info->codestream_size += addlen;
-
-  /* navigate through all the tiles */
-  for (tileno = 0; tileno < numtiles; tileno++) {
-
-    /* start_pos: increment with markers before SOT */
-    addlen = 0;
-    for (mm = 0; mm < jwmarker_num; mm++)
-      if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].start_pos)
-        addlen += jwmarker[mm].len + 2;
-    info->tile[tileno].start_pos += addlen;
-
-    /* end_header: increment with markers before of it */
-    addlen = 0;
-    for (mm = 0; mm < jwmarker_num; mm++)
-      if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].end_header)
-        addlen += jwmarker[mm].len + 2;
-    info->tile[tileno].end_header += addlen;
-
-    /* end_pos: increment with markers before the end of this tile */
-    /* code is disabled, since according to JPWL no markers can be beyond TPH */
-    addlen = 0;
-    for (mm = 0; mm < jwmarker_num; mm++)
-      if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].end_pos)
-        addlen += jwmarker[mm].len + 2;
-    info->tile[tileno].end_pos += addlen;
-
-    /* navigate through all the tile parts */
-    for (tpno = 0; tpno < info->tile[tileno].num_tps; tpno++) {
-
-      /* start_pos: increment with markers before SOT */
-      addlen = 0;
-      for (mm = 0; mm < jwmarker_num; mm++)
-        if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_start_pos)
-          addlen += jwmarker[mm].len + 2;
-      info->tile[tileno].tp[tpno].tp_start_pos += addlen;
-
-      /* end_header: increment with markers before of it */
-      addlen = 0;
-      for (mm = 0; mm < jwmarker_num; mm++)
-        if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_end_header)
-          addlen += jwmarker[mm].len + 2;
-      info->tile[tileno].tp[tpno].tp_end_header += addlen;
-
-      /* end_pos: increment with markers before the end of this tile part */
-      addlen = 0;
-      for (mm = 0; mm < jwmarker_num; mm++)
-        if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_end_pos)
-          addlen += jwmarker[mm].len + 2;
-      info->tile[tileno].tp[tpno].tp_end_pos += addlen;
-
-    }
-
-    /* navigate through all the packets in this tile */
-    for (packno = 0; packno < numpacks; packno++) {
-
-      /* start_pos: increment with markers before the packet */
-      /* disabled for the same reason as before */
-      addlen = 0;
-      for (mm = 0; mm < jwmarker_num; mm++)
-        if (jwmarker[mm].pos <= (unsigned long int) info->tile[tileno].packet[packno].start_pos)
-          addlen += jwmarker[mm].len + 2;
-      info->tile[tileno].packet[packno].start_pos += addlen;
-
-      /* end_ph_pos: increment with markers before the packet */
-      /* disabled for the same reason as before */
-      /*addlen = 0;
-      for (mm = 0; mm < jwmarker_num; mm++)
-        if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].end_ph_pos)
-          addlen += jwmarker[mm].len + 2;*/
-      info->tile[tileno].packet[packno].end_ph_pos += addlen;
-
-      /* end_pos: increment if marker is before the end of packet */
-      /* disabled for the same reason as before */
-      /*addlen = 0;
-      for (mm = 0; mm < jwmarker_num; mm++)
-        if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].end_pos)
-          addlen += jwmarker[mm].len + 2;*/
-      info->tile[tileno].packet[packno].end_pos += addlen;
-
-    }
-  }
-
-  /* reorder the markers list */
-
-  return true;
-}
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/rs.c b/Utilities/gdcmopenjpeg-v2/jpwl/rs.c
deleted file mode 100644
index 9c2582d..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/rs.c
+++ /dev/null
@@ -1,594 +0,0 @@
- /*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-/**
- at file rs.c
- at brief Functions used to compute the Reed-Solomon parity and check of byte arrays
-
-*/
-
-/**
- * Reed-Solomon coding and decoding
- * Phil Karn (karn at ka9q.ampr.org) September 1996
- *
- * This file is derived from the program "new_rs_erasures.c" by Robert
- * Morelos-Zaragoza (robert at spectra.eng.hawaii.edu) and Hari Thirumoorthy
- * (harit at spectra.eng.hawaii.edu), Aug 1995
- *
- * I've made changes to improve performance, clean up the code and make it
- * easier to follow. Data is now passed to the encoding and decoding functions
- * through arguments rather than in global arrays. The decode function returns
- * the number of corrected symbols, or -1 if the word is uncorrectable.
- *
- * This code supports a symbol size from 2 bits up to 16 bits,
- * implying a block size of 3 2-bit symbols (6 bits) up to 65535
- * 16-bit symbols (1,048,560 bits). The code parameters are set in rs.h.
- *
- * Note that if symbols larger than 8 bits are used, the type of each
- * data array element switches from unsigned char to unsigned int. The
- * caller must ensure that elements larger than the symbol range are
- * not passed to the encoder or decoder.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include "rs.h"
-
-/* This defines the type used to store an element of the Galois Field
- * used by the code. Make sure this is something larger than a char if
- * if anything larger than GF(256) is used.
- *
- * Note: unsigned char will work up to GF(256) but int seems to run
- * faster on the Pentium.
- */
-typedef int gf;
-
-/* Primitive polynomials - see Lin & Costello, Appendix A,
- * and  Lee & Messerschmitt, p. 453.
- */
-#if(MM == 2)/* Admittedly silly */
-int Pp[MM+1] = { 1, 1, 1 };
-
-#elif(MM == 3)
-/* 1 + x + x^3 */
-int Pp[MM+1] = { 1, 1, 0, 1 };
-
-#elif(MM == 4)
-/* 1 + x + x^4 */
-int Pp[MM+1] = { 1, 1, 0, 0, 1 };
-
-#elif(MM == 5)
-/* 1 + x^2 + x^5 */
-int Pp[MM+1] = { 1, 0, 1, 0, 0, 1 };
-
-#elif(MM == 6)
-/* 1 + x + x^6 */
-int Pp[MM+1] = { 1, 1, 0, 0, 0, 0, 1 };
-
-#elif(MM == 7)
-/* 1 + x^3 + x^7 */
-int Pp[MM+1] = { 1, 0, 0, 1, 0, 0, 0, 1 };
-
-#elif(MM == 8)
-/* 1+x^2+x^3+x^4+x^8 */
-int Pp[MM+1] = { 1, 0, 1, 1, 1, 0, 0, 0, 1 };
-
-#elif(MM == 9)
-/* 1+x^4+x^9 */
-int Pp[MM+1] = { 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
-
-#elif(MM == 10)
-/* 1+x^3+x^10 */
-int Pp[MM+1] = { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 11)
-/* 1+x^2+x^11 */
-int Pp[MM+1] = { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 12)
-/* 1+x+x^4+x^6+x^12 */
-int Pp[MM+1] = { 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 13)
-/* 1+x+x^3+x^4+x^13 */
-int Pp[MM+1] = { 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 14)
-/* 1+x+x^6+x^10+x^14 */
-int Pp[MM+1] = { 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 };
-
-#elif(MM == 15)
-/* 1+x+x^15 */
-int Pp[MM+1] = { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-
-#elif(MM == 16)
-/* 1+x+x^3+x^12+x^16 */
-int Pp[MM+1] = { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 };
-
-#else
-#error "MM must be in range 2-16"
-#endif
-
-/* Alpha exponent for the first root of the generator polynomial */
-#define B0  0  /* Different from the default 1 */
-
-/* index->polynomial form conversion table */
-gf Alpha_to[NN + 1];
-
-/* Polynomial->index form conversion table */
-gf Index_of[NN + 1];
-
-/* No legal value in index form represents zero, so
- * we need a special value for this purpose
- */
-#define A0  (NN)
-
-/* Generator polynomial g(x)
- * Degree of g(x) = 2*TT
- * has roots @**B0, @**(B0+1), ... ,@^(B0+2*TT-1)
- */
-/*gf Gg[NN - KK + 1];*/
-gf    Gg[NN - 1];
-
-/* Compute x % NN, where NN is 2**MM - 1,
- * without a slow divide
- */
-static /*inline*/ gf
-modnn(int x)
-{
-  while (x >= NN) {
-    x -= NN;
-    x = (x >> MM) + (x & NN);
-  }
-  return x;
-}
-
-/*#define  min(a,b)  ((a) < (b) ? (a) : (b))*/
-
-#define  CLEAR(a,n) {\
-  int ci;\
-  for(ci=(n)-1;ci >=0;ci--)\
-    (a)[ci] = 0;\
-  }
-
-#define  COPY(a,b,n) {\
-  int ci;\
-  for(ci=(n)-1;ci >=0;ci--)\
-    (a)[ci] = (b)[ci];\
-  }
-#define  COPYDOWN(a,b,n) {\
-  int ci;\
-  for(ci=(n)-1;ci >=0;ci--)\
-    (a)[ci] = (b)[ci];\
-  }
-
-void init_rs(int k)
-{
-  KK = k;
-  if (KK >= NN) {
-    printf("KK must be less than 2**MM - 1\n");
-    exit(1);
-  }
-
-  generate_gf();
-  gen_poly();
-}
-
-/* generate GF(2**m) from the irreducible polynomial p(X) in p[0]..p[m]
-   lookup tables:  index->polynomial form   alpha_to[] contains j=alpha**i;
-                   polynomial form -> index form  index_of[j=alpha**i] = i
-   alpha=2 is the primitive element of GF(2**m)
-   HARI's COMMENT: (4/13/94) alpha_to[] can be used as follows:
-        Let @ represent the primitive element commonly called "alpha" that
-   is the root of the primitive polynomial p(x). Then in GF(2^m), for any
-   0 <= i <= 2^m-2,
-        @^i = a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
-   where the binary vector (a(0),a(1),a(2),...,a(m-1)) is the representation
-   of the integer "alpha_to[i]" with a(0) being the LSB and a(m-1) the MSB. Thus for
-   example the polynomial representation of @^5 would be given by the binary
-   representation of the integer "alpha_to[5]".
-                   Similarily, index_of[] can be used as follows:
-        As above, let @ represent the primitive element of GF(2^m) that is
-   the root of the primitive polynomial p(x). In order to find the power
-   of @ (alpha) that has the polynomial representation
-        a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
-   we consider the integer "i" whose binary representation with a(0) being LSB
-   and a(m-1) MSB is (a(0),a(1),...,a(m-1)) and locate the entry
-   "index_of[i]". Now, @^index_of[i] is that element whose polynomial
-    representation is (a(0),a(1),a(2),...,a(m-1)).
-   NOTE:
-        The element alpha_to[2^m-1] = 0 always signifying that the
-   representation of "@^infinity" = 0 is (0,0,0,...,0).
-        Similarily, the element index_of[0] = A0 always signifying
-   that the power of alpha which has the polynomial representation
-   (0,0,...,0) is "infinity".
-
-*/
-
-void
-generate_gf(void)
-{
-  register int i, mask;
-
-  mask = 1;
-  Alpha_to[MM] = 0;
-  for (i = 0; i < MM; i++) {
-    Alpha_to[i] = mask;
-    Index_of[Alpha_to[i]] = i;
-    /* If Pp[i] == 1 then, term @^i occurs in poly-repr of @^MM */
-    if (Pp[i] != 0)
-      Alpha_to[MM] ^= mask;  /* Bit-wise EXOR operation */
-    mask <<= 1;  /* single left-shift */
-  }
-  Index_of[Alpha_to[MM]] = MM;
-  /*
-   * Have obtained poly-repr of @^MM. Poly-repr of @^(i+1) is given by
-   * poly-repr of @^i shifted left one-bit and accounting for any @^MM
-   * term that may occur when poly-repr of @^i is shifted.
-   */
-  mask >>= 1;
-  for (i = MM + 1; i < NN; i++) {
-    if (Alpha_to[i - 1] >= mask)
-      Alpha_to[i] = Alpha_to[MM] ^ ((Alpha_to[i - 1] ^ mask) << 1);
-    else
-      Alpha_to[i] = Alpha_to[i - 1] << 1;
-    Index_of[Alpha_to[i]] = i;
-  }
-  Index_of[0] = A0;
-  Alpha_to[NN] = 0;
-}
-
-
-/*
- * Obtain the generator polynomial of the TT-error correcting, length
- * NN=(2**MM -1) Reed Solomon code from the product of (X+@**(B0+i)), i = 0,
- * ... ,(2*TT-1)
- *
- * Examples:
- *
- * If B0 = 1, TT = 1. deg(g(x)) = 2*TT = 2.
- * g(x) = (x+@) (x+@**2)
- *
- * If B0 = 0, TT = 2. deg(g(x)) = 2*TT = 4.
- * g(x) = (x+1) (x+@) (x+@**2) (x+@**3)
- */
-void
-gen_poly(void)
-{
-  register int i, j;
-
-  Gg[0] = Alpha_to[B0];
-  Gg[1] = 1;    /* g(x) = (X+@**B0) initially */
-  for (i = 2; i <= NN - KK; i++) {
-    Gg[i] = 1;
-    /*
-     * Below multiply (Gg[0]+Gg[1]*x + ... +Gg[i]x^i) by
-     * (@**(B0+i-1) + x)
-     */
-    for (j = i - 1; j > 0; j--)
-      if (Gg[j] != 0)
-        Gg[j] = Gg[j - 1] ^ Alpha_to[modnn((Index_of[Gg[j]]) + B0 + i - 1)];
-      else
-        Gg[j] = Gg[j - 1];
-    /* Gg[0] can never be zero */
-    Gg[0] = Alpha_to[modnn((Index_of[Gg[0]]) + B0 + i - 1)];
-  }
-  /* convert Gg[] to index form for quicker encoding */
-  for (i = 0; i <= NN - KK; i++)
-    Gg[i] = Index_of[Gg[i]];
-}
-
-
-/*
- * take the string of symbols in data[i], i=0..(k-1) and encode
- * systematically to produce NN-KK parity symbols in bb[0]..bb[NN-KK-1] data[]
- * is input and bb[] is output in polynomial form. Encoding is done by using
- * a feedback shift register with appropriate connections specified by the
- * elements of Gg[], which was generated above. Codeword is   c(X) =
- * data(X)*X**(NN-KK)+ b(X)
- */
-int
-encode_rs(dtype *data, dtype *bb)
-{
-  register int i, j;
-  gf feedback;
-
-  CLEAR(bb,NN-KK);
-  for (i = KK - 1; i >= 0; i--) {
-#if (MM != 8)
-    if(data[i] > NN)
-      return -1;  /* Illegal symbol */
-#endif
-    feedback = Index_of[data[i] ^ bb[NN - KK - 1]];
-    if (feedback != A0) {  /* feedback term is non-zero */
-      for (j = NN - KK - 1; j > 0; j--)
-        if (Gg[j] != A0)
-          bb[j] = bb[j - 1] ^ Alpha_to[modnn(Gg[j] + feedback)];
-        else
-          bb[j] = bb[j - 1];
-      bb[0] = Alpha_to[modnn(Gg[0] + feedback)];
-    } else {  /* feedback term is zero. encoder becomes a
-         * single-byte shifter */
-      for (j = NN - KK - 1; j > 0; j--)
-        bb[j] = bb[j - 1];
-      bb[0] = 0;
-    }
-  }
-  return 0;
-}
-
-/*
- * Performs ERRORS+ERASURES decoding of RS codes. If decoding is successful,
- * writes the codeword into data[] itself. Otherwise data[] is unaltered.
- *
- * Return number of symbols corrected, or -1 if codeword is illegal
- * or uncorrectable.
- *
- * First "no_eras" erasures are declared by the calling program. Then, the
- * maximum # of errors correctable is t_after_eras = floor((NN-KK-no_eras)/2).
- * If the number of channel errors is not greater than "t_after_eras" the
- * transmitted codeword will be recovered. Details of algorithm can be found
- * in R. Blahut's "Theory ... of Error-Correcting Codes".
- */
-int
-eras_dec_rs(dtype *data, int *eras_pos, int no_eras)
-{
-  int deg_lambda, el, deg_omega;
-  int i, j, r;
-  gf u,q,tmp,num1,num2,den,discr_r;
-  gf recd[NN];
-  /* Err+Eras Locator poly and syndrome poly */
-  /*gf lambda[NN-KK + 1], s[NN-KK + 1];
-  gf b[NN-KK + 1], t[NN-KK + 1], omega[NN-KK + 1];
-  gf root[NN-KK], reg[NN-KK + 1], loc[NN-KK];*/
-  gf lambda[NN + 1], s[NN + 1];
-  gf b[NN + 1], t[NN + 1], omega[NN + 1];
-  gf root[NN], reg[NN + 1], loc[NN];
-  int syn_error, count;
-
-  /* data[] is in polynomial form, copy and convert to index form */
-  for (i = NN-1; i >= 0; i--){
-#if (MM != 8)
-    if(data[i] > NN)
-      return -1;  /* Illegal symbol */
-#endif
-    recd[i] = Index_of[data[i]];
-  }
-  /* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
-   * namely @**(B0+i), i = 0, ... ,(NN-KK-1)
-   */
-  syn_error = 0;
-  for (i = 1; i <= NN-KK; i++) {
-    tmp = 0;
-    for (j = 0; j < NN; j++)
-      if (recd[j] != A0)  /* recd[j] in index form */
-        tmp ^= Alpha_to[modnn(recd[j] + (B0+i-1)*j)];
-    syn_error |= tmp;  /* set flag if non-zero syndrome =>
-           * error */
-    /* store syndrome in index form  */
-    s[i] = Index_of[tmp];
-  }
-  if (!syn_error) {
-    /*
-     * if syndrome is zero, data[] is a codeword and there are no
-     * errors to correct. So return data[] unmodified
-     */
-    return 0;
-  }
-  CLEAR(&lambda[1],NN-KK);
-  lambda[0] = 1;
-  if (no_eras > 0) {
-    /* Init lambda to be the erasure locator polynomial */
-    lambda[1] = Alpha_to[eras_pos[0]];
-    for (i = 1; i < no_eras; i++) {
-      u = eras_pos[i];
-      for (j = i+1; j > 0; j--) {
-        tmp = Index_of[lambda[j - 1]];
-        if(tmp != A0)
-          lambda[j] ^= Alpha_to[modnn(u + tmp)];
-      }
-    }
-#ifdef ERASURE_DEBUG
-    /* find roots of the erasure location polynomial */
-    for(i=1;i<=no_eras;i++)
-      reg[i] = Index_of[lambda[i]];
-    count = 0;
-    for (i = 1; i <= NN; i++) {
-      q = 1;
-      for (j = 1; j <= no_eras; j++)
-        if (reg[j] != A0) {
-          reg[j] = modnn(reg[j] + j);
-          q ^= Alpha_to[reg[j]];
-        }
-      if (!q) {
-        /* store root and error location
-         * number indices
-         */
-        root[count] = i;
-        loc[count] = NN - i;
-        count++;
-      }
-    }
-    if (count != no_eras) {
-      printf("\n lambda(x) is WRONG\n");
-      return -1;
-    }
-#ifndef NO_PRINT
-    printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n");
-    for (i = 0; i < count; i++)
-      printf("%d ", loc[i]);
-    printf("\n");
-#endif
-#endif
-  }
-  for(i=0;i<NN-KK+1;i++)
-    b[i] = Index_of[lambda[i]];
-
-  /*
-   * Begin Berlekamp-Massey algorithm to determine error+erasure
-   * locator polynomial
-   */
-  r = no_eras;
-  el = no_eras;
-  while (++r <= NN-KK) {  /* r is the step number */
-    /* Compute discrepancy at the r-th step in poly-form */
-    discr_r = 0;
-    for (i = 0; i < r; i++){
-      if ((lambda[i] != 0) && (s[r - i] != A0)) {
-        discr_r ^= Alpha_to[modnn(Index_of[lambda[i]] + s[r - i])];
-      }
-    }
-    discr_r = Index_of[discr_r];  /* Index form */
-    if (discr_r == A0) {
-      /* 2 lines below: B(x) <-- x*B(x) */
-      COPYDOWN(&b[1],b,NN-KK);
-      b[0] = A0;
-    } else {
-      /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
-      t[0] = lambda[0];
-      for (i = 0 ; i < NN-KK; i++) {
-        if(b[i] != A0)
-          t[i+1] = lambda[i+1] ^ Alpha_to[modnn(discr_r + b[i])];
-        else
-          t[i+1] = lambda[i+1];
-      }
-      if (2 * el <= r + no_eras - 1) {
-        el = r + no_eras - el;
-        /*
-         * 2 lines below: B(x) <-- inv(discr_r) *
-         * lambda(x)
-         */
-        for (i = 0; i <= NN-KK; i++)
-          b[i] = (lambda[i] == 0) ? A0 : modnn(Index_of[lambda[i]] - discr_r + NN);
-      } else {
-        /* 2 lines below: B(x) <-- x*B(x) */
-        COPYDOWN(&b[1],b,NN-KK);
-        b[0] = A0;
-      }
-      COPY(lambda,t,NN-KK+1);
-    }
-  }
-
-  /* Convert lambda to index form and compute deg(lambda(x)) */
-  deg_lambda = 0;
-  for(i=0;i<NN-KK+1;i++){
-    lambda[i] = Index_of[lambda[i]];
-    if(lambda[i] != A0)
-      deg_lambda = i;
-  }
-  /*
-   * Find roots of the error+erasure locator polynomial. By Chien
-   * Search
-   */
-  COPY(&reg[1],&lambda[1],NN-KK);
-  count = 0;    /* Number of roots of lambda(x) */
-  for (i = 1; i <= NN; i++) {
-    q = 1;
-    for (j = deg_lambda; j > 0; j--)
-      if (reg[j] != A0) {
-        reg[j] = modnn(reg[j] + j);
-        q ^= Alpha_to[reg[j]];
-      }
-    if (!q) {
-      /* store root (index-form) and error location number */
-      root[count] = i;
-      loc[count] = NN - i;
-      count++;
-    }
-  }
-
-#ifdef DEBUG
-  printf("\n Final error positions:\t");
-  for (i = 0; i < count; i++)
-    printf("%d ", loc[i]);
-  printf("\n");
-#endif
-  if (deg_lambda != count) {
-    /*
-     * deg(lambda) unequal to number of roots => uncorrectable
-     * error detected
-     */
-    return -1;
-  }
-  /*
-   * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
-   * x**(NN-KK)). in index form. Also find deg(omega).
-   */
-  deg_omega = 0;
-  for (i = 0; i < NN-KK;i++){
-    tmp = 0;
-    j = (deg_lambda < i) ? deg_lambda : i;
-    for(;j >= 0; j--){
-      if ((s[i + 1 - j] != A0) && (lambda[j] != A0))
-        tmp ^= Alpha_to[modnn(s[i + 1 - j] + lambda[j])];
-    }
-    if(tmp != 0)
-      deg_omega = i;
-    omega[i] = Index_of[tmp];
-  }
-  omega[NN-KK] = A0;
-
-  /*
-   * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
-   * inv(X(l))**(B0-1) and den = lambda_pr(inv(X(l))) all in poly-form
-   */
-  for (j = count-1; j >=0; j--) {
-    num1 = 0;
-    for (i = deg_omega; i >= 0; i--) {
-      if (omega[i] != A0)
-        num1  ^= Alpha_to[modnn(omega[i] + i * root[j])];
-    }
-    num2 = Alpha_to[modnn(root[j] * (B0 - 1) + NN)];
-    den = 0;
-
-    /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
-    for (i = min(deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) {
-      if(lambda[i+1] != A0)
-        den ^= Alpha_to[modnn(lambda[i+1] + i * root[j])];
-    }
-    if (den == 0) {
-#ifdef DEBUG
-      printf("\n ERROR: denominator = 0\n");
-#endif
-      return -1;
-    }
-    /* Apply error to data */
-    if (num1 != 0) {
-      data[loc[j]] ^= Alpha_to[modnn(Index_of[num1] + Index_of[num2] + NN - Index_of[den])];
-    }
-  }
-  return count;
-}
-
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v2/jpwl/rs.h b/Utilities/gdcmopenjpeg-v2/jpwl/rs.h
deleted file mode 100644
index 7e9c5d2..0000000
--- a/Utilities/gdcmopenjpeg-v2/jpwl/rs.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
- * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_JPWL
-
-/**
- at file rs.h
- at brief Functions used to compute Reed-Solomon parity and check of byte arrays
-
-*/
-
-#ifndef __RS_HEADER__
-#define __RS_HEADER__
-
-/** Global definitions for Reed-Solomon encoder/decoder
- * Phil Karn KA9Q, September 1996
- *
- * The parameters MM and KK specify the Reed-Solomon code parameters.
- *
- * Set MM to be the size of each code symbol in bits. The Reed-Solomon
- * block size will then be NN = 2**M - 1 symbols. Supported values are
- * defined in rs.c.
- *
- * Set KK to be the number of data symbols in each block, which must be
- * less than the block size. The code will then be able to correct up
- * to NN-KK erasures or (NN-KK)/2 errors, or combinations thereof with
- * each error counting as two erasures.
- */
-#define MM  8    /* RS code over GF(2**MM) - change to suit */
-//static int  KK;
-int  KK;
-
-/* Original code */
-/*#define KK  239*/    /* KK = number of information symbols */
-
-#define  NN ((1 << MM) - 1)
-
-#if (MM <= 8)
-typedef unsigned char dtype;
-#else
-typedef unsigned int dtype;
-#endif
-
-/** Initialization function */
-void init_rs(int);
-
-/** These two functions *must* be called in this order (e.g.,
- * by init_rs()) before any encoding/decoding
- */
-void generate_gf(void);  /* Generate Galois Field */
-void gen_poly(void);  /* Generate generator polynomial */
-
-/** Reed-Solomon encoding
- * data[] is the input block, parity symbols are placed in bb[]
- * bb[] may lie past the end of the data, e.g., for (255,223):
- *  encode_rs(&data[0],&data[223]);
- */
-int encode_rs(dtype data[], dtype bb[]);
-
-/** Reed-Solomon erasures-and-errors decoding
- * The received block goes into data[], and a list of zero-origin
- * erasure positions, if any, goes in eras_pos[] with a count in no_eras.
- *
- * The decoder corrects the symbols in place, if possible and returns
- * the number of corrected symbols. If the codeword is illegal or
- * uncorrectible, the data array is unchanged and -1 is returned
- */
-int eras_dec_rs(dtype data[], int eras_pos[], int no_eras);
-
-/**
-Computes the minimum between two integers
- at param a first integer to compare
- at param b second integer to compare
- at return returns the minimum integer between a and b
-*/
-#ifndef min
-#define min(a,b)    (((a) < (b)) ? (a) : (b))
-#endif /* min */
-
-#endif /* __RS_HEADER__ */
-
-
-#endif /* USE_JPWL */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/libopenjpeg/CMakeLists.txt
deleted file mode 100644
index 8ae6b4a..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/CMakeLists.txt
+++ /dev/null
@@ -1,92 +0,0 @@
-include_regular_expression("^.*$")
-# Defines the source code for the library
-set(OPENJPEG_SRCS
-  tcd.c
-  bio.c
-  cio.c
-  dwt.c
-  event.c
-  image.c
-  j2k.c
-  j2k_lib.c
-  jp2.c
-  jpt.c
-  mct.c
-  mqc.c
-  openjpeg.c
-  pi.c
-  raw.c
-  t1.c
-  tgt.c
-  profile.c
-  invert.c
-  function_list.c
-  t2.c
-  bio.h
-  cio.h
-  dwt.h
-  event.h
-  image.h
-  j2k.h
-  j2k_lib.h
-  jp2.h
-  jpt.h
-  mct.h
-  mqc.h
-  openjpeg.h
-  pi.h
-  int.h
-  raw.h
-  t1.h
-  t2.h
-  tcd.h
-  tgt.h
-  profile.h
-  invert.h
-  function_list.h
-)
-
-# Pass proper definition to preprocessor to generate shared lib
-if(WIN32)
-  if(BUILD_SHARED_LIBS)
-    add_definitions(-DOPJ_EXPORTS)
-  else()
-    add_definitions(-DOPJ_STATIC)
-  endif()
-endif()
-
-if(ENABLE_PROFILING)
-    add_definitions(-D_PROFILE)
-endif()
-
-# Create the library
-add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
-if(UNIX)
-  target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
-endif()
-set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${GDCM_LIBRARY_PROPERTIES})
-if(BUILD_SHARED_LIBS)
-  set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES "" LINK_INTERFACE_LIBRARIES "")
-endif()
-
-
-# Install library
-if(NOT OPENJPEG_INSTALL_NO_LIBRARIES)
-  install(TARGETS ${OPENJPEG_LIBRARY_NAME}
-    EXPORT ${GDCM_TARGETS_NAME}
-    RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
-    LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
-    ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT DebugDevel
-    )
-endif()
-
-# Install includes files
-if(NOT OPENJPEG_INSTALL_NO_DEVELOPMENT)
-  file(GLOB header_files "*.h")
-  install(FILES ${header_files}
-    DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
-    )
-endif()
-#install(FILES openjpeg.h
-#	DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
-#)
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.c
deleted file mode 100644
index b0d5462..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "bio.h"
-#include "opj_malloc.h"
-
-/** @defgroup BIO BIO - Individual bit input-output stream */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Write a bit
- at param bio BIO handle
- at param b Bit to write (0 or 1)
-*/
-static void bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
-/**
-Read a bit
- at param bio BIO handle
- at return Returns the read bit
-*/
-static OPJ_UINT32 bio_getbit(opj_bio_t *bio);
-/**
-Write a byte
- at param bio BIO handle
- at return Returns 0 if successful, returns 1 otherwise
-*/
-static bool bio_byteout(opj_bio_t *bio);
-/**
-Read a byte
- at param bio BIO handle
- at return Returns 0 if successful, returns 1 otherwise
-*/
-static bool bio_bytein(opj_bio_t *bio);
-
-/*@}*/
-
-/*@}*/
-
-/*
-==========================================================
-   local functions
-==========================================================
-*/
-
-static bool bio_byteout(opj_bio_t *bio) {
-  bio->buf = (bio->buf << 8) & 0xffff;
-  bio->ct = bio->buf == 0xff00 ? 7 : 8;
-  if (bio->bp >= bio->end) {
-    return true;
-  }
-  *bio->bp++ = bio->buf >> 8;
-  return false;
-}
-
-static bool bio_bytein(opj_bio_t *bio) {
-  bio->buf = (bio->buf << 8) & 0xffff;
-  bio->ct = bio->buf == 0xff00 ? 7 : 8;
-  if (bio->bp >= bio->end) {
-    return true;
-  }
-  bio->buf |= *bio->bp++;
-  return false;
-}
-
-static void bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) {
-  if (bio->ct == 0) {
-    bio_byteout(bio);
-  }
-  bio->ct--;
-  bio->buf |= b << bio->ct;
-}
-
-static OPJ_UINT32 bio_getbit(opj_bio_t *bio) {
-  if (bio->ct == 0) {
-    bio_bytein(bio);
-  }
-  bio->ct--;
-  return (bio->buf >> bio->ct) & 1;
-}
-
-/*
-==========================================================
-   Bit Input/Output interface
-==========================================================
-*/
-
-opj_bio_t* bio_create(void) {
-  opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
-  return bio;
-}
-
-void bio_destroy(opj_bio_t *bio) {
-  if(bio) {
-    opj_free(bio);
-  }
-}
-
-OPJ_UINT32 bio_numbytes(opj_bio_t *bio) {
-  return (bio->bp - bio->start);
-}
-
-void bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
-  bio->start = bp;
-  bio->end = bp + len;
-  bio->bp = bp;
-  bio->buf = 0;
-  bio->ct = 8;
-}
-
-void bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
-  bio->start = bp;
-  bio->end = bp + len;
-  bio->bp = bp;
-  bio->buf = 0;
-  bio->ct = 0;
-}
-
-void bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
-  OPJ_UINT32 i;
-  for (i = n - 1; i != -1 ; --i) {
-    bio_putbit(bio, (v >> i) & 1);
-  }
-}
-
-OPJ_UINT32 bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
-  OPJ_UINT32 i, v;
-  v = 0;
-  for (i = n - 1; i != -1 ; --i) {
-    v += bio_getbit(bio) << i;
-  }
-  return v;
-}
-
-bool bio_flush(opj_bio_t *bio) {
-  bio->ct = 0;
-  if (bio_byteout(bio)) {
-    return true;
-  }
-  if (bio->ct == 7) {
-    bio->ct = 0;
-    if (bio_byteout(bio)) {
-      return true;
-    }
-  }
-  return false;
-}
-
-bool bio_inalign(opj_bio_t *bio) {
-  bio->ct = 0;
-  if ((bio->buf & 0xff) == 0xff) {
-    if (bio_bytein(bio)) {
-      return true;
-    }
-    bio->ct = 0;
-  }
-  return false;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.h
deleted file mode 100644
index ecb873f..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/bio.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __BIO_H
-#define __BIO_H
-/**
- at file bio.h
- at brief Implementation of an individual bit input-output (BIO)
-
-The functions in BIO.C have for goal to realize an individual bit input - output.
-*/
-#include "openjpeg.h"
-/** @defgroup BIO BIO - Individual bit input-output stream */
-/*@{*/
-
-/**
-Individual bit input-output stream (BIO)
-*/
-typedef struct opj_bio {
-  /** pointer to the start of the buffer */
-  OPJ_BYTE *start;
-  /** pointer to the end of the buffer */
-  OPJ_BYTE *end;
-  /** pointer to the present position in the buffer */
-  OPJ_BYTE *bp;
-  /** temporary place where each byte is read or written */
-  OPJ_UINT32 buf;
-  /** coder : number of bits free to write. decoder : number of bits read */
-  OPJ_UINT32 ct;
-} opj_bio_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new BIO handle
- at return Returns a new BIO handle if successful, returns NULL otherwise
-*/
-opj_bio_t* bio_create(void);
-/**
-Destroy a previously created BIO handle
- at param bio BIO handle to destroy
-*/
-void bio_destroy(opj_bio_t *bio);
-/**
-Number of bytes written.
- at param bio BIO handle
- at return Returns the number of bytes written
-*/
-OPJ_UINT32 bio_numbytes(opj_bio_t *bio);
-/**
-Init encoder
- at param bio BIO handle
- at param bp Output buffer
- at param len Output buffer length
-*/
-void bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
-/**
-Init decoder
- at param bio BIO handle
- at param bp Input buffer
- at param len Input buffer length
-*/
-void bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
-/**
-Write bits
- at param bio BIO handle
- at param v Value of bits
- at param n Number of bits to write
-*/
-void bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n);
-/**
-Read bits
- at param bio BIO handle
- at param n Number of bits to read
- at return Returns the corresponding read number
-*/
-OPJ_UINT32 bio_read(opj_bio_t *bio, OPJ_UINT32 n);
-/**
-Flush bits
- at param bio BIO handle
- at return Returns 1 if successful, returns 0 otherwise
-*/
-bool bio_flush(opj_bio_t *bio);
-/**
-Passes the ending bits (coming from flushing)
- at param bio BIO handle
- at return Returns 1 if successful, returns 0 otherwise
-*/
-bool bio_inalign(opj_bio_t *bio);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __BIO_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.c
deleted file mode 100644
index 1d59312..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.c
+++ /dev/null
@@ -1,825 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "cio.h"
-#include "opj_includes.h"
-#include "opj_malloc.h"
-#include "event.h"
-
-/* ----------------------------------------------------------------------- */
-
-
-/**
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- * @param p_nb_bytes  the number of bytes to write
-*/
-void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
-{
-  const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes;
-  assert(p_nb_bytes > 0 && p_nb_bytes <=  sizeof(OPJ_UINT32));
-  memcpy(p_buffer,l_data_ptr,p_nb_bytes);
-}
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- * @param p_nb_bytes  the number of bytes to write
- * @return        the number of bytes written or -1 if an error occured
-*/
-void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
-{
-  const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes - 1;
-  OPJ_UINT32 i;
-
-  assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
-  for
-    (i=0;i<p_nb_bytes;++i)
-  {
-    *(p_buffer++) = *(l_data_ptr--);
-  }
-}
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- * @param p_nb_bytes  the nb bytes to read.
- * @return        the number of bytes read or -1 if an error occured.
- */
-void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes)
-{
-  OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
-  assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
-  *p_value = 0;
-  memcpy(l_data_ptr+4-p_nb_bytes,p_buffer,p_nb_bytes);
-}
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- * @param p_nb_bytes  the nb bytes to read.
- * @return        the number of bytes read or -1 if an error occured.
- */
-void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes)
-{
-  OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + p_nb_bytes-1;
-  OPJ_UINT32 i;
-
-  assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
-  *p_value = 0;
-  for
-    (i=0;i<p_nb_bytes;++i)
-  {
-    *(l_data_ptr--) = *(p_buffer++);
-  }
-}
-
-/**
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- * @return        the number of bytes written or -1 if an error occured
- */
-void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
-{
-  const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
-  memcpy(p_buffer,l_data_ptr,sizeof(OPJ_FLOAT64));
-}
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- */
-void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
-{
-  const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(OPJ_FLOAT64) - 1;
-  OPJ_UINT32 i;
-  for
-    (i=0;i<sizeof(OPJ_FLOAT64);++i)
-  {
-    *(p_buffer++) = *(l_data_ptr--);
-  }
-}
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
-{
-  OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
-  memcpy(l_data_ptr,p_buffer,sizeof(OPJ_FLOAT64));
-}
-
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
-{
-  OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT64)-1;
-  OPJ_UINT32 i;
-  for
-    (i=0;i<sizeof(OPJ_FLOAT64);++i)
-  {
-    *(l_data_ptr--) = *(p_buffer++);
-  }
-}
-
-/**
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- * @return        the number of bytes written or -1 if an error occured
- */
-void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
-{
-  const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
-  memcpy(p_buffer,l_data_ptr,sizeof(OPJ_FLOAT32));
-}
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- */
-void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
-{
-  const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(OPJ_FLOAT32) - 1;
-  OPJ_UINT32 i;
-  for
-    (i=0;i<sizeof(OPJ_FLOAT32);++i)
-  {
-    *(p_buffer++) = *(l_data_ptr--);
-  }
-}
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
-{
-  OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
-  memcpy(l_data_ptr,p_buffer,sizeof(OPJ_FLOAT32));
-}
-
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
-{
-  OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT32)-1;
-  OPJ_UINT32 i;
-  for
-    (i=0;i<sizeof(OPJ_FLOAT32);++i)
-  {
-    *(l_data_ptr--) = *(p_buffer++);
-  }
-}
-
-
-/**
- * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
- * @return a stream object.
-*/
-opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_UINT32 p_size,bool l_is_input)
-{
-  opj_stream_private_t * l_stream = 00;
-  l_stream = (opj_stream_private_t*) opj_malloc(sizeof(opj_stream_private_t));
-  if
-    (! l_stream)
-  {
-    return 00;
-  }
-  memset(l_stream,0,sizeof(opj_stream_private_t));
-  l_stream->m_buffer_size = p_size;
-  l_stream->m_stored_data = (OPJ_BYTE *) opj_malloc(p_size);
-  if
-    (! l_stream->m_stored_data)
-  {
-    opj_free(l_stream);
-    return 00;
-  }
-  l_stream->m_current_data = l_stream->m_stored_data;
-  if
-    (l_is_input)
-  {
-    l_stream->m_status |= opj_stream_e_input;
-    l_stream->m_opj_skip = opj_stream_read_skip;
-    l_stream->m_opj_seek = opj_stream_read_seek;
-  }
-  else
-  {
-    l_stream->m_status |= opj_stream_e_output;
-    l_stream->m_opj_skip = opj_stream_write_skip;
-    l_stream->m_opj_seek = opj_stream_write_seek;
-  }
-  l_stream->m_read_fn = opj_stream_default_read;
-  l_stream->m_write_fn = opj_stream_default_write;
-  l_stream->m_skip_fn = opj_stream_default_skip;
-  l_stream->m_seek_fn = opj_stream_default_seek;
-
-  return (opj_stream_t *) l_stream;
-}
-
-/**
- * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
- * @return a stream object.
-*/
-opj_stream_t* OPJ_CALLCONV opj_stream_default_create(bool l_is_input)
-{
-  return opj_stream_create(J2K_STREAM_CHUNK_SIZE,l_is_input);
-}
-
-/**
- * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
- * close its own implementation of the stream.
- */
-OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream)
-{
-  opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-  if
-    (l_stream)
-  {
-    opj_free(l_stream->m_stored_data);
-    l_stream->m_stored_data = 00;
-    opj_free(l_stream);
-  }
-
-}
-
-/**
- * Sets the given function to be used as a read function.
- * @param    p_stream  the stream to modify
- * @param    p_function  the function to use a read function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function)
-{
-  opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-  if
-    ((!l_stream) || (! (l_stream->m_status & opj_stream_e_input)))
-  {
-    return;
-  }
-  l_stream->m_read_fn = p_function;
-}
-
-OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function)
-{
-  opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-  if
-    (!l_stream)
-  {
-    return;
-  }
-  l_stream->m_seek_fn = p_function;
-}
-
-/**
- * Sets the given function to be used as a write function.
- * @param    p_stream  the stream to modify
- * @param    p_function  the function to use a write function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function)
-{
-  opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-  if
-    ((!l_stream )|| (! (l_stream->m_status & opj_stream_e_output)))
-  {
-    return;
-  }
-  l_stream->m_write_fn = p_function;
-}
-
-/**
- * Sets the given function to be used as a skip function.
- * @param    p_stream  the stream to modify
- * @param    p_function  the function to use a skip function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function)
-{
-  opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-  if
-    (! l_stream)
-  {
-    return;
-  }
-  l_stream->m_skip_fn = p_function;
-}
-
-/**
- * Sets the given data to be used as a user data for the stream.
- * @param    p_stream  the stream to modify
- * @param    p_data    the data to set.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void * p_data)
-{
-  opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
-  l_stream->m_user_data = p_data;
-}
-
-/**
- * Reads some bytes from the stream.
- * @param    p_stream  the stream to read data from.
- * @param    p_buffer  pointer to the data buffer that will receive the data.
- * @param    p_size    number of bytes to read.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes read, or -1 if an error occured or if the stream is at the end.
- */
-OPJ_UINT32 opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_UINT32 p_size, opj_event_mgr_t * p_event_mgr)
-{
-  OPJ_UINT32 l_read_nb_bytes = 0;
-  if
-    (p_stream->m_bytes_in_buffer >= p_size)
-  {
-    memcpy(p_buffer,p_stream->m_current_data,p_size);
-    p_stream->m_current_data += p_size;
-    p_stream->m_bytes_in_buffer -= p_size;
-    l_read_nb_bytes += p_size;
-    p_stream->m_byte_offset += p_size;
-    return l_read_nb_bytes;
-  }
-
-  // we are now in the case when the remaining data if not sufficient
-  if
-    (p_stream->m_status & opj_stream_e_end)
-  {
-    l_read_nb_bytes += p_stream->m_bytes_in_buffer;
-    memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
-    p_stream->m_current_data += p_stream->m_bytes_in_buffer;
-    p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
-    p_stream->m_bytes_in_buffer = 0;
-    return l_read_nb_bytes ? l_read_nb_bytes : -1;
-  }
-
-  // the flag is not set, we copy data and then do an actual read on the stream
-  if
-    (p_stream->m_bytes_in_buffer)
-  {
-    l_read_nb_bytes += p_stream->m_bytes_in_buffer;
-    memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
-    p_stream->m_current_data = p_stream->m_stored_data;
-    p_buffer += p_stream->m_bytes_in_buffer;
-    p_size -= p_stream->m_bytes_in_buffer;
-    p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
-    p_stream->m_bytes_in_buffer = 0;
-  }
-  else
-  {
-    /* case where we are already at the end of the buffer
-       so reset the m_current_data to point to the start of the
-       stored buffer to get ready to read from disk*/
-    p_stream->m_current_data = p_stream->m_stored_data;
-  }
-
-
-  while
-    (true)
-  {
-    // we should read less than a chunk -> read a chunk
-    if
-      (p_size < p_stream->m_buffer_size)
-    {
-      // we should do an actual read on the media
-      p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_stream->m_stored_data,p_stream->m_buffer_size,p_stream->m_user_data);
-      if
-        (p_stream->m_bytes_in_buffer == -1)
-      {
-        // end of stream
-        opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
-        p_stream->m_bytes_in_buffer = 0;
-        p_stream->m_status |= opj_stream_e_end;
-        // end of stream
-        return l_read_nb_bytes ? l_read_nb_bytes : -1;
-      }
-      else if
-        (p_stream->m_bytes_in_buffer < p_size)
-      {
-        // not enough data
-        l_read_nb_bytes += p_stream->m_bytes_in_buffer;
-        memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
-        p_stream->m_current_data = p_stream->m_stored_data;
-        p_buffer += p_stream->m_bytes_in_buffer;
-        p_size -= p_stream->m_bytes_in_buffer;
-        p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
-        p_stream->m_bytes_in_buffer = 0;
-      }
-      else
-      {
-        l_read_nb_bytes += p_size;
-        memcpy(p_buffer,p_stream->m_current_data,p_size);
-        p_stream->m_current_data += p_size;
-        p_stream->m_bytes_in_buffer -= p_size;
-        p_stream->m_byte_offset += p_size;
-        return l_read_nb_bytes;
-      }
-    }
-    else
-    {
-      // direct read on the dest buffer
-      p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_buffer,p_size,p_stream->m_user_data);
-      if
-        (p_stream->m_bytes_in_buffer == -1)
-      {
-        // end of stream
-        opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
-        p_stream->m_bytes_in_buffer = 0;
-        p_stream->m_status |= opj_stream_e_end;
-        // end of stream
-        return l_read_nb_bytes ? l_read_nb_bytes : -1;
-      }
-      else if
-        (p_stream->m_bytes_in_buffer < p_size)
-      {
-        // not enough data
-        l_read_nb_bytes += p_stream->m_bytes_in_buffer;
-        p_stream->m_current_data = p_stream->m_stored_data;
-        p_buffer += p_stream->m_bytes_in_buffer;
-        p_size -= p_stream->m_bytes_in_buffer;
-        p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
-        p_stream->m_bytes_in_buffer = 0;
-      }
-      else
-      {
-        // we have read the exact size
-        l_read_nb_bytes += p_stream->m_bytes_in_buffer;
-        p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
-        p_stream->m_current_data = p_stream->m_stored_data;
-        p_stream->m_bytes_in_buffer = 0;
-        return l_read_nb_bytes;
-      }
-    }
-  }
-}
-
-/**
- * Writes some bytes from the stream.
- * @param    p_stream  the stream to write data to.
- * @param    p_buffer  pointer to the data buffer holds the data to be writtent.
- * @param    p_size    number of bytes to write.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes writtent, or -1 if an error occured.
- */
-OPJ_UINT32 opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer,OPJ_UINT32 p_size, opj_event_mgr_t * p_event_mgr)
-{
-  OPJ_UINT32 l_remaining_bytes = 0;
-  OPJ_UINT32 l_write_nb_bytes = 0;
-
-  if
-    (p_stream->m_status & opj_stream_e_error)
-  {
-    return -1;
-  }
-
-  while
-    (true)
-  {
-    l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_in_buffer;
-    // we have more memory than required
-    if
-      (l_remaining_bytes >= p_size)
-    {
-      memcpy(p_stream->m_current_data,p_buffer,p_size);
-      p_stream->m_current_data += p_size;
-      p_stream->m_bytes_in_buffer += p_size;
-      l_write_nb_bytes += p_size;
-      p_stream->m_byte_offset += p_size;
-      return l_write_nb_bytes;
-    }
-
-    // we copy data and then do an actual read on the stream
-    if
-      (l_remaining_bytes)
-    {
-      l_write_nb_bytes += l_remaining_bytes;
-      memcpy(p_stream->m_current_data,p_buffer,l_remaining_bytes);
-      p_stream->m_current_data = p_stream->m_stored_data;
-      p_buffer += l_remaining_bytes;
-      p_size -= l_remaining_bytes;
-      p_stream->m_bytes_in_buffer += l_remaining_bytes;
-      p_stream->m_byte_offset += l_remaining_bytes;
-    }
-    if
-      (! opj_stream_flush(p_stream, p_event_mgr))
-    {
-      return -1;
-    }
-  }
-
-}
-
-/**
- * Writes the content of the stream buffer to the stream.
- * @param    p_stream  the stream to write data to.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes written, or -1 if an error occured.
- */
-bool opj_stream_flush (opj_stream_private_t * p_stream, opj_event_mgr_t * p_event_mgr)
-{
-  // the number of bytes written on the media.
-  OPJ_UINT32 l_current_write_nb_bytes = 0;
-  p_stream->m_current_data = p_stream->m_stored_data;
-
-  while
-    (p_stream->m_bytes_in_buffer)
-  {
-    // we should do an actual write on the media
-    l_current_write_nb_bytes = p_stream->m_write_fn(p_stream->m_current_data,p_stream->m_bytes_in_buffer,p_stream->m_user_data);
-    if
-      (l_current_write_nb_bytes == -1)
-    {
-      p_stream->m_status |= opj_stream_e_error;
-      opj_event_msg(p_event_mgr, EVT_INFO, "Error on writting stream!\n");
-      return false;
-    }
-    p_stream->m_current_data += l_current_write_nb_bytes;
-    p_stream->m_bytes_in_buffer -= l_current_write_nb_bytes;
-  }
-  p_stream->m_current_data = p_stream->m_stored_data;
-  return true;
-}
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-OPJ_SIZE_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
-{
-  OPJ_SIZE_T l_skip_nb_bytes = 0;
-  OPJ_SIZE_T l_current_skip_nb_bytes = 0;
-
-  if
-    (p_stream->m_bytes_in_buffer >= p_size)
-  {
-    p_stream->m_current_data += p_size;
-    p_stream->m_bytes_in_buffer -= p_size;
-    l_skip_nb_bytes += p_size;
-    p_stream->m_byte_offset += l_skip_nb_bytes;
-    return l_skip_nb_bytes;
-  }
-
-  // we are now in the case when the remaining data if not sufficient
-  if
-    (p_stream->m_status & opj_stream_e_end)
-  {
-    l_skip_nb_bytes += p_stream->m_bytes_in_buffer;
-    p_stream->m_current_data += p_stream->m_bytes_in_buffer;
-    p_stream->m_bytes_in_buffer = 0;
-    p_stream->m_byte_offset += l_skip_nb_bytes;
-    return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_SIZE_T) -1;
-  }
-
-  // the flag is not set, we copy data and then do an actual skip on the stream
-  if
-    (p_stream->m_bytes_in_buffer)
-  {
-    l_skip_nb_bytes += p_stream->m_bytes_in_buffer;
-    p_stream->m_current_data = p_stream->m_stored_data;
-    p_size -= p_stream->m_bytes_in_buffer;
-    p_stream->m_bytes_in_buffer = 0;
-  }
-
-  while
-    (p_size > 0)
-  {
-    // we should do an actual skip on the media
-    l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
-    if
-      (l_current_skip_nb_bytes == (OPJ_SIZE_T) -1)
-    {
-      opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
-      p_stream->m_status |= opj_stream_e_end;
-      p_stream->m_byte_offset += l_skip_nb_bytes;
-      // end if stream
-      return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_SIZE_T) -1;
-    }
-    p_size -= l_current_skip_nb_bytes;
-    l_skip_nb_bytes += l_current_skip_nb_bytes;
-  }
-  p_stream->m_byte_offset += l_skip_nb_bytes;
-  return l_skip_nb_bytes;
-}
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-OPJ_SIZE_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
-{
-  bool l_is_written = 0;
-  OPJ_SIZE_T l_current_skip_nb_bytes = 0;
-  OPJ_SIZE_T l_skip_nb_bytes = 0;
-
-  if
-    (p_stream->m_status & opj_stream_e_error)
-  {
-    return (OPJ_SIZE_T) -1;
-  }
-
-  // we should flush data
-  l_is_written = opj_stream_flush (p_stream, p_event_mgr);
-  if
-    (! l_is_written)
-  {
-    p_stream->m_status |= opj_stream_e_error;
-    p_stream->m_bytes_in_buffer = 0;
-    p_stream->m_current_data = p_stream->m_current_data;
-    return (OPJ_SIZE_T) -1;
-  }
-  // then skip
-
-  while
-    (p_size > 0)
-  {
-    // we should do an actual skip on the media
-    l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
-    if
-      (l_current_skip_nb_bytes == (OPJ_SIZE_T)-1)
-    {
-      opj_event_msg(p_event_mgr, EVT_INFO, "Stream error!\n");
-      p_stream->m_status |= opj_stream_e_error;
-      p_stream->m_byte_offset += l_skip_nb_bytes;
-      // end if stream
-      return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_SIZE_T)-1;
-    }
-    p_size -= l_current_skip_nb_bytes;
-    l_skip_nb_bytes += l_current_skip_nb_bytes;
-  }
-  p_stream->m_byte_offset += l_skip_nb_bytes;
-  return l_skip_nb_bytes;
-}
-
-/**
- * Tells the byte offset on the stream (similar to ftell).
- *
- * @param    p_stream  the stream to get the information from.
- *
- * @return    the current position o fthe stream.
- */
-OPJ_SIZE_T opj_stream_tell (const opj_stream_private_t * p_stream)
-{
-  return p_stream->m_byte_offset;
-}
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-OPJ_SIZE_T opj_stream_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
-{
-  return p_stream->m_opj_skip(p_stream,p_size,p_event_mgr);
-}
-
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-bool opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
-{
-  p_stream->m_current_data = p_stream->m_stored_data;
-  p_stream->m_bytes_in_buffer = 0;
-  if
-    (! p_stream->m_seek_fn(p_size,p_stream->m_user_data))
-  {
-    p_stream->m_status |= opj_stream_e_end;
-    return false;
-  }
-  else
-  {
-    // reset stream status
-    p_stream->m_status &= (~opj_stream_e_end);
-    p_stream->m_byte_offset = p_size;
-
-  }
-  return true;
-}
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-bool opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
-{
-  if
-    (! opj_stream_flush(p_stream,p_event_mgr))
-  {
-    p_stream->m_status |= opj_stream_e_error;
-    return false;
-  }
-
-  p_stream->m_current_data = p_stream->m_stored_data;
-  p_stream->m_bytes_in_buffer = 0;
-
-  if
-    (! p_stream->m_seek_fn(p_size,p_stream->m_user_data))
-  {
-    p_stream->m_status |= opj_stream_e_error;
-    return false;
-  }
-  else
-  {
-    p_stream->m_byte_offset = p_size;
-  }
-  return true;
-}
-
-
-/**
- * Seeks a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    true if the stream is seekable.
- */
-bool opj_stream_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr)
-{
-  return p_stream->m_opj_seek(p_stream,p_size,p_event_mgr);
-}
-
-/**
- * Tells if the given stream is seekable.
- */
-bool opj_stream_has_seek (const opj_stream_private_t * p_stream)
-{
-  return p_stream->m_seek_fn != opj_stream_default_seek;
-}
-
-
-
-
-
-OPJ_UINT32 opj_stream_default_read (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data)
-{
-  return (OPJ_UINT32) -1;
-}
-OPJ_UINT32 opj_stream_default_write (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data)
-{
-  return (OPJ_UINT32) -1;
-}
-OPJ_SIZE_T opj_stream_default_skip (OPJ_SIZE_T p_nb_bytes, void * p_user_data)
-{
-  return (OPJ_SIZE_T) -1;
-}
-
-bool opj_stream_default_seek (OPJ_SIZE_T p_nb_bytes, void * p_user_data)
-{
-  return false;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.h
deleted file mode 100644
index 6c37857..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/cio.h
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __CIO_H
-#define __CIO_H
-/**
- at file cio.h
- at brief Implementation of a byte input-output process (CIO)
-
-The functions in CIO.C have for goal to realize a byte input / output process.
-*/
-
-/** @defgroup CIO CIO - byte input-output stream */
-/*@{*/
-
-#include "openjpeg.h"
-#include "opj_configure.h"
-struct opj_event_mgr;
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-#if defined(OPJ_BIG_ENDIAN)
-  #if !defined(OPJ_LITTLE_ENDIAN)
-      #define opj_write_bytes    opj_write_bytes_BE
-      #define opj_read_bytes    opj_read_bytes_BE
-      #define opj_write_double  opj_write_double_BE
-      #define opj_read_double    opj_read_double_BE
-      #define opj_write_float    opj_write_float_BE
-      #define opj_read_float    opj_read_float_BE
-  #else
-      #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
-  #endif
-#else
-  #if defined(OPJ_LITTLE_ENDIAN)
-      #define opj_write_bytes    opj_write_bytes_LE
-      #define opj_read_bytes    opj_read_bytes_LE
-      #define opj_write_double  opj_write_double_LE
-      #define opj_read_double    opj_read_double_LE
-      #define opj_write_float    opj_write_float_LE
-      #define opj_read_float    opj_read_float_LE
-  #else
-    #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not none."
-  #endif
-#endif
-
-
-
-typedef enum
-{
-  opj_stream_e_output    = 0x1,
-  opj_stream_e_input    = 0x2,
-  opj_stream_e_end    = 0x4,
-  opj_stream_e_error    = 0x8
-}
-opj_stream_flag ;
-
-/**
-Byte input-output stream.
-*/
-typedef struct opj_stream_private
-{
-  /**
-   * User data, be it files, ... The actual data depends on the type of the stream.
-   */
-  void *          m_user_data;
-
-  /**
-   * Pointer to actual read function (NULL at the initialization of the cio.
-   */
-  opj_stream_read_fn    m_read_fn;
-
-  /**
-   * Pointer to actual write function (NULL at the initialization of the cio.
-   */
-  opj_stream_write_fn    m_write_fn;
-
-  /**
-   * Pointer to actual skip function (NULL at the initialization of the cio.
-   * There is no seek function to prevent from back and forth slow procedures.
-   */
-  opj_stream_skip_fn    m_skip_fn;
-
-  /**
-   * Pointer to actual seek function (if available).
-   */
-  opj_stream_seek_fn    m_seek_fn;
-
-
-
-
-  /**
-   * Actual data stored into the stream if readed from. Data is read by chunk of fixed size.
-   * you should never access this data directly.
-   */
-  OPJ_BYTE *          m_stored_data;
-
-  /**
-   * Pointer to the current read data.
-   */
-  OPJ_BYTE *          m_current_data;
-
-  OPJ_SIZE_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_SIZE_T , struct opj_event_mgr *);
-
-  bool (* m_opj_seek) (struct opj_stream_private * , OPJ_SIZE_T , struct opj_event_mgr *);
-
-  /**
-   * number of bytes containing in the buffer.
-   */
-  OPJ_UINT32      m_bytes_in_buffer;
-
-  /**
-   * The number of bytes read/written.
-   */
-  OPJ_SIZE_T      m_byte_offset;
-
-  /**
-   * The size of the buffer.
-   */
-  OPJ_UINT32      m_buffer_size;
-
-  /**
-   * Flags to tell the status of the stream.
-   */
-  OPJ_UINT32      m_status;
-
-}
-opj_stream_private_t;
-
-
-/**
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- * @param p_nb_bytes  the number of bytes to write
-*/
-void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- * @param p_nb_bytes  the nb bytes to read.
- * @return        the number of bytes read or -1 if an error occured.
- */
-void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- * @param p_nb_bytes  the number of bytes to write
- * @return        the number of bytes written or -1 if an error occured
-*/
-void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- * @param p_nb_bytes  the nb bytes to read.
- * @return        the number of bytes read or -1 if an error occured.
- */
-void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
-
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- */
-void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
-
-/***
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- */
-void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
-
-/**
- * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to read data from.
- * @param p_value    pointer to the value that will store the data.
- */
-void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
-
-/**
- * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- */
-void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
-
-/***
- * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
- * @param p_buffer    pointer the data buffer to write data to.
- * @param p_value    the value to write
- */
-void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
-
-/**
- * Reads some bytes from the stream.
- * @param    p_stream  the stream to read data from.
- * @param    p_buffer  pointer to the data buffer that will receive the data.
- * @param    p_size    number of bytes to read.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes read, or -1 if an error occured or if the stream is at the end.
- */
-OPJ_UINT32 opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_UINT32 p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Writes some bytes to the stream.
- * @param    p_stream  the stream to write data to.
- * @param    p_buffer  pointer to the data buffer holds the data to be writtent.
- * @param    p_size    number of bytes to write.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes writtent, or -1 if an error occured.
- */
-OPJ_UINT32 opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_UINT32 p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Writes the content of the stream buffer to the stream.
- * @param    p_stream  the stream to write data to.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    true if the data could be flushed, false else.
- */
-bool opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-OPJ_SIZE_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Tells the byte offset on the stream (similar to ftell).
- *
- * @param    p_stream  the stream to get the information from.
- *
- * @return    the current position o fthe stream.
- */
-OPJ_SIZE_T opj_stream_tell (const opj_stream_private_t * p_stream);
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-OPJ_SIZE_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-OPJ_SIZE_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-bool opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Skips a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    the number of bytes skipped, or -1 if an error occured.
- */
-bool opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Seeks a number of bytes from the stream.
- * @param    p_stream  the stream to skip data from.
- * @param    p_size    the number of bytes to skip.
- * @param    p_event_mgr  the user event manager to be notified of special events.
- * @return    true if the stream is seekable.
- */
-bool opj_stream_seek (opj_stream_private_t * p_stream, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
-
-/**
- * Tells if the given stream is seekable.
- */
-bool opj_stream_has_seek (const opj_stream_private_t * p_stream);
-
-OPJ_UINT32 opj_stream_default_read (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data);
-OPJ_UINT32 opj_stream_default_write (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data);
-OPJ_SIZE_T opj_stream_default_skip (OPJ_SIZE_T p_nb_bytes, void * p_user_data);
-bool opj_stream_default_seek (OPJ_SIZE_T p_nb_bytes, void * p_user_data);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __CIO_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.c
deleted file mode 100644
index 86d28e6..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.c
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Jonathan Ballard <dzonatas at dzonux.net>
- * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef __SSE__
-#include <xmmintrin.h>
-#endif
-
-#include "dwt.h"
-#include "j2k.h"
-#include "tcd.h"
-#include "fix.h"
-#include "opj_malloc.h"
-#include "int.h"
-
-/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
-/*@{*/
-
-#define WS(i) v->mem[(i)*2]
-#define WD(i) v->mem[(1+(i)*2)]
-
-/** @name Local data structures */
-/*@{*/
-
-typedef struct dwt_local {
-  OPJ_INT32* mem;
-  OPJ_INT32 dn;
-  OPJ_INT32 sn;
-  OPJ_INT32 cas;
-} dwt_t;
-
-typedef union {
-  OPJ_FLOAT32  f[4];
-} v4;
-
-typedef struct v4dwt_local {
-  v4*  wavelet ;
-  OPJ_INT32    dn ;
-  OPJ_INT32    sn ;
-  OPJ_INT32    cas ;
-} v4dwt_t ;
-
-static const OPJ_FLOAT32 dwt_alpha =  1.586134342f; //  12994
-static const OPJ_FLOAT32 dwt_beta  =  0.052980118f; //    434
-static const OPJ_FLOAT32 dwt_gamma = -0.882911075f; //  -7233
-static const OPJ_FLOAT32 delta = -0.443506852f; //  -3633
-
-static const OPJ_FLOAT32 K      = 1.230174105f; //  10078
-/* FIXME: What is this constant? */
-static const OPJ_FLOAT32 c13318 = 1.625732422f;
-
-/*@}*/
-
-/**
-Virtual function type for wavelet transform in 1-D
-*/
-typedef void (*DWT1DFN)(dwt_t* v);
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Forward lazy transform (horizontal)
-*/
-static void dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
-/**
-Forward lazy transform (vertical)
-*/
-static void dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas);
-/**
-Inverse lazy transform (horizontal)
-*/
-static void dwt_interleave_h(dwt_t* h, OPJ_INT32 *a);
-/**
-Inverse lazy transform (vertical)
-*/
-static void dwt_interleave_v(dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x);
-/**
-Forward 5-3 wavelet transform in 1-D
-*/
-static void dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
-/**
-Inverse 5-3 wavelet transform in 1-D
-*/
-static void dwt_decode_1(dwt_t *v);
-/**
-Forward 9-7 wavelet transform in 1-D
-*/
-static void dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
-/**
-Explicit calculation of the Quantization Stepsizes
-*/
-static void dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize);
-/**
-Inverse wavelet transform in 2-D.
-*/
-static bool dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i, DWT1DFN fn);
-
-static OPJ_UINT32 dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i);
-
-static bool dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) );
-/*@}*/
-
-/*@}*/
-
-#define S(i) a[(i)*2]
-#define D(i) a[(1+(i)*2)]
-#define S_(i) ((i)<0?S(0):((i)>=sn?S(sn-1):S(i)))
-#define D_(i) ((i)<0?D(0):((i)>=dn?D(dn-1):D(i)))
-/* new */
-#define SS_(i) ((i)<0?S(0):((i)>=dn?S(dn-1):S(i)))
-#define DD_(i) ((i)<0?D(0):((i)>=sn?D(sn-1):D(i)))
-
-/* <summary>                                                              */
-/* This table contains the norms of the 5-3 wavelets for different bands. */
-/* </summary>                                                             */
-static const OPJ_FLOAT64 dwt_norms[4][10] = {
-  {1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
-  {1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-  {1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
-  {.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
-};
-
-/* <summary>                                                              */
-/* This table contains the norms of the 9-7 wavelets for different bands. */
-/* </summary>                                                             */
-static const OPJ_FLOAT64 dwt_norms_real[4][10] = {
-  {1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
-  {2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
-  {2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
-  {2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
-};
-
-/*
-==========================================================
-   local functions
-==========================================================
-*/
-
-/* <summary>                       */
-/* Forward lazy transform (horizontal).  */
-/* </summary>                            */
-static void dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
-  OPJ_INT32 i;
-
-  OPJ_INT32 * l_dest = b;
-  OPJ_INT32 * l_src = a+cas;
-    for
-    (i=0; i<sn; ++i)
-  {
-    *l_dest++ = *l_src;
-    l_src += 2;
-  }
-  l_dest = b + sn;
-  l_src = a + 1 - cas;
-    for
-    (i=0; i<dn; ++i)
-  {
-    *l_dest++=*l_src;
-    l_src += 2;
-  }
-}
-
-/* <summary>                             */
-/* Forward lazy transform (vertical).    */
-/* </summary>                            */
-static void dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas) {
-    OPJ_INT32 i = sn;
-  OPJ_INT32 * l_dest = b;
-  OPJ_INT32 * l_src = a+cas;
-
-    while
-    (i--)
-  {
-    *l_dest = *l_src;
-    l_dest += x;
-    l_src += 2;
-    /* b[i*x]=a[2*i+cas]; */
-  }
-  l_dest = b + sn * x;
-  l_src = a + 1 - cas;
-
-  i = dn;
-    while
-    (i--)
-  {
-    *l_dest = *l_src;
-    l_dest += x;
-    l_src += 2;
-    /*b[(sn+i)*x]=a[(2*i+1-cas)];*/
-  }
-}
-
-/* <summary>                             */
-/* Inverse lazy transform (horizontal).  */
-/* </summary>                            */
-static void dwt_interleave_h(dwt_t* h, OPJ_INT32 *a) {
-    OPJ_INT32 *ai = a;
-    OPJ_INT32 *bi = h->mem + h->cas;
-    OPJ_INT32  i  = h->sn;
-    while
-    ( i-- )
-  {
-    *bi = *(ai++);
-    bi += 2;
-    }
-    ai  = a + h->sn;
-    bi  = h->mem + 1 - h->cas;
-    i  = h->dn ;
-    while
-    ( i-- )
-  {
-    *bi = *(ai++);
-    bi += 2;
-    }
-}
-
-/* <summary>                             */
-/* Inverse lazy transform (vertical).    */
-/* </summary>                            */
-static void dwt_interleave_v(dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x) {
-    OPJ_INT32 *ai = a;
-    OPJ_INT32 *bi = v->mem + v->cas;
-    OPJ_INT32  i = v->sn;
-    while( i-- ) {
-      *bi = *ai;
-    bi += 2;
-    ai += x;
-    }
-    ai = a + (v->sn * x);
-    bi = v->mem + 1 - v->cas;
-    i = v->dn ;
-    while( i-- ) {
-      *bi = *ai;
-    bi += 2;
-    ai += x;
-    }
-}
-
-
-/* <summary>                            */
-/* Forward 5-3 wavelet transform in 1-D. */
-/* </summary>                           */
-static void dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
-  OPJ_INT32 i;
-
-  if (!cas) {
-    if ((dn > 0) || (sn > 1)) {  /* NEW :  CASE ONE ELEMENT */
-      for (i = 0; i < dn; i++) D(i) -= (S_(i) + S_(i + 1)) >> 1;
-      for (i = 0; i < sn; i++) S(i) += (D_(i - 1) + D_(i) + 2) >> 2;
-    }
-  } else {
-    if (!sn && dn == 1)        /* NEW :  CASE ONE ELEMENT */
-      S(0) *= 2;
-    else {
-      for (i = 0; i < dn; i++) S(i) -= (DD_(i) + DD_(i - 1)) >> 1;
-      for (i = 0; i < sn; i++) D(i) += (SS_(i) + SS_(i + 1) + 2) >> 2;
-    }
-  }
-}
-
-/* <summary>                            */
-/* Inverse 5-3 wavelet transform in 1-D. */
-/* </summary>                           */
-static void dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
-  OPJ_INT32 i;
-
-  if (!cas) {
-    if ((dn > 0) || (sn > 1)) { /* NEW :  CASE ONE ELEMENT */
-      for (i = 0; i < sn; i++) S(i) -= (D_(i - 1) + D_(i) + 2) >> 2;
-      for (i = 0; i < dn; i++) D(i) += (S_(i) + S_(i + 1)) >> 1;
-    }
-  } else {
-    if (!sn  && dn == 1)          /* NEW :  CASE ONE ELEMENT */
-      S(0) /= 2;
-    else {
-      for (i = 0; i < sn; i++) D(i) -= (SS_(i) + SS_(i + 1) + 2) >> 2;
-      for (i = 0; i < dn; i++) S(i) += (DD_(i) + DD_(i - 1)) >> 1;
-    }
-  }
-}
-
-/* <summary>                            */
-/* Inverse 5-3 wavelet transform in 1-D. */
-/* </summary>                           */
-static void dwt_decode_1(dwt_t *v) {
-  dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
-}
-
-/* <summary>                             */
-/* Forward 9-7 wavelet transform in 1-D. */
-/* </summary>                            */
-static void dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
-  OPJ_INT32 i;
-  if (!cas) {
-    if ((dn > 0) || (sn > 1)) {  /* NEW :  CASE ONE ELEMENT */
-      for (i = 0; i < dn; i++)
-        D(i) -= fix_mul(S_(i) + S_(i + 1), 12993);
-      for (i = 0; i < sn; i++)
-        S(i) -= fix_mul(D_(i - 1) + D_(i), 434);
-      for (i = 0; i < dn; i++)
-        D(i) += fix_mul(S_(i) + S_(i + 1), 7233);
-      for (i = 0; i < sn; i++)
-        S(i) += fix_mul(D_(i - 1) + D_(i), 3633);
-      for (i = 0; i < dn; i++)
-        D(i) = fix_mul(D(i), 5038);  /*5038 */
-      for (i = 0; i < sn; i++)
-        S(i) = fix_mul(S(i), 6659);  /*6660 */
-    }
-  } else {
-    if ((sn > 0) || (dn > 1)) {  /* NEW :  CASE ONE ELEMENT */
-      for (i = 0; i < dn; i++)
-        S(i) -= fix_mul(DD_(i) + DD_(i - 1), 12993);
-      for (i = 0; i < sn; i++)
-        D(i) -= fix_mul(SS_(i) + SS_(i + 1), 434);
-      for (i = 0; i < dn; i++)
-        S(i) += fix_mul(DD_(i) + DD_(i - 1), 7233);
-      for (i = 0; i < sn; i++)
-        D(i) += fix_mul(SS_(i) + SS_(i + 1), 3633);
-      for (i = 0; i < dn; i++)
-        S(i) = fix_mul(S(i), 5038);  /*5038 */
-      for (i = 0; i < sn; i++)
-        D(i) = fix_mul(D(i), 6659);  /*6660 */
-    }
-  }
-}
-
-static void dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize) {
-  OPJ_INT32 p, n;
-  p = int_floorlog2(stepsize) - 13;
-  n = 11 - int_floorlog2(stepsize);
-  bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
-  bandno_stepsize->expn = numbps - p;
-}
-
-/*
-==========================================================
-   DWT interface
-==========================================================
-*/
-
-/* <summary>                            */
-/* Forward 5-3 wavelet transform in 2-D. */
-/* </summary>                           */
-INLINE bool dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) )
-{
-  OPJ_INT32 i, j, k;
-  OPJ_INT32 *a = 00;
-  OPJ_INT32 *aj = 00;
-  OPJ_INT32 *bj = 00;
-  OPJ_INT32 w, l;
-
-  OPJ_INT32 rw;      /* width of the resolution level computed   */
-  OPJ_INT32 rh;      /* height of the resolution level computed  */
-  OPJ_INT32 l_data_size;
-
-  opj_tcd_resolution_t * l_cur_res = 0;
-  opj_tcd_resolution_t * l_last_res = 0;
-
-  w = tilec->x1-tilec->x0;
-  l = tilec->numresolutions-1;
-  a = tilec->data;
-
-  l_cur_res = tilec->resolutions + l;
-  l_last_res = l_cur_res - 1;
-
-  rw = l_cur_res->x1 - l_cur_res->x0;
-  rh = l_cur_res->y1 - l_cur_res->y0;
-
-  l_data_size = dwt_max_resolution( tilec->resolutions,tilec->numresolutions) * sizeof(OPJ_INT32);
-  bj = (OPJ_INT32*)opj_malloc(l_data_size);
-  if
-    (! bj)
-  {
-    return false;
-  }
-  i = l;
-
-  while
-    (i--)
-  {
-    OPJ_INT32 rw1;    /* width of the resolution level once lower than computed one                                       */
-    OPJ_INT32 rh1;    /* height of the resolution level once lower than computed one                                      */
-    OPJ_INT32 cas_col;  /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
-    OPJ_INT32 cas_row;  /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
-    OPJ_INT32 dn, sn;
-
-    rw  = l_cur_res->x1 - l_cur_res->x0;
-    rh  = l_cur_res->y1 - l_cur_res->y0;
-    rw1 = l_last_res->x1 - l_last_res->x0;
-    rh1 = l_last_res->y1 - l_last_res->y0;
-
-    cas_row = l_cur_res->x0 & 1;
-    cas_col = l_cur_res->y0 & 1;
-
-    sn = rh1;
-    dn = rh - rh1;
-    for
-      (j = 0; j < rw; ++j)
-    {
-      aj = a + j;
-      for
-        (k = 0; k < rh; ++k)
-      {
-        bj[k] = aj[k*w];
-      }
-      (*p_function) (bj, dn, sn, cas_col);
-      dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
-    }
-    sn = rw1;
-    dn = rw - rw1;
-    for (j = 0; j < rh; j++)
-    {
-      aj = a + j * w;
-      for (k = 0; k < rw; k++)  bj[k] = aj[k];
-      (*p_function) (bj, dn, sn, cas_row);
-      dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
-    }
-    l_cur_res = l_last_res;
-    --l_last_res;
-  }
-  opj_free(bj);
-  return true;
-}
-/* Forward 5-3 wavelet transform in 2-D. */
-/* </summary>                           */
-bool dwt_encode(opj_tcd_tilecomp_t * tilec)
-{
-  return dwt_encode_procedure(tilec,dwt_encode_1);
-}
-
-/* <summary>                            */
-/* Inverse 5-3 wavelet transform in 2-D. */
-/* </summary>                           */
-bool dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
-  return dwt_decode_tile(tilec, numres, &dwt_decode_1);
-}
-
-
-/* <summary>                          */
-/* Get gain of 5-3 wavelet transform. */
-/* </summary>                         */
-OPJ_UINT32 dwt_getgain(OPJ_UINT32 orient) {
-  if (orient == 0)
-    return 0;
-  if (orient == 1 || orient == 2)
-    return 1;
-  return 2;
-}
-
-/* <summary>                */
-/* Get norm of 5-3 wavelet. */
-/* </summary>               */
-OPJ_FLOAT64 dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient) {
-  return dwt_norms[orient][level];
-}
-
-/* <summary>                             */
-/* Forward 9-7 wavelet transform in 2-D. */
-/* </summary>                            */
-bool dwt_encode_real(opj_tcd_tilecomp_t * tilec)
-{
-  return dwt_encode_procedure(tilec,dwt_encode_1_real);
-}
-
-
-
-/* <summary>                          */
-/* Get gain of 9-7 wavelet transform. */
-/* </summary>                         */
-OPJ_UINT32 dwt_getgain_real(OPJ_UINT32 orient) {
-  (void)orient;
-  return 0;
-}
-
-/* <summary>                */
-/* Get norm of 9-7 wavelet. */
-/* </summary>               */
-OPJ_FLOAT64 dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient) {
-  return dwt_norms_real[orient][level];
-}
-
-void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec) {
-  OPJ_UINT32 numbands, bandno;
-  numbands = 3 * tccp->numresolutions - 2;
-  for (bandno = 0; bandno < numbands; bandno++) {
-    OPJ_FLOAT64 stepsize;
-    OPJ_UINT32 resno, level, orient, gain;
-
-    resno = (bandno == 0) ? 0 : ((bandno - 1) / 3 + 1);
-    orient = (bandno == 0) ? 0 : ((bandno - 1) % 3 + 1);
-    level = tccp->numresolutions - 1 - resno;
-    gain = (tccp->qmfbid == 0) ? 0 : ((orient == 0) ? 0 : (((orient == 1) || (orient == 2)) ? 1 : 2));
-    if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
-      stepsize = 1.0;
-    } else {
-      OPJ_FLOAT64 norm = dwt_norms_real[orient][level];
-      stepsize = (1 << (gain)) / norm;
-    }
-    dwt_encode_stepsize((OPJ_INT32) floor(stepsize * 8192.0), prec + gain, &tccp->stepsizes[bandno]);
-  }
-}
-
-
-/* <summary>                             */
-/* Determine maximum computed resolution level for inverse wavelet transform */
-/* </summary>                            */
-static OPJ_UINT32 dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i) {
-  OPJ_UINT32 mr  = 0;
-  OPJ_UINT32 w;
-  while( --i ) {
-    ++r;
-    if( mr < ( w = r->x1 - r->x0 ) )
-      mr = w ;
-    if( mr < ( w = r->y1 - r->y0 ) )
-      mr = w ;
-  }
-  return mr ;
-}
-
-
-/* <summary>                            */
-/* Inverse wavelet transform in 2-D.     */
-/* </summary>                           */
-static bool dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D) {
-  dwt_t h;
-  dwt_t v;
-
-  opj_tcd_resolution_t* tr = tilec->resolutions;
-
-  OPJ_UINT32 rw = tr->x1 - tr->x0;  /* width of the resolution level computed */
-  OPJ_UINT32 rh = tr->y1 - tr->y0;  /* height of the resolution level computed */
-
-  OPJ_UINT32 w = tilec->x1 - tilec->x0;
-
-  h.mem = (OPJ_INT32*)
-  opj_aligned_malloc(dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32));
-  if
-    (! h.mem)
-  {
-    return false;
-  }
-
-  v.mem = h.mem;
-
-  while( --numres) {
-    OPJ_INT32 * restrict tiledp = tilec->data;
-    OPJ_UINT32 j;
-
-    ++tr;
-    h.sn = rw;
-    v.sn = rh;
-
-    rw = tr->x1 - tr->x0;
-    rh = tr->y1 - tr->y0;
-
-    h.dn = rw - h.sn;
-    h.cas = tr->x0 % 2;
-
-    for(j = 0; j < rh; ++j) {
-      dwt_interleave_h(&h, &tiledp[j*w]);
-      (dwt_1D)(&h);
-      memcpy(&tiledp[j*w], h.mem, rw * sizeof(OPJ_INT32));
-    }
-
-    v.dn = rh - v.sn;
-    v.cas = tr->y0 % 2;
-
-    for(j = 0; j < rw; ++j){
-      OPJ_UINT32 k;
-      dwt_interleave_v(&v, &tiledp[j], w);
-      (dwt_1D)(&v);
-      for(k = 0; k < rh; ++k) {
-        tiledp[k * w + j] = v.mem[k];
-      }
-    }
-  }
-  opj_aligned_free(h.mem);
-  return true;
-}
-
-static void v4dwt_interleave_h(v4dwt_t* restrict w, OPJ_FLOAT32* restrict a, OPJ_INT32 x, OPJ_INT32 size){
-  OPJ_FLOAT32* restrict bi = (OPJ_FLOAT32*) (w->wavelet + w->cas);
-  OPJ_INT32 count = w->sn;
-  OPJ_INT32 i, k;
-  for(k = 0; k < 2; ++k){
-    for(i = 0; i < count; ++i){
-      OPJ_INT32 j = i;
-      bi[i*8    ] = a[j];
-      j += x;
-      if(j >= size) continue;
-      bi[i*8 + 1] = a[j];
-      j += x;
-      if(j >= size) continue;
-      bi[i*8 + 2] = a[j];
-      j += x;
-      if(j >= size) continue;
-      bi[i*8 + 3] = a[j];
-    }
-    bi = (OPJ_FLOAT32*) (w->wavelet + 1 - w->cas);
-    a += w->sn;
-    size -= w->sn;
-    count = w->dn;
-  }
-}
-
-static void v4dwt_interleave_v(v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x){
-  v4* restrict bi = v->wavelet + v->cas;
-  OPJ_INT32 i;
-  for(i = 0; i < v->sn; ++i){
-    memcpy(&bi[i*2], &a[i*x], 4 * sizeof(OPJ_FLOAT32));
-  }
-  a += v->sn * x;
-  bi = v->wavelet + 1 - v->cas;
-  for(i = 0; i < v->dn; ++i){
-    memcpy(&bi[i*2], &a[i*x], 4 * sizeof(OPJ_FLOAT32));
-  }
-}
-
-#ifdef __SSE__
-
-static void v4dwt_decode_step1_sse(v4* w, OPJ_INT32 count, const __m128 c){
-  __m128* restrict vw = (__m128*) w;
-  OPJ_INT32 i;
-  for(i = 0; i < count; ++i){
-    __m128 tmp = vw[i*2];
-    vw[i*2] = tmp * c;
-  }
-}
-
-static void v4dwt_decode_step2_sse(v4* l, v4* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c){
-  __m128* restrict vl = (__m128*) l;
-  __m128* restrict vw = (__m128*) w;
-  OPJ_INT32 i;
-  for(i = 0; i < m; ++i){
-    __m128 tmp1 = vl[ 0];
-    __m128 tmp2 = vw[-1];
-    __m128 tmp3 = vw[ 0];
-    vw[-1] = tmp2 + ((tmp1 + tmp3) * c);
-    vl = vw;
-    vw += 2;
-  }
-  if(m >= k){
-    return;
-  }
-  c += c;
-  c *= vl[0];
-  for(; m < k; ++m){
-    __m128 tmp = vw[-1];
-    vw[-1] = tmp + c;
-    vw += 2;
-  }
-}
-
-#else
-
-static void v4dwt_decode_step1(v4* w, OPJ_INT32 count, const OPJ_FLOAT32 c){
-  OPJ_FLOAT32* restrict fw = (OPJ_FLOAT32*) w;
-  OPJ_INT32 i;
-  for(i = 0; i < count; ++i){
-    OPJ_FLOAT32 tmp1 = fw[i*8    ];
-    OPJ_FLOAT32 tmp2 = fw[i*8 + 1];
-    OPJ_FLOAT32 tmp3 = fw[i*8 + 2];
-    OPJ_FLOAT32 tmp4 = fw[i*8 + 3];
-    fw[i*8    ] = tmp1 * c;
-    fw[i*8 + 1] = tmp2 * c;
-    fw[i*8 + 2] = tmp3 * c;
-    fw[i*8 + 3] = tmp4 * c;
-  }
-}
-
-static void v4dwt_decode_step2(v4* l, v4* w, OPJ_INT32 k, OPJ_INT32 m, OPJ_FLOAT32 c){
-  OPJ_FLOAT32* restrict fl = (OPJ_FLOAT32*) l;
-  OPJ_FLOAT32* restrict fw = (OPJ_FLOAT32*) w;
-  OPJ_INT32 i;
-  for(i = 0; i < m; ++i){
-    OPJ_FLOAT32 tmp1_1 = fl[0];
-    OPJ_FLOAT32 tmp1_2 = fl[1];
-    OPJ_FLOAT32 tmp1_3 = fl[2];
-    OPJ_FLOAT32 tmp1_4 = fl[3];
-    OPJ_FLOAT32 tmp2_1 = fw[-4];
-    OPJ_FLOAT32 tmp2_2 = fw[-3];
-    OPJ_FLOAT32 tmp2_3 = fw[-2];
-    OPJ_FLOAT32 tmp2_4 = fw[-1];
-    OPJ_FLOAT32 tmp3_1 = fw[0];
-    OPJ_FLOAT32 tmp3_2 = fw[1];
-    OPJ_FLOAT32 tmp3_3 = fw[2];
-    OPJ_FLOAT32 tmp3_4 = fw[3];
-    fw[-4] = tmp2_1 + ((tmp1_1 + tmp3_1) * c);
-    fw[-3] = tmp2_2 + ((tmp1_2 + tmp3_2) * c);
-    fw[-2] = tmp2_3 + ((tmp1_3 + tmp3_3) * c);
-    fw[-1] = tmp2_4 + ((tmp1_4 + tmp3_4) * c);
-    fl = fw;
-    fw += 8;
-  }
-  if(m < k){
-    OPJ_FLOAT32 c1;
-    OPJ_FLOAT32 c2;
-    OPJ_FLOAT32 c3;
-    OPJ_FLOAT32 c4;
-    c += c;
-    c1 = fl[0] * c;
-    c2 = fl[1] * c;
-    c3 = fl[2] * c;
-    c4 = fl[3] * c;
-    for(; m < k; ++m){
-      OPJ_FLOAT32 tmp1 = fw[-4];
-      OPJ_FLOAT32 tmp2 = fw[-3];
-      OPJ_FLOAT32 tmp3 = fw[-2];
-      OPJ_FLOAT32 tmp4 = fw[-1];
-      fw[-4] = tmp1 + c1;
-      fw[-3] = tmp2 + c2;
-      fw[-2] = tmp3 + c3;
-      fw[-1] = tmp4 + c4;
-      fw += 8;
-    }
-  }
-}
-
-#endif
-
-/* <summary>                             */
-/* Inverse 9-7 wavelet transform in 1-D. */
-/* </summary>                            */
-static void v4dwt_decode(v4dwt_t* restrict dwt){
-  OPJ_INT32 a, b;
-  if(dwt->cas == 0) {
-    if(!((dwt->dn > 0) || (dwt->sn > 1))){
-      return;
-    }
-    a = 0;
-    b = 1;
-  }else{
-    if(!((dwt->sn > 0) || (dwt->dn > 1))) {
-      return;
-    }
-    a = 1;
-    b = 0;
-  }
-#ifdef __SSE__
-  v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(K));
-  v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(c13318));
-  v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(delta));
-  v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_gamma));
-  v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_beta));
-  v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_alpha));
-#else
-  v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, K);
-  v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, c13318);
-  v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), delta);
-  v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_gamma);
-  v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_beta);
-  v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_alpha);
-#endif
-}
-
-/* <summary>                             */
-/* Inverse 9-7 wavelet transform in 2-D. */
-/* </summary>                            */
-bool dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numres){
-  v4dwt_t h;
-  v4dwt_t v;
-
-  opj_tcd_resolution_t* res = tilec->resolutions;
-
-  OPJ_UINT32 rw = res->x1 - res->x0;  /* width of the resolution level computed */
-  OPJ_UINT32 rh = res->y1 - res->y0;  /* height of the resolution level computed */
-
-  OPJ_UINT32 w = tilec->x1 - tilec->x0;
-
-  h.wavelet = (v4*) opj_aligned_malloc((dwt_max_resolution(res, numres)+5) * sizeof(v4));
-  v.wavelet = h.wavelet;
-
-  while( --numres) {
-    OPJ_FLOAT32 * restrict aj = (OPJ_FLOAT32*) tilec->data;
-    OPJ_UINT32 bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0);
-    OPJ_INT32 j;
-
-    h.sn = rw;
-    v.sn = rh;
-
-    ++res;
-
-    rw = res->x1 - res->x0;  /* width of the resolution level computed */
-    rh = res->y1 - res->y0;  /* height of the resolution level computed */
-
-    h.dn = rw - h.sn;
-    h.cas = res->x0 & 1;
-
-    for(j = rh; j > 0; j -= 4){
-      v4dwt_interleave_h(&h, aj, w, bufsize);
-      v4dwt_decode(&h);
-      if(j >= 4){
-        OPJ_INT32 k = rw;
-        while
-          (--k >= 0)
-        {
-          aj[k    ] = h.wavelet[k].f[0];
-          aj[k+w  ] = h.wavelet[k].f[1];
-          aj[k+w*2] = h.wavelet[k].f[2];
-          aj[k+w*3] = h.wavelet[k].f[3];
-        }
-      }else{
-        OPJ_INT32 k = rw;
-        while
-          (--k >= 0)
-        {
-          switch(j) {
-            case 3: aj[k+w*2] = h.wavelet[k].f[2];
-            case 2: aj[k+w  ] = h.wavelet[k].f[1];
-            case 1: aj[k    ] = h.wavelet[k].f[0];
-          }
-        }
-      }
-      aj += w*4;
-      bufsize -= w*4;
-    }
-
-    v.dn = rh - v.sn;
-    v.cas = res->y0 % 2;
-
-    aj = (OPJ_FLOAT32*) tilec->data;
-    for(j = rw; j > 0; j -= 4){
-      v4dwt_interleave_v(&v, aj, w);
-      v4dwt_decode(&v);
-      if(j >= 4){
-        OPJ_UINT32 k;
-        for(k = 0; k < rh; ++k){
-          memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(OPJ_FLOAT32));
-        }
-      }else{
-        OPJ_UINT32 k;
-        for(k = 0; k < rh; ++k){
-          memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(OPJ_FLOAT32));
-        }
-      }
-      aj += 4;
-    }
-  }
-
-  opj_aligned_free(h.wavelet);
-  return true;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.h
deleted file mode 100644
index 32714e4..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/dwt.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __DWT_H
-#define __DWT_H
-/**
- at file dwt.h
- at brief Implementation of a discrete wavelet transform (DWT)
-
-The functions in DWT.C have for goal to realize forward and inverse discret wavelet
-transform with filter 5-3 (reversible) and filter 9-7 (irreversible). The functions in
-DWT.C are used by some function in TCD.C.
-*/
-#include "openjpeg.h"
-
-struct opj_tcd_tilecomp;
-struct opj_tccp;
-
-/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
-/*@{*/
-
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Forward 5-3 wavelet tranform in 2-D.
-Apply a reversible DWT transform to a component of an image.
- at param tilec Tile component information (current tile)
-*/
-bool dwt_encode(struct opj_tcd_tilecomp * tilec);
-/**
-Inverse 5-3 wavelet tranform in 2-D.
-Apply a reversible inverse DWT transform to a component of an image.
- at param tilec Tile component information (current tile)
- at param numres Number of resolution levels to decode
-*/
-bool dwt_decode(struct opj_tcd_tilecomp* tilec, OPJ_UINT32 numres);
-/**
-Get the gain of a subband for the reversible 5-3 DWT.
- at param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
- at return Returns 0 if orient = 0, returns 1 if orient = 1 or 2, returns 2 otherwise
-*/
-OPJ_UINT32 dwt_getgain(OPJ_UINT32 orient);
-/**
-Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT.
- at param level Level of the wavelet function
- at param orient Band of the wavelet function
- at return Returns the norm of the wavelet function
-*/
-OPJ_FLOAT64 dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient);
-/**
-Forward 9-7 wavelet transform in 2-D.
-Apply an irreversible DWT transform to a component of an image.
- at param tilec Tile component information (current tile)
-*/
-bool dwt_encode_real(struct opj_tcd_tilecomp * tilec);
-/**
-Inverse 9-7 wavelet transform in 2-D.
-Apply an irreversible inverse DWT transform to a component of an image.
- at param tilec Tile component information (current tile)
- at param numres Number of resolution levels to decode
-*/
-bool dwt_decode_real(struct opj_tcd_tilecomp* tilec, OPJ_UINT32 numres);
-/**
-Get the gain of a subband for the irreversible 9-7 DWT.
- at param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
- at return Returns the gain of the 9-7 wavelet transform
-*/
-OPJ_UINT32 dwt_getgain_real(OPJ_UINT32 orient);
-/**
-Get the norm of a wavelet function of a subband at a specified level for the irreversible 9-7 DWT
- at param level Level of the wavelet function
- at param orient Band of the wavelet function
- at return Returns the norm of the 9-7 wavelet
-*/
-OPJ_FLOAT64 dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient);
-/**
-Explicit calculation of the Quantization Stepsizes
- at param tccp Tile-component coding parameters
- at param prec Precint analyzed
-*/
-void dwt_calc_explicit_stepsizes(struct opj_tccp * tccp, OPJ_UINT32 prec);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __DWT_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/event.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/event.c
deleted file mode 100644
index 96dcd3c..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/event.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "event.h"
-#include "openjpeg.h"
-#include "opj_includes.h"
-
-
-/* ==========================================================
-     Utility functions
-   ==========================================================*/
-
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-static OPJ_CHAR*
-i2a(OPJ_UINT32 i, OPJ_CHAR *a, OPJ_UINT32 r) {
-  if (i/r > 0) a = i2a(i/r,a,r);
-  *a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
-  return a+1;
-}
-#endif
-/* ----------------------------------------------------------------------- */
-
-bool opj_event_msg(opj_event_mgr_t * p_event_mgr, OPJ_INT32 event_type, const OPJ_CHAR *fmt, ...) {
-#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
-  opj_msg_callback msg_handler = 00;
-  void * l_data = 00;
-
-
-  if(p_event_mgr != 00) {
-    switch(event_type) {
-      case EVT_ERROR:
-        msg_handler = p_event_mgr->error_handler;
-        l_data = p_event_mgr->m_error_data;
-        break;
-      case EVT_WARNING:
-        msg_handler = p_event_mgr->warning_handler;
-        l_data = p_event_mgr->m_warning_data;
-        break;
-      case EVT_INFO:
-        msg_handler = p_event_mgr->info_handler;
-        l_data = p_event_mgr->m_info_data;
-        break;
-      default:
-        break;
-    }
-    if(msg_handler == 00) {
-      return false;
-    }
-  } else {
-    return false;
-  }
-
-  if ((fmt != 00) && (p_event_mgr != 00)) {
-    va_list arg;
-    OPJ_INT32 str_length/*, i, j*/; /* UniPG */
-    OPJ_CHAR message[MSG_SIZE];
-    memset(message, 0, MSG_SIZE);
-    /* initialize the optional parameter list */
-    va_start(arg, fmt);
-    /* check the length of the format string */
-    str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt);
-    /* parse the format string and put the result in 'message' */
-    vsprintf(message, fmt, arg); /* UniPG */
-    /* deinitialize the optional parameter list */
-    va_end(arg);
-
-    /* output the message to the user program */
-    msg_handler(message, l_data);
-  }
-
-  return true;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/fix.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/fix.h
deleted file mode 100644
index f4bb87f..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/fix.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __FIX_H
-#define __FIX_H
-
-#include "openjpeg.h"
-#include "opj_includes.h"
-
-/**
- at file fix.h
- at brief Implementation of operations of specific multiplication (FIX)
-
-The functions in FIX.H have for goal to realize specific multiplication.
-*/
-/** @defgroup FIX FIX - Implementation of operations of specific multiplication */
-/*@{*/
-
-/**
-Multiply two fixed-precision rational numbers.
- at param a
- at param b
- at return Returns a * b
-*/
-static INLINE int fix_mul(int a, int b) {
-    OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
-    temp += temp & 4096;
-    return (int) (temp >> 13) ;
-}
-
-/*@}*/
-
-#endif /* __FIX_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/function_list.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/function_list.c
deleted file mode 100644
index a249719..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/function_list.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "function_list.h"
-#include "opj_includes.h"
-#include "opj_malloc.h"
-/**
- * Default size of the validation list, if not sufficient, data will be reallocated with a double size.
- */
-#define OPJ_VALIDATION_SIZE 10
-
-/**
- * Creates a validation list.
- *
- * @return  the newly created validation list.
- */
-opj_procedure_list_t *  opj_procedure_list_create()
-{
-  /* memory allocation */
-  opj_procedure_list_t * l_validation = (opj_procedure_list_t *) opj_malloc(sizeof(opj_procedure_list_t));
-  if
-    (! l_validation)
-  {
-    return 00;
-  }
-  /* initialization */
-  memset(l_validation,0,sizeof(opj_procedure_list_t));
-  l_validation->m_nb_max_procedures = OPJ_VALIDATION_SIZE;
-  l_validation->m_procedures = (void**)opj_malloc(
-    OPJ_VALIDATION_SIZE * sizeof(opj_procedure));
-  if
-    (! l_validation->m_procedures)
-  {
-    opj_free(l_validation);
-    return 00;
-  }
-  memset(l_validation->m_procedures,0,OPJ_VALIDATION_SIZE * sizeof(opj_procedure));
-  return l_validation;
-}
-
-
-
-/**
- * Destroys a validation list.
- *
- * @param p_list the list to destroy.
- */
-void  opj_procedure_list_destroy(opj_procedure_list_t * p_list)
-{
-  if
-    (! p_list)
-  {
-    return;
-  }
-  /* initialization */
-  if
-    (p_list->m_procedures)
-  {
-    opj_free(p_list->m_procedures);
-  }
-  opj_free(p_list);
-}
-
-/**
- * Adds a new validation procedure.
- *
- * @param  p_validation_list the list of procedure to modify.
- * @param  p_procedure    the procedure to add.
- */
-bool  opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure)
-{
-  if
-    (p_validation_list->m_nb_max_procedures == p_validation_list->m_nb_procedures)
-  {
-    p_validation_list->m_nb_max_procedures += OPJ_VALIDATION_SIZE;
-    p_validation_list->m_procedures = (void**)opj_realloc(
-    p_validation_list->m_procedures,p_validation_list->m_nb_max_procedures * sizeof(opj_procedure));
-    if
-      (! p_validation_list->m_procedures)
-    {
-      p_validation_list->m_nb_max_procedures = 0;
-      p_validation_list->m_nb_procedures = 0;
-      return false;
-    }
-  }
-  p_validation_list->m_procedures[p_validation_list->m_nb_procedures] = p_procedure;
-  ++p_validation_list->m_nb_procedures;
-  return true;
-}
-
-/**
- * Gets the number of validation procedures.
- *
- * @param  p_validation_list the list of procedure to modify.
- *
- * @return the number of validation procedures.
- */
-OPJ_UINT32 opj_procedure_list_get_nb_procedures (opj_procedure_list_t * p_validation_list)
-{
-  return p_validation_list->m_nb_procedures;
-}
-
-/**
- * Gets the pointer on the first validation procedure. This function is similar to the C++
- * iterator class to iterate through all the procedures inside the validation list.
- * the caller does not take ownership of the pointer.
- *
- * @param  p_validation_list the list of procedure to get the first procedure from.
- *
- * @return  a pointer to the first procedure.
- */
-opj_procedure* opj_procedure_list_get_first_procedure (opj_procedure_list_t * p_validation_list)
-{
-  return p_validation_list->m_procedures;
-}
-
-/**
- * Clears the list of validation procedures.
- *
- * @param  p_validation_list the list of procedure to clear.
- *
- */
-void  opj_procedure_list_clear (opj_procedure_list_t * p_validation_list)
-{
-  p_validation_list->m_nb_procedures = 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/image.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/image.c
deleted file mode 100644
index 3305f4f..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/image.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "image.h"
-#include "openjpeg.h"
-#include "opj_malloc.h"
-#include "j2k.h"
-#include "int.h"
-
-opj_image_t* opj_image_create0(void) {
-  opj_image_t *image = (opj_image_t*)opj_malloc(sizeof(opj_image_t));
-  memset(image,0,sizeof(opj_image_t));
-  return image;
-}
-
-opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
-  OPJ_UINT32 compno;
-  opj_image_t *image = 00;
-
-  image = (opj_image_t*) opj_malloc(sizeof(opj_image_t));
-  if
-    (image)
-  {
-    memset(image,0,sizeof(opj_image_t));
-    image->color_space = clrspc;
-    image->numcomps = numcmpts;
-    /* allocate memory for the per-component information */
-    image->comps = (opj_image_comp_t*)opj_malloc(image->numcomps * sizeof(opj_image_comp_t));
-    if
-      (!image->comps)
-    {
-      opj_image_destroy(image);
-      return 00;
-    }
-    memset(image->comps,0,image->numcomps * sizeof(opj_image_comp_t));
-    /* create the individual image components */
-    for(compno = 0; compno < numcmpts; compno++) {
-      opj_image_comp_t *comp = &image->comps[compno];
-      comp->dx = cmptparms[compno].dx;
-      comp->dy = cmptparms[compno].dy;
-      comp->w = cmptparms[compno].w;
-      comp->h = cmptparms[compno].h;
-      comp->x0 = cmptparms[compno].x0;
-      comp->y0 = cmptparms[compno].y0;
-      comp->prec = cmptparms[compno].prec;
-      comp->sgnd = cmptparms[compno].sgnd;
-      comp->data = (OPJ_INT32*) opj_calloc(comp->w * comp->h, sizeof(OPJ_INT32));
-      if
-        (!comp->data)
-      {
-        opj_image_destroy(image);
-        return 00;
-      }
-    }
-  }
-  return image;
-}
-
-opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
-  OPJ_UINT32 compno;
-  opj_image_t *image = 00;
-
-  image = (opj_image_t*) opj_malloc(sizeof(opj_image_t));
-  if
-    (image)
-  {
-    memset(image,0,sizeof(opj_image_t));
-    image->color_space = clrspc;
-    image->numcomps = numcmpts;
-    /* allocate memory for the per-component information */
-    image->comps = (opj_image_comp_t*)opj_malloc(image->numcomps * sizeof(opj_image_comp_t));
-    if
-      (!image->comps)
-    {
-      opj_image_destroy(image);
-      return 00;
-    }
-    memset(image->comps,0,image->numcomps * sizeof(opj_image_comp_t));
-    /* create the individual image components */
-    for(compno = 0; compno < numcmpts; compno++) {
-      opj_image_comp_t *comp = &image->comps[compno];
-      comp->dx = cmptparms[compno].dx;
-      comp->dy = cmptparms[compno].dy;
-      comp->w = cmptparms[compno].w;
-      comp->h = cmptparms[compno].h;
-      comp->x0 = cmptparms[compno].x0;
-      comp->y0 = cmptparms[compno].y0;
-      comp->prec = cmptparms[compno].prec;
-      comp->sgnd = cmptparms[compno].sgnd;
-      comp->data = 0;
-    }
-  }
-  return image;
-}
-
-void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
-  OPJ_UINT32 i;
-  if
-    (image)
-  {
-    if
-      (image->comps)
-    {
-      /* image components */
-      for(i = 0; i < image->numcomps; i++) {
-        opj_image_comp_t *image_comp = &image->comps[i];
-        if(image_comp->data) {
-          opj_free(image_comp->data);
-        }
-      }
-      opj_free(image->comps);
-    }
-    opj_free(image);
-  }
-}
-
-/**
- * Updates the components of the image from the coding parameters.
- *
- * @param p_image    the image to update.
- * @param p_cp      the coding parameters from which to update the image.
- */
-void opj_image_comp_update(opj_image_t * p_image,const opj_cp_t * p_cp)
-{
-  OPJ_UINT32 i, l_width, l_height;
-  OPJ_INT32 l_x0,l_y0,l_x1,l_y1;
-  OPJ_INT32 l_comp_x0,l_comp_y0,l_comp_x1,l_comp_y1;
-  opj_image_comp_t * l_img_comp = 00;
-
-  l_x0 = int_max(p_cp->tx0 , p_image->x0);
-  l_y0 = int_max(p_cp->ty0 , p_image->y0);
-  l_x1 = int_min(p_cp->tx0 + p_cp->tw * p_cp->tdx, p_image->x1);
-  l_y1 = int_min(p_cp->ty0 + p_cp->th * p_cp->tdy, p_image->y1);
-
-  l_img_comp = p_image->comps;
-  for
-    (i = 0; i < p_image->numcomps; ++i)
-  {
-    l_comp_x0 = int_ceildiv(l_x0, l_img_comp->dx);
-    l_comp_y0 = int_ceildiv(l_y0, l_img_comp->dy);
-    l_comp_x1 = int_ceildiv(l_x1, l_img_comp->dx);
-    l_comp_y1 = int_ceildiv(l_y1, l_img_comp->dy);
-    l_width = int_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_comp->factor);
-    l_height = int_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
-    l_img_comp->w = l_width;
-    l_img_comp->h = l_height;
-    l_img_comp->x0 = l_x0;
-    l_img_comp->y0 = l_y0;
-    ++l_img_comp;
-  }
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/int.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/int.h
deleted file mode 100644
index 43e576f..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/int.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __INT_H
-#define __INT_H
-/**
- at file int.h
- at brief Implementation of operations on integers (INT)
-
-The functions in INT.H have for goal to realize operations on integers.
-*/
-#include "openjpeg.h"
-#include "opj_includes.h"
-/** @defgroup INT INT - Implementation of operations on integers */
-/*@{*/
-
-/** @name Exported functions (see also openjpeg.h) */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Get the minimum of two integers
- at return Returns a if a < b else b
-*/
-static INLINE OPJ_INT32 int_min(OPJ_INT32 a, OPJ_INT32 b) {
-  return a < b ? a : b;
-}
-
-/**
-Get the minimum of two integers
- at return Returns a if a < b else b
-*/
-static INLINE OPJ_UINT32 uint_min(OPJ_UINT32 a, OPJ_UINT32 b) {
-  return a < b ? a : b;
-}
-
-/**
-Get the maximum of two integers
- at return Returns a if a > b else b
-*/
-static INLINE OPJ_INT32 int_max(OPJ_INT32  a, OPJ_INT32  b) {
-  return (a > b) ? a : b;
-}
-
-/**
-Get the maximum of two integers
- at return Returns a if a > b else b
-*/
-static INLINE OPJ_UINT32 uint_max(OPJ_UINT32  a, OPJ_UINT32  b) {
-  return (a > b) ? a : b;
-}
-/**
-Clamp an integer inside an interval
- at return
-<ul>
-<li>Returns a if (min < a < max)
-<li>Returns max if (a > max)
-<li>Returns min if (a < min)
-</ul>
-*/
-static INLINE OPJ_INT32  int_clamp(OPJ_INT32  a, OPJ_INT32  min, OPJ_INT32  max) {
-  if (a < min)
-    return min;
-  if (a > max)
-    return max;
-  return a;
-}
-/**
- at return Get absolute value of integer
-*/
-static INLINE OPJ_INT32  int_abs(OPJ_INT32  a) {
-  return a < 0 ? -a : a;
-}
-/**
-Divide an integer and round upwards
- at return Returns a divided by b
-*/
-static INLINE OPJ_INT32  int_ceildiv(OPJ_INT32  a, OPJ_INT32  b) {
-  return (a + b - 1) / b;
-}
-
-/**
-Divide an integer and round upwards
- at return Returns a divided by b
-*/
-static INLINE OPJ_UINT32  uint_ceildiv(OPJ_UINT32  a, OPJ_UINT32  b) {
-  return (a + b - 1) / b;
-}
-/**
-Divide an integer by a power of 2 and round upwards
- at return Returns a divided by 2^b
-*/
-static INLINE OPJ_INT32  int_ceildivpow2(OPJ_INT32  a, OPJ_INT32  b) {
-  return (a + (1 << b) - 1) >> b;
-}
-/**
-Divide an integer by a power of 2 and round downwards
- at return Returns a divided by 2^b
-*/
-static INLINE OPJ_INT32  int_floordivpow2(OPJ_INT32  a, OPJ_INT32  b) {
-  return a >> b;
-}
-/**
-Get logarithm of an integer and round downwards
- at return Returns log2(a)
-*/
-static INLINE OPJ_INT32  int_floorlog2(OPJ_INT32  a) {
-  OPJ_INT32  l;
-  for (l = 0; a > 1; l++) {
-    a >>= 1;
-  }
-  return l;
-}
-
-/**
-Get logarithm of an integer and round downwards
- at return Returns log2(a)
-*/
-static INLINE OPJ_UINT32  uint_floorlog2(OPJ_UINT32  a) {
-  OPJ_UINT32  l;
-  for (l = 0; a > 1; ++l)
-  {
-    a >>= 1;
-  }
-  return l;
-}
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/invert.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/invert.c
deleted file mode 100644
index 14ce3e4..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/invert.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "invert.h"
-#include "opj_malloc.h"
-
-
-bool opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations, OPJ_FLOAT32 * p_swap_area,OPJ_UINT32 n);
-void opj_lupSolve(OPJ_FLOAT32 * pResult, OPJ_FLOAT32* pMatrix, OPJ_FLOAT32* pVector, OPJ_UINT32* pPermutations, OPJ_UINT32 n,OPJ_FLOAT32 * p_intermediate_data);
-void opj_lupInvert (OPJ_FLOAT32 * pSrcMatrix,
-           OPJ_FLOAT32 * pDestMatrix,
-           OPJ_UINT32 n,
-           OPJ_UINT32 * pPermutations,
-           OPJ_FLOAT32 * p_src_temp,
-           OPJ_FLOAT32 * p_dest_temp,
-           OPJ_FLOAT32 * p_swap_area);
-
-/**
- * Matrix inversion.
- */
-bool opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,OPJ_FLOAT32 * pDestMatrix, OPJ_UINT32 n)
-{
-  OPJ_BYTE * l_data = 00;
-  OPJ_UINT32 l_permutation_size = n * sizeof(OPJ_UINT32);
-  OPJ_UINT32 l_swap_size = n * sizeof(OPJ_FLOAT32);
-  OPJ_UINT32 l_total_size = l_permutation_size + 3 * l_swap_size;
-  OPJ_UINT32 * lPermutations = 00;
-  OPJ_FLOAT32 * l_double_data = 00;
-
-  l_data = (OPJ_BYTE *) opj_malloc(l_total_size);
-  if
-    (l_data == 0)
-  {
-    return false;
-  }
-  lPermutations = (OPJ_UINT32 *) l_data;
-  l_double_data = (OPJ_FLOAT32 *) (l_data + l_permutation_size);
-  memset(lPermutations,0,l_permutation_size);
-
-  if
-    (! opj_lupDecompose(pSrcMatrix,lPermutations,l_double_data,n))
-  {
-    opj_free(l_data);
-    return false;
-  }
-  opj_lupInvert(pSrcMatrix,pDestMatrix,n,lPermutations,l_double_data,l_double_data + n,l_double_data + 2*n);
-  opj_free(l_data);
-  return true;
-}
-
-
-/**
- * LUP decomposition
- */
-bool opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations, OPJ_FLOAT32 * p_swap_area,OPJ_UINT32 n)
-{
-  OPJ_UINT32 * tmpPermutations = permutations;
-  OPJ_UINT32 * dstPermutations;
-  OPJ_UINT32 k2=0,t;
-  OPJ_FLOAT32 temp;
-  OPJ_UINT32 i,j,k;
-  OPJ_FLOAT32 p;
-  OPJ_UINT32 lLastColum = n - 1;
-  OPJ_UINT32 lSwapSize = n * sizeof(OPJ_FLOAT32);
-  OPJ_FLOAT32 * lTmpMatrix = matrix;
-  OPJ_FLOAT32 * lColumnMatrix,* lDestMatrix;
-  OPJ_UINT32 offset = 1;
-  OPJ_UINT32 lStride = n-1;
-
-  //initialize permutations
-  for
-    (i = 0; i < n; ++i)
-  {
-      *tmpPermutations++ = i;
-  }
-
-
-
-  // now make a pivot with colum switch
-  tmpPermutations = permutations;
-  for
-    (k = 0; k < lLastColum; ++k)
-  {
-    p = 0.0;
-
-    // take the middle element
-    lColumnMatrix = lTmpMatrix + k;
-
-    // make permutation with the biggest value in the column
-    for
-      (i = k; i < n; ++i)
-    {
-      temp = ((*lColumnMatrix > 0) ? *lColumnMatrix : -(*lColumnMatrix));
-         if
-        (temp > p)
-      {
-           p = temp;
-           k2 = i;
-         }
-      // next line
-      lColumnMatrix += n;
-       }
-
-       // a whole rest of 0 -> non singular
-       if
-      (p == 0.0)
-    {
-        return false;
-    }
-
-    // should we permute ?
-    if
-      (k2 != k)
-    {
-      //exchange of line
-         // k2 > k
-      dstPermutations = tmpPermutations + k2 - k;
-      // swap indices
-      t = *tmpPermutations;
-         *tmpPermutations = *dstPermutations;
-         *dstPermutations = t;
-
-      // and swap entire line.
-      lColumnMatrix = lTmpMatrix + (k2 - k) * n;
-      memcpy(p_swap_area,lColumnMatrix,lSwapSize);
-      memcpy(lColumnMatrix,lTmpMatrix,lSwapSize);
-      memcpy(lTmpMatrix,p_swap_area,lSwapSize);
-    }
-
-    // now update data in the rest of the line and line after
-    lDestMatrix = lTmpMatrix + k;
-    lColumnMatrix = lDestMatrix + n;
-    // take the middle element
-    temp = *(lDestMatrix++);
-
-    // now compute up data (i.e. coeff up of the diagonal).
-       for (i = offset; i < n; ++i)
-    {
-      //lColumnMatrix;
-      // divide the lower column elements by the diagonal value
-
-      // matrix[i][k] /= matrix[k][k];
-         // p = matrix[i][k]
-      p = *lColumnMatrix / temp;
-      *(lColumnMatrix++) = p;
-         for
-        (j = /* k + 1 */ offset; j < n; ++j)
-      {
-        // matrix[i][j] -= matrix[i][k] * matrix[k][j];
-           *(lColumnMatrix++) -= p * (*(lDestMatrix++));
-      }
-      // come back to the k+1th element
-      lDestMatrix -= lStride;
-      // go to kth element of the next line
-      lColumnMatrix += k;
-       }
-    // offset is now k+2
-    ++offset;
-    // 1 element less for stride
-    --lStride;
-    // next line
-    lTmpMatrix+=n;
-    // next permutation element
-    ++tmpPermutations;
-  }
-    return true;
-}
-
-
-
-/**
- * LUP solving
- */
-void opj_lupSolve (OPJ_FLOAT32 * pResult, OPJ_FLOAT32 * pMatrix, OPJ_FLOAT32 * pVector, OPJ_UINT32* pPermutations, OPJ_UINT32 n,OPJ_FLOAT32 * p_intermediate_data)
-{
-  OPJ_UINT32 i,j;
-  OPJ_FLOAT32 sum;
-  OPJ_FLOAT32 u;
-    OPJ_UINT32 lStride = n+1;
-  OPJ_FLOAT32 * lCurrentPtr;
-  OPJ_FLOAT32 * lIntermediatePtr;
-  OPJ_FLOAT32 * lDestPtr;
-  OPJ_FLOAT32 * lTmpMatrix;
-  OPJ_FLOAT32 * lLineMatrix = pMatrix;
-  OPJ_FLOAT32 * lBeginPtr = pResult + n - 1;
-  OPJ_FLOAT32 * lGeneratedData;
-  OPJ_UINT32 * lCurrentPermutationPtr = pPermutations;
-
-
-  lIntermediatePtr = p_intermediate_data;
-  lGeneratedData = p_intermediate_data + n - 1;
-
-    for
-    (i = 0; i < n; ++i)
-  {
-         sum = 0.0;
-    lCurrentPtr = p_intermediate_data;
-    lTmpMatrix = lLineMatrix;
-        for
-      (j = 1; j <= i; ++j)
-    {
-      // sum += matrix[i][j-1] * y[j-1];
-          sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
-        }
-    //y[i] = pVector[pPermutations[i]] - sum;
-        *(lIntermediatePtr++) = pVector[*(lCurrentPermutationPtr++)] - sum;
-    lLineMatrix += n;
-  }
-
-  // we take the last point of the matrix
-  lLineMatrix = pMatrix + n*n - 1;
-
-  // and we take after the last point of the destination vector
-  lDestPtr = pResult + n;
-
-  for
-    (i = n - 1; i != -1 ; --i)
-  {
-    sum = 0.0;
-    lTmpMatrix = lLineMatrix;
-        u = *(lTmpMatrix++);
-    lCurrentPtr = lDestPtr--;
-        for
-      (j = i + 1; j < n; ++j)
-    {
-      // sum += matrix[i][j] * x[j]
-          sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
-    }
-    //x[i] = (y[i] - sum) / u;
-        *(lBeginPtr--) = (*(lGeneratedData--) - sum) / u;
-    lLineMatrix -= lStride;
-  }
-}
-
-/** LUP inversion (call with the result of lupDecompose)
- */
-void opj_lupInvert (
-           OPJ_FLOAT32 * pSrcMatrix,
-           OPJ_FLOAT32 * pDestMatrix,
-           OPJ_UINT32 n,
-           OPJ_UINT32 * pPermutations,
-           OPJ_FLOAT32 * p_src_temp,
-           OPJ_FLOAT32 * p_dest_temp,
-           OPJ_FLOAT32 * p_swap_area
-           )
-{
-  OPJ_UINT32 j,i;
-  OPJ_FLOAT32 * lCurrentPtr;
-  OPJ_FLOAT32 * lLineMatrix = pDestMatrix;
-  OPJ_UINT32 lSwapSize = n * sizeof(OPJ_FLOAT32);
-
-  for
-    (j = 0; j < n; ++j)
-  {
-    lCurrentPtr = lLineMatrix++;
-        memset(p_src_temp,0,lSwapSize);
-      p_src_temp[j] = 1.0;
-    opj_lupSolve(p_dest_temp,pSrcMatrix,p_src_temp, pPermutations, n , p_swap_area);
-
-    for
-      (i = 0; i < n; ++i)
-    {
-        *(lCurrentPtr) = p_dest_temp[i];
-      lCurrentPtr+=n;
-      }
-    }
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.c
deleted file mode 100644
index c16b210..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.c
+++ /dev/null
@@ -1,9411 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "j2k.h"
-#include "opj_malloc.h"
-#include "opj_includes.h"
-#include "pi.h"
-#include "event.h"
-#include "cio.h"
-#include "int.h"
-#include "tcd.h"
-#include "function_list.h"
-#include "invert.h"
-#include "dwt.h"
-#include "mct.h"
-#include "image.h"
-
-/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
-/*@{*/
-
-
-/***************************************************************************
- ********************** TYPEDEFS *******************************************
- ***************************************************************************/
-/**
- * Correspondance prog order <-> string representation
- */
-typedef struct j2k_prog_order
-{
-  OPJ_PROG_ORDER enum_prog;
-  OPJ_CHAR str_prog[5];
-}
-j2k_prog_order_t;
-
-typedef struct opj_dec_memory_marker_handler
-{
-  /** marker value */
-  OPJ_UINT32 id;
-  /** value of the state when the marker can appear */
-  OPJ_UINT32 states;
-  /** action linked to the marker */
-  bool (*handler) (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-            );
-}
-opj_dec_memory_marker_handler_t;
-
-
-
-/** @name Local static functions */
-/*@{*/
-/**
- * Writes a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
- *
- * @param  p_comp_no  the component number to output.
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
- *
-*/
-static bool j2k_write_SPCod_SPCoc(
-                opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_tile_no,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-          );
-
-/**
- * Reads a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
- * @param  p_header_data  the data contained in the COM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the COM marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_SPCod_SPCoc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 compno,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-              );
-
-/**
- * Gets the size taken by writting a SPCod or SPCoc for the given tile and component.
- *
- * @param  p_tile_no    the tile indix.
- * @param  p_comp_no    the component being outputted.
- * @param  p_j2k      the J2K codec.
- *
- * @return  the number of bytes taken by the SPCod element.
- */
-static OPJ_UINT32 j2k_get_SPCod_SPCoc_size (
-            opj_j2k_t *p_j2k,
-            OPJ_UINT32 p_tile_no,
-            OPJ_UINT32 p_comp_no
-            );
-
-/**
- * Writes a SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param  p_tile_no    the tile to output.
- * @param  p_comp_no    the component number to output.
- * @param  p_data      the data buffer.
- * @param  p_header_size  pointer to the size of the data buffer, it is changed by the function.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
- *
-*/
-static bool j2k_write_SQcd_SQcc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_tile_no,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-          );
-
-/**
- * Reads a SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param  p_tile_no    the tile to output.
- * @param  p_comp_no    the component number to output.
- * @param  p_data      the data buffer.
- * @param  p_header_size  pointer to the size of the data buffer, it is changed by the function.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
- *
-*/
-static bool j2k_read_SQcd_SQcc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 compno,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-          );
-/**
- * Updates the Tile Length Marker.
- */
-static void j2k_update_tlm (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 p_tile_part_size);
-
-/**
- * Gets the size taken by writting SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param  p_tile_no    the tile indix.
- * @param  p_comp_no    the component being outputted.
- * @param  p_j2k      the J2K codec.
- *
- * @return  the number of bytes taken by the SPCod element.
- */
-static OPJ_UINT32 j2k_get_SQcd_SQcc_size (
-                  opj_j2k_t *p_j2k,
-                    OPJ_UINT32 p_tile_no,
-                  OPJ_UINT32 p_comp_no
-
-            );
-
-/**
- * Copies the tile component parameters of all the component from the first tile component.
- *
- * @param    p_j2k    the J2k codec.
- */
-static void j2k_copy_tile_component_parameters(
-              opj_j2k_t *p_j2k
-              );
-
-/**
- * Writes the SOC marker (Start Of Codestream)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-
-static bool j2k_write_soc(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-                );
-/**
- * Reads a SOC marker (Start of Codestream)
- * @param  p_header_data  the data contained in the SOC box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the SOC marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_soc(
-          opj_j2k_t *p_j2k,
-          struct opj_stream_private *p_stream,
-          struct opj_event_mgr * p_manager
-         );
-/**
- * Writes the SIZ marker (image and tile size)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-static bool j2k_write_siz(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-                );
-/**
- * Writes the CBD-MCT-MCC-MCO markers (Multi components transform)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-static bool j2k_write_mct_data_group(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-                );
-
-/**
- * Reads a SIZ marker (image and tile size)
- * @param  p_header_data  the data contained in the SIZ box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the SIZ marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_siz (
-              opj_j2k_t *p_j2k,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 p_header_size,
-              struct opj_event_mgr * p_manager
-          );
-/**
- * Writes the COM marker (comment)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-static bool j2k_write_com(
-          opj_j2k_t *p_j2k,
-          struct opj_stream_private *p_stream,
-          struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a COM marker (comments)
- * @param  p_header_data  the data contained in the COM box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the COM marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_com (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          );
-
-
-
-/**
- * Writes the COD marker (Coding style default)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-static bool j2k_write_cod(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-            );
-/**
- * Reads a COD marker (Coding Styke defaults)
- * @param  p_header_data  the data contained in the COD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the COD marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_cod (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the COC marker (Coding style component)
- *
- * @param  p_comp_number  the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_coc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_number,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-              );
-
-/**
- * Writes the COC marker (Coding style component)
- *
- * @param  p_comp_no    the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static void j2k_write_coc_in_memory(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_data_written,
-              struct opj_event_mgr * p_manager
-            );
-/**
- * Gets the maximum size taken by a coc.
- *
- * @param  p_j2k  the jpeg2000 codec to use.
- */
-static OPJ_UINT32 j2k_get_max_coc_size(opj_j2k_t *p_j2k);
-
-/**
- * Reads a COC marker (Coding Style Component)
- * @param  p_header_data  the data contained in the COC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the COC marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_coc (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the QCD marker (quantization default)
- *
- * @param  p_comp_number  the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_qcd(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-              );
-
-
-/**
- * Reads a QCD marker (Quantization defaults)
- * @param  p_header_data  the data contained in the QCD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the QCD marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_qcd (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          );
-/**
- * Writes the QCC marker (quantization component)
- *
- * @param  p_comp_no  the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_qcc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-              );
-/**
- * Writes the QCC marker (quantization component)
- *
- * @param  p_comp_no  the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static void j2k_write_qcc_in_memory(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_data_written,
-              struct opj_event_mgr * p_manager
-              );
-/**
- * Gets the maximum size taken by a qcc.
- */
-static OPJ_UINT32 j2k_get_max_qcc_size (opj_j2k_t *p_j2k);
-
-/**
- * Reads a QCC marker (Quantization component)
- * @param  p_header_data  the data contained in the QCC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the QCC marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_qcc(
-              opj_j2k_t *p_j2k,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 p_header_size,
-              struct opj_event_mgr * p_manager);
-/**
- * Writes the POC marker (Progression Order Change)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_poc(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the updated tlm.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_updated_tlm(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the POC marker (Progression Order Change)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
- */
-static void j2k_write_poc_in_memory(
-              opj_j2k_t *p_j2k,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_data_written,
-              struct opj_event_mgr * p_manager
-          );
-
-/**
- * Gets the maximum size taken by the writting of a POC.
- */
-static OPJ_UINT32 j2k_get_max_poc_size(opj_j2k_t *p_j2k);
-
-/**
- * Gets the maximum size taken by the toc headers of all the tile parts of any given tile.
- */
-static OPJ_UINT32 j2k_get_max_toc_size (opj_j2k_t *p_j2k);
-
-/**
- * Gets the maximum size taken by the headers of the SOT.
- *
- * @param  p_j2k  the jpeg2000 codec to use.
- */
-static OPJ_UINT32 j2k_get_specific_header_sizes(opj_j2k_t *p_j2k);
-
-/**
- * Reads a POC marker (Progression Order Change)
- *
- * @param  p_header_data  the data contained in the POC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the POC marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_poc (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a CRG marker (Component registration)
- *
- * @param  p_header_data  the data contained in the TLM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the TLM marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_crg (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a TLM marker (Tile Length Marker)
- *
- * @param  p_header_data  the data contained in the TLM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the TLM marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_tlm (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a PLM marker (Packet length, main header marker)
- *
- * @param  p_header_data  the data contained in the TLM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the TLM marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_plm (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a PLT marker (Packet length, tile-part header)
- *
- * @param  p_header_data  the data contained in the PLT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the PLT marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_plt (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a PPM marker (Packed packet headers, main header)
- *
- * @param  p_header_data  the data contained in the POC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the POC marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_ppm (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a PPT marker (Packed packet headers, tile-part header)
- *
- * @param  p_header_data  the data contained in the PPT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the PPT marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_ppt (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Writes the TLM marker (Tile Length Marker)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_tlm(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Writes the SOT marker (Start of tile-part)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_sot(
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_data,
-            OPJ_UINT32 * p_data_written,
-            const struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a PPT marker (Packed packet headers, tile-part header)
- *
- * @param  p_header_data  the data contained in the PPT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the PPT marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_sot (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Writes the SOD marker (Start of data)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_sod(
-            opj_j2k_t *p_j2k,
-            struct opj_tcd * p_tile_coder,
-            OPJ_BYTE * p_data,
-            OPJ_UINT32 * p_data_written,
-            OPJ_UINT32 p_total_data_size,
-            const struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a SOD marker (Start Of Data)
- *
- * @param  p_header_data  the data contained in the SOD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the SOD marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_sod (
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Writes the RGN marker (Region Of Interest)
- *
- * @param  p_tile_no    the tile to output
- * @param  p_comp_no    the component to output
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_rgn(
-            opj_j2k_t *p_j2k,
-            OPJ_UINT32 p_tile_no,
-            OPJ_UINT32 p_comp_no,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a RGN marker (Region Of Interest)
- *
- * @param  p_header_data  the data contained in the POC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the POC marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_rgn (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          ) ;
-/**
- * Writes the EOC marker (End of Codestream)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_eoc(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Copies the tile component parameters of all the component from the first tile component.
- *
- * @param    p_j2k    the J2k codec.
- */
-static void j2k_copy_tile_quantization_parameters(
-              opj_j2k_t *p_j2k
-              );
-
-/**
- * Reads a EOC marker (End Of Codestream)
- *
- * @param  p_header_data  the data contained in the SOD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the SOD marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_eoc (
-              opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          ) ;
-
-/**
- * Inits the Info
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_init_info(
-              opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Reads an unknown marker
- *
- * @param  p_stream        the stream object to read from.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_manager    the user event manager.
- *
- * @return  true      if the marker could be deduced.
-*/
-static bool j2k_read_unk (
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Ends the encoding, i.e. frees memory.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_end_encoding(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the CBD marker (Component bit depth definition)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_cbd(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Reads a CBD marker (Component bit depth definition)
- * @param  p_header_data  the data contained in the CBD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the CBD marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_cbd (
-              opj_j2k_t *p_j2k,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 p_header_size,
-              struct opj_event_mgr * p_manager);
-
-/**
- * Writes the MCT marker (Multiple Component Transform)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_mct_record(
-            opj_j2k_t *p_j2k,
-            opj_mct_data_t * p_mct_record,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Reads a MCT marker (Multiple Component Transform)
- *
- * @param  p_header_data  the data contained in the MCT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the MCT marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_mct (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the MCC marker (Multiple Component Collection)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_mcc_record(
-              opj_j2k_t *p_j2k,
-            struct opj_simple_mcc_decorrelation_data * p_mcc_record,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Reads a MCC marker (Multiple Component Collection)
- *
- * @param  p_header_data  the data contained in the MCC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the MCC marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_mcc (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the MCO marker (Multiple component transformation ordering)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_mco(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Reads a MCO marker (Multiple Component Transform Ordering)
- *
- * @param  p_header_data  the data contained in the MCO box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the MCO marker.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_read_mco (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Writes the image components.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_image_components(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes regions of interests.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_regions(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-/**
- * Writes EPC ????
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_write_epc(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Checks the progression order changes values. Tells of the poc given as input are valid.
- * A nice message is outputted at errors.
- *
- * @param  p_pocs        the progression order changes.
- * @param  p_nb_pocs      the number of progression order changes.
- * @param  p_nb_resolutions  the number of resolutions.
- * @param  numcomps      the number of components
- * @param  numlayers      the number of layers.
- *
- * @return  true if the pocs are valid.
- */
-static bool j2k_check_poc_val(
-                const opj_poc_t *p_pocs,
-                OPJ_UINT32 p_nb_pocs,
-                OPJ_UINT32 p_nb_resolutions,
-                OPJ_UINT32 numcomps,
-                OPJ_UINT32 numlayers,
-                opj_event_mgr_t * p_manager);
-
-/**
- * Gets the number of tile parts used for the given change of progression (if any) and the given tile.
- *
- * @param    cp      the coding parameters.
- * @param    pino    the offset of the given poc (i.e. its position in the coding parameter).
- * @param    tileno    the given tile.
- *
- * @return    the number of tile parts.
- */
-static OPJ_UINT32 j2k_get_num_tp(
-              opj_cp_t *cp,
-              OPJ_UINT32 pino,
-              OPJ_UINT32 tileno);
-/**
- * Calculates the total number of tile parts needed by the encoder to
- * encode such an image. If not enough memory is available, then the function return false.
- *
- * @param  p_nb_tiles  pointer that will hold the number of tile parts.
- * @param  cp      the coding parameters for the image.
- * @param  image    the image to encode.
- * @param  p_j2k      the p_j2k encoder.
- * @param  p_manager  the user event manager.
- *
- * @return true if the function was successful, false else.
- */
-static bool j2k_calculate_tp(
-            opj_j2k_t *p_j2k,
-            opj_cp_t *cp,
-            OPJ_UINT32 * p_nb_tiles,
-            opj_image_t *image,
-            opj_event_mgr_t * p_manager);
-
-static bool j2k_write_first_tile_part (
-                  opj_j2k_t *p_j2k,
-                  OPJ_BYTE * p_data,
-                  OPJ_UINT32 * p_data_written,
-                  OPJ_UINT32 p_total_data_size,
-                  opj_stream_private_t *p_stream,
-                  struct opj_event_mgr * p_manager
-                );
-static bool j2k_write_all_tile_parts(
-                  opj_j2k_t *p_j2k,
-                  OPJ_BYTE * p_data,
-                  OPJ_UINT32 * p_data_written,
-                  OPJ_UINT32 p_total_data_size,
-                  opj_stream_private_t *p_stream,
-                  struct opj_event_mgr * p_manager
-                );
-
-/**
- * Reads the lookup table containing all the marker, status and action, and returns the handler associated
- * with the marker value.
- * @param  p_id    Marker value to look up
- *
- * @return  the handler associated with the id.
-*/
-static const struct opj_dec_memory_marker_handler * j2k_get_marker_handler (OPJ_UINT32 p_id);
-
-/**
- * Destroys a tile coding parameter structure.
- *
- * @param  p_tcp    the tile coding parameter to destroy.
- */
-static void j2k_tcp_destroy (opj_tcp_t *p_tcp);
-
-static void j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data);
-
-/**
- * Destroys a coding parameter structure.
- *
- * @param  p_cp    the coding parameter to destroy.
- */
-static void j2k_cp_destroy (opj_cp_t *p_cp);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-static void j2k_setup_encoding_validation (opj_j2k_t *p_j2k);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-static void j2k_setup_decoding_validation (opj_j2k_t *p_j2k);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-static void j2k_setup_end_compress (opj_j2k_t *p_j2k);
-
-/**
- * Creates a tile-coder decoder.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_create_tcd(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Excutes the given procedures on the given codec.
- *
- * @param  p_procedure_list  the list of procedures to execute
- * @param  p_j2k          the jpeg2000 codec to execute the procedures on.
- * @param  p_stream          the stream to execute the procedures on.
- * @param  p_manager      the user manager.
- *
- * @return  true        if all the procedures were successfully executed.
- */
-static bool j2k_exec (
-          opj_j2k_t * p_j2k,
-          opj_procedure_list_t * p_procedure_list,
-          opj_stream_private_t *p_stream,
-          opj_event_mgr_t * p_manager
-          );
-/**
- * Updates the rates of the tcp.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_update_rates(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * The default encoding validation procedure without any extension.
- *
- * @param  p_j2k      the jpeg2000 codec to validate.
- * @param  p_stream        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool j2k_encoding_validation (
-                opj_j2k_t * p_j2k,
-                opj_stream_private_t *p_stream,
-                opj_event_mgr_t * p_manager
-              );
-/**
- * The read header procedure.
- */
-bool j2k_read_header_procedure(
-                  opj_j2k_t *p_j2k,
-                struct opj_stream_private *p_stream,
-                struct opj_event_mgr * p_manager);
-
-/**
- * The default decoding validation procedure without any extension.
- *
- * @param  p_j2k      the jpeg2000 codec to validate.
- * @param  p_stream        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool j2k_decoding_validation (
-                opj_j2k_t * p_j2k,
-                opj_stream_private_t *p_stream,
-                opj_event_mgr_t * p_manager
-              );
-/**
- * Reads the tiles.
- */
-bool j2k_decode_tiles (
-                opj_j2k_t *p_j2k,
-                struct opj_stream_private *p_stream,
-                struct opj_event_mgr * p_manager);
-
-/**
- * The mct encoding validation procedure.
- *
- * @param  p_j2k      the jpeg2000 codec to validate.
- * @param  p_stream        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool j2k_mct_validation (
-                opj_j2k_t * p_j2k,
-                opj_stream_private_t *p_stream,
-                opj_event_mgr_t * p_manager
-              );
-/**
- * Builds the tcd decoder to use to decode tile.
- */
-bool j2k_build_decoder (
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            );
-/**
- * Builds the tcd encoder to use to encode tile.
- */
-bool j2k_build_encoder (
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            );
-/**
- * Copies the decoding tile parameters onto all the tile parameters.
- * Creates also the tile decoder.
- */
-bool j2k_copy_default_tcp_and_create_tcd(
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            );
-/**
- * Destroys the memory associated with the decoding of headers.
- */
-bool j2k_destroy_header_memory (
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            );
-
-/**
- * Sets up the procedures to do on writting header. Developpers wanting to extend the library can add their own writting procedures.
- */
-void j2k_setup_header_writting (opj_j2k_t *p_j2k);
-
-/**
- * Sets up the procedures to do on reading header. Developpers wanting to extend the library can add their own reading procedures.
- */
-void j2k_setup_header_reading (opj_j2k_t *p_j2k);
-
-/**
- * Writes a tile.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-static bool j2k_post_write_tile (
-           opj_j2k_t * p_j2k,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           opj_stream_private_t *p_stream,
-           opj_event_mgr_t * p_manager
-          );
-
-static bool j2k_pre_write_tile (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 p_tile_index,
-           opj_stream_private_t *p_stream,
-           opj_event_mgr_t * p_manager
-          );
-static bool j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data);
-
-static bool j2k_add_mct(opj_tcp_t * p_tcp,opj_image_t * p_image, OPJ_UINT32 p_index);
-/**
- * Gets the offset of the header.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-static bool j2k_get_end_header(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          );
-
-static void  j2k_read_int16_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_read_int32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_read_float32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_read_float64_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-static void  j2k_read_int16_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_read_int32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_read_float32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_read_float64_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-static void  j2k_write_float_to_int16 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_write_float_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_write_float_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-static void  j2k_write_float_to_float64 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-
-
-/****************************************************************************
- ********************* CONSTANTS ********************************************
- ****************************************************************************/
-
-
-
-
-/**
- * List of progression orders.
- */
-const j2k_prog_order_t j2k_prog_order_list [] =
-{
-  {CPRL, "CPRL"},
-  {LRCP, "LRCP"},
-  {PCRL, "PCRL"},
-  {RLCP, "RLCP"},
-  {RPCL, "RPCL"},
-  {(OPJ_PROG_ORDER)-1, ""}
-};
-
-const OPJ_UINT32 MCT_ELEMENT_SIZE [] =
-{
-  2,
-  4,
-  4,
-  8
-};
-
-typedef void (* j2k_mct_function) (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
-
-const j2k_mct_function j2k_mct_read_functions_to_float [] =
-{
-  j2k_read_int16_to_float,
-  j2k_read_int32_to_float,
-  j2k_read_float32_to_float,
-  j2k_read_float64_to_float
-};
-
-const j2k_mct_function j2k_mct_read_functions_to_int32 [] =
-{
-  j2k_read_int16_to_int32,
-  j2k_read_int32_to_int32,
-  j2k_read_float32_to_int32,
-  j2k_read_float64_to_int32
-};
-
-const j2k_mct_function j2k_mct_write_functions_from_float [] =
-{
-  j2k_write_float_to_int16,
-  j2k_write_float_to_int32,
-  j2k_write_float_to_float,
-  j2k_write_float_to_float64
-};
-
-
-
-
-/*const opj_dec_stream_marker_handler_t j2k_stream_marker_handler_tab[] =
-{
-  {J2K_MS_SOC, J2K_DEC_STATE_MHSOC, j2k_read_soc},
-  {J2K_MS_SOD, J2K_DEC_STATE_TPH, j2k_read_sod},
-  {J2K_MS_EOC, J2K_DEC_STATE_TPHSOT, j2k_read_eoc},
-  {J2K_MS_SOP, 0, 0},
-#ifdef USE_JPWL
-  {J2K_MS_EPC, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_epc},
-  {J2K_MS_EPB, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_epb},
-  {J2K_MS_ESD, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_esd},
-  {J2K_MS_RED, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_red},
-#endif
-#ifdef USE_JPSEC
-  {J2K_MS_SEC, J2K_DEC_STATE_MH, j2k_read_sec},
-  {J2K_MS_INSEC, 0, j2k_read_insec},
-#endif
-
-  {0, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_unk}
-};*/
-
-const opj_dec_memory_marker_handler_t j2k_memory_marker_handler_tab [] =
-{
-  {J2K_MS_SOT, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPHSOT, j2k_read_sot},
-  {J2K_MS_COD, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_cod},
-  {J2K_MS_COC, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_coc},
-  {J2K_MS_RGN, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_rgn},
-  {J2K_MS_QCD, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_qcd},
-  {J2K_MS_QCC, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_qcc},
-  {J2K_MS_POC, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_poc},
-  {J2K_MS_SIZ, J2K_DEC_STATE_MHSIZ , j2k_read_siz},
-  {J2K_MS_TLM, J2K_DEC_STATE_MH, j2k_read_tlm},
-  {J2K_MS_PLM, J2K_DEC_STATE_MH, j2k_read_plm},
-  {J2K_MS_PLT, J2K_DEC_STATE_TPH, j2k_read_plt},
-  {J2K_MS_PPM, J2K_DEC_STATE_MH, j2k_read_ppm},
-  {J2K_MS_PPT, J2K_DEC_STATE_TPH, j2k_read_ppt},
-  {J2K_MS_SOP, 0, 0},
-  {J2K_MS_CRG, J2K_DEC_STATE_MH, j2k_read_crg},
-  {J2K_MS_COM, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_com},
-  {J2K_MS_MCT, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_mct},
-  {J2K_MS_CBD, J2K_DEC_STATE_MH , j2k_read_cbd},
-  {J2K_MS_MCC, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_mcc},
-  {J2K_MS_MCO, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_mco},
-#ifdef USE_JPWL
-  {J2K_MS_EPC, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_epc},
-  {J2K_MS_EPB, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_epb},
-  {J2K_MS_ESD, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_esd},
-  {J2K_MS_RED, J2K_DEC_STATE_MH | J2K_DEC_STATE_TPH, j2k_read_red},
-#endif /* USE_JPWL */
-#ifdef USE_JPSEC
-  {J2K_MS_SEC, J2K_DEC_STATE_MH, j2k_read_sec},
-  {J2K_MS_INSEC, 0, j2k_read_insec}
-#endif /* USE_JPSEC */
-};
-
-void  j2k_read_int16_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_bytes(l_src_data,&l_temp,2);
-    l_src_data+=sizeof(OPJ_INT16);
-    *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
-  }
-}
-
-void  j2k_read_int32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_bytes(l_src_data,&l_temp,4);
-    l_src_data+=sizeof(OPJ_INT32);
-    *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
-  }
-}
-void  j2k_read_float32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_FLOAT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_float(l_src_data,&l_temp);
-    l_src_data+=sizeof(OPJ_FLOAT32);
-    *(l_dest_data++) = l_temp;
-  }
-}
-
-void  j2k_read_float64_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_FLOAT64 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_double(l_src_data,&l_temp);
-    l_src_data+=sizeof(OPJ_FLOAT64);
-    *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
-  }
-
-}
-
-void  j2k_read_int16_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_bytes(l_src_data,&l_temp,2);
-    l_src_data+=sizeof(OPJ_INT16);
-    *(l_dest_data++) = (OPJ_INT32) l_temp;
-  }
-}
-
-void  j2k_read_int32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_bytes(l_src_data,&l_temp,4);
-    l_src_data+=sizeof(OPJ_INT32);
-    *(l_dest_data++) = (OPJ_INT32) l_temp;
-  }
-}
-void  j2k_read_float32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_FLOAT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_float(l_src_data,&l_temp);
-    l_src_data+=sizeof(OPJ_FLOAT32);
-    *(l_dest_data++) = (OPJ_INT32) l_temp;
-  }
-}
-
-void  j2k_read_float64_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
-  OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
-  OPJ_UINT32 i;
-  OPJ_FLOAT64 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    opj_read_double(l_src_data,&l_temp);
-    l_src_data+=sizeof(OPJ_FLOAT64);
-    *(l_dest_data++) = (OPJ_INT32) l_temp;
-  }
-
-}
-
-void  j2k_write_float_to_int16 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
-  OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    l_temp = (OPJ_UINT32) *(l_src_data++);
-    opj_write_bytes(l_dest_data,l_temp,sizeof(OPJ_INT16));
-    l_dest_data+=sizeof(OPJ_INT16);
-  }
-}
-
-void  j2k_write_float_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
-  OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    l_temp = (OPJ_UINT32) *(l_src_data++);
-    opj_write_bytes(l_dest_data,l_temp,sizeof(OPJ_INT32));
-    l_dest_data+=sizeof(OPJ_INT32);
-  }
-}
-
-void  j2k_write_float_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
-  OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
-  OPJ_UINT32 i;
-  OPJ_FLOAT32 l_temp;
-
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    l_temp = (OPJ_FLOAT32) *(l_src_data++);
-    opj_write_float(l_dest_data,l_temp);
-    l_dest_data+=sizeof(OPJ_FLOAT32);
-  }
-
-}
-
-void  j2k_write_float_to_float64 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
-{
-  OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
-  OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
-  OPJ_UINT32 i;
-  OPJ_FLOAT64 l_temp;
-  for
-    (i=0;i<p_nb_elem;++i)
-  {
-    l_temp = (OPJ_FLOAT64) *(l_src_data++);
-    opj_write_double(l_dest_data,l_temp);
-    l_dest_data+=sizeof(OPJ_FLOAT64);
-  }
-}
-
-
-
-
-/**
- * Converts an enum type progression order to string type.
- *
- * @param prg_order    the progression order to get.
- *
- * @return  the string representation of the gicen progression order.
- */
-const OPJ_CHAR * j2k_convert_progression_order(OPJ_PROG_ORDER p_prg_order)
-{
-  const j2k_prog_order_t *po;
-  for
-    (po = j2k_prog_order_list; po->enum_prog != -1; ++po )
-  {
-    if
-      (po->enum_prog == p_prg_order)
-    {
-      return po->str_prog;
-    }
-  }
-  return po->str_prog;
-}
-
-
-
-
-
-
-
-/**
- * Checks the progression order changes values. Tells if the poc given as input are valid.
- *
- * @param  p_pocs        the progression order changes.
- * @param  p_nb_pocs      the number of progression order changes.
- * @param  p_nb_resolutions  the number of resolutions.
- * @param  numcomps      the number of components
- * @param  numlayers      the number of layers.
- * @param  p_manager      the user event manager.
- *
- * @return  true if the pocs are valid.
- */
-bool j2k_check_poc_val(const opj_poc_t *p_pocs, OPJ_UINT32 p_nb_pocs, OPJ_UINT32 p_nb_resolutions, OPJ_UINT32 p_num_comps, OPJ_UINT32 p_num_layers, opj_event_mgr_t * p_manager)
-{
-  OPJ_UINT32* packet_array;
-  OPJ_UINT32 index , resno, compno, layno;
-  OPJ_UINT32 i;
-  OPJ_UINT32 step_c = 1;
-  OPJ_UINT32 step_r = p_num_comps * step_c;
-  OPJ_UINT32 step_l = p_nb_resolutions * step_r;
-  bool loss = false;
-  OPJ_UINT32 layno0 = 0;
-
-  packet_array = (OPJ_UINT32*) opj_calloc(step_l * p_num_layers, sizeof(OPJ_UINT32));
-  if
-    (packet_array == 00)
-  {
-    opj_event_msg(p_manager , EVT_ERROR, "Not enough memory for checking the poc values.\n");
-    return false;
-  }
-  memset(packet_array,0,step_l * p_num_layers* sizeof(OPJ_UINT32));
-  if
-    (p_nb_pocs == 0)
-  {
-    return true;
-  }
-
-  index = step_r * p_pocs->resno0;
-  // take each resolution for each poc
-  for
-    (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno)
-  {
-    OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
-    // take each comp of each resolution for each poc
-    for
-      (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno)
-    {
-      OPJ_UINT32 comp_index = res_index + layno0 * step_l;
-      // and finally take each layer of each res of ...
-      for
-        (layno = layno0; layno < p_pocs->layno1 ; ++layno)
-      {
-        //index = step_r * resno + step_c * compno + step_l * layno;
-        packet_array[comp_index] = 1;
-        comp_index += step_l;
-      }
-      res_index += step_c;
-    }
-    index += step_r;
-  }
-  ++p_pocs;
-  // iterate through all the pocs
-  for
-    (i = 1; i < p_nb_pocs ; ++i)
-  {
-    OPJ_UINT32 l_last_layno1 = (p_pocs-1)->layno1 ;
-    layno0 = (p_pocs->layno1 > l_last_layno1)? l_last_layno1 : 0;
-    index = step_r * p_pocs->resno0;
-    // take each resolution for each poc
-    for
-      (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno)
-    {
-      OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
-      // take each comp of each resolution for each poc
-      for
-        (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno)
-      {
-        OPJ_UINT32 comp_index = res_index + layno0 * step_l;
-        // and finally take each layer of each res of ...
-        for
-          (layno = layno0; layno < p_pocs->layno1 ; ++layno)
-        {
-          //index = step_r * resno + step_c * compno + step_l * layno;
-          packet_array[comp_index] = 1;
-          comp_index += step_l;
-        }
-        res_index += step_c;
-      }
-      index += step_r;
-    }
-    ++p_pocs;
-  }
-
-  index = 0;
-  for
-    (layno = 0; layno < p_num_layers ; ++layno)
-  {
-    for
-      (resno = 0; resno < p_nb_resolutions; ++resno)
-    {
-      for
-        (compno = 0; compno < p_num_comps; ++compno)
-      {
-        loss |= (packet_array[index]!=1);
-        //index = step_r * resno + step_c * compno + step_l * layno;
-        index += step_c;
-      }
-    }
-  }
-  if
-    (loss)
-  {
-    opj_event_msg(p_manager , EVT_ERROR, "Missing packets possible loss of data\n");
-  }
-  opj_free(packet_array);
-  return !loss;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-/**
- * Gets the number of tile parts used for the given change of progression (if any) and the given tile.
- *
- * @param    cp      the coding parameters.
- * @param    pino    the offset of the given poc (i.e. its position in the coding parameter).
- * @param    tileno    the given tile.
- *
- * @return    the number of tile parts.
- */
-OPJ_UINT32 j2k_get_num_tp(opj_cp_t *cp,OPJ_UINT32 pino,OPJ_UINT32 tileno)
-{
-  const OPJ_CHAR *prog = 00;
-  OPJ_UINT32 i;
-  OPJ_UINT32 tpnum = 1;
-  opj_tcp_t *tcp = 00;
-  opj_poc_t * l_current_poc = 00;
-
-  // preconditions only in debug
-  assert(tileno < (cp->tw * cp->th));
-  assert(pino < (cp->tcps[tileno].numpocs + 1));
-
-  // get the given tile coding parameter
-  tcp = &cp->tcps[tileno];
-  assert(tcp != 00);
-  l_current_poc = &(tcp->pocs[pino]);
-  assert(l_current_poc != 0);
-
-  // get the progression order as a character string
-  prog = j2k_convert_progression_order(tcp->prg);
-  assert(strlen(prog) > 0);
-
-  if
-    (cp->m_specific_param.m_enc.m_tp_on == 1)
-  {
-    for
-      (i=0;i<4;++i)
-    {
-      switch
-        (prog[i])
-      {
-        // component wise
-        case 'C':
-          tpnum *= l_current_poc->compE;
-          break;
-        // resolution wise
-        case 'R':
-          tpnum *= l_current_poc->resE;
-          break;
-        // precinct wise
-        case 'P':
-          tpnum *= l_current_poc->prcE;
-          break;
-        // layer wise
-        case 'L':
-          tpnum *= l_current_poc->layE;
-          break;
-      }
-      // whould we split here ?
-      if
-        ( cp->m_specific_param.m_enc.m_tp_flag == prog[i] )
-      {
-        cp->m_specific_param.m_enc.m_tp_pos=i;
-        break;
-      }
-    }
-  }
-  else
-  {
-    tpnum=1;
-  }
-  return tpnum;
-}
-
-/**
- * Calculates the total number of tile parts needed by the encoder to
- * encode such an image. If not enough memory is available, then the function return false.
- *
- * @param  p_nb_tiles  pointer that will hold the number of tile parts.
- * @param  cp      the coding parameters for the image.
- * @param  image    the image to encode.
- * @param  p_j2k      the p_j2k encoder.
- * @param  p_manager  the user event manager.
- *
- * @return true if the function was successful, false else.
- */
-bool j2k_calculate_tp(
-            opj_j2k_t *p_j2k,
-            opj_cp_t *cp,
-            OPJ_UINT32 * p_nb_tiles,
-            opj_image_t *image,
-            opj_event_mgr_t * p_manager)
-{
-  OPJ_UINT32 pino,tileno;
-  OPJ_UINT32 l_nb_tiles;
-  opj_tcp_t *tcp;
-
-  // preconditions
-  assert(p_nb_tiles != 00);
-  assert(cp != 00);
-  assert(image != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_nb_tiles = cp->tw * cp->th;
-  * p_nb_tiles = 0;
-  tcp = cp->tcps;
-
-  /* INDEX >> */
-  if
-    (p_j2k->cstr_info)
-  {
-    opj_tile_info_t * l_info_tile_ptr = p_j2k->cstr_info->tile;
-    for
-      (tileno = 0; tileno < l_nb_tiles; ++tileno)
-    {
-      OPJ_UINT32 cur_totnum_tp = 0;
-      pi_update_encoding_parameters(image,cp,tileno);
-      for
-        (pino = 0; pino <= tcp->numpocs; ++pino)
-      {
-        OPJ_UINT32 tp_num = j2k_get_num_tp(cp,pino,tileno);
-        *p_nb_tiles = *p_nb_tiles + tp_num;
-        cur_totnum_tp += tp_num;
-      }
-      tcp->m_nb_tile_parts = cur_totnum_tp;
-      l_info_tile_ptr->tp = (opj_tp_info_t *) opj_malloc(cur_totnum_tp * sizeof(opj_tp_info_t));
-      if
-        (l_info_tile_ptr->tp == 00)
-      {
-        return false;
-      }
-      memset(l_info_tile_ptr->tp,0,cur_totnum_tp * sizeof(opj_tp_info_t));
-      l_info_tile_ptr->num_tps = cur_totnum_tp;
-      ++l_info_tile_ptr;
-      ++tcp;
-    }
-  }
-  else
-  {
-    for
-      (tileno = 0; tileno < l_nb_tiles; ++tileno)
-    {
-      OPJ_UINT32 cur_totnum_tp = 0;
-      pi_update_encoding_parameters(image,cp,tileno);
-      for
-        (pino = 0; pino <= tcp->numpocs; ++pino)
-      {
-        OPJ_UINT32 tp_num=0;
-        tp_num = j2k_get_num_tp(cp,pino,tileno);
-        *p_nb_tiles = *p_nb_tiles + tp_num;
-        cur_totnum_tp += tp_num;
-      }
-      tcp->m_nb_tile_parts = cur_totnum_tp;
-      ++tcp;
-    }
-  }
-  return true;
-}
-
-/**
- * Writes the SOC marker (Start Of Codestream)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-
-bool j2k_write_soc(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-                )
-{
-  /* 2 bytes will be written */
-  OPJ_BYTE * l_start_stream = 00;
-
-  // preconditions
-  assert(p_stream != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_start_stream = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-  /* write SOC identifier */
-  opj_write_bytes(l_start_stream,J2K_MS_SOC,2);
-  if
-    (opj_stream_write_data(p_stream,l_start_stream,2,p_manager) != 2)
-  {
-    return false;
-  }
-/* UniPG>> */
-#ifdef USE_JPWL
-  /* update markers struct */
-  j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOC, p_stream_tell(p_stream) - 2, 2);
-#endif /* USE_JPWL */
-  return true;
-/* <<UniPG */
-}
-
-/**
- * Reads a SOC marker (Start of Codestream)
- * @param  p_header_data  the data contained in the SOC box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the SOC marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_soc(
-          opj_j2k_t *p_j2k,
-          struct opj_stream_private *p_stream,
-          struct opj_event_mgr * p_manager
-         )
-
-{
-  OPJ_BYTE l_data [2];
-  OPJ_UINT32 l_marker;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-  if
-    (opj_stream_read_data(p_stream,l_data,2,p_manager) != 2)
-  {
-    return false;
-  }
-  opj_read_bytes(l_data,&l_marker,2);
-  if
-    (l_marker != J2K_MS_SOC)
-  {
-    return false;
-  }
-  /* assure length of data is correct (0) */
-  p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_MHSIZ;
-  /* Index */
-  if
-    (p_j2k->cstr_info)
-  {
-    //TODO p_j2k->cstr_info->main_head_start = opj_stream_tell(p_stream) - 2; // why - 2 ?
-    p_j2k->cstr_info->codestream_size = 0;/*p_stream_numbytesleft(p_j2k->p_stream) + 2 - p_j2k->cstr_info->main_head_start*/;
-  }
-  return true;
-}
-
-/**
- * Writes the SIZ marker (image and tile size)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-bool j2k_write_siz(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_size_len;
-  OPJ_BYTE * l_current_ptr;
-  opj_image_t * l_image = 00;
-  opj_cp_t *cp = 00;
-  opj_image_comp_t * l_img_comp = 00;
-
-  // preconditions
-  assert(p_stream != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_image = p_j2k->m_image;
-  cp = &(p_j2k->m_cp);
-  l_size_len = 40 + 3 * l_image->numcomps;
-  l_img_comp = l_image->comps;
-
-  if
-    (l_size_len > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_size_len);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_size_len;
-  }
-
-  l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-  /* write SOC identifier */
-  opj_write_bytes(l_current_ptr,J2K_MS_SIZ,2);  /* SIZ */
-  l_current_ptr+=2;
-  opj_write_bytes(l_current_ptr,l_size_len-2,2); /* L_SIZ */
-  l_current_ptr+=2;
-  opj_write_bytes(l_current_ptr, cp->rsiz, 2);  /* Rsiz (capabilities) */
-  l_current_ptr+=2;
-  opj_write_bytes(l_current_ptr, l_image->x1, 4);  /* Xsiz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, l_image->y1, 4);  /* Ysiz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, l_image->x0, 4);  /* X0siz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, l_image->y0, 4);  /* Y0siz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, cp->tdx, 4);    /* XTsiz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, cp->tdy, 4);    /* YTsiz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, cp->tx0, 4);    /* XT0siz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, cp->ty0, 4);    /* YT0siz */
-  l_current_ptr+=4;
-  opj_write_bytes(l_current_ptr, l_image->numcomps, 2);  /* Csiz */
-  l_current_ptr+=2;
-  for
-    (i = 0; i < l_image->numcomps; ++i)
-  {
-    // TODO here with MCT ?
-    opj_write_bytes(l_current_ptr, l_img_comp->prec - 1 + (l_img_comp->sgnd << 7), 1);  /* Ssiz_i */
-    ++l_current_ptr;
-    opj_write_bytes(l_current_ptr, l_img_comp->dx, 1);  /* XRsiz_i */
-    ++l_current_ptr;
-    opj_write_bytes(l_current_ptr, l_img_comp->dy, 1);  /* YRsiz_i */
-    ++l_current_ptr;
-    ++l_img_comp;
-  }
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_size_len,p_manager) != l_size_len)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a SIZ marker (image and tile size)
- * @param  p_header_data  the data contained in the SIZ box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the SIZ marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_siz (
-            opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_size, i;
-  OPJ_UINT32 l_nb_comp;
-  OPJ_UINT32 l_nb_comp_remain;
-  OPJ_UINT32 l_remaining_size;
-  OPJ_UINT32 l_nb_tiles;
-  OPJ_UINT32 l_tmp;
-  opj_image_t *l_image = 00;
-  opj_cp_t *l_cp = 00;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcp_t * l_current_tile_param = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_header_data != 00);
-
-  l_image = p_j2k->m_image;
-  l_cp = &(p_j2k->m_cp);
-  if
-    (p_header_size < 36)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\n");
-    return false;
-  }
-  l_remaining_size = p_header_size - 36;
-
-  l_nb_comp = l_remaining_size / 3;
-  l_nb_comp_remain = l_remaining_size % 3;
-  if
-    (l_nb_comp_remain != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\n");
-    return false;
-  }
-  l_size = p_header_size + 2;      /* Lsiz */
-
-  opj_read_bytes(p_header_data,&l_tmp ,2);      /* Rsiz (capabilities) */
-  p_header_data+=2;
-  l_cp->rsiz = (OPJ_RSIZ_CAPABILITIES) l_tmp;
-  opj_read_bytes(p_header_data,(OPJ_UINT32 *) (&l_image->x1) ,4);      /* Xsiz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data,(OPJ_UINT32*) (&l_image->y1),4);        /* Ysiz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data,(OPJ_UINT32*) &l_image->x0,4);        /* X0siz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data,(OPJ_UINT32*) &l_image->y0,4);        /* Y0siz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data, (&l_cp->tdx),4);        /* XTsiz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data,&l_cp->tdy,4);        /* YTsiz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data,(OPJ_UINT32 *) (&l_cp->tx0),4);        /* XT0siz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data,(OPJ_UINT32 *) (&l_cp->ty0),4);        /* YT0siz */
-  p_header_data+=4;
-  opj_read_bytes(p_header_data,(&l_image->numcomps),2);        /* Csiz */
-  p_header_data+=2;
-  if
-    (l_image->numcomps != l_nb_comp)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\n");
-    return false;
-  }
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-    /* if JPWL is on, we check whether TX errors have damaged
-      too much the SIZ parameters */
-    if (!(image->x1 * image->y1)) {
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "JPWL: bad image size (%d x %d)\n",
-        image->x1, image->y1);
-      if (!JPWL_ASSUME || JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-    }
-    if (image->numcomps != ((len - 38) / 3)) {
-      opj_event_msg(p_j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-        "JPWL: Csiz is %d => space in SIZ only for %d comps.!!!\n",
-        image->numcomps, ((len - 38) / 3));
-      if (!JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-      /* we try to correct */
-      opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- trying to adjust this\n");
-      if (image->numcomps < ((len - 38) / 3)) {
-        len = 38 + 3 * image->numcomps;
-        opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- setting Lsiz to %d => HYPOTHESIS!!!\n",
-          len);
-      } else {
-        image->numcomps = ((len - 38) / 3);
-        opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- setting Csiz to %d => HYPOTHESIS!!!\n",
-          image->numcomps);
-      }
-    }
-
-    /* update components number in the jpwl_exp_comps filed */
-    cp->exp_comps = image->numcomps;
-  }
-#endif /* USE_JPWL */
-
-  l_image->comps = (opj_image_comp_t*) opj_calloc(l_image->numcomps, sizeof(opj_image_comp_t));
-  if
-    (l_image->comps == 00)
-  {
-    l_image->numcomps = 0;
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
-    return false;
-  }
-  memset(l_image->comps,0,l_image->numcomps * sizeof(opj_image_comp_t));
-  l_img_comp = l_image->comps;
-  for
-    (i = 0; i < l_image->numcomps; ++i)
-  {
-    OPJ_UINT32 tmp;
-    opj_read_bytes(p_header_data,&tmp,1);        /* Ssiz_i */
-    ++p_header_data;
-    l_img_comp->prec = (tmp & 0x7f) + 1;
-    l_img_comp->sgnd = tmp >> 7;
-    opj_read_bytes(p_header_data,&l_img_comp->dx,1);        /* XRsiz_i */
-    ++p_header_data;
-    opj_read_bytes(p_header_data,&l_img_comp->dy,1);        /* YRsiz_i */
-    ++p_header_data;
-#ifdef USE_JPWL
-    if (p_j2k->m_cp->correct) {
-    /* if JPWL is on, we check whether TX errors have damaged
-      too much the SIZ parameters, again */
-      if (!(image->comps[i].dx * image->comps[i].dy)) {
-        opj_event_msg(p_j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-          "JPWL: bad XRsiz_%d/YRsiz_%d (%d x %d)\n",
-          i, i, image->comps[i].dx, image->comps[i].dy);
-        if (!JPWL_ASSUME) {
-          opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-          return;
-        }
-        /* we try to correct */
-        opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- trying to adjust them\n");
-        if (!image->comps[i].dx) {
-          image->comps[i].dx = 1;
-          opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- setting XRsiz_%d to %d => HYPOTHESIS!!!\n",
-            i, image->comps[i].dx);
-        }
-        if (!image->comps[i].dy) {
-          image->comps[i].dy = 1;
-          opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- setting YRsiz_%d to %d => HYPOTHESIS!!!\n",
-            i, image->comps[i].dy);
-        }
-      }
-
-    }
-#endif /* USE_JPWL */
-    l_img_comp->resno_decoded = 0;  /* number of resolution decoded */
-    l_img_comp->factor = l_cp->m_specific_param.m_dec.m_reduce; /* reducing factor per component */
-    ++l_img_comp;
-  }
-
-  l_cp->tw = int_ceildiv(l_image->x1 - l_cp->tx0, l_cp->tdx);
-  l_cp->th = int_ceildiv(l_image->y1 - l_cp->ty0, l_cp->tdy);
-  l_nb_tiles = l_cp->tw * l_cp->th;
-  if
-    (p_j2k->m_specific_param.m_decoder.m_discard_tiles)
-  {
-    p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_j2k->m_specific_param.m_decoder.m_start_tile_x - l_cp->tx0) / l_cp->tdx;
-    p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) / l_cp->tdy;
-    p_j2k->m_specific_param.m_decoder.m_end_tile_x = int_ceildiv((p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0), l_cp->tdx);
-    p_j2k->m_specific_param.m_decoder.m_end_tile_y = int_ceildiv((p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0), l_cp->tdy);
-  }
-  else
-  {
-    p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
-    p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
-    p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
-    p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
-  }
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-    /* if JPWL is on, we check whether TX errors have damaged
-      too much the SIZ parameters */
-    if ((cp->tw < 1) || (cp->th < 1) || (cp->tw > cp->max_tiles) || (cp->th > cp->max_tiles)) {
-      opj_event_msg(p_j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-        "JPWL: bad number of tiles (%d x %d)\n",
-        cp->tw, cp->th);
-      if (!JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-      /* we try to correct */
-      opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- trying to adjust them\n");
-      if (cp->tw < 1) {
-        cp->tw= 1;
-        opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- setting %d tiles in x => HYPOTHESIS!!!\n",
-          cp->tw);
-      }
-      if (cp->tw > cp->max_tiles) {
-        cp->tw= 1;
-        opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- too large x, increase expectance of %d\n"
-          "- setting %d tiles in x => HYPOTHESIS!!!\n",
-          cp->max_tiles, cp->tw);
-      }
-      if (cp->th < 1) {
-        cp->th= 1;
-        opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- setting %d tiles in y => HYPOTHESIS!!!\n",
-          cp->th);
-      }
-      if (cp->th > cp->max_tiles) {
-        cp->th= 1;
-        opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- too large y, increase expectance of %d to continue\n",
-          "- setting %d tiles in y => HYPOTHESIS!!!\n",
-          cp->max_tiles, cp->th);
-      }
-    }
-  }
-#endif /* USE_JPWL */
-  /* memory allocations */
-  l_cp->tcps = (opj_tcp_t*) opj_calloc(l_nb_tiles, sizeof(opj_tcp_t));
-  if
-    (l_cp->tcps == 00)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
-    return false;
-  }
-  memset(l_cp->tcps,0,l_nb_tiles*sizeof(opj_tcp_t));
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-    if (!cp->tcps) {
-      opj_event_msg(p_j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-        "JPWL: could not alloc tcps field of cp\n");
-      if (!JPWL_ASSUME || JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-    }
-  }
-#endif /* USE_JPWL */
-
-  p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps = (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_tccp_t));
-  if
-    (p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps  == 00)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
-    return false;
-  }
-  memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps ,0,l_image->numcomps*sizeof(opj_tccp_t));
-
-  p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records =
-  (opj_mct_data_t*)opj_malloc(J2K_MCT_DEFAULT_NB_RECORDS * sizeof(opj_mct_data_t));
-  if
-    (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
-    return false;
-  }
-  memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records,0,J2K_MCT_DEFAULT_NB_RECORDS * sizeof(opj_mct_data_t));
-  p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records = J2K_MCT_DEFAULT_NB_RECORDS;
-
-  p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records =
-  (opj_simple_mcc_decorrelation_data_t*)
-  opj_malloc(J2K_MCC_DEFAULT_NB_RECORDS * sizeof(opj_simple_mcc_decorrelation_data_t));
-  if
-    (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
-    return false;
-  }
-  memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records,0,J2K_MCC_DEFAULT_NB_RECORDS * sizeof(opj_simple_mcc_decorrelation_data_t));
-  p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records = J2K_MCC_DEFAULT_NB_RECORDS;
-
-  /* set up default dc level shift */
-  for
-    (i=0;i<l_image->numcomps;++i)
-  {
-    if
-      (! l_image->comps[i].sgnd)
-    {
-      p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1 << (l_image->comps[i].prec - 1);
-    }
-  }
-
-  l_current_tile_param = l_cp->tcps;
-  for
-    (i = 0; i < l_nb_tiles; ++i)
-  {
-    l_current_tile_param->tccps = (opj_tccp_t*) opj_malloc(l_image->numcomps * sizeof(opj_tccp_t));
-    if
-      (l_current_tile_param->tccps == 00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
-      return false;
-    }
-    memset(l_current_tile_param->tccps,0,l_image->numcomps * sizeof(opj_tccp_t));
-
-    ++l_current_tile_param;
-
-  }
-  p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_MH;
-  opj_image_comp_update(l_image,l_cp);
-
-  /* Index */
-  if
-    (p_j2k->cstr_info)
-  {
-    opj_codestream_info_t *cstr_info = p_j2k->cstr_info;
-    cstr_info->image_w = l_image->x1 - l_image->x0;
-    cstr_info->image_h = l_image->y1 - l_image->y0;
-    cstr_info->numcomps = l_image->numcomps;
-    cstr_info->tw = l_cp->tw;
-    cstr_info->th = l_cp->th;
-    cstr_info->tile_x = l_cp->tdx;
-    cstr_info->tile_y = l_cp->tdy;
-    cstr_info->tile_Ox = l_cp->tx0;
-    cstr_info->tile_Oy = l_cp->ty0;
-    cstr_info->tile = (opj_tile_info_t*) opj_calloc(l_nb_tiles, sizeof(opj_tile_info_t));
-    if
-      (cstr_info->tile == 00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
-      return false;
-    }
-    memset(cstr_info->tile,0,l_nb_tiles * sizeof(opj_tile_info_t));
-  }
-  return true;
-}
-
-/**
- * Writes the COM marker (comment)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-bool j2k_write_com(
-            opj_j2k_t *p_j2k,
-          struct opj_stream_private *p_stream,
-          struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_comment_size;
-  OPJ_UINT32 l_total_com_size;
-  const OPJ_CHAR *l_comment;
-  OPJ_BYTE * l_current_ptr = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  l_comment = p_j2k->m_cp.comment;
-  l_comment_size = strlen(l_comment);
-  l_total_com_size = l_comment_size + 6;
-
-  if
-    (l_total_com_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_total_com_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_total_com_size;
-  }
-  l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-  opj_write_bytes(l_current_ptr,J2K_MS_COM , 2);  /* COM */
-  l_current_ptr+=2;
-  opj_write_bytes(l_current_ptr,l_total_com_size - 2 , 2);  /* L_COM */
-  l_current_ptr+=2;
-  opj_write_bytes(l_current_ptr,1 , 2);  /* General use (IS 8859-15:1999 (Latin) values) */
-  l_current_ptr+=2,
-  memcpy(  l_current_ptr,l_comment,l_comment_size);
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_total_com_size,p_manager) != l_total_com_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a COM marker (comments)
- * @param  p_header_data  the data contained in the COM box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the COM marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_com (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_header_data != 00);
-  return true;
-}
-
-/**
- * Gets the size taken by writting a SPCod or SPCoc for the given tile and component.
- *
- * @param  p_tile_no    the tile indix.
- * @param  p_comp_no    the component being outputted.
- * @param  p_j2k      the J2K codec.
- *
- * @return  the number of bytes taken by the SPCod element.
- */
-OPJ_UINT32 j2k_get_SPCod_SPCoc_size (
-            opj_j2k_t *p_j2k,
-            OPJ_UINT32 p_tile_no,
-            OPJ_UINT32 p_comp_no
-            )
-{
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_tile_no];
-  l_tccp = &l_tcp->tccps[p_comp_no];
-
-  // preconditions again
-  assert(p_tile_no < (l_cp->tw * l_cp->th));
-  assert(p_comp_no < p_j2k->m_image->numcomps);
-
-  if
-    (l_tccp->csty & J2K_CCP_CSTY_PRT)
-  {
-    return 5 + l_tccp->numresolutions;
-  }
-  else
-  {
-    return 5;
-  }
-}
-
-
-/**
- * Writes a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
- *
- * @param  p_comp_no  the component number to output.
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
- *
-*/
-bool j2k_write_SPCod_SPCoc(
-                opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_tile_no,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_header_size != 00);
-  assert(p_manager != 00);
-  assert(p_data != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_tile_no];
-  l_tccp = &l_tcp->tccps[p_comp_no];
-
-  // preconditions again
-  assert(p_tile_no < (l_cp->tw * l_cp->th));
-  assert(p_comp_no <(p_j2k->m_image->numcomps));
-
-  if
-    (*p_header_size < 5)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error writting SPCod SPCoc element\n");
-    return false;
-  }
-
-  opj_write_bytes(p_data,l_tccp->numresolutions - 1, 1);  /* SPcoc (D) */
-  ++p_data;
-  opj_write_bytes(p_data,l_tccp->cblkw - 2, 1);        /* SPcoc (E) */
-  ++p_data;
-  opj_write_bytes(p_data,l_tccp->cblkh - 2, 1);        /* SPcoc (F) */
-  ++p_data;
-  opj_write_bytes(p_data,l_tccp->cblksty, 1);        /* SPcoc (G) */
-  ++p_data;
-  opj_write_bytes(p_data,l_tccp->qmfbid, 1);        /* SPcoc (H) */
-  ++p_data;
-
-  *p_header_size = *p_header_size - 5;
-  if
-    (l_tccp->csty & J2K_CCP_CSTY_PRT)
-  {
-    if
-      (*p_header_size < l_tccp->numresolutions)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error writting SPCod SPCoc element\n");
-      return false;
-    }
-    for
-      (i = 0; i < l_tccp->numresolutions; ++i)
-    {
-      opj_write_bytes(p_data,l_tccp->prcw[i] + (l_tccp->prch[i] << 4), 1);        /* SPcoc (I_i) */
-      ++p_data;
-    }
-    *p_header_size = *p_header_size - l_tccp->numresolutions;
-
-  }
-  return true;
-}
-
-
-/**
- * Reads a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
- * @param  p_header_data  the data contained in the COM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the COM marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_SPCod_SPCoc(
-                opj_j2k_t *p_j2k,
-              OPJ_UINT32 compno,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-              )
-{
-  // loop
-  OPJ_UINT32 i;
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-  OPJ_BYTE * l_current_ptr = 00;
-  OPJ_UINT32 l_tmp;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_header_data != 00);
-
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
-  // precondition again
-  assert(compno < p_j2k->m_image->numcomps);
-  l_tccp = &l_tcp->tccps[compno];
-  l_current_ptr = p_header_data;
-
-
-  // make sure room is sufficient
-  if
-    (* p_header_size < 5)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element\n");
-    return false;
-  }
-  opj_read_bytes(l_current_ptr, &l_tccp->numresolutions ,1);    /* SPcox (D) */
-  ++l_tccp->numresolutions;                    /* tccp->numresolutions = read() + 1 */
-  ++l_current_ptr;
-
-  // If user wants to remove more resolutions than the codestream contains, return error
-  if
-    (l_cp->m_specific_param.m_dec.m_reduce >= l_tccp->numresolutions)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number "
-          "of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
-    p_j2k->m_specific_param.m_decoder.m_state |= J2K_DEC_STATE_ERR;
-    return false;
-  }
-
-  opj_read_bytes(l_current_ptr,&l_tccp->cblkw ,1);    /* SPcoc (E) */
-  ++l_current_ptr;
-  l_tccp->cblkw += 2;
-
-  opj_read_bytes(l_current_ptr,&l_tccp->cblkh ,1);    /* SPcoc (F) */
-  ++l_current_ptr;
-  l_tccp->cblkh += 2;
-
-  opj_read_bytes(l_current_ptr,&l_tccp->cblksty ,1);    /* SPcoc (G) */
-  ++l_current_ptr;
-
-  opj_read_bytes(l_current_ptr,&l_tccp->qmfbid ,1);    /* SPcoc (H) */
-  ++l_current_ptr;
-
-  * p_header_size = * p_header_size - 5;
-
-  // use custom precinct size ?
-  if
-    (l_tccp->csty & J2K_CCP_CSTY_PRT)
-  {
-    if
-      (* p_header_size < l_tccp->numresolutions)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element\n");
-      return false;
-    }
-    for
-      (i = 0; i < l_tccp->numresolutions; ++i)
-    {
-      opj_read_bytes(l_current_ptr,&l_tmp ,1);    /* SPcoc (I_i) */
-      ++l_current_ptr;
-      l_tccp->prcw[i] = l_tmp & 0xf;
-      l_tccp->prch[i] = l_tmp >> 4;
-    }
-    * p_header_size = * p_header_size - l_tccp->numresolutions;
-  }
-  else
-  {
-    /* set default size for the precinct width and height */
-    for
-      (i = 0; i < l_tccp->numresolutions; ++i)
-    {
-      l_tccp->prcw[i] = 15;
-      l_tccp->prch[i] = 15;
-    }
-  }
-
-  /* INDEX >> */
-  if
-    (p_j2k->cstr_info && compno == 0)
-  {
-    OPJ_UINT32 l_data_size = l_tccp->numresolutions * sizeof(OPJ_UINT32);
-    memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdx,l_tccp->prcw, l_data_size);
-    memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdy,l_tccp->prch, l_data_size);
-  }
-  /* << INDEX */
-  return true;
-}
-
-/**
- * Copies the tile component parameters of all the component from the first tile component.
- *
- * @param    p_j2k    the J2k codec.
- */
-void j2k_copy_tile_component_parameters(
-              opj_j2k_t *p_j2k
-              )
-{
-  // loop
-  OPJ_UINT32 i;
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_ref_tccp = 00;
-  opj_tccp_t *l_copied_tccp = 00;
-  OPJ_UINT32 l_prc_size;
-  // preconditions
-  assert(p_j2k != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
-  l_ref_tccp = &l_tcp->tccps[0];
-  l_copied_tccp = l_ref_tccp + 1;
-  l_prc_size = l_ref_tccp->numresolutions * sizeof(OPJ_UINT32);
-
-  for
-    (i=1;i<p_j2k->m_image->numcomps;++i)
-  {
-    l_copied_tccp->numresolutions = l_ref_tccp->numresolutions;
-    l_copied_tccp->cblkw = l_ref_tccp->cblkw;
-    l_copied_tccp->cblkh = l_ref_tccp->cblkh;
-    l_copied_tccp->cblksty = l_ref_tccp->cblksty;
-    l_copied_tccp->qmfbid = l_ref_tccp->qmfbid;
-    memcpy(l_copied_tccp->prcw,l_ref_tccp->prcw,l_prc_size);
-    memcpy(l_copied_tccp->prch,l_ref_tccp->prch,l_prc_size);
-    ++l_copied_tccp;
-  }
-}
-
-
-
-/**
- * Writes the COD marker (Coding style default)
- *
- * @param  p_stream      the stream to write data to.
- * @param  p_j2k      J2K codec.
- * @param  p_manager  the user event manager.
-*/
-bool j2k_write_cod(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-            )
-{
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  OPJ_UINT32 l_code_size,l_remaining_size;
-  OPJ_BYTE * l_current_data = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
-  l_code_size = 9 + j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,0);
-  l_remaining_size = l_code_size;
-
-  if
-    (l_code_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_code_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_code_size;
-  }
-
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-  opj_write_bytes(l_current_data,J2K_MS_COD,2);    /* COD */
-  l_current_data += 2;
-
-  opj_write_bytes(l_current_data,l_code_size-2,2);    /* L_COD */
-  l_current_data += 2;
-
-  opj_write_bytes(l_current_data,l_tcp->csty,1);    /* Scod */
-  ++l_current_data;
-
-  opj_write_bytes(l_current_data,l_tcp->prg,1);    /* SGcod (A) */
-  ++l_current_data;
-
-  opj_write_bytes(l_current_data,l_tcp->numlayers,2);    /* SGcod (B) */
-  l_current_data+=2;
-
-  opj_write_bytes(l_current_data,l_tcp->mct,1);    /* SGcod (C) */
-  ++l_current_data;
-
-  l_remaining_size -= 9;
-
-  if
-    (! j2k_write_SPCod_SPCoc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_size,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error writting COD marker\n");
-    return false;
-  }
-  if
-    (l_remaining_size != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error writting COD marker\n");
-    return false;
-  }
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_code_size,p_manager) != l_code_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a COD marker (Coding Styke defaults)
- * @param  p_header_data  the data contained in the COD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the COD marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_cod (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          )
-{
-  // loop
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_tmp;
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_image_t *l_image = 00;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-  l_image = p_j2k->m_image;
-
-  // make sure room is sufficient
-  if
-    (p_header_size < 5)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
-    return false;
-  }
-
-  opj_read_bytes(p_header_data,&l_tcp->csty,1);      /* Scod */
-  ++p_header_data;
-  opj_read_bytes(p_header_data,&l_tmp,1);      /* SGcod (A) */
-  ++p_header_data;
-  l_tcp->prg = (OPJ_PROG_ORDER) l_tmp;
-  opj_read_bytes(p_header_data,&l_tcp->numlayers,2);  /* SGcod (B) */
-  p_header_data+=2;
-  if
-    (l_cp->m_specific_param.m_dec.m_layer)
-  {
-    l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_layer;
-  }
-  else
-  {
-    l_tcp->num_layers_to_decode = l_tcp->numlayers;
-  }
-
-  opj_read_bytes(p_header_data,&l_tcp->mct,1);      /* SGcod (C) */
-  ++p_header_data;
-
-  p_header_size -= 5;
-  for
-    (i = 0; i < l_image->numcomps; ++i)
-  {
-    l_tcp->tccps[i].csty = l_tcp->csty & J2K_CCP_CSTY_PRT;
-  }
-
-  if
-    (! j2k_read_SPCod_SPCoc(p_j2k,0,p_header_data,&p_header_size,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
-    return false;
-  }
-  if
-    (p_header_size != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
-    return false;
-  }
-  j2k_copy_tile_component_parameters(p_j2k);
-
-
-  /* Index */
-  if
-    (p_j2k->cstr_info)
-  {
-    opj_codestream_info_t *l_cstr_info = p_j2k->cstr_info;
-    l_cstr_info->prog = l_tcp->prg;
-    l_cstr_info->numlayers = l_tcp->numlayers;
-    l_cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32));
-    for
-      (i = 0; i < l_image->numcomps; ++i)
-    {
-      l_cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1;
-    }
-  }
-  return true;
-}
-
-/**
- * Writes the COC marker (Coding style component)
- *
- * @param  p_comp_no    the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_coc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-            )
-{
-  OPJ_UINT32 l_coc_size,l_remaining_size;
-  OPJ_UINT32 l_comp_room;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_comp_room = (p_j2k->m_image->numcomps <= 256) ? 1 : 2;
-
-  l_coc_size = 5 + l_comp_room + j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
-  if
-    (l_coc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_coc_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_coc_size;
-  }
-
-  j2k_write_coc_in_memory(p_j2k,p_comp_no,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&l_remaining_size,p_manager);
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_coc_size,p_manager) != l_coc_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Gets the maximum size taken by a coc.
- *
- * @param  p_j2k  the jpeg2000 codec to use.
- */
-OPJ_UINT32 j2k_get_max_coc_size(opj_j2k_t *p_j2k)
-{
-  OPJ_UINT32 i,j;
-  OPJ_UINT32 l_nb_comp;
-  OPJ_UINT32 l_nb_tiles;
-  OPJ_UINT32 l_max = 0;
-
-  // preconditions
-
-  l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;
-  l_nb_comp = p_j2k->m_image->numcomps;
-
-  for
-    (i=0;i<l_nb_tiles;++i)
-  {
-    for
-      (j=0;j<l_nb_comp;++j)
-    {
-      l_max = uint_max(l_max,j2k_get_SPCod_SPCoc_size(p_j2k,i,j));
-    }
-  }
-  return 6 + l_max;
-}
-
-/**
- * Gets the maximum size taken by the toc headers of all the tile parts of any given tile.
- */
-OPJ_UINT32 j2k_get_max_toc_size (opj_j2k_t *p_j2k)
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_nb_tiles;
-  OPJ_UINT32 l_max = 0;
-  opj_tcp_t * l_tcp = 00;
-  // preconditions
-
-  l_tcp = p_j2k->m_cp.tcps;
-  l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;
-
-  for
-    (i=0;i<l_nb_tiles;++i)
-  {
-    l_max = uint_max(l_max,l_tcp->m_nb_tile_parts);
-    ++l_tcp;
-  }
-  return 12 * l_max;
-}
-
-
-/**
- * Gets the maximum size taken by the headers of the SOT.
- *
- * @param  p_j2k  the jpeg2000 codec to use.
- */
-OPJ_UINT32 j2k_get_specific_header_sizes(opj_j2k_t *p_j2k)
-{
-  OPJ_UINT32 l_nb_bytes = 0;
-  OPJ_UINT32 l_nb_comps;
-  OPJ_UINT32 l_coc_bytes,l_qcc_bytes;
-
-
-  l_nb_comps = p_j2k->m_image->numcomps - 1;
-  l_nb_bytes += j2k_get_max_toc_size(p_j2k);
-  if
-    (p_j2k->m_cp.m_specific_param.m_enc.m_cinema == 0)
-  {
-    l_coc_bytes = j2k_get_max_coc_size(p_j2k);
-    l_nb_bytes += l_nb_comps * l_coc_bytes;
-    l_qcc_bytes = j2k_get_max_qcc_size(p_j2k);
-    l_nb_bytes += l_nb_comps * l_qcc_bytes;
-  }
-  l_nb_bytes += j2k_get_max_poc_size(p_j2k);
-  /*** DEVELOPER CORNER, Add room for your headers ***/
-
-
-  return l_nb_bytes;
-}
-
-
-/**
- * Writes the COC marker (Coding style component)
- *
- * @param  p_comp_no    the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-void j2k_write_coc_in_memory(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_data_written,
-              struct opj_event_mgr * p_manager
-            )
-{
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  OPJ_UINT32 l_coc_size,l_remaining_size;
-  OPJ_BYTE * l_current_data = 00;
-  opj_image_t *l_image = 00;
-  OPJ_UINT32 l_comp_room;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
-  l_image = p_j2k->m_image;
-  l_comp_room = (l_image->numcomps <= 256) ? 1 : 2;
-
-  l_coc_size = 5 + l_comp_room + j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
-  l_remaining_size = l_coc_size;
-
-  l_current_data = p_data;
-
-  opj_write_bytes(l_current_data,J2K_MS_COC,2);        /* COC */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_coc_size-2,2);        /* L_COC */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,p_comp_no, l_comp_room);    /* Ccoc */
-  l_current_data+=l_comp_room;
-  opj_write_bytes(l_current_data, l_tcp->tccps[p_comp_no].csty, 1);    /* Scoc */
-  ++l_current_data;
-  l_remaining_size -= (5 + l_comp_room);
-  j2k_write_SPCod_SPCoc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_size,p_manager);
-  * p_data_written = l_coc_size;
-}
-
-
-/**
- * Reads a COC marker (Coding Style Component)
- * @param  p_header_data  the data contained in the COC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the COC marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_coc (
-          opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          )
-{
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_image_t *l_image = 00;
-  OPJ_UINT32 l_comp_room;
-  OPJ_UINT32 l_comp_no;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-  l_image = p_j2k->m_image;
-
-  l_comp_room = l_image->numcomps <= 256 ? 1 : 2;
-  // make sure room is sufficient
-  if
-    (p_header_size < l_comp_room + 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
-    return false;
-  }
-  p_header_size -= l_comp_room + 1;
-
-  opj_read_bytes(p_header_data,&l_comp_no,l_comp_room);      /* Ccoc */
-  p_header_data += l_comp_room;
-  if
-    (l_comp_no >= l_image->numcomps)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker (bad number of components)\n");
-    return false;
-  }
-  opj_read_bytes(p_header_data,&l_tcp->tccps[l_comp_no].csty,1);      /* Scoc */
-  ++p_header_data ;
-
-  if
-    (! j2k_read_SPCod_SPCoc(p_j2k,l_comp_no,p_header_data,&p_header_size,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
-    return false;
-  }
-  if
-    (p_header_size != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
-    return false;
-  }
-  return true;
-}
-
-/**
- * Gets the size taken by writting SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
- *
- * @param  p_tile_no    the tile indix.
- * @param  p_comp_no    the component being outputted.
- * @param  p_j2k      the J2K codec.
- *
- * @return  the number of bytes taken by the SPCod element.
- */
-OPJ_UINT32 j2k_get_SQcd_SQcc_size (
-            opj_j2k_t *p_j2k,
-            OPJ_UINT32 p_tile_no,
-            OPJ_UINT32 p_comp_no
-            )
-{
-  OPJ_UINT32 l_num_bands;
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_tile_no];
-  l_tccp = &l_tcp->tccps[p_comp_no];
-
-  // preconditions again
-  assert(p_tile_no < l_cp->tw * l_cp->th);
-  assert(p_comp_no < p_j2k->m_image->numcomps);
-
-  l_num_bands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 : (l_tccp->numresolutions * 3 - 2);
-
-  if
-    (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT)
-  {
-    return 1 + l_num_bands;
-  }
-  else
-  {
-    return 1 + 2*l_num_bands;
-  }
-}
-
-/**
- * Writes a SQcd or SQcc element, i.e. the quantization values of a band.
- *
- * @param  p_tile_no    the tile to output.
- * @param  p_comp_no    the component number to output.
- * @param  p_data      the data buffer.
- * @param  p_header_size  pointer to the size of the data buffer, it is changed by the function.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
- *
-*/
-bool j2k_write_SQcd_SQcc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_tile_no,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_header_size;
-  OPJ_UINT32 l_band_no, l_num_bands;
-  OPJ_UINT32 l_expn,l_mant;
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_header_size != 00);
-  assert(p_manager != 00);
-  assert(p_data != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_tile_no];
-  l_tccp = &l_tcp->tccps[p_comp_no];
-
-  // preconditions again
-  assert(p_tile_no < l_cp->tw * l_cp->th);
-  assert(p_comp_no <p_j2k->m_image->numcomps);
-
-  l_num_bands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 : (l_tccp->numresolutions * 3 - 2);
-
-  if
-    (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT)
-  {
-    l_header_size = 1 + l_num_bands;
-    if
-      (*p_header_size < l_header_size)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error writting SQcd SQcc element\n");
-      return false;
-    }
-    opj_write_bytes(p_data,l_tccp->qntsty + (l_tccp->numgbits << 5), 1);  /* Sqcx */
-    ++p_data;
-    for
-      (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no)
-    {
-      l_expn = l_tccp->stepsizes[l_band_no].expn;
-      opj_write_bytes(p_data, l_expn << 3, 1);  /* SPqcx_i */
-      ++p_data;
-    }
-  }
-  else
-  {
-    l_header_size = 1 + 2*l_num_bands;
-    if
-      (*p_header_size < l_header_size)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error writting SQcd SQcc element\n");
-      return false;
-    }
-    opj_write_bytes(p_data,l_tccp->qntsty + (l_tccp->numgbits << 5), 1);  /* Sqcx */
-    ++p_data;
-    for
-      (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no)
-    {
-      l_expn = l_tccp->stepsizes[l_band_no].expn;
-      l_mant = l_tccp->stepsizes[l_band_no].mant;
-      opj_write_bytes(p_data, (l_expn << 11) + l_mant, 2);  /* SPqcx_i */
-      p_data += 2;
-    }
-  }
-  *p_header_size = *p_header_size - l_header_size;
-  return true;
-}
-
-/**
- * Reads a SQcd or SQcc element, i.e. the quantization values of a band.
- *
- * @param  p_comp_no    the component being targeted.
- * @param  p_header_data  the data contained in the COM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the COM marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_SQcd_SQcc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE* p_header_data,
-              OPJ_UINT32 * p_header_size,
-              struct opj_event_mgr * p_manager
-              )
-{
-  // loop
-  OPJ_UINT32 l_band_no;
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-  OPJ_BYTE * l_current_ptr = 00;
-  OPJ_UINT32 l_tmp;
-  OPJ_UINT32 l_num_band;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_header_data != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-  // precondition again
-  assert(p_comp_no <  p_j2k->m_image->numcomps);
-  l_tccp = &l_tcp->tccps[p_comp_no];
-  l_current_ptr = p_header_data;
-
-  if
-    (* p_header_size < 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading SQcd or SQcc element\n");
-    return false;
-  }
-  * p_header_size -= 1;
-
-  opj_read_bytes(l_current_ptr, &l_tmp ,1);      /* Sqcx */
-  ++l_current_ptr;
-
-  l_tccp->qntsty = l_tmp & 0x1f;
-  l_tccp->numgbits = l_tmp >> 5;
-  if
-    (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT)
-  {
-        l_num_band = 1;
-  }
-  else
-  {
-    l_num_band = (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) ? (*p_header_size) : (*p_header_size) / 2;
-    if( l_num_band > J2K_MAXBANDS )
-      {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading CCP_QNTSTY element\n");
-      return false;
-      }
-  }
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-
-    /* if JPWL is on, we check whether there are too many subbands */
-    if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) {
-      opj_event_msg(p_j2k->cinfo, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
-        "JPWL: bad number of subbands in Sqcx (%d)\n",
-        numbands);
-      if (!JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-      /* we try to correct */
-      numbands = 1;
-      opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- trying to adjust them\n"
-        "- setting number of bands to %d => HYPOTHESIS!!!\n",
-        numbands);
-    };
-
-  };
-#endif /* USE_JPWL */
-  if
-    (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT)
-  {
-    for
-      (l_band_no = 0; l_band_no < l_num_band; l_band_no++)
-    {
-      opj_read_bytes(l_current_ptr, &l_tmp ,1);      /* SPqcx_i */
-      ++l_current_ptr;
-      l_tccp->stepsizes[l_band_no].expn = l_tmp>>3;
-      l_tccp->stepsizes[l_band_no].mant = 0;
-    }
-    * p_header_size = * p_header_size - l_num_band;
-  }
-  else
-  {
-    for
-      (l_band_no = 0; l_band_no < l_num_band; l_band_no++)
-    {
-      opj_read_bytes(l_current_ptr, &l_tmp ,2);      /* SPqcx_i */
-      l_current_ptr+=2;
-      l_tccp->stepsizes[l_band_no].expn = l_tmp >> 11;
-      l_tccp->stepsizes[l_band_no].mant = l_tmp & 0x7ff;
-    }
-    * p_header_size = * p_header_size - 2*l_num_band;
-  }
-
-  /* Add Antonin : if scalar_derived -> compute other stepsizes */
-  if
-    (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT)
-  {
-    for
-      (l_band_no = 1; l_band_no < J2K_MAXBANDS; l_band_no++)
-    {
-      l_tccp->stepsizes[l_band_no].expn =
-        ((l_tccp->stepsizes[0].expn) - ((l_band_no - 1) / 3) > 0) ?
-          (l_tccp->stepsizes[0].expn) - ((l_band_no - 1) / 3) : 0;
-      l_tccp->stepsizes[l_band_no].mant = l_tccp->stepsizes[0].mant;
-    }
-
-  }
-  return true;
-}
-
-
-
-/**
- * Copies the tile component parameters of all the component from the first tile component.
- *
- * @param    p_j2k    the J2k codec.
- */
-void j2k_copy_tile_quantization_parameters(
-              opj_j2k_t *p_j2k
-              )
-{
-  // loop
-  OPJ_UINT32 i;
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_ref_tccp = 00;
-  opj_tccp_t *l_copied_tccp = 00;
-  OPJ_UINT32 l_size;
-  // preconditions
-  assert(p_j2k != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-  // precondition again
-  l_ref_tccp = &l_tcp->tccps[0];
-  l_copied_tccp = l_ref_tccp + 1;
-  l_size = J2K_MAXBANDS * sizeof(opj_stepsize_t);
-
-  for
-    (i=1;i<p_j2k->m_image->numcomps;++i)
-  {
-    l_copied_tccp->qntsty = l_ref_tccp->qntsty;
-    l_copied_tccp->numgbits = l_ref_tccp->numgbits;
-    memcpy(l_copied_tccp->stepsizes,l_ref_tccp->stepsizes,l_size);
-    ++l_copied_tccp;
-  }
-}
-
-
-
-/**
- * Writes the QCD marker (quantization default)
- *
- * @param  p_comp_number  the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_qcd(
-              opj_j2k_t *p_j2k,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-              )
-{
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  OPJ_UINT32 l_qcd_size,l_remaining_size;
-  OPJ_BYTE * l_current_data = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
-  l_qcd_size = 4 + j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,0);
-  l_remaining_size = l_qcd_size;
-
-  if
-    (l_qcd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_qcd_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcd_size;
-  }
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-  opj_write_bytes(l_current_data,J2K_MS_QCD,2);    /* QCD */
-  l_current_data += 2;
-
-  opj_write_bytes(l_current_data,l_qcd_size-2,2);    /* L_QCD */
-  l_current_data += 2;
-
-  l_remaining_size -= 4;
-
-  if
-    (! j2k_write_SQcd_SQcc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_size,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error writting QCD marker\n");
-    return false;
-  }
-  if
-    (l_remaining_size != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error writting QCD marker\n");
-    return false;
-  }
-
-  if
-    (opj_stream_write_data(p_stream, p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_qcd_size,p_manager) != l_qcd_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a QCD marker (Quantization defaults)
- * @param  p_header_data  the data contained in the QCD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the QCD marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_qcd (
-            opj_j2k_t *p_j2k,
-          OPJ_BYTE * p_header_data,
-          OPJ_UINT32 p_header_size,
-          struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (! j2k_read_SQcd_SQcc(p_j2k,0,p_header_data,&p_header_size,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading QCD marker\n");
-    return false;
-  }
-  if
-    (p_header_size != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading QCD marker\n");
-    return false;
-  }
-  j2k_copy_tile_quantization_parameters(p_j2k);
-  return true;
-}
-
-
-/**
- * Writes the QCC marker (quantization component)
- *
- * @param  p_comp_no  the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_qcc(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              struct opj_stream_private *p_stream,
-              struct opj_event_mgr * p_manager
-              )
-{
-  OPJ_UINT32 l_qcc_size,l_remaining_size;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_qcc_size = 6 + j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
-  l_remaining_size = l_qcc_size;
-  if
-    (l_qcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_qcc_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcc_size;
-  }
-  j2k_write_qcc_in_memory(p_j2k,p_comp_no,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&l_remaining_size,p_manager);
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_qcc_size,p_manager) != l_qcc_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-
-/**
- * Writes the QCC marker (quantization component)
- *
- * @param  p_comp_no  the index of the component to output.
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-void j2k_write_qcc_in_memory(
-              opj_j2k_t *p_j2k,
-              OPJ_UINT32 p_comp_no,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_data_written,
-              struct opj_event_mgr * p_manager
-              )
-{
-  OPJ_UINT32 l_qcc_size,l_remaining_size;
-  OPJ_BYTE * l_current_data = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_qcc_size = 6 + j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
-  l_remaining_size = l_qcc_size;
-
-  l_current_data = p_data;
-
-  opj_write_bytes(l_current_data,J2K_MS_QCC,2);    /* QCC */
-  l_current_data += 2;
-
-  if
-    (p_j2k->m_image->numcomps <= 256)
-  {
-    --l_qcc_size;
-    opj_write_bytes(l_current_data,l_qcc_size-2,2);    /* L_QCC */
-    l_current_data += 2;
-    opj_write_bytes(l_current_data, p_comp_no, 1);  /* Cqcc */
-    ++l_current_data;
-    // in the case only one byte is sufficient the last byte allocated is useless -> still do -6 for available
-    l_remaining_size -= 6;
-  }
-  else
-  {
-    opj_write_bytes(l_current_data,l_qcc_size-2,2);    /* L_QCC */
-    l_current_data += 2;
-    opj_write_bytes(l_current_data, p_comp_no, 2);  /* Cqcc */
-    l_current_data+=2;
-    l_remaining_size -= 6;
-  }
-  j2k_write_SQcd_SQcc(p_j2k,p_j2k->m_current_tile_number,p_comp_no,l_current_data,&l_remaining_size,p_manager);
-  * p_data_written = l_qcc_size;
-}
-
-/**
- * Gets the maximum size taken by a qcc.
- */
-OPJ_UINT32 j2k_get_max_qcc_size (opj_j2k_t *p_j2k)
-{
-  return j2k_get_max_coc_size(p_j2k);
-}
-
-/**
- * Reads a QCC marker (Quantization component)
- * @param  p_header_data  the data contained in the QCC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the QCC marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_qcc(
-              opj_j2k_t *p_j2k,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 p_header_size,
-              struct opj_event_mgr * p_manager)
-{
-  OPJ_UINT32 l_num_comp,l_comp_no;
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_num_comp = p_j2k->m_image->numcomps;
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-
-    static OPJ_UINT32 backup_compno = 0;
-
-    /* compno is negative or larger than the number of components!!! */
-    if ((compno < 0) || (compno >= numcomp)) {
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "JPWL: bad component number in QCC (%d out of a maximum of %d)\n",
-        compno, numcomp);
-      if (!JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-      /* we try to correct */
-      compno = backup_compno % numcomp;
-      opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- trying to adjust this\n"
-        "- setting component number to %d\n",
-        compno);
-    }
-
-    /* keep your private count of tiles */
-    backup_compno++;
-  };
-#endif /* USE_JPWL */
-  if
-    (l_num_comp <= 256)
-  {
-    if
-      (p_header_size < 1)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
-      return false;
-    }
-    opj_read_bytes(p_header_data,&l_comp_no,1);
-    ++p_header_data;
-    --p_header_size;
-  }
-  else
-  {
-    if
-      (p_header_size < 2)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
-      return false;
-    }
-    opj_read_bytes(p_header_data,&l_comp_no,2);
-    p_header_data+=2;
-    p_header_size-=2;
-  }
-  if
-    (! j2k_read_SQcd_SQcc(p_j2k,l_comp_no,p_header_data,&p_header_size,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
-    return false;
-  }
-  if
-    (p_header_size != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
-    return false;
-  }
-  return true;
-
-}
-
-
-/**
- * Writes the CBD marker (Component bit depth definition)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_cbd(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_cbd_size;
-  OPJ_BYTE * l_current_data = 00;
-  opj_image_t *l_image = 00;
-  opj_image_comp_t * l_comp = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_image = p_j2k->m_image;
-  l_cbd_size = 6 + p_j2k->m_image->numcomps;
-
-  if
-    (l_cbd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_cbd_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_cbd_size;
-  }
-
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-  opj_write_bytes(l_current_data,J2K_MS_CBD,2);          /* CBD */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_cbd_size-2,2);          /* L_CBD */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_image->numcomps, 2);    /* Ncbd */
-  l_current_data+=2;
-  l_comp = l_image->comps;
-  for
-    (i=0;i<l_image->numcomps;++i)
-  {
-    opj_write_bytes(l_current_data, (l_comp->sgnd << 7) | (l_comp->prec - 1), 1);    /* Component bit depth */
-    ++l_current_data;
-    ++l_comp;
-  }
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_cbd_size,p_manager) != l_cbd_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a CBD marker (Component bit depth definition)
- * @param  p_header_data  the data contained in the CBD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the CBD marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_cbd (
-              opj_j2k_t *p_j2k,
-              OPJ_BYTE * p_header_data,
-              OPJ_UINT32 p_header_size,
-              struct opj_event_mgr * p_manager)
-{
-  OPJ_UINT32 l_nb_comp,l_num_comp;
-  OPJ_UINT32 l_comp_def;
-  OPJ_UINT32 i;
-  opj_image_comp_t * l_comp = 00;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_num_comp = p_j2k->m_image->numcomps;
-
-  if
-    (p_header_size != (p_j2k->m_image->numcomps + 2))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Crror reading CBD marker\n");
-    return false;
-  }
-  opj_read_bytes(p_header_data,&l_nb_comp,2);        /* Ncbd */
-  p_header_data+=2;
-  if
-    (l_nb_comp != l_num_comp)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Crror reading CBD marker\n");
-    return false;
-  }
-
-  l_comp = p_j2k->m_image->comps;
-  for
-    (i=0;i<l_num_comp;++i)
-  {
-    opj_read_bytes(p_header_data,&l_comp_def,1);      /* Component bit depth */
-    ++p_header_data;
-        l_comp->sgnd = (l_comp_def>>7) & 1;
-    l_comp->prec = (l_comp_def&0x7f) + 1;
-    ++l_comp;
-  }
-  return true;
-}
-
-/**
- * Writes the MCC marker (Multiple Component Collection)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_mcc_record(
-            opj_j2k_t *p_j2k,
-            struct opj_simple_mcc_decorrelation_data * p_mcc_record,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_mcc_size;
-  OPJ_BYTE * l_current_data = 00;
-  OPJ_UINT32 l_nb_bytes_for_comp;
-  OPJ_UINT32 l_mask;
-  OPJ_UINT32 l_tmcc;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  if
-    (p_mcc_record->m_nb_comps > 255 )
-  {
-        l_nb_bytes_for_comp = 2;
-    l_mask = 0x8000;
-  }
-  else
-  {
-    l_nb_bytes_for_comp = 1;
-    l_mask = 0;
-  }
-
-  l_mcc_size = p_mcc_record->m_nb_comps * 2 * l_nb_bytes_for_comp + 19;
-  if
-    (l_mcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_mcc_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mcc_size;
-  }
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-  opj_write_bytes(l_current_data,J2K_MS_MCC,2);          /* MCC */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_mcc_size-2,2);          /* Lmcc */
-  l_current_data += 2;
-
-  /* first marker */
-  opj_write_bytes(l_current_data,0,2);          /* Zmcc */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,p_mcc_record->m_index,1);          /* Imcc -> no need for other values, take the first */
-  ++l_current_data;
-  /* only one marker atm */
-  opj_write_bytes(l_current_data,0,2);          /* Ymcc */
-  l_current_data+=2;
-  opj_write_bytes(l_current_data,1,2);          /* Qmcc -> number of collections -> 1 */
-  l_current_data+=2;
-  opj_write_bytes(l_current_data,0x1,1);          /* Xmcci type of component transformation -> array based decorrelation */
-  ++l_current_data;
-
-  opj_write_bytes(l_current_data,p_mcc_record->m_nb_comps | l_mask,2);  /* Nmcci number of input components involved and size for each component offset = 8 bits */
-  l_current_data+=2;
-
-  for
-    (i=0;i<p_mcc_record->m_nb_comps;++i)
-  {
-    opj_write_bytes(l_current_data,i,l_nb_bytes_for_comp);        /* Cmccij Component offset*/
-    l_current_data+=l_nb_bytes_for_comp;
-  }
-
-  opj_write_bytes(l_current_data,p_mcc_record->m_nb_comps|l_mask,2);  /* Mmcci number of output components involved and size for each component offset = 8 bits */
-  l_current_data+=2;
-  for
-    (i=0;i<p_mcc_record->m_nb_comps;++i)
-  {
-    opj_write_bytes(l_current_data,i,l_nb_bytes_for_comp);        /* Wmccij Component offset*/
-    l_current_data+=l_nb_bytes_for_comp;
-  }
-  l_tmcc = ((!p_mcc_record->m_is_irreversible)&1)<<16;
-  if
-    (p_mcc_record->m_decorrelation_array)
-  {
-    l_tmcc |= p_mcc_record->m_decorrelation_array->m_index;
-  }
-  if
-    (p_mcc_record->m_offset_array)
-  {
-    l_tmcc |= ((p_mcc_record->m_offset_array->m_index)<<8);
-  }
-  opj_write_bytes(l_current_data,l_tmcc,3);  /* Tmcci : use MCT defined as number 1 and irreversible array based. */
-  l_current_data+=3;
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mcc_size,p_manager) != l_mcc_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-
-/**
- * Reads a MCC marker (Multiple Component Collection)
- *
- * @param  p_header_data  the data contained in the MCC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the MCC marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_mcc (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i,j;
-  OPJ_UINT32 l_tmp;
-  OPJ_UINT32 l_indix;
-  opj_tcp_t * l_tcp;
-  opj_simple_mcc_decorrelation_data_t * l_mcc_record;
-  opj_mct_data_t * l_mct_data;
-  OPJ_UINT32 l_nb_collections;
-  OPJ_UINT32 l_nb_comps;
-  OPJ_UINT32 l_nb_bytes_by_comp;
-
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH ? &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
-  if
-    (p_header_size < 2)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-    return false;
-  }
-
-  /* first marker */
-  opj_read_bytes(p_header_data,&l_tmp,2);        /* Zmcc */
-  p_header_data += 2;
-  if
-    (l_tmp != 0)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple data spanning\n");
-    return true;
-  }
-  if
-    (p_header_size < 7)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-    return false;
-  }
-  opj_read_bytes(p_header_data,&l_indix,1);        /* Imcc -> no need for other values, take the first */
-  ++p_header_data;
-
-  l_mcc_record = l_tcp->m_mcc_records;
-  for
-    (i=0;i<l_tcp->m_nb_mcc_records;++i)
-  {
-    if
-      (l_mcc_record->m_index == l_indix)
-    {
-      break;
-    }
-    ++l_mcc_record;
-  }
-  /** NOT FOUND */
-  if
-    (i == l_tcp->m_nb_mcc_records)
-  {
-    if
-      (l_tcp->m_nb_mcc_records == l_tcp->m_nb_max_mcc_records)
-    {
-      l_tcp->m_nb_max_mcc_records += J2K_MCC_DEFAULT_NB_RECORDS;
-      l_tcp->m_mcc_records = (opj_simple_mcc_decorrelation_data_t*)
-      opj_realloc(l_tcp->m_mcc_records,l_tcp->m_nb_max_mcc_records * sizeof(opj_simple_mcc_decorrelation_data_t));
-      if
-        (! l_tcp->m_mcc_records)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-        return false;
-      }
-      l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
-      memset(l_mcc_record,0,(l_tcp->m_nb_max_mcc_records-l_tcp->m_nb_mcc_records) * sizeof(opj_simple_mcc_decorrelation_data_t));
-    }
-    l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
-  }
-  l_mcc_record->m_index = l_indix;
-
-  /* only one marker atm */
-  opj_read_bytes(p_header_data,&l_tmp,2);        /* Ymcc */
-  p_header_data+=2;
-  if
-    (l_tmp != 0)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple data spanning\n");
-    return true;
-  }
-  opj_read_bytes(p_header_data,&l_nb_collections,2);        /* Qmcc -> number of collections -> 1 */
-  p_header_data+=2;
-  if
-    (l_nb_collections > 1)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple collections\n");
-    return true;
-  }
-  p_header_size -= 7;
-  for
-    (i=0;i<l_nb_collections;++i)
-  {
-    if
-      (p_header_size < 3)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-      return false;
-    }
-    opj_read_bytes(p_header_data,&l_tmp,1);  /* Xmcci type of component transformation -> array based decorrelation */
-    ++p_header_data;
-    if
-      (l_tmp != 1)
-    {
-      opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections other than array decorrelation\n");
-      return true;
-    }
-    opj_read_bytes(p_header_data,&l_nb_comps,2);
-    p_header_data+=2;
-    p_header_size-=3;
-    l_nb_bytes_by_comp = 1 + (l_nb_comps>>15);
-    l_mcc_record->m_nb_comps = l_nb_comps & 0x7fff;
-    if
-      (p_header_size < (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 2))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-      return false;
-    }
-    p_header_size -= (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 2);
-    for
-      (j=0;j<l_mcc_record->m_nb_comps;++j)
-    {
-      opj_read_bytes(p_header_data,&l_tmp,l_nb_bytes_by_comp);  /* Cmccij Component offset*/
-      p_header_data+=l_nb_bytes_by_comp;
-      if
-        (l_tmp != j)
-      {
-        opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections with indix shuffle\n");
-        return true;
-      }
-    }
-    opj_read_bytes(p_header_data,&l_nb_comps,2);
-    p_header_data+=2;
-    l_nb_bytes_by_comp = 1 + (l_nb_comps>>15);
-    l_nb_comps &= 0x7fff;
-    if
-      (l_nb_comps != l_mcc_record->m_nb_comps)
-    {
-      opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections without same number of indixes\n");
-      return true;
-    }
-    if
-      (p_header_size < (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 3))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-      return false;
-    }
-    p_header_size -= (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 3);
-    for
-      (j=0;j<l_mcc_record->m_nb_comps;++j)
-    {
-      opj_read_bytes(p_header_data,&l_tmp,l_nb_bytes_by_comp);  /* Wmccij Component offset*/
-      p_header_data+=l_nb_bytes_by_comp;
-      if
-        (l_tmp != j)
-      {
-        opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections with indix shuffle\n");
-        return true;
-      }
-    }
-    opj_read_bytes(p_header_data,&l_tmp,3);  /* Wmccij Component offset*/
-    p_header_data += 3;
-    l_mcc_record->m_is_irreversible = ! ((l_tmp>>16) & 1);
-    l_mcc_record->m_decorrelation_array = 00;
-    l_mcc_record->m_offset_array = 00;
-    l_indix = l_tmp & 0xff;
-    if
-      (l_indix != 0)
-    {
-      l_mct_data = l_tcp->m_mct_records;
-      for
-        (j=0;j<l_tcp->m_nb_mct_records;++j)
-      {
-        if
-          (l_mct_data->m_index == l_indix)
-        {
-          l_mcc_record->m_decorrelation_array = l_mct_data;
-          break;
-        }
-        ++l_mct_data;
-      }
-      if
-        (l_mcc_record->m_decorrelation_array == 00)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-        return false;
-      }
-    }
-    l_indix = (l_tmp >> 8) & 0xff;
-    if
-      (l_indix != 0)
-    {
-      l_mct_data = l_tcp->m_mct_records;
-      for
-        (j=0;j<l_tcp->m_nb_mct_records;++j)
-      {
-        if
-          (l_mct_data->m_index == l_indix)
-        {
-          l_mcc_record->m_offset_array = l_mct_data;
-          break;
-        }
-        ++l_mct_data;
-      }
-      if
-        (l_mcc_record->m_offset_array == 00)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-        return false;
-      }
-    }
-  }
-  if
-    (p_header_size != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
-    return false;
-  }
-  ++l_tcp->m_nb_mcc_records;
-  return true;
-}
-
-/**
- * Writes the MCT marker (Multiple Component Transform)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_mct_record(
-            opj_j2k_t *p_j2k,
-            opj_mct_data_t * p_mct_record,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_mct_size;
-  OPJ_BYTE * l_current_data = 00;
-  OPJ_UINT32 l_tmp;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_mct_size = 10 + p_mct_record->m_data_size;
-  if
-    (l_mct_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_mct_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mct_size;
-  }
-
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-  opj_write_bytes(l_current_data,J2K_MS_MCT,2);          /* MCT */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_mct_size-2,2);          /* Lmct */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,0,2);              /* Zmct */
-  l_current_data += 2;
-  /* only one marker atm */
-  l_tmp = (p_mct_record->m_index & 0xff) | (p_mct_record->m_array_type << 8) | (p_mct_record->m_element_type << 10);
-  opj_write_bytes(l_current_data,l_tmp,2);
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,0,2);              /* Ymct */
-  l_current_data+=2;
-
-  memcpy(l_current_data,p_mct_record->m_data,p_mct_record->m_data_size);
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mct_size,p_manager) != l_mct_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a MCT marker (Multiple Component Transform)
- *
- * @param  p_header_data  the data contained in the MCT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the MCT marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_mct (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  opj_tcp_t *l_tcp = 00;
-  OPJ_UINT32 l_tmp;
-  OPJ_UINT32 l_indix;
-  opj_mct_data_t * l_mct_data;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-
-  l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH ? &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
-  if
-    (p_header_size < 2)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
-    return false;
-  }
-  /* first marker */
-  opj_read_bytes(p_header_data,&l_tmp,2);        /* Zmct */
-  p_header_data += 2;
-  if
-    (l_tmp != 0)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge mct data within multiple MCT records\n");
-    return true;
-  }
-  if
-    (p_header_size <= 6)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
-    return false;
-  }
-  opj_read_bytes(p_header_data,&l_tmp,2);        /* Imct -> no need for other values, take the first, type is double with decorrelation x0000 1101 0000 0000*/
-  p_header_data += 2;
-
-  l_indix = l_tmp & 0xff;
-  l_mct_data = l_tcp->m_mct_records;
-  for
-    (i=0;i<l_tcp->m_nb_mct_records;++i)
-  {
-    if
-      (l_mct_data->m_index == l_indix)
-    {
-      break;
-    }
-    ++l_mct_data;
-  }
-  /* NOT FOUND */
-  if
-    (i == l_tcp->m_nb_mct_records)
-  {
-    if
-      (l_tcp->m_nb_mct_records == l_tcp->m_nb_max_mct_records)
-    {
-      l_tcp->m_nb_max_mct_records += J2K_MCT_DEFAULT_NB_RECORDS;
-      l_tcp->m_mct_records = (opj_mct_data_t*)opj_realloc(l_tcp->m_mct_records,l_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
-      if
-        (! l_tcp->m_mct_records)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
-        return false;
-      }
-      l_mct_data = l_tcp->m_mct_records + l_tcp->m_nb_mct_records;
-      memset(l_mct_data ,0,(l_tcp->m_nb_max_mct_records - l_tcp->m_nb_mct_records) * sizeof(opj_mct_data_t));
-    }
-    l_mct_data = l_tcp->m_mct_records + l_tcp->m_nb_mct_records;
-  }
-  if
-    (l_mct_data->m_data)
-  {
-    opj_free(l_mct_data->m_data);
-    l_mct_data->m_data = 00;
-  }
-  l_mct_data->m_index = l_indix;
-  l_mct_data->m_array_type = (J2K_MCT_ARRAY_TYPE)((l_tmp  >> 8) & 3);
-  l_mct_data->m_element_type = (J2K_MCT_ELEMENT_TYPE)((l_tmp  >> 10) & 3);
-
-  opj_read_bytes(p_header_data,&l_tmp,2);        /* Ymct */
-  p_header_data+=2;
-  if
-    (l_tmp != 0)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple MCT markers\n");
-    return true;
-  }
-  p_header_size -= 6;
-  l_mct_data->m_data = (OPJ_BYTE*)opj_malloc(p_header_size);
-  if
-    (! l_mct_data->m_data)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
-    return false;
-  }
-  memcpy(l_mct_data->m_data,p_header_data,p_header_size);
-  l_mct_data->m_data_size = p_header_size;
-  ++l_tcp->m_nb_mct_records;
-  return true;
-}
-
-bool   j2k_setup_mct_encoding (opj_tcp_t * p_tcp,opj_image_t * p_image)
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_indix = 1;
-  opj_mct_data_t * l_mct_deco_data = 00,* l_mct_offset_data = 00;
-  opj_simple_mcc_decorrelation_data_t * l_mcc_data;
-  OPJ_UINT32 l_mct_size,l_nb_elem;
-  OPJ_FLOAT32 * l_data, * l_current_data;
-  opj_tccp_t * l_tccp;
-
-  // preconditions
-  assert(p_tcp != 00);
-
-  if
-    (p_tcp->mct != 2)
-  {
-    return true;
-  }
-
-  if
-    (p_tcp->m_mct_decoding_matrix)
-  {
-    if
-      (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records)
-    {
-      p_tcp->m_nb_max_mct_records += J2K_MCT_DEFAULT_NB_RECORDS;
-      p_tcp->m_mct_records = (opj_mct_data_t*)opj_realloc(p_tcp->m_mct_records,p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
-      if
-        (! p_tcp->m_mct_records)
-      {
-        return false;
-      }
-      l_mct_deco_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-      memset(l_mct_deco_data ,0,(p_tcp->m_nb_max_mct_records - p_tcp->m_nb_mct_records) * sizeof(opj_mct_data_t));
-    }
-    l_mct_deco_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-
-    if
-      (l_mct_deco_data->m_data)
-    {
-      opj_free(l_mct_deco_data->m_data);
-      l_mct_deco_data->m_data = 00;
-    }
-    l_mct_deco_data->m_index = l_indix++;
-    l_mct_deco_data->m_array_type = MCT_TYPE_DECORRELATION;
-    l_mct_deco_data->m_element_type = MCT_TYPE_FLOAT;
-    l_nb_elem = p_image->numcomps * p_image->numcomps;
-    l_mct_size = l_nb_elem * MCT_ELEMENT_SIZE[l_mct_deco_data->m_element_type];
-    l_mct_deco_data->m_data = (OPJ_BYTE*)opj_malloc(l_mct_size );
-    if
-      (! l_mct_deco_data->m_data)
-    {
-      return false;
-    }
-    j2k_mct_write_functions_from_float[l_mct_deco_data->m_element_type](p_tcp->m_mct_decoding_matrix,l_mct_deco_data->m_data,l_nb_elem);
-    l_mct_deco_data->m_data_size = l_mct_size;
-    ++p_tcp->m_nb_mct_records;
-  }
-
-  if
-    (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records)
-  {
-    p_tcp->m_nb_max_mct_records += J2K_MCT_DEFAULT_NB_RECORDS;
-    p_tcp->m_mct_records = (opj_mct_data_t*)opj_realloc(p_tcp->m_mct_records,p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
-    if
-      (! p_tcp->m_mct_records)
-    {
-      return false;
-    }
-    l_mct_offset_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-    memset(l_mct_offset_data ,0,(p_tcp->m_nb_max_mct_records - p_tcp->m_nb_mct_records) * sizeof(opj_mct_data_t));
-    if
-      (l_mct_deco_data)
-    {
-      l_mct_deco_data = l_mct_offset_data - 1;
-    }
-  }
-  l_mct_offset_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
-  if
-    (l_mct_offset_data->m_data)
-  {
-    opj_free(l_mct_offset_data->m_data);
-    l_mct_offset_data->m_data = 00;
-  }
-
-  l_mct_offset_data->m_index = l_indix++;
-  l_mct_offset_data->m_array_type = MCT_TYPE_OFFSET;
-  l_mct_offset_data->m_element_type = MCT_TYPE_FLOAT;
-  l_nb_elem = p_image->numcomps;
-  l_mct_size = l_nb_elem * MCT_ELEMENT_SIZE[l_mct_offset_data->m_element_type];
-  l_mct_offset_data->m_data = (OPJ_BYTE*)opj_malloc(l_mct_size );
-  if
-    (! l_mct_offset_data->m_data)
-  {
-    return false;
-  }
-  l_data = (OPJ_FLOAT32*)opj_malloc(l_nb_elem * sizeof(OPJ_FLOAT32));
-  if
-    (! l_data)
-  {
-    opj_free(l_mct_offset_data->m_data);
-    l_mct_offset_data->m_data = 00;
-    return false;
-  }
-  l_tccp = p_tcp->tccps;
-  l_current_data = l_data;
-  for
-    (i=0;i<l_nb_elem;++i)
-  {
-    *(l_current_data++) = (OPJ_FLOAT32) (l_tccp->m_dc_level_shift);
-    ++l_tccp;
-  }
-  j2k_mct_write_functions_from_float[l_mct_offset_data->m_element_type](l_data,l_mct_offset_data->m_data,l_nb_elem);
-  opj_free(l_data);
-  l_mct_offset_data->m_data_size = l_mct_size;
-  ++p_tcp->m_nb_mct_records;
-
-  if
-    (p_tcp->m_nb_mcc_records == p_tcp->m_nb_max_mcc_records)
-  {
-    p_tcp->m_nb_max_mcc_records += J2K_MCT_DEFAULT_NB_RECORDS;
-    p_tcp->m_mcc_records = (opj_simple_mcc_decorrelation_data_t*)
-    opj_realloc(p_tcp->m_mcc_records,p_tcp->m_nb_max_mcc_records * sizeof(opj_simple_mcc_decorrelation_data_t));
-    if
-      (! p_tcp->m_mcc_records)
-    {
-      return false;
-    }
-    l_mcc_data = p_tcp->m_mcc_records + p_tcp->m_nb_mcc_records;
-    memset(l_mcc_data ,0,(p_tcp->m_nb_max_mcc_records - p_tcp->m_nb_mcc_records) * sizeof(opj_simple_mcc_decorrelation_data_t));
-
-  }
-  l_mcc_data = p_tcp->m_mcc_records + p_tcp->m_nb_mcc_records;
-  l_mcc_data->m_decorrelation_array = l_mct_deco_data;
-  l_mcc_data->m_is_irreversible = 1;
-  l_mcc_data->m_nb_comps = p_image->numcomps;
-  l_mcc_data->m_index = l_indix++;
-  l_mcc_data->m_offset_array = l_mct_offset_data;
-  ++p_tcp->m_nb_mcc_records;
-  return true;
-}
-
-/**
- * Writes the MCO marker (Multiple component transformation ordering)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_mco(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_BYTE * l_current_data = 00;
-  OPJ_UINT32 l_mco_size;
-  opj_tcp_t * l_tcp = 00;
-  opj_simple_mcc_decorrelation_data_t * l_mcc_record;
-  OPJ_UINT32 i;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_tcp =&(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-  l_mco_size = 5 + l_tcp->m_nb_mcc_records;
-  if
-    (l_mco_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_mco_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mco_size;
-  }
-
-  opj_write_bytes(l_current_data,J2K_MS_MCO,2);      /* MCO */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_mco_size-2,2);          /* Lmco */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_tcp->m_nb_mcc_records,1);          /* Nmco : only one tranform stage*/
-  ++l_current_data;
-
-  l_mcc_record = l_tcp->m_mcc_records;
-  for
-    (i=0;i<l_tcp->m_nb_mcc_records;++i)
-  {
-    opj_write_bytes(l_current_data,l_mcc_record->m_index,1);          /* Imco -> use the mcc indicated by 1*/
-    ++l_current_data;
-    ++l_mcc_record;
-  }
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mco_size,p_manager) != l_mco_size)
-  {
-    return false;
-  }
-  return true;
-}
-/**
- * Reads a MCO marker (Multiple Component Transform Ordering)
- *
- * @param  p_header_data  the data contained in the MCO box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the MCO marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_mco (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_tmp, i;
-  OPJ_UINT32 l_nb_stages;
-  opj_tcp_t * l_tcp;
-  opj_tccp_t * l_tccp;
-  opj_image_t * l_image;
-  opj_image_comp_t * l_img_comp;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_image = p_j2k->m_image;
-  l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH ? &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-  if
-    (p_header_size < 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading MCO marker\n");
-    return false;
-  }
-
-  opj_read_bytes(p_header_data,&l_nb_stages,1);        /* Nmco : only one tranform stage*/
-  ++p_header_data;
-  if
-    (l_nb_stages > 1)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple transformation stages.\n");
-    return true;
-  }
-  if
-    (p_header_size != l_nb_stages + 1)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Error reading MCO marker\n");
-    return false;
-  }
-
-  l_tccp = l_tcp->tccps;
-  l_img_comp = l_image->comps;
-  for
-    (i=0;i<l_image->numcomps;++i)
-  {
-    l_tccp->m_dc_level_shift = 0;
-    ++l_tccp;
-  }
-  if
-    (l_tcp->m_mct_decoding_matrix)
-  {
-    opj_free(l_tcp->m_mct_decoding_matrix);
-    l_tcp->m_mct_decoding_matrix = 00;
-  }
-
-  for
-    (i=0;i<l_nb_stages;++i)
-  {
-    opj_read_bytes(p_header_data,&l_tmp,1);
-    ++p_header_data;
-    if
-      (! j2k_add_mct(l_tcp,p_j2k->m_image,l_tmp))
-    {
-      return false;
-    }
-  }
-  return true;
-}
-
-bool j2k_add_mct(opj_tcp_t * p_tcp,opj_image_t * p_image, OPJ_UINT32 p_index)
-{
-  OPJ_UINT32 i;
-  opj_simple_mcc_decorrelation_data_t * l_mcc_record;
-  opj_mct_data_t * l_deco_array, * l_offset_array;
-  OPJ_UINT32 l_data_size,l_mct_size, l_offset_size;
-  OPJ_UINT32 l_nb_elem;
-  OPJ_UINT32 * l_offset_data, * l_current_offset_data;
-  opj_tccp_t * l_tccp;
-
-
-  // preconditions
-  assert(p_tcp != 00);
-
-  l_mcc_record = p_tcp->m_mcc_records;
-  for
-    (i=0;i<p_tcp->m_nb_mcc_records;++i)
-  {
-    if
-      (l_mcc_record->m_index == p_index)
-    {
-      break;
-    }
-  }
-  if
-    (i==p_tcp->m_nb_mcc_records)
-  {
-    /** element discarded **/
-    return true;
-  }
-  if
-    (l_mcc_record->m_nb_comps != p_image->numcomps)
-  {
-    /** do not support number of comps != image */
-    return true;
-  }
-  l_deco_array = l_mcc_record->m_decorrelation_array;
-  if
-    (l_deco_array)
-  {
-    l_data_size = MCT_ELEMENT_SIZE[l_deco_array->m_element_type] * p_image->numcomps * p_image->numcomps;
-    if
-      (l_deco_array->m_data_size != l_data_size)
-    {
-      return false;
-    }
-    l_nb_elem = p_image->numcomps * p_image->numcomps;
-    l_mct_size = l_nb_elem * sizeof(OPJ_FLOAT32);
-    p_tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(l_mct_size);
-    if
-      (! p_tcp->m_mct_decoding_matrix )
-    {
-      return false;
-    }
-    j2k_mct_read_functions_to_float[l_deco_array->m_element_type](l_deco_array->m_data,p_tcp->m_mct_decoding_matrix,l_nb_elem);
-  }
-  l_offset_array = l_mcc_record->m_offset_array;
-  if
-    (l_offset_array)
-  {
-    l_data_size = MCT_ELEMENT_SIZE[l_offset_array->m_element_type] * p_image->numcomps;
-    if
-      (l_offset_array->m_data_size != l_data_size)
-    {
-      return false;
-    }
-    l_nb_elem = p_image->numcomps;
-    l_offset_size = l_nb_elem * sizeof(OPJ_UINT32);
-    l_offset_data = (OPJ_UINT32*)opj_malloc(l_offset_size);
-    if
-      (! l_offset_data )
-    {
-      return false;
-    }
-    j2k_mct_read_functions_to_int32[l_offset_array->m_element_type](l_offset_array->m_data,l_offset_data,l_nb_elem);
-    l_tccp = p_tcp->tccps;
-    l_current_offset_data = l_offset_data;
-    for
-      (i=0;i<p_image->numcomps;++i)
-    {
-      l_tccp->m_dc_level_shift = *(l_current_offset_data++);
-      ++l_tccp;
-    }
-    opj_free(l_offset_data);
-  }
-  return true;
-}
-
-/**
- * Writes the MCT marker (Multiple Component Transform)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_mct_data_group(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  opj_simple_mcc_decorrelation_data_t * l_mcc_record;
-  opj_mct_data_t * l_mct_record;
-  opj_tcp_t * l_tcp;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  if
-    (! j2k_write_cbd(p_j2k,p_stream,p_manager))
-  {
-    return false;
-  }
-  l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
-  l_mct_record = l_tcp->m_mct_records;
-  for
-    (i=0;i<l_tcp->m_nb_mct_records;++i)
-  {
-    if
-      (! j2k_write_mct_record(p_j2k,l_mct_record,p_stream,p_manager))
-    {
-      return false;
-    }
-    ++l_mct_record;
-  }
-  l_mcc_record = l_tcp->m_mcc_records;
-  for
-    (i=0;i<l_tcp->m_nb_mcc_records;++i)
-  {
-    if
-      (! j2k_write_mcc_record(p_j2k,l_mcc_record,p_stream,p_manager))
-    {
-      return false;
-    }
-    ++l_mcc_record;
-  }
-  if
-    (! j2k_write_mco(p_j2k,p_stream,p_manager))
-  {
-    return false;
-  }
-  return true;
-}
-
-
-/**
- * Writes the POC marker (Progression Order Change)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_poc(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_nb_comp;
-  OPJ_UINT32 l_nb_poc;
-  OPJ_UINT32 l_poc_size;
-  OPJ_UINT32 l_written_size = 0;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-  OPJ_UINT32 l_poc_room;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number];
-  l_tccp = &l_tcp->tccps[0];
-  l_nb_comp = p_j2k->m_image->numcomps;
-  l_nb_poc = 1 + l_tcp->numpocs;
-  if
-    (l_nb_comp <= 256)
-  {
-    l_poc_room = 1;
-  }
-  else
-  {
-    l_poc_room = 2;
-  }
-  l_poc_size = 4 + (5 + 2 * l_poc_room) * l_nb_poc;
-  if
-    (l_poc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_poc_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_poc_size;
-  }
-
-  j2k_write_poc_in_memory(p_j2k,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&l_written_size,p_manager);
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_poc_size,p_manager) != l_poc_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-
-/**
- * Writes EPC ????
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_epc(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  opj_codestream_info_t * l_info = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_info = p_j2k->cstr_info;
-  if
-    (l_info)
-  {
-    l_info->codestream_size = opj_stream_tell(p_stream);
-    /* UniPG>> */
-    /* The following adjustment is done to adjust the codestream size */
-    /* if SOD is not at 0 in the buffer. Useful in case of JP2, where */
-    /* the first bunch of bytes is not in the codestream              */
-    l_info->codestream_size -= l_info->main_head_start;
-    /* <<UniPG */
-  }
-
-#ifdef USE_JPWL
-  /*
-  preparation of JPWL marker segments
-  */
-  if(cp->epc_on) {
-
-    /* encode according to JPWL */
-    jpwl_encode(p_j2k, p_stream, image);
-
-  }
-#endif /* USE_JPWL */
-  return true;
-}
-
-
-/**
- * Gets the maximum size taken by the writting of a POC.
- */
-OPJ_UINT32 j2k_get_max_poc_size(opj_j2k_t *p_j2k)
-{
-  opj_tcp_t * l_tcp = 00;
-  OPJ_UINT32 l_nb_tiles = 0;
-  OPJ_UINT32 l_max_poc = 0;
-  OPJ_UINT32 i;
-
-  l_tcp = p_j2k->m_cp.tcps;
-  l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
-
-  for
-    (i=0;i<l_nb_tiles;++i)
-  {
-    l_max_poc = uint_max(l_max_poc,l_tcp->numpocs);
-    ++l_tcp;
-  }
-  ++l_max_poc;
-  return 4 + 9 * l_max_poc;
-}
-
-
-/**
- * Writes the POC marker (Progression Order Change)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-void j2k_write_poc_in_memory(
-              opj_j2k_t *p_j2k,
-              OPJ_BYTE * p_data,
-              OPJ_UINT32 * p_data_written,
-              struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  OPJ_BYTE * l_current_data = 00;
-  OPJ_UINT32 l_nb_comp;
-  OPJ_UINT32 l_nb_poc;
-  OPJ_UINT32 l_poc_size;
-  opj_image_t *l_image = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-  opj_poc_t *l_current_poc = 00;
-  OPJ_UINT32 l_poc_room;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number];
-  l_tccp = &l_tcp->tccps[0];
-  l_image = p_j2k->m_image;
-  l_nb_comp = l_image->numcomps;
-  l_nb_poc = 1 + l_tcp->numpocs;
-  if
-    (l_nb_comp <= 256)
-  {
-    l_poc_room = 1;
-  }
-  else
-  {
-    l_poc_room = 2;
-  }
-  l_poc_size = 4 + (5 + 2 * l_poc_room) * l_nb_poc;
-
-  l_current_data = p_data;
-
-  opj_write_bytes(l_current_data,J2K_MS_POC,2);          /* POC  */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_poc_size-2,2);          /* Lpoc */
-  l_current_data += 2;
-
-  l_current_poc =  l_tcp->pocs;
-  for
-    (i = 0; i < l_nb_poc; ++i)
-  {
-    opj_write_bytes(l_current_data,l_current_poc->resno0,1);        /* RSpoc_i */
-    ++l_current_data;
-    opj_write_bytes(l_current_data,l_current_poc->compno0,l_poc_room);    /* CSpoc_i */
-    l_current_data+=l_poc_room;
-    opj_write_bytes(l_current_data,l_current_poc->layno1,2);        /* LYEpoc_i */
-    l_current_data+=2;
-    opj_write_bytes(l_current_data,l_current_poc->resno1,1);        /* REpoc_i */
-    ++l_current_data;
-    opj_write_bytes(l_current_data,l_current_poc->compno1,l_poc_room);    /* CEpoc_i */
-    l_current_data+=l_poc_room;
-    opj_write_bytes(l_current_data,l_current_poc->prg,1);          /* Ppoc_i */
-    ++l_current_data;
-
-    /* change the value of the max layer according to the actual number of layers in the file, components and resolutions*/
-    l_current_poc->layno1 = int_min(l_current_poc->layno1, l_tcp->numlayers);
-    l_current_poc->resno1 = int_min(l_current_poc->resno1, l_tccp->numresolutions);
-    l_current_poc->compno1 = int_min(l_current_poc->compno1, l_nb_comp);
-    ++l_current_poc;
-  }
-  * p_data_written = l_poc_size;
-}
-
-
-/**
- * Reads a POC marker (Progression Order Change)
- *
- * @param  p_header_data  the data contained in the POC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the POC marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_poc (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_nb_comp;
-  opj_image_t * l_image = 00;
-  OPJ_UINT32 l_old_poc_nb,l_current_poc_nb,l_current_poc_remaining;
-  OPJ_UINT32 l_chunk_size;
-  OPJ_UINT32 l_tmp;
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_poc_t *l_current_poc = 00;
-  OPJ_UINT32 l_comp_room;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_image = p_j2k->m_image;
-  l_nb_comp = l_image->numcomps;
-  if
-    (l_nb_comp <= 256)
-  {
-    l_comp_room = 1;
-  }
-  else
-  {
-    l_comp_room = 2;
-  }
-  l_chunk_size = 5 + 2 * l_comp_room;
-  l_current_poc_nb = p_header_size / l_chunk_size;
-  l_current_poc_remaining = p_header_size % l_chunk_size;
-
-  if
-    ((l_current_poc_nb <= 0) || (l_current_poc_remaining != 0))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading POC marker\n");
-    return false;
-  }
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-  l_old_poc_nb = l_tcp->POC ? l_tcp->numpocs + 1 : 0;
-  l_current_poc_nb += l_old_poc_nb;
-  assert(l_current_poc_nb < 32);
-
-  /* now poc is in use.*/
-  l_tcp->POC = 1;
-
-  l_current_poc = &l_tcp->pocs[l_old_poc_nb];
-  for
-    (i = l_old_poc_nb; i < l_current_poc_nb; ++i)
-  {
-    opj_read_bytes(p_header_data,&(l_current_poc->resno0),1);          /* RSpoc_i */
-    ++p_header_data;
-    opj_read_bytes(p_header_data,&(l_current_poc->compno0),l_comp_room);    /* CSpoc_i */
-    p_header_data+=l_comp_room;
-    opj_read_bytes(p_header_data,&(l_current_poc->layno1),2);          /* LYEpoc_i */
-    p_header_data+=2;
-    opj_read_bytes(p_header_data,&(l_current_poc->resno1),1);           /* REpoc_i */
-    ++p_header_data;
-    opj_read_bytes(p_header_data,&(l_current_poc->compno1),l_comp_room);    /* CEpoc_i */
-    p_header_data+=l_comp_room;
-    opj_read_bytes(p_header_data,&l_tmp,1);            /* Ppoc_i */
-    ++p_header_data;
-    l_current_poc->prg = (OPJ_PROG_ORDER) l_tmp;
-    /* make sure comp is in acceptable bounds */
-    l_current_poc->compno1 = uint_min(l_current_poc->compno1, l_nb_comp);
-    ++l_current_poc;
-  }
-  l_tcp->numpocs = l_current_poc_nb - 1;
-  return true;
-}
-
-/**
- * Writes the RGN marker (Region Of Interest)
- *
- * @param  p_tile_no    the tile to output
- * @param  p_comp_no    the component to output
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_rgn(
-            opj_j2k_t *p_j2k,
-            OPJ_UINT32 p_tile_no,
-            OPJ_UINT32 p_comp_no,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_BYTE * l_current_data = 00;
-  OPJ_UINT32 l_nb_comp;
-  OPJ_UINT32 l_rgn_size;
-  opj_image_t *l_image = 00;
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  opj_tccp_t *l_tccp = 00;
-  OPJ_UINT32 l_comp_room;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_tile_no];
-  l_tccp = &l_tcp->tccps[p_comp_no];
-
-  l_nb_comp = l_image->numcomps;
-
-  if
-    (l_nb_comp <= 256)
-  {
-    l_comp_room = 1;
-  }
-  else
-  {
-    l_comp_room = 2;
-  }
-  l_rgn_size = 6 + l_comp_room;
-
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-  opj_write_bytes(l_current_data,J2K_MS_RGN,2);          /* RGN  */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_rgn_size-2,2);          /* Lrgn */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,p_comp_no,l_comp_room);      /* Crgn */
-  l_current_data+=l_comp_room;
-  opj_write_bytes(l_current_data, 0,1);              /* Srgn */
-  ++l_current_data;
-  opj_write_bytes(l_current_data, l_tccp->roishift,1);      /* SPrgn */
-  ++l_current_data;
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_rgn_size,p_manager) != l_rgn_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a RGN marker (Region Of Interest)
- *
- * @param  p_header_data  the data contained in the POC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the POC marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_rgn (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_nb_comp;
-  opj_image_t * l_image = 00;
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  OPJ_UINT32 l_comp_room;
-  OPJ_UINT32 l_comp_no;
-  OPJ_UINT32 l_roi_sty;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_image = p_j2k->m_image;
-  l_nb_comp = l_image->numcomps;
-  if
-    (l_nb_comp <= 256)
-  {
-    l_comp_room = 1;
-  }
-  else
-  {
-    l_comp_room = 2;
-  }
-  if
-    (p_header_size != 2 + l_comp_room)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading RGN marker\n");
-    return false;
-  }
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
-
-  opj_read_bytes(p_header_data,&l_comp_no,l_comp_room);    /* Crgn */
-  p_header_data+=l_comp_room;
-  opj_read_bytes(p_header_data,&l_roi_sty,1);          /* Srgn */
-  ++p_header_data;
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-    /* totlen is negative or larger than the bytes left!!! */
-    if (compno >= numcomps) {
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "JPWL: bad component number in RGN (%d when there are only %d)\n",
-        compno, numcomps);
-      if (!JPWL_ASSUME || JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-    }
-  };
-#endif /* USE_JPWL */
-
-  opj_read_bytes(p_header_data,(OPJ_UINT32 *) (&(l_tcp->tccps[l_comp_no].roishift)),1);  /* SPrgn */
-  ++p_header_data;
-  return true;
-
-}
-
-/**
- * Writes the TLM marker (Tile Length Marker)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_tlm(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_BYTE * l_current_data = 00;
-  OPJ_UINT32 l_tlm_size;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_tlm_size = 6 + (5*p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
-  if
-    (l_tlm_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
-  {
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data
-      = (OPJ_BYTE*)opj_realloc(
-        p_j2k->m_specific_param.m_encoder.m_header_tile_data,
-        l_tlm_size);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_tlm_size;
-  }
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
-
-  /* change the way data is written to avoid seeking if possible */
-  // TODO
-  p_j2k->m_specific_param.m_encoder.m_tlm_start = opj_stream_tell(p_stream);
-
-  opj_write_bytes(l_current_data,J2K_MS_TLM,2);          /* TLM */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,l_tlm_size-2,2);          /* Lpoc */
-  l_current_data += 2;
-  opj_write_bytes(l_current_data,0,1);              /* Ztlm=0*/
-  ++l_current_data;
-  opj_write_bytes(l_current_data,0x50,1);              /* Stlm ST=1(8bits-255 tiles max),SP=1(Ptlm=32bits) */
-  ++l_current_data;
-  /* do nothing on the 5 * l_j2k->m_specific_param.m_encoder.m_total_tile_parts remaining data */
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_tlm_size,p_manager) != l_tlm_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a TLM marker (Tile Length Marker)
- *
- * @param  p_header_data  the data contained in the TLM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the TLM marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_tlm (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_Ztlm, l_Stlm, l_ST, l_SP, l_tot_num_tp, l_tot_num_tp_remaining, l_quotient, l_Ptlm_size;
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_header_size < 2)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading TLM marker\n");
-    return false;
-  }
-  p_header_size -= 2;
-
-
-  opj_read_bytes(p_header_data,&l_Ztlm,1);        /* Ztlm */
-  ++p_header_data;
-  opj_read_bytes(p_header_data,&l_Stlm,1);        /* Stlm */
-  ++p_header_data;
-
-  l_ST = ((l_Stlm >> 4) & 0x3);
-  l_SP = (l_Stlm >> 6) & 0x1;
-
-  l_Ptlm_size = (l_SP + 1) * 2;
-  l_quotient = l_Ptlm_size + l_ST;
-
-  l_tot_num_tp = p_header_size / l_quotient;
-  l_tot_num_tp_remaining = p_header_size % l_quotient;
-  if
-    (l_tot_num_tp_remaining != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading TLM marker\n");
-    return false;
-  }
-  /* Do not care of this at the moment since only local variables are set here */
-  /*
-  for
-    (i = 0; i < l_tot_num_tp; ++i)
-  {
-    opj_read_bytes(p_header_data,&l_Ttlm_i,l_ST);        // Ttlm_i
-    p_header_data += l_ST;
-    opj_read_bytes(p_header_data,&l_Ptlm_i,l_Ptlm_size);    // Ptlm_i
-    p_header_data += l_Ptlm_size;
-  }*/
-  return true;
-}
-
-/**
- * Reads a CRG marker (Component registration)
- *
- * @param  p_header_data  the data contained in the TLM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the TLM marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_crg (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_nb_comp;
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  l_nb_comp = p_j2k->m_image->numcomps;
-
-  if
-    (p_header_size != l_nb_comp *4)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading CRG marker\n");
-    return false;
-  }
-  /* Do not care of this at the moment since only local variables are set here */
-  /*
-  for
-    (i = 0; i < l_nb_comp; ++i)
-  {
-    opj_read_bytes(p_header_data,&l_Xcrg_i,2);        // Xcrg_i
-    p_header_data+=2;
-    opj_read_bytes(p_header_data,&l_Ycrg_i,2);        // Xcrg_i
-    p_header_data+=2;
-  }
-  */
-  return true;
-}
-
-/**
- * Reads a PLM marker (Packet length, main header marker)
- *
- * @param  p_header_data  the data contained in the TLM box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the TLM marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_plm (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_header_size < 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
-    return false;
-  }
-  /* Do not care of this at the moment since only local variables are set here */
-  /*
-  opj_read_bytes(p_header_data,&l_Zplm,1);          // Zplm
-  ++p_header_data;
-  --p_header_size;
-
-  while
-    (p_header_size > 0)
-  {
-    opj_read_bytes(p_header_data,&l_Nplm,1);        // Nplm
-    ++p_header_data;
-    p_header_size -= (1+l_Nplm);
-    if
-      (p_header_size < 0)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
-      return false;
-    }
-    for
-      (i = 0; i < l_Nplm; ++i)
-    {
-      opj_read_bytes(p_header_data,&l_tmp,1);        // Iplm_ij
-      ++p_header_data;
-      // take only the last seven bytes
-      l_packet_len |= (l_tmp & 0x7f);
-      if
-        (l_tmp & 0x80)
-      {
-        l_packet_len <<= 7;
-      }
-      else
-      {
-                // store packet length and proceed to next packet
-        l_packet_len = 0;
-      }
-    }
-    if
-      (l_packet_len != 0)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
-      return false;
-    }
-  }
-  */
-  return true;
-}
-
-/**
- * Reads a PLT marker (Packet length, tile-part header)
- *
- * @param  p_header_data  the data contained in the PLT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the PLT marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_plt (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_Zplt, l_tmp, l_packet_len = 0, i;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_header_size < 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
-    return false;
-  }
-
-  opj_read_bytes(p_header_data,&l_Zplt,1);          // Zplt
-  ++p_header_data;
-  --p_header_size;
-  for
-    (i = 0; i < p_header_size; ++i)
-  {
-    opj_read_bytes(p_header_data,&l_tmp,1);        // Iplm_ij
-    ++p_header_data;
-    // take only the last seven bytes
-    l_packet_len |= (l_tmp & 0x7f);
-    if
-      (l_tmp & 0x80)
-    {
-      l_packet_len <<= 7;
-    }
-    else
-    {
-            // store packet length and proceed to next packet
-      l_packet_len = 0;
-    }
-  }
-  if
-    (l_packet_len != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a PPM marker (Packed packet headers, main header)
- *
- * @param  p_header_data  the data contained in the POC box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the POC marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_ppm (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-
-  opj_cp_t *l_cp = 00;
-  OPJ_UINT32 l_remaining_data, l_Z_ppm, l_N_ppm;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_header_size < 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading RGN marker\n");
-    return false;
-  }
-  l_cp = &(p_j2k->m_cp);
-  l_cp->ppm = 1;
-
-  opj_read_bytes(p_header_data,&l_Z_ppm,1);    /* Z_ppm */
-  ++p_header_data;
-  --p_header_size;
-
-  // first PPM marker
-  if
-    (l_Z_ppm == 0)
-  {
-    if
-      (p_header_size < 4)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error reading PPM marker\n");
-      return false;
-    }
-    // read a N_ppm
-    opj_read_bytes(p_header_data,&l_N_ppm,4);    /* N_ppm */
-    p_header_data+=4;
-    p_header_size-=4;
-    /* First PPM marker */
-    l_cp->ppm_len = l_N_ppm;
-    l_cp->ppm_data_size = 0;
-    l_cp->ppm_buffer = (OPJ_BYTE *) opj_malloc(l_cp->ppm_len);
-    l_cp->ppm_data = l_cp->ppm_buffer;
-    if
-      (l_cp->ppm_buffer == 00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Not enough memory reading ppm marker\n");
-      return false;
-    }
-    memset(l_cp->ppm_buffer,0,l_cp->ppm_len);
-  }
-
-  while
-    (true)
-  {
-    if
-      (l_cp->ppm_data_size == l_cp->ppm_len)
-    {
-      if
-        (p_header_size >= 4)
-      {
-        // read a N_ppm
-        opj_read_bytes(p_header_data,&l_N_ppm,4);    /* N_ppm */
-        p_header_data+=4;
-        p_header_size-=4;
-        l_cp->ppm_len += l_N_ppm ;
-        l_cp->ppm_buffer = (OPJ_BYTE *) opj_realloc(l_cp->ppm_buffer, l_cp->ppm_len);
-        l_cp->ppm_data = l_cp->ppm_buffer;
-        if
-          (l_cp->ppm_buffer == 00)
-        {
-          opj_event_msg(p_manager, EVT_ERROR, "Not enough memory reading ppm marker\n");
-          return false;
-        }
-        memset(l_cp->ppm_buffer+l_cp->ppm_data_size,0,l_N_ppm);
-      }
-      else
-      {
-        return false;
-      }
-    }
-    l_remaining_data = l_cp->ppm_len - l_cp->ppm_data_size;
-    if
-      (l_remaining_data <= p_header_size)
-    {
-      /* we must store less information than available in the packet */
-      memcpy(l_cp->ppm_buffer + l_cp->ppm_data_size , p_header_data , l_remaining_data);
-      l_cp->ppm_data_size = l_cp->ppm_len;
-      p_header_size -= l_remaining_data;
-      p_header_data += l_remaining_data;
-    }
-    else
-    {
-      memcpy(l_cp->ppm_buffer + l_cp->ppm_data_size , p_header_data , p_header_size);
-      l_cp->ppm_data_size += p_header_size;
-      p_header_data += p_header_size;
-      p_header_size = 0;
-      break;
-    }
-  }
-  return true;
-}
-
-/**
- * Reads a PPT marker (Packed packet headers, tile-part header)
- *
- * @param  p_header_data  the data contained in the PPT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the PPT marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_ppt (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  OPJ_UINT32 l_Z_ppt;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_header_size < 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading PPT marker\n");
-    return false;
-  }
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &(l_cp->tcps[p_j2k->m_current_tile_number]);
-  l_tcp->ppt = 1;
-
-  opj_read_bytes(p_header_data,&l_Z_ppt,1);    /* Z_ppt */
-  ++p_header_data;
-  --p_header_size;
-
-  // first PPM marker
-  if
-    (l_Z_ppt == 0)
-  {
-    /* First PPM marker */
-    l_tcp->ppt_len = p_header_size;
-    l_tcp->ppt_data_size = 0;
-    l_tcp->ppt_buffer = (OPJ_BYTE *) opj_malloc(l_tcp->ppt_len);
-    l_tcp->ppt_data = l_tcp->ppt_buffer;
-    if
-      (l_tcp->ppt_buffer == 00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Not enough memory reading PPT marker\n");
-      return false;
-    }
-    memset(l_tcp->ppt_buffer,0,l_tcp->ppt_len);
-  }
-  else
-  {
-    l_tcp->ppt_len += p_header_size;
-    l_tcp->ppt_buffer = (OPJ_BYTE *) opj_realloc(l_tcp->ppt_buffer,l_tcp->ppt_len);
-    if
-      (l_tcp->ppt_buffer == 00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Not enough memory reading PPT marker\n");
-      return false;
-    }
-    l_tcp->ppt_data = l_tcp->ppt_buffer;
-    memset(l_tcp->ppt_buffer+l_tcp->ppt_data_size,0,p_header_size);
-  }
-  memcpy(l_tcp->ppt_buffer+l_tcp->ppt_data_size,p_header_data,p_header_size);
-  l_tcp->ppt_data_size += p_header_size;
-  return true;
-}
-
-/**
- * Writes the SOT marker (Start of tile-part)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_sot(
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_data,
-            OPJ_UINT32 * p_data_written,
-            const struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  opj_write_bytes(p_data,J2K_MS_SOT,2);          /* SOT */
-  p_data += 2;
-
-  opj_write_bytes(p_data,10,2);              /* Lsot */
-  p_data += 2;
-
-  opj_write_bytes(p_data, p_j2k->m_current_tile_number,2);      /* Isot */
-  p_data += 2;
-
-  /* Psot  */
-  p_data += 4;
-
-  opj_write_bytes(p_data, p_j2k->m_specific_param.m_encoder.m_current_tile_part_number,1);      /* TPsot */
-  ++p_data;
-
-  opj_write_bytes(p_data, p_j2k->m_cp.tcps[p_j2k->m_current_tile_number].m_nb_tile_parts,1);      /* TNsot */
-  ++p_data;
-  /* UniPG>> */
-#ifdef USE_JPWL
-  /* update markers struct */
-  j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOT, p_j2k->sot_start, len + 2);
-#endif /* USE_JPWL */
-
-  * p_data_written = 12;
-  return true;
-}
-
-/**
- * Reads a PPT marker (Packed packet headers, tile-part header)
- *
- * @param  p_header_data  the data contained in the PPT box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the PPT marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_sot (
-            opj_j2k_t *p_j2k,
-            OPJ_BYTE * p_header_data,
-            OPJ_UINT32 p_header_size,
-            struct opj_event_mgr * p_manager
-          )
-{
-
-  opj_cp_t *l_cp = 00;
-  opj_tcp_t *l_tcp = 00;
-  OPJ_UINT32 l_tot_len, l_num_parts = 0;
-  OPJ_UINT32 l_current_part;
-  OPJ_UINT32 l_tile_x,l_tile_y;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_header_size != 8)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error reading SOT marker\n");
-    return false;
-  }
-  l_cp = &(p_j2k->m_cp);
-  opj_read_bytes(p_header_data,&(p_j2k->m_current_tile_number),2);    /* Isot */
-  p_header_data+=2;
-
-
-  l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
-  l_tile_x = p_j2k->m_current_tile_number % l_cp->tw;
-  l_tile_y = p_j2k->m_current_tile_number / l_cp->tw;
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-
-    static int backup_tileno = 0;
-
-    /* tileno is negative or larger than the number of tiles!!! */
-    if ((tileno < 0) || (tileno > (cp->tw * cp->th))) {
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "JPWL: bad tile number (%d out of a maximum of %d)\n",
-        tileno, (cp->tw * cp->th));
-      if (!JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-      /* we try to correct */
-      tileno = backup_tileno;
-      opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- trying to adjust this\n"
-        "- setting tile number to %d\n",
-        tileno);
-    }
-
-    /* keep your private count of tiles */
-    backup_tileno++;
-  };
-#endif /* USE_JPWL */
-
-  /* look for the tile in the list of already processed tile (in parts). */
-  /* Optimization possible here with a more complex data structure and with the removing of tiles */
-  /* since the time taken by this function can only grow at the time */
-
-  opj_read_bytes(p_header_data,&l_tot_len,4);    /* Psot */
-  p_header_data+=4;
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-
-    /* totlen is negative or larger than the bytes left!!! */
-    if ((totlen < 0) || (totlen > (p_stream_numbytesleft(p_stream) + 8))) {
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "JPWL: bad tile byte size (%d bytes against %d bytes left)\n",
-        totlen, p_stream_numbytesleft(p_stream) + 8);
-      if (!JPWL_ASSUME) {
-        opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
-        return;
-      }
-      /* we try to correct */
-      totlen = 0;
-      opj_event_msg(p_j2k->cinfo, EVT_WARNING, "- trying to adjust this\n"
-        "- setting Psot to %d => assuming it is the last tile\n",
-        totlen);
-    }
-
-  };
-#endif /* USE_JPWL */
-
-  if
-    (!l_tot_len)
-  {
-    void* l_data = p_manager->m_error_data;
-      assert( l_data );
-    if( l_data )
-      {
-      OPJ_UINT32 **s = (OPJ_UINT32**)l_data;
-      assert( s[1] == 0 );
-      if( s[1] == 0 )
-        {
-        s[1] = &l_tot_len;
-        }
-      }
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot read data with no size known, giving up\n");
-    assert( l_tot_len != 0 );
-    if( !l_tot_len )
-      return false;
-  }
-
-  opj_read_bytes(p_header_data,&l_current_part ,1);    /* Psot */
-  ++p_header_data;
-
-  opj_read_bytes(p_header_data,&l_num_parts ,1);    /* Psot */
-  ++p_header_data;
-
-  if
-    (l_num_parts != 0)
-  {
-    l_tcp->m_nb_tile_parts = l_num_parts;
-  }
-  if
-    (l_tcp->m_nb_tile_parts)
-  {
-    if
-      (l_tcp->m_nb_tile_parts == (l_current_part + 1))
-    {
-      p_j2k->m_specific_param.m_decoder.m_can_decode = 1;
-    }
-  }
-  p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12;
-  p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_TPH;
-  p_j2k->m_specific_param.m_decoder.m_skip_data =
-      (l_tile_x < p_j2k->m_specific_param.m_decoder.m_start_tile_x)
-    ||  (l_tile_x >= p_j2k->m_specific_param.m_decoder.m_end_tile_x)
-    ||  (l_tile_y < p_j2k->m_specific_param.m_decoder.m_start_tile_y)
-    ||  (l_tile_y >= p_j2k->m_specific_param.m_decoder.m_end_tile_y);
-  /* Index */
-
-  /* move this onto a separate method to call before reading any SOT */
-  /*if
-    TODO
-    (p_j2k->cstr_info)
-  {
-    if
-      (l_tcp->first)
-    {
-      if
-        (tileno == 0)
-      {
-        p_j2k->cstr_info->main_head_end = p_stream_tell(p_stream) - 13;
-      }
-      p_j2k->cstr_info->tile[tileno].tileno = tileno;
-      p_j2k->cstr_info->tile[tileno].start_pos = p_stream_tell(p_stream) - 12;
-      p_j2k->cstr_info->tile[tileno].end_pos = p_j2k->cstr_info->tile[tileno].start_pos + totlen - 1;
-      p_j2k->cstr_info->tile[tileno].num_tps = numparts;
-      if
-        (numparts)
-      {
-        p_j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t));
-      }
-      else
-      {
-        p_j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10)
-      }
-    }
-    else
-    {
-      p_j2k->cstr_info->tile[tileno].end_pos += totlen;
-    }
-    p_j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = p_stream_tell(p_stream) - 12;
-    p_j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos =
-    p_j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1;
-  }*/
-  return true;
-}
-
-/**
- * Writes the SOD marker (Start of data)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_sod(
-            opj_j2k_t *p_j2k,
-            struct opj_tcd * p_tile_coder,
-            OPJ_BYTE * p_data,
-            OPJ_UINT32 * p_data_written,
-            OPJ_UINT32 p_total_data_size,
-            const struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  opj_tcp_t *l_tcp = 00;
-  opj_codestream_info_t *l_cstr_info = 00;
-  opj_cp_t *l_cp = 00;
-
-  OPJ_UINT32 l_size_tile;
-  OPJ_UINT32 l_remaining_data;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  opj_write_bytes(p_data,J2K_MS_SOD,2);          /* SOD */
-  p_data += 2;
-
-  /* make room for the EOF marker */
-  l_remaining_data =  p_total_data_size - 4;
-
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
-  l_cstr_info = p_j2k->cstr_info;
-
-  /* update tile coder */
-  p_tile_coder->tp_num = p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number ;
-  p_tile_coder->cur_tp_num = p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
-  l_size_tile = l_cp->th * l_cp->tw;
-
-  /* INDEX >> */
-  if
-    (l_cstr_info)
-  {
-    if
-      (!p_j2k->m_specific_param.m_encoder.m_current_tile_part_number )
-    {
-      //TODO cstr_info->tile[p_j2k->m_current_tile_number].end_header = p_stream_tell(p_stream) + p_j2k->pos_correction - 1;
-      l_cstr_info->tile[p_j2k->m_current_tile_number].tileno = p_j2k->m_current_tile_number;
-    }
-    else
-    {
-      /*
-      TODO
-      if
-        (cstr_info->tile[p_j2k->m_current_tile_number].packet[cstr_info->packno - 1].end_pos < p_stream_tell(p_stream))
-      {
-        cstr_info->tile[p_j2k->m_current_tile_number].packet[cstr_info->packno].start_pos = p_stream_tell(p_stream);
-      }*/
-
-    }
-    /* UniPG>> */
-#ifdef USE_JPWL
-    /* update markers struct */
-    j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOD, p_j2k->sod_start, 2);
-#endif /* USE_JPWL */
-    /* <<UniPG */
-  }
-  /* << INDEX */
-
-  if
-    (p_j2k->m_specific_param.m_encoder.m_current_tile_part_number == 0)
-  {
-    p_tile_coder->tcd_image->tiles->packno = 0;
-    if
-      (l_cstr_info)
-    {
-      l_cstr_info->packno = 0;
-    }
-  }
-  *p_data_written = 0;
-  if
-    (! tcd_encode_tile(p_tile_coder, p_j2k->m_current_tile_number, p_data, p_data_written, l_remaining_data , l_cstr_info))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot encode tile\n");
-    return false;
-  }
-  *p_data_written += 2;
-  return true;
-}
-
-/**
- * Updates the Tile Length Marker.
- */
-void j2k_update_tlm (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 p_tile_part_size
-           )
-{
-  opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,p_j2k->m_current_tile_number,1);          /* PSOT */
-  ++p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current;
-  opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,p_tile_part_size,4);          /* PSOT */
-  p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 4;
-}
-
-
-/**
- * Reads a SOD marker (Start Of Data)
- *
- * @param  p_header_data  the data contained in the SOD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the SOD marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_sod (
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_current_read_size;
-  opj_codestream_info_t * l_cstr_info = 00;
-  OPJ_BYTE ** l_current_data = 00;
-  opj_tcp_t * l_tcp = 00;
-  OPJ_UINT32 * l_tile_len = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
-  p_j2k->m_specific_param.m_decoder.m_sot_length -= 2;
-  l_cstr_info = p_j2k->cstr_info;
-
-  l_current_data = &(l_tcp->m_data);
-  l_tile_len = &l_tcp->m_data_size;
-
-  if
-    (! *l_current_data)
-  {
-    *l_current_data = (OPJ_BYTE*) my_opj_malloc(p_j2k->m_specific_param.m_decoder.m_sot_length);
-  }
-  else
-  {
-    *l_current_data = (OPJ_BYTE*) my_opj_realloc(*l_current_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length);
-  }
-  if
-    (*l_current_data == 00)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile\n");
-    return false;
-  }
-
-  /* Index */
-  if
-    (l_cstr_info)
-  {
-    OPJ_SIZE_T l_current_pos = opj_stream_tell(p_stream)-1;
-    l_cstr_info->tile[p_j2k->m_current_tile_number].tp[p_j2k->m_specific_param.m_encoder.m_current_tile_part_number].tp_end_header = l_current_pos;
-    if
-      (p_j2k->m_specific_param.m_encoder.m_current_tile_part_number == 0)
-    {
-      l_cstr_info->tile[p_j2k->m_current_tile_number].end_header = l_current_pos;
-    }
-    l_cstr_info->packno = 0;
-  }
-  l_current_read_size = opj_stream_read_data(p_stream, *l_current_data + *l_tile_len , p_j2k->m_specific_param.m_decoder.m_sot_length,p_manager);
-  if
-    (l_current_read_size != p_j2k->m_specific_param.m_decoder.m_sot_length)
-  {
-    p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_NEOC;
-  }
-  else
-  {
-    p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_TPHSOT;
-  }
-  *l_tile_len +=  l_current_read_size;
-  return true;
-}
-
-/**
- * Writes the EOC marker (End of Codestream)
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_eoc(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_header_tile_data,J2K_MS_EOC,2);          /* EOC */
-
-
-/* UniPG>> */
-#ifdef USE_JPWL
-  /* update markers struct */
-  j2k_add_marker(p_j2k->cstr_info, J2K_MS_EOC, p_stream_tell(p_stream) - 2, 2);
-#endif /* USE_JPWL */
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,2,p_manager) != 2)
-  {
-    return false;
-  }
-  if
-    (! opj_stream_flush(p_stream,p_manager))
-  {
-    return false;
-  }
-  return true;
-}
-
-
-/**
- * Inits the Info
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_init_info(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  opj_codestream_info_t * l_cstr_info = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-  l_cstr_info = p_j2k->cstr_info;
-
-  if
-    (l_cstr_info)
-  {
-    OPJ_UINT32 compno;
-    l_cstr_info->tile = (opj_tile_info_t *) opj_malloc(p_j2k->m_cp.tw * p_j2k->m_cp.th * sizeof(opj_tile_info_t));
-    l_cstr_info->image_w = p_j2k->m_image->x1 - p_j2k->m_image->x0;
-    l_cstr_info->image_h = p_j2k->m_image->y1 - p_j2k->m_image->y0;
-    l_cstr_info->prog = (&p_j2k->m_cp.tcps[0])->prg;
-    l_cstr_info->tw = p_j2k->m_cp.tw;
-    l_cstr_info->th = p_j2k->m_cp.th;
-    l_cstr_info->tile_x = p_j2k->m_cp.tdx;  /* new version parser */
-    l_cstr_info->tile_y = p_j2k->m_cp.tdy;  /* new version parser */
-    l_cstr_info->tile_Ox = p_j2k->m_cp.tx0;  /* new version parser */
-    l_cstr_info->tile_Oy = p_j2k->m_cp.ty0;  /* new version parser */
-    l_cstr_info->numcomps = p_j2k->m_image->numcomps;
-    l_cstr_info->numlayers = (&p_j2k->m_cp.tcps[0])->numlayers;
-    l_cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(p_j2k->m_image->numcomps * sizeof(OPJ_INT32));
-    for (compno=0; compno < p_j2k->m_image->numcomps; compno++) {
-      l_cstr_info->numdecompos[compno] = (&p_j2k->m_cp.tcps[0])->tccps->numresolutions - 1;
-    }
-    l_cstr_info->D_max = 0.0;    /* ADD Marcela */
-    l_cstr_info->main_head_start = opj_stream_tell(p_stream); /* position of SOC */
-    l_cstr_info->maxmarknum = 100;
-    l_cstr_info->marker = (opj_marker_info_t *) opj_malloc(l_cstr_info->maxmarknum * sizeof(opj_marker_info_t));
-    l_cstr_info->marknum = 0;
-  }
-  return j2k_calculate_tp(p_j2k,&(p_j2k->m_cp),&p_j2k->m_specific_param.m_encoder.m_total_tile_parts,p_j2k->m_image,p_manager);
-}
-
-/**
- * Creates a tile-coder decoder.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_create_tcd(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  p_j2k->m_tcd = tcd_create(false);
-  if
-    (! p_j2k->m_tcd)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to create Tile Coder\n");
-    return false;
-  }
-  if
-    (! tcd_init(p_j2k->m_tcd,p_j2k->m_image,&p_j2k->m_cp))
-  {
-    tcd_destroy(p_j2k->m_tcd);
-    p_j2k->m_tcd = 00;
-    return false;
-  }
-  return true;
-}
-
-OPJ_FLOAT32 get_tp_stride (opj_tcp_t * p_tcp)
-{
-  return (OPJ_FLOAT32) ((p_tcp->m_nb_tile_parts - 1) * 14);
-}
-
-OPJ_FLOAT32 get_default_stride (opj_tcp_t * p_tcp)
-{
-  return 0;
-}
-
-/**
- * Updates the rates of the tcp.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_update_rates(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  opj_cp_t * l_cp = 00;
-  opj_image_t * l_image = 00;
-  opj_tcp_t * l_tcp = 00;
-  opj_image_comp_t * l_img_comp = 00;
-
-  OPJ_UINT32 i,j,k;
-  OPJ_INT32 l_x0,l_y0,l_x1,l_y1;
-  OPJ_FLOAT32 * l_rates = 0;
-  OPJ_FLOAT32 l_sot_remove;
-  OPJ_UINT32 l_bits_empty, l_size_pixel;
-  OPJ_UINT32 l_tile_size = 0;
-  OPJ_UINT32 l_last_res;
-  OPJ_FLOAT32 (* l_tp_stride_func)(opj_tcp_t *) = 00;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-
-  l_cp = &(p_j2k->m_cp);
-  l_image = p_j2k->m_image;
-  l_tcp = l_cp->tcps;
-
-  l_bits_empty = 8 * l_image->comps->dx * l_image->comps->dy;
-  l_size_pixel = l_image->numcomps * l_image->comps->prec;
-  l_sot_remove = ((OPJ_FLOAT32) opj_stream_tell(p_stream)) / (l_cp->th * l_cp->tw);
-
-  if
-    (l_cp->m_specific_param.m_enc.m_tp_on)
-  {
-    l_tp_stride_func = get_tp_stride;
-  }
-  else
-  {
-    l_tp_stride_func = get_default_stride;
-  }
-
-  for
-    (i=0;i<l_cp->th;++i)
-  {
-    for
-      (j=0;j<l_cp->tw;++j)
-    {
-      OPJ_FLOAT32 l_offset = ((*l_tp_stride_func)(l_tcp)) / l_tcp->numlayers;
-      /* 4 borders of the tile rescale on the image if necessary */
-      l_x0 = int_max(l_cp->tx0 + j * l_cp->tdx, l_image->x0);
-      l_y0 = int_max(l_cp->ty0 + i * l_cp->tdy, l_image->y0);
-      l_x1 = int_min(l_cp->tx0 + (j + 1) * l_cp->tdx, l_image->x1);
-      l_y1 = int_min(l_cp->ty0 + (i + 1) * l_cp->tdy, l_image->y1);
-      l_rates = l_tcp->rates;
-
-      /* Modification of the RATE >> */
-      if
-        (*l_rates)
-      {
-        *l_rates =     (( (float) (l_size_pixel * (l_x1 - l_x0) * (l_y1 - l_y0)))
-                /
-                ((*l_rates) * l_bits_empty)
-                )
-                -
-                l_offset;
-      }
-      ++l_rates;
-      for
-        (k = 1; k < l_tcp->numlayers; ++k)
-      {
-        if
-          (*l_rates)
-        {
-          *l_rates =     (( (OPJ_FLOAT32) (l_size_pixel * (l_x1 - l_x0) * (l_y1 - l_y0)))
-                  /
-                    ((*l_rates) * l_bits_empty)
-                  )
-                  -
-                  l_offset;
-        }
-        ++l_rates;
-      }
-      ++l_tcp;
-    }
-  }
-
-  l_tcp = l_cp->tcps;
-  for
-    (i=0;i<l_cp->th;++i)
-  {
-    for
-      (j=0;j<l_cp->tw;++j)
-    {
-      l_rates = l_tcp->rates;
-      if
-        (*l_rates)
-      {
-        *l_rates -= l_sot_remove;
-        if
-          (*l_rates < 30)
-        {
-          *l_rates = 30;
-        }
-      }
-      ++l_rates;
-      l_last_res = l_tcp->numlayers - 1;
-      for
-        (k = 1; k < l_last_res; ++k)
-      {
-        if
-          (*l_rates)
-        {
-          *l_rates -= l_sot_remove;
-          if
-            (*l_rates < *(l_rates - 1) + 10)
-          {
-            *l_rates  = (*(l_rates - 1)) + 20;
-          }
-        }
-        ++l_rates;
-      }
-      if
-        (*l_rates)
-      {
-        *l_rates -= (l_sot_remove + 2.f);
-        if
-          (*l_rates < *(l_rates - 1) + 10)
-        {
-          *l_rates  = (*(l_rates - 1)) + 20;
-        }
-      }
-      ++l_tcp;
-    }
-  }
-
-  l_img_comp = l_image->comps;
-  l_tile_size = 0;
-  for
-    (i=0;i<l_image->numcomps;++i)
-  {
-    l_tile_size += (    uint_ceildiv(l_cp->tdx,l_img_comp->dx)
-             *
-                uint_ceildiv(l_cp->tdy,l_img_comp->dy)
-             *
-                l_img_comp->prec
-            );
-    ++l_img_comp;
-  }
-
-  l_tile_size = (OPJ_UINT32) (l_tile_size * 0.1625); /* 1.3/8 = 0.1625 */
-  l_tile_size += j2k_get_specific_header_sizes(p_j2k);
-
-  p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = l_tile_size;
-  p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = (OPJ_BYTE *) my_opj_malloc(p_j2k->m_specific_param.m_encoder.m_encoded_tile_size);
-  if
-    (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data == 00)
-  {
-    return false;
-  }
-  if
-    (l_cp->m_specific_param.m_enc.m_cinema)
-  {
-    p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = (OPJ_BYTE *) opj_malloc(5*p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
-    if
-      (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer)
-    {
-      return false;
-    }
-    p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer;
-  }
-  return true;
-}
-
-/**
- * Reads a EOC marker (End Of Codestream)
- *
- * @param  p_header_data  the data contained in the SOD box.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_header_size  the size of the data contained in the SOD marker.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_read_eoc (
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 i;
-  opj_tcd_t * l_tcd = 00;
-  OPJ_UINT32 l_nb_tiles;
-  opj_tcp_t * l_tcp = 00;
-  bool l_success;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
-  l_tcp = p_j2k->m_cp.tcps;
-
-  l_tcd = tcd_create(true);
-  if
-    (l_tcd == 00)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
-    return false;
-  }
-
-
-
-  for
-    (i = 0; i < l_nb_tiles; ++i)
-  {
-    if
-      (l_tcp->m_data)
-    {
-      if
-        (! tcd_init_decode_tile(l_tcd, i))
-      {
-        tcd_destroy(l_tcd);
-        opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
-        return false;
-      }
-      l_success = tcd_decode_tile(l_tcd, l_tcp->m_data, l_tcp->m_data_size, i, p_j2k->cstr_info);
-      /* cleanup */
-      if
-        (! l_success)
-      {
-        p_j2k->m_specific_param.m_decoder.m_state |= J2K_DEC_STATE_ERR;
-        break;
-      }
-    }
-    j2k_tcp_destroy(l_tcp);
-    ++l_tcp;
-  }
-  tcd_destroy(l_tcd);
-  return true;
-}
-
-/**
- * Writes the image components.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_image_components(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 compno;
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  for
-    (compno = 1; compno < p_j2k->m_image->numcomps; ++compno)
-  {
-    if
-      (! j2k_write_coc(p_j2k,compno,p_stream, p_manager))
-    {
-      return false;
-    }
-    if
-      (! j2k_write_qcc(p_j2k,compno,p_stream, p_manager))
-    {
-      return false;
-    }
-  }
-  return true;
-}
-
-/**
- * Writes regions of interests.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_regions(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 compno;
-  const opj_tccp_t *l_tccp = 00;
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_tccp = p_j2k->m_cp.tcps->tccps;
-  for
-    (compno = 0; compno < p_j2k->m_image->numcomps; ++compno)
-  {
-    if
-      (l_tccp->roishift)
-    {
-      if
-        (! j2k_write_rgn(p_j2k,0,compno,p_stream,p_manager))
-      {
-        return false;
-      }
-    }
-    ++l_tccp;
-  }
-  return true;
-}
-/**
- * Writes the updated tlm.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_write_updated_tlm(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_UINT32 l_tlm_size;
-  OPJ_SIZE_T l_tlm_position, l_current_position;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  l_tlm_size = 5 * p_j2k->m_specific_param.m_encoder.m_total_tile_parts;
-  l_tlm_position = 6 + p_j2k->m_specific_param.m_encoder.m_tlm_start;
-  l_current_position = opj_stream_tell(p_stream);
-
-  if
-    (! opj_stream_seek(p_stream,l_tlm_position,p_manager))
-  {
-    return false;
-  }
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer,l_tlm_size,p_manager) != l_tlm_size)
-  {
-    return false;
-  }
-  if
-    (! opj_stream_seek(p_stream,l_current_position,p_manager))
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Ends the encoding, i.e. frees memory.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_end_encoding(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  tcd_destroy(p_j2k->m_tcd);
-  p_j2k->m_tcd = 00;
-
-  if
-    (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer)
-  {
-    opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer);
-    p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 0;
-    p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 0;
-  }
-  if
-    (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data)
-  {
-    opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
-    p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 0;
-  }
-  p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = 0;
-
-  return true;
-}
-
-/**
- * Gets the offset of the header.
- *
- * @param  p_stream        the stream to write data to.
- * @param  p_j2k        J2K codec.
- * @param  p_manager    the user event manager.
-*/
-bool j2k_get_end_header(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  p_j2k->cstr_info->main_head_end = opj_stream_tell(p_stream);
-  return true;
-}
-
-
-
-
-/**
- * Reads an unknown marker
- *
- * @param  p_stream        the stream object to read from.
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_manager    the user event manager.
- *
- * @return  true      if the marker could be deduced.
-*/
-bool j2k_read_unk (
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager
-          )
-{
-  OPJ_BYTE l_data [2];
-  OPJ_UINT32 l_unknown_size;
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-  assert(p_stream != 00);
-
-  opj_event_msg(p_manager, EVT_WARNING, "Unknown marker\n");
-
-#ifdef USE_JPWL
-  if (p_j2k->m_cp->correct) {
-    OPJ_INT32 m = 0, id, i;
-    OPJ_INT32 min_id = 0, min_dist = 17, cur_dist = 0, tmp_id;
-    p_stream_seek(p_j2k->p_stream, p_stream_tell(p_j2k->p_stream) - 2);
-    id = p_stream_read(p_j2k->p_stream, 2);
-    opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-      "JPWL: really don't know this marker %x\n",
-      id);
-    if (!JPWL_ASSUME) {
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "- possible synch loss due to uncorrectable codestream errors => giving up\n");
-      return;
-    }
-    /* OK, activate this at your own risk!!! */
-    /* we look for the marker at the minimum hamming distance from this */
-    while (j2k_dec_mstab[m].id) {
-
-      /* 1's where they differ */
-      tmp_id = j2k_dec_mstab[m].id ^ id;
-
-      /* compute the hamming distance between our id and the current */
-      cur_dist = 0;
-      for (i = 0; i < 16; i++) {
-        if ((tmp_id >> i) & 0x0001) {
-          cur_dist++;
-        }
-      }
-
-      /* if current distance is smaller, set the minimum */
-      if (cur_dist < min_dist) {
-        min_dist = cur_dist;
-        min_id = j2k_dec_mstab[m].id;
-      }
-
-      /* jump to the next marker */
-      m++;
-    }
-
-    /* do we substitute the marker? */
-    if (min_dist < JPWL_MAXIMUM_HAMMING) {
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "- marker %x is at distance %d from the read %x\n",
-        min_id, min_dist, id);
-      opj_event_msg(p_j2k->cinfo, EVT_ERROR,
-        "- trying to substitute in place and crossing fingers!\n");
-      p_stream_seek(p_j2k->p_stream, p_stream_tell(p_j2k->p_stream) - 2);
-      p_stream_write(p_j2k->p_stream, min_id, 2);
-
-      /* rewind */
-      p_stream_seek(p_j2k->p_stream, p_stream_tell(p_j2k->p_stream) - 2);
-
-    }
-
-  };
-#endif /* USE_JPWL */
-  if
-    (opj_stream_read_data(p_stream,l_data,2,p_manager) != 2)
-  {
-    opj_event_msg(p_manager, EVT_WARNING, "Unknown marker\n");
-    return false;
-  }
-  opj_read_bytes(l_data,&l_unknown_size,2);
-  if
-    (l_unknown_size < 2)
-  {
-    return false;
-  }
-  l_unknown_size-=2;
-
-  if
-    (opj_stream_skip(p_stream,l_unknown_size,p_manager) != l_unknown_size)
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads the lookup table containing all the marker, status and action, and returns the handler associated
- * with the marker value.
- * @param  p_id    Marker value to look up
- *
- * @return  the handler associated with the id.
-*/
-const opj_dec_memory_marker_handler_t * j2k_get_marker_handler (OPJ_UINT32 p_id)
-{
-  const opj_dec_memory_marker_handler_t *e;
-  for
-    (e = j2k_memory_marker_handler_tab; e->id != 0; ++e)
-  {
-    if
-      (e->id == p_id)
-    {
-      break;
-    }
-  }
-  return e;
-}
-
-/**
- * Destroys a tile coding parameter structure.
- *
- * @param  p_tcp    the tile coding parameter to destroy.
- */
-void j2k_tcp_destroy (opj_tcp_t *p_tcp)
-{
-  if
-    (p_tcp == 00)
-  {
-    return;
-  }
-  if
-    (p_tcp->ppt_buffer != 00)
-  {
-    opj_free(p_tcp->ppt_buffer);
-    p_tcp->ppt_buffer = 00;
-  }
-  if
-    (p_tcp->tccps != 00)
-  {
-    opj_free(p_tcp->tccps);
-    p_tcp->tccps = 00;
-  }
-  if
-    (p_tcp->m_mct_coding_matrix != 00)
-  {
-    opj_free(p_tcp->m_mct_coding_matrix);
-    p_tcp->m_mct_coding_matrix = 00;
-  }
-  if
-    (p_tcp->m_mct_decoding_matrix != 00)
-  {
-    opj_free(p_tcp->m_mct_decoding_matrix);
-    p_tcp->m_mct_decoding_matrix = 00;
-  }
-  if
-    (p_tcp->m_mcc_records)
-  {
-    opj_free(p_tcp->m_mcc_records);
-    p_tcp->m_mcc_records = 00;
-    p_tcp->m_nb_max_mcc_records = 0;
-    p_tcp->m_nb_mcc_records = 0;
-  }
-  if
-    (p_tcp->m_mct_records)
-  {
-    opj_mct_data_t * l_mct_data = p_tcp->m_mct_records;
-    OPJ_UINT32 i;
-    for
-      (i=0;i<p_tcp->m_nb_mct_records;++i)
-    {
-      if
-        (l_mct_data->m_data)
-      {
-        opj_free(l_mct_data->m_data);
-        l_mct_data->m_data = 00;
-      }
-      ++l_mct_data;
-    }
-    opj_free(p_tcp->m_mct_records);
-    p_tcp->m_mct_records = 00;
-  }
-
-  if
-    (p_tcp->mct_norms != 00)
-  {
-    opj_free(p_tcp->mct_norms);
-    p_tcp->mct_norms = 00;
-  }
-  if
-    (p_tcp->m_data)
-  {
-    opj_free(p_tcp->m_data);
-    p_tcp->m_data = 00;
-  }
-}
-
-/**
- * Destroys a coding parameter structure.
- *
- * @param  p_cp    the coding parameter to destroy.
- */
-void j2k_cp_destroy (opj_cp_t *p_cp)
-{
-  OPJ_UINT32 l_nb_tiles;
-  opj_tcp_t * l_current_tile = 00;
-  OPJ_UINT32 i;
-
-  if
-    (p_cp == 00)
-  {
-    return;
-  }
-  if
-    (p_cp->tcps != 00)
-  {
-    l_current_tile = p_cp->tcps;
-    l_nb_tiles = p_cp->th * p_cp->tw;
-
-    for
-      (i = 0; i < l_nb_tiles; ++i)
-    {
-      j2k_tcp_destroy(l_current_tile);
-      ++l_current_tile;
-    }
-    opj_free(p_cp->tcps);
-    p_cp->tcps = 00;
-  }
-  if
-    (p_cp->ppm_buffer != 00)
-  {
-    opj_free(p_cp->ppm_buffer);
-    p_cp->ppm_buffer = 00;
-  }
-  if
-    (p_cp->comment != 00)
-  {
-    opj_free(p_cp->comment);
-    p_cp->comment = 00;
-  }
-  if
-    (! p_cp->m_is_decoder)
-  {
-    if
-      (p_cp->m_specific_param.m_enc.m_matrice)
-    {
-      opj_free(p_cp->m_specific_param.m_enc.m_matrice);
-      p_cp->m_specific_param.m_enc.m_matrice = 00;
-    }
-  }
-}
-
-/* ----------------------------------------------------------------------- */
-/* J2K / JPT decoder interface                                             */
-/* ----------------------------------------------------------------------- */
-/**
- * Creates a J2K decompression structure.
- *
- * @return a handle to a J2K decompressor if successful, NULL otherwise.
-*/
-opj_j2k_t* j2k_create_decompress()
-{
-  opj_j2k_t *l_j2k = (opj_j2k_t*) opj_malloc(sizeof(opj_j2k_t));
-  if
-    (!l_j2k)
-  {
-    return 00;
-  }
-  memset(l_j2k,0,sizeof(opj_j2k_t));
-  l_j2k->m_is_decoder = 1;
-  l_j2k->m_cp.m_is_decoder = 1;
-  l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_t*) opj_malloc(sizeof(opj_tcp_t));
-  if
-    (!l_j2k->m_specific_param.m_decoder.m_default_tcp)
-  {
-    opj_free(l_j2k);
-    return 00;
-  }
-  memset(l_j2k->m_specific_param.m_decoder.m_default_tcp,0,sizeof(opj_tcp_t));
-
-  l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_malloc(J2K_DEFAULT_HEADER_SIZE);
-  if
-    (! l_j2k->m_specific_param.m_decoder.m_header_data)
-  {
-    j2k_destroy(l_j2k);
-    return 00;
-  }
-  l_j2k->m_specific_param.m_decoder.m_header_data_size = J2K_DEFAULT_HEADER_SIZE;
-
-  // validation list creation
-  l_j2k->m_validation_list = opj_procedure_list_create();
-  if
-    (! l_j2k->m_validation_list)
-  {
-    j2k_destroy(l_j2k);
-    return 00;
-  }
-
-  // execution list creation
-  l_j2k->m_procedure_list = opj_procedure_list_create();
-  if
-    (! l_j2k->m_procedure_list)
-  {
-    j2k_destroy(l_j2k);
-    return 00;
-  }
-  return l_j2k;
-}
-
-opj_j2k_t* j2k_create_compress()
-{
-  opj_j2k_t *l_j2k = (opj_j2k_t*) opj_malloc(sizeof(opj_j2k_t));
-  if
-    (!l_j2k)
-  {
-    return 00;
-  }
-  memset(l_j2k,0,sizeof(opj_j2k_t));
-  l_j2k->m_is_decoder = 0;
-  l_j2k->m_cp.m_is_decoder = 0;
-
-  l_j2k->m_specific_param.m_encoder.m_header_tile_data = (OPJ_BYTE *) opj_malloc(J2K_DEFAULT_HEADER_SIZE);
-  if
-    (! l_j2k->m_specific_param.m_encoder.m_header_tile_data)
-  {
-    j2k_destroy(l_j2k);
-    return 00;
-  }
-  l_j2k->m_specific_param.m_encoder.m_header_tile_data_size = J2K_DEFAULT_HEADER_SIZE;
-
-  // validation list creation
-  l_j2k->m_validation_list = opj_procedure_list_create();
-  if
-    (! l_j2k->m_validation_list)
-  {
-    j2k_destroy(l_j2k);
-    return 00;
-  }
-
-  // execution list creation
-  l_j2k->m_procedure_list = opj_procedure_list_create();
-  if
-    (! l_j2k->m_procedure_list)
-  {
-    j2k_destroy(l_j2k);
-    return 00;
-  }
-  return l_j2k;
-}
-
-
-/**
- * Destroys a jpeg2000 codec.
- *
- * @param  p_j2k  the jpeg20000 structure to destroy.
- */
-void j2k_destroy (opj_j2k_t *p_j2k)
-{
-  if
-    (p_j2k == 00)
-  {
-    return;
-  }
-
-  if
-    (p_j2k->m_is_decoder)
-  {
-    if
-      (p_j2k->m_specific_param.m_decoder.m_default_tcp != 00)
-    {
-      j2k_tcp_destroy(p_j2k->m_specific_param.m_decoder.m_default_tcp);
-      opj_free(p_j2k->m_specific_param.m_decoder.m_default_tcp);
-      p_j2k->m_specific_param.m_decoder.m_default_tcp = 00;
-    }
-    if
-      (p_j2k->m_specific_param.m_decoder.m_header_data != 00)
-    {
-      opj_free(p_j2k->m_specific_param.m_decoder.m_header_data);
-      p_j2k->m_specific_param.m_decoder.m_header_data = 00;
-      p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
-    }
-
-  }
-  else
-  {
-    if
-      (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data)
-    {
-      opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
-      p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 00;
-    }
-    if
-      (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer)
-    {
-      opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer);
-      p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 00;
-      p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 00;
-    }
-    if
-      (p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-    {
-      opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
-      p_j2k->m_specific_param.m_encoder.m_header_tile_data = 00;
-      p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
-    }
-  }
-  tcd_destroy(p_j2k->m_tcd);
-
-  j2k_cp_destroy(&(p_j2k->m_cp));
-  memset(&(p_j2k->m_cp),0,sizeof(opj_cp_t));
-
-  opj_procedure_list_destroy(p_j2k->m_procedure_list);
-  p_j2k->m_procedure_list = 00;
-
-  opj_procedure_list_destroy(p_j2k->m_validation_list);
-  p_j2k->m_procedure_list = 00;
-
-  opj_free(p_j2k);
-}
-
-/**
- * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
- *
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream object.
- * @param  p_manager  the user event manager.
- *
- * @return true if the codec is valid.
- */
-bool j2k_start_compress(
-            opj_j2k_t *p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_image_t * p_image,
-            opj_event_mgr_t * p_manager)
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-  p_j2k->m_image = p_image;
-
-
-  /* customization of the validation */
-  j2k_setup_encoding_validation (p_j2k);
-
-  /* validation of the parameters codec */
-  if
-    (! j2k_exec(p_j2k,p_j2k->m_validation_list,p_stream,p_manager))
-  {
-    return false;
-  }
-
-  /* customization of the encoding */
-  j2k_setup_header_writting(p_j2k);
-
-  /* write header */
-  if
-    (! j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager))
-  {
-    return false;
-  }
-  return true;
-}
-/**
- * Sets up the procedures to do on reading header. Developpers wanting to extend the library can add their own reading procedures.
- */
-void j2k_setup_header_reading (opj_j2k_t *p_j2k)
-{
-  // preconditions
-  assert(p_j2k != 00);
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_read_header_procedure);
-
-  /* DEVELOPER CORNER, add your custom procedures */
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_copy_default_tcp_and_create_tcd);
-
-}
-
-/**
- * Sets up the procedures to do on decoding data. Developpers wanting to extend the library can add their own reading procedures.
- */
-void j2k_setup_decoding (opj_j2k_t *p_j2k)
-{
-  // preconditions
-  assert(p_j2k != 00);
-
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_decode_tiles);
-  /* DEVELOPER CORNER, add your custom procedures */
-
-}
-
-/**
- * Sets up the procedures to do on writting header. Developpers wanting to extend the library can add their own writting procedures.
- */
-void j2k_setup_header_writting (opj_j2k_t *p_j2k)
-{
-  // preconditions
-  assert(p_j2k != 00);
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_init_info );
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_soc );
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_siz );
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_cod );
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_qcd );
-
-
-  if
-    (p_j2k->m_cp.m_specific_param.m_enc.m_cinema)
-  {
-    opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_image_components );
-    opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_tlm );
-    if
-      (p_j2k->m_cp.m_specific_param.m_enc.m_cinema == CINEMA4K_24)
-    {
-      opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_poc );
-    }
-  }
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_regions);
-
-  if
-    (p_j2k->m_cp.comment != 00)
-  {
-    opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_com);
-  }
-
-  /* DEVELOPER CORNER, insert your custom procedures */
-  if
-    (p_j2k->m_cp.rsiz & MCT)
-  {
-    opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_mct_data_group );
-  }
-  /* End of Developer Corner */
-
-  if
-    (p_j2k->cstr_info)
-  {
-    opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_get_end_header );
-  }
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_create_tcd);
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_update_rates);
-}
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-void j2k_setup_end_compress (opj_j2k_t *p_j2k)
-{
-  // preconditions
-  assert(p_j2k != 00);
-
-  /* DEVELOPER CORNER, insert your custom procedures */
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_eoc );
-  if
-    (p_j2k->m_cp.m_specific_param.m_enc.m_cinema)
-  {
-    opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_updated_tlm);
-  }
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_write_epc );
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_end_encoding );
-  opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(void*)j2k_destroy_header_memory);
-}
-
-
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-void j2k_setup_encoding_validation (opj_j2k_t *p_j2k)
-{
-  // preconditions
-  assert(p_j2k != 00);
-  opj_procedure_list_add_procedure(p_j2k->m_validation_list, (void*)j2k_build_encoder);
-  opj_procedure_list_add_procedure(p_j2k->m_validation_list, (void*)j2k_encoding_validation);
-
-
-  /* DEVELOPER CORNER, add your custom validation procedure */
-  opj_procedure_list_add_procedure(p_j2k->m_validation_list, (void*)j2k_mct_validation);
-}
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-void j2k_setup_decoding_validation (opj_j2k_t *p_j2k)
-{
-  // preconditions
-  assert(p_j2k != 00);
-  opj_procedure_list_add_procedure(p_j2k->m_validation_list, (void*)j2k_build_decoder);
-  opj_procedure_list_add_procedure(p_j2k->m_validation_list, (void*)j2k_decoding_validation);
-  /* DEVELOPER CORNER, add your custom validation procedure */
-
-}
-
-
-/**
- * Excutes the given procedures on the given codec.
- *
- * @param  p_procedure_list  the list of procedures to execute
- * @param  p_j2k          the jpeg2000 codec to execute the procedures on.
- * @param  p_stream          the stream to execute the procedures on.
- * @param  p_manager      the user manager.
- *
- * @return  true        if all the procedures were successfully executed.
- */
-bool j2k_exec (
-          opj_j2k_t * p_j2k,
-          opj_procedure_list_t * p_procedure_list,
-          opj_stream_private_t *p_stream,
-          opj_event_mgr_t * p_manager
-          )
-{
-  bool (** l_procedure) (opj_j2k_t * ,opj_stream_private_t *,opj_event_mgr_t *) = 00;
-  bool l_result = true;
-  OPJ_UINT32 l_nb_proc, i;
-
-  // preconditions
-  assert(p_procedure_list != 00);
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  l_nb_proc = opj_procedure_list_get_nb_procedures(p_procedure_list);
-  l_procedure = (bool (**) (opj_j2k_t * ,opj_stream_private_t *,opj_event_mgr_t *)) opj_procedure_list_get_first_procedure(p_procedure_list);
-  for
-    (i=0;i<l_nb_proc;++i)
-  {
-    l_result = l_result && ((*l_procedure) (p_j2k,p_stream,p_manager));
-    ++l_procedure;
-  }
-  // and clear the procedure list at the end.
-  opj_procedure_list_clear(p_procedure_list);
-  return l_result;
-}
-
-/**
- * The default encoding validation procedure without any extension.
- *
- * @param  p_j2k      the jpeg2000 codec to validate.
- * @param  p_stream        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool j2k_encoding_validation (
-                opj_j2k_t * p_j2k,
-                opj_stream_private_t *p_stream,
-                opj_event_mgr_t * p_manager
-              )
-{
-  bool l_is_valid = true;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  /* STATE checking */
-  /* make sure the state is at 0 */
-  l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_NONE);
-
-  /* POINTER validation */
-  /* make sure a p_j2k codec is present */
-  l_is_valid &= (p_j2k->m_procedure_list != 00);
-  /* make sure a validation list is present */
-  l_is_valid &= (p_j2k->m_validation_list != 00);
-
-  if
-    ((p_j2k->m_cp.tdx) < (OPJ_UINT32) (1 << p_j2k->m_cp.tcps->tccps->numresolutions))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is too high in comparison to the size of tiles\n");
-    return false;
-  }
-  if
-    ((p_j2k->m_cp.tdy) < (OPJ_UINT32) (1 << p_j2k->m_cp.tcps->tccps->numresolutions))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is too high in comparison to the size of tiles\n");
-    return false;
-  }
-
-  /* PARAMETER VALIDATION */
-  return l_is_valid;
-}
-
-/**
- * The default decoding validation procedure without any extension.
- *
- * @param  p_j2k      the jpeg2000 codec to validate.
- * @param  p_stream        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool j2k_decoding_validation (
-                opj_j2k_t *p_j2k,
-                opj_stream_private_t *p_stream,
-                opj_event_mgr_t * p_manager
-                )
-{
-  bool l_is_valid = true;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  /* STATE checking */
-  /* make sure the state is at 0 */
-  l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_NONE);
-
-  /* POINTER validation */
-  /* make sure a p_j2k codec is present */
-  /* make sure a procedure list is present */
-  l_is_valid &= (p_j2k->m_procedure_list != 00);
-  /* make sure a validation list is present */
-  l_is_valid &= (p_j2k->m_validation_list != 00);
-
-  /* PARAMETER VALIDATION */
-  return l_is_valid;
-}
-
-/**
- * The mct encoding validation procedure.
- *
- * @param  p_j2k      the jpeg2000 codec to validate.
- * @param  p_stream        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool j2k_mct_validation (
-                opj_j2k_t * p_j2k,
-                opj_stream_private_t *p_stream,
-                opj_event_mgr_t * p_manager
-              )
-{
-  bool l_is_valid = true;
-  OPJ_UINT32 i,j;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  if
-    ((p_j2k->m_cp.rsiz & 0x8200) == 0x8200)
-  {
-    OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
-    opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
-    for
-      (i=0;i<l_nb_tiles;++i)
-    {
-      if
-        (l_tcp->mct == 2)
-      {
-        opj_tccp_t * l_tccp = l_tcp->tccps;
-        l_is_valid &= (l_tcp->m_mct_coding_matrix != 00);
-        for
-          (j=0;j<p_j2k->m_image->numcomps;++j)
-        {
-          l_is_valid &= ! (l_tccp->qmfbid & 1);
-          ++l_tccp;
-        }
-      }
-      ++l_tcp;
-    }
-  }
-  return l_is_valid;
-}
-
-/**
- * Builds the cp decoder parameters to use to decode tile.
- */
-bool j2k_build_decoder (
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            )
-{
-  // add here initialization of cp
-  // copy paste of setup_decoder
-  return true;
-}
-
-/**
- * Builds the cp encoder parameters to use to encode tile.
- */
-bool j2k_build_encoder (
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            )
-{
-  // add here initialization of cp
-  // copy paste of setup_encoder
-  return true;
-}
-
-bool j2k_copy_default_tcp_and_create_tcd
-            (
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            )
-{
-  opj_tcp_t * l_tcp = 00;
-  opj_tcp_t * l_default_tcp = 00;
-  OPJ_UINT32 l_nb_tiles;
-  OPJ_UINT32 i,j;
-  opj_tccp_t *l_current_tccp = 00;
-  OPJ_UINT32 l_tccp_size;
-  OPJ_UINT32 l_mct_size;
-  opj_image_t * l_image;
-  OPJ_UINT32 l_mcc_records_size,l_mct_records_size;
-  opj_mct_data_t * l_src_mct_rec, *l_dest_mct_rec;
-  opj_simple_mcc_decorrelation_data_t * l_src_mcc_rec, *l_dest_mcc_rec;
-  OPJ_UINT32 l_offset;
-
-  // preconditions in debug
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  l_image = p_j2k->m_image;
-  l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
-  l_tcp = p_j2k->m_cp.tcps;
-  l_tccp_size = l_image->numcomps * sizeof(opj_tccp_t);
-  l_default_tcp = p_j2k->m_specific_param.m_decoder.m_default_tcp;
-  l_mct_size = l_image->numcomps * l_image->numcomps * sizeof(OPJ_FLOAT32);
-  for
-    (i=0;i<l_nb_tiles;++i)
-  {
-    l_current_tccp = l_tcp->tccps;
-    memcpy(l_tcp,l_default_tcp, sizeof(opj_tcp_t));
-    l_tcp->ppt = 0;
-    l_tcp->ppt_data = 00;
-    l_tcp->tccps = l_current_tccp;
-    if
-      (l_default_tcp->m_mct_decoding_matrix)
-    {
-      l_tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(l_mct_size);
-      if
-        (! l_tcp->m_mct_decoding_matrix )
-      {
-        return false;
-      }
-      memcpy(l_tcp->m_mct_decoding_matrix,l_default_tcp->m_mct_decoding_matrix,l_mct_size);
-    }
-    l_mct_records_size = l_default_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t);
-    l_tcp->m_mct_records = (opj_mct_data_t*)opj_malloc(l_mct_records_size);
-    if
-      (! l_tcp->m_mct_records)
-    {
-      return false;
-    }
-    memcpy(l_tcp->m_mct_records, l_default_tcp->m_mct_records,l_mct_records_size);
-    l_src_mct_rec = l_default_tcp->m_mct_records;
-    l_dest_mct_rec = l_tcp->m_mct_records;
-    for
-      (j=0;j<l_default_tcp->m_nb_mct_records;++j)
-    {
-      if
-        (l_src_mct_rec->m_data)
-      {
-        l_dest_mct_rec->m_data = (OPJ_BYTE*)
-        opj_malloc(l_src_mct_rec->m_data_size);
-        if
-          (! l_dest_mct_rec->m_data)
-        {
-          return false;
-        }
-        memcpy(l_dest_mct_rec->m_data,l_src_mct_rec->m_data,l_src_mct_rec->m_data_size);
-      }
-      ++l_src_mct_rec;
-      ++l_dest_mct_rec;
-    }
-    l_mcc_records_size = l_default_tcp->m_nb_max_mcc_records * sizeof(opj_simple_mcc_decorrelation_data_t);
-    l_tcp->m_mcc_records = (opj_simple_mcc_decorrelation_data_t*)
-    opj_malloc(l_mcc_records_size);
-    if
-      (! l_tcp->m_mcc_records)
-    {
-      return false;
-    }
-    memcpy(l_tcp->m_mcc_records,l_default_tcp->m_mcc_records,l_mcc_records_size);
-    l_src_mcc_rec = l_default_tcp->m_mcc_records;
-    l_dest_mcc_rec = l_tcp->m_mcc_records;
-    for
-      (j=0;j<l_default_tcp->m_nb_max_mcc_records;++j)
-    {
-      if
-        (l_src_mcc_rec->m_decorrelation_array)
-      {
-        l_offset = l_src_mcc_rec->m_decorrelation_array - l_default_tcp->m_mct_records;
-        l_dest_mcc_rec->m_decorrelation_array = l_tcp->m_mct_records + l_offset;
-      }
-      if
-        (l_src_mcc_rec->m_offset_array)
-      {
-        l_offset = l_src_mcc_rec->m_offset_array - l_default_tcp->m_mct_records;
-        l_dest_mcc_rec->m_offset_array = l_tcp->m_mct_records + l_offset;
-      }
-      ++l_src_mcc_rec;
-      ++l_dest_mcc_rec;
-    }
-    memcpy(l_current_tccp,l_default_tcp->tccps,l_tccp_size);
-    ++l_tcp;
-  }
-  p_j2k->m_tcd = tcd_create(true);
-  if
-    (! p_j2k->m_tcd )
-  {
-    return false;
-  }
-  if
-    (! tcd_init(p_j2k->m_tcd, l_image, &(p_j2k->m_cp)))
-  {
-    tcd_destroy(p_j2k->m_tcd);
-    p_j2k->m_tcd = 00;
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
-    return false;
-  }
-  return true;
-}
-
-/**
- * Destroys the memory associated with the decoding of headers.
- */
-bool j2k_destroy_header_memory (
-            opj_j2k_t * p_j2k,
-            opj_stream_private_t *p_stream,
-            opj_event_mgr_t * p_manager
-            )
-{
-  // preconditions in debug
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_j2k->m_specific_param.m_encoder.m_header_tile_data)
-  {
-    opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
-    p_j2k->m_specific_param.m_encoder.m_header_tile_data = 0;
-  }
-  p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
-  return true;
-}
-
-/**
- * Sets up the decoder decoding parameters using user parameters.
- * Decoding parameters are stored in p_j2k->m_cp.
- *
- * @param  p_j2k      J2K codec
- * @param  p_parameters  decompression parameters
- * @deprecated
-*/
-void j2k_setup_decoder(
-             opj_j2k_t *p_j2k,
-             opj_dparameters_t *p_parameters
-             )
-{
-  if
-    (p_j2k && p_parameters)
-  {
-    /* create and initialize the coding parameters structure */
-    p_j2k->m_cp.m_specific_param.m_dec.m_reduce = p_parameters->cp_reduce;
-    p_j2k->m_cp.m_specific_param.m_dec.m_layer = p_parameters->cp_layer;
-    p_j2k->m_specific_param.m_decoder.m_discard_tiles = p_parameters->m_use_restrict_decode;
-    if
-      (p_parameters->m_use_restrict_decode)
-    {
-      p_j2k->m_specific_param.m_decoder.m_start_tile_x = p_parameters->m_decode_start_x;
-      p_j2k->m_specific_param.m_decoder.m_start_tile_y = p_parameters->m_decode_start_y;
-      p_j2k->m_specific_param.m_decoder.m_end_tile_x = p_parameters->m_decode_end_x;
-      p_j2k->m_specific_param.m_decoder.m_end_tile_y = p_parameters->m_decode_end_y;
-    }
-
-#ifdef USE_JPWL
-    cp->correct = parameters->jpwl_correct;
-    cp->exp_comps = parameters->jpwl_exp_comps;
-    cp->max_tiles = parameters->jpwl_max_tiles;
-#endif /* USE_JPWL */
-  }
-}
-
-void j2k_setup_encoder(opj_j2k_t *p_j2k, opj_cparameters_t *parameters, opj_image_t *image, struct opj_event_mgr * p_manager) {
-  OPJ_UINT32 i, j, tileno, numpocs_tile;
-  opj_cp_t *cp = 00;
-  bool l_res;
-  if(!p_j2k || !parameters || ! image) {
-    return;
-  }
-
-  /* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
-  cp = &(p_j2k->m_cp);
-
-  /* set default values for cp */
-  cp->tw = 1;
-  cp->th = 1;
-
-  /*
-  copy user encoding parameters
-  */
-  cp->m_specific_param.m_enc.m_cinema = parameters->cp_cinema;
-  cp->m_specific_param.m_enc.m_max_comp_size =  parameters->max_comp_size;
-  cp->rsiz   = parameters->cp_rsiz;
-  cp->m_specific_param.m_enc.m_disto_alloc = parameters->cp_disto_alloc;
-  cp->m_specific_param.m_enc.m_fixed_alloc = parameters->cp_fixed_alloc;
-  cp->m_specific_param.m_enc.m_fixed_quality = parameters->cp_fixed_quality;
-
-  /* mod fixed_quality */
-  if
-    (parameters->cp_matrice)
-  {
-    size_t array_size = parameters->tcp_numlayers * parameters->numresolution * 3 * sizeof(OPJ_INT32);
-    cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(array_size);
-    memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matrice, array_size);
-  }
-
-  /* tiles */
-  cp->tdx = parameters->cp_tdx;
-  cp->tdy = parameters->cp_tdy;
-
-  /* tile offset */
-  cp->tx0 = parameters->cp_tx0;
-  cp->ty0 = parameters->cp_ty0;
-
-  /* comment string */
-  if(parameters->cp_comment) {
-    cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) + 1);
-    if(cp->comment) {
-      strcpy(cp->comment, parameters->cp_comment);
-    }
-  }
-
-  /*
-  calculate other encoding parameters
-  */
-
-  if (parameters->tile_size_on) {
-    cp->tw = int_ceildiv(image->x1 - cp->tx0, cp->tdx);
-    cp->th = int_ceildiv(image->y1 - cp->ty0, cp->tdy);
-  } else {
-    cp->tdx = image->x1 - cp->tx0;
-    cp->tdy = image->y1 - cp->ty0;
-  }
-
-  if
-    (parameters->tp_on)
-  {
-    cp->m_specific_param.m_enc.m_tp_flag = parameters->tp_flag;
-    cp->m_specific_param.m_enc.m_tp_on = 1;
-  }
-
-#ifdef USE_JPWL
-  /*
-  calculate JPWL encoding parameters
-  */
-
-  if (parameters->jpwl_epc_on) {
-    OPJ_INT32 i;
-
-    /* set JPWL on */
-    cp->epc_on = true;
-    cp->info_on = false; /* no informative technique */
-
-    /* set EPB on */
-    if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) {
-      cp->epb_on = true;
-
-      cp->hprot_MH = parameters->jpwl_hprot_MH;
-      for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-        cp->hprot_TPH_tileno[i] = parameters->jpwl_hprot_TPH_tileno[i];
-        cp->hprot_TPH[i] = parameters->jpwl_hprot_TPH[i];
-      }
-      /* if tile specs are not specified, copy MH specs */
-      if (cp->hprot_TPH[0] == -1) {
-        cp->hprot_TPH_tileno[0] = 0;
-        cp->hprot_TPH[0] = parameters->jpwl_hprot_MH;
-      }
-      for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
-        cp->pprot_tileno[i] = parameters->jpwl_pprot_tileno[i];
-        cp->pprot_packno[i] = parameters->jpwl_pprot_packno[i];
-        cp->pprot[i] = parameters->jpwl_pprot[i];
-      }
-    }
-
-    /* set ESD writing */
-    if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) {
-      cp->esd_on = true;
-
-      cp->sens_size = parameters->jpwl_sens_size;
-      cp->sens_addr = parameters->jpwl_sens_addr;
-      cp->sens_range = parameters->jpwl_sens_range;
-
-      cp->sens_MH = parameters->jpwl_sens_MH;
-      for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-        cp->sens_TPH_tileno[i] = parameters->jpwl_sens_TPH_tileno[i];
-        cp->sens_TPH[i] = parameters->jpwl_sens_TPH[i];
-      }
-    }
-
-    /* always set RED writing to false: we are at the encoder */
-    cp->red_on = false;
-
-  } else {
-    cp->epc_on = false;
-  }
-#endif /* USE_JPWL */
-
-
-  /* initialize the mutiple tiles */
-  /* ---------------------------- */
-  cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
-  if
-    (parameters->numpocs)
-  {
-    /* initialisation of POC */
-    l_res = j2k_check_poc_val(parameters->POC,parameters->numpocs, parameters->numresolution, image->numcomps, parameters->tcp_numlayers, p_manager);
-    // TODO
-  }
-  for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-    opj_tcp_t *tcp = &cp->tcps[tileno];
-    tcp->numlayers = parameters->tcp_numlayers;
-    for (j = 0; j < tcp->numlayers; j++) {
-      if(cp->m_specific_param.m_enc.m_cinema){
-        if (cp->m_specific_param.m_enc.m_fixed_quality) {
-          tcp->distoratio[j] = parameters->tcp_distoratio[j];
-        }
-        tcp->rates[j] = parameters->tcp_rates[j];
-      }else{
-        if (cp->m_specific_param.m_enc.m_fixed_quality) {  /* add fixed_quality */
-          tcp->distoratio[j] = parameters->tcp_distoratio[j];
-        } else {
-          tcp->rates[j] = parameters->tcp_rates[j];
-        }
-      }
-    }
-    tcp->csty = parameters->csty;
-    tcp->prg = parameters->prog_order;
-    tcp->mct = parameters->tcp_mct;
-
-
-
-    numpocs_tile = 0;
-    tcp->POC = 0;
-    if
-      (parameters->numpocs)
-    {
-      /* initialisation of POC */
-      tcp->POC = 1;
-      // TODO
-      for (i = 0; i < (unsigned int) parameters->numpocs; i++) {
-        if((tileno == parameters->POC[i].tile - 1) || (parameters->POC[i].tile == -1)) {
-          opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
-          tcp_poc->resno0    = parameters->POC[numpocs_tile].resno0;
-          tcp_poc->compno0  = parameters->POC[numpocs_tile].compno0;
-          tcp_poc->layno1    = parameters->POC[numpocs_tile].layno1;
-          tcp_poc->resno1    = parameters->POC[numpocs_tile].resno1;
-          tcp_poc->compno1  = parameters->POC[numpocs_tile].compno1;
-          tcp_poc->prg1    = parameters->POC[numpocs_tile].prg1;
-          tcp_poc->tile    = parameters->POC[numpocs_tile].tile;
-          numpocs_tile++;
-        }
-      }
-      tcp->numpocs = numpocs_tile -1 ;
-    }else{
-      tcp->numpocs = 0;
-    }
-
-    tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(opj_tccp_t));
-    if
-      (parameters->mct_data)
-    {
-      OPJ_UINT32 lMctSize = image->numcomps * image->numcomps * sizeof(OPJ_FLOAT32);
-      OPJ_FLOAT32 * lTmpBuf = (OPJ_FLOAT32*)opj_malloc(lMctSize);
-      OPJ_INT32 * l_dc_shift = (OPJ_INT32 *) ((OPJ_BYTE *) parameters->mct_data + lMctSize);
-      tcp->mct = 2;
-      tcp->m_mct_coding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize);
-      memcpy(tcp->m_mct_coding_matrix,parameters->mct_data,lMctSize);
-      memcpy(lTmpBuf,parameters->mct_data,lMctSize);
-      tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize);
-      assert(opj_matrix_inversion_f(lTmpBuf,(tcp->m_mct_decoding_matrix),image->numcomps));
-      tcp->mct_norms = (OPJ_FLOAT64*)
-      opj_malloc(image->numcomps * sizeof(OPJ_FLOAT64));
-      opj_calculate_norms(tcp->mct_norms,image->numcomps,tcp->m_mct_decoding_matrix);
-      opj_free(lTmpBuf);
-      for
-        (i = 0; i < image->numcomps; i++)
-      {
-        opj_tccp_t *tccp = &tcp->tccps[i];
-        tccp->m_dc_level_shift = l_dc_shift[i];
-      }
-      j2k_setup_mct_encoding(tcp,image);
-    }
-    else
-    {
-      for
-        (i = 0; i < image->numcomps; i++)
-      {
-        opj_tccp_t *tccp = &tcp->tccps[i];
-        opj_image_comp_t * l_comp = &(image->comps[i]);
-        if
-          (! l_comp->sgnd)
-        {
-          tccp->m_dc_level_shift = 1 << (l_comp->prec - 1);
-        }
-      }
-    }
-
-
-    for (i = 0; i < image->numcomps; i++) {
-      opj_tccp_t *tccp = &tcp->tccps[i];
-      tccp->csty = parameters->csty & 0x01;  /* 0 => one precinct || 1 => custom precinct  */
-      tccp->numresolutions = parameters->numresolution;
-      tccp->cblkw = int_floorlog2(parameters->cblockw_init);
-      tccp->cblkh = int_floorlog2(parameters->cblockh_init);
-      tccp->cblksty = parameters->mode;
-      tccp->qmfbid = parameters->irreversible ? 0 : 1;
-      tccp->qntsty = parameters->irreversible ? J2K_CCP_QNTSTY_SEQNT : J2K_CCP_QNTSTY_NOQNT;
-      tccp->numgbits = 2;
-      if (i == parameters->roi_compno) {
-        tccp->roishift = parameters->roi_shift;
-      } else {
-        tccp->roishift = 0;
-      }
-
-      if(parameters->cp_cinema)
-      {
-        //Precinct size for lowest frequency subband=128
-        tccp->prcw[0] = 7;
-        tccp->prch[0] = 7;
-        //Precinct size at all other resolutions = 256
-        for (j = 1; j < tccp->numresolutions; j++) {
-          tccp->prcw[j] = 8;
-          tccp->prch[j] = 8;
-        }
-      }else{
-        if (parameters->csty & J2K_CCP_CSTY_PRT) {
-          int p = 0;
-          for (j = tccp->numresolutions - 1; j >= 0; j--) {
-            if (p < parameters->res_spec) {
-
-              if (parameters->prcw_init[p] < 1) {
-                tccp->prcw[j] = 1;
-              } else {
-                tccp->prcw[j] = int_floorlog2(parameters->prcw_init[p]);
-              }
-
-              if (parameters->prch_init[p] < 1) {
-                tccp->prch[j] = 1;
-              }else {
-                tccp->prch[j] = int_floorlog2(parameters->prch_init[p]);
-              }
-
-            } else {
-              int res_spec = parameters->res_spec;
-              int size_prcw = parameters->prcw_init[res_spec - 1] >> (p - (res_spec - 1));
-              int size_prch = parameters->prch_init[res_spec - 1] >> (p - (res_spec - 1));
-
-              if (size_prcw < 1) {
-                tccp->prcw[j] = 1;
-              } else {
-                tccp->prcw[j] = int_floorlog2(size_prcw);
-              }
-
-              if (size_prch < 1) {
-                tccp->prch[j] = 1;
-              } else {
-                tccp->prch[j] = int_floorlog2(size_prch);
-              }
-            }
-            p++;
-            /*printf("\nsize precinct for level %d : %d,%d\n", j,tccp->prcw[j], tccp->prch[j]); */
-          }  //end for
-        } else {
-          for (j = 0; j < tccp->numresolutions; j++) {
-            tccp->prcw[j] = 15;
-            tccp->prch[j] = 15;
-          }
-        }
-      }
-
-      dwt_calc_explicit_stepsizes(tccp, image->comps[i].prec);
-    }
-  }
-  if
-    (parameters->mct_data)
-  {
-    opj_free(parameters->mct_data);
-    parameters->mct_data = 00;
-  }
-}
-
-bool j2k_write_first_tile_part (
-                  opj_j2k_t *p_j2k,
-                  OPJ_BYTE * p_data,
-                  OPJ_UINT32 * p_data_written,
-                  OPJ_UINT32 p_total_data_size,
-                  opj_stream_private_t *p_stream,
-                  struct opj_event_mgr * p_manager
-                )
-{
-  OPJ_UINT32 compno;
-  OPJ_UINT32 l_nb_bytes_written = 0;
-  OPJ_UINT32 l_current_nb_bytes_written;
-  OPJ_BYTE * l_begin_data = 00;
-
-  opj_tcp_t *l_tcp = 00;
-  opj_tcd_t * l_tcd = 00;
-  opj_cp_t * l_cp = 00;
-
-  l_tcd = p_j2k->m_tcd;
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = l_cp->tcps + p_j2k->m_current_tile_number;
-
-  l_tcd->cur_pino = 0;
-  /*Get number of tile parts*/
-
-  p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
-  /* INDEX >> */
-
-  /* << INDEX */
-  l_current_nb_bytes_written = 0;
-  l_begin_data = p_data;
-  if
-    (! j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager))
-  {
-    return false;
-  }
-  l_nb_bytes_written += l_current_nb_bytes_written;
-  p_data += l_current_nb_bytes_written;
-  p_total_data_size -= l_current_nb_bytes_written;
-
-  if
-    (l_cp->m_specific_param.m_enc.m_cinema == 0)
-  {
-    for
-      (compno = 1; compno < p_j2k->m_image->numcomps; compno++)
-    {
-      l_current_nb_bytes_written = 0;
-      j2k_write_coc_in_memory(p_j2k,compno,p_data,&l_current_nb_bytes_written,p_manager);
-      l_nb_bytes_written += l_current_nb_bytes_written;
-      p_data += l_current_nb_bytes_written;
-      p_total_data_size -= l_current_nb_bytes_written;
-
-      l_current_nb_bytes_written = 0;
-      j2k_write_qcc_in_memory(p_j2k,compno,p_data,&l_current_nb_bytes_written,p_manager);
-      l_nb_bytes_written += l_current_nb_bytes_written;
-      p_data += l_current_nb_bytes_written;
-      p_total_data_size -= l_current_nb_bytes_written;
-    }
-    if
-      (l_cp->tcps[p_j2k->m_current_tile_number].numpocs)
-    {
-      l_current_nb_bytes_written = 0;
-      j2k_write_poc_in_memory(p_j2k,p_data,&l_current_nb_bytes_written,p_manager);
-      l_nb_bytes_written += l_current_nb_bytes_written;
-      p_data += l_current_nb_bytes_written;
-      p_total_data_size -= l_current_nb_bytes_written;
-    }
-  }
-  l_current_nb_bytes_written = 0;
-  if
-    (! j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,p_manager))
-  {
-    return false;
-  }
-  l_nb_bytes_written += l_current_nb_bytes_written;
-  * p_data_written = l_nb_bytes_written;
-
-  /* Writing Psot in SOT marker */
-  opj_write_bytes(l_begin_data + 6,l_nb_bytes_written,4);          /* PSOT */
-  if
-    (l_cp->m_specific_param.m_enc.m_cinema)
-  {
-    j2k_update_tlm(p_j2k,l_nb_bytes_written);
-  }
-  return true;
-}
-
-bool j2k_write_all_tile_parts(
-                  opj_j2k_t *p_j2k,
-                  OPJ_BYTE * p_data,
-                  OPJ_UINT32 * p_data_written,
-                  OPJ_UINT32 p_total_data_size,
-                  opj_stream_private_t *p_stream,
-                  struct opj_event_mgr * p_manager
-                )
-{
-  OPJ_UINT32 tilepartno=0;
-  OPJ_UINT32 l_nb_bytes_written = 0;
-  OPJ_UINT32 l_current_nb_bytes_written;
-  OPJ_UINT32 l_part_tile_size;
-  OPJ_UINT32 tot_num_tp;
-  OPJ_UINT32 pino;
-
-  OPJ_BYTE * l_begin_data;
-  opj_tcp_t *l_tcp = 00;
-  opj_tcd_t * l_tcd = 00;
-  opj_cp_t * l_cp = 00;
-
-
-  l_tcd = p_j2k->m_tcd;
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = l_cp->tcps + p_j2k->m_current_tile_number;
-
-  /*Get number of tile parts*/
-  tot_num_tp = j2k_get_num_tp(l_cp,0,p_j2k->m_current_tile_number);
-  for
-    (tilepartno = 1; tilepartno < tot_num_tp ; ++tilepartno)
-  {
-    p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;
-    l_current_nb_bytes_written = 0;
-    l_part_tile_size = 0;
-    l_begin_data = p_data;
-    if
-      (! j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager))
-    {
-      return false;
-    }
-    l_nb_bytes_written += l_current_nb_bytes_written;
-    p_data += l_current_nb_bytes_written;
-    p_total_data_size -= l_current_nb_bytes_written;
-    l_part_tile_size += l_nb_bytes_written;
-
-    l_current_nb_bytes_written = 0;
-    if
-      (! j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,p_manager))
-    {
-      return false;
-    }
-    p_data += l_current_nb_bytes_written;
-    l_nb_bytes_written += l_current_nb_bytes_written;
-    p_total_data_size -= l_current_nb_bytes_written;
-    l_part_tile_size += l_nb_bytes_written;
-
-    /* Writing Psot in SOT marker */
-    opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);          /* PSOT */
-
-    if
-      (l_cp->m_specific_param.m_enc.m_cinema)
-    {
-      j2k_update_tlm(p_j2k,l_part_tile_size);
-    }
-    ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
-  }
-  for
-    (pino = 1; pino <= l_tcp->numpocs; ++pino)
-  {
-    l_tcd->cur_pino = pino;
-    /*Get number of tile parts*/
-    tot_num_tp = j2k_get_num_tp(l_cp,pino,p_j2k->m_current_tile_number);
-    for
-      (tilepartno = 0; tilepartno < tot_num_tp ; ++tilepartno)
-    {
-      p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;
-      l_current_nb_bytes_written = 0;
-      l_part_tile_size = 0;
-      l_begin_data = p_data;
-      if
-        (! j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager))
-      {
-        return false;
-      }
-      l_nb_bytes_written += l_current_nb_bytes_written;
-      p_data += l_current_nb_bytes_written;
-      p_total_data_size -= l_current_nb_bytes_written;
-      l_part_tile_size += l_current_nb_bytes_written;
-
-      l_current_nb_bytes_written = 0;
-      if
-        (! j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,p_manager))
-      {
-        return false;
-      }
-      l_nb_bytes_written += l_current_nb_bytes_written;
-      p_data += l_current_nb_bytes_written;
-      p_total_data_size -= l_current_nb_bytes_written;
-      l_part_tile_size += l_current_nb_bytes_written;
-
-      /* Writing Psot in SOT marker */
-      opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);          /* PSOT */
-
-      if
-        (l_cp->m_specific_param.m_enc.m_cinema)
-      {
-        j2k_update_tlm(p_j2k,l_part_tile_size);
-      }
-      ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
-    }
-  }
-  *p_data_written = l_nb_bytes_written;
-  return true;
-}
-
-
-bool j2k_pre_write_tile (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 p_tile_index,
-           opj_stream_private_t *p_stream,
-           opj_event_mgr_t * p_manager
-          )
-{
-  if
-    (p_tile_index != p_j2k->m_current_tile_number)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "The given tile index does not match." );
-    return false;
-  }
-
-  opj_event_msg(p_manager, EVT_INFO, "tile number %d / %d\n", p_j2k->m_current_tile_number + 1, p_j2k->m_cp.tw * p_j2k->m_cp.th);
-
-  p_j2k->m_specific_param.m_encoder.m_current_tile_part_number = 0;
-  p_j2k->m_tcd->cur_totnum_tp = p_j2k->m_cp.tcps[p_tile_index].m_nb_tile_parts;
-  p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
-  /* initialisation before tile encoding  */
-  if
-    (! tcd_init_encode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number))
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Writes a tile.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool j2k_write_tile (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 p_tile_index,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           opj_stream_private_t *p_stream,
-           opj_event_mgr_t * p_manager
-          )
-{
-  if
-    (! j2k_pre_write_tile(p_j2k,p_tile_index,p_stream,p_manager))
-  {
-    return false;
-  }
-  return j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,p_manager);
-}
-
-/**
- * Writes a tile.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool j2k_post_write_tile (
-           opj_j2k_t * p_j2k,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           opj_stream_private_t *p_stream,
-           opj_event_mgr_t * p_manager
-          )
-{
-  opj_tcd_t * l_tcd = 00;
-  opj_cp_t * l_cp = 00;
-  opj_tcp_t * l_tcp = 00;
-  OPJ_UINT32 l_nb_bytes_written;
-  OPJ_BYTE * l_current_data = 00;
-  OPJ_UINT32 l_tile_size = 0;
-  OPJ_UINT32 l_available_data;
-
-  assert(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
-
-  l_tcd = p_j2k->m_tcd;
-  l_cp = &(p_j2k->m_cp);
-  l_tcp = l_cp->tcps + p_j2k->m_current_tile_number;
-
-  l_tile_size = p_j2k->m_specific_param.m_encoder.m_encoded_tile_size;
-  l_available_data = l_tile_size;
-  l_current_data = p_j2k->m_specific_param.m_encoder.m_encoded_tile_data;
-  if
-    (! tcd_copy_tile_data(l_tcd,p_data,p_data_size))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Size mismtach between tile data and sent data." );
-    return false;
-  }
-
-  l_nb_bytes_written = 0;
-  if
-    (! j2k_write_first_tile_part(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_stream,p_manager))
-  {
-    return false;
-  }
-  l_current_data += l_nb_bytes_written;
-  l_available_data -= l_nb_bytes_written;
-
-  l_nb_bytes_written = 0;
-  if
-    (! j2k_write_all_tile_parts(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_stream,p_manager))
-  {
-    return false;
-  }
-
-  l_available_data -= l_nb_bytes_written;
-  l_nb_bytes_written = l_tile_size - l_available_data;
-
-  if
-    (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_encoded_tile_data,l_nb_bytes_written,p_manager) != l_nb_bytes_written)
-  {
-    return false;
-  }
-  ++p_j2k->m_current_tile_number;
-  return true;
-}
-
-/**
- * Reads a tile header.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool j2k_read_tile_header (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 * p_tile_index,
-           OPJ_UINT32 * p_data_size,
-           OPJ_INT32 * p_tile_x0,
-           OPJ_INT32 * p_tile_y0,
-           OPJ_INT32 * p_tile_x1,
-           OPJ_INT32 * p_tile_y1,
-           OPJ_UINT32 * p_nb_comps,
-           bool * p_go_on,
-           opj_stream_private_t *p_stream,
-           opj_event_mgr_t * p_manager
-          )
-{
-  OPJ_UINT32 l_current_marker = J2K_MS_SOT;
-  OPJ_UINT32 l_marker_size;
-  const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
-  opj_tcp_t * l_tcp = 00;
-  OPJ_UINT32 l_nb_tiles;
-
-  // preconditions
-  assert(p_stream != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_EOC)
-  {
-    l_current_marker = J2K_MS_EOC;
-  }
-  else if
-    (p_j2k->m_specific_param.m_decoder.m_state != J2K_DEC_STATE_TPHSOT)
-  {
-    return false;
-  }
-
-  while
-    (! p_j2k->m_specific_param.m_decoder.m_can_decode && l_current_marker != J2K_MS_EOC)
-  {
-    while
-      (l_current_marker != J2K_MS_SOD)
-    {
-      if
-        (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-        return false;
-      }
-      opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2);
-      if
-        (p_j2k->m_specific_param.m_decoder.m_state & J2K_DEC_STATE_TPH)
-      {
-        p_j2k->m_specific_param.m_decoder.m_sot_length -= (l_marker_size + 2);
-      }
-      l_marker_size -= 2;
-
-      l_marker_handler = j2k_get_marker_handler(l_current_marker);
-      // Check if the marker is known
-      if
-        (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) )
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
-        return false;
-      }
-      if
-        (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size)
-      {
-        p_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE*)
-        opj_realloc(p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size);
-        if
-          (p_j2k->m_specific_param.m_decoder.m_header_data == 00)
-        {
-          return false;
-        }
-        p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size;
-
-      }
-      if
-        (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager) != l_marker_size)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-        return false;
-      }
-      if
-        (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager))
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
-        return false;
-      }
-      if
-        (p_j2k->m_specific_param.m_decoder.m_skip_data)
-      {
-        if
-          (opj_stream_skip(p_stream,p_j2k->m_specific_param.m_decoder.m_sot_length,p_manager) != p_j2k->m_specific_param.m_decoder.m_sot_length)
-        {
-          opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-          return false;
-        }
-        l_current_marker = J2K_MS_SOD;
-      }
-      else
-      {
-        if
-          (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2)
-        {
-          opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-          return false;
-        }
-        opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
-      }
-    }
-
-    if
-      (! p_j2k->m_specific_param.m_decoder.m_skip_data)
-    {
-      if
-        (! j2k_read_sod(p_j2k,p_stream,p_manager))
-      {
-        return false;
-      }
-    }
-    else
-    {
-      p_j2k->m_specific_param.m_decoder.m_skip_data = 0;
-      p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
-      p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_TPHSOT;
-      if
-        (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-        return false;
-      }
-      opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
-    }
-  }
-
-  if
-    (l_current_marker == J2K_MS_EOC)
-  {
-    if
-      (p_j2k->m_specific_param.m_decoder.m_state != J2K_DEC_STATE_EOC)
-    {
-      p_j2k->m_current_tile_number = 0;
-      p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_EOC;
-    }
-  }
-  if
-    ( ! p_j2k->m_specific_param.m_decoder.m_can_decode)
-  {
-    l_tcp = p_j2k->m_cp.tcps + p_j2k->m_current_tile_number;
-    l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
-    while
-      (
-        (p_j2k->m_current_tile_number < l_nb_tiles)
-        &&  (l_tcp->m_data == 00)
-      )
-    {
-      ++p_j2k->m_current_tile_number;
-      ++l_tcp;
-    }
-    if
-      (p_j2k->m_current_tile_number == l_nb_tiles)
-    {
-      *p_go_on = false;
-      return true;
-    }
-  }
-  if
-    (! tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
-    return false;
-  }
-  *p_tile_index = p_j2k->m_current_tile_number;
-  *p_go_on = true;
-  *p_data_size = tcd_get_decoded_tile_size(p_j2k->m_tcd);
-  * p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0;
-  * p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0;
-  * p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1;
-  * p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1;
-  * p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps;
-  p_j2k->m_specific_param.m_decoder.m_state |= J2K_DEC_STATE_DATA;
-  return true;
-}
-
-bool j2k_decode_tile (
-          opj_j2k_t * p_j2k,
-          OPJ_UINT32 p_tile_index,
-          OPJ_BYTE * p_data,
-          OPJ_UINT32 p_data_size,
-          opj_stream_private_t *p_stream,
-          opj_event_mgr_t * p_manager
-          )
-{
-  OPJ_UINT32 l_current_marker;
-  OPJ_BYTE l_data [2];
-  opj_tcp_t * l_tcp;
-
-  // preconditions
-  assert(p_stream != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  if
-    (! (p_j2k->m_specific_param.m_decoder.m_state & J2K_DEC_STATE_DATA) || p_tile_index != p_j2k->m_current_tile_number)
-  {
-    return false;
-  }
-  l_tcp = &(p_j2k->m_cp.tcps[p_tile_index]);
-  if
-    (! l_tcp->m_data)
-  {
-    j2k_tcp_destroy(&(p_j2k->m_cp.tcps[p_tile_index]));
-    return false;
-  }
-  if
-    (! tcd_decode_tile(p_j2k->m_tcd, l_tcp->m_data, l_tcp->m_data_size, p_tile_index, p_j2k->cstr_info))
-  {
-    j2k_tcp_destroy(l_tcp);
-    p_j2k->m_specific_param.m_decoder.m_state |= J2K_DEC_STATE_ERR;
-    return false;
-  }
-  if
-    (! tcd_update_tile_data(p_j2k->m_tcd,p_data,p_data_size))
-  {
-    return false;
-  }
-  j2k_tcp_destroy(l_tcp);
-  p_j2k->m_tcd->tcp = 0;
-
-  p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
-  p_j2k->m_specific_param.m_decoder.m_state &= (~J2K_DEC_STATE_DATA);
-  if
-    (p_j2k->m_specific_param.m_decoder.m_state != J2K_DEC_STATE_EOC)
-  {
-    if
-      (opj_stream_read_data(p_stream,l_data,2,p_manager) != 2)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-      return false;
-    }
-    opj_read_bytes(l_data,&l_current_marker,2);
-    if
-      (l_current_marker == J2K_MS_EOC)
-    {
-      p_j2k->m_current_tile_number = 0;
-      p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_EOC;
-    }
-    else if
-      (l_current_marker != J2K_MS_SOT)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Stream too short, expected SOT\n");
-      return false;
-    }
-  }
-  return true;
-}
-
-
-/**
- * Ends the compression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool j2k_end_compress(opj_j2k_t *p_j2k, struct opj_stream_private *p_stream, struct opj_event_mgr * p_manager)
-{
-  /* customization of the encoding */
-  j2k_setup_end_compress(p_j2k);
-
-  if
-    (! j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager))
-  {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Reads a jpeg2000 codestream header structure.
- *
- * @param p_stream the stream to read data from.
- * @param p_j2k the jpeg2000 codec.
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-bool j2k_read_header(
-                opj_j2k_t *p_j2k,
-                struct opj_image ** p_image,
-                OPJ_INT32 * p_tile_x0,
-                OPJ_INT32 * p_tile_y0,
-                OPJ_UINT32 * p_tile_width,
-                OPJ_UINT32 * p_tile_height,
-                OPJ_UINT32 * p_nb_tiles_x,
-                OPJ_UINT32 * p_nb_tiles_y,
-                struct opj_stream_private *p_stream,
-                struct opj_event_mgr * p_manager
-              )
-{
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  *p_image = 00;
-  /* create an empty image */
-  p_j2k->m_image = opj_image_create0();
-  if
-    (! p_j2k->m_image)
-  {
-    return false;
-  }
-
-  /* customization of the validation */
-  j2k_setup_decoding_validation (p_j2k);
-
-  /* validation of the parameters codec */
-  if
-    (! j2k_exec(p_j2k,p_j2k->m_validation_list,p_stream,p_manager))
-  {
-    opj_image_destroy(p_j2k->m_image);
-    p_j2k->m_image = 00;
-    return false;
-  }
-
-  /* customization of the encoding */
-  j2k_setup_header_reading(p_j2k);
-
-  /* read header */
-  if
-    (! j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager))
-  {
-    opj_image_destroy(p_j2k->m_image);
-    p_j2k->m_image = 00;
-    return false;
-  }
-  *p_image = p_j2k->m_image;
-  * p_tile_x0 = p_j2k->m_cp.tx0;
-    * p_tile_y0 = p_j2k->m_cp.ty0;
-  * p_tile_width = p_j2k->m_cp.tdx;
-    * p_tile_height = p_j2k->m_cp.tdy;
-  * p_nb_tiles_x = p_j2k->m_cp.tw;
-  * p_nb_tiles_y = p_j2k->m_cp.th;
-  return true;
-}
-
-/**
- * The read header procedure.
- */
-bool j2k_read_header_procedure(
-                opj_j2k_t *p_j2k,
-                struct opj_stream_private *p_stream,
-                struct opj_event_mgr * p_manager)
-{
-  OPJ_UINT32 l_current_marker;
-  OPJ_UINT32 l_marker_size;
-  const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
-
-  // preconditions
-  assert(p_stream != 00);
-  assert(p_j2k != 00);
-  assert(p_manager != 00);
-
-  p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_MHSOC;
-
-  if
-    (! j2k_read_soc(p_j2k,p_stream,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Expected a SOC marker \n");
-    return false;
-  }
-  if
-    (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-    return false;
-  }
-  opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
-
-  while
-    (l_current_marker != J2K_MS_SOT)
-  {
-    if
-      (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-      return false;
-    }
-    opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2);
-    l_marker_size -= 2;
-    /*if
-      (l_current_marker < 0xff00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "%.8x: expected a marker instead of %x\n", opj_stream_tell(p_stream) - 2, l_current_marker);
-      return 0;
-    }
-    */
-    l_marker_handler = j2k_get_marker_handler(l_current_marker);
-    // Check if the marker is known
-    if
-      (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) )
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
-      return false;
-    }
-    if
-      (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size)
-    {
-      p_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE*)
-      opj_realloc(p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size);
-      if
-        (p_j2k->m_specific_param.m_decoder.m_header_data == 00)
-      {
-        return false;
-      }
-      p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size;
-    }
-    if
-      (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager) != l_marker_size)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-      return false;
-    }
-    if
-      (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
-      return false;
-    }
-    if
-      (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
-      return false;
-    }
-    opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
-  }
-  p_j2k->m_specific_param.m_decoder.m_state = J2K_DEC_STATE_TPHSOT;
-  return true;
-}
-
-
-
-/**
- * Reads the tiles.
- */
-bool j2k_decode_tiles (
-                opj_j2k_t *p_j2k,
-                struct opj_stream_private *p_stream,
-                struct opj_event_mgr * p_manager)
-{
-  bool l_go_on = true;
-  OPJ_UINT32 l_current_tile_no;
-  OPJ_UINT32 l_data_size,l_max_data_size;
-  OPJ_INT32 l_tile_x0,l_tile_y0,l_tile_x1,l_tile_y1;
-  OPJ_UINT32 l_nb_comps;
-  OPJ_BYTE * l_current_data;
-
-  l_current_data = (OPJ_BYTE*)opj_malloc(1000);
-  if
-    (! l_current_data)
-  {
-    return false;
-  }
-  l_max_data_size = 1000;
-
-  while
-    (true)
-  {
-    if
-      (! j2k_read_tile_header(
-        p_j2k,&l_current_tile_no,
-        &l_data_size,
-        &l_tile_x0,
-        &l_tile_y0,
-        &l_tile_x1,
-        &l_tile_y1,
-        &l_nb_comps,
-        &l_go_on,
-        p_stream,
-        p_manager))
-    {
-      return false;
-    }
-    if
-      (! l_go_on)
-    {
-      break;
-    }
-    if
-      (l_data_size > l_max_data_size)
-    {
-      l_current_data = (OPJ_BYTE*)opj_realloc(l_current_data,l_data_size);
-      if
-        (! l_current_data)
-      {
-        return false;
-      }
-      l_max_data_size = l_data_size;
-    }
-    if
-      (! j2k_decode_tile(p_j2k,l_current_tile_no,l_current_data,l_data_size,p_stream,p_manager))
-    {
-      opj_free(l_current_data);
-      return false;
-    }
-    if
-      (! j2k_update_image_data(p_j2k->m_tcd,l_current_data))
-    {
-      opj_free(l_current_data);
-      return false;
-    }
-
-  }
-  opj_free(l_current_data);
-  return true;
-}
-
-
-
-
-
-
-/**
- * Decodes the tiles of the stream.
- */
-opj_image_t * j2k_decode(
-              opj_j2k_t * p_j2k,
-             opj_stream_private_t * p_stream,
-             opj_event_mgr_t * p_manager)
-{
-  /* customization of the encoding */
-  j2k_setup_decoding(p_j2k);
-
-  /* write header */
-  if
-    (! j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager))
-  {
-    opj_image_destroy(p_j2k->m_image);
-    p_j2k->m_image = 00;
-  }
-  return p_j2k->m_image;
-}
-
-/**
- * Encodes all the tiles in a row.
- */
-bool j2k_encode(
-          opj_j2k_t * p_j2k,
-          opj_stream_private_t *p_stream,
-          opj_event_mgr_t * p_manager
-        )
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_nb_tiles;
-  OPJ_UINT32 l_max_tile_size, l_current_tile_size;
-  OPJ_BYTE * l_current_data;
-
-  // preconditions
-  assert(p_j2k != 00);
-  assert(p_stream != 00);
-  assert(p_manager != 00);
-
-  l_current_data = (OPJ_BYTE*)opj_malloc(1000);
-  if
-    (! l_current_data)
-  {
-    return false;
-  }
-  l_max_tile_size = 1000;
-
-  l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
-  for
-    (i=0;i<l_nb_tiles;++i)
-  {
-    if
-      (! j2k_pre_write_tile(p_j2k,i,p_stream,p_manager))
-    {
-      opj_free(l_current_data);
-      return false;
-    }
-    l_current_tile_size = tcd_get_encoded_tile_size(p_j2k->m_tcd);
-    if
-      (l_current_tile_size > l_max_tile_size)
-    {
-      l_current_data = (OPJ_BYTE*)opj_realloc(l_current_data,l_current_tile_size);
-      if
-        (! l_current_data)
-      {
-        return false;
-      }
-      l_max_tile_size = l_current_tile_size;
-    }
-    j2k_get_tile_data(p_j2k->m_tcd,l_current_data);
-    if
-      (! j2k_post_write_tile (p_j2k,l_current_data,l_current_tile_size,p_stream,p_manager))
-    {
-      return false;
-    }
-  }
-  opj_free(l_current_data);
-  return true;
-}
-
-
-
-/**
- * Ends the decompression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool j2k_end_decompress(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *p_stream,
-            struct opj_event_mgr * p_manager)
-{
-  return true;
-}
-
-
-
-void j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
-{
-  OPJ_UINT32 i,j,k = 0;
-  OPJ_UINT32 l_width,l_height,l_stride, l_offset_x,l_offset_y, l_image_width;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcd_tilecomp_t * l_tilec = 00;
-  opj_image_t * l_image = 00;
-  OPJ_UINT32 l_size_comp, l_remaining;
-  OPJ_INT32 * l_src_ptr;
-  l_tilec = p_tcd->tcd_image->tiles->comps;
-  l_image = p_tcd->image;
-  l_img_comp = l_image->comps;
-  for
-    (i=0;i<p_tcd->image->numcomps;++i)
-  {
-    l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
-    l_remaining = l_img_comp->prec & 7;  /* (%8) */
-    if
-      (l_remaining)
-    {
-      ++l_size_comp;
-    }
-    if
-      (l_size_comp == 3)
-    {
-      l_size_comp = 4;
-    }
-    l_width = (l_tilec->x1 - l_tilec->x0);
-    l_height = (l_tilec->y1 - l_tilec->y0);
-    l_offset_x = int_ceildiv(l_image->x0, l_img_comp->dx);
-    l_offset_y = int_ceildiv(l_image->y0, l_img_comp->dy);
-    l_image_width = int_ceildiv(l_image->x1 - l_image->x0, l_img_comp->dx);
-    l_stride = l_image_width - l_width;
-    l_src_ptr = l_img_comp->data + (l_tilec->x0 - l_offset_x) + (l_tilec->y0 - l_offset_y) * l_image_width;
-
-    switch
-      (l_size_comp)
-    {
-      case 1:
-        {
-          OPJ_CHAR * l_dest_ptr = (OPJ_CHAR*) p_data;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr) = (OPJ_CHAR) (*l_src_ptr);
-                ++l_dest_ptr;
-                ++l_src_ptr;
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          else
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr) = (*l_src_ptr)&0xff;
-                ++l_dest_ptr;
-                ++l_src_ptr;
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          p_data = (OPJ_BYTE*) l_dest_ptr;
-        }
-        break;
-      case 2:
-        {
-          OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_data;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (OPJ_INT16) (*(l_src_ptr++));
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          else
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          p_data = (OPJ_BYTE*) l_dest_ptr;
-        }
-        break;
-      case 4:
-        {
-          OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_data;
-          for
-            (j=0;j<l_height;++j)
-          {
-            for
-              (k=0;k<l_width;++k)
-            {
-              *(l_dest_ptr++) = *(l_src_ptr++);
-            }
-            l_src_ptr += l_stride;
-          }
-          p_data = (OPJ_BYTE*) l_dest_ptr;
-        }
-        break;
-    }
-    ++l_img_comp;
-    ++l_tilec;
-  }
-}
-
-bool j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
-{
-  OPJ_UINT32 i,j,k = 0;
-  OPJ_UINT32 l_width,l_height,l_offset_x,l_offset_y;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcd_tilecomp_t * l_tilec = 00;
-  opj_image_t * l_image = 00;
-  OPJ_UINT32 l_size_comp, l_remaining;
-  OPJ_UINT32 l_dest_stride;
-  OPJ_INT32 * l_dest_ptr;
-  opj_tcd_resolution_t* l_res= 00;
-
-
-  l_tilec = p_tcd->tcd_image->tiles->comps;
-  l_image = p_tcd->image;
-  l_img_comp = l_image->comps;
-  for
-    (i=0;i<p_tcd->image->numcomps;++i)
-  {
-    if
-      (!l_img_comp->data)
-    {
-      l_img_comp->data = (OPJ_INT32*) opj_malloc(l_img_comp->w * l_img_comp->h * sizeof(OPJ_INT32));
-      if
-        (! l_img_comp->data)
-      {
-        return false;
-      }
-      memset(l_img_comp->data,0,l_img_comp->w * l_img_comp->h * sizeof(OPJ_INT32));
-    }
-
-    l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
-    l_remaining = l_img_comp->prec & 7;  /* (%8) */
-    l_res = l_tilec->resolutions + l_img_comp->resno_decoded;
-
-    if
-      (l_remaining)
-    {
-      ++l_size_comp;
-    }
-    if
-      (l_size_comp == 3)
-    {
-      l_size_comp = 4;
-    }
-    l_width = (l_res->x1 - l_res->x0);
-    l_height = (l_res->y1 - l_res->y0);
-    l_dest_stride = (l_img_comp->w) - l_width;
-    l_offset_x = int_ceildivpow2(l_img_comp->x0, l_img_comp->factor);
-    l_offset_y = int_ceildivpow2(l_img_comp->y0, l_img_comp->factor);
-    l_dest_ptr = l_img_comp->data + (l_res->x0 - l_offset_x) + (l_res->y0 - l_offset_y) * l_img_comp->w;
-
-    switch
-      (l_size_comp)
-    {
-      case 1:
-        {
-          OPJ_CHAR * l_src_ptr = (OPJ_CHAR*) p_data;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
-              }
-              l_dest_ptr += l_dest_stride;
-            }
-
-          }
-          else
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (OPJ_INT32) ((*(l_src_ptr++))&0xff);
-              }
-              l_dest_ptr += l_dest_stride;
-            }
-          }
-          p_data = (OPJ_BYTE*) l_src_ptr;
-        }
-        break;
-      case 2:
-        {
-          OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_data;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = *(l_src_ptr++);
-              }
-              l_dest_ptr += l_dest_stride;
-            }
-          }
-          else
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
-              }
-              l_dest_ptr += l_dest_stride;
-            }
-          }
-          p_data = (OPJ_BYTE*) l_src_ptr;
-        }
-        break;
-      case 4:
-        {
-          OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_data;
-          for
-            (j=0;j<l_height;++j)
-          {
-            for
-              (k=0;k<l_width;++k)
-            {
-              *(l_dest_ptr++) = (*(l_src_ptr++));
-            }
-            l_dest_ptr += l_dest_stride;
-          }
-          p_data = (OPJ_BYTE*) l_src_ptr;
-        }
-        break;
-    }
-    ++l_img_comp;
-    ++l_tilec;
-  }
-  return true;
-}
-
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_start_x    the left position of the rectangle to decode (in image coordinates).
- * @param  p_end_x      the right position of the rectangle to decode (in image coordinates).
- * @param  p_start_y    the up position of the rectangle to decode (in image coordinates).
- * @param  p_end_y      the bottom position of the rectangle to decode (in image coordinates).
- * @param  p_manager    the user event manager
- *
- * @return  true      if the area could be set.
- */
-bool j2k_set_decode_area(
-      opj_j2k_t *p_j2k,
-      OPJ_INT32 p_start_x,
-      OPJ_INT32 p_start_y,
-      OPJ_INT32 p_end_x,
-      OPJ_INT32 p_end_y,
-      struct opj_event_mgr * p_manager
-      )
-{
-  opj_cp_t * l_cp = &(p_j2k->m_cp);
-
-  if
-    (p_j2k->m_specific_param.m_decoder.m_state != J2K_DEC_STATE_TPHSOT)
-  {
-    return false;
-  }
-  p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_start_x - l_cp->tx0) / l_cp->tdx;
-  p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_start_y - l_cp->ty0) / l_cp->tdy;
-  p_j2k->m_specific_param.m_decoder.m_end_tile_x = int_ceildiv((p_end_x - l_cp->tx0), l_cp->tdx);
-  p_j2k->m_specific_param.m_decoder.m_end_tile_y = int_ceildiv((p_end_y - l_cp->ty0), l_cp->tdy);
-  p_j2k->m_specific_param.m_decoder.m_discard_tiles = 1;
-  return true;
-}
-
-void j2k_dump_image(FILE *fd, opj_image_t * img) {
-  OPJ_UINT32 compno; // to avoid signed/unsigned mismatch
-  fprintf(fd, "image {\n");
-  fprintf(fd, "  x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
-  fprintf(fd, "  numcomps=%d\n", img->numcomps);
-  for (compno = 0; compno < img->numcomps; compno++) {
-    opj_image_comp_t *comp = &img->comps[compno];
-    fprintf(fd, "  comp %d {\n", compno);
-    fprintf(fd, "    dx=%d, dy=%d\n", comp->dx, comp->dy);
-    fprintf(fd, "    prec=%d\n", comp->prec);
-    //fprintf(fd, "    bpp=%d\n", comp->bpp);
-    fprintf(fd, "    sgnd=%d\n", comp->sgnd);
-    fprintf(fd, "  }\n");
-  }
-  fprintf(fd, "}\n");
-}
-
-/*
-void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
-  int tileno, compno, layno, bandno, resno, numbands;
-  fprintf(fd, "coding parameters {\n");
-  fprintf(fd, "  tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
-  fprintf(fd, "  tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
-  fprintf(fd, "  tw=%d, th=%d\n", cp->tw, cp->th);
-  for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
-    opj_tcp_t *tcp = &cp->tcps[tileno];
-    fprintf(fd, "  tile %d {\n", tileno);
-    fprintf(fd, "    csty=%x\n", tcp->csty);
-    fprintf(fd, "    prg=%d\n", tcp->prg);
-    fprintf(fd, "    numlayers=%d\n", tcp->numlayers);
-    fprintf(fd, "    mct=%d\n", tcp->mct);
-    fprintf(fd, "    rates=");
-    for (layno = 0; layno < tcp->numlayers; layno++) {
-      fprintf(fd, "%.1f ", tcp->rates[layno]);
-    }
-    fprintf(fd, "\n");
-    for (compno = 0; compno < img->numcomps; compno++) {
-      opj_tccp_t *tccp = &tcp->tccps[compno];
-      fprintf(fd, "    comp %d {\n", compno);
-      fprintf(fd, "      csty=%x\n", tccp->csty);
-      fprintf(fd, "      numresolutions=%d\n", tccp->numresolutions);
-      fprintf(fd, "      cblkw=%d\n", tccp->cblkw);
-      fprintf(fd, "      cblkh=%d\n", tccp->cblkh);
-      fprintf(fd, "      cblksty=%x\n", tccp->cblksty);
-      fprintf(fd, "      qmfbid=%d\n", tccp->qmfbid);
-      fprintf(fd, "      qntsty=%d\n", tccp->qntsty);
-      fprintf(fd, "      numgbits=%d\n", tccp->numgbits);
-      fprintf(fd, "      roishift=%d\n", tccp->roishift);
-      fprintf(fd, "      stepsizes=");
-      numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
-      for (bandno = 0; bandno < numbands; bandno++) {
-        fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
-          tccp->stepsizes[bandno].expn);
-      }
-      fprintf(fd, "\n");
-
-      if (tccp->csty & J2K_CCP_CSTY_PRT) {
-        fprintf(fd, "      prcw=");
-        for (resno = 0; resno < tccp->numresolutions; resno++) {
-          fprintf(fd, "%d ", tccp->prcw[resno]);
-        }
-        fprintf(fd, "\n");
-        fprintf(fd, "      prch=");
-        for (resno = 0; resno < tccp->numresolutions; resno++) {
-          fprintf(fd, "%d ", tccp->prch[resno]);
-        }
-        fprintf(fd, "\n");
-      }
-      fprintf(fd, "    }\n");
-    }
-    fprintf(fd, "  }\n");
-  }
-  fprintf(fd, "}\n");
-}
-*/
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.h
deleted file mode 100644
index a6a9f79..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k.h
+++ /dev/null
@@ -1,737 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __J2K_H
-#define __J2K_H
-/**
- at file j2k.h
- at brief The JPEG-2000 Codestream Reader/Writer (J2K)
-
-The functions in J2K.C have for goal to read/write the several parts of the codestream: markers and data.
-*/
-
-#include "openjpeg.h"
-
-struct opj_dparameters;
-struct opj_stream_private;
-struct opj_event_mgr;
-/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
-/*@{*/
-
-#define J2K_CP_CSTY_PRT 0x01
-#define J2K_CP_CSTY_SOP 0x02
-#define J2K_CP_CSTY_EPH 0x04
-#define J2K_CCP_CSTY_PRT 0x01
-#define J2K_CCP_CBLKSTY_LAZY 0x01
-#define J2K_CCP_CBLKSTY_RESET 0x02
-#define J2K_CCP_CBLKSTY_TERMALL 0x04
-#define J2K_CCP_CBLKSTY_VSC 0x08
-#define J2K_CCP_CBLKSTY_PTERM 0x10
-#define J2K_CCP_CBLKSTY_SEGSYM 0x20
-#define J2K_CCP_QNTSTY_NOQNT 0
-#define J2K_CCP_QNTSTY_SIQNT 1
-#define J2K_CCP_QNTSTY_SEQNT 2
-
-/* ----------------------------------------------------------------------- */
-
-#define J2K_MS_SOC 0xff4f  /**< SOC marker value */
-#define J2K_MS_SOT 0xff90  /**< SOT marker value */
-#define J2K_MS_SOD 0xff93  /**< SOD marker value */
-#define J2K_MS_EOC 0xffd9  /**< EOC marker value */
-#define J2K_MS_SIZ 0xff51  /**< SIZ marker value */
-#define J2K_MS_COD 0xff52  /**< COD marker value */
-#define J2K_MS_COC 0xff53  /**< COC marker value */
-#define J2K_MS_RGN 0xff5e  /**< RGN marker value */
-#define J2K_MS_QCD 0xff5c  /**< QCD marker value */
-#define J2K_MS_QCC 0xff5d  /**< QCC marker value */
-#define J2K_MS_POC 0xff5f  /**< POC marker value */
-#define J2K_MS_TLM 0xff55  /**< TLM marker value */
-#define J2K_MS_PLM 0xff57  /**< PLM marker value */
-#define J2K_MS_PLT 0xff58  /**< PLT marker value */
-#define J2K_MS_PPM 0xff60  /**< PPM marker value */
-#define J2K_MS_PPT 0xff61  /**< PPT marker value */
-#define J2K_MS_SOP 0xff91  /**< SOP marker value */
-#define J2K_MS_EPH 0xff92  /**< EPH marker value */
-#define J2K_MS_CRG 0xff63  /**< CRG marker value */
-#define J2K_MS_COM 0xff64  /**< COM marker value */
-#define J2K_MS_CBD 0xff78  /**< CBD marker value */
-#define J2K_MS_MCC 0xff75  /**< MCC marker value */
-#define J2K_MS_MCT 0xff74  /**< MCT marker value */
-#define J2K_MS_MCO 0xff77  /**< MCO marker value */
-
-/* UniPG>> */
-#ifdef USE_JPWL
-#define J2K_MS_EPC 0xff68  /**< EPC marker value (Part 11: JPEG 2000 for Wireless) */
-#define J2K_MS_EPB 0xff66  /**< EPB marker value (Part 11: JPEG 2000 for Wireless) */
-#define J2K_MS_ESD 0xff67  /**< ESD marker value (Part 11: JPEG 2000 for Wireless) */
-#define J2K_MS_RED 0xff69  /**< RED marker value (Part 11: JPEG 2000 for Wireless) */
-#endif /* USE_JPWL */
-#ifdef USE_JPSEC
-#define J2K_MS_SEC 0xff65    /**< SEC marker value (Part 8: Secure JPEG 2000) */
-#define J2K_MS_INSEC 0xff94  /**< INSEC marker value (Part 8: Secure JPEG 2000) */
-#endif /* USE_JPSEC */
-/* <<UniPG */
-
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Values that specify the status of the decoding process when decoding the main header.
-These values may be combined with a | operator.
-*/
-typedef enum
-{
-  J2K_DEC_STATE_NONE  =  0x0000, /**< a SOC marker is expected */
-  J2K_DEC_STATE_MHSOC  = 0x0001, /**< a SOC marker is expected */
-  J2K_DEC_STATE_MHSIZ  = 0x0002, /**< a SIZ marker is expected */
-  J2K_DEC_STATE_MH     = 0x0004, /**< the decoding process is in the main header */
-  J2K_DEC_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */
-  J2K_DEC_STATE_TPH    = 0x0010, /**< the decoding process is in a tile part header */
-  J2K_DEC_STATE_MT     = 0x0020, /**< the EOC marker has just been read */
-  J2K_DEC_STATE_NEOC   = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
-  J2K_DEC_STATE_DATA   = 0x0080, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
-  J2K_DEC_STATE_ERR    = 0x8000,  /**< the decoding process has encountered an error */
-  J2K_DEC_STATE_EOC   = 0x0100
-}
-J2K_DECODING_STATUS;
-
-/**
-Values that specify the status of the decoding process when decoding the main header.
-These values may be combined with a | operator.
-*/
-typedef enum
-{
-  J2K_ENC_STATE_NONE  =  0x0000, /**< a SOC marker is expected */
-  J2K_ENC_STATE_ENCODE  = 0x0001 /**< a SOC marker is expected */
-}
-J2K_ENCODING_STATUS;
-
-/**
- * Type of data for storing the MCT data
- */
-typedef enum MCT_ELEMENT_TYPE
-{
-  MCT_TYPE_INT16 = 0,    /** MCT data is stored as signed shorts*/
-  MCT_TYPE_INT32 = 1,    /** MCT data is stored as signed integers*/
-  MCT_TYPE_FLOAT = 2,    /** MCT data is stored as floats*/
-  MCT_TYPE_DOUBLE = 3    /** MCT data is stored as doubles*/
-} J2K_MCT_ELEMENT_TYPE;
-
-/**
- * Type of data for storing the MCT data
- */
-typedef enum MCT_ARRAY_TYPE
-{
-  MCT_TYPE_DEPENDENCY = 0,
-  MCT_TYPE_DECORRELATION = 1,
-  MCT_TYPE_OFFSET = 2
-} J2K_MCT_ARRAY_TYPE;
-
-
-/* ----------------------------------------------------------------------- */
-
-
-
-/**
-Quantization stepsize
-*/
-typedef struct opj_stepsize
-{
-  /** exponent */
-  OPJ_UINT32 expn;
-  /** mantissa */
-  OPJ_UINT32 mant;
-}
-opj_stepsize_t;
-
-typedef struct opj_mct_data
-{
-  J2K_MCT_ELEMENT_TYPE m_element_type;
-  J2K_MCT_ARRAY_TYPE   m_array_type;
-  OPJ_UINT32       m_index;
-  OPJ_BYTE *       m_data;
-  OPJ_UINT32       m_data_size;
-}
-opj_mct_data_t;
-
-typedef struct opj_simple_mcc_decorrelation_data
-{
-  OPJ_UINT32       m_index;
-  OPJ_UINT32       m_nb_comps;
-  opj_mct_data_t *   m_decorrelation_array;
-  opj_mct_data_t *   m_offset_array;
-  OPJ_UINT32       m_is_irreversible : 1;
-}
-opj_simple_mcc_decorrelation_data_t;
-
-
-/**
-Tile-component coding parameters
-*/
-typedef struct opj_tccp
-{
-  /** coding style */
-  OPJ_UINT32 csty;
-  /** number of resolutions */
-  OPJ_UINT32 numresolutions;
-  /** code-blocks width */
-  OPJ_UINT32 cblkw;
-  /** code-blocks height */
-  OPJ_UINT32 cblkh;
-  /** code-block coding style */
-  OPJ_UINT32 cblksty;
-  /** discrete wavelet transform identifier */
-  OPJ_UINT32 qmfbid;
-  /** quantisation style */
-  OPJ_UINT32 qntsty;
-  /** stepsizes used for quantization */
-  opj_stepsize_t stepsizes[J2K_MAXBANDS];
-  /** number of guard bits */
-  OPJ_UINT32 numgbits;
-  /** Region Of Interest shift */
-  OPJ_INT32 roishift;
-  /** precinct width */
-  OPJ_UINT32 prcw[J2K_MAXRLVLS];
-  /** precinct height */
-  OPJ_UINT32 prch[J2K_MAXRLVLS];
-  /** the dc_level_shift **/
-  OPJ_INT32 m_dc_level_shift;
-}
-opj_tccp_t;
-
-/**
-Tile coding parameters :
-this structure is used to store coding/decoding parameters common to all
-tiles (information like COD, COC in main header)
-*/
-typedef struct opj_tcp
-{
-  /** coding style */
-  OPJ_UINT32 csty;
-  /** progression order */
-  OPJ_PROG_ORDER prg;
-  /** number of layers */
-  OPJ_UINT32 numlayers;
-  OPJ_UINT32 num_layers_to_decode;
-  /** multi-component transform identifier */
-  OPJ_UINT32 mct;
-  /** rates of layers */
-  OPJ_FLOAT32 rates[100];
-  /** number of progression order changes */
-  OPJ_UINT32 numpocs;
-  /** progression order changes */
-  opj_poc_t pocs[32];
-  /** packet header store there for futur use in t2_decode_packet */
-  OPJ_BYTE *ppt_data;
-  /** used to keep a track of the allocated memory */
-  OPJ_BYTE *ppt_buffer;
-  /** Number of bytes stored inside ppt_data*/
-  OPJ_UINT32 ppt_data_size;
-  /** size of ppt_data*/
-  OPJ_UINT32 ppt_len;
-  /** add fixed_quality */
-  OPJ_FLOAT32 distoratio[100];
-  /** tile-component coding parameters */
-  opj_tccp_t *tccps;
-  /** number of tile parts for the tile. */
-  OPJ_UINT32 m_nb_tile_parts;
-  /** data for the tile */
-  OPJ_BYTE *    m_data;
-  /** size of data */
-  OPJ_UINT32    m_data_size;
-  /** encoding norms */
-  OPJ_FLOAT64 *  mct_norms;
-  /** the mct decoding matrix */
-  OPJ_FLOAT32 *  m_mct_decoding_matrix;
-  /** the mct coding matrix */
-  OPJ_FLOAT32 *  m_mct_coding_matrix;
-  /** mct records */
-  opj_mct_data_t * m_mct_records;
-  /** the number of mct records. */
-  OPJ_UINT32 m_nb_mct_records;
-  /** the max number of mct records. */
-  OPJ_UINT32 m_nb_max_mct_records;
-  /** mcc records */
-  opj_simple_mcc_decorrelation_data_t * m_mcc_records;
-  /** the number of mct records. */
-  OPJ_UINT32 m_nb_mcc_records;
-  /** the max number of mct records. */
-  OPJ_UINT32 m_nb_max_mcc_records;
-
-
-
-  /***** FLAGS *******/
-  /** If ppt == 1 --> there was a PPT marker for the present tile */
-  OPJ_UINT32 ppt : 1;
-  /** indicates if a POC marker has been used O:NO, 1:YES */
-  OPJ_UINT32 POC : 1;
-} opj_tcp_t;
-
-typedef struct opj_encoding_param
-{
-  /** Digital cinema profile*/
-  OPJ_CINEMA_MODE m_cinema;
-  /** Maximum rate for each component. If == 0, component size limitation is not considered */
-  OPJ_UINT32 m_max_comp_size;
-  /** Position of tile part flag in progression order*/
-  OPJ_INT32 m_tp_pos;
-  /** fixed layer */
-  OPJ_INT32 *m_matrice;
-  /** Flag determining tile part generation*/
-  OPJ_BYTE m_tp_flag;
-  /** allocation by rate/distortion */
-  OPJ_UINT32 m_disto_alloc : 1;
-  /** allocation by fixed layer */
-  OPJ_UINT32 m_fixed_alloc : 1;
-  /** add fixed_quality */
-  OPJ_UINT32 m_fixed_quality : 1;
-  /** Enabling Tile part generation*/
-  OPJ_UINT32 m_tp_on : 1;
-}
-opj_encoding_param_t;
-
-typedef struct opj_decoding_param
-{
-  /** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
-  OPJ_UINT32 m_reduce;
-  /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
-  OPJ_UINT32 m_layer;
-}
-opj_decoding_param_t;
-
-/**
-Coding parameters
-*/
-typedef struct opj_cp
-{
-  /** Size of the image in bits*/
-  /*int img_size;*/
-  /** Rsiz*/
-  OPJ_RSIZ_CAPABILITIES rsiz;
-  /** XTOsiz */
-  OPJ_INT32 tx0;
-  /** YTOsiz */
-  OPJ_INT32 ty0;
-  /** XTsiz */
-  OPJ_UINT32 tdx;
-  /** YTsiz */
-  OPJ_UINT32 tdy;
-  /** comment */
-  OPJ_CHAR *comment;
-  /** number of tiles in width */
-  OPJ_UINT32 tw;
-  /** number of tiles in heigth */
-  OPJ_UINT32 th;
-  /** packet header storage original buffer */
-  OPJ_BYTE *ppm_buffer;
-  /** packet header store there for futur use in t2_decode_packet */
-  OPJ_BYTE *ppm_data;
-  /** size of the ppm_data*/
-  OPJ_UINT32 ppm_len;
-  /** Number of bytes actually stored inside the ppm_data */
-  OPJ_UINT32 ppm_data_size;
-  /** tile coding parameters */
-  opj_tcp_t *tcps;
-  union
-  {
-    opj_decoding_param_t m_dec;
-    opj_encoding_param_t m_enc;
-  }
-  m_specific_param;
-
-
-/* UniPG>> */
-#ifdef USE_JPWL
-  /** enables writing of EPC in MH, thus activating JPWL */
-  bool epc_on;
-  /** enables writing of EPB, in case of activated JPWL */
-  bool epb_on;
-  /** enables writing of ESD, in case of activated JPWL */
-  bool esd_on;
-  /** enables writing of informative techniques of ESD, in case of activated JPWL */
-  bool info_on;
-  /** enables writing of RED, in case of activated JPWL */
-  bool red_on;
-  /** error protection method for MH (0,1,16,32,37-128) */
-  int hprot_MH;
-  /** tile number of header protection specification (>=0) */
-  int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-  /** error protection methods for TPHs (0,1,16,32,37-128) */
-  int hprot_TPH[JPWL_MAX_NO_TILESPECS];
-  /** tile number of packet protection specification (>=0) */
-  int pprot_tileno[JPWL_MAX_NO_PACKSPECS];
-  /** packet number of packet protection specification (>=0) */
-  int pprot_packno[JPWL_MAX_NO_PACKSPECS];
-  /** error protection methods for packets (0,1,16,32,37-128) */
-  int pprot[JPWL_MAX_NO_PACKSPECS];
-  /** enables writing of ESD, (0/2/4 bytes) */
-  int sens_size;
-  /** sensitivity addressing size (0=auto/2/4 bytes) */
-  int sens_addr;
-  /** sensitivity range (0-3) */
-  int sens_range;
-  /** sensitivity method for MH (-1,0-7) */
-  int sens_MH;
-  /** tile number of sensitivity specification (>=0) */
-  int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-  /** sensitivity methods for TPHs (-1,0-7) */
-  int sens_TPH[JPWL_MAX_NO_TILESPECS];
-  /** enables JPWL correction at the decoder */
-  bool correct;
-  /** expected number of components at the decoder */
-  int exp_comps;
-  /** maximum number of tiles at the decoder */
-  int max_tiles;
-#endif /* USE_JPWL */
-
-  /******** FLAGS *********/
-  /** if ppm == 1 --> there was a PPM marker*/
-  OPJ_UINT32 ppm : 1;
-  /** tells if the parameter is a coding or decoding one */
-  OPJ_UINT32 m_is_decoder : 1;
-/* <<UniPG */
-} opj_cp_t;
-
-typedef struct opj_j2k_dec
-{
-  /** locate in which part of the codestream the decoder is (main header, tile header, end) */
-  OPJ_UINT32 m_state;
-  /**
-   * store decoding parameters common to all tiles (information like COD, COC in main header)
-   */
-  opj_tcp_t *m_default_tcp;
-  OPJ_BYTE  *m_header_data;
-  OPJ_UINT32 m_header_data_size;
-  /** to tell the tile part length */
-  OPJ_UINT32 m_sot_length;
-  /** Only tiles index in the correct range will be decoded.*/
-  OPJ_UINT32 m_start_tile_x;
-  OPJ_UINT32 m_start_tile_y;
-  OPJ_UINT32 m_end_tile_x;
-  OPJ_UINT32 m_end_tile_y;
-  /** to tell that a tile can be decoded. */
-  OPJ_UINT32 m_can_decode      : 1;
-  OPJ_UINT32 m_discard_tiles    : 1;
-  OPJ_UINT32 m_skip_data      : 1;
-
-} opj_j2k_dec_t;
-
-typedef struct opj_j2k_enc
-{
-  /** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/
-  OPJ_UINT32 m_current_poc_tile_part_number; // tp_num
-
-  /** Tile part number currently coding, taking into account POC. m_current_tile_part_number holds the total number of tile parts while encoding the last tile part.*/
-  OPJ_UINT32 m_current_tile_part_number; //cur_tp_num
-
-  /**
-  locate the start position of the TLM marker
-  after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length.
-  */
-  OPJ_SIZE_T m_tlm_start;
-  /**
-   * Stores the sizes of the tlm.
-   */
-  OPJ_BYTE * m_tlm_sot_offsets_buffer;
-  /**
-   * The current offset of the tlm buffer.
-   */
-  OPJ_BYTE * m_tlm_sot_offsets_current;
-
-  /** Total num of tile parts in whole image = num tiles* num tileparts in each tile*/
-  /** used in TLMmarker*/
-  OPJ_UINT32 m_total_tile_parts;   // totnum_tp
-
-  /* encoded data for a tile */
-  OPJ_BYTE * m_encoded_tile_data;
-
-  /* size of the encoded_data */
-  OPJ_UINT32 m_encoded_tile_size;
-
-  /* encoded data for a tile */
-  OPJ_BYTE * m_header_tile_data;
-
-  /* size of the encoded_data */
-  OPJ_UINT32 m_header_tile_data_size;
-
-
-} opj_j2k_enc_t;
-
-
-
-
-/**
-JPEG-2000 codestream reader/writer
-*/
-typedef struct opj_j2k
-{
-  union
-  {
-    opj_j2k_dec_t m_decoder;
-    opj_j2k_enc_t m_encoder;
-  }
-  m_specific_param;
-
-  /** number of the tile curently concern by coding/decoding */
-  OPJ_UINT32 m_current_tile_number;
-
-  /** pointer to the encoded / decoded image */
-  opj_image_t *m_image;
-
-  /** Coding parameters */
-  opj_cp_t m_cp;
-
-  /** the list of procedures to exec **/
-  struct opj_procedure_list *  m_procedure_list;
-
-  /** the list of validation procedures to follow to make sure the code is valid **/
-  struct opj_procedure_list *  m_validation_list;
-
-  /** helper used to write the index file */
-  opj_codestream_info_t *cstr_info;
-
-  /** the current tile coder/decoder **/
-  struct opj_tcd *  m_tcd;
-
-  OPJ_UINT32 m_is_decoder : 1;
-
-}
-opj_j2k_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
- * Creates a J2K decompression structure.
- *
- * @return a handle to a J2K decompressor if successful, NULL otherwise.
-*/
-opj_j2k_t* j2k_create_decompress();
-
-/**
- * Destroys a jpeg2000 codec.
- *
- * @param  p_j2k  the jpeg20000 structure to destroy.
- */
-void j2k_destroy (opj_j2k_t *p_j2k);
-
-/**
- * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
- *
- * @param  p_j2k    the jpeg2000 codec.
- * @param  cio      the stream object.
- * @param  p_manager  the user event manager.
- *
- * @return true if the codec is valid.
- */
-bool j2k_start_compress(
-            opj_j2k_t *p_j2k,
-            struct opj_stream_private *cio,
-            struct opj_image * p_image,
-            struct opj_event_mgr * p_manager
-            );
-/**
- * Ends the compression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool j2k_end_compress(opj_j2k_t *p_j2k, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
-
-/**
- * Sets up the decoder decoding parameters using user parameters.
- * Decoding parameters are stored in j2k->cp.
- *
- * @param  p_j2k      J2K codec
- * @param  p_parameters  decompression parameters
- * @deprecated
-*/
-void j2k_setup_decoder(
-             opj_j2k_t *p_j2k,
-             struct opj_dparameters *p_parameters
-             );
-/**
- * Reads a jpeg2000 codestream header structure.
- *
- * @param cio the stream to read data from.
- * @param p_j2k the jpeg2000 codec.
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-bool j2k_read_header(
-                opj_j2k_t *p_j2k,
-                struct opj_image ** p_image,
-                OPJ_INT32 * p_tile_x0,
-                OPJ_INT32 * p_tile_y0,
-                OPJ_UINT32 * p_tile_width,
-                OPJ_UINT32 * p_tile_height,
-                OPJ_UINT32 * p_nb_tiles_x,
-                OPJ_UINT32 * p_nb_tiles_y,
-                struct opj_stream_private *cio,
-                struct opj_event_mgr * p_manager
-              );
-/**
-Decode an image from a JPEG-2000 codestream
- at param j2k J2K decompressor handle
- at param cio Input buffer stream
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-opj_image_t* j2k_decode(opj_j2k_t *j2k, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
-
-/**
- * Ends the decompression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool j2k_end_decompress(opj_j2k_t *j2k, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
-
-/**
-Decode an image form a JPT-stream (JPEG 2000, JPIP)
- at param j2k J2K decompressor handle
- at param cio Input buffer stream
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, struct opj_stream_private *cio, struct opj_codestream_info *cstr_info);
-
-/**
-Creates a J2K compression structure
- at param cinfo Codec context info
- at return Returns a handle to a J2K compressor if successful, returns NULL otherwise
-*/
-opj_j2k_t* j2k_create_compress();
-
-/**
-Setup the encoder parameters using the current image and using user parameters.
-Coding parameters are returned in j2k->cp.
- at param j2k J2K compressor handle
- at param parameters compression parameters
- at param image input filled image
-*/
-void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image, struct opj_event_mgr * p_manager);
-
-/**
- * Writes a tile.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool j2k_write_tile (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 p_tile_index,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           struct opj_stream_private *p_stream,
-           struct opj_event_mgr * p_manager
-          );
-
-/**
- * Converts an enum type progression order to string type.
- *
- * @param prg_order    the progression order to get.
- *
- * @return  the string representation of the gicen progression order.
- */
-const char * j2k_convert_progression_order(OPJ_PROG_ORDER prg_order);
-
-
-/**
- * Encodes an image into a JPEG-2000 codestream
- */
-bool j2k_encode(
-          opj_j2k_t * p_j2k,
-          struct opj_stream_private *cio,
-          struct opj_event_mgr * p_manager
-        );
-bool   j2k_setup_mct_encoding (opj_tcp_t * p_tcp,opj_image_t * p_image);
-
-/**
- * Decode tile data.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool j2k_decode_tile (
-          opj_j2k_t * p_j2k,
-          OPJ_UINT32 p_tile_index,
-          OPJ_BYTE * p_data,
-          OPJ_UINT32 p_data_size,
-          struct opj_stream_private *p_stream,
-          struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a tile header.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool j2k_read_tile_header (
-           opj_j2k_t * p_j2k,
-           OPJ_UINT32 * p_tile_index,
-           OPJ_UINT32 * p_data_size,
-           OPJ_INT32 * p_tile_x0,
-           OPJ_INT32 * p_tile_y0,
-           OPJ_INT32 * p_tile_x1,
-           OPJ_INT32 * p_tile_y1,
-           OPJ_UINT32 * p_nb_comps,
-           bool * p_go_on,
-           struct opj_stream_private *p_stream,
-           struct opj_event_mgr * p_manager
-          );
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param  p_j2k      the jpeg2000 codec.
- * @param  p_start_x    the left position of the rectangle to decode (in image coordinates).
- * @param  p_end_x      the right position of the rectangle to decode (in image coordinates).
- * @param  p_start_y    the up position of the rectangle to decode (in image coordinates).
- * @param  p_end_y      the bottom position of the rectangle to decode (in image coordinates).
- * @param  p_manager    the user event manager
- *
- * @return  true      if the area could be set.
- */
-bool j2k_set_decode_area(
-      opj_j2k_t *p_j2k,
-      OPJ_INT32 p_start_x,
-      OPJ_INT32 p_start_y,
-      OPJ_INT32 p_end_x,
-      OPJ_INT32 p_end_y,
-      struct opj_event_mgr * p_manager
-      );
-
-void j2k_dump_image(FILE *fd, opj_image_t * img);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __J2K_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k_lib.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k_lib.c
deleted file mode 100644
index 5515bd7..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k_lib.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef WIN32
-#include <windows.h>
-#else
-/*#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/times.h>
-*/
-#endif /* WIN32 */
-#include "j2k_lib.h"
-
-
-OPJ_FLOAT64 opj_clock(void) {
-#if 0
-#ifdef WIN32
-  /* WIN32: use QueryPerformance (very accurate) */
-    LARGE_INTEGER freq , t ;
-    /* freq is the clock speed of the CPU */
-    QueryPerformanceFrequency(&freq) ;
-  /* cout << "freq = " << ((double) freq.QuadPart) << endl; */
-    /* t is the high resolution performance counter (see MSDN) */
-    QueryPerformanceCounter ( & t ) ;
-    return ( t.QuadPart /(double) freq.QuadPart ) ;
-#else
-  /* Unix or Linux: use resource usage */
-    struct rusage t;
-    double procTime;
-    /* (1) Get the rusage data structure at this moment (man getrusage) */
-    getrusage(0,&t);
-    /* (2) What is the elapsed time ? - CPU time = User time + System time */
-  /* (2a) Get the seconds */
-    procTime = t.ru_utime.tv_sec + t.ru_stime.tv_sec;
-    /* (2b) More precisely! Get the microseconds part ! */
-    return ( procTime + (t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
-#endif
-
-#endif
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.c
deleted file mode 100644
index 523a207..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.c
+++ /dev/null
@@ -1,2229 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "jp2.h"
-#include "cio.h"
-#include "opj_malloc.h"
-#include "event.h"
-#include "j2k.h"
-#include "function_list.h"
-#include "assert.h"
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-#define BOX_SIZE  1024
-
-
-
-/** @name Local static functions */
-/*@{*/
-
-
-
-/**
- * Writes the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  user event manager.
- *
- * @return true if writting was successful.
-*/
-bool jp2_write_jp2h(
-            opj_jp2_t *jp2,
-            struct opj_stream_private *cio,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Skips the Jpeg2000 Codestream Header box - JP2C Header box.
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  user event manager.
- *
- * @return true if writting was successful.
-*/
-bool jp2_skip_jp2c(
-            opj_jp2_t *jp2,
-            struct opj_stream_private *cio,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
- *
- * @param  p_header_data  the data contained in the file header box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the file header box.
- * @param  p_manager    the user event manager.
- *
- * @return true if the JP2 Header box was successfully reconized.
-*/
-bool jp2_read_jp2h(
-            opj_jp2_t *jp2,
-            unsigned char * p_header_data,
-            unsigned int p_header_size,
-            struct opj_event_mgr * p_manager
-          );
-
-/**
- * Writes the Jpeg2000 codestream Header box - JP2C Header box. This function must be called AFTER the coding has been done.
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  user event manager.
- *
- * @return true if writting was successful.
-*/
-static bool jp2_write_jp2c(
-           opj_jp2_t *jp2,
-           struct opj_stream_private *cio,
-           struct opj_event_mgr * p_manager
-           );
-
-/**
- * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure.
- *
- * @param  cio            the input stream to read data from.
- * @param  box            the box structure to fill.
- * @param  p_number_bytes_read    pointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
- * @param  p_manager        user event manager.
- *
- * @return  true if the box is reconized, false otherwise
-*/
-static bool jp2_read_boxhdr(
-                opj_jp2_box_t *box,
-                OPJ_UINT32 * p_number_bytes_read,
-                struct opj_stream_private *cio,
-                struct opj_event_mgr * p_manager
-              );
-
-/**
- * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure. Data is read from a character string
- *
- * @param  p_data          the character string to read data from.
- * @param  box            the box structure to fill.
- * @param  p_number_bytes_read    pointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
- * @param  p_box_max_size      the maximum number of bytes in the box.
- *
- * @return  true if the box is reconized, false otherwise
-*/
-static bool jp2_read_boxhdr_char(
-                opj_jp2_box_t *box,
-                OPJ_BYTE * p_data,
-                OPJ_UINT32 * p_number_bytes_read,
-                OPJ_UINT32 p_box_max_size,
-                struct opj_event_mgr * p_manager
-              );
-
-/**
- * Reads a jpeg2000 file signature box.
- *
- * @param  p_header_data  the data contained in the signature box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the signature box.
- * @param  p_manager    the user event manager.
- *
- * @return true if the file signature box is valid.
- */
-static bool jp2_read_jp(
-          opj_jp2_t *jp2,
-          unsigned char * p_header_data,
-          unsigned int p_header_size,
-          struct opj_event_mgr * p_manager
-         );
-
-/**
- * Writes a jpeg2000 file signature box.
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  the user event manager.
- *
- * @return true if writting was successful.
- */
-static bool jp2_write_jp(
-              opj_jp2_t *jp2,
-              struct opj_stream_private *cio,
-              struct opj_event_mgr * p_manager
-            );
-
-/**
- * Writes a FTYP box - File type box
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  the user event manager.
- *
- * @return  true if writting was successful.
- */
-static bool jp2_write_ftyp(
-              opj_jp2_t *jp2,
-              struct opj_stream_private *cio,
-              struct opj_event_mgr * p_manager
-              );
-
-/**
- * Reads a a FTYP box - File type box
- *
- * @param  p_header_data  the data contained in the FTYP box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the FTYP box.
- * @param  p_manager    the user event manager.
- *
- * @return true if the FTYP box is valid.
- */
-static bool jp2_read_ftyp(
-              opj_jp2_t *jp2,
-              unsigned char * p_header_data,
-              unsigned int p_header_size,
-              struct opj_event_mgr * p_manager
-            );
-
-/**
- * Reads a IHDR box - Image Header box
- *
- * @param  p_image_header_data      pointer to actual data (already read from file)
- * @param  jp2              the jpeg2000 file codec.
- * @param  p_image_header_size      the size of the image header
- * @param  p_manager          the user event manager.
- *
- * @return  true if the image header is valid, fale else.
- */
-static bool jp2_read_ihdr(
-              opj_jp2_t *jp2,
-              unsigned char * p_image_header_data,
-              unsigned int p_image_header_size,
-              struct opj_event_mgr * p_manager
-              );
-
-/**
- * Writes the Image Header box - Image Header box.
- *
- * @param jp2          jpeg2000 file codec.
- * @param p_nb_bytes_written  pointer to store the nb of bytes written by the function.
- *
- * @return  the data being copied.
-*/
-static unsigned char * jp2_write_ihdr(
-                opj_jp2_t *jp2,
-                unsigned int * p_nb_bytes_written
-               );
-
-/**
- * Reads a Bit per Component box.
- *
- * @param  p_bpc_header_data      pointer to actual data (already read from file)
- * @param  jp2              the jpeg2000 file codec.
- * @param  p_bpc_header_size      the size of the bpc header
- * @param  p_manager          the user event manager.
- *
- * @return  true if the bpc header is valid, fale else.
- */
-static bool jp2_read_bpcc(
-              opj_jp2_t *jp2,
-              unsigned char * p_bpc_header_data,
-              unsigned int p_bpc_header_size,
-              struct opj_event_mgr * p_manager
-              );
-
-
-/**
- * Writes the Bit per Component box.
- *
- * @param  jp2            jpeg2000 file codec.
- * @param  p_nb_bytes_written    pointer to store the nb of bytes written by the function.
- *
- * @return  the data being copied.
-*/
-static unsigned char * jp2_write_bpcc(
-                opj_jp2_t *jp2,
-                unsigned int * p_nb_bytes_written
-               );
-
-/**
- * Reads the Colour Specification box.
- *
- * @param  p_colr_header_data      pointer to actual data (already read from file)
- * @param  jp2              the jpeg2000 file codec.
- * @param  p_colr_header_size      the size of the color header
- * @param  p_manager          the user event manager.
- *
- * @return  true if the bpc header is valid, fale else.
-*/
-static bool jp2_read_colr(
-              opj_jp2_t *jp2,
-              unsigned char * p_colr_header_data,
-              unsigned int p_colr_header_size,
-              struct opj_event_mgr * p_manager
-              );
-
-/**
- * Writes the Colour Specification box.
- *
- * @param jp2          jpeg2000 file codec.
- * @param p_nb_bytes_written  pointer to store the nb of bytes written by the function.
- *
- * @return  the data being copied.
-*/
-static unsigned char *jp2_write_colr(
-                opj_jp2_t *jp2,
-                unsigned int * p_nb_bytes_written
-              );
-
-
-/**
- * Reads a jpeg2000 file header structure.
- *
- * @param cio the stream to read data from.
- * @param jp2 the jpeg2000 file header structure.
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-bool jp2_read_header_procedure(
-                opj_jp2_t *jp2,
-                struct opj_stream_private *cio,
-                struct opj_event_mgr * p_manager
-              );
-/**
- * Excutes the given procedures on the given codec.
- *
- * @param  p_procedure_list  the list of procedures to execute
- * @param  jp2          the jpeg2000 file codec to execute the procedures on.
- * @param  cio          the stream to execute the procedures on.
- * @param  p_manager      the user manager.
- *
- * @return  true        if all the procedures were successfully executed.
- */
-static bool jp2_exec (
-          opj_jp2_t * jp2,
-          struct opj_procedure_list * p_procedure_list,
-          struct opj_stream_private *cio,
-          struct opj_event_mgr * p_manager
-          );
-/**
- * Finds the execution function related to the given box id.
- *
- * @param  p_id  the id of the handler to fetch.
- *
- * @return  the given handler or NULL if it could not be found.
- */
-static const opj_jp2_header_handler_t * jp2_find_handler (int p_id);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-static void jp2_setup_encoding_validation (opj_jp2_t *jp2);
-
-/**
- * Sets up the procedures to do on writting header. Developpers wanting to extend the library can add their own writting procedures.
- */
-static void jp2_setup_header_writting (opj_jp2_t *jp2);
-
-/**
- * The default validation procedure without any extension.
- *
- * @param  jp2        the jpeg2000 codec to validate.
- * @param  cio        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool jp2_default_validation (
-                  opj_jp2_t * jp2,
-                  struct opj_stream_private *cio,
-                  struct opj_event_mgr * p_manager
-                    );
-
-/**
- * Finds the execution function related to the given box id.
- *
- * @param  p_id  the id of the handler to fetch.
- *
- * @return  the given handler or NULL if it could not be found.
- */
-static const opj_jp2_header_handler_t * jp2_find_handler (
-                        int p_id
-                        );
-
-/**
- * Finds the image execution function related to the given box id.
- *
- * @param  p_id  the id of the handler to fetch.
- *
- * @return  the given handler or NULL if it could not be found.
- */
-static const opj_jp2_header_handler_t * jp2_img_find_handler (
-                        int p_id
-                        );
-
-/**
- * Sets up the procedures to do on writting header after the codestream.
- * Developpers wanting to extend the library can add their own writting procedures.
- */
-static void jp2_setup_end_header_writting (opj_jp2_t *jp2);
-
-/**
- * Sets up the procedures to do on reading header after the codestream.
- * Developpers wanting to extend the library can add their own writting procedures.
- */
-static void jp2_setup_end_header_reading (opj_jp2_t *jp2);
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-static void jp2_setup_decoding_validation (opj_jp2_t *jp2);
-
-/**
- * Sets up the procedures to do on reading header.
- * Developpers wanting to extend the library can add their own writting procedures.
- */
-static void jp2_setup_header_reading (opj_jp2_t *jp2);
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-const opj_jp2_header_handler_t jp2_header [] =
-{
-  {JP2_JP,jp2_read_jp},
-  {JP2_FTYP,jp2_read_ftyp},
-  {JP2_JP2H,jp2_read_jp2h}
-};
-
-const opj_jp2_header_handler_t jp2_img_header [] =
-{
-  {JP2_IHDR,jp2_read_ihdr},
-  {JP2_COLR,jp2_read_colr},
-  {JP2_BPCC,jp2_read_bpcc}
-};
-/**
- * Finds the execution function related to the given box id.
- *
- * @param  p_id  the id of the handler to fetch.
- *
- * @return  the given handler or 00 if it could not be found.
- */
-const opj_jp2_header_handler_t * jp2_find_handler (
-                        int p_id
-                        )
-{
-  unsigned int i, l_handler_size = sizeof(jp2_header) / sizeof(opj_jp2_header_handler_t);
-  for
-    (i=0;i<l_handler_size;++i)
-  {
-    if
-      (jp2_header[i].id == p_id)
-    {
-      return &jp2_header[i];
-    }
-  }
-  return 00;
-}
-
-/**
- * Finds the image execution function related to the given box id.
- *
- * @param  p_id  the id of the handler to fetch.
- *
- * @return  the given handler or 00 if it could not be found.
- */
-static const opj_jp2_header_handler_t * jp2_img_find_handler (
-                        int p_id
-                        )
-{
-  unsigned int i, l_handler_size = sizeof(jp2_img_header) / sizeof(opj_jp2_header_handler_t);
-  for
-    (i=0;i<l_handler_size;++i)
-  {
-    if
-      (jp2_img_header[i].id == p_id)
-    {
-      return &jp2_img_header[i];
-    }
-  }
-  return 00;
-
-}
-
-/**
- * Reads a jpeg2000 file header structure.
- *
- * @param cio the stream to read data from.
- * @param jp2 the jpeg2000 file header structure.
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-bool jp2_read_header_procedure(
-           opj_jp2_t *jp2,
-           opj_stream_private_t *cio,
-           opj_event_mgr_t * p_manager)
-{
-  opj_jp2_box_t box;
-  unsigned int l_nb_bytes_read;
-  const opj_jp2_header_handler_t * l_current_handler;
-  unsigned int l_last_data_size = BOX_SIZE;
-  unsigned int l_current_data_size;
-  unsigned char * l_current_data = 00;
-
-  // preconditions
-  assert(cio != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  l_current_data = (unsigned char*)opj_malloc(l_last_data_size);
-
-  if
-    (l_current_data == 00)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle jpeg2000 file header\n");
-    return false;
-  }
-  memset(l_current_data, 0 , l_last_data_size);
-  while
-    (jp2_read_boxhdr(&box,&l_nb_bytes_read,cio,p_manager))
-  {
-    // is it the codestream box ?
-    if
-      (box.type == JP2_JP2C)
-    {
-      if
-        (jp2->jp2_state & JP2_STATE_HEADER)
-      {
-        jp2->jp2_state |= JP2_STATE_CODESTREAM;
-        return true;
-      }
-      else
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "bad placed jpeg codestream\n");
-        return false;
-      }
-    }
-    else if
-      (box.length == 0)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
-      return false;
-    }
-
-    l_current_handler = jp2_find_handler(box.type);
-    l_current_data_size = box.length - l_nb_bytes_read;
-
-    if
-      (l_current_handler != 00)
-    {
-      if
-        (l_current_data_size > l_last_data_size)
-      {
-        l_current_data = (unsigned char*)opj_realloc(l_current_data,l_current_data_size);
-        l_last_data_size = l_current_data_size;
-      }
-      l_nb_bytes_read = opj_stream_read_data(cio,l_current_data,l_current_data_size,p_manager);
-      if
-        (l_nb_bytes_read != l_current_data_size)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Problem with reading JPEG2000 box, stream error\n");
-        return false;
-      }
-      if
-        (! l_current_handler->handler(jp2,l_current_data,l_current_data_size,p_manager))
-      {
-        return false;
-      }
-    }
-    else
-    {
-      jp2->jp2_state |= JP2_STATE_UNKNOWN;
-      if
-        (opj_stream_skip(cio,l_current_data_size,p_manager) != l_current_data_size)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Problem with skipping JPEG2000 box, stream error\n");
-        return false;
-      }
-    }
-  }
-  return true;
-}
-
-/**
- * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure.
- *
- * @param  cio            the input stream to read data from.
- * @param  box            the box structure to fill.
- * @param  p_number_bytes_read    pointer to an int that will store the number of bytes read from the stream (should usually be 8).
- * @param  p_manager        user event manager.
- *
- * @return  true if the box is reconized, false otherwise
-*/
-bool jp2_read_boxhdr(opj_jp2_box_t *box, OPJ_UINT32 * p_number_bytes_read,opj_stream_private_t *cio, opj_event_mgr_t * p_manager)
-{
-  /* read header from file */
-  unsigned char l_data_header [8];
-
-  // preconditions
-  assert(cio != 00);
-  assert(box != 00);
-  assert(p_number_bytes_read != 00);
-  assert(p_manager != 00);
-
-  *p_number_bytes_read = opj_stream_read_data(cio,l_data_header,8,p_manager);
-  if
-    (*p_number_bytes_read != 8)
-  {
-    return false;
-  }
-  /* process read data */
-  opj_read_bytes(l_data_header,&(box->length), 4);
-  opj_read_bytes(l_data_header+4,&(box->type), 4);
-
-  // do we have a "special very large box ?"
-  // read then the XLBox
-  if
-    (box->length == 1)
-  {
-    OPJ_UINT32 l_xl_part_size;
-    OPJ_UINT32 l_nb_bytes_read = opj_stream_read_data(cio,l_data_header,8,p_manager);
-    if
-      (l_nb_bytes_read != 8)
-    {
-      if
-        (l_nb_bytes_read > 0)
-      {
-        *p_number_bytes_read += l_nb_bytes_read;
-      }
-      return false;
-    }
-    opj_read_bytes(l_data_header,&l_xl_part_size, 4);
-    if
-      (l_xl_part_size != 0)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
-      return false;
-    }
-    opj_read_bytes(l_data_header,&(box->length), 4);
-  }
-  return true;
-}
-
-/**
- * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure. Data is read from a character string
- *
- * @param  p_data          the character string to read data from.
- * @param  box            the box structure to fill.
- * @param  p_number_bytes_read    pointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
- * @param  p_box_max_size      the maximum number of bytes in the box.
- *
- * @return  true if the box is reconized, false otherwise
-*/
-static bool jp2_read_boxhdr_char(
-                opj_jp2_box_t *box,
-                OPJ_BYTE * p_data,
-                OPJ_UINT32 * p_number_bytes_read,
-                OPJ_UINT32 p_box_max_size,
-                opj_event_mgr_t * p_manager
-              )
-{
-  // preconditions
-  assert(p_data != 00);
-  assert(box != 00);
-  assert(p_number_bytes_read != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_box_max_size < 8)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of less than 8 bytes\n");
-    return false;
-  }
-  /* process read data */
-  opj_read_bytes(p_data,&(box->length), 4);
-  p_data += 4;
-  opj_read_bytes(p_data,&(box->type), 4);
-  p_data += 4;
-  *p_number_bytes_read = 8;
-
-  // do we have a "special very large box ?"
-  // read then the XLBox
-  if
-    (box->length == 1)
-  {
-    unsigned int l_xl_part_size;
-    if
-      (p_box_max_size < 16)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Cannot handle XL box of less than 16 bytes\n");
-      return false;
-    }
-
-    opj_read_bytes(p_data,&l_xl_part_size, 4);
-    p_data += 4;
-    *p_number_bytes_read += 4;
-    if
-      (l_xl_part_size != 0)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
-      return false;
-    }
-    opj_read_bytes(p_data,&(box->length), 4);
-    *p_number_bytes_read += 4;
-    if
-      (box->length == 0)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
-      return false;
-    }
-
-  }
-  else if
-    (box->length == 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
-    return false;
-  }
-  return true;
-}
-
-
-/**
- * Reads a jpeg2000 file signature box.
- *
- * @param  p_header_data  the data contained in the signature box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the signature box.
- * @param  p_manager    the user event manager.
- *
- * @return true if the file signature box is valid.
- */
-bool jp2_read_jp(
-          opj_jp2_t *jp2,
-          unsigned char * p_header_data,
-          unsigned int p_header_size,
-          opj_event_mgr_t * p_manager
-         )
-{
-  unsigned int l_magic_number;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  if
-    (jp2->jp2_state != JP2_STATE_NONE)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "The signature box must be the first box in the file.\n");
-    return false;
-  }
-
-
-  /* assure length of data is correct (4 -> magic number) */
-  if
-    (p_header_size != 4)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error with JP signature Box size\n");
-    return false;
-  }
-
-  // rearrange data
-  opj_read_bytes(p_header_data,&l_magic_number,4);
-  if
-    (l_magic_number != 0x0d0a870a )
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error with JP Signature : bad magic number\n");
-    return false;
-  }
-  jp2->jp2_state |= JP2_STATE_SIGNATURE;
-  return true;
-}
-
-/**
- * Reads a a FTYP box - File type box
- *
- * @param  p_header_data  the data contained in the FTYP box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the FTYP box.
- * @param  p_manager    the user event manager.
- *
- * @return true if the FTYP box is valid.
- */
-bool jp2_read_ftyp(
-              opj_jp2_t *jp2,
-              unsigned char * p_header_data,
-              unsigned int p_header_size,
-              opj_event_mgr_t * p_manager
-            )
-{
-  unsigned int i;
-  unsigned int l_remaining_bytes;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  if
-    (jp2->jp2_state != JP2_STATE_SIGNATURE)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "The ftyp box must be the second box in the file.\n");
-    return false;
-  }
-
-  /* assure length of data is correct */
-  if
-    (p_header_size < 8)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error with FTYP signature Box size\n");
-    return false;
-  }
-
-  opj_read_bytes(p_header_data,&jp2->brand,4);    /* BR */
-  p_header_data += 4;
-
-  opj_read_bytes(p_header_data,&jp2->minversion,4);    /* MinV */
-  p_header_data += 4;
-
-  l_remaining_bytes = p_header_size - 8;
-
-  /* the number of remaining bytes should be a multiple of 4 */
-  if
-    ((l_remaining_bytes & 0x3) != 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error with FTYP signature Box size\n");
-    return false;
-  }
-  /* div by 4 */
-  jp2->numcl = l_remaining_bytes >> 2;
-  if
-    (jp2->numcl)
-  {
-    jp2->cl = (unsigned int *) opj_malloc(jp2->numcl * sizeof(unsigned int));
-    if
-      (jp2->cl == 00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Not enough memory with FTYP Box\n");
-      return false;
-    }
-    memset(jp2->cl,0,jp2->numcl * sizeof(unsigned int));
-  }
-
-
-  for
-    (i = 0; i < jp2->numcl; ++i)
-  {
-    opj_read_bytes(p_header_data,&jp2->cl[i],4);    /* CLi */
-    p_header_data += 4;
-
-  }
-  jp2->jp2_state |= JP2_STATE_FILE_TYPE;
-  return true;
-}
-
-/**
- * Writes a jpeg2000 file signature box.
- *
- * @param cio the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param p_manager the user event manager.
- *
- * @return true if writting was successful.
- */
-bool jp2_write_jp (
-          opj_jp2_t *jp2,
-          opj_stream_private_t *cio,
-          opj_event_mgr_t * p_manager
-           )
-{
-  /* 12 bytes will be read */
-  unsigned char l_signature_data [12];
-
-  // preconditions
-  assert(cio != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-
-  /* write box length */
-  opj_write_bytes(l_signature_data,12,4);
-  /* writes box type */
-  opj_write_bytes(l_signature_data+4,JP2_JP,4);
-  /* writes magic number*/
-  opj_write_bytes(l_signature_data+8,0x0d0a870a,4);
-  if
-    (opj_stream_write_data(cio,l_signature_data,12,p_manager) != 12)
-  {
-    return false;
-  }
-  return true;
-}
-
-
-/**
- * Writes a FTYP box - File type box
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  the user event manager.
- *
- * @return  true if writting was successful.
- */
-bool jp2_write_ftyp(
-            opj_jp2_t *jp2,
-            opj_stream_private_t *cio,
-            opj_event_mgr_t * p_manager
-          )
-{
-  unsigned int i;
-  unsigned int l_ftyp_size = 16 + 4 * jp2->numcl;
-  unsigned char * l_ftyp_data, * l_current_data_ptr;
-  bool l_result;
-
-  // preconditions
-  assert(cio != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  l_ftyp_data = (unsigned char *) opj_malloc(l_ftyp_size);
-
-  if
-    (l_ftyp_data == 00)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle ftyp data\n");
-    return false;
-  }
-  memset(l_ftyp_data,0,l_ftyp_size);
-
-  l_current_data_ptr = l_ftyp_data;
-
-  opj_write_bytes(l_current_data_ptr, l_ftyp_size,4); /* box size */
-  l_current_data_ptr += 4;
-
-  opj_write_bytes(l_current_data_ptr, JP2_FTYP,4); /* FTYP */
-  l_current_data_ptr += 4;
-
-  opj_write_bytes(l_current_data_ptr, jp2->brand,4); /* BR */
-  l_current_data_ptr += 4;
-
-  opj_write_bytes(l_current_data_ptr, jp2->minversion,4); /* MinV */
-  l_current_data_ptr += 4;
-
-  for
-    (i = 0; i < jp2->numcl; i++)
-  {
-    opj_write_bytes(l_current_data_ptr, jp2->cl[i],4);  /* CL */
-  }
-
-  l_result = (opj_stream_write_data(cio,l_ftyp_data,l_ftyp_size,p_manager) == l_ftyp_size);
-  if
-    (! l_result)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error while writting ftyp data to stream\n");
-  }
-  opj_free(l_ftyp_data);
-  return l_result;
-}
-
-/**
- * Writes the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
- *
- * @param cio      the stream to write data to.
- * @param jp2      the jpeg2000 file codec.
- * @param p_manager    user event manager.
- *
- * @return true if writting was successful.
-*/
-bool jp2_write_jp2h(
-            opj_jp2_t *jp2,
-            opj_stream_private_t *cio,
-            opj_event_mgr_t * p_manager
-          )
-{
-  opj_jp2_img_header_writer_handler_t l_writers [3];
-  opj_jp2_img_header_writer_handler_t * l_current_writer;
-
-  int i, l_nb_pass;
-  /* size of data for super box*/
-  int l_jp2h_size = 8;
-  bool l_result = true;
-
-  /* to store the data of the super box */
-  unsigned char l_jp2h_data [8];
-
-  // preconditions
-  assert(cio != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  memset(l_writers,0,sizeof(l_writers));
-
-  if
-    (jp2->bpc == 255)
-  {
-    l_nb_pass = 3;
-    l_writers[0].handler = jp2_write_ihdr;
-    l_writers[1].handler = jp2_write_bpcc;
-    l_writers[2].handler = jp2_write_colr;
-  }
-  else
-  {
-    l_nb_pass = 2;
-    l_writers[0].handler = jp2_write_ihdr;
-    l_writers[1].handler = jp2_write_colr;
-  }
-
-  /* write box header */
-  /* write JP2H type */
-  opj_write_bytes(l_jp2h_data+4,JP2_JP2H,4);
-
-  l_current_writer = l_writers;
-  for
-    (i=0;i<l_nb_pass;++i)
-  {
-    l_current_writer->m_data = l_current_writer->handler(jp2,&(l_current_writer->m_size));
-    if
-      (l_current_writer->m_data == 00)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to hold JP2 Header data\n");
-      l_result = false;
-      break;
-    }
-    l_jp2h_size += l_current_writer->m_size;
-    ++l_current_writer;
-  }
-
-  if
-    (! l_result)
-  {
-    l_current_writer = l_writers;
-    for
-      (i=0;i<l_nb_pass;++i)
-    {
-      if
-        (l_current_writer->m_data != 00)
-      {
-        opj_free(l_current_writer->m_data );
-      }
-      ++l_current_writer;
-    }
-    return false;
-  }
-
-  /* write super box size */
-  opj_write_bytes(l_jp2h_data,l_jp2h_size,4);
-
-  /* write super box data on stream */
-  if
-    (opj_stream_write_data(cio,l_jp2h_data,8,p_manager) != 8)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Stream error while writting JP2 Header box\n");
-    l_result = false;
-  }
-
-  if
-    (l_result)
-  {
-    l_current_writer = l_writers;
-    for
-      (i=0;i<l_nb_pass;++i)
-    {
-      if
-        (opj_stream_write_data(cio,l_current_writer->m_data,l_current_writer->m_size,p_manager) != l_current_writer->m_size)
-      {
-        opj_event_msg(p_manager, EVT_ERROR, "Stream error while writting JP2 Header box\n");
-        l_result = false;
-        break;
-      }
-      ++l_current_writer;
-    }
-  }
-  l_current_writer = l_writers;
-  /* cleanup */
-  for
-    (i=0;i<l_nb_pass;++i)
-  {
-    if
-      (l_current_writer->m_data != 00)
-    {
-      opj_free(l_current_writer->m_data );
-    }
-    ++l_current_writer;
-  }
-  return l_result;
-}
-
-/**
- * Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
- *
- * @param  p_header_data  the data contained in the file header box.
- * @param  jp2        the jpeg2000 file codec.
- * @param  p_header_size  the size of the data contained in the file header box.
- * @param  p_manager    the user event manager.
- *
- * @return true if the JP2 Header box was successfully reconized.
-*/
-bool jp2_read_jp2h(
-            opj_jp2_t *jp2,
-            unsigned char * p_header_data,
-            unsigned int p_header_size,
-            opj_event_mgr_t * p_manager
-          )
-{
-  unsigned int l_box_size=0, l_current_data_size = 0;
-  opj_jp2_box_t box;
-  const opj_jp2_header_handler_t * l_current_handler;
-
-  // preconditions
-  assert(p_header_data != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  /* make sure the box is well placed */
-  if
-    ((jp2->jp2_state & JP2_STATE_FILE_TYPE) != JP2_STATE_FILE_TYPE )
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "The  box must be the first box in the file.\n");
-    return false;
-  }
-  jp2->jp2_img_state = JP2_IMG_STATE_NONE;
-
-  /* iterate while remaining data */
-  while
-    (p_header_size > 0)
-  {
-    if
-      (! jp2_read_boxhdr_char(&box,p_header_data,&l_box_size,p_header_size, p_manager))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Stream error while reading JP2 Header box\n");
-      return false;
-    }
-    if
-      (box.length > p_header_size)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Stream error while reading JP2 Header box\n");
-      return false;
-    }
-    l_current_handler = jp2_img_find_handler(box.type);
-
-    l_current_data_size = box.length - l_box_size;
-    p_header_data += l_box_size;
-
-    if
-      (l_current_handler != 00)
-    {
-      if
-        (! l_current_handler->handler(jp2,p_header_data,l_current_data_size,p_manager))
-      {
-        return false;
-      }
-    }
-    else
-    {
-      jp2->jp2_img_state |= JP2_IMG_STATE_UNKNOWN;
-    }
-    p_header_data += l_current_data_size;
-    p_header_size -= box.length;
-  }
-  jp2->jp2_state |= JP2_STATE_HEADER;
-  return true;
-}
-
-/**
- * Reads a IHDR box - Image Header box
- *
- * @param  p_image_header_data      pointer to actual data (already read from file)
- * @param  jp2              the jpeg2000 file codec.
- * @param  p_image_header_size      the size of the image header
- * @param  p_image_header_max_size    maximum size of the header, any size bigger than this value should result the function to output false.
- * @param  p_manager          the user event manager.
- *
- * @return  true if the image header is valid, fale else.
- */
-bool jp2_read_ihdr(
-              opj_jp2_t *jp2,
-              unsigned char * p_image_header_data,
-              unsigned int p_image_header_size,
-              opj_event_mgr_t * p_manager
-              )
-{
-  // preconditions
-  assert(p_image_header_data != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_image_header_size != 14)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Bad image header box (bad size)\n");
-    return false;
-  }
-  opj_read_bytes(p_image_header_data,&(jp2->h),4);      /* HEIGHT */
-  p_image_header_data += 4;
-  opj_read_bytes(p_image_header_data,&(jp2->w),4);      /* WIDTH */
-  p_image_header_data += 4;
-  opj_read_bytes(p_image_header_data,&(jp2->numcomps),2);      /* NC */
-  p_image_header_data += 2;
-
-  /* allocate memory for components */
-  jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
-  if
-    (jp2->comps == 0)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle image header (ihdr)\n");
-    return false;
-  }
-  memset(jp2->comps,0,jp2->numcomps * sizeof(opj_jp2_comps_t));
-
-  opj_read_bytes(p_image_header_data,&(jp2->bpc),1);      /* BPC */
-  ++ p_image_header_data;
-  opj_read_bytes(p_image_header_data,&(jp2->C),1);      /* C */
-  ++ p_image_header_data;
-  opj_read_bytes(p_image_header_data,&(jp2->UnkC),1);      /* UnkC */
-  ++ p_image_header_data;
-  opj_read_bytes(p_image_header_data,&(jp2->IPR),1);      /* IPR */
-  ++ p_image_header_data;
-  return true;
-}
-
-/**
- * Writes the Image Header box - Image Header box.
- *
- * @param jp2          jpeg2000 file codec.
- * @param p_nb_bytes_written  pointer to store the nb of bytes written by the function.
- *
- * @return  the data being copied.
-*/
-static unsigned char * jp2_write_ihdr(
-                opj_jp2_t *jp2,
-                unsigned int * p_nb_bytes_written
-               )
-{
-  unsigned char * l_ihdr_data,* l_current_ihdr_ptr;
-
-  // preconditions
-  assert(jp2 != 00);
-  assert(p_nb_bytes_written != 00);
-
-  /* default image header is 22 bytes wide */
-  l_ihdr_data = (unsigned char *) opj_malloc(22);
-  if
-    (l_ihdr_data == 00)
-  {
-    return 00;
-  }
-  memset(l_ihdr_data,0,22);
-
-  l_current_ihdr_ptr = l_ihdr_data;
-
-  opj_write_bytes(l_current_ihdr_ptr,22,4);        /* write box size */
-  l_current_ihdr_ptr+=4;
-  opj_write_bytes(l_current_ihdr_ptr,JP2_IHDR, 4);    /* IHDR */
-  l_current_ihdr_ptr+=4;
-  opj_write_bytes(l_current_ihdr_ptr,jp2->h, 4);    /* HEIGHT */
-  l_current_ihdr_ptr+=4;
-  opj_write_bytes(l_current_ihdr_ptr, jp2->w, 4);    /* WIDTH */
-  l_current_ihdr_ptr+=4;
-  opj_write_bytes(l_current_ihdr_ptr, jp2->numcomps, 2);    /* NC */
-  l_current_ihdr_ptr+=2;
-  opj_write_bytes(l_current_ihdr_ptr, jp2->bpc, 1);    /* BPC */
-  ++l_current_ihdr_ptr;
-  opj_write_bytes(l_current_ihdr_ptr, jp2->C, 1);    /* C : Always 7 */
-  ++l_current_ihdr_ptr;
-  opj_write_bytes(l_current_ihdr_ptr, jp2->UnkC, 1);    /* UnkC, colorspace unknown */
-  ++l_current_ihdr_ptr;
-  opj_write_bytes(l_current_ihdr_ptr, jp2->IPR, 1);    /* IPR, no intellectual property */
-  ++l_current_ihdr_ptr;
-  *p_nb_bytes_written = 22;
-  return l_ihdr_data;
-}
-
-/**
- * Writes the Bit per Component box.
- *
- * @param  jp2            jpeg2000 file codec.
- * @param  p_nb_bytes_written    pointer to store the nb of bytes written by the function.
- *
- * @return  the data being copied.
-*/
-unsigned char * jp2_write_bpcc(
-                opj_jp2_t *jp2,
-                unsigned int * p_nb_bytes_written
-               )
-{
-  unsigned int i;
-  /* room for 8 bytes for box and 1 byte for each component */
-  int l_bpcc_size = 8 + jp2->numcomps;
-  unsigned char * l_bpcc_data,* l_current_bpcc_ptr;
-
-  // preconditions
-  assert(jp2 != 00);
-  assert(p_nb_bytes_written != 00);
-
-  l_bpcc_data = (unsigned char *) opj_malloc(l_bpcc_size);
-  if
-    (l_bpcc_data == 00)
-  {
-    return 00;
-  }
-  memset(l_bpcc_data,0,l_bpcc_size);
-
-  l_current_bpcc_ptr = l_bpcc_data;
-
-  opj_write_bytes(l_current_bpcc_ptr,l_bpcc_size,4);        /* write box size */
-  l_current_bpcc_ptr += 4;
-  opj_write_bytes(l_current_bpcc_ptr,JP2_BPCC,4);          /* BPCC */
-  l_current_bpcc_ptr += 4;
-
-  for
-    (i = 0; i < jp2->numcomps; ++i)
-  {
-    opj_write_bytes(l_current_bpcc_ptr, jp2->comps[i].bpcc, 1); /* write each component information */
-    ++l_current_bpcc_ptr;
-  }
-  *p_nb_bytes_written = l_bpcc_size;
-  return l_bpcc_data;
-}
-
-/**
- * Reads a Bit per Component box.
- *
- * @param  p_bpc_header_data      pointer to actual data (already read from file)
- * @param  jp2              the jpeg2000 file codec.
- * @param  p_bpc_header_size      pointer that will hold the size of the bpc header
- * @param  p_bpc_header_max_size    maximum size of the header, any size bigger than this value should result the function to output false.
- * @param  p_manager          the user event manager.
- *
- * @return  true if the bpc header is valid, fale else.
- */
-bool jp2_read_bpcc(
-              opj_jp2_t *jp2,
-              unsigned char * p_bpc_header_data,
-              unsigned int p_bpc_header_size,
-              opj_event_mgr_t * p_manager
-              )
-{
-  unsigned int i;
-
-  // preconditions
-  assert(p_bpc_header_data != 00);
-  assert(jp2 != 00);
-  assert(p_manager != 00);
-
-  // and length is relevant
-  if
-    (p_bpc_header_size != jp2->numcomps)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Bad BPCC header box (bad size)\n");
-    return false;
-  }
-
-  // read info for each component
-  for
-    (i = 0; i < jp2->numcomps; ++i)
-  {
-    opj_read_bytes(p_bpc_header_data,&jp2->comps[i].bpcc ,1);  /* read each BPCC component */
-    ++p_bpc_header_data;
-  }
-  return true;
-}
-
-/**
- * Writes the Colour Specification box.
- *
- * @param jp2          jpeg2000 file codec.
- * @param p_nb_bytes_written  pointer to store the nb of bytes written by the function.
- *
- * @return  the data being copied.
-*/
-unsigned char *jp2_write_colr(
-                opj_jp2_t *jp2,
-                unsigned int * p_nb_bytes_written
-              )
-{
-  /* room for 8 bytes for box 3 for common data and variable upon profile*/
-  unsigned int l_colr_size = 11;
-  unsigned char * l_colr_data,* l_current_colr_ptr;
-
-  // preconditions
-  assert(jp2 != 00);
-  assert(p_nb_bytes_written != 00);
-
-  switch
-    (jp2->meth)
-  {
-    case 1 :
-      l_colr_size += 4;
-      break;
-    case 2 :
-      ++l_colr_size;
-      break;
-    default :
-      return 00;
-  }
-
-  l_colr_data = (unsigned char *) opj_malloc(l_colr_size);
-  if
-    (l_colr_data == 00)
-  {
-    return 00;
-  }
-  memset(l_colr_data,0,l_colr_size);
-  l_current_colr_ptr = l_colr_data;
-
-  opj_write_bytes(l_current_colr_ptr,l_colr_size,4);        /* write box size */
-  l_current_colr_ptr += 4;
-  opj_write_bytes(l_current_colr_ptr,JP2_COLR,4);          /* BPCC */
-  l_current_colr_ptr += 4;
-
-  opj_write_bytes(l_current_colr_ptr, jp2->meth,1);        /* METH */
-  ++l_current_colr_ptr;
-  opj_write_bytes(l_current_colr_ptr, jp2->precedence,1);      /* PRECEDENCE */
-  ++l_current_colr_ptr;
-  opj_write_bytes(l_current_colr_ptr, jp2->approx,1);        /* APPROX */
-  ++l_current_colr_ptr;
-
-  if
-    (jp2->meth == 1)
-  {
-    opj_write_bytes(l_current_colr_ptr, jp2->enumcs,4);      /* EnumCS */
-  }
-  else
-  {
-    opj_write_bytes(l_current_colr_ptr, 0, 1);            /* PROFILE (??) */
-  }
-  *p_nb_bytes_written = l_colr_size;
-  return l_colr_data;
-}
-
-/**
- * Reads the Colour Specification box.
- *
- * @param  p_colr_header_data      pointer to actual data (already read from file)
- * @param  jp2              the jpeg2000 file codec.
- * @param  p_colr_header_size      pointer that will hold the size of the color header
- * @param  p_colr_header_max_size    maximum size of the header, any size bigger than this value should result the function to output false.
- * @param  p_manager          the user event manager.
- *
- * @return  true if the bpc header is valid, fale else.
-*/
-bool jp2_read_colr(
-              opj_jp2_t * jp2,
-              unsigned char * p_colr_header_data,
-              unsigned int p_colr_header_size,
-              opj_event_mgr_t * p_manager
-              )
-{
-  // preconditions
-  assert(jp2 != 00);
-  assert(p_colr_header_data != 00);
-  assert(p_manager != 00);
-
-  if
-    (p_colr_header_size < 3)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Bad BPCC header box (bad size)\n");
-    return false;
-  }
-
-  opj_read_bytes(p_colr_header_data,&jp2->meth ,1);      /* METH */
-  ++p_colr_header_data;
-
-  opj_read_bytes(p_colr_header_data,&jp2->precedence ,1);      /* PRECEDENCE */
-  ++p_colr_header_data;
-
-  opj_read_bytes(p_colr_header_data,&jp2->approx ,1);      /* APPROX */
-  ++p_colr_header_data;
-
-
-  if
-    (jp2->meth == 1)
-  {
-    if
-      (p_colr_header_size != 7)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Bad BPCC header box (bad size)\n");
-      return false;
-    }
-    opj_read_bytes(p_colr_header_data,&jp2->enumcs ,4);      /* EnumCS */
-  }
-  /*else
-  {
-    // do not care with profiles.
-  }*/
-  return true;
-}
-
-/**
- * Writes the Jpeg2000 codestream Header box - JP2C Header box.
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  user event manager.
- *
- * @return true if writting was successful.
-*/
-bool jp2_write_jp2c(
-           opj_jp2_t *jp2,
-           opj_stream_private_t *cio,
-           opj_event_mgr_t * p_manager
-           )
-{
-  unsigned int j2k_codestream_exit;
-  unsigned char l_data_header [8];
-
-  // preconditions
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-  assert(opj_stream_has_seek(cio));
-
-  j2k_codestream_exit = opj_stream_tell(cio);
-  opj_write_bytes(l_data_header,j2k_codestream_exit - jp2->j2k_codestream_offset,4); /* size of codestream */
-  opj_write_bytes(l_data_header + 4,JP2_JP2C,4);                     /* JP2C */
-
-  if
-    (! opj_stream_seek(cio,jp2->j2k_codestream_offset,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
-    return false;
-  }
-
-  if
-    (opj_stream_write_data(cio,l_data_header,8,p_manager) != 8)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
-    return false;
-  }
-
-  if
-    (! opj_stream_seek(cio,j2k_codestream_exit,p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
-    return false;
-  }
-  return true;
-}
-
-/**
- * Destroys a jpeg2000 file decompressor.
- *
- * @param  jp2    a jpeg2000 file decompressor.
- */
-void jp2_destroy(opj_jp2_t *jp2)
-{
-  if
-    (jp2)
-  {
-    /* destroy the J2K codec */
-    j2k_destroy(jp2->j2k);
-    jp2->j2k = 00;
-    if
-      (jp2->comps)
-    {
-      opj_free(jp2->comps);
-      jp2->comps = 00;
-    }
-    if
-      (jp2->cl)
-    {
-      opj_free(jp2->cl);
-      jp2->cl = 00;
-    }
-    if
-      (jp2->m_validation_list)
-    {
-      opj_procedure_list_destroy(jp2->m_validation_list);
-      jp2->m_validation_list = 00;
-    }
-    if
-      (jp2->m_procedure_list)
-    {
-      opj_procedure_list_destroy(jp2->m_procedure_list);
-      jp2->m_procedure_list = 00;
-    }
-    opj_free(jp2);
-  }
-}
-
-
-
-
-
-/* ----------------------------------------------------------------------- */
-/* JP2 encoder interface                                             */
-/* ----------------------------------------------------------------------- */
-
-opj_jp2_t* jp2_create(bool p_is_decoder)
-{
-  opj_jp2_t *jp2 = (opj_jp2_t*)opj_malloc(sizeof(opj_jp2_t));
-  if
-    (jp2)
-  {
-    memset(jp2,0,sizeof(opj_jp2_t));
-    /* create the J2K codec */
-    if
-      (! p_is_decoder)
-    {
-      jp2->j2k = j2k_create_compress();
-    }
-    else
-    {
-      jp2->j2k = j2k_create_decompress();
-    }
-    if
-      (jp2->j2k == 00)
-    {
-      jp2_destroy(jp2);
-      return 00;
-    }
-    // validation list creation
-    jp2->m_validation_list = opj_procedure_list_create();
-    if
-      (! jp2->m_validation_list)
-    {
-      jp2_destroy(jp2);
-      return 00;
-    }
-
-    // execution list creation
-    jp2->m_procedure_list = opj_procedure_list_create();
-    if
-      (! jp2->m_procedure_list)
-    {
-      jp2_destroy(jp2);
-      return 00;
-    }
-  }
-  return jp2;
-}
-
-/**
- * Excutes the given procedures on the given codec.
- *
- * @param  p_procedure_list  the list of procedures to execute
- * @param  jp2          the jpeg2000 file codec to execute the procedures on.
- * @param  cio          the stream to execute the procedures on.
- * @param  p_manager      the user manager.
- *
- * @return  true        if all the procedures were successfully executed.
- */
-bool jp2_exec (
-          opj_jp2_t * jp2,
-          opj_procedure_list_t * p_procedure_list,
-          opj_stream_private_t *cio,
-          opj_event_mgr_t * p_manager
-          )
-{
-  bool (** l_procedure) (opj_jp2_t * jp2,opj_stream_private_t *,opj_event_mgr_t *) = 00;
-  bool l_result = true;
-  unsigned int l_nb_proc, i;
-
-  // preconditions
-  assert(p_procedure_list != 00);
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-
-  l_nb_proc = opj_procedure_list_get_nb_procedures(p_procedure_list);
-  l_procedure = (bool (**) (opj_jp2_t * jp2,opj_stream_private_t *,opj_event_mgr_t *)) opj_procedure_list_get_first_procedure(p_procedure_list);
-  for
-    (i=0;i<l_nb_proc;++i)
-  {
-    l_result = l_result && (*l_procedure) (jp2,cio,p_manager);
-    ++l_procedure;
-  }
-  // and clear the procedure list at the end.
-  opj_procedure_list_clear(p_procedure_list);
-  return l_result;
-}
-
-
-/**
- * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
- *
- * @param  jp2    the jpeg2000 file codec.
- * @param  cio    the stream object.
- *
- * @return true if the codec is valid.
- */
-bool jp2_start_compress(opj_jp2_t *jp2,  struct opj_stream_private *cio,opj_image_t * p_image, struct opj_event_mgr * p_manager)
-{
-  // preconditions
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-
-  /* customization of the validation */
-  jp2_setup_encoding_validation (jp2);
-
-  /* validation of the parameters codec */
-  if
-    (! jp2_exec(jp2,jp2->m_validation_list,cio,p_manager))
-  {
-    return false;
-  }
-
-  /* customization of the encoding */
-  jp2_setup_header_writting(jp2);
-
-  /* write header */
-  if
-    (! jp2_exec (jp2,jp2->m_procedure_list,cio,p_manager))
-  {
-    return false;
-  }
-  return j2k_start_compress(jp2->j2k,cio,p_image,p_manager);
-}
-
-/**
- * Reads a jpeg2000 file header structure.
- *
- * @param cio the stream to read data from.
- * @param jp2 the jpeg2000 file header structure.
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-bool jp2_read_header(
-                opj_jp2_t *jp2,
-                opj_image_t ** p_image,
-                OPJ_INT32 * p_tile_x0,
-                OPJ_INT32 * p_tile_y0,
-                OPJ_UINT32 * p_tile_width,
-                OPJ_UINT32 * p_tile_height,
-                OPJ_UINT32 * p_nb_tiles_x,
-                OPJ_UINT32 * p_nb_tiles_y,
-                struct opj_stream_private *cio,
-                struct opj_event_mgr * p_manager
-              )
-{
-  // preconditions
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-
-  /* customization of the validation */
-  jp2_setup_decoding_validation (jp2);
-
-  /* customization of the encoding */
-  jp2_setup_header_reading(jp2);
-
-  /* validation of the parameters codec */
-  if
-    (! jp2_exec(jp2,jp2->m_validation_list,cio,p_manager))
-  {
-    return false;
-  }
-
-  /* read header */
-  if
-    (! jp2_exec (jp2,jp2->m_procedure_list,cio,p_manager))
-  {
-    return false;
-  }
-  return j2k_read_header(
-    jp2->j2k,
-    p_image,
-    p_tile_x0,
-    p_tile_y0,
-    p_tile_width,
-    p_tile_height,
-    p_nb_tiles_x,
-    p_nb_tiles_y,
-    cio,
-    p_manager);
-}
-
-/**
- * Ends the decompression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool jp2_end_decompress(opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t * p_manager)
-{
-  // preconditions
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-
-  /* customization of the end encoding */
-  jp2_setup_end_header_reading(jp2);
-
-  /* write header */
-  if
-    (! jp2_exec (jp2,jp2->m_procedure_list,cio,p_manager))
-  {
-    return false;
-  }
-  return j2k_end_decompress(jp2->j2k, cio, p_manager);
-}
-
-
-/**
- * Ends the compression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool jp2_end_compress(opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t * p_manager)
-{
-  // preconditions
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-
-  /* customization of the end encoding */
-  jp2_setup_end_header_writting(jp2);
-
-  if
-    (! j2k_end_compress(jp2->j2k,cio,p_manager))
-  {
-    return false;
-  }
-  /* write header */
-  return jp2_exec (jp2,jp2->m_procedure_list,cio,p_manager);
-}
-
-/**
-Encode an image into a JPEG-2000 file stream
- at param jp2 JP2 compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-bool jp2_encode(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager)
-{
-  return j2k_encode(jp2->j2k,cio,p_manager);
-}
-/**
- * Writes a tile.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool jp2_write_tile (
-           opj_jp2_t *p_jp2,
-           OPJ_UINT32 p_tile_index,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           struct opj_stream_private *p_stream,
-           struct opj_event_mgr * p_manager
-          )
-{
-  return j2k_write_tile (p_jp2->j2k,p_tile_index,p_data,p_data_size,p_stream,p_manager);
-}
-
-/**
- * Decode tile data.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool jp2_decode_tile (
-          opj_jp2_t * p_jp2,
-          OPJ_UINT32 p_tile_index,
-          OPJ_BYTE * p_data,
-          OPJ_UINT32 p_data_size,
-          opj_stream_private_t *p_stream,
-          opj_event_mgr_t * p_manager
-          )
-{
-  return j2k_decode_tile (p_jp2->j2k,p_tile_index,p_data,p_data_size,p_stream,p_manager);
-}
-/**
- * Reads a tile header.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool jp2_read_tile_header (
-           opj_jp2_t * p_jp2,
-           OPJ_UINT32 * p_tile_index,
-           OPJ_UINT32 * p_data_size,
-           OPJ_INT32 * p_tile_x0,
-           OPJ_INT32 * p_tile_y0,
-           OPJ_INT32 * p_tile_x1,
-           OPJ_INT32 * p_tile_y1,
-           OPJ_UINT32 * p_nb_comps,
-           bool * p_go_on,
-           opj_stream_private_t *p_stream,
-           opj_event_mgr_t * p_manager
-          )
-{
-  return j2k_read_tile_header (p_jp2->j2k,
-                p_tile_index,
-                p_data_size,
-                p_tile_x0,
-                p_tile_y0,
-                p_tile_x1,
-                p_tile_y1,
-                p_nb_comps,
-                p_go_on,
-                p_stream,
-                p_manager);
-}
-
-/**
- * Sets up the procedures to do on writting header after the codestream.
- * Developpers wanting to extend the library can add their own writting procedures.
- */
-void jp2_setup_end_header_writting (opj_jp2_t *jp2)
-{
-  // preconditions
-  assert(jp2 != 00);
-
-  opj_procedure_list_add_procedure(jp2->m_procedure_list,(void*)jp2_write_jp2c );
-  /* DEVELOPER CORNER, add your custom procedures */
-}
-
-/**
- * Sets up the procedures to do on reading header.
- * Developpers wanting to extend the library can add their own writting procedures.
- */
-void jp2_setup_header_reading (opj_jp2_t *jp2)
-{
-  // preconditions
-  assert(jp2 != 00);
-
-  opj_procedure_list_add_procedure(jp2->m_procedure_list,(void*)jp2_read_header_procedure );
-  /* DEVELOPER CORNER, add your custom procedures */
-}
-
-/**
- * Sets up the procedures to do on reading header after the codestream.
- * Developpers wanting to extend the library can add their own writting procedures.
- */
-void jp2_setup_end_header_reading (opj_jp2_t *jp2)
-{
-  // preconditions
-  assert(jp2 != 00);
-  opj_procedure_list_add_procedure(jp2->m_procedure_list,(void*)jp2_read_header_procedure );
-  /* DEVELOPER CORNER, add your custom procedures */
-}
-
-
-/**
- * The default validation procedure without any extension.
- *
- * @param  jp2        the jpeg2000 codec to validate.
- * @param  cio        the input stream to validate.
- * @param  p_manager    the user event manager.
- *
- * @return true if the parameters are correct.
- */
-bool jp2_default_validation (
-                opj_jp2_t * jp2,
-                opj_stream_private_t *cio,
-                opj_event_mgr_t * p_manager
-              )
-{
-  bool l_is_valid = true;
-  unsigned int i;
-
-  // preconditions
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-  /* JPEG2000 codec validation */
-  /*TODO*/
-
-  /* STATE checking */
-  /* make sure the state is at 0 */
-  l_is_valid &= (jp2->jp2_state == JP2_STATE_NONE);
-  /* make sure not reading a jp2h ???? WEIRD */
-  l_is_valid &= (jp2->jp2_img_state == JP2_IMG_STATE_NONE);
-
-  /* POINTER validation */
-  /* make sure a j2k codec is present */
-  l_is_valid &= (jp2->j2k != 00);
-  /* make sure a procedure list is present */
-  l_is_valid &= (jp2->m_procedure_list != 00);
-  /* make sure a validation list is present */
-  l_is_valid &= (jp2->m_validation_list != 00);
-
-  /* PARAMETER VALIDATION */
-  /* number of components */
-  l_is_valid &= (jp2->numcl > 0);
-  /* width */
-  l_is_valid &= (jp2->h > 0);
-  /* height */
-  l_is_valid &= (jp2->w > 0);
-  /* precision */
-  for
-    (i = 0; i < jp2->numcomps; ++i)
-  {
-    l_is_valid &= (jp2->comps[i].bpcc > 0);
-  }
-  /* METH */
-  l_is_valid &= ((jp2->meth > 0) && (jp2->meth < 3));
-
-
-
-  /* stream validation */
-  /* back and forth is needed */
-  l_is_valid &= opj_stream_has_seek(cio);
-
-  return l_is_valid;
-
-}
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-void jp2_setup_encoding_validation (opj_jp2_t *jp2)
-{
-  // preconditions
-  assert(jp2 != 00);
-  opj_procedure_list_add_procedure(jp2->m_validation_list, (void*)jp2_default_validation);
-  /* DEVELOPER CORNER, add your custom validation procedure */
-}
-
-/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
- */
-void jp2_setup_decoding_validation (opj_jp2_t *jp2)
-{
-  // preconditions
-  assert(jp2 != 00);
-  /* DEVELOPER CORNER, add your custom validation procedure */
-}
-
-/**
- * Sets up the procedures to do on writting header. Developpers wanting to extend the library can add their own writting procedures.
- */
-void jp2_setup_header_writting (opj_jp2_t *jp2)
-{
-  // preconditions
-  assert(jp2 != 00);
-  opj_procedure_list_add_procedure(jp2->m_procedure_list,(void*)jp2_write_jp );
-  opj_procedure_list_add_procedure(jp2->m_procedure_list,(void*)jp2_write_ftyp );
-  opj_procedure_list_add_procedure(jp2->m_procedure_list,(void*)jp2_write_jp2h );
-  opj_procedure_list_add_procedure(jp2->m_procedure_list,(void*)jp2_skip_jp2c );
-
-  /* DEVELOPER CORNER, insert your custom procedures */
-
-}
-
-
-/**
- * Skips the Jpeg2000 Codestream Header box - JP2C Header box.
- *
- * @param  cio      the stream to write data to.
- * @param  jp2      the jpeg2000 file codec.
- * @param  p_manager  user event manager.
- *
- * @return true if writting was successful.
-*/
-bool jp2_skip_jp2c(
-            opj_jp2_t *jp2,
-            struct opj_stream_private *cio,
-            struct opj_event_mgr * p_manager
-          )
-{
-  // preconditions
-  assert(jp2 != 00);
-  assert(cio != 00);
-  assert(p_manager != 00);
-
-  jp2->j2k_codestream_offset = opj_stream_tell(cio);
-  if
-    (opj_stream_skip(cio,8,p_manager) != 8)
-  {
-    return false;
-  }
-  return true;
-}
-
-struct opj_image * jp2_decode(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager)
-{
-  /* J2K decoding */
-  struct opj_image * image = j2k_decode(jp2->j2k, cio, p_manager);
-  if
-    (!image)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Failed to decode J2K image\n");
-    return false;
-  }
-
-  /* Set Image Color Space */
-  if (jp2->enumcs == 16)
-    image->color_space = CLRSPC_SRGB;
-  else if (jp2->enumcs == 17)
-    image->color_space = CLRSPC_GRAY;
-  else if (jp2->enumcs == 18)
-    image->color_space = CLRSPC_SYCC;
-  else
-    image->color_space = CLRSPC_UNKNOWN;
-  return image;
-}
-
-void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_t *image,opj_event_mgr_t * p_manager)
-{
-  unsigned int i;
-  int depth_0, sign;
-
-  if(!jp2 || !parameters || !image)
-    return;
-
-  /* setup the J2K codec */
-  /* ------------------- */
-
-  /* Check if number of components respects standard */
-  if (image->numcomps < 1 || image->numcomps > 16384) {
-    opj_event_msg(p_manager, EVT_ERROR, "Invalid number of components specified while setting up JP2 encoder\n");
-    return;
-  }
-
-  j2k_setup_encoder(jp2->j2k, parameters, image,p_manager);
-
-  /* setup the JP2 codec */
-  /* ------------------- */
-
-  /* Profile box */
-
-  jp2->brand = JP2_JP2;  /* BR */
-  jp2->minversion = 0;  /* MinV */
-  jp2->numcl = 1;
-  jp2->cl = (unsigned int*) opj_malloc(jp2->numcl * sizeof(unsigned int));
-  jp2->cl[0] = JP2_JP2;  /* CL0 : JP2 */
-
-  /* Image Header box */
-
-  jp2->numcomps = image->numcomps;  /* NC */
-  jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
-  jp2->h = image->y1 - image->y0;    /* HEIGHT */
-  jp2->w = image->x1 - image->x0;    /* WIDTH */
-  /* BPC */
-  depth_0 = image->comps[0].prec - 1;
-  sign = image->comps[0].sgnd;
-  jp2->bpc = depth_0 + (sign << 7);
-  for (i = 1; i < image->numcomps; i++) {
-    int depth = image->comps[i].prec - 1;
-    sign = image->comps[i].sgnd;
-    if (depth_0 != depth)
-      jp2->bpc = 255;
-  }
-  jp2->C = 7;      /* C : Always 7 */
-  jp2->UnkC = 0;    /* UnkC, colorspace specified in colr box */
-  jp2->IPR = 0;    /* IPR, no intellectual property */
-
-  /* BitsPerComponent box */
-
-  for (i = 0; i < image->numcomps; i++) {
-    jp2->comps[i].bpcc = image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
-  }
-
-  /* Colour Specification box */
-
-  if ((image->numcomps == 1 || image->numcomps == 3) && (jp2->bpc != 255)) {
-    jp2->meth = 1;  /* METH: Enumerated colourspace */
-  } else {
-    jp2->meth = 2;  /* METH: Restricted ICC profile */
-  }
-  if (jp2->meth == 1) {
-    if (image->color_space == 1)
-      jp2->enumcs = 16;  /* sRGB as defined by IEC 61966�2�1 */
-    else if (image->color_space == 2)
-      jp2->enumcs = 17;  /* greyscale */
-    else if (image->color_space == 3)
-      jp2->enumcs = 18;  /* YUV */
-  } else {
-    jp2->enumcs = 0;    /* PROFILE (??) */
-  }
-  jp2->precedence = 0;  /* PRECEDENCE */
-  jp2->approx = 0;    /* APPROX */
-
-}
-
-void jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
-{
-  if(!jp2 || !parameters)
-    return;
-
-  /* setup the J2K codec */
-  /* ------------------- */
-  j2k_setup_decoder(jp2->j2k, parameters);
-}
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param  p_jp2      the jpeg2000 codec.
- * @param  p_end_x      the right position of the rectangle to decode (in image coordinates).
- * @param  p_start_y    the up position of the rectangle to decode (in image coordinates).
- * @param  p_end_y      the bottom position of the rectangle to decode (in image coordinates).
- * @param  p_manager    the user event manager
- *
- * @return  true      if the area could be set.
- */
-bool jp2_set_decode_area(
-      opj_jp2_t *p_jp2,
-      OPJ_INT32 p_start_x,
-      OPJ_INT32 p_start_y,
-      OPJ_INT32 p_end_x,
-      OPJ_INT32 p_end_y,
-      struct opj_event_mgr * p_manager
-      )
-{
-  return j2k_set_decode_area(p_jp2->j2k,p_start_x,p_start_y,p_end_x,p_end_y,p_manager);
-}
-
-#if 0
-
-
-
-
-
-static void jp2_write_url(opj_cio_t *cio, char *Idx_file) {
-  unsigned int i;
-  opj_jp2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio, 4);
-  cio_write(cio, JP2_URL, 4);  /* DBTL */
-  cio_write(cio, 0, 1);    /* VERS */
-  cio_write(cio, 0, 3);    /* FLAG */
-
-  if(Idx_file) {
-    for (i = 0; i < strlen(Idx_file); i++) {
-      cio_write(cio, Idx_file[i], 1);
-    }
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L */
-  cio_seek(cio, box.init_pos + box.length);
-}
-#endif
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.h
deleted file mode 100644
index eee3c65..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jp2.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __JP2_H
-#define __JP2_H
-/**
- at file jp2.h
- at brief The JPEG-2000 file format Reader/Writer (JP2)
-
-*/
-#include "openjpeg.h"
-
-
-
-
-/**********************************************************************************
- ********************************* FORWARD DECLARATIONS ***************************
- **********************************************************************************/
-struct opj_j2k;
-struct opj_procedure_list;
-struct opj_event_mgr;
-struct opj_stream_private;
-struct opj_dparameters;
-struct opj_cparameters;
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-#define JPIP_JPIP 0x6a706970
-
-#define JP2_JP   0x6a502020    /**< JPEG 2000 signature box */
-#define JP2_FTYP 0x66747970    /**< File type box */
-#define JP2_JP2H 0x6a703268    /**< JP2 header box */
-#define JP2_IHDR 0x69686472    /**< Image header box */
-#define JP2_COLR 0x636f6c72    /**< Colour specification box */
-#define JP2_JP2C 0x6a703263    /**< Contiguous codestream box */
-#define JP2_URL  0x75726c20    /**< URL box */
-#define JP2_DBTL 0x6474626c    /**< ??? */
-#define JP2_BPCC 0x62706363    /**< Bits per component box */
-#define JP2_JP2  0x6a703220    /**< File type fields */
-
-/* ----------------------------------------------------------------------- */
-
-
-typedef enum
-{
-  JP2_STATE_NONE      = 0x0,
-  JP2_STATE_SIGNATURE    = 0x1,
-  JP2_STATE_FILE_TYPE    = 0x2,
-  JP2_STATE_HEADER    = 0x4,
-  JP2_STATE_CODESTREAM  = 0x8,
-  JP2_STATE_END_CODESTREAM  = 0x10,
-  JP2_STATE_UNKNOWN    = 0x80000000
-}
-JP2_STATE;
-
-typedef enum
-{
-  JP2_IMG_STATE_NONE      = 0x0,
-  JP2_IMG_STATE_UNKNOWN    = 0x80000000
-}
-JP2_IMG_STATE;
-
-/**
-JP2 component
-*/
-typedef struct opj_jp2_comps
-{
-  unsigned int depth;
-  int sgnd;
-  unsigned int bpcc;
-}
-opj_jp2_comps_t;
-
-/**
-JPEG-2000 file format reader/writer
-*/
-typedef struct opj_jp2
-{
-  /** handle to the J2K codec  */
-  struct opj_j2k *j2k;
-  /** list of validation procedures */
-  struct opj_procedure_list * m_validation_list;
-  /** list of execution procedures */
-  struct opj_procedure_list * m_procedure_list;
-
-  /* width of image */
-  unsigned int w;
-  /* height of image */
-  unsigned int h;
-  /* number of components in the image */
-  unsigned int numcomps;
-  unsigned int bpc;
-  unsigned int C;
-  unsigned int UnkC;
-  unsigned int IPR;
-  unsigned int meth;
-  unsigned int approx;
-  unsigned int enumcs;
-  unsigned int precedence;
-  unsigned int brand;
-  unsigned int minversion;
-  unsigned int numcl;
-  unsigned int *cl;
-  opj_jp2_comps_t *comps;
-  unsigned int j2k_codestream_offset;
-  unsigned int jp2_state;
-  unsigned int jp2_img_state;
-
-}
-opj_jp2_t;
-
-/**
-JP2 Box
-*/
-typedef struct opj_jp2_box
-{
-  unsigned int length;
-  unsigned int type;
-}
-opj_jp2_box_t;
-
-typedef struct opj_jp2_header_handler
-{
-  /* marker value */
-  int id;
-  /* action linked to the marker */
-  bool (*handler) (opj_jp2_t *jp2,unsigned char * p_header_data, unsigned int p_header_size,struct opj_event_mgr * p_manager);
-}
-opj_jp2_header_handler_t;
-
-
-typedef struct opj_jp2_img_header_writer_handler
-{
-  /* action to perform */
-  unsigned char* (*handler) (opj_jp2_t *jp2,  unsigned int * p_data_size);
-  /* result of the action : data */
-  unsigned char *      m_data;
-  /* size of data */
-  unsigned int        m_size;
-}
-opj_jp2_img_header_writer_handler_t;
-
-
-
-
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
- * Creates a jpeg2000 file decompressor.
- *
- * @return  an empty jpeg2000 file codec.
- */
-opj_jp2_t* jp2_create (bool p_is_decoder);
-
-/**
-Destroy a JP2 decompressor handle
- at param jp2 JP2 decompressor handle to destroy
-*/
-void jp2_destroy(opj_jp2_t *jp2);
-
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in jp2->j2k->cp.
- at param jp2 JP2 decompressor handle
- at param parameters decompression parameters
-*/
-void jp2_setup_decoder(opj_jp2_t *jp2, struct opj_dparameters *parameters);
-
-/**
- * Decode an image from a JPEG-2000 file stream
- * @param jp2 JP2 decompressor handle
- * @param cio Input buffer stream
- * @param cstr_info Codestream information structure if required, NULL otherwise
- * @return Returns a decoded image if successful, returns NULL otherwise
-*/
-struct opj_image* jp2_decode(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
-/**
-Setup the encoder parameters using the current image and using user parameters.
-Coding parameters are returned in jp2->j2k->cp.
- at param jp2 JP2 compressor handle
- at param parameters compression parameters
- at param image input filled image
-*/
-void jp2_setup_encoder(opj_jp2_t *jp2, struct opj_cparameters *parameters, struct opj_image *image,struct opj_event_mgr * p_manager);
-
-/**
- * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
- *
- * @param  jp2    the jpeg2000 file codec.
- * @param  cio    the stream object.
- *
- * @return true if the codec is valid.
- */
-bool jp2_start_compress(opj_jp2_t *jp2,  struct opj_stream_private *cio,struct opj_image * p_image,struct opj_event_mgr * p_manager);
-
-/**
- * Ends the compression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool jp2_end_compress(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
-
-/**
-Encode an image into a JPEG-2000 file stream
- at param jp2 JP2 compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param cstr_info Codestream information structure if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-bool jp2_encode(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
-
-/**
- * Reads a jpeg2000 file header structure.
- *
- * @param cio the stream to read data from.
- * @param jp2 the jpeg2000 file header structure.
- * @param p_manager the user event manager.
- *
- * @return true if the box is valid.
- */
-bool jp2_read_header(
-                opj_jp2_t *jp2,
-                struct opj_image ** p_image,
-                OPJ_INT32 * p_tile_x0,
-                OPJ_INT32 * p_tile_y0,
-                OPJ_UINT32 * p_tile_width,
-                OPJ_UINT32 * p_tile_height,
-                OPJ_UINT32 * p_nb_tiles_x,
-                OPJ_UINT32 * p_nb_tiles_y,
-                struct opj_stream_private *cio,
-                struct opj_event_mgr * p_manager
-              );
-/**
- * Ends the decompression procedures and possibiliy add data to be read after the
- * codestream.
- */
-bool jp2_end_decompress(opj_jp2_t *jp2, struct opj_stream_private *cio, struct opj_event_mgr * p_manager);
-
-/**
- * Writes a tile.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool jp2_write_tile (
-           opj_jp2_t *p_jp2,
-           OPJ_UINT32 p_tile_index,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           struct opj_stream_private *p_stream,
-           struct opj_event_mgr * p_manager
-          );
-/**
- * Decode tile data.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool jp2_decode_tile (
-          opj_jp2_t * p_jp2,
-          OPJ_UINT32 p_tile_index,
-          OPJ_BYTE * p_data,
-          OPJ_UINT32 p_data_size,
-          struct opj_stream_private *p_stream,
-          struct opj_event_mgr * p_manager
-          );
-/**
- * Reads a tile header.
- * @param  p_j2k    the jpeg2000 codec.
- * @param  p_stream      the stream to write data to.
- * @param  p_manager  the user event manager.
- */
-bool jp2_read_tile_header (
-           opj_jp2_t * p_j2k,
-           OPJ_UINT32 * p_tile_index,
-           OPJ_UINT32 * p_data_size,
-           OPJ_INT32 * p_tile_x0,
-           OPJ_INT32 * p_tile_y0,
-           OPJ_INT32 * p_tile_x1,
-           OPJ_INT32 * p_tile_y1,
-           OPJ_UINT32 * p_nb_comps,
-           bool * p_go_on,
-           struct opj_stream_private *p_stream,
-           struct opj_event_mgr * p_manager
-          );
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param  p_jp2      the jpeg2000 codec.
- * @param  p_end_x      the right position of the rectangle to decode (in image coordinates).
- * @param  p_start_y    the up position of the rectangle to decode (in image coordinates).
- * @param  p_end_y      the bottom position of the rectangle to decode (in image coordinates).
- * @param  p_manager    the user event manager
- *
- * @return  true      if the area could be set.
- */
-bool jp2_set_decode_area(
-      opj_jp2_t *p_jp2,
-      OPJ_INT32 p_start_x,
-      OPJ_INT32 p_start_y,
-      OPJ_INT32 p_end_x,
-      OPJ_INT32 p_end_y,
-      struct opj_event_mgr * p_manager
-      );
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __JP2_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.c
deleted file mode 100644
index 0cfe44f..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "jpt.h"
-#include "openjpeg.h"
-#include "cio.h"
-#include "event.h"
-/*
- * Read the information contains in VBAS [JPP/JPT stream message header]
- * Store information (7 bits) in value
- * @param p_cio the stream to read from.
- * @param p_value the data to update
- * @return the nb of bytes read or -1 if an io error occurred.
- */
-bool jpt_read_VBAS_info(opj_stream_private_t * p_cio, OPJ_UINT32 * p_nb_bytes_read, OPJ_UINT32 * p_value, opj_event_mgr_t * p_manager)
-{
-  OPJ_BYTE l_elmt;
-  OPJ_UINT32 l_nb_bytes_read = 0;
-
-  // read data till the MSB of the current byte is 1.
-  // concatenate 7 bits of data, last bit is finish flag
-
-  // read data from the stream
-
-  if
-    (opj_stream_read_data(p_cio,&l_elmt,1,p_manager) != 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data.\n");
-    return false;
-  }
-  ++l_nb_bytes_read;
-
-  // is the MSB equal to 1 ?
-  while
-    (l_elmt & 0x80)
-  {
-    // concatenate 7 bits of data, last bit is finish flag
-    *p_value = (*p_value  << 7) | (l_elmt & 0x7f);
-    if
-      (opj_stream_read_data(p_cio,&l_elmt,1,p_manager) != 1)
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data.\n");
-      return false;
-    }
-    ++l_nb_bytes_read;
-  }
-  // concatenate 7 bits of data, last bit is finish flag
-  *p_value = (*p_value  << 7) | (l_elmt & 0x7f);
-  * p_nb_bytes_read = l_nb_bytes_read;
-  return true;
-}
-
-/*
- * Initialize the value of the message header structure
- *
- */
-void jpt_init_msg_header(opj_jpt_msg_header_t * header)
-{
-  header->Id = 0;    /* In-class Identifier    */
-  header->last_byte = 0;  /* Last byte information  */
-  header->Class_Id = 0;    /* Class Identifier       */
-  header->CSn_Id = 0;    /* CSn : index identifier */
-  header->Msg_offset = 0;  /* Message offset         */
-  header->Msg_length = 0;  /* Message length         */
-  header->Layer_nb = 0;    /* Auxiliary for JPP case */
-}
-
-/*
- * Re-initialize the value of the message header structure
- *
- * Only parameters always present in message header
- *
- */
-void jpt_reinit_msg_header(opj_jpt_msg_header_t * header)
-{
-  header->Id = 0;    /* In-class Identifier    */
-  header->last_byte = 0;  /* Last byte information  */
-  header->Msg_offset = 0;  /* Message offset         */
-  header->Msg_length = 0;  /* Message length         */
-}
-
-/*
- * Read the message header for a JPP/JPT - stream
- *
- */
-bool jpt_read_msg_header(opj_stream_private_t *cio, opj_jpt_msg_header_t *header, OPJ_UINT32 * p_nb_bytes_read, opj_event_mgr_t * p_manager)
-{
-  OPJ_BYTE elmt, Class = 0, CSn = 0;
-  OPJ_UINT32 l_nb_bytes_read = 0;
-  OPJ_UINT32 l_last_nb_bytes_read;
-
-
-  jpt_reinit_msg_header(header);
-
-  /* ------------- */
-  /* VBAS : Bin-ID */
-  /* ------------- */
-  if
-    (opj_stream_read_data(cio,&elmt,1,p_manager) != 1)
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Forbidden value encounter in message header !!\n");
-    return false;
-  }
-  ++l_nb_bytes_read;
-
-  /* See for Class and CSn */
-  switch ((elmt >> 5) & 0x03)
-  {
-    case 0:
-      opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
-      break;
-    case 1:
-      Class = 0;
-      CSn = 0;
-      break;
-    case 2:
-      Class = 1;
-      CSn = 0;
-      break;
-    case 3:
-      Class = 1;
-      CSn = 1;
-      break;
-    default:
-      break;
-  }
-
-  /* see information on bits 'c' [p 10 : A.2.1 general, ISO/IEC FCD 15444-9] */
-  if
-    (((elmt >> 4) & 0x01) == 1)
-  {
-    header->last_byte = 1;
-  }
-
-  /* In-class identifier */
-  header->Id |= (elmt & 0x0f);
-  if
-    ((elmt >> 7) == 1)
-  {
-    l_last_nb_bytes_read = 0;
-    if
-      (! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Id), p_manager))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
-      return false;
-    }
-    l_nb_bytes_read += l_last_nb_bytes_read;
-  }
-
-  /* ------------ */
-  /* VBAS : Class */
-  /* ------------ */
-  if (Class == 1)
-  {
-    header->Class_Id = 0;
-    l_last_nb_bytes_read = 0;
-    if
-      (! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Class_Id), p_manager))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
-      return false;
-    }
-    l_nb_bytes_read += l_last_nb_bytes_read;
-  }
-
-  /* ---------- */
-  /* VBAS : CSn */
-  /* ---------- */
-  if (CSn == 1)
-  {
-    header->CSn_Id = 0;
-    l_last_nb_bytes_read = 0;
-    if
-      (! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->CSn_Id), p_manager))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
-      return false;
-    }
-    l_nb_bytes_read += l_last_nb_bytes_read;
-  }
-
-  /* ----------------- */
-  /* VBAS : Msg_offset */
-  /* ----------------- */
-  l_last_nb_bytes_read = 0;
-  if
-    (! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Msg_offset), p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
-    return false;
-  }
-  l_nb_bytes_read += l_last_nb_bytes_read;
-
-  /* ----------------- */
-  /* VBAS : Msg_length */
-  /* ----------------- */
-  l_last_nb_bytes_read = 0;
-  if
-    (! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Msg_length), p_manager))
-  {
-    opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
-    return false;
-  }
-  l_nb_bytes_read += l_last_nb_bytes_read;
-
-  /* ---------- */
-  /* VBAS : Aux */
-  /* ---------- */
-  if ((header->Class_Id & 0x01) == 1)
-  {
-    header->Layer_nb = 0;
-    if
-      (! jpt_read_VBAS_info(cio, &l_last_nb_bytes_read, &(header->Layer_nb), p_manager))
-    {
-      opj_event_msg(p_manager, EVT_ERROR, "Error trying to read a byte of data!!!\n");
-      return false;
-    }
-    l_nb_bytes_read += l_last_nb_bytes_read;
-  }
-  * p_nb_bytes_read = l_nb_bytes_read;
-  return true;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.h
deleted file mode 100644
index 7c67cff..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/jpt.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __JPT_H
-#define __JPT_H
-/**
- at file jpt.h
- at brief JPT-stream reader (JPEG 2000, JPIP)
-
-JPT-stream functions are implemented in J2K.C.
-*/
-#include "openjpeg.h"
-struct opj_stream_private;
-struct opj_event_mgr;
-/**
-Message Header JPT stream structure
-*/
-typedef struct opj_jpt_msg_header
-{
-  /** In-class Identifier */
-  OPJ_UINT32 Id;
-  /** Last byte information */
-  OPJ_UINT32 last_byte;
-  /** Class Identifier */
-  OPJ_UINT32 Class_Id;
-  /** CSn : index identifier */
-  OPJ_UINT32 CSn_Id;
-  /** Message offset */
-  OPJ_UINT32 Msg_offset;
-  /** Message length */
-  OPJ_UINT32 Msg_length;
-  /** Auxiliary for JPP case */
-  OPJ_UINT32 Layer_nb;
-} opj_jpt_msg_header_t;
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Initialize the value of the message header structure
- at param header Message header structure
-*/
-void jpt_init_msg_header(opj_jpt_msg_header_t * header);
-
-/**
- * Read the message header for a JPP/JPT - stream
- * @param  p_cio    stream handle
- * @param  header    JPT Message header structure
- * @param  p_manager  user event manager to display nice messages.
-*/
-bool jpt_read_msg_header(
-    struct opj_stream_private * p_cio,
-    opj_jpt_msg_header_t * p_header,
-    OPJ_UINT32 * p_nb_bytes_read,
-    struct opj_event_mgr * p_manager);
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.c
deleted file mode 100644
index 5eadc21..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mct.h"
-#include "fix.h"
-#include "opj_malloc.h"
-
-/* <summary> */
-/* This table contains the norms of the basis function of the reversible MCT. */
-/* </summary> */
-static const OPJ_FLOAT64 mct_norms[3] = { 1.732, .8292, .8292 };
-
-/* <summary> */
-/* This table contains the norms of the basis function of the irreversible MCT. */
-/* </summary> */
-static const OPJ_FLOAT64 mct_norms_real[3] = { 1.732, 1.805, 1.573 };
-
-
-
-const OPJ_FLOAT64 * get_mct_norms ()
-{
-  return mct_norms;
-}
-
-const OPJ_FLOAT64 * get_mct_norms_real ()
-{
-  return mct_norms_real;
-}
-
-
-
-/* <summary> */
-/* Foward reversible MCT. */
-/* </summary> */
-void mct_encode(
-    OPJ_INT32* restrict c0,
-    OPJ_INT32* restrict c1,
-    OPJ_INT32* restrict c2,
-    OPJ_UINT32 n)
-{
-  OPJ_UINT32 i;
-  for(i = 0; i < n; ++i) {
-    OPJ_INT32 r = c0[i];
-    OPJ_INT32 g = c1[i];
-    OPJ_INT32 b = c2[i];
-    OPJ_INT32 y = (r + (g * 2) + b) >> 2;
-    OPJ_INT32 u = b - g;
-    OPJ_INT32 v = r - g;
-    c0[i] = y;
-    c1[i] = u;
-    c2[i] = v;
-  }
-}
-
-/* <summary> */
-/* Inverse reversible MCT. */
-/* </summary> */
-void mct_decode(
-    OPJ_INT32* restrict c0,
-    OPJ_INT32* restrict c1,
-    OPJ_INT32* restrict c2,
-    OPJ_UINT32 n)
-{
-  OPJ_UINT32 i;
-  for (i = 0; i < n; ++i) {
-    OPJ_INT32 y = c0[i];
-    OPJ_INT32 u = c1[i];
-    OPJ_INT32 v = c2[i];
-    OPJ_INT32 g = y - ((u + v) >> 2);
-    OPJ_INT32 r = v + g;
-    OPJ_INT32 b = u + g;
-    c0[i] = r;
-    c1[i] = g;
-    c2[i] = b;
-  }
-}
-
-/* <summary> */
-/* Get norm of basis function of reversible MCT. */
-/* </summary> */
-OPJ_FLOAT64 mct_getnorm(OPJ_UINT32 compno) {
-  return mct_norms[compno];
-}
-
-/* <summary> */
-/* Foward irreversible MCT. */
-/* </summary> */
-void mct_encode_real(
-    OPJ_INT32* restrict c0,
-    OPJ_INT32* restrict c1,
-    OPJ_INT32* restrict c2,
-    OPJ_UINT32 n)
-{
-  OPJ_UINT32 i;
-  for(i = 0; i < n; ++i) {
-    OPJ_INT32 r = c0[i];
-    OPJ_INT32 g = c1[i];
-    OPJ_INT32 b = c2[i];
-    OPJ_INT32 y =  fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
-    OPJ_INT32 u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
-    OPJ_INT32 v =  fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
-    c0[i] = y;
-    c1[i] = u;
-    c2[i] = v;
-  }
-}
-
-/* <summary> */
-/* Inverse irreversible MCT. */
-/* </summary> */
-void mct_decode_real(
-    OPJ_FLOAT32* restrict c0,
-    OPJ_FLOAT32* restrict c1,
-    OPJ_FLOAT32* restrict c2,
-    OPJ_UINT32 n)
-{
-  OPJ_UINT32 i;
-  for(i = 0; i < n; ++i) {
-    OPJ_FLOAT32 y = c0[i];
-    OPJ_FLOAT32 u = c1[i];
-    OPJ_FLOAT32 v = c2[i];
-    OPJ_FLOAT32 r = y + (v * 1.402f);
-    OPJ_FLOAT32 g = y - (u * 0.34413f) - (v * (0.71414f));
-    OPJ_FLOAT32 b = y + (u * 1.772f);
-    c0[i] = r;
-    c1[i] = g;
-    c2[i] = b;
-  }
-}
-
-/* <summary> */
-/* Get norm of basis function of irreversible MCT. */
-/* </summary> */
-OPJ_FLOAT64 mct_getnorm_real(OPJ_UINT32 compno) {
-  return mct_norms_real[compno];
-}
-
-bool mct_encode_custom(
-             // MCT data
-             OPJ_BYTE * pCodingdata,
-             // size of components
-             OPJ_UINT32 n,
-             // components
-             OPJ_BYTE ** pData,
-             // nb of components (i.e. size of pData)
-             OPJ_UINT32 pNbComp,
-             // tells if the data is signed
-             OPJ_UINT32 isSigned)
-{
-  OPJ_FLOAT32 * lMct = (OPJ_FLOAT32 *) pCodingdata;
-  OPJ_UINT32 i;
-  OPJ_UINT32 j;
-  OPJ_UINT32 k;
-  OPJ_UINT32 lNbMatCoeff = pNbComp * pNbComp;
-  OPJ_INT32 * lCurrentData = 00;
-  OPJ_INT32 * lCurrentMatrix = 00;
-  OPJ_INT32 ** lData = (OPJ_INT32 **) pData;
-  OPJ_UINT32 lMultiplicator = 1 << 13;
-  OPJ_INT32 * lMctPtr;
-
-  lCurrentData = (OPJ_INT32 *) opj_malloc((pNbComp + lNbMatCoeff) * sizeof(OPJ_INT32));
-  if
-    (! lCurrentData)
-  {
-    return false;
-  }
-  lCurrentMatrix = lCurrentData + pNbComp;
-  for
-    (i =0;i<lNbMatCoeff;++i)
-  {
-    lCurrentMatrix[i] = (OPJ_INT32) (*(lMct++) * lMultiplicator);
-  }
-  for
-    (i = 0; i < n; ++i)
-  {
-    lMctPtr = lCurrentMatrix;
-    for
-      (j=0;j<pNbComp;++j)
-    {
-      lCurrentData[j] = (*(lData[j]));
-    }
-    for
-      (j=0;j<pNbComp;++j)
-    {
-      *(lData[j]) = 0;
-      for
-        (k=0;k<pNbComp;++k)
-      {
-        *(lData[j]) += fix_mul(*lMctPtr, lCurrentData[k]);
-        ++lMctPtr;
-      }
-      ++lData[j];
-    }
-  }
-  opj_free(lCurrentData);
-  return true;
-}
-
-bool mct_decode_custom(
-             // MCT data
-             OPJ_BYTE * pDecodingData,
-             // size of components
-             OPJ_UINT32 n,
-             // components
-             OPJ_BYTE ** pData,
-             // nb of components (i.e. size of pData)
-             OPJ_UINT32 pNbComp,
-             // tells if the data is signed
-             OPJ_UINT32 isSigned)
-{
-  OPJ_FLOAT32 * lMct;
-  OPJ_UINT32 i;
-  OPJ_UINT32 j;
-  OPJ_UINT32 k;
-
-  OPJ_FLOAT32 * lCurrentData = 00;
-  OPJ_FLOAT32 * lCurrentResult = 00;
-  OPJ_FLOAT32 ** lData = (OPJ_FLOAT32 **) pData;
-
-  lCurrentData = (OPJ_FLOAT32 *) opj_malloc (2 * pNbComp * sizeof(OPJ_FLOAT32));
-  if
-    (! lCurrentData)
-  {
-    return false;
-  }
-  lCurrentResult = lCurrentData + pNbComp;
-
-  for
-    (i = 0; i < n; ++i)
-  {
-    lMct = (OPJ_FLOAT32 *) pDecodingData;
-    for
-      (j=0;j<pNbComp;++j)
-    {
-      lCurrentData[j] = (OPJ_FLOAT32) (*(lData[j]));
-    }
-    for
-      (j=0;j<pNbComp;++j)
-    {
-      lCurrentResult[j] = 0;
-      for
-        (k=0;k<pNbComp;++k)
-      {
-        lCurrentResult[j] += *(lMct++) * lCurrentData[k];
-      }
-      *(lData[j]++) = (OPJ_FLOAT32) (lCurrentResult[j]);
-    }
-  }
-  opj_free(lCurrentData);
-  return true;
-}
-
-void opj_calculate_norms(OPJ_FLOAT64 * pNorms,OPJ_UINT32 pNbComps,OPJ_FLOAT32 * pMatrix)
-{
-  OPJ_UINT32 i,j,lIndex;
-  OPJ_FLOAT32 lCurrentValue;
-  OPJ_FLOAT64 * lNorms = (OPJ_FLOAT64 *) pNorms;
-  OPJ_FLOAT32 * lMatrix = (OPJ_FLOAT32 *) pMatrix;
-
-  for
-    (i=0;i<pNbComps;++i)
-  {
-    lNorms[i] = 0;
-    lIndex = i;
-    for
-      (j=0;j<pNbComps;++j)
-    {
-      lCurrentValue = lMatrix[lIndex];
-      lIndex += pNbComps;
-      lNorms[i] += lCurrentValue * lCurrentValue;
-    }
-    lNorms[i] = sqrt(lNorms[i]);
-  }
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.h
deleted file mode 100644
index f8a040c..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mct.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MCT_H
-#define __MCT_H
-/**
- at file mct.h
- at brief Implementation of a multi-component transforms (MCT)
-
-The functions in MCT.C have for goal to realize reversible and irreversible multicomponent
-transform. The functions in MCT.C are used by some function in TCD.C.
-*/
-#include "openjpeg.h"
-/** @defgroup MCT MCT - Implementation of a multi-component transform */
-/*@{*/
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Apply a reversible multi-component transform to an image
- at param c0 Samples for red component
- at param c1 Samples for green component
- at param c2 Samples blue component
- at param n Number of samples for each component
-*/
-void mct_encode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
-/**
-Apply a reversible multi-component inverse transform to an image
- at param c0 Samples for luminance component
- at param c1 Samples for red chrominance component
- at param c2 Samples for blue chrominance component
- at param n Number of samples for each component
-*/
-void mct_decode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
-/**
-Get norm of the basis function used for the reversible multi-component transform
- at param compno Number of the component (0->Y, 1->U, 2->V)
- at return
-*/
-OPJ_FLOAT64 mct_getnorm(OPJ_UINT32 compno);
-
-/**
-Apply an irreversible multi-component transform to an image
- at param c0 Samples for red component
- at param c1 Samples for green component
- at param c2 Samples blue component
- at param n Number of samples for each component
-*/
-void mct_encode_real(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
-/**
-Apply an irreversible multi-component inverse transform to an image
- at param c0 Samples for luminance component
- at param c1 Samples for red chrominance component
- at param c2 Samples for blue chrominance component
- at param n Number of samples for each component
-*/
-void mct_decode_real(OPJ_FLOAT32* c0, OPJ_FLOAT32* c1, OPJ_FLOAT32* c2, OPJ_UINT32 n);
-/**
-Get norm of the basis function used for the irreversible multi-component transform
- at param compno Number of the component (0->Y, 1->U, 2->V)
- at return
-*/
-OPJ_FLOAT64 mct_getnorm_real(OPJ_UINT32 compno);
-
-bool mct_encode_custom(
-             // MCT data
-             OPJ_BYTE * p_coding_data,
-             // size of components
-             OPJ_UINT32 n,
-             // components
-             OPJ_BYTE ** p_data,
-             // nb of components (i.e. size of p_data)
-             OPJ_UINT32 p_nb_comp,
-             // tells if the data is signed
-             OPJ_UINT32 is_signed);
-
-bool mct_decode_custom(
-             // MCT data
-             OPJ_BYTE * pDecodingData,
-             // size of components
-             OPJ_UINT32 n,
-             // components
-             OPJ_BYTE ** pData,
-             // nb of components (i.e. size of pData)
-             OPJ_UINT32 pNbComp,
-             // tells if the data is signed
-             OPJ_UINT32 isSigned);
-
-void opj_calculate_norms(OPJ_FLOAT64 * pNorms,OPJ_UINT32 p_nb_comps,OPJ_FLOAT32 * pMatrix);
-
-const OPJ_FLOAT64 * get_mct_norms ();
-const OPJ_FLOAT64 * get_mct_norms_real ();
-
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __MCT_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.c
deleted file mode 100644
index 5f5573d..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "mqc.h"
-#include "t1.h"
-#include "opj_malloc.h"
-
-/** @defgroup MQC MQC - Implementation of an MQ-Coder */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Output a byte, doing bit-stuffing if necessary.
-After a 0xff byte, the next byte must be smaller than 0x90.
- at param mqc MQC handle
-*/
-static void mqc_byteout(opj_mqc_t *mqc);
-/**
-Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000
- at param mqc MQC handle
-*/
-static void mqc_renorme(opj_mqc_t *mqc);
-/**
-Encode the most probable symbol
- at param mqc MQC handle
-*/
-static void mqc_codemps(opj_mqc_t *mqc);
-/**
-Encode the most least symbol
- at param mqc MQC handle
-*/
-static void mqc_codelps(opj_mqc_t *mqc);
-/**
-Fill mqc->c with 1's for flushing
- at param mqc MQC handle
-*/
-static void mqc_setbits(opj_mqc_t *mqc);
-/**
-FIXME: documentation ???
- at param mqc MQC handle
- at return
-*/
-static OPJ_INT32 mqc_mpsexchange(opj_mqc_t *mqc);
-/**
-FIXME: documentation ???
- at param mqc MQC handle
- at return
-*/
-static OPJ_INT32 mqc_lpsexchange(opj_mqc_t *mqc);
-/**
-Input a byte
- at param mqc MQC handle
-*/
-static void mqc_bytein(opj_mqc_t *mqc);
-/**
-Renormalize mqc->a and mqc->c while decoding
- at param mqc MQC handle
-*/
-static void mqc_renormd(opj_mqc_t *mqc);
-
-/*@}*/
-
-/*@}*/
-
-/* <summary> */
-/* This array defines all the possible states for a context. */
-/* </summary> */
-static opj_mqc_state_t mqc_states[47 * 2] = {
-  {0x5601, 0, &mqc_states[2], &mqc_states[3]},
-  {0x5601, 1, &mqc_states[3], &mqc_states[2]},
-  {0x3401, 0, &mqc_states[4], &mqc_states[12]},
-  {0x3401, 1, &mqc_states[5], &mqc_states[13]},
-  {0x1801, 0, &mqc_states[6], &mqc_states[18]},
-  {0x1801, 1, &mqc_states[7], &mqc_states[19]},
-  {0x0ac1, 0, &mqc_states[8], &mqc_states[24]},
-  {0x0ac1, 1, &mqc_states[9], &mqc_states[25]},
-  {0x0521, 0, &mqc_states[10], &mqc_states[58]},
-  {0x0521, 1, &mqc_states[11], &mqc_states[59]},
-  {0x0221, 0, &mqc_states[76], &mqc_states[66]},
-  {0x0221, 1, &mqc_states[77], &mqc_states[67]},
-  {0x5601, 0, &mqc_states[14], &mqc_states[13]},
-  {0x5601, 1, &mqc_states[15], &mqc_states[12]},
-  {0x5401, 0, &mqc_states[16], &mqc_states[28]},
-  {0x5401, 1, &mqc_states[17], &mqc_states[29]},
-  {0x4801, 0, &mqc_states[18], &mqc_states[28]},
-  {0x4801, 1, &mqc_states[19], &mqc_states[29]},
-  {0x3801, 0, &mqc_states[20], &mqc_states[28]},
-  {0x3801, 1, &mqc_states[21], &mqc_states[29]},
-  {0x3001, 0, &mqc_states[22], &mqc_states[34]},
-  {0x3001, 1, &mqc_states[23], &mqc_states[35]},
-  {0x2401, 0, &mqc_states[24], &mqc_states[36]},
-  {0x2401, 1, &mqc_states[25], &mqc_states[37]},
-  {0x1c01, 0, &mqc_states[26], &mqc_states[40]},
-  {0x1c01, 1, &mqc_states[27], &mqc_states[41]},
-  {0x1601, 0, &mqc_states[58], &mqc_states[42]},
-  {0x1601, 1, &mqc_states[59], &mqc_states[43]},
-  {0x5601, 0, &mqc_states[30], &mqc_states[29]},
-  {0x5601, 1, &mqc_states[31], &mqc_states[28]},
-  {0x5401, 0, &mqc_states[32], &mqc_states[28]},
-  {0x5401, 1, &mqc_states[33], &mqc_states[29]},
-  {0x5101, 0, &mqc_states[34], &mqc_states[30]},
-  {0x5101, 1, &mqc_states[35], &mqc_states[31]},
-  {0x4801, 0, &mqc_states[36], &mqc_states[32]},
-  {0x4801, 1, &mqc_states[37], &mqc_states[33]},
-  {0x3801, 0, &mqc_states[38], &mqc_states[34]},
-  {0x3801, 1, &mqc_states[39], &mqc_states[35]},
-  {0x3401, 0, &mqc_states[40], &mqc_states[36]},
-  {0x3401, 1, &mqc_states[41], &mqc_states[37]},
-  {0x3001, 0, &mqc_states[42], &mqc_states[38]},
-  {0x3001, 1, &mqc_states[43], &mqc_states[39]},
-  {0x2801, 0, &mqc_states[44], &mqc_states[38]},
-  {0x2801, 1, &mqc_states[45], &mqc_states[39]},
-  {0x2401, 0, &mqc_states[46], &mqc_states[40]},
-  {0x2401, 1, &mqc_states[47], &mqc_states[41]},
-  {0x2201, 0, &mqc_states[48], &mqc_states[42]},
-  {0x2201, 1, &mqc_states[49], &mqc_states[43]},
-  {0x1c01, 0, &mqc_states[50], &mqc_states[44]},
-  {0x1c01, 1, &mqc_states[51], &mqc_states[45]},
-  {0x1801, 0, &mqc_states[52], &mqc_states[46]},
-  {0x1801, 1, &mqc_states[53], &mqc_states[47]},
-  {0x1601, 0, &mqc_states[54], &mqc_states[48]},
-  {0x1601, 1, &mqc_states[55], &mqc_states[49]},
-  {0x1401, 0, &mqc_states[56], &mqc_states[50]},
-  {0x1401, 1, &mqc_states[57], &mqc_states[51]},
-  {0x1201, 0, &mqc_states[58], &mqc_states[52]},
-  {0x1201, 1, &mqc_states[59], &mqc_states[53]},
-  {0x1101, 0, &mqc_states[60], &mqc_states[54]},
-  {0x1101, 1, &mqc_states[61], &mqc_states[55]},
-  {0x0ac1, 0, &mqc_states[62], &mqc_states[56]},
-  {0x0ac1, 1, &mqc_states[63], &mqc_states[57]},
-  {0x09c1, 0, &mqc_states[64], &mqc_states[58]},
-  {0x09c1, 1, &mqc_states[65], &mqc_states[59]},
-  {0x08a1, 0, &mqc_states[66], &mqc_states[60]},
-  {0x08a1, 1, &mqc_states[67], &mqc_states[61]},
-  {0x0521, 0, &mqc_states[68], &mqc_states[62]},
-  {0x0521, 1, &mqc_states[69], &mqc_states[63]},
-  {0x0441, 0, &mqc_states[70], &mqc_states[64]},
-  {0x0441, 1, &mqc_states[71], &mqc_states[65]},
-  {0x02a1, 0, &mqc_states[72], &mqc_states[66]},
-  {0x02a1, 1, &mqc_states[73], &mqc_states[67]},
-  {0x0221, 0, &mqc_states[74], &mqc_states[68]},
-  {0x0221, 1, &mqc_states[75], &mqc_states[69]},
-  {0x0141, 0, &mqc_states[76], &mqc_states[70]},
-  {0x0141, 1, &mqc_states[77], &mqc_states[71]},
-  {0x0111, 0, &mqc_states[78], &mqc_states[72]},
-  {0x0111, 1, &mqc_states[79], &mqc_states[73]},
-  {0x0085, 0, &mqc_states[80], &mqc_states[74]},
-  {0x0085, 1, &mqc_states[81], &mqc_states[75]},
-  {0x0049, 0, &mqc_states[82], &mqc_states[76]},
-  {0x0049, 1, &mqc_states[83], &mqc_states[77]},
-  {0x0025, 0, &mqc_states[84], &mqc_states[78]},
-  {0x0025, 1, &mqc_states[85], &mqc_states[79]},
-  {0x0015, 0, &mqc_states[86], &mqc_states[80]},
-  {0x0015, 1, &mqc_states[87], &mqc_states[81]},
-  {0x0009, 0, &mqc_states[88], &mqc_states[82]},
-  {0x0009, 1, &mqc_states[89], &mqc_states[83]},
-  {0x0005, 0, &mqc_states[90], &mqc_states[84]},
-  {0x0005, 1, &mqc_states[91], &mqc_states[85]},
-  {0x0001, 0, &mqc_states[90], &mqc_states[86]},
-  {0x0001, 1, &mqc_states[91], &mqc_states[87]},
-  {0x5601, 0, &mqc_states[92], &mqc_states[92]},
-  {0x5601, 1, &mqc_states[93], &mqc_states[93]},
-};
-
-/*
-==========================================================
-   local functions
-==========================================================
-*/
-
-static void mqc_byteout(opj_mqc_t *mqc) {
-  if (*mqc->bp == 0xff) {
-    mqc->bp++;
-    *mqc->bp = mqc->c >> 20;
-    mqc->c &= 0xfffff;
-    mqc->ct = 7;
-  } else {
-    if ((mqc->c & 0x8000000) == 0) {  /* ((mqc->c&0x8000000)==0) CHANGE */
-      mqc->bp++;
-      *mqc->bp = mqc->c >> 19;
-      mqc->c &= 0x7ffff;
-      mqc->ct = 8;
-    } else {
-      (*mqc->bp)++;
-      if (*mqc->bp == 0xff) {
-        mqc->c &= 0x7ffffff;
-        mqc->bp++;
-        *mqc->bp = mqc->c >> 20;
-        mqc->c &= 0xfffff;
-        mqc->ct = 7;
-      } else {
-        mqc->bp++;
-        *mqc->bp = mqc->c >> 19;
-        mqc->c &= 0x7ffff;
-        mqc->ct = 8;
-      }
-    }
-  }
-}
-
-static void mqc_renorme(opj_mqc_t *mqc) {
-  do {
-    mqc->a <<= 1;
-    mqc->c <<= 1;
-    mqc->ct--;
-    if (mqc->ct == 0) {
-      mqc_byteout(mqc);
-    }
-  } while ((mqc->a & 0x8000) == 0);
-}
-
-static void mqc_codemps(opj_mqc_t *mqc) {
-  mqc->a -= (*mqc->curctx)->qeval;
-  if ((mqc->a & 0x8000) == 0) {
-    if (mqc->a < (*mqc->curctx)->qeval) {
-      mqc->a = (*mqc->curctx)->qeval;
-    } else {
-      mqc->c += (*mqc->curctx)->qeval;
-    }
-    *mqc->curctx = (*mqc->curctx)->nmps;
-    mqc_renorme(mqc);
-  } else {
-    mqc->c += (*mqc->curctx)->qeval;
-  }
-}
-
-static void mqc_codelps(opj_mqc_t *mqc) {
-  mqc->a -= (*mqc->curctx)->qeval;
-  if (mqc->a < (*mqc->curctx)->qeval) {
-    mqc->c += (*mqc->curctx)->qeval;
-  } else {
-    mqc->a = (*mqc->curctx)->qeval;
-  }
-  *mqc->curctx = (*mqc->curctx)->nlps;
-  mqc_renorme(mqc);
-}
-
-static void mqc_setbits(opj_mqc_t *mqc) {
-  OPJ_UINT32 tempc = mqc->c + mqc->a;
-  mqc->c |= 0xffff;
-  if (mqc->c >= tempc) {
-    mqc->c -= 0x8000;
-  }
-}
-
-static OPJ_INT32 mqc_mpsexchange(opj_mqc_t *mqc) {
-  OPJ_INT32 d;
-  if (mqc->a < (*mqc->curctx)->qeval) {
-    d = 1 - (*mqc->curctx)->mps;
-    *mqc->curctx = (*mqc->curctx)->nlps;
-  } else {
-    d = (*mqc->curctx)->mps;
-    *mqc->curctx = (*mqc->curctx)->nmps;
-  }
-
-  return d;
-}
-
-static OPJ_INT32 mqc_lpsexchange(opj_mqc_t *mqc) {
-  OPJ_INT32 d;
-  if (mqc->a < (*mqc->curctx)->qeval) {
-    mqc->a = (*mqc->curctx)->qeval;
-    d = (*mqc->curctx)->mps;
-    *mqc->curctx = (*mqc->curctx)->nmps;
-  } else {
-    mqc->a = (*mqc->curctx)->qeval;
-    d = 1 - (*mqc->curctx)->mps;
-    *mqc->curctx = (*mqc->curctx)->nlps;
-  }
-
-  return d;
-}
-
-static void mqc_bytein(opj_mqc_t *mqc) {
-  if (mqc->bp != mqc->end) {
-    OPJ_UINT32 c;
-    if (mqc->bp + 1 != mqc->end) {
-      c = *(mqc->bp + 1);
-    } else {
-      c = 0xff;
-    }
-    if (*mqc->bp == 0xff) {
-      if (c > 0x8f) {
-        mqc->c += 0xff00;
-        mqc->ct = 8;
-      } else {
-        mqc->bp++;
-        mqc->c += c << 9;
-        mqc->ct = 7;
-      }
-    } else {
-      mqc->bp++;
-      mqc->c += c << 8;
-      mqc->ct = 8;
-    }
-  } else {
-    mqc->c += 0xff00;
-    mqc->ct = 8;
-  }
-}
-
-static void mqc_renormd(opj_mqc_t *mqc) {
-  do {
-    if (mqc->ct == 0) {
-      mqc_bytein(mqc);
-    }
-    mqc->a <<= 1;
-    mqc->c <<= 1;
-    mqc->ct--;
-  } while (mqc->a < 0x8000);
-}
-
-/*
-==========================================================
-   MQ-Coder interface
-==========================================================
-*/
-
-opj_mqc_t* mqc_create(void) {
-  opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
-  return mqc;
-}
-
-void mqc_destroy(opj_mqc_t *mqc) {
-  if
-    (mqc)
-  {
-    opj_free(mqc);
-  }
-}
-
-OPJ_UINT32 mqc_numbytes(opj_mqc_t *mqc) {
-  return mqc->bp - mqc->start;
-}
-
-void mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) {
-  mqc_setcurctx(mqc, 0);
-  mqc->a = 0x8000;
-  mqc->c = 0;
-  mqc->bp = bp - 1;
-  *(mqc->bp) = 0;
-  mqc->ct = 12;
-  /*if (*mqc->bp == 0xff) {
-    mqc->ct = 13;
-  }*/
-  mqc->start = bp;
-}
-
-void mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d) {
-  if ((*mqc->curctx)->mps == d) {
-    mqc_codemps(mqc);
-  } else {
-    mqc_codelps(mqc);
-  }
-}
-
-void mqc_flush(opj_mqc_t *mqc) {
-  mqc_setbits(mqc);
-  mqc->c <<= mqc->ct;
-  mqc_byteout(mqc);
-  mqc->c <<= mqc->ct;
-  mqc_byteout(mqc);
-
-  if (*mqc->bp != 0xff) {
-    mqc->bp++;
-  }
-}
-
-void mqc_bypass_init_enc(opj_mqc_t *mqc) {
-  mqc->c = 0;
-  mqc->ct = 8;
-  /*if (*mqc->bp == 0xff) {
-  mqc->ct = 7;
-     } */
-}
-
-void mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d) {
-  mqc->ct--;
-  mqc->c = mqc->c + (d << mqc->ct);
-  if (mqc->ct == 0) {
-    mqc->bp++;
-    *mqc->bp = mqc->c;
-    mqc->ct = 8;
-    if (*mqc->bp == 0xff) {
-      mqc->ct = 7;
-    }
-    mqc->c = 0;
-  }
-}
-
-OPJ_UINT32 mqc_bypass_flush_enc(opj_mqc_t *mqc) {
-  OPJ_BYTE bit_padding;
-
-  bit_padding = 0;
-
-  if (mqc->ct != 0) {
-    while (mqc->ct > 0) {
-      mqc->ct--;
-      mqc->c += bit_padding << mqc->ct;
-      bit_padding = (bit_padding + 1) & 0x01;
-    }
-    mqc->bp++;
-    *mqc->bp = mqc->c;
-    mqc->ct = 8;
-    mqc->c = 0;
-  }
-
-  return 1;
-}
-
-void mqc_reset_enc(opj_mqc_t *mqc) {
-  mqc_resetstates(mqc);
-  mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
-  mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-  mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-}
-
-OPJ_UINT32 mqc_restart_enc(opj_mqc_t *mqc) {
-  OPJ_UINT32 correction = 1;
-
-  /* <flush part> */
-  OPJ_INT32 n = 27 - 15 - mqc->ct;
-  mqc->c <<= mqc->ct;
-  while (n > 0) {
-    mqc_byteout(mqc);
-    n -= mqc->ct;
-    mqc->c <<= mqc->ct;
-  }
-  mqc_byteout(mqc);
-
-  return correction;
-}
-
-void mqc_restart_init_enc(opj_mqc_t *mqc) {
-  /* <Re-init part> */
-  mqc_setcurctx(mqc, 0);
-  mqc->a = 0x8000;
-  mqc->c = 0;
-  mqc->ct = 12;
-  mqc->bp--;
-  if (*mqc->bp == 0xff) {
-    mqc->ct = 13;
-  }
-}
-
-void mqc_erterm_enc(opj_mqc_t *mqc) {
-  OPJ_INT32 k = 11 - mqc->ct + 1;
-
-  while (k > 0) {
-    mqc->c <<= mqc->ct;
-    mqc->ct = 0;
-    mqc_byteout(mqc);
-    k -= mqc->ct;
-  }
-
-  if (*mqc->bp != 0xff) {
-    mqc_byteout(mqc);
-  }
-}
-
-void mqc_segmark_enc(opj_mqc_t *mqc) {
-  OPJ_UINT32 i;
-  mqc_setcurctx(mqc, 18);
-
-  for (i = 1; i < 5; i++) {
-    mqc_encode(mqc, i % 2);
-  }
-}
-
-void mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len) {
-  mqc_setcurctx(mqc, 0);
-  mqc->start = bp;
-  mqc->end = bp + len;
-  mqc->bp = bp;
-  if (len==0) mqc->c = 0xff << 16;
-  else mqc->c = *mqc->bp << 16;
-  mqc_bytein(mqc);
-  mqc->c <<= 7;
-  mqc->ct -= 7;
-  mqc->a = 0x8000;
-}
-
-OPJ_UINT32 mqc_decode(opj_mqc_t *mqc) {
-  OPJ_INT32 d;
-  mqc->a -= (*mqc->curctx)->qeval;
-  if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
-    d = mqc_lpsexchange(mqc);
-    mqc_renormd(mqc);
-  } else {
-    mqc->c -= (*mqc->curctx)->qeval << 16;
-    if ((mqc->a & 0x8000) == 0) {
-      d = mqc_mpsexchange(mqc);
-      mqc_renormd(mqc);
-    } else {
-      d = (*mqc->curctx)->mps;
-    }
-  }
-
-  return (OPJ_UINT32)d;
-}
-
-void mqc_resetstates(opj_mqc_t *mqc) {
-  OPJ_UINT32 i;
-  for (i = 0; i < MQC_NUMCTXS; i++) {
-    mqc->ctxs[i] = mqc_states;
-  }
-}
-
-void mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob) {
-  mqc->ctxs[ctxno] = &mqc_states[msb + (prob << 1)];
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.h
deleted file mode 100644
index 0b64ba4..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/mqc.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MQC_H
-#define __MQC_H
-/**
- at file mqc.h
- at brief Implementation of an MQ-Coder (MQC)
-
-The functions in MQC.C have for goal to realize the MQ-coder operations. The functions
-in MQC.C are used by some function in T1.C.
-*/
-#include "openjpeg.h"
-/** @defgroup MQC MQC - Implementation of an MQ-Coder */
-/*@{*/
-
-/**
-This struct defines the state of a context.
-*/
-typedef struct opj_mqc_state {
-  /** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */
-  OPJ_UINT32 qeval;
-  /** the Most Probable Symbol (0 or 1) */
-  OPJ_INT32 mps;
-  /** next state if the next encoded symbol is the MPS */
-  struct opj_mqc_state *nmps;
-  /** next state if the next encoded symbol is the LPS */
-  struct opj_mqc_state *nlps;
-} opj_mqc_state_t;
-
-#define MQC_NUMCTXS 32
-
-/**
-MQ coder
-*/
-typedef struct opj_mqc {
-  OPJ_UINT32 c;
-  OPJ_UINT32 a;
-  OPJ_UINT32 ct;
-  OPJ_BYTE *bp;
-  OPJ_BYTE *start;
-  OPJ_BYTE *end;
-  opj_mqc_state_t *ctxs[MQC_NUMCTXS];
-  opj_mqc_state_t **curctx;
-} opj_mqc_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new MQC handle
- at return Returns a new MQC handle if successful, returns NULL otherwise
-*/
-opj_mqc_t* mqc_create(void);
-/**
-Destroy a previously created MQC handle
- at param mqc MQC handle to destroy
-*/
-void mqc_destroy(opj_mqc_t *mqc);
-/**
-Return the number of bytes written/read since initialisation
- at param mqc MQC handle
- at return Returns the number of bytes already encoded
-*/
-OPJ_UINT32 mqc_numbytes(opj_mqc_t *mqc);
-/**
-Reset the states of all the context of the coder/decoder
-(each context is set to a state where 0 and 1 are more or less equiprobable)
- at param mqc MQC handle
-*/
-void mqc_resetstates(opj_mqc_t *mqc);
-/**
-Set the state of a particular context
- at param mqc MQC handle
- at param ctxno Number that identifies the context
- at param msb The MSB of the new state of the context
- at param prob Number that identifies the probability of the symbols for the new state of the context
-*/
-void mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob);
-/**
-Initialize the encoder
- at param mqc MQC handle
- at param bp Pointer to the start of the buffer where the bytes will be written
-*/
-void mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp);
-/**
-Set the current context used for coding/decoding
- at param mqc MQC handle
- at param ctxno Number that identifies the context
-*/
-#define mqc_setcurctx(mqc, ctxno)  (mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)]
-/**
-Encode a symbol using the MQ-coder
- at param mqc MQC handle
- at param d The symbol to be encoded (0 or 1)
-*/
-void mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d);
-/**
-Flush the encoder, so that all remaining data is written
- at param mqc MQC handle
-*/
-void mqc_flush(opj_mqc_t *mqc);
-/**
-BYPASS mode switch, initialization operation.
-JPEG 2000 p 505.
-<h2>Not fully implemented and tested !!</h2>
- at param mqc MQC handle
-*/
-void mqc_bypass_init_enc(opj_mqc_t *mqc);
-/**
-BYPASS mode switch, coding operation.
-JPEG 2000 p 505.
-<h2>Not fully implemented and tested !!</h2>
- at param mqc MQC handle
- at param d The symbol to be encoded (0 or 1)
-*/
-void mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d);
-/**
-BYPASS mode switch, flush operation
-<h2>Not fully implemented and tested !!</h2>
- at param mqc MQC handle
- at return Returns 1 (always)
-*/
-OPJ_UINT32 mqc_bypass_flush_enc(opj_mqc_t *mqc);
-/**
-RESET mode switch
- at param mqc MQC handle
-*/
-void mqc_reset_enc(opj_mqc_t *mqc);
-/**
-RESTART mode switch (TERMALL)
- at param mqc MQC handle
- at return Returns 1 (always)
-*/
-OPJ_UINT32 mqc_restart_enc(opj_mqc_t *mqc);
-/**
-RESTART mode switch (TERMALL) reinitialisation
- at param mqc MQC handle
-*/
-void mqc_restart_init_enc(opj_mqc_t *mqc);
-/**
-ERTERM mode switch (PTERM)
- at param mqc MQC handle
-*/
-void mqc_erterm_enc(opj_mqc_t *mqc);
-/**
-SEGMARK mode switch (SEGSYM)
- at param mqc MQC handle
-*/
-void mqc_segmark_enc(opj_mqc_t *mqc);
-/**
-Initialize the decoder
- at param mqc MQC handle
- at param bp Pointer to the start of the buffer from which the bytes will be read
- at param len Length of the input buffer
-*/
-void mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len);
-/**
-Decode a symbol
- at param mqc MQC handle
- at return Returns the decoded symbol (0 or 1)
-*/
-OPJ_UINT32 mqc_decode(opj_mqc_t *mqc);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __MQC_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.c
deleted file mode 100644
index b9fb403..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.c
+++ /dev/null
@@ -1,947 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef WIN32
-#include <windows.h>
-#endif /* WIN32 */
-
-#include "openjpeg.h"
-#include "opj_malloc.h"
-#include "j2k.h"
-#include "jp2.h"
-#include "event.h"
-#include "cio.h"
-
-typedef struct opj_decompression
-{
-  bool (* opj_read_header) (
-    void *p_codec,
-    opj_image_t **,
-    OPJ_INT32 * p_tile_x0,
-    OPJ_INT32 * p_tile_y0,
-    OPJ_UINT32 * p_tile_width,
-    OPJ_UINT32 * p_tile_height,
-    OPJ_UINT32 * p_nb_tiles_x,
-    OPJ_UINT32 * p_nb_tiles_y,
-    struct opj_stream_private *cio,
-    struct opj_event_mgr * p_manager);
-  opj_image_t* (* opj_decode) (void * p_codec, struct opj_stream_private *p_cio, struct opj_event_mgr * p_manager);
-  bool (*opj_read_tile_header)(
-    void * p_codec,
-    OPJ_UINT32 * p_tile_index,
-    OPJ_UINT32* p_data_size,
-    OPJ_INT32 * p_tile_x0,
-    OPJ_INT32 * p_tile_y0,
-    OPJ_INT32 * p_tile_x1,
-    OPJ_INT32 * p_tile_y1,
-    OPJ_UINT32 * p_nb_comps,
-    bool * p_should_go_on,
-    struct opj_stream_private *p_cio,
-    struct opj_event_mgr * p_manager);
-    bool (*opj_decode_tile_data)(void * p_codec,OPJ_UINT32 p_tile_index,OPJ_BYTE * p_data,OPJ_UINT32 p_data_size,struct opj_stream_private *p_cio,struct opj_event_mgr * p_manager);
-  bool (* opj_end_decompress) (void *p_codec,struct opj_stream_private *cio,struct opj_event_mgr * p_manager);
-  void (* opj_destroy) (void * p_codec);
-  void (*opj_setup_decoder) (void * p_codec,opj_dparameters_t * p_param);
-  bool (*opj_set_decode_area) (void * p_codec,OPJ_INT32 p_start_x,OPJ_INT32 p_end_x,OPJ_INT32 p_start_y,OPJ_INT32 p_end_y,struct opj_event_mgr * p_manager);
-
-
-}opj_decompression_t;
-
-typedef struct opj_compression
-{
-  bool (* opj_start_compress) (void *p_codec,struct opj_stream_private *cio,struct opj_image * p_image,  struct opj_event_mgr * p_manager);
-  bool (* opj_encode) (void * p_codec, struct opj_stream_private *p_cio, struct opj_event_mgr * p_manager);
-  bool (* opj_write_tile) (void * p_codec,OPJ_UINT32 p_tile_index,OPJ_BYTE * p_data,OPJ_UINT32 p_data_size,struct opj_stream_private * p_cio,struct opj_event_mgr * p_manager);
-  bool (* opj_end_compress) (void * p_codec, struct opj_stream_private *p_cio, struct opj_event_mgr * p_manager);
-  void (* opj_destroy) (void * p_codec);
-  void (*opj_setup_encoder) (void * p_codec,opj_cparameters_t * p_param,struct opj_image * p_image, struct opj_event_mgr * p_manager);
-
-}opj_compression_t;
-
-
-
-typedef struct opj_codec_private
-{
-  union
-  {    /* code-blocks informations */
-    opj_decompression_t m_decompression;
-    opj_compression_t m_compression;
-    } m_codec_data;
-  void * m_codec;
-  opj_event_mgr_t m_event_mgr;
-  unsigned is_decompressor : 1;
-}
-opj_codec_private_t;
-
-
-
-/**
- * Default callback function.
- * Do nothing.
- */
-void opj_default_callback (const char *msg, void *client_data)
-{
-#if 0
-  fprintf( stderr, msg );
-  assert( 0 );
-#endif
-}
-
-void set_default_event_handler(opj_event_mgr_t * p_manager)
-{
-  p_manager->m_error_data = 00;
-  p_manager->m_warning_data = 00;
-  p_manager->m_info_data = 00;
-  p_manager->error_handler = opj_default_callback;
-  p_manager->info_handler = opj_default_callback;
-  p_manager->warning_handler = opj_default_callback;
-}
-
-OPJ_UINT32 opj_read_from_file (void * p_buffer, OPJ_UINT32 p_nb_bytes, FILE * p_file)
-{
-  OPJ_UINT32 l_nb_read = fread(p_buffer,1,p_nb_bytes,p_file);
-  return l_nb_read ? l_nb_read : -1;
-}
-
-OPJ_UINT32 opj_write_from_file (void * p_buffer, OPJ_UINT32 p_nb_bytes, FILE * p_file)
-{
-  return fwrite(p_buffer,1,p_nb_bytes,p_file);
-}
-
-OPJ_SIZE_T opj_skip_from_file (OPJ_SIZE_T p_nb_bytes, FILE * p_user_data)
-{
-  if
-    (fseek(p_user_data,p_nb_bytes,SEEK_CUR))
-  {
-    return -1;
-  }
-  return p_nb_bytes;
-}
-
-bool opj_seek_from_file (OPJ_SIZE_T p_nb_bytes, FILE * p_user_data)
-{
-  if
-    (fseek(p_user_data,p_nb_bytes,SEEK_SET))
-  {
-    return false;
-  }
-  return true;
-}
-
-/* ---------------------------------------------------------------------- */
-#ifdef WIN32
-#ifndef OPJ_STATIC
-BOOL APIENTRY
-DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
-  switch (ul_reason_for_call) {
-    case DLL_PROCESS_ATTACH :
-      break;
-    case DLL_PROCESS_DETACH :
-      break;
-    case DLL_THREAD_ATTACH :
-    case DLL_THREAD_DETACH :
-      break;
-    }
-
-    return TRUE;
-}
-#endif /* OPJ_STATIC */
-#endif /* WIN32 */
-
-/* ---------------------------------------------------------------------- */
-
-
-const char* OPJ_CALLCONV opj_version(void) {
-    return OPENJPEG_VERSION;
-}
-
-opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
-{
-  opj_codec_private_t *l_info = 00;
-
-  l_info = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t));
-  if
-    (!l_info)
-  {
-    return 00;
-  }
-  memset(l_info, 0, sizeof(opj_codec_private_t));
-  l_info->is_decompressor = 1;
-  switch
-    (p_format)
-  {
-    case CODEC_J2K:
-      l_info->m_codec_data.m_decompression.opj_decode = (opj_image_t* (*) (void *, struct opj_stream_private *, struct opj_event_mgr * ))j2k_decode;
-      l_info->m_codec_data.m_decompression.opj_end_decompress =  (bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *))j2k_end_decompress;
-      l_info->m_codec_data.m_decompression.opj_read_header =  (bool (*) (
-        void *,
-        opj_image_t **,
-        OPJ_INT32 * ,
-        OPJ_INT32 * ,
-        OPJ_UINT32 * ,
-        OPJ_UINT32 * ,
-        OPJ_UINT32 * ,
-        OPJ_UINT32 * ,
-        struct opj_stream_private *,
-        struct opj_event_mgr * )) j2k_read_header;
-      l_info->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))j2k_destroy;
-      l_info->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) j2k_setup_decoder;
-      l_info->m_codec_data.m_decompression.opj_read_tile_header = (bool (*) (
-        void *,
-        OPJ_UINT32*,
-        OPJ_UINT32*,
-        OPJ_INT32 * ,
-        OPJ_INT32 * ,
-        OPJ_INT32 * ,
-        OPJ_INT32 * ,
-        OPJ_UINT32 * ,
-        bool *,
-        struct opj_stream_private *,
-        struct opj_event_mgr * )) j2k_read_tile_header;
-        l_info->m_codec_data.m_decompression.opj_decode_tile_data = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *,  struct opj_event_mgr * )) j2k_decode_tile;
-      l_info->m_codec_data.m_decompression.opj_set_decode_area = (bool (*) (void *,OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32, struct opj_event_mgr * )) j2k_set_decode_area;
-      l_info->m_codec = j2k_create_decompress();
-      if
-        (! l_info->m_codec)
-      {
-        opj_free(l_info);
-        return 00;
-      }
-      break;
-
-    case CODEC_JP2:
-      /* get a JP2 decoder handle */
-      l_info->m_codec_data.m_decompression.opj_decode = (opj_image_t* (*) (void *, struct opj_stream_private *, struct opj_event_mgr * ))jp2_decode;
-      l_info->m_codec_data.m_decompression.opj_end_decompress =  (bool (*) (void *,struct opj_stream_private *,struct opj_event_mgr *)) jp2_end_decompress;
-      l_info->m_codec_data.m_decompression.opj_read_header =  (bool (*) (
-        void *,
-        opj_image_t **,
-
-        OPJ_INT32 * ,
-        OPJ_INT32 * ,
-        OPJ_UINT32 * ,
-        OPJ_UINT32 * ,
-        OPJ_UINT32 * ,
-        OPJ_UINT32 * ,
-        struct opj_stream_private *,
-        struct opj_event_mgr * )) jp2_read_header;
-
-      l_info->m_codec_data.m_decompression.opj_read_tile_header = (
-        bool (*) (
-          void *,
-          OPJ_UINT32*,
-          OPJ_UINT32*,
-          OPJ_INT32*,
-          OPJ_INT32*,
-          OPJ_INT32 * ,
-          OPJ_INT32 * ,
-          OPJ_UINT32 * ,
-          bool *,
-          struct opj_stream_private *,
-          struct opj_event_mgr * )) jp2_read_tile_header;
-
-      l_info->m_codec_data.m_decompression.opj_decode_tile_data = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *,  struct opj_event_mgr * )) jp2_decode_tile;
-
-      l_info->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))jp2_destroy;
-      l_info->m_codec_data.m_decompression.opj_setup_decoder = (void (*) (void * ,opj_dparameters_t * )) jp2_setup_decoder;
-      l_info->m_codec_data.m_decompression.opj_set_decode_area = (bool (*) (void *,OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32, struct opj_event_mgr * )) jp2_set_decode_area;
-
-
-      l_info->m_codec = jp2_create(true);
-      if
-        (! l_info->m_codec)
-      {
-        opj_free(l_info);
-        return 00;
-      }
-      break;
-    case CODEC_UNKNOWN:
-    case CODEC_JPT:
-    default:
-      opj_free(l_info);
-      return 00;
-  }
-  set_default_event_handler(&(l_info->m_event_mgr));
-  return (opj_codec_t*) l_info;
-}
-
-void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_info)
-{
-  if
-    (p_info)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
-    if
-      (l_info->is_decompressor)
-    {
-      l_info->m_codec_data.m_decompression.opj_destroy(l_info->m_codec);
-    }
-    else
-    {
-      l_info->m_codec_data.m_compression.opj_destroy(l_info->m_codec);
-    }
-    l_info->m_codec = 00;
-    opj_free(l_info);
-  }
-}
-
-void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
-  if(parameters) {
-    memset(parameters, 0, sizeof(opj_dparameters_t));
-    /* default decoding parameters */
-    parameters->cp_layer = 0;
-    parameters->cp_reduce = 0;
-
-    parameters->decod_format = -1;
-    parameters->cod_format = -1;
-/* UniPG>> */
-#ifdef USE_JPWL
-    parameters->jpwl_correct = false;
-    parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
-    parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
-#endif /* USE_JPWL */
-/* <<UniPG */
-  }
-}
-
-bool OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_info, opj_dparameters_t *parameters) {
-  if
-    (p_info && parameters)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
-    if
-      (! l_info->is_decompressor)
-    {
-      return false;
-    }
-    l_info->m_codec_data.m_decompression.opj_setup_decoder(l_info->m_codec,parameters);
-    return true;
-  }
-  return false;
-}
-
-opj_image_t* OPJ_CALLCONV opj_decode(opj_codec_t *p_info, opj_stream_t *cio)
-{
-  if
-    (p_info && cio)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) cio;
-    if
-      (! l_info->is_decompressor)
-    {
-      return 00;
-    }
-    return l_info->m_codec_data.m_decompression.opj_decode(l_info->m_codec,l_cio,&(l_info->m_event_mgr));
-  }
-  return 00;
-}
-
-/**
- * Writes a tile with the given data.
- *
- * @param  p_compressor    the jpeg2000 codec.
- * @param  p_tile_index    the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
- * @param  p_data        pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
- * @param  p_data_size      this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes,
- *                depending on the precision of the given component.
- * @param  p_stream      the stream to write data to.
- */
-bool OPJ_CALLCONV opj_write_tile (
-           opj_codec_t *p_codec,
-           OPJ_UINT32 p_tile_index,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           opj_stream_t *p_stream
-          )
-{
-  if
-    (p_codec && p_stream && p_data)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream;
-    if
-      (l_info->is_decompressor)
-    {
-      return false;
-    }
-    return l_info->m_codec_data.m_compression.opj_write_tile(l_info->m_codec,p_tile_index,p_data,p_data_size,l_cio,&(l_info->m_event_mgr));
-  }
-  return false;
-}
-
-/**
- * Reads a tile header. This function is compulsory and allows one to know the size of the tile thta will be decoded.
- * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
- *
- * @param  p_codec      the jpeg2000 codec.
- * @param  p_tile_index  pointer to a value that will hold the index of the tile being decoded, in case of success.
- * @param  p_data_size    pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
- *              of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
- *              as depicted in opj_write_tile.
- * @param  p_tile_x0    pointer to a value that will hold the x0 pos of the tile (in the image).
- * @param  p_tile_y0    pointer to a value that will hold the y0 pos of the tile (in the image).
- * @param  p_tile_x1    pointer to a value that will hold the x1 pos of the tile (in the image).
- * @param  p_tile_y1    pointer to a value that will hold the y1 pos of the tile (in the image).
- * @param  p_nb_comps    pointer to a value that will hold the number of components in the tile.
- * @param  p_should_go_on  pointer to a boolean that will hold the fact that the decoding should go on. In case the
- *              codestream is over at the time of the call, the value will be set to false. The user should then stop
- *              the decoding.
- * @param  p_stream    the stream to decode.
- * @return  true      if the tile header could be decoded. In case the decoding should end, the returned value is still true.
- *              returning false may be the result of a shortage of memory or an internal error.
- */
-bool OPJ_CALLCONV opj_read_tile_header(
-          opj_codec_t *p_codec,
-          OPJ_UINT32 * p_tile_index,
-          OPJ_UINT32 * p_data_size,
-          OPJ_INT32 * p_tile_x0,
-          OPJ_INT32 * p_tile_y0,
-          OPJ_INT32 * p_tile_x1,
-          OPJ_INT32 * p_tile_y1,
-          OPJ_UINT32 * p_nb_comps,
-          bool * p_should_go_on,
-          opj_stream_t * p_stream)
-{
-  if
-    (p_codec && p_stream && p_data_size && p_tile_index)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream;
-    if
-      (! l_info->is_decompressor)
-    {
-      return false;
-    }
-    return l_info->m_codec_data.m_decompression.opj_read_tile_header(
-      l_info->m_codec,
-      p_tile_index,
-      p_data_size,
-      p_tile_x0,
-      p_tile_y0,
-      p_tile_x1,
-      p_tile_y1,
-      p_nb_comps,
-      p_should_go_on,
-      l_cio,&(l_info->m_event_mgr));
-  }
-  return false;
-}
-
-/**
- * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
- * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
- *
- * @param  p_codec      the jpeg2000 codec.
- * @param  p_tile_index  the index of the tile being decoded, this should be the value set by opj_read_tile_header.
- * @param  p_data      pointer to a memory block that will hold the decoded data.
- * @param  p_data_size    size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
- * @param  p_stream    the stream to decode.
- *
- * @return  true      if the data could be decoded.
- */
-bool OPJ_CALLCONV opj_decode_tile_data(
-          opj_codec_t *p_codec,
-          OPJ_UINT32 p_tile_index,
-          OPJ_BYTE * p_data,
-          OPJ_UINT32 p_data_size,
-          opj_stream_t *p_stream
-          )
-{
-  if
-    (p_codec && p_data && p_stream)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) p_stream;
-    if
-      (! l_info->is_decompressor)
-    {
-      return false;
-    }
-    return l_info->m_codec_data.m_decompression.opj_decode_tile_data(l_info->m_codec,p_tile_index,p_data,p_data_size,l_cio,&(l_info->m_event_mgr));
-  }
-  return false;
-}
-
-bool OPJ_CALLCONV opj_read_header (
-                   opj_codec_t *p_codec,
-                   opj_image_t ** p_image,
-                   OPJ_INT32 * p_tile_x0,
-                   OPJ_INT32 * p_tile_y0,
-                   OPJ_UINT32 * p_tile_width,
-                   OPJ_UINT32 * p_tile_height,
-                   OPJ_UINT32 * p_nb_tiles_x,
-                   OPJ_UINT32 * p_nb_tiles_y,
-                   opj_stream_t *p_cio)
-{
-  if
-    (p_codec && p_cio)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
-    if
-      (! l_info->is_decompressor)
-    {
-      return false;
-    }
-    return l_info->m_codec_data.m_decompression.opj_read_header(
-      l_info->m_codec,
-      p_image,
-      p_tile_x0,
-      p_tile_y0,
-      p_tile_width,
-      p_tile_height,
-      p_nb_tiles_x,
-      p_nb_tiles_y,
-      l_cio,
-      &(l_info->m_event_mgr));
-  }
-  return false;
-}
-
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param  p_codec      the jpeg2000 codec.
- * @param  p_start_x    the left position of the rectangle to decode (in image coordinates).
- * @param  p_end_x      the right position of the rectangle to decode (in image coordinates).
- * @param  p_start_y    the up position of the rectangle to decode (in image coordinates).
- * @param  p_end_y      the bottom position of the rectangle to decode (in image coordinates).
- *
- * @return  true      if the area could be set.
- */
-bool OPJ_CALLCONV opj_set_decode_area(
-          opj_codec_t *p_codec,
-          OPJ_INT32 p_start_x,
-          OPJ_INT32 p_start_y,
-          OPJ_INT32 p_end_x,
-          OPJ_INT32 p_end_y
-          )
-{
-  if
-    (p_codec)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
-    if
-      (! l_info->is_decompressor)
-    {
-      return false;
-    }
-    return  l_info->m_codec_data.m_decompression.opj_set_decode_area(
-        l_info->m_codec,
-        p_start_x,
-        p_start_y,
-        p_end_x,
-        p_end_y,
-        &(l_info->m_event_mgr));
-
-  }
-  return false;
-
-}
-
-bool OPJ_CALLCONV opj_end_decompress (opj_codec_t *p_codec,opj_stream_t *p_cio)
-{
-  if
-    (p_codec && p_cio)
-  {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_codec;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
-    if
-      (! l_info->is_decompressor)
-    {
-      return false;
-    }
-    return l_info->m_codec_data.m_decompression.opj_end_decompress(l_info->m_codec,l_cio,&(l_info->m_event_mgr));
-  }
-  return false;
-}
-
-
-opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
-{
-  opj_codec_private_t *l_info = 00;
-
-  l_info = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t));
-  if
-    (!l_info)
-  {
-    return 00;
-  }
-  memset(l_info, 0, sizeof(opj_codec_private_t));
-  l_info->is_decompressor = 0;
-  switch
-    (p_format)
-  {
-    case CODEC_J2K:
-      l_info->m_codec_data.m_compression.opj_encode = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) j2k_encode;
-      l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) j2k_end_compress;
-      l_info->m_codec_data.m_compression.opj_start_compress = (bool (*) (void *,struct opj_stream_private *,struct opj_image * ,  struct opj_event_mgr *)) j2k_start_compress;
-      l_info->m_codec_data.m_compression.opj_write_tile = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *,  struct opj_event_mgr *)) j2k_write_tile;
-      l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) j2k_destroy;
-      l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) j2k_setup_encoder;
-
-      l_info->m_codec = j2k_create_compress();
-      if
-        (! l_info->m_codec)
-      {
-        opj_free(l_info);
-        return 00;
-      }
-      break;
-
-    case CODEC_JP2:
-      /* get a JP2 decoder handle */
-      l_info->m_codec_data.m_compression.opj_encode = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) jp2_encode;
-      l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) jp2_end_compress;
-      l_info->m_codec_data.m_compression.opj_start_compress = (bool (*) (void *,struct opj_stream_private *,struct opj_image * ,  struct opj_event_mgr *))  jp2_start_compress;
-      l_info->m_codec_data.m_compression.opj_write_tile = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *,  struct opj_event_mgr *)) jp2_write_tile;
-      l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) jp2_destroy;
-      l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) jp2_setup_encoder;
-
-      l_info->m_codec = jp2_create(false);
-      if
-        (! l_info->m_codec)
-      {
-        opj_free(l_info);
-        return 00;
-      }
-      break;
-    case CODEC_UNKNOWN:
-    case CODEC_JPT:
-    default:
-      opj_free(l_info);
-      return 00;
-  }
-  set_default_event_handler(&(l_info->m_event_mgr));
-  return (opj_codec_t*) l_info;
-}
-
-void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
-  if(parameters) {
-    memset(parameters, 0, sizeof(opj_cparameters_t));
-    /* default coding parameters */
-    parameters->cp_cinema = OFF;
-    parameters->max_comp_size = 0;
-    parameters->numresolution = 6;
-    parameters->cp_rsiz = STD_RSIZ;
-    parameters->cblockw_init = 64;
-    parameters->cblockh_init = 64;
-    parameters->prog_order = LRCP;
-    parameters->roi_compno = -1;    /* no ROI */
-    parameters->subsampling_dx = 1;
-    parameters->subsampling_dy = 1;
-    parameters->tp_on = 0;
-    parameters->decod_format = -1;
-    parameters->cod_format = -1;
-    parameters->tcp_rates[0] = 0;
-    parameters->tcp_numlayers = 0;
-    parameters->cp_disto_alloc = 0;
-    parameters->cp_fixed_alloc = 0;
-    parameters->cp_fixed_quality = 0;
-/* UniPG>> */
-#ifdef USE_JPWL
-    parameters->jpwl_epc_on = false;
-    parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
-    {
-      int i;
-      for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-        parameters->jpwl_hprot_TPH_tileno[i] = -1; /* unassigned */
-        parameters->jpwl_hprot_TPH[i] = 0; /* absent */
-      }
-    };
-    {
-      int i;
-      for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
-        parameters->jpwl_pprot_tileno[i] = -1; /* unassigned */
-        parameters->jpwl_pprot_packno[i] = -1; /* unassigned */
-        parameters->jpwl_pprot[i] = 0; /* absent */
-      }
-    };
-    parameters->jpwl_sens_size = 0; /* 0 means no ESD */
-    parameters->jpwl_sens_addr = 0; /* 0 means auto */
-    parameters->jpwl_sens_range = 0; /* 0 means packet */
-    parameters->jpwl_sens_MH = -1; /* -1 means unassigned */
-    {
-      int i;
-      for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
-        parameters->jpwl_sens_TPH_tileno[i] = -1; /* unassigned */
-        parameters->jpwl_sens_TPH[i] = -1; /* absent */
-      }
-    };
-#endif /* USE_JPWL */
-/* <<UniPG */
-  }
-}
-
-/**
- * Helper function.
- * Sets the stream to be a file stream. The FILE must have been open previously.
- * @param    p_stream  the stream to modify
- * @param    p_file    handler to an already open file.
-*/
-opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file,bool p_is_read_stream)
-{
-  return opj_stream_create_file_stream(p_file,J2K_STREAM_CHUNK_SIZE,p_is_read_stream);
-}
-
-opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file,OPJ_UINT32 p_size,bool p_is_read_stream)
-{
-  opj_stream_t* l_stream = 00;
-  if
-    (! p_file)
-  {
-    return 00;
-  }
-  l_stream = opj_stream_create(p_size,p_is_read_stream);
-  if
-    (! l_stream)
-  {
-    return 00;
-  }
-  opj_stream_set_user_data(l_stream,p_file);
-  opj_stream_set_read_function(l_stream,(opj_stream_read_fn) opj_read_from_file);
-  opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);
-  opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_file);
-  opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_file);
-  return l_stream;
-}
-
-
-bool OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_info, opj_cparameters_t *parameters, opj_image_t *image)
-{
-  if
-    (p_info && parameters && image)
-  {
-    opj_codec_private_t * l_codec = ((opj_codec_private_t *) p_info);
-    if
-      (! l_codec->is_decompressor)
-    {
-      l_codec->m_codec_data.m_compression.opj_setup_encoder(l_codec->m_codec,parameters,image,&(l_codec->m_event_mgr));
-      return true;
-    }
-  }
-  return false;
-}
-
-bool OPJ_CALLCONV opj_encode(opj_codec_t *p_info, opj_stream_t *cio)
-{
-  if
-    (p_info && cio)
-  {
-    opj_codec_private_t * l_codec = (opj_codec_private_t *) p_info;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) cio;
-    if
-      (! l_codec->is_decompressor)
-    {
-      l_codec->m_codec_data.m_compression.opj_encode(l_codec->m_codec,l_cio,&(l_codec->m_event_mgr));
-      return true;
-    }
-  }
-  return false;
-
-}
-
-bool OPJ_CALLCONV opj_start_compress (opj_codec_t *p_codec,opj_image_t * p_image,opj_stream_t *p_cio)
-{
-  if
-    (p_codec && p_cio)
-  {
-    opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
-    if
-      (! l_codec->is_decompressor)
-    {
-      return l_codec->m_codec_data.m_compression.opj_start_compress(l_codec->m_codec,l_cio,p_image,&(l_codec->m_event_mgr));
-    }
-  }
-  return false;
-}
-
-bool OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec,opj_stream_t *p_cio)
-{
-  if
-    (p_codec && p_cio)
-  {
-    opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-    opj_stream_private_t * l_cio = (opj_stream_private_t *) p_cio;
-    if
-      (! l_codec->is_decompressor)
-    {
-      return l_codec->m_codec_data.m_compression.opj_end_compress(l_codec->m_codec,l_cio,&(l_codec->m_event_mgr));
-    }
-  }
-  return false;
-
-}
-
-bool OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data)
-{
-  opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-  if
-    (! l_codec)
-  {
-    return false;
-  }
-  l_codec->m_event_mgr.info_handler = p_callback;
-  l_codec->m_event_mgr.m_info_data = p_user_data;
-  return true;
-}
-
-bool OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data)
-{
-  opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-  if
-    (! l_codec)
-  {
-    return false;
-  }
-  l_codec->m_event_mgr.warning_handler = p_callback;
-  l_codec->m_event_mgr.m_warning_data = p_user_data;
-  return true;
-}
-
-bool OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data)
-{
-  opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
-  if
-    (! l_codec)
-  {
-    return false;
-  }
-  l_codec->m_event_mgr.error_handler = p_callback;
-  l_codec->m_event_mgr.m_error_data = p_user_data;
-  return true;
-}
-
-/*bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_stream_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
-  if(cinfo && cio && image) {
-    switch(cinfo->codec_format) {
-      case CODEC_J2K:
-        return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, (opj_stream_private_t *) cio, image, cstr_info);
-      case CODEC_JP2:
-        return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, (opj_stream_private_t *) cio, image, cstr_info);
-      case CODEC_JPT:
-      case CODEC_UNKNOWN:
-      default:
-        break;
-    }
-  }
-  return false;
-}*/
-
-void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
-  if
-    (cstr_info)
-  {
-    int tileno;
-    for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
-      opj_tile_info_t *tile_info = &cstr_info->tile[tileno];
-      opj_free(tile_info->thresh);
-      opj_free(tile_info->packet);
-      opj_free(tile_info->tp);
-    }
-    opj_free(cstr_info->tile);
-    opj_free(cstr_info->marker);
-  }
-}
-
-bool OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,OPJ_FLOAT32 * pEncodingMatrix,OPJ_INT32 * p_dc_shift,OPJ_UINT32 pNbComp)
-{
-  OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * sizeof(OPJ_FLOAT32);
-  OPJ_UINT32 l_dc_shift_size = pNbComp * sizeof(OPJ_INT32);
-  OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
-  // add MCT capability
-  int rsiz = (int)parameters->cp_rsiz | (int)MCT;
-  parameters->cp_rsiz = (OPJ_RSIZ_CAPABILITIES)rsiz;
-  parameters->irreversible = 1;
-  // use array based MCT
-  parameters->tcp_mct = 2;
-  parameters->mct_data = opj_malloc(l_mct_total_size);
-  if
-    (! parameters->mct_data)
-  {
-    return false;
-  }
-  memcpy(parameters->mct_data,pEncodingMatrix,l_matrix_size);
-  memcpy(((OPJ_BYTE *) parameters->mct_data) +  l_matrix_size,p_dc_shift,l_dc_shift_size);
-  return true;
-}
-
-/**
- * Restricts the decoding to the given image area.
- *
- * @param  parameters    the parameters to update.
- * @param  p_start_x    the starting x position of the area to decode.
- * @param  p_start_y    the starting y position of the area to decode.
- * @param  p_end_x      the x end position of the area to decode.
- * @param  p_end_x      the y end position of the area to decode.
- */
-OPJ_API bool OPJ_CALLCONV opj_restrict_decoding (opj_dparameters_t *parameters,OPJ_INT32 p_start_x,OPJ_INT32 p_start_y,OPJ_INT32 p_end_x,OPJ_INT32 p_end_y)
-{
-  parameters->m_use_restrict_decode = 1;
-  parameters->m_decode_start_x = p_start_x;
-  parameters->m_decode_start_y = p_start_y;
-  parameters->m_decode_end_x = p_end_x;
-  parameters->m_decode_end_y = p_end_y;
-  return true;
-}
-
-int j2k_get_reversible(
-  opj_j2k_t * p_j2k)
-{
-  opj_cp_t *cp = 00;
-  cp = &(p_j2k->m_cp);
-  return cp->tcps->tccps->qmfbid;
-}
-int jp2_get_reversible(
-  opj_jp2_t * p_jp2)
-{
-  return j2k_get_reversible(p_jp2->j2k);
-}
-
-int OPJ_CALLCONV opj_get_reversible(opj_codec_t *p_info, opj_dparameters_t *parameters)
-{
-  int ret = -1;
-  if (p_info)
-    {
-    opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
-    if (l_info->is_decompressor)
-      {
-      switch(parameters->decod_format)
-        {
-      case 0: // J2K_CFMT:
-        ret = j2k_get_reversible(l_info->m_codec);
-        break;
-      case 1: // JP2_CFMT:
-        ret = jp2_get_reversible(l_info->m_codec);
-        break;
-        }
-      }
-    }
-  return ret;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.h
deleted file mode 100644
index 74fefe3..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/openjpeg.h
+++ /dev/null
@@ -1,1072 +0,0 @@
- /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPENJPEG_H
-#define OPENJPEG_H
-
-#if defined(OPJ_STATIC) || (!defined(WIN32) && !defined(__MINGW32__)) || defined(__WIN32__)
-  #define OPJ_API
-  #define OPJ_CALLCONV
-#else
-  #define OPJ_CALLCONV __stdcall
-  #ifdef OPJ_EXPORTS
-    #define OPJ_API __declspec(dllexport)
-  #else
-    #define OPJ_API __declspec(dllimport)
-  #endif /* OPJ_EXPORTS */
-#endif /* !OPJ_STATIC || !WIN32 */
-
-#ifndef __cplusplus
-  #if defined(HAVE_STDBOOL_H)
-    #include <stdbool.h>
-  #else
-    #if !defined(bool)
-      #define  bool  int
-    #endif
-    #if !defined(true)
-      #define true  1
-    #endif
-    #if !defined(false)
-      #define  false  0
-    #endif
-  #endif
-#endif /* __cplusplus */
-typedef unsigned int  OPJ_UINT32;
-typedef int    OPJ_INT32;
-typedef unsigned short  OPJ_UINT16;
-typedef short    OPJ_INT16;
-typedef char    OPJ_CHAR;
-typedef unsigned char  OPJ_BYTE;
-typedef unsigned int  OPJ_SIZE_T;
-typedef double    OPJ_FLOAT64;
-typedef float    OPJ_FLOAT32;
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-  typedef __int64    OPJ_INT64;
-#else
-  typedef long long  OPJ_INT64;
-#endif
-
-#define OPENJPEG_VERSION "2.0.0"
-#include "openjpeg_mangle.h"
-/*
-==========================================================
-   Compiler directives
-==========================================================
-*/
-#include <stdio.h>
-
-
-
-
-
-/*
-==========================================================
-   Useful constant definitions
-==========================================================
-*/
-
-#define OPJ_PATH_LEN          4096 /**< Maximum allowed size for filenames */
-#define J2K_MAXRLVLS          33          /**< Number of maximum resolution level authorized */
-#define J2K_MAXBANDS          (3*J2K_MAXRLVLS-2)  /**< Number of maximum sub-band linked to number of resolution level */
-#define J2K_DEFAULT_NB_SEGS        10
-#define J2K_STREAM_CHUNK_SIZE      0x100000 /** 1 mega by default */
-#define J2K_DEFAULT_HEADER_SIZE      1000
-#define J2K_MCC_DEFAULT_NB_RECORDS    10
-#define J2K_MCT_DEFAULT_NB_RECORDS    10
-
-/* UniPG>> */
-#define JPWL_MAX_NO_TILESPECS  16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
-#define JPWL_MAX_NO_PACKSPECS  16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
-#define JPWL_MAX_NO_MARKERS  512 /**< Maximum number of JPWL markers: increase at your will */
-#define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
-#define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
-#define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
-#define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
-#define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
-/* <<UniPG */
-
-/*
-==========================================================
-   enum definitions
-==========================================================
-*/
-/**
-Rsiz Capabilities
-*/
-typedef enum RSIZ_CAPABILITIES {
-  STD_RSIZ = 0,    /** Standard JPEG2000 profile*/
-  CINEMA2K = 3,    /** Profile name for a 2K image*/
-  CINEMA4K = 4,    /** Profile name for a 4K image*/
-  MCT = 0x8100
-} OPJ_RSIZ_CAPABILITIES;
-
-/**
-Digital cinema operation mode
-*/
-typedef enum CINEMA_MODE {
-  OFF = 0,          /** Not Digital Cinema*/
-  CINEMA2K_24 = 1,  /** 2K Digital Cinema at 24 fps*/
-  CINEMA2K_48 = 2,  /** 2K Digital Cinema at 48 fps*/
-  CINEMA4K_24 = 3    /** 4K Digital Cinema at 24 fps*/
-}OPJ_CINEMA_MODE;
-
-/**
-Progression order
-*/
-typedef enum PROG_ORDER {
-  PROG_UNKNOWN = -1,  /**< place-holder */
-  LRCP = 0,    /**< layer-resolution-component-precinct order */
-  RLCP = 1,    /**< resolution-layer-component-precinct order */
-  RPCL = 2,    /**< resolution-precinct-component-layer order */
-  PCRL = 3,    /**< precinct-component-resolution-layer order */
-  CPRL = 4    /**< component-precinct-resolution-layer order */
-} OPJ_PROG_ORDER;
-
-/**
-Supported image color spaces
-*/
-typedef enum COLOR_SPACE {
-  CLRSPC_UNKNOWN = -1,  /**< not supported by the library */
-  CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */
-  CLRSPC_SRGB = 1,    /**< sRGB */
-  CLRSPC_GRAY = 2,    /**< grayscale */
-  CLRSPC_SYCC = 3      /**< YUV */
-} OPJ_COLOR_SPACE;
-
-/**
-Supported codec
-*/
-typedef enum CODEC_FORMAT {
-  CODEC_UNKNOWN = -1,  /**< place-holder */
-  CODEC_J2K = 0,    /**< JPEG-2000 codestream : read/write */
-  CODEC_JPT = 1,    /**< JPT-stream (JPEG 2000, JPIP) : read only */
-  CODEC_JP2 = 2    /**< JPEG-2000 file format : read/write */
-} OPJ_CODEC_FORMAT;
-
-
-
-
-/*
-==========================================================
-   event manager typedef definitions
-==========================================================
-*/
-
-/**
-Callback function prototype for events
- at param msg Event message
- at param client_data
-*/
-typedef void (*opj_msg_callback) (const OPJ_CHAR *msg, void *client_data);
-
-
-
-
-/*
-==========================================================
-   codec typedef definitions
-==========================================================
-*/
-
-/**
-Progression order changes
-*/
-typedef struct opj_poc
-{
-  /** Resolution num start, Component num start, given by POC */
-  OPJ_UINT32 resno0, compno0;
-  /** Layer num end,Resolution num end, Component num end, given by POC */
-  OPJ_UINT32 layno1, resno1, compno1;
-  /** Layer num start,Precinct num start, Precinct num end */
-  OPJ_UINT32 layno0, precno0, precno1;
-  /** Progression order enum*/
-  OPJ_PROG_ORDER prg1,prg;
-  /** Progression order string*/
-  OPJ_CHAR progorder[5];
-  /** Tile number */
-  OPJ_UINT32 tile;
-  /** Start and end values for Tile width and height*/
-  OPJ_INT32 tx0,tx1,ty0,ty1;
-  /** Start value, initialised in pi_initialise_encode*/
-  OPJ_UINT32 layS, resS, compS, prcS;
-  /** End value, initialised in pi_initialise_encode */
-  OPJ_UINT32 layE, resE, compE, prcE;
-  /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
-  OPJ_UINT32 txS,txE,tyS,tyE,dx,dy;
-  /** Temporary values for Tile parts, initialised in pi_create_encode */
-  OPJ_UINT32 lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
-} opj_poc_t;
-
-/**
-Compression parameters
-*/
-typedef struct opj_cparameters {
-  /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
-  bool tile_size_on;
-  /** XTOsiz */
-  int cp_tx0;
-  /** YTOsiz */
-  int cp_ty0;
-  /** XTsiz */
-  int cp_tdx;
-  /** YTsiz */
-  int cp_tdy;
-  /** allocation by rate/distortion */
-  int cp_disto_alloc;
-  /** allocation by fixed layer */
-  int cp_fixed_alloc;
-  /** add fixed_quality */
-  int cp_fixed_quality;
-  /** fixed layer */
-  int *cp_matrice;
-  /** comment for coding */
-  char *cp_comment;
-  /** csty : coding style */
-  int csty;
-  /** progression order (default LRCP) */
-  OPJ_PROG_ORDER prog_order;
-  /** progression order changes */
-  opj_poc_t POC[32];
-  /** number of progression order changes (POC), default to 0 */
-  int numpocs;
-  /** number of layers */
-  int tcp_numlayers;
-  /** rates of layers */
-  float tcp_rates[100];
-  /** different psnr for successive layers */
-  float tcp_distoratio[100];
-  /** number of resolutions */
-  int numresolution;
-  /** initial code block width, default to 64 */
-   int cblockw_init;
-  /** initial code block height, default to 64 */
-  int cblockh_init;
-  /** mode switch (cblk_style) */
-  int mode;
-  /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
-  int irreversible;
-  /** region of interest: affected component in [0..3], -1 means no ROI */
-  int roi_compno;
-  /** region of interest: upshift value */
-  int roi_shift;
-  /* number of precinct size specifications */
-  int res_spec;
-  /** initial precinct width */
-  int prcw_init[J2K_MAXRLVLS];
-  /** initial precinct height */
-  int prch_init[J2K_MAXRLVLS];
-
-  /**@name command line encoder parameters (not used inside the library) */
-  /*@{*/
-  /** input file name */
-  char infile[OPJ_PATH_LEN];
-  /** output file name */
-  char outfile[OPJ_PATH_LEN];
-  /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
-  int index_on;
-  /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
-  char index[OPJ_PATH_LEN];
-  /** subimage encoding: origin image offset in x direction */
-  int image_offset_x0;
-  /** subimage encoding: origin image offset in y direction */
-  int image_offset_y0;
-  /** subsampling value for dx */
-  int subsampling_dx;
-  /** subsampling value for dy */
-  int subsampling_dy;
-  /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
-  int decod_format;
-  /** output file format 0: J2K, 1: JP2, 2: JPT */
-  int cod_format;
-  /*@}*/
-
-/* UniPG>> */
-  /**@name JPWL encoding parameters */
-  /*@{*/
-  /** enables writing of EPC in MH, thus activating JPWL */
-  bool jpwl_epc_on;
-  /** error protection method for MH (0,1,16,32,37-128) */
-  int jpwl_hprot_MH;
-  /** tile number of header protection specification (>=0) */
-  int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-  /** error protection methods for TPHs (0,1,16,32,37-128) */
-  int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
-  /** tile number of packet protection specification (>=0) */
-  int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
-  /** packet number of packet protection specification (>=0) */
-  int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
-  /** error protection methods for packets (0,1,16,32,37-128) */
-  int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
-  /** enables writing of ESD, (0=no/1/2 bytes) */
-  int jpwl_sens_size;
-  /** sensitivity addressing size (0=auto/2/4 bytes) */
-  int jpwl_sens_addr;
-  /** sensitivity range (0-3) */
-  int jpwl_sens_range;
-  /** sensitivity method for MH (-1=no,0-7) */
-  int jpwl_sens_MH;
-  /** tile number of sensitivity specification (>=0) */
-  int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
-  /** sensitivity methods for TPHs (-1=no,0-7) */
-  int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
-  /*@}*/
-/* <<UniPG */
-
-  /** Digital Cinema compliance 0-not compliant, 1-compliant*/
-  OPJ_CINEMA_MODE cp_cinema;
-  /** Maximum rate for each component. If == 0, component size limitation is not considered */
-  int max_comp_size;
-  /** Profile name*/
-  OPJ_RSIZ_CAPABILITIES cp_rsiz;
-  /** Tile part generation*/
-  char tp_on;
-  /** Flag for Tile part generation*/
-  char tp_flag;
-  /** MCT (multiple component transform) */
-  char tcp_mct;
-  /** Naive implementation of MCT restricted to a single reversible array based encoding without offset concerning all the components. */
-  void * mct_data;
-
-} opj_cparameters_t;
-
-/**
-Decompression parameters
-*/
-typedef struct opj_dparameters {
-  /**
-  Set the number of highest resolution levels to be discarded.
-  The image resolution is effectively divided by 2 to the power of the number of discarded levels.
-  The reduce factor is limited by the smallest total number of decomposition levels among tiles.
-  if != 0, then original dimension divided by 2^(reduce);
-  if == 0 or not used, image is decoded to the full resolution
-  */
-  int cp_reduce;
-  /**
-  Set the maximum number of quality layers to decode.
-  If there are less quality layers than the specified number, all the quality layers are decoded.
-  if != 0, then only the first "layer" layers are decoded;
-  if == 0 or not used, all the quality layers are decoded
-  */
-  int cp_layer;
-
-  /**
-   * Restrictive decoding parameters.
-   */
-  OPJ_INT32 m_decode_start_x;
-  OPJ_INT32 m_decode_start_y ;
-  OPJ_INT32 m_decode_end_x ;
-  OPJ_INT32 m_decode_end_y ;
-
-  /**@name command line encoder parameters (not used inside the library) */
-  /*@{*/
-  /** input file name */
-  char infile[OPJ_PATH_LEN];
-  /** output file name */
-  char outfile[OPJ_PATH_LEN];
-  /** input file format 0: J2K, 1: JP2, 2: JPT */
-  int decod_format;
-  /** output file format 0: PGX, 1: PxM, 2: BMP */
-  int cod_format;
-  /*@}*/
-
-/* UniPG>> */
-  /**@name JPWL decoding parameters */
-  /*@{*/
-  /** activates the JPWL correction capabilities */
-  bool jpwl_correct;
-  /** expected number of components */
-  int jpwl_exp_comps;
-  /** maximum number of tiles */
-  int jpwl_max_tiles;
-
-  /** use restrictive decoding ? */
-  OPJ_UINT32 m_use_restrict_decode : 1;
-  /*@}*/
-/* <<UniPG */
-
-} opj_dparameters_t;
-
-/**
- * J2k codec.
- */
-typedef void * opj_codec_t;
-
-
-/*
-==========================================================
-   I/O stream typedef definitions
-==========================================================
-*/
-
-/*
- * Stream open flags.
- */
-/** The stream was opened for reading. */
-#define OPJ_STREAM_READ  0x0001
-/** The stream was opened for writing. */
-#define OPJ_STREAM_WRITE 0x0002
-
-
-typedef OPJ_UINT32 (* opj_stream_read_fn) (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data) ;
-typedef OPJ_UINT32 (* opj_stream_write_fn) (void * p_buffer, OPJ_UINT32 p_nb_bytes, void * p_user_data) ;
-typedef OPJ_SIZE_T (* opj_stream_skip_fn) (OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
-typedef bool (* opj_stream_seek_fn) (OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
-
-
-typedef void * opj_stream_t;
-
-/*
-==========================================================
-   image typedef definitions
-==========================================================
-*/
-
-/**
-Defines a single image component
-*/
-typedef struct opj_image_comp {
-  /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
-  OPJ_UINT32 dx;
-  /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-  OPJ_UINT32 dy;
-  /** data width */
-  OPJ_UINT32 w;
-  /** data height */
-  OPJ_UINT32 h;
-  /** x component offset compared to the whole image */
-  OPJ_INT32 x0;
-  /** y component offset compared to the whole image */
-  OPJ_INT32 y0;
-  /** precision */
-  OPJ_UINT32 prec;
-  /** number of decoded resolution */
-  OPJ_UINT32 resno_decoded;
-  /** number of division by 2 of the out image compared to the original size of image */
-  OPJ_UINT32 factor;
-  /** image component data */
-  int *data;
-  /** signed (1) / unsigned (0) */
-  OPJ_UINT32 sgnd : 1;
-
-} opj_image_comp_t;
-
-/**
-Defines image data and characteristics
-*/
-typedef struct opj_image
-{
-  /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
-  OPJ_INT32 x0;
-  /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
-  OPJ_INT32 y0;
-  /** Xsiz: width of the reference grid */
-  OPJ_INT32 x1;
-  /** Ysiz: height of the reference grid */
-  OPJ_INT32 y1;
-  /** number of components in the image */
-  OPJ_UINT32 numcomps;
-  /** color space: sRGB, Greyscale or YUV */
-  OPJ_COLOR_SPACE color_space;
-  /** image components */
-  opj_image_comp_t *comps;
-} opj_image_t;
-
-/**
-Component parameters structure used by the opj_image_create function
-*/
-typedef struct opj_image_comptparm {
-  /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
-  unsigned int dx;
-  /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
-  unsigned int dy;
-  /** data width */
-  unsigned int w;
-  /** data height */
-  unsigned int h;
-  /** x component offset compared to the whole image */
-  int x0;
-  /** y component offset compared to the whole image */
-  int y0;
-  /** precision */
-  int prec;
-  /** image depth in bits */
-  int bpp;
-  /** signed (1) / unsigned (0) */
-  int sgnd;
-} opj_image_cmptparm_t;
-
-/*
-==========================================================
-   Information on the JPEG 2000 codestream
-==========================================================
-*/
-
-/**
-Index structure : Information concerning a packet inside tile
-*/
-typedef struct opj_packet_info {
-  /** packet start position (including SOP marker if it exists) */
-  int start_pos;
-  /** end of packet header position (including EPH marker if it exists)*/
-  int end_ph_pos;
-  /** packet end position */
-  int end_pos;
-  /** packet distorsion */
-  double disto;
-} opj_packet_info_t;
-
-/**
-Index structure : Information concerning tile-parts
-*/
-typedef struct opj_tp_info {
-  /** start position of tile part */
-  int tp_start_pos;
-  /** end position of tile part header */
-  int tp_end_header;
-  /** end position of tile part */
-  int tp_end_pos;
-  /** start packet of tile part */
-  int tp_start_pack;
-  /** number of packets of tile part */
-  int tp_numpacks;
-} opj_tp_info_t;
-
-/**
-Index structure : information regarding tiles
-*/
-typedef struct opj_tile_info {
-  /** value of thresh for each layer by tile cfr. Marcela   */
-  double *thresh;
-  /** number of tile */
-  int tileno;
-  /** start position */
-  int start_pos;
-  /** end position of the header */
-  int end_header;
-  /** end position */
-  int end_pos;
-  /** precinct number for each resolution level (width) */
-  int pw[33];
-  /** precinct number for each resolution level (height) */
-  int ph[33];
-  /** precinct size (in power of 2), in X for each resolution level */
-  int pdx[33];
-  /** precinct size (in power of 2), in Y for each resolution level */
-  int pdy[33];
-  /** information concerning packets inside tile */
-  opj_packet_info_t *packet;
-  /** add fixed_quality */
-  int numpix;
-  /** add fixed_quality */
-  double distotile;
-  /** number of tile parts */
-  int num_tps;
-  /** information concerning tile parts */
-  opj_tp_info_t *tp;
-} opj_tile_info_t;
-
-/* UniPG>> */
-/**
-Marker structure
-*/
-typedef struct opj_marker_info_t {
-  /** marker type */
-  unsigned short int type;
-  /** position in codestream */
-  int pos;
-  /** length, marker val included */
-  int len;
-} opj_marker_info_t;
-/* <<UniPG */
-
-/**
-Index structure of the codestream
-*/
-typedef struct opj_codestream_info {
-  /** maximum distortion reduction on the whole image (add for Marcela) */
-  double D_max;
-  /** packet number */
-  int packno;
-  /** writing the packet in the index with t2_encode_packets */
-  int index_write;
-  /** image width */
-  int image_w;
-  /** image height */
-  int image_h;
-  /** progression order */
-  OPJ_PROG_ORDER prog;
-  /** tile size in x */
-  int tile_x;
-  /** tile size in y */
-  int tile_y;
-  /** */
-  int tile_Ox;
-  /** */
-  int tile_Oy;
-  /** number of tiles in X */
-  int tw;
-  /** number of tiles in Y */
-  int th;
-  /** component numbers */
-  int numcomps;
-  /** number of layer */
-  int numlayers;
-  /** number of decomposition for each component */
-  int *numdecompos;
-/* UniPG>> */
-  /** number of markers */
-  int marknum;
-  /** list of markers */
-  opj_marker_info_t *marker;
-  /** actual size of markers array */
-  int maxmarknum;
-/* <<UniPG */
-  /** main header position */
-  int main_head_start;
-  /** main header position */
-  int main_head_end;
-  /** codestream's size */
-  int codestream_size;
-  /** information regarding tiles inside image */
-  opj_tile_info_t *tile;
-} opj_codestream_info_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*
-==========================================================
-   openjpeg version
-==========================================================
-*/
-
-OPJ_API const OPJ_CHAR * OPJ_CALLCONV opj_version(void);
-
-/*
-==========================================================
-   image functions definitions
-==========================================================
-*/
-
-/**
-Create an image
- at param numcmpts number of components
- at param cmptparms components parameters
- at param clrspc image color space
- at return returns a new image structure if successful, returns NULL otherwise
-*/
-OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
-
-/**
- * Creates an image without allocating memory for the image (used in the new version of the library).
- *
- * @param  p_num_cmpts      the number of components
- * @param  p_cmpt_parms    the components parameters
- * @param  p_clr_spc      the image color space
- *
- * @return  a new image structure if successful, NULL otherwise.
-*/
-OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
-
-/**
-Deallocate any resources associated with an image
- at param image image to be destroyed
-*/
-OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
-
-/*
-==========================================================
-   stream functions definitions
-==========================================================
-*/
-
-/**
- * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
- *
- * @param  l_is_reader    if set to true then the stream will be an input stream, an output stream else.
- *
- * @return  a stream object.
-*/
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(bool p_is_input);
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_UINT32 p_size,bool p_is_input);
-
-/**
- * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
- * close its own implementation of the stream.
- *
- * @param  p_stream  the stream to destroy.
- */
-OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
-
-/**
- * Sets the given function to be used as a read function.
- * @param    p_stream  the stream to modify
- * @param    p_function  the function to use a read function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function);
-
-/**
- * Sets the given function to be used as a write function.
- * @param    p_stream  the stream to modify
- * @param    p_function  the function to use a write function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function);
-
-/**
- * Sets the given function to be used as a skip function.
- * @param    p_stream  the stream to modify
- * @param    p_function  the function to use a skip function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function);
-
-/**
- * Sets the given function to be used as a seek function, the stream is then seekable.
- * @param    p_stream  the stream to modify
- * @param    p_function  the function to use a skip function.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function);
-
-
-/**
- * Sets the given data to be used as a user data for the stream.
- * @param    p_stream  the stream to modify
- * @param    p_data    the data to set.
-*/
-OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data);
-
-/**
- * Helper function.
- * Sets the stream to be a file stream. The FILE must have been open previously.
- * @param    p_stream  the stream to modify
- * @param    p_file    handler to an already open file.
-*/
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (FILE * p_file,bool p_is_read_stream);
-OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (FILE * p_file,OPJ_UINT32 p_buffer_size, bool p_is_read_stream);
-
-
-
-/*
-==========================================================
-   event manager functions definitions
-==========================================================
-*/
-OPJ_API bool OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data);
-OPJ_API bool OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data);
-OPJ_API bool OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data);
-
-
-
-/*
-==========================================================
-   codec functions definitions
-==========================================================
-*/
-/**
-Creates a J2K/JPT/JP2 decompression structure
- at param format Decoder to select
- at return Returns a handle to a decompressor if successful, returns NULL otherwise
-*/
-OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
-
-/**
-Set decoding parameters to default values
- at param parameters Decompression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
-
-#define USE_OPJ_DEPRECATED
-#ifdef USE_OPJ_DEPRECATED
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in j2k->cp.
- at param dinfo decompressor handle
- at param parameters decompression parameters
-*/
-OPJ_API bool OPJ_CALLCONV opj_setup_decoder(opj_codec_t *dinfo, opj_dparameters_t *parameters);
-#endif
-
-/**
-Decode an image from a JPEG-2000 codestream
- at param dinfo decompressor handle
- at param cio Input buffer stream
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor, opj_stream_t * cio);
-
-OPJ_API int OPJ_CALLCONV opj_get_reversible(opj_codec_t *p_decompressor, opj_dparameters_t *parameters);
-
-/**
- * Writes a tile with the given data.
- *
- * @param  p_compressor    the jpeg2000 codec.
- * @param  p_tile_index    the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
- * @param  p_data        pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
- * @param  p_data_size      this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes,
- *                depending on the precision of the given component.
- * @param  p_stream      the stream to write data to.
- *
- * @return  true if the data could be written.
- */
-OPJ_API bool OPJ_CALLCONV opj_write_tile (
-           opj_codec_t *p_codec,
-           OPJ_UINT32 p_tile_index,
-           OPJ_BYTE * p_data,
-           OPJ_UINT32 p_data_size,
-           opj_stream_t *p_stream
-          );
-
-/**
- * Reads a tile header. This function is compulsory and allows one to know the size of the tile thta will be decoded.
- * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
- *
- * @param  p_codec      the jpeg2000 codec.
- * @param  p_tile_index  pointer to a value that will hold the index of the tile being decoded, in case of success.
- * @param  p_data_size    pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
- *              of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
- *              as depicted in opj_write_tile.
- * @param  p_tile_x0    pointer to a value that will hold the x0 pos of the tile (in the image).
- * @param  p_tile_y0    pointer to a value that will hold the y0 pos of the tile (in the image).
- * @param  p_tile_x1    pointer to a value that will hold the x1 pos of the tile (in the image).
- * @param  p_tile_y1    pointer to a value that will hold the y1 pos of the tile (in the image).
- * @param  p_nb_comps    pointer to a value that will hold the number of components in the tile.
- * @param  p_should_go_on  pointer to a boolean that will hold the fact that the decoding should go on. In case the
- *              codestream is over at the time of the call, the value will be set to false. The user should then stop
- *              the decoding.
- * @param  p_stream    the stream to decode.
- * @return  true      if the tile header could be decoded. In case the decoding should end, the returned value is still true.
- *              returning false may be the result of a shortage of memory or an internal error.
- */
-OPJ_API bool OPJ_CALLCONV opj_read_tile_header(
-          opj_codec_t *p_codec,
-          OPJ_UINT32 * p_tile_index,
-          OPJ_UINT32 * p_data_size,
-          OPJ_INT32 * p_tile_x0,
-          OPJ_INT32 * p_tile_y0,
-          OPJ_INT32 * p_tile_x1,
-          OPJ_INT32 * p_tile_y1,
-          OPJ_UINT32 * p_nb_comps,
-          bool * p_should_go_on,
-          opj_stream_t * p_stream);
-
-
-/**
- * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
- * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
- *
- * @param  p_codec      the jpeg2000 codec.
- * @param  p_tile_index  the index of the tile being decoded, this should be the value set by opj_read_tile_header.
- * @param  p_data      pointer to a memory block that will hold the decoded data.
- * @param  p_data_size    size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
- * @param  p_stream    the stream to decode.
- *
- * @return  true      if the data could be decoded.
- */
-OPJ_API bool OPJ_CALLCONV opj_decode_tile_data(
-          opj_codec_t *p_codec,
-          OPJ_UINT32 p_tile_index,
-          OPJ_BYTE * p_data,
-          OPJ_UINT32 p_data_size,
-          opj_stream_t *p_stream
-          );
-
-/**
- * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
- *
- * @param  p_codec      the jpeg2000 codec.
- * @param  p_start_x    the left position of the rectangle to decode (in image coordinates).
- * @param  p_end_x      the right position of the rectangle to decode (in image coordinates).
- * @param  p_start_y    the up position of the rectangle to decode (in image coordinates).
- * @param  p_end_y      the bottom position of the rectangle to decode (in image coordinates).
- *
- * @return  true      if the area could be set.
- */
-OPJ_API bool OPJ_CALLCONV opj_set_decode_area(
-          opj_codec_t *p_codec,
-          OPJ_INT32 p_start_x,
-          OPJ_INT32 p_start_y,
-          OPJ_INT32 p_end_x,
-          OPJ_INT32 p_end_y
-          );
-
-
-/**
-Decode an image from a JPEG-2000 codestream and extract the codestream information
- at param dinfo decompressor handle
- at param cio Input buffer stream
- at param cstr_info Codestream information structure if needed afterwards, NULL otherwise
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-//OPJ_API opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_stream_t cio, opj_codestream_info_t *cstr_info);
-/**
-Creates a J2K/JP2 compression structure
- at param format Coder to select
- at return Returns a handle to a compressor if successful, returns NULL otherwise
-*/
-OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
-
-/**
-Destroy a decompressor handle
- at param dinfo decompressor handle to destroy
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);
-
-/**
-Set encoding parameters to default values, that means :
-<ul>
-<li>Lossless
-<li>1 tile
-<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
-<li>Size of code-block : 64 x 64
-<li>Number of resolutions: 6
-<li>No SOP marker in the codestream
-<li>No EPH marker in the codestream
-<li>No sub-sampling in x or y direction
-<li>No mode switch activated
-<li>Progression order: LRCP
-<li>No index file
-<li>No ROI upshifted
-<li>No offset of the origin of the image
-<li>No offset of the origin of the tiles
-<li>Reversible DWT 5-3
-</ul>
- at param parameters Compression parameters
-*/
-OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
-
-/**
- * Sets the MCT matrix to use.
- *
- * @param  parameters    the parameters to change.
- * @param  pEncodingMatrix  the encoding matrix.
- * @param  p_dc_shift    the dc shift coefficients to use.
- * @param  pNbComp      the number of components of the image.
- *
- * @return  true if the parameters could be set.
- */
-OPJ_API bool OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,OPJ_FLOAT32 * pEncodingMatrix,OPJ_INT32 * p_dc_shift,OPJ_UINT32 pNbComp);
-
-/**
- * Restricts the decoding to the given image area.
- *
- * @param  parameters    the parameters to update.
- * @param  p_start_x    the starting x position of the area to decode.
- * @param  p_start_y    the starting y position of the area to decode.
- * @param  p_end_x      the x end position of the area to decode.
- * @param  p_end_x      the y end position of the area to decode.
- */
-OPJ_API bool OPJ_CALLCONV opj_restrict_decoding (opj_dparameters_t *parameters,OPJ_INT32 p_start_x,OPJ_INT32 p_start_y,OPJ_INT32 p_end_x,OPJ_INT32 p_end_y);
-
-#ifdef USE_OPJ_DEPRECATED
-/**
-Setup the encoder parameters using the current image and using user parameters.
- at param cinfo Compressor handle
- at param parameters Compression parameters
- at param image Input filled image
-*/
-OPJ_API bool OPJ_CALLCONV opj_setup_encoder(opj_codec_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
-#endif
-
-/**
- * Decodes an image header.
- *
- * @param  p_codec      codec to use to decode the image.
- * @param  p_image      pointer to a previously created image.
- * @param  p_tile_x0    pointer to a value that will hold the reference point x0 of the tiling grid.
- * @param  p_tile_y0    pointer to a value that will hold the reference point y0 of the tiling grid.
- * @param  p_tile_width  pointer to a value that will hold the size in x of a tile in the grid.
- * @param  p_tile_height  pointer to a value that will hold the size in y of a tile in the grid.
- * @param  p_nb_tiles_x  pointer to a value that will hold the number of tiles in the x direction.
- * @param  p_nb_tiles_y  pointer to a value that will hold the number of tiles in the y direction.
- */
-OPJ_API bool OPJ_CALLCONV opj_read_header (
-                    opj_codec_t *p_codec,
-                    opj_image_t ** p_image,
-                    OPJ_INT32 * p_tile_x0,
-                    OPJ_INT32 * p_tile_y0,
-                    OPJ_UINT32 * p_tile_width,
-                    OPJ_UINT32 * p_tile_height,
-                    OPJ_UINT32 * p_nb_tiles_x,
-                    OPJ_UINT32 * p_nb_tiles_y,
-                    opj_stream_t *p_cio);
-
-
-OPJ_API bool OPJ_CALLCONV opj_end_decompress (opj_codec_t *p_codec,opj_stream_t *p_cio);
-/**
-Encode an image into a JPEG-2000 codestream
- at param cinfo compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
- at return Returns true if successful, returns false otherwise
-*/
-OPJ_API bool OPJ_CALLCONV opj_encode(opj_codec_t *cinfo, opj_stream_t * cio);
-
-OPJ_API bool OPJ_CALLCONV opj_start_compress (opj_codec_t *p_codec,opj_image_t * p_image,opj_stream_t *p_cio);
-
-OPJ_API bool OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec,opj_stream_t *p_cio);
-/**
-Encode an image into a JPEG-2000 codestream and extract the codestream information
- at param cinfo compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param cstr_info Codestream information structure if needed afterwards, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-//OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_stream_t cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
-/**
-Destroy Codestream information after compression or decompression
- at param cstr_info Codestream information structure
-*/
-OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
-
-//==============================================================================
-//==============================================================================
-/** profiling part */
-#ifdef _PROFILE
-void _ProfInit(void);
-void _ProfPrint(void);
-#define PROFINIT() _ProfInit();
-#define PROFSAVE(file) _ProfSave(file);
-#define PROFPRINT() _ProfPrint();
-#else
-#define PROFINIT()
-#define PROFSAVE(file)
-#define PROFPRINT()
-#endif // !_PROFILE
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPENJPEG_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_configure.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_configure.h
deleted file mode 100644
index 7d7c63a..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_configure.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * here is where system comupted values get stored these values should only
- * change when the target compile platform changes
- */
-
-/* what byte order */
-#ifndef __OPJ_CONFIGURE_H
-#define __OPJ_CONFIGURE_H
-/* #undef CMAKE_WORDS_BIGENDIAN */
-#ifdef CMAKE_WORDS_BIGENDIAN
-        #define OPJ_BIG_ENDIAN
-#else
-        #define OPJ_LITTLE_ENDIAN
-#endif
-
-#endif /* __OPJ_CONFIGURE_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_includes.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_includes.h
deleted file mode 100644
index e75a220..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_includes.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef OPJ_INCLUDES_H
-#define OPJ_INCLUDES_H
-
-/*
- ==========================================================
-   Standard includes used by the library
- ==========================================================
-*/
-#include <memory.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <float.h>
-#include <time.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <assert.h>
-
-/*
- ==========================================================
-   OpenJPEG interface
- ==========================================================
- */
-
-/*
- ==========================================================
-   OpenJPEG modules
- ==========================================================
-*/
-
-/* Ignore GCC attributes if this is not GCC */
-#ifndef __GNUC__
-  #define __attribute__(x) /* __attribute__(x) */
-#endif
-
-/*
-The inline keyword is supported by C99 but not by C90.
-Most compilers implement their own version of this keyword ...
-*/
-#ifndef INLINE
-  #if defined(_MSC_VER)
-    #define INLINE __inline
-  #elif defined(__GNUC__)
-    #define INLINE __inline__
-  #elif defined(__MWERKS__)
-    #define INLINE inline
-  #else
-    /* add other compilers here ... */
-    #define INLINE
-  #endif /* defined(<Compiler>) */
-#endif /* INLINE */
-
-/* Are restricted pointers available? (C99) */
-#if (__STDC_VERSION__ != 199901L)
-  /* Not a C99 compiler */
-  #ifdef __GNUC__
-    #define restrict __restrict__
-  #else
-    #define restrict /* restrict */
-  #endif
-#endif
-
-/* MSVC and Borland C do not have lrintf */
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-
-/* MSVC 64bits doesn't support _asm */
-#if !defined(_WIN64)
-static INLINE long lrintf(float f){
-  int i;
-
-  _asm{
-    fld f
-    fistp i
-  };
-
-  return i;
-}
-#else
-static INLINE long lrintf(float x){
-  long r;
-  if (x>=0.f)
-  {
-     x+=0.5f;
-  }
-  else
-  {
-     x-=0.5f;
-  }
-  r = (long)(x);
-  if ( x != (float)(r) ) return r;
-  return 2*(r/2);
-}
-#endif
-
-#endif
-
-#endif /* OPJ_INCLUDES_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_malloc.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_malloc.h
deleted file mode 100644
index ebb3c85..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/opj_malloc.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2005, Hervé Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __OPJ_MALLOC_H
-#define __OPJ_MALLOC_H
-/**
- at file opj_malloc.h
- at brief Internal functions
-
-The functions in opj_malloc.h are internal utilities used for memory management.
-*/
-#include "openjpeg.h"
-#include "opj_includes.h"
-/** @defgroup MISC MISC - Miscellaneous internal functions */
-/*@{*/
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Allocate an uninitialized memory block
- at param size Bytes to allocate
- at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-#define opj_malloc(size)    malloc(size)
-#define my_opj_malloc(size)    malloc(size)
-
-/**
-Allocate a memory block with elements initialized to 0
- at param num Blocks to allocate
- at param size Bytes per block to allocate
- at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-#define opj_calloc(num, size) calloc(num, size)
-
-/**
-Allocate memory aligned to a 16 byte boundry
- at param size Bytes to allocate
- at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
-#ifdef WIN32
-  /* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
-  #ifdef __GNUC__
-    #include <mm_malloc.h>
-    #define HAVE_MM_MALLOC
-  #else /* MSVC, Intel C++ */
-    #include <malloc.h>
-    #ifdef _mm_malloc
-      #define HAVE_MM_MALLOC
-    #endif
-  #endif
-#else /* Not WIN32 */
-  #if defined(__sun)
-    #define HAVE_MEMALIGN
-  /* Linux x86_64 and OSX always align allocations to 16 bytes */
-  #elif !defined(__amd64__) && !defined(__APPLE__) && !defined(__ANDROID__)
-    /* FIXME: Yes, this is a big assumption */
-    #define HAVE_POSIX_MEMALIGN
-  #endif
-#endif
-
-#define opj_aligned_malloc(size) malloc(size)
-#define opj_aligned_free(m) free(m)
-
-#ifdef HAVE_MM_MALLOC
-  #undef opj_aligned_malloc
-  #define opj_aligned_malloc(size) _mm_malloc(size, 16)
-  #undef opj_aligned_free
-  #define opj_aligned_free(m) _mm_free(m)
-#endif
-
-#ifdef HAVE_MEMALIGN
-  extern void* memalign(size_t, size_t);
-  #undef opj_aligned_malloc
-  #define opj_aligned_malloc(size) memalign(16, (size))
-  #undef opj_aligned_free
-  #define opj_aligned_free(m) free(m)
-#endif
-
-#ifdef HAVE_POSIX_MEMALIGN
-  #undef opj_aligned_malloc
-  extern int posix_memalign(void**, size_t, size_t);
-
-  static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
-    void* mem = NULL;
-    posix_memalign(&mem, 16, size);
-    return mem;
-  }
-  #undef opj_aligned_free
-  #define opj_aligned_free(m) free(m)
-#endif
-
-/**
-Reallocate memory blocks.
- at param memblock Pointer to previously allocated memory block
- at param size New size in bytes
- at return Returns a void pointer to the reallocated (and possibly moved) memory block
-*/
-#define opj_realloc(m, s)    realloc(m, s)
-#define my_opj_realloc(m,s)    realloc(m,s)
-
-
-/**
-Deallocates or frees a memory block.
- at param memblock Previously allocated memory block to be freed
-*/
-#define opj_free(m) free(m)
-
-#ifdef __GNUC__
-#pragma GCC poison malloc calloc realloc free
-#endif
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __OPJ_MALLOC_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/pi.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/pi.c
deleted file mode 100644
index d8c7252..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/pi.c
+++ /dev/null
@@ -1,2000 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "pi.h"
-#include "int.h"
-#include "opj_malloc.h"
-#include "j2k.h"
-/** @defgroup PI PI - Implementation of a packet iterator */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Get next packet in layer-resolution-component-precinct order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true
-*/
-static bool pi_next_lrcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-layer-component-precinct order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true
-*/
-static bool pi_next_rlcp(opj_pi_iterator_t * pi);
-/**
-Get next packet in resolution-precinct-component-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true
-*/
-static bool pi_next_rpcl(opj_pi_iterator_t * pi);
-/**
-Get next packet in precinct-component-resolution-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true
-*/
-static bool pi_next_pcrl(opj_pi_iterator_t * pi);
-/**
-Get next packet in component-precinct-resolution-layer order.
- at param pi packet iterator to modify
- at return returns false if pi pointed to the last packet or else returns true
-*/
-static bool pi_next_cprl(opj_pi_iterator_t * pi);
-
-/**
- * Updates the coding parameters if the encoding is used with Progression order changes and final (or cinema parameters are used).
- *
- * @param  p_cp    the coding parameters to modify
- * @param  p_tileno  the tile index being concerned.
- * @param  p_tx0    X0 parameter for the tile
- * @param  p_tx1    X1 parameter for the tile
- * @param  p_ty0    Y0 parameter for the tile
- * @param  p_ty1    Y1 parameter for the tile
- * @param  p_max_prec  the maximum precision for all the bands of the tile
- * @param  p_max_res  the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min    the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min    the minimum dy of all the components of all the resolutions for the tile.
- */
-void pi_update_encode_poc_and_final (
-                   opj_cp_t *p_cp,
-                   OPJ_UINT32 p_tileno,
-                   OPJ_INT32 p_tx0,
-                   OPJ_INT32 p_tx1,
-                   OPJ_INT32 p_ty0,
-                   OPJ_INT32 p_ty1,
-                   OPJ_UINT32 p_max_prec,
-                   OPJ_UINT32 p_max_res,
-                                     OPJ_UINT32 p_dx_min,
-                   OPJ_UINT32 p_dy_min);
-
-/**
- * Updates the coding parameters if the encoding is not used with Progression order changes and final (and cinema parameters are used).
- *
- * @param  p_cp    the coding parameters to modify
- * @param  p_tileno  the tile index being concerned.
- * @param  p_tx0    X0 parameter for the tile
- * @param  p_tx1    X1 parameter for the tile
- * @param  p_ty0    Y0 parameter for the tile
- * @param  p_ty1    Y1 parameter for the tile
- * @param  p_max_prec  the maximum precision for all the bands of the tile
- * @param  p_max_res  the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min    the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min    the minimum dy of all the components of all the resolutions for the tile.
- */
-void pi_update_encode_not_poc (
-                opj_cp_t *p_cp,
-                OPJ_UINT32 p_num_comps,
-                OPJ_UINT32 p_tileno,
-                OPJ_INT32 p_tx0,
-                OPJ_INT32 p_tx1,
-                OPJ_INT32 p_ty0,
-                OPJ_INT32 p_ty1,
-                OPJ_UINT32 p_max_prec,
-                OPJ_UINT32 p_max_res,
-                                OPJ_UINT32 p_dx_min,
-                OPJ_UINT32 p_dy_min);
-
-/**
- * Gets the encoding parameters needed to update the coding parameters and all the pocs.
- *
- * @param  p_image      the image being encoded.
- * @param  p_cp      the coding parameters.
- * @param  tileno      the tile index of the tile being encoded.
- * @param  p_tx0      pointer that will hold the X0 parameter for the tile
- * @param  p_tx1      pointer that will hold the X1 parameter for the tile
- * @param  p_ty0      pointer that will hold the Y0 parameter for the tile
- * @param  p_ty1      pointer that will hold the Y1 parameter for the tile
- * @param  p_max_prec    pointer that will hold the the maximum precision for all the bands of the tile
- * @param  p_max_res    pointer that will hold the the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min      pointer that will hold the the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min      pointer that will hold the the minimum dy of all the components of all the resolutions for the tile.
- */
-void get_encoding_parameters(
-                const opj_image_t *p_image,
-                const opj_cp_t *p_cp,
-                OPJ_UINT32  tileno,
-                OPJ_INT32  * p_tx0,
-                OPJ_INT32 * p_tx1,
-                OPJ_INT32 * p_ty0,
-                OPJ_INT32 * p_ty1,
-                OPJ_UINT32 * p_dx_min,
-                OPJ_UINT32 * p_dy_min,
-                OPJ_UINT32 * p_max_prec,
-                OPJ_UINT32 * p_max_res
-              );
-
-/**
- * Gets the encoding parameters needed to update the coding parameters and all the pocs.
- * The precinct widths, heights, dx and dy for each component at each resolution will be stored as well.
- * the last parameter of the function should be an array of pointers of size nb components, each pointer leading
- * to an area of size 4 * max_res. The data is stored inside this area with the following pattern :
- * dx_compi_res0 , dy_compi_res0 , w_compi_res0, h_compi_res0 , dx_compi_res1 , dy_compi_res1 , w_compi_res1, h_compi_res1 , ...
- *
- * @param  p_image      the image being encoded.
- * @param  p_cp      the coding parameters.
- * @param  tileno      the tile index of the tile being encoded.
- * @param  p_tx0      pointer that will hold the X0 parameter for the tile
- * @param  p_tx1      pointer that will hold the X1 parameter for the tile
- * @param  p_ty0      pointer that will hold the Y0 parameter for the tile
- * @param  p_ty1      pointer that will hold the Y1 parameter for the tile
- * @param  p_max_prec    pointer that will hold the the maximum precision for all the bands of the tile
- * @param  p_max_res    pointer that will hold the the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min      pointer that will hold the the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min      pointer that will hold the the minimum dy of all the components of all the resolutions for the tile.
- * @param  p_resolutions  pointer to an area corresponding to the one described above.
- */
-void get_all_encoding_parameters(
-                const opj_image_t *p_image,
-                const opj_cp_t *p_cp,
-                OPJ_UINT32 tileno,
-                OPJ_INT32 * p_tx0,
-                OPJ_INT32 * p_tx1,
-                OPJ_INT32 * p_ty0,
-                OPJ_INT32 * p_ty1,
-                OPJ_UINT32 * p_dx_min,
-                OPJ_UINT32 * p_dy_min,
-                OPJ_UINT32 * p_max_prec,
-                OPJ_UINT32 * p_max_res,
-                OPJ_UINT32 ** p_resolutions
-              );
-/**
- * Allocates memory for a packet iterator. Data and data sizes are set by this operation.
- * No other data is set. The include section of the packet  iterator is not allocated.
- *
- * @param  p_image    the image used to initialize the packet iterator (in fact only the number of components is relevant.
- * @param  p_cp    the coding parameters.
- * @param  p_tile_no  the index of the tile from which creating the packet iterator.
- */
-opj_pi_iterator_t * pi_create(
-                const opj_image_t *image,
-                const opj_cp_t *cp,
-                OPJ_UINT32 tileno
-              );
-void pi_update_decode_not_poc (opj_pi_iterator_t * p_pi,opj_tcp_t * p_tcp,OPJ_UINT32 p_max_precision,OPJ_UINT32 p_max_res);
-void pi_update_decode_poc (opj_pi_iterator_t * p_pi,opj_tcp_t * p_tcp,OPJ_UINT32 p_max_precision,OPJ_UINT32 p_max_res);
-
-
-/*@}*/
-
-/*@}*/
-
-/*
-==========================================================
-   local functions
-==========================================================
-*/
-
-static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
-  opj_pi_comp_t *comp = 00;
-  opj_pi_resolution_t *res = 00;
-  OPJ_UINT32 index = 0;
-
-  if (!pi->first) {
-    comp = &pi->comps[pi->compno];
-    res = &comp->resolutions[pi->resno];
-    goto LABEL_SKIP;
-  } else {
-    pi->first = 0;
-  }
-
-  for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-    for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
-    pi->resno++) {
-      for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-        comp = &pi->comps[pi->compno];
-        if (pi->resno >= comp->numresolutions) {
-          continue;
-        }
-        res = &comp->resolutions[pi->resno];
-        if (!pi->tp_on){
-          pi->poc.precno1 = res->pw * res->ph;
-        }
-        for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
-          index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-          if (!pi->include[index]) {
-            pi->include[index] = 1;
-            return true;
-          }
-LABEL_SKIP:;
-        }
-      }
-    }
-  }
-
-  return false;
-}
-
-static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
-  opj_pi_comp_t *comp = 00;
-  opj_pi_resolution_t *res = 00;
-  OPJ_UINT32 index = 0;
-
-  if (!pi->first) {
-    comp = &pi->comps[pi->compno];
-    res = &comp->resolutions[pi->resno];
-    goto LABEL_SKIP;
-  } else {
-    pi->first = 0;
-  }
-
-  for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-    for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-      for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-        comp = &pi->comps[pi->compno];
-        if (pi->resno >= comp->numresolutions) {
-          continue;
-        }
-        res = &comp->resolutions[pi->resno];
-        if(!pi->tp_on){
-          pi->poc.precno1 = res->pw * res->ph;
-        }
-        for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
-          index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-          if (!pi->include[index]) {
-            pi->include[index] = 1;
-            return true;
-          }
-LABEL_SKIP:;
-        }
-      }
-    }
-  }
-
-  return false;
-}
-
-static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
-  opj_pi_comp_t *comp = 00;
-  opj_pi_resolution_t *res = 00;
-  OPJ_UINT32 index = 0;
-
-  if (!pi->first) {
-    goto LABEL_SKIP;
-  } else {
-    OPJ_UINT32 compno, resno;
-    pi->first = 0;
-    pi->dx = 0;
-    pi->dy = 0;
-    for (compno = 0; compno < pi->numcomps; compno++) {
-      comp = &pi->comps[compno];
-      for (resno = 0; resno < comp->numresolutions; resno++) {
-        OPJ_UINT32 dx, dy;
-        res = &comp->resolutions[resno];
-        dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-        dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-        pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-        pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-      }
-    }
-  }
-if (!pi->tp_on){
-      pi->poc.ty0 = pi->ty0;
-      pi->poc.tx0 = pi->tx0;
-      pi->poc.ty1 = pi->ty1;
-      pi->poc.tx1 = pi->tx1;
-    }
-  for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
-    for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-      for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-        for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-          OPJ_UINT32 levelno;
-          OPJ_INT32 trx0, try0;
-          OPJ_INT32  trx1, try1;
-          OPJ_UINT32  rpx, rpy;
-          OPJ_INT32  prci, prcj;
-          comp = &pi->comps[pi->compno];
-          if (pi->resno >= comp->numresolutions) {
-            continue;
-          }
-          res = &comp->resolutions[pi->resno];
-          levelno = comp->numresolutions - 1 - pi->resno;
-          trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-          try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-          trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
-          try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
-          rpx = res->pdx + levelno;
-          rpy = res->pdy + levelno;
-          if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
-            continue;
-          }
-          if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
-            continue;
-          }
-
-          if ((res->pw==0)||(res->ph==0)) continue;
-
-          if ((trx0==trx1)||(try0==try1)) continue;
-
-          prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
-             - int_floordivpow2(trx0, res->pdx);
-          prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
-             - int_floordivpow2(try0, res->pdy);
-          pi->precno = prci + prcj * res->pw;
-          for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-            index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-            if (!pi->include[index]) {
-              pi->include[index] = 1;
-              return true;
-            }
-LABEL_SKIP:;
-          }
-        }
-      }
-    }
-  }
-
-  return false;
-}
-
-static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
-  opj_pi_comp_t *comp = 00;
-  opj_pi_resolution_t *res = 00;
-  OPJ_UINT32 index = 0;
-
-  if (!pi->first) {
-    comp = &pi->comps[pi->compno];
-    goto LABEL_SKIP;
-  } else {
-    OPJ_UINT32 compno, resno;
-    pi->first = 0;
-    pi->dx = 0;
-    pi->dy = 0;
-    for (compno = 0; compno < pi->numcomps; compno++) {
-      comp = &pi->comps[compno];
-      for (resno = 0; resno < comp->numresolutions; resno++) {
-        OPJ_UINT32 dx, dy;
-        res = &comp->resolutions[resno];
-        dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-        dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-        pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-        pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-      }
-    }
-  }
-  if (!pi->tp_on){
-      pi->poc.ty0 = pi->ty0;
-      pi->poc.tx0 = pi->tx0;
-      pi->poc.ty1 = pi->ty1;
-      pi->poc.tx1 = pi->tx1;
-    }
-  for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-    for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-      for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-        comp = &pi->comps[pi->compno];
-        // TODO
-        for (pi->resno = pi->poc.resno0; pi->resno < uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
-          OPJ_UINT32 levelno;
-          OPJ_INT32 trx0, try0;
-          OPJ_INT32 trx1, try1;
-          OPJ_UINT32 rpx, rpy;
-          OPJ_INT32 prci, prcj;
-          res = &comp->resolutions[pi->resno];
-          levelno = comp->numresolutions - 1 - pi->resno;
-          trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-          try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-          trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
-          try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
-          rpx = res->pdx + levelno;
-          rpy = res->pdy + levelno;
-          if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
-            continue;
-          }
-          if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
-            continue;
-          }
-
-          if ((res->pw==0)||(res->ph==0)) continue;
-
-          if ((trx0==trx1)||(try0==try1)) continue;
-
-          prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
-             - int_floordivpow2(trx0, res->pdx);
-          prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
-             - int_floordivpow2(try0, res->pdy);
-          pi->precno = prci + prcj * res->pw;
-          for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-            index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-            if (!pi->include[index]) {
-              pi->include[index] = 1;
-              return true;
-            }
-LABEL_SKIP:;
-          }
-        }
-      }
-    }
-  }
-
-  return false;
-}
-
-static bool pi_next_cprl(opj_pi_iterator_t * pi) {
-  opj_pi_comp_t *comp = 00;
-  opj_pi_resolution_t *res = 00;
-  OPJ_UINT32 index = 0;
-
-  if (!pi->first) {
-    comp = &pi->comps[pi->compno];
-    goto LABEL_SKIP;
-  } else {
-    pi->first = 0;
-  }
-
-  for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
-    OPJ_UINT32 resno;
-    comp = &pi->comps[pi->compno];
-    pi->dx = 0;
-    pi->dy = 0;
-    for (resno = 0; resno < comp->numresolutions; resno++) {
-      OPJ_UINT32 dx, dy;
-      res = &comp->resolutions[resno];
-      dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
-      dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
-      pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
-      pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
-    }
-    if (!pi->tp_on){
-      pi->poc.ty0 = pi->ty0;
-      pi->poc.tx0 = pi->tx0;
-      pi->poc.ty1 = pi->ty1;
-      pi->poc.tx1 = pi->tx1;
-    }
-    for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
-      for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
-        // TODO
-        for (pi->resno = pi->poc.resno0; pi->resno < uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
-          OPJ_UINT32 levelno;
-          OPJ_INT32 trx0, try0;
-          OPJ_INT32 trx1, try1;
-          OPJ_UINT32 rpx, rpy;
-          OPJ_INT32 prci, prcj;
-          res = &comp->resolutions[pi->resno];
-          levelno = comp->numresolutions - 1 - pi->resno;
-          trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
-          try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
-          trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
-          try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
-          rpx = res->pdx + levelno;
-          rpy = res->pdy + levelno;
-          if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
-            continue;
-          }
-          if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
-            continue;
-          }
-
-          if ((res->pw==0)||(res->ph==0)) continue;
-
-          if ((trx0==trx1)||(try0==try1)) continue;
-
-          prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
-             - int_floordivpow2(trx0, res->pdx);
-          prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
-             - int_floordivpow2(try0, res->pdy);
-          pi->precno = prci + prcj * res->pw;
-          for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
-            index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
-            if (!pi->include[index]) {
-              pi->include[index] = 1;
-              return true;
-            }
-LABEL_SKIP:;
-          }
-        }
-      }
-    }
-  }
-
-  return false;
-}
-
-/*
-==========================================================
-   Packet iterator interface
-==========================================================
-*/
-opj_pi_iterator_t *pi_create_decode(
-                    opj_image_t *p_image,
-                    opj_cp_t *p_cp,
-                    OPJ_UINT32 p_tile_no
-                    )
-{
-  // loop
-  OPJ_UINT32 pino;
-  OPJ_UINT32 compno, resno;
-
-  // to store w, h, dx and dy fro all components and resolutions
-  OPJ_UINT32 * l_tmp_data;
-  OPJ_UINT32 ** l_tmp_ptr;
-
-  // encoding prameters to set
-  OPJ_UINT32 l_max_res;
-  OPJ_UINT32 l_max_prec;
-  OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
-  OPJ_UINT32 l_dx_min,l_dy_min;
-  OPJ_UINT32 l_bound;
-  OPJ_UINT32 l_step_p , l_step_c , l_step_r , l_step_l ;
-  OPJ_UINT32 l_data_stride;
-
-  // pointers
-  opj_pi_iterator_t *l_pi = 00;
-  opj_tcp_t *l_tcp = 00;
-  const opj_tccp_t *l_tccp = 00;
-  opj_pi_comp_t *l_current_comp = 00;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_pi_iterator_t * l_current_pi = 00;
-  OPJ_UINT32 * l_encoding_value_ptr = 00;
-
-  // preconditions in debug
-  assert(p_cp != 00);
-  assert(p_image != 00);
-  assert(p_tile_no < p_cp->tw * p_cp->th);
-
-  // initializations
-  l_tcp = &p_cp->tcps[p_tile_no];
-  l_bound = l_tcp->numpocs+1;
-
-  l_data_stride = 4 * J2K_MAXRLVLS;
-  l_tmp_data = (OPJ_UINT32*)opj_malloc(
-    l_data_stride * p_image->numcomps * sizeof(OPJ_UINT32));
-  if
-    (! l_tmp_data)
-  {
-    return 00;
-  }
-  l_tmp_ptr = (OPJ_UINT32**)opj_malloc(
-    p_image->numcomps * sizeof(OPJ_UINT32 *));
-  if
-    (! l_tmp_ptr)
-  {
-    opj_free(l_tmp_data);
-    return 00;
-  }
-
-  // memory allocation for pi
-  l_pi = pi_create(p_image,p_cp,p_tile_no);
-  if
-    (!l_pi)
-  {
-    opj_free(l_tmp_data);
-    opj_free(l_tmp_ptr);
-    return 00;
-  }
-
-  l_encoding_value_ptr = l_tmp_data;
-  // update pointer array
-  for
-    (compno = 0; compno < p_image->numcomps; ++compno)
-  {
-    l_tmp_ptr[compno] = l_encoding_value_ptr;
-    l_encoding_value_ptr += l_data_stride;
-  }
-  // get encoding parameters
-  get_all_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res,l_tmp_ptr);
-
-  // step calculations
-  l_step_p = 1;
-  l_step_c = l_max_prec * l_step_p;
-  l_step_r = p_image->numcomps * l_step_c;
-  l_step_l = l_max_res * l_step_r;
-
-  // set values for first packet iterator
-  l_current_pi = l_pi;
-
-  // memory allocation for include
-  l_current_pi->include = (OPJ_INT16*) opj_calloc(l_tcp->numlayers * l_step_l, sizeof(OPJ_INT16));
-  if
-    (!l_current_pi->include)
-  {
-    opj_free(l_tmp_data);
-    opj_free(l_tmp_ptr);
-    pi_destroy(l_pi, l_bound);
-    return 00;
-  }
-  memset(l_current_pi->include,0,l_tcp->numlayers * l_step_l* sizeof(OPJ_INT16));
-
-  // special treatment for the first packet iterator
-  l_current_comp = l_current_pi->comps;
-  l_img_comp = p_image->comps;
-  l_tccp = l_tcp->tccps;
-
-  l_current_pi->tx0 = l_tx0;
-  l_current_pi->ty0 = l_ty0;
-  l_current_pi->tx1 = l_tx1;
-  l_current_pi->ty1 = l_ty1;
-
-  //l_current_pi->dx = l_img_comp->dx;
-  //l_current_pi->dy = l_img_comp->dy;
-
-  l_current_pi->step_p = l_step_p;
-  l_current_pi->step_c = l_step_c;
-  l_current_pi->step_r = l_step_r;
-  l_current_pi->step_l = l_step_l;
-
-  /* allocation for components and number of components has already been calculated by pi_create */
-  for
-    (compno = 0; compno < l_current_pi->numcomps; ++compno)
-  {
-    opj_pi_resolution_t *l_res = l_current_comp->resolutions;
-    l_encoding_value_ptr = l_tmp_ptr[compno];
-
-    l_current_comp->dx = l_img_comp->dx;
-    l_current_comp->dy = l_img_comp->dy;
-    /* resolutions have already been initialized */
-    for
-      (resno = 0; resno < l_current_comp->numresolutions; resno++)
-    {
-      l_res->pdx = *(l_encoding_value_ptr++);
-      l_res->pdy = *(l_encoding_value_ptr++);
-      l_res->pw =  *(l_encoding_value_ptr++);
-      l_res->ph =  *(l_encoding_value_ptr++);
-      ++l_res;
-    }
-    ++l_current_comp;
-    ++l_img_comp;
-    ++l_tccp;
-  }
-  ++l_current_pi;
-
-  for
-    (pino = 1 ; pino<l_bound ; ++pino )
-  {
-    opj_pi_comp_t *l_current_comp = l_current_pi->comps;
-    opj_image_comp_t * l_img_comp = p_image->comps;
-    l_tccp = l_tcp->tccps;
-
-    l_current_pi->tx0 = l_tx0;
-    l_current_pi->ty0 = l_ty0;
-    l_current_pi->tx1 = l_tx1;
-    l_current_pi->ty1 = l_ty1;
-    //l_current_pi->dx = l_dx_min;
-    //l_current_pi->dy = l_dy_min;
-    l_current_pi->step_p = l_step_p;
-    l_current_pi->step_c = l_step_c;
-    l_current_pi->step_r = l_step_r;
-    l_current_pi->step_l = l_step_l;
-
-    /* allocation for components and number of components has already been calculated by pi_create */
-    for
-      (compno = 0; compno < l_current_pi->numcomps; ++compno)
-    {
-      opj_pi_resolution_t *l_res = l_current_comp->resolutions;
-      l_encoding_value_ptr = l_tmp_ptr[compno];
-
-      l_current_comp->dx = l_img_comp->dx;
-      l_current_comp->dy = l_img_comp->dy;
-      /* resolutions have already been initialized */
-      for
-        (resno = 0; resno < l_current_comp->numresolutions; resno++)
-      {
-        l_res->pdx = *(l_encoding_value_ptr++);
-        l_res->pdy = *(l_encoding_value_ptr++);
-        l_res->pw =  *(l_encoding_value_ptr++);
-        l_res->ph =  *(l_encoding_value_ptr++);
-        ++l_res;
-      }
-      ++l_current_comp;
-      ++l_img_comp;
-      ++l_tccp;
-    }
-    // special treatment
-    l_current_pi->include = (l_current_pi-1)->include;
-    ++l_current_pi;
-  }
-  opj_free(l_tmp_data);
-  l_tmp_data = 00;
-  opj_free(l_tmp_ptr);
-  l_tmp_ptr = 00;
-  if
-    (l_tcp->POC)
-  {
-    pi_update_decode_poc (l_pi,l_tcp,l_max_prec,l_max_res);
-  }
-  else
-  {
-    pi_update_decode_not_poc(l_pi,l_tcp,l_max_prec,l_max_res);
-  }
-  return l_pi;
-}
-
-void pi_update_decode_poc (opj_pi_iterator_t * p_pi,opj_tcp_t * p_tcp,OPJ_UINT32 p_max_precision,OPJ_UINT32 p_max_res)
-{
-  // loop
-  OPJ_UINT32 pino;
-
-  // encoding prameters to set
-  OPJ_UINT32 l_bound;
-
-  opj_pi_iterator_t * l_current_pi = 00;
-  opj_poc_t* l_current_poc = 0;
-
-  // preconditions in debug
-  assert(p_pi != 00);
-  assert(p_tcp != 00);
-
-  // initializations
-  l_bound = p_tcp->numpocs+1;
-  l_current_pi = p_pi;
-  l_current_poc = p_tcp->pocs;
-
-  for
-    (pino = 0;pino<l_bound;++pino)
-  {
-    l_current_pi->poc.prg = l_current_poc->prg;
-    l_current_pi->first = 1;
-
-    l_current_pi->poc.resno0 = l_current_poc->resno0;
-    l_current_pi->poc.compno0 = l_current_poc->compno0;
-    l_current_pi->poc.layno0 = 0;
-    l_current_pi->poc.precno0 = 0;
-    l_current_pi->poc.resno1 = l_current_poc->resno1;
-    l_current_pi->poc.compno1 = l_current_poc->compno1;
-    l_current_pi->poc.layno1 = l_current_poc->layno1;
-    l_current_pi->poc.precno1 = p_max_precision;
-    ++l_current_pi;
-    ++l_current_poc;
-  }
-}
-
-void pi_update_decode_not_poc (opj_pi_iterator_t * p_pi,opj_tcp_t * p_tcp,OPJ_UINT32 p_max_precision,OPJ_UINT32 p_max_res)
-{
-  // loop
-  OPJ_UINT32 pino;
-
-  // encoding prameters to set
-  OPJ_UINT32 l_bound;
-
-  opj_pi_iterator_t * l_current_pi = 00;
-  // preconditions in debug
-  assert(p_tcp != 00);
-  assert(p_pi != 00);
-
-  // initializations
-  l_bound = p_tcp->numpocs+1;
-  l_current_pi = p_pi;
-
-  for
-    (pino = 0;pino<l_bound;++pino)
-  {
-    l_current_pi->poc.prg = p_tcp->prg;
-    l_current_pi->first = 1;
-    l_current_pi->poc.resno0 = 0;
-    l_current_pi->poc.compno0 = 0;
-    l_current_pi->poc.layno0 = 0;
-    l_current_pi->poc.precno0 = 0;
-    l_current_pi->poc.resno1 = p_max_res;
-    l_current_pi->poc.compno1 = l_current_pi->numcomps;
-    l_current_pi->poc.layno1 = p_tcp->numlayers;
-    l_current_pi->poc.precno1 = p_max_precision;
-    ++l_current_pi;
-  }
-}
-
-/**
- * Creates a packet iterator for encoding.
- *
- * @param  p_image    the image being encoded.
- * @param  p_cp    the coding parameters.
- * @param  p_tile_no  index of the tile being encoded.
- * @param  p_t2_mode  the type of pass for generating the packet iterator
- * @return  a list of packet iterator that points to the first packet of the tile (not true).
-*/
-opj_pi_iterator_t *pi_initialise_encode(
-                    const opj_image_t *p_image,
-                    opj_cp_t *p_cp,
-                    OPJ_UINT32 p_tile_no,
-                    J2K_T2_MODE p_t2_mode
-                    )
-{
-  // loop
-  OPJ_UINT32 pino;
-  OPJ_UINT32 compno, resno;
-
-  // to store w, h, dx and dy fro all components and resolutions
-  OPJ_UINT32 * l_tmp_data;
-  OPJ_UINT32 ** l_tmp_ptr;
-
-  // encoding prameters to set
-  OPJ_UINT32 l_max_res;
-  OPJ_UINT32 l_max_prec;
-  OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
-  OPJ_UINT32 l_dx_min,l_dy_min;
-  OPJ_UINT32 l_bound;
-  OPJ_UINT32 l_step_p , l_step_c , l_step_r , l_step_l ;
-  OPJ_UINT32 l_data_stride;
-
-  // pointers
-  opj_pi_iterator_t *l_pi = 00;
-  opj_tcp_t *l_tcp = 00;
-  const opj_tccp_t *l_tccp = 00;
-  opj_pi_comp_t *l_current_comp = 00;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_pi_iterator_t * l_current_pi = 00;
-  OPJ_UINT32 * l_encoding_value_ptr = 00;
-
-  // preconditions in debug
-  assert(p_cp != 00);
-  assert(p_image != 00);
-  assert(p_tile_no < p_cp->tw * p_cp->th);
-
-  // initializations
-  l_tcp = &p_cp->tcps[p_tile_no];
-  l_bound = l_tcp->numpocs+1;
-
-  l_data_stride = 4 * J2K_MAXRLVLS;
-  l_tmp_data = (OPJ_UINT32*)opj_malloc(
-    l_data_stride * p_image->numcomps * sizeof(OPJ_UINT32));
-  if
-    (! l_tmp_data)
-  {
-    return 00;
-  }
-  l_tmp_ptr = (OPJ_UINT32**)opj_malloc(
-    p_image->numcomps * sizeof(OPJ_UINT32 *));
-  if
-    (! l_tmp_ptr)
-  {
-    opj_free(l_tmp_data);
-    return 00;
-  }
-
-  // memory allocation for pi
-  l_pi = pi_create(p_image,p_cp,p_tile_no);
-  if
-    (!l_pi)
-  {
-    opj_free(l_tmp_data);
-    opj_free(l_tmp_ptr);
-    return 00;
-  }
-
-  l_encoding_value_ptr = l_tmp_data;
-  // update pointer array
-  for
-    (compno = 0; compno < p_image->numcomps; ++compno)
-  {
-    l_tmp_ptr[compno] = l_encoding_value_ptr;
-    l_encoding_value_ptr += l_data_stride;
-  }
-  // get encoding parameters
-  get_all_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res,l_tmp_ptr);
-
-  // step calculations
-  l_step_p = 1;
-  l_step_c = l_max_prec * l_step_p;
-  l_step_r = p_image->numcomps * l_step_c;
-  l_step_l = l_max_res * l_step_r;
-
-  // set values for first packet iterator
-  l_pi->tp_on = p_cp->m_specific_param.m_enc.m_tp_on;
-  l_current_pi = l_pi;
-
-  // memory allocation for include
-  l_current_pi->include = (OPJ_INT16*) opj_calloc(l_tcp->numlayers * l_step_l, sizeof(OPJ_INT16));
-  if
-    (!l_current_pi->include)
-  {
-    opj_free(l_tmp_data);
-    opj_free(l_tmp_ptr);
-    pi_destroy(l_pi, l_bound);
-    return 00;
-  }
-  memset(l_current_pi->include,0,l_tcp->numlayers * l_step_l* sizeof(OPJ_INT16));
-
-  // special treatment for the first packet iterator
-  l_current_comp = l_current_pi->comps;
-  l_img_comp = p_image->comps;
-  l_tccp = l_tcp->tccps;
-  l_current_pi->tx0 = l_tx0;
-  l_current_pi->ty0 = l_ty0;
-  l_current_pi->tx1 = l_tx1;
-  l_current_pi->ty1 = l_ty1;
-  l_current_pi->dx = l_dx_min;
-  l_current_pi->dy = l_dy_min;
-  l_current_pi->step_p = l_step_p;
-  l_current_pi->step_c = l_step_c;
-  l_current_pi->step_r = l_step_r;
-  l_current_pi->step_l = l_step_l;
-
-  /* allocation for components and number of components has already been calculated by pi_create */
-  for
-    (compno = 0; compno < l_current_pi->numcomps; ++compno)
-  {
-    opj_pi_resolution_t *l_res = l_current_comp->resolutions;
-    l_encoding_value_ptr = l_tmp_ptr[compno];
-
-    l_current_comp->dx = l_img_comp->dx;
-    l_current_comp->dy = l_img_comp->dy;
-    /* resolutions have already been initialized */
-    for
-      (resno = 0; resno < l_current_comp->numresolutions; resno++)
-    {
-      l_res->pdx = *(l_encoding_value_ptr++);
-      l_res->pdy = *(l_encoding_value_ptr++);
-      l_res->pw =  *(l_encoding_value_ptr++);
-      l_res->ph =  *(l_encoding_value_ptr++);
-      ++l_res;
-    }
-    ++l_current_comp;
-    ++l_img_comp;
-    ++l_tccp;
-  }
-  ++l_current_pi;
-
-  for
-    (pino = 1 ; pino<l_bound ; ++pino )
-  {
-    opj_pi_comp_t *l_current_comp = l_current_pi->comps;
-    opj_image_comp_t * l_img_comp = p_image->comps;
-    l_tccp = l_tcp->tccps;
-
-    l_current_pi->tx0 = l_tx0;
-    l_current_pi->ty0 = l_ty0;
-    l_current_pi->tx1 = l_tx1;
-    l_current_pi->ty1 = l_ty1;
-    l_current_pi->dx = l_dx_min;
-    l_current_pi->dy = l_dy_min;
-    l_current_pi->step_p = l_step_p;
-    l_current_pi->step_c = l_step_c;
-    l_current_pi->step_r = l_step_r;
-    l_current_pi->step_l = l_step_l;
-
-    /* allocation for components and number of components has already been calculated by pi_create */
-    for
-      (compno = 0; compno < l_current_pi->numcomps; ++compno)
-    {
-      opj_pi_resolution_t *l_res = l_current_comp->resolutions;
-      l_encoding_value_ptr = l_tmp_ptr[compno];
-
-      l_current_comp->dx = l_img_comp->dx;
-      l_current_comp->dy = l_img_comp->dy;
-      /* resolutions have already been initialized */
-      for
-        (resno = 0; resno < l_current_comp->numresolutions; resno++)
-      {
-        l_res->pdx = *(l_encoding_value_ptr++);
-        l_res->pdy = *(l_encoding_value_ptr++);
-        l_res->pw =  *(l_encoding_value_ptr++);
-        l_res->ph =  *(l_encoding_value_ptr++);
-        ++l_res;
-      }
-      ++l_current_comp;
-      ++l_img_comp;
-      ++l_tccp;
-    }
-    // special treatment
-    l_current_pi->include = (l_current_pi-1)->include;
-    ++l_current_pi;
-  }
-  opj_free(l_tmp_data);
-  l_tmp_data = 00;
-  opj_free(l_tmp_ptr);
-  l_tmp_ptr = 00;
-  if
-    (l_tcp->POC && ( p_cp->m_specific_param.m_enc.m_cinema || p_t2_mode == FINAL_PASS))
-  {
-    pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
-  }
-  else
-  {
-    pi_update_encode_not_poc(p_cp,p_image->numcomps,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
-  }
-  return l_pi;
-}
-
-/**
- * Updates the encoding parameters of the codec.
- *
- * @param  p_image    the image being encoded.
- * @param  p_cp    the coding parameters.
- * @param  p_tile_no  index of the tile being encoded.
-*/
-void pi_update_encoding_parameters(
-                    const opj_image_t *p_image,
-                    opj_cp_t *p_cp,
-                    OPJ_UINT32 p_tile_no
-                    )
-{
-  // encoding prameters to set
-  OPJ_UINT32 l_max_res;
-  OPJ_UINT32 l_max_prec;
-  OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
-  OPJ_UINT32 l_dx_min,l_dy_min;
-
-  // pointers
-  opj_tcp_t *l_tcp = 00;
-
-  // preconditions in debug
-  assert(p_cp != 00);
-  assert(p_image != 00);
-  assert(p_tile_no < p_cp->tw * p_cp->th);
-
-  l_tcp = &(p_cp->tcps[p_tile_no]);
-  // get encoding parameters
-  get_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res);
-  if
-    (l_tcp->POC)
-  {
-    pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
-  }
-  else
-  {
-    pi_update_encode_not_poc(p_cp,p_image->numcomps,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
-  }
-}
-
-
-/**
- * Gets the encoding parameters needed to update the coding parameters and all the pocs.
- *
- * @param  p_image      the image being encoded.
- * @param  p_cp      the coding parameters.
- * @param  p_tileno      the tile index of the tile being encoded.
- * @param  p_tx0      pointer that will hold the X0 parameter for the tile
- * @param  p_tx1      pointer that will hold the X1 parameter for the tile
- * @param  p_ty0      pointer that will hold the Y0 parameter for the tile
- * @param  p_ty1      pointer that will hold the Y1 parameter for the tile
- * @param  p_max_prec    pointer that will hold the the maximum precision for all the bands of the tile
- * @param  p_max_res    pointer that will hold the the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min      pointer that will hold the the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min      pointer that will hold the the minimum dy of all the components of all the resolutions for the tile.
- */
-void get_encoding_parameters(
-                const opj_image_t *p_image,
-                const opj_cp_t *p_cp,
-                OPJ_UINT32 p_tileno,
-                OPJ_INT32 * p_tx0,
-                OPJ_INT32  * p_tx1,
-                OPJ_INT32  * p_ty0,
-                OPJ_INT32  * p_ty1,
-                OPJ_UINT32 * p_dx_min,
-                OPJ_UINT32 * p_dy_min,
-                OPJ_UINT32 * p_max_prec,
-                OPJ_UINT32 * p_max_res
-              )
-{
-  // loop
-  OPJ_UINT32  compno, resno;
-  // pointers
-  const opj_tcp_t *l_tcp = 00;
-  const opj_tccp_t * l_tccp = 00;
-  const opj_image_comp_t * l_img_comp = 00;
-
-  // position in x and y of tile
-  OPJ_UINT32 p, q;
-
-  // preconditions in debug
-  assert(p_cp != 00);
-  assert(p_image != 00);
-  assert(p_tileno < p_cp->tw * p_cp->th);
-
-  // initializations
-  l_tcp = &p_cp->tcps [p_tileno];
-  l_img_comp = p_image->comps;
-  l_tccp = l_tcp->tccps;
-
-  /* here calculation of tx0, tx1, ty0, ty1, maxprec, dx and dy */
-  p = p_tileno % p_cp->tw;
-  q = p_tileno / p_cp->tw;
-
-  // find extent of tile
-  *p_tx0 = int_max(p_cp->tx0 + p * p_cp->tdx, p_image->x0);
-  *p_tx1 = int_min(p_cp->tx0 + (p + 1) * p_cp->tdx, p_image->x1);
-  *p_ty0 = int_max(p_cp->ty0 + q * p_cp->tdy, p_image->y0);
-  *p_ty1 = int_min(p_cp->ty0 + (q + 1) * p_cp->tdy, p_image->y1);
-
-  // max precision is 0 (can only grow)
-  *p_max_prec = 0;
-  *p_max_res = 0;
-
-  // take the largest value for dx_min and dy_min
-  *p_dx_min = 0x7fffffff;
-  *p_dy_min  = 0x7fffffff;
-
-  for
-    (compno = 0; compno < p_image->numcomps; ++compno)
-  {
-    // aritmetic variables to calculate
-    OPJ_UINT32 l_level_no;
-    OPJ_INT32 l_rx0, l_ry0, l_rx1, l_ry1;
-    OPJ_INT32 l_px0, l_py0, l_px1, py1;
-    OPJ_UINT32 l_pdx, l_pdy;
-    OPJ_UINT32 l_pw, l_ph;
-    OPJ_UINT32 l_product;
-    OPJ_INT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1;
-
-    l_tcx0 = int_ceildiv(*p_tx0, l_img_comp->dx);
-    l_tcy0 = int_ceildiv(*p_ty0, l_img_comp->dy);
-    l_tcx1 = int_ceildiv(*p_tx1, l_img_comp->dx);
-    l_tcy1 = int_ceildiv(*p_ty1, l_img_comp->dy);
-    if
-      (l_tccp->numresolutions > *p_max_res)
-    {
-      *p_max_res = l_tccp->numresolutions;
-    }
-    // use custom size for precincts
-    for
-      (resno = 0; resno < l_tccp->numresolutions; ++resno)
-    {
-      OPJ_UINT32 l_dx, l_dy;
-      // precinct width and height
-      l_pdx = l_tccp->prcw[resno];
-      l_pdy = l_tccp->prch[resno];
-
-      l_dx = l_img_comp->dx * (1 << (l_pdx + l_tccp->numresolutions - 1 - resno));
-      l_dy = l_img_comp->dy * (1 << (l_pdy + l_tccp->numresolutions - 1 - resno));
-      // take the minimum size for dx for each comp and resolution
-      *p_dx_min = uint_min(*p_dx_min, l_dx);
-      *p_dy_min = uint_min(*p_dy_min, l_dy);
-      // various calculations of extents
-      l_level_no = l_tccp->numresolutions - 1 - resno;
-      l_rx0 = int_ceildivpow2(l_tcx0, l_level_no);
-      l_ry0 = int_ceildivpow2(l_tcy0, l_level_no);
-      l_rx1 = int_ceildivpow2(l_tcx1, l_level_no);
-      l_ry1 = int_ceildivpow2(l_tcy1, l_level_no);
-      l_px0 = int_floordivpow2(l_rx0, l_pdx) << l_pdx;
-      l_py0 = int_floordivpow2(l_ry0, l_pdy) << l_pdy;
-      l_px1 = int_ceildivpow2(l_rx1, l_pdx) << l_pdx;
-      py1 = int_ceildivpow2(l_ry1, l_pdy) << l_pdy;
-      l_pw = (l_rx0==l_rx1)?0:((l_px1 - l_px0) >> l_pdx);
-      l_ph = (l_ry0==l_ry1)?0:((py1 - l_py0) >> l_pdy);
-      l_product = l_pw * l_ph;
-      // update precision
-      if
-        (l_product > *p_max_prec)
-      {
-        *p_max_prec = l_product;
-      }
-    }
-    ++l_img_comp;
-    ++l_tccp;
-  }
-}
-
-/**
- * Gets the encoding parameters needed to update the coding parameters and all the pocs.
- * The precinct widths, heights, dx and dy for each component at each resolution will be stored as well.
- * the last parameter of the function should be an array of pointers of size nb components, each pointer leading
- * to an area of size 4 * max_res. The data is stored inside this area with the following pattern :
- * dx_compi_res0 , dy_compi_res0 , w_compi_res0, h_compi_res0 , dx_compi_res1 , dy_compi_res1 , w_compi_res1, h_compi_res1 , ...
- *
- * @param  p_image      the image being encoded.
- * @param  p_cp      the coding parameters.
- * @param  tileno      the tile index of the tile being encoded.
- * @param  p_tx0      pointer that will hold the X0 parameter for the tile
- * @param  p_tx1      pointer that will hold the X1 parameter for the tile
- * @param  p_ty0      pointer that will hold the Y0 parameter for the tile
- * @param  p_ty1      pointer that will hold the Y1 parameter for the tile
- * @param  p_max_prec    pointer that will hold the the maximum precision for all the bands of the tile
- * @param  p_max_res    pointer that will hold the the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min      pointer that will hold the the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min      pointer that will hold the the minimum dy of all the components of all the resolutions for the tile.
- * @param  p_resolutions  pointer to an area corresponding to the one described above.
- */
-void get_all_encoding_parameters(
-                const opj_image_t *p_image,
-                const opj_cp_t *p_cp,
-                OPJ_UINT32 tileno,
-                OPJ_INT32 * p_tx0,
-                OPJ_INT32 * p_tx1,
-                OPJ_INT32 * p_ty0,
-                OPJ_INT32 * p_ty1,
-                OPJ_UINT32 * p_dx_min,
-                OPJ_UINT32 * p_dy_min,
-                OPJ_UINT32 * p_max_prec,
-                OPJ_UINT32 * p_max_res,
-                OPJ_UINT32 ** p_resolutions
-              )
-{
-  // loop
-  OPJ_UINT32 compno, resno;
-
-  // pointers
-  const opj_tcp_t *tcp = 00;
-  const opj_tccp_t * l_tccp = 00;
-  const opj_image_comp_t * l_img_comp = 00;
-
-  // to store l_dx, l_dy, w and h for each resolution and component.
-  OPJ_UINT32 * lResolutionPtr;
-
-  // position in x and y of tile
-  OPJ_UINT32 p, q;
-
-  // preconditions in debug
-  assert(p_cp != 00);
-  assert(p_image != 00);
-  assert(tileno < p_cp->tw * p_cp->th);
-
-  // initializations
-  tcp = &p_cp->tcps [tileno];
-  l_tccp = tcp->tccps;
-  l_img_comp = p_image->comps;
-
-  // position in x and y of tile
-
-  p = tileno % p_cp->tw;
-  q = tileno / p_cp->tw;
-
-  /* here calculation of tx0, tx1, ty0, ty1, maxprec, l_dx and l_dy */
-  *p_tx0 = int_max(p_cp->tx0 + p * p_cp->tdx, p_image->x0);
-  *p_tx1 = int_min(p_cp->tx0 + (p + 1) * p_cp->tdx, p_image->x1);
-  *p_ty0 = int_max(p_cp->ty0 + q * p_cp->tdy, p_image->y0);
-  *p_ty1 = int_min(p_cp->ty0 + (q + 1) * p_cp->tdy, p_image->y1);
-
-  // max precision and resolution is 0 (can only grow)
-  *p_max_prec = 0;
-  *p_max_res = 0;
-
-  // take the largest value for dx_min and dy_min
-  *p_dx_min = 0x7fffffff;
-  *p_dy_min  = 0x7fffffff;
-
-  for
-    (compno = 0; compno < p_image->numcomps; ++compno)
-  {
-    // aritmetic variables to calculate
-    OPJ_UINT32 l_level_no;
-    OPJ_INT32 l_rx0, l_ry0, l_rx1, l_ry1;
-    OPJ_INT32 l_px0, l_py0, l_px1, py1;
-    OPJ_UINT32 l_product;
-    OPJ_INT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1;
-    OPJ_UINT32 l_pdx, l_pdy , l_pw , l_ph;
-
-    lResolutionPtr = p_resolutions[compno];
-
-    l_tcx0 = int_ceildiv(*p_tx0, l_img_comp->dx);
-    l_tcy0 = int_ceildiv(*p_ty0, l_img_comp->dy);
-    l_tcx1 = int_ceildiv(*p_tx1, l_img_comp->dx);
-    l_tcy1 = int_ceildiv(*p_ty1, l_img_comp->dy);
-    if
-      (l_tccp->numresolutions > *p_max_res)
-    {
-      *p_max_res = l_tccp->numresolutions;
-    }
-
-    // use custom size for precincts
-    l_level_no = l_tccp->numresolutions - 1;
-    for
-      (resno = 0; resno < l_tccp->numresolutions; ++resno)
-    {
-      OPJ_UINT32 l_dx, l_dy;
-      // precinct width and height
-      l_pdx = l_tccp->prcw[resno];
-      l_pdy = l_tccp->prch[resno];
-      *lResolutionPtr++ = l_pdx;
-      *lResolutionPtr++ = l_pdy;
-      l_dx = l_img_comp->dx * (1 << (l_pdx + l_level_no));
-      l_dy = l_img_comp->dy * (1 << (l_pdy + l_level_no));
-      // take the minimum size for l_dx for each comp and resolution
-      *p_dx_min = int_min(*p_dx_min, l_dx);
-      *p_dy_min = int_min(*p_dy_min, l_dy);
-      // various calculations of extents
-
-      l_rx0 = int_ceildivpow2(l_tcx0, l_level_no);
-      l_ry0 = int_ceildivpow2(l_tcy0, l_level_no);
-      l_rx1 = int_ceildivpow2(l_tcx1, l_level_no);
-      l_ry1 = int_ceildivpow2(l_tcy1, l_level_no);
-      l_px0 = int_floordivpow2(l_rx0, l_pdx) << l_pdx;
-      l_py0 = int_floordivpow2(l_ry0, l_pdy) << l_pdy;
-      l_px1 = int_ceildivpow2(l_rx1, l_pdx) << l_pdx;
-      py1 = int_ceildivpow2(l_ry1, l_pdy) << l_pdy;
-      l_pw = (l_rx0==l_rx1)?0:((l_px1 - l_px0) >> l_pdx);
-      l_ph = (l_ry0==l_ry1)?0:((py1 - l_py0) >> l_pdy);
-      *lResolutionPtr++ = l_pw;
-      *lResolutionPtr++ = l_ph;
-      l_product = l_pw * l_ph;
-      // update precision
-      if
-        (l_product > *p_max_prec)
-      {
-        *p_max_prec = l_product;
-      }
-      --l_level_no;
-    }
-    ++l_tccp;
-    ++l_img_comp;
-  }
-}
-
-/**
- * Allocates memory for a packet iterator. Data and data sizes are set by this operation.
- * No other data is set. The include section of the packet  iterator is not allocated.
- *
- * @param  p_image    the image used to initialize the packet iterator (in fact only the number of components is relevant.
- * @param  p_cp    the coding parameters.
- * @param  p_tile_no  the index of the tile from which creating the packet iterator.
- */
-opj_pi_iterator_t * pi_create(
-                const opj_image_t *image,
-                const opj_cp_t *cp,
-                OPJ_UINT32 tileno
-              )
-{
-  // loop
-  OPJ_UINT32 pino, compno;
-  // number of poc in the p_pi
-  OPJ_UINT32 l_poc_bound;
-
-  // pointers to tile coding parameters and components.
-  opj_pi_iterator_t *l_pi = 00;
-  opj_tcp_t *tcp = 00;
-  const opj_tccp_t *tccp = 00;
-
-  // current packet iterator being allocated
-  opj_pi_iterator_t *l_current_pi = 00;
-
-  // preconditions in debug
-  assert(cp != 00);
-  assert(image != 00);
-  assert(tileno < cp->tw * cp->th);
-
-  // initializations
-  tcp = &cp->tcps[tileno];
-  l_poc_bound = tcp->numpocs+1;
-
-
-  // memory allocations
-  l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound), sizeof(opj_pi_iterator_t));
-
-  if
-    (!l_pi)
-  {
-    return 00;
-  }
-  memset(l_pi,0,l_poc_bound * sizeof(opj_pi_iterator_t));
-  l_current_pi = l_pi;
-  for
-    (pino = 0; pino < l_poc_bound ; ++pino)
-  {
-    l_current_pi->comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
-    if
-      (! l_current_pi->comps)
-    {
-      pi_destroy(l_pi, l_poc_bound);
-      return 00;
-    }
-    l_current_pi->numcomps = image->numcomps;
-    memset(l_current_pi->comps,0,image->numcomps * sizeof(opj_pi_comp_t));
-    for
-      (compno = 0; compno < image->numcomps; ++compno)
-    {
-      opj_pi_comp_t *comp = &l_current_pi->comps[compno];
-      tccp = &tcp->tccps[compno];
-      comp->resolutions = (opj_pi_resolution_t*) opj_malloc(tccp->numresolutions * sizeof(opj_pi_resolution_t));
-      if
-        (!comp->resolutions)
-      {
-        pi_destroy(l_pi, l_poc_bound);
-        return 00;
-      }
-      comp->numresolutions = tccp->numresolutions;
-      memset(comp->resolutions,0,tccp->numresolutions * sizeof(opj_pi_resolution_t));
-    }
-    ++l_current_pi;
-  }
-  return l_pi;
-}
-
-/**
- * Updates the coding parameters if the encoding is used with Progression order changes and final (or cinema parameters are used).
- *
- * @param  p_cp    the coding parameters to modify
- * @param  p_tileno  the tile index being concerned.
- * @param  p_tx0    X0 parameter for the tile
- * @param  p_tx1    X1 parameter for the tile
- * @param  p_ty0    Y0 parameter for the tile
- * @param  p_ty1    Y1 parameter for the tile
- * @param  p_max_prec  the maximum precision for all the bands of the tile
- * @param  p_max_res  the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min    the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min    the minimum dy of all the components of all the resolutions for the tile.
- */
-void pi_update_encode_poc_and_final (
-                   opj_cp_t *p_cp,
-                   OPJ_UINT32 p_tileno,
-                   OPJ_INT32 p_tx0,
-                   OPJ_INT32 p_tx1,
-                   OPJ_INT32 p_ty0,
-                   OPJ_INT32 p_ty1,
-                   OPJ_UINT32 p_max_prec,
-                   OPJ_UINT32 p_max_res,
-                                     OPJ_UINT32 p_dx_min,
-                   OPJ_UINT32 p_dy_min)
-{
-  // loop
-  OPJ_UINT32 pino;
-  // tile coding parameter
-  opj_tcp_t *l_tcp = 00;
-  // current poc being updated
-  opj_poc_t * l_current_poc = 00;
-
-  // number of pocs
-  OPJ_UINT32 l_poc_bound;
-
-  // preconditions in debug
-  assert(p_cp != 00);
-  assert(p_tileno < p_cp->tw * p_cp->th);
-
-  // initializations
-  l_tcp = &p_cp->tcps [p_tileno];
-  /* number of iterations in the loop */
-  l_poc_bound = l_tcp->numpocs+1;
-
-  // start at first element, and to make sure the compiler will not make a calculation each time in the loop
-  // store a pointer to the current element to modify rather than l_tcp->pocs[i]
-  l_current_poc = l_tcp->pocs;
-
-  l_current_poc->compS = l_current_poc->compno0;
-  l_current_poc->compE = l_current_poc->compno1;
-  l_current_poc->resS = l_current_poc->resno0;
-  l_current_poc->resE = l_current_poc->resno1;
-  l_current_poc->layE = l_current_poc->layno1;
-
-  // special treatment for the first element
-  l_current_poc->layS = 0;
-  l_current_poc->prg  = l_current_poc->prg1;
-  l_current_poc->prcS = 0;
-
-  l_current_poc->prcE = p_max_prec;
-  l_current_poc->txS = p_tx0;
-  l_current_poc->txE = p_tx1;
-  l_current_poc->tyS = p_ty0;
-  l_current_poc->tyE = p_ty1;
-  l_current_poc->dx = p_dx_min;
-  l_current_poc->dy = p_dy_min;
-
-  ++ l_current_poc;
-  for
-    (pino = 1;pino < l_poc_bound ; ++pino)
-  {
-    l_current_poc->compS = l_current_poc->compno0;
-    l_current_poc->compE= l_current_poc->compno1;
-    l_current_poc->resS = l_current_poc->resno0;
-    l_current_poc->resE = l_current_poc->resno1;
-    l_current_poc->layE = l_current_poc->layno1;
-    l_current_poc->prg  = l_current_poc->prg1;
-    l_current_poc->prcS = 0;
-    // special treatment here different from the first element
-    l_current_poc->layS = (l_current_poc->layE > (l_current_poc-1)->layE) ? l_current_poc->layE : 0;
-
-    l_current_poc->prcE = p_max_prec;
-    l_current_poc->txS = p_tx0;
-    l_current_poc->txE = p_tx1;
-    l_current_poc->tyS = p_ty0;
-    l_current_poc->tyE = p_ty1;
-    l_current_poc->dx = p_dx_min;
-    l_current_poc->dy = p_dy_min;
-    ++ l_current_poc;
-  }
-}
-
-/**
- * Updates the coding parameters if the encoding is not used with Progression order changes and final (and cinema parameters are used).
- *
- * @param  p_cp    the coding parameters to modify
- * @param  p_tileno  the tile index being concerned.
- * @param  p_tx0    X0 parameter for the tile
- * @param  p_tx1    X1 parameter for the tile
- * @param  p_ty0    Y0 parameter for the tile
- * @param  p_ty1    Y1 parameter for the tile
- * @param  p_max_prec  the maximum precision for all the bands of the tile
- * @param  p_max_res  the maximum number of resolutions for all the poc inside the tile.
- * @param  dx_min    the minimum dx of all the components of all the resolutions for the tile.
- * @param  dy_min    the minimum dy of all the components of all the resolutions for the tile.
- */
-void pi_update_encode_not_poc (
-                opj_cp_t *p_cp,
-                OPJ_UINT32 p_num_comps,
-                OPJ_UINT32 p_tileno,
-                OPJ_INT32 p_tx0,
-                OPJ_INT32 p_tx1,
-                OPJ_INT32 p_ty0,
-                OPJ_INT32 p_ty1,
-                OPJ_UINT32 p_max_prec,
-                OPJ_UINT32 p_max_res,
-                                OPJ_UINT32 p_dx_min,
-                OPJ_UINT32 p_dy_min)
-{
-  // loop
-  OPJ_UINT32 pino;
-  // tile coding parameter
-  opj_tcp_t *l_tcp = 00;
-  // current poc being updated
-  opj_poc_t * l_current_poc = 00;
-  // number of pocs
-  OPJ_UINT32 l_poc_bound;
-
-  // preconditions in debug
-  assert(p_cp != 00);
-  assert(p_tileno < p_cp->tw * p_cp->th);
-
-  // initializations
-  l_tcp = &p_cp->tcps [p_tileno];
-
-  /* number of iterations in the loop */
-  l_poc_bound = l_tcp->numpocs+1;
-
-  // start at first element, and to make sure the compiler will not make a calculation each time in the loop
-  // store a pointer to the current element to modify rather than l_tcp->pocs[i]
-  l_current_poc = l_tcp->pocs;
-
-  for
-    (pino = 0; pino < l_poc_bound ; ++pino)
-  {
-    l_current_poc->compS = 0;
-    l_current_poc->compE = p_num_comps;/*p_image->numcomps;*/
-    l_current_poc->resS = 0;
-    l_current_poc->resE = p_max_res;
-    l_current_poc->layS = 0;
-    l_current_poc->layE = l_tcp->numlayers;
-    l_current_poc->prg  = l_tcp->prg;
-    l_current_poc->prcS = 0;
-    l_current_poc->prcE = p_max_prec;
-    l_current_poc->txS = p_tx0;
-    l_current_poc->txE = p_tx1;
-    l_current_poc->tyS = p_ty0;
-    l_current_poc->tyE = p_ty1;
-    l_current_poc->dx = p_dx_min;
-    l_current_poc->dy = p_dy_min;
-    ++ l_current_poc;
-  }
-}
-
-/**
- * Destroys a packet iterator array.
- *
- * @param  p_pi      the packet iterator array to destroy.
- * @param  p_nb_elements  the number of elements in the array.
- */
-void pi_destroy(
-        opj_pi_iterator_t *p_pi,
-        OPJ_UINT32 p_nb_elements)
-{
-  OPJ_UINT32 compno, pino;
-  opj_pi_iterator_t *l_current_pi = p_pi;
-  if
-    (p_pi)
-  {
-    if
-      (p_pi->include)
-    {
-      opj_free(p_pi->include);
-      p_pi->include = 00;
-    }
-    // TODO
-    for
-      (pino = 0; pino < p_nb_elements; ++pino)
-    {
-      if
-        (l_current_pi->comps)
-      {
-        opj_pi_comp_t *l_current_component = l_current_pi->comps;
-        for
-          (compno = 0; compno < l_current_pi->numcomps; compno++)
-        {
-          if
-            (l_current_component->resolutions)
-          {
-            opj_free(l_current_component->resolutions);
-            l_current_component->resolutions = 00;
-          }
-          ++l_current_component;
-        }
-        opj_free(l_current_pi->comps);
-        l_current_pi->comps = 0;
-      }
-      ++l_current_pi;
-    }
-    opj_free(p_pi);
-  }
-}
-
-bool pi_next(opj_pi_iterator_t * pi) {
-  switch (pi->poc.prg) {
-    case LRCP:
-      return pi_next_lrcp(pi);
-    case RLCP:
-      return pi_next_rlcp(pi);
-    case RPCL:
-      return pi_next_rpcl(pi);
-    case PCRL:
-      return pi_next_pcrl(pi);
-    case CPRL:
-      return pi_next_cprl(pi);
-    case PROG_UNKNOWN:
-      return false;
-  }
-
-  return false;
-}
-
-OPJ_INT32 pi_check_next_level(OPJ_INT32 pos,opj_cp_t *cp,OPJ_UINT32 tileno, OPJ_UINT32 pino, const OPJ_CHAR *prog)
-{
-  OPJ_INT32 i,l;
-  opj_tcp_t *tcps =&cp->tcps[tileno];
-  opj_poc_t *tcp = &tcps->pocs[pino];
-  if(pos>=0){
-    for(i=pos;pos>=0;i--){
-      switch(prog[i]){
-    case 'R':
-      if(tcp->res_t==tcp->resE){
-        l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
-        if(l==1){
-          return 1;
-        }else{
-          return 0;
-        }
-      }else{
-        return 1;
-      }
-      break;
-    case 'C':
-      if(tcp->comp_t==tcp->compE){
-        l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
-        if(l==1){
-          return 1;
-        }else{
-          return 0;
-        }
-      }else{
-        return 1;
-      }
-      break;
-    case 'L':
-      if(tcp->lay_t==tcp->layE){
-        l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
-        if(l==1){
-          return 1;
-        }else{
-          return 0;
-        }
-      }else{
-        return 1;
-      }
-      break;
-    case 'P':
-      switch(tcp->prg){
-        case LRCP||RLCP:
-          if(tcp->prc_t == tcp->prcE){
-            l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-            if(l==1){
-              return 1;
-            }else{
-              return 0;
-            }
-          }else{
-            return 1;
-          }
-          break;
-      default:
-        if(tcp->tx0_t == tcp->txE){
-          //TY
-          if(tcp->ty0_t == tcp->tyE){
-            l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-            if(l==1){
-              return 1;
-            }else{
-              return 0;
-            }
-          }else{
-            return 1;
-          }//TY
-        }else{
-          return 1;
-        }
-        break;
-      }//end case P
-    }//end switch
-    }//end for
-  }//end if
-  return 0;
-}
-
-
-void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,OPJ_UINT32 tileno, OPJ_UINT32 pino,OPJ_UINT32 tpnum, OPJ_INT32 tppos, J2K_T2_MODE t2_mode)
-{
-  const OPJ_CHAR *prog;
-  OPJ_INT32 i,l;
-  OPJ_UINT32 incr_top=1,resetX=0;
-  opj_tcp_t *tcps =&cp->tcps[tileno];
-  opj_poc_t *tcp= &tcps->pocs[pino];
-
-  prog = j2k_convert_progression_order(tcp->prg);
-
-  pi[pino].first = 1;
-  pi[pino].poc.prg = tcp->prg;
-
-  if(!(cp->m_specific_param.m_enc.m_tp_on&& ((!cp->m_specific_param.m_enc.m_cinema && (t2_mode == FINAL_PASS)) || cp->m_specific_param.m_enc.m_cinema))){
-    pi[pino].poc.resno0 = tcp->resS;
-    pi[pino].poc.resno1 = tcp->resE;
-    pi[pino].poc.compno0 = tcp->compS;
-    pi[pino].poc.compno1 = tcp->compE;
-    pi[pino].poc.layno0 = tcp->layS;
-    pi[pino].poc.layno1 = tcp->layE;
-    pi[pino].poc.precno0 = tcp->prcS;
-    pi[pino].poc.precno1 = tcp->prcE;
-    pi[pino].poc.tx0 = tcp->txS;
-    pi[pino].poc.ty0 = tcp->tyS;
-    pi[pino].poc.tx1 = tcp->txE;
-    pi[pino].poc.ty1 = tcp->tyE;
-  }else {
-    for(i=tppos+1;i<4;i++){
-      switch(prog[i]){
-      case 'R':
-        pi[pino].poc.resno0 = tcp->resS;
-        pi[pino].poc.resno1 = tcp->resE;
-        break;
-      case 'C':
-        pi[pino].poc.compno0 = tcp->compS;
-        pi[pino].poc.compno1 = tcp->compE;
-        break;
-      case 'L':
-        pi[pino].poc.layno0 = tcp->layS;
-        pi[pino].poc.layno1 = tcp->layE;
-        break;
-      case 'P':
-        switch(tcp->prg){
-          case LRCP:
-          case RLCP:
-            pi[pino].poc.precno0 = tcp->prcS;
-            pi[pino].poc.precno1 = tcp->prcE;
-            break;
-          default:
-            pi[pino].poc.tx0 = tcp->txS;
-            pi[pino].poc.ty0 = tcp->tyS;
-            pi[pino].poc.tx1 = tcp->txE;
-            pi[pino].poc.ty1 = tcp->tyE;
-            break;
-        }
-        break;
-      }
-    }
-
-    if(tpnum==0){
-      for(i=tppos;i>=0;i--){
-        switch(prog[i]){
-            case 'C':
-              tcp->comp_t = tcp->compS;
-              pi[pino].poc.compno0 = tcp->comp_t;
-              pi[pino].poc.compno1 = tcp->comp_t+1;
-              tcp->comp_t+=1;
-              break;
-            case 'R':
-              tcp->res_t = tcp->resS;
-              pi[pino].poc.resno0 = tcp->res_t;
-              pi[pino].poc.resno1 = tcp->res_t+1;
-              tcp->res_t+=1;
-              break;
-            case 'L':
-              tcp->lay_t = tcp->layS;
-              pi[pino].poc.layno0 = tcp->lay_t;
-              pi[pino].poc.layno1 = tcp->lay_t+1;
-              tcp->lay_t+=1;
-              break;
-            case 'P':
-              switch(tcp->prg){
-                case LRCP:
-                case RLCP:
-                  tcp->prc_t = tcp->prcS;
-                  pi[pino].poc.precno0 = tcp->prc_t;
-                  pi[pino].poc.precno1 = tcp->prc_t+1;
-                  tcp->prc_t+=1;
-                  break;
-                default:
-                  tcp->tx0_t = tcp->txS;
-                  tcp->ty0_t = tcp->tyS;
-                  pi[pino].poc.tx0 = tcp->tx0_t;
-                  pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx);
-                  pi[pino].poc.ty0 = tcp->ty0_t;
-                  pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-                  tcp->tx0_t = pi[pino].poc.tx1;
-                  tcp->ty0_t = pi[pino].poc.ty1;
-                  break;
-              }
-              break;
-        }
-      }
-      incr_top=1;
-    }else{
-      for(i=tppos;i>=0;i--){
-        switch(prog[i]){
-            case 'C':
-              pi[pino].poc.compno0 = tcp->comp_t-1;
-              pi[pino].poc.compno1 = tcp->comp_t;
-              break;
-            case 'R':
-              pi[pino].poc.resno0 = tcp->res_t-1;
-              pi[pino].poc.resno1 = tcp->res_t;
-              break;
-            case 'L':
-              pi[pino].poc.layno0 = tcp->lay_t-1;
-              pi[pino].poc.layno1 = tcp->lay_t;
-              break;
-            case 'P':
-              switch(tcp->prg){
-                case LRCP:
-                case RLCP:
-                  pi[pino].poc.precno0 = tcp->prc_t-1;
-                  pi[pino].poc.precno1 = tcp->prc_t;
-                  break;
-                default:
-                  pi[pino].poc.tx0 = tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx);
-                  pi[pino].poc.tx1 = tcp->tx0_t ;
-                  pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
-                  pi[pino].poc.ty1 = tcp->ty0_t ;
-                  break;
-              }
-              break;
-        }
-        if(incr_top==1){
-          switch(prog[i]){
-              case 'R':
-                if(tcp->res_t==tcp->resE){
-                  l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                  if(l==1){
-                    tcp->res_t = tcp->resS;
-                    pi[pino].poc.resno0 = tcp->res_t;
-                    pi[pino].poc.resno1 = tcp->res_t+1;
-                    tcp->res_t+=1;
-                    incr_top=1;
-                  }else{
-                    incr_top=0;
-                  }
-                }else{
-                  pi[pino].poc.resno0 = tcp->res_t;
-                  pi[pino].poc.resno1 = tcp->res_t+1;
-                  tcp->res_t+=1;
-                  incr_top=0;
-                }
-                break;
-              case 'C':
-                if(tcp->comp_t ==tcp->compE){
-                  l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                  if(l==1){
-                    tcp->comp_t = tcp->compS;
-                    pi[pino].poc.compno0 = tcp->comp_t;
-                    pi[pino].poc.compno1 = tcp->comp_t+1;
-                    tcp->comp_t+=1;
-                    incr_top=1;
-                  }else{
-                    incr_top=0;
-                  }
-                }else{
-                  pi[pino].poc.compno0 = tcp->comp_t;
-                  pi[pino].poc.compno1 = tcp->comp_t+1;
-                  tcp->comp_t+=1;
-                  incr_top=0;
-                }
-                break;
-              case 'L':
-                if(tcp->lay_t == tcp->layE){
-                  l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                  if(l==1){
-                    tcp->lay_t = tcp->layS;
-                    pi[pino].poc.layno0 = tcp->lay_t;
-                    pi[pino].poc.layno1 = tcp->lay_t+1;
-                    tcp->lay_t+=1;
-                    incr_top=1;
-                  }else{
-                    incr_top=0;
-                  }
-                }else{
-                  pi[pino].poc.layno0 = tcp->lay_t;
-                  pi[pino].poc.layno1 = tcp->lay_t+1;
-                  tcp->lay_t+=1;
-                  incr_top=0;
-                }
-                break;
-              case 'P':
-                switch(tcp->prg){
-                  case LRCP:
-                  case RLCP:
-                    if(tcp->prc_t == tcp->prcE){
-                      l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                      if(l==1){
-                        tcp->prc_t = tcp->prcS;
-                        pi[pino].poc.precno0 = tcp->prc_t;
-                        pi[pino].poc.precno1 = tcp->prc_t+1;
-                        tcp->prc_t+=1;
-                        incr_top=1;
-                      }else{
-                        incr_top=0;
-                      }
-                    }else{
-                      pi[pino].poc.precno0 = tcp->prc_t;
-                      pi[pino].poc.precno1 = tcp->prc_t+1;
-                      tcp->prc_t+=1;
-                      incr_top=0;
-                    }
-                    break;
-                  default:
-                    if(tcp->tx0_t >= tcp->txE){
-                      if(tcp->ty0_t >= tcp->tyE){
-                        l=pi_check_next_level(i-1,cp,tileno,pino,prog);
-                        if(l==1){
-                          tcp->ty0_t = tcp->tyS;
-                          pi[pino].poc.ty0 = tcp->ty0_t;
-                          pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-                          tcp->ty0_t = pi[pino].poc.ty1;
-                          incr_top=1;resetX=1;
-                        }else{
-                          incr_top=0;resetX=0;
-                        }
-                      }else{
-                        pi[pino].poc.ty0 = tcp->ty0_t;
-                        pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
-                        tcp->ty0_t = pi[pino].poc.ty1;
-                        incr_top=0;resetX=1;
-                      }
-                      if(resetX==1){
-                        tcp->tx0_t = tcp->txS;
-                        pi[pino].poc.tx0 = tcp->tx0_t;
-                        pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx);
-                        tcp->tx0_t = pi[pino].poc.tx1;
-                      }
-                    }else{
-                      pi[pino].poc.tx0 = tcp->tx0_t;
-                      pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx);
-                      tcp->tx0_t = pi[pino].poc.tx1;
-                      incr_top=0;
-                    }
-                    break;
-                }
-                break;
-          }
-        }
-      }
-    }
-  }
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.c
deleted file mode 100644
index 398fb4a..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * Adapted from Herb Marselas
-"Profiling, Data Analysis, Scalability, and Magic Numbers: Meeting the Minimum System Requirements for AGE OF EMPIRES 2: THE AGE OF KINGS"
-Game Developer magazine
-June, 2000 issue.
-*/
-
-#include "profile.h"
-#include <string.h>
-#include <stdio.h>
-#include <time.h>
-//==============================================================================
-static OPJ_PROFILE_LIST group_list [PGROUP_LASTGROUP];
-
-//==============================================================================
-static void GetTimeStamp(OPJ_UINT32 *pdwtime);
-
-//==============================================================================
-#define SetMajorSection(entry, major) \
-        { group_list[ entry ].section = entry ; \
-          group_list[ entry ].sectionName = #major ; }
-
-//==============================================================================
-void _ProfInit(void)
-{
-   // clear everything out
-   memset(group_list, 0, sizeof(group_list));
-
-   // set groups and parents for timing
-   SetMajorSection(PGROUP_DWT,PGROUP_DWT);
-   SetMajorSection(PGROUP_T1, PGROUP_T1);
-   SetMajorSection(PGROUP_T2, PGROUP_T2);
-} // ProfInit
-
-//==============================================================================
-void _ProfStart (OPJ_PROFILE_GROUP group)
-{
-   // make sure this hasn't been incorrectly started twice
-   if (group_list[group].start)
-   {
-      return;
-   }
-
-   // get the start time
-   GetTimeStamp(&(group_list[group].start));
-
-} // _ProfStart
-
-//==============================================================================
-void _ProfStop(OPJ_PROFILE_GROUP group)
-{
-   // make sure we called start first
-   if (!group_list[group].start)
-   {
-      return;
-   }
-
-   // get ending time
-   GetTimeStamp(&(group_list[group].end));
-
-   // calculate this latest elapsed interval
-   group_list[group].total_time += group_list[group].end - group_list[group].start;
-
-   // reset starting time
-   group_list[group].start = 0;
-
-   // incr the number of calls made
-   ++group_list[group].totalCalls;
-
-} // _ProfStop
-
-//==============================================================================
-#define proftracef(id,totalTime) \
-        fprintf(p, #id "\t%u\t\t%6.6f\t\t%12.6f\t%2.2f%%\n",  \
-                group_list[ id ].totalCalls, \
-               (OPJ_FLOAT64) group_list[ id ].total_time / CLOCKS_PER_SEC, \
-               ((OPJ_FLOAT64) group_list[ id ].total_time / (group_list[ id ].totalCalls ? group_list[ id ].totalCalls : 1)), \
-         ((OPJ_FLOAT64) group_list[ id ].total_time / totalTime * 100))
-
-#define proftracep(id,totalTime) \
-        printf(#id "\t%u\t\t%6.6f\t\t%12.6f\t%2.2f%%\n",  \
-                group_list[ id ].totalCalls, \
-               (OPJ_FLOAT64) group_list[ id ].total_time / CLOCKS_PER_SEC, \
-               ((OPJ_FLOAT64) group_list[ id ].total_time  / (group_list[ id ].totalCalls ? group_list[ id ].totalCalls : 1)), \
-         ((OPJ_FLOAT64) group_list[ id ].total_time / totalTime * 100))
-
-//==============================================================================
-void _ProfSave(const OPJ_CHAR * pFileName)
-{
-  FILE *p = fopen(pFileName, "wt");
-  OPJ_FLOAT64 totalTime = 0.;
-  OPJ_UINT32 i;
-
-  if (!p)
-  {
-    return;
-  }
-
-  for
-    (i=0;i<PGROUP_LASTGROUP;++i)
-  {
-    totalTime += group_list[i].total_time;
-  }
-
-  fputs("\n\nProfile Data:\n", p);
-  fputs("description\tnb calls\ttotal time (sec)\ttime per call\t%% of section\n", p);
-
-  proftracef(PGROUP_DWT,totalTime);
-  proftracef(PGROUP_T1,totalTime);
-  proftracef(PGROUP_T2,totalTime);
-
-   fputs("=== end of profile list ===\n\n", p);
-
-   fclose(p);
-
-} // _ProfSave
-
-//==============================================================================
-void _ProfPrint(void)
-{
-  OPJ_FLOAT64 totalTime = 0.;
-  OPJ_UINT32 i;
-
-  for
-    (i=0;i<PGROUP_LASTGROUP;++i)
-  {
-    totalTime += group_list[i].total_time;
-  }
-
-  printf("\n\nProfile Data:\n");
-  printf("description\tnb calls\ttotal time (sec)\ttime per call\t%% of section\n");
-
-  proftracep(PGROUP_RATE, totalTime);
-  proftracep(PGROUP_DC_SHIFT, totalTime);
-  proftracep(PGROUP_MCT, totalTime);
-  proftracep(PGROUP_DWT, totalTime);
-  proftracep(PGROUP_T1, totalTime);
-  proftracep(PGROUP_T2, totalTime);
-
-  printf("\nTotal time: %6.3f second(s)\n", totalTime / CLOCKS_PER_SEC);
-
-  printf("=== end of profile list ===\n\n");
-
-} // _ProfPrint
-
-//==============================================================================
-static void GetTimeStamp(unsigned *time)
-{
-   *time = clock();
-
-} // GetTimeStamp
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.h
deleted file mode 100644
index da20856..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/profile.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * Adapted from Herb Marselas
-"Profiling, Data Analysis, Scalability, and Magic Numbers: Meeting the Minimum System Requirements for AGE OF EMPIRES 2: THE AGE OF KINGS"
-Game Developer magazine
-June, 2000 issue.
-*/
-
-
-#ifndef __PROFILE_H
-#define __PROFILE_H
-
-#include "openjpeg.h"
-//==============================================================================
-typedef enum
-{
-  PGROUP_RATE,
-  PGROUP_DC_SHIFT,
-  PGROUP_MCT,
-  PGROUP_DWT,
-  PGROUP_T1,
-  PGROUP_T2,
-  PGROUP_LASTGROUP
-} OPJ_PROFILE_GROUP;
-
-//==============================================================================
-typedef struct PROFILELIST
-{
-  OPJ_UINT32   start;
-  OPJ_UINT32   end;
-    OPJ_UINT32   total_time;
-    OPJ_UINT32   totalCalls;
-    OPJ_PROFILE_GROUP   section;
-    const OPJ_CHAR     *sectionName; // string name of the profile group
-} OPJ_PROFILE_LIST;
-
-//==============================================================================
-void _ProfStart(OPJ_PROFILE_GROUP group);
-void _ProfStop (OPJ_PROFILE_GROUP group);
-
-//==============================================================================
-//==============================================================================
-#ifdef _PROFILE
-#define PROFINIT() _ProfInit();
-#define PROFSTART (group) _ProfStart (group);
-#define PROFSTOP (group) _ProfStop (group);
-#define PROFSAVE(file) _ProfSave(file);
-#define PROFPRINT() _ProfPrint();
-#else
-#define PROFINIT()
-#define PROFSTART(group)
-#define PROFSTOP (group)
-#define PROFSAVE(file)
-#define PROFPRINT()
-#endif // !_PROFILE
-
-//==============================================================================
-#endif // __PROFILE_H
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.c
deleted file mode 100644
index b3466dc..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "raw.h"
-#include "opj_malloc.h"
-
-/*
-==========================================================
-   local functions
-==========================================================
-*/
-
-
-/*
-==========================================================
-   RAW encoding interface
-==========================================================
-*/
-
-opj_raw_t* raw_create(void) {
-  opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
-  return raw;
-}
-
-void raw_destroy(opj_raw_t *raw) {
-  if(raw) {
-    opj_free(raw);
-  }
-}
-
-OPJ_UINT32 raw_numbytes(opj_raw_t *raw) {
-  return raw->bp - raw->start;
-}
-
-void raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len) {
-  raw->start = bp;
-  raw->lenmax = len;
-  raw->len = 0;
-  raw->c = 0;
-  raw->ct = 0;
-}
-
-OPJ_UINT32 raw_decode(opj_raw_t *raw) {
-  OPJ_UINT32 d;
-  if (raw->ct == 0) {
-    raw->ct = 8;
-    if (raw->len == raw->lenmax) {
-      raw->c = 0xff;
-    } else {
-      if (raw->c == 0xff) {
-        raw->ct = 7;
-      }
-      raw->c = *(raw->start + raw->len);
-      raw->len++;
-    }
-  }
-  raw->ct--;
-  d = (raw->c >> raw->ct) & 0x01;
-
-  return d;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.h
deleted file mode 100644
index 7f02052..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/raw.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __RAW_H
-#define __RAW_H
-/**
- at file raw.h
- at brief Implementation of operations for raw encoding (RAW)
-
-The functions in RAW.C have for goal to realize the operation of raw encoding linked
-with the corresponding mode switch.
-*/
-#include "openjpeg.h"
-/** @defgroup RAW RAW - Implementation of operations for raw encoding */
-/*@{*/
-
-/**
-RAW encoding operations
-*/
-typedef struct opj_raw {
-  /** temporary buffer where bits are coded or decoded */
-  OPJ_BYTE c;
-  /** number of bits already read or free to write */
-  OPJ_UINT32 ct;
-  /** maximum length to decode */
-  OPJ_UINT32 lenmax;
-  /** length decoded */
-  OPJ_UINT32 len;
-  /** pointer to the current position in the buffer */
-  OPJ_BYTE *bp;
-  /** pointer to the start of the buffer */
-  OPJ_BYTE *start;
-  /** pointer to the end of the buffer */
-  unsigned char *end;
-} opj_raw_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Create a new RAW handle
- at return Returns a new RAW handle if successful, returns NULL otherwise
-*/
-opj_raw_t* raw_create(void);
-/**
-Destroy a previously created RAW handle
- at param raw RAW handle to destroy
-*/
-void raw_destroy(opj_raw_t *raw);
-/**
-Return the number of bytes written/read since initialisation
- at param raw RAW handle to destroy
- at return Returns the number of bytes already encoded
-*/
-OPJ_UINT32 raw_numbytes(opj_raw_t *raw);
-/**
-Initialize the decoder
- at param raw RAW handle
- at param bp Pointer to the start of the buffer from which the bytes will be read
- at param len Length of the input buffer
-*/
-void raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len);
-/**
-Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
- at param raw RAW handle
- at return Returns the decoded symbol (0 or 1)
-*/
-OPJ_UINT32 raw_decode(opj_raw_t *raw);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __RAW_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.c
deleted file mode 100644
index 68e2e53..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.c
+++ /dev/null
@@ -1,1284 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "t1.h"
-#include "t1_luts.h"
-#include "opj_includes.h"
-#include "j2k.h"
-#include "tcd.h"
-#include "mqc.h"
-#include "raw.h"
-#include "opj_malloc.h"
-#include "int.h"
-#include "dwt.h"
-#include "fix.h"
-/** @defgroup T1 T1 - Implementation of the tier-1 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static INLINE OPJ_BYTE t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient);
-static OPJ_BYTE t1_getctxno_sc(OPJ_UINT32 f);
-static INLINE OPJ_UINT32 t1_getctxno_mag(OPJ_UINT32 f);
-static OPJ_BYTE t1_getspb(OPJ_UINT32 f);
-static OPJ_INT16 t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos);
-static OPJ_INT16 t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos);
-static void t1_updateflags(flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride);
-/**
-Encode significant pass
-*/
-static void t1_enc_sigpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 bpno,
-    OPJ_INT32 one,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc);
-/**
-Decode significant pass
-*/
-static void t1_dec_sigpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 oneplushalf,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc);
-/**
-Encode significant pass
-*/
-static void t1_enc_sigpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty);
-/**
-Decode significant pass
-*/
-static void t1_dec_sigpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty);
-/**
-Encode refinement pass
-*/
-static void t1_enc_refpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_INT32 bpno,
-    OPJ_INT32 one,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc);
-/**
-Decode refinement pass
-*/
-static void t1_dec_refpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_INT32 poshalf,
-    OPJ_INT32 neghalf,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc);
-/**
-Encode refinement pass
-*/
-static void t1_enc_refpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty);
-/**
-Decode refinement pass
-*/
-static void t1_dec_refpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty);
-/**
-Encode clean-up pass
-*/
-static void t1_enc_clnpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 bpno,
-    OPJ_INT32 one,
-    OPJ_INT32 *nmsedec,
-    OPJ_UINT32 partial,
-    OPJ_UINT32 vsc);
-/**
-Decode clean-up pass
-*/
-static void t1_dec_clnpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 oneplushalf,
-    OPJ_UINT32 partial,
-    OPJ_UINT32 vsc);
-/**
-Encode clean-up pass
-*/
-static void t1_enc_clnpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_INT32 *nmsedec,
-    OPJ_UINT32 cblksty);
-/**
-Decode clean-up pass
-*/
-static void t1_dec_clnpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_UINT32 cblksty);
-
-static OPJ_FLOAT64 t1_getwmsedec(
-    OPJ_INT32 nmsedec,
-    OPJ_UINT32 compno,
-    OPJ_UINT32 level,
-    OPJ_UINT32 orient,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 qmfbid,
-    OPJ_FLOAT64 stepsize,
-    OPJ_UINT32 numcomps,
-    const OPJ_FLOAT64 * mct_norms);
-/**
-Encode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param compno Component number
- at param level
- at param qmfbid
- at param stepsize
- at param cblksty Code-block style
- at param numcomps
- at param tile
-*/
-static void t1_encode_cblk(
-    opj_t1_t *t1,
-    opj_tcd_cblk_enc_t* cblk,
-    OPJ_UINT32 orient,
-    OPJ_UINT32 compno,
-    OPJ_UINT32 level,
-    OPJ_UINT32 qmfbid,
-    OPJ_FLOAT64 stepsize,
-    OPJ_UINT32 cblksty,
-    OPJ_UINT32 numcomps,
-    opj_tcd_tile_t * tile,
-    const OPJ_FLOAT64 * mct_norms);
-/**
-Decode 1 code-block
- at param t1 T1 handle
- at param cblk Code-block coding parameters
- at param orient
- at param roishift Region of interest shifting value
- at param cblksty Code-block style
-*/
-static void t1_decode_cblk(
-    opj_t1_t *t1,
-    opj_tcd_cblk_dec_t* cblk,
-    OPJ_UINT32 orient,
-    OPJ_UINT32 roishift,
-    OPJ_UINT32 cblksty);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-static OPJ_BYTE t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient) {
-  return lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)];
-}
-
-static OPJ_BYTE t1_getctxno_sc(OPJ_UINT32 f) {
-  return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
-}
-
-static OPJ_UINT32 t1_getctxno_mag(OPJ_UINT32 f) {
-  OPJ_UINT32 tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG;
-  OPJ_UINT32 tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1;
-  return (tmp2);
-}
-
-static OPJ_BYTE t1_getspb(OPJ_UINT32 f) {
-  return lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
-}
-
-static OPJ_INT16 t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos)
-{
-  if (bitpos > T1_NMSEDEC_FRACBITS) {
-    return lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-  }
-
-  return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static OPJ_INT16 t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
-  if (bitpos > T1_NMSEDEC_FRACBITS) {
-    return lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
-  }
-
-    return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
-}
-
-static void t1_updateflags(flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride) {
-  flag_t *np = flagsp - stride;
-  flag_t *sp = flagsp + stride;
-
-  static const flag_t mod[] = {
-    T1_SIG_S, T1_SIG_S|T1_SGN_S,
-    T1_SIG_E, T1_SIG_E|T1_SGN_E,
-    T1_SIG_W, T1_SIG_W|T1_SGN_W,
-    T1_SIG_N, T1_SIG_N|T1_SGN_N
-  };
-
-  np[-1] |= T1_SIG_SE;
-  np[0]  |= mod[s];
-  np[1]  |= T1_SIG_SW;
-
-  flagsp[-1] |= mod[s+2];
-  flagsp[0]  |= T1_SIG;
-  flagsp[1]  |= mod[s+4];
-
-  sp[-1] |= T1_SIG_NE;
-  sp[0]  |= mod[s+6];
-  sp[1]  |= T1_SIG_NW;
-}
-
-static void t1_enc_sigpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 bpno,
-    OPJ_INT32 one,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc)
-{
-  OPJ_INT32 v;
-  OPJ_UINT32 flag;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-  if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-    v = int_abs(*datap) & one ? 1 : 0;
-    mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));  /* ESSAI */
-    if (type == T1_TYPE_RAW) {  /* BYPASS/LAZY MODE */
-      mqc_bypass_enc(mqc, v);
-    } else {
-      mqc_encode(mqc, v);
-    }
-    if (v) {
-      v = *datap < 0 ? 1 : 0;
-      *nmsedec +=  t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
-      mqc_setcurctx(mqc, t1_getctxno_sc(flag));  /* ESSAI */
-      if (type == T1_TYPE_RAW) {  /* BYPASS/LAZY MODE */
-        mqc_bypass_enc(mqc, v);
-      } else {
-        mqc_encode(mqc, v ^ t1_getspb(flag));
-      }
-      t1_updateflags(flagsp, v, t1->flags_stride);
-    }
-    *flagsp |= T1_VISIT;
-  }
-}
-
-static void t1_dec_sigpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 oneplushalf,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc)
-{
-  OPJ_UINT32 v, flag;
-
-  opj_raw_t *raw = t1->raw;  /* RAW component */
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-  if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
-    if (type == T1_TYPE_RAW) {
-      if (raw_decode(raw)) {
-        v = raw_decode(raw);  /* ESSAI */
-        *datap = v ? -oneplushalf : oneplushalf;
-        t1_updateflags(flagsp, v, t1->flags_stride);
-      }
-    } else {
-      mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-      if (mqc_decode(mqc)) {
-        mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-        v = mqc_decode(mqc) ^ t1_getspb(flag);
-        *datap = v ? -oneplushalf : oneplushalf;
-        t1_updateflags(flagsp, v, t1->flags_stride);
-      }
-    }
-    *flagsp |= T1_VISIT;
-  }
-}        /* VSC and  BYPASS by Antonin */
-
-static void t1_enc_sigpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty)
-{
-  OPJ_UINT32 i, j, k, vsc;
-  OPJ_INT32 one;
-
-  *nmsedec = 0;
-  one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-  for (k = 0; k < t1->h; k += 4) {
-    for (i = 0; i < t1->w; ++i) {
-      for (j = k; j < k + 4 && j < t1->h; ++j) {
-        vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-        t1_enc_sigpass_step(
-            t1,
-            &t1->flags[((j+1) * t1->flags_stride) + i + 1],
-            &t1->data[(j * t1->w) + i],
-            orient,
-            bpno,
-            one,
-            nmsedec,
-            type,
-            vsc);
-      }
-    }
-  }
-}
-
-static void t1_dec_sigpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty)
-{
-  OPJ_UINT32 i, j, k, vsc;
-  OPJ_INT32 one, half, oneplushalf;
-  one = 1 << bpno;
-  half = one >> 1;
-  oneplushalf = one | half;
-  for (k = 0; k < t1->h; k += 4) {
-    for (i = 0; i < t1->w; ++i) {
-      for (j = k; j < k + 4 && j < t1->h; ++j) {
-        vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-        t1_dec_sigpass_step(
-            t1,
-            &t1->flags[((j+1) * t1->flags_stride) + i + 1],
-            &t1->data[(j * t1->w) + i],
-            orient,
-            oneplushalf,
-            type,
-            vsc);
-      }
-    }
-  }
-}        /* VSC and  BYPASS by Antonin */
-
-static void t1_enc_refpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_INT32 bpno,
-    OPJ_INT32 one,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc)
-{
-  OPJ_INT32 v;
-  OPJ_UINT32 flag;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-  if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-    *nmsedec += t1_getnmsedec_ref(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
-    v = int_abs(*datap) & one ? 1 : 0;
-    mqc_setcurctx(mqc, t1_getctxno_mag(flag));  /* ESSAI */
-    if (type == T1_TYPE_RAW) {  /* BYPASS/LAZY MODE */
-      mqc_bypass_enc(mqc, v);
-    } else {
-      mqc_encode(mqc, v);
-    }
-    *flagsp |= T1_REFINE;
-  }
-}
-
-static void t1_dec_refpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_INT32 poshalf,
-    OPJ_INT32 neghalf,
-    OPJ_BYTE type,
-    OPJ_UINT32 vsc)
-{
-  OPJ_INT32  t;
-  OPJ_UINT32 v,flag;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-  opj_raw_t *raw = t1->raw;  /* RAW component */
-
-  flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-  if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
-    mqc_setcurctx(mqc, t1_getctxno_mag(flag));  /* ESSAI */
-    if (type == T1_TYPE_RAW) {
-      v = raw_decode(raw);
-    } else {
-      v = mqc_decode(mqc);
-    }
-    t = v ? poshalf : neghalf;
-    *datap += *datap < 0 ? -t : t;
-    *flagsp |= T1_REFINE;
-  }
-}        /* VSC and  BYPASS by Antonin  */
-
-static void t1_enc_refpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_INT32 *nmsedec,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty)
-{
-  OPJ_UINT32 i, j, k, vsc;
-  OPJ_INT32 one;
-
-  *nmsedec = 0;
-  one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-  for (k = 0; k < t1->h; k += 4) {
-    for (i = 0; i < t1->w; ++i) {
-      for (j = k; j < k + 4 && j < t1->h; ++j) {
-        vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-        t1_enc_refpass_step(
-            t1,
-            &t1->flags[((j+1) * t1->flags_stride) + i + 1],
-            &t1->data[(j * t1->w) + i],
-            bpno,
-            one,
-            nmsedec,
-            type,
-            vsc);
-      }
-    }
-  }
-}
-
-static void t1_dec_refpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_BYTE type,
-    OPJ_UINT32 cblksty)
-{
-  OPJ_UINT32 i, j, k;
-  OPJ_INT32 one, poshalf, neghalf;
-  OPJ_UINT32 vsc;
-  one = 1 << bpno;
-  poshalf = one >> 1;
-  neghalf = bpno > 0 ? -poshalf : -1;
-  for (k = 0; k < t1->h; k += 4) {
-    for (i = 0; i < t1->w; ++i) {
-      for (j = k; j < k + 4 && j < t1->h; ++j) {
-        vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-        t1_dec_refpass_step(
-            t1,
-            &t1->flags[((j+1) * t1->flags_stride) + i + 1],
-            &t1->data[(j * t1->w) + i],
-            poshalf,
-            neghalf,
-            type,
-            vsc);
-      }
-    }
-  }
-}        /* VSC and  BYPASS by Antonin */
-
-static void t1_enc_clnpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 bpno,
-    OPJ_INT32 one,
-    OPJ_INT32 *nmsedec,
-    OPJ_UINT32 partial,
-    OPJ_UINT32 vsc)
-{
-  OPJ_INT32 v;
-  OPJ_UINT32 flag;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-  if (partial) {
-    goto LABEL_PARTIAL;
-  }
-  if (!(*flagsp & (T1_SIG | T1_VISIT))) {
-    mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-    v = int_abs(*datap) & one ? 1 : 0;
-    mqc_encode(mqc, v);
-    if (v) {
-LABEL_PARTIAL:
-      *nmsedec += t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
-      mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-      v = *datap < 0 ? 1 : 0;
-      mqc_encode(mqc, v ^ t1_getspb(flag));
-      t1_updateflags(flagsp, v, t1->flags_stride);
-    }
-  }
-  *flagsp &= ~T1_VISIT;
-}
-
-static void t1_dec_clnpass_step(
-    opj_t1_t *t1,
-    flag_t *flagsp,
-    OPJ_INT32 *datap,
-    OPJ_UINT32 orient,
-    OPJ_INT32 oneplushalf,
-    OPJ_UINT32 partial,
-    OPJ_UINT32 vsc)
-{
-  OPJ_INT32 v;
-  OPJ_UINT32 flag;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
-  if (partial) {
-    goto LABEL_PARTIAL;
-  }
-  if (!(flag & (T1_SIG | T1_VISIT))) {
-    mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
-    if (mqc_decode(mqc)) {
-LABEL_PARTIAL:
-      mqc_setcurctx(mqc, t1_getctxno_sc(flag));
-      v = mqc_decode(mqc) ^ t1_getspb(flag);
-      *datap = v ? -oneplushalf : oneplushalf;
-      t1_updateflags(flagsp, v, t1->flags_stride);
-    }
-  }
-  *flagsp &= ~T1_VISIT;
-}        /* VSC and  BYPASS by Antonin */
-
-static void t1_enc_clnpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_INT32 *nmsedec,
-    OPJ_UINT32 cblksty)
-{
-  OPJ_UINT32 i, j, k;
-  OPJ_INT32 one;
-  OPJ_UINT32 agg, runlen, vsc;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  *nmsedec = 0;
-  one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
-  for (k = 0; k < t1->h; k += 4) {
-    for (i = 0; i < t1->w; ++i) {
-      if (k + 3 < t1->h) {
-        if (cblksty & J2K_CCP_CBLKSTY_VSC) {
-          agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || (MACRO_t1_flags(1 + k + 3,1 + i)
-            & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |  T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-        } else {
-          agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-        }
-      } else {
-        agg = 0;
-      }
-      if (agg) {
-        for (runlen = 0; runlen < 4; ++runlen) {
-          if (int_abs(t1->data[((k + runlen)*t1->w) + i]) & one)
-            break;
-        }
-        mqc_setcurctx(mqc, T1_CTXNO_AGG);
-        mqc_encode(mqc, runlen != 4);
-        if (runlen == 4) {
-          continue;
-        }
-        mqc_setcurctx(mqc, T1_CTXNO_UNI);
-        mqc_encode(mqc, runlen >> 1);
-        mqc_encode(mqc, runlen & 1);
-      } else {
-        runlen = 0;
-      }
-      for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
-        vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-        t1_enc_clnpass_step(
-            t1,
-            &t1->flags[((j+1) * t1->flags_stride) + i + 1],
-            &t1->data[(j * t1->w) + i],
-            orient,
-            bpno,
-            one,
-            nmsedec,
-            agg && (j == k + runlen),
-            vsc);
-      }
-    }
-  }
-}
-
-static void t1_dec_clnpass(
-    opj_t1_t *t1,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 orient,
-    OPJ_UINT32 cblksty)
-{
-  OPJ_UINT32 i, j, k, one;
-  OPJ_INT32 half, oneplushalf;
-  OPJ_UINT32 agg, runlen, vsc;
-  OPJ_UINT32 segsym = cblksty & J2K_CCP_CBLKSTY_SEGSYM;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  one = 1 << bpno;
-  half = one >> 1;
-  oneplushalf = one | half;
-  for (k = 0; k < t1->h; k += 4) {
-    for (i = 0; i < t1->w; ++i) {
-      if (k + 3 < t1->h) {
-        if (cblksty & J2K_CCP_CBLKSTY_VSC) {
-          agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || (MACRO_t1_flags(1 + k + 3,1 + i)
-            & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |  T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-        } else {
-          agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
-            || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
-        }
-      } else {
-        agg = 0;
-      }
-      if (agg) {
-        mqc_setcurctx(mqc, T1_CTXNO_AGG);
-        if (!mqc_decode(mqc)) {
-          continue;
-        }
-        mqc_setcurctx(mqc, T1_CTXNO_UNI);
-        runlen = mqc_decode(mqc);
-        runlen = (runlen << 1) | mqc_decode(mqc);
-      } else {
-        runlen = 0;
-      }
-      for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
-        vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
-        t1_dec_clnpass_step(
-            t1,
-            &t1->flags[((j+1) * t1->flags_stride) + i + 1],
-            &t1->data[(j * t1->w) + i],
-            orient,
-            oneplushalf,
-            agg && (j == k + runlen),
-            vsc);
-      }
-    }
-  }
-  if (segsym) {
-    OPJ_UINT32 v = 0;
-    mqc_setcurctx(mqc, T1_CTXNO_UNI);
-    v = mqc_decode(mqc);
-    v = (v << 1) | mqc_decode(mqc);
-    v = (v << 1) | mqc_decode(mqc);
-    v = (v << 1) | mqc_decode(mqc);
-    /*
-    if (v!=0xa) {
-      opj_event_msg(t1->cinfo, EVT_WARNING, "Bad segmentation symbol %x\n", v);
-    }
-    */
-  }
-}        /* VSC and  BYPASS by Antonin */
-
-
-/** mod fixed_quality */
-static OPJ_FLOAT64 t1_getwmsedec(
-    OPJ_INT32 nmsedec,
-    OPJ_UINT32 compno,
-    OPJ_UINT32 level,
-    OPJ_UINT32 orient,
-    OPJ_INT32 bpno,
-    OPJ_UINT32 qmfbid,
-    OPJ_FLOAT64 stepsize,
-    OPJ_UINT32 numcomps,
-    const OPJ_FLOAT64 * mct_norms)
-{
-  OPJ_FLOAT64 w1 = 1, w2, wmsedec;
-  if
-    (mct_norms)
-  {
-    w1 = mct_norms[compno];
-  }
-  if (qmfbid == 1)
-  {
-    w2 = dwt_getnorm(level, orient);
-  } else {      /* if (qmfbid == 0) */
-    w2 = dwt_getnorm_real(level, orient);
-  }
-  wmsedec = w1 * w2 * stepsize * (1 << bpno);
-  wmsedec *= wmsedec * nmsedec / 8192.0;
-  return wmsedec;
-}
-
-static bool allocate_buffers(
-    opj_t1_t *t1,
-    OPJ_UINT32 w,
-    OPJ_UINT32 h)
-{
-  OPJ_UINT32 datasize=w * h;
-  OPJ_UINT32 flagssize;
-
-  if(datasize > t1->datasize){
-    opj_aligned_free(t1->data);
-    t1->data = (OPJ_INT32*) opj_aligned_malloc(datasize * sizeof(OPJ_INT32));
-    if(!t1->data){
-      return false;
-    }
-    t1->datasize=datasize;
-  }
-  memset(t1->data,0,datasize * sizeof(OPJ_INT32));
-
-  t1->flags_stride=w+2;
-  flagssize=t1->flags_stride * (h+2);
-
-  if(flagssize > t1->flagssize){
-    opj_aligned_free(t1->flags);
-    t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t));
-    if(!t1->flags){
-      return false;
-    }
-    t1->flagssize=flagssize;
-  }
-  memset(t1->flags,0,flagssize * sizeof(flag_t));
-
-  t1->w=w;
-  t1->h=h;
-
-  return true;
-}
-
-/** mod fixed_quality */
-static void t1_encode_cblk(
-    opj_t1_t *t1,
-    opj_tcd_cblk_enc_t* cblk,
-    OPJ_UINT32 orient,
-    OPJ_UINT32 compno,
-    OPJ_UINT32 level,
-    OPJ_UINT32 qmfbid,
-    OPJ_FLOAT64 stepsize,
-    OPJ_UINT32 cblksty,
-    OPJ_UINT32 numcomps,
-    opj_tcd_tile_t * tile,
-    const OPJ_FLOAT64 * mct_norms)
-{
-  OPJ_FLOAT64 cumwmsedec = 0.0;
-
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  OPJ_UINT32 passno;
-  OPJ_INT32 bpno;
-  OPJ_UINT32 passtype;
-  OPJ_INT32 nmsedec = 0;
-  OPJ_INT32 max;
-  OPJ_UINT32 i;
-  OPJ_BYTE type = T1_TYPE_MQ;
-  OPJ_FLOAT64 tempwmsedec;
-
-  max = 0;
-  for (i = 0; i < t1->w * t1->h; ++i) {
-    OPJ_INT32 tmp = abs(t1->data[i]);
-    max = int_max(max, tmp);
-  }
-
-  cblk->numbps = max ? (int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
-
-  bpno = cblk->numbps - 1;
-  passtype = 2;
-
-  mqc_resetstates(mqc);
-  mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
-  mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-  mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-  mqc_init_enc(mqc, cblk->data);
-
-  for (passno = 0; bpno >= 0; ++passno) {
-    opj_tcd_pass_t *pass = &cblk->passes[passno];
-    OPJ_UINT32 correction = 3;
-    type = ((bpno < ((OPJ_INT32) (cblk->numbps) - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-
-    switch (passtype) {
-      case 0:
-        t1_enc_sigpass(t1, bpno, orient, &nmsedec, type, cblksty);
-        break;
-      case 1:
-        t1_enc_refpass(t1, bpno, &nmsedec, type, cblksty);
-        break;
-      case 2:
-        t1_enc_clnpass(t1, bpno, orient, &nmsedec, cblksty);
-        /* code switch SEGMARK (i.e. SEGSYM) */
-        if (cblksty & J2K_CCP_CBLKSTY_SEGSYM)
-          mqc_segmark_enc(mqc);
-        break;
-    }
-
-    /* fixed_quality */
-    tempwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps,mct_norms) ;
-    cumwmsedec += tempwmsedec;
-    tile->distotile += tempwmsedec;
-
-    /* Code switch "RESTART" (i.e. TERMALL) */
-    if ((cblksty & J2K_CCP_CBLKSTY_TERMALL)  && !((passtype == 2) && (bpno - 1 < 0))) {
-      if (type == T1_TYPE_RAW) {
-        mqc_flush(mqc);
-        correction = 1;
-        /* correction = mqc_bypass_flush_enc(); */
-      } else {      /* correction = mqc_restart_enc(); */
-        mqc_flush(mqc);
-        correction = 1;
-      }
-      pass->term = 1;
-    } else {
-      if (((bpno < ((OPJ_INT32) (cblk->numbps) - 4) && (passtype > 0))
-        || ((bpno == (cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) {
-        if (type == T1_TYPE_RAW) {
-          mqc_flush(mqc);
-          correction = 1;
-          /* correction = mqc_bypass_flush_enc(); */
-        } else {    /* correction = mqc_restart_enc(); */
-          mqc_flush(mqc);
-          correction = 1;
-        }
-        pass->term = 1;
-      } else {
-        pass->term = 0;
-      }
-    }
-
-    if (++passtype == 3) {
-      passtype = 0;
-      bpno--;
-    }
-
-    if (pass->term && bpno > 0) {
-      type = ((bpno < ((OPJ_INT32) (cblk->numbps) - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-      if (type == T1_TYPE_RAW)
-        mqc_bypass_init_enc(mqc);
-      else
-        mqc_restart_init_enc(mqc);
-    }
-
-    pass->distortiondec = cumwmsedec;
-    pass->rate = mqc_numbytes(mqc) + correction;  /* FIXME */
-
-    /* Code-switch "RESET" */
-    if (cblksty & J2K_CCP_CBLKSTY_RESET)
-      mqc_reset_enc(mqc);
-  }
-
-  /* Code switch "ERTERM" (i.e. PTERM) */
-  if (cblksty & J2K_CCP_CBLKSTY_PTERM)
-    mqc_erterm_enc(mqc);
-  else /* Default coding */ if (!(cblksty & J2K_CCP_CBLKSTY_LAZY))
-    mqc_flush(mqc);
-
-  cblk->totalpasses = passno;
-
-  for (passno = 0; passno<cblk->totalpasses; passno++) {
-    opj_tcd_pass_t *pass = &cblk->passes[passno];
-    if (pass->rate > mqc_numbytes(mqc))
-      pass->rate = mqc_numbytes(mqc);
-    /*Preventing generation of FF as last data byte of a pass*/
-    if((pass->rate>1) && (cblk->data[pass->rate - 1] == 0xFF)){
-      pass->rate--;
-    }
-    pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);
-  }
-}
-
-static void t1_decode_cblk(
-    opj_t1_t *t1,
-    opj_tcd_cblk_dec_t* cblk,
-    OPJ_UINT32 orient,
-    OPJ_UINT32 roishift,
-    OPJ_UINT32 cblksty)
-{
-  opj_raw_t *raw = t1->raw;  /* RAW component */
-  opj_mqc_t *mqc = t1->mqc;  /* MQC component */
-
-  OPJ_INT32 bpno;
-  OPJ_UINT32 passtype;
-  OPJ_UINT32 segno, passno;
-  OPJ_BYTE type = T1_TYPE_MQ; /* BYPASS mode */
-
-  if(!allocate_buffers(
-        t1,
-        cblk->x1 - cblk->x0,
-        cblk->y1 - cblk->y0))
-  {
-    return;
-  }
-
-  bpno = roishift + cblk->numbps - 1;
-  passtype = 2;
-
-  mqc_resetstates(mqc);
-  mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
-  mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-  mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-
-  for (segno = 0; segno < cblk->real_num_segs; ++segno) {
-    opj_tcd_seg_t *seg = &cblk->segs[segno];
-
-    /* BYPASS mode */
-    type = ((bpno <= ((OPJ_INT32) (cblk->numbps) - 1) - 4) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
-    /* FIXME: slviewer gets here with a null pointer. Why? Partially downloaded and/or corrupt textures? */
-    if(seg->data == 00){
-      continue;
-    }
-    if (type == T1_TYPE_RAW) {
-      raw_init_dec(raw, (*seg->data) + seg->dataindex, seg->len);
-    } else {
-      mqc_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len);
-    }
-
-    for (passno = 0; passno < seg->real_num_passes; ++passno) {
-      switch (passtype) {
-        case 0:
-          t1_dec_sigpass(t1, bpno+1, orient, type, cblksty);
-          break;
-        case 1:
-          t1_dec_refpass(t1, bpno+1, type, cblksty);
-          break;
-        case 2:
-          t1_dec_clnpass(t1, bpno+1, orient, cblksty);
-          break;
-      }
-
-      if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
-        mqc_resetstates(mqc);
-        mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
-        mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-        mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
-      }
-      if (++passtype == 3) {
-        passtype = 0;
-        bpno--;
-      }
-    }
-  }
-}
-
-/* ----------------------------------------------------------------------- */
-/**
- * Creates a new Tier 1 handle
- * and initializes the look-up tables of the Tier-1 coder/decoder
- * @return a new T1 handle if successful, returns NULL otherwise
-*/
-opj_t1_t* t1_create()
-{
-  opj_t1_t *l_t1 = 00;
-
-  l_t1 = (opj_t1_t*) opj_malloc(sizeof(opj_t1_t));
-  if
-    (!l_t1)
-  {
-    return 00;
-  }
-  memset(l_t1,0,sizeof(opj_t1_t));
-
-  /* create MQC and RAW handles */
-  l_t1->mqc = mqc_create();
-  if
-    (! l_t1->mqc)
-  {
-    t1_destroy(l_t1);
-    return 00;
-  }
-  l_t1->raw = raw_create();
-  if
-    (! l_t1->raw)
-  {
-    t1_destroy(l_t1);
-    return 00;
-  }
-  return l_t1;
-}
-
-/**
- * Destroys a previously created T1 handle
- *
- * @param p_t1 Tier 1 handle to destroy
-*/
-void t1_destroy(opj_t1_t *p_t1)
-{
-  if
-    (! p_t1)
-  {
-    return;
-  }
-
-  /* destroy MQC and RAW handles */
-  mqc_destroy(p_t1->mqc);
-  p_t1->mqc = 00;
-  raw_destroy(p_t1->raw);
-  p_t1->raw = 00;
-  if
-    (p_t1->data)
-  {
-    opj_aligned_free(p_t1->data);
-    p_t1->data = 00;
-  }
-  if
-    (p_t1->flags)
-  {
-    opj_aligned_free(p_t1->flags);
-    p_t1->flags = 00;
-  }
-  opj_free(p_t1);
-}
-
-bool t1_encode_cblks(
-    opj_t1_t *t1,
-    opj_tcd_tile_t *tile,
-    opj_tcp_t *tcp,
-    const OPJ_FLOAT64 * mct_norms)
-{
-  OPJ_UINT32 compno, resno, bandno, precno, cblkno;
-
-  tile->distotile = 0;    /* fixed_quality */
-
-  for (compno = 0; compno < tile->numcomps; ++compno) {
-    opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
-    opj_tccp_t* tccp = &tcp->tccps[compno];
-    OPJ_UINT32 tile_w = tilec->x1 - tilec->x0;
-
-    for (resno = 0; resno < tilec->numresolutions; ++resno) {
-      opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-      for (bandno = 0; bandno < res->numbands; ++bandno) {
-        opj_tcd_band_t* restrict band = &res->bands[bandno];
-
-        for (precno = 0; precno < res->pw * res->ph; ++precno) {
-          opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-          for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
-            opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-            OPJ_INT32 * restrict datap;
-            OPJ_INT32* restrict tiledp;
-            OPJ_UINT32 cblk_w;
-            OPJ_UINT32 cblk_h;
-            OPJ_UINT32 i, j;
-
-            OPJ_INT32 x = cblk->x0 - band->x0;
-            OPJ_INT32 y = cblk->y0 - band->y0;
-            if (band->bandno & 1) {
-              opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-              x += pres->x1 - pres->x0;
-            }
-            if (band->bandno & 2) {
-              opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
-              y += pres->y1 - pres->y0;
-            }
-
-            if(!allocate_buffers(
-                  t1,
-                  cblk->x1 - cblk->x0,
-                  cblk->y1 - cblk->y0))
-            {
-              return false;
-            }
-
-            datap=t1->data;
-            cblk_w = t1->w;
-            cblk_h = t1->h;
-
-            tiledp=&tilec->data[(y * tile_w) + x];
-            if (tccp->qmfbid == 1) {
-              for (j = 0; j < cblk_h; ++j) {
-                for (i = 0; i < cblk_w; ++i) {
-                  OPJ_INT32 tmp = tiledp[(j * tile_w) + i];
-                  datap[(j * cblk_w) + i] = tmp << T1_NMSEDEC_FRACBITS;
-                }
-              }
-            } else {    /* if (tccp->qmfbid == 0) */
-              for (j = 0; j < cblk_h; ++j) {
-                for (i = 0; i < cblk_w; ++i) {
-                  OPJ_INT32 tmp = tiledp[(j * tile_w) + i];
-                  datap[(j * cblk_w) + i] =
-                    fix_mul(
-                    tmp,
-                    8192 * 8192 / ((OPJ_INT32) floor(band->stepsize * 8192))) >> (11 - T1_NMSEDEC_FRACBITS);
-                }
-              }
-            }
-
-            t1_encode_cblk(
-                t1,
-                cblk,
-                band->bandno,
-                compno,
-                tilec->numresolutions - 1 - resno,
-                tccp->qmfbid,
-                band->stepsize,
-                tccp->cblksty,
-                tile->numcomps,
-                tile,
-                mct_norms);
-
-          } /* cblkno */
-        } /* precno */
-      } /* bandno */
-    } /* resno  */
-  } /* compno  */
-  return true;
-}
-
-void t1_decode_cblks(
-    opj_t1_t* t1,
-    opj_tcd_tilecomp_t* tilec,
-    opj_tccp_t* tccp)
-{
-  OPJ_UINT32 resno, bandno, precno, cblkno;
-
-  OPJ_UINT32 tile_w = tilec->x1 - tilec->x0;
-
-  for (resno = 0; resno < tilec->minimum_num_resolutions; ++resno) {
-    opj_tcd_resolution_t* res = &tilec->resolutions[resno];
-
-    for (bandno = 0; bandno < res->numbands; ++bandno) {
-      opj_tcd_band_t* restrict band = &res->bands[bandno];
-
-      for (precno = 0; precno < res->pw * res->ph; ++precno) {
-        opj_tcd_precinct_t* precinct = &band->precincts[precno];
-
-        for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
-          opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
-          OPJ_INT32* restrict datap;
-          void* restrict tiledp;
-          OPJ_UINT32 cblk_w, cblk_h;
-          OPJ_INT32 x, y;
-          OPJ_UINT32 i, j;
-
-          t1_decode_cblk(
-              t1,
-              cblk,
-              band->bandno,
-              tccp->roishift,
-              tccp->cblksty);
-
-          x = cblk->x0 - band->x0;
-          y = cblk->y0 - band->y0;
-          if (band->bandno & 1) {
-            opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
-            x += pres->x1 - pres->x0;
-          }
-          if (band->bandno & 2) {
-            opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
-            y += pres->y1 - pres->y0;
-          }
-
-          datap=t1->data;
-          cblk_w = t1->w;
-          cblk_h = t1->h;
-
-          if (tccp->roishift) {
-            OPJ_INT32 thresh = 1 << tccp->roishift;
-            for (j = 0; j < cblk_h; ++j) {
-              for (i = 0; i < cblk_w; ++i) {
-                OPJ_INT32 val = datap[(j * cblk_w) + i];
-                OPJ_INT32 mag = abs(val);
-                if (mag >= thresh) {
-                  mag >>= tccp->roishift;
-                  datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;
-                }
-              }
-            }
-          }
-
-          tiledp=(void*)&tilec->data[(y * tile_w) + x];
-          if (tccp->qmfbid == 1) {
-            for (j = 0; j < cblk_h; ++j) {
-              for (i = 0; i < cblk_w; ++i) {
-                OPJ_INT32 tmp = datap[(j * cblk_w) + i];
-                ((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp / 2;
-              }
-            }
-          } else {    /* if (tccp->qmfbid == 0) */
-            for (j = 0; j < cblk_h; ++j) {
-              for (i = 0; i < cblk_w; ++i) {
-                float tmp = datap[(j * cblk_w) + i] * band->stepsize;
-                ((float*)tiledp)[(j * tile_w) + i] = tmp;
-              }
-            }
-          }
-          //opj_free(cblk->segs);
-          //cblk->segs = 00;
-        } /* cblkno */
-      } /* precno */
-    } /* bandno */
-  } /* resno */
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.h
deleted file mode 100644
index b98eca2..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __T1_H
-#define __T1_H
-/**
- at file t1.h
- at brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1)
-
-The functions in T1.C have for goal to realize the tier-1 coding operation. The functions
-in T1.C are used by some function in TCD.C.
-*/
-#include "openjpeg.h"
-/** @defgroup T1 T1 - Implementation of the tier-1 coding */
-/*@{*/
-//#include "raw.h"
-/* ----------------------------------------------------------------------- */
-#define T1_NMSEDEC_BITS 7
-
-#define T1_SIG_NE 0x0001  /**< Context orientation : North-East direction */
-#define T1_SIG_SE 0x0002  /**< Context orientation : South-East direction */
-#define T1_SIG_SW 0x0004  /**< Context orientation : South-West direction */
-#define T1_SIG_NW 0x0008  /**< Context orientation : North-West direction */
-#define T1_SIG_N 0x0010    /**< Context orientation : North direction */
-#define T1_SIG_E 0x0020    /**< Context orientation : East direction */
-#define T1_SIG_S 0x0040    /**< Context orientation : South direction */
-#define T1_SIG_W 0x0080    /**< Context orientation : West direction */
-#define T1_SIG_OTH (T1_SIG_N|T1_SIG_NE|T1_SIG_E|T1_SIG_SE|T1_SIG_S|T1_SIG_SW|T1_SIG_W|T1_SIG_NW)
-#define T1_SIG_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W)
-
-#define T1_SGN_N 0x0100
-#define T1_SGN_E 0x0200
-#define T1_SGN_S 0x0400
-#define T1_SGN_W 0x0800
-#define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W)
-
-#define T1_SIG 0x1000
-#define T1_REFINE 0x2000
-#define T1_VISIT 0x4000
-
-#define T1_NUMCTXS_ZC 9
-#define T1_NUMCTXS_SC 5
-#define T1_NUMCTXS_MAG 3
-#define T1_NUMCTXS_AGG 1
-#define T1_NUMCTXS_UNI 1
-
-#define T1_CTXNO_ZC 0
-#define T1_CTXNO_SC (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
-#define T1_CTXNO_MAG (T1_CTXNO_SC+T1_NUMCTXS_SC)
-#define T1_CTXNO_AGG (T1_CTXNO_MAG+T1_NUMCTXS_MAG)
-#define T1_CTXNO_UNI (T1_CTXNO_AGG+T1_NUMCTXS_AGG)
-#define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
-
-#define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
-
-#define T1_TYPE_MQ 0  /**< Normal coding using entropy coder */
-#define T1_TYPE_RAW 1  /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/
-
-/* ----------------------------------------------------------------------- */
-struct opj_common_struct;
-struct opj_tcd_tile;
-struct opj_tcp;
-struct opj_tcd_tilecomp;
-struct opj_mqc;
-struct opj_raw;
-struct opj_tccp;
-
-
-typedef short flag_t;
-
-/**
-Tier-1 coding (coding of code-block coefficients)
-*/
-typedef struct opj_t1 {
-  /** MQC component */
-  struct opj_mqc *mqc;
-  /** RAW component */
-  struct opj_raw *raw;
-
-  OPJ_INT32 *data;
-  flag_t *flags;
-  OPJ_UINT32 w;
-  OPJ_UINT32 h;
-  OPJ_UINT32 datasize;
-  OPJ_UINT32 flagssize;
-  OPJ_UINT32 flags_stride;
-} opj_t1_t;
-
-#define MACRO_t1_flags(x,y) t1->flags[((x)*(t1->flags_stride))+(y)]
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
- * Creates a new Tier 1 handle
- * and initializes the look-up tables of the Tier-1 coder/decoder
- * @return a new T1 handle if successful, returns NULL otherwise
-*/
-opj_t1_t* t1_create();
-
-/**
- * Destroys a previously created T1 handle
- *
- * @param p_t1 Tier 1 handle to destroy
-*/
-void t1_destroy(opj_t1_t *p_t1);
-
-/**
-Encode the code-blocks of a tile
- at param t1 T1 handle
- at param tile The tile to encode
- at param tcp Tile coding parameters
-*/
-bool t1_encode_cblks(opj_t1_t *t1, struct opj_tcd_tile *tile, struct opj_tcp *tcp,const OPJ_FLOAT64 * mct_norms);
-/**
-Decode the code-blocks of a tile
- at param t1 T1 handle
- at param tile The tile to decode
- at param tcp Tile coding parameters
-*/
-void t1_decode_cblks(opj_t1_t* t1, struct opj_tcd_tilecomp* tilec, struct opj_tccp* tccp);
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __T1_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1_luts.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1_luts.h
deleted file mode 100644
index da400ae..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t1_luts.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* This file was automatically generated by t1_generate_luts.c */
-
-static char lut_ctxno_zc[1024] = {
-  0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-  5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-  5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  0, 3, 3, 6, 3, 6, 6, 8, 3, 6, 6, 8, 6, 8, 8, 8, 1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8,
-  1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8,
-  1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8,
-  2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8,
-  1, 4, 4, 7, 4, 7, 7, 8, 4, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8,
-  2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8,
-  2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8,
-  2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8
-};
-
-static char lut_ctxno_sc[256] = {
-  0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa,
-  0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xb, 0x9, 0xa, 0xd, 0xc, 0xa, 0x9,
-  0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xd, 0xc, 0xd, 0xb, 0xc, 0xb, 0xc,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xb, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xd, 0x9, 0xa, 0xb, 0xc, 0xa, 0x9,
-  0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xb, 0x9, 0xa, 0xb, 0xb, 0xa, 0xa,
-  0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xb, 0x9, 0xa, 0xb, 0xb, 0xa, 0xa,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xd, 0x9, 0xa, 0xb, 0xc, 0xa, 0x9,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xb, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb,
-  0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xd, 0xc, 0xd, 0xb, 0xc, 0xb, 0xc,
-  0x9, 0xa, 0xc, 0xd, 0xa, 0x9, 0xb, 0xc, 0xc, 0xb, 0x9, 0xa, 0xd, 0xc, 0xa, 0x9,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa,
-  0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc,
-  0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd
-};
-
-static char lut_spb[256] = {
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0,
-  0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1,
-  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0,
-  0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-  0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1,
-  0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-};
-
-static short lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0180, 0x0300, 0x0480, 0x0600, 0x0780, 0x0900, 0x0a80,
-  0x0c00, 0x0d80, 0x0f00, 0x1080, 0x1200, 0x1380, 0x1500, 0x1680,
-  0x1800, 0x1980, 0x1b00, 0x1c80, 0x1e00, 0x1f80, 0x2100, 0x2280,
-  0x2400, 0x2580, 0x2700, 0x2880, 0x2a00, 0x2b80, 0x2d00, 0x2e80,
-  0x3000, 0x3180, 0x3300, 0x3480, 0x3600, 0x3780, 0x3900, 0x3a80,
-  0x3c00, 0x3d80, 0x3f00, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680,
-  0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5100, 0x5280,
-  0x5400, 0x5580, 0x5700, 0x5880, 0x5a00, 0x5b80, 0x5d00, 0x5e80,
-  0x6000, 0x6180, 0x6300, 0x6480, 0x6600, 0x6780, 0x6900, 0x6a80,
-  0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680
-};
-
-static short lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080,
-  0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
-  0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400,
-  0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
-  0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00,
-  0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180,
-  0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780,
-  0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00,
-  0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2680, 0x2780,
-  0x2880, 0x2980, 0x2b00, 0x2c00, 0x2d00, 0x2e80, 0x2f80, 0x3100,
-  0x3200, 0x3380, 0x3480, 0x3600, 0x3700, 0x3880, 0x3a00, 0x3b00,
-  0x3c80, 0x3e00, 0x3f80, 0x4080, 0x4200, 0x4380, 0x4500, 0x4680,
-  0x4800, 0x4980, 0x4b00, 0x4c80, 0x4e00, 0x4f80, 0x5180, 0x5300,
-  0x5480, 0x5600, 0x5800, 0x5980, 0x5b00, 0x5d00, 0x5e80, 0x6080,
-  0x6200, 0x6400, 0x6580, 0x6780, 0x6900, 0x6b00, 0x6d00, 0x6e80,
-  0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00
-};
-
-static short lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
-  0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480,
-  0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080,
-  0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80,
-  0x0c00, 0x0b80, 0x0b00, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880,
-  0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0500, 0x0480,
-  0x0400, 0x0380, 0x0300, 0x0280, 0x0200, 0x0180, 0x0100, 0x0080,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380,
-  0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
-  0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b00, 0x0b80,
-  0x0c00, 0x0c80, 0x0d00, 0x0d80, 0x0e00, 0x0e80, 0x0f00, 0x0f80,
-  0x1000, 0x1080, 0x1100, 0x1180, 0x1200, 0x1280, 0x1300, 0x1380,
-  0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780
-};
-
-static short lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {
-  0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980,
-  0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300,
-  0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00,
-  0x0c80, 0x0c00, 0x0b80, 0x0a80, 0x0a00, 0x0980, 0x0900, 0x0880,
-  0x0800, 0x0780, 0x0700, 0x0680, 0x0600, 0x0580, 0x0580, 0x0500,
-  0x0480, 0x0400, 0x0400, 0x0380, 0x0300, 0x0300, 0x0280, 0x0280,
-  0x0200, 0x0200, 0x0180, 0x0180, 0x0100, 0x0100, 0x0100, 0x0080,
-  0x0080, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080,
-  0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
-  0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400,
-  0x0480, 0x0500, 0x0580, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
-  0x0800, 0x0880, 0x0900, 0x0980, 0x0a00, 0x0a80, 0x0b80, 0x0c00,
-  0x0c80, 0x0d00, 0x0e00, 0x0e80, 0x0f00, 0x1000, 0x1080, 0x1180,
-  0x1200, 0x1300, 0x1380, 0x1480, 0x1500, 0x1600, 0x1700, 0x1780,
-  0x1880, 0x1980, 0x1a80, 0x1b00, 0x1c00, 0x1d00, 0x1e00, 0x1f00
-};
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.c
deleted file mode 100644
index 812f70a..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.c
+++ /dev/null
@@ -1,1287 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include "openjpeg.h"
-#include "opj_includes.h"
-#include "t2.h"
-#include "bio.h"
-#include "tcd.h"
-#include "pi.h"
-#include "event.h"
-#include "j2k.h"
-#include "tgt.h"
-#include "int.h"
-#include "opj_malloc.h"
-#include "pi.h"
-
-
-/** @defgroup T2 T2 - Implementation of a tier-2 coding */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-static void t2_putcommacode(opj_bio_t *bio, OPJ_UINT32 n);
-static OPJ_UINT32 t2_getcommacode(opj_bio_t *bio);
-/**
-Variable length code for signalling delta Zil (truncation point)
- at param bio Bit Input/Output component
- at param n delta Zil
-*/
-static void t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n);
-static OPJ_UINT32 t2_getnumpasses(opj_bio_t *bio);
-/**
-Encode a packet of a tile to a destination buffer
- at param tile Tile for which to write the packets
- at param tcp Tile coding parameters
- at param pi Packet identity
- at param dest Destination buffer
- at param len Length of the destination buffer
- at param cstr_info Codestream information structure
- at param tileno Number of the tile encoded
- at return
-*/
-static bool t2_encode_packet(
-               OPJ_UINT32 tileno,
-               opj_tcd_tile_t *tile,
-               opj_tcp_t *tcp,
-               opj_pi_iterator_t *pi,
-               OPJ_BYTE *dest,
-               OPJ_UINT32 * p_data_written,
-               OPJ_UINT32 len,
-               opj_codestream_info_t *cstr_info);
-/**
- at param seg
- at param cblksty
- at param first
-*/
-static bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, OPJ_UINT32 index, OPJ_UINT32 cblksty, OPJ_UINT32 first);
-/**
-Decode a packet of a tile from a source buffer
- at param t2 T2 handle
- at param src Source buffer
- at param len Length of the source buffer
- at param tile Tile for which to write the packets
- at param tcp Tile coding parameters
- at param pi Packet identity
- at return
-*/
-static bool t2_decode_packet(
-               opj_t2_t* p_t2,
-               opj_tcd_tile_t *p_tile,
-                             opj_tcp_t *p_tcp,
-               opj_pi_iterator_t *p_pi,
-               OPJ_BYTE *p_src,
-               OPJ_UINT32 * p_data_read,
-               OPJ_UINT32 p_max_length,
-               opj_packet_info_t *p_pack_info);
-
-/*@}*/
-
-/*@}*/
-
-/* ----------------------------------------------------------------------- */
-
-/* #define RESTART 0x04 */
-
-static void t2_putcommacode(opj_bio_t *bio, OPJ_UINT32 n) {
-  while
-    (--n != -1)
-  {
-    bio_write(bio, 1, 1);
-  }
-  bio_write(bio, 0, 1);
-}
-
-static OPJ_UINT32 t2_getcommacode(opj_bio_t *bio) {
-  OPJ_UINT32 n = 0;
-  while
-    (bio_read(bio, 1))
-  {
-    ++n;
-  }
-  return n;
-}
-
-static void t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n) {
-  if (n == 1) {
-    bio_write(bio, 0, 1);
-  } else if (n == 2) {
-    bio_write(bio, 2, 2);
-  } else if (n <= 5) {
-    bio_write(bio, 0xc | (n - 3), 4);
-  } else if (n <= 36) {
-    bio_write(bio, 0x1e0 | (n - 6), 9);
-  } else if (n <= 164) {
-    bio_write(bio, 0xff80 | (n - 37), 16);
-  }
-}
-
-static OPJ_UINT32 t2_getnumpasses(opj_bio_t *bio) {
-  OPJ_UINT32 n;
-  if (!bio_read(bio, 1))
-    return 1;
-  if (!bio_read(bio, 1))
-    return 2;
-  if ((n = bio_read(bio, 2)) != 3)
-    return (3 + n);
-  if ((n = bio_read(bio, 5)) != 31)
-    return (6 + n);
-  return (37 + bio_read(bio, 7));
-}
-
-static bool t2_encode_packet(
-               OPJ_UINT32 tileno,
-               opj_tcd_tile_t * tile,
-               opj_tcp_t * tcp,
-               opj_pi_iterator_t *pi,
-               OPJ_BYTE *dest,
-               OPJ_UINT32 * p_data_written,
-               OPJ_UINT32 length,
-               opj_codestream_info_t *cstr_info)
-{
-  OPJ_UINT32 bandno, cblkno;
-  OPJ_BYTE *c = dest;
-  OPJ_UINT32 l_nb_bytes;
-  OPJ_UINT32 compno = pi->compno;  /* component value */
-  OPJ_UINT32 resno  = pi->resno;    /* resolution level value */
-  OPJ_UINT32 precno = pi->precno;  /* precinct value */
-  OPJ_UINT32 layno  = pi->layno;    /* quality layer value */
-  OPJ_UINT32 l_nb_blocks;
-  opj_tcd_band_t *band = 00;
-  opj_tcd_cblk_enc_t* cblk = 00;
-  opj_tcd_pass_t *pass = 00;
-
-  opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
-  opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-  opj_bio_t *bio = 00;  /* BIO component */
-
-  /* <SOP 0xff91> */
-  if (tcp->csty & J2K_CP_CSTY_SOP) {
-    c[0] = 255;
-    c[1] = 145;
-    c[2] = 0;
-    c[3] = 4;
-    c[4] = (tile->packno % 65536) / 256;
-    c[5] = (tile->packno % 65536) % 256;
-    c += 6;
-    length -= 6;
-  }
-  /* </SOP> */
-
-  if (!layno) {
-    band = res->bands;
-    for
-      (bandno = 0; bandno < res->numbands; ++bandno)
-    {
-      opj_tcd_precinct_t *prc = &band->precincts[precno];
-      tgt_reset(prc->incltree);
-      tgt_reset(prc->imsbtree);
-      l_nb_blocks = prc->cw * prc->ch;
-      for
-        (cblkno = 0; cblkno < l_nb_blocks; ++cblkno)
-      {
-        opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
-        cblk->numpasses = 0;
-        tgt_setvalue(prc->imsbtree, cblkno, band->numbps - cblk->numbps);
-      }
-      ++band;
-    }
-  }
-
-  bio = bio_create();
-  bio_init_enc(bio, c, length);
-  bio_write(bio, 1, 1);    /* Empty header bit */
-
-  /* Writing Packet header */
-  band = res->bands;
-  for
-    (bandno = 0; bandno < res->numbands; ++bandno)
-  {
-    opj_tcd_precinct_t *prc = &band->precincts[precno];
-    l_nb_blocks = prc->cw * prc->ch;
-    cblk = prc->cblks.enc;
-    for (cblkno = 0; cblkno < l_nb_blocks; ++cblkno)
-    {
-      opj_tcd_layer_t *layer = &cblk->layers[layno];
-      if
-        (!cblk->numpasses && layer->numpasses)
-      {
-        tgt_setvalue(prc->incltree, cblkno, layno);
-      }
-      ++cblk;
-    }
-    cblk = prc->cblks.enc;
-    for
-      (cblkno = 0; cblkno < l_nb_blocks; cblkno++)
-    {
-      opj_tcd_layer_t *layer = &cblk->layers[layno];
-      OPJ_UINT32 increment = 0;
-      OPJ_UINT32 nump = 0;
-      OPJ_UINT32 len = 0, passno;
-      OPJ_UINT32 l_nb_passes;
-      /* cblk inclusion bits */
-      if (!cblk->numpasses) {
-        tgt_encode(bio, prc->incltree, cblkno, layno + 1);
-      } else {
-        bio_write(bio, layer->numpasses != 0, 1);
-      }
-      /* if cblk not included, go to the next cblk  */
-      if
-        (!layer->numpasses)
-      {
-        ++cblk;
-        continue;
-      }
-      /* if first instance of cblk --> zero bit-planes information */
-      if
-        (!cblk->numpasses)
-      {
-        cblk->numlenbits = 3;
-        tgt_encode(bio, prc->imsbtree, cblkno, 999);
-      }
-      /* number of coding passes included */
-      t2_putnumpasses(bio, layer->numpasses);
-      l_nb_passes = cblk->numpasses + layer->numpasses;
-      pass = cblk->passes +  cblk->numpasses;
-      /* computation of the increase of the length indicator and insertion in the header     */
-      for
-        (passno = cblk->numpasses; passno < l_nb_passes; ++passno)
-      {
-        ++nump;
-        len += pass->len;
-        if
-          (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1)
-        {
-          increment = int_max(increment, int_floorlog2(len) + 1 - (cblk->numlenbits + int_floorlog2(nump)));
-          len = 0;
-          nump = 0;
-        }
-        ++pass;
-      }
-      t2_putcommacode(bio, increment);
-
-      /* computation of the new Length indicator */
-      cblk->numlenbits += increment;
-
-      pass = cblk->passes +  cblk->numpasses;
-      /* insertion of the codeword segment length */
-      for
-        (passno = cblk->numpasses; passno < l_nb_passes; ++passno)
-      {
-        nump++;
-        len += pass->len;
-        if
-          (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1)
-        {
-          bio_write(bio, len, cblk->numlenbits + int_floorlog2(nump));
-          len = 0;
-          nump = 0;
-        }
-        ++pass;
-      }
-      ++cblk;
-    }
-    ++band;
-  }
-
-  if
-    (bio_flush(bio))
-  {
-    bio_destroy(bio);
-    return false;    /* modified to eliminate longjmp !! */
-  }
-  l_nb_bytes = bio_numbytes(bio);
-  c += l_nb_bytes;
-  length -= l_nb_bytes;
-  bio_destroy(bio);
-
-  /* <EPH 0xff92> */
-  if (tcp->csty & J2K_CP_CSTY_EPH) {
-    c[0] = 255;
-    c[1] = 146;
-    c += 2;
-    length -= 2;
-  }
-  /* </EPH> */
-
-  /* << INDEX */
-  // End of packet header position. Currently only represents the distance to start of packet
-  // Will be updated later by incrementing with packet start value
-  if(cstr_info && cstr_info->index_write) {
-    opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
-    info_PK->end_ph_pos = (OPJ_INT32)(c - dest);
-  }
-  /* INDEX >> */
-
-  /* Writing the packet body */
-  band = res->bands;
-  for
-    (bandno = 0; bandno < res->numbands; bandno++)
-  {
-    opj_tcd_precinct_t *prc = &band->precincts[precno];
-    l_nb_blocks = prc->cw * prc->ch;
-    cblk = prc->cblks.enc;
-    for
-      (cblkno = 0; cblkno < l_nb_blocks; ++cblkno)
-    {
-      opj_tcd_layer_t *layer = &cblk->layers[layno];
-      if
-        (!layer->numpasses)
-      {
-        ++cblk;
-        continue;
-      }
-      if
-        (layer->len > length)
-      {
-        return false;
-      }
-      memcpy(c, layer->data, layer->len);
-      cblk->numpasses += layer->numpasses;
-      c += layer->len;
-      length -= layer->len;
-      /* << INDEX */
-      if(cstr_info && cstr_info->index_write) {
-        opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
-        info_PK->disto += layer->disto;
-        if (cstr_info->D_max < info_PK->disto) {
-          cstr_info->D_max = info_PK->disto;
-        }
-      }
-      ++cblk;
-      /* INDEX >> */
-    }
-    ++band;
-  }
-  * p_data_written += (c - dest);
-  return true;
-}
-
-static bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, OPJ_UINT32 index, OPJ_UINT32 cblksty, OPJ_UINT32 first)
-{
-  opj_tcd_seg_t* seg = 00;
-  OPJ_UINT32 l_nb_segs = index + 1;
-
-  if
-    (l_nb_segs > cblk->m_current_max_segs)
-  {
-    cblk->m_current_max_segs += J2K_DEFAULT_NB_SEGS;
-        cblk->segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, cblk->m_current_max_segs * sizeof(opj_tcd_seg_t));
-    if
-      (! cblk->segs)
-    {
-      return false;
-    }
-  }
-  seg = &cblk->segs[index];
-  memset(seg,0,sizeof(opj_tcd_seg_t));
-
-  if (cblksty & J2K_CCP_CBLKSTY_TERMALL) {
-    seg->maxpasses = 1;
-  }
-  else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
-    if (first) {
-      seg->maxpasses = 10;
-    } else {
-      seg->maxpasses = (((seg - 1)->maxpasses == 1) || ((seg - 1)->maxpasses == 10)) ? 2 : 1;
-    }
-  } else {
-    seg->maxpasses = 109;
-  }
-  return true;
-}
-
-static bool t2_read_packet_header(
-               opj_t2_t* p_t2,
-               opj_tcd_tile_t *p_tile,
-                             opj_tcp_t *p_tcp,
-               opj_pi_iterator_t *p_pi,
-               bool * p_is_data_present,
-               OPJ_BYTE *p_src_data,
-               OPJ_UINT32 * p_data_read,
-               OPJ_UINT32 p_max_length,
-               opj_packet_info_t *p_pack_info)
-{
-  /* loop */
-  OPJ_UINT32 bandno, cblkno;
-  OPJ_UINT32 l_nb_code_blocks;
-  OPJ_UINT32 l_remaining_length;
-  OPJ_UINT32 l_header_length;
-  OPJ_UINT32 * l_modified_length_ptr = 00;
-  OPJ_BYTE *l_current_data = p_src_data;
-  opj_cp_t *l_cp = p_t2->cp;
-  opj_bio_t *l_bio = 00;  /* BIO component */
-  opj_tcd_band_t *l_band = 00;
-  opj_tcd_cblk_dec_t* l_cblk = 00;
-  opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
-
-  OPJ_BYTE *l_header_data = 00;
-  OPJ_BYTE **l_header_data_start = 00;
-
-  OPJ_UINT32 l_present;
-
-  if
-    (p_pi->layno == 0)
-  {
-    l_band = l_res->bands;
-    /* reset tagtrees */
-    for
-      (bandno = 0; bandno < l_res->numbands; ++bandno)
-    {
-      opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
-
-      if (
-        ! ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)))
-      {
-        tgt_reset(l_prc->incltree);
-        tgt_reset(l_prc->imsbtree);
-        l_cblk = l_prc->cblks.dec;
-        l_nb_code_blocks = l_prc->cw * l_prc->ch;
-        for
-          (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
-        {
-          l_cblk->numsegs = 0;
-          l_cblk->real_num_segs = 0;
-          ++l_cblk;
-        }
-      }
-      ++l_band;
-    }
-  }
-
-  /* SOP markers */
-
-  if (p_tcp->csty & J2K_CP_CSTY_SOP) {
-    if ((*l_current_data) != 0xff || (*(l_current_data + 1) != 0x91)) {
-      // TODO opj_event_msg(t2->cinfo->event_mgr, EVT_WARNING, "Expected SOP marker\n");
-    } else {
-      l_current_data += 6;
-    }
-
-    /** TODO : check the Nsop value */
-  }
-
-  /*
-  When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
-  This part deal with this caracteristic
-  step 1: Read packet header in the saved structure
-  step 2: Return to codestream for decoding
-  */
-
-  l_bio = bio_create();
-  if
-    (! l_bio)
-  {
-    return false;
-  }
-
-  if
-    (l_cp->ppm == 1)
-  {    /* PPM */
-    l_header_data_start = &l_cp->ppm_data;
-    l_header_data = *l_header_data_start;
-    l_modified_length_ptr = &(l_cp->ppm_len);
-
-  }
-  else if
-    (p_tcp->ppt == 1)
-  {  /* PPT */
-    l_header_data_start = &(p_tcp->ppt_data);
-    l_header_data = *l_header_data_start;
-    l_modified_length_ptr = &(p_tcp->ppt_len);
-  }
-  else
-  {  /* Normal Case */
-    l_header_data_start = &(l_current_data);
-    l_header_data = *l_header_data_start;
-    l_remaining_length = p_src_data+p_max_length-l_header_data;
-    l_modified_length_ptr = &(l_remaining_length);
-  }
-  bio_init_dec(l_bio, l_header_data,*l_modified_length_ptr);
-  l_present = bio_read(l_bio, 1);
-  if
-    (!l_present)
-  {
-    bio_inalign(l_bio);
-    l_header_data += bio_numbytes(l_bio);
-    bio_destroy(l_bio);
-    /* EPH markers */
-    if (p_tcp->csty & J2K_CP_CSTY_EPH) {
-      if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
-        printf("Error : expected EPH marker\n");
-      } else {
-        l_header_data += 2;
-      }
-    }
-    l_header_length = (l_header_data - *l_header_data_start);
-    *l_modified_length_ptr -= l_header_length;
-    *l_header_data_start += l_header_length;
-    /* << INDEX */
-    // End of packet header position. Currently only represents the distance to start of packet
-    // Will be updated later by incrementing with packet start value
-    if
-      (p_pack_info)
-    {
-      p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
-    }
-    /* INDEX >> */
-    * p_is_data_present = false;
-    *p_data_read = l_current_data - p_src_data;
-    return true;
-  }
-
-  l_band = l_res->bands;
-  for
-    (bandno = 0; bandno < l_res->numbands; ++bandno)
-  {
-    opj_tcd_precinct_t *l_prc = &(l_band->precincts[p_pi->precno]);
-
-    if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0))
-    {
-      ++l_band;
-      continue;
-    }
-    l_nb_code_blocks = l_prc->cw * l_prc->ch;
-    l_cblk = l_prc->cblks.dec;
-    for
-      (cblkno = 0; cblkno < l_nb_code_blocks; cblkno++)
-    {
-      OPJ_UINT32 l_included,l_increment, l_segno;
-      OPJ_INT32 n;
-      /* if cblk not yet included before --> inclusion tagtree */
-      if
-        (!l_cblk->numsegs)
-      {
-        l_included = tgt_decode(l_bio, l_prc->incltree, cblkno, p_pi->layno + 1);
-        /* else one bit */
-      }
-      else
-      {
-        l_included = bio_read(l_bio, 1);
-      }
-      /* if cblk not included */
-      if
-        (!l_included)
-      {
-        l_cblk->numnewpasses = 0;
-        ++l_cblk;
-        continue;
-      }
-      /* if cblk not yet included --> zero-bitplane tagtree */
-      if
-        (!l_cblk->numsegs)
-      {
-        OPJ_UINT32 i = 0;
-        while
-          (!tgt_decode(l_bio, l_prc->imsbtree, cblkno, i))
-        {
-          ++i;
-        }
-        l_cblk->numbps = l_band->numbps + 1 - i;
-        l_cblk->numlenbits = 3;
-      }
-      /* number of coding passes */
-      l_cblk->numnewpasses = t2_getnumpasses(l_bio);
-      l_increment = t2_getcommacode(l_bio);
-      /* length indicator increment */
-      l_cblk->numlenbits += l_increment;
-      l_segno = 0;
-      if
-        (!l_cblk->numsegs)
-      {
-        if
-          (! t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 1))
-        {
-          bio_destroy(l_bio);
-          return false;
-        }
-
-      }
-      else
-      {
-        l_segno = l_cblk->numsegs - 1;
-        if
-          (l_cblk->segs[l_segno].numpasses == l_cblk->segs[l_segno].maxpasses)
-        {
-          ++l_segno;
-          if
-            (! t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0))
-          {
-            bio_destroy(l_bio);
-            return false;
-          }
-        }
-      }
-      n = l_cblk->numnewpasses;
-
-      do {
-        l_cblk->segs[l_segno].numnewpasses = int_min(l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses, n);
-        l_cblk->segs[l_segno].newlen = bio_read(l_bio, l_cblk->numlenbits + uint_floorlog2(l_cblk->segs[l_segno].numnewpasses));
-        n -= l_cblk->segs[l_segno].numnewpasses;
-        if
-          (n > 0)
-        {
-          ++l_segno;
-          if
-            (! t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0))
-          {
-            bio_destroy(l_bio);
-            return false;
-          }
-        }
-      }
-      while (n > 0);
-      ++l_cblk;
-    }
-    ++l_band;
-  }
-
-  if
-    (bio_inalign(l_bio))
-  {
-    bio_destroy(l_bio);
-    return false;
-  }
-
-  l_header_data += bio_numbytes(l_bio);
-  bio_destroy(l_bio);
-
-  /* EPH markers */
-  if (p_tcp->csty & J2K_CP_CSTY_EPH) {
-    if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
-      // TODO opj_event_msg(t2->cinfo->event_mgr, EVT_ERROR, "Expected EPH marker\n");
-    } else {
-      l_header_data += 2;
-    }
-  }
-
-
-  l_header_length = (l_header_data - *l_header_data_start);
-  *l_modified_length_ptr -= l_header_length;
-  *l_header_data_start += l_header_length;
-  /* << INDEX */
-  // End of packet header position. Currently only represents the distance to start of packet
-  // Will be updated later by incrementing with packet start value
-  if
-    (p_pack_info)
-  {
-    p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
-  }
-  /* INDEX >> */
-  * p_is_data_present = true;
-  *p_data_read = l_current_data - p_src_data;
-  return true;
-}
-
-static bool t2_read_packet_data(
-               opj_t2_t* p_t2,
-               opj_tcd_tile_t *p_tile,
-               opj_pi_iterator_t *p_pi,
-               OPJ_BYTE *p_src_data,
-               OPJ_UINT32 * p_data_read,
-               OPJ_UINT32 p_max_length,
-               opj_packet_info_t *pack_info)
-{
-  OPJ_UINT32 bandno, cblkno;
-  OPJ_UINT32 l_nb_code_blocks;
-  OPJ_BYTE *l_current_data = p_src_data;
-  opj_tcd_band_t *l_band = 00;
-  opj_tcd_cblk_dec_t* l_cblk = 00;
-  opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
-
-  l_band = l_res->bands;
-  for
-    (bandno = 0; bandno < l_res->numbands; ++bandno)
-  {
-    opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
-
-    if
-      ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0))
-    {
-      ++l_band;
-      continue;
-    }
-    l_nb_code_blocks = l_prc->cw * l_prc->ch;
-    l_cblk = l_prc->cblks.dec;
-    for
-      (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
-    {
-      opj_tcd_seg_t *l_seg = 00;
-      if
-        (!l_cblk->numnewpasses)
-      {
-        /* nothing to do */
-        ++l_cblk;
-        continue;
-      }
-      if
-        (!l_cblk->numsegs)
-      {
-        l_seg = l_cblk->segs;
-        ++l_cblk->numsegs;
-        l_cblk->len = 0;
-      }
-      else
-      {
-        l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
-        if
-          (l_seg->numpasses == l_seg->maxpasses)
-        {
-          ++l_seg;
-          ++l_cblk->numsegs;
-        }
-      }
-
-      do
-      {
-        if
-          (l_current_data + l_seg->newlen > p_src_data + p_max_length)
-        {
-          return false;
-        }
-
-#ifdef USE_JPWL
-      /* we need here a j2k handle to verify if making a check to
-      the validity of cblocks parameters is selected from user (-W) */
-
-        /* let's check that we are not exceeding */
-        if ((cblk->len + seg->newlen) > 8192) {
-          opj_event_msg(t2->cinfo, EVT_WARNING,
-            "JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
-            seg->newlen, cblkno, precno, bandno, resno, compno);
-          if (!JPWL_ASSUME) {
-            opj_event_msg(t2->cinfo, EVT_ERROR, "JPWL: giving up\n");
-            return -999;
-          }
-          seg->newlen = 8192 - cblk->len;
-          opj_event_msg(t2->cinfo, EVT_WARNING, "      - truncating segment to %d\n", seg->newlen);
-          break;
-        };
-
-#endif /* USE_JPWL */
-
-        memcpy(l_cblk->data + l_cblk->len, l_current_data, l_seg->newlen);
-        if
-          (l_seg->numpasses == 0)
-        {
-          l_seg->data = &l_cblk->data;
-          l_seg->dataindex = l_cblk->len;
-        }
-        l_current_data += l_seg->newlen;
-        l_seg->numpasses += l_seg->numnewpasses;
-        l_cblk->numnewpasses -= l_seg->numnewpasses;
-
-        l_seg->real_num_passes = l_seg->numpasses;
-        l_cblk->len += l_seg->newlen;
-        l_seg->len += l_seg->newlen;
-        if
-          (l_cblk->numnewpasses > 0)
-        {
-          ++l_seg;
-          ++l_cblk->numsegs;
-        }
-      }
-      while (l_cblk->numnewpasses > 0);
-      l_cblk->real_num_segs = l_cblk->numsegs;
-      ++l_cblk;
-    }
-    ++l_band;
-  }
-  *(p_data_read) = l_current_data - p_src_data;
-  return true;
-}
-
-
-static bool t2_skip_packet_data(
-               opj_t2_t* p_t2,
-               opj_tcd_tile_t *p_tile,
-               opj_pi_iterator_t *p_pi,
-               OPJ_UINT32 * p_data_read,
-               OPJ_UINT32 p_max_length,
-               opj_packet_info_t *pack_info)
-{
-  OPJ_UINT32 bandno, cblkno;
-  OPJ_UINT32 l_nb_code_blocks;
-  opj_tcd_band_t *l_band = 00;
-  opj_tcd_cblk_dec_t* l_cblk = 00;
-
-  opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
-
-  *p_data_read = 0;
-  l_band = l_res->bands;
-  for
-    (bandno = 0; bandno < l_res->numbands; ++bandno)
-  {
-    opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
-
-    if
-      ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0))
-    {
-      ++l_band;
-      continue;
-    }
-    l_nb_code_blocks = l_prc->cw * l_prc->ch;
-    l_cblk = l_prc->cblks.dec;
-    for
-      (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
-    {
-      opj_tcd_seg_t *l_seg = 00;
-      if
-        (!l_cblk->numnewpasses)
-      {
-        /* nothing to do */
-        ++l_cblk;
-        continue;
-      }
-      if
-        (!l_cblk->numsegs)
-      {
-        l_seg = l_cblk->segs;
-        ++l_cblk->numsegs;
-        l_cblk->len = 0;
-      }
-      else
-      {
-        l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
-        if
-          (l_seg->numpasses == l_seg->maxpasses)
-        {
-          ++l_seg;
-          ++l_cblk->numsegs;
-        }
-      }
-
-      do
-      {
-        if
-          (* p_data_read + l_seg->newlen > p_max_length)
-        {
-          return false;
-        }
-
-#ifdef USE_JPWL
-      /* we need here a j2k handle to verify if making a check to
-      the validity of cblocks parameters is selected from user (-W) */
-
-        /* let's check that we are not exceeding */
-        if ((cblk->len + seg->newlen) > 8192) {
-          opj_event_msg(t2->cinfo, EVT_WARNING,
-            "JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
-            seg->newlen, cblkno, precno, bandno, resno, compno);
-          if (!JPWL_ASSUME) {
-            opj_event_msg(t2->cinfo, EVT_ERROR, "JPWL: giving up\n");
-            return -999;
-          }
-          seg->newlen = 8192 - cblk->len;
-          opj_event_msg(t2->cinfo, EVT_WARNING, "      - truncating segment to %d\n", seg->newlen);
-          break;
-        };
-
-#endif /* USE_JPWL */
-        *(p_data_read) += l_seg->newlen;
-        l_seg->numpasses += l_seg->numnewpasses;
-        l_cblk->numnewpasses -= l_seg->numnewpasses;
-        if
-          (l_cblk->numnewpasses > 0)
-        {
-          ++l_seg;
-          ++l_cblk->numsegs;
-        }
-      }
-      while (l_cblk->numnewpasses > 0);
-      ++l_cblk;
-    }
-    ++l_band;
-  }
-  return true;
-}
-
-static bool t2_decode_packet(
-               opj_t2_t* p_t2,
-               opj_tcd_tile_t *p_tile,
-                             opj_tcp_t *p_tcp,
-               opj_pi_iterator_t *p_pi,
-               OPJ_BYTE *p_src,
-               OPJ_UINT32 * p_data_read,
-               OPJ_UINT32 p_max_length,
-               opj_packet_info_t *p_pack_info)
-{
-  bool l_read_data;
-  OPJ_UINT32 l_nb_bytes_read = 0;
-  OPJ_UINT32 l_nb_total_bytes_read = 0;
-
-  *p_data_read = 0;
-
-  if
-    (! t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info))
-  {
-    return false;
-  }
-  p_src += l_nb_bytes_read;
-  l_nb_total_bytes_read += l_nb_bytes_read;
-  p_max_length -= l_nb_bytes_read;
-  /* we should read data for the packet */
-  if
-    (l_read_data)
-  {
-    l_nb_bytes_read = 0;
-    if
-      (! t2_read_packet_data(p_t2,p_tile,p_pi,p_src,&l_nb_bytes_read,p_max_length,p_pack_info))
-    {
-      return false;
-    }
-    l_nb_total_bytes_read += l_nb_bytes_read;
-  }
-  *p_data_read = l_nb_total_bytes_read;
-  return true;
-}
-
-static bool t2_skip_packet(
-               opj_t2_t* p_t2,
-               opj_tcd_tile_t *p_tile,
-                             opj_tcp_t *p_tcp,
-               opj_pi_iterator_t *p_pi,
-               OPJ_BYTE *p_src,
-               OPJ_UINT32 * p_data_read,
-               OPJ_UINT32 p_max_length,
-               opj_packet_info_t *p_pack_info)
-{
-  bool l_read_data;
-  OPJ_UINT32 l_nb_bytes_read = 0;
-  OPJ_UINT32 l_nb_total_bytes_read = 0;
-
-  *p_data_read = 0;
-
-  if
-    (! t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info))
-  {
-    return false;
-  }
-  p_src += l_nb_bytes_read;
-  l_nb_total_bytes_read += l_nb_bytes_read;
-  p_max_length -= l_nb_bytes_read;
-  /* we should read data for the packet */
-  if
-    (l_read_data)
-  {
-    l_nb_bytes_read = 0;
-    if
-      (! t2_skip_packet_data(p_t2,p_tile,p_pi,&l_nb_bytes_read,p_max_length,p_pack_info))
-    {
-      return false;
-    }
-    l_nb_total_bytes_read += l_nb_bytes_read;
-  }
-  *p_data_read = l_nb_total_bytes_read;
-  return true;
-}
-
-/* ----------------------------------------------------------------------- */
-
-bool t2_encode_packets(
-             opj_t2_t* p_t2,
-             OPJ_UINT32 p_tile_no,
-             opj_tcd_tile_t *p_tile,
-             OPJ_UINT32 p_maxlayers,
-             OPJ_BYTE *p_dest,
-             OPJ_UINT32 * p_data_written,
-             OPJ_UINT32 p_max_len,
-             opj_codestream_info_t *cstr_info,
-             OPJ_UINT32 p_tp_num,
-             OPJ_INT32 p_tp_pos,
-             OPJ_UINT32 p_pino,
-             J2K_T2_MODE p_t2_mode)
-{
-  OPJ_BYTE *l_current_data = p_dest;
-  OPJ_UINT32 l_nb_bytes = 0;
-  OPJ_UINT32 compno;
-  OPJ_UINT32 poc;
-  opj_pi_iterator_t *l_pi = 00;
-  opj_pi_iterator_t *l_current_pi = 00;
-  opj_image_t *l_image = p_t2->image;
-  opj_cp_t *l_cp = p_t2->cp;
-  opj_tcp_t *l_tcp = &l_cp->tcps[p_tile_no];
-  OPJ_UINT32 pocno = l_cp->m_specific_param.m_enc.m_cinema == CINEMA4K_24? 2: 1;
-  OPJ_UINT32 l_max_comp = l_cp->m_specific_param.m_enc.m_max_comp_size > 0 ? l_image->numcomps : 1;
-  OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1;
-
-  l_pi = pi_initialise_encode(l_image, l_cp, p_tile_no, p_t2_mode);
-  if
-    (!l_pi)
-  {
-    return false;
-  }
-  * p_data_written = 0;
-  if
-    (p_t2_mode == THRESH_CALC )
-  { /* Calculating threshold */
-    l_current_pi = l_pi;
-    for
-      (compno = 0; compno < l_max_comp; ++compno)
-    {
-      OPJ_UINT32 l_comp_len = 0;
-      l_current_pi = l_pi;
-
-      for
-        (poc = 0; poc < pocno ; ++poc)
-      {
-        OPJ_UINT32 l_tp_num = compno;
-        pi_create_encode(l_pi, l_cp,p_tile_no,poc,l_tp_num,p_tp_pos,p_t2_mode);
-        while
-          (pi_next(l_current_pi))
-        {
-          if
-            (l_current_pi->layno < p_maxlayers)
-          {
-            l_nb_bytes = 0;
-            if
-              (! t2_encode_packet(p_tile_no,p_tile, l_tcp, l_current_pi, l_current_data, &l_nb_bytes, p_max_len, cstr_info))
-            {
-              pi_destroy(l_pi, l_nb_pocs);
-              return false;
-            }
-            l_comp_len += l_nb_bytes;
-            l_current_data += l_nb_bytes;
-            p_max_len -= l_nb_bytes;
-            * p_data_written += l_nb_bytes;
-          }
-        }
-        if
-          (l_cp->m_specific_param.m_enc.m_max_comp_size)
-        {
-          if
-            (l_comp_len > l_cp->m_specific_param.m_enc.m_max_comp_size)
-          {
-            pi_destroy(l_pi, l_nb_pocs);
-            return false;
-          }
-        }
-        ++l_current_pi;
-      }
-    }
-  }
-  else
-  {  /* t2_mode == FINAL_PASS  */
-    pi_create_encode(l_pi, l_cp,p_tile_no,p_pino,p_tp_num,p_tp_pos,p_t2_mode);
-    l_current_pi = &l_pi[p_pino];
-    while
-      (pi_next(l_current_pi))
-    {
-      if
-        (l_current_pi->layno < p_maxlayers)
-      {
-        l_nb_bytes=0;
-        if
-          (! t2_encode_packet(p_tile_no,p_tile, l_tcp, l_current_pi, l_current_data, &l_nb_bytes, p_max_len, cstr_info))
-        {
-          pi_destroy(l_pi, l_nb_pocs);
-          return false;
-        }
-        l_current_data += l_nb_bytes;
-        p_max_len -= l_nb_bytes;
-        * p_data_written += l_nb_bytes;
-
-        /* INDEX >> */
-        if(cstr_info) {
-          if(cstr_info->index_write) {
-            opj_tile_info_t *info_TL = &cstr_info->tile[p_tile_no];
-            opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
-            if (!cstr_info->packno) {
-              info_PK->start_pos = info_TL->end_header + 1;
-            } else {
-              info_PK->start_pos = ((l_cp->m_specific_param.m_enc.m_tp_on | l_tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
-            }
-            info_PK->end_pos = info_PK->start_pos + l_nb_bytes - 1;
-            info_PK->end_ph_pos += info_PK->start_pos - 1;  // End of packet header which now only represents the distance
-                                                            // to start of packet is incremented by value of start of packet
-          }
-
-          cstr_info->packno++;
-        }
-        /* << INDEX */
-        ++p_tile->packno;
-      }
-    }
-  }
-  pi_destroy(l_pi, l_nb_pocs);
-  return true;
-}
-
-bool t2_decode_packets(
-            opj_t2_t *p_t2,
-            OPJ_UINT32 p_tile_no,
-            struct opj_tcd_tile *p_tile,
-            OPJ_BYTE *p_src,
-            OPJ_UINT32 * p_data_read,
-            OPJ_UINT32 p_max_len,
-            struct opj_codestream_info *p_cstr_info)
-{
-  OPJ_BYTE *l_current_data = p_src;
-  opj_pi_iterator_t *l_pi = 00;
-  OPJ_UINT32 pino;
-  opj_image_t *l_image = p_t2->image;
-  opj_cp_t *l_cp = p_t2->cp;
-  opj_cp_t *cp = p_t2->cp;
-  opj_tcp_t *l_tcp = &(p_t2->cp->tcps[p_tile_no]);
-  OPJ_UINT32 l_nb_bytes_read;
-  OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1;
-  opj_pi_iterator_t *l_current_pi = 00;
-  OPJ_UINT32 curtp = 0;
-  OPJ_UINT32 tp_start_packno;
-  opj_packet_info_t *l_pack_info = 00;
-  opj_image_comp_t* l_img_comp = 00;
-
-
-  if
-    (p_cstr_info)
-  {
-    l_pack_info = p_cstr_info->tile[p_tile_no].packet;
-  }
-
-  /* create a packet iterator */
-  l_pi = pi_create_decode(l_image, l_cp, p_tile_no);
-  if
-    (!l_pi)
-  {
-    return false;
-  }
-
-  tp_start_packno = 0;
-  l_current_pi = l_pi;
-
-  for
-    (pino = 0; pino <= l_tcp->numpocs; ++pino)
-  {
-    while
-      (pi_next(l_current_pi))
-    {
-
-      if
-        (l_tcp->num_layers_to_decode > l_current_pi->layno && l_current_pi->resno < p_tile->comps[l_current_pi->compno].minimum_num_resolutions)
-      {
-        l_nb_bytes_read = 0;
-        if
-          (! t2_decode_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info))
-        {
-          pi_destroy(l_pi,l_nb_pocs);
-          return false;
-        }
-        l_img_comp = &(l_image->comps[l_current_pi->compno]);
-        l_img_comp->resno_decoded = uint_max(l_current_pi->resno, l_img_comp->resno_decoded);
-      }
-      else
-      {
-        l_nb_bytes_read = 0;
-        if
-          (! t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info))
-        {
-          pi_destroy(l_pi,l_nb_pocs);
-          return false;
-        }
-      }
-      l_current_data += l_nb_bytes_read;
-      p_max_len -= l_nb_bytes_read;
-
-      /* INDEX >> */
-      if(p_cstr_info) {
-        opj_tile_info_t *info_TL = &p_cstr_info->tile[p_tile_no];
-        opj_packet_info_t *info_PK = &info_TL->packet[p_cstr_info->packno];
-        if (!p_cstr_info->packno) {
-          info_PK->start_pos = info_TL->end_header + 1;
-        } else if (info_TL->packet[p_cstr_info->packno-1].end_pos >= (OPJ_INT32)p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_pos){ // New tile part
-          info_TL->tp[curtp].tp_numpacks = p_cstr_info->packno - tp_start_packno; // Number of packets in previous tile-part
-          tp_start_packno = p_cstr_info->packno;
-          curtp++;
-          info_PK->start_pos = p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_header+1;
-        } else {
-          info_PK->start_pos = (cp->m_specific_param.m_enc.m_tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[p_cstr_info->packno - 1].end_pos + 1;
-        }
-        info_PK->end_pos = info_PK->start_pos + l_nb_bytes_read - 1;
-        info_PK->end_ph_pos += info_PK->start_pos - 1;  // End of packet header which now only represents the distance
-        ++p_cstr_info->packno;
-      }
-      /* << INDEX */
-    }
-    ++l_current_pi;
-  }
-  /* INDEX >> */
-  if
-    (p_cstr_info) {
-    p_cstr_info->tile[p_tile_no].tp[curtp].tp_numpacks = p_cstr_info->packno - tp_start_packno; // Number of packets in last tile-part
-  }
-  /* << INDEX */
-
-  /* don't forget to release pi */
-  pi_destroy(l_pi,l_nb_pocs);
-  *p_data_read = l_current_data - p_src;
-  return true;
-}
-
-/* ----------------------------------------------------------------------- */
-/**
- * Creates a Tier 2 handle
- *
- * @param  p_image    Source or destination image
- * @param  p_cp    Image coding parameters.
- * @return    a new T2 handle if successful, NULL otherwise.
-*/
-opj_t2_t* t2_create(
-          opj_image_t *p_image,
-          opj_cp_t *p_cp)
-{
-  /* create the tcd structure */
-  opj_t2_t *l_t2 = (opj_t2_t*)opj_malloc(sizeof(opj_t2_t));
-  if
-    (!l_t2)
-  {
-    return 00;
-  }
-  memset(l_t2,0,sizeof(opj_t2_t));
-  l_t2->image = p_image;
-  l_t2->cp = p_cp;
-  return l_t2;
-}
-
-/**
- * Destroys a Tier 2 handle.
- *
- * @param  p_t2  the Tier 2 handle to destroy
-*/
-void t2_destroy(opj_t2_t *p_t2)
-{
-  if
-    (p_t2)
-  {
-    opj_free(p_t2);
-  }
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.h
deleted file mode 100644
index 050a264..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/t2.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __T2_H
-#define __T2_H
-/**
- at file t2.h
- at brief Implementation of a tier-2 coding (packetization of code-block data) (T2)
-
-*/
-#include "openjpeg.h"
-
-struct opj_common_struct;
-struct opj_image;
-struct opj_cp;
-struct opj_tcd_tile;
-struct opj_codestream_info;
-
-/** @defgroup T2 T2 - Implementation of a tier-2 coding */
-/*@{*/
-
-/**
-T2 encoding mode
-*/
-typedef enum T2_MODE
-{
-  THRESH_CALC = 0,  /** Function called in Rate allocation process*/
-  FINAL_PASS = 1    /** Function called in Tier 2 process*/
-}
-J2K_T2_MODE;
-
-/**
-Tier-2 coding
-*/
-
-typedef struct opj_t2 {
-  /** Encoding: pointer to the src image. Decoding: pointer to the dst image. */
-  struct opj_image *image;
-  /** pointer to the image coding parameters */
-  struct opj_cp *cp;
-} opj_t2_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Encode the packets of a tile to a destination buffer
- at param t2 T2 handle
- at param tileno number of the tile encoded
- at param tile the tile for which to write the packets
- at param maxlayers maximum number of layers
- at param dest the destination buffer
- at param len the length of the destination buffer
- at param cstr_info Codestream information structure
- at param tpnum Tile part number of the current tile
- at param tppos The position of the tile part flag in the progression order
- at param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
-*/
-bool t2_encode_packets(opj_t2_t* t2,OPJ_UINT32 tileno, struct opj_tcd_tile *tile, OPJ_UINT32 maxlayers, OPJ_BYTE *dest, OPJ_UINT32 * p_data_written, OPJ_UINT32 len, struct opj_codestream_info *cstr_info,OPJ_UINT32 tpnum, OPJ_INT32 tppos,OPJ_UINT32 pino,J2K_T2_MODE t2_mode);
-/**
-Decode the packets of a tile from a source buffer
- at param t2 T2 handle
- at param src the source buffer
- at param len length of the source buffer
- at param tileno number that identifies the tile for which to decode the packets
- at param tile tile for which to decode the packets
- */
-bool t2_decode_packets(opj_t2_t *t2, OPJ_UINT32 tileno,struct opj_tcd_tile *tile, OPJ_BYTE *src, OPJ_UINT32 * p_data_read, OPJ_UINT32 len,   struct opj_codestream_info *cstr_info);
-
-/**
- * Creates a Tier 2 handle
- *
- * @param  p_image    Source or destination image
- * @param  p_cp    Image coding parameters.
- * @return    a new T2 handle if successful, NULL otherwise.
-*/
-opj_t2_t* t2_create(struct opj_image *p_image, struct opj_cp *p_cp);
-
-/**
- * Destroys a Tier 2 handle.
- *
- * @param  p_t2  the Tier 2 handle to destroy
-*/
-void t2_destroy(opj_t2_t *t2);
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __T2_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.c
deleted file mode 100644
index 6b9c598..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.c
+++ /dev/null
@@ -1,2121 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2006-2007, Parvatha Elangovan
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "tcd.h"
-#include "openjpeg.h"
-#include "j2k.h"
-#include "opj_includes.h"
-#include "event.h"
-#include "t2.h"
-#include "t1.h"
-#include "opj_malloc.h"
-#include "int.h"
-#include "tgt.h"
-#include "dwt.h"
-#include "mct.h"
-#include "j2k_lib.h"
-#include "profile.h"
-
-/**
- * Deallocates the encoding data of the given precinct.
- */
-static void tcd_code_block_enc_deallocate (opj_tcd_precinct_t * p_precinct);
-/**
- * Allocates memory for an encoding code block.
- */
-static bool tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_block);
-/**
- * Allocates memory for a decoding code block.
- */
-static bool tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block);
-/**
-Free the memory allocated for encoding
- at param tcd TCD handle
-*/
-static void tcd_free_tile(opj_tcd_t *tcd);
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Create a new TCD handle
-*/
-opj_tcd_t* tcd_create(bool p_is_decoder)
-{
-  opj_tcd_t *l_tcd = 00;
-
-  /* create the tcd structure */
-  l_tcd = (opj_tcd_t*)  opj_malloc(sizeof(opj_tcd_t));
-  if
-    (!l_tcd)
-  {
-    return 00;
-  }
-  memset(l_tcd,0,sizeof(opj_tcd_t));
-  l_tcd->m_is_decoder = p_is_decoder ? 1 : 0;
-  l_tcd->tcd_image = (opj_tcd_image_t*)opj_malloc(sizeof(opj_tcd_image_t));
-  if
-    (!l_tcd->tcd_image)
-  {
-    opj_free(l_tcd);
-    return 00;
-  }
-  memset(l_tcd->tcd_image,0,sizeof(opj_tcd_image_t));
-  return l_tcd;
-}
-
-/**
-Destroy a previously created TCD handle
-*/
-void tcd_destroy(opj_tcd_t *tcd) {
-  if
-    (tcd)
-  {
-    tcd_free_tile(tcd);
-    if
-      (tcd->tcd_image)
-    {
-      opj_free(tcd->tcd_image);
-      tcd->tcd_image = 00;
-    }
-    opj_free(tcd);
-  }
-}
-
-/* ----------------------------------------------------------------------- */
-/**
- * Initialize the tile coder and may reuse some meory.
- * @param  p_tcd    TCD handle.
- * @param  p_image    raw image.
- * @param  p_cp    coding parameters.
- * @param  p_tile_no  current tile index to encode.
- *
- * @return true if the encoding values could be set (false otherwise).
-*/
-#define MACRO_TCD_ALLOCATE(FUNCTION,TYPE,FRACTION,ELEMENT,FUNCTION_ELEMENT)  \
-bool FUNCTION                                \
-      (                                \
-        opj_tcd_t *p_tcd,                      \
-        OPJ_UINT32 p_tile_no                    \
-      )                                \
-{                                      \
-  OPJ_UINT32 (*l_gain_ptr)(OPJ_UINT32) = 00;                \
-  OPJ_UINT32 compno, resno, bandno, precno, cblkno;            \
-  opj_tcp_t * l_tcp = 00;                          \
-  opj_cp_t * l_cp = 00;                          \
-  opj_tcd_tile_t * l_tile = 00;                      \
-  opj_tccp_t *l_tccp = 00;                        \
-  opj_tcd_tilecomp_t *l_tilec = 00;                    \
-  opj_image_comp_t * l_image_comp = 00;                  \
-  opj_tcd_resolution_t *l_res = 00;                    \
-  opj_tcd_band_t *l_band = 00;                      \
-  opj_stepsize_t * l_step_size = 00;                    \
-  opj_tcd_precinct_t *l_current_precinct = 00;              \
-  TYPE* l_code_block = 00;                        \
-  opj_image_t *  l_image = 00;                      \
-  OPJ_UINT32 p,q;                              \
-  OPJ_UINT32 l_level_no;                          \
-  OPJ_UINT32 l_pdx, l_pdy;                        \
-  OPJ_UINT32 l_gain;                            \
-  OPJ_INT32 l_x0b, l_y0b;                          \
-  /* extent of precincts , top left, bottom right**/            \
-  OPJ_INT32 l_tl_prc_x_start, l_tl_prc_y_start, l_br_prc_x_end, l_br_prc_y_end;  \
-  /* number of precinct for a resolution */                \
-  OPJ_UINT32 l_nb_precincts;                        \
-  /* room needed to store l_nb_precinct precinct for a resolution */    \
-  OPJ_UINT32 l_nb_precinct_size;                      \
-  /* number of code blocks for a precinct*/                \
-  OPJ_UINT32 l_nb_code_blocks;                      \
-  /* room needed to store l_nb_code_blocks code blocks for a precinct*/  \
-  OPJ_UINT32 l_nb_code_blocks_size;                    \
-  /* size of data for a tile */                      \
-  OPJ_UINT32 l_data_size;                          \
-  l_cp = p_tcd->cp;                            \
-  l_tcp = &(l_cp->tcps[p_tile_no]);                    \
-  l_tile = p_tcd->tcd_image->tiles;                    \
-  l_tccp = l_tcp->tccps;                          \
-  l_tilec = l_tile->comps;                        \
-  l_image = p_tcd->image;                          \
-  l_image_comp = p_tcd->image->comps;                    \
-                                      \
-  p = p_tile_no % l_cp->tw;  /* tile coordinates */            \
-  q = p_tile_no / l_cp->tw;                        \
-                                      \
-  /* 4 borders of the tile rescale on the image if necessary */      \
-  l_tile->x0 = int_max(l_cp->tx0 + p * l_cp->tdx, l_image->x0);      \
-  l_tile->y0 = int_max(l_cp->ty0 + q * l_cp->tdy, l_image->y0);      \
-  l_tile->x1 = int_min(l_cp->tx0 + (p + 1) * l_cp->tdx, l_image->x1);    \
-  l_tile->y1 = int_min(l_cp->ty0 + (q + 1) * l_cp->tdy, l_image->y1);    \
-  /*tile->numcomps = image->numcomps; */                  \
-  for                                    \
-    (compno = 0; compno < l_tile->numcomps; ++compno)          \
-  {                                    \
-    /* border of each l_tile component (global) */            \
-    l_tilec->x0 = int_ceildiv(l_tile->x0, l_image_comp->dx);      \
-    l_tilec->y0 = int_ceildiv(l_tile->y0, l_image_comp->dy);      \
-    l_tilec->x1 = int_ceildiv(l_tile->x1, l_image_comp->dx);      \
-    l_tilec->y1 = int_ceildiv(l_tile->y1, l_image_comp->dy);      \
-                                      \
-    l_data_size = (l_tilec->x1 - l_tilec->x0)              \
-          * (l_tilec->y1 - l_tilec->y0) * sizeof(OPJ_UINT32 );  \
-    l_tilec->numresolutions = l_tccp->numresolutions;          \
-    if                                  \
-      (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_reduce)\
-    {                                  \
-      l_tilec->minimum_num_resolutions = 1;              \
-    }                                  \
-    else                                \
-    {                                  \
-      l_tilec->minimum_num_resolutions = l_tccp->numresolutions - l_cp->m_specific_param.m_dec.m_reduce;\
-    }                                  \
-    if                                  \
-      (l_tilec->data == 00)                      \
-    {                                  \
-            l_tilec->data = (OPJ_INT32 *) opj_aligned_malloc(l_data_size);  \
-      if                                \
-        (! l_tilec->data )                      \
-      {                                \
-        return false;                        \
-      }                                \
-      l_tilec->data_size = l_data_size;                \
-    }                                  \
-    else if                                \
-      (l_data_size > l_tilec->data_size)                \
-    {                                  \
-      l_tilec->data = (OPJ_INT32 *) opj_realloc(l_tilec->data, l_data_size);\
-      if                                \
-        (! l_tilec->data)                      \
-      {                                \
-        return false;                        \
-      }                                \
-      l_tilec->data_size = l_data_size;                \
-    }                                  \
-    l_data_size = l_tilec->numresolutions * sizeof(opj_tcd_resolution_t);\
-    if                                  \
-      (l_tilec->resolutions == 00)                  \
-    {                                  \
-            l_tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(l_data_size);\
-      if                                \
-        (! l_tilec->resolutions )                  \
-      {                                \
-        return false;                        \
-      }                                \
-      l_tilec->resolutions_size = l_data_size;            \
-      memset(l_tilec->resolutions,0,l_data_size);            \
-    }                                  \
-    else if                                \
-      (l_data_size > l_tilec->resolutions_size)            \
-    {                                  \
-      l_tilec->resolutions = (opj_tcd_resolution_t *) opj_realloc(l_tilec->resolutions, l_data_size);\
-      if                                \
-        (! l_tilec->resolutions)                  \
-      {                                \
-        return false;                        \
-      }                                \
-      memset(((OPJ_BYTE*) l_tilec->resolutions)+l_tilec->resolutions_size,0,l_data_size - l_tilec->resolutions_size);\
-      l_tilec->resolutions_size = l_data_size;            \
-    }                                  \
-    l_level_no = l_tilec->numresolutions - 1;              \
-    l_res = l_tilec->resolutions;                    \
-    l_step_size = l_tccp->stepsizes;                  \
-    if                                  \
-      (l_tccp->qmfbid == 0)                      \
-    {                                  \
-      l_gain_ptr = &dwt_getgain_real;                  \
-    }                                  \
-    else                                \
-    {                                  \
-      l_gain_ptr  = &dwt_getgain;                    \
-    }                                  \
-    for                                  \
-      (resno = 0; resno < l_tilec->numresolutions; ++resno)      \
-    {                                  \
-      OPJ_INT32 tlcbgxstart, tlcbgystart, brcbgxend, brcbgyend;    \
-      OPJ_UINT32 cbgwidthexpn, cbgheightexpn;              \
-      OPJ_UINT32 cblkwidthexpn, cblkheightexpn;            \
-      /* border for each resolution level (global) */          \
-      l_res->x0 = int_ceildivpow2(l_tilec->x0, l_level_no);      \
-      l_res->y0 = int_ceildivpow2(l_tilec->y0, l_level_no);      \
-      l_res->x1 = int_ceildivpow2(l_tilec->x1, l_level_no);      \
-      l_res->y1 = int_ceildivpow2(l_tilec->y1, l_level_no);      \
-      /* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */\
-      l_pdx = l_tccp->prcw[resno];                  \
-      l_pdy = l_tccp->prch[resno];                  \
-      /* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000)  */  \
-      l_tl_prc_x_start = int_floordivpow2(l_res->x0, l_pdx) << l_pdx;  \
-      l_tl_prc_y_start = int_floordivpow2(l_res->y0, l_pdy) << l_pdy;  \
-      l_br_prc_x_end = int_ceildivpow2(l_res->x1, l_pdx) << l_pdx;  \
-      l_br_prc_y_end = int_ceildivpow2(l_res->y1, l_pdy) << l_pdy;  \
-                                      \
-      l_res->pw = (l_res->x0 == l_res->x1) ? 0 : ((l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx);\
-      l_res->ph = (l_res->y0 == l_res->y1) ? 0 : ((l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);\
-      l_nb_precincts = l_res->pw * l_res->ph;              \
-      l_nb_precinct_size = l_nb_precincts * sizeof(opj_tcd_precinct_t);\
-      if                                \
-        (resno == 0)                        \
-      {                                \
-        tlcbgxstart = l_tl_prc_x_start;                \
-        tlcbgystart = l_tl_prc_y_start;                \
-        brcbgxend = l_br_prc_x_end;                  \
-        brcbgyend = l_br_prc_y_end;                  \
-        cbgwidthexpn = l_pdx;                    \
-        cbgheightexpn = l_pdy;                    \
-        l_res->numbands = 1;                    \
-      }                                \
-      else                              \
-      {                                \
-        tlcbgxstart = int_ceildivpow2(l_tl_prc_x_start, 1);      \
-        tlcbgystart = int_ceildivpow2(l_tl_prc_y_start, 1);      \
-        brcbgxend = int_ceildivpow2(l_br_prc_x_end, 1);        \
-        brcbgyend = int_ceildivpow2(l_br_prc_y_end, 1);        \
-        cbgwidthexpn = l_pdx - 1;                  \
-        cbgheightexpn = l_pdy - 1;                  \
-        l_res->numbands = 3;                    \
-      }                                \
-                                      \
-      cblkwidthexpn = uint_min(l_tccp->cblkw, cbgwidthexpn);      \
-      cblkheightexpn = uint_min(l_tccp->cblkh, cbgheightexpn);    \
-      l_band = l_res->bands;                      \
-      for                                \
-        (bandno = 0; bandno < l_res->numbands; ++bandno)      \
-      {                                \
-        OPJ_INT32 numbps;                      \
-        if                              \
-          (resno == 0)                      \
-        {                              \
-          l_band->bandno = 0 ;                  \
-          l_band->x0 = int_ceildivpow2(l_tilec->x0, l_level_no);  \
-          l_band->y0 = int_ceildivpow2(l_tilec->y0, l_level_no);  \
-          l_band->x1 = int_ceildivpow2(l_tilec->x1, l_level_no);  \
-          l_band->y1 = int_ceildivpow2(l_tilec->y1, l_level_no);  \
-        }                              \
-        else                            \
-        {                              \
-          l_band->bandno = bandno + 1;              \
-          /* x0b = 1 if bandno = 1 or 3 */            \
-          l_x0b = l_band->bandno&1;                \
-          /* y0b = 1 if bandno = 2 or 3 */            \
-          l_y0b = (l_band->bandno)>>1;              \
-          /* l_band border (global) */              \
-          l_band->x0 = int_ceildivpow2(l_tilec->x0 - (1 << l_level_no) * l_x0b, l_level_no + 1);\
-          l_band->y0 = int_ceildivpow2(l_tilec->y0 - (1 << l_level_no) * l_y0b, l_level_no + 1);\
-          l_band->x1 = int_ceildivpow2(l_tilec->x1 - (1 << l_level_no) * l_x0b, l_level_no + 1);\
-          l_band->y1 = int_ceildivpow2(l_tilec->y1 - (1 << l_level_no) * l_y0b, l_level_no + 1);\
-        }                              \
-        /** avoid an if with storing function pointer */      \
-        l_gain = (*l_gain_ptr) (l_band->bandno);          \
-        numbps = l_image_comp->prec + l_gain;            \
-        l_band->stepsize = (OPJ_FLOAT32)(((1.0 + l_step_size->mant / 2048.0) * pow(2.0, (OPJ_INT32) (numbps - l_step_size->expn)))) * FRACTION;\
-        l_band->numbps = l_step_size->expn + l_tccp->numgbits - 1;  /* WHY -1 ? */\
-        if                              \
-          (! l_band->precincts)                  \
-        {                              \
-          l_band->precincts = (opj_tcd_precinct_t *) opj_malloc(/*3 * */ l_nb_precinct_size);\
-          if                            \
-            (! l_band->precincts)                \
-          {                            \
-            return false;                    \
-          }                            \
-          memset(l_band->precincts,0,l_nb_precinct_size);      \
-          l_band->precincts_data_size = l_nb_precinct_size;    \
-        }                              \
-        else if                            \
-          (l_band->precincts_data_size < l_nb_precinct_size)    \
-        {                              \
-          l_band->precincts = (opj_tcd_precinct_t *) opj_realloc(l_band->precincts,/*3 * */ l_nb_precinct_size);\
-          if                            \
-            (! l_band->precincts)                \
-          {                            \
-            return false;                    \
-          }                            \
-          memset(((OPJ_BYTE *) l_band->precincts) + l_band->precincts_data_size,0,l_nb_precinct_size - l_band->precincts_data_size);\
-          l_band->precincts_data_size = l_nb_precinct_size;    \
-        }                              \
-        l_current_precinct = l_band->precincts;            \
-        for                              \
-          (precno = 0; precno < l_nb_precincts; ++precno)      \
-        {                              \
-          OPJ_INT32 tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;  \
-          OPJ_INT32 cbgxstart = tlcbgxstart + (precno % l_res->pw) * (1 << cbgwidthexpn);\
-          OPJ_INT32 cbgystart = tlcbgystart + (precno / l_res->pw) * (1 << cbgheightexpn);\
-          OPJ_INT32 cbgxend = cbgxstart + (1 << cbgwidthexpn);      \
-          OPJ_INT32 cbgyend = cbgystart + (1 << cbgheightexpn);      \
-          /* precinct size (global) */              \
-          l_current_precinct->x0 = int_max(cbgxstart, l_band->x0);\
-          l_current_precinct->y0 = int_max(cbgystart, l_band->y0);\
-          l_current_precinct->x1 = int_min(cbgxend, l_band->x1);  \
-          l_current_precinct->y1 = int_min(cbgyend, l_band->y1);  \
-          tlcblkxstart = int_floordivpow2(l_current_precinct->x0, cblkwidthexpn) << cblkwidthexpn;\
-          tlcblkystart = int_floordivpow2(l_current_precinct->y0, cblkheightexpn) << cblkheightexpn;\
-          brcblkxend = int_ceildivpow2(l_current_precinct->x1, cblkwidthexpn) << cblkwidthexpn;\
-          brcblkyend = int_ceildivpow2(l_current_precinct->y1, cblkheightexpn) << cblkheightexpn;\
-          l_current_precinct->cw = (brcblkxend - tlcblkxstart) >> cblkwidthexpn;\
-          l_current_precinct->ch = (brcblkyend - tlcblkystart) >> cblkheightexpn;\
-          l_nb_code_blocks = l_current_precinct->cw * l_current_precinct->ch;\
-          l_nb_code_blocks_size = l_nb_code_blocks * sizeof(TYPE);\
-          if                            \
-            (! l_current_precinct->cblks.ELEMENT)        \
-          {                            \
-            l_current_precinct->cblks.ELEMENT = (TYPE*) opj_malloc(l_nb_code_blocks_size);\
-            if                          \
-              (! l_current_precinct->cblks.ELEMENT )      \
-            {                          \
-              return false;                  \
-            }                          \
-            memset(l_current_precinct->cblks.ELEMENT,0,l_nb_code_blocks_size);\
-            l_current_precinct->block_size = l_nb_code_blocks_size;\
-          }                            \
-          else if                          \
-            (l_nb_code_blocks_size > l_current_precinct->block_size)\
-          {                            \
-            l_current_precinct->cblks.ELEMENT = (TYPE*)      \
-              opj_realloc(l_current_precinct->cblks.ELEMENT, l_nb_code_blocks_size);\
-            if                          \
-              (! l_current_precinct->cblks.ELEMENT )      \
-            {                          \
-              return false;                  \
-            }                          \
-            memset(((OPJ_BYTE *) l_current_precinct->cblks.ELEMENT) + l_current_precinct->block_size\
-                    ,0                  \
-                    ,l_nb_code_blocks_size - l_current_precinct->block_size);\
-            l_current_precinct->block_size = l_nb_code_blocks_size;\
-          }                            \
-          if                            \
-            (! l_current_precinct->incltree)          \
-          {                            \
-                        l_current_precinct->incltree = tgt_create(l_current_precinct->cw,\
-                                  l_current_precinct->ch);\
-          }                            \
-          else                          \
-          {                            \
-            l_current_precinct->incltree = tgt_init(l_current_precinct->incltree,\
-                                l_current_precinct->cw, \
-                                l_current_precinct->ch);\
-          }                            \
-          if                            \
-            (! l_current_precinct->incltree)          \
-          {                            \
-            return false;                    \
-          }                            \
-          if                            \
-            (! l_current_precinct->imsbtree)          \
-          {                            \
-                        l_current_precinct->imsbtree = tgt_create(      \
-                            l_current_precinct->cw,\
-                            l_current_precinct->ch);\
-          }                            \
-          else                          \
-          {                            \
-            l_current_precinct->imsbtree = tgt_init(      \
-                              l_current_precinct->imsbtree,\
-                              l_current_precinct->cw,\
-                              l_current_precinct->ch);\
-          }                            \
-          if                            \
-            (! l_current_precinct->imsbtree)          \
-          {                            \
-            return false;                    \
-          }                            \
-          l_code_block = l_current_precinct->cblks.ELEMENT;    \
-          for                            \
-            (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)  \
-          {                            \
-            OPJ_INT32 cblkxstart = tlcblkxstart + (cblkno % l_current_precinct->cw) * (1 << cblkwidthexpn);\
-            OPJ_INT32 cblkystart = tlcblkystart + (cblkno / l_current_precinct->cw) * (1 << cblkheightexpn);\
-            OPJ_INT32 cblkxend = cblkxstart + (1 << cblkwidthexpn);  \
-            OPJ_INT32 cblkyend = cblkystart + (1 << cblkheightexpn);  \
-            /* code-block size (global) */            \
-            l_code_block->x0 = int_max(cblkxstart, l_current_precinct->x0);\
-            l_code_block->y0 = int_max(cblkystart, l_current_precinct->y0);\
-            l_code_block->x1 = int_min(cblkxend, l_current_precinct->x1);\
-            l_code_block->y1 = int_min(cblkyend, l_current_precinct->y1);\
-            if                          \
-              (! FUNCTION_ELEMENT(l_code_block))        \
-            {                          \
-              return false;                  \
-            }                          \
-            ++l_code_block;                    \
-          }                            \
-          ++l_current_precinct;                  \
-        } /* precno */                        \
-        ++l_band;                          \
-        ++l_step_size;                        \
-      } /* bandno */                          \
-      ++l_res;                            \
-      --l_level_no;                          \
-    } /* resno */                            \
-    ++l_tccp;                              \
-    ++l_tilec;                              \
-    ++l_image_comp;                            \
-  } /* compno */                              \
-  return true;                              \
-}                                      \
-
-MACRO_TCD_ALLOCATE(tcd_init_encode_tile,opj_tcd_cblk_enc_t,1.f,enc,tcd_code_block_enc_allocate)
-MACRO_TCD_ALLOCATE(tcd_init_decode_tile,opj_tcd_cblk_dec_t,0.5f,dec,tcd_code_block_dec_allocate)
-
-#undef MACRO_TCD_ALLOCATE
-
-/**
- * Allocates memory for an encoding code block.
- */
-bool tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_block)
-{
-  if
-    (! p_code_block->data)
-  {
-    p_code_block->data = (OPJ_BYTE*) opj_malloc(8192+1);
-    if
-      (! p_code_block->data)
-    {
-      return false;
-    }
-    p_code_block->data+=1;
-    /* no memset since data */
-    p_code_block->layers = (opj_tcd_layer_t*) opj_malloc(100 * sizeof(opj_tcd_layer_t));
-    if
-      (! p_code_block->layers)
-    {
-      return false;
-    }
-    p_code_block->passes = (opj_tcd_pass_t*) opj_malloc(100 * sizeof(opj_tcd_pass_t));
-    if
-      (! p_code_block->passes)
-    {
-      return false;
-    }
-  }
-  memset(p_code_block->layers,0,100 * sizeof(opj_tcd_layer_t));
-  memset(p_code_block->passes,0,100 * sizeof(opj_tcd_pass_t));
-  return true;
-}
-
-/**
- * Allocates memory for a decoding code block.
- */
-bool tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block)
-{
-  OPJ_UINT32 l_seg_size;
-
-  if
-    (! p_code_block->data)
-  {
-    p_code_block->data = (OPJ_BYTE*) opj_malloc(8192);
-    if
-      (! p_code_block->data)
-    {
-      return false;
-    }
-    l_seg_size = J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t);
-    p_code_block->segs = (opj_tcd_seg_t *) opj_malloc(l_seg_size);
-    if
-      (! p_code_block->segs)
-    {
-      return false;
-    }
-    memset(p_code_block->segs,0,l_seg_size);
-    p_code_block->m_current_max_segs = J2K_DEFAULT_NB_SEGS;
-  }
-  // TODO
-  //p_code_block->numsegs = 0;
-  return true;
-}
-
-/**
- * Deallocates the encoding data of the given precinct.
- */
-void tcd_code_block_enc_deallocate (opj_tcd_precinct_t * p_precinct)
-{
-  OPJ_UINT32 cblkno , l_nb_code_blocks;
-
-  opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc;
-  if
-    (l_code_block)
-  {
-    l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_enc_t);
-    for
-      (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
-    {
-      if
-        (l_code_block->data)
-      {
-        opj_free(l_code_block->data-1);
-        l_code_block->data = 00;
-      }
-      if
-        (l_code_block->layers)
-      {
-        opj_free(l_code_block->layers );
-        l_code_block->layers = 00;
-      }
-      if
-        (l_code_block->passes)
-      {
-        opj_free(l_code_block->passes );
-        l_code_block->passes = 00;
-      }
-      ++l_code_block;
-    }
-    opj_free(p_precinct->cblks.enc);
-    p_precinct->cblks.enc = 00;
-  }
-}
-
-/**
- * Deallocates the encoding data of the given precinct.
- */
-void tcd_code_block_dec_deallocate (opj_tcd_precinct_t * p_precinct)
-{
-  OPJ_UINT32 cblkno , l_nb_code_blocks;
-
-  opj_tcd_cblk_dec_t * l_code_block = p_precinct->cblks.dec;
-  if
-    (l_code_block)
-  {
-    l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_dec_t);
-    for
-      (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
-    {
-      if
-        (l_code_block->data)
-      {
-        opj_free(l_code_block->data);
-        l_code_block->data = 00;
-      }
-      if
-        (l_code_block->segs)
-      {
-        opj_free(l_code_block->segs );
-        l_code_block->segs = 00;
-      }
-      ++l_code_block;
-    }
-    opj_free(p_precinct->cblks.dec);
-    p_precinct->cblks.dec = 00;
-  }
-}
-
-void tcd_free_tile(opj_tcd_t *p_tcd)
-{
-  OPJ_UINT32 compno, resno, bandno, precno;
-  opj_tcd_tile_t *l_tile = 00;
-  opj_tcd_tilecomp_t *l_tile_comp = 00;
-  opj_tcd_resolution_t *l_res = 00;
-  opj_tcd_band_t *l_band = 00;
-  opj_tcd_precinct_t *l_precinct = 00;
-  OPJ_UINT32 l_nb_resolutions, l_nb_precincts;
-  void (* l_tcd_code_block_deallocate) (opj_tcd_precinct_t *) = 00;
-
-  if
-    (! p_tcd)
-  {
-    return;
-  }
-  if
-    (! p_tcd->tcd_image)
-  {
-    return;
-  }
-  if
-    (p_tcd->m_is_decoder)
-  {
-    l_tcd_code_block_deallocate = tcd_code_block_dec_deallocate;
-  }
-  else
-  {
-    l_tcd_code_block_deallocate = tcd_code_block_enc_deallocate;
-  }
-
-
-  l_tile = p_tcd->tcd_image->tiles;
-  if
-    (! l_tile)
-  {
-    return;
-  }
-  l_tile_comp = l_tile->comps;
-
-  for
-    (compno = 0; compno < l_tile->numcomps; ++compno)
-  {
-    l_res = l_tile_comp->resolutions;
-    if
-      (l_res)
-    {
-      l_nb_resolutions = l_tile_comp->resolutions_size / sizeof(opj_tcd_resolution_t);
-      for
-        (resno = 0; resno < l_nb_resolutions; ++resno)
-      {
-        l_band = l_res->bands;
-        for
-          (bandno = 0; bandno < 3; ++bandno)
-        {
-          l_precinct = l_band->precincts;
-          if
-            (l_precinct)
-          {
-            l_nb_precincts = l_band->precincts_data_size / sizeof(opj_tcd_precinct_t);
-            for
-              (precno = 0; precno < l_nb_precincts; ++precno)
-            {
-              tgt_destroy(l_precinct->incltree);
-              l_precinct->incltree = 00;
-              tgt_destroy(l_precinct->imsbtree);
-              l_precinct->imsbtree = 00;
-              (*l_tcd_code_block_deallocate) (l_precinct);
-              ++l_precinct;
-            }
-            opj_free(l_band->precincts);
-            l_band->precincts = 00;
-          }
-          ++l_band;
-        } /* for (resno */
-        ++l_res;
-      }
-      opj_free(l_tile_comp->resolutions);
-      l_tile_comp->resolutions = 00;
-    }
-    if
-      (l_tile_comp->data)
-    {
-      opj_aligned_free(l_tile_comp->data);
-      l_tile_comp->data = 00;
-    }
-    ++l_tile_comp;
-  }
-  opj_free(l_tile->comps);
-  l_tile->comps = 00;
-  opj_free(p_tcd->tcd_image->tiles);
-  p_tcd->tcd_image->tiles = 00;
-}
-
-bool tcd_init(
-             opj_tcd_t *p_tcd,
-             opj_image_t * p_image,
-             opj_cp_t * p_cp
-             )
-{
-  OPJ_UINT32 l_tile_comp_size;
-
-  p_tcd->image = p_image;
-  p_tcd->cp = p_cp;
-  p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(sizeof(opj_tcd_tile_t));
-
-  if
-    (! p_tcd->tcd_image->tiles)
-  {
-    return false;
-  }
-  memset(p_tcd->tcd_image->tiles,0, sizeof(opj_tcd_tile_t));
-
-  l_tile_comp_size = p_image->numcomps * sizeof(opj_tcd_tilecomp_t);
-  p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_malloc(l_tile_comp_size);
-  if
-    (! p_tcd->tcd_image->tiles->comps )
-  {
-    return false;
-  }
-  memset( p_tcd->tcd_image->tiles->comps , 0 , l_tile_comp_size);
-  p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
-  p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;
-  return true;
-}
-
-void tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final) {
-  OPJ_UINT32 compno, resno, bandno, precno, cblkno;
-  OPJ_INT32 value;      /*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3]; */
-  OPJ_INT32 matrice[10][10][3];
-  OPJ_UINT32 i, j, k;
-
-  opj_cp_t *cp = tcd->cp;
-  opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
-  opj_tcp_t *tcd_tcp = tcd->tcp;
-
-  for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-    opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-    for (i = 0; i < tcd_tcp->numlayers; i++) {
-      for (j = 0; j < tilec->numresolutions; j++) {
-        for (k = 0; k < 3; k++) {
-          matrice[i][j][k] =
-            (OPJ_INT32) (cp->m_specific_param.m_enc.m_matrice[i * tilec->numresolutions * 3 + j * 3 + k]
-            * (OPJ_FLOAT32) (tcd->image->comps[compno].prec / 16.0));
-        }
-      }
-    }
-
-    for (resno = 0; resno < tilec->numresolutions; resno++) {
-      opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-      for (bandno = 0; bandno < res->numbands; bandno++) {
-        opj_tcd_band_t *band = &res->bands[bandno];
-        for (precno = 0; precno < res->pw * res->ph; precno++) {
-          opj_tcd_precinct_t *prc = &band->precincts[precno];
-          for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-            opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
-            opj_tcd_layer_t *layer = &cblk->layers[layno];
-            OPJ_UINT32 n;
-            OPJ_INT32 imsb = tcd->image->comps[compno].prec - cblk->numbps;  /* number of bit-plan equal to zero */
-            /* Correction of the matrix of coefficient to include the IMSB information */
-            if (layno == 0) {
-              value = matrice[layno][resno][bandno];
-              if (imsb >= value) {
-                value = 0;
-              } else {
-                value -= imsb;
-              }
-            } else {
-              value =  matrice[layno][resno][bandno] -  matrice[layno - 1][resno][bandno];
-              if (imsb >= matrice[layno - 1][resno][bandno]) {
-                value -= (imsb - matrice[layno - 1][resno][bandno]);
-                if (value < 0) {
-                  value = 0;
-                }
-              }
-            }
-
-            if (layno == 0) {
-              cblk->numpassesinlayers = 0;
-            }
-
-            n = cblk->numpassesinlayers;
-            if (cblk->numpassesinlayers == 0) {
-              if (value != 0) {
-                n = 3 * value - 2 + cblk->numpassesinlayers;
-              } else {
-                n = cblk->numpassesinlayers;
-              }
-            } else {
-              n = 3 * value + cblk->numpassesinlayers;
-            }
-
-            layer->numpasses = n - cblk->numpassesinlayers;
-
-            if (!layer->numpasses)
-              continue;
-
-            if (cblk->numpassesinlayers == 0) {
-              layer->len = cblk->passes[n - 1].rate;
-              layer->data = cblk->data;
-            } else {
-              layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers - 1].rate;
-              layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
-            }
-            if (final)
-              cblk->numpassesinlayers = n;
-          }
-        }
-      }
-    }
-  }
-}
-
-void tcd_rateallocate_fixed(opj_tcd_t *tcd) {
-  OPJ_UINT32 layno;
-  for (layno = 0; layno < tcd->tcp->numlayers; layno++) {
-    tcd_makelayer_fixed(tcd, layno, 1);
-  }
-}
-
-void tcd_makelayer(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_FLOAT64 thresh, OPJ_UINT32 final) {
-  OPJ_UINT32 compno, resno, bandno, precno, cblkno;
-  OPJ_UINT32 passno;
-
-  opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
-
-  tcd_tile->distolayer[layno] = 0;  /* fixed_quality */
-
-  for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-    opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-    for (resno = 0; resno < tilec->numresolutions; resno++) {
-      opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-      for (bandno = 0; bandno < res->numbands; bandno++) {
-        opj_tcd_band_t *band = &res->bands[bandno];
-        for (precno = 0; precno < res->pw * res->ph; precno++) {
-          opj_tcd_precinct_t *prc = &band->precincts[precno];
-          for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-            opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
-            opj_tcd_layer_t *layer = &cblk->layers[layno];
-
-            OPJ_UINT32 n;
-            if (layno == 0) {
-              cblk->numpassesinlayers = 0;
-            }
-            n = cblk->numpassesinlayers;
-            for (passno = cblk->numpassesinlayers; passno < cblk->totalpasses; passno++) {
-              OPJ_INT32 dr;
-              OPJ_FLOAT64 dd;
-              opj_tcd_pass_t *pass = &cblk->passes[passno];
-              if (n == 0) {
-                dr = pass->rate;
-                dd = pass->distortiondec;
-              } else {
-                dr = pass->rate - cblk->passes[n - 1].rate;
-                dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
-              }
-              if (!dr) {
-                if (dd != 0)
-                  n = passno + 1;
-                continue;
-              }
-              if (dd / dr >= thresh)
-                n = passno + 1;
-            }
-            layer->numpasses = n - cblk->numpassesinlayers;
-
-            if (!layer->numpasses) {
-              layer->disto = 0;
-              continue;
-            }
-            if (cblk->numpassesinlayers == 0) {
-              layer->len = cblk->passes[n - 1].rate;
-              layer->data = cblk->data;
-              layer->disto = cblk->passes[n - 1].distortiondec;
-            } else {
-              layer->len = cblk->passes[n - 1].rate -  cblk->passes[cblk->numpassesinlayers - 1].rate;
-              layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
-              layer->disto = cblk->passes[n - 1].distortiondec - cblk->passes[cblk->numpassesinlayers - 1].distortiondec;
-            }
-
-            tcd_tile->distolayer[layno] += layer->disto;  /* fixed_quality */
-
-            if (final)
-              cblk->numpassesinlayers = n;
-          }
-        }
-      }
-    }
-  }
-}
-
-bool tcd_rateallocate(opj_tcd_t *tcd, OPJ_BYTE *dest, OPJ_UINT32 * p_data_written, OPJ_UINT32 len, opj_codestream_info_t *cstr_info) {
-  OPJ_UINT32 compno, resno, bandno, precno, cblkno, layno;
-  OPJ_UINT32 passno;
-  OPJ_FLOAT64 min, max;
-  OPJ_FLOAT64 cumdisto[100];  /* fixed_quality */
-  const OPJ_FLOAT64 K = 1;    /* 1.1; fixed_quality */
-  OPJ_FLOAT64 maxSE = 0;
-
-  opj_cp_t *cp = tcd->cp;
-  opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
-  opj_tcp_t *tcd_tcp = tcd->tcp;
-
-  min = DBL_MAX;
-  max = 0;
-
-  tcd_tile->numpix = 0;    /* fixed_quality */
-
-  for (compno = 0; compno < tcd_tile->numcomps; compno++) {
-    opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
-    tilec->numpix = 0;
-
-    for (resno = 0; resno < tilec->numresolutions; resno++) {
-      opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
-      for (bandno = 0; bandno < res->numbands; bandno++) {
-        opj_tcd_band_t *band = &res->bands[bandno];
-
-        for (precno = 0; precno < res->pw * res->ph; precno++) {
-          opj_tcd_precinct_t *prc = &band->precincts[precno];
-
-          for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
-            opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
-
-            for (passno = 0; passno < cblk->totalpasses; passno++) {
-              opj_tcd_pass_t *pass = &cblk->passes[passno];
-              OPJ_INT32 dr;
-              OPJ_FLOAT64 dd, rdslope;
-              if (passno == 0) {
-                dr = pass->rate;
-                dd = pass->distortiondec;
-              } else {
-                dr = pass->rate - cblk->passes[passno - 1].rate;
-                dd = pass->distortiondec - cblk->passes[passno - 1].distortiondec;
-              }
-              if (dr == 0) {
-                continue;
-              }
-              rdslope = dd / dr;
-              if (rdslope < min) {
-                min = rdslope;
-              }
-              if (rdslope > max) {
-                max = rdslope;
-              }
-            } /* passno */
-
-            /* fixed_quality */
-            tcd_tile->numpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0));
-            tilec->numpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0));
-          } /* cbklno */
-        } /* precno */
-      } /* bandno */
-    } /* resno */
-
-    maxSE += (((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) - 1.0)
-      * ((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) -1.0))
-      * ((OPJ_FLOAT64)(tilec->numpix));
-  } /* compno */
-
-  /* index file */
-  if(cstr_info) {
-    opj_tile_info_t *tile_info = &cstr_info->tile[tcd->tcd_tileno];
-    tile_info->numpix = tcd_tile->numpix;
-    tile_info->distotile = tcd_tile->distotile;
-    tile_info->thresh = (OPJ_FLOAT64 *) opj_malloc(tcd_tcp->numlayers * sizeof(OPJ_FLOAT64));
-  }
-
-  for (layno = 0; layno < tcd_tcp->numlayers; layno++) {
-    OPJ_FLOAT64 lo = min;
-    OPJ_FLOAT64 hi = max;
-    bool success = false;
-    OPJ_UINT32 maxlen = tcd_tcp->rates[layno] ? uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
-    OPJ_FLOAT64 goodthresh = 0;
-    OPJ_FLOAT64 stable_thresh = 0;
-    OPJ_UINT32 i;
-    OPJ_FLOAT64 distotarget;    /* fixed_quality */
-
-    /* fixed_quality */
-    distotarget = tcd_tile->distotile - ((K * maxSE) / pow((OPJ_FLOAT32)10, tcd_tcp->distoratio[layno] / 10));
-
-    /* Don't try to find an optimal threshold but rather take everything not included yet, if
-      -r xx,yy,zz,0   (disto_alloc == 1 and rates == 0)
-      -q xx,yy,zz,0    (fixed_quality == 1 and distoratio == 0)
-      ==> possible to have some lossy layers and the last layer for sure lossless */
-    if ( ((cp->m_specific_param.m_enc.m_disto_alloc==1) && (tcd_tcp->rates[layno]>0)) || ((cp->m_specific_param.m_enc.m_fixed_quality==1) && (tcd_tcp->distoratio[layno]>0))) {
-      opj_t2_t *t2 = t2_create(tcd->image, cp);
-      OPJ_FLOAT64 thresh = 0;
-      if
-        (t2 == 00)
-      {
-        return false;
-      }
-
-      for
-        (i = 0; i < 128; ++i)
-      {
-        OPJ_FLOAT64 distoachieved = 0;  /* fixed_quality */
-        thresh = (lo + hi) / 2;
-
-        tcd_makelayer(tcd, layno, thresh, 0);
-
-        if (cp->m_specific_param.m_enc.m_fixed_quality) {  /* fixed_quality */
-          if(cp->m_specific_param.m_enc.m_cinema){
-            if
-              (! t2_encode_packets(t2,tcd->tcd_tileno, tcd_tile, layno + 1, dest, p_data_written, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC))
-            {
-              lo = thresh;
-              continue;
-            }
-            else
-            {
-               distoachieved =  layno == 0 ?
-              tcd_tile->distolayer[0]  : cumdisto[layno - 1] + tcd_tile->distolayer[layno];
-              if (distoachieved < distotarget) {
-                hi=thresh;
-                stable_thresh = thresh;
-                continue;
-              }else{
-                lo=thresh;
-              }
-            }
-          }else{
-            distoachieved =  (layno == 0) ?
-              tcd_tile->distolayer[0]  : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
-            if (distoachieved < distotarget) {
-              hi = thresh;
-              stable_thresh = thresh;
-              continue;
-            }
-            lo = thresh;
-          }
-        } else {
-          if
-            (! t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest,p_data_written, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC))
-          {
-            /* TODO: what to do with l ??? seek / tell ??? */
-            /* opj_event_msg(tcd->cinfo, EVT_INFO, "rate alloc: len=%d, max=%d\n", l, maxlen); */
-            lo = thresh;
-            continue;
-          }
-          hi = thresh;
-          stable_thresh = thresh;
-        }
-      }
-      success = true;
-      goodthresh = stable_thresh == 0? thresh : stable_thresh;
-      t2_destroy(t2);
-    } else {
-      success = true;
-      goodthresh = min;
-    }
-
-    if (!success) {
-      return false;
-    }
-
-    if(cstr_info) {  /* Threshold for Marcela Index */
-      cstr_info->tile[tcd->tcd_tileno].thresh[layno] = goodthresh;
-    }
-    tcd_makelayer(tcd, layno, goodthresh, 1);
-
-    /* fixed_quality */
-    cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
-  }
-
-  return true;
-}
-
-OPJ_UINT32 tcd_get_encoded_tile_size (
-             opj_tcd_t *p_tcd
-             )
-{
-  OPJ_UINT32 i,l_data_size = 0;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcd_tilecomp_t * l_tilec = 00;
-  OPJ_UINT32 l_size_comp, l_remaining;
-
-  l_tilec = p_tcd->tcd_image->tiles->comps;
-  l_img_comp = p_tcd->image->comps;
-  for
-    (i=0;i<p_tcd->image->numcomps;++i)
-  {
-    l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
-    l_remaining = l_img_comp->prec & 7;  /* (%8) */
-    if
-      (l_remaining)
-    {
-      ++l_size_comp;
-    }
-    if
-      (l_size_comp == 3)
-    {
-      l_size_comp = 4;
-    }
-    l_data_size += l_size_comp * (l_tilec->x1 - l_tilec->x0) * (l_tilec->y1 - l_tilec->y0);
-    ++l_img_comp;
-    ++l_tilec;
-  }
-  return l_data_size;
-}
-
-bool tcd_copy_tile_data (
-             opj_tcd_t *p_tcd,
-             OPJ_BYTE * p_src,
-             OPJ_UINT32 p_src_length
-             )
-{
-  OPJ_UINT32 i,j,l_data_size = 0;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcd_tilecomp_t * l_tilec = 00;
-  OPJ_UINT32 l_size_comp, l_remaining;
-  OPJ_UINT32 l_nb_elem;
-
-  l_data_size = tcd_get_encoded_tile_size(p_tcd);
-  if
-    (l_data_size != p_src_length)
-  {
-    return false;
-  }
-  l_tilec = p_tcd->tcd_image->tiles->comps;
-  l_img_comp = p_tcd->image->comps;
-  for
-    (i=0;i<p_tcd->image->numcomps;++i)
-  {
-    l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
-    l_remaining = l_img_comp->prec & 7;  /* (%8) */
-    l_nb_elem = (l_tilec->x1 - l_tilec->x0) * (l_tilec->y1 - l_tilec->y0);
-    if
-      (l_remaining)
-    {
-      ++l_size_comp;
-    }
-    if
-      (l_size_comp == 3)
-    {
-      l_size_comp = 4;
-    }
-    switch
-      (l_size_comp)
-    {
-      case 1:
-        {
-          OPJ_CHAR * l_src_ptr = (OPJ_CHAR *) p_src;
-          OPJ_INT32 * l_dest_ptr = l_tilec->data;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_nb_elem;++j)
-            {
-              *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
-            }
-          }
-          else
-          {
-            for
-              (j=0;j<l_nb_elem;++j)
-            {
-              *(l_dest_ptr++) = (*(l_src_ptr++))&0xff;
-            }
-          }
-          p_src = (OPJ_BYTE*) l_src_ptr;
-        }
-        break;
-      case 2:
-        {
-          OPJ_INT32 * l_dest_ptr = l_tilec->data;
-          OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_src;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_nb_elem;++j)
-            {
-              *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
-            }
-          }
-          else
-          {
-            for
-              (j=0;j<l_nb_elem;++j)
-            {
-              *(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
-            }
-
-          }
-          p_src = (OPJ_BYTE*) l_src_ptr;
-        }
-        break;
-      case 4:
-        {
-          OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_src;
-          OPJ_INT32 * l_dest_ptr = l_tilec->data;
-          for
-            (j=0;j<l_nb_elem;++j)
-          {
-            *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
-          }
-          p_src = (OPJ_BYTE*) l_src_ptr;
-        }
-        break;
-    }
-    ++l_img_comp;
-    ++l_tilec;
-  }
-  return true;
-}
-
-bool tcd_update_tile_data (
-             opj_tcd_t *p_tcd,
-             OPJ_BYTE * p_dest,
-             OPJ_UINT32 p_dest_length
-             )
-{
-  OPJ_UINT32 i,j,k,l_data_size = 0;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcd_tilecomp_t * l_tilec = 00;
-  opj_tcd_resolution_t * l_res;
-  OPJ_UINT32 l_size_comp, l_remaining;
-  OPJ_UINT32 l_stride, l_width,l_height;
-
-  l_data_size = tcd_get_decoded_tile_size(p_tcd);
-  if
-    (l_data_size > p_dest_length)
-  {
-    return false;
-  }
-
-  l_tilec = p_tcd->tcd_image->tiles->comps;
-  l_img_comp = p_tcd->image->comps;
-  for
-    (i=0;i<p_tcd->image->numcomps;++i)
-  {
-    l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
-    l_remaining = l_img_comp->prec & 7;  /* (%8) */
-    l_res = l_tilec->resolutions + l_img_comp->resno_decoded;
-    l_width = (l_res->x1 - l_res->x0);
-    l_height = (l_res->y1 - l_res->y0);
-    l_stride = (l_tilec->x1 - l_tilec->x0) - l_width;
-    if
-      (l_remaining)
-    {
-      ++l_size_comp;
-    }
-    if
-      (l_size_comp == 3)
-    {
-      l_size_comp = 4;
-    }
-    switch
-      (l_size_comp)
-    {
-      case 1:
-        {
-          OPJ_CHAR * l_dest_ptr = (OPJ_CHAR *) p_dest;
-          const OPJ_INT32 * l_src_ptr = l_tilec->data;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (OPJ_CHAR) (*(l_src_ptr++));
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          else
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (OPJ_BYTE) ((*(l_src_ptr++))&0xff);
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          p_dest = (OPJ_BYTE *)l_dest_ptr;
-
-        }
-        break;
-      case 2:
-        {
-          const OPJ_INT32 * l_src_ptr = l_tilec->data;
-          OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_dest;
-          if
-            (l_img_comp->sgnd)
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (OPJ_INT16) (*(l_src_ptr++));
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          else
-          {
-            for
-              (j=0;j<l_height;++j)
-            {
-              for
-                (k=0;k<l_width;++k)
-              {
-                *(l_dest_ptr++) = (OPJ_UINT16) ((*(l_src_ptr++))&0xffff);
-              }
-              l_src_ptr += l_stride;
-            }
-          }
-          p_dest = (OPJ_BYTE*) l_dest_ptr;
-        }
-        break;
-      case 4:
-        {
-          OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_dest;
-          OPJ_INT32 * l_src_ptr = l_tilec->data;
-          for
-            (j=0;j<l_height;++j)
-          {
-            for
-              (k=0;k<l_width;++k)
-            {
-              *(l_dest_ptr++) = (*(l_src_ptr++));
-            }
-            l_src_ptr += l_stride;
-          }
-          p_dest = (OPJ_BYTE*) l_dest_ptr;
-        }
-        break;
-    }
-    ++l_img_comp;
-    ++l_tilec;
-  }
-  return true;
-}
-
-OPJ_UINT32 tcd_get_decoded_tile_size (
-             opj_tcd_t *p_tcd
-             )
-{
-  OPJ_UINT32 i;
-  OPJ_UINT32 l_data_size = 0;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcd_tilecomp_t * l_tile_comp = 00;
-  opj_tcd_resolution_t * l_res = 00;
-  OPJ_UINT32 l_size_comp, l_remaining;
-
-  l_tile_comp = p_tcd->tcd_image->tiles->comps;
-  l_img_comp = p_tcd->image->comps;
-  for
-    (i=0;i<p_tcd->image->numcomps;++i)
-  {
-    l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
-    l_remaining = l_img_comp->prec & 7;  /* (%8) */
-    if
-      (l_remaining)
-    {
-      ++l_size_comp;
-    }
-    if
-      (l_size_comp == 3)
-    {
-      l_size_comp = 4;
-    }
-    l_res = l_tile_comp->resolutions + l_tile_comp->minimum_num_resolutions - 1;
-    l_data_size += l_size_comp * (l_res->x1 - l_res->x0) * (l_res->y1 - l_res->y0);
-    ++l_img_comp;
-    ++l_tile_comp;
-  }
-  return l_data_size;
-}
-
-bool tcd_dc_level_shift_encode (
-             opj_tcd_t *p_tcd
-             )
-{
-  OPJ_UINT32 compno;
-  opj_tcd_tilecomp_t * l_tile_comp = 00;
-  opj_tccp_t * l_tccp = 00;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcp_t * l_tcp = 00;
-  opj_tcd_tile_t * l_tile;
-  OPJ_UINT32 l_nb_elem,i;
-  OPJ_INT32 * l_current_ptr;
-
-  l_tile = p_tcd->tcd_image->tiles;
-  l_tile_comp = l_tile->comps;
-  l_tcp = p_tcd->tcp;
-  l_tccp = p_tcd->tcp->tccps;
-  l_img_comp = p_tcd->image->comps;
-  for
-    (compno = 0; compno < l_tile->numcomps; compno++)
-  {
-    l_current_ptr = l_tile_comp->data;
-    l_nb_elem = (l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_comp->y1 - l_tile_comp->y0);
-    if
-      (l_tccp->qmfbid == 1)
-    {
-      for
-        (i = 0; i < l_nb_elem; ++i)
-      {
-        *l_current_ptr -= l_tccp->m_dc_level_shift ;
-        ++l_current_ptr;
-      }
-    }
-    else
-    {
-      for
-        (i = 0; i < l_nb_elem; ++i)
-      {
-        *l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) << 11 ;
-        ++l_current_ptr;
-      }
-    }
-    ++l_img_comp;
-    ++l_tccp;
-    ++l_tile_comp;
-  }
-  return true;
-}
-
-bool tcd_mct_encode (
-           opj_tcd_t *p_tcd
-           )
-{
-  opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
-  opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps;
-  OPJ_UINT32 samples = (l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_comp->y1 - l_tile_comp->y0);
-  OPJ_UINT32 i;
-  OPJ_BYTE ** l_data = 00;
-  opj_tcp_t * l_tcp = p_tcd->tcp;
-  if
-    (!p_tcd->tcp->mct)
-  {
-    return true;
-  }
-
-  if
-    (p_tcd->tcp->mct == 2)
-  {
-    if
-      (! p_tcd->tcp->m_mct_coding_matrix)
-    {
-      return true;
-    }
-        l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps*sizeof(OPJ_BYTE*));
-    if
-      (! l_data)
-    {
-      return false;
-    }
-    for
-      (i=0;i<l_tile->numcomps;++i)
-    {
-      l_data[i] = (OPJ_BYTE*) l_tile_comp->data;
-      ++l_tile_comp;
-    }
-    if
-      (! mct_encode_custom(// MCT data
-          (OPJ_BYTE*) p_tcd->tcp->m_mct_coding_matrix,
-          // size of components
-          samples,
-          // components
-          l_data,
-          // nb of components (i.e. size of pData)
-          l_tile->numcomps,
-          // tells if the data is signed
-          p_tcd->image->comps->sgnd)
-      )
-    {
-            opj_free(l_data);
-      return false;
-    }
-    opj_free(l_data);
-  }
-  else if (l_tcp->tccps->qmfbid == 0)
-  {
-    mct_encode_real(l_tile->comps[0].data, l_tile->comps[1].data, l_tile->comps[2].data, samples);
-  }
-  else
-  {
-    mct_encode(l_tile->comps[0].data, l_tile->comps[1].data, l_tile->comps[2].data, samples);
-  }
-  return true;
-}
-
-bool tcd_dwt_encode (
-            opj_tcd_t *p_tcd
-           )
-{
-  opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
-  opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps;
-  opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
-  OPJ_UINT32 compno;
-
-
-   for
-     (compno = 0; compno < l_tile->numcomps; ++compno)
-  {
-    if
-      (l_tccp->qmfbid == 1)
-    {
-      if
-        (! dwt_encode(l_tile_comp))
-      {
-        return false;
-      }
-    }
-    else if
-      (l_tccp->qmfbid == 0)
-    {
-      if
-        (! dwt_encode_real(l_tile_comp))
-      {
-        return false;
-      }
-    }
-    ++l_tile_comp;
-    ++l_tccp;
-  }
-  return true;
-}
-
-bool tcd_t1_encode (
-            opj_tcd_t *p_tcd
-           )
-{
-  opj_t1_t * l_t1;
-  const OPJ_FLOAT64 * l_mct_norms;
-  opj_tcp_t * l_tcp = p_tcd->tcp;
-
-  l_t1 = t1_create();
-  if
-    (l_t1 == 00)
-  {
-    return false;
-  }
-  if
-    (l_tcp->mct == 1)
-  {
-    // irreversible encoding
-    if
-      (l_tcp->tccps->qmfbid == 0)
-    {
-      l_mct_norms = get_mct_norms_real();
-    }
-    else
-    {
-      l_mct_norms = get_mct_norms();
-    }
-  }
-  else
-  {
-    l_mct_norms = (const OPJ_FLOAT64 *) (l_tcp->mct_norms);
-  }
-
-  if
-    (! t1_encode_cblks(l_t1, p_tcd->tcd_image->tiles , l_tcp, l_mct_norms))
-  {
-        t1_destroy(l_t1);
-    return false;
-  }
-  t1_destroy(l_t1);
-  return true;
-}
-
-bool tcd_t2_encode (
-          opj_tcd_t *p_tcd,
-          OPJ_BYTE * p_dest_data,
-          OPJ_UINT32 * p_data_written,
-          OPJ_UINT32 p_max_dest_size,
-          opj_codestream_info_t *p_cstr_info
-          )
-{
-  opj_t2_t * l_t2;
-
-  l_t2 = t2_create(p_tcd->image, p_tcd->cp);
-  if
-    (l_t2 == 00)
-  {
-    return false;
-  }
-
-  if
-    (! t2_encode_packets(
-          l_t2,
-          p_tcd->tcd_tileno,
-          p_tcd->tcd_image->tiles,
-          p_tcd->tcp->numlayers,
-          p_dest_data,
-          p_data_written,
-          p_max_dest_size,
-          p_cstr_info,
-          p_tcd->tp_num,
-          p_tcd->tp_pos,
-          p_tcd->cur_pino,
-          FINAL_PASS))
-  {
-    t2_destroy(l_t2);
-    return false;
-  }
-  t2_destroy(l_t2);
-
-  /*---------------CLEAN-------------------*/
-  return true;
-}
-
-bool tcd_rate_allocate_encode(
-            opj_tcd_t *p_tcd,
-            OPJ_BYTE * p_dest_data,
-            OPJ_UINT32 p_max_dest_size,
-            opj_codestream_info_t *p_cstr_info
-            )
-{
-  opj_cp_t * l_cp = p_tcd->cp;
-  OPJ_UINT32 l_nb_written = 0;
-
-  if
-    (p_cstr_info)
-  {
-    p_cstr_info->index_write = 0;
-  }
-  if
-    (l_cp->m_specific_param.m_enc.m_disto_alloc|| l_cp->m_specific_param.m_enc.m_fixed_quality)
-  {  /* fixed_quality */
-    /* Normal Rate/distortion allocation */
-    if
-      (! tcd_rateallocate(p_tcd, p_dest_data,&l_nb_written, p_max_dest_size, p_cstr_info))
-    {
-      return false;
-    }
-  }
-  else
-  {
-    /* Fixed layer allocation */
-    tcd_rateallocate_fixed(p_tcd);
-  }
-  return true;
-}
-
-bool tcd_t2_decode (
-          opj_tcd_t *p_tcd,
-          OPJ_BYTE * p_src_data,
-          OPJ_UINT32 * p_data_read,
-          OPJ_UINT32 p_max_src_size,
-          opj_codestream_info_t *p_cstr_info
-          )
-{
-  opj_t2_t * l_t2;
-
-  l_t2 = t2_create(p_tcd->image, p_tcd->cp);
-  if
-    (l_t2 == 00)
-  {
-    return false;
-  }
-
-  if
-    (! t2_decode_packets(
-          l_t2,
-          p_tcd->tcd_tileno,
-          p_tcd->tcd_image->tiles,
-          p_src_data,
-          p_data_read,
-          p_max_src_size,
-          p_cstr_info))
-  {
-    t2_destroy(l_t2);
-    return false;
-  }
-  t2_destroy(l_t2);
-
-  /*---------------CLEAN-------------------*/
-  return true;
-}
-
-bool tcd_t1_decode (
-            opj_tcd_t *p_tcd
-           )
-{
-  OPJ_UINT32 compno;
-  opj_t1_t * l_t1;
-  opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
-  opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps;
-  opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
-
-
-  l_t1 = t1_create();
-  if
-    (l_t1 == 00)
-  {
-    return false;
-  }
-  for
-    (compno = 0; compno < l_tile->numcomps; ++compno)
-  {
-    /* The +3 is headroom required by the vectorized DWT */
-    t1_decode_cblks(l_t1, l_tile_comp, l_tccp);
-    ++l_tile_comp;
-    ++l_tccp;
-  }
-  t1_destroy(l_t1);
-  return true;
-}
-
-bool tcd_dwt_decode (
-            opj_tcd_t *p_tcd
-           )
-{
-  OPJ_UINT32 compno;
-  opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
-  opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
-  opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
-  opj_image_comp_t * l_img_comp = p_tcd->image->comps;
-
-  for
-    (compno = 0; compno < l_tile->numcomps; compno++)
-  {
-    /*
-    if (tcd->cp->reduce != 0) {
-      tcd->image->comps[compno].resno_decoded =
-        tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
-      if (tcd->image->comps[compno].resno_decoded < 0)
-      {
-        return false;
-      }
-    }
-    numres2decode = tcd->image->comps[compno].resno_decoded + 1;
-    if(numres2decode > 0){
-    */
-    if
-      (l_tccp->qmfbid == 1)
-    {
-      if
-        (! dwt_decode(l_tile_comp, l_img_comp->resno_decoded+1))
-      {
-        return false;
-      }
-    }
-    else
-    {
-      if
-        (! dwt_decode_real(l_tile_comp, l_img_comp->resno_decoded+1))
-      {
-        return false;
-      }
-    }
-    ++l_tile_comp;
-    ++l_img_comp;
-    ++l_tccp;
-  }
-  return true;
-}
-bool tcd_mct_decode (
-            opj_tcd_t *p_tcd
-           )
-{
-  opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
-  opj_tcp_t * l_tcp = p_tcd->tcp;
-  opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
-  OPJ_UINT32 l_samples,i;
-
-  if
-    (! l_tcp->mct)
-  {
-    return true;
-  }
-  l_samples = (l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_comp->y1 - l_tile_comp->y0);
-  if
-    (l_tcp->mct == 2)
-  {
-    OPJ_BYTE ** l_data;
-    if
-      (! l_tcp->m_mct_decoding_matrix)
-    {
-      return true;
-    }
-    l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps*sizeof(OPJ_BYTE*));
-    if
-      (! l_data)
-    {
-      return false;
-    }
-    for
-      (i=0;i<l_tile->numcomps;++i)
-    {
-      l_data[i] = (OPJ_BYTE*) l_tile_comp->data;
-      ++l_tile_comp;
-    }
-    if
-      (! mct_decode_custom(  // MCT data
-                (OPJ_BYTE*) l_tcp->m_mct_decoding_matrix,
-                // size of components
-                l_samples,
-                // components
-                l_data,
-                // nb of components (i.e. size of pData)
-                l_tile->numcomps,
-                // tells if the data is signed
-                p_tcd->image->comps->sgnd))
-    {
-      opj_free(l_data);
-      return false;
-    }
-    opj_free(l_data);
-  }
-  else
-  {
-    if
-      (l_tcp->tccps->qmfbid == 1)
-    {
-      mct_decode(
-          l_tile->comps[0].data,
-          l_tile->comps[1].data,
-          l_tile->comps[2].data,
-          l_samples);
-    }
-    else
-    {
-      mct_decode_real(
-          (float*)l_tile->comps[0].data,
-          (float*)l_tile->comps[1].data,
-          (float*)l_tile->comps[2].data,
-          l_samples);
-    }
-  }
-  return true;
-}
-
-bool tcd_dc_level_shift_decode (
-             opj_tcd_t *p_tcd
-             )
-{
-  OPJ_UINT32 compno;
-  opj_tcd_tilecomp_t * l_tile_comp = 00;
-  opj_tccp_t * l_tccp = 00;
-  opj_image_comp_t * l_img_comp = 00;
-  opj_tcd_resolution_t* l_res = 00;
-  opj_tcp_t * l_tcp = 00;
-  opj_tcd_tile_t * l_tile;
-  OPJ_UINT32 l_width,l_height,i,j;
-  OPJ_INT32 * l_current_ptr;
-  OPJ_INT32 l_min, l_max;
-  OPJ_UINT32 l_stride;
-
-  l_tile = p_tcd->tcd_image->tiles;
-  l_tile_comp = l_tile->comps;
-  l_tcp = p_tcd->tcp;
-  l_tccp = p_tcd->tcp->tccps;
-  l_img_comp = p_tcd->image->comps;
-
-  for
-    (compno = 0; compno < l_tile->numcomps; compno++)
-  {
-    l_res = l_tile_comp->resolutions + l_img_comp->resno_decoded;
-    l_width = (l_res->x1 - l_res->x0);
-    l_height = (l_res->y1 - l_res->y0);
-    l_stride = (l_tile_comp->x1 - l_tile_comp->x0) - l_width;
-    if
-      (l_img_comp->sgnd)
-    {
-      l_min = -(1 << (l_img_comp->prec - 1));
-      l_max = (1 << (l_img_comp->prec - 1)) - 1;
-    }
-    else
-    {
-            l_min = 0;
-      l_max = (1 << l_img_comp->prec) - 1;
-    }
-    l_current_ptr = l_tile_comp->data;
-    if
-      (l_tccp->qmfbid == 1)
-    {
-      for
-        (j=0;j<l_height;++j)
-      {
-        for
-          (i = 0; i < l_width; ++i)
-        {
-          *l_current_ptr = int_clamp(*l_current_ptr + l_tccp->m_dc_level_shift, l_min, l_max);
-          ++l_current_ptr;
-        }
-        l_current_ptr += l_stride;
-      }
-    }
-    else
-    {
-      for
-        (j=0;j<l_height;++j)
-      {
-        for
-          (i = 0; i < l_width; ++i)
-        {
-          OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *) l_current_ptr);
-          *l_current_ptr = int_clamp(lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ;
-          ++l_current_ptr;
-        }
-        l_current_ptr += l_stride;
-      }
-    }
-    ++l_img_comp;
-    ++l_tccp;
-    ++l_tile_comp;
-  }
-  return true;
-}
-
-bool tcd_encode_tile(
-           opj_tcd_t *p_tcd,
-           OPJ_UINT32 p_tile_no,
-           OPJ_BYTE *p_dest,
-           OPJ_UINT32 * p_data_written,
-           OPJ_UINT32 p_max_length,
-           opj_codestream_info_t *p_cstr_info)
-{
-
-  if
-    (p_tcd->cur_tp_num == 0)
-  {
-    p_tcd->tcd_tileno = p_tile_no;
-    p_tcd->tcp = &p_tcd->cp->tcps[p_tile_no];
-    /* INDEX >> "Precinct_nb_X et Precinct_nb_Y" */
-    if(p_cstr_info)
-    {
-      OPJ_UINT32 l_num_packs = 0;
-      OPJ_UINT32 i;
-      opj_tcd_tilecomp_t *l_tilec_idx = &p_tcd->tcd_image->tiles->comps[0];  /* based on component 0 */
-      opj_tccp_t *l_tccp = p_tcd->tcp->tccps;  /* based on component 0 */
-      for (i = 0; i < l_tilec_idx->numresolutions; i++) {
-        opj_tcd_resolution_t *l_res_idx = &l_tilec_idx->resolutions[i];
-
-        p_cstr_info->tile[p_tile_no].pw[i] = l_res_idx->pw;
-        p_cstr_info->tile[p_tile_no].ph[i] = l_res_idx->ph;
-
-        l_num_packs += l_res_idx->pw * l_res_idx->ph;
-        p_cstr_info->tile[p_tile_no].pdx[i] = l_tccp->prcw[i];
-        p_cstr_info->tile[p_tile_no].pdy[i] = l_tccp->prch[i];
-      }
-      p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t*) opj_calloc(p_cstr_info->numcomps * p_cstr_info->numlayers * l_num_packs, sizeof(opj_packet_info_t));
-    }
-    /* << INDEX */
-    _ProfStart(PGROUP_DC_SHIFT);
-    /*---------------TILE-------------------*/
-    if
-      (! tcd_dc_level_shift_encode(p_tcd))
-    {
-      return false;
-    }
-    _ProfStop(PGROUP_DC_SHIFT);
-
-    _ProfStart(PGROUP_MCT);
-    if
-      (! tcd_mct_encode(p_tcd))
-    {
-      return false;
-    }
-    _ProfStop(PGROUP_MCT);
-
-    _ProfStart(PGROUP_DWT);
-    if
-      (! tcd_dwt_encode(p_tcd))
-    {
-      return false;
-    }
-    _ProfStop(PGROUP_DWT);
-
-    _ProfStart(PGROUP_T1);
-    if
-      (! tcd_t1_encode(p_tcd))
-    {
-      return false;
-    }
-    _ProfStop(PGROUP_T1);
-
-    _ProfStart(PGROUP_RATE);
-    if
-      (! tcd_rate_allocate_encode(p_tcd,p_dest,p_max_length,p_cstr_info))
-    {
-      return false;
-    }
-    _ProfStop(PGROUP_RATE);
-
-  }
-  /*--------------TIER2------------------*/
-
-  /* INDEX */
-  if
-    (p_cstr_info)
-  {
-    p_cstr_info->index_write = 1;
-  }
-  _ProfStart(PGROUP_T2);
-  if
-    (! tcd_t2_encode(p_tcd,p_dest,p_data_written,p_max_length,p_cstr_info))
-  {
-    return false;
-  }
-  _ProfStop(PGROUP_T2);
-  /*---------------CLEAN-------------------*/
-  return true;
-}
-
-bool tcd_decode_tile(
-           opj_tcd_t *p_tcd,
-           OPJ_BYTE *p_src,
-           OPJ_UINT32 p_max_length,
-           OPJ_UINT32 p_tile_no,
-           opj_codestream_info_t *p_cstr_info)
-{
-  OPJ_UINT32 l_data_read;
-  p_tcd->tcd_tileno = p_tile_no;
-  p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]);
-
-  /* INDEX >>  */
-  if(p_cstr_info) {
-    OPJ_UINT32 resno, compno, numprec = 0;
-    for (compno = 0; compno < (OPJ_UINT32) p_cstr_info->numcomps; compno++) {
-      opj_tcp_t *tcp = &p_tcd->cp->tcps[0];
-      opj_tccp_t *tccp = &tcp->tccps[compno];
-      opj_tcd_tilecomp_t *tilec_idx = &p_tcd->tcd_image->tiles->comps[compno];
-      for (resno = 0; resno < tilec_idx->numresolutions; resno++) {
-        opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno];
-        p_cstr_info->tile[p_tile_no].pw[resno] = res_idx->pw;
-        p_cstr_info->tile[p_tile_no].ph[resno] = res_idx->ph;
-        numprec += res_idx->pw * res_idx->ph;
-        p_cstr_info->tile[p_tile_no].pdx[resno] = tccp->prcw[resno];
-        p_cstr_info->tile[p_tile_no].pdy[resno] = tccp->prch[resno];
-      }
-    }
-    p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_malloc(p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t));
-    p_cstr_info->packno = 0;
-  }
-  /* << INDEX */
-
-  /*--------------TIER2------------------*/
-  _ProfStart(PGROUP_T2);
-  l_data_read = 0;
-  if
-    (! tcd_t2_decode(p_tcd,p_src,&l_data_read,p_max_length,p_cstr_info))
-  {
-    return false;
-  }
-  _ProfStop(PGROUP_T2);
-
-  /*------------------TIER1-----------------*/
-
-  _ProfStart(PGROUP_T1);
-  if
-    (! tcd_t1_decode(p_tcd))
-  {
-    return false;
-  }
-  _ProfStop(PGROUP_T1);
-
-  /*----------------DWT---------------------*/
-
-  _ProfStart(PGROUP_DWT);
-  if
-    (! tcd_dwt_decode(p_tcd))
-  {
-    return false;
-  }
-  _ProfStop(PGROUP_DWT);
-
-  /*----------------MCT-------------------*/
-  _ProfStart(PGROUP_MCT);
-  if
-    (! tcd_mct_decode(p_tcd))
-  {
-    return false;
-  }
-  _ProfStop(PGROUP_MCT);
-
-  _ProfStart(PGROUP_DC_SHIFT);
-  if
-    (! tcd_dc_level_shift_decode(p_tcd))
-  {
-    return false;
-  }
-  _ProfStop(PGROUP_DC_SHIFT);
-
-
-  /*---------------TILE-------------------*/
-  return true;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.h b/Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.h
deleted file mode 100644
index 62bbdb7..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tcd.h
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __TCD_H
-#define __TCD_H
-/**
- at file tcd.h
- at brief Implementation of a tile coder/decoder (TCD)
-
-The functions in TCD.C have for goal to encode or decode each tile independently from
-each other. The functions in TCD.C are used by some function in J2K.C.
-*/
-#include "openjpeg.h"
-/** @defgroup TCD TCD - Implementation of a tile coder/decoder */
-/*@{*/
-struct opj_common_struct;
-struct opj_codestream_info;
-struct opj_image;
-struct opj_tcp;
-struct opj_cp;
-struct opj_tgt_tree;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_seg {
-  OPJ_BYTE ** data;
-  OPJ_UINT32 dataindex;
-  OPJ_UINT32 numpasses;
-  OPJ_UINT32 real_num_passes;
-  OPJ_UINT32 len;
-  OPJ_UINT32 maxpasses;
-  OPJ_UINT32 numnewpasses;
-  OPJ_UINT32 newlen;
-} opj_tcd_seg_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_pass {
-  OPJ_UINT32 rate;
-  OPJ_FLOAT64 distortiondec;
-  OPJ_UINT32 len;
-  OPJ_UINT32 term : 1;
-} opj_tcd_pass_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_layer {
-  OPJ_UINT32 numpasses;    /* Number of passes in the layer */
-  OPJ_UINT32 len;      /* len of information */
-  OPJ_FLOAT64 disto;      /* add for index (Cfr. Marcela) */
-  OPJ_BYTE *data;    /* data */
-} opj_tcd_layer_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_cblk_enc {
-  OPJ_BYTE* data;  /* Data */
-  opj_tcd_layer_t* layers;  /* layer information */
-  opj_tcd_pass_t* passes;  /* information about the passes */
-  OPJ_INT32 x0, y0, x1, y1;    /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
-  OPJ_UINT32 numbps;
-  OPJ_UINT32 numlenbits;
-  OPJ_UINT32 numpasses;    /* number of pass already done for the code-blocks */
-  OPJ_UINT32 numpassesinlayers;  /* number of passes in the layer */
-  OPJ_UINT32 totalpasses;    /* total number of passes */
-} opj_tcd_cblk_enc_t;
-
-typedef struct opj_tcd_cblk_dec {
-  OPJ_BYTE * data;  /* Data */
-  opj_tcd_seg_t* segs;    /* segments informations */
-  OPJ_INT32 x0, y0, x1, y1;    /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
-  OPJ_UINT32 numbps;
-  OPJ_UINT32 numlenbits;
-  OPJ_UINT32 len;      /* length */
-  OPJ_UINT32 numnewpasses;    /* number of pass added to the code-blocks */
-  OPJ_UINT32 numsegs;      /* number of segments */
-  OPJ_UINT32 real_num_segs;
-  OPJ_UINT32 m_current_max_segs;
-} opj_tcd_cblk_dec_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_precinct {
-  OPJ_INT32 x0, y0, x1, y1;    /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
-  OPJ_UINT32 cw, ch;      /* number of precinct in width and heigth */
-  union{    /* code-blocks informations */
-    opj_tcd_cblk_enc_t* enc;
-    opj_tcd_cblk_dec_t* dec;
-  } cblks;
-  OPJ_UINT32 block_size;    /* size taken by cblks (in bytes) */
-  struct opj_tgt_tree *incltree;    /* inclusion tree */
- struct opj_tgt_tree *imsbtree;    /* IMSB tree */
-} opj_tcd_precinct_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_band {
-  OPJ_INT32 x0, y0, x1, y1;    /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
-  OPJ_UINT32 bandno;
-  opj_tcd_precinct_t *precincts;  /* precinct information */
-  OPJ_UINT32 precincts_data_size;    /* size of data taken by precincts */
-  OPJ_INT32 numbps;
-  OPJ_FLOAT32 stepsize;
-} opj_tcd_band_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_resolution {
-  OPJ_INT32 x0, y0, x1, y1;    /* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */
-  OPJ_UINT32 pw, ph;
-  OPJ_UINT32 numbands;      /* number sub-band for the resolution level */
-  opj_tcd_band_t bands[3];    /* subband information */
-} opj_tcd_resolution_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_tilecomp
-{
-  OPJ_INT32 x0, y0, x1, y1;    /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
-  OPJ_UINT32 numresolutions;    /* number of resolutions level */
-  OPJ_UINT32 minimum_num_resolutions;    /* number of resolutions level to decode (at max)*/
-  opj_tcd_resolution_t *resolutions;  /* resolutions information */
-  OPJ_UINT32 resolutions_size;    /* size of data for resolutions (in bytes) */
-  OPJ_INT32 *data;      /* data of the component */
-  OPJ_UINT32 data_size;      /* size of the data of the component */
-  OPJ_INT32 numpix;      /* add fixed_quality */
-} opj_tcd_tilecomp_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_tile {
-  OPJ_INT32 x0, y0, x1, y1;    /* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */
-  OPJ_UINT32 numcomps;      /* number of components in tile */
-  opj_tcd_tilecomp_t *comps;  /* Components information */
-  OPJ_INT32 numpix;      /* add fixed_quality */
-  OPJ_FLOAT64 distotile;    /* add fixed_quality */
-  OPJ_FLOAT64 distolayer[100];  /* add fixed_quality */
-  /** packet number */
-  OPJ_UINT32 packno;
-} opj_tcd_tile_t;
-
-/**
-FIXME: documentation
-*/
-typedef struct opj_tcd_image
-{
-  opj_tcd_tile_t *tiles;    /* Tiles information */
-}
-opj_tcd_image_t;
-
-/**
-Tile coder/decoder
-*/
-typedef struct opj_tcd
-{
-  /** Position of the tilepart flag in Progression order*/
-  OPJ_INT32 tp_pos;
-  /** Tile part number*/
-  OPJ_UINT32 tp_num;
-  /** Current tile part number*/
-  OPJ_UINT32 cur_tp_num;
-  /** Total number of tileparts of the current tile*/
-  OPJ_UINT32 cur_totnum_tp;
-  /** Current Packet iterator number */
-  OPJ_UINT32 cur_pino;
-  /** info on each image tile */
-  struct opj_tcd_image *tcd_image;
-  /** image */
-  struct opj_image *image;
-  /** coding parameters */
-  struct opj_cp *cp;
-  /** coding/decoding parameters common to all tiles */
-  struct opj_tcp *tcp;
-  /** current encoded/decoded tile */
-  OPJ_UINT32 tcd_tileno;
-  /** tell if the tcd is a decoder. */
-  OPJ_UINT32 m_is_decoder : 1;
-} opj_tcd_t;
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Dump the content of a tcd structure
-*/
-//void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);
-/**
-Create a new TCD handle
- at param cinfo Codec context info
- at return Returns a new TCD handle if successful returns NULL otherwise
-*/
-opj_tcd_t* tcd_create(bool p_is_decoder);
-
-/**
-Destroy a previously created TCD handle
- at param tcd TCD handle to destroy
-*/
-void tcd_destroy(opj_tcd_t *tcd);
-
-
-
-
-/**
- * Initialize the tile coder and may reuse some meory.
- * @param  p_tcd    TCD handle.
- * @param  p_image    raw image.
- * @param  p_cp    coding parameters.
- * @param  p_tile_no  current tile index to encode.
- *
- * @return true if the encoding values could be set (false otherwise).
-*/
-bool tcd_init(
-            opj_tcd_t *p_tcd,
-            struct opj_image * p_image,
-            struct opj_cp * p_cp
-          );
-
-
-/**
- * Allocates memory for decoding a specific tile.
- *
- * @param  p_tcd    the tile decoder.
- * @param  p_image    the image to decode.
- * @param  p_cp    the decoding parameters.
- * @param  p_tile_no  the index of the tile received in sequence. This not necesseraly lead to the
- * tile at index p_tile_no.
- * @param  p_cstr_info  codestream info (if any).
- *
- * @return  true if the remaining data is sufficient.s
- */
-bool tcd_init_decode_tile(
-              opj_tcd_t *p_tcd,
-              OPJ_UINT32 p_tile_no
-              );
-/**
- * Initialize the tile coder and may reuse some meory.
- * @param  p_tcd    TCD handle.
- * @param  p_image    raw image.
- * @param  p_cp    coding parameters.
- * @param  p_tile_no  current tile index to encode.
- *
- * @return true if the encoding values could be set (false otherwise).
-*/
-bool tcd_init_encode_tile
-              (
-              opj_tcd_t *p_tcd,
-              OPJ_UINT32 p_tile_no
-              );
-
-void tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final);
-void tcd_rateallocate_fixed(opj_tcd_t *tcd);
-void tcd_makelayer(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_FLOAT64 thresh, OPJ_UINT32 final);
-bool tcd_rateallocate(opj_tcd_t *tcd, OPJ_BYTE *dest, OPJ_UINT32 * p_data_written, OPJ_UINT32 len, struct opj_codestream_info *cstr_info);
-/**
- * Encodes a tile from the raw image into the given buffer.
- * @param  p_tcd      Tile Coder handle
- * @param  p_tile_no    Index of the tile to encode.
- * @param  p_dest      Destination buffer
- * @param  p_data_written  pointer to an int that is incremented by the number of bytes really written on p_dest
- * @param  p_len      Maximum length of the destination buffer
- * @param  p_cstr_info    Codestream information structure
- * @return  true if the coding is successfull.
-*/
-bool tcd_encode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, OPJ_BYTE *p_dest, OPJ_UINT32 * p_data_written, OPJ_UINT32 p_len, struct opj_codestream_info *p_cstr_info);
-
-/**
-Decode a tile from a buffer into a raw image
- at param tcd TCD handle
- at param src Source buffer
- at param len Length of source buffer
- at param tileno Number that identifies one of the tiles to be decoded
-*/
-bool tcd_decode_tile(opj_tcd_t *tcd, OPJ_BYTE *src, OPJ_UINT32 len, OPJ_UINT32 tileno, struct opj_codestream_info *cstr_info);
-
-/**
- * Copies tile data from the given memory block onto the system.
- */
-bool tcd_copy_tile_data (
-             opj_tcd_t *p_tcd,
-             OPJ_BYTE * p_src,
-             OPJ_UINT32 p_src_length
-             );
-/**
- * Copies tile data from the system onto the given memory block.
- */
-bool tcd_update_tile_data (
-             opj_tcd_t *p_tcd,
-             OPJ_BYTE * p_dest,
-             OPJ_UINT32 p_dest_length
-             );
-/**
- * Gets the maximum tile size that will be taken by the tile once decoded.
- */
-OPJ_UINT32 tcd_get_decoded_tile_size (
-             opj_tcd_t *p_tcd
-             );
-
-OPJ_UINT32 tcd_get_encoded_tile_size (
-             opj_tcd_t *p_tcd
-             );
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __TCD_H */
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tgt.c b/Utilities/gdcmopenjpeg-v2/libopenjpeg/tgt.c
deleted file mode 100644
index 120d5ae..0000000
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tgt.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
- * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "tgt.h"
-#include "bio.h"
-#include "opj_malloc.h"
-
-/*
-==========================================================
-   Tag-tree coder interface
-==========================================================
-*/
-
-opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
-  OPJ_INT32 nplh[32];
-  OPJ_INT32 nplv[32];
-  opj_tgt_node_t *node = 00;
-  opj_tgt_node_t *l_parent_node = 00;
-  opj_tgt_node_t *l_parent_node0 = 00;
-  opj_tgt_tree_t *tree = 00;
-  OPJ_UINT32 i;
-  OPJ_INT32  j,k;
-  OPJ_UINT32 numlvls;
-  OPJ_UINT32 n;
-
-  tree = (opj_tgt_tree_t *) opj_malloc(sizeof(opj_tgt_tree_t));
-  if(!tree) return 00;
-  memset(tree,0,sizeof(opj_tgt_tree_t));
-
-  tree->numleafsh = numleafsh;
-  tree->numleafsv = numleafsv;
-
-  numlvls = 0;
-  nplh[0] = numleafsh;
-  nplv[0] = numleafsv;
-  tree->numnodes = 0;
-  do {
-    n = nplh[numlvls] * nplv[numlvls];
-    nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
-    nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
-    tree->numnodes += n;
-    ++numlvls;
-  } while (n > 1);
-
-  /* ADD */
-  if (tree->numnodes == 0) {
-    opj_free(tree);
-    return 00;
-  }
-
-  tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes, sizeof(opj_tgt_node_t));
-  if(!tree->nodes) {
-    opj_free(tree);
-    return 00;
-  }
-  memset(tree->nodes,0,tree->numnodes * sizeof(opj_tgt_node_t));
-  tree->nodes_size = tree->numnodes * sizeof(opj_tgt_node_t);
-
-  node = tree->nodes;
-  l_parent_node = &tree->nodes[tree->numleafsh * tree->numleafsv];
-  l_parent_node0 = l_parent_node;
-
-  for (i = 0; i < numlvls - 1; ++i) {
-    for (j = 0; j < nplv[i]; ++j) {
-      k = nplh[i];
-      while (--k >= 0) {
-        node->parent = l_parent_node;
-        ++node;
-        if (--k >= 0) {
-          node->parent = l_parent_node;
-          ++node;
-        }
-        ++l_parent_node;
-      }
-      if ((j & 1) || j == nplv[i] - 1) {
-        l_parent_node0 = l_parent_node;
-      } else {
-        l_parent_node = l_parent_node0;
-        l_parent_node0 += nplh[i];
-      }
-    }
-  }
-  node->parent = 0;
-  tgt_reset(tree);
-  return tree;
-}
-/**
- * Reinitialises a tag-tree from an exixting one.
- *
- * @param  p_tree        the tree to reinitialize.
- * @param  p_num_leafs_h    the width of the array of leafs of the tree
- * @param  p_num_leafs_v    the height of the array of leafs of the tree
- * @return  a new tag-tree if successful, NULL otherwise
-*/
-opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_UINT32 p_num_leafs_v)
-{
-  OPJ_INT32 l_nplh[32];
-  OPJ_INT32 l_nplv[32];
-  opj_tgt_node_t *l_node = 00;
-  opj_tgt_node_t *l_parent_node = 00;
-  opj_tgt_node_t *l_parent_node0 = 00;
-  OPJ_UINT32 i;
-  OPJ_INT32 j,k;
-  OPJ_UINT32 l_num_levels;
-  OPJ_UINT32 n;
-  OPJ_UINT32 l_node_size;
-
-  if
-    (! p_tree)
-  {
-    return 00;
-  }
-  if
-    ((p_tree->numleafsh != p_num_leafs_h) || (p_tree->numleafsv != p_num_leafs_v))
-  {
-    p_tree->numleafsh = p_num_leafs_h;
-    p_tree->numleafsv = p_num_leafs_v;
-
-    l_num_levels = 0;
-    l_nplh[0] = p_num_leafs_h;
-    l_nplv[0] = p_num_leafs_v;
-    p_tree->numnodes = 0;
-    do
-    {
-      n = l_nplh[l_num_levels] * l_nplv[l_num_levels];
-      l_nplh[l_num_levels + 1] = (l_nplh[l_num_levels] + 1) / 2;
-      l_nplv[l_num_levels + 1] = (l_nplv[l_num_levels] + 1) / 2;
-      p_tree->numnodes += n;
-      ++l_num_levels;
-    }
-    while (n > 1);
-
-    /* ADD */
-    if
-      (p_tree->numnodes == 0)
-    {
-      tgt_destroy(p_tree);
-            return 00;
-    }
-    l_node_size = p_tree->numnodes * sizeof(opj_tgt_node_t);
-    if
-      (l_node_size > p_tree->nodes_size)
-    {
-      p_tree->nodes = (opj_tgt_node_t*) opj_realloc(p_tree->nodes, l_node_size);
-      if
-        (! p_tree->nodes)
-      {
-        tgt_destroy(p_tree);
-        return 00;
-      }
-      memset(((char *) p_tree->nodes) + p_tree->nodes_size, 0 , l_node_size - p_tree->nodes_size);
-      p_tree->nodes_size = l_node_size;
-    }
-    l_node = p_tree->nodes;
-    l_parent_node = &p_tree->nodes[p_tree->numleafsh * p_tree->numleafsv];
-    l_parent_node0 = l_parent_node;
-
-    for
-      (i = 0; i < l_num_levels - 1; ++i)
-    {
-      for
-        (j = 0; j < l_nplv[i]; ++j)
-      {
-        k = l_nplh[i];
-        while
-          (--k >= 0)
-        {
-          l_node->parent = l_parent_node;
-          ++l_node;
-          if (--k >= 0)
-          {
-            l_node->parent = l_parent_node;
-            ++l_node;
-          }
-          ++l_parent_node;
-        }
-        if ((j & 1) || j == l_nplv[i] - 1)
-        {
-          l_parent_node0 = l_parent_node;
-        }
-        else
-        {
-          l_parent_node = l_parent_node0;
-          l_parent_node0 += l_nplh[i];
-        }
-      }
-    }
-    l_node->parent = 0;
-  }
-  tgt_reset(p_tree);
-
-  return p_tree;
-}
-
-void tgt_destroy(opj_tgt_tree_t *p_tree)
-{
-  if
-    (! p_tree)
-  {
-    return;
-  }
-  if
-    (p_tree->nodes)
-  {
-    opj_free(p_tree->nodes);
-    p_tree->nodes = 00;
-  }
-  opj_free(p_tree);
-}
-
-void tgt_reset(opj_tgt_tree_t *p_tree) {
-  OPJ_UINT32 i;
-  opj_tgt_node_t * l_current_node = 00;;
-
-  if
-    (! p_tree)
-  {
-    return;
-  }
-  l_current_node = p_tree->nodes;
-  for
-    (i = 0; i < p_tree->numnodes; ++i)
-  {
-    l_current_node->value = 999;
-    l_current_node->low = 0;
-    l_current_node->known = 0;
-    ++l_current_node;
-  }
-}
-
-void tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32  leafno, OPJ_INT32 value) {
-  opj_tgt_node_t *node;
-  node = &tree->nodes[leafno];
-  while (node && node->value > value) {
-    node->value = value;
-    node = node->parent;
-  }
-}
-
-void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32  threshold) {
-  opj_tgt_node_t *stk[31];
-  opj_tgt_node_t **stkptr;
-  opj_tgt_node_t *node;
-  OPJ_INT32  low;
-
-  stkptr = stk;
-  node = &tree->nodes[leafno];
-  while (node->parent) {
-    *stkptr++ = node;
-    node = node->parent;
-  }
-
-  low = 0;
-  for (;;) {
-    if (low > node->low) {
-      node->low = low;
-    } else {
-      low = node->low;
-    }
-
-    while (low < threshold) {
-      if (low >= node->value) {
-        if (!node->known) {
-          bio_write(bio, 1, 1);
-          node->known = 1;
-        }
-        break;
-      }
-      bio_write(bio, 0, 1);
-      ++low;
-    }
-
-    node->low = low;
-    if (stkptr == stk)
-      break;
-    node = *--stkptr;
-  }
-}
-
-OPJ_UINT32  tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32  leafno, OPJ_INT32  threshold) {
-  opj_tgt_node_t *stk[31];
-  opj_tgt_node_t **stkptr;
-  opj_tgt_node_t *node;
-  OPJ_INT32  low;
-
-  stkptr = stk;
-  node = &tree->nodes[leafno];
-  while (node->parent) {
-    *stkptr++ = node;
-    node = node->parent;
-  }
-
-  low = 0;
-  for (;;) {
-    if (low > node->low) {
-      node->low = low;
-    } else {
-      low = node->low;
-    }
-    while (low < threshold && low < node->value) {
-      if (bio_read(bio, 1)) {
-        node->value = low;
-      } else {
-        ++low;
-      }
-    }
-    node->low = low;
-    if (stkptr == stk) {
-      break;
-    }
-    node = *--stkptr;
-  }
-
-  return (node->value < threshold) ? 1 : 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/mj2/CMakeLists.txt
deleted file mode 100644
index 56a59d5..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Makefile for the MJ2 codecs of the OpenJPEG library: frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2 and wrap_j2k_in_mj2
-
-# Headers file are located here:
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  )
-
-add_executable(frames_to_mj2
-  frames_to_mj2.c
-  compat/getopt.c
-  mj2_convert.c mj2.c )
-target_link_libraries(frames_to_mj2 ${OPJ_PREFIX}openjpeg)
-if(UNIX)
-  target_link_libraries(frames_to_mj2 m)
-endif()
-
-add_executable(mj2_to_frames
-    mj2_to_frames.c
-    compat/getopt.c mj2_convert.c mj2.c )
-target_link_libraries(mj2_to_frames ${OPJ_PREFIX}openjpeg)
-if(UNIX)
-  target_link_libraries(mj2_to_frames m)
-endif()
-
-add_executable(extract_j2k_from_mj2
-    extract_j2k_from_mj2.c
-    mj2.c )
-target_link_libraries(extract_j2k_from_mj2 ${OPJ_PREFIX}openjpeg)
-if(UNIX)
-  target_link_libraries(extract_j2k_from_mj2 m)
-endif()
-
-add_executable(wrap_j2k_in_mj2
-    wrap_j2k_in_mj2.c
-    mj2.c )
-target_link_libraries(wrap_j2k_in_mj2 ${OPJ_PREFIX}openjpeg)
-if(UNIX)
-  target_link_libraries(wrap_j2k_in_mj2 m)
-endif()
-
-install(TARGETS frames_to_mj2 mj2_to_frames extract_j2k_from_mj2 wrap_j2k_in_mj2
-	DESTINATION bin)
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/Makefile b/Utilities/gdcmopenjpeg-v2/mj2/Makefile
deleted file mode 100644
index 18d6030..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Makefile for the MJ2 codecs of the OpenJPEG library: frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2 and wrap_j2k_in_mj2
-
-CFLAGS = -O3 -lstdc++ # -g -p -pg
-
-all: frames_to_mj2 mj2_to_frames extract_j2k_from_mj2 wrap_j2k_in_mj2
-
-frames_to_mj2: frames_to_mj2.c ../libopenjpeg.a
-	gcc $(CFLAGS) compat/getopt.c mj2_convert.c mj2.c frames_to_mj2.c -o frames_to_mj2 -L.. -lopenjpeg -I ../libopenjpeg/ -lm
-
-mj2_to_frames: mj2_to_frames.c ../libopenjpeg.a
-	gcc $(CFLAGS) compat/getopt.c mj2_convert.c mj2.c mj2_to_frames.c -o mj2_to_frames -L.. -lopenjpeg -I ../libopenjpeg/ -lm
-
-extract_j2k_from_mj2: extract_j2k_from_mj2.c ../libopenjpeg.a
-	gcc $(CFLAGS) mj2.c extract_j2k_from_mj2.c -o extract_j2k_from_mj2 -L.. -lopenjpeg -I ../libopenjpeg/ -lm
-
-wrap_j2k_in_mj2: wrap_j2k_in_mj2.c ../libopenjpeg.a
-	gcc $(CFLAGS) mj2.c wrap_j2k_in_mj2.c -o wrap_j2k_in_mj2 -L.. -lopenjpeg -I ../libopenjpeg/ -lm
-
-clean:
-	rm -f frames_to_mj2 mj2_to_frames extract_j2k_from_mj2 wrap_j2k_in_mj2
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/extract_j2k_from_mj2.c b/Utilities/gdcmopenjpeg-v2/mj2/extract_j2k_from_mj2.c
deleted file mode 100644
index 08b5b2e..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/extract_j2k_from_mj2.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "openjpeg.h"
-#include "j2k.h"
-#include "jp2.h"
-#include "mj2.h"
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-int main(int argc, char *argv[]) {
-  opj_dinfo_t* dinfo;
-  opj_event_mgr_t event_mgr;    /* event manager */
-  int tnum;
-  unsigned int snum;
-  opj_mj2_t *movie;
-  mj2_tk_t *track;
-  mj2_sample_t *sample;
-  unsigned char* frame_codestream;
-  FILE *file, *outfile;
-  char outfilename[50];
-  mj2_dparameters_t parameters;
-
-  if (argc != 3) {
-    printf("Bad syntax: Usage: MJ2_extractor mj2filename output_location\n");
-    printf("Example: MJ2_extractor foreman.mj2 output/foreman\n");
-    return 1;
-  }
-
-  file = fopen(argv[1], "rb");
-
-  if (!file) {
-    fprintf(stderr, "failed to open %s for reading\n", argv[1]);
-    return 1;
-  }
-
-  /*
-  configure the event callbacks (not required)
-  setting of each callback is optionnal
-  */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = info_callback;
-
-  /* get a MJ2 decompressor handle */
-  dinfo = mj2_create_decompress();
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-  /* setup the decoder decoding parameters using user parameters */
-  movie = (opj_mj2_t*) dinfo->mj2_handle;
-  mj2_setup_decoder(dinfo->mj2_handle, &parameters);
-
-  if (mj2_read_struct(file, movie)) // Creating the movie structure
-    return 1;
-
-  // Decode first video track
-  tnum = 0;
-  while (movie->tk[tnum].track_type != 0)
-    tnum ++;
-
-  track = &movie->tk[tnum];
-
-  fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
-
-  for (snum=0; snum < track->num_samples; snum++)
-  {
-    sample = &track->sample[snum];
-    frame_codestream = (unsigned char*) malloc (sample->sample_size-8); // Skipping JP2C marker
-    fseek(file,sample->offset+8,SEEK_SET);
-    fread(frame_codestream,sample->sample_size-8,1, file);  // Assuming that jp and ftyp markers size do
-
-    sprintf(outfilename,"%s_%05d.j2k",argv[2],snum);
-    outfile = fopen(outfilename, "wb");
-    if (!outfile) {
-      fprintf(stderr, "failed to open %s for writing\n",outfilename);
-      return 1;
-    }
-    fwrite(frame_codestream,sample->sample_size-8,1,outfile);
-    fclose(outfile);
-    free(frame_codestream);
-    }
-  fclose(file);
-  fprintf(stdout, "%d frames correctly extracted\n", snum);
-
-  /* free remaining structures */
-  if(dinfo) {
-    mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
-  }
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/frames_to_mj2.c b/Utilities/gdcmopenjpeg-v2/mj2/frames_to_mj2.c
deleted file mode 100644
index 676c5e3..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/frames_to_mj2.c
+++ /dev/null
@@ -1,806 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2002-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "openjpeg.h"
-#include "j2k_lib.h"
-#include "j2k.h"
-#include "jp2.h"
-#include "cio.h"
-#include "mj2.h"
-#include "mj2_convert.h"
-#include "compat/getopt.h"
-
-/**
-Size of memory first allocated for MOOV box
-*/
-#define TEMP_BUF 10000
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-void help_display()
-{
-  fprintf(stdout,"HELP\n----\n\n");
-  fprintf(stdout,"- the -h option displays this help information on screen\n\n");
-
-
-  fprintf(stdout,"List of parameters for the MJ2 encoder:\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"REMARKS:\n");
-  fprintf(stdout,"---------\n");
-  fprintf(stdout,"\n");
-  fprintf
-    (stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
-  fprintf
-    (stdout,"COD and QCD never appear in the tile_header.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"By default:\n");
-  fprintf(stdout,"------------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout," * Lossless\n");
-  fprintf(stdout," * 1 tile\n");
-  fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
-  fprintf(stdout," * Size of code-block : 64 x 64\n");
-  fprintf(stdout," * Number of resolutions: 6\n");
-  fprintf(stdout," * No SOP marker in the codestream\n");
-  fprintf(stdout," * No EPH marker in the codestream\n");
-  fprintf(stdout," * No sub-sampling in x or y direction\n");
-  fprintf(stdout," * No mode switch activated\n");
-  fprintf(stdout," * Progression order: LRCP\n");
-  fprintf(stdout," * No index file\n");
-  fprintf(stdout," * No ROI upshifted\n");
-  fprintf(stdout," * No offset of the origin of the image\n");
-  fprintf(stdout," * No offset of the origin of the tiles\n");
-  fprintf(stdout," * Reversible DWT 5-3\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Parameters:\n");
-  fprintf(stdout,"------------\n");
-  fprintf(stdout,"\n");
-  fprintf
-    (stdout,"Required Parameters (except with -h):\n");
-  fprintf
-    (stdout,"-i           : source file  (-i source.yuv) \n");
-  fprintf
-    (stdout,"-o           : destination file (-o dest.mj2) \n");
-  fprintf
-    (stdout,"Optional Parameters:\n");
-  fprintf(stdout,"-h           : display the help information \n");
-  fprintf(stdout,"-r           : different compression ratios for successive layers (-r 20,10,5)\n ");
-  fprintf(stdout,"           - The rate specified for each quality level is the desired \n");
-  fprintf(stdout,"             compression factor.\n");
-  fprintf(stdout,"       Example: -r 20,10,1 means quality 1: compress 20x, \n");
-  fprintf(stdout,"         quality 2: compress 10x and quality 3: compress lossless\n");
-  fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-
-  fprintf(stdout,"-q           : different psnr for successive layers (-q 30,40,50) \n ");
-
-  fprintf(stdout,"               (options -r and -q cannot be used together)\n ");
-
-  fprintf(stdout,"-n           : number of resolutions (-n 3) \n");
-  fprintf(stdout,"-b           : size of code block (-b 32,32) \n");
-  fprintf(stdout,"-c           : size of precinct (-c 128,128) \n");
-  fprintf(stdout,"-t           : size of tile (-t 512,512) \n");
-  fprintf
-    (stdout,"-p           : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
-  fprintf
-    (stdout,"-s           : subsampling factor (-s 2,2) [-s X,Y] \n");
-  fprintf(stdout,"       Remark: subsampling bigger than 2 can produce error\n");
-  fprintf
-    (stdout,"-SOP         : write SOP marker before each packet \n");
-  fprintf
-    (stdout,"-EPH         : write EPH marker after each header packet \n");
-  fprintf
-    (stdout,"-M           : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
-  fprintf
-    (stdout,"                 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
-  fprintf
-    (stdout,"                 Indicate multiple modes by adding their values. \n");
-  fprintf
-    (stdout,"                 ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
-  fprintf
-    (stdout,"-ROI         : c=%%d,U=%%d : quantization indices upshifted \n");
-  fprintf
-    (stdout,"               for component c=%%d [%%d = 0,1,2]\n");
-  fprintf
-    (stdout,"               with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
-  fprintf
-    (stdout,"-d           : offset of the origin of the image (-d 150,300) \n");
-  fprintf
-    (stdout,"-T           : offset of the origin of the tiles (-T 100,75) \n");
-  fprintf(stdout,"-I           : use the irreversible DWT 9-7 (-I) \n");
-  fprintf(stdout,"-W           : image width, height and the dx and dy subsampling \n");
-  fprintf(stdout,"               of the Cb and Cr components for YUV files \n");
-  fprintf(stdout,"               (default is '352,288,2,2' for CIF format's 352x288 and 4:2:0)\n");
-  fprintf(stdout,"-F           : video frame rate (set to 25 by default)\n");
-
-  fprintf(stdout,"\n");
-  fprintf(stdout,"IMPORTANT:\n");
-  fprintf(stdout,"-----------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The index file has the structure below:\n");
-  fprintf(stdout,"---------------------------------------\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Image_height Image_width\n");
-  fprintf(stdout,"progression order\n");
-  fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
-  fprintf(stdout,"Components_nb\n");
-  fprintf(stdout,"Layers_nb\n");
-  fprintf(stdout,"decomposition_levels\n");
-  fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
-  fprintf(stdout,"   [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
-  fprintf(stdout,"Main_header_end_position\n");
-  fprintf(stdout,"Codestream_size\n");
-  fprintf(stdout,"Tile_0 start_pos end_Theader end_pos TotalDisto NumPix MaxMSE\n");
-  fprintf(stdout,"Tile_1   ''           ''        ''        ''       ''    ''\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"Tile_Nt   ''           ''        ''        ''       ''    ''\n");
-  fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
-  fprintf(stdout,"...\n");
-  fprintf(stdout,"Tpacket_Np ''   ''    ''   ''    ''       ''       ''     ''\n");
-
-  fprintf(stdout,"MaxDisto\n");
-
-  fprintf(stdout,"TotalDisto\n\n");
-}
-
-int give_progression(char progression[4])
-{
-  if (progression[0] == 'L' && progression[1] == 'R'
-    && progression[2] == 'C' && progression[3] == 'P') {
-    return 0;
-  } else {
-    if (progression[0] == 'R' && progression[1] == 'L'
-      && progression[2] == 'C' && progression[3] == 'P') {
-      return 1;
-    } else {
-      if (progression[0] == 'R' && progression[1] == 'P'
-        && progression[2] == 'C' && progression[3] == 'L') {
-        return 2;
-      } else {
-        if (progression[0] == 'P' && progression[1] == 'C'
-          && progression[2] == 'R' && progression[3] == 'L') {
-          return 3;
-        } else {
-          if (progression[0] == 'C' && progression[1] == 'P'
-            && progression[2] == 'R' && progression[3] == 'L') {
-            return 4;
-          } else {
-            return -1;
-          }
-        }
-      }
-    }
-  }
-}
-
-
-
-
-int main(int argc, char **argv)
-{
-  mj2_cparameters_t mj2_parameters;  /* MJ2 compression parameters */
-  opj_cparameters_t *j2k_parameters;  /* J2K compression parameters */
-  opj_event_mgr_t event_mgr;    /* event manager */
-  opj_cio_t *cio;
-  char value;
-  opj_mj2_t *movie;
-  opj_image_t *img;
-  int i, j;
-  char *s, S1, S2, S3;
-  char *buf;
-  int x1, y1,  len;
-  long mdat_initpos, offset;
-  FILE *mj2file;
-  int sampleno;
-  opj_cinfo_t* cinfo;
-  bool bSuccess;
-  int numframes;
-  double total_time = 0;
-
-  /* default value */
-  /* ------------- */
-  mj2_parameters.Dim[0] = 0;
-  mj2_parameters.Dim[1] = 0;
-  mj2_parameters.w = 352;      // CIF default value
-  mj2_parameters.h = 288;      // CIF default value
-  mj2_parameters.CbCr_subsampling_dx = 2;  // CIF default value
-  mj2_parameters.CbCr_subsampling_dy = 2;  // CIF default value
-  mj2_parameters.frame_rate = 25;
-  /*
-  configure the event callbacks (not required)
-  setting of each callback is optionnal
-  */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = NULL;
-
-  /* set J2K encoding parameters to default values */
-  opj_set_default_encoder_parameters(&mj2_parameters.j2k_parameters);
-  j2k_parameters = &mj2_parameters.j2k_parameters;
-
-  /* Create comment for codestream */
-  if(j2k_parameters->cp_comment == NULL) {
-    const char comment[] = "Created by OpenJPEG version ";
-    const size_t clen = strlen(comment);
-    const char *version = opj_version();
-    j2k_parameters->cp_comment = (char*)malloc(clen+strlen(version)+1);
-    sprintf(j2k_parameters->cp_comment,"%s%s", comment, version);
-  }
-
-  mj2_parameters.decod_format = 0;
-  mj2_parameters.cod_format = 0;
-
-  while (1) {
-    int c = getopt(argc, argv,
-      "i:o:r:q:f:t:n:c:b:p:s:d:h P:S:E:M:R:T:C:I:W:F:");
-    if (c == -1)
-      break;
-    switch (c) {
-    case 'i':      /* IN fill */
-      {
-        char *infile = optarg;
-        s = optarg;
-        while (*s) {
-          s++;
-        }
-        s--;
-        S3 = *s;
-        s--;
-        S2 = *s;
-        s--;
-        S1 = *s;
-
-        if ((S1 == 'y' && S2 == 'u' && S3 == 'v')
-          || (S1 == 'Y' && S2 == 'U' && S3 == 'V')) {
-          mj2_parameters.decod_format = YUV_DFMT;
-        }
-        else {
-          fprintf(stderr,
-            "!! Unrecognized format for infile : %c%c%c [accept only *.yuv] !!\n\n",
-            S1, S2, S3);
-          return 1;
-        }
-        strncpy(mj2_parameters.infile, infile, sizeof(mj2_parameters.infile)-1);
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 'o':      /* OUT fill */
-      {
-        char *outfile = optarg;
-        while (*outfile) {
-          outfile++;
-        }
-        outfile--;
-        S3 = *outfile;
-        outfile--;
-        S2 = *outfile;
-        outfile--;
-        S1 = *outfile;
-
-        outfile = optarg;
-
-        if ((S1 == 'm' && S2 == 'j' && S3 == '2')
-          || (S1 == 'M' && S2 == 'J' && S3 == '2'))
-          mj2_parameters.cod_format = MJ2_CFMT;
-        else {
-          fprintf(stderr,
-            "Unknown output format image *.%c%c%c [only *.mj2]!! \n",
-            S1, S2, S3);
-          return 1;
-        }
-        strncpy(mj2_parameters.outfile, outfile, sizeof(mj2_parameters.outfile)-1);
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 'r':      /* rates rates/distorsion */
-      {
-        float rate;
-        s = optarg;
-        while (sscanf(s, "%f", &rate) == 1) {
-          j2k_parameters->tcp_rates[j2k_parameters->tcp_numlayers] = rate * 2;
-          j2k_parameters->tcp_numlayers++;
-          while (*s && *s != ',') {
-            s++;
-          }
-          if (!*s)
-            break;
-          s++;
-        }
-        j2k_parameters->cp_disto_alloc = 1;
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 'q':      /* add fixed_quality */
-      s = optarg;
-      while (sscanf(s, "%f", &j2k_parameters->tcp_distoratio[j2k_parameters->tcp_numlayers]) == 1) {
-        j2k_parameters->tcp_numlayers++;
-        while (*s && *s != ',') {
-          s++;
-        }
-        if (!*s)
-          break;
-        s++;
-      }
-      j2k_parameters->cp_fixed_quality = 1;
-      break;
-      /* dda */
-      /* ----------------------------------------------------- */
-    case 'f':      /* mod fixed_quality (before : -q) */
-      {
-        int *row = NULL, *col = NULL;
-        int numlayers = 0, numresolution = 0, matrix_width = 0;
-
-        s = optarg;
-        sscanf(s, "%d", &numlayers);
-        s++;
-        if (numlayers > 9)
-          s++;
-
-        j2k_parameters->tcp_numlayers = numlayers;
-        numresolution = j2k_parameters->numresolution;
-        matrix_width = numresolution * 3;
-        j2k_parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
-        s = s + 2;
-
-        for (i = 0; i < numlayers; i++) {
-          row = &j2k_parameters->cp_matrice[i * matrix_width];
-          col = row;
-          j2k_parameters->tcp_rates[i] = 1;
-          sscanf(s, "%d,", &col[0]);
-          s += 2;
-          if (col[0] > 9)
-            s++;
-          col[1] = 0;
-          col[2] = 0;
-          for (j = 1; j < numresolution; j++) {
-            col += 3;
-            sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
-            s += 6;
-            if (col[0] > 9)
-              s++;
-            if (col[1] > 9)
-              s++;
-            if (col[2] > 9)
-              s++;
-          }
-          if (i < numlayers - 1)
-            s++;
-        }
-        j2k_parameters->cp_fixed_alloc = 1;
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 't':      /* tiles */
-      sscanf(optarg, "%d,%d", &j2k_parameters->cp_tdx, &j2k_parameters->cp_tdy);
-      j2k_parameters->tile_size_on = true;
-      break;
-      /* ----------------------------------------------------- */
-    case 'n':      /* resolution */
-      sscanf(optarg, "%d", &j2k_parameters->numresolution);
-      break;
-      /* ----------------------------------------------------- */
-    case 'c':      /* precinct dimension */
-      {
-        char sep;
-        int res_spec = 0;
-
-        char *s = optarg;
-        do {
-          sep = 0;
-          sscanf(s, "[%d,%d]%c", &j2k_parameters->prcw_init[res_spec],
-                                 &j2k_parameters->prch_init[res_spec], &sep);
-          j2k_parameters->csty |= 0x01;
-          res_spec++;
-          s = strpbrk(s, "]") + 2;
-        }
-        while (sep == ',');
-        j2k_parameters->res_spec = res_spec;
-      }
-      break;
-
-      /* ----------------------------------------------------- */
-    case 'b':      /* code-block dimension */
-      {
-        int cblockw_init = 0, cblockh_init = 0;
-        sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
-        if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
-          || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
-          fprintf(stderr,
-            "!! Size of code_block error (option -b) !!\n\nRestriction :\n"
-            "    * width*height<=4096\n    * 4<=width,height<= 1024\n\n");
-          return 1;
-        }
-        j2k_parameters->cblockw_init = cblockw_init;
-        j2k_parameters->cblockh_init = cblockh_init;
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 'p':      /* progression order */
-      {
-        char progression[4];
-
-        strncpy(progression, optarg, 4);
-        j2k_parameters->prog_order = give_progression(progression);
-        if (j2k_parameters->prog_order == -1) {
-          fprintf(stderr, "Unrecognized progression order "
-            "[LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
-          return 1;
-        }
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 's':      /* subsampling factor */
-      {
-        if (sscanf(optarg, "%d,%d", &j2k_parameters->subsampling_dx,
-                                    &j2k_parameters->subsampling_dy) != 2) {
-          fprintf(stderr,  "'-s' sub-sampling argument error !  [-s dx,dy]\n");
-          return 1;
-        }
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 'd':      /* coordonnate of the reference grid */
-      {
-        if (sscanf(optarg, "%d,%d", &j2k_parameters->image_offset_x0,
-                                    &j2k_parameters->image_offset_y0) != 2) {
-          fprintf(stderr,  "-d 'coordonnate of the reference grid' argument "
-            "error !! [-d x0,y0]\n");
-          return 1;
-        }
-      }
-      break;
-      /* ----------------------------------------------------- */
-    case 'h':      /* Display an help description */
-      help_display();
-      return 0;
-      break;
-      /* ----------------------------------------------------- */
-    case 'P':      /* POC */
-      {
-        int numpocs = 0;    /* number of progression order change (POC) default 0 */
-        opj_poc_t *POC = NULL;  /* POC : used in case of Progression order change */
-
-        char *s = optarg;
-        POC = j2k_parameters->POC;
-
-        while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
-          &POC[numpocs].resno0, &POC[numpocs].compno0,
-          &POC[numpocs].layno1, &POC[numpocs].resno1,
-          &POC[numpocs].compno1, &POC[numpocs].progorder) == 7) {
-          POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
-          numpocs++;
-          while (*s && *s != '/') {
-            s++;
-          }
-          if (!*s) {
-            break;
-          }
-          s++;
-        }
-        j2k_parameters->numpocs = numpocs;
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'S':      /* SOP marker */
-      j2k_parameters->csty |= 0x02;
-      break;
-      /* ------------------------------------------------------ */
-    case 'E':      /* EPH marker */
-      j2k_parameters->csty |= 0x04;
-      break;
-      /* ------------------------------------------------------ */
-    case 'M':      /* Mode switch pas tous au point !! */
-      if (sscanf(optarg, "%d", &value) == 1) {
-        for (i = 0; i <= 5; i++) {
-          int cache = value & (1 << i);
-          if (cache)
-            j2k_parameters->mode |= (1 << i);
-        }
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'R':      /* ROI */
-      {
-        if (sscanf(optarg, "OI:c=%d,U=%d", &j2k_parameters->roi_compno,
-                                           &j2k_parameters->roi_shift) != 2) {
-          fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
-          return 1;
-        }
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'T':      /* Tile offset */
-      {
-        if (sscanf(optarg, "%d,%d", &j2k_parameters->cp_tx0, &j2k_parameters->cp_ty0) != 2) {
-          fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
-          return 1;
-        }
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'C':      /* Add a comment */
-      {
-        j2k_parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
-        if(j2k_parameters->cp_comment) {
-          strcpy(j2k_parameters->cp_comment, optarg);
-        }
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'I':      /* reversible or not */
-      {
-        j2k_parameters->irreversible = 1;
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'W':      /* Width and Height and Cb and Cr subsampling in case of YUV format files */
-      if (sscanf
-        (optarg, "%d,%d,%d,%d", &mj2_parameters.w, &mj2_parameters.h, &mj2_parameters.CbCr_subsampling_dx,
-        &mj2_parameters.CbCr_subsampling_dy) != 4) {
-        fprintf(stderr, "-W argument error");
-        return 1;
-      }
-      break;
-      /* ------------------------------------------------------ */
-    case 'F':      /* Video frame rate */
-      if (sscanf(optarg, "%d", &mj2_parameters.frame_rate) != 1) {
-        fprintf(stderr, "-F argument error");
-        return 1;
-      }
-      break;
-      /* ------------------------------------------------------ */
-    default:
-      return 1;
-    }
-  }
-
-  /* Error messages */
-  /* -------------- */
-  if (!mj2_parameters.cod_format || !mj2_parameters.decod_format) {
-    fprintf(stderr,
-      "Correct usage: mj2_encoder -i yuv-file -o mj2-file (+ options)\n");
-    return 1;
-  }
-
-  if ((j2k_parameters->cp_disto_alloc || j2k_parameters->cp_fixed_alloc || j2k_parameters->cp_fixed_quality)
-    && (!(j2k_parameters->cp_disto_alloc ^ j2k_parameters->cp_fixed_alloc ^ j2k_parameters->cp_fixed_quality))) {
-    fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
-    return 1;
-  }        /* mod fixed_quality */
-
-  /* if no rate entered, lossless by default */
-  if (j2k_parameters->tcp_numlayers == 0) {
-    j2k_parameters->tcp_rates[0] = 0;  /* MOD antonin : losslessbug */
-    j2k_parameters->tcp_numlayers++;
-    j2k_parameters->cp_disto_alloc = 1;
-  }
-
-  if((j2k_parameters->cp_tx0 > j2k_parameters->image_offset_x0) || (j2k_parameters->cp_ty0 > j2k_parameters->image_offset_y0)) {
-    fprintf(stderr,
-      "Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
-      j2k_parameters->cp_tx0, j2k_parameters->image_offset_x0, j2k_parameters->cp_ty0, j2k_parameters->image_offset_y0);
-    return 1;
-  }
-
-  for (i = 0; i < j2k_parameters->numpocs; i++) {
-    if (j2k_parameters->POC[i].prg == -1) {
-      fprintf(stderr,
-        "Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
-        i + 1);
-    }
-  }
-
-  if (j2k_parameters->cp_tdx > mj2_parameters.Dim[0] || j2k_parameters->cp_tdy > mj2_parameters.Dim[1]) {
-    fprintf(stderr,
-      "Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
-      j2k_parameters->cp_tdx, mj2_parameters.Dim[0], j2k_parameters->cp_tdy, mj2_parameters.Dim[1]);
-    return 1;
-  }
-
-  /* to respect profile - 0 */
-  /* ---------------------- */
-
-  x1 = !mj2_parameters.Dim[0] ? (mj2_parameters.w - 1) * j2k_parameters->subsampling_dx
-    + 1 : mj2_parameters.Dim[0] + (mj2_parameters.w - 1) * j2k_parameters->subsampling_dx + 1;
-  y1 = !mj2_parameters.Dim[1] ? (mj2_parameters.h - 1) * j2k_parameters->subsampling_dy
-    + 1 : mj2_parameters.Dim[1] + (mj2_parameters.h - 1) * j2k_parameters->subsampling_dy + 1;
-  mj2_parameters.numcomps = 3;      /* Because YUV files only have 3 components */
-  mj2_parameters.prec = 8;      /* Because in YUV files, components have 8-bit depth */
-
-  j2k_parameters->tcp_mct = 0;
-
-  mj2file = fopen(mj2_parameters.outfile, "wb");
-
-  if (!mj2file) {
-    fprintf(stderr, "failed to open %s for writing\n", argv[2]);
-    return 1;
-  }
-
-  /* get a MJ2 decompressor handle */
-  cinfo = mj2_create_compress();
-  movie = cinfo->mj2_handle;
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
-
-  /* setup encoder parameters */
-  mj2_setup_encoder(movie, &mj2_parameters);
-
-  movie->tk[0].num_samples = yuv_num_frames(&movie->tk[0],mj2_parameters.infile);
-  if (movie->tk[0].num_samples == -1) {
-    return 1;
-  }
-
-  // One sample per chunk
-  movie->tk[0].chunk = (mj2_chunk_t*) malloc(movie->tk[0].num_samples * sizeof(mj2_chunk_t));
-  movie->tk[0].sample = (mj2_sample_t*) malloc(movie->tk[0].num_samples * sizeof(mj2_sample_t));
-
-  if (mj2_init_stdmovie(movie)) {
-    fprintf(stderr, "Error with movie initialization");
-    return 1;
-  };
-
-  // Writing JP, FTYP and MDAT boxes
-  buf = (char*) malloc (300 * sizeof(char)); // Assuming that the JP and FTYP
-  // boxes won't be longer than 300 bytes
-  cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, 300);
-  mj2_write_jp(cio);
-  mj2_write_ftyp(movie, cio);
-  mdat_initpos = cio_tell(cio);
-  cio_skip(cio, 4);
-  cio_write(cio, MJ2_MDAT, 4);
-  fwrite(buf,cio_tell(cio),1,mj2file);
-  offset = cio_tell(cio);
-  opj_cio_close(cio);
-  free(buf);
-
-  for (i = 0; i < movie->num_stk + movie->num_htk + movie->num_vtk; i++) {
-    if (movie->tk[i].track_type != 0) {
-      fprintf(stderr, "Unable to write sound or hint tracks\n");
-    } else {
-      mj2_tk_t *tk;
-      int buflen = 0;
-
-      tk = &movie->tk[i];
-      tk->num_chunks = tk->num_samples;
-      numframes = tk->num_samples;
-
-      fprintf(stderr, "Video Track number %d\n", i + 1);
-
-      img = mj2_image_create(tk, j2k_parameters);
-      buflen = 2 * (tk->w * tk->h * 8);
-      buf = (char *) malloc(buflen*sizeof(char));
-
-      for (sampleno = 0; sampleno < numframes; sampleno++) {
-        double init_time = opj_clock();
-        double elapsed_time;
-        if (yuvtoimage(tk, img, sampleno, j2k_parameters, mj2_parameters.infile)) {
-          fprintf(stderr, "Error with frame number %d in YUV file\n", sampleno);
-          return 1;
-        }
-
-        /* setup the encoder parameters using the current image and user parameters */
-        opj_setup_encoder(cinfo, j2k_parameters, img);
-
-        cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, buflen);
-
-        cio_skip(cio, 4);
-        cio_write(cio, JP2_JP2C, 4);  // JP2C
-
-        /* encode the image */
-        bSuccess = opj_encode(cinfo, cio, img, NULL);
-        if (!bSuccess) {
-          opj_cio_close(cio);
-          fprintf(stderr, "failed to encode image\n");
-          return 1;
-        }
-
-        len = cio_tell(cio) - 8;
-        cio_seek(cio, 0);
-        cio_write(cio, len+8,4);
-        opj_cio_close(cio);
-        tk->sample[sampleno].sample_size = len+8;
-        tk->sample[sampleno].offset = offset;
-        tk->chunk[sampleno].offset = offset;  // There is one sample per chunk
-        fwrite(buf, 1, len+8, mj2file);
-        offset += len+8;
-        elapsed_time = opj_clock()-init_time;
-        fprintf(stderr, "Frame number %d/%d encoded in %.2f mseconds\n", sampleno + 1, numframes, elapsed_time*1000);
-        total_time += elapsed_time;
-
-      }
-      /* free buffer data */
-      free(buf);
-      /* free image data */
-      opj_image_destroy(img);
-    }
-  }
-
-  fseek(mj2file, mdat_initpos, SEEK_SET);
-
-  buf = (char*) malloc(4*sizeof(char));
-
-  // Init a cio to write box length variable in a little endian way
-  cio = opj_cio_open(NULL, buf, 4);
-  cio_write(cio, offset - mdat_initpos, 4);
-  fwrite(buf, 4, 1, mj2file);
-  fseek(mj2file,0,SEEK_END);
-  free(buf);
-
-  // Writing MOOV box
-  buf = (char*) malloc ((TEMP_BUF+numframes*20) * sizeof(char));
-  cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+numframes*20));
-  mj2_write_moov(movie, cio);
-  fwrite(buf,cio_tell(cio),1,mj2file);
-  free(buf);
-
-  fprintf(stdout,"Total encoding time: %.2f s for %d frames (%.1f fps)\n", total_time, numframes, (float)numframes/total_time);
-
-  // Ending program
-
-  fclose(mj2file);
-  /* free remaining compression structures */
-  mj2_destroy_compress(movie);
-  free(cinfo);
-  /* free user parameters structure */
-  if(j2k_parameters->cp_comment) free(j2k_parameters->cp_comment);
-  if(j2k_parameters->cp_matrice) free(j2k_parameters->cp_matrice);
-  opj_cio_close(cio);
-
-  return 0;
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/meta_out.c b/Utilities/gdcmopenjpeg-v2/mj2/meta_out.c
deleted file mode 100644
index 6d714d4..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/meta_out.c
+++ /dev/null
@@ -1,2181 +0,0 @@
-/* meta_out.c */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Callable from mj2_to_metadata */
-/* Contributed to Open JPEG by Glenn Pearson, contract software developer, U.S. National Library of Medicine.
-
-The base code in this file was developed by the author as part of a video archiving
-project for the U.S. National Library of Medicine, Bethesda, MD.
-It is the policy of NLM (and U.S. government) to not assert copyright.
-
-A non-exclusive copy of this code has been contributed to the Open JPEG project.
-Except for copyright, inclusion of the code within Open JPEG for distribution and use
-can be bound by the Open JPEG open-source license and disclaimer, expressed elsewhere.
-*/
-
-#include <windows.h> /* for time functions */
-
-#include "opj_includes.h"
-#include "mj2.h"
-
-#include <time.h>
-#include "meta_out.h"
-
-static BOOL notes = TRUE;
-static BOOL sampletables = FALSE;
-static BOOL raw = TRUE;
-static BOOL derived = TRUE;
-
-opj_tcp_t *j2k_default_tcp;
-
-/* Forwards */
-int xml_write_overall_header(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr);
-int xml_write_moov(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr);
-
-void uint_to_chars(unsigned int value, char* buf);
-
-void xml_write_trak(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum, unsigned int sampleframe, opj_event_mgr_t *event_mgr);
-void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum);
-
-void UnixTimeToFileTime(time_t t, LPFILETIME pft);
-void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst);
-void xml_time_out(FILE* xmlout, time_t t);
-
-void int16_to_3packedchars(short int value, char* buf);
-
-void xml_write_moov_udta(FILE* xmlout, opj_mj2_t * movie);
-void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie);
-void xml_write_uuid(FILE* xmlout, opj_mj2_t * movie);
-
-int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int snum, opj_event_mgr_t *event_mgr);
-
-void xml_out_frame_siz(FILE* xmlout, opj_image_t *img, opj_cp_t *cp);
-void xml_out_frame_cod(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_coc(FILE* xmlout, opj_tcp_t *tcp, int numcomps); /* opj_image_t *img); */
-BOOL same_component_style(opj_tccp_t *tccp1, opj_tccp_t *tccp2);
-void xml_out_frame_qcd(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_qcc(FILE* xmlout, opj_tcp_t *tcp, int numcomps); /* opj_image_t *img); */
-BOOL same_component_quantization(opj_tccp_t *tccp1, opj_tccp_t *tccp2);
-void xml_out_frame_rgn(FILE* xmlout, opj_tcp_t *tcp, int numcomps);/* opj_image_t *img);*/
-void xml_out_frame_poc(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_ppm(FILE* xmlout, opj_cp_t *cp);
-void xml_out_frame_ppt(FILE* xmlout, opj_tcp_t *tcp);
-void xml_out_frame_tlm(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* NO-OP.  TLM NOT SAVED IN DATA STRUCTURE */
-void xml_out_frame_plm(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE.  opt in main; can be used in conjunction with PLT */
-void xml_out_frame_plt(FILE* xmlout, opj_tcp_t *tcp); /* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE.  opt in main; can be used in conjunction with PLT */
-void xml_out_frame_crg(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* opt in main; */
-void xml_out_frame_com(FILE* xmlout, opj_tcp_t *tcp); /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */ /* opt in main; */
-void xml_out_dump_hex(FILE* xmlout, char *data, int data_len, char* s);
-void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len, char* s);
-void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct);
-#ifdef NOTYET
-/* Shown with cp, extended, as data structure... but it could be a new different one */
-void xml_out_frame_jp2i(FILE* xmlout, opj_cp_t *cp);/* IntellectualProperty 'jp2i' (no restrictions on location) */
-void xml_out_frame_xml(FILE* xmlout, opj_cp_t *cp); /* XML 'xml\040' (0x786d6c20).  Can appear multiply */
-void xml_out_frame_uuid(FILE* xmlout, opj_cp_t *cp); /* UUID 'uuid' (top level only) */
-void xml_out_frame_uinf(FILE* xmlout, opj_cp_t *cp); /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */
-void xml_out_frame_unknown_type(FILE* xmlout, opj_cp_t *cp);
-#endif
-
-
-void xml_write_init(BOOL n, BOOL t, BOOL r, BOOL d)
-{
-  /* Init file globals */
-  notes = n;
-  sampletables = t;
-  raw = r;
-  derived = d;
-}
-
-int xml_write_struct(FILE* file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, char* stringDTD, opj_event_mgr_t *event_mgr) {
-
-  if(stringDTD != NULL)
-  {
-    fprintf(xmlout,"<?xml version=\"1.0\" standalone=\"no\"?>\n");
-  /* stringDTD is known to start with "SYSTEM " or "PUBLIC " */
-  /* typical: SYSTEM mj2_to_metadata.dtd */
-  stringDTD[6] = '\0'; /* Break into two strings at space, so quotes can be inserted. */
-    fprintf(xmlout,"<!DOCTYPE MJ2_File %s \"%s\">\n", stringDTD, stringDTD+7);
-  stringDTD[6] = ' '; /* restore for sake of debugger or memory allocator */
-  } else
-    fprintf(xmlout,"<?xml version=\"1.0\" standalone=\"yes\"?>\n");
-
-  fprintf(xmlout, "<MJ2_File>\n");
-  xml_write_overall_header(file, xmlout, movie, sampleframe, event_mgr);
-  fprintf(xmlout, "</MJ2_File>");
-  return 0;
-}
-
-/* ------------- */
-
-int xml_write_overall_header(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr)
-{
-  int i;
-  char buf[5];
-  buf[4] = '\0';
-
-  fprintf(xmlout,   "  <JP2 BoxType=\"jP[space][space]\" Signature=\"0x0d0a870a\" />\n");
-  // Called after structure initialized by mj2_read_ftyp
-  fprintf(xmlout,   "  <FileType BoxType=\"ftyp\">\n");
-  uint_to_chars(movie->brand, buf);
-  fprintf(xmlout,   "    <Brand>%s</Brand>\n", buf);    /* 4 character; BR              */
-  fprintf(xmlout,   "    <MinorVersion>%u</MinorVersion>\n", movie->minversion);    /* 4 char; MinV            */
-  fprintf(xmlout,   "    <CompatibilityList Count=\"%d\">\n",movie->num_cl);
-  for (i = movie->num_cl - 1; i > -1; i--) /* read routine stored in reverse order, so let's undo damage */
-  {
-    uint_to_chars(movie->cl[i], buf);
-    fprintf(xmlout, "      <CompatibleBrand>%s</CompatibleBrand>\n", buf);    /*4 characters, each CLi */
-  }
-  fprintf(xmlout,   "    </CompatibilityList>\n");
-  fprintf(xmlout,   "  </FileType>\n");
-  xml_write_moov(file, xmlout, movie, sampleframe, event_mgr);
-  // To come?              <mdat>  // This is the container for media data that can also be accessed through track structures,
-                                   // so is redundant, and simply not of interest as metadata
-  //                       <moof>  // Allows incremental build up of movie.  Probably not in Simple Profile
-  xml_write_free_and_skip(xmlout, movie); /* NO OP so far */ /* May be a place where user squirrels metadata */
-  xml_write_uuid(xmlout, movie); /* NO OP so far */ /* May be a place where user squirrels metadata */
-  return 0;
-}
-
-/* ------------- */
-
-int xml_write_moov(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, opj_event_mgr_t *event_mgr)
-{
-  unsigned int tnum;
-  mj2_tk_t *track;
-
-  fprintf(xmlout,   "  <MovieBox BoxType=\"moov\">\n");
-  fprintf(xmlout,   "    <MovieHeader BoxType=\"mvhd\">\n");
-  fprintf(xmlout,   "      <CreationTime>\n");
-  if(raw)
-    fprintf(xmlout, "        <InSeconds>%u</InSeconds>\n", movie->creation_time);
-  if(notes)
-    fprintf(xmlout, "        <!-- Seconds since start of Jan. 1, 1904 UTC (Greenwich) -->\n");
-  /*  2082844800 = seconds between 1/1/04 and 1/1/70 */
-  /* There's still a time zone offset problem not solved... but spec is ambigous as to whether stored time
-     should be local or UTC */
-  if(derived) {
-    fprintf(xmlout, "        <AsLocalTime>");
-                             xml_time_out(xmlout, movie->creation_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,   "      </CreationTime>\n");
-  fprintf(xmlout,   "      <ModificationTime>\n");
-  if(raw)
-    fprintf(xmlout, "        <InSeconds>%u</InSeconds>\n", movie->modification_time);
-  if(derived) {
-    fprintf(xmlout, "        <AsLocalTime>");
-                             xml_time_out(xmlout, movie->modification_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,   "      </ModificationTime>\n");
-  fprintf(xmlout,   "      <Timescale>%d</Timescale>\n", movie->timescale);
-  if(notes)
-    fprintf(xmlout, "      <!-- Timescale defines time units in one second -->\n");
-  fprintf(xmlout,   "      <Rate>\n");        /* Rate to play presentation  (default = 0x00010000)          */
-  if(notes) {
-    fprintf(xmlout, "      <!-- Rate to play presentation is stored as fixed-point binary 16.16 value. Decimal value is approximation. -->\n");
-    fprintf(xmlout, "      <!-- Rate is expressed relative to normal (default) value of 0x00010000 (1.0) -->\n");
-  }
-  if(raw)
-    fprintf(xmlout, "        <AsHex>0x%08x</AsHex>\n", movie->rate);
-  if(derived)
-    fprintf(xmlout, "        <AsDecimal>%12.6f</AsDecimal>\n", (double)movie->rate/(double)0x00010000);
-  fprintf(xmlout,   "      </Rate>\n");
-  fprintf(xmlout,   "      <Duration>\n");
-  if(raw)
-    fprintf(xmlout, "        <InTimeUnits>%u</InTimeUnits>\n", movie->duration);
-  if(derived)
-    fprintf(xmlout, "        <InSeconds>%12.3f</InSeconds>\n", (double)movie->duration/(double)movie->timescale);    // Make this double later to get fractional seconds
-  fprintf(xmlout,   "      </Duration>\n");
-#ifdef CURRENTSTRUCT
-  movie->volume = movie->volume << 8;
-#endif
-  fprintf(xmlout,   "      <Volume>\n");
-  if(notes) {
-    fprintf(xmlout, "      <!-- Audio volume stored as fixed-point binary 8.8 value. Decimal value is approximation. -->\n");
-    fprintf(xmlout, "      <!-- Full, normal (default) value is 0x0100 (1.0) -->\n");
-  }
-  if(raw)
-    fprintf(xmlout, "        <AsHex>0x%04x</AsHex>\n", movie->volume);
-  if(derived)
-    fprintf(xmlout, "        <AsDecimal>%6.3f</AsDecimal>\n", (double)movie->volume/(double)0x0100);
-  fprintf(xmlout,   "      </Volume>\n");
-#ifdef CURRENTSTRUCT
-  if(notes)
-    fprintf(xmlout, "      <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-  movie->volume = movie->volume >> 8;
-#endif
-  /* Transformation matrix for video                            */
-  fprintf(xmlout,   "      <TransformationMatrix>\n");
-  if(notes) {
-    fprintf(xmlout, "      <!-- 3 x 3 Video Transformation Matrix {a,b,u,c,d,v,x,y,w}.  Required: u=0, v=0, w=1 -->\n");
-    fprintf(xmlout, "      <!-- Maps decompressed point (p,q) to rendered point (ap + cq + x, bp + dq + y) -->\n");
-    fprintf(xmlout, "      <!-- Stored as Fixed Point Hex: all are binary 16.16, except u,v,w are 2.30 -->\n");
-    fprintf(xmlout, "      <!-- Unity = 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 -->\n");
-  }
-  fprintf(xmlout,   "        <TMa>0x%08x</TMa>\n", movie->trans_matrix[0]);
-  fprintf(xmlout,   "        <TMb>0x%08x</TMb>\n", movie->trans_matrix[1]);
-  fprintf(xmlout,   "        <TMu>0x%08x</TMu>\n", movie->trans_matrix[2]);
-  fprintf(xmlout,   "        <TMc>0x%08x</TMc>\n", movie->trans_matrix[3]);
-  fprintf(xmlout,   "        <TMd>0x%08x</TMd>\n", movie->trans_matrix[4]);
-  fprintf(xmlout,   "        <TMv>0x%08x</TMv>\n", movie->trans_matrix[5]);
-  fprintf(xmlout,   "        <TMx>0x%08x</TMx>\n", movie->trans_matrix[6]);
-  fprintf(xmlout,   "        <TMy>0x%08x</TMy>\n", movie->trans_matrix[7]);
-  fprintf(xmlout,   "        <TMw>0x%08x</TMw>\n", movie->trans_matrix[8]);
-  fprintf(xmlout,   "      </TransformationMatrix>\n");
-  fprintf(xmlout,   "    </MovieHeader>\n");
-
-  fprintf(xmlout,   "    <Statistics>\n");
-  fprintf(xmlout,   "      <TracksFound>\n");
-  fprintf(xmlout,   "        <Video>%d</Video>\n", movie->num_vtk);
-  fprintf(xmlout,   "        <Audio>%d</Audio>\n", movie->num_stk);
-  fprintf(xmlout,   "        <Hint>%d</Hint>\n", movie->num_htk);
-  if(notes)
-    fprintf(xmlout, "        <!-- Hint tracks for streaming video are not part of MJ2, but are a defined extension. -->\n");
-  /* See Part 3 Amend 2 Section 4.2 for relation of MJ2 to Part 12 Sections 7 and 10 hints */
-  fprintf(xmlout,   "      </TracksFound>\n");
-  fprintf(xmlout,   "    </Statistics>\n");
-  /* Idea for the future:  It would be possible to add code to verify that the file values:
-    1) are legal and self-consistent
-  2) comply with particular JP2 and/or MJ2 profiles.
-  This could be reported here as additional XML elements */
-
-  // Find first video track
-  tnum = 0;
-  while (movie->tk[tnum].track_type != 0)
-    tnum ++;
-
-  track = &(movie->tk[tnum]);
-  // For now, output info on first video track
-  xml_write_trak(file, xmlout, track, tnum, sampleframe, event_mgr);
-
-  // to come:                <MovieExtends mvek> // possibly not in Simple Profile
-  xml_write_moov_udta(xmlout, movie); /* NO OP so far */ /* <UserDataBox udta> contains <CopyrightBox cprt> */
-  fprintf(xmlout,   "  </MovieBox>\n");
-  return 0;
-}
-
-/* --------------- */
-
-void uint_to_chars(unsigned int value, char* buf)
-{
-  /* buf is at least char[5] */
-    int i;
-    for (i = 3; i >= 0; i--)
-    {
-        buf[i] = (value & 0x000000ff);
-        value = (value >> 8);
-    }
-  buf[4] = '\0'; /* Precautionary */
-}
-
-/* ------------- */
-
-/* WINDOWS SPECIFIC */
-
-void UnixTimeToFileTime(time_t t, LPFILETIME pft)
-{
-  /* Windows specific.  From MS Q167296 */
-  /* 'time_t' represents seconds since midnight January 1, 1970 UTC (coordinated universal time). */
-  /* 64-bit FILETIME structure represents the number of 100-nanosecond intervals since January 1, 1601 UTC (coordinate universal time). */
-  LONGLONG ll; /* LONGLONG is a 64-bit value. */
-  ll = Int32x32To64(t, 10000000) + 116444736000000000;
-  pft->dwLowDateTime = (DWORD)ll;
-  /* pft->dwLowDateTime = (DWORD)(0x00000000ffffffff & ll); */
-  pft->dwHighDateTime = (DWORD)(ll >> 32);
-}
-// Once the UNIX time is converted to a FILETIME structure,
-// other Win32 time formats can be easily obtained by using Win32 functions such
-// as FileTimeToSystemTime() and FileTimeToDosDateTime().
-
-/* ------------- */
-
-void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
-{
-  /* Windows specific */
-  FILETIME ft;
-  UnixTimeToFileTime(t, &ft);
-  FileTimeToLocalFileTime( &ft, &ft ); /* Adjust from UTC to local time zone */
-  FileTimeToSystemTime(&ft, pst);
-}
-
-/* ------------- */
-
-void xml_time_out(FILE* xmlout, time_t t)
-{
-  /* Windows specific */
-  SYSTEMTIME st;
-  char szLocalDate[255], szLocalTime[255];
-  UnixTimeToSystemTime( t, &st );
-  GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szLocalDate, 255 );
-  GetTimeFormat( LOCALE_USER_DEFAULT, 0, &st, NULL, szLocalTime, 255 );
-  fprintf(xmlout, "%s %s", szLocalDate, szLocalTime );
-}
-
-/* END WINDOWS SPECIFIC */
-
-/* ------------- */
-
-void xml_write_moov_udta(FILE* xmlout, opj_mj2_t * movie) {
-  /* Compare with xml_write_udta */
-#ifdef NOTYET
-  /* NO-OP so far.  Optional UserData 'udta' (zero or one in moov or each trak)
-     can contain multiple Copyright 'cprt' with different language codes */
-  /* There may be nested non-standard boxes within udta */
-  IMAGINE movie->udta, movie->copyright_count, movie->copyright_language[i] (array of 16bit ints), movie->copyright_notice[i] (array of buffers)
-  PROBABLY ALSO NEED movie->udta_len or special handler for non-standard boxes
-  char buf[5];
-  int i;
-
-  if(movie->udta != 1)
-    return; /* Not present */
-
-  fprintf(xmlout,    "    <UserData BoxType=\"udta\">\n");
-  for(i = 0; i < movie->copyright_count; i++) {
-    fprintf(xmlout,  "      <Copyright BoxType=\"cprt\"> Instance=\"%d\">\n", i+1);
-    int16_to_3packedchars((short int)movie->copyright_languages[i], buf);
-    fprintf(xmlout,  "        <Language>%s</Language>\n", buf);    /* 3 chars */
-    fprintf(xmlout,  "        <Notice>%s</Notice>\n",movie->copyright_notices[i]);
-    fprintf(xmlout,  "      </Copyright>\n", i+1);
-  }
-  /* TO DO: Non-standard boxes */
-  fprintf(xmlout,    "    </UserData>\n");
-#endif
-}
-
-void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie) {
-#ifdef NOTYET
-  /* NO-OP so far.  There can be zero or more instances of free and/or skip
-     at the top level of the file.  This may be a place where the user squirrel's metadata.
-   Let's assume unstructured, and do a dump */
-  IMAGINE movie->free_and_skip, movie->free_and_skip_count, movie->free_and_skip_content[i] (array of buffers),
-    movie->free_and_skip_len[i] (array of ints), movie->is_skip[i] (array of BOOL)
-  int i;
-
-  if(movie->free_and_skip != 1)
-    return; /* Not present */
-
-  for(i = 0; i < movie->free_and_skip_count; i++) {
-    if(movie->is_skip[i])
-      fprintf(xmlout,    "  <Skip BoxType=\"skip\">\n");
-  else
-      fprintf(xmlout,    "  <Free BoxType=\"free\">\n");
-
-    xml_out_dump_hex_and_ascii(xmlout, movie->free_and_skip_contents[i], movie->free_and_skip_len[i]);
-
-    if(movie->is_skip[i])
-      fprintf(xmlout,    "  </Skip>\n");
-  else
-      fprintf(xmlout,    "  </Free>\n");
-  }
-#endif
-}
-
-void xml_write_uuid(FILE* xmlout, opj_mj2_t * movie) {
-/* Univeral Unique IDs of 16 bytes.  */
-#ifdef NOTYET
-  /* NO-OP so far.  There can be zero or more instances of private uuid boxes in a file.
-     This function supports the top level of the file, but uuid may be elsewhere [not yet supported].
-   This may be a place where the user squirrel's metadata.  Let's assume unstructured, and do a dump */
-  IMAGINE movie->uuid, movie->uuid_count, movie->uuid_content[i] (array of buffers),
-    movie->uuid_len[i] (array of ints), movie->uuid_type[i] (array of 17-byte (16+null termination) buffers)
-  int i;
-
-  if(movie->uuid != 1)
-    return; /* Not present */
-
-  for(i = 0; i < movie->uuid_count; i++) {
-    fprintf(xmlout,    "  <PrivateExtension BoxType=\"uuid\" UUID=\"%s\">\n", movie->uuid_type[i]);
-  // See Part III section 5.2.1, 6.1, 6.2
-    xml_out_dump_hex_and_ascii(xmlout, movie->uuid_contents[i], movie->uuid_len[i]);
-    fprintf(xmlout,    "  </PrivateExtension>\n");
-  }
-#endif
-}
-
-/* ------------- */
-
-void xml_write_trak(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum, unsigned int sampleframe, opj_event_mgr_t *event_mgr)
-{
-  fprintf(xmlout,    "    <Track BoxType=\"trak\" Instance=\"%d\">\n", tnum);
-  xml_write_tkhd(file, xmlout, track, tnum);
-  // TO DO: TrackReferenceContainer 'tref'  just used in hint track
-  // TO DO: EditListContainer 'edts', contains EditList 'elst' with media-time, segment-duration, media-rate
-  xml_write_mdia(file, xmlout, track, tnum);
-  xml_write_udta(file, xmlout, track, tnum); // NO-OP so far.  Optional UserData 'udta', can contain multiple Copyright 'cprt'
-
-  if(track->track_type==0) { /* Only do for visual track */
-  /* sampleframe is from user option -f.  1 = first frame */
-    /* sampleframe of 0 is a user requests: no jp2 header */
-  /* Treat out-of-bounds values in the same way */
-  if(sampleframe > 0 && sampleframe <= track->num_samples)
-    {
-      mj2_sample_t *sample;
-      unsigned int snum;
-
-      snum = sampleframe-1;
-      // Someday maybe do a smart range scan... for (snum=0; snum < track->num_samples; snum++){
-      //  fprintf(stdout,"Frame %d: ",snum+1);
-      sample = &track->sample[snum];
-    if(xml_out_frame(file, xmlout, sample, snum, event_mgr))
-      return; /* Not great error handling here */
-    }
-  }
-  fprintf(xmlout,    "    </Track>\n");
-}
-
-/* ------------- */
-
-void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum)
-{
-  fprintf(xmlout,    "      <TrackHeader BoxType=\"tkhd\">\n");
-  if(notes) {
-    fprintf(xmlout,  "      <!-- Not shown here: CreationTime, ModificationTime, Duration. -->\n");
-    fprintf(xmlout,  "      <!-- These 3 fields are reported under MediaHeader below.   When reading these 3, -->\n");
-    fprintf(xmlout,  "      <!-- m2j_to_metadata currently doesn't distinguish between TrackHeader and MediaHeader source. -->\n");
-    fprintf(xmlout,  "      <!-- If both found, value read from MediaHeader is used. -->\n");
-  }
-  fprintf(xmlout,    "        <TrackID>%u</TrackID>\n", track->track_ID);
-  if(track->track_type==0) /* For visual track */
-  {
-    fprintf(xmlout,  "        <TrackLayer>%d</TrackLayer>\n", track->layer);
-    if(notes)
-      fprintf(xmlout,"        <!-- front-to-back ordering of video tracks. 0 = normal, -1 is closer, etc. -->\n");
-  }
-  if(track->track_type!=0) /* volume irrelevant for visual track */
-  {
-#ifdef CURRENTSTRUCT
-    track->volume = track->volume << 8;
-#endif
-    fprintf(xmlout,  "        <Volume>\n");
-  if(notes) {
-      fprintf(xmlout,"          <!-- Track audio volume stored as fixed-point binary 8.8 value. Decimal value is approximation. -->\n");
-      fprintf(xmlout,"          <!-- Full, normal (default) value is 0x0100 (1.0) -->\n");
-  }
-  if(raw)
-      fprintf(xmlout,"          <AsHex>0x%04x</AsHex>\n", track->volume);
-  if(derived)
-      fprintf(xmlout,"          <AsDecimal>%6.3f</AsDecimal>\n", (double)track->volume/(double)0x0100);
-    fprintf(xmlout,  "        </Volume>\n");
-#ifdef CURRENTSTRUCT
-  if(notes)
-    fprintf(xmlout,  "        <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-  track->volume = track->volume >> 8;
-#endif
-  }
-  if(track->track_type==0)
-  {
-    /* Transformation matrix for video                            */
-    fprintf(xmlout,  "        <TransformationMatrix>\n");
-  if(notes) {
-      fprintf(xmlout,"          <!-- Comments about matrix in MovieHeader apply here as well. -->\n");
-      fprintf(xmlout,"          <!-- This matrix is applied before MovieHeader one. -->\n");
-  }
-    fprintf(xmlout,  "          <TMa>0x%08x</TMa>\n", track->trans_matrix[0]);
-    fprintf(xmlout,  "          <TMb>0x%08x</TMb>\n", track->trans_matrix[1]);
-    fprintf(xmlout,  "          <TMu>0x%08x</TMu>\n", track->trans_matrix[2]);
-    fprintf(xmlout,  "          <TMc>0x%08x</TMc>\n", track->trans_matrix[3]);
-    fprintf(xmlout,  "          <TMd>0x%08x</TMd>\n", track->trans_matrix[4]);
-    fprintf(xmlout,  "          <TMv>0x%08x</TMv>\n", track->trans_matrix[5]);
-    fprintf(xmlout,  "          <TMx>0x%08x</TMx>\n", track->trans_matrix[6]);
-    fprintf(xmlout,  "          <TMy>0x%08x</TMy>\n", track->trans_matrix[7]);
-    fprintf(xmlout,  "          <TMw>0x%08x</TMw>\n", track->trans_matrix[8]);
-    fprintf(xmlout,  "        </TransformationMatrix>\n");
-  }
-#ifdef CURRENTSTRUCT
-  track->w = track->w << 16;
-  track->h = track->h << 16;
-#endif
-  if(notes) {
-    fprintf(xmlout,  "        <!-- Width and Height in pixels are for the presentation; frames will be scaled to this. -->\n");
-    fprintf(xmlout,  "        <!-- Both stored as fixed-point binary 16.16 values. Decimal values are approximations. -->\n");
-  }
-  fprintf(xmlout,    "        <Width>\n");
-  if(raw)
-    fprintf(xmlout,  "          <AsHex>0x%08x</AsHex>\n", track->w);
-  if(derived)
-    fprintf(xmlout,  "          <AsDecimal>%12.6f</AsDecimal>\n", (double)track->w/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-  fprintf(xmlout,    "        </Width>\n");
-  fprintf(xmlout,    "        <Height>\n");
-  if(raw)
-    fprintf(xmlout,  "          <AsHex>0x%08x</AsHex>\n", track->h);
-  if(derived)
-    fprintf(xmlout,  "          <AsDecimal>%12.6f</AsDecimal>\n", (double)track->h/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-  fprintf(xmlout,    "        </Height>\n");
-#ifdef CURRENTSTRUCT
-  if(notes) {
-    fprintf(xmlout,  "        <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-    fprintf(xmlout,  "        <!-- Also, width and height values shown here will actually be those read from track's <VisualSampleEntry> if given. -->\n");
-  }
-  track->w = track->w >> 16;
-  track->h = track->h >> 16;
-#endif
-  fprintf(xmlout,    "      </TrackHeader>\n");
-}
-
-/* ------------- */
-
-void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum) {
-  /* NO-OP so far.  Optional UserData 'udta' (zero or one in moov or each trak)
-     can contain multiple Copyright 'cprt' with different language codes */
-  /* There may be nested non-standard boxes within udta */
-#ifdef NOTYET
-  IMAGINE track->udta, track->copyright_count, track->copyright_language[i] (array of 16bit ints), track->copyright_notice[i] (array of buffers)
-  PROBABLY ALSO NEED track->udta_len or special handler for non-standard boxes
-  char buf[5];
-  int i;
-
-  if(track->udta != 1)
-    return; /* Not present */
-
-  fprintf(xmlout,    "      <UserData BoxType=\"udta\">\n");
-  for(i = 0; i < track->copyright_count; i++) {
-    fprintf(xmlout,  "        <Copyright BoxType=\"cprt\"> Instance=\"%d\">\n", i+1);
-    int16_to_3packedchars((short int)track->copyright_languages[i], buf);
-    fprintf(xmlout,  "          <Language>%s</Language>\n", buf);    /* 3 chars */
-    fprintf(xmlout,  "          <Notice>%s</Notice>\n",track->copyright_notices[i]);
-    fprintf(xmlout,  "        </Copyright>\n", i+1);
-  }
-  /* TO DO: Non-standard boxes */
-  fprintf(xmlout,    "      </UserData>\n");
-#endif
-}
-
-/* ------------- */
-
-void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum)
-{
-  char buf[5];
-  int i, k;
-  buf[4] = '\0';
-
-  fprintf(xmlout,    "      <Media BoxType=\"mdia\">\n");
-  fprintf(xmlout,    "        <MediaHeader BoxType=\"mdhd\">\n");
-  fprintf(xmlout,    "          <CreationTime>\n");
-  if(raw)
-    fprintf(xmlout,  "            <InSeconds>%u</InSeconds>\n", track->creation_time);
-  if(notes)
-    fprintf(xmlout,  "            <!-- Seconds since start of Jan. 1, 1904 UTC (Greenwich) -->\n");
-  /*  2082844800 = seconds between 1/1/04 and 1/1/70 */
-  /* There's still a time zone offset problem not solved... but spec is ambigous as to whether stored time
-     should be local or UTC */
-  if(derived) {
-    fprintf(xmlout,  "            <AsLocalTime>");
-                                xml_time_out(xmlout, track->creation_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,    "          </CreationTime>\n");
-  fprintf(xmlout,    "          <ModificationTime>\n");
-  if(raw)
-    fprintf(xmlout,  "            <InSeconds>%u</InSeconds>\n", track->modification_time);
-  if(derived) {
-    fprintf(xmlout,  "            <AsLocalTime>");
-                                xml_time_out(xmlout, track->modification_time - 2082844800);
-                                                     fprintf(xmlout,"</AsLocalTime>\n");
-  }
-  fprintf(xmlout,    "          </ModificationTime>\n");
-  fprintf(xmlout,    "          <Timescale>%d</Timescale>\n", track->timescale);
-  if(notes)
-    fprintf(xmlout,  "          <!-- Timescale defines time units in one second -->\n");
-  fprintf(xmlout,    "          <Duration>\n");
-  if(raw)
-    fprintf(xmlout,  "            <InTimeUnits>%u</InTimeUnits>\n", track->duration);
-  if(derived)
-    fprintf(xmlout,  "            <InSeconds>%12.3f</InSeconds>\n", (double)track->duration/(double)track->timescale);    // Make this double later to get fractional seconds
-  fprintf(xmlout,    "          </Duration>\n");
-  int16_to_3packedchars((short int)track->language, buf);
-  fprintf(xmlout,    "          <Language>%s</Language>\n", buf);    /* 3 chars */
-  fprintf(xmlout,    "        </MediaHeader>\n");
-  fprintf(xmlout,    "        <HandlerReference BoxType=\"hdlr\">\n");
-  switch(track->track_type)
-  {
-  case 0:
-    fprintf(xmlout,  "          <HandlerType Code=\"vide\">video media track</HandlerType>\n"); break;
-  case 1:
-    fprintf(xmlout,  "          <HandlerType Code=\"soun\">Sound</HandlerType>\n"); break;
-  case 2:
-    fprintf(xmlout,  "          <HandlerType Code=\"hint\">Hint</HandlerType>\n"); break;
-  }
-  if(notes) {
-    fprintf(xmlout,  "          <!-- String value shown is not actually read from file. -->\n");
-    fprintf(xmlout,  "          <!-- Shown value is one used for our encode. -->\n");
-  }
-  fprintf(xmlout,    "        </HandlerReference>\n");
-  fprintf(xmlout,    "        <MediaInfoContainer BoxType=\"minf\">\n");
-  switch(track->track_type)
-  {
-  case 0:
-    fprintf(xmlout,  "          <VideoMediaHeader BoxType=\"vmhd\">\n");
-    fprintf(xmlout,  "            <GraphicsMode>0x%02x</GraphicsMode>\n", track->graphicsmode);
-  if(notes) {
-      fprintf(xmlout,"            <!-- Enumerated values of graphics mode: -->\n");
-      fprintf(xmlout,"            <!--  0x00 = copy (over existing image); -->\n");
-      fprintf(xmlout,"            <!--  0x24 = transparent; 'blue-screen' this image using opcolor; -->\n");
-      fprintf(xmlout,"            <!--  0x100 = alpha; alpha-blend this image -->\n");
-/*    fprintf(xmlout,"            <!--  0x101 = whitealpha; alpha-blend this image, which has been blended with white; -->\n"); This was evidently dropped upon amendment */
-      fprintf(xmlout,"            <!--  0x102 = pre-multiplied black alpha; image has been already been alpha-blended with black. -->\n");
-      fprintf(xmlout,"            <!--  0x110 = component alpha; blend alpha channel(s) and color channels individually. -->\n");
-  }
-    fprintf(xmlout,  "            <Opcolor>\n");
-    fprintf(xmlout,  "              <Red>0x%02x</Red>\n", track->opcolor[0]);
-    fprintf(xmlout,  "              <Green>0x%02x</Green>\n",track->opcolor[1]);
-    fprintf(xmlout,  "              <Blue>0x%02x</Blue>\n",track->opcolor[2]);
-    fprintf(xmlout,  "            </Opcolor>\n");
-    fprintf(xmlout,  "          </VideoMediaHeader>\n");
-    break;
-  case 1:
-    fprintf(xmlout,  "          <SoundMediaHeader BoxType=\"smhd\">\n");
-#ifdef CURRENTSTRUCT
-  track->balance = track->balance << 8;
-#endif
-    fprintf(xmlout,  "            <Balance>\n");
-  if(notes) {
-      fprintf(xmlout,"              <!-- Track audio balance fixes mono track in stereo space. -->\n");
-      fprintf(xmlout,"              <!-- Stored as fixed-point binary 8.8 value. Decimal value is approximation. -->\n");
-      fprintf(xmlout,"              <!-- 0.0 = center, -1.0 = full left, 1.0 = full right -->\n");
-  }
-  if(raw)
-      fprintf(xmlout,"              <AsHex>0x%04x</AsHex>\n", track->balance);
-    if(derived)
-    fprintf(xmlout,"              <AsDecimal>%6.3f</AsDecimal>\n", (double)track->balance/(double)0x0100);
-    fprintf(xmlout,  "            </Balance>\n");
-#ifdef CURRENTSTRUCT
-    if(notes)
-    fprintf(xmlout,"            <!-- Current m2j_to_metadata implementation always shows bits to right of decimal as zeroed. -->\n");
-  track->balance = track->balance >> 8;
-#endif
-    fprintf(xmlout,  "          </SoundMediaHeader>\n");
-    break;
-  case 2:
-    fprintf(xmlout,  "          <HintMediaHeader BoxType=\"hmhd\">\n");
-    fprintf(xmlout,  "            <MaxPDU_Size>%d</MaxPDU_Size>\n", track->maxPDUsize);
-    if(notes)
-      fprintf(xmlout,"            <!-- Size in bytes of largest PDU in this hint stream. -->\n");
-    fprintf(xmlout,  "            <AvgPDU_Size>%d</AvgPDU_Size>\n", track->avgPDUsize);
-    if(notes)
-      fprintf(xmlout,"            <!-- Average size in bytes of a PDU over the entire presentation. -->\n");
-    fprintf(xmlout,  "            <MaxBitRate>%d</MaxBitRate>\n", track->maxbitrate);
-    if(notes)
-      fprintf(xmlout,"            <!-- Maximum rate in bits per second over any window of 1 second. -->\n");
-    fprintf(xmlout,  "            <AvgBitRate>%d</AvgBitRate>\n", track->avgbitrate);
-    if(notes)
-      fprintf(xmlout,"            <!-- Averate rate in bits per second over the entire presentation. -->\n");
-    fprintf(xmlout,  "            <SlidingAvgBit>%d</SlidingAvgBitRate>\n", track->slidingavgbitrate);
-    if(notes)
-      fprintf(xmlout,"            <!-- Maximum rate in bits per second over any window of one minute. -->\n");
-    fprintf(xmlout,  "          </HintMediaHeader>\n");
-    break;
-  }
-  fprintf(xmlout,    "          <DataInfo BoxType=\"dinf\">\n");
-  fprintf(xmlout,    "            <DataReference BoxType=\"dref\"  URL_Count=\"%d\" URN_Count=\"%d\">\n", track->num_url, track->num_urn); // table w. flags, URLs, URNs
-  // Data structure does not distinguish between single URL, single URN, or DREF table or URLs & URNs.
-  // We could infer those, but for now just present everything as a DREF table.
-  if(notes)
-    fprintf(xmlout,  "              <!-- No entries here mean that file is self-contained, as required by Simple Profile. -->\n");
-  for(k = 0; k < track->num_url; k++) {
-    fprintf(xmlout,  "            <DataEntryUrlBox BoxType=\"url[space]\">\n"); // table w. flags, URLs, URNs
-    if(notes)
-      fprintf(xmlout,"              <!-- Only the first 16 bytes of URL location are recorded in mj2_to_metadata data structure. -->\n");
-    for(i = 0; i < 4; i++) {
-      uint_to_chars(track->url[track->num_url].location[i], buf);
-    fprintf(xmlout,  "              <Location>%s</Location>\n");
-    }
-    fprintf(xmlout,  "            </DataEntryUrlBox>\n"); // table w. flags, URLs, URNs
-  }
-  for(k = 0; k < track->num_urn; k++) {
-    fprintf(xmlout,"            <DataEntryUrnBox BoxType=\"urn[space]\">\n"); // table w. flags, URLs, URNs
-    // Only the first 16 bytes are recorded in the data structure currently.
-    if(notes)
-      fprintf(xmlout,"              <!-- Only the first 16 bytes each of URN name and optional location are recorded in mj2_to_metadata data structure. -->\n");
-    fprintf(xmlout,  "              <Name>");
-    for(i = 0; i < 4; i++) {
-      uint_to_chars(track->urn[track->num_urn].name[i], buf);
-      fprintf(xmlout,"%s", buf);
-    }
-    fprintf(xmlout,  "</Name>\n");
-    fprintf(xmlout,  "              <Location>");
-    for(i = 0; i < 4; i++) {
-      uint_to_chars(track->urn[track->num_urn].location[i], buf);
-      fprintf(xmlout,"%s");
-    }
-    fprintf(xmlout,  "</Location>\n");
-    fprintf(xmlout,  "            </DataEntryUrnBox>\n");
-  }
-  fprintf(xmlout,    "            </DataReference>\n");
-  fprintf(xmlout,    "          </DataInfo>\n");
-
-  xml_write_stbl(file, xmlout, track, tnum); /* SampleTable */
-
-  fprintf(xmlout,    "        </MediaInfoContainer>\n");
-  fprintf(xmlout,    "      </Media>\n");
-}
-
-/* ------------- */
-
-void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum)
-{
-  char buf[5], buf33[33];
-  int i, len;
-  buf[4] = '\0';
-
-  fprintf(xmlout,      "          <SampleTable BoxType=\"stbl\">\n");
-  if(notes)
-    fprintf(xmlout,    "            <!-- What follows are specific instances of generic SampleDescription BoxType=\"stsd\" -->\n");
-  switch(track->track_type)
-  {
-  case 0:
-    // There could be multiple instances of this, but "entry_count" is just a local at read-time.
-    // And it's used wrong, too, as count of just visual type, when it's really all 3 types.
-    // This is referred to as "smj2" within mj2.c
-    fprintf(xmlout,    "            <VisualSampleEntry BoxType=\"mjp2\">\n");
-  if(notes) {
-      fprintf(xmlout,  "            <!-- If multiple instances of this box, only first is shown here. -->\n");
-    fprintf(xmlout,  "            <!-- Width and Height are in pixels.  Unlike the Track Header, there is no fractional part. -->\n");
-    fprintf(xmlout,  "            <!-- In mj2_to_metadata implementation, the values are not represented separately from Track Header's values. -->\n");
-  }
-  /* No shifting required.  If CURRENTSTRUCT gets changed, then may need to revisit treatment of these */
-    fprintf(xmlout,    "              <WidthAsInteger>%d</WidthAsInteger>\n", track->w);
-    fprintf(xmlout,    "              <HeightAsInteger>%d</HeightAsInteger>\n", track->h);
-// Horizresolution and vertresolution don't require shifting, already stored right in CURRENTSTRUCT
-    if(notes) {
-      fprintf(xmlout,  "              <!-- Resolutions are in pixels per inch, for the highest-resolution component (typically luminance). -->\n");
-      fprintf(xmlout,  "              <!-- Both stored as fixed-point binary 16.16 values. Decimal values are approximations. -->\n");
-      fprintf(xmlout,  "              <!-- Typical value for both resolutions is 0x00480000  (72.0) -->\n");
-  }
-    fprintf(xmlout,    "              <HorizontalRes>\n");
-  if(raw)
-      fprintf(xmlout,  "                <AsHex>0x%08x</AsHex>\n", track->horizresolution);
-  if(derived)
-      fprintf(xmlout,  "                <AsDecimal>%12.6f</AsDecimal>\n", (double)track->horizresolution/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-    fprintf(xmlout,    "              </HorizontalRes>\n");
-    fprintf(xmlout,    "              <VerticalRes>\n");
-  if(raw)
-      fprintf(xmlout,  "                <AsHex>0x%08x</AsHex>\n", track->vertresolution);
-  if(derived)
-      fprintf(xmlout,  "                <AsDecimal>%12.6f</AsDecimal>\n", (double)track->vertresolution/(double)0x00010000);        /* Rate to play presentation  (default = 0x00010000)          */
-    fprintf(xmlout,    "              </VerticalRes>\n");
-
-    buf33[0] = '\0';
-    for(i = 0; i < 8; i++) {
-      uint_to_chars((unsigned int)track->compressorname[i], buf);
-      strcat(buf33, buf); /* This loads up (4 * 8) + 1 chars, but trailing ones are usually junk */
-    }
-    len = (int)buf33[0]; /* First byte has string length in bytes.  There may be garbage beyond it. */
-    buf33[len+1] = '\0'; /* Suppress it */
-    fprintf(xmlout,    "              <CompressorName>%s</CompressorName>\n", buf33+1); /* Start beyond first byte */
-  if(notes) {
-      fprintf(xmlout,  "              <!-- Compressor name for debugging.  Standard restricts max length to 31 bytes. -->\n");
-      fprintf(xmlout,  "              <!-- Usually blank or \"Motion JPEG2000\" -->\n");
-  }
-    fprintf(xmlout,    "              <Depth>0x%02x</Depth>\n",track->depth);
-  if(notes) {
-      fprintf(xmlout,  "              <!-- Depth is: -->\n");
-      fprintf(xmlout,  "              <!--   0x20: alpha channels present (color or grayscale) -->\n");
-      fprintf(xmlout,  "              <!--   0x28: grayscale without alpha -->\n");
-      fprintf(xmlout,  "              <!--   0x18: color without alpha -->\n");
-  }
-
-    xml_out_frame_jp2h(xmlout, &(track->jp2_struct));  /* JP2 Header */
-
-  /* Following subboxes are optional */
-    fprintf(xmlout,    "              <FieldCoding BoxType=\"fiel\">\n");
-    fprintf(xmlout,    "                <FieldCount>%d</FieldCount>\n", (unsigned int)track->fieldcount); /* uchar as 1 byte uint */
-    if(notes)
-      fprintf(xmlout,  "                <!-- Must be either 1 or 2 -->\n");
-    fprintf(xmlout,    "                <FieldOrder>%d</FieldOrder>\n", (unsigned int)track->fieldorder); /* uchar as 1 byte uint */
-  if(notes) {
-      fprintf(xmlout,  "                <!-- When FieldCount=2, FieldOrder means: -->\n");
-      fprintf(xmlout,  "                <!--   0: Field coding unknown -->\n");
-      fprintf(xmlout,  "                <!--   1: Field with topmost line is stored first in sample; fields are in temporal order -->\n");
-      fprintf(xmlout,  "                <!--   6: Field with topmost line is stored second in sample; fields are in temporal order -->\n");
-      fprintf(xmlout,  "                <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->\n");
-      fprintf(xmlout,  "                <!-- Current implementation doesn't retain whether box was actually present. -->\n");
-  }
-    fprintf(xmlout,    "              </FieldCoding>\n");
-
-    fprintf(xmlout,    "              <MJP2_Profile BoxType=\"jp2p\" Count=\"%d\">\n",track->num_br);
-    for (i = 0; i < track->num_br; i++) /* read routine stored in reverse order, so let's undo damage */
-    {
-      uint_to_chars(track->br[i], buf);
-      fprintf(xmlout,  "                <CompatibleBrand>%s</CompatibleBrand>\n", buf);    /*4 characters, each CLi */
-    }
-    fprintf(xmlout,    "              </MJP2_Profile>\n");
-
-    fprintf(xmlout,    "              <MJP2_Prefix BoxType=\"jp2x\" Count=\"%d\">\n",track->num_jp2x);
-    for (i = 0; i < track->num_jp2x; i++)
-    { // We'll probably need better formatting than this
-      fprintf(xmlout,  "                <Data>0x%02x</Data>\n", track->jp2xdata[i]);    /* Each entry is single byte */
-    }
-    fprintf(xmlout,    "              </MJP2_Prefix>\n");
-
-    fprintf(xmlout,    "              <MJP2_SubSampling BoxType=\"jsub\">\n"); /* These values are all 1 byte */
-    if(notes)
-    fprintf(xmlout,  "              <!-- Typical subsample value is 2 for 4:2:0 -->\n");
-    fprintf(xmlout,    "                <HorizontalSub>%d</HorizontalSub>\n", track->hsub);
-    fprintf(xmlout,    "                <VerticalSub>%d</VerticalSub>\n", track->vsub);
-    fprintf(xmlout,    "                <HorizontalOffset>%d</HorizontalOffset>\n", track->hoff);
-    fprintf(xmlout,    "                <VerticalOffset>%d</VerticalOffset>\n", track->voff);
-  if(notes) {
-    fprintf(xmlout,  "                <!-- Typical {horizontal, vertical} chroma offset values: -->\n");
-    fprintf(xmlout,  "                <!-- 4:2:2 format (CCIR601, H.262, MPEG2, MPEG4, recom. Exif): {0, 0} -->\n");
-    fprintf(xmlout,  "                <!-- 4:2:2 format (JFIF):                                      {1, 0} -->\n");
-    fprintf(xmlout,  "                <!-- 4:2:0 format (H.262, MPEG2, MPEG4):                       {0, 1} -->\n");
-    fprintf(xmlout,  "                <!-- 4:2:0 format (MPEG1, H.261, JFIF, recom. Exif):           {1, 1} -->\n");
-  }
-    fprintf(xmlout,    "              </MJP2_SubSampling>\n"); /* These values are all 1 byte */
-
-    fprintf(xmlout,    "              <MJP2_OriginalFormat BoxType=\"orfo\">\n"); /* Part III Appx. 2 */
-    fprintf(xmlout,    "                <OriginalFieldCount>%u</OriginalFieldCount>\n", (unsigned int)track->or_fieldcount); /* uchar as 1-byte uint */
-    if(notes)
-      fprintf(xmlout,  "                <!-- In original material before encoding.  Must be either 1 or 2 -->\n");
-    fprintf(xmlout,    "                <OriginalFieldOrder>%u</OriginalFieldOrder>\n", (unsigned int)track->or_fieldorder); /* uchar as 1-byte uint */
-  if(notes) {
-      fprintf(xmlout,  "                <!-- When FieldCount=2, FieldOrder means: -->\n");
-      fprintf(xmlout,  "                <!--   0: Field coding unknown -->\n");
-      fprintf(xmlout,  "                <!--   11: Topmost line came from the earlier field; -->\n");
-      fprintf(xmlout,  "                <!--   16:  Topmost line came form the later field. -->\n");
-      fprintf(xmlout,  "                <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->\n");
-      fprintf(xmlout,  "                <!-- Current implementation doesn't retain whether box was actually present. -->\n");
-  }
-    fprintf(xmlout,    "              </MJP2_OriginalFormat>\n");
-    fprintf(xmlout,    "            </VisualSampleEntry>\n");
-    break;
-  case 1: case 2:
-    if(notes)
-      fprintf(xmlout,  "            <!-- mj2_to_metadata's data structure doesn't record this currently. -->\n"); break;
-  }
-  fprintf(xmlout,      "            <TimeToSample BoxType=\"stts\">\n");
-  fprintf(xmlout,      "              <SampleStatistics>\n");
-  fprintf(xmlout,      "                <TotalSamples>%d</TotalSamples>\n", track->num_samples);
-  if(notes)
-    fprintf(xmlout,    "                <!-- For video, gives the total frames in the track, by summing all entries in the Sample Table -->\n");
-  fprintf(xmlout,      "              </SampleStatistics>\n");
-  fprintf(xmlout,      "              <SampleEntries EntryCount=\"%d\">\n", track->num_tts);
-  for (i = 0; i < track->num_tts; i++) {
-    fprintf(xmlout,    "                <Table Entry=\"%u\" SampleCount=\"%d\" SampleDelta=\"%u\" />\n",
-                                      i+1, track->tts[i].sample_count, track->tts[i].sample_delta);
-  }
-  fprintf(xmlout,      "              </SampleEntries>\n");
-  fprintf(xmlout,      "            </TimeToSample>\n");
-
-  fprintf(xmlout,      "            <SampleToChunk BoxType=\"stsc\" Count=\"%d\">\n", track->num_samplestochunk);
-  for (i = 0; i < track->num_samplestochunk; i++) {
-    fprintf(xmlout,    "              <FirstChunk>%u</FirstChunk>\n",track->sampletochunk[i].first_chunk); /* 4 bytes */
-    fprintf(xmlout,    "              <SamplesPerChunk>%u</SamplesPerChunk>\n",track->sampletochunk[i].samples_per_chunk); /* 4 bytes */
-    fprintf(xmlout,    "              <SampleDescrIndex>%u</SampleDescrIndex>\n",track->sampletochunk[i].sample_descr_idx); /* 4 bytes */
-  }
-  fprintf(xmlout,      "            </SampleToChunk>\n");
-  // After reading this info in, track->num_chunks is calculated and a decompressed table established internally.
-
-  fprintf(xmlout,      "            <SampleSize BoxType=\"stsz\">\n");
-  if(track->same_sample_size) {
-    // all values in track->sample[i].sample_size are equal.  Grab the first one.
-    fprintf(xmlout,    "              <Sample_Size>%u</Sample_Size>\n", track->sample[0].sample_size);
-  if(notes) {
-      fprintf(xmlout,  "              <!-- Non-zero value means all samples have that size. -->\n");
-    fprintf(xmlout,  "              <!-- So <Sample_Count> (aka Entry_Count in std.) has no meaning, is suppressed from this output, and no table follows. -->\n");
-  }
-  } else {
-    fprintf(xmlout,    "              <Sample_Size>0</Sample_Size>\n");
-    if(notes)
-    if(sampletables)
-        fprintf(xmlout,"              <!-- Zero value means samples have different sizes, given in table next of length Sample_Count (aka Entry_Count in std). -->\n");
-    else
-        fprintf(xmlout,"              <!-- Zero value means samples have different sizes, given in table (not shown) of length Sample_Count (aka Entry_Count in std). -->\n");
-  fprintf(xmlout,    "              <Sample_Count>%u</Sample_Count>\n", track->num_samples);
-  if(sampletables)
-     for (i = 0; i < (int)track->num_samples; i++) {
-      fprintf(xmlout,  "              <EntrySize Num=\"%u\">%u</EntrySize>\n", i+1, track->sample[i].sample_size);
-     }
-  }
-  fprintf(xmlout,      "            </SampleSize>\n");
-
-  fprintf(xmlout,      "            <ChunkOffset BoxType=\"stco\">\n");
-  // Structure not yet - Variant ChunkLargeOffset 'co64'
-  fprintf(xmlout,      "              <EntryCount>%u</EntryCount>\n", track->num_chunks);
-  if(notes) {
-    fprintf(xmlout,    "              <!-- For this implementation, EntryCount shown is one calculated during file read of <SampleToChunk> data. -->\n");
-    fprintf(xmlout,    "              <!-- Implementation will report failure during file read of <ChunkOffset> data if read entry-count disagrees. -->\n");
-  }
-  if(sampletables)
-    for (i = 0; i < (int)track->num_chunks; i++)
-      fprintf(xmlout,  "              <Chunk_Offset Num=\"%d\">%u</Chunk_Offset>\n", i+1, track->chunk[i].offset);
-  fprintf(xmlout,      "            </ChunkOffset>\n");
-
-  fprintf(xmlout,      "          </SampleTable>\n");
-}
-
-/* ------------- */
-
-int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int snum, opj_event_mgr_t *event_mgr)
-{
-  opj_dparameters_t parameters;  /* decompression parameters */
-  opj_image_t *img;
-  opj_cp_t *cp;
-  int i;
-  int numcomps;
-  unsigned char* frame_codestream;
-  opj_dinfo_t* dinfo = NULL;  /* handle to a decompressor */
-  opj_cio_t *cio = NULL;
-  opj_j2k_t *j2k;
-
-  /* JPEG 2000 compressed image data */
-
-  /* get a decoder handle */
-  dinfo = opj_create_decompress(CODEC_J2K);
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)dinfo, event_mgr, stderr);
-
-  /* setup the decoder decoding parameters using the current image and user parameters */
-  parameters.cp_limit_decoding = DECODE_ALL_BUT_PACKETS;
-  opj_setup_decoder(dinfo, &parameters);
-
-  frame_codestream = (unsigned char*) malloc (sample->sample_size-8); /* Skipping JP2C marker */
-  if(frame_codestream == NULL)
-    return 1;
-
-  fseek(file,sample->offset+8,SEEK_SET);
-  fread(frame_codestream,sample->sample_size-8,1, file);  /* Assuming that jp and ftyp markers size do */
-
-  /* open a byte stream */
-  cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
-
-  /* Decode J2K to image: */
-  img = opj_decode(dinfo, cio);
-  if (!img) {
-    fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
-    opj_destroy_decompress(dinfo);
-    opj_cio_close(cio);
-    return 1;
-  }
-
-  j2k = (opj_j2k_t*)dinfo->j2k_handle;
-  j2k_default_tcp = j2k->default_tcp;
-  cp = j2k->cp;
-
-  numcomps = img->numcomps;
-  /*  Alignments:        "      <       To help maintain xml pretty-printing */
-  fprintf(xmlout,      "      <JP2_Frame Num=\"%d\">\n", snum+1);
-  fprintf(xmlout,      "        <MainHeader>\n");
-  /* There can be multiple codestreams; a particular image is entirely within a single codestream */
-  /* TO DO:  A frame can be represented by two I-guess-contigious codestreams if its interleaved. */
-  fprintf(xmlout,      "          <StartOfCodestream Marker=\"SOC\" />\n");
-  /* "cp" stands for "coding parameter"; "tcp" is tile coding parameters, "tccp" is tile-component coding parameters */
-  xml_out_frame_siz(xmlout, img, cp); /* reqd in main */
-  xml_out_frame_cod(xmlout, j2k_default_tcp); /* reqd in main */
-  xml_out_frame_coc(xmlout, j2k_default_tcp, numcomps); /* opt in main, at most 1 per component */
-  xml_out_frame_qcd(xmlout, j2k_default_tcp); /* reqd in main */
-  xml_out_frame_qcc(xmlout, j2k_default_tcp, numcomps);  /* opt in main, at most 1 per component */
-  xml_out_frame_rgn(xmlout, j2k_default_tcp, numcomps); /* opt, at most 1 per component */
-  xml_out_frame_poc(xmlout, j2k_default_tcp); /*  opt (but reqd in main or tile for any progression order changes) */
-  /* Next four get j2k_default_tcp passed globally: */
-#ifdef SUPPRESS_FOR_NOW
-  xml_out_frame_ppm(xmlout, cp); /* opt (but either PPM or PPT [distributed in tile headers] or codestream packet header reqd) */
-#endif
-  xml_out_frame_tlm(xmlout); /* NO-OP.  TLM NOT SAVED IN DATA STRUCTURE */ /* opt */
-  xml_out_frame_plm(xmlout); /* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE */ /* opt in main; can be used in conjunction with PLT */
-  xml_out_frame_crg(xmlout); /* NO-OP.  CRG NOT SAVED IN DATA STRUCTURE */ /* opt in main; */
-  xml_out_frame_com(xmlout, j2k_default_tcp); /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */ /* opt in main; */
-
-  fprintf(xmlout,      "        </MainHeader>\n");
-
-  /*  TO DO: all the tile headers (sigh)  */
-  fprintf(xmlout,      "        <TilePartHeaders Count=\"%d\">\n", cp->tileno_size);    /* size of the vector tileno */
-  for(i = 0; i < cp->tileno_size; i++) { /* I think cp->tileno_size will be same number as (cp->tw * cp->th) or as global j2k_curtileno */
-    // Standard seems to use zero-based # for tile-part.
-    fprintf(xmlout,    "          <TilePartHeader Num=\"%d\" ID=\"%d\">\n", i, cp->tileno[i]);      /* ID number of the tiles present in the codestream */
-    fprintf(xmlout,    "            <StartOfTilePart Marker=\"SOT\" />\n");
-  /* All markers in tile-part headers (between SOT and SOD) are optional, unless structure requires. */
-    if(i == 0) {
-      xml_out_frame_cod(xmlout, &(cp->tcps[i])); /* No more than 1 per tile */
-      xml_out_frame_coc(xmlout, &(cp->tcps[i]), numcomps); /* No more than 1 per component */
-      xml_out_frame_qcd(xmlout, &(cp->tcps[i])); /* No more than 1 per tile */
-      xml_out_frame_qcc(xmlout, &(cp->tcps[i]), numcomps);  /* No more than 1 per component */
-      xml_out_frame_rgn(xmlout, &(cp->tcps[i]), numcomps); /* No more than 1 per component */
-    }
-    xml_out_frame_poc(xmlout, &(cp->tcps[i])); /* Reqd only if any progression order changes different from main POC */
-#ifdef SUPPRESS_FOR_NOW
-    xml_out_frame_ppt(xmlout, &(cp->tcps[i])); /* Either PPT [distributed in tile headers] or PPM or codestream packet header reqd. */
-#endif
-    xml_out_frame_plt(xmlout, &(cp->tcps[i])); /* NO-OP.  PLT NOT SAVED IN DATA STRUCTURE */ /* Can be used in conjunction with main's PLM */
-    xml_out_frame_com(xmlout, &(cp->tcps[i])); /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */
-    /* opj_tcp_t * cp->tcps; "tile coding parameters" */
-    /* Maybe not: fprintf(xmlout,  "        <>%d</>, cp->matrice[i];      */ /* Fixed layer    */
-    fprintf(xmlout,    "            <StartOfData Marker=\"SOD\" />\n");
-    if(notes)
-      fprintf(xmlout,  "            <!-- Tile-part bitstream, not shown, follows tile-part header and SOD marker. -->\n");
-    fprintf(xmlout,    "          </TilePartHeader>\n");
-  }
-  fprintf(xmlout,      "        </TilePartHeaders>\n");    /* size of the vector tileno */
-
-#ifdef NOTYET
-  IMAGINE the cp object has data to support the following... but we could use an new different data structure instead
-  /* I'm unclear if the span of the original fread(frame_codestream...) included the following items if they're trailing. */
-  /* ALSO TO DO, BUT DATA STRUCTURE DOESN'T HANDLE YET: boxes (anywhere in file except before the Filetype box): */
-  xml_out_frame_jp2i(xmlout, &cp); /* IntellectualProperty 'jp2i' (no restrictions on location) */
-  xml_out_frame_xml(xmlout, &cp); /* XML 'xml\040' (0x786d6c20).  Can appear multiply */
-  xml_out_frame_uuid(xmlout, &cp); /* UUID 'uuid' (top level only) */
-  xml_out_frame_uinf(xmlout, &cp); /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */
-#endif
-
-  fprintf(xmlout,      "      </JP2_Frame>\n");
-
-  /* Extra commentary: */
-  if(notes) {
-    fprintf(xmlout,    "      <!-- Given the number and size of components, mj2_to_frame would try to convert this -->\n");
-    if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2)
-      && (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1))
-      || (img->numcomps == 1)) {
-      fprintf(xmlout,  "      <!-- file to a YUV movie in the normal manner. -->\n");
-    }
-    else if ((img->numcomps == 3) &&
-      (img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
-    (img->comps[2].dx == 1))  {// If YUV 4:4:4 input --> to bmp
-    fprintf(xmlout,  "      <!-- YUV 4:4:4 file to a series of .bmp files. -->\n");
-    }
-    else {
-    fprintf(xmlout,  "      <!-- file whose image component dimension are unknown, to a series of .j2k files. -->\n");
-    }
-  }
-
-  opj_destroy_decompress(dinfo);
-  opj_cio_close(cio);
-  free(frame_codestream);
-
-  return 0;
-}
-
-/* ------------- */
-
-void int16_to_3packedchars(short int value, char* buf)
-{
-    /* This is to retrieve the 3-letter ASCII language code */
-    /* Each char is packed into 5 bits, as difference from 0x60 */
-    int i;
-    for (i = 2; i >= 0; i--)
-    {
-        buf[i] = (value & 0x001f) + 0x60;
-        value = (value >>5);
-    }
-    buf[3] = '\0';
-}
-
-/* ------------- */
-
-void xml_out_frame_siz(FILE* xmlout, opj_image_t *img, opj_cp_t *cp)
-{
-  opj_image_comp_t *comp;
-  int i;
-
-  fprintf(xmlout,    "          <ImageAndFileSize Marker=\"SIZ\">\n");
-  // This is similar to j2k.c's j2k_dump_image.
-  // Not of interest: Lsiz, Rsiz
-  fprintf(xmlout,    "            <Xsiz>%d</Xsiz>\n", img->x1);
-  fprintf(xmlout,    "            <Ysiz>%d</Ysiz>\n", img->y1);
-  if(notes)
-    fprintf(xmlout,  "            <!-- Xsiz, Ysiz is the size of the reference grid. -->\n");
-  fprintf(xmlout,    "            <XOsiz>%d</XOsiz>\n", img->x0);
-  fprintf(xmlout,    "            <YOsiz>%d</YOsiz>\n", img->y0);
-  if(notes)
-    fprintf(xmlout,  "            <!-- XOsiz, YOsiz are offsets from grid origin to image origin. -->\n");
-  fprintf(xmlout,    "            <XTsiz>%d</XTsiz>\n", cp->tdx);
-  fprintf(xmlout,    "            <YTsiz>%d</YTsiz>\n", cp->tdy);
-  if(notes)
-    fprintf(xmlout,  "            <!-- XTsiz, YTsiz is the size of one tile with respect to the grid. -->\n");
-  fprintf(xmlout,    "            <XTOsiz>%d</XTOsiz>\n", cp->tx0);
-  fprintf(xmlout,    "            <YTOsiz>%d</YTOsiz>\n", cp->ty0);
-  if(notes)
-    fprintf(xmlout,  "            <!-- XTOsiz, YTOsiz are offsets from grid origin to first tile origin. -->\n");
-  fprintf(xmlout,    "            <Csiz>%d</Csiz>\n", img->numcomps);
-  if(notes) {
-    fprintf(xmlout,  "            <!-- Csiz is the number of components in the image. -->\n");
-    fprintf(xmlout,  "            <!-- For image components next: -->\n");
-    fprintf(xmlout,  "            <!--   XRsiz, YRsiz denote pixel-sample-spacing on the grid, per Part I Annex B. -->\n");
-    //fprintf(xmlout,"            <!--   XO, YO is offset of the component compared to the whole image. -->\n");
-    fprintf(xmlout,  "            <!--   Bits per pixel (bpp) is the pixel depth. -->\n");
-    fprintf(xmlout,  "            <!--   WidthOfData and HeightOfData are calculated values, e.g.: w = roundup((Xsiz - XOsiz)/ XRsiz) -->\n");
-  }
-
-  for (i = 0; i < img->numcomps; i++) {/* image-components */
-    comp = &(img->comps[i]);
-    fprintf(xmlout,  "            <Component Num=\"%d\">\n", i+1);
-    fprintf(xmlout,  "              <Ssiz>\n");
-  if(raw)
-      fprintf(xmlout,"                <AsHex>0x%02x</AsHex>\n", (comp->sgnd << 7) & (comp->prec - 1));
-  if(derived) {
-      fprintf(xmlout,"                <Signed>%d</Signed>\n", comp->sgnd);
-      fprintf(xmlout,"                <PrecisionInBits>%d</PrecisionInBits>\n", comp->prec);
-  }
-    fprintf(xmlout,  "              </Ssiz>\n");
-    fprintf(xmlout,  "              <XRsiz>%d</XRsiz>\n", comp->dx);
-    fprintf(xmlout,  "              <YRsiz>%d</YRsiz>\n", comp->dy);
-    fprintf(xmlout,  "              <WidthOfData>%d</WidthOfData>\n", comp->w);
-    fprintf(xmlout,  "              <HeightOfData>%d</HeightOfData>\n", comp->h);
-    /* Rest of these aren't calculated when SIZ is read:
-    fprintf(xmlout,  "              <XO>%d</XO>\n", comp->x0);
-    fprintf(xmlout,  "              <YO>%d</YO>\n", comp->y0);
-  if(notes)
-    fprintf(xmlout,"              <!--  XO, YO is offset of the component compared to the whole image. -->\n");
-    fprintf(xmlout,  "              <BitsPerPixel>%d</BitsPerPixel>\n", comp->bpp);
-    fprintf(xmlout,  "              <NumberOfDecodedResolution>%d</NumberOfDecodedResolution>\n", comp->resno_decoded); */
-    // SUPPRESS: n/a to mj2_to_metadata.  fprintf(xmlout,"        <Factor>%d</Factor\n", comp->factor);
-    /* factor = number of division by 2 of the out image  compare to the original size of image */
-    // TO DO comp->data:  int *data;      /* image-component data      */
-
-    fprintf(xmlout,  "            </Component>\n");
-  }
-  fprintf(xmlout,    "          </ImageAndFileSize>\n");
-}
-
-/* ------------- */
-
-void xml_out_frame_cod(FILE* xmlout, opj_tcp_t *tcp)
-{
-/* Could be called with tcp = &j2k_default_tcp;
-/* Or, for tile-part header, with &j2k_cp->tcps[j2k_curtileno]
-/*  Alignment for main:"          < < < <   To help maintain xml pretty-printing */
-/*  Alignment for tile:"            < < <   To help maintain xml pretty-printing */
-  opj_tccp_t *tccp;
-  int i;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-  tccp = &(tcp->tccps[0]);
-
-  fprintf(xmlout,      "%s<CodingStyleDefault Marker=\"COD\">\n",s); /* Required in main header */
-  /* Not retained or of interest: Lcod */
-  fprintf(xmlout,      "%s  <Scod>0x%02x</Scod>\n", s, tcp->csty); /* 1 byte */
-  if(notes) {
-    fprintf(xmlout,    "%s  <!-- For Scod, specific bits mean (where bit 0 is lowest or rightmost): -->\n",s);
-    fprintf(xmlout,    "%s  <!-- bit 0: Defines entropy coder precincts -->\n",s);
-    fprintf(xmlout,    "%s  <!--        0 = (PPx=15, PPy=15); 1 = precincts defined below. -->\n",s);
-    fprintf(xmlout,    "%s  <!-- bit 1: 1 = SOP marker may be used; 0 = not. -->\n",s);
-    fprintf(xmlout,    "%s  <!-- bit 2: 1 = EPH marker may be used; 0 = not. -->\n",s);
-  }
-  fprintf(xmlout,      "%s  <SGcod>\n",s);
-  fprintf(xmlout,      "%s    <ProgressionOrder>%d</ProgressionOrder>\n", s, tcp->prg); /* 1 byte, SGcod (A) */
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- Defined Progression Order Values are: -->\n",s);
-    fprintf(xmlout,    "%s    <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->\n",s);
-    fprintf(xmlout,    "%s    <!-- where L = \"layer\", R = \"resolution level\", C = \"component\", P = \"position\". -->\n",s);
-  }
-  fprintf(xmlout,      "%s    <NumberOfLayers>%d</NumberOfLayers>\n", s, tcp->numlayers); /* 2 bytes, SGcod (B) */
-  fprintf(xmlout,      "%s    <MultipleComponentTransformation>%d</MultipleComponentTransformation>\n", s, tcp->mct); /* 1 byte, SGcod (C).  More or less boolean */
-  if(notes)
-    fprintf(xmlout,    "%s    <!-- For MCT, 0 = none, 1 = transform first 3 components for efficiency, per Part I Annex G -->\n",s);
-  fprintf(xmlout,      "%s  </SGcod>\n",s);
-  /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-  fprintf(xmlout,      "%s  <SPcod>\n",s);
-  /* Internal data structure tccp defines separate defaults for each component, but they all get the same values */
-  /* So we only have to report the first component's values here. */
-  /* Compare j2k_read_cox(...) */
-  fprintf(xmlout,      "%s    <NumberOfDecompositionLevels>%d</NumberOfDecompositionLevels>\n", s, tccp->numresolutions - 1);  /* 1 byte, SPcox (D) */
-  fprintf(xmlout,      "%s    <CodeblockWidth>%d</CodeblockWidth>\n", s, tccp->cblkw - 2);  /* 1 byte, SPcox (E) */
-  fprintf(xmlout,      "%s    <CodeblockHeight>%d</CodeblockHeight>\n", s, tccp->cblkh - 2);  /* 1 byte, SPcox (F) */
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- CBW and CBH are non-negative, and summed cannot exceed 8 -->\n",s);
-    fprintf(xmlout,    "%s    <!-- Codeblock dimension is 2^(value + 2) -->\n", s);
-  }
-  fprintf(xmlout,      "%s    <CodeblockStyle>0x%02x</CodeblockStyle>\n", s, tccp->cblksty);  /* 1 byte, SPcox (G) */
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- For CodeblockStyle, bits mean (with value 1=feature on, 0=off): -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 0: Selective arithmetic coding bypass. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 1: Reset context probabilities on coding pass boundaries. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 2: Termination on each coding pass. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 3: Vertically causal context. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 4: Predictable termination. -->\n",s);
-    fprintf(xmlout,    "%s    <!-- bit 5: Segmentation symbols are used. -->\n",s);
-  }
-  fprintf(xmlout,      "%s    <Transformation>%d</Transformation>\n", s, tccp->qmfbid);  /* 1 byte, SPcox (H) */
-  if(notes)
-    fprintf(xmlout,    "%s    <!-- For Transformation, 0=\"9-7 irreversible filter\", 1=\"5-3 reversible filter\" -->\n",s);
-  if (tccp->csty & J2K_CP_CSTY_PRT) {
-    fprintf(xmlout,    "%s    <PrecinctSize>\n",s); /* 1 byte, SPcox (I_i) */
-    if(notes)
-      fprintf(xmlout,  "%s    <!-- These are size exponents PPx and PPy. May be zero only for first level (aka N(L)LL subband)-->\n",s);
-    for (i = 0; i < tccp->numresolutions; i++) {
-      fprintf(xmlout,  "%s      <PrecinctHeightAndWidth  ResolutionLevel=\"%d\">\n", s, i);
-    if(raw)
-        fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->prch[i] << 4) | tccp->prcw[i]);  /* packed into 1 byte, SPcox (G) */
-    if(derived) {
-        fprintf(xmlout,"%s        <WidthAsDecimal>%d</WidthAsDecimal>\n", s, tccp->prcw[i]);
-        fprintf(xmlout,"%s        <HeightAsDecimal>%d</HeightAsDecimal>\n", s, tccp->prch[i]);
-    }
-      fprintf(xmlout,  "%s      </PrecinctHeightAndWidth>\n", s, i);
-    }
-    fprintf(xmlout,    "%s    </PrecinctSize>\n",s); /* 1 byte, SPcox (I_i) */
-  }
-  fprintf(xmlout,      "%s  </SPcod>\n",s);
-  fprintf(xmlout,      "%s</CodingStyleDefault>\n",s);
-}
-
-/* ------------- */
-
-void xml_out_frame_coc(FILE* xmlout, opj_tcp_t *tcp, int numcomps) /* Optional in main & tile-part headers */
-{
-/* Uses global j2k_default_tcp */
-  opj_tccp_t *tccp, *firstcomp_tccp;
-  int i, compno;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  firstcomp_tccp = &(tcp->tccps[0]);
-    /* Internal data structure tccp defines separate defaults for each component, set from main */
-  /* default, then selectively overwritten. */
-    /* Compare j2k_read_cox(...) */
-  /* We don't really know which was the default, and which were not */
-  /* Let's pretend that [0] is the default and all others are not */
-  if(notes) {
-    fprintf(xmlout,    "%s<!-- mj2_to_metadata implementation always reports component[0] as using default COD, -->\n", s);
-    if(tcp == j2k_default_tcp)
-      fprintf(xmlout,  "%s<!-- and any other component, with main-header style values different from [0], as COC. -->\n", s);
-    else
-      fprintf(xmlout,  "%s<!-- and any other component, with tile-part-header style values different from [0], as COC. -->\n", s);
-  }
-  for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */
-  {
-    tccp = &tcp->tccps[compno];
-    if(same_component_style(firstcomp_tccp, tccp))
-    continue;
-
-/*  Alignments:          "      < < < < <   To help maintain xml pretty-printing */
-    fprintf(xmlout,      "%s<CodingStyleComponent Marker=\"COC\">\n", s); /* Optional in main header, at most 1 per component */
-    if(notes)
-      fprintf(xmlout,    "%s  <!-- See Ccoc below for zero-based component number. -->\n", s);
-    /* Overrides the main COD for the specific component */
-    /* Not retained or of interest: Lcod */
-    fprintf(xmlout,      "%s  <Scoc>0x%02x</Scoc>\n", s, tccp->csty); /* 1 byte */
-  if(notes) {
-    fprintf(xmlout,    "%s  <!-- Scoc defines entropy coder precincts: -->\n", s);
-      fprintf(xmlout,    "%s  <!--   0 = maximum, namely (PPx=15, PPy=15); 1 = precincts defined below. -->\n", s);
-  }
-    fprintf(xmlout,      "%s  <Ccoc>%d</Ccoc>\n", s, compno); /* 1 or 2 bytes */
-    /* Unfortunately compo isn't retained in j2k_read_coc:  compno = cio_read(j2k_img->numcomps <= 256 ? 1 : 2);  /* Ccoc */
-    /*if(j2k_img_numcomps <=256)
-    component is 1 byte
-    else
-      compno is 2 byte */
-
-    /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-    fprintf(xmlout,      "%s  <SPcoc>\n", s);
-    fprintf(xmlout,      "%s    <NumberOfDecompositionLevels>%d</NumberOfDecompositionLevels>\n", s, tccp->numresolutions - 1);  /* 1 byte, SPcox (D) */
-    fprintf(xmlout,      "%s    <CodeblockWidth>%d</CodeblockWidth>\n", s, tccp->cblkw - 2);  /* 1 byte, SPcox (E) */
-    fprintf(xmlout,      "%s    <CodeblockHeight>%d</CodeblockHeight>\n", s, tccp->cblkh - 2);  /* 1 byte, SPcox (F) */
-  if(notes) {
-      fprintf(xmlout,    "%s    <!-- CBW and CBH are non-negative, and summed cannot exceed 8 -->\n", s);
-      fprintf(xmlout,    "%s    <!-- Codeblock dimension is 2^(value + 2) -->\n", s);
-  }
-    fprintf(xmlout,      "%s    <CodeblockStyle>0x%02x</CodeblockStyle>\n", s, tccp->cblksty);  /* 1 byte, SPcox (G) */
-  if(notes) {
-      fprintf(xmlout,    "%s    <!-- For CodeblockStyle, bits mean (with value 1=feature on, 0=off): -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 0: Selective arithmetic coding bypass. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 1: Reset context probabilities on coding pass boundaries. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 2: Termination on each coding pass. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 3: Vertically causal context. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 4: Predictable termination. -->\n", s);
-      fprintf(xmlout,    "%s    <!-- bit 5: Segmentation symbols are used. -->\n", s);
-  }
-    fprintf(xmlout,      "%s    <Transformation>%d</Transformation>\n", s, tccp->qmfbid);  /* 1 byte, SPcox (H) */
-    if(notes)
-      fprintf(xmlout,    "%s    <!-- For Transformation, 0=\"9-7 irreversible filter\", 1=\"5-3 reversible filter\" -->\n", s);
-    if (tccp->csty & J2K_CP_CSTY_PRT) {
-      fprintf(xmlout,    "%s    <PrecinctSize>\n", s); /* 1 byte, SPcox (I_i) */
-      if(notes)
-        fprintf(xmlout,  "%s      <!-- These are size exponents PPx and PPy. May be zero only for first level (aka N(L)LL subband)-->\n", s);
-      for (i = 0; i < tccp->numresolutions-1; i++) { /* subtract 1 to get # of decomposition levels */
-        fprintf(xmlout,  "%s      <PrecinctHeightAndWidth  ResolutionLevel=\"%d\">\n", s, i);
-    if(raw)
-          fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->prch[i] << 4) | tccp->prcw[i]);  /* packed into 1 byte, SPcox (G) */
-    if(derived) {
-          fprintf(xmlout,"%s        <WidthAsDecimal>%d</WidthAsDecimal>\n", s, tccp->prcw[i]);
-          fprintf(xmlout,"%s        <HeightAsDecimal>%d</HeightAsDecimal>\n", s, tccp->prch[i]);
-    }
-        fprintf(xmlout,  "%s      </PrecinctHeightAndWidth>\n", s, i);
-      }
-      fprintf(xmlout,    "%s    </PrecinctSize>\n", s); /* 1 byte, SPcox (I_i) */
-    }
-    fprintf(xmlout,      "%s  </SPcoc>\n", s);
-    fprintf(xmlout,      "%s</CodingStyleComponent>\n", s);
-  }
-}
-
-/* ------------- */
-
-BOOL same_component_style(opj_tccp_t *tccp1, opj_tccp_t *tccp2)
-{
-  int i;
-
-  if(tccp1->numresolutions != tccp2->numresolutions)
-    return FALSE;
-  if(tccp1->cblkw != tccp2->cblkw)
-    return FALSE;
-  if(tccp1->cblkh != tccp2->cblkh)
-    return FALSE;
-  if(tccp1->cblksty != tccp2->cblksty)
-    return FALSE;
-  if(tccp1->csty != tccp2->csty)
-    return FALSE;
-
-  if (tccp1->csty & J2K_CP_CSTY_PRT) {
-      for (i = 0; i < tccp1->numresolutions; i++) {
-         if(tccp1->prcw[i] != tccp2->prcw[i] || tccp1->prch[i] != tccp2->prch[i])
-       return FALSE;
-      }
-  }
-  return TRUE;
-}
-
-/* ------------- */
-
-void xml_out_frame_qcd(FILE* xmlout, opj_tcp_t *tcp)
-{
-  /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-  opj_tccp_t *tccp;
-  int bandno, numbands;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  /* Compare j2k_read_qcx */
-  fprintf(xmlout,      "%s<QuantizationDefault Marker=\"QCD\">\n", s); /* Required in main header, single occurrence */
-  tccp = &(tcp->tccps[0]);
-  /* Not retained or of interest: Lqcd */
-  fprintf(xmlout,      "%s  <Sqcd>\n", s);    /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "%s  <!-- Default quantization style for all components. -->\n", s);
-  if(raw)
-    fprintf(xmlout,    "%s    <AsHex>0x%02x</AsHex>\n", s, (tccp->numgbits) << 5 | tccp->qntsty);
-  if(derived)
-    fprintf(xmlout,    "%s    <QuantizationStyle>%d</QuantizationStyle>\n", s, tccp->qntsty);
-  if(notes) {
-    fprintf(xmlout,    "%s    <!-- Quantization style (in Sqcd's low 5 bits) may be: -->\n", s);
-    fprintf(xmlout,    "%s    <!--   0 = No quantization. SPqcd size = 8 bits-->\n", s);
-    fprintf(xmlout,    "%s    <!--   1 = Scalar derived (values signaled for N(L)LL subband only). Use Eq. E.5. SPqcd size = 16. -->\n", s);
-    fprintf(xmlout,    "%s    <!--   2 = Scalar expounded (values signaled for each subband). SPqcd size = 16. -->\n", s);
-  }
-  if(derived)
-    fprintf(xmlout,    "%s    <NumberOfGuardBits>%d</NumberOfGuardBits>\n", s,  tccp->numgbits);
-  if(notes)
-    fprintf(xmlout,    "%s    <!-- 0-7 guard bits allowed (stored in Sqcd's high 3 bits) -->\n", s);
-  fprintf(xmlout,      "%s  </Sqcd>\n", s);
-
-  /* Problem: numbands in some cases is calculated from len, which is not retained or available here at this time */
-  /* So we'll just dump all internal values */
-  /* We could calculate it, but I'm having trouble believing the length equations in the standard */
-
-  fprintf(xmlout,      "%s  <SPqcd>\n", s);
-  switch(tccp->qntsty) {
-  case J2K_CCP_QNTSTY_NOQNT: /* no quantization */
-    /* This is what standard says, but I don't believe it: len = 4 + (3*decomp); */
-    numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */
-  /* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-    /* Instead look for first zero exponent, quit there.  Adequate? */
-    fprintf(xmlout,    "%s    <ReversibleStepSizeValue>\n", s);
-  if(notes) {
-      fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-    fprintf(xmlout,  "%s    <!-- until an exponent with zero value is reached. -->\n", s);
-    fprintf(xmlout,  "%s    <!-- Exponent epsilon(b) of reversible dynamic range. -->\n", s);
-    fprintf(xmlout,  "%s    <!-- Hex value is as stored, in high-order 5 bits. -->\n", s);
-  }
-    for (bandno = 0; bandno < numbands; bandno++) {
-      if(tccp->stepsizes[bandno].expn == 0)
-        break; /* Remove when we have real numbands */
-      fprintf(xmlout,  "%s      <DynamicRangeExponent Subband=\"%d\">\n", s, bandno);
-    if(raw)
-        fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, tccp->stepsizes[bandno].expn << 3);
-    if(derived)
-        fprintf(xmlout,"%s        <AsDecimal>%d</AsDecimal>\n", s, tccp->stepsizes[bandno].expn);
-      fprintf(xmlout,  "%s      </DynamicRangeExponent>\n", s);
-    }
-    fprintf(xmlout,    "%s    </ReversibleStepSizeValue>\n", s);
-    break;
-  case J2K_CCP_QNTSTY_SIQNT:  /* scalar quantization derived */
-    /* This is what standard says.  Should I believe it:: len = 5;
-    /* numbands = 1; */
-    fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-    if(notes)
-      fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-    fprintf(xmlout,    "%s      <QuantizationValues Subband=\"0\">\n", s);
-    if(notes)
-      fprintf(xmlout,  "%s      <!-- For N(L)LL subband: >\n", s);
-  if(raw)
-      fprintf(xmlout,  "%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[0].expn << 11) | tccp->stepsizes[0].mant);
-  if(derived) {
-      fprintf(xmlout,  "%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[0].expn);
-      fprintf(xmlout,  "%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[0].mant);
-  }
-    fprintf(xmlout,    "%s      </QuantizationValues>\n", s);
-  if(notes) {
-      fprintf(xmlout,  "%s      <!-- Exponents for subbands beyond 0 are not from header, but calculated per Eq. E.5 -->\n", s);
-      fprintf(xmlout,  "%s      <!-- The mantissa for all subbands is the same, given by the value above. -->\n", s);
-      fprintf(xmlout,  "%s      <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-    fprintf(xmlout,  "%s      <!-- until a subband with exponent of zero value is reached. -->\n", s);
-  }
-
-    for (bandno = 1; bandno < J2K_MAXBANDS; bandno++) {
-      if(tccp->stepsizes[bandno].expn == 0)
-        break;
-
-      fprintf(xmlout,  "%s      <CalculatedExponent Subband=\"%d\">%d</CalculatedExponent>\n", s, bandno, tccp->stepsizes[bandno].expn);
-    }
-
-    fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-    break;
-
-  default: /* J2K_CCP_QNTSTY_SEQNT */ /* scalar quantization expounded */
-    /* This is what standard says, but should I believe it: len = 5 + 6*decomp; */
-    numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/
-  /* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-    fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-  if(notes) {
-      fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-      fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-      fprintf(xmlout,  "%s    <!-- until a subband with mantissa and exponent of zero values is reached. -->\n", s);
-    }
-    for (bandno = 0; bandno < numbands; bandno++) {
-      if(tccp->stepsizes[bandno].expn == 0 && tccp->stepsizes[bandno].mant == 0)
-        break; /* Remove when we have real numbands */
-
-      fprintf(xmlout,  "%s      <QuantizationValues Subband=\"%d\">\n", s, bandno);
-    if(raw)
-        fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[bandno].expn << 11) | tccp->stepsizes[bandno].mant);
-    if(derived) {
-        fprintf(xmlout,"%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[bandno].expn);
-        fprintf(xmlout,"%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[bandno].mant);
-    }
-      fprintf(xmlout,  "%s      </QuantizationValues>\n", s);
-    }
-    fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-    break;
-  } /* switch */
-  fprintf(xmlout,      "%s  </SPqcd>\n", s);
-  fprintf(xmlout,      "%s</QuantizationDefault>\n", s);
-
-/*  Alignments:        "    < < < < <   To help maintain xml pretty-printing */
-}
-
-/* ------------- */
-
-void xml_out_frame_qcc(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
-{
-/* Uses global j2k_default_tcp */
-  /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */
-  opj_tccp_t *tccp, *firstcomp_tccp;
-  int bandno, numbands;
-  int compno;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  firstcomp_tccp = &(tcp->tccps[0]);
-    /* Internal data structure tccp defines separate defaults for each component, set from main */
-  /* default, then selectively overwritten. */
-    /* Compare j2k_read_qcx(...) */
-  /* We don't really know which was the default, and which were not */
-  /* Let's pretend that [0] is the default and all others are not */
-  if(notes) {
-    fprintf(xmlout,      "%s<!-- mj2_to_metadata implementation always reports component[0] as using default QCD, -->\n", s);
-    if(tcp == j2k_default_tcp)
-      fprintf(xmlout,    "%s<!-- and any other component, with main-header quantization values different from [0], as QCC. -->\n", s);
-    else
-      fprintf(xmlout,    "%s<!-- and any other component, with tile-part-header quantization values different from [0], as QCC. -->\n", s);
-  }
-  for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */
-  {
-    tccp = &(tcp->tccps[compno]);
-    if(same_component_quantization(firstcomp_tccp, tccp))
-    continue;
-
-    /* Compare j2k_read_qcx */
-    fprintf(xmlout,      "%s<QuantizationComponent Marker=\"QCC\" Component=\"%d\">\n", s, compno); /* Required in main header, single occurrence */
-    tccp = &j2k_default_tcp->tccps[0];
-    /* Not retained or perhaps of interest: Lqcd   It maybe can be calculated.  */
-    fprintf(xmlout,      "%s  <Sqcc>\n", s);    /* 1 byte */
-    if(notes)
-      fprintf(xmlout,    "%s  <!-- Quantization style for this component. -->\n", s);
-  if(raw)
-      fprintf(xmlout,    "%s    <AsHex>0x%02x</AsHex>\n", s, (tccp->numgbits) << 5 | tccp->qntsty);
-  if(derived)
-      fprintf(xmlout,    "%s    <QuantizationStyle>%d</QuantizationStyle>\n", s, tccp->qntsty);
-  if(notes) {
-      fprintf(xmlout,    "%s    <!-- Quantization style (in Sqcc's low 5 bits) may be: -->\n", s);
-      fprintf(xmlout,    "%s    <!--   0 = No quantization. SPqcc size = 8 bits-->\n", s);
-      fprintf(xmlout,    "%s    <!--   1 = Scalar derived (values signaled for N(L)LL subband only). Use Eq. E.5. SPqcc size = 16. -->\n", s);
-      fprintf(xmlout,    "%s    <!--   2 = Scalar expounded (values signaled for each subband). SPqcc size = 16. -->\n", s);
-  }
-  if(derived)
-      fprintf(xmlout,    "%s    <NumberOfGuardBits>%d</NumberOfGuardBits>\n", s,  tccp->numgbits);
-    if(notes)
-      fprintf(xmlout,    "%s    <!-- 0-7 guard bits allowed (stored in Sqcc's high 3 bits) -->\n", s);
-    fprintf(xmlout,      "%s  </Sqcc>\n", s);
-
-    /* Problem: numbands in some cases is calculated from len, which is not retained or available here at this time */
-    /* So we'll just dump all internal values */
-    fprintf(xmlout,      "%s  <SPqcc>\n", s);
-    switch(tccp->qntsty) {
-    case J2K_CCP_QNTSTY_NOQNT:
-      numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */
-    /* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-
-      /* Instead look for first zero exponent, quit there.  Adequate? */
-      fprintf(xmlout,    "%s    <ReversibleStepSizeValue>\n", s);
-    if(notes) {
-        fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-      fprintf(xmlout,  "%s    <!-- until an exponent with zero value is reached. -->\n", s);
-      fprintf(xmlout,  "%s    <!-- Exponent epsilon(b) of reversible dynamic range. -->\n", s);
-      fprintf(xmlout,  "%s    <!-- Hex value is as stored, in high-order 5 bits. -->\n", s);
-    }
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp->stepsizes[bandno].expn == 0)
-          break; /* Remove this once we have real numbands */
-        fprintf(xmlout,  "%s      <Exponent Subband=\"%d\">\n", s, bandno);
-    if(raw)
-          fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, tccp->stepsizes[bandno].expn << 3);
-    if(derived)
-          fprintf(xmlout,"%s        <AsDecimal>%d</AsDecimal>\n", s, tccp->stepsizes[bandno].expn);
-        fprintf(xmlout,  "%s      </Exponent>\n", s);
-      }
-      fprintf(xmlout,    "%s    </ReversibleStepSizeValue>\n", s);
-      break;
-    case J2K_CCP_QNTSTY_SIQNT:
-      /* numbands = 1; */
-      fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-      if(notes)
-        fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-      fprintf(xmlout,    "%s      <QuantizationValuesForSubband0>\n", s);
-      if(notes)
-        fprintf(xmlout,  "%s      <!-- For N(L)LL subband: >\n", s);
-    if(raw)
-        fprintf(xmlout,  "%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[0].expn << 11) | tccp->stepsizes[0].mant);
-    if(derived) {
-        fprintf(xmlout,  "%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[0].expn);
-        fprintf(xmlout,  "%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[0].mant);
-    }
-      fprintf(xmlout,    "%s      </QuantizationValuesForSubband0>\n", s);
-    if(notes) {
-        fprintf(xmlout,  "%s      <!-- Exponents for subbands beyond 0 are not from header, but calculated per Eq. E.5 -->\n", s);
-        fprintf(xmlout,  "%s      <!-- The mantissa for all subbands is the same, given by the value above. -->\n", s);
-        fprintf(xmlout,  "%s      <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-      fprintf(xmlout,  "%s      <!-- until a subband with exponent of zero value is reached. -->\n", s);
-        }
-
-      for (bandno = 1; bandno < J2K_MAXBANDS; bandno++) {
-        if(tccp->stepsizes[bandno].expn == 0)
-          break;
-
-        fprintf(xmlout,  "%s      <CalculatedExponent Subband=\"%d\">%d</CalculatedExponent>\n", s, bandno, tccp->stepsizes[bandno].expn);
-      }
-      fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-      break;
-
-    default: /* J2K_CCP_QNTSTY_SEQNT */
-      numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/
-    /* Better: IMAGINE numbands = tccp->stepsize_numbands; */
-      fprintf(xmlout,    "%s    <QuantizationStepSizeValues>\n", s);
-      if(notes) {
-        fprintf(xmlout,  "%s    <!-- For irreversible transformation only.  See Part I Annex E Equation E.3 -->\n", s);
-        fprintf(xmlout,  "%s    <!-- Current mj2_to_metadata implementation dumps entire internal table, -->\n", s);
-      fprintf(xmlout,  "%s    <!-- until a subband with mantissa and exponent of zero values is reached. -->\n", s);
-    }
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp->stepsizes[bandno].expn == 0 && tccp->stepsizes[bandno].mant == 0)
-      break; /* Remove this once we have real numbands count */
-        fprintf(xmlout,  "%s      <QuantizationValues Subband=\"%d\">\n", s, bandno);
-    if(raw)
-          fprintf(xmlout,"%s        <AsHex>0x%02x</AsHex>\n", s, (tccp->stepsizes[bandno].expn << 11) | tccp->stepsizes[bandno].mant);
-    if(derived) {
-          fprintf(xmlout,"%s        <Exponent>%d</Exponent>\n", s, tccp->stepsizes[bandno].expn);
-          fprintf(xmlout,"%s        <Mantissa>%d</Mantissa>\n", s, tccp->stepsizes[bandno].mant);
-    }
-        fprintf(xmlout,  "%s      </QuantizationValues>\n", s);
-      }
-      fprintf(xmlout,    "%s    </QuantizationStepSizeValues>\n", s);
-      break;
-    } /* switch */
-    fprintf(xmlout,      "%s  </SPqcc>\n", s);
-    fprintf(xmlout,      "%s</QuantizationComponent>\n", s);
-  }
-/*  Alignments:          "    < < < < <   To help maintain xml pretty-printing */
-}
-
-/* ------------- */
-
-BOOL same_component_quantization(opj_tccp_t *tccp1, opj_tccp_t *tccp2)
-{
-  int bandno, numbands;
-
-  if(tccp1->qntsty != tccp2->qntsty)
-    return FALSE;
-  if(tccp1->numgbits != tccp2->numgbits)
-    return FALSE;
-
-  switch(tccp1->qntsty) {
-    case J2K_CCP_QNTSTY_NOQNT:
-      numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */
-      /* Instead look for first zero exponent, quit there.  Adequate? */
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp1->stepsizes[bandno].expn == 0)
-          break;
-        if(tccp1->stepsizes[bandno].expn != tccp2->stepsizes[bandno].expn)
-         return FALSE;
-      }
-      break;
-    case J2K_CCP_QNTSTY_SIQNT:
-      /* numbands = 1; */
-      if(tccp1->stepsizes[0].expn != tccp2->stepsizes[0].expn || tccp1->stepsizes[0].mant != tccp2->stepsizes[0].mant)
-        return FALSE;
-    /* Don't need to check remainder, since they are calculated from [0] */
-      break;
-
-    default: /* J2K_CCP_QNTSTY_SEQNT */
-      numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/
-    /* This comparison may cause us problems with trailing junk values. */
-      for (bandno = 0; bandno < numbands; bandno++) {
-        if(tccp1->stepsizes[bandno].expn != tccp2->stepsizes[bandno].expn || tccp1->stepsizes[bandno].mant != tccp2->stepsizes[bandno].mant);
-          return FALSE;
-      }
-      break;
-    } /* switch */
-  return TRUE;
-}
-
-/* ------------- */
-
-void xml_out_frame_rgn(FILE* xmlout, opj_tcp_t *tcp, int numcomps)
-{
-  int compno, SPrgn;
-  /* MJ2 files can have regions of interest if hybridized with JPX Part II */
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  for(compno = 0; compno < numcomps; compno++) {
-    SPrgn = tcp->tccps[compno].roishift;  /* 1 byte; SPrgn */
-    if(SPrgn == 0)
-    continue; /* Yet another kludge */
-
-    fprintf(xmlout,    "%s<RegionOfInterest Marker=\"RGN\">\n", s); /* Optional in main header, at most 1 per component */
-    if(notes)
-      fprintf(xmlout,  "%s<!-- See Crgn below for zero-based component number. -->\n", s);
-    /* Not retained or of interest: Lrgd */
-    fprintf(xmlout,    "%s  <Srgn>0</Srgn>\n", s); /* 1 byte */
-    if(notes)
-    fprintf(xmlout,  "%s  <!-- Srgn is ROI style.  Only style=0 defined: Implicit ROI (max. shift) -->\n", s);
-    fprintf(xmlout,    "%s  <Crgn>%d</Crgn>\n", s, compno); /* 1 or 2 bytes */
-    fprintf(xmlout,    "%s  <SPrgn>%d</SPrgn>\n", s, SPrgn); /* 1 byte */
-    if(notes)
-      fprintf(xmlout,  "%s  <!-- SPrgn is implicit ROI shift, i.e., binary shifting of ROI coefficients above background. -->\n", s);
-    fprintf(xmlout,    "</RegionOfInterest\n", s); /* Optional in main header, at most 1 per component */
-  }
-}
-
-/* ------------- */
-
-void xml_out_frame_poc(FILE* xmlout, opj_tcp_t *tcp) { /* Progression Order Change */
-  /* Compare j2k_read_poc() */
-  int i;
-  opj_poc_t *poc;
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-
-  if(tcp->POC != 1)
-    return; /* Not present */
-
-  fprintf(xmlout,    "%s<ProgressionOrderChange Marker=\"POC\">\n", s); /* Optional in main header, at most 1 per component */
-  /* j2k_read_poc seems to allow accumulation of default pocs from multiple POC segments, but does
-  the spec really allow that? */
-  /* 2 bytes, not retained; Lpoc */
-  /* I probably didn't get this dump precisely right. */
-  for (i = 0; i < tcp->numpocs; i++) {
-    poc = &tcp->pocs[i];
-    fprintf(xmlout,  "%s  <Progression Num=\"%d\">\n", s, i+1);
-    fprintf(xmlout,  "%S    <RSpoc>%d</RSpoc>\n", s, poc->resno0);  /* 1 byte, RSpoc_i */
-    if(notes)
-    fprintf(xmlout,"%s    <!-- Resolution level index (inclusive) for progression start. Range: 0 to 33 -->\n", s);
-    fprintf(xmlout,  "%s    <CSpoc>%d</CSpoc>\n", s, poc->compno0);/* j2k_img->numcomps <= 256 ? 1 byte : 2 bytes; CSpoc_i */
-    if(notes)
-      fprintf(xmlout,"%s    <!-- Component index (inclusive) for progression start. -->\n", s);
-    fprintf(xmlout,  "%s    <LYEpoc>%d</LYEpoc>\n", s, poc->layno1); /* int_min(cio_read(2), tcp->numlayers);  /* 2 bytes; LYEpoc_i */
-    if(notes)
-      fprintf(xmlout,"%s    <!-- Layer index (exclusive) for progression end. -->\n", s);
-    fprintf(xmlout,  "%s    <REpoc>%d</REpoc>\n", s, poc->resno1); /*int_min(cio_read(1), tccp->numresolutions);  /* REpoc_i */
-    if(notes)
-      fprintf(xmlout,"%s    <!-- Resolution level index (exclusive) for progression end. Range: RSpoc to 33 -->\n", s);
-    fprintf(xmlout,  "%s    <CEpoc>%d</CEpoc>\n", s, poc->compno1); /* int_min(cio_read(j2k_img->numcomps <= 256 ? 1 : 2), j2k_img->numcomps);  /* CEpoc_i */
-    if(notes)
-    fprintf(xmlout,"%s    <!-- Component index (exclusive) for progression end.  Minimum: CSpoc -->\n", s);
-    fprintf(xmlout,  "%s    <Ppoc>%d</Ppoc>\n", s, poc->prg); /* 1 byte Ppoc_i */
-  if(notes) {
-      fprintf(xmlout,"%s    <!-- Defined Progression Order Values are: -->\n", s);
-      fprintf(xmlout,"%s    <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->\n", s);
-      fprintf(xmlout,"%s    <!-- where L = \"layer\", R = \"resolution level\", C = \"component\", P = \"position\". -->\n", s);
-  }
-    fprintf(xmlout,  "%s  </Progression>\n", s);
-  }
-  fprintf(xmlout,    "%s</ProgressionOrderChange\n", s);
-}
-
-/* ------------- */
-
-#ifdef SUPPRESS_FOR_NOW
-/* Suppress PPM and PPT since we're not showing data from the third option, namely within the codestream, and
-that's evidently what frames_to_mj2 uses.  And a hex dump isn't so useful anyway */
-
-void xml_out_frame_ppm(FILE *xmlout, opj_cp_t *cp) { /* For main header, not tile-part (which uses PPT instead). */
-/* Either the PPM or PPT is required if the packet headers are not distributed in the bit stream */
-/* Use of PPM and PPT are mutually exclusive. */
-/* Compare j2k_read_ppm() */
-  int j;
-
-  if(cp->ppm != 1)
-    return; /* Not present */
-/* Main header uses indent of 10 spaces */
-  fprintf(xmlout,    "          <PackedPacketHeadersMainHeader Marker=\"PPM\">\n"); /* Optional in main header, but if not, must be in PPT or codestream */
-  /* 2 bytes Lppm not saved */
-  if(notes) {
-    fprintf(xmlout,  "          <!-- If there are multiple PPM marker segments in the main header, -->\n");
-    fprintf(xmlout,  "          <!-- this mj2_to_metadata implementation will report them as a single consolidated PPM header. -->\n");
-    fprintf(xmlout,  "          <!-- The implementation can't currently segregate by tile-part. -->\n");
-    fprintf(xmlout,  "          <!-- TO DO? further map the packet headers to xml. -->\n");
-  }
-
-  /* 1 byte, not retained ; Zppm is sequence # of this PPM header */
-  /* 4 bytes, possibly overwritten multiple times in j2k_cp->ppm_previous: Nppm */
-  /* Use j symbol for index instead of i, to make comparable with j2k_read_ppm */
-  /* Not real clear whether to use ppm->store or ppm_len as upper bound */
-  fprintf(xmlout,    "            <PackedData>\n");
-  xml_out_dump_hex(xmlout, cp->ppm_data, cp->ppm_len);
-  /* Dump packet headers 1 byte at a time: lppm[i][j] */
-  fprintf(xmlout,    "            </PackedData>\n");
-  fprintf(xmlout,    "          </PackedPacketHeadersMainHeader>\n"); /* Optional in main header, but if not, must be in PPT or codestream */
-}
-
-/* ------------- */
-
-void xml_out_frame_ppt(FILE *xmlout, opj_tcp_t *tcp) { /* For tile-part header, not main (which uses PPM instead). */
-/* Either the PPM or PPT is required if the packet headers are not distributed in the bit stream */
-/* Use of PPM and PPT are mutually exclusive. */
-/* Compare j2k_read_ppt() */
-  int j;
-
-  if(tcp->ppt != 1)
-    return; /* Not present */
-
-  /* Tile-part indents are 12 spaces */
-  fprintf(xmlout,    "            <PackedPacketHeadersTilePartHeader Marker=\"PPT\">\n"); /* Optional in main header, but if not, must be in PPT or codestream */
-  /* 2 bytes Lppm not saved */
-  if(notes) {
-    fprintf(xmlout,  "            <!-- If there are multiple PPT marker segments in the tile-part header, -->\n");
-    fprintf(xmlout,  "            <!-- this mj2_to_metadata implementation will report them as a single consolidated PPT header. -->\n");
-    fprintf(xmlout,  "            <!-- The implementation can't currently segregate by tile-part. -->\n");
-    fprintf(xmlout,  "            <!-- TO DO? further map the packet headers to xml. -->\n");
-  }
-
-  /* 1 byte, not retained ; Zppt is sequence # of this PPT header */
-  /* 4 bytes, possibly overwritten multiple times in j2k_cp->ppt_previous: Nppt */
-  /* Use j symbol for index instead of i, to make comparable with j2k_read_ppt */
-  /* Not real clear whether to use ppt->store or ppt_len as upper bound */
-  fprintf(xmlout,    "              <PackedData>\n");
-  xml_out_dump_hex(xmlout, tcp->ppt_data, tcp->ppt_len);
-  /* Dump packet headers 1 byte at a time: lppt[i][j] */
-  fprintf(xmlout,    "              </PackedData>\n");
-  fprintf(xmlout,    "            </PackedPacketHeadersTileHeader>\n"); /* Optional in tile-part header, but if not, must be in PPM or codestream */
-}
-#endif SUPPRESS_FOR_NOW
-
-/* ------------- */
-
-void xml_out_frame_tlm(FILE* xmlout) { /* opt, main header only.  May be multiple. */
-/* Compare j2k_read_tlm()... which doesn't retain anything! */
-/* Plan:  Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
-/* Main header indents are 10 spaces */
-}
-
-/* ------------- */
-
-void xml_out_frame_plm(FILE* xmlout) { /* opt, main header only; can be used in conjunction with tile-part's PLT */
-/* NO-OP.  PLM NOT SAVED IN DATA STRUCTURE */
-  /* Compare j2k_read_plm()... which doesn't retain anything! */
-/* Plan:  Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
-/* Main header indents are 10 spaces */
-}
-
-/* ------------- */
-
-void xml_out_frame_plt(FILE* xmlout, opj_tcp_t *tcp) { /* opt, tile-part headers only; can be used in conjunction with main header's PLM */
-/* NO-OP.  PLT NOT SAVED IN DATA STRUCTURE */
-  /* Compare j2k_read_plt()... which doesn't retain anything! */
-/* Tile-part header indents are 12 spaces */
-}
-
-/* ------------- */
-
-void xml_out_frame_crg(FILE* xmlout) { /* NO-OP.  CRG NOT SAVED IN DATA STRUCTURE */ /* opt, main header only; */
-/* Compare j2k_read_crg()... which doesn't retain anything! */
-/* Plan:  Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */
-#ifdef NOTYET
-  THIS PSEUDOCODE IMAGINES THESE EXIST: j2k_default_tcp->crg, j2k_default_tcp->crg_i, j2k_default_tcp->crg_xcrg*, j2k_default_tcp->crg_ycrg*
-  (POSSIBLY DON'T NEED crg_i, CAN GET NUMBER OR COMPONENTS FROM ELSEWHERE)
-  if(j2k_default_tcp->crg != 1 || j2k_default_tcp->crg_i == 0)
-    return; /* Not present */
-
-/* Main header indents are 10 spaces */
-  fprintf(xmlout,    "          <ComponentRegistration Marker=\"RG\" Count=\"%d\">\n", j2k_default_tcp->crg_i);
-  if(notes) {
-    fprintf(xmlout,  "          <!-- Fine tuning of registration of components with respect to each other, -->\n");
-    fprintf(xmlout,  "          <!-- not required but potentially helpful for decoder. -->\n");
-    fprintf(xmlout,  "          <!-- These supplementary fractional offsets are in units of 1/65536 of the horizontal -->\n");
-    fprintf(xmlout,  "          <!-- or vertical separation (e.g., XRsiz[i] or YRsiz[i] for component i). -->\n");
-  }
-  /* This isn't the most compact form of table, but is OK when number of components is small, as is likely. */
-  for (i = 0; i < j2k_default_tcp->crg_i; i++) {
-    fprintf(xmlout,  "            <Component Num=\"%d\">\n", i+1);
-    fprintf(xmlout,  "              <Xcrg>\n");
-  if(raw)
-      fprintf(xmlout,"                <AsNumerator>%d</AsNumerator>\n", j2k_default_tcp->crg_xcrg[i]);
-  if(derived) {
-    /* Calculate n * 100%/65536; 4 digits after decimal point is sufficiently accurate */
-      fprintf(xmlout,"                <AsPercentage>%.4f</AsPercentage>\n", ((double)j2k_default_tcp->crg_xcrg[i])/655.36);
-    /* We could do another calculation that include XRsiz[i]; maybe later. */
-  }
-    fprintf(xmlout,  "              </Xcrg>\n");
-    fprintf(xmlout,  "              <Ycrg>\n");
-  if(raw)
-      fprintf(xmlout,"                <AsNumerator>%d</AsNumerator>\n", j2k_default_tcp->crg_ycrg[i]);
-  if(derived) {
-      fprintf(xmlout,"                <AsPercentage>%f</AsPercentage>\n", ((double)j2k_default_tcp->crg_ycrg[i])/655.36);
-  }
-    fprintf(xmlout,  "              </Ycrg>\n");
-    fprintf(xmlout,  "            </Component>\n");
-  }
-
-  fprintf(xmlout,    "          </ComponentRegistration>\n");
-
-#endif
-}
-
-/* ------------- */
-
-/* Regrettably from a metadata point of view, j2k_read_com() skips over any comments in main header or tile-part-header */
-void xml_out_frame_com(FILE* xmlout, opj_tcp_t *tcp) { /* NO-OP.  COM NOT SAVED IN DATA STRUCTURE */ /* opt in main or tile-part headers; */
-/* Compare j2k_read_com()... which doesn't retain anything! */
-#ifdef NOTYET
-  char spaces[13] = "            "; /* 12 spaces if tilepart*/
-  char* s = spaces;
-  if(tcp == &j2k_default_tcp) {
-    s++;s++; /* shorten s to 10 spaces if main */
-  }
-  THIS PSEUDOCODE IMAGINES THESE EXIST: tcp->com, tcp->com_len, tcp->com_data array
-  if(tcp->com != 1)
-    return; /* Not present */
-
-  fprintf(xmlout,    "%s<Comment Marker=\"COM\">\n", s); /* Optional in main or tile-part header */
-  xml_out_dump_hex_and_ascii(tcp->com_data, tcp->com_len, s);
-  fprintf(xmlout,    "%s</Comment>\n", s);
-#endif
-}
-
-void xml_out_dump_hex(FILE* xmlout, char *data, int data_len, char* s) {
-  /* s is a string of spaces for indent */
-  int i;
-
-  /* This is called when raw is true, or there is no appropriate derived form */
-  fprintf(xmlout,    "%s<AsHex>\n", s);
-  fprintf(xmlout,    "%s  ", s); /* Inadequate for pretty printing */
-  for (i = 0; i < data_len; i++) {  /* Dump packet headers */
-    fprintf(xmlout,  "%02x", data[i]);
-  }
-  fprintf(xmlout,    "%s</AsHex>\n", s);
-}
-
-/* Define this as an even number: */
-#define BYTES_PER_DUMP_LINE 40
-/* Current total width for Hex and ASCII is : 11 spaces lead + (3 * BPDL) + 2 spaces + BPDL */
-void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len, char* s) {
-  /* s is a string of spaces for indent */
-  int i,j;
-
-  if(raw)
-    xml_out_dump_hex(xmlout, data, data_len, s);
-
-  if(derived) {
-    fprintf(xmlout,  "%s<AsHexAndASCII>\n", s);
-  for (i = 0; i < data_len; ) {
-      fprintf(xmlout,"%s ", s); /* Additional leading space added in loop */
-    /* First column: hex */
-      for (j = 0; j < BYTES_PER_DUMP_LINE; j++)  /* Dump bytes */
-        fprintf(xmlout," %02x", data[i+j]);
-      /* Space between columns... */ fprintf(xmlout,  "  ");
-    /* Second column: ASCII */
-    for (j = 0; j < BYTES_PER_DUMP_LINE; j++, i++) {
-      if(isprint((int)data[i]) && i < data_len)
-          fprintf(xmlout,"%c", data[i]);
-      else
-        fprintf(xmlout," ");
-      }
-      /* If we also wanted to output UCS-2 Unicode as a third column, then entire document
-      must use fwprintf.  Forget about it for now.  As it stands, if data is UCS-2 format but still
-      the ASCII set, then we'll be able to read every other byte as ASCII in column 2.  If
-      data is UTF-8 format but still ASCII, then we'll be able to read every byte as ASCII
-      in column 2. */
-    }
-    fprintf(xmlout,  "%s</AsHexAndASCII>\n", s);
-  }
-}
-
-
-/* ------------- */
-
-void xml_out_frame_jp2h(FILE* xmlout, opj_jp2_t *jp2_struct) {  /* JP2 Header */
-/* Compare jp2_read_jp2h(opj_jp2_t * jp2_struct) */
-  int i;
-
-  fprintf(xmlout,      "              <JP2Header BoxType=\"jp2h\">\n");
-
-/* Compare jp2_read_ihdr(jp2_struct)) */
-  fprintf(xmlout,      "                <ImageHeader BoxType=\"ihdr\">\n");
-  fprintf(xmlout,      "                  <HEIGHT>%d</HEIGHT>\n", jp2_struct->h); /* 4 bytes */
-  fprintf(xmlout,      "                  <WIDTH>%d</WIDTH>\n", jp2_struct->w); /* 4 bytes */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- HEIGHT here, if 2 fields per image, is of total deinterlaced height. -->\n");
-  fprintf(xmlout,      "                  <NC>%d</NC>\n", jp2_struct->numcomps); /* 2 bytes */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- NC is number of components -->\n"); /* 2 bytes */
-  fprintf(xmlout,      "                  <BPC>\n"); /* 1 byte */
-  if(jp2_struct->bpc == 255) {
-    fprintf(xmlout,    "                    <AsHex>0x%02x</AsHex>\n", jp2_struct->bpc); /* 1 byte */
-    if(notes)
-      fprintf(xmlout,  "                    <!-- BPC = 0xff means bits per pixel varies with component; see table below. -->\n");
-  } else { /* Not 0xff */
-    if(raw) {
-      fprintf(xmlout,  "                    <AsHex>0x%02x</AsHex>\n", jp2_struct->bpc); /* 1 byte */
-      if(notes)
-        fprintf(xmlout,"                    <!-- BPC = 0xff means bits per pixel varies with component; see table below. -->\n");
-  }
-    if(derived) {
-      fprintf(xmlout,  "                    <BitsPerPixel>%d</BitsPerPixel>\n", jp2_struct->bpc & 0x7f);
-      fprintf(xmlout,  "                    <Signed>%d</Signed>\n", jp2_struct->bpc >> 7);
-  }
-  }
-  fprintf(xmlout,      "                  </BPC>\n");
-  fprintf(xmlout,      "                  <C>%d</C>\n", jp2_struct->C); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- C is compression type.  Only \"7\" is allowed to date. -->\n"); /* 2 bytes */
-  fprintf(xmlout,      "                  <UnkC>%d</UnkC>\n", jp2_struct->UnkC); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- Colourspace Unknown. 1 = unknown, 0 = known (e.g., colourspace spec is accurate) -->\n"); /* 1 byte */
-  fprintf(xmlout,      "                  <IPR>%d</IPR>\n", jp2_struct->IPR); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- IPR is 1 if frame contains an Intellectual Property box; 0 otherwise. -->\n"); /* 2 bytes */
-  fprintf(xmlout,      "                </ImageHeader>\n");
-
-  if (jp2_struct->bpc == 255)
-  {
-    fprintf(xmlout,    "                <BitsPerComponent BoxType=\"bpcc\">\n");
-    if(notes)
-      fprintf(xmlout,  "                <!-- Pixel depth (range 1 to 38) is low 7 bits of hex value + 1 -->\n");
-  /* Bits per pixel varies with components */
-    /* Compare jp2_read_bpcc(jp2_struct) */
-  for (i = 0; i < (int)jp2_struct->numcomps; i++) {
-    if(raw)
-        fprintf(xmlout,"                  <AsHex>0x%02x</AsHex>\n", jp2_struct->comps[i].bpcc); /* 1 byte */
-    if(derived) {
-        fprintf(xmlout,"                  <BitsPerPixel>%d</BitsPerPixel>\n", (jp2_struct->comps[i].bpcc & 0x7f)+1);
-        fprintf(xmlout,"                  <Signed>%d</Signed>\n", jp2_struct->comps[i].bpcc >> 7);
-    }
-  }
-    fprintf(xmlout,    "                </BitsPerComponent>\n");
-  }
-
-  /* Compare jp2_read_colr(jp2_struct) */
-  fprintf(xmlout,      "                <ColourSpecification BoxType=\"colr\">\n");
-  fprintf(xmlout,      "                  <METH>%d</METH>\n", jp2_struct->meth); /* 1 byte */
-  if(notes) {
-    fprintf(xmlout,    "                  <!-- Valid values of specification method so far: -->\n");
-    fprintf(xmlout,    "                  <!--   1 = Enumerated colourspace, in EnumCS field -->\n");
-    fprintf(xmlout,    "                  <!--   2 = Restricted ICC Profile, in PROFILE field -->\n");
-  }
-  fprintf(xmlout,      "                  <PREC>%d</PREC>\n", jp2_struct->precedence); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- 0 is only valid value of precedence so far. -->\n");
-  fprintf(xmlout,      "                  <APPROX>%d</APPROX>\n", jp2_struct->approx); /* 1 byte */
-  if(notes)
-    fprintf(xmlout,    "                  <!-- 0 is only valid value of colourspace approximation so far. -->\n");
-
-  if (jp2_struct->meth == 1) {
-    fprintf(xmlout,    "                  <EnumCS>%d</EnumCS>\n", jp2_struct->enumcs); /* 4 bytes */
-  if(notes) {
-    fprintf(xmlout,  "                  <!-- Valid values of enumerated MJ2 colourspace so far: -->\n");
-    fprintf(xmlout,  "                  <!--   16: sRGB as defined by IEC 61966-2-1. -->\n");
-    fprintf(xmlout,  "                  <!--   17: greyscale (related to sRGB). -->\n");
-    fprintf(xmlout,  "                  <!--   18: sRGB YCC (from JPEG 2000 Part II). -->\n");
-    fprintf(xmlout,  "                  <!-- (Additional JPX values are defined in Part II). -->\n");
-  }
-  }
-  else
-    if(notes)
-      fprintf(xmlout,  "                  <!-- PROFILE is not handled by current OpenJPEG implementation. -->\n");
-    /* only 1 byte is read and nothing stored */
-  fprintf(xmlout,      "                </ColourSpecification>\n");
-
-  /* TO DO?  No OpenJPEG support.
-  Palette 'pclr'
-  ComponentMapping 'cmap'
-  ChannelDefinition 'cdef'
-  Resolution 'res'
-  */
-  fprintf(xmlout,      "              </JP2Header>\n");
-}
-/* ------------- */
-
-#ifdef NOTYET
-IMAGE these use cp structure, extended... but we could use a new data structure instead
-void xml_out_frame_jp2i(FILE* xmlout, opj_cp_t *cp) {
-  /* IntellectualProperty 'jp2i' (no restrictions on location) */
-  int i;
-  IMAGE cp->jp2i, cp->jp2i_count, cp->jp2i_data (array of chars), cp->cp2i_len (array of ints)
-  if(cp->jp2i != 1)
-    return; /* Not present */
-
-  for(i = 0; i < cp->jp2i_count; i++)
-  {
-    fprintf(xmlout,      "            <IntellectualProperty BoxType=\"jp2i\">\n");
-  /* I think this can be anything, including binary, so do a dump */
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. */
-    xml_out_dump_hex_and_ascii(xmlout, cp->jp2i_data[i], cp->jp2i_len[i]);
-    fprintf(xmlout,      "            </IntellectualProperty>\n");
-  }
-}
-
-void xml_out_frame_xml(FILE* xmlout, opj_cp_t *cp) {
-  /* XML 'xml\040' (0x786d6c20).  Can appear multiply, before or after jp2c codestreams */
-  IMAGE cp->xml, cp->xml_count, cp->xml_data (array of chars)
-  MAYBE WE DON'T NEED cp->xml_len (array of ints) IF WE ASSUME xml_data IS NULL-TERMINATED.
-  ASSUME ASSUME EACH LINE IS ENDED BY \n.
-  int i;
-  if(cp->xml != 1)
-    return; /* Not present */
-
-  for(i = 0; i < cp->xml_count; i++)
-  {
-    fprintf(xmlout,      "            <TextFormXML BoxType=\"xml[space]" Instance=\"%d\">\n", i+1);
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. Being lazy, didn't indent here. */
-    fprintf(xmlout,cp->xml_data[i]); /* May be multiple lines */ /* Could check if this is well-formed */
-    fprintf(xmlout,      "            </TextFormXML>\n");
-  }
-}
-
-void xml_out_frame_uuid(FILE* xmlout, opj_cp_t *cp) {
-  /* UUID 'uuid' (top level only) */
-  /* Part I 1.7.2 says: may appear multiply in JP2 file, anywhere except before File Type box */
-  /* Part III 5.2.1 says: Private extensions shall be achieved through the 'uuid' type. */
-  /* A UUID is a 16-byte value.  There is a conventional string representation for it:
-     "0x12345678-9ABC-DEF0-1234-567890ABCDEF".  Let's assume that is what is stored in uuid_value */
-
-  /* Part III 6.1 Any other MJ2 box type could be alternatively written as a 'uuid' box, with value given
-     as : 0xXXXXXXXX-0011-0010-8000-00AA00389B71, where the Xs are the boxtype in hex.  However,
-     such a file is "not compliant; systems may choose to read [such] objects ... as equivalent to the box of
-     the same type, or not."  Here, we choose not to. */
-  int i;
-  IMAGE cp->uuid, cp->uuid_count, cp->uuid_value (array of uuids... let's say fixed-length strings) cp->uuid_data (array of char buffers), cp->uuid_len (array of ints)
-  if(cp->juuid != 1)
-    return; /* Not present */
-
-  for(i = 0; i < cp->uuid_count; i++)
-  {
-    fprintf(xmlout,      "            <UniversalUniqueID BoxType=\"uuid\">
-  fprintf(xmlout,      "              <UUID>%s</UUDI>\n", cp->uuid_value[i]);
-  fprintf(xmlout,      "              <Data>\n");
-  /* I think this can be anything, including binary, so do a dump */
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. */
-    xml_out_dump_hex_and_ascii(xmlout, cp->uuid_data[i], cp->uuid_len[i]);
-  fprintf(xmlout,      "              </Data>\n");
-    fprintf(xmlout,      "            </UniversalUniqueID>\n");
-  }
-}
-
-void xml_out_frame_uinf(FILE* xmlout, opj_cp_t *cp) {
-  /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */
-  /* Part I 1.7.3 says: may appear multiply in JP2 file, anywhere at the top level except before File Type box */
-  /* So there may be multiple ulst's, and each can have multiple UUIDs listed (with a single URL) */
-  /* This is not quite as vendor-specific as UUIDs, or at least is meant to be generally readable */
-  /* Assume UUIDs stored in canonical string format */
-  int i, j;
-  IMAGE cp->uinf, cp->uinf_count, cp->uinf_ulst_nu (array of ints)
-    cp->uinf_uuid (2 dimensional array of uuids... let's say fixed-length strings),
-    cp->uinf_url (array of char buffers)
-
-  if(cp->uinf != 1)
-    return; /* Not present */
-
-  for(i = 0; i < cp->uuid_count; i++)
-  {
-    fprintf(xmlout,      "            <UUIDInfo BoxType=\"uinf\">\n");
-    fprintf(xmlout,      "              <UUIDList BoxType=\"ulst\" Count=\"%d\">\n",cp->cp->uinf_ulst_nu[i]);
-  for(j = 0; j < cp->uinf_ulst_nu[i];  j++)
-    fprintf(xmlout,    "              <ID Instance=\"%s\">%s</ID>\n", cp->uuif_uuid[i][j], j+1);
-    fprintf(xmlout,      "              </UUIDList>\n");
-  fprintf(xmlout,      "              <DataEntryURL>\n");
-  /* Could add VERS and FLAG here */
-  fprintf(xmlout,      "                <LOC>\n");
-    fprintf(xmlout,      "                  %s",cp->uinf_url[i]); /* Probably single line, so indent works */ /* In theory, could check if this is well-formed, or good live link */
-  fprintf(xmlout,      "                </LOC>\n");
-  fprintf(xmlout,      "              </DataEntryURL>\n");
-    fprintf(xmlout,      "            </UUIDInfo>\n");
-  }
-}
-
-IMAGE these use cp structure, extended... but we could use a new data structure instead
-void xml_out_frame_unknown_type(FILE* xmlout, opj_cp_t *cp) {
-  /* Part III 5.2.1 says "Type fields not defined here are reserved.  Private extensions
-     shall be acieved through the 'uuid' type." [This implies an unknown
-     type would be an error, but then...] "Boxes not explicitly defined in this standard,
-   or otherwise unrecognized by a reader, may be ignored."
-   Also, it says  "the following types are not and will not be used, or used only in
-   their existing sense, in future versions of this specification, to avoid conflict
-   with existing content using earlier pre-standard versions of this format:
-     clip, crgn, matt, kmat, pnot, ctab, load, imap;
-     track reference types tmcd, chap, sync,scpt, ssrc"
-   [But good luck figuring out the mapping.]
-   Part III Amend. 2 4.1 is stronger: "All these specifications [of this family, e.g.,
-   JP2 Part I, ISO Base format (Part 12) leading to MP4, Quicktime, and possibly including
-   MJ2] require that readers ignore objects that are unrecognizable to them".
-   */
-  int i;
-  IMAGE cp->unknown_type, cp->unknown_type_count, cp->unknown_type_boxtype (array of buf[5]s), cp->unknown_type_data (array of chars), cp->unknown_type_len (array of ints)
-  if(cp->unknown_type != 1)
-    return; /* Not present */
-
-  for(i = 0; i < cp->unknown_type_count; i++)
-  {
-    fprintf(xmlout,      "            <UnknownType BoxType=\"%s\">\n", cp->unknown_type_boxtype[i]);
-    /* Can be anything, including binary, so do a dump */
-    /* Is it better to indent or not indent this content?  Indent is better for reading, but
-    worse for cut/paste. */
-    xml_out_dump_hex_and_ascii(xmlout, cp->unknown_type_data[i], cp->unknown_type_len[i]);
-    fprintf(xmlout,      "            </UnknownType>\n");
-  }
-}
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/meta_out.h b/Utilities/gdcmopenjpeg-v2/mj2/meta_out.h
deleted file mode 100644
index be1965d..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/meta_out.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* meta_out.h */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Callable from mj2_to_metadata */
-/* Contributed to Open JPEG by Glenn Pearson, U.S. National Library of Medicine */
-
-#define BOOL int
-#define FALSE 0
-#define TRUE 1
-
-void xml_write_init(BOOL n, BOOL t, BOOL r, BOOL d);
-
-int xml_write_struct(FILE *file, FILE *xmlout, opj_mj2_t * movie, unsigned int sampleframe, char* stringDTD, opj_event_mgr_t *event_mgr);
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2.c b/Utilities/gdcmopenjpeg-v2/mj2/mj2.c
deleted file mode 100644
index 8c39d15..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2.c
+++ /dev/null
@@ -1,2906 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "opj_includes.h"
-#include "mj2.h"
-
-/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
-/*@{*/
-
-/** @name Local static functions */
-/*@{*/
-
-/**
-Read box headers
- at param cinfo Codec context info
- at param cio Input stream
- at param box
- at return Returns true if successful, returns false otherwise
-*/
-static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
-
-/*
-*
-* Read box headers
-*
-*/
-
-int mj2_read_boxhdr(mj2_box_t * box, opj_cio_t *cio)
-{
-  box->init_pos = cio_tell(cio);
-  box->length = cio_read(cio, 4);
-  box->type = cio_read(cio, 4);
-  if (box->length == 1) {
-    if (cio_read(cio, 4) != 0) {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Cannot handle box sizes higher than 2^32\n");
-      return 1;
-    };
-    box->length = cio_read(cio, 4);
-    if (box->length == 0)
-      box->length = cio_numbytesleft(cio) + 12;
-  }
-  else if (box->length == 0) {
-    box->length = cio_numbytesleft(cio) + 8;
-  }
-  return 0;
-}
-
-/*
-*
-* Initialisation of a Standard Movie, given a simple movie structure defined by the user
-* The movie will have one sample per chunk
-*
-* Arguments: opj_mj2_t * movie
-* Several variables of "movie" must be defined in order to enable a correct execution of
-* this function:
-*   - The number of tracks of each type (movie->num_vtk, movie->num_stk, movie->num_htk)
-*   - The memory for each must be allocated (movie->tk)
-*   - For each track:
-*    The track type (tk->track_type)
-*    The number of sample (tk->num_samples)
-*    The sample rate (tk->sample_rate)
-*
-*/
-
-int mj2_init_stdmovie(opj_mj2_t * movie)
-{
-  int i;
-  unsigned int j;
-  time_t ltime;
-
-  movie->brand = MJ2_MJ2;
-  movie->minversion = 0;
-  movie->num_cl = 2;
-  movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
-
-  movie->cl[0] = MJ2_MJ2;
-  movie->cl[1] = MJ2_MJ2S;
-  time(&ltime);      /* Time since 1/1/70 */
-  movie->creation_time = (unsigned int) ltime + 2082844800;  /* Seconds between 1/1/04 and 1/1/70 */
-  movie->timescale = 1000;
-
-  movie->rate = 1 << 16;    /* Rate to play presentation  (default = 0x00010000)          */
-  movie->volume = 1 << 8;    /* Movie volume (default = 0x0100)                            */
-  movie->trans_matrix[0] = 0x00010000;  /* Transformation matrix for video                            */
-  movie->trans_matrix[1] = 0;  /* Unity is { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 }  */
-  movie->trans_matrix[2] = 0;
-  movie->trans_matrix[3] = 0;
-  movie->trans_matrix[4] = 0x00010000;
-  movie->trans_matrix[5] = 0;
-  movie->trans_matrix[6] = 0;
-  movie->trans_matrix[7] = 0;
-  movie->trans_matrix[8] = 0x40000000;
-  movie->next_tk_id = 1;
-
-  for (i = 0; i < movie->num_htk + movie->num_stk + movie->num_vtk; i++) {
-    mj2_tk_t *tk = &movie->tk[i];
-    movie->next_tk_id++;
-    tk->jp2_struct.comps = NULL;
-    tk->jp2_struct.cl = NULL;
-
-    if (tk->track_type == 0) {
-      if (tk->num_samples == 0)
-        return 1;
-
-      tk->Dim[0] = 0;
-      tk->Dim[1] = 0;
-
-      tk->timescale = 1000;  /* Timescale = 1 ms                                          */
-
-      tk->chunk[0].num_samples = 1;
-      tk->chunk[0].sample_descr_idx = 1;
-
-      tk->same_sample_size = 0;
-
-      tk->num_samplestochunk = 1;  /* One sample per chunk                                      */
-    tk->sampletochunk = (mj2_sampletochunk_t*) opj_malloc(tk->num_samplestochunk * sizeof(mj2_sampletochunk_t));
-      tk->sampletochunk[0].first_chunk = 1;
-      tk->sampletochunk[0].samples_per_chunk = 1;
-      tk->sampletochunk[0].sample_descr_idx = 1;
-
-      if (tk->sample_rate == 0) {
-        opj_event_msg(tk->cinfo, EVT_ERROR,
-          "Error while initializing MJ2 movie: Sample rate of track %d must be different from zero\n",
-          tk->track_ID);
-        return 1;
-      }
-
-      for (j = 0; j < tk->num_samples; j++) {
-        tk->sample[j].sample_delta = tk->timescale / tk->sample_rate;
-      }
-
-      tk->num_tts = 1;
-    tk->tts = (mj2_tts_t*) opj_malloc(tk->num_tts * sizeof(mj2_tts_t));
-      tk->tts[0].sample_count = tk->num_samples;
-      tk->tts[0].sample_delta = tk->timescale / tk->sample_rate;
-
-      tk->horizresolution = 0x00480000;  /* Horizontal resolution (typically 72)                       */
-      tk->vertresolution = 0x00480000;  /* Vertical resolution (typically 72)                         */
-      tk->compressorname[0] = 0x0f4d6f74;  /* Compressor Name[]: Motion JPEG2000                         */
-      tk->compressorname[1] = 0x696f6e20;
-      tk->compressorname[2] = 0x4a504547;
-      tk->compressorname[3] = 0x32303030;
-      tk->compressorname[4] = 0x00120000;
-      tk->compressorname[5] = 0;
-      tk->compressorname[6] = 0x00000042;
-      tk->compressorname[7] = 0x000000DC;
-      tk->num_url = 0;    /* Number of URL                                              */
-      tk->num_urn = 0;    /* Number of URN                                              */
-      tk->graphicsmode = 0;  /* Graphicsmode                                               */
-      tk->opcolor[0] = 0;  /* OpColor                                                    */
-      tk->opcolor[1] = 0;  /* OpColor                                                    */
-      tk->opcolor[2] = 0;  /* OpColor                                                    */
-      tk->creation_time = movie->creation_time;  /* Seconds between 1/1/04 and 1/1/70          */
-      tk->language = 0;    /* Language (undefined)                */
-      tk->layer = 0;
-      tk->volume = 1 << 8;    /* Movie volume (default = 0x0100) */
-      tk->trans_matrix[0] = 0x00010000;  /* Transformation matrix for track */
-      tk->trans_matrix[1] = 0;  /* Unity is { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 }  */
-      tk->trans_matrix[2] = 0;
-      tk->trans_matrix[3] = 0;
-      tk->trans_matrix[4] = 0x00010000;
-      tk->trans_matrix[5] = 0;
-      tk->trans_matrix[6] = 0;
-      tk->trans_matrix[7] = 0;
-      tk->trans_matrix[8] = 0x40000000;
-      tk->fieldcount = 1;
-      tk->fieldorder = 0;
-      tk->or_fieldcount = 1;
-      tk->or_fieldorder = 0;
-      tk->num_br = 2;
-    tk->br = (unsigned int*) opj_malloc(tk->num_br * sizeof(unsigned int));
-      tk->br[0] = MJ2_JP2;
-      tk->br[1] = MJ2_J2P0;
-      tk->num_jp2x = 0;
-      tk->hsub = 2;    /* 4:2:0                                                      */
-      tk->vsub = 2;    /* 4:2:0                                                      */
-      tk->hoff = 0;
-      tk->voff = 0;
-      tk->visual_w = tk->w << 16;
-      tk->visual_h = tk->h << 16;
-    }
-    else {
-      tk->num_br = 0;
-      tk->jp2xdata = NULL;
-    }
-  }
-  return 0;
-}
-
-/*
-* Time To Sample box Decompact
-*
-*/
-void mj2_tts_decompact(mj2_tk_t * tk)
-{
-  int i, j;
-  tk->num_samples = 0;
-  for (i = 0; i < tk->num_tts; i++) {
-    tk->num_samples += tk->tts[i].sample_count;
-  }
-
-  tk->sample = (mj2_sample_t*) opj_malloc(tk->num_samples * sizeof(mj2_sample_t));
-
-  for (i = 0; i < tk->num_tts; i++) {
-    for (j = 0; j < tk->tts[i].sample_count; j++) {
-      tk->sample[j].sample_delta = tk->tts[i].sample_delta;
-    }
-  }
-}
-
-/*
-* Sample To Chunk box Decompact
-*
-*/
-void mj2_stsc_decompact(mj2_tk_t * tk)
-{
-  int j, i;
-  unsigned int k;
-  int sampleno=0;
-
-  if (tk->num_samplestochunk == 1) {
-    tk->num_chunks =
-      (unsigned int) ceil((double) tk->num_samples /
-      (double) tk->sampletochunk[0].samples_per_chunk);
-   tk->chunk = (mj2_chunk_t*) opj_malloc(tk->num_chunks * sizeof(mj2_chunk_t));
-    for (k = 0; k < tk->num_chunks; k++) {
-      tk->chunk[k].num_samples = tk->sampletochunk[0].samples_per_chunk;
-    }
-
-  } else {
-    tk->chunk = (mj2_chunk_t*) opj_malloc(tk->num_samples * sizeof(mj2_chunk_t));
-    tk->num_chunks = 0;
-    for (i = 0; i < tk->num_samplestochunk -1 ; i++) {
-      for (j = tk->sampletochunk[i].first_chunk - 1;
-      j < tk->sampletochunk[i + 1].first_chunk - 1; j++) {
-        tk->chunk[j].num_samples = tk->sampletochunk[i].samples_per_chunk;
-        tk->num_chunks++;
-        sampleno += tk->chunk[j].num_samples;
-      }
-    }
-    tk->num_chunks += (int)(tk->num_samples  - sampleno) / tk->sampletochunk[tk->num_samplestochunk - 1].samples_per_chunk;
-    for (k = tk->sampletochunk[tk->num_samplestochunk - 1].first_chunk - 1;
-    k < tk->num_chunks; k++) {
-      tk->chunk[k].num_samples =
-        tk->sampletochunk[tk->num_samplestochunk - 1].samples_per_chunk;
-    }
-    tk->chunk = opj_realloc(tk->chunk, tk->num_chunks * sizeof(mj2_chunk_t));
-  }
-
-}
-
-
-/*
-* Chunk offset box Decompact
-*
-*/
-void mj2_stco_decompact(mj2_tk_t * tk)
-{
-  int j;
-  unsigned int i;
-  int k = 0;
-  int intra_chunk_offset;
-
-  for (i = 0; i < tk->num_chunks; i++) {
-    intra_chunk_offset = 0;
-    for (j = 0; j < tk->chunk[i].num_samples; j++) {
-      tk->sample[k].offset = intra_chunk_offset + tk->chunk[i].offset;
-      intra_chunk_offset += tk->sample[k].sample_size;
-      k++;
-    }
-  }
-}
-
-/*
-* Write the JP box
-*
-* JP Signature box
-*
-*/
-void mj2_write_jp(opj_cio_t *cio)
-{
-  mj2_box_t box;
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-
-  cio_write(cio, MJ2_JP, 4);    /* JP */
-  cio_write(cio, 0x0d0a870a, 4);  /* 0x0d0a870a required in a JP box */
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JP box
-*
-* JPEG 2000 signature
-*
-*/
-int mj2_read_jp(opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JP != box.type) {  /* Check Marker */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JP Marker\n");
-    return 1;
-  }
-  if (0x0d0a870a != cio_read(cio, 4)) {  /* read the 0x0d0a870a required in a JP box */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP Marker\n");
-    return 1;
-  }
-  if (cio_tell(cio) - box.init_pos != box.length) {  /* Check box length */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP Box size \n");
-    return 1;
-  }
-  return 0;
-
-}
-
-/*
-* Write the FTYP box
-*
-* File type box
-*
-*/
-void mj2_write_ftyp(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-
-  cio_write(cio, MJ2_FTYP, 4);  /* FTYP       */
-  cio_write(cio, movie->brand, 4);  /* BR         */
-  cio_write(cio, movie->minversion, 4);  /* MinV       */
-
-  for (i = 0; i < movie->num_cl; i++)
-    cio_write(cio, movie->cl[i], 4);  /* CL         */
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* Length     */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the FTYP box
-*
-* File type box
-*
-*/
-int mj2_read_ftyp(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);  /* Box Size */
-  if (MJ2_FTYP != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected FTYP Marker\n");
-    return 1;
-  }
-
-  movie->brand = cio_read(cio, 4);  /* BR              */
-  movie->minversion = cio_read(cio, 4);  /* MinV            */
-  movie->num_cl = (box.length - 16) / 4;
-  movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
-
-  for (i = movie->num_cl - 1; i > -1; i--)
-    movie->cl[i] = cio_read(cio, 4);  /* CLi */
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with FTYP Box\n");
-    return 1;
-  }
-  return 0;
-}
-
-
-/*
-* Write the STCO box
-*
-* Chunk Offset Box
-*
-*/
-void mj2_write_stco(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STCO, 4);  /* STCO       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, tk->num_chunks, 4);  /* Entry Count */
-
-  for (i = 0; i < tk->num_chunks; i++) {
-    cio_write(cio, tk->chunk[i].offset, 4);  /* Entry offset */
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STCO box
-*
-* Chunk Offset Box
-*
-*/
-int mj2_read_stco(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  unsigned int i;
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);  /* Box Size */
-  if (MJ2_STCO != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STCO Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STCO box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STCO box. Expected flag 0\n");
-    return 1;
-  }
-
-
-  if (cio_read(cio, 4) != tk->num_chunks) {
-    opj_event_msg(cio->cinfo, EVT_ERROR,
-      "Error in STCO box: expecting same amount of entry-count as chunks \n");
-  } else {
-    for (i = 0; i < tk->num_chunks; i++) {
-      tk->chunk[i].offset = cio_read(cio, 4);  /* Entry offset */
-    }
-  }
-
-  mj2_stco_decompact(tk);
-
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STCO Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the STSZ box
-*
-* Sample size box
-*
-*/
-void mj2_write_stsz(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STSZ, 4);  /* STSZ       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  if (tk->same_sample_size == 1) {  /* If they all have the same size */
-    cio_write(cio, tk->sample[0].sample_size, 4);  /* Size */
-
-    cio_write(cio, 1, 4);    /* Entry count = 1 */
-  }
-
-  else {
-    cio_write(cio, 0, 4);    /* Sample Size = 0 becase they all have different sizes */
-
-    cio_write(cio, tk->num_samples, 4);  /* Sample Count */
-
-    for (i = 0; i < tk->num_samples; i++) {
-      cio_write(cio, tk->sample[i].sample_size, 4);
-    }
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STSZ box
-*
-* Sample size box
-*
-*/
-int mj2_read_stsz(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int sample_size;
-  unsigned int i;
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);  /* Box Size */
-  if (MJ2_STSZ != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STSZ Marker\n");
-    return 1;
-  }
-
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STSZ box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STSZ box. Expected flag 0\n");
-    return 1;
-  }
-
-  sample_size = cio_read(cio, 4);
-
-  if (sample_size != 0) {  /* Samples do have the same size */
-    tk->same_sample_size = 1;
-    for (i = 0; i < tk->num_samples; i++) {
-      tk->sample[i].sample_size = sample_size;
-    }
-    cio_skip(cio,4);    /* Sample count = 1 */
-  } else {
-    tk->same_sample_size = 0;
-    if (tk->num_samples != cio_read(cio, 4)) {  /* Sample count */
-      opj_event_msg(cio->cinfo, EVT_ERROR,
-        "Error in STSZ box. Expected that sample-count is number of samples in track\n");
-      return 1;
-    }
-    for (i = 0; i < tk->num_samples; i++) {
-      tk->sample[i].sample_size = cio_read(cio, 4);  /* Sample Size */
-    }
-
-    if (cio_tell(cio) - box.init_pos != box.length) {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STSZ Box size\n");
-      return 1;
-    }
-  }
-  return 0;
-
-}
-
-/*
-* Write the STSC box
-*
-* Sample to Chunk
-*
-*/
-void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STSC, 4);  /* STSC       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, tk->num_samplestochunk, 4);  /* Entry Count */
-
-  for (i = 0; i < tk->num_samplestochunk; i++) {
-    cio_write(cio, tk->sampletochunk[i].first_chunk, 4);  /* First Chunk */
-    cio_write(cio, tk->sampletochunk[i].samples_per_chunk, 4);  /* Samples per chunk */
-    cio_write(cio, tk->sampletochunk[i].sample_descr_idx, 4);  /* Samples description index */
-  }
-
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STSC box
-*
-* Sample to Chunk
-*
-*/
-int mj2_read_stsc(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);  /* Box Size */
-  if (MJ2_STSC != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STSC Marker\n");
-    return 1;
-  }
-
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STSC box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STSC box. Expected flag 0\n");
-    return 1;
-  }
-
-  tk->num_samplestochunk = cio_read(cio, 4);
-
-  tk->sampletochunk = (mj2_sampletochunk_t*) opj_malloc(tk->num_samplestochunk * sizeof(mj2_sampletochunk_t));
-
-  for (i = 0; i < tk->num_samplestochunk; i++) {
-    tk->sampletochunk[i].first_chunk = cio_read(cio, 4);
-    tk->sampletochunk[i].samples_per_chunk = cio_read(cio, 4);
-    tk->sampletochunk[i].sample_descr_idx = cio_read(cio, 4);
-  }
-
-  mj2_stsc_decompact(tk);  /* decompact sample to chunk box */
-
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STSC Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the STTS box
-*
-* Time to Sample Box
-*
-*/
-void mj2_write_stts(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  int i;
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STTS, 4);  /* STTS       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, tk->num_tts, 4);  /* entry_count */
-  for (i = 0; i < tk->num_tts; i++) {
-    cio_write(cio, tk->tts[i].sample_count, 4);  /* Sample-count */
-    cio_write(cio, tk->tts[i].sample_delta, 4);  /* Sample-Delta */
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STTS box
-*
-*
-*
-*/
-int mj2_read_stts(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_STTS != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STTS Marker\n");
-    return 1;
-  }
-
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STTS box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STTS box. Expected flag 0\n");
-    return 1;
-  }
-
-  tk->num_tts = cio_read(cio, 4);
-
-  tk->tts = (mj2_tts_t*) opj_malloc(tk->num_tts * sizeof(mj2_tts_t));
-
-  for (i = 0; i < tk->num_tts; i++) {
-    tk->tts[i].sample_count = cio_read(cio, 4);
-    tk->tts[i].sample_delta = cio_read(cio, 4);
-  }
-
-  mj2_tts_decompact(tk);
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STTS Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the FIEL box
-*
-* Field coding Box
-*
-*/
-void mj2_write_fiel(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_FIEL, 4);  /* STTS       */
-
-  cio_write(cio, tk->fieldcount, 1);  /* Field count */
-  cio_write(cio, tk->fieldorder, 1);  /* Field order */
-
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the FIEL box
-*
-* Field coding Box
-*
-*/
-int mj2_read_fiel(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_FIEL != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected FIEL Marker\n");
-    return 1;
-  }
-
-
-  tk->fieldcount = cio_read(cio, 1);
-  tk->fieldorder = cio_read(cio, 1);
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with FIEL Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the ORFO box
-*
-* Original Format Box
-*
-*/
-void mj2_write_orfo(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_ORFO, 4);
-
-  cio_write(cio, tk->or_fieldcount, 1);  /* Original Field count */
-  cio_write(cio, tk->or_fieldorder, 1);  /* Original Field order */
-
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the ORFO box
-*
-* Original Format Box
-*
-*/
-int mj2_read_orfo(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_ORFO != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected ORFO Marker\n");
-    return 1;
-  }
-
-
-  tk->or_fieldcount = cio_read(cio, 1);
-  tk->or_fieldorder = cio_read(cio, 1);
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with ORFO Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the JP2P box
-*
-* MJP2 Profile Box
-*
-*/
-void mj2_write_jp2p(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  int i;
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_JP2P, 4);
-
-  cio_write(cio, 0, 4);    /* Version 0, flags =0 */
-
-  for (i = 0; i < tk->num_br; i++) {
-    cio_write(cio, tk->br[i], 4);
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JP2P box
-*
-* MJP2 Profile Box
-*
-*/
-int mj2_read_jp2p(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JP2P != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JP2P Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in JP2P box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in JP2P box. Expected flag 0\n");
-    return 1;
-  }
-
-
-  tk->num_br = (box.length - 12) / 4;
-  tk->br = (unsigned int*) opj_malloc(tk->num_br * sizeof(unsigned int));
-
-  for (i = 0; i < tk->num_br; i++) {
-    tk->br[i] = cio_read(cio, 4);
-  }
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP2P Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the JP2X box
-*
-* MJP2 Prefix Box
-*
-*/
-void mj2_write_jp2x(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  int i;
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_JP2X, 4);
-
-  for (i = 0; i < tk->num_jp2x; i++) {
-    cio_write(cio, tk->jp2xdata[i], 1);
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JP2X box
-*
-* MJP2 Prefix Box
-*
-*/
-int mj2_read_jp2x(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  unsigned int i;
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JP2X != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JP2X Marker\n");
-    return 1;
-  }
-
-
-  tk->num_jp2x = (box.length - 8);
-  tk->jp2xdata = (unsigned char*) opj_malloc(tk->num_jp2x * sizeof(unsigned char));
-
-  for (i = 0; i < tk->num_jp2x; i++) {
-    tk->jp2xdata[i] = cio_read(cio, 1);
-  }
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JP2X Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the JSUB box
-*
-* MJP2 Subsampling Box
-*
-*/
-void mj2_write_jsub(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_JSUB, 4);
-
-  cio_write(cio, tk->hsub, 1);
-  cio_write(cio, tk->vsub, 1);
-  cio_write(cio, tk->hoff, 1);
-  cio_write(cio, tk->voff, 1);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the JSUB box
-*
-* MJP2 Subsampling Box
-*
-*/
-int mj2_read_jsub(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_JSUB != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected JSUB Marker\n");
-    return 1;
-  }
-
-  tk->hsub = cio_read(cio, 1);
-  tk->vsub = cio_read(cio, 1);
-  tk->hoff = cio_read(cio, 1);;
-  tk->voff = cio_read(cio, 1);
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with JSUB Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the SMJ2 box
-*
-* Visual Sample Entry Description
-*
-*/
-void mj2_write_smj2(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MJ2, 4);  /* MJ2       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, 1, 4);
-
-  cio_write(cio, 0, 2);    /* Pre-defined */
-
-  cio_write(cio, 0, 2);    /* Reserved */
-
-  cio_write(cio, 0, 4);    /* Pre-defined */
-  cio_write(cio, 0, 4);    /* Pre-defined */
-  cio_write(cio, 0, 4);    /* Pre-defined */
-
-  cio_write(cio, tk->w, 2);    /* Width  */
-  cio_write(cio, tk->h, 2);    /* Height */
-
-  cio_write(cio, tk->horizresolution, 4);  /* Horizontal resolution */
-  cio_write(cio, tk->vertresolution, 4);  /* Vertical resolution   */
-
-  cio_write(cio, 0, 4);    /* Reserved */
-
-  cio_write(cio, 1, 2);    /* Pre-defined = 1 */
-
-  cio_write(cio, tk->compressorname[0], 4);  /* Compressor Name */
-  cio_write(cio, tk->compressorname[1], 4);
-  cio_write(cio, tk->compressorname[2], 4);
-  cio_write(cio, tk->compressorname[3], 4);
-  cio_write(cio, tk->compressorname[4], 4);
-  cio_write(cio, tk->compressorname[5], 4);
-  cio_write(cio, tk->compressorname[6], 4);
-  cio_write(cio, tk->compressorname[7], 4);
-
-  cio_write(cio, tk->depth, 2);  /* Depth */
-
-  cio_write(cio, 0xffff, 2);    /* Pre-defined = -1 */
-
-  jp2_write_jp2h(&tk->jp2_struct, cio);
-
-  mj2_write_fiel(tk, cio);
-
-  if (tk->num_br != 0)
-    mj2_write_jp2p(tk, cio);
-  if (tk->num_jp2x != 0)
-    mj2_write_jp2x(tk, cio);
-
-  mj2_write_jsub(tk, cio);
-  mj2_write_orfo(tk, cio);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the SMJ2 box
-*
-* Visual Sample Entry Description
-*
-*/
-int mj2_read_smj2(opj_image_t * img, mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  mj2_box_t box2;
-  int i;
-
-  mj2_read_boxhdr(&box, cio);
-
-  if (MJ2_MJ2 != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error in SMJ2 box: Expected MJ2 Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in MJP2 box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in MJP2 box. Expected flag 0\n");
-    return 1;
-  }
-
-  cio_skip(cio,4);
-
-  cio_skip(cio,2);      /* Pre-defined */
-
-  cio_skip(cio,2);      /* Reserved */
-
-  cio_skip(cio,4);      /* Pre-defined */
-  cio_skip(cio,4);      /* Pre-defined */
-  cio_skip(cio,4);      /* Pre-defined */
-
-  tk->w = cio_read(cio, 2);    /* Width  */
-  tk->h = cio_read(cio, 2);    /* Height */
-
-  tk->horizresolution = cio_read(cio, 4);  /* Horizontal resolution */
-  tk->vertresolution = cio_read(cio, 4);  /* Vertical resolution   */
-
-  cio_skip(cio,4);      /* Reserved */
-
-  cio_skip(cio,2);      /* Pre-defined = 1 */
-
-  tk->compressorname[0] = cio_read(cio, 4);  /* Compressor Name */
-  tk->compressorname[1] = cio_read(cio, 4);
-  tk->compressorname[2] = cio_read(cio, 4);
-  tk->compressorname[3] = cio_read(cio, 4);
-  tk->compressorname[4] = cio_read(cio, 4);
-  tk->compressorname[5] = cio_read(cio, 4);
-  tk->compressorname[6] = cio_read(cio, 4);
-  tk->compressorname[7] = cio_read(cio, 4);
-
-  tk->depth = cio_read(cio, 2);  /* Depth */
-
-  /* Init std value */
-  tk->num_jp2x = 0;
-  tk->fieldcount = 1;
-  tk->fieldorder = 0;
-  tk->or_fieldcount = 1;
-  tk->or_fieldorder = 0;
-
-  cio_skip(cio,2);      /* Pre-defined = -1 */
-
-  if (!jp2_read_jp2h(&tk->jp2_struct, cio)) {
-    opj_event_msg(tk->cinfo, EVT_ERROR, "Error reading JP2H Box\n");
-    return 1;
-  }
-
-  tk->jp2_struct.comps = (opj_jp2_comps_t*) opj_malloc(tk->jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
-  tk->jp2_struct.cl = (int*) opj_malloc(sizeof(int));
-
-  tk->num_br = 0;
-  tk->num_jp2x = 0;
-
-  for (i = 0; cio_tell(cio) - box.init_pos < box.length; i++) {
-    mj2_read_boxhdr(&box2, cio);
-    cio_seek(cio, box2.init_pos);
-    switch (box2.type) {
-    case MJ2_FIEL:
-      if (mj2_read_fiel(tk, cio))
-        return 1;
-      break;
-
-    case MJ2_JP2P:
-      if (mj2_read_jp2p(tk, cio))
-        return 1;
-      break;
-
-    case MJ2_JP2X:
-      if (mj2_read_jp2x(tk, cio))
-        return 1;
-      break;
-
-    case MJ2_JSUB:
-      if (mj2_read_jsub(tk, cio))
-        return 1;
-      break;
-
-    case MJ2_ORFO:
-      if (mj2_read_orfo(tk, cio))
-        return 1;
-      break;
-
-    default:
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MJP2 Box size\n");
-      return 1;
-      break;
-
-    }
-  }
-  return 0;
-}
-
-
-/*
-* Write the STSD box
-*
-* Sample Description
-*
-*/
-void mj2_write_stsd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STSD, 4);  /* STSD       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, 1, 4);    /* entry_count = 1 (considering same JP2 headerboxes) */
-
-  if (tk->track_type == 0) {
-    mj2_write_smj2(tk, cio);
-  } else if (tk->track_type == 1) {
-    // Not implemented
-  }
-  if (tk->track_type == 2) {
-    // Not implemented
-  }
-
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STSD box
-*
-* Sample Description
-*
-*/
-int mj2_read_stsd(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  int i;
-  int entry_count, len_2skip;
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-
-  if (MJ2_STSD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STSD Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in STSD box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in STSD box. Expected flag 0\n");
-    return 1;
-  }
-
-  entry_count = cio_read(cio, 4);
-
-  if (tk->track_type == 0) {
-    for (i = 0; i < entry_count; i++) {
-      if (mj2_read_smj2(img, tk, cio))
-        return 1;
-    }
-  } else if (tk->track_type == 1) {
-    len_2skip = cio_read(cio, 4);  // Not implemented -> skipping box
-    cio_skip(cio,len_2skip - 4);
-  } else if (tk->track_type == 2) {
-    len_2skip = cio_read(cio, 4);  // Not implemented -> skipping box
-    cio_skip(cio,len_2skip - 4);
-  }
-
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STSD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the STBL box
-*
-* Sample table box box
-*
-*/
-void mj2_write_stbl(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_STBL, 4);  /* STBL       */
-
-  mj2_write_stsd(tk, cio);
-  mj2_write_stts(tk, cio);
-  mj2_write_stsc(tk, cio);
-  mj2_write_stsz(tk, cio);
-  mj2_write_stco(tk, cio);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the STBL box
-*
-* Sample table box box
-*
-*/
-int mj2_read_stbl(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_STBL != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected STBL Marker\n");
-    return 1;
-  }
-
-  if (mj2_read_stsd(tk, img, cio))
-    return 1;
-  if (mj2_read_stts(tk, cio))
-    return 1;
-  if (mj2_read_stsc(tk, cio))
-    return 1;
-  if (mj2_read_stsz(tk, cio))
-    return 1;
-  if (mj2_read_stco(tk, cio))
-    return 1;
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with STBL Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the URL box
-*
-* URL box
-*
-*/
-void mj2_write_url(mj2_tk_t * tk, int url_num, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_URL, 4);  /* URL       */
-
-  if (url_num == 0)
-    cio_write(cio, 1, 4);    /* Version = 0, flags = 1 because stored in same file */
-  else {
-    cio_write(cio, 0, 4);    /* Version = 0, flags =  0 */
-    cio_write(cio, tk->url[url_num - 1].location[0], 4);
-    cio_write(cio, tk->url[url_num - 1].location[1], 4);
-    cio_write(cio, tk->url[url_num - 1].location[2], 4);
-    cio_write(cio, tk->url[url_num - 1].location[3], 4);
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the URL box
-*
-* URL box
-*
-*/
-int mj2_read_url(mj2_tk_t * tk, int urn_num, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_URL != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected URL Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in URL box\n");
-    return 1;
-  }
-
-  if (1 != cio_read(cio, 3)) {  /* If flags = 1 --> media data in file */
-    tk->url[urn_num].location[0] = cio_read(cio, 4);
-    tk->url[urn_num].location[1] = cio_read(cio, 4);
-    tk->url[urn_num].location[2] = cio_read(cio, 4);
-    tk->url[urn_num].location[3] = cio_read(cio, 4);
-  } else {
-    tk->num_url--;
-  }
-
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with URL Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the URN box
-*
-* URN box
-*
-*/
-void mj2_write_urn(mj2_tk_t * tk, int urn_num, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_URN, 4);  /* URN       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags =  0 */
-
-  cio_write(cio, tk->urn[urn_num].name[0], 4);
-  cio_write(cio, tk->urn[urn_num].name[1], 4);
-  cio_write(cio, tk->urn[urn_num].name[2], 4);
-  cio_write(cio, tk->urn[urn_num].name[3], 4);
-  cio_write(cio, tk->urn[urn_num].location[0], 4);
-  cio_write(cio, tk->urn[urn_num].location[1], 4);
-  cio_write(cio, tk->urn[urn_num].location[2], 4);
-  cio_write(cio, tk->urn[urn_num].location[3], 4);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the URN box
-*
-* URN box
-*
-*/
-int mj2_read_urn(mj2_tk_t * tk, int urn_num, opj_cio_t *cio)
-{
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_URN != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected URN Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in URN box\n");
-    return 1;
-  }
-
-  if (1 != cio_read(cio, 3)) {  /* If flags = 1 --> media data in file */
-    tk->urn[urn_num].name[0] = cio_read(cio, 4);
-    tk->urn[urn_num].name[1] = cio_read(cio, 4);
-    tk->urn[urn_num].name[2] = cio_read(cio, 4);
-    tk->urn[urn_num].name[3] = cio_read(cio, 4);
-    tk->urn[urn_num].location[0] = cio_read(cio, 4);
-    tk->urn[urn_num].location[1] = cio_read(cio, 4);
-    tk->urn[urn_num].location[2] = cio_read(cio, 4);
-    tk->urn[urn_num].location[3] = cio_read(cio, 4);
-  }
-
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with URN Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-
-/*
-* Write the DREF box
-*
-* Data reference box
-*
-*/
-void mj2_write_dref(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_DREF, 4);  /* DREF       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  if (tk->num_url + tk->num_urn == 0) {  /* Media data in same file */
-    cio_write(cio, 1, 4);    /* entry_count = 1 */
-    mj2_write_url(tk, 0, cio);
-  } else {
-    cio_write(cio, tk->num_url + tk->num_urn, 4);  /* entry_count */
-
-    for (i = 0; i < tk->num_url; i++)
-      mj2_write_url(tk, i + 1, cio);
-
-    for (i = 0; i < tk->num_urn; i++)
-      mj2_write_urn(tk, i, cio);
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the DREF box
-*
-* Data reference box
-*
-*/
-int mj2_read_dref(mj2_tk_t * tk, opj_cio_t *cio)
-{
-
-  int i;
-  int entry_count, marker;
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_DREF != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected DREF Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in DREF box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in DREF box. Expected flag 0\n");
-    return 1;
-  }
-
-  entry_count = cio_read(cio, 4);
-  tk->num_url = 0;
-  tk->num_urn = 0;
-
-  for (i = 0; i < entry_count; i++) {
-    cio_skip(cio,4);
-    marker = cio_read(cio, 4);
-    if (marker == MJ2_URL) {
-      cio_skip(cio,-8);
-      tk->num_url++;
-      if (mj2_read_url(tk, tk->num_url, cio))
-        return 1;
-    } else if (marker == MJ2_URN) {
-      cio_skip(cio,-8);
-      tk->num_urn++;
-      if (mj2_read_urn(tk, tk->num_urn, cio))
-        return 1;
-    } else {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with in DREF box. Expected URN or URL box\n");
-      return 1;
-    }
-
-  }
-
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with DREF Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the DINF box
-*
-* Data information box
-*
-*/
-void mj2_write_dinf(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_DINF, 4);  /* DINF       */
-
-  mj2_write_dref(tk, cio);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the DINF box
-*
-* Data information box
-*
-*/
-int mj2_read_dinf(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_DINF != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected DINF Marker\n");
-    return 1;
-  }
-
-  if (mj2_read_dref(tk, cio))
-    return 1;
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with DINF Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the VMHD box
-*
-* Video Media information box
-*
-*/
-void mj2_write_vmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_VMHD, 4);  /* VMHD       */
-
-  cio_write(cio, 1, 4);    /* Version = 0, flags = 1 */
-
-  cio_write(cio, tk->graphicsmode, 2);
-  cio_write(cio, tk->opcolor[0], 2);
-  cio_write(cio, tk->opcolor[1], 2);
-  cio_write(cio, tk->opcolor[2], 2);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the VMHD box
-*
-* Video Media information box
-*
-*/
-int mj2_read_vmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_VMHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected VMHD Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in VMHD box\n");
-    return 1;
-  }
-
-  if (1 != cio_read(cio, 3)) {  /* Flags = 1  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in VMHD box. Expected flag 1\n");
-    return 1;
-  }
-
-  tk->track_type = 0;
-  tk->graphicsmode = cio_read(cio, 2);
-  tk->opcolor[0] = cio_read(cio, 2);
-  tk->opcolor[1] = cio_read(cio, 2);
-  tk->opcolor[2] = cio_read(cio, 2);
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with VMHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the SMHD box
-*
-* Sound Media information box
-*
-*/
-void mj2_write_smhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_SMHD, 4);  /* SMHD       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, tk->balance, 2);
-
-  cio_write(cio, 0, 2);    /* Reserved */
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the SMHD box
-*
-* Sound Media information box
-*
-*/
-int mj2_read_smhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_SMHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected SMHD Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in SMHD box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in SMHD box. Expected flag 0\n");
-    return 1;
-  }
-
-  tk->track_type = 1;
-  tk->balance = cio_read(cio, 2);
-
-  /* Init variables to zero to avoid problems when freeeing memory
-  The values will possibly be overidded when decoding the track structure */
-  tk->num_br = 0;
-  tk->num_url = 0;
-  tk->num_urn = 0;
-  tk->num_chunks = 0;
-  tk->num_tts = 0;
-  tk->num_samplestochunk = 0;
-  tk->num_samples = 0;
-
-  cio_skip(cio,2);      /* Reserved */
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with SMHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the HMHD box
-*
-* Hint Media information box
-*
-*/
-void mj2_write_hmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_HMHD, 4);  /* HMHD       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, tk->maxPDUsize, 2);
-  cio_write(cio, tk->avgPDUsize, 2);
-  cio_write(cio, tk->maxbitrate, 4);
-  cio_write(cio, tk->avgbitrate, 4);
-  cio_write(cio, tk->slidingavgbitrate, 4);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the HMHD box
-*
-* Hint Media information box
-*
-*/
-int mj2_read_hmhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_HMHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected HMHD Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in HMHD box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in HMHD box. Expected flag 0\n");
-    return 1;
-  }
-
-  tk->track_type = 2;
-  tk->maxPDUsize = cio_read(cio, 2);
-  tk->avgPDUsize = cio_read(cio, 2);
-  tk->maxbitrate = cio_read(cio, 4);
-  tk->avgbitrate = cio_read(cio, 4);
-  tk->slidingavgbitrate = cio_read(cio, 4);
-
-  /* Init variables to zero to avoid problems when freeeing memory
-  The values will possibly be overidded when decoding the track structure */
-  tk->num_br = 0;
-  tk->num_url = 0;
-  tk->num_urn = 0;
-  tk->num_chunks = 0;
-  tk->num_tts = 0;
-  tk->num_samplestochunk = 0;
-  tk->num_samples = 0;
-
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with HMHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MINF box
-*
-* Media information box
-*
-*/
-void mj2_write_minf(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MINF, 4);  /* MINF       */
-
-  if (tk->track_type == 0) {
-    mj2_write_vmhd(tk, cio);
-  } else if (tk->track_type == 1) {
-    mj2_write_smhd(tk, cio);
-  } else if (tk->track_type == 2) {
-    mj2_write_hmhd(tk, cio);
-  }
-
-  mj2_write_dinf(tk, cio);
-  mj2_write_stbl(tk, cio);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MINF box
-*
-* Media information box
-*
-*/
-int mj2_read_minf(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-
-  unsigned int box_type;
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MINF != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MINF Marker\n");
-    return 1;
-  }
-
-  cio_skip(cio,4);
-  box_type = cio_read(cio, 4);
-  cio_skip(cio,-8);
-
-  if (box_type == MJ2_VMHD) {
-    if (mj2_read_vmhd(tk, cio))
-      return 1;
-  } else if (box_type == MJ2_SMHD) {
-    if (mj2_read_smhd(tk, cio))
-      return 1;
-  } else if (box_type == MJ2_HMHD) {
-    if (mj2_read_hmhd(tk, cio))
-      return 1;
-  } else {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error in MINF box expected vmhd, smhd or hmhd\n");
-    return 1;
-  }
-
-  if (mj2_read_dinf(tk, cio))
-    return 1;
-
-  if (mj2_read_stbl(tk, img, cio))
-    return 1;
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MINF Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the HDLR box
-*
-* Handler reference box
-*
-*/
-void mj2_write_hdlr(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_HDLR, 4);  /* HDLR       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, 0, 4);    /* Predefine */
-
-  tk->name = 0;      /* The track name is immediately determined by the track type */
-
-  if (tk->track_type == 0) {
-    tk->handler_type = 0x76696465;  /* Handler type: vide */
-    cio_write(cio, tk->handler_type, 4);
-
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);    /* Reserved */
-
-    cio_write(cio, 0x76696465, 4);
-    cio_write(cio, 0x6F206d65, 4);
-    cio_write(cio, 0x64696120, 4);
-    cio_write(cio, 0x74726163, 4);
-    cio_write(cio, 0x6b00, 2);  /* String: video media track */
-  } else if (tk->track_type == 1) {
-    tk->handler_type = 0x736F756E;  /* Handler type: soun */
-    cio_write(cio, tk->handler_type, 4);
-
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);    /* Reserved */
-
-    cio_write(cio, 0x536F756E, 4);
-    cio_write(cio, 0x6400, 2);  /* String: Sound */
-  } else if (tk->track_type == 2) {
-    tk->handler_type = 0x68696E74;  /* Handler type: hint */
-    cio_write(cio, tk->handler_type, 4);
-
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);
-    cio_write(cio, 0, 4);    /* Reserved */
-
-    cio_write(cio, 0x48696E74, 4);
-    cio_write(cio, 0, 2);    /* String: Hint */
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the HDLR box
-*
-* Handler reference box
-*
-*/
-int mj2_read_hdlr(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_HDLR != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected HDLR Marker\n");
-    return 1;
-  }
-
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in HDLR box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0  */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in HDLR box. Expected flag 0\n");
-    return 1;
-  }
-
-  cio_skip(cio,4);      /* Reserved */
-
-  tk->handler_type = cio_read(cio, 4);
-  cio_skip(cio,12);      /* Reserved */
-
-  tk->name_size = box.length - 32;
-
-  tk->name = (char*) opj_malloc(tk->name_size * sizeof(char));
-  for (i = 0; i < tk->name_size; i++) {
-    tk->name[i] = cio_read(cio, 1);  /* Name */
-  }
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with HDLR Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MDHD box
-*
-* Media Header Box
-*
-*/
-void mj2_write_mdhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-  time_t ltime;
-  unsigned int modification_time;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MDHD, 4);  /* MDHD       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  cio_write(cio, tk->creation_time, 4);  /* Creation Time */
-
-  time(&ltime);      /* Time since 1/1/70 */
-  modification_time = (unsigned int)ltime + 2082844800;  /* Seoonds between 1/1/04 and 1/1/70 */
-
-  cio_write(cio, modification_time, 4);  /* Modification Time */
-
-  cio_write(cio, tk->timescale, 4);  /* Timescale */
-
-  tk->duration = 0;
-
-  for (i = 0; i < tk->num_samples; i++)
-    tk->duration += tk->sample[i].sample_delta;
-
-  cio_write(cio, tk->duration, 4);  /* Duration */
-
-  cio_write(cio, tk->language, 2);  /* Language */
-
-  cio_write(cio, 0, 2);    /* Predefined */
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MDHD box
-*
-* Media Header Box
-*
-*/
-int mj2_read_mdhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (!(MJ2_MHDR == box.type || MJ2_MDHD == box.type)) {  // Kakadu writes MHDR instead of MDHD
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MDHD Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in MDHD box\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 3)) {  /* Flags = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with flag in MDHD box. Expected flag 0\n");
-    return 1;
-  }
-
-
-  tk->creation_time = cio_read(cio, 4);  /* Creation Time */
-
-  tk->modification_time = cio_read(cio, 4);  /* Modification Time */
-
-  tk->timescale = cio_read(cio, 4);  /* Timescale */
-
-  tk->duration = cio_read(cio, 4);  /* Duration */
-
-  tk->language = cio_read(cio, 2);  /* Language */
-
-  cio_skip(cio,2);      /* Predefined */
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MDHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MDIA box
-*
-* Media box
-*
-*/
-void mj2_write_mdia(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MDIA, 4);  /* MDIA       */
-
-  mj2_write_mdhd(tk, cio);
-  mj2_write_hdlr(tk, cio);
-  mj2_write_minf(tk, cio);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MDIA box
-*
-* Media box
-*
-*/
-int mj2_read_mdia(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MDIA != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MDIA Marker\n");
-    return 1;
-  }
-
-  if (mj2_read_mdhd(tk, cio))
-    return 1;
-  if (mj2_read_hdlr(tk, cio))
-    return 1;
-  if (mj2_read_minf(tk, img, cio))
-    return 1;
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MDIA Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the TKHD box
-*
-* Track Header box
-*
-*/
-void mj2_write_tkhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-  unsigned int i;
-  time_t ltime;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-
-  cio_write(cio, MJ2_TKHD, 4);  /* TKHD       */
-
-  cio_write(cio, 3, 4);    /* Version=0, flags=3 */
-
-  time(&ltime);      /* Time since 1/1/70 */
-  tk->modification_time = (unsigned int)ltime + 2082844800;  /* Seoonds between 1/1/04 and 1/1/70 */
-
-  cio_write(cio, tk->creation_time, 4);  /* Creation Time */
-
-  cio_write(cio, tk->modification_time, 4);  /* Modification Time */
-
-  cio_write(cio, tk->track_ID, 4);  /* Track ID */
-
-  cio_write(cio, 0, 4);    /* Reserved */
-
-  tk->duration = 0;
-
-  for (i = 0; i < tk->num_samples; i++)
-    tk->duration += tk->sample[i].sample_delta;
-
-  cio_write(cio, tk->duration, 4);  /* Duration */
-
-  cio_write(cio, 0, 4);    /* Reserved */
-  cio_write(cio, 0, 4);    /* Reserved */
-
-  cio_write(cio, tk->layer, 2);  /* Layer    */
-
-  cio_write(cio, 0, 2);    /* Predefined */
-
-  cio_write(cio, tk->volume, 2);  /* Volume       */
-
-  cio_write(cio, 0, 2);    /* Reserved */
-
-  cio_write(cio, tk->trans_matrix[0], 4);  /* Transformation matrix for track */
-  cio_write(cio, tk->trans_matrix[1], 4);
-  cio_write(cio, tk->trans_matrix[2], 4);
-  cio_write(cio, tk->trans_matrix[3], 4);
-  cio_write(cio, tk->trans_matrix[4], 4);
-  cio_write(cio, tk->trans_matrix[5], 4);
-  cio_write(cio, tk->trans_matrix[6], 4);
-  cio_write(cio, tk->trans_matrix[7], 4);
-  cio_write(cio, tk->trans_matrix[8], 4);
-
-  cio_write(cio, tk->visual_w, 4);  /* Video Visual Width  */
-
-  cio_write(cio, tk->visual_h, 4);  /* Video Visual Height */
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the TKHD box
-*
-* Track Header box
-*
-*/
-int mj2_read_tkhd(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  int flag;
-
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-
-  if (MJ2_TKHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected TKHD Marker\n");
-    return 1;
-  }
-
-  if (0 != cio_read(cio, 1)) {  /* Version = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in TKHD box\n");
-    return 1;
-  }
-
-  flag = cio_read(cio, 3);
-
-  if (!(flag == 1 || flag == 2 || flag == 3 || flag == 4)) {  /* Flags = 1,2,3 or 4 */
-    opj_event_msg(cio->cinfo, EVT_ERROR,
-      "Error with flag in TKHD box: Expected flag 1,2,3 or 4\n");
-    return 1;
-  }
-
-  tk->creation_time = cio_read(cio, 4);  /* Creation Time */
-
-  tk->modification_time = cio_read(cio, 4);  /* Modification Time */
-
-  tk->track_ID = cio_read(cio, 4);  /* Track ID */
-
-  cio_skip(cio,4);      /* Reserved */
-
-  tk->duration = cio_read(cio, 4);  /* Duration */
-
-  cio_skip(cio,8);      /* Reserved */
-
-  tk->layer = cio_read(cio, 2);  /* Layer    */
-
-  cio_read(cio, 2);      /* Predefined */
-
-  tk->volume = cio_read(cio, 2);  /* Volume       */
-
-  cio_skip(cio,2);      /* Reserved */
-
-  tk->trans_matrix[0] = cio_read(cio, 4);  /* Transformation matrix for track */
-  tk->trans_matrix[1] = cio_read(cio, 4);
-  tk->trans_matrix[2] = cio_read(cio, 4);
-  tk->trans_matrix[3] = cio_read(cio, 4);
-  tk->trans_matrix[4] = cio_read(cio, 4);
-  tk->trans_matrix[5] = cio_read(cio, 4);
-  tk->trans_matrix[6] = cio_read(cio, 4);
-  tk->trans_matrix[7] = cio_read(cio, 4);
-  tk->trans_matrix[8] = cio_read(cio, 4);
-
-  tk->visual_w = cio_read(cio, 4);  /* Video Visual Width  */
-
-  tk->visual_h = cio_read(cio, 4);  /* Video Visual Height */
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with TKHD Box size\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the TRAK box
-*
-* Track box
-*
-*/
-void mj2_write_trak(mj2_tk_t * tk, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-
-  cio_write(cio, MJ2_TRAK, 4);  /* TRAK       */
-
-  mj2_write_tkhd(tk, cio);
-  mj2_write_mdia(tk, cio);
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the TRAK box
-*
-* Track box
-*
-*/
-int mj2_read_trak(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_TRAK != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected TRAK Marker\n");
-    return 1;
-  }
-  if (mj2_read_tkhd(tk, cio))
-    return 1;
-  if (mj2_read_mdia(tk, img, cio))
-    return 1;
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with TRAK Box\n");
-    return 1;
-  }
-  return 0;
-}
-
-/*
-* Write the MVHD box
-*
-* Movie header Box
-*
-*/
-void mj2_write_mvhd(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-  unsigned j;
-  time_t ltime;
-  int max_tk_num = 0;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MVHD, 4);  /* MVHD       */
-
-  cio_write(cio, 0, 4);    /* Version = 0, flags = 0 */
-
-  time(&ltime);      /* Time since 1/1/70 */
-  movie->modification_time = (unsigned int)ltime + 2082844800;  /* Seoonds between 1/1/04 and 1/1/70 */
-
-  cio_write(cio, movie->creation_time, 4);  /* Creation Time */
-
-  cio_write(cio, movie->modification_time, 4);  /* Modification Time */
-
-  cio_write(cio, movie->timescale, 4);  /* Timescale */
-
-  movie->duration = 0;
-
-  for (i = 0; i < (movie->num_stk + movie->num_htk + movie->num_vtk); i++) {
-    mj2_tk_t *tk = &movie->tk[i];
-
-    for (j = 0; j < tk->num_samples; j++) {
-      movie->duration += tk->sample[j].sample_delta;
-    }
-  }
-
-  cio_write(cio, movie->duration, 4);
-
-  cio_write(cio, movie->rate, 4);  /* Rate to play presentation    */
-
-  cio_write(cio, movie->volume, 2);  /* Volume       */
-
-  cio_write(cio, 0, 2);    /* Reserved */
-  cio_write(cio, 0, 4);    /* Reserved */
-  cio_write(cio, 0, 4);    /* Reserved */
-
-  cio_write(cio, movie->trans_matrix[0], 4);  /* Transformation matrix for video */
-  cio_write(cio, movie->trans_matrix[1], 4);
-  cio_write(cio, movie->trans_matrix[2], 4);
-  cio_write(cio, movie->trans_matrix[3], 4);
-  cio_write(cio, movie->trans_matrix[4], 4);
-  cio_write(cio, movie->trans_matrix[5], 4);
-  cio_write(cio, movie->trans_matrix[6], 4);
-  cio_write(cio, movie->trans_matrix[7], 4);
-  cio_write(cio, movie->trans_matrix[8], 4);
-
-  cio_write(cio, 0, 4);    /* Pre-defined */
-  cio_write(cio, 0, 4);    /* Pre-defined */
-  cio_write(cio, 0, 4);    /* Pre-defined */
-  cio_write(cio, 0, 4);    /* Pre-defined */
-  cio_write(cio, 0, 4);    /* Pre-defined */
-  cio_write(cio, 0, 4);    /* Pre-defined */
-
-
-  for (i = 0; i < movie->num_htk + movie->num_stk + movie->num_vtk; i++) {
-    if (max_tk_num < movie->tk[i].track_ID)
-      max_tk_num = movie->tk[i].track_ID;
-  }
-
-  movie->next_tk_id = max_tk_num + 1;
-
-  cio_write(cio, movie->next_tk_id, 4);  /* ID of Next track to be added */
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MVHD box
-*
-* Movie header Box
-*
-*/
-int mj2_read_mvhd(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  mj2_box_t box;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MVHD != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MVHD Marker\n");
-    return 1;
-  }
-
-
-  if (0 != cio_read(cio, 4)) {  /* Version = 0, flags = 0 */
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Only Version 0 handled in MVHD box\n");
-  }
-
-  movie->creation_time = cio_read(cio, 4);  /* Creation Time */
-
-  movie->modification_time = cio_read(cio, 4);  /* Modification Time */
-
-  movie->timescale = cio_read(cio, 4);  /* Timescale */
-
-  movie->duration = cio_read(cio, 4);  /* Duration */
-
-  movie->rate = cio_read(cio, 4);    /* Rate to play presentation    */
-
-  movie->volume = cio_read(cio, 2);    /* Volume       */
-
-  cio_skip(cio,10);        /* Reserved */
-
-  movie->trans_matrix[0] = cio_read(cio, 4);  /* Transformation matrix for video */
-  movie->trans_matrix[1] = cio_read(cio, 4);
-  movie->trans_matrix[2] = cio_read(cio, 4);
-  movie->trans_matrix[3] = cio_read(cio, 4);
-  movie->trans_matrix[4] = cio_read(cio, 4);
-  movie->trans_matrix[5] = cio_read(cio, 4);
-  movie->trans_matrix[6] = cio_read(cio, 4);
-  movie->trans_matrix[7] = cio_read(cio, 4);
-  movie->trans_matrix[8] = cio_read(cio, 4);
-
-  cio_skip(cio,24);      /* Pre-defined */
-
-  movie->next_tk_id = cio_read(cio, 4);  /* ID of Next track to be added */
-
-  if (cio_tell(cio) - box.init_pos != box.length) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MVHD Box Size\n");
-    return 1;
-  }
-  return 0;
-}
-
-
-/*
-* Write the MOOV box
-*
-* Movie Box
-*
-*/
-void mj2_write_moov(opj_mj2_t * movie, opj_cio_t *cio)
-{
-  int i;
-  mj2_box_t box;
-
-  box.init_pos = cio_tell(cio);
-  cio_skip(cio,4);
-  cio_write(cio, MJ2_MOOV, 4);  /* MOOV       */
-
-  mj2_write_mvhd(movie, cio);
-
-  for (i = 0; i < (movie->num_stk + movie->num_htk + movie->num_vtk); i++) {
-    mj2_write_trak(&movie->tk[i], cio);
-  }
-
-  box.length = cio_tell(cio) - box.init_pos;
-  cio_seek(cio, box.init_pos);
-  cio_write(cio, box.length, 4);  /* L          */
-  cio_seek(cio, box.init_pos + box.length);
-}
-
-/*
-* Read the MOOV box
-*
-* Movie Box
-*
-*/
-int mj2_read_moov(opj_mj2_t * movie, opj_image_t * img, opj_cio_t *cio)
-{
-  unsigned int i;
-  mj2_box_t box;
-  mj2_box_t box2;
-
-  mj2_read_boxhdr(&box, cio);
-  if (MJ2_MOOV != box.type) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MOOV Marker\n");
-    return 1;
-  }
-
-  if (mj2_read_mvhd(movie, cio))
-    return 1;
-
-  movie->tk = (mj2_tk_t*) opj_malloc((movie->next_tk_id - 1) * sizeof(mj2_tk_t));
-
-  for (i = 0; cio_tell(cio) - box.init_pos < box.length; i++) {
-    mj2_tk_t *tk = &movie->tk[i];
-    tk->cinfo = movie->cinfo;
-    mj2_read_boxhdr(&box2, cio);
-    if (box2.type == MJ2_TRAK) {
-      cio_seek(cio, box2.init_pos);
-      if (mj2_read_trak(tk, img, cio))
-        return 1;
-
-      if (tk->track_type == 0) {
-        movie->num_vtk++;
-      } else if (tk->track_type == 1) {
-        movie->num_stk++;
-      } else if (tk->track_type == 2) {
-        movie->num_htk++;
-      }
-    } else if (box2.type == MJ2_MVEX) {
-      cio_seek(cio, box2.init_pos);
-      cio_skip(cio,box2.length);
-      i--;
-    } else {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Error with MOOV Box: Expected TRAK or MVEX box\n");
-      return 1;
-    }
-  }
-  return 0;
-}
-
-int mj2_read_struct(FILE *file, opj_mj2_t *movie) {
-  mj2_box_t box;
-  opj_image_t img;
-  char * src;
-  int fsresult;
-  int foffset;
-  opj_cio_t *cio;
-
-  /* open a byte stream for reading */
-  src = (char*) opj_malloc(300 * sizeof(char));
-
-  /* Assuming that jp and ftyp markers size do
-     not exceed 300 bytes */
-  fread(src,300,1, file);
-
-  cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, 300);
-
-  if (mj2_read_jp(cio))
-    return 1;
-  if (mj2_read_ftyp(movie, cio))
-    return 1;
-
-  fsresult = fseek(file,cio_tell(cio),SEEK_SET);
-  if( fsresult ) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read data after FTYP box\n" );
-    return 1;
-  }
-
-  foffset = cio_tell(cio);
-
-  box.type = 0;
-
-  fread(src,30,1,file);
-  cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, 300);
-  mj2_read_boxhdr(&box, cio);
-
-  while(box.type != MJ2_MOOV) {
-
-    switch(box.type)
-    {
-    case MJ2_MDAT:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-        opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MDAT box\n" );
-        return 1;
-      }
-      foffset += box.length;
-      break;
-
-    case MJ2_MOOF:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-        opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MOOF box\n" );
-        return 1;
-      }
-      foffset += box.length;
-      break;
-    case MJ2_FREE:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-        opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read FREE box\n" );
-        return 1;
-      }
-      foffset += box.length;
-      break;
-    case MJ2_SKIP:
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-        opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read SKIP box\n" );
-        return 1;
-      }
-      foffset += box.length;
-      break;
-    default:
-      opj_event_msg(cio->cinfo, EVT_ERROR, "Unknown box in MJ2 stream\n");
-      fsresult = fseek(file,foffset+box.length,SEEK_SET);
-      if( fsresult ) {
-        opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read end of unknown box\n");
-        return 1;
-      }
-      foffset += box.length;
-      break;
-    }
-    fsresult = fread(src,8,1,file);
-    if (fsresult != 1) {
-      opj_event_msg(cio->cinfo, EVT_ERROR, "MOOV box not found in file\n");
-      return 1;
-    }
-    cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, 8);
-    mj2_read_boxhdr(&box, cio);
-  }
-
-  fseek(file,foffset,SEEK_SET);
-  src = opj_realloc(src,box.length);
-  fsresult = fread(src,box.length,1,file);
-  if (fsresult != 1) {
-    opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MOOV box\n");
-    return 1;
-  }
-
-  cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, box.length);
-
-  if (mj2_read_moov(movie, &img, cio))
-    return 1;
-
-  opj_free(src);
-  return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-/* MJ2 decoder interface                                                   */
-/* ----------------------------------------------------------------------- */
-
-opj_dinfo_t* mj2_create_decompress() {
-  opj_mj2_t* mj2;
-  opj_dinfo_t *dinfo = (opj_dinfo_t*) opj_calloc(1, sizeof(opj_dinfo_t));
-  if(!dinfo) return NULL;
-
-  dinfo->is_decompressor = true;
-
-  mj2 = (opj_mj2_t*) opj_calloc(1, sizeof(opj_mj2_t));
-  dinfo->mj2_handle = mj2;
-  if(mj2) {
-    mj2->cinfo = (opj_common_ptr)dinfo;
-  }
-  mj2->j2k = j2k_create_decompress((opj_common_ptr)dinfo);
-  dinfo->j2k_handle = mj2->j2k;
-
-  return dinfo;
-}
-
-void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters) {
-  movie->num_vtk=0;
-  movie->num_stk=0;
-  movie->num_htk=0;
-
-  /* setup the J2K decoder parameters */
-  j2k_setup_decoder(movie->cinfo->j2k_handle, &mj2_parameters->j2k_parameters);
-
-}
-
-void mj2_destroy_decompress(opj_mj2_t *movie) {
-  if(movie) {
-    int i;
-    mj2_tk_t *tk=NULL;
-
-    if (movie->cinfo->j2k_handle)
-      j2k_destroy_compress(movie->j2k);
-
-    if (movie->num_cl != 0)
-      opj_free(movie->cl);
-
-    for (i = 0; i < movie->num_vtk + movie->num_stk + movie->num_htk; i++) {
-      tk = &movie->tk[i];
-      if (tk->name_size != 0)
-        opj_free(tk->name);
-      if (tk->track_type == 0)  {// Video track
-        if (tk->jp2_struct.comps != 0)
-          opj_free(tk->jp2_struct.comps);
-        if (tk->jp2_struct.cl != 0)
-          opj_free(tk->jp2_struct.cl);
-        if (tk->num_jp2x != 0)
-          opj_free(tk->jp2xdata);
-
-      }
-      if (tk->num_url != 0)
-        opj_free(tk->url);
-      if (tk->num_urn != 0)
-        opj_free(tk->urn);
-      if (tk->num_br != 0)
-        opj_free(tk->br);
-      if (tk->num_tts != 0)
-        opj_free(tk->tts);
-      if (tk->num_chunks != 0)
-        opj_free(tk->chunk);
-      if (tk->num_samplestochunk != 0)
-        opj_free(tk->sampletochunk);
-      if (tk->num_samples != 0)
-        opj_free(tk->sample);
-    }
-
-    opj_free(movie->tk);
-  }
-  opj_free(movie);
-}
-
-/* ----------------------------------------------------------------------- */
-/* MJ2 encoder interface                                                   */
-/* ----------------------------------------------------------------------- */
-
-
-opj_cinfo_t* mj2_create_compress() {
-  opj_mj2_t* mj2;
-  opj_cinfo_t *cinfo = (opj_cinfo_t*) opj_calloc(1, sizeof(opj_cinfo_t));
-  if(!cinfo) return NULL;
-
-  mj2 = (opj_mj2_t*) opj_calloc(1, sizeof(opj_mj2_t));
-  cinfo->mj2_handle = mj2;
-  if(mj2) {
-    mj2->cinfo = (opj_common_ptr)cinfo;
-  }
-
-  mj2->j2k = j2k_create_compress(mj2->cinfo);
-  cinfo->j2k_handle = mj2->j2k;
-
-  return cinfo;
-}
-
-void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
-  if(movie && parameters) {
-    opj_jp2_t *jp2_struct;
-
-    movie->num_htk = 0;    // No hint tracks
-    movie->num_stk = 0;    // No sound tracks
-    movie->num_vtk = 1;    // One video track
-
-    movie->brand = MJ2_MJ2;  // One brand: MJ2
-    movie->num_cl = 2;    // Two compatible brands: MJ2 and MJ2S
-    movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
-    movie->cl[0] = MJ2_MJ2;
-    movie->cl[1] = MJ2_MJ2S;
-    movie->minversion = 0;    // Minimum version: 0
-
-    movie->tk = (mj2_tk_t*) opj_malloc(sizeof(mj2_tk_t)); //Memory allocation for the video track
-    movie->tk[0].track_ID = 1;    // Track ID = 1
-    movie->tk[0].track_type = 0;    // Video track
-    movie->tk[0].Dim[0] = parameters->Dim[0];
-    movie->tk[0].Dim[1] = parameters->Dim[1];
-    movie->tk[0].w = parameters->w;
-    movie->tk[0].h = parameters->h;
-    movie->tk[0].CbCr_subsampling_dx = parameters->CbCr_subsampling_dx;
-    movie->tk[0].CbCr_subsampling_dy = parameters->CbCr_subsampling_dy;
-    movie->tk[0].sample_rate = parameters->frame_rate;
-    movie->tk[0].name_size = 0;
-    movie->tk[0].chunk = (mj2_chunk_t*) opj_malloc(sizeof(mj2_chunk_t));
-    movie->tk[0].sample = (mj2_sample_t*) opj_malloc(sizeof(mj2_sample_t));
-
-    jp2_struct = &movie->tk[0].jp2_struct;
-    jp2_struct->numcomps = 3;  // NC
-    jp2_struct->comps = (opj_jp2_comps_t*) opj_malloc(jp2_struct->numcomps * sizeof(opj_jp2_comps_t));
-    jp2_struct->precedence = 0;   /* PRECEDENCE*/
-    jp2_struct->approx = 0;   /* APPROX*/
-    jp2_struct->brand = JP2_JP2;  /* BR         */
-    jp2_struct->minversion = 0;  /* MinV       */
-    jp2_struct->numcl = 1;
-    jp2_struct->cl = (unsigned int*) opj_malloc(jp2_struct->numcl * sizeof(int));
-    jp2_struct->cl[0] = JP2_JP2;  /* CL0 : JP2  */
-    jp2_struct->C = 7;      /* C : Always 7*/
-    jp2_struct->UnkC = 0;      /* UnkC, colorspace specified in colr box*/
-    jp2_struct->IPR = 0;      /* IPR, no intellectual property*/
-    jp2_struct->w = parameters->w;
-    jp2_struct->h = parameters->h;
-    jp2_struct->bpc = 7;
-    jp2_struct->meth = 1;
-    jp2_struct->enumcs = 18;  // YUV
-  }
-}
-
-void mj2_destroy_compress(opj_mj2_t *movie) {
-  if(movie) {
-    int i;
-    mj2_tk_t *tk=NULL;
-
-    if (movie->cinfo->j2k_handle) {
-      j2k_destroy_compress(movie->j2k);
-    }
-
-    if (movie->num_cl != 0)
-      opj_free(movie->cl);
-
-    for (i = 0; i < movie->num_vtk + movie->num_stk + movie->num_htk; i++) {
-      tk = &movie->tk[i];
-      if (tk->name_size != 0)
-        opj_free(tk->name);
-      if (tk->track_type == 0)  {// Video track
-        if (tk->jp2_struct.comps != 0)
-          opj_free(tk->jp2_struct.comps);
-        if (tk->jp2_struct.cl != 0)
-          opj_free(tk->jp2_struct.cl);
-        if (tk->num_jp2x != 0)
-          opj_free(tk->jp2xdata);
-
-      }
-      if (tk->num_url != 0)
-        opj_free(tk->url);
-      if (tk->num_urn != 0)
-        opj_free(tk->urn);
-      if (tk->num_br != 0)
-        opj_free(tk->br);
-      if (tk->num_tts != 0)
-        opj_free(tk->tts);
-      if (tk->num_chunks != 0)
-        opj_free(tk->chunk);
-      if (tk->num_samplestochunk != 0)
-        opj_free(tk->sampletochunk);
-      if (tk->num_samples != 0)
-        opj_free(tk->sample);
-    }
-
-    opj_free(movie->tk);
-  }
-  opj_free(movie);
-}
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2.h b/Utilities/gdcmopenjpeg-v2/mj2/mj2.h
deleted file mode 100644
index 2903c7a..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2.h
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2003-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MJ2_H
-#define __MJ2_H
-/**
- at file mj2.h
- at brief The Motion JPEG 2000 file format Reader/Writer (MJ22)
-
-*/
-
-/** @defgroup MJ2 MJ2 - Motion JPEG 2000 file format reader/writer */
-/*@{*/
-
-#define MJ2_JP    0x6a502020
-#define MJ2_FTYP  0x66747970
-#define MJ2_MJ2   0x6d6a7032
-#define MJ2_MJ2S  0x6d6a3273
-#define MJ2_MDAT  0x6d646174
-#define MJ2_MOOV  0x6d6f6f76
-#define MJ2_MVHD  0x6d766864
-#define MJ2_TRAK  0x7472616b
-#define MJ2_TKHD  0x746b6864
-#define MJ2_MDIA  0x6d646961
-#define MJ2_MDHD  0x6d646864
-#define MJ2_MHDR  0x6d686472
-#define MJ2_HDLR  0x68646C72
-#define MJ2_MINF  0x6d696e66
-#define MJ2_VMHD  0x766d6864
-#define MJ2_SMHD  0x736d6864
-#define MJ2_HMHD  0x686d6864
-#define MJ2_DINF  0x64696e66
-#define MJ2_DREF  0x64726566
-#define MJ2_URL   0x75726c20
-#define MJ2_URN   0x75726e20
-#define MJ2_STBL  0x7374626c
-#define MJ2_STSD  0x73747364
-#define MJ2_STTS  0x73747473
-#define MJ2_STSC  0x73747363
-#define MJ2_STSZ  0x7374737a
-#define MJ2_STCO  0x7374636f
-#define MJ2_MOOF  0x6d6f6f66
-#define MJ2_FREE  0x66726565
-#define MJ2_SKIP  0x736b6970
-#define MJ2_JP2C  0x6a703263
-#define MJ2_FIEL  0x6669656c
-#define MJ2_JP2P  0x6a703270
-#define MJ2_JP2X  0x6a703278
-#define MJ2_JSUB  0x6a737562
-#define MJ2_ORFO  0x6f72666f
-#define MJ2_MVEX  0x6d766578
-#define MJ2_JP2   0x6a703220
-#define MJ2_J2P0  0x4a325030
-
-/**
-Decompressed format used in parameters
-YUV = 0
-*/
-#define YUV_DFMT 1
-
-/**
-Compressed format used in parameters
-MJ2 = 0
-*/
-#define MJ2_CFMT 2
-
-
-/* ----------------------------------------------------------------------- */
-
-/**
-Time To Sample
-*/
-typedef struct mj2_tts {
-  int sample_count;
-  int sample_delta;
-} mj2_tts_t;
-
-/**
-Chunk
-*/
-typedef struct mj2_chunk {
-  int num_samples;
-  int sample_descr_idx;
-  int offset;
-} mj2_chunk_t;
-
-/**
-Sample to chunk
-*/
-typedef struct mj2_sampletochunk {
-  int first_chunk;
-  int samples_per_chunk;
-  int sample_descr_idx;
-} mj2_sampletochunk_t;
-
-/**
-Sample
-*/
-typedef struct mj2_sample {
-  unsigned int sample_size;
-  unsigned int offset;
-  unsigned int sample_delta;
-} mj2_sample_t;
-
-/**
-URL
-*/
-typedef struct mj2_url {
-  int location[4];
-} mj2_url_t;
-
-/**
-URN
-*/
-typedef struct mj2_urn {
-  int name[2];
-  int location[4];
-} mj2_urn_t;
-
-/**
-Video Track Parameters
-*/
-typedef struct mj2_tk {
-  /** codec context */
-  opj_common_ptr cinfo;
-  int track_ID;
-  int track_type;
-  unsigned int creation_time;
-  unsigned int modification_time;
-  int duration;
-  int timescale;
-  int layer;
-  int volume;
-  int language;
-  int balance;
-  int maxPDUsize;
-  int avgPDUsize;
-  int maxbitrate;
-  int avgbitrate;
-  int slidingavgbitrate;
-  int graphicsmode;
-  int opcolor[3];
-  int num_url;
-  mj2_url_t *url;
-  int num_urn;
-  mj2_urn_t *urn;
-  int Dim[2];
-  int w;
-  int h;
-  int visual_w;
-  int visual_h;
-  int CbCr_subsampling_dx;
-  int CbCr_subsampling_dy;
-  int sample_rate;
-  int sample_description;
-  int horizresolution;
-  int vertresolution;
-  int compressorname[8];
-  int depth;
-  unsigned char fieldcount;
-  unsigned char fieldorder;
-  unsigned char or_fieldcount;
-  unsigned char or_fieldorder;
-  int num_br;
-  unsigned int *br;
-  unsigned char num_jp2x;
-  unsigned char *jp2xdata;
-  unsigned char hsub;
-  unsigned char vsub;
-  unsigned char hoff;
-  unsigned char voff;
-  int trans_matrix[9];
-  /** Number of samples */
-  unsigned int num_samples;
-  int transorm;
-  int handler_type;
-  int name_size;
-  unsigned char same_sample_size;
-  int num_tts;
-  /** Time to sample    */
-  mj2_tts_t *tts;
-  unsigned int num_chunks;
-  mj2_chunk_t *chunk;
-  int num_samplestochunk;
-  mj2_sampletochunk_t *sampletochunk;
-  char *name;
-  opj_jp2_t jp2_struct;
-  /** Sample parameters */
-  mj2_sample_t *sample;
-} mj2_tk_t;
-
-/**
-MJ2 box
-*/
-typedef struct mj2_box {
-  int length;
-  int type;
-  int init_pos;
-} mj2_box_t;
-
-/**
-MJ2 Movie
-*/
-typedef struct opj_mj2 {
-  /** codec context */
-  opj_common_ptr cinfo;
-  /** handle to the J2K codec  */
-  opj_j2k_t *j2k;
-  unsigned int brand;
-  unsigned int minversion;
-  int num_cl;
-  unsigned int *cl;
-  unsigned int creation_time;
-  unsigned int modification_time;
-  int timescale;
-  unsigned int duration;
-  int rate;
-  int num_vtk;
-  int num_stk;
-  int num_htk;
-  int volume;
-  int trans_matrix[9];
-  int next_tk_id;
-  /** Track Parameters  */
-  mj2_tk_t *tk;
-} opj_mj2_t;
-
-/**
-Decompression parameters
-*/
-typedef struct mj2_dparameters {
-  /**@name command line encoder parameters (not used inside the library) */
-  /*@{*/
-  /** input file name */
-  char infile[OPJ_PATH_LEN];
-  /** output file name */
-  char outfile[OPJ_PATH_LEN];
-  /** J2K decompression parameters */
-  opj_dparameters_t j2k_parameters;
-} mj2_dparameters_t;
-
-/**
-Compression parameters
-*/
-typedef struct mj2_cparameters {
-  /**@name command line encoder parameters (not used inside the library) */
-  /*@{*/
-  /** J2K compression parameters */
-  opj_cparameters_t j2k_parameters;
-  /** input file name */
-  char infile[OPJ_PATH_LEN];
-  /** output file name */
-  char outfile[OPJ_PATH_LEN];
-  /** input file format 0:MJ2 */
-  int decod_format;
-  /** output file format 0:YUV */
-  int cod_format;
-  /** Portion of the image coded */
-  int Dim[2];
-  /** YUV Frame width */
-  int w;
-  /** YUV Frame height */
-  int h;
-  /*   Sample rate of YUV 4:4:4, 4:2:2 or 4:2:0 */
-  int CbCr_subsampling_dx;
-  /*   Sample rate of YUV 4:4:4, 4:2:2 or 4:2:0 */
-  int CbCr_subsampling_dy;
-  /*   Video Frame Rate  */
-  int frame_rate;
-  /*   In YUV files, numcomps always considered as 3 */
-  int numcomps;
-  /*   In YUV files, precision always considered as 8 */
-  int prec;
-} mj2_cparameters_t;
-
-
-/** @name Exported functions */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-/**
-Write the JP box
-*/
-void mj2_write_jp(opj_cio_t *cio);
-/**
-Write the FTYP box
- at param movie MJ2 movie
- at param cio Output buffer stream
-*/
-void mj2_write_ftyp(opj_mj2_t *movie, opj_cio_t *cio);
-/**
-Creates an MJ2 decompression structure
- at return Returns a handle to a MJ2 decompressor if successful, returns NULL otherwise
-*/
-opj_dinfo_t* mj2_create_decompress();
-/**
-Destroy a MJ2 decompressor handle
- at param movie MJ2 decompressor handle to destroy
-*/
-void mj2_destroy_decompress(opj_mj2_t *movie);
-/**
-Setup the decoder decoding parameters using user parameters.
-Decoding parameters are returned in mj2->j2k->cp.
- at param movie MJ2 decompressor handle
- at param parameters decompression parameters
-*/
-void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters);
-/**
-Decode an image from a JPEG-2000 file stream
- at param movie MJ2 decompressor handle
- at param cio Input buffer stream
- at return Returns a decoded image if successful, returns NULL otherwise
-*/
-opj_image_t* mj2_decode(opj_mj2_t *movie, opj_cio_t *cio);
-/**
-Creates a MJ2 compression structure
- at return Returns a handle to a MJ2 compressor if successful, returns NULL otherwise
-*/
-opj_cinfo_t* mj2_create_compress();
-/**
-Destroy a MJ2 compressor handle
- at param movie MJ2 compressor handle to destroy
-*/
-void mj2_destroy_compress(opj_mj2_t *movie);
-/**
-Setup the encoder parameters using the current image and using user parameters.
-Coding parameters are returned in mj2->j2k->cp.
- at param movie MJ2 compressor handle
- at param parameters compression parameters
-*/
-void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters);
-/**
-Encode an image into a JPEG-2000 file stream
- at param movie MJ2 compressor handle
- at param cio Output buffer stream
- at param image Image to encode
- at param index Name of the index file if required, NULL otherwise
- at return Returns true if successful, returns false otherwise
-*/
-bool mj2_encode(opj_mj2_t *movie, opj_cio_t *cio, opj_image_t *image, char *index);
-
-/**
-Init a Standard MJ2 movie
- at param movie MJ2 Movie
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int mj2_init_stdmovie(opj_mj2_t *movie);
-/**
-Read the structure of an MJ2 file
- at param File MJ2 input File
- at param movie J2 movie structure
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int mj2_read_struct(FILE *file, opj_mj2_t *mj2);
-/**
-Write the the MOOV box to an output buffer stream
- at param movie MJ2 movie structure
- at param cio Output buffer stream
-*/
-void mj2_write_moov(opj_mj2_t *movie, opj_cio_t *cio);
-
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __MJ2_H */
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.c b/Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.c
deleted file mode 100644
index 6b2b65a..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
-* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
-* Copyright (c) 2002-2007, Professor Benoit Macq
-* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "opj_includes.h"
-#include "mj2.h"
-
-/*  -----------------------        */
-/*              */
-/*              */
-/*  Count the number of frames        */
-/*  in a YUV file          */
-/*              */
-/*  -----------------------        */
-
-int yuv_num_frames(mj2_tk_t * tk, char *infile)
-{
-  int numimages, frame_size;
-  long end_of_f;
-  FILE *f;
-
-  f = fopen(infile,"rb");
-  if (!f) {
-    fprintf(stderr, "failed to open %s for reading\n",infile);
-    return -1;
-  }
-
-  frame_size = (int) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy)));  /* Calculate frame size */
-
-  fseek(f, 0, SEEK_END);
-  end_of_f = ftell(f);    /* Calculate file size */
-
-  if (end_of_f < frame_size) {
-    fprintf(stderr,
-      "YUV does not contains any frame of %d x %d size\n", tk->w,
-      tk->h);
-    return -1;
-  }
-
-  numimages = end_of_f / frame_size;  /* Calculate number of images */
-  fclose(f);
-
-  return numimages;
-}
-
-//  -----------------------
-//
-//
-//  YUV to IMAGE
-//
-//  -----------------------
-
-opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
-{
-  opj_image_cmptparm_t cmptparm[3];
-  opj_image_t * img;
-  int i;
-  int numcomps = 3;
-  int subsampling_dx = parameters->subsampling_dx;
-  int subsampling_dy = parameters->subsampling_dy;
-
-  /* initialize image components */
-  memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
-  for(i = 0; i < numcomps; i++) {
-    cmptparm[i].prec = 8;
-    cmptparm[i].bpp = 8;
-    cmptparm[i].sgnd = 0;
-    cmptparm[i].dx = i ? subsampling_dx * tk->CbCr_subsampling_dx : subsampling_dx;
-    cmptparm[i].dy = i ? subsampling_dy * tk->CbCr_subsampling_dy : subsampling_dy;
-    cmptparm[i].w = tk->w;
-    cmptparm[i].h = tk->h;
-  }
-  /* create the image */
-  img = opj_image_create(numcomps, cmptparm, CLRSPC_SRGB);
-  return img;
-}
-
-char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile)
-{
-  int i, compno;
-  int offset;
-  long end_of_f, position;
-  int numcomps = 3;
-  int subsampling_dx = parameters->subsampling_dx;
-  int subsampling_dy = parameters->subsampling_dy;
-  FILE *yuvfile;
-
-  yuvfile = fopen(infile,"rb");
-  if (!yuvfile) {
-    fprintf(stderr, "failed to open %s for readings\n",parameters->infile);
-    return 1;
-  }
-
-  offset = (int) ((double) (frame_num * tk->w * tk->h) * (1.0 +
-    1.0 * (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy)));
-  fseek(yuvfile, 0, SEEK_END);
-  end_of_f = ftell(yuvfile);
-  fseek(yuvfile, sizeof(unsigned char) * offset, SEEK_SET);
-  position = ftell(yuvfile);
-  if (position >= end_of_f) {
-    fprintf(stderr, "Cannot reach frame number %d in yuv file !!\n",
-      frame_num);
-    fclose(yuvfile);
-    return 1;
-  }
-
-  img->x0 = tk->Dim[0];
-  img->y0 = tk->Dim[1];
-  img->x1 = !tk->Dim[0] ? (tk->w - 1) * subsampling_dx + 1 : tk->Dim[0] +
-    (tk->w - 1) * subsampling_dx + 1;
-  img->y1 = !tk->Dim[1] ? (tk->h - 1) * subsampling_dy + 1 : tk->Dim[1] +
-    (tk->h - 1) * subsampling_dy + 1;
-
-  for(compno = 0; compno < numcomps; compno++) {
-    for (i = 0; i < (tk->w * tk->h / (img->comps[compno].dx * img->comps[compno].dy))
-      && !feof(yuvfile); i++) {
-      if (!fread(&img->comps[compno].data[i], 1, 1, yuvfile)) {
-        fprintf(stderr, "Error reading %s file !!\n", infile);
-        return 1;
-      }
-    }
-  }
-  fclose(yuvfile);
-
-  return 0;
-}
-
-
-
-//  -----------------------
-//
-//
-//  IMAGE to YUV
-//
-//  -----------------------
-
-
-bool imagetoyuv(opj_image_t * img, char *outfile)
-{
-  FILE *f;
-  int i;
-
-  if (img->numcomps == 3) {
-    if (img->comps[0].dx != img->comps[1].dx / 2
-      || img->comps[1].dx != img->comps[2].dx) {
-      fprintf(stderr,
-        "Error with the input image components size: cannot create yuv file)\n");
-      return false;
-    }
-  } else if (!(img->numcomps == 1)) {
-    fprintf(stderr,
-      "Error with the number of image components(must be one or three)\n");
-    return false;
-  }
-
-  f = fopen(outfile, "a+b");
-  if (!f) {
-    fprintf(stderr, "failed to open %s for writing\n", outfile);
-    return false;
-  }
-
-
-  for (i = 0; i < (img->comps[0].w * img->comps[0].h); i++) {
-    unsigned char y;
-    y = img->comps[0].data[i];
-    fwrite(&y, 1, 1, f);
-  }
-
-
-  if (img->numcomps == 3) {
-    for (i = 0; i < (img->comps[1].w * img->comps[1].h); i++) {
-      unsigned char cb;
-      cb = img->comps[1].data[i];
-      fwrite(&cb, 1, 1, f);
-    }
-
-
-    for (i = 0; i < (img->comps[2].w * img->comps[2].h); i++) {
-      unsigned char cr;
-      cr = img->comps[2].data[i];
-      fwrite(&cr, 1, 1, f);
-    }
-  } else if (img->numcomps == 1) {
-    for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
-      unsigned char cb = 125;
-      fwrite(&cb, 1, 1, f);
-    }
-
-
-    for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
-      unsigned char cr = 125;
-      fwrite(&cr, 1, 1, f);
-    }
-  }
-  fclose(f);
-  return true;
-}
-
-//  -----------------------
-//
-//
-//  IMAGE to BMP
-//
-//  -----------------------
-
-int imagetobmp(opj_image_t * img, char *outfile) {
-  int w,wr,h,hr,i,pad;
-  FILE *f;
-
-  if (img->numcomps == 3 && img->comps[0].dx == img->comps[1].dx
-    && img->comps[1].dx == img->comps[2].dx
-    && img->comps[0].dy == img->comps[1].dy
-    && img->comps[1].dy == img->comps[2].dy
-    && img->comps[0].prec == img->comps[1].prec
-    && img->comps[1].prec == img->comps[2].prec) {
-    /* -->> -->> -->> -->>
-
-      24 bits color
-
-    <<-- <<-- <<-- <<-- */
-
-    f = fopen(outfile, "wb");
-    if (!f) {
-      fprintf(stderr, "failed to open %s for writing\n", outfile);
-      return 1;
-    }
-
-    w = img->comps[0].w;
-    wr = int_ceildivpow2(img->comps[0].w, img->comps[0].factor);
-
-    h = img->comps[0].h;
-    hr = int_ceildivpow2(img->comps[0].h, img->comps[0].factor);
-
-    fprintf(f, "BM");
-
-    /* FILE HEADER */
-    /* ------------- */
-    fprintf(f, "%c%c%c%c",
-      (unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) +
-      54) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
-      >> 8) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
-      >> 16) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
-      >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,
-      ((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
-
-    /* INFO HEADER   */
-    /* ------------- */
-    fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
-      ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
-      (unsigned char) ((wr) >> 8) & 0xff,
-      (unsigned char) ((wr) >> 16) & 0xff,
-      (unsigned char) ((wr) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
-      (unsigned char) ((hr) >> 8) & 0xff,
-      (unsigned char) ((hr) >> 16) & 0xff,
-      (unsigned char) ((hr) >> 24) & 0xff);
-    fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
-    fprintf(f, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c",
-      (unsigned char) (3 * hr * wr +
-      3 * hr * (wr % 2)) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
-      8) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
-      16) & 0xff,
-      (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
-      24) & 0xff);
-    fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
-      ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
-      ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-    fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
-      ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
-
-    for (i = 0; i < wr * hr; i++) {
-      unsigned char R, G, B;
-      /* a modifier */
-      // R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
-      // G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
-      // B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
-      B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
-      fprintf(f, "%c%c%c", B, G, R);
-
-      if ((i + 1) % wr == 0) {
-        for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--)  /* ADD */
-          fprintf(f, "%c", 0);
-      }
-    }
-    fclose(f);
-  }
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.h b/Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.h
deleted file mode 100644
index 78e6c47..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2_convert.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2002-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-#include "mj2.h"
-
-#ifndef __MJ2_CONVERT_H
-#define __MJ2_CONVERT_H
-
-int imagetoyuv(opj_image_t * img, char *outfile);
-
-int imagetobmp(opj_image_t * img, char *outfile);
-
-opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters);
-
-char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile);
-
-int yuv_num_frames(mj2_tk_t * tk, char *infile);
-
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_frames.c b/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_frames.c
deleted file mode 100644
index 73fee46..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_frames.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
-* Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
-* Copyright (c) 2002-2004,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "openjpeg.h"
-#include "j2k_lib.h"
-#include "j2k.h"
-#include "jp2.h"
-#include "mj2.h"
-#include "mj2_convert.h"
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-int main(int argc, char *argv[]) {
-  mj2_dparameters_t mj2_parameters;      /* decompression parameters */
-  opj_dinfo_t* dinfo;
-  opj_event_mgr_t event_mgr;    /* event manager */
-  opj_cio_t *cio = NULL;
-  unsigned int tnum, snum;
-  opj_mj2_t *movie;
-  mj2_tk_t *track;
-  mj2_sample_t *sample;
-  unsigned char* frame_codestream;
-  FILE *file, *outfile;
-  char outfilename[50];
-  opj_image_t *img = NULL;
-  unsigned int max_codstrm_size = 0;
-  double total_time = 0;
-  unsigned int numframes = 0;
-
-  if (argc != 3) {
-    printf("Bad syntax: Usage: mj2_to_frames inputfile.mj2 outputfile.yuv\n");
-    printf("Example: MJ2_decoder foreman.mj2 foreman.yuv\n");
-    return 1;
-  }
-
-  file = fopen(argv[1], "rb");
-
-  if (!file) {
-    fprintf(stderr, "failed to open %s for reading\n", argv[1]);
-    return 1;
-  }
-
-  // Checking output file
-  outfile = fopen(argv[2], "w");
-  if (!file) {
-    fprintf(stderr, "failed to open %s for writing\n", argv[2]);
-    return 1;
-  }
-  fclose(outfile);
-
-  /*
-  configure the event callbacks (not required)
-  setting of each callback is optionnal
-  */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = NULL;
-
-  /* get a MJ2 decompressor handle */
-  dinfo = mj2_create_decompress();
-  movie = dinfo->mj2_handle;
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-  /* set J2K decoding parameters to default values */
-  opj_set_default_decoder_parameters(&mj2_parameters.j2k_parameters);
-
-  /* setup the decoder decoding parameters using user parameters */
-  mj2_setup_decoder(dinfo->mj2_handle, &mj2_parameters);
-
-  if (mj2_read_struct(file, movie)) // Creating the movie structure
-    return 1;
-
-  // Decode first video track
-  for (tnum=0; tnum < (unsigned int)(movie->num_htk + movie->num_stk + movie->num_vtk); tnum++) {
-    if (movie->tk[tnum].track_type == 0)
-      break;
-  }
-
-  if (movie->tk[tnum].track_type != 0) {
-    printf("Error. Movie does not contain any video track\n");
-    return 1;
-  }
-
-  track = &movie->tk[tnum];
-
-  // Output info on first video tracl
-  fprintf(stdout,"The first video track contains %d frames.\nWidth: %d, Height: %d \n\n",
-    track->num_samples, track->w, track->h);
-
-  max_codstrm_size = track->sample[0].sample_size-8;
-  frame_codestream = (unsigned char*) malloc(max_codstrm_size * sizeof(unsigned char));
-
-  numframes = track->num_samples;
-
-  for (snum=0; snum < numframes; snum++)
-  {
-    double init_time = opj_clock();
-    double elapsed_time;
-
-    sample = &track->sample[snum];
-    if (sample->sample_size-8 > max_codstrm_size) {
-      max_codstrm_size =  sample->sample_size-8;
-      if ((frame_codestream = realloc(frame_codestream, max_codstrm_size)) == NULL) {
-        printf("Error reallocation memory\n");
-        return 1;
-      };
-    }
-    fseek(file,sample->offset+8,SEEK_SET);
-    fread(frame_codestream, sample->sample_size-8, 1, file);  // Assuming that jp and ftyp markers size do
-
-    /* open a byte stream */
-    cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
-
-    img = opj_decode(dinfo, cio); // Decode J2K to image
-
-    if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2)
-      && (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1))
-      || (img->numcomps == 1)) {
-
-      if (!imagetoyuv(img, argv[2]))  // Convert image to YUV
-        return 1;
-    }
-    else if ((img->numcomps == 3) &&
-      (img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
-      (img->comps[2].dx == 1))// If YUV 4:4:4 input --> to bmp
-    {
-      fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
-      sprintf(outfilename,"output_%d.bmp",snum);
-      if (imagetobmp(img, outfilename))  // Convert image to BMP
-        return 1;
-
-    }
-    else {
-      fprintf(stdout,"Image component dimensions are unknown. Unable to output image\n");
-      fprintf(stdout,"The frames will be output in a j2k file (output_1.j2k, ...)\n");
-
-      sprintf(outfilename,"output_%d.j2k",snum);
-      outfile = fopen(outfilename, "wb");
-      if (!outfile) {
-        fprintf(stderr, "failed to open %s for writing\n",outfilename);
-        return 1;
-      }
-      fwrite(frame_codestream,sample->sample_size-8,1,outfile);
-      fclose(outfile);
-    }
-    /* close the byte stream */
-    opj_cio_close(cio);
-    /* free image data structure */
-    opj_image_destroy(img);
-    elapsed_time = opj_clock()-init_time;
-    fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds\n", snum + 1, numframes, elapsed_time*1000);
-    total_time += elapsed_time;
-
-  }
-
-  free(frame_codestream);
-  fclose(file);
-
-  /* free remaining structures */
-  if(dinfo) {
-    mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
-  }
-  free(dinfo);
-
-  fprintf(stdout, "%d frame(s) correctly decompressed\n", snum);
-  fprintf(stdout,"Total decoding time: %.2f seconds (%.1f fps)\n", total_time, (float)numframes/total_time);
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.c b/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.c
deleted file mode 100644
index 9a326ef..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/* mj2_to_metadata.c */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Contributed to Open JPEG by Glenn Pearson, contract software developer, U.S. National Library of Medicine.
-
-The base code in this file was developed by the author as part of a video archiving
-project for the U.S. National Library of Medicine, Bethesda, MD.
-It is the policy of NLM (and U.S. government) to not assert copyright.
-
-A non-exclusive copy of this code has been contributed to the Open JPEG project.
-Except for copyright, inclusion of the code within Open JPEG for distribution and use
-can be bound by the Open JPEG open-source license and disclaimer, expressed elsewhere.
-*/
-
-#include "opj_includes.h"
-#include "mj2.h"
-
-#include "mj2_to_metadata.h"
-#include <string.h>
-#include "compat/getopt.h"
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-
-/* ------------- */
-
-void help_display()
-{
-  /*             "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
-  fprintf(stdout,"                Help for the 'mj2_to_metadata' Program\n");
-  fprintf(stdout,"                ======================================\n");
-  fprintf(stdout,"The -h option displays this information on screen.\n\n");
-
-  fprintf(stdout,"mj2_to_metadata generates an XML file from a Motion JPEG 2000 file.\n");
-  fprintf(stdout,"The generated XML shows the structural, but not (yet) curatorial,\n");
-  fprintf(stdout,"metadata from the movie header and from the JPEG 2000 image and tile\n");
-  fprintf(stdout,"headers of a sample frame.  Excluded: low-level packed-bits image data.\n\n");
-
-  fprintf(stdout,"By Default\n");
-  fprintf(stdout,"----------\n");
-  fprintf(stdout,"The metadata includes the jp2 image and tile headers of the first frame.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Metadata values are shown in 'raw' form (e.g., hexidecimal) as stored in the\n");
-  fprintf(stdout,"file, and, if apt, in a 'derived' form that is more quickly grasped.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Notes explaining the XML are embedded as terse comments.  These include\n");
-  fprintf(stdout,"   meaning of non-obvious tag abbreviations;\n");
-  fprintf(stdout,"   range and precision of valid values;\n");
-  fprintf(stdout,"   interpretations of values, such as enumerations; and\n");
-  fprintf(stdout,"   current implementation limitations.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The sample-size and chunk-offset tables, each with 1 row per frame, are not reported.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"The file is self-contained and no verification (e.g., against a DTD) is requested.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Required Parameters (except with -h)\n");
-  fprintf(stdout,"------------------------------------\n");
-  fprintf(stdout,"[Caution: file strings that contain spaces should be wrapped with quotes.]\n");
-  fprintf(stdout,"-i input.mj2  : where 'input' is any source file name or path.\n");
-  fprintf(stdout,"                MJ2 files created with 'frames_to_mj2' are supported so far.\n");
-  fprintf(stdout,"                These are silent, single-track, 'MJ2 Simple Profile' videos.\n");
-  fprintf(stdout,"-o output.xml : where 'output' is any destination file name or path.\n");
-  fprintf(stdout,"\n");
-  fprintf(stdout,"Optional Parameters\n");
-  fprintf(stdout,"-------------------\n");
-  fprintf(stdout,"-h            : Display this help information.\n");
-  fprintf(stdout,"-n            : Suppress all mj2_to_metadata notes.\n");
-  fprintf(stdout,"-t            : Include sample-size and chunk-offset tables.\n");
-  fprintf(stdout,"-f n          : where n > 0.  Include jp2 header info for frame n [default=1].\n");
-  fprintf(stdout,"-f 0          : No jp2 header info.\n");
-  fprintf(stdout,"-r            : Suppress all 'raw' data for which a 'derived' form exists.\n");
-  fprintf(stdout,"-d            : Suppress all 'derived' data.\n");
-  fprintf(stdout,"                (If both -r and -d given, -r will be ignored.)\n");
-  fprintf(stdout,"-v string     : Verify against the DTD file located by the string.\n");
-  fprintf(stdout,"                Prepend quoted 'string' with either SYSTEM or PUBLIC keyword.\n");
-  fprintf(stdout,"                Thus, for the distributed DTD placed in the same directory as\n");
-  fprintf(stdout,"                the output file: -v \"SYSTEM mj2_to_metadata.dtd\"\n");
-  fprintf(stdout,"                \"PUBLIC\" is used with an access protocol (e.g., http:) + URL.\n");
-  /* More to come */
-  fprintf(stdout,"\n");
-  /*             "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
-}
-
-/* ------------- */
-
-int main(int argc, char *argv[]) {
-
-  opj_dinfo_t* dinfo;
-  opj_event_mgr_t event_mgr;    /* event manager */
-
-  FILE *file, *xmlout;
-/*  char xmloutname[50]; */
-  opj_mj2_t *movie;
-
-  char* infile = 0;
-  char* outfile = 0;
-  char* s, S1, S2, S3;
-  int len;
-  unsigned int sampleframe = 1; /* First frame */
-  char* stringDTD = NULL;
-  BOOL notes = TRUE;
-  BOOL sampletables = FALSE;
-  BOOL raw = TRUE;
-  BOOL derived = TRUE;
-  mj2_dparameters_t parameters;
-
-  while (TRUE) {
-  /* ':' after letter means it takes an argument */
-    int c = getopt(argc, argv, "i:o:f:v:hntrd");
-  /* FUTURE:  Reserve 'p' for pruning file (which will probably make -t redundant) */
-    if (c == -1)
-      break;
-    switch (c) {
-    case 'i':      /* IN file */
-      infile = optarg;
-      s = optarg;
-      while (*s) { s++; } /* Run to filename end */
-      s--;
-      S3 = *s;
-      s--;
-      S2 = *s;
-      s--;
-      S1 = *s;
-
-      if ((S1 == 'm' && S2 == 'j' && S3 == '2')
-      || (S1 == 'M' && S2 == 'J' && S3 == '2')) {
-       break;
-      }
-      fprintf(stderr, "Input file name must have .mj2 extension, not .%c%c%c.\n", S1, S2, S3);
-      return 1;
-
-      /* ----------------------------------------------------- */
-    case 'o':      /* OUT file */
-      outfile = optarg;
-      while (*outfile) { outfile++; } /* Run to filename end */
-      outfile--;
-      S3 = *outfile;
-      outfile--;
-      S2 = *outfile;
-      outfile--;
-      S1 = *outfile;
-
-      outfile = optarg;
-
-      if ((S1 == 'x' && S2 == 'm' && S3 == 'l')
-    || (S1 == 'X' && S2 == 'M' && S3 == 'L'))
-        break;
-
-      fprintf(stderr,
-    "Output file name must have .xml extension, not .%c%c%c\n", S1, S2, S3);
-    return 1;
-
-      /* ----------------------------------------------------- */
-    case 'f':      /* Choose sample frame.  0 = none */
-      sscanf(optarg, "%u", &sampleframe);
-      break;
-
-      /* ----------------------------------------------------- */
-    case 'v':      /* Verification by DTD. */
-      stringDTD = optarg;
-    /* We will not insist upon last 3 chars being "dtd", since non-file
-    access protocol may be used. */
-    if(strchr(stringDTD,'"') != NULL) {
-        fprintf(stderr, "-D's string must not contain any embedded double-quote characters.\n");
-      return 1;
-    }
-
-      if (strncmp(stringDTD,"PUBLIC ",7) == 0 || strncmp(stringDTD,"SYSTEM ",7) == 0)
-        break;
-
-      fprintf(stderr, "-D's string must start with \"PUBLIC \" or \"SYSTEM \"\n");
-    return 1;
-
-    /* ----------------------------------------------------- */
-    case 'n':      /* Suppress comments */
-      notes = FALSE;
-      break;
-
-    /* ----------------------------------------------------- */
-    case 't':      /* Show sample size and chunk offset tables */
-      sampletables = TRUE;
-      break;
-
-    /* ----------------------------------------------------- */
-    case 'h':      /* Display an help description */
-      help_display();
-      return 0;
-
-    /* ----------------------------------------------------- */
-    case 'r':      /* Suppress raw data */
-      raw = FALSE;
-      break;
-
-    /* ----------------------------------------------------- */
-    case 'd':      /* Suppress derived data */
-      derived = FALSE;
-      break;
-
-   /* ----------------------------------------------------- */
-    default:
-      return 1;
-    } /* switch */
-  } /* while */
-
-  if(!raw && !derived)
-    raw = TRUE; /* At least one of 'raw' and 'derived' must be true */
-
-    /* Error messages */
-  /* -------------- */
-  if (!infile || !outfile) {
-    fprintf(stderr,"Correct usage: mj2_to_metadata -i mj2-file -o xml-file (plus options)\n");
-    return 1;
-  }
-
-/* was:
-  if (argc != 3) {
-    printf("Bad syntax: Usage: MJ2_to_metadata inputfile.mj2 outputfile.xml\n");
-    printf("Example: MJ2_to_metadata foreman.mj2 foreman.xml\n");
-    return 1;
-  }
-*/
-  len = strlen(infile);
-  if(infile[0] == ' ')
-  {
-    infile++; /* There may be a leading blank if user put space after -i */
-  }
-
-  file = fopen(infile, "rb"); /* was: argv[1] */
-
-  if (!file) {
-    fprintf(stderr, "Failed to open %s for reading.\n", infile); /* was: argv[1] */
-    return 1;
-  }
-
-  len = strlen(outfile);
-  if(outfile[0] == ' ')
-  {
-    outfile++; /* There may be a leading blank if user put space after -o */
-  }
-
-  // Checking output file
-  xmlout = fopen(outfile, "w"); /* was: argv[2] */
-  if (!xmlout) {
-    fprintf(stderr, "Failed to open %s for writing.\n", outfile); /* was: argv[2] */
-    return 1;
-  }
-  // Leave it open
-
-  /*
-  configure the event callbacks (not required)
-  setting of each callback is optionnal
-  */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = info_callback;
-
-  /* get a MJ2 decompressor handle */
-  dinfo = mj2_create_decompress();
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
-  /* setup the decoder decoding parameters using user parameters */
-  movie = (opj_mj2_t*) dinfo->mj2_handle;
-  mj2_setup_decoder(dinfo->mj2_handle, &parameters);
-
-  if (mj2_read_struct(file, movie)) // Creating the movie structure
-  {
-    fclose(xmlout);
-    return 1;
-  }
-
-  xml_write_init(notes, sampletables, raw, derived);
-  xml_write_struct(file, xmlout, movie, sampleframe, stringDTD, &event_mgr);
-  fclose(xmlout);
-
-  fprintf(stderr,"Metadata correctly extracted to XML file \n");;
-
-  /* free remaining structures */
-  if(dinfo) {
-    mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
-  }
-
-  return 0;
-}
-
-
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.dtd b/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.dtd
deleted file mode 100644
index 249de1a..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.dtd
+++ /dev/null
@@ -1,425 +0,0 @@
-<!--
-Preliminary DTD for Open JPEG "mj2_to_metadata" function.
-Last revised: April 20, 2005
-Author:  Glenn Pearson, at U.S. National Library of Medicine.
-See mj2_to_metadata.c regarding copyright, license, disclaimer status.
-
-While the vocabulary of this DTD is based on the relevant portions of the
-ISO/IEC JPEG 200 standard, the detailed representation is the author's own.
-It is neither an ISO/IEC nor NLM official or consensus representation.
-Furthermore, it deviates from a pure representation of the ISO/IEC standard
-in these aspects:
-
-  - it is incomplete in a number of ways (which to some extent may be
-    addressed over time);
-  - it has extensions for "derived" data and "statistics";
-  - it is more flexible.  That is, some elements are marked as optional
-    not because they are optional in an MJ2 file, but because reporting
-    of them is optional based on current or projected mj2_to_metadata
-    command-line flags.
--->
-<!ELEMENT MJ2_File (JP2?, FileType?, MovieBox?)>
-<!ELEMENT JP2 EMPTY>
-<!ATTLIST JP2 BoxType CDATA #FIXED "jP[space][space]">
-<!ATTLIST JP2 Signature CDATA #FIXED "0x0d0a870a">
-<!ELEMENT FileType (Brand, MinorVersion, CompatibilityList)>
-<!ATTLIST FileType BoxType CDATA #FIXED "ftyp">
-<!ELEMENT Brand (#PCDATA)> <!-- 4 characters max -->
-<!ELEMENT MinorVersion (#PCDATA)> <!-- 4 chararcters max -->
-<!ELEMENT CompatibilityList (CompatibleBrand)*>
-<!ATTLIST CompatibilityList Count CDATA #REQUIRED>  <!-- Count >= 0 -->
-<!ELEMENT CompatibleBrand (#PCDATA)> <!-- 4 characters max -->
-<!ELEMENT MovieBox (MovieHeader, Statistics?, Track*)>
-<!ATTLIST MovieBox BoxType CDATA #FIXED "moov">
-<!ELEMENT MovieHeader (CreationTime, ModificationTime, Timescale, Rate, Duration, Volume, TransformationMatrix)>
-<!ATTLIST MovieHeader BoxType CDATA #FIXED "mvhd">
-<!ELEMENT CreationTime (InSeconds?,AsLocalTime?)>
-<!ELEMENT InSeconds (#PCDATA)>
-<!ELEMENT AsLocalTime (#PCDATA)>
-<!ELEMENT ModificationTime (InSeconds?,AsLocalTime?)>
-<!ELEMENT Timescale (#PCDATA)> <!-- Timescale defines time units in one second -->
-<!ELEMENT Rate (AsHex | (AsHex, AsDecimal) | AsDecimal)>  <!-- Decimal is Approximation; Optional on input. -->
-<!ELEMENT AsHex (#PCDATA)>
-<!ELEMENT AsDecimal (#PCDATA)> 
-<!ELEMENT Duration (InTimeUnits | (InTimeUnits, InSeconds) | InSeconds)>  <!-- InSeconds Optional on input. -->
-<!ELEMENT InTimeUnits (#PCDATA)>
-<!ELEMENT Volume (AsHex | (AsHex, AsDecimal) | AsDecimal)>   <!-- hex default = 0x0100 -->
-<!-- Fixed 8.8 value of audio volume.  Full, normal value is 1.0 (0x0100) -->
-<!ELEMENT TransformationMatrix (TMa,TMb,TMu,TMc,TMd,TMv,TMx,TMy,TMw)> <!-- for video -->
-<!-- 3 x 3 Video Transformation Matrix {a,b,u,c,d,v,x,y,w}.  Required: u=0, v=0, w=1 -->
-<!-- Maps decompressed point (p,q) to rendered point (ap + cq + x, bp + dq + y) -->
-<!-- Stored as Fixed Point Hex: all are 16.16, except u,v,w are 2.30 -->
-<!-- Unity = 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 -->
-<!ELEMENT TMa (#PCDATA)>    
-<!ELEMENT TMb (#PCDATA)>  
-<!ELEMENT TMu (#PCDATA)> <!--Always "0x00000000" -->
-<!ELEMENT TMc (#PCDATA)>
-<!ELEMENT TMd (#PCDATA)>
-<!ELEMENT TMv (#PCDATA)> <!--Always "0x00000000" -->
-<!ELEMENT TMx (#PCDATA)>
-<!ELEMENT TMy (#PCDATA)>
-<!ELEMENT TMw (#PCDATA)> <!--Always "0x40000000" -->
-
-<!ELEMENT Statistics (TracksFound)>
-<!ELEMENT TracksFound (Video,Audio,Hint)>
-<!ELEMENT Video (#PCDATA)>
-<!ELEMENT Audio (#PCDATA)>
-<!ELEMENT Hint (#PCDATA)>
- 
-
-<!-- For now, output info on at most one video track -->
-
-
-<!ELEMENT Track (TrackHeader, TrackReferenceContainer?, EditListContainer?, Media, JP2_Frame?)>  <!-- JP2_Frame is mj2_to_metadata extension -->
-<!ATTLIST Track BoxType CDATA #FIXED "trak">
-<!ATTLIST Track Instance CDATA #REQUIRED>
-<!ELEMENT TrackHeader (TrackID, TrackLayer?, Volume?, TransformationMatrix?, Width?, Height?)>
-<!ATTLIST TrackHeader BoxType CDATA #FIXED "tkhd">
-<!-- Not shown here: CreationTime, ModificationTime, Duration. -->
-<!-- These 3 fields are reported under MediaHeader below.   When reading these 3, -->
-<!-- m2j_to_metadata currently doesn't distinguish between TrackHeader and MediaHeader source. -->
-<!-- If both found, value read from MediaHeader is used. -->
-<!ELEMENT TrackID (#PCDATA)>
-<!ELEMENT TrackLayer (#PCDATA)>  <!-- front-to-back ordering of video tracks. 0 = normal, -1 is closer, etc. -->
-<!-- "Volume" element described above; here it is for particular audio track.  Full, normal (default = 0x0100) -->
-<!-- "TransformationMatrix" element described above; matrix here is applied before MovieHeader one. -->
-<!ELEMENT Width (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!ELEMENT Height (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!-- AsHex, AsDecimal already defined above -->
- <!-- Width and Height are for the presentation; frames will be scaled to this -->
-<!-- /TrackHeader -->
-<!ELEMENT TrackReferenceContainer ANY>  <!-- TO DO: TrackReferenceContainer 'tref'  just used in hint track -->
-<!ELEMENT EditListContainer ANY>  <!-- TO DO: EditListContainer 'edts', contains EditList 'elst' with media-time, segment-duration, media-rate -->
-<!ELEMENT Media (MediaHeader, HandlerReference,MediaInfoContainer)>
-<!ATTLIST Media BoxType CDATA #FIXED "mdia">
-<!ELEMENT MediaHeader (CreationTime,ModificationTime,Timescale,Duration,Language)>
-<!ATTLIST MediaHeader BoxType CDATA #FIXED "mdhd">
-<!-- Elements already defined above: CreationTime, ModificationTime, Timescale, Duration -->
-<!ELEMENT Language (#PCDATA)> <!-- 3 chars max.  There's an enumeration available -->
-<!ELEMENT HandlerReference (HandlerType)>
-<!ATTLIST HandlerReference BoxType CDATA #FIXED "hdlr">
-<!ELEMENT HandlerType (#PCDATA)>
-<!ATTLIST HandlerType Code ( vide | soun | hint ) "vide">
-
-<!-- make the media headers multiple? -->
-<!ELEMENT MediaInfoContainer ((VideoMediaHeader | SoundMediaHeader | HintMediaHeader), DataInfo, SampleTable)>
-<!ATTLIST MediaInfoContainer BoxType CDATA #FIXED "minf">
-<!ELEMENT VideoMediaHeader (GraphicsMode, Opcolor)>
-<!ATTLIST VideoMediaHeader BoxType CDATA #FIXED "vmhd">
-<!ELEMENT GraphicsMode (#PCDATA)>
-          <!-- Enumerated values of graphics mode: -->
-          <!--  0x00 = copy (over existing image); -->
-          <!--  0x24 = transparent; 'blue-screen' this image using opcolor; -->
-          <!--  0x100 = alpha; alpha-blend this image -->
-          <!--  0x101 = whitealpha; alpha-blend this image, which has been blended with white; -->
-          <!--  0x102 = blackalpha; alpha-blend this image, which has been blended with black. -->
-<!ELEMENT Opcolor (Red,Green,Blue)>
-<!ELEMENT Red (#PCDATA)>
-<!ELEMENT Green (#PCDATA)>
-<!ELEMENT Blue (#PCDATA)>
-<!ELEMENT SoundMediaHeader (Balance)>
-<!ATTLIST SoundMediaHeader BoxType CDATA #FIXED "smhd">
-<!ELEMENT Balance (#PCDATA)>
-          <!-- Fixed Point 8.8, fixes mono track in stereo space. -->
-          <!-- 0.0 = center, -1.0 = full left, 1.0 = full right -->
-<!ELEMENT HintMediaHeader (MaxPDU_Size, AvgPDU_Size, MaxBitRate, AvgBitRate, SlidingAvgBitRate)>
-<!ATTLIST HintMediaHeader BoxType CDATA #FIXED "hmhd">
-<!ELEMENT MaxPDU_Size (#PCDATA)>
-          <!-- Size in bytes of largest PDU in this hint stream. -->
-<!ELEMENT AvgPDU_Size (#PCDATA)>
-           <!-- Average size in bytes of a PDU over the entire presentation. -->
-<!ELEMENT MaxBitRate (#PCDATA)>
-          <!-- Maximum rate in bits per second over any window of 1 second. -->
-<!ELEMENT AvgBitRate (#PCDATA)>
-          <!-- Averate rate in bits per second over the entire presentation. -->
-<!ELEMENT SlidingAvgBit (#PCDATA)>
-          <!-- Maximum rate in bits per second over any window of one minute. -->
- 
-<!ELEMENT DataInfo (DataReference)>
-<!ATTLIST DataInfo BoxType CDATA #FIXED "dinf">
-<!ELEMENT DataReference (DataEntryUrlBox | DataEntryUrnBox )*>
-<!ATTLIST DataReference BoxType CDATA #FIXED "dref">
-<!ATTLIST DataReference URL_Count CDATA #REQUIRED>
-<!ATTLIST DataReference URN_Count CDATA #REQUIRED> <!-- table w. flags, URLs, URNs -->
-<!--  // Data structure does not distinguish between single URL, single URN, or DREF table or URLs & URNs.
-  // We could infer those, but for now just present everything as a DREF table.
--->
-              <!-- No entries here mean that file is self-contained, as required by Simple Profile. -->
-
-<!ELEMENT DataEntryUrlBox (Location)>
-<!ATTLIST DataEntryUrlBox BoxType CDATA #FIXED "url[space]"> <!-- table w. flags, URLs, URNs -->
-            <!-- Only the first 16 bytes of URL location are recorded in mj2_to_metadata data structure. -->
-<!ELEMENT DataEntryUrnBox (Name, Location?)>
-<!ATTLIST DataEntryUrnBox BoxType CDATA #FIXED "urn[space]\">
-            <!-- Only the first 16 bytes each of URN name and optional location are recorded in mj2_to_metadata data structure. -->
-
-<!ELEMENT SampleTable (VisualSampleEntry,TimeToSample,SampleToChunk,SampleSize,ChunkOffset)>  <!-- structure doesn't do non-visual sample entry yet -->
-<!ATTLIST SampleTable BoxType CDATA #FIXED "stbl">  <!-- to add: entry count -->
-            <!-- Next are instances of generic SampleDescription BoxType=\"stsd\" -->
- 
-    <!-- There could be multiple instances of this, but "entry_count" is just a local at read-time.
-       And it's used wrong, too, as count of just visual type, when it's really all 3 types.
-       This is referred to as "smj2" within mj2.c -->
-<!ELEMENT VisualSampleEntry (WidthAsInteger, HeightAsInteger, HorizontalRes, VerticalRes, CompressorName, Depth, JP2Header?, FieldCoding?, MJP2_Profile?, MJP2_Prefix?, MJP2_SubSampling?, MJP2_OriginalFormat?)>
-<!ATTLIST VisualSampleEntry BoxType CDATA #FIXED "mjp2">
-          <!-- If multiple instances of this, only first is shown here. -->
-<!ELEMENT WidthAsInteger (#PCDATA)>
-<!ELEMENT HeightAsInteger (#PCDATA)>
-<!ELEMENT HorizontalRes (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!ELEMENT VerticalRes (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!-- Typical value for both resolution is 72 (0x00480000) -->
-<!ELEMENT CompressorName (#PCDATA)>
-          <!-- Compressor name for debugging.  Standard restricts max length to 31 bytes. -->
-          <!-- Usually blank or \"Motion JPEG2000\" -->
-<!ELEMENT Depth (#PCDATA)>
-          <!-- Depth is: -->
-          <!--   0x20: alpha channels present (color or grayscale) -->
-          <!--   0x28: grayscale without alpha -->
-          <!--   0x18: color without alpha -->
-
-<!-- TODO somewhere: tk->jp2_struct.numcomps -->
-<!ELEMENT JP2Header (ImageHeader, ColourSpecification)>
-<!ATTLIST JP2Header BoxType CDATA #FIXED "jp2h">
-<!ELEMENT ImageHeader (HEIGHT, WIDTH, NC, BPC, C, UnkC, IPR)>
-<!ATTLIST ImageHeader BoxType CDATA #FIXED "ihdr">
-<!ELEMENT HEIGHT (#PCDATA)>  <!-- If 2 fields/frame, total deinterlaced height -->
-<!ELEMENT WIDTH (#PCDATA)>
-<!ELEMENT NC (#PCDATA)>  <!-- number of components -->
-<!ELEMENT BPC (AsHex | (AsHex,BitsPerPixel,Signed) | (BitsPerPixel,Signed))>
-<!ELEMENT BitsPerPixel (#PCDATA)>
-<!ELEMENT Signed (#PCDATA)>
-<!ELEMENT C (#PCDATA)>  <!-- Compression type.  Only "7" defined -->
-<!ELEMENT UnkC (#PCDATA)>  <!-- Colourspace Unknown. 1 = unknown, 0 = known -->
-<!ELEMENT IPR (#PCDATA)>  <!-- 1 = frame has Intellectual Prop. box; otherwise 0 -->
-<!ELEMENT ColourSpecification (METH, PREC, APPROX, EnumCS)>
-<!ATTLIST ColourSpecification BoxType CDATA #FIXED "colr">
-<!ELEMENT METH (#PCDATA)>  <!-- 1 = EnumCS field; 2 = PROFILE field (not yet generated) -->
-<!ELEMENT PREC (#PCDATA)> <!-- precedence must be 0 so far -->
-<!ELEMENT APPROX (#PCDATA)>  <!-- colourspace approximation must be 0 so far -->
-<!ELEMENT EnumCS (#PCDATA)> <!-- Valid enumerated MJ2 colourspaces: 16 (sRGB), 17 (grey sRGB), 18 (YCC) -->
-
-<!-- Following subboxes are optional -->
-<!ELEMENT FieldCoding (FieldCount, FieldOrder)>
-<!ATTLIST FieldCoding BoxType CDATA #FIXED "fiel">
-<!ELEMENT FieldCount (#PCDATA)>
-            <!-- Must be either 1 or 2 -->
-<!ELEMENT FieldOrder (#PCDATA)>
-            <!-- When FieldCount=2, FieldOrder means: -->
-            <!--   0: Field coding unknown -->
-            <!--   1: Field with topmost line is stored first in sample; fields are in temporal order -->
-            <!--   6: Field with topmost line is stored second in sample; fields are in temporal order -->
-            <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->
-            <!-- Current implementation doesn't retain whether box was actually present. -->
-
-<!ELEMENT MJP2_Profile (CompatibleBrand*)>
-<!ATTLIST MJP2_Profile BoxType CDATA #FIXED "jp2p">
-<!ATTLIST MJP2_Profile Count CDATA #REQUIRED>
-
-<!ELEMENT MJP2_Prefix (Data*)>
-<!ATTLIST MJP2_Prefix BoxType CDATA #FIXED "jp2x">
-<!ATTLIST MJP2_Prefix Count CDATA #REQUIRED>
-<!-- We'll probably need better formatting than this  -->
-<!ELEMENT Data (#PCDATA)>    <!-- Multiple. Each entry is single byte -->
-
-<!ELEMENT MJP2_SubSampling (HorizontalSub, VerticalSub, HorizontalOffset, VerticalOffset)>
-<!ATTLIST MJP2_SubSampling BoxType CDATA #FIXED "jsub">
-<!-- These values are all 1 byte -->
-            <!-- Typical subsample value is 2 for 4:2:0 -->
-<!ELEMENT HorizontalSub (#PCDATA)>
-<!ELEMENT VerticalSub (#PCDATA)>
-<!ELEMENT HorizontalOffset (#PCDATA)>
-<!ELEMENT VerticalOffset (#PCDATA)>
-
-<!ELEMENT MJP2_OriginalFormat (OriginalFieldCount, OriginalFieldOrder)>
-<!ATTLIST MJP2_OriginalFormat BoxType CDATA #FIXED "orfo"> <!-- Part III Appx. 2 -->
-<!ELEMENT OriginalFieldCount (#PCDATA)>
-            <!-- In original material before encoding.  Must be either 1 or 2 -->
-<!ELEMENT OriginalFieldOrder (#PCDATA)>
-            <!-- When FieldCount=2, FieldOrder means: -->
-            <!--   0: Field coding unknown -->
-            <!--   11: Topmost line came from the earlier field; -->
-            <!--   16:  Topmost line came form the later field. -->
-            <!-- Defaults: FieldCount=1, FieldOrder=0 if FieldCoding box not present -->
-            <!-- Current implementation doesn't retain whether box was actually present. -->
-
-
-            <!-- mj2_to_metadata's data structure doesn't record Audio and Hint sample data currently. -->
-
-<!-- Within SampleTable: -->
-<!ELEMENT TimeToSample (SampleStatistics, SampleEntries)>
-<!ATTLIST TimeToSample BoxType CDATA #FIXED "stts">  
-<!ELEMENT SampleStatistics (TotalSamples)>  <!-- Not part of standard -->  
-<!ELEMENT TotalSamples (#PCDATA)>
-                <!-- For video, gives the total frames in the track, by summing all entries in the Sample Table -->
-
-<!ELEMENT SampleEntries (Table*)>
-<!ATTLIST SampleEntries EntryCount CDATA #REQUIRED>
-<!ELEMENT Table EMPTY> <!-- Multiple.  Attributes have values -->
-<!ATTLIST Table Entry CDATA #REQUIRED>
-<!ATTLIST Table SampleCount CDATA #REQUIRED>
-<!ATTLIST Table SampleDelta CDATA #REQUIRED>
-
-<!-- Within SampleTable: -->
-<!ELEMENT SampleToChunk (FirstChunk,SamplesPerChunk,SampleDescrIndex)>
-<!ATTLIST SampleToChunk BoxType CDATA #FIXED "stsc">
-<!ATTLIST SampleToChunk Count CDATA #REQUIRED>
-<!ELEMENT FirstChunk (#PCDATA)>
-<!ELEMENT SamplesPerChunk (#PCDATA)>
-<!ELEMENT SampleDescrIndex (#PCDATA)>
-<!ELEMENT SampleSize (Sample_Size,Sample_Count,EntrySize*)>
-<!ATTLIST SampleSize BoxType CDATA #FIXED "stsz">
-<!ELEMENT Sample_Size (#PCDATA)>
-<!ELEMENT Sample_Count (#PCDATA)>
-<!ELEMENT EntrySize (#PCDATA)>  <!-- appears multiply, but only with mj2_to_metadata option -t -->
-<!ATTLIST EntrySize Num CDATA #REQUIRED>
-<!ELEMENT ChunkOffset (EntryCount, Chunk_Offset*)>
-<!ATTLIST ChunkOffset BoxType CDATA #FIXED "stco">
-<!ELEMENT EntryCount (#PCDATA)>
-<!ELEMENT Chunk_Offset (#PCDATA)>  <!-- appears multiply, but only with mj2_to_metadata option -t -->
-<!ATTLIST Chunk_Offset Num CDATA #REQUIRED>
-<!-- </SampleTable> </MediaInfoContainer> </Media> -->
-
-<!-- TO DO: optional UserData 'udat', can contain multiple Copyright 'cprt' -->
-
-
-<!-- Optional, and only for Visual Track: given individual frame -->
-<!ELEMENT JP2_Frame (MainHeader, TilePartHeaders)>
-<!ATTLIST JP2_Frame Num CDATA #REQUIRED>
-<!ELEMENT MainHeader (StartOfCodestream,ImageAndFileSize,CodingStyleDefault,QuantizationDefault,QuantizationComponent*,RegionOfInterest?,ProgressionOrderChange*)>
-<!ELEMENT StartOfCodestream EMPTY>
-<!ATTLIST StartOfCodestream Marker CDATA #FIXED "SOC">
-<!ELEMENT ImageAndFileSize (Xsiz,Ysiz,XOsiz,YOsiz,XTsiz,YTsiz,XTOsiz,YTOsiz,Csiz,Component+)>
-<!ATTLIST ImageAndFileSize Marker CDATA #FIXED "SIZ">
-<!ELEMENT Xsiz (#PCDATA)>
-<!ELEMENT Ysiz (#PCDATA)>  <!-- Xsiz, Ysiz is the size of the reference grid. -->
-<!ELEMENT XOsiz (#PCDATA)>
-<!ELEMENT YOsiz (#PCDATA)>  <!-- XOsiz, YOsiz are offsets from grid origin to image origin. -->
-<!ELEMENT XTsiz (#PCDATA)>
-<!ELEMENT YTsiz (#PCDATA)>  <!-- XTsiz, YTsiz is the size of one tile with respect to the grid. -->
-<!ELEMENT XTOsiz (#PCDATA)>
-<!ELEMENT YTOsiz (#PCDATA)> <!-- XTOsiz, YTOsiz are offsets from grid origin to first tile origin. -->
-<!ELEMENT Csiz (#PCDATA)>  <!-- Csiz is the number of components in the image. -->
-<!-- For image components next -->
-<!ELEMENT Component (Ssiz,XRsiz,YRsiz,WidthOfData,HeightOfData)>
-<!ATTLIST Component Num CDATA #REQUIRED>
-<!ELEMENT Ssiz (AsHex | (AsHex,Signed,PrecisionInBits) | (Signed,PrecisionInBits))>
-<!-- Signed already defined -->
-<!ELEMENT PrecisionInBits (#PCDATA)>  <!--   Bits per pixel (bpp) or pixel depth. -->
-<!ELEMENT XRsiz (#PCDATA)>
-<!ELEMENT YRsiz (#PCDATA)> <!-- XRsiz, YRsiz denote pixel-sample-spacing on the grid, per Part I Annex B. -->
-<!ELEMENT WidthOfData (#PCDATA)>
-<!ELEMENT HeightOfData (#PCDATA)>  <!-- WidthOfData and HeightOfData are calculated values, e.g.: w = roundup((Xsiz - XOsiz)/ XRsiz) -->
-<!-- -->
-<!ELEMENT CodingStyleDefault (Scod,SGcod,SPcod)>
-<!ATTLIST CodingStyleDefault Marker CDATA #FIXED "COD">
-<!ELEMENT Scod (#PCDATA)>
-          <!-- For Scod, specific bits mean (where bit 0 is lowest or rightmost): -->
-          <!-- bit 0: Defines entropy coder precincts -->
-          <!--        0 = (PPx=15, PPy=15); 1 = precincts defined below. -->
-          <!-- bit 1: 1 = SOP marker may be used; 0 = not. -->
-          <!-- bit 2: 1 = EPH marker may be used; 0 = not. -->
-<!ELEMENT SGcod (ProgressionOrder,NumberOfLayers,MultipleComponentTransformation)>
-<!ELEMENT ProgressionOrder (#PCDATA)>
-            <!-- Defined Progression Order Values are: -->
-            <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->
-            <!-- where L = "layer", R = "resolution level", C = "component", P = "position". -->
-<!ELEMENT NumberOfLayers (#PCDATA)>
-<!ELEMENT MultipleComponentTransformation (#PCDATA)>
-            <!-- For MCT, 0 = none, 1 = transform first 3 components for efficiency, per Part I Annex G -->
-<!ELEMENT SPcod (NumberOfDecompositionLevels,CodeblockWidth,CodeblockHeight,CodeblockStyle,Transformation)>
-<!ELEMENT NumberOfDecompositionLevels (#PCDATA)>
-<!ELEMENT CodeblockWidth (#PCDATA)>   <!-- CBW and CBH are non-negative, and summed cannot exceed 8 -->
-<!ELEMENT CodeblockHeight (#PCDATA)>  <!-- Codeblock dimension is 2^(value + 2) -->
-<!ELEMENT CodeblockStyle (#PCDATA)>
-            <!-- For CodeblockStyle, bits mean (with value 1=feature on, 0=off): -->
-            <!-- bit 0: Selective arithmetic coding bypass. -->
-            <!-- bit 1: Reset context probabilities on coding pass boundaries. -->
-            <!-- bit 2: Termination on each coding pass. -->
-            <!-- bit 3: Vertically causal context. -->
-            <!-- bit 4: Predictable termination. -->
-            <!-- bit 5: Segmentation symbols are used. -->
-<!ELEMENT Transformation (#PCDATA)> <!-- For Transformation, 0="9-7 irreversible filter", 1="5-3 reversible filter" -->
-        <!-- mj2_to_metadata implementation always reports component[0] as using default COD, -->
-        <!-- and any other component, with main-header style values different from [0], as COC. -->
-<!ELEMENT QuantizationDefault (Sqcd,SPqcd)>
-<!ATTLIST QuantizationDefault Marker CDATA #FIXED "QCD">
-<!ELEMENT Sqcd (AsHex | (AsHex,QuantizationStyle,NumberOfGuardBits) | (QuantizationStyle,NumberOfGuardBits))>
-<!ELEMENT QuantizationStyle (#PCDATA)>  <!-- Default quantization style for all components. -->
-            <!-- Quantization style (in Sqcd's low 5 bits) may be: -->
-            <!--   0 = No quantization. SPqcd size = 8 bits-->
-            <!--   1 = Scalar derived (values signaled for N(L)LL subband only). Use Eq. E.5. SPqcd size = 16. -->
-            <!--   2 = Scalar expounded (values signaled for each subband). SPqcd size = 16. -->
-<!ELEMENT NumberOfGuardBits (#PCDATA)>  <!-- 0-7 guard bits allowed (stored in Sqcd's high 3 bits) -->
-<!ELEMENT SPqcd (ReversibleStepSizeValue | QuantizationStepSizeValues )>  <!-- TO DO: Irreversible choices -->
-<!ELEMENT ReversibleStepSizeValue (DynamicRangeExponent+)>
-            <!-- Current mj2_to_metadata implementation dumps entire internal table, -->
-            <!-- until an exponent with zero value is reached. -->
-            <!-- Exponent epsilon(b) of reversible dynamic range. -->
-            <!-- Hex value is as stored, in high-order 5 bits. -->
-<!ELEMENT DynamicRangeExponent (AsHex | (AsHex, AsDecimal) | AsDecimal)>
-<!ATTLIST DynamicRangeExponent Subband CDATA #REQUIRED>
-<!ELEMENT QuantizationStepSizeValues (QuantizationValues+, CalculatedExponent*)>  <!-- Calculated exponents iff only subband 0 reported -->
-<!ELEMENT QuantizationValues (AsHex | (AsHex,Exponent,Mantissa) | (Exponent,Mantissa))>
-<!ATTLIST QuantizationValues Subband CDATA #REQUIRED>
-<!ELEMENT Exponent (#PCDATA)>
-<!ELEMENT Mantissa (#PCDATA)>
-<!ELEMENT CalculatedExponent (#PCDATA)>
-<!ATTLIST CalculatedExponent Subband CDATA #REQUIRED>
-<!-- /QuantizationDefault -->
-        <!-- mj2_to_metadata implementation always reports component[0] as using default QCD, -->
-        <!-- and any other component, with main-header quantization values different from [0], as QCC. -->
-<!ELEMENT QuantizationComponent (Sqcc,SPqcc)>
-<!ATTLIST QuantizationComponent Marker CDATA #FIXED "QCC">
-<!ATTLIST QuantizationComponent Component CDATA #REQUIRED>
-<!ELEMENT Sqcc (AsHex | (AsHex,QuantizationStyle,NumberOfGuardBits) | (QuantizationStyle,NumberOfGuardBits))>
-<!ELEMENT SPqcc (ReversibleStepSizeValue | QuantizationStepSizeValues )>  <!-- TO DO: Irreversible choices -->
-<!-- /QuantizationComponent -->
-<!-- Don't know if MJ2 files can have regions of interest.  Assume yes -->
-<!ELEMENT RegionOfInterest (Srgn,Crgn,Sprgn)> <!-- Optional in main header, at most 1 per component -->
-<!ATTLIST RegionOfInterest Marker CDATA #FIXED "RGN">
-<!ELEMENT Srgn (#PCDATA)>  <!-- ROI style.  Only style=0 defined: Implicit ROI (max. shift) -->
-<!ELEMENT Crgn (#PCDATA)>  <!-- Zero-based component number. -->
-<!ELEMENT SPrgn (#PCDATA)> <!-- Implicit ROI shift, i.e., binary shifting of ROI coefficients above background. -->
-<!-- </RegionOfInterest> -->
-<!ELEMENT ProgressionOrderChange (Progression+)> <!-- Optional in main header, at most 1 per component (but impl allows more?) -->
-<!ATTLIST ProgressionOrderChange Marker CDATA #REQUIRED>
-<!ELEMENT Progression (RSpoc,CSpoc,LYEpoc,REpoc,CEpoc,Ppoc)>
-<!ATTLIST Progression Num CDATA #REQUIRED>
-<!ELEMENT RSpoc (#PCDATA)> <!-- Resolution level index (inclusive) for progression start. Range: 0 to 33 -->
-<!ELEMENT CSpoc (#PCDATA)> <!-- Component index (inclusive) for progression start. -->
-<!ELEMENT LYEpoc (#PCDATA)> <!-- Layer index (exclusive) for progression end. -->
-<!ELEMENT REpoc (#PCDATA)> <!-- Resolution level index (exclusive) for progression end. Range: RSpoc to 33 -->
-<!ELEMENT CEpoc (#PCDATA)> <!-- Component index (exclusive) for progression end.  Minimum: CSpoc -->
-<!ELEMENT Ppoc (#PCDATA)> <!-- Defined Progression Order Values are: -->
-                          <!-- 0 = LRCP; 1 = RLCP; 2 = RPCL; 3 = PCRL; 4 = CPRL -->
-                          <!-- where L = "layer", R = "resolution level", C = "component", P = "position". -->
-<!-- </Progression>, </ProgressionOrderChange -->
-<!-- /MainHeader -->
-<!ELEMENT TilePartHeaders (TilePartHeader+)>
-<!ATTLIST TilePartHeaders Count CDATA #REQUIRED>
-<!ELEMENT TilePartHeader (StartOfTilePart,CodingStyleDefault,QuantizationDefault,QuantizationComponent*,RegionOfInterest?,ProgressionOrderChange*,StartOfData)>
-<!ATTLIST TilePartHeader Num CDATA #REQUIRED>
-<!ATTLIST TilePartHeader ID CDATA #REQUIRED>
-<!ELEMENT StartOfTilePart EMPTY>
-<!ATTLIST StartOfTilePart Marker CDATA #FIXED "SOT">
-<!-- CodingStyleDefault, QuantizationDefault, QuantizationComponent already defined -->
-        <!-- mj2_to_metadata implementation always reports component[0] as using default QCD, -->
-        <!-- and any other component, with tile-part-header quantization values different from [0], as QCC. -->
-<!ELEMENT StartOfData EMPTY> <!-- always empty for now -->
-<!ATTLIST StartOfData Marker CDATA #FIXED "SOD">
-          <!-- Tile-part bitstream, not shown, follows tile-part header and SOD marker. -->
-<!-- /TilePartHeader, /TilePartHeaders, /JP2_Frame -->
-<!-- </Track> -->
-
-<!-- to come:
-  <MovieExtends mvek> // possibly not in Simple Profile
-  <UserDataBox udat> contains <CopyrightBox cprt>
-  -->
-<!-- /MovieBox -->
-<!-- To come:
-  <mdat>
-  <moof>  // probably not in Simple Profile
-  <free>
-  <skip>
-  -->
-<!-- </MJ2_File> -->
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.h b/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.h
deleted file mode 100644
index f4c3491..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* mj2_to_metadata.h */
-/* Dump MJ2, JP2 metadata (partial so far) to xml file */
-/* Contributed to Open JPEG by Glenn Pearson, U.S. National Library of Medicine */
-
-#define BOOL int
-#define FALSE 0
-#define TRUE 1
-
-#include "meta_out.h"
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata_Notes.doc b/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata_Notes.doc
deleted file mode 100644
index 05ccec2..0000000
Binary files a/Utilities/gdcmopenjpeg-v2/mj2/mj2_to_metadata_Notes.doc and /dev/null differ
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/readme.txt b/Utilities/gdcmopenjpeg-v2/mj2/readme.txt
deleted file mode 100644
index 29b8c86..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/readme.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Attention : the motion jpeg 2000 files currently only work with OpenJPEG v0.97 that you can find here :
-
-http://www.openjpeg.org/openjpeg_v097.tar.gz
\ No newline at end of file
diff --git a/Utilities/gdcmopenjpeg-v2/mj2/wrap_j2k_in_mj2.c b/Utilities/gdcmopenjpeg-v2/mj2/wrap_j2k_in_mj2.c
deleted file mode 100644
index 85ac294..0000000
--- a/Utilities/gdcmopenjpeg-v2/mj2/wrap_j2k_in_mj2.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "openjpeg.h"
-#include "j2k.h"
-#include "jp2.h"
-#include "cio.h"
-#include "mj2.h"
-
-static int int_ceildiv(int a, int b) {
-  return (a + b - 1) / b;
-}
-
-/**
-Size of memory first allocated for MOOV box
-*/
-#define TEMP_BUF 10000
-
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-
-
-static void read_siz_marker(FILE *file, opj_image_t *image)
-{
-  int len,i;
-  char buf, buf2[2];
-  char *siz_buffer;
-  opj_cio_t *cio;
-
-  fseek(file, 0, SEEK_SET);
-  do {
-    fread(&buf,1,1, file);
-    if (buf==(char)0xff)
-      fread(&buf,1,1, file);
-  }
-  while (!(buf==(char)0x51));
-
-  fread(buf2,2,1,file);    /* Lsiz                */
-  len = ((buf2[0])<<8) + buf2[1];
-
-  siz_buffer = (char*) malloc(len * sizeof(char));
-  fread(siz_buffer,len, 1, file);
-  cio = opj_cio_open(NULL, siz_buffer, len);
-
-  cio_read(cio, 2);      /* Rsiz (capabilities) */
-  image->x1 = cio_read(cio, 4);  /* Xsiz                */
-  image->y1 = cio_read(cio, 4);  /* Ysiz                */
-  image->x0 = cio_read(cio, 4);  /* X0siz               */
-  image->y0 = cio_read(cio, 4);  /* Y0siz               */
-  cio_skip(cio, 16);      /* XTsiz, YTsiz, XT0siz, YT0siz        */
-
-  image->numcomps = cio_read(cio,2);  /* Csiz                */
-  image->comps =
-    (opj_image_comp_t *) malloc(image->numcomps * sizeof(opj_image_comp_t));
-
-  for (i = 0; i < image->numcomps; i++) {
-    int tmp;
-    tmp = cio_read(cio,1);    /* Ssiz_i          */
-    image->comps[i].prec = (tmp & 0x7f) + 1;
-    image->comps[i].sgnd = tmp >> 7;
-    image->comps[i].dx = cio_read(cio,1);  /* XRsiz_i         */
-    image->comps[i].dy = cio_read(cio,1);  /* YRsiz_i         */
-    image->comps[i].resno_decoded = 0;  /* number of resolution decoded */
-    image->comps[i].factor = 0;  /* reducing factor by component */
-  }
-  fseek(file, 0, SEEK_SET);
-  opj_cio_close(cio);
-}
-
-static void setparams(opj_mj2_t *movie, opj_image_t *image) {
-  int i, depth_0, depth, sign;
-
-  movie->tk[0].sample_rate = 25;
-  movie->tk[0].w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
-  movie->tk[0].h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
-  mj2_init_stdmovie(movie);
-
-  movie->tk[0].depth = image->comps[0].prec;
-
-  if (image->numcomps==3) {
-    if ((image->comps[0].dx == 1)
-  && (image->comps[1].dx == 1)
-  && (image->comps[2].dx == 1))
-      movie->tk[0].CbCr_subsampling_dx = 1;
-    else
-  if ((image->comps[0].dx == 1)
-  && (image->comps[1].dx == 2)
-  && (image->comps[2].dx == 2))
-      movie->tk[0].CbCr_subsampling_dx = 2;
-    else
-      fprintf(stderr,"Image component sizes are incoherent\n");
-
-    if ((image->comps[0].dy == 1)
-  && (image->comps[1].dy == 1)
-  && (image->comps[2].dy == 1))
-      movie->tk[0].CbCr_subsampling_dy = 1;
-    else
-  if ((image->comps[0].dy == 1)
-  && (image->comps[1].dy == 2)
-  && (image->comps[2].dy == 2))
-      movie->tk[0].CbCr_subsampling_dy = 2;
-    else
-      fprintf(stderr,"Image component sizes are incoherent\n");
-  }
-
-  movie->tk[0].sample_rate = 25;
-
-  movie->tk[0].jp2_struct.numcomps = image->numcomps;  // NC
-
-  /* Init Standard jp2 structure */
-
-  movie->tk[0].jp2_struct.comps =
-    (opj_jp2_comps_t *) malloc(movie->tk[0].jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
-  movie->tk[0].jp2_struct.precedence = 0;   /* PRECEDENCE*/
-  movie->tk[0].jp2_struct.approx = 0;   /* APPROX*/
-  movie->tk[0].jp2_struct.brand = JP2_JP2;  /* BR         */
-  movie->tk[0].jp2_struct.minversion = 0;  /* MinV       */
-  movie->tk[0].jp2_struct.numcl = 1;
-  movie->tk[0].jp2_struct.cl = (unsigned int *) malloc(movie->tk[0].jp2_struct.numcl * sizeof(int));
-  movie->tk[0].jp2_struct.cl[0] = JP2_JP2;  /* CL0 : JP2  */
-  movie->tk[0].jp2_struct.C = 7;      /* C : Always 7*/
-  movie->tk[0].jp2_struct.UnkC = 0;      /* UnkC, colorspace specified in colr box*/
-  movie->tk[0].jp2_struct.IPR = 0;      /* IPR, no intellectual property*/
-  movie->tk[0].jp2_struct.w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
-  movie->tk[0].jp2_struct.h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
-
-  depth_0 = image->comps[0].prec - 1;
-  sign = image->comps[0].sgnd;
-  movie->tk[0].jp2_struct.bpc = depth_0 + (sign << 7);
-
-  for (i = 1; i < image->numcomps; i++) {
-    depth = image->comps[i].prec - 1;
-    sign = image->comps[i].sgnd;
-    if (depth_0 != depth)
-      movie->tk[0].jp2_struct.bpc = 255;
-  }
-
-  for (i = 0; i < image->numcomps; i++)
-    movie->tk[0].jp2_struct.comps[i].bpcc =
-    image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
-
-  if ((image->numcomps == 1 || image->numcomps == 3)
-    && (movie->tk[0].jp2_struct.bpc != 255))
-    movie->tk[0].jp2_struct.meth = 1;
-  else
-    movie->tk[0].jp2_struct.meth = 2;
-
-    if (image->numcomps == 1)
-     movie->tk[0].jp2_struct.enumcs = 17;  // Grayscale
-
-    else
-  if ((image->comps[0].dx == 1)
-  && (image->comps[1].dx == 1)
-  && (image->comps[2].dx == 1)
-    && (image->comps[0].dy == 1)
-  && (image->comps[1].dy == 1)
-  && (image->comps[2].dy == 1))
-     movie->tk[0].jp2_struct.enumcs = 16;    // RGB
-
-    else
-  if ((image->comps[0].dx == 1)
-  && (image->comps[1].dx == 2)
-  && (image->comps[2].dx == 2)
-    && (image->comps[0].dy == 1)
-  && (image->comps[1].dy == 2)
-  && (image->comps[2].dy == 2))
-     movie->tk[0].jp2_struct.enumcs = 18;  // YUV
-
-  else
-    movie->tk[0].jp2_struct.enumcs = 0;  // Unkown profile */
-}
-
-int main(int argc, char *argv[]) {
-  opj_cinfo_t* cinfo;
-  opj_event_mgr_t event_mgr;    /* event manager */
-  unsigned int snum;
-  opj_mj2_t *movie;
-  mj2_sample_t *sample;
-  unsigned char* frame_codestream;
-  FILE *mj2file, *j2kfile;
-  char j2kfilename[50];
-  char *buf;
-  int offset, mdat_initpos;
-  opj_image_t img;
-   opj_cio_t *cio;
-  mj2_cparameters_t parameters;
-
-  if (argc != 3) {
-    printf("Bad syntax: Usage: MJ2_Wrapper source_location mj2_filename\n");
-    printf("Example: MJ2_Wrapper input/input output.mj2\n");
-    return 1;
-  }
-
-  mj2file = fopen(argv[2], "wb");
-
-  if (!mj2file) {
-    fprintf(stderr, "failed to open %s for writing\n", argv[2]);
-    return 1;
-  }
-
-  /*
-  configure the event callbacks (not required)
-  setting of each callback is optionnal
-  */
-  memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
-  event_mgr.error_handler = error_callback;
-  event_mgr.warning_handler = warning_callback;
-  event_mgr.info_handler = info_callback;
-
-  /* get a MJ2 decompressor handle */
-  cinfo = mj2_create_compress();
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
-
-  /* setup the decoder encoding parameters using user parameters */
-  movie = (opj_mj2_t*) cinfo->mj2_handle;
-  mj2_setup_encoder(cinfo->mj2_handle, &parameters);
-
-
-  /* Writing JP, FTYP and MDAT boxes
-  Assuming that the JP and FTYP boxes won't be longer than 300 bytes */
-
-  buf = (char*) malloc (300 * sizeof(char));
-  cio = opj_cio_open(movie->cinfo, buf, 300);
-  mj2_write_jp(cio);
-  mj2_write_ftyp(movie, cio);
-  mdat_initpos = cio_tell(cio);
-  cio_skip(cio, 4);
-  cio_write(cio,MJ2_MDAT, 4);
-  fwrite(buf,cio_tell(cio),1,mj2file);
-  free(buf);
-
-  // Insert each j2k codestream in a JP2C box
-  snum=0;
-  offset = 0;
-  while(1)
-  {
-    sample = &movie->tk[0].sample[snum];
-    sprintf(j2kfilename,"%s_%05d.j2k",argv[1],snum);
-    j2kfile = fopen(j2kfilename, "rb");
-    if (!j2kfile) {
-      if (snum==0) {  // Could not open a single codestream
-        fprintf(stderr, "failed to open %s for reading\n",j2kfilename);
-        return 1;
-      }
-      else {        // Tried to open a inexistant codestream
-        fprintf(stdout,"%d frames are being added to the MJ2 file\n",snum);
-        break;
-      }
-    }
-
-    // Calculating offset for samples and chunks
-    offset += cio_tell(cio);
-    sample->offset = offset;
-    movie->tk[0].chunk[snum].offset = offset;  // There will be one sample per chunk
-
-    // Calculating sample size
-    fseek(j2kfile,0,SEEK_END);
-    sample->sample_size = ftell(j2kfile) + 8; // Sample size is codestream + JP2C box header
-    fseek(j2kfile,0,SEEK_SET);
-
-    // Reading siz marker of j2k image for the first codestream
-    if (snum==0)
-      read_siz_marker(j2kfile, &img);
-
-    // Writing JP2C box header
-    frame_codestream = (unsigned char*) malloc (sample->sample_size+8);
-    cio = opj_cio_open(movie->cinfo, frame_codestream, sample->sample_size);
-    cio_write(cio,sample->sample_size, 4);  // Sample size
-    cio_write(cio,JP2_JP2C, 4);  // JP2C
-
-    // Writing codestream from J2K file to MJ2 file
-    fread(frame_codestream+8,sample->sample_size-8,1,j2kfile);
-    fwrite(frame_codestream,sample->sample_size,1,mj2file);
-    cio_skip(cio, sample->sample_size-8);
-
-    // Ending loop
-    fclose(j2kfile);
-    snum++;
-    movie->tk[0].sample = realloc(movie->tk[0].sample, (snum+1) * sizeof(mj2_sample_t));
-    movie->tk[0].chunk = realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
-    free(frame_codestream);
-  }
-
-  // Writing the MDAT box length in header
-  offset += cio_tell(cio);
-  buf = (char*) malloc (4 * sizeof(char));
-  cio = opj_cio_open(movie->cinfo, buf, 4);
-  cio_write(cio,offset-mdat_initpos,4);
-  fseek(mj2file,(long)mdat_initpos,SEEK_SET);
-  fwrite(buf,4,1,mj2file);
-  fseek(mj2file,0,SEEK_END);
-  free(buf);
-
-  // Setting movie parameters
-  movie->tk[0].num_samples=snum;
-  movie->tk[0].num_chunks=snum;
-  setparams(movie, &img);
-
-  // Writing MOOV box
-  buf = (char*) malloc ((TEMP_BUF+snum*20) * sizeof(char));
-  cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20));
-  mj2_write_moov(movie, cio);
-  fwrite(buf,cio_tell(cio),1,mj2file);
-
-  // Ending program
-  fclose(mj2file);
-  free(img.comps);
-  opj_cio_close(cio);
-  mj2_destroy_compress(movie);
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/openjpeg_mangle.h.in b/Utilities/gdcmopenjpeg-v2/openjpeg_mangle.h.in
deleted file mode 100644
index 62f15ec..0000000
--- a/Utilities/gdcmopenjpeg-v2/openjpeg_mangle.h.in
+++ /dev/null
@@ -1,278 +0,0 @@
-/* This file was generated by CMake http://www.cmake.org */
-
-#ifndef @MANGLE_PREFIX at _mangle_h
-#define @MANGLE_PREFIX at _mangle_h
-
-/*
- * This header file mangles all symbols exported from the openjpeg library.
- * It is included in all files while building the openjpeg library.  Due to
- * namespace pollution, no openjpeg headers should be included in .h files in
- * GDCM.
- *
- * The following command was used to obtain the symbol list:
- *
- * nm lib at MANGLE_PREFIX@.a | grep " [RT] "
- */
-
-#define MCT_ELEMENT_SIZE                       @MANGLE_PREFIX at _MCT_ELEMENT_SIZE
-#define _ProfInit                              @MANGLE_PREFIX at __ProfInit
-#define _ProfPrint                             @MANGLE_PREFIX at __ProfPrint
-#define _ProfSave                              @MANGLE_PREFIX at __ProfSave
-#define _ProfStart                             @MANGLE_PREFIX at __ProfStart
-#define _ProfStop                              @MANGLE_PREFIX at __ProfStop
-#define bio_create                             @MANGLE_PREFIX at _bio_create
-#define bio_destroy                            @MANGLE_PREFIX at _bio_destroy
-#define bio_flush                              @MANGLE_PREFIX at _bio_flush
-#define bio_inalign                            @MANGLE_PREFIX at _bio_inalign
-#define bio_init_dec                           @MANGLE_PREFIX at _bio_init_dec
-#define bio_init_enc                           @MANGLE_PREFIX at _bio_init_enc
-#define bio_numbytes                           @MANGLE_PREFIX at _bio_numbytes
-#define bio_read                               @MANGLE_PREFIX at _bio_read
-#define bio_write                              @MANGLE_PREFIX at _bio_write
-#define dwt_calc_explicit_stepsizes            @MANGLE_PREFIX at _dwt_calc_explicit_stepsizes
-#define dwt_decode                             @MANGLE_PREFIX at _dwt_decode
-#define dwt_decode_real                        @MANGLE_PREFIX at _dwt_decode_real
-#define dwt_encode                             @MANGLE_PREFIX at _dwt_encode
-#define dwt_encode_real                        @MANGLE_PREFIX at _dwt_encode_real
-#define dwt_getgain                            @MANGLE_PREFIX at _dwt_getgain
-#define dwt_getgain_real                       @MANGLE_PREFIX at _dwt_getgain_real
-#define dwt_getnorm                            @MANGLE_PREFIX at _dwt_getnorm
-#define dwt_getnorm_real                       @MANGLE_PREFIX at _dwt_getnorm_real
-#define get_all_encoding_parameters            @MANGLE_PREFIX at _get_all_encoding_parameters
-#define get_default_stride                     @MANGLE_PREFIX at _get_default_stride
-#define get_encoding_parameters                @MANGLE_PREFIX at _get_encoding_parameters
-#define get_mct_norms                          @MANGLE_PREFIX at _get_mct_norms
-#define get_mct_norms_real                     @MANGLE_PREFIX at _get_mct_norms_real
-#define get_tp_stride                          @MANGLE_PREFIX at _get_tp_stride
-#define j2k_build_decoder                      @MANGLE_PREFIX at _j2k_build_decoder
-#define j2k_build_encoder                      @MANGLE_PREFIX at _j2k_build_encoder
-#define j2k_convert_progression_order          @MANGLE_PREFIX at _j2k_convert_progression_order
-#define j2k_copy_default_tcp_and_create_tcd    @MANGLE_PREFIX at _j2k_copy_default_tcp_and_create_tcd
-#define j2k_create_compress                    @MANGLE_PREFIX at _j2k_create_compress
-#define j2k_create_decompress                  @MANGLE_PREFIX at _j2k_create_decompress
-#define j2k_decode                             @MANGLE_PREFIX at _j2k_decode
-#define j2k_decode_tile                        @MANGLE_PREFIX at _j2k_decode_tile
-#define j2k_decode_tiles                       @MANGLE_PREFIX at _j2k_decode_tiles
-#define j2k_decoding_validation                @MANGLE_PREFIX at _j2k_decoding_validation
-#define j2k_destroy                            @MANGLE_PREFIX at _j2k_destroy
-#define j2k_destroy_header_memory              @MANGLE_PREFIX at _j2k_destroy_header_memory
-#define j2k_dump_image                         @MANGLE_PREFIX at _j2k_dump_image
-#define j2k_encode                             @MANGLE_PREFIX at _j2k_encode
-#define j2k_encoding_validation                @MANGLE_PREFIX at _j2k_encoding_validation
-#define j2k_end_compress                       @MANGLE_PREFIX at _j2k_end_compress
-#define j2k_end_decompress                     @MANGLE_PREFIX at _j2k_end_decompress
-#define j2k_mct_read_functions_to_float        @MANGLE_PREFIX at _j2k_mct_read_functions_to_float
-#define j2k_mct_read_functions_to_int32        @MANGLE_PREFIX at _j2k_mct_read_functions_to_int32
-#define j2k_mct_validation                     @MANGLE_PREFIX at _j2k_mct_validation
-#define j2k_mct_write_functions_from_float     @MANGLE_PREFIX at _j2k_mct_write_functions_from_float
-#define j2k_memory_marker_handler_tab          @MANGLE_PREFIX at _j2k_memory_marker_handler_tab
-#define j2k_prog_order_list                    @MANGLE_PREFIX at _j2k_prog_order_list
-#define j2k_read_header                        @MANGLE_PREFIX at _j2k_read_header
-#define j2k_read_header_procedure              @MANGLE_PREFIX at _j2k_read_header_procedure
-#define j2k_read_tile_header                   @MANGLE_PREFIX at _j2k_read_tile_header
-#define j2k_set_decode_area                    @MANGLE_PREFIX at _j2k_set_decode_area
-#define j2k_setup_decoder                      @MANGLE_PREFIX at _j2k_setup_decoder
-#define j2k_setup_decoding                     @MANGLE_PREFIX at _j2k_setup_decoding
-#define j2k_setup_encoder                      @MANGLE_PREFIX at _j2k_setup_encoder
-#define j2k_setup_header_reading               @MANGLE_PREFIX at _j2k_setup_header_reading
-#define j2k_setup_header_writting              @MANGLE_PREFIX at _j2k_setup_header_writting
-#define j2k_setup_mct_encoding                 @MANGLE_PREFIX at _j2k_setup_mct_encoding
-#define j2k_start_compress                     @MANGLE_PREFIX at _j2k_start_compress
-#define j2k_write_tile                         @MANGLE_PREFIX at _j2k_write_tile
-#define jp2_create                             @MANGLE_PREFIX at _jp2_create
-#define jp2_decode                             @MANGLE_PREFIX at _jp2_decode
-#define jp2_decode_tile                        @MANGLE_PREFIX at _jp2_decode_tile
-#define jp2_default_validation                 @MANGLE_PREFIX at _jp2_default_validation
-#define jp2_destroy                            @MANGLE_PREFIX at _jp2_destroy
-#define jp2_encode                             @MANGLE_PREFIX at _jp2_encode
-#define jp2_end_compress                       @MANGLE_PREFIX at _jp2_end_compress
-#define jp2_end_decompress                     @MANGLE_PREFIX at _jp2_end_decompress
-#define jp2_header                             @MANGLE_PREFIX at _jp2_header
-#define jp2_img_header                         @MANGLE_PREFIX at _jp2_img_header
-#define jp2_read_header                        @MANGLE_PREFIX at _jp2_read_header
-#define jp2_read_header_procedure              @MANGLE_PREFIX at _jp2_read_header_procedure
-#define jp2_read_jp2h                          @MANGLE_PREFIX at _jp2_read_jp2h
-#define jp2_read_tile_header                   @MANGLE_PREFIX at _jp2_read_tile_header
-#define jp2_set_decode_area                    @MANGLE_PREFIX at _jp2_set_decode_area
-#define jp2_setup_decoder                      @MANGLE_PREFIX at _jp2_setup_decoder
-#define jp2_setup_encoder                      @MANGLE_PREFIX at _jp2_setup_encoder
-#define jp2_skip_jp2c                          @MANGLE_PREFIX at _jp2_skip_jp2c
-#define jp2_start_compress                     @MANGLE_PREFIX at _jp2_start_compress
-#define jp2_write_jp2h                         @MANGLE_PREFIX at _jp2_write_jp2h
-#define jp2_write_tile                         @MANGLE_PREFIX at _jp2_write_tile
-#define jpt_init_msg_header                    @MANGLE_PREFIX at _jpt_init_msg_header
-#define jpt_read_VBAS_info                     @MANGLE_PREFIX at _jpt_read_VBAS_info
-#define jpt_read_msg_header                    @MANGLE_PREFIX at _jpt_read_msg_header
-#define jpt_reinit_msg_header                  @MANGLE_PREFIX at _jpt_reinit_msg_header
-#define mct_decode                             @MANGLE_PREFIX at _mct_decode
-#define mct_decode_custom                      @MANGLE_PREFIX at _mct_decode_custom
-#define mct_decode_real                        @MANGLE_PREFIX at _mct_decode_real
-#define mct_encode                             @MANGLE_PREFIX at _mct_encode
-#define mct_encode_custom                      @MANGLE_PREFIX at _mct_encode_custom
-#define mct_encode_real                        @MANGLE_PREFIX at _mct_encode_real
-#define mct_getnorm                            @MANGLE_PREFIX at _mct_getnorm
-#define mct_getnorm_real                       @MANGLE_PREFIX at _mct_getnorm_real
-#define mqc_bypass_enc                         @MANGLE_PREFIX at _mqc_bypass_enc
-#define mqc_bypass_flush_enc                   @MANGLE_PREFIX at _mqc_bypass_flush_enc
-#define mqc_bypass_init_enc                    @MANGLE_PREFIX at _mqc_bypass_init_enc
-#define mqc_create                             @MANGLE_PREFIX at _mqc_create
-#define mqc_decode                             @MANGLE_PREFIX at _mqc_decode
-#define mqc_destroy                            @MANGLE_PREFIX at _mqc_destroy
-#define mqc_encode                             @MANGLE_PREFIX at _mqc_encode
-#define mqc_erterm_enc                         @MANGLE_PREFIX at _mqc_erterm_enc
-#define mqc_flush                              @MANGLE_PREFIX at _mqc_flush
-#define mqc_init_dec                           @MANGLE_PREFIX at _mqc_init_dec
-#define mqc_init_enc                           @MANGLE_PREFIX at _mqc_init_enc
-#define mqc_numbytes                           @MANGLE_PREFIX at _mqc_numbytes
-#define mqc_reset_enc                          @MANGLE_PREFIX at _mqc_reset_enc
-#define mqc_resetstates                        @MANGLE_PREFIX at _mqc_resetstates
-#define mqc_restart_enc                        @MANGLE_PREFIX at _mqc_restart_enc
-#define mqc_restart_init_enc                   @MANGLE_PREFIX at _mqc_restart_init_enc
-#define mqc_segmark_enc                        @MANGLE_PREFIX at _mqc_segmark_enc
-#define mqc_setstate                           @MANGLE_PREFIX at _mqc_setstate
-#define opj_calculate_norms                    @MANGLE_PREFIX at _opj_calculate_norms
-#define opj_clock                              @MANGLE_PREFIX at _opj_clock
-#define opj_create_compress                    @MANGLE_PREFIX at _opj_create_compress
-#define opj_create_decompress                  @MANGLE_PREFIX at _opj_create_decompress
-#define opj_decode                             @MANGLE_PREFIX at _opj_decode
-#define opj_decode_tile_data                   @MANGLE_PREFIX at _opj_decode_tile_data
-#define opj_default_callback                   @MANGLE_PREFIX at _opj_default_callback
-#define opj_destroy_codec                      @MANGLE_PREFIX at _opj_destroy_codec
-#define opj_destroy_cstr_info                  @MANGLE_PREFIX at _opj_destroy_cstr_info
-#define opj_encode                             @MANGLE_PREFIX at _opj_encode
-#define opj_end_compress                       @MANGLE_PREFIX at _opj_end_compress
-#define opj_end_decompress                     @MANGLE_PREFIX at _opj_end_decompress
-#define opj_event_msg                          @MANGLE_PREFIX at _opj_event_msg
-#define opj_image_comp_update                  @MANGLE_PREFIX at _opj_image_comp_update
-#define opj_image_create                       @MANGLE_PREFIX at _opj_image_create
-#define opj_image_create0                      @MANGLE_PREFIX at _opj_image_create0
-#define opj_image_destroy                      @MANGLE_PREFIX at _opj_image_destroy
-#define opj_image_tile_create                  @MANGLE_PREFIX at _opj_image_tile_create
-#define opj_lupDecompose                       @MANGLE_PREFIX at _opj_lupDecompose
-#define opj_lupInvert                          @MANGLE_PREFIX at _opj_lupInvert
-#define opj_lupSolve                           @MANGLE_PREFIX at _opj_lupSolve
-#define opj_matrix_inversion_f                 @MANGLE_PREFIX at _opj_matrix_inversion_f
-#define opj_procedure_list_add_procedure       @MANGLE_PREFIX at _opj_procedure_list_add_procedure
-#define opj_procedure_list_clear               @MANGLE_PREFIX at _opj_procedure_list_clear
-#define opj_procedure_list_create              @MANGLE_PREFIX at _opj_procedure_list_create
-#define opj_procedure_list_destroy             @MANGLE_PREFIX at _opj_procedure_list_destroy
-#define opj_procedure_list_get_first_procedure @MANGLE_PREFIX at _opj_procedure_list_get_first_procedure
-#define opj_procedure_list_get_nb_procedures   @MANGLE_PREFIX at _opj_procedure_list_get_nb_procedures
-#define opj_read_bytes_BE                      @MANGLE_PREFIX at _opj_read_bytes_BE
-#define opj_read_bytes_LE                      @MANGLE_PREFIX at _opj_read_bytes_LE
-#define opj_read_double_BE                     @MANGLE_PREFIX at _opj_read_double_BE
-#define opj_read_double_LE                     @MANGLE_PREFIX at _opj_read_double_LE
-#define opj_read_float_BE                      @MANGLE_PREFIX at _opj_read_float_BE
-#define opj_read_float_LE                      @MANGLE_PREFIX at _opj_read_float_LE
-#define opj_read_from_file                     @MANGLE_PREFIX at _opj_read_from_file
-#define opj_read_header                        @MANGLE_PREFIX at _opj_read_header
-#define opj_read_tile_header                   @MANGLE_PREFIX at _opj_read_tile_header
-#define opj_restrict_decoding                  @MANGLE_PREFIX at _opj_restrict_decoding
-#define opj_seek_from_file                     @MANGLE_PREFIX at _opj_seek_from_file
-#define opj_set_MCT                            @MANGLE_PREFIX at _opj_set_MCT
-#define opj_set_decode_area                    @MANGLE_PREFIX at _opj_set_decode_area
-#define opj_set_default_decoder_parameters     @MANGLE_PREFIX at _opj_set_default_decoder_parameters
-#define opj_set_default_encoder_parameters     @MANGLE_PREFIX at _opj_set_default_encoder_parameters
-#define opj_set_error_handler                  @MANGLE_PREFIX at _opj_set_error_handler
-#define opj_set_info_handler                   @MANGLE_PREFIX at _opj_set_info_handler
-#define opj_set_warning_handler                @MANGLE_PREFIX at _opj_set_warning_handler
-#define opj_setup_decoder                      @MANGLE_PREFIX at _opj_setup_decoder
-#define opj_setup_encoder                      @MANGLE_PREFIX at _opj_setup_encoder
-#define opj_skip_from_file                     @MANGLE_PREFIX at _opj_skip_from_file
-#define opj_start_compress                     @MANGLE_PREFIX at _opj_start_compress
-#define opj_stream_create                      @MANGLE_PREFIX at _opj_stream_create
-#define opj_stream_create_default_file_stream  @MANGLE_PREFIX at _opj_stream_create_default_file_stream
-#define opj_stream_create_file_stream          @MANGLE_PREFIX at _opj_stream_create_file_stream
-#define opj_stream_default_create              @MANGLE_PREFIX at _opj_stream_default_create
-#define opj_stream_default_read                @MANGLE_PREFIX at _opj_stream_default_read
-#define opj_stream_default_seek                @MANGLE_PREFIX at _opj_stream_default_seek
-#define opj_stream_default_skip                @MANGLE_PREFIX at _opj_stream_default_skip
-#define opj_stream_default_write               @MANGLE_PREFIX at _opj_stream_default_write
-#define opj_stream_destroy                     @MANGLE_PREFIX at _opj_stream_destroy
-#define opj_stream_flush                       @MANGLE_PREFIX at _opj_stream_flush
-#define opj_stream_has_seek                    @MANGLE_PREFIX at _opj_stream_has_seek
-#define opj_stream_read_data                   @MANGLE_PREFIX at _opj_stream_read_data
-#define opj_stream_read_seek                   @MANGLE_PREFIX at _opj_stream_read_seek
-#define opj_stream_read_skip                   @MANGLE_PREFIX at _opj_stream_read_skip
-#define opj_stream_seek                        @MANGLE_PREFIX at _opj_stream_seek
-#define opj_stream_set_read_function           @MANGLE_PREFIX at _opj_stream_set_read_function
-#define opj_stream_set_seek_function           @MANGLE_PREFIX at _opj_stream_set_seek_function
-#define opj_stream_set_skip_function           @MANGLE_PREFIX at _opj_stream_set_skip_function
-#define opj_stream_set_user_data               @MANGLE_PREFIX at _opj_stream_set_user_data
-#define opj_stream_set_write_function          @MANGLE_PREFIX at _opj_stream_set_write_function
-#define opj_stream_skip                        @MANGLE_PREFIX at _opj_stream_skip
-#define opj_stream_tell                        @MANGLE_PREFIX at _opj_stream_tell
-#define opj_stream_write_data                  @MANGLE_PREFIX at _opj_stream_write_data
-#define opj_stream_write_seek                  @MANGLE_PREFIX at _opj_stream_write_seek
-#define opj_stream_write_skip                  @MANGLE_PREFIX at _opj_stream_write_skip
-#define opj_version                            @MANGLE_PREFIX at _opj_version
-#define opj_write_bytes_BE                     @MANGLE_PREFIX at _opj_write_bytes_BE
-#define opj_write_bytes_LE                     @MANGLE_PREFIX at _opj_write_bytes_LE
-#define opj_write_double_BE                    @MANGLE_PREFIX at _opj_write_double_BE
-#define opj_write_double_LE                    @MANGLE_PREFIX at _opj_write_double_LE
-#define opj_write_float_BE                     @MANGLE_PREFIX at _opj_write_float_BE
-#define opj_write_float_LE                     @MANGLE_PREFIX at _opj_write_float_LE
-#define opj_write_from_file                    @MANGLE_PREFIX at _opj_write_from_file
-#define opj_write_tile                         @MANGLE_PREFIX at _opj_write_tile
-#define pi_check_next_level                    @MANGLE_PREFIX at _pi_check_next_level
-#define pi_create                              @MANGLE_PREFIX at _pi_create
-#define pi_create_decode                       @MANGLE_PREFIX at _pi_create_decode
-#define pi_create_encode                       @MANGLE_PREFIX at _pi_create_encode
-#define pi_destroy                             @MANGLE_PREFIX at _pi_destroy
-#define pi_initialise_encode                   @MANGLE_PREFIX at _pi_initialise_encode
-#define pi_next                                @MANGLE_PREFIX at _pi_next
-#define pi_update_decode_not_poc               @MANGLE_PREFIX at _pi_update_decode_not_poc
-#define pi_update_decode_poc                   @MANGLE_PREFIX at _pi_update_decode_poc
-#define pi_update_encode_not_poc               @MANGLE_PREFIX at _pi_update_encode_not_poc
-#define pi_update_encode_poc_and_final         @MANGLE_PREFIX at _pi_update_encode_poc_and_final
-#define pi_update_encoding_parameters          @MANGLE_PREFIX at _pi_update_encoding_parameters
-#define raw_create                             @MANGLE_PREFIX at _raw_create
-#define raw_decode                             @MANGLE_PREFIX at _raw_decode
-#define raw_destroy                            @MANGLE_PREFIX at _raw_destroy
-#define raw_init_dec                           @MANGLE_PREFIX at _raw_init_dec
-#define raw_numbytes                           @MANGLE_PREFIX at _raw_numbytes
-#define set_default_event_handler              @MANGLE_PREFIX at _set_default_event_handler
-#define t1_create                              @MANGLE_PREFIX at _t1_create
-#define t1_decode_cblks                        @MANGLE_PREFIX at _t1_decode_cblks
-#define t1_destroy                             @MANGLE_PREFIX at _t1_destroy
-#define t1_encode_cblks                        @MANGLE_PREFIX at _t1_encode_cblks
-#define t2_create                              @MANGLE_PREFIX at _t2_create
-#define t2_decode_packets                      @MANGLE_PREFIX at _t2_decode_packets
-#define t2_destroy                             @MANGLE_PREFIX at _t2_destroy
-#define t2_encode_packets                      @MANGLE_PREFIX at _t2_encode_packets
-#define tcd_code_block_dec_deallocate          @MANGLE_PREFIX at _tcd_code_block_dec_deallocate
-#define tcd_copy_tile_data                     @MANGLE_PREFIX at _tcd_copy_tile_data
-#define tcd_create                             @MANGLE_PREFIX at _tcd_create
-#define tcd_dc_level_shift_decode              @MANGLE_PREFIX at _tcd_dc_level_shift_decode
-#define tcd_dc_level_shift_encode              @MANGLE_PREFIX at _tcd_dc_level_shift_encode
-#define tcd_decode_tile                        @MANGLE_PREFIX at _tcd_decode_tile
-#define tcd_destroy                            @MANGLE_PREFIX at _tcd_destroy
-#define tcd_dwt_decode                         @MANGLE_PREFIX at _tcd_dwt_decode
-#define tcd_dwt_encode                         @MANGLE_PREFIX at _tcd_dwt_encode
-#define tcd_encode_tile                        @MANGLE_PREFIX at _tcd_encode_tile
-#define tcd_get_decoded_tile_size              @MANGLE_PREFIX at _tcd_get_decoded_tile_size
-#define tcd_get_encoded_tile_size              @MANGLE_PREFIX at _tcd_get_encoded_tile_size
-#define tcd_init                               @MANGLE_PREFIX at _tcd_init
-#define tcd_init_decode_tile                   @MANGLE_PREFIX at _tcd_init_decode_tile
-#define tcd_init_encode_tile                   @MANGLE_PREFIX at _tcd_init_encode_tile
-#define tcd_makelayer                          @MANGLE_PREFIX at _tcd_makelayer
-#define tcd_makelayer_fixed                    @MANGLE_PREFIX at _tcd_makelayer_fixed
-#define tcd_mct_decode                         @MANGLE_PREFIX at _tcd_mct_decode
-#define tcd_mct_encode                         @MANGLE_PREFIX at _tcd_mct_encode
-#define tcd_rate_allocate_encode               @MANGLE_PREFIX at _tcd_rate_allocate_encode
-#define tcd_rateallocate                       @MANGLE_PREFIX at _tcd_rateallocate
-#define tcd_rateallocate_fixed                 @MANGLE_PREFIX at _tcd_rateallocate_fixed
-#define tcd_t1_decode                          @MANGLE_PREFIX at _tcd_t1_decode
-#define tcd_t1_encode                          @MANGLE_PREFIX at _tcd_t1_encode
-#define tcd_t2_decode                          @MANGLE_PREFIX at _tcd_t2_decode
-#define tcd_t2_encode                          @MANGLE_PREFIX at _tcd_t2_encode
-#define tcd_update_tile_data                   @MANGLE_PREFIX at _tcd_update_tile_data
-#define tgt_create                             @MANGLE_PREFIX at _tgt_create
-#define tgt_decode                             @MANGLE_PREFIX at _tgt_decode
-#define tgt_destroy                            @MANGLE_PREFIX at _tgt_destroy
-#define tgt_encode                             @MANGLE_PREFIX at _tgt_encode
-#define tgt_init                               @MANGLE_PREFIX at _tgt_init
-#define tgt_reset                              @MANGLE_PREFIX at _tgt_reset
-#define tgt_setvalue                           @MANGLE_PREFIX at _tgt_setvalue
-
-#endif
diff --git a/Utilities/gdcmopenjpeg-v2/opj_configure.h.in b/Utilities/gdcmopenjpeg-v2/opj_configure.h.in
deleted file mode 100644
index fad7612..0000000
--- a/Utilities/gdcmopenjpeg-v2/opj_configure.h.in
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * here is where system comupted values get stored these values should only
- * change when the target compile platform changes
- */
-
-/* what byte order */
-#ifndef __OPJ_CONFIGURE_H
-#define __OPJ_CONFIGURE_H
-#cmakedefine CMAKE_WORDS_BIGENDIAN
-#ifdef CMAKE_WORDS_BIGENDIAN
-        #define OPJ_BIG_ENDIAN
-#else
-        #define OPJ_LITTLE_ENDIAN
-#endif
-
-#endif /* __OPJ_CONFIGURE_H */
diff --git a/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/CMakeLists.txt
deleted file mode 100644
index cc55b49..0000000
--- a/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-# Build the demo app, small examples
-
-# First thing define the common source:
-
-# Then check if getopt is present:
-include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-
-# Headers file are located here:
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  )
-
-# Do the proper thing when building static...if only there was configured
-# headers or def files instead
-if(NOT BUILD_SHARED_LIBS)
-  add_definitions(-DOPJ_STATIC)
-endif()
-
-#include(${OPENJPEG_SOURCE_DIR}/CMake/Free_CMakeImport.cmake)
-add_definitions ( -DFREEIMAGE_LIB )
-
-# Loop over all executables:
-foreach(exe test2_encoder test2_decoder)
-  add_executable(${exe} ${exe}.c)
-  target_link_libraries(${exe} ${OPJ_PREFIX}openjpeg)
-  target_link_libraries(${exe} ${FREEIMAGE_LIBRARIES})
-endforeach()
diff --git a/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/test2_decoder.c b/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/test2_decoder.c
deleted file mode 100644
index ce89eb4..0000000
--- a/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/test2_decoder.c
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define USE_OPJ_DEPRECATED
-/* set this macro to enable profiling for the given test */
-/* warning : in order to be effective, openjpeg must have been built with profiling enabled !! */
-//#define _PROFILE
-#include "openjpeg.h"
-#include "FreeImage.h"
-#ifdef WIN32
-#include <malloc.h>
-#endif
-#include <string.h>
-#include <stdlib.h>
-
-#define NB_EXTENSIONS 2
-/* -------------------------------------------------------------------------- */
-struct opj_format
-{
-  const char * m_extension;
-  OPJ_CODEC_FORMAT m_format;
-};
-
-const struct opj_format c_extensions[] =
-{
-  {".j2k",CODEC_J2K},
-  {".jp2",CODEC_JP2}
-};
-
-OPJ_CODEC_FORMAT get_format (const char * l_file_name)
-{
-  OPJ_INT32 i;
-  const struct opj_format * l_current = c_extensions;
-  for
-    (i=0;i<NB_EXTENSIONS;++i)
-  {
-    if
-      (! memcmp(l_current->m_extension,l_file_name + strlen(l_file_name)-4,4))
-    {
-      return l_current->m_format;
-    }
-    ++l_current;
-  }
-  return CODEC_UNKNOWN;
-}
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample error debug callback expecting no client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[ERROR] %s", msg);
-}
-/**
-sample warning debug callback expecting no client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main (int argc,char * argv [])
-{
-  opj_dparameters_t l_param;
-  opj_codec_t * l_codec;
-  opj_image_t * l_image;
-  FILE * l_file;
-  opj_stream_t * l_stream;
-  OPJ_UINT32 l_data_size;
-  OPJ_UINT32 l_max_data_size = 1000;
-  OPJ_UINT32 l_tile_index;
-  OPJ_BYTE * l_data = (OPJ_BYTE *) malloc(1000);
-  bool l_go_on = true;
-  OPJ_INT32 l_tile_x0,l_tile_y0;
-  OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y,l_nb_comps;
-  OPJ_INT32 l_current_tile_x0,l_current_tile_y0,l_current_tile_x1,l_current_tile_y1;
-  char * l_input_file,* l_output_file;
-  OPJ_INT32 l_min_x, l_min_y, l_max_x, l_max_y;
-  OPJ_CODEC_FORMAT l_codec_format;
-  FIBITMAP * l_bitmap;
-  unsigned char * l_image_data;
-  OPJ_INT32 l_req_x,l_req_y;
-  OPJ_UINT32 l_image_width,l_image_height,l_image_boundary,l_offset;
-  unsigned char * l_tile_ptr [3];
-  unsigned char * l_line_ptr, * l_current_ptr;
-  OPJ_UINT32 i,j;
-
-  if
-    (argc != 8)
-  {
-    printf("usage : ... \n");
-    return 1;
-  }
-
-  PROFINIT();
-  FreeImage_Initialise(0);
-
-  l_input_file = argv[1];
-  l_output_file = argv[2];
-  l_min_x = atoi(argv[3]);
-  l_min_y = atoi(argv[4]);
-  l_max_x = atoi(argv[5]);
-  l_max_y = atoi(argv[6]);
-
-  l_codec_format = get_format(l_input_file);
-
-  if
-    ((! l_data) || (l_codec_format == CODEC_UNKNOWN))
-  {
-    return 1;
-  }
-
-
-  opj_set_default_decoder_parameters(&l_param);
-
-  /** you may here add custom decoding parameters */
-  /* do not use layer decoding limitations */
-  l_param.cp_layer = 0;
-
-  /* do not use resolutions reductions */
-  l_param.cp_reduce = atoi(argv[7]);
-
-  /* to decode only a part of the image data */
-  //opj_restrict_decoding(&l_param,0,0,1000,1000);
-
-  l_codec = opj_create_decompress(l_codec_format);
-  if
-    (! l_codec)
-  {
-    free(l_data);
-    return 1;
-  }
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_info_handler(l_codec, info_callback,00);
-  opj_set_warning_handler(l_codec, warning_callback,00);
-  opj_set_error_handler(l_codec, error_callback,00);
-  opj_restrict_decoding(&l_param,l_min_x, l_min_y, l_max_x, l_max_y);
-
-  if
-    (! opj_setup_decoder(l_codec,&l_param))
-  {
-    free(l_data);
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-
-  l_file = fopen(l_input_file,"rb");
-  if
-    (! l_file)
-  {
-    fprintf(stdout, "Error opening input file\n");
-    free(l_data);
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-
-  l_stream = opj_stream_create_default_file_stream(l_file,true);
-
-  if
-    (! opj_read_header(l_codec,
-              &l_image,
-              &l_tile_x0,
-              &l_tile_y0,
-              &l_tile_width,
-              &l_tile_height,
-              &l_nb_tiles_x,
-              &l_nb_tiles_y,
-              l_stream))
-  {
-    free(l_data);
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-
-  if
-    ((l_tile_x0 != 0) || (l_tile_y0 != 0))
-  {
-    free(l_data);
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-
-  l_min_x -= l_min_x % l_tile_width;
-  l_min_y -= l_min_y % l_tile_height;
-
-  l_req_x = l_max_x % l_tile_width;
-  if
-    (l_req_x)
-  {
-    l_max_x += l_tile_width - l_req_x;
-  }
-
-  l_req_y = l_max_y % l_tile_height;
-  if
-    (l_req_y)
-  {
-    l_max_y += l_tile_height - l_req_y;
-  }
-
-  l_min_x = l_min_x < l_image->x0 ? l_image->x0 : l_min_x;
-  l_min_y = l_min_y < l_image->y0 ? l_image->y0 : l_min_y;
-  l_max_x = l_max_x > l_image->x1 ? l_image->x1 : l_max_x;
-  l_max_y = l_max_y > l_image->y1 ? l_image->y1 : l_max_y;
-
-  l_image_width = (l_max_x - l_min_x + (1 << l_param.cp_reduce) - 1) >> l_param.cp_reduce;
-  l_image_height = (l_max_y - l_min_y + (1 << l_param.cp_reduce) - 1) >> l_param.cp_reduce;
-  l_image_boundary = 3 * l_image_width;
-  l_req_x = l_image_boundary % 4;
-  if
-    (l_req_x)
-  {
-    l_image_boundary += 4-l_req_x;
-  }
-
-  l_bitmap = FreeImage_Allocate(l_image_width, l_image_height, 24, 0, 0, 0);
-  l_image_data = FreeImage_GetBits(l_bitmap);
-
-  while
-    (l_go_on)
-  {
-    if
-      (! opj_read_tile_header(
-            l_codec,
-            &l_tile_index,
-            &l_data_size,
-            &l_current_tile_x0,
-            &l_current_tile_y0,
-            &l_current_tile_x1,
-            &l_current_tile_y1,
-            &l_nb_comps,
-            &l_go_on,
-            l_stream))
-    {
-      free(l_data);
-      opj_stream_destroy(l_stream);
-      fclose(l_file);
-      opj_destroy_codec(l_codec);
-      opj_image_destroy(l_image);
-      return 1;
-    }
-    if
-      (l_go_on)
-    {
-      if
-        (l_data_size > l_max_data_size)
-      {
-        l_data = (OPJ_BYTE *) realloc(l_data,l_data_size);
-        if
-          (! l_data)
-        {
-          opj_stream_destroy(l_stream);
-          fclose(l_file);
-          opj_destroy_codec(l_codec);
-          opj_image_destroy(l_image);
-          return 1;
-        }
-        l_max_data_size = l_data_size;
-      }
-
-      if
-        (! opj_decode_tile_data(l_codec,l_tile_index,l_data,l_data_size,l_stream))
-      {
-        free(l_data);
-        opj_stream_destroy(l_stream);
-        fclose(l_file);
-        opj_destroy_codec(l_codec);
-        opj_image_destroy(l_image);
-        return 1;
-      }
-      /** now should inspect image to know the reduction factor and then how to behave with data */
-      l_offset = (((l_max_y - l_current_tile_y0 + (1 << l_param.cp_reduce) - 1)>>l_param.cp_reduce) - 1) * l_image_boundary + ((l_current_tile_x0 - l_min_x + (1 << l_param.cp_reduce) - 1)>> l_param.cp_reduce )* 3;
-
-      l_tile_width = (l_current_tile_x1 - l_current_tile_x0 + (1 << l_param.cp_reduce) - 1)>>l_param.cp_reduce;
-      l_tile_height = (l_current_tile_y1 - l_current_tile_y0 + (1 << l_param.cp_reduce) - 1)>>l_param.cp_reduce;
-      l_tile_ptr[0] = l_data + 2 * l_tile_width * l_tile_height;
-      l_tile_ptr[1] = l_data + l_tile_width * l_tile_height;
-      l_tile_ptr[2] = l_data ;
-      l_line_ptr = l_image_data + l_offset;
-      for
-        (i=0;i<l_tile_width;++i)
-      {
-        l_current_ptr = l_line_ptr;
-        for
-          (j=0;j<l_tile_height;++j)
-        {
-          *(l_current_ptr++) = *(l_tile_ptr[0]++);
-          *(l_current_ptr++) = *(l_tile_ptr[1]++);
-          *(l_current_ptr++) = *(l_tile_ptr[2]++);
-        }
-        l_line_ptr -= l_image_boundary;
-      }
-    }
-  }
-  if
-    (! opj_end_decompress(l_codec,l_stream))
-  {
-    free(l_data);
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-  free(l_data);
-  opj_stream_destroy(l_stream);
-  fclose(l_file);
-  opj_destroy_codec(l_codec);
-  opj_image_destroy(l_image);
-
-  // Print profiling
-  PROFPRINT();
-  FreeImage_Save(0,l_bitmap,l_output_file,0);
-  FreeImage_Unload(l_bitmap);
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/test2_encoder.c b/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/test2_encoder.c
deleted file mode 100644
index eccf197..0000000
--- a/Utilities/gdcmopenjpeg-v2/test_Free_image_V2_tile_handling/test2_encoder.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#define USE_OPJ_DEPRECATED
-/* set this macro to enable profiling for the given test */
-/* warning : in order to be effective, openjpeg must have been built with profiling enabled !! */
-//#define _PROFILE
-
-#include "openjpeg.h"
-#include <FreeImage.h>
-#include <string.h>
-#include <stdlib.h>
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample error debug callback expecting no client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[ERROR] %s", msg);
-}
-/**
-sample warning debug callback expecting no client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[INFO] %s", msg);
-}
-
-struct opj_format
-{
-  const char * m_extension;
-  OPJ_CODEC_FORMAT m_format;
-};
-
-const struct opj_format c_extensions[] =
-{
-  {".j2k",CODEC_J2K},
-  {".jp2",CODEC_JP2}
-};
-
-#define NB_EXTENSIONS 2
-OPJ_CODEC_FORMAT get_format (const char * l_file_name)
-{
-  OPJ_INT32 i;
-  const struct opj_format * l_current = c_extensions;
-  for
-    (i=0;i<NB_EXTENSIONS;++i)
-  {
-    if
-      (! memcmp(l_current->m_extension,l_file_name + strlen(l_file_name)-4,4))
-    {
-      return l_current->m_format;
-    }
-    ++l_current;
-  }
-  return CODEC_UNKNOWN;
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main (int argc, char * argv [])
-{
-  opj_cparameters_t l_param;
-  opj_codec_t * l_codec;
-  opj_image_t * l_image;
-  opj_image_cmptparm_t l_params [3];
-  FILE * l_file;
-  opj_stream_t * l_stream;
-  opj_image_cmptparm_t * l_current_param_ptr;
-  OPJ_UINT32 i,j,k,l;
-  OPJ_BYTE *l_tile_data,*l_line_ptr,*l_current_ptr;
-  OPJ_BYTE * l_tile_ptr [3];
-  OPJ_UINT32 l_tile_width,l_image_width,l_image_height,l_chunk_size,l_image_boundary,l_req_x,l_req_y,l_nb_tiles_x,l_nb_tiles_y,l_current_tile_nb,l_data_size;
-  OPJ_UINT32 l_offset;
-
-  OPJ_CODEC_FORMAT l_codec_format;
-  FIBITMAP * l_bitmap;
-  FREE_IMAGE_FORMAT l_input_format;
-  unsigned char * l_image_data;
-  char * l_input_file,*l_output_file;
-  if
-    (argc != 6)
-  {
-    printf("usage \n");
-    return 1;
-  }
-
-  l_input_file = argv[1];
-  l_output_file = argv[2];
-  l_tile_width = atoi(argv[3]);
-
-  FreeImage_Initialise(0);
-
-  l_codec_format = get_format(l_output_file);
-  if
-    (l_codec_format == CODEC_UNKNOWN)
-  {
-    return 1;
-  }
-
-  l_input_format = FreeImage_GetFileType(l_input_file,0);
-  if
-    (l_input_format == -1)
-  {
-    return 1;
-  }
-  l_bitmap = FreeImage_Load(l_input_format,l_input_file,0);
-  l_image_data = FreeImage_GetBits(l_bitmap);
-  l_image_width = FreeImage_GetWidth(l_bitmap);
-  l_image_height = FreeImage_GetHeight(l_bitmap);
-  l_chunk_size = FreeImage_GetBPP(l_bitmap);
-  l_chunk_size /= 8;
-
-  if
-    (l_chunk_size < 3)
-  {
-    return 1;
-  }
-  l_image_boundary = l_image_width * l_chunk_size;
-
-  l_req_x = l_image_boundary % 4;
-  if
-    (l_req_x)
-  {
-    l_image_boundary += 4 - l_req_x;
-  }
-
-  l_tile_data = (OPJ_BYTE*) malloc(l_tile_width * l_tile_width * 3);
-
-  l_nb_tiles_x = l_image_width / l_tile_width;
-  l_req_x = l_image_width % l_tile_width;
-  l_nb_tiles_y = l_image_height / l_tile_width;
-  l_req_y = l_image_height % l_tile_width;
-
-  opj_set_default_encoder_parameters(&l_param);
-  /** you may here add custom encoding parameters */
-  /* rate specifications */
-  /** number of quality layers in the stream */
-  l_param.tcp_numlayers = 1;
-  l_param.cp_fixed_quality = 1;
-  /* is using others way of calculation */
-  /* l_param.cp_disto_alloc = 1 or l_param.cp_fixed_alloc = 1 */
-  /* l_param.tcp_rates[0] = ... */
-
-
-  /* tile definitions parameters */
-  /* position of the tile grid aligned with the image */
-  l_param.cp_tx0 = 0;
-  l_param.cp_ty0 = 0;
-  /* tile size, we are using tile based encoding */
-  l_param.tile_size_on = true;
-  l_param.cp_tdx = l_tile_width;
-  l_param.cp_tdy = l_tile_width;
-
-  /* use irreversible encoding ?*/
-  l_param.irreversible = atoi(argv[5]);
-
-  /* do not bother with mct, the rsiz is set when calling opj_set_MCT*/
-  /*l_param.cp_rsiz = STD_RSIZ;*/
-
-  /* no cinema */
-  /*l_param.cp_cinema = 0;*/
-
-  /* no not bother using SOP or EPH markers, do not use custom size precinct */
-  /* number of precincts to specify */
-  /* l_param.csty = 0;*/
-  /* l_param.res_spec = ... */
-  /* l_param.prch_init[i] = .. */
-  /* l_param.prcw_init[i] = .. */
-
-
-  /* do not use progression order changes */
-  /*l_param.numpocs = 0;*/
-  /* l_param.POC[i].... */
-
-  /* do not restrain the size for a component.*/
-  /* l_param.max_comp_size = 0; */
-
-  /** block encoding style for each component, do not use at the moment */
-  /** J2K_CCP_CBLKSTY_TERMALL, J2K_CCP_CBLKSTY_LAZY, J2K_CCP_CBLKSTY_VSC, J2K_CCP_CBLKSTY_SEGSYM, J2K_CCP_CBLKSTY_RESET */
-  /* l_param.mode = 0;*/
-
-  /** number of resolutions */
-  l_param.numresolution = atoi(argv[4]);
-
-  /** progression order to use*/
-  /** LRCP, RLCP, RPCL, PCRL, CPRL */
-  l_param.prog_order = LRCP;
-
-  /** no "region" of interest, more precisally component */
-  /* l_param.roi_compno = -1; */
-  /* l_param.roi_shift = 0; */
-
-  /* we are not using multiple tile parts for a tile. */
-  /* l_param.tp_on = 0; */
-  /* l_param.tp_flag = 0; */
-
-  l_param.tcp_mct = 1;
-  /* if we are using mct */
-  /* opj_set_MCT(&l_param,l_mct,l_offsets,NUM_COMPS); */
-
-
-  /* image definition */
-  l_current_param_ptr = l_params;
-  for
-    (i=0;i<3;++i)
-  {
-    /* do not bother bpp useless */
-    /*l_current_param_ptr->bpp = COMP_PREC;*/
-    l_current_param_ptr->dx = 1;
-    l_current_param_ptr->dy = 1;
-    l_current_param_ptr->h = l_image_height;
-    l_current_param_ptr->sgnd = 0;
-    l_current_param_ptr->prec = 8;
-    l_current_param_ptr->w = l_image_width;
-    l_current_param_ptr->x0 = 0;
-    l_current_param_ptr->y0 = 0;
-    ++l_current_param_ptr;
-  }
-
-  l_codec = opj_create_compress(l_codec_format);
-  if
-    (! l_codec)
-  {
-    return 1;
-  }
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_info_handler(l_codec, info_callback,00);
-  opj_set_warning_handler(l_codec, warning_callback,00);
-  opj_set_error_handler(l_codec, error_callback,00);
-
-  l_image = opj_image_tile_create(3,l_params,CLRSPC_SRGB);
-  if
-    (! l_image)
-  {
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-  l_image->x0 = 0;
-  l_image->y0 = 0;
-  l_image->x1 = l_image_width;
-  l_image->y1 = l_image_height;
-  l_image->color_space = CLRSPC_SRGB;
-
-  if
-    (! opj_setup_encoder(l_codec,&l_param,l_image))
-  {
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-
-  l_file = fopen(l_output_file,"wb");
-  if
-    (! l_file)
-  {
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-
-  l_stream = opj_stream_create_default_file_stream(l_file,false);
-
-  if
-    (! opj_start_compress(l_codec,l_image,l_stream))
-  {
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-
-  l_current_tile_nb = 0;
-
-  for
-    (i=0;i<l_nb_tiles_y;++i)
-  {
-    for
-      (j=0;j<l_nb_tiles_x;++j)
-    {
-      l_offset = (l_image_height - i * l_tile_width - 1) * l_image_boundary + l_chunk_size * j * l_tile_width;
-      l_line_ptr = l_image_data + l_offset;
-      l_tile_ptr[0] = l_tile_data;
-      l_tile_ptr[1] = l_tile_data + l_tile_width * l_tile_width;
-      l_tile_ptr[2] = l_tile_data + 2 * l_tile_width * l_tile_width;
-      for
-        (k=0;k<l_tile_width;++k)
-      {
-        l_current_ptr = l_line_ptr;
-        for
-          (l=0;l<l_tile_width;++l)
-        {
-          *(l_tile_ptr[0]++) = *(l_current_ptr+2);
-          *(l_tile_ptr[1]++) = *(l_current_ptr+1);
-          *(l_tile_ptr[2]++) = *(l_current_ptr);
-          l_current_ptr += l_chunk_size;
-        }
-        l_line_ptr -= l_image_boundary;
-      }
-      l_data_size = l_tile_width * l_tile_width * 3;
-      if
-        (! opj_write_tile(l_codec,l_current_tile_nb++,l_tile_data,l_data_size,l_stream))
-      {
-        opj_stream_destroy(l_stream);
-        fclose(l_file);
-        opj_destroy_codec(l_codec);
-        opj_image_destroy(l_image);
-        return 1;
-      }
-    }
-    if
-      (l_req_x)
-    {
-      l_offset = (l_image_height - i * l_tile_width - 1) * l_image_boundary + l_chunk_size * j * l_tile_width;
-      l_line_ptr = l_image_data + l_offset;
-      l_tile_ptr[0] = l_tile_data;
-      l_tile_ptr[1] = l_tile_data + l_tile_width * l_req_x;
-      l_tile_ptr[2] = l_tile_data + 2 * l_tile_width * l_req_x;
-      for
-        (k=0;k<l_tile_width;++k)
-      {
-        l_current_ptr = l_line_ptr;
-        for
-          (l=0;l<l_req_x;++l)
-        {
-          *(l_tile_ptr[0]++) = *(l_current_ptr+2);
-          *(l_tile_ptr[1]++) = *(l_current_ptr+1);
-          *(l_tile_ptr[2]++) = *(l_current_ptr);
-          l_current_ptr += l_chunk_size;
-        }
-        l_line_ptr -= l_image_boundary;
-      }
-      l_data_size = l_tile_width * l_req_x * 3;
-      if
-        (! opj_write_tile(l_codec,l_current_tile_nb++,l_tile_data,l_data_size,l_stream))
-      {
-        opj_stream_destroy(l_stream);
-        fclose(l_file);
-        opj_destroy_codec(l_codec);
-        opj_image_destroy(l_image);
-        return 1;
-      }
-
-    }
-  }
-  if
-    (l_req_y)
-  {
-    for
-      (j=0;j<l_nb_tiles_x;++j)
-    {
-      l_offset = (l_image_height - i * l_tile_width - 1) * l_image_boundary + l_chunk_size * j * l_tile_width;
-      l_line_ptr = l_image_data + l_offset;
-      l_tile_ptr[0] = l_tile_data;
-      l_tile_ptr[1] = l_tile_data + l_tile_width * l_req_y;
-      l_tile_ptr[2] = l_tile_data + 2 * l_tile_width * l_req_y;
-      for
-        (k=0;k<l_req_y;++k)
-      {
-        l_current_ptr = l_line_ptr;
-        for
-          (l=0;l<l_tile_width;++l)
-        {
-          *(l_tile_ptr[0]++) = *(l_current_ptr+2);
-          *(l_tile_ptr[1]++) = *(l_current_ptr+1);
-          *(l_tile_ptr[2]++) = *(l_current_ptr);
-          l_current_ptr += l_chunk_size;
-        }
-        l_line_ptr -= l_image_boundary;
-      }
-      l_data_size = l_req_y * l_tile_width * 3;
-      if
-        (! opj_write_tile(l_codec,l_current_tile_nb++,l_tile_data,l_data_size,l_stream))
-      {
-        opj_stream_destroy(l_stream);
-        fclose(l_file);
-        opj_destroy_codec(l_codec);
-        opj_image_destroy(l_image);
-        return 1;
-      }
-    }
-    if
-      (l_req_x)
-    {
-      l_offset = (l_image_height - i * l_tile_width - 1) * l_image_boundary + l_chunk_size * j * l_tile_width;
-      l_line_ptr = l_image_data + l_offset;
-      l_tile_ptr[0] = l_tile_data;
-      l_tile_ptr[1] = l_tile_data + l_req_x * l_req_y;
-      l_tile_ptr[2] = l_tile_data + 2 * l_req_x * l_req_y;
-      for
-        (k=0;k<l_req_y;++k)
-      {
-        l_current_ptr = l_line_ptr;
-        for
-          (l=0;l<l_req_x;++l)
-        {
-          *(l_tile_ptr[0]++) = *(l_current_ptr+2);
-          *(l_tile_ptr[1]++) = *(l_current_ptr+1);
-          *(l_tile_ptr[2]++) = *(l_current_ptr);
-          l_current_ptr += l_chunk_size;
-        }
-        l_line_ptr -= l_image_boundary;
-      }
-      l_data_size = l_req_y * l_req_x * 3;
-      if
-        (! opj_write_tile(l_codec,l_current_tile_nb++,l_tile_data,l_data_size,l_stream))
-      {
-        opj_stream_destroy(l_stream);
-        fclose(l_file);
-        opj_destroy_codec(l_codec);
-        opj_image_destroy(l_image);
-        return 1;
-      }
-    }
-  }
-
-
-  if
-    (! opj_end_compress(l_codec,l_stream))
-  {
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-  opj_stream_destroy(l_stream);
-  fclose(l_file);
-  opj_destroy_codec(l_codec);
-  opj_image_destroy(l_image);
-
-
-  FreeImage_DeInitialise();
-
-  // Print profiling
-  PROFPRINT();
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/CMakeLists.txt b/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/CMakeLists.txt
deleted file mode 100644
index 251f59e..0000000
--- a/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# Build the demo app, small examples
-
-# First thing define the common source:
-
-# Then check if getopt is present:
-include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-
-# Headers file are located here:
-include_directories(
-  ${OPENJPEG_SOURCE_DIR}/libopenjpeg
-  )
-
-# Do the proper thing when building static...if only there was configured
-# headers or def files instead
-if(NOT BUILD_SHARED_LIBS)
-  add_definitions(-DOPJ_STATIC)
-endif()
-
-
-# Loop over all executables:
-foreach(exe test_encoder test_decoder)
-  add_executable(${exe} ${exe}.c)
-  target_link_libraries(${exe} ${OPJ_PREFIX}openjpeg)
-endforeach()
diff --git a/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/test_decoder.c b/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/test_decoder.c
deleted file mode 100644
index afc6485..0000000
--- a/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/test_decoder.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#define USE_OPJ_DEPRECATED
-/* set this macro to enable profiling for the given test */
-/* warning : in order to be effective, openjpeg must have been built with profiling enabled !! */
-//#define _PROFILE
-
-#include "openjpeg.h"
-#include "stdlib.h"
-#ifdef WIN32
-#include <malloc.h>
-#else
-#include <stdlib.h>
-#endif
-#define DA_X0 0
-#define DA_Y0 0
-#define DA_X1 1000
-#define DA_Y1 1000
-#define INPUT_FILE      "test.j2k"
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample error debug callback expecting no client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[ERROR] %s", msg);
-}
-/**
-sample warning debug callback expecting no client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main ()
-{
-  opj_dparameters_t l_param;
-  opj_codec_t * l_codec;
-  opj_image_t * l_image;
-  FILE * l_file;
-  opj_stream_t * l_stream;
-  OPJ_UINT32 l_data_size;
-  OPJ_UINT32 l_max_data_size = 1000;
-  OPJ_UINT32 l_tile_index;
-  OPJ_BYTE * l_data = (OPJ_BYTE *) malloc(1000);
-  bool l_go_on = true;
-  OPJ_INT32 l_tile_x0,l_tile_y0;
-  OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y,l_nb_comps;
-  OPJ_INT32 l_current_tile_x0,l_current_tile_y0,l_current_tile_x1,l_current_tile_y1;
-
-  PROFINIT();
-
-
-  if
-    (! l_data)
-  {
-    return 1;
-  }
-  opj_set_default_decoder_parameters(&l_param);
-
-  /** you may here add custom decoding parameters */
-  /* do not use layer decoding limitations */
-  l_param.cp_layer = 0;
-
-  /* do not use resolutions reductions */
-  l_param.cp_reduce = 0;
-
-  /* to decode only a part of the image data */
-  //opj_restrict_decoding(&l_param,0,0,1000,1000);
-
-  l_codec = opj_create_decompress(CODEC_J2K);
-  if
-    (! l_codec)
-  {
-    free(l_data);
-    return 1;
-  }
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_info_handler(l_codec, info_callback,00);
-  opj_set_warning_handler(l_codec, warning_callback,00);
-  opj_set_error_handler(l_codec, error_callback,00);
-
-  if
-    (! opj_setup_decoder(l_codec,&l_param))
-  {
-    free(l_data);
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-
-  l_file = fopen(INPUT_FILE,"rb");
-  if
-    (! l_file)
-  {
-    fprintf(stdout, "Error opening input file\n");
-    free(l_data);
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-
-  l_stream = opj_stream_create_default_file_stream(l_file,true);
-
-  if
-    (! opj_read_header(l_codec,
-              &l_image,
-              &l_tile_x0,
-              &l_tile_y0,
-              &l_tile_width,
-              &l_tile_height,
-              &l_nb_tiles_x,
-              &l_nb_tiles_y,
-              l_stream))
-  {
-    free(l_data);
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-  printf("Setting decoding area to %d,%d,%d,%d\n", DA_X0, DA_Y0, DA_X1, DA_Y1);
-  opj_set_decode_area(l_codec, DA_X0, DA_Y0, DA_X1, DA_Y1);
-  while
-    (l_go_on)
-  {
-    if
-      (! opj_read_tile_header(
-            l_codec,
-            &l_tile_index,
-            &l_data_size,
-            &l_current_tile_x0,
-            &l_current_tile_y0,
-            &l_current_tile_x1,
-            &l_current_tile_y1,
-            &l_nb_comps,
-            &l_go_on,
-            l_stream))
-    {
-      free(l_data);
-      opj_stream_destroy(l_stream);
-      fclose(l_file);
-      opj_destroy_codec(l_codec);
-      opj_image_destroy(l_image);
-      return 1;
-    }
-    if
-      (l_go_on)
-    {
-      if
-        (l_data_size > l_max_data_size)
-      {
-        l_data = (OPJ_BYTE *) realloc(l_data,l_data_size);
-        if
-          (! l_data)
-        {
-          opj_stream_destroy(l_stream);
-          fclose(l_file);
-          opj_destroy_codec(l_codec);
-          opj_image_destroy(l_image);
-          return 1;
-        }
-        l_max_data_size = l_data_size;
-      }
-
-      if
-        (! opj_decode_tile_data(l_codec,l_tile_index,l_data,l_data_size,l_stream))
-      {
-        free(l_data);
-        opj_stream_destroy(l_stream);
-        fclose(l_file);
-        opj_destroy_codec(l_codec);
-        opj_image_destroy(l_image);
-        return 1;
-      }
-      /** now should inspect image to know the reduction factor and then how to behave with data */
-    }
-  }
-  if
-    (! opj_end_decompress(l_codec,l_stream))
-  {
-    free(l_data);
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-  free(l_data);
-  opj_stream_destroy(l_stream);
-  fclose(l_file);
-  opj_destroy_codec(l_codec);
-  opj_image_destroy(l_image);
-
-  // Print profiling
-  PROFPRINT();
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/test_encoder.c b/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/test_encoder.c
deleted file mode 100644
index 2a10f49..0000000
--- a/Utilities/gdcmopenjpeg-v2/test_V2_tile_handling/test_encoder.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#define USE_OPJ_DEPRECATED
-
-#include "openjpeg.h"
-#include "stdlib.h"
-
-/* set this macro to enable profiling for the given test */
-/* warning : in order to be effective, openjpeg must have been built with profiling enabled !! */
-//#define _PROFILE
-
-#ifdef WIN32
-#include "windows.h" // needed for rand() function
-#else
-#include <stdlib.h>
-#endif
-
-
-#define NUM_COMPS      3
-#define IMAGE_WIDTH      2000
-#define IMAGE_HEIGHT    2000
-#define TILE_WIDTH      1000
-#define TILE_HEIGHT      1000
-#define COMP_PREC      8
-#define OUTPUT_FILE      "test.j2k"
-
-/* -------------------------------------------------------------------------- */
-
-/**
-sample error callback expecting a FILE* client object
-*/
-void error_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-void warning_callback_file(const char *msg, void *client_data) {
-  FILE *stream = (FILE*)client_data;
-  fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample error debug callback expecting no client object
-*/
-void error_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[ERROR] %s", msg);
-}
-/**
-sample warning debug callback expecting no client object
-*/
-void warning_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting no client object
-*/
-void info_callback(const char *msg, void *client_data) {
-  (void)client_data;
-  fprintf(stdout, "[INFO] %s", msg);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int main ()
-{
-  opj_cparameters_t l_param;
-  opj_codec_t * l_codec;
-  opj_image_t * l_image;
-  opj_image_cmptparm_t l_params [NUM_COMPS];
-  FILE * l_file;
-  opj_stream_t * l_stream;
-  OPJ_UINT32 l_nb_tiles = (IMAGE_WIDTH/TILE_WIDTH) * (IMAGE_HEIGHT/TILE_HEIGHT);
-  OPJ_UINT32 l_data_size = TILE_WIDTH * TILE_HEIGHT * NUM_COMPS * (COMP_PREC/8);
-
-#ifdef USING_MCT
-  const OPJ_FLOAT32 l_mct [] =
-  {
-    1 , 0 , 0 ,
-    0 , 1 , 0 ,
-    0 , 0 , 1
-  };
-
-  const OPJ_INT32 l_offsets [] =
-  {
-    128 , 128 , 128
-  };
-#endif
-
-  opj_image_cmptparm_t * l_current_param_ptr;
-  OPJ_UINT32 i;
-  OPJ_BYTE *l_data;
-
-  PROFINIT();
-  l_data = (OPJ_BYTE*) malloc(TILE_WIDTH * TILE_HEIGHT * NUM_COMPS * (COMP_PREC/8) * sizeof(OPJ_BYTE));
-
-  fprintf(stdout, "Encoding random values -> keep in mind that this is very hard to compress\n");
-  for
-    (i=0;i<l_data_size;++i)
-  {
-    l_data[i] = rand();
-  }
-
-  opj_set_default_encoder_parameters(&l_param);
-  /** you may here add custom encoding parameters */
-  /* rate specifications */
-  /** number of quality layers in the stream */
-  l_param.tcp_numlayers = 1;
-  l_param.cp_fixed_quality = 1;
-  l_param.tcp_distoratio[0] = 20;
-  /* is using others way of calculation */
-  /* l_param.cp_disto_alloc = 1 or l_param.cp_fixed_alloc = 1 */
-  /* l_param.tcp_rates[0] = ... */
-
-
-  /* tile definitions parameters */
-  /* position of the tile grid aligned with the image */
-  l_param.cp_tx0 = 0;
-  l_param.cp_ty0 = 0;
-  /* tile size, we are using tile based encoding */
-  l_param.tile_size_on = true;
-  l_param.cp_tdx = TILE_WIDTH;
-  l_param.cp_tdy = TILE_HEIGHT;
-
-  /* use irreversible encoding ?*/
-  l_param.irreversible = 1;
-
-  /* do not bother with mct, the rsiz is set when calling opj_set_MCT*/
-  /*l_param.cp_rsiz = STD_RSIZ;*/
-
-  /* no cinema */
-  /*l_param.cp_cinema = 0;*/
-
-  /* no not bother using SOP or EPH markers, do not use custom size precinct */
-  /* number of precincts to specify */
-  /* l_param.csty = 0;*/
-  /* l_param.res_spec = ... */
-  /* l_param.prch_init[i] = .. */
-  /* l_param.prcw_init[i] = .. */
-
-
-  /* do not use progression order changes */
-  /*l_param.numpocs = 0;*/
-  /* l_param.POC[i].... */
-
-  /* do not restrain the size for a component.*/
-  /* l_param.max_comp_size = 0; */
-
-  /** block encoding style for each component, do not use at the moment */
-  /** J2K_CCP_CBLKSTY_TERMALL, J2K_CCP_CBLKSTY_LAZY, J2K_CCP_CBLKSTY_VSC, J2K_CCP_CBLKSTY_SEGSYM, J2K_CCP_CBLKSTY_RESET */
-  /* l_param.mode = 0;*/
-
-  /** number of resolutions */
-  l_param.numresolution = 6;
-
-  /** progression order to use*/
-  /** LRCP, RLCP, RPCL, PCRL, CPRL */
-  l_param.prog_order = LRCP;
-
-  /** no "region" of interest, more precisally component */
-  /* l_param.roi_compno = -1; */
-  /* l_param.roi_shift = 0; */
-
-  /* we are not using multiple tile parts for a tile. */
-  /* l_param.tp_on = 0; */
-  /* l_param.tp_flag = 0; */
-
-  /* if we are using mct */
-#ifdef USING_MCT
-  opj_set_MCT(&l_param,l_mct,l_offsets,NUM_COMPS);
-#endif
-
-
-  /* image definition */
-  l_current_param_ptr = l_params;
-  for
-    (i=0;i<NUM_COMPS;++i)
-  {
-    /* do not bother bpp useless */
-    /*l_current_param_ptr->bpp = COMP_PREC;*/
-    l_current_param_ptr->dx = 1;
-    l_current_param_ptr->dy = 1;
-    l_current_param_ptr->h = IMAGE_HEIGHT;
-    l_current_param_ptr->sgnd = 0;
-    l_current_param_ptr->prec = COMP_PREC;
-    l_current_param_ptr->w = IMAGE_WIDTH;
-    l_current_param_ptr->x0 = 0;
-    l_current_param_ptr->y0 = 0;
-    ++l_current_param_ptr;
-  }
-
-  l_codec = opj_create_compress(CODEC_J2K);
-  if
-    (! l_codec)
-  {
-    return 1;
-  }
-
-  /* catch events using our callbacks and give a local context */
-  opj_set_info_handler(l_codec, info_callback,00);
-  opj_set_warning_handler(l_codec, warning_callback,00);
-  opj_set_error_handler(l_codec, error_callback,00);
-
-  l_image = opj_image_tile_create(NUM_COMPS,l_params,CLRSPC_SRGB);
-  if
-    (! l_image)
-  {
-    opj_destroy_codec(l_codec);
-    return 1;
-  }
-  l_image->x0 = 0;
-  l_image->y0 = 0;
-  l_image->x1 = IMAGE_WIDTH;
-  l_image->y1 = IMAGE_HEIGHT;
-  l_image->color_space = CLRSPC_SRGB;
-
-  if
-    (! opj_setup_encoder(l_codec,&l_param,l_image))
-  {
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-
-  l_file = fopen(OUTPUT_FILE,"wb");
-  if
-    (! l_file)
-  {
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-
-  l_stream = opj_stream_create_default_file_stream(l_file,false);
-
-  if
-    (! opj_start_compress(l_codec,l_image,l_stream))
-  {
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-  for
-    (i=0;i<l_nb_tiles;++i)
-  {
-    if
-      (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream))
-    {
-      opj_stream_destroy(l_stream);
-      fclose(l_file);
-      opj_destroy_codec(l_codec);
-      opj_image_destroy(l_image);
-      return 1;
-    }
-  }
-  if
-    (! opj_end_compress(l_codec,l_stream))
-  {
-    opj_stream_destroy(l_stream);
-    fclose(l_file);
-    opj_destroy_codec(l_codec);
-    opj_image_destroy(l_image);
-    return 1;
-  }
-  opj_stream_destroy(l_stream);
-  fclose(l_file);
-  opj_destroy_codec(l_codec);
-  opj_image_destroy(l_image);
-
-  // Print profiling
-  PROFPRINT();
-
-  return 0;
-}
diff --git a/Utilities/gdcmopenjpeg/CMakeLists.txt b/Utilities/gdcmopenjpeg/CMakeLists.txt
new file mode 100644
index 0000000..140fc3b
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/CMakeLists.txt
@@ -0,0 +1,385 @@
+# Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
+# Written by Mathieu Malaterre
+
+# This CMake project will by default create a library called openjpeg
+# But if you want to use this project within your own (CMake) project
+# you will eventually like to prefix the library to avoid linking confusion
+# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
+# e.g.:
+# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
+cmake_minimum_required(VERSION 2.8.2)
+
+if(COMMAND CMAKE_POLICY)
+  cmake_policy(SET CMP0003 NEW)
+  if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
+    cmake_policy(SET CMP0042 NEW)
+  endif()
+endif()
+
+if(NOT OPENJPEG_NAMESPACE)
+  set(OPENJPEG_NAMESPACE "OPENJPEG")
+  set(OPENJPEG_STANDALONE 1)
+endif()
+# In all cases:
+#string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
+set(OPENJPEG_LIBRARY_NAME gdcmopenjp2)
+
+project(${OPENJPEG_NAMESPACE} C)
+
+# Do full dependency headers.
+include_regular_expression("^.*$")
+
+#-----------------------------------------------------------------------------
+# OPENJPEG version number, useful for packaging and doxygen doc:
+set(OPENJPEG_VERSION_MAJOR 2)
+set(OPENJPEG_VERSION_MINOR 1)
+set(OPENJPEG_VERSION_BUILD 1)
+set(OPENJPEG_VERSION
+  "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
+set(PACKAGE_VERSION
+  "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
+
+# Because autotools does not support X.Y notation for SOVERSION, we have to use
+# two numbering, one for the openjpeg version and one for openjpeg soversion
+# version | soversion
+#   1.0   |  0
+#   1.1   |  1
+#   1.2   |  2
+#   1.3   |  3
+#   1.4   |  4
+#   1.5   |  5
+#   1.5.1 |  5
+#   2.0   |  6
+#   2.0.1 |  6
+#   2.1   |  7
+#   2.1.1 |  7
+# above is the recommendation by the OPJ team. If you really need to override this default,
+# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
+# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
+if(NOT OPENJPEG_SOVERSION)
+  set(OPENJPEG_SOVERSION 7)
+endif(NOT OPENJPEG_SOVERSION)
+set(OPENJPEG_LIBRARY_PROPERTIES
+  VERSION   "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
+  SOVERSION "${OPENJPEG_SOVERSION}"
+)
+
+# --------------------------------------------------------------------------
+# Path to additional CMake modules
+set(CMAKE_MODULE_PATH
+    ${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake
+    ${CMAKE_MODULE_PATH})
+
+# --------------------------------------------------------------------------
+# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
+# warnings
+if(WIN32)
+  if(NOT BORLAND)
+    if(NOT CYGWIN)
+      if(NOT MINGW)
+        if(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
+          add_definitions(
+            -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
+            -D_CRT_IS_WCTYPE_NO_DEPRECATE
+            -D_CRT_MANAGED_FP_NO_DEPRECATE
+            -D_CRT_NONSTDC_NO_DEPRECATE
+            -D_CRT_SECURE_NO_DEPRECATE
+            -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
+            -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
+            -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
+            -D_CRT_VCCLRIT_NO_DEPRECATE
+            -D_SCL_SECURE_NO_DEPRECATE
+            )
+        endif()
+      endif()
+    endif()
+  endif()
+endif()
+
+
+# --------------------------------------------------------------------------
+# Install directories
+# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
+option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
+
+string(TOLOWER ${PROJECT_NAME} projectname)
+set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
+
+if(NOT OPENJPEG_INSTALL_BIN_DIR)
+  set(OPENJPEG_INSTALL_BIN_DIR "bin")
+endif()
+
+if(NOT OPENJPEG_INSTALL_LIB_DIR)
+  set(OPENJPEG_INSTALL_LIB_DIR "lib")
+endif()
+
+if(NOT OPENJPEG_INSTALL_SHARE_DIR)
+  set(OPENJPEG_INSTALL_SHARE_DIR "share")
+endif()
+
+if(NOT OPENJPEG_INSTALL_DATA_DIR)
+  set(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
+endif()
+
+if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
+  set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
+endif()
+
+if(BUILD_DOC)
+if(NOT OPENJPEG_INSTALL_MAN_DIR)
+  set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
+endif()
+
+if(NOT OPENJPEG_INSTALL_DOC_DIR)
+  set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
+endif()
+endif()
+
+if(NOT OPENJPEG_INSTALL_JNI_DIR)
+  if(WIN32)
+    set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_BIN_DIR})
+  else()
+    set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_LIB_DIR})
+  endif()
+endif()
+
+if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
+  # We could install *.cmake files in share/ however those files contains
+  # hardcoded path to libraries on a multi-arch system (fedora/debian) those
+  # path will be different (lib/i386-linux-gnu vs lib/x86_64-linux-gnu)
+  set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
+endif()
+
+if (APPLE)
+	list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}")
+	option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
+endif()
+
+#-----------------------------------------------------------------------------
+# Big endian test:
+include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
+TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
+
+#-----------------------------------------------------------------------------
+# Setup file for setting custom ctest vars
+configure_file(
+  ${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/CTestCustom.cmake.in
+  ${${OPENJPEG_NAMESPACE}_BINARY_DIR}/CTestCustom.cmake
+  @ONLY
+  )
+
+#-----------------------------------------------------------------------------
+# OpenJPEG build configuration options.
+#option(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
+set (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
+set (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
+mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
+
+#-----------------------------------------------------------------------------
+# configure name mangling to allow multiple libraries to coexist
+# peacefully
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
+set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
+               ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
+               @ONLY)
+endif()
+
+#-----------------------------------------------------------------------------
+# Compiler specific flags:
+if(CMAKE_COMPILER_IS_GNUCC)
+  # For all builds, make sure openjpeg is std99 compliant:
+  # set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
+  # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
+  set(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
+endif()
+
+#-----------------------------------------------------------------------------
+# opj_config.h generation (1/2)
+
+# Check if some include files are provided by the system
+include(EnsureFileInclude)
+# These files are mandatory
+ensure_file_include("string.h"   HAVE_STRING_H YES)
+ensure_file_include("memory.h"   HAVE_MEMORY_H YES)
+ensure_file_include("stdlib.h"   HAVE_STDLIB_H YES)
+ensure_file_include("stdio.h"    HAVE_STDIO_H  YES)
+ensure_file_include("math.h"     HAVE_MATH_H   YES)
+ensure_file_include("float.h"    HAVE_FLOAT_H  YES)
+ensure_file_include("time.h"     HAVE_TIME_H   YES)
+ensure_file_include("stdarg.h"   HAVE_STDARG_H YES)
+ensure_file_include("ctype.h"    HAVE_CTYPE_H  YES)
+ensure_file_include("assert.h"   HAVE_ASSERT_H YES)
+
+# For the following files, we provide an alternative, they are not mandatory
+ensure_file_include("stdint.h"   OPJ_HAVE_STDINT_H   NO)
+ensure_file_include("inttypes.h" OPJ_HAVE_INTTYPES_H NO)
+
+# why check this one ? for openjpip ?
+include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
+CHECK_INCLUDE_FILE("strings.h"      HAVE_STRINGS_H)
+CHECK_INCLUDE_FILE("sys/stat.h"     HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILE("sys/types.h"    HAVE_SYS_TYPES_H)
+CHECK_INCLUDE_FILE("unistd.h"       HAVE_UNISTD_H)
+
+# Enable Large file support
+include(TestLargeFiles)
+OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
+
+# Allocating Aligned Memory Blocks
+include(CheckIncludeFiles)
+check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
+include(CheckSymbolExists)
+# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
+check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
+# posix_memalign (needs _POSIX_C_SOURCE >= 200112L on Linux)
+set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
+check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
+unset(CMAKE_REQUIRED_DEFINITIONS)
+# memalign (obsolete)
+check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
+#-----------------------------------------------------------------------------
+# Build Library
+if(BUILD_JPIP_SERVER)
+  find_package(CURL REQUIRED)
+  find_package(FCGI REQUIRED)
+  find_package(Threads REQUIRED)
+  if(NOT CMAKE_USE_PTHREADS_INIT)
+    message(FATAL_ERROR "Only pthread are supported")
+  endif()
+endif()
+add_subdirectory(src/lib)
+
+#-----------------------------------------------------------------------------
+# Build Applications
+option(BUILD_CODEC "Build the CODEC executables" OFF)
+option(BUILD_MJ2 "Build the MJ2 executables." OFF)
+option(BUILD_JPWL "Build the JPWL library and executables" OFF)
+option(BUILD_JPIP "Build the JPIP library and executables." OFF)
+if(BUILD_JPIP)
+  option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
+endif()
+option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
+option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
+option(BUILD_JP3D "Build the JP3D comp" OFF)
+mark_as_advanced(BUILD_VIEWER)
+mark_as_advanced(BUILD_JAVA)
+mark_as_advanced(BUILD_JP3D)
+
+if(BUILD_CODEC OR BUILD_MJ2)
+  # OFF: It will only build 3rd party libs if they are not found on the system
+  # ON: 3rd party libs will ALWAYS be build, and used
+  option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
+  add_subdirectory(thirdparty)
+  add_subdirectory(src/bin)
+endif ()
+#add_subdirectory(wrapping)
+
+#-----------------------------------------------------------------------------
+# opj_config.h generation (2/2)
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
+ @ONLY
+ )
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config_private.h.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config_private.h
+ @ONLY
+ )
+
+#-----------------------------------------------------------------------------
+# build documentation in doc subdir:
+if(BUILD_DOC)
+  add_subdirectory(doc)
+endif()
+
+#-----------------------------------------------------------------------------
+# Buld Testing
+option(BUILD_TESTING "Build the tests." OFF)
+if(BUILD_TESTING)
+  if(BUILD_CODEC)
+    enable_testing()
+    include(CTest)
+
+    # Search openjpeg data needed for the tests
+    # They could be found via git on the OpenJPEG GitHub code project
+    # git clone https://github.com/uclouvain/openjpeg-data.git
+    find_path(OPJ_DATA_ROOT README-OPJ-Data
+      PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
+      NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
+      )
+
+    # Add repository where to find tests
+    add_subdirectory(tests)
+
+  else()
+    #message(FATAL_ERROR "You need build codec to run the tests")
+  endif()
+endif()
+
+#-----------------------------------------------------------------------------
+# install all targets referenced as OPENJPEGTargets
+#install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
+configure_file( ${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
+  ${${OPENJPEG_NAMESPACE}_BINARY_DIR}/OpenJPEGConfig.cmake
+  @ONLY
+)
+install( FILES ${${OPENJPEG_NAMESPACE}_BINARY_DIR}/OpenJPEGConfig.cmake
+  DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
+)
+
+#-----------------------------------------------------------------------------
+# install CHANGES and LICENSE
+if(BUILD_DOC)
+if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
+  install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
+endif()
+
+install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
+endif()
+
+#include (cmake/OpenJPEGCPack.cmake)
+
+#-----------------------------------------------------------------------------
+# pkgconfig support
+# enabled by default on Unix, disabled by default on other platforms
+if(UNIX)
+  option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
+else()
+  option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
+endif()
+if(BUILD_PKGCONFIG_FILES)
+  # install in lib and not share (see multi-arch note above)
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc @ONLY)
+  install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc DESTINATION
+    ${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
+#
+  if(BUILD_JPWL)
+  # install in lib and not share (see multi-arch note above)
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpwl/libopenjpwl.pc.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc @ONLY)
+  install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc DESTINATION
+    ${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
+  endif()
+#
+  if(BUILD_JPIP)
+  # install in lib and not share (see multi-arch note above)
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpip/libopenjpip.pc.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc @ONLY)
+  install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc DESTINATION
+    ${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
+  endif()
+#
+  if(BUILD_JP3D)
+  # install in lib and not share (see multi-arch note above)
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp3d/libopenjp3d.pc.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc @ONLY)
+  install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc DESTINATION
+    ${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
+  endif()
+endif()
+
+#-----------------------------------------------------------------------------
diff --git a/Utilities/gdcmopenjpeg-v2/license.txt b/Utilities/gdcmopenjpeg/LICENSE
similarity index 70%
rename from Utilities/gdcmopenjpeg-v2/license.txt
rename to Utilities/gdcmopenjpeg/LICENSE
index 93abc45..e8fa410 100644
--- a/Utilities/gdcmopenjpeg-v2/license.txt
+++ b/Utilities/gdcmopenjpeg/LICENSE
@@ -1,10 +1,19 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2001-2003, David Janssens
- * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2003-2009, Francois-Olivier Devaux
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ *
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/Utilities/gdcmopenjpeg/README.GDCM.txt b/Utilities/gdcmopenjpeg/README.GDCM.txt
new file mode 100644
index 0000000..a596ee8
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/README.GDCM.txt
@@ -0,0 +1,23 @@
+This directory contains a subset of the OpenJPEG project (https://github.com/uclouvain/openjpeg/)
+
+It was retrieved on Mon Sep 26 13:40:05 CEST 2016
+URL:
+https://github.com/uclouvain/openjpeg/archive/v2.1.1.tar.gz
+This is the 2.1.1 Release
+
+Project Description
+OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been
+developed in order to promote the use of JPEG 2000, a still-image compression
+standard from the Joint Photographic Experts Group (JPEG). Since April 2015, it
+is officially recognized by ISO/IEC and ITU-T as a JPEG 2000 Reference
+Software.
+
+We only include enough of distribution to build the openjp2 library.
+
+
+Modifications
+-------------
+
+- only include the cmake & src/lib/openjp2 subdirs (+toplevel CMakeLists.txt)
+- modify toplevel cmakelists.txt to fix compilations issues about missing directories
+- add a symbols mangling mechanism
diff --git a/Utilities/gdcmopenjpeg/cmake/CTestCustom.cmake.in b/Utilities/gdcmopenjpeg/cmake/CTestCustom.cmake.in
new file mode 100644
index 0000000..5afda93
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/CTestCustom.cmake.in
@@ -0,0 +1,40 @@
+#----------------------------------------------------------------------
+#
+# For further details regarding this file,
+# see http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
+#
+# and
+# http://www.kitware.com/blog/home/post/27
+#
+#----------------------------------------------------------------------
+
+set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
+set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS   50)
+set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
+
+set(CTEST_CUSTOM_COVERAGE_EXCLUDE
+  ${CTEST_CUSTOM_COVERAGE_EXCLUDE}
+
+  # Exclude files from the Testing directories
+  ".*/tests/.*"
+
+  # Exclude files from the ThirdParty Utilities directories
+  ".*/thirdparty/.*"
+  )
+
+set(CTEST_CUSTOM_WARNING_EXCEPTION
+  ${CTEST_CUSTOM_WARNING_EXCEPTION}
+
+  # Ignore clang's summary warning, assuming prior text has matched some
+  # other warning expression:
+  "[0-9,]+ warnings? generated."
+  # Suppress warning caused by intentional messages about deprecation
+  ".*warning,.* is deprecated"
+  # java also warns about deprecated API
+  ".*java.*deprecation"
+  ".*deprecation.*"
+  # suppress warnings caused by 3rd party libs:
+  ".*thirdparty.*"
+  "libtiff.*has no symbols"
+  "libpng.*has no symbols"
+  )
diff --git a/Utilities/gdcmopenjpeg/cmake/EnsureFileInclude.cmake b/Utilities/gdcmopenjpeg/cmake/EnsureFileInclude.cmake
new file mode 100644
index 0000000..a4c064b
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/EnsureFileInclude.cmake
@@ -0,0 +1,26 @@
+# Ensure that an include file is provided by the system
+# Add the check about the mandatory status to the check_include_file macro
+# provided by cmake
+
+include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
+
+macro(ensure_file_include INCLUDE_FILENAME VARIABLE_NAME MANDATORY_STATUS)
+
+#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
+#                "VARIABLE_NAME=${VARIABLE_NAME} \n"
+#                "MANDATORY_STATUS=${MANDATORY_STATUS}")
+
+CHECK_INCLUDE_FILE(${INCLUDE_FILENAME} ${VARIABLE_NAME})
+
+#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
+#                "VARIABLE_NAME=${VARIABLE_NAME} \n"
+#                "VARIABLE_NAME_VALUE=${${VARIABLE_NAME}} \n"
+#                "MANDATORY_STATUS=${MANDATORY_STATUS}")
+
+if (NOT ${${VARIABLE_NAME}})
+  if (${MANDATORY_STATUS})
+    message(FATAL_ERROR "The file ${INCLUDE_FILENAME} is mandatory but not found on your system")
+  endif()
+endif()
+
+endmacro()
diff --git a/Utilities/gdcmopenjpeg/cmake/FindCPPCHECK.cmake b/Utilities/gdcmopenjpeg/cmake/FindCPPCHECK.cmake
new file mode 100644
index 0000000..6e11bf7
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/FindCPPCHECK.cmake
@@ -0,0 +1,16 @@
+# cppcheck
+#
+#  Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre at gmail.com>
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+find_program(CPPCHECK_EXECUTABLE
+  cppcheck
+  )
+
+mark_as_advanced(
+  CPPCHECK_EXECUTABLE
+  )
diff --git a/Utilities/gdcmopenjpeg/cmake/FindFCGI.cmake b/Utilities/gdcmopenjpeg/cmake/FindFCGI.cmake
new file mode 100644
index 0000000..309bdd4
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/FindFCGI.cmake
@@ -0,0 +1,20 @@
+# Look for the header file.
+find_path(FCGI_INCLUDE_DIR NAMES fastcgi.h)
+
+# Look for the library.
+find_library(FCGI_LIBRARY NAMES fcgi)
+
+# Handle the QUIETLY and REQUIRED arguments and set FCGI_FOUND to TRUE if all listed variables are TRUE.
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(FCGI DEFAULT_MSG FCGI_LIBRARY FCGI_INCLUDE_DIR)
+
+# Copy the results to the output variables.
+if(FCGI_FOUND)
+	set(FCGI_LIBRARIES ${FCGI_LIBRARY})
+	set(FCGI_INCLUDE_DIRS ${FCGI_INCLUDE_DIR})
+else()
+	set(FCGI_LIBRARIES)
+	set(FCGI_INCLUDE_DIRS)
+endif()
+
+mark_as_advanced(FCGI_INCLUDE_DIR FCGI_LIBRARY)
diff --git a/Utilities/gdcmopenjpeg/cmake/FindJPYLYZER.cmake b/Utilities/gdcmopenjpeg/cmake/FindJPYLYZER.cmake
new file mode 100644
index 0000000..4fbbaa8
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/FindJPYLYZER.cmake
@@ -0,0 +1,12 @@
+#
+# this module looks for JPYLYZER
+# http://jpylyzer.openpreservation.org
+#
+
+find_program(JPYLYZER_EXECUTABLE
+  jpylyzer
+  )
+
+mark_as_advanced(
+  JPYLYZER_EXECUTABLE
+  )
diff --git a/Utilities/gdcmopenjpeg/cmake/FindKAKADU.cmake b/Utilities/gdcmopenjpeg/cmake/FindKAKADU.cmake
new file mode 100644
index 0000000..0564a0e
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/FindKAKADU.cmake
@@ -0,0 +1,24 @@
+#
+# this module looks for KAKADU
+# http://www.kakadusoftware.com/
+#
+#
+#  Copyright (c) 2006-2014 Mathieu Malaterre <mathieu.malaterre at gmail.com>
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+find_program(KDU_EXPAND_EXECUTABLE
+  kdu_expand
+  )
+
+find_program(KDU_COMPRESS_EXECUTABLE
+  kdu_compress
+  )
+
+mark_as_advanced(
+  KDU_EXPAND_EXECUTABLE
+  KDU_COMPRESS_EXECUTABLE
+  )
diff --git a/Utilities/gdcmopenjpeg/cmake/FindLCMS.cmake b/Utilities/gdcmopenjpeg/cmake/FindLCMS.cmake
new file mode 100644
index 0000000..e659895
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/FindLCMS.cmake
@@ -0,0 +1,31 @@
+# - Find LCMS library
+# Find the native LCMS includes and library
+# Once done this will define
+#
+#  LCMS_INCLUDE_DIR    - Where to find lcms.h, etc.
+#  LCMS_LIBRARIES      - Libraries to link against to use LCMS.
+#  LCMS_FOUND          - If false, do not try to use LCMS.
+#
+# also defined, but not for general use are
+#  LCMS_LIBRARY, where to find the LCMS library.
+
+#=============================================================================
+#=============================================================================
+
+find_path(LCMS_INCLUDE_DIR lcms.h  PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
+
+set(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
+
+find_library(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
+
+mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARY)
+
+# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS  DEFAULT_MSG  LCMS_LIBRARY  LCMS_INCLUDE_DIR)
+
+if(LCMS_FOUND)
+  set( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
+  set( LCMS_LIBRARIES ${LCMS_LIBRARY} )
+endif()
diff --git a/Utilities/gdcmopenjpeg/cmake/FindLCMS2.cmake b/Utilities/gdcmopenjpeg/cmake/FindLCMS2.cmake
new file mode 100644
index 0000000..65b6525
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/FindLCMS2.cmake
@@ -0,0 +1,31 @@
+# - Find LCMS2 library
+# Find the native LCMS2 includes and library
+# Once done this will define
+#
+#  LCMS2_INCLUDE_DIR    - Where to find lcms2.h, etc.
+#  LCMS2_LIBRARIES      - Libraries to link against to use LCMS2.
+#  LCMS2_FOUND          - If false, do not try to use LCMS2.
+#
+# also defined, but not for general use are
+#  LCMS2_LIBRARY        - Where to find the LCMS2 library.
+
+#=============================================================================
+#=============================================================================
+
+find_path(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
+
+set(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
+
+find_library(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
+
+mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
+
+# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2  DEFAULT_MSG  LCMS2_LIBRARY  LCMS2_INCLUDE_DIR)
+
+if(LCMS2_FOUND)
+  set( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
+  set( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
+endif()
diff --git a/Utilities/gdcmopenjpeg/cmake/JPIPTestDriver.cmake b/Utilities/gdcmopenjpeg/cmake/JPIPTestDriver.cmake
new file mode 100644
index 0000000..2147c46
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/JPIPTestDriver.cmake
@@ -0,0 +1,9 @@
+# JPIP test driver
+#message(STATUS "${D_URL}")
+file(DOWNLOAD
+  "${D_URL}"
+  "${D_FILE}"
+  LOG log
+  EXPECTED_MD5 "${EXPECTED_MD5}"
+  )
+message(STATUS "LOG: ${log}")
diff --git a/Utilities/gdcmopenjpeg/cmake/OpenJPEGCPack.cmake b/Utilities/gdcmopenjpeg/cmake/OpenJPEGCPack.cmake
new file mode 100644
index 0000000..a6e9a86
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/OpenJPEGCPack.cmake
@@ -0,0 +1,72 @@
+# package bundler
+if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
+  if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
+    set(CMAKE_INSTALL_MFC_LIBRARIES 0)
+    set(CMAKE_INSTALL_DEBUG_LIBRARIES 0)
+    if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
+      set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
+    endif()
+    include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
+  endif()
+
+  set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
+  set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg at googlegroups.com>")
+
+  set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
+  set(CPACK_PACKAGE_VENDOR           "OpenJPEG Team")
+  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
+    "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
+    )
+  # For PackageMaker on MacOSX it is important to have a file extension:
+  set(CPACK_PACKAGE_DESCRIPTION_FILE    "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
+  set(CPACK_RESOURCE_FILE_LICENSE    "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
+  set(CPACK_PACKAGE_VERSION_MAJOR    "${OPENJPEG_VERSION_MAJOR}")
+  set(CPACK_PACKAGE_VERSION_MINOR    "${OPENJPEG_VERSION_MINOR}")
+  set(CPACK_PACKAGE_VERSION_PATCH    "${OPENJPEG_VERSION_BUILD}")
+  set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
+  set(CPACK_SOURCE_PACKAGE_FILE_NAME  "openjpeg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+
+  # Make this explicit here, rather than accepting the CPack default value,
+  # so we can refer to it:
+  set(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
+
+  if(NOT DEFINED CPACK_SYSTEM_NAME)
+    # make sure package is not Cygwin-unknown, for Cygwin just
+    # cygwin is good for the system name
+    if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
+      set(CPACK_SYSTEM_NAME Cygwin)
+    else()
+      set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
+    endif()
+  endif()
+  if(${CPACK_SYSTEM_NAME} MATCHES Windows)
+    if(CMAKE_CL_64)
+      set(CPACK_SYSTEM_NAME win64-x64)
+    else()
+      set(CPACK_SYSTEM_NAME win32-x86)
+    endif()
+  endif()
+
+  if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
+    # if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
+    # default to source package - system, on cygwin system is not
+    # needed
+    if(CYGWIN)
+      set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
+    else()
+      set(CPACK_PACKAGE_FILE_NAME
+        "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
+    endif()
+  endif()
+
+  set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
+  if(APPLE)
+    configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
+      ${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
+    set(CPACK_BUNDLE_PLIST
+      ${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
+    #include(BundleUtilities)
+  endif()
+
+  include(CPack)
+endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
diff --git a/Utilities/gdcmopenjpeg-v1/CMake/OpenJPEGConfig.cmake.in b/Utilities/gdcmopenjpeg/cmake/OpenJPEGConfig.cmake.in
similarity index 75%
rename from Utilities/gdcmopenjpeg-v1/CMake/OpenJPEGConfig.cmake.in
rename to Utilities/gdcmopenjpeg/cmake/OpenJPEGConfig.cmake.in
index 3196844..caf6f2e 100644
--- a/Utilities/gdcmopenjpeg-v1/CMake/OpenJPEGConfig.cmake.in
+++ b/Utilities/gdcmopenjpeg/cmake/OpenJPEGConfig.cmake.in
@@ -6,18 +6,18 @@
 # module to load OPENJPEG's settings for an external project.
 @OPENJPEG_CONFIG_INSTALL_ONLY@
 # The OPENJPEG version number.
-set(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
-set(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
-set(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
+set(OPENJPEG_VERSION_MAJOR "@OPENJPEG_VERSION_MAJOR@")
+set(OPENJPEG_VERSION_MINOR "@OPENJPEG_VERSION_MINOR@")
+set(OPENJPEG_VERSION_BUILD "@OPENJPEG_VERSION_BUILD@")
 
 # The libraries.
-set(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
+set(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
 
 # The CMake macros dir.
-set(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
+set(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
 
 # The configuration options.
-set(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
+set(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
 
 # The "use" file.
 set(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
@@ -26,7 +26,7 @@ get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
 if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
   # This is an install tree
   include(${SELF_DIR}/OpenJPEGTargets.cmake)
-  get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
+  get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
   set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
 
 else()
diff --git a/Utilities/gdcmopenjpeg/cmake/TestFileOffsetBits.c b/Utilities/gdcmopenjpeg/cmake/TestFileOffsetBits.c
new file mode 100644
index 0000000..cd679c1
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/TestFileOffsetBits.c
@@ -0,0 +1,11 @@
+#include <sys/types.h>
+
+/* Cause a compile-time error if off_t is smaller than 64 bits */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];  
+
+int main(int argc, char **argv)
+{
+  return 0;
+}
+
diff --git a/Utilities/gdcmopenjpeg/cmake/TestLargeFiles.c.cmake.in b/Utilities/gdcmopenjpeg/cmake/TestLargeFiles.c.cmake.in
new file mode 100644
index 0000000..623f95f
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/TestLargeFiles.c.cmake.in
@@ -0,0 +1,23 @@
+#cmakedefine _LARGEFILE_SOURCE
+#cmakedefine _LARGE_FILES
+#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv)
+{
+  /* Cause a compile-time error if off_t is smaller than 64 bits,
+   * and make sure we have ftello / fseeko.
+   */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
+  FILE *fp = fopen(argv[0],"r");
+  off_t offset = ftello( fp );
+
+  fseeko( fp, offset, SEEK_CUR );
+  fclose(fp);
+  return 0;
+}
+
diff --git a/Utilities/gdcmopenjpeg/cmake/TestLargeFiles.cmake b/Utilities/gdcmopenjpeg/cmake/TestLargeFiles.cmake
new file mode 100644
index 0000000..01e4ea7
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/TestLargeFiles.cmake
@@ -0,0 +1,134 @@
+# - Define macro to check large file support
+#
+#  OPJ_TEST_LARGE_FILES(VARIABLE)
+#
+#  VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present.
+#  This macro will also defines the necessary variable enable large file support, for instance
+#  _LARGE_FILES
+#  _LARGEFILE_SOURCE
+#  _FILE_OFFSET_BITS 64
+#  OPJ_HAVE_FSEEKO
+#
+#  However, it is YOUR job to make sure these defines are set in a #cmakedefine so they
+#  end up in a config.h file that is included in your source if necessary!
+#
+#  Adapted from Gromacs project (http://www.gromacs.org/)
+#  by Julien Malik
+#
+
+macro(OPJ_TEST_LARGE_FILES VARIABLE)
+    if(NOT DEFINED ${VARIABLE})
+
+        # On most platforms it is probably overkill to first test the flags for 64-bit off_t,
+        # and then separately fseeko. However, in the future we might have 128-bit filesystems
+        # (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
+
+        message(STATUS "Checking for 64-bit off_t")
+
+        # First check without any special flags
+        try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
+                    "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c")
+        if(FILE64_OK)
+          message(STATUS "Checking for 64-bit off_t - present")
+       	endif()
+
+        if(NOT FILE64_OK)
+            # Test with _FILE_OFFSET_BITS=64
+            try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
+                        "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
+                        COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
+            if(FILE64_OK)
+                message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
+                set(_FILE_OFFSET_BITS 64)
+            endif()
+        endif()
+
+        if(NOT FILE64_OK)
+            # Test with _LARGE_FILES
+            try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
+                        "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
+                        COMPILE_DEFINITIONS "-D_LARGE_FILES" )
+            if(FILE64_OK)
+                message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
+                set(_LARGE_FILES 1)
+            endif()
+        endif()
+	
+        if(NOT FILE64_OK)
+            # Test with _LARGEFILE_SOURCE
+            try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
+                        "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
+                        COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
+            if(FILE64_OK)
+                message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
+                set(_LARGEFILE_SOURCE 1)
+            endif()
+        endif()
+
+
+        #if(NOT FILE64_OK)
+        #    # now check for Windows stuff
+        #    try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
+        #                "${PROJECT_SOURCE_DIR}/cmake/TestWindowsFSeek.c")
+        #    if(FILE64_OK)
+        #        message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
+        #        set(HAVE__FSEEKI64 1)
+        #    endif()
+        #endif()
+
+        if(NOT FILE64_OK)
+            message(STATUS "Checking for 64-bit off_t - not present")
+        endif()
+
+        set(_FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} CACHE INTERNAL "Result of test for needed _FILE_OFFSET_BITS=64")
+        set(_LARGE_FILES      ${_LARGE_FILES}      CACHE INTERNAL "Result of test for needed _LARGE_FILES")
+        set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
+
+        # Set the flags we might have determined to be required above
+        configure_file("${PROJECT_SOURCE_DIR}/cmake/TestLargeFiles.c.cmake.in"
+                       "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
+
+        message(STATUS "Checking for fseeko/ftello")
+
+	    # Test if ftello/fseeko are	available
+	    try_compile(FSEEKO_COMPILE_OK
+	                "${PROJECT_BINARY_DIR}"
+                    "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
+	
+	    if(FSEEKO_COMPILE_OK)
+            message(STATUS "Checking for fseeko/ftello - present")
+        endif()
+
+        if(NOT FSEEKO_COMPILE_OK)
+                # glibc 2.2 needs _LARGEFILE_SOURCE for fseeko (but not for 64-bit off_t...)
+                try_compile(FSEEKO_COMPILE_OK
+                            "${PROJECT_BINARY_DIR}"
+                            "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
+                            COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
+
+                if(FSEEKO_COMPILE_OK)
+                    message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
+                    set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
+                endif()
+        endif()
+
+	    if(FSEEKO_COMPILE_OK)
+                set(OPJ_HAVE_FSEEKO ON CACHE INTERNAL "Result of test for fseeko/ftello")
+        else()
+                message(STATUS "Checking for fseeko/ftello - not found")
+                set(OPJ_HAVE_FSEEKO OFF CACHE INTERNAL "Result of test for fseeko/ftello")
+        endif()
+
+	    if(FILE64_OK AND FSEEKO_COMPILE_OK)
+                message(STATUS "Large File support - found")
+                set(${VARIABLE} ON CACHE INTERNAL "Result of test for large file support")
+        else()
+                message(STATUS "Large File support - not found")
+                set(${VARIABLE} OFF CACHE INTERNAL "Result of test for large file support")
+        endif()
+
+    endif()
+endmacro()
+
+
+
diff --git a/Utilities/gdcmopenjpeg/cmake/TestWindowsFSeek.c b/Utilities/gdcmopenjpeg/cmake/TestWindowsFSeek.c
new file mode 100644
index 0000000..ad9f0be
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/TestWindowsFSeek.c
@@ -0,0 +1,11 @@
+
+#include <stdio.h>
+    
+int main()
+{
+  __int64 off=0;
+
+  _fseeki64(NULL, off, SEEK_SET);
+        
+  return 0;
+}
diff --git a/Utilities/gdcmopenjpeg/cmake/openjpeg_valgrind.supp b/Utilities/gdcmopenjpeg/cmake/openjpeg_valgrind.supp
new file mode 100644
index 0000000..f107646
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/cmake/openjpeg_valgrind.supp
@@ -0,0 +1,39 @@
+
+
+{
+   <Appears with libpng uses with Ubuntu10.04 (hulk)>
+   Memcheck:Cond
+   fun:deflate
+   obj:/lib/libpng12.so.0.42.0
+   obj:/lib/libpng12.so.0.42.0
+   obj:/lib/libpng12.so.0.42.0
+   fun:png_write_row
+   fun:imagetopng
+   fun:main
+}
+{
+   <Appears with libpng uses with Ubuntu10.04 (hulk)>
+   Memcheck:Value8
+   fun:crc32
+   obj:/lib/libpng12.so.0.42.0
+   fun:png_write_chunk
+   obj:/lib/libpng12.so.0.42.0
+   obj:/lib/libpng12.so.0.42.0
+   obj:/lib/libpng12.so.0.42.0
+   obj:/lib/libpng12.so.0.42.0
+   fun:png_write_row
+   fun:imagetopng
+   fun:main
+}
+{
+   <Appears with libpng uses with Ubuntu10.04 (hulk)>
+   Memcheck:Param
+   write(buf)
+   fun:__write_nocancel
+   fun:_IO_file_write@@GLIBC_2.2.5
+   fun:_IO_do_write@@GLIBC_2.2.5
+   fun:_IO_file_close_it@@GLIBC_2.2.5
+   fun:fclose@@GLIBC_2.2.5
+   fun:imagetopng
+   fun:main
+}
diff --git a/Utilities/gdcmopenjpeg/src/lib/CMakeLists.txt b/Utilities/gdcmopenjpeg/src/lib/CMakeLists.txt
new file mode 100644
index 0000000..da8846b
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/CMakeLists.txt
@@ -0,0 +1,17 @@
+# source code for openjpeg project:
+# Part 1 & 2:
+add_subdirectory(openjp2)
+
+# optionals components:
+if(BUILD_JPWL)
+  add_subdirectory(openjpwl)
+endif()
+if(BUILD_MJ2)
+  add_subdirectory(openmj2)
+endif()
+if(BUILD_JPIP)
+  add_subdirectory(openjpip)
+endif()
+if(BUILD_JP3D)
+  add_subdirectory(openjp3d)
+endif()
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/CMakeLists.txt b/Utilities/gdcmopenjpeg/src/lib/openjp2/CMakeLists.txt
new file mode 100644
index 0000000..0336232
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/CMakeLists.txt
@@ -0,0 +1,153 @@
+include_regular_expression("^.*$")
+
+# configure name mangling to allow multiple libraries to coexist
+# peacefully
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
+set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
+               ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
+               @ONLY)
+endif()
+
+#
+install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/opj_config.h
+ DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers)
+
+include_directories(
+  ${${OPENJPEG_NAMESPACE}_BINARY_DIR}/src/lib/openjp2 # opj_config.h and opj_config_private.h
+)
+# Defines the source code for the library
+set(OPENJPEG_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/bio.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/bio.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/cio.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/cio.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/dwt.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/dwt.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/event.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/event.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/image.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/image.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/invert.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/invert.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/j2k.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/j2k.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/jp2.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/jp2.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/mct.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/mct.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/mqc.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/pi.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/pi.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/raw.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/raw.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/t1.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/t1.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/t2.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/t2.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/tcd.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/tcd.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/tgt.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/tgt.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/function_list.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/function_list.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_codec.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_includes.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_intmath.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/opj_stdint.h
+)
+if(BUILD_JPIP)
+  add_definitions(-DUSE_JPIP)
+  set(OPENJPEG_SRCS
+    ${OPENJPEG_SRCS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/phix_manager.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/ppix_manager.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/thix_manager.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/tpix_manager.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/indexbox_manager.h
+  )
+endif()
+
+option(OPJ_DISABLE_TPSOT_FIX "Disable TPsot==TNsot fix. See https://github.com/uclouvain/openjpeg/issues/254." OFF)
+if(OPJ_DISABLE_TPSOT_FIX)
+  add_definitions(-DOPJ_DISABLE_TPSOT_FIX)
+endif()
+
+# Build the library
+if(WIN32)
+  if(BUILD_SHARED_LIBS)
+    add_definitions(-DOPJ_EXPORTS)
+  else()
+    add_definitions(-DOPJ_STATIC)
+  endif()
+endif()
+add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
+if(UNIX)
+  target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
+endif()
+set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
+if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+  target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
+endif()
+
+# Install library
+install(TARGETS ${OPENJPEG_LIBRARY_NAME}
+  EXPORT ${GDCM_TARGETS_NAME}
+  RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
+  LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
+  ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
+)
+
+# Install includes files
+install(FILES openjpeg.h opj_stdint.h
+  DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
+)
+
+if(BUILD_DOC)
+# install man page of the library
+install(
+  FILES       ${OPENJPEG_SOURCE_DIR}/doc/man/man3/libopenjp2.3
+  DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
+endif()
+
+# internal utilities to generate t1_luts.h (part of the jp2 lib)
+# no need to install:
+#add_executable(t1_generate_luts t1_generate_luts.c)
+#if(UNIX)
+#  target_link_libraries(t1_generate_luts m)
+#endif()
+
+# Experimental option; let's how cppcheck performs
+# Implementation details:
+# I could not figure out how to easily upload a file to CDash. Instead simply
+# pretend cppcheck is part of the Build step. Technically cppcheck can even
+# output gcc formatted error/warning report
+# Another implementation detail: I could not redirect error to the error
+# catching mechanism something is busted in cmake 2.8.5, I had to use the
+# warning regex to catch them.
+if(OPENJPEG_CPPCHECK)
+  find_package(CPPCHECK REQUIRED)
+  foreach(f ${OPENJPEG_SRCS})
+    # cppcheck complains about too many configuration, pretend to be WIN32:
+    add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME}
+      COMMAND ${CPPCHECK_EXECUTABLE} -DWIN32 ${f})
+  endforeach()
+endif()
+
+if(OPJ_USE_DSYMUTIL)
+  if(BUILD_SHARED_LIBS)
+    add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME} POST_BUILD
+    COMMAND "dsymutil" "$<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
+    COMMENT "dsymutil $<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
+    DEPENDS ${OPENJPEG_LIBRARY_NAME})
+  endif()
+endif()
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/bio.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/bio.c
similarity index 50%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/bio.c
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/bio.c
index 4c02f46..269769b 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/bio.c
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/bio.c
@@ -1,9 +1,15 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
@@ -42,25 +48,25 @@ Write a bit
 @param bio BIO handle
 @param b Bit to write (0 or 1)
 */
-static void bio_putbit(opj_bio_t *bio, int b);
+static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
 /**
 Read a bit
 @param bio BIO handle
 @return Returns the read bit
 */
-static int bio_getbit(opj_bio_t *bio);
+static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio);
 /**
 Write a byte
 @param bio BIO handle
- at return Returns 0 if successful, returns 1 otherwise
+ at return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
 */
-static int bio_byteout(opj_bio_t *bio);
+static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio);
 /**
 Read a byte
 @param bio BIO handle
- at return Returns 0 if successful, returns 1 otherwise
+ at return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
 */
-static int bio_bytein(opj_bio_t *bio);
+static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio);
 
 /*@}*/
 
@@ -72,37 +78,37 @@ static int bio_bytein(opj_bio_t *bio);
 ==========================================================
 */
 
-static int bio_byteout(opj_bio_t *bio) {
+static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) {
 	bio->buf = (bio->buf << 8) & 0xffff;
 	bio->ct = bio->buf == 0xff00 ? 7 : 8;
-	if (bio->bp >= bio->end) {
-		return 1;
+	if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
+		return OPJ_FALSE;
 	}
-	*bio->bp++ = bio->buf >> 8;
-	return 0;
+	*bio->bp++ = (OPJ_BYTE)(bio->buf >> 8);
+	return OPJ_TRUE;
 }
 
-static int bio_bytein(opj_bio_t *bio) {
+static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) {
 	bio->buf = (bio->buf << 8) & 0xffff;
 	bio->ct = bio->buf == 0xff00 ? 7 : 8;
-	if (bio->bp >= bio->end) {
-		return 1;
+	if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
+		return OPJ_FALSE;
 	}
 	bio->buf |= *bio->bp++;
-	return 0;
+	return OPJ_TRUE;
 }
 
-static void bio_putbit(opj_bio_t *bio, int b) {
+static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) {
 	if (bio->ct == 0) {
-		bio_byteout(bio);
+		opj_bio_byteout(bio); /* MSD: why not check the return value of this function ? */
 	}
 	bio->ct--;
 	bio->buf |= b << bio->ct;
 }
 
-static int bio_getbit(opj_bio_t *bio) {
+static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) {
 	if (bio->ct == 0) {
-		bio_bytein(bio);
+		opj_bio_bytein(bio); /* MSD: why not check the return value of this function ? */
 	}
 	bio->ct--;
 	return (bio->buf >> bio->ct) & 1;
@@ -114,22 +120,22 @@ static int bio_getbit(opj_bio_t *bio) {
 ==========================================================
 */
 
-opj_bio_t* bio_create(void) {
+opj_bio_t* opj_bio_create(void) {
 	opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
 	return bio;
 }
 
-void bio_destroy(opj_bio_t *bio) {
+void opj_bio_destroy(opj_bio_t *bio) {
 	if(bio) {
 		opj_free(bio);
 	}
 }
 
-int bio_numbytes(opj_bio_t *bio) {
+ptrdiff_t opj_bio_numbytes(opj_bio_t *bio) {
 	return (bio->bp - bio->start);
 }
 
-void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) {
+void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
 	bio->start = bp;
 	bio->end = bp + len;
 	bio->bp = bp;
@@ -137,7 +143,7 @@ void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) {
 	bio->ct = 8;
 }
 
-void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) {
+void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
 	bio->start = bp;
 	bio->end = bp + len;
 	bio->bp = bp;
@@ -145,43 +151,53 @@ void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) {
 	bio->ct = 0;
 }
 
-void bio_write(opj_bio_t *bio, int v, int n) {
-	int i;
-	for (i = n - 1; i >= 0; i--) {
-		bio_putbit(bio, (v >> i) & 1);
+OPJ_NOSANITIZE("unsigned-integer-overflow")
+void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
+	OPJ_UINT32 i;
+	
+	assert((n > 0U) && (n <= 32U));
+	for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
+		opj_bio_putbit(bio, (v >> i) & 1);
 	}
 }
 
-int bio_read(opj_bio_t *bio, int n) {
-	int i, v;
-	v = 0;
-	for (i = n - 1; i >= 0; i--) {
-		v += bio_getbit(bio) << i;
+OPJ_NOSANITIZE("unsigned-integer-overflow")
+OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
+	OPJ_UINT32 i;
+	OPJ_UINT32 v;
+	
+	assert((n > 0U) /* && (n <= 32U)*/);
+#ifdef OPJ_UBSAN_BUILD
+	/* This assert fails for some corrupted images which are gracefully rejected */
+	/* Add this assert only for ubsan build. */
+	/* This is the condition for overflow not to occur below which is needed because of OPJ_NOSANITIZE */
+	assert(n <= 32U);
+#endif
+	v = 0U;
+	for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
+		v |= opj_bio_getbit(bio) << i; /* can't overflow, opj_bio_getbit returns 0 or 1 */
 	}
 	return v;
 }
 
-int bio_flush(opj_bio_t *bio) {
-	bio->ct = 0;
-	if (bio_byteout(bio)) {
-		return 1;
+OPJ_BOOL opj_bio_flush(opj_bio_t *bio) {
+	if (! opj_bio_byteout(bio)) {
+		return OPJ_FALSE;
 	}
 	if (bio->ct == 7) {
-		bio->ct = 0;
-		if (bio_byteout(bio)) {
-			return 1;
+		if (! opj_bio_byteout(bio)) {
+			return OPJ_FALSE;
 		}
 	}
-	return 0;
+	return OPJ_TRUE;
 }
 
-int bio_inalign(opj_bio_t *bio) {
-	bio->ct = 0;
+OPJ_BOOL opj_bio_inalign(opj_bio_t *bio) {
 	if ((bio->buf & 0xff) == 0xff) {
-		if (bio_bytein(bio)) {
-			return 1;
+		if (! opj_bio_bytein(bio)) {
+			return OPJ_FALSE;
 		}
-		bio->ct = 0;
 	}
-	return 0;
+	bio->ct = 0;
+	return OPJ_TRUE;
 }
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/bio.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/bio.h
similarity index 72%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/bio.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/bio.h
index 764d7cb..fba2428 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/bio.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/bio.h
@@ -1,9 +1,15 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
@@ -31,6 +37,9 @@
 
 #ifndef __BIO_H
 #define __BIO_H
+
+#include <stddef.h> /* ptrdiff_t */
+
 /** 
 @file bio.h
 @brief Implementation of an individual bit input-output (BIO)
@@ -46,15 +55,15 @@ Individual bit input-output stream (BIO)
 */
 typedef struct opj_bio {
 	/** pointer to the start of the buffer */
-	unsigned char *start;
+	OPJ_BYTE *start;
 	/** pointer to the end of the buffer */
-	unsigned char *end;
+	OPJ_BYTE *end;
 	/** pointer to the present position in the buffer */
-	unsigned char *bp;
+	OPJ_BYTE *bp;
 	/** temporary place where each byte is read or written */
-	unsigned int buf;
+	OPJ_UINT32 buf;
 	/** coder : number of bits free to write. decoder : number of bits read */
-	int ct;
+	OPJ_UINT32 ct;
 } opj_bio_t;
 
 /** @name Exported functions */
@@ -64,58 +73,58 @@ typedef struct opj_bio {
 Create a new BIO handle 
 @return Returns a new BIO handle if successful, returns NULL otherwise
 */
-opj_bio_t* bio_create(void);
+opj_bio_t* opj_bio_create(void);
 /**
 Destroy a previously created BIO handle
 @param bio BIO handle to destroy
 */
-void bio_destroy(opj_bio_t *bio);
+void opj_bio_destroy(opj_bio_t *bio);
 /**
 Number of bytes written.
 @param bio BIO handle
 @return Returns the number of bytes written
 */
-int bio_numbytes(opj_bio_t *bio);
+ptrdiff_t opj_bio_numbytes(opj_bio_t *bio);
 /**
 Init encoder
 @param bio BIO handle
 @param bp Output buffer
 @param len Output buffer length 
 */
-void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len);
+void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
 /**
 Init decoder
 @param bio BIO handle
 @param bp Input buffer
 @param len Input buffer length 
 */
-void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len);
+void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len);
 /**
 Write bits
 @param bio BIO handle
 @param v Value of bits
 @param n Number of bits to write
 */
-void bio_write(opj_bio_t *bio, int v, int n);
+void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n);
 /**
 Read bits
 @param bio BIO handle
 @param n Number of bits to read 
 @return Returns the corresponding read number
 */
-int bio_read(opj_bio_t *bio, int n);
+OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n);
 /**
 Flush bits
 @param bio BIO handle
- at return Returns 1 if successful, returns 0 otherwise
+ at return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
 */
-int bio_flush(opj_bio_t *bio);
+OPJ_BOOL opj_bio_flush(opj_bio_t *bio);
 /**
 Passes the ending bits (coming from flushing)
 @param bio BIO handle
- at return Returns 1 if successful, returns 0 otherwise
+ at return Returns OPJ_TRUE if successful, returns OPJ_FALSE otherwise
 */
-int bio_inalign(opj_bio_t *bio);
+OPJ_BOOL opj_bio_inalign(opj_bio_t *bio);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/cidx_manager.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/cidx_manager.c
new file mode 100644
index 0000000..30561ed
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/cidx_manager.c
@@ -0,0 +1,241 @@
+/*
+ * $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara at gmail.com $
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+
+/* 
+ * Write CPTR Codestream finder box
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] clen length of j2k codestream
+ * @param[in] cio  file output handle
+ */
+
+void opj_write_cptr(int coff, int clen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+
+
+
+
+int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t cstr_info, int j2klen,
+              opj_event_mgr_t * p_manager )
+{
+  int i;
+  OPJ_OFF_T lenp;
+  OPJ_UINT32 len;
+  opj_jp2_box_t *box;
+  int num_box = 0;
+  OPJ_BOOL  EPHused;
+  OPJ_BYTE l_data_header [4];
+
+  lenp = -1;
+  box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
+  if(box == NULL){
+	return 0;
+  }
+  for (i=0;i<2;i++){
+  
+    if(i)
+      opj_stream_seek(cio,lenp,p_manager);
+
+
+    lenp = opj_stream_tell (cio);
+
+    opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
+
+    opj_write_bytes(l_data_header,JPIP_CIDX,4); /* CIDX */
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+    opj_write_cptr( offset, cstr_info.codestream_size, cio,p_manager);
+
+    opj_write_manf( i, num_box, box, cio,p_manager);
+    
+    num_box = 0;
+    box[num_box].length = (OPJ_UINT32)opj_write_mainmhix( offset, cstr_info, cio,p_manager);
+    box[num_box].type = JPIP_MHIX;
+    num_box++;
+
+    box[num_box].length = (OPJ_UINT32)opj_write_tpix( offset, cstr_info, j2klen, cio,p_manager);
+    box[num_box].type = JPIP_TPIX;
+    num_box++;
+      
+    box[num_box].length = (OPJ_UINT32)opj_write_thix( offset, cstr_info, cio, p_manager);
+    box[num_box].type = JPIP_THIX;
+    num_box++;
+
+    EPHused = opj_check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio,p_manager);
+      
+    box[num_box].length = (OPJ_UINT32)opj_write_ppix( offset, cstr_info, EPHused, j2klen, cio,p_manager);
+    box[num_box].type = JPIP_PPIX;
+    num_box++;
+    
+    box[num_box].length = (OPJ_UINT32)opj_write_phix( offset, cstr_info, EPHused, j2klen, cio,p_manager);
+    box[num_box].type = JPIP_PHIX;
+    num_box++;
+      
+    len = (OPJ_UINT32) (opj_stream_tell(cio)-lenp);
+    opj_stream_seek(cio, lenp,p_manager);
+    opj_write_bytes(l_data_header,len,4);/* L  */
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+    opj_stream_seek(cio, lenp+len,p_manager);
+  }
+
+  opj_free( box);
+  
+  return (int)len;
+}
+
+
+
+void opj_write_cptr(int coff, int clen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [3*8];
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+
+
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip( cio, 4, p_manager);               /* L [at the end]     */
+  opj_write_bytes( l_data_header, JPIP_CPTR, 4);   /* T                  */
+  opj_write_bytes( l_data_header+4, 0, 2);           /* DR  A PRECISER !!  */
+  opj_write_bytes( l_data_header+6, 0, 2);           /* CONT               */
+  opj_write_bytes( l_data_header+8, (OPJ_UINT32)coff, 8);    /* COFF A PRECISER !! */
+  opj_write_bytes( l_data_header+16, (OPJ_UINT32)clen, 8);    /* CLEN               */
+  opj_stream_write_data(cio,l_data_header,3*8,p_manager);
+
+  len = (OPJ_UINT32) (opj_stream_tell(cio) - lenp);
+  opj_stream_seek(cio,lenp,p_manager);
+  opj_write_bytes(l_data_header, len, 4);         /* L                  */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+
+}
+
+
+
+void opj_write_manf(int second, 
+                    int v, 
+                    opj_jp2_box_t *box, 
+                    opj_stream_private_t *cio,
+                    opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [4];
+  int i;
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+  
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip( cio, 4, p_manager);             /* L [at the end]     */
+  opj_write_bytes( l_data_header, JPIP_MANF, 4);   /* T                  */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+  if (second){                          /* Write only during the second pass */
+    for( i=0; i<v; i++){
+      opj_write_bytes( l_data_header, box[i].length, 4); /* Box length                     */
+      opj_stream_write_data(cio,l_data_header,4,p_manager);
+      opj_write_bytes( l_data_header, box[i].type, 4); /* Box type                       */
+      opj_stream_write_data(cio,l_data_header,4,p_manager);
+    }
+  }
+
+  len = (OPJ_UINT32) (opj_stream_tell(cio) - lenp);
+  opj_stream_seek(cio,lenp,p_manager);
+  opj_write_bytes(l_data_header, len, 4);/* L                                 */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio,lenp+len,p_manager);
+}
+
+
+int opj_write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [8];
+  OPJ_UINT32 i;
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+  
+  lenp = opj_stream_tell (cio);
+  opj_stream_skip(cio, 4, p_manager);               /* L [at the end]                    */
+  opj_write_bytes(l_data_header,JPIP_MHIX,4);       /* MHIX                              */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+  opj_write_bytes(l_data_header, (OPJ_UINT32)(cstr_info.main_head_end-cstr_info.main_head_start+1), 8);        /* TLEN                              */
+  opj_stream_write_data(cio,l_data_header,8,p_manager);
+
+  for(i = 1; i < (OPJ_UINT32)cstr_info.marknum; i++){    /* Marker restricted to 1 apparition, skip SOC marker */
+    opj_write_bytes( l_data_header, cstr_info.marker[i].type, 2);
+    opj_write_bytes( l_data_header+2, 0, 2);
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+    opj_write_bytes( l_data_header,(OPJ_UINT32) (cstr_info.marker[i].pos-coff), 8);
+    opj_stream_write_data(cio,l_data_header,8,p_manager);
+    opj_write_bytes( l_data_header, (OPJ_UINT32)cstr_info.marker[i].len, 2);
+    opj_stream_write_data(cio,l_data_header,2,p_manager);
+  }
+
+  len = (OPJ_UINT32) (opj_stream_tell(cio)-lenp);
+  opj_stream_seek(cio, lenp,p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L  */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+  
+  return (int)len;
+}
+
+OPJ_BOOL opj_check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [4];
+  OPJ_BOOL EPHused = OPJ_FALSE;
+  int i=0;
+  OPJ_OFF_T org_pos;
+  unsigned int Scod;
+
+  for(i = 0; i < marknum; i++)
+    {
+    if( markers[i].type == J2K_MS_COD)
+      {
+      org_pos = opj_stream_tell(cio);
+      opj_stream_seek(cio, coff+markers[i].pos+2,p_manager);
+
+      opj_stream_read_data(cio,l_data_header,1,p_manager);
+      opj_read_bytes(l_data_header,&Scod,1);
+      if( ((Scod >> 2) & 1))
+        EPHused = OPJ_TRUE;
+      opj_stream_seek( cio, org_pos, p_manager);
+
+      break;
+      }
+    }    
+  return EPHused;
+}
diff --git a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/bio.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/cidx_manager.h
similarity index 51%
rename from Utilities/gdcmopenjpeg-v1/indexer_JPIP/bio.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/cidx_manager.h
index eea6cff..d0bbef8 100644
--- a/Utilities/gdcmopenjpeg-v1/indexer_JPIP/bio.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/cidx_manager.h
@@ -1,7 +1,10 @@
 /*
- * Copyright (c) 2001-2002, David Janssens
+ * $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara at gmail.com $
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
+ * Copyright (c) 2010-2011, Kaori Hagihara
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,13 +29,40 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef __BIO_H
-#define __BIO_H
+/*! \file
+ *  \brief Modification of jpip.h from 2KAN indexer
+ */
+
+
+#ifndef  CIDX_MANAGER_H_
+# define CIDX_MANAGER_H_
+
+#include "openjpeg.h"
+
 
-int bio_numbytes();
-void bio_init_dec(unsigned char *bp, int len);
-int bio_read(int n);
-int bio_flush();
-int bio_inalign();
+/* 
+ * Write Codestream index box (superbox)
+ *
+ * @param[in] offset    offset of j2k codestream
+ * @param[in] cio       file output handle
+ * @param[in] image     image data
+ * @param[in] cstr_info codestream information
+ * @param[in] j2klen    length of j2k codestream
+ * @return              length of cidx box
+ */
+int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t cstr_info, int j2klen,
+              opj_event_mgr_t * p_manager );
+
+/* 
+ * Check if EPH option is used
+ *
+ * @param[in] coff    offset of j2k codestream
+ * @param[in] markers marker information
+ * @param[in] marknum number of markers
+ * @param[in] cio     file output handle
+ * @return            true if EPH is used
+ */
+OPJ_BOOL opj_check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
 
-#endif
+#endif      /* !CIDX_MANAGER_H_ */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/cio.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/cio.c
new file mode 100644
index 0000000..b115cf5
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/cio.c
@@ -0,0 +1,644 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
+void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
+{
+	const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value)+sizeof(OPJ_UINT32)-p_nb_bytes;
+
+	assert(p_nb_bytes > 0 && p_nb_bytes <=  sizeof(OPJ_UINT32));
+
+	memcpy(p_buffer,l_data_ptr,p_nb_bytes);
+}
+
+void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
+{
+	const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes - 1;
+	OPJ_UINT32 i;
+
+	assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
+
+	for	(i=0;i<p_nb_bytes;++i) {
+		*(p_buffer++) = *(l_data_ptr--);
+	}
+}
+
+void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes)
+{
+	OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
+
+	assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
+
+	*p_value = 0;
+	memcpy(l_data_ptr+sizeof(OPJ_UINT32)-p_nb_bytes,p_buffer,p_nb_bytes);
+}
+
+void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes)
+{
+	OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + p_nb_bytes-1;
+	OPJ_UINT32 i;
+
+	assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
+
+	*p_value = 0;
+	for (i=0;i<p_nb_bytes;++i) {
+		*(l_data_ptr--) = *(p_buffer++);
+	}
+}
+
+void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
+{
+	const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
+	memcpy(p_buffer,l_data_ptr,sizeof(OPJ_FLOAT64));
+}
+
+void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value)
+{
+	const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(OPJ_FLOAT64) - 1;
+	OPJ_UINT32 i;
+	for	(i=0;i<sizeof(OPJ_FLOAT64);++i) {
+		*(p_buffer++) = *(l_data_ptr--);
+	}
+}
+
+void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
+{
+	OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
+	memcpy(l_data_ptr,p_buffer,sizeof(OPJ_FLOAT64));
+}
+
+void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value)
+{
+	OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT64)-1;
+	OPJ_UINT32 i;
+	for (i=0;i<sizeof(OPJ_FLOAT64);++i) {
+		*(l_data_ptr--) = *(p_buffer++);
+	}
+}
+
+void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
+{
+	const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value);
+	memcpy(p_buffer,l_data_ptr,sizeof(OPJ_FLOAT32));
+}
+
+void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value)
+{
+	const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + sizeof(OPJ_FLOAT32) - 1;
+	OPJ_UINT32 i;
+	for	(i=0;i<sizeof(OPJ_FLOAT32);++i) {
+		*(p_buffer++) = *(l_data_ptr--);
+	}
+}
+
+void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
+{
+	OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
+	memcpy(l_data_ptr,p_buffer,sizeof(OPJ_FLOAT32));
+}
+
+void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
+{
+	OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + sizeof(OPJ_FLOAT32)-1;
+	OPJ_UINT32 i;
+	for	(i=0;i<sizeof(OPJ_FLOAT32);++i) {
+		*(l_data_ptr--) = *(p_buffer++);
+	}
+}
+
+opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,OPJ_BOOL l_is_input)
+{
+	opj_stream_private_t * l_stream = 00;
+	l_stream = (opj_stream_private_t*) opj_calloc(1,sizeof(opj_stream_private_t));
+	if (! l_stream) {
+		return 00;
+	}
+
+	l_stream->m_buffer_size = p_buffer_size;
+	l_stream->m_stored_data = (OPJ_BYTE *) opj_malloc(p_buffer_size);
+	if (! l_stream->m_stored_data) {
+		opj_free(l_stream);
+		return 00;
+	}
+
+	l_stream->m_current_data = l_stream->m_stored_data;
+
+	if (l_is_input) {
+		l_stream->m_status |= OPJ_STREAM_STATUS_INPUT;
+		l_stream->m_opj_skip = opj_stream_read_skip;
+		l_stream->m_opj_seek = opj_stream_read_seek;
+	}
+	else {
+		l_stream->m_status |= OPJ_STREAM_STATUS_OUTPUT;
+		l_stream->m_opj_skip = opj_stream_write_skip;
+		l_stream->m_opj_seek = opj_stream_write_seek;
+	}
+
+	l_stream->m_read_fn = opj_stream_default_read;
+	l_stream->m_write_fn = opj_stream_default_write;
+	l_stream->m_skip_fn = opj_stream_default_skip;
+	l_stream->m_seek_fn = opj_stream_default_seek;
+
+	return (opj_stream_t *) l_stream;
+}
+
+opj_stream_t* OPJ_CALLCONV opj_stream_default_create(OPJ_BOOL l_is_input)
+{
+	return opj_stream_create(OPJ_J2K_STREAM_CHUNK_SIZE,l_is_input);
+}
+
+void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream)
+{
+	opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+	
+	if (l_stream) {
+		if (l_stream->m_free_user_data_fn) {
+			l_stream->m_free_user_data_fn(l_stream->m_user_data);
+		}
+		opj_free(l_stream->m_stored_data);
+		l_stream->m_stored_data = 00;
+		opj_free(l_stream);
+	}
+}
+
+void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function)
+{
+	opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+
+	if ((!l_stream) || (! (l_stream->m_status & OPJ_STREAM_STATUS_INPUT))) {
+		return;
+	}
+
+	l_stream->m_read_fn = p_function;
+}
+
+void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function)
+{
+	opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+	
+	if (!l_stream) {
+		return;
+	}
+	l_stream->m_seek_fn = p_function;
+}
+
+void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function)
+{
+	opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+	
+	if ((!l_stream )|| (! (l_stream->m_status & OPJ_STREAM_STATUS_OUTPUT))) {
+		return;
+	}
+
+	l_stream->m_write_fn = p_function;
+}
+
+void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function)
+{
+	opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+	
+	if (! l_stream) {
+		return;
+	}
+
+	l_stream->m_skip_fn = p_function;
+}
+
+void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function)
+{
+	opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+	if (!l_stream)
+		return;
+	l_stream->m_user_data = p_data;
+  l_stream->m_free_user_data_fn = p_function;
+}
+
+void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT64 data_length)
+{
+	opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+	if (!l_stream)
+		return;
+	l_stream->m_user_data_length = data_length;
+}
+
+OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, opj_event_mgr_t * p_event_mgr)
+{
+	OPJ_SIZE_T l_read_nb_bytes = 0;
+	if (p_stream->m_bytes_in_buffer >= p_size) {
+		memcpy(p_buffer,p_stream->m_current_data,p_size);
+		p_stream->m_current_data += p_size;
+		p_stream->m_bytes_in_buffer -= p_size;
+		l_read_nb_bytes += p_size;
+		p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
+		return l_read_nb_bytes;
+	}
+
+	/* we are now in the case when the remaining data if not sufficient */
+	if (p_stream->m_status & OPJ_STREAM_STATUS_END) {
+		l_read_nb_bytes += p_stream->m_bytes_in_buffer;
+		memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
+		p_stream->m_current_data += p_stream->m_bytes_in_buffer;
+		p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+		p_stream->m_bytes_in_buffer = 0;
+		return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1;
+	}
+
+	/* the flag is not set, we copy data and then do an actual read on the stream */
+	if (p_stream->m_bytes_in_buffer) {
+		l_read_nb_bytes += p_stream->m_bytes_in_buffer;
+		memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
+		p_stream->m_current_data = p_stream->m_stored_data;
+		p_buffer += p_stream->m_bytes_in_buffer;
+		p_size -= p_stream->m_bytes_in_buffer;
+		p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+		p_stream->m_bytes_in_buffer = 0;
+	}
+	else {
+    /* case where we are already at the end of the buffer
+       so reset the m_current_data to point to the start of the
+       stored buffer to get ready to read from disk*/
+		p_stream->m_current_data = p_stream->m_stored_data;
+	}
+
+	for (;;) {
+		/* we should read less than a chunk -> read a chunk */
+		if (p_size < p_stream->m_buffer_size) {
+			/* we should do an actual read on the media */
+			p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_stream->m_stored_data,p_stream->m_buffer_size,p_stream->m_user_data);
+
+			if (p_stream->m_bytes_in_buffer == (OPJ_SIZE_T)-1) {
+				/* end of stream */
+				opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
+
+				p_stream->m_bytes_in_buffer = 0;
+				p_stream->m_status |= OPJ_STREAM_STATUS_END;
+				/* end of stream */
+				return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1;
+			}
+			else if	(p_stream->m_bytes_in_buffer < p_size) {
+				/* not enough data */
+				l_read_nb_bytes += p_stream->m_bytes_in_buffer;
+				memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
+				p_stream->m_current_data = p_stream->m_stored_data;
+				p_buffer += p_stream->m_bytes_in_buffer;
+				p_size -= p_stream->m_bytes_in_buffer;
+				p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+				p_stream->m_bytes_in_buffer = 0;
+			}
+			else {
+				l_read_nb_bytes += p_size;
+				memcpy(p_buffer,p_stream->m_current_data,p_size);
+				p_stream->m_current_data += p_size;
+				p_stream->m_bytes_in_buffer -= p_size;
+				p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
+				return l_read_nb_bytes;
+			}
+		}
+		else {
+			/* direct read on the dest buffer */
+			p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_buffer,p_size,p_stream->m_user_data);
+
+			if (p_stream->m_bytes_in_buffer == (OPJ_SIZE_T)-1) {
+				/*  end of stream */
+				opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
+
+				p_stream->m_bytes_in_buffer = 0;
+				p_stream->m_status |= OPJ_STREAM_STATUS_END;
+				/* end of stream */
+				return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1;
+			}
+			else if (p_stream->m_bytes_in_buffer < p_size) {
+				/* not enough data */
+				l_read_nb_bytes += p_stream->m_bytes_in_buffer;
+				p_stream->m_current_data = p_stream->m_stored_data;
+				p_buffer += p_stream->m_bytes_in_buffer;
+				p_size -= p_stream->m_bytes_in_buffer;
+				p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+				p_stream->m_bytes_in_buffer = 0;
+			}
+			else {
+				/* we have read the exact size */
+				l_read_nb_bytes += p_stream->m_bytes_in_buffer;
+				p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+				p_stream->m_current_data = p_stream->m_stored_data;
+				p_stream->m_bytes_in_buffer = 0;
+				return l_read_nb_bytes;
+			}
+		}
+	}
+}
+
+OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,
+								  const OPJ_BYTE * p_buffer,
+								  OPJ_SIZE_T p_size, 
+								  opj_event_mgr_t * p_event_mgr)
+{
+	OPJ_SIZE_T l_remaining_bytes = 0;
+	OPJ_SIZE_T l_write_nb_bytes = 0;
+
+	if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) {
+		return (OPJ_SIZE_T)-1;
+	}
+
+	for (;;) {
+		l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_in_buffer;
+		
+		/* we have more memory than required */
+		if (l_remaining_bytes >= p_size) {
+			memcpy(p_stream->m_current_data, p_buffer, p_size);
+			
+			p_stream->m_current_data += p_size;
+			p_stream->m_bytes_in_buffer += p_size;
+			l_write_nb_bytes += p_size;
+			p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
+			
+			return l_write_nb_bytes;
+		}
+
+		/* we copy data and then do an actual read on the stream */
+		if (l_remaining_bytes) {
+			l_write_nb_bytes += l_remaining_bytes;
+			
+			memcpy(p_stream->m_current_data,p_buffer,l_remaining_bytes);
+			
+			p_stream->m_current_data = p_stream->m_stored_data;
+			
+			p_buffer += l_remaining_bytes;
+			p_size -= l_remaining_bytes;
+			p_stream->m_bytes_in_buffer += l_remaining_bytes;
+			p_stream->m_byte_offset += (OPJ_OFF_T)l_remaining_bytes;
+		}
+
+		if (! opj_stream_flush(p_stream, p_event_mgr)) {
+			return (OPJ_SIZE_T)-1;
+		}
+	}
+
+}
+
+OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, opj_event_mgr_t * p_event_mgr)
+{
+	/* the number of bytes written on the media. */
+	OPJ_SIZE_T l_current_write_nb_bytes = 0;
+
+	p_stream->m_current_data = p_stream->m_stored_data;
+
+	while (p_stream->m_bytes_in_buffer) {
+		/* we should do an actual write on the media */
+		l_current_write_nb_bytes = p_stream->m_write_fn(p_stream->m_current_data,
+														p_stream->m_bytes_in_buffer,
+														p_stream->m_user_data);
+		
+		if (l_current_write_nb_bytes == (OPJ_SIZE_T)-1) {
+			p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
+			opj_event_msg(p_event_mgr, EVT_INFO, "Error on writing stream!\n");
+
+			return OPJ_FALSE;
+		}
+
+		p_stream->m_current_data += l_current_write_nb_bytes;
+		p_stream->m_bytes_in_buffer -= l_current_write_nb_bytes;
+	}
+
+	p_stream->m_current_data = p_stream->m_stored_data;
+	
+	return OPJ_TRUE;
+}
+
+OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
+{
+	OPJ_OFF_T l_skip_nb_bytes = 0;
+	OPJ_OFF_T l_current_skip_nb_bytes = 0;
+	
+	assert( p_size >= 0 );
+	
+	if (p_stream->m_bytes_in_buffer >= (OPJ_SIZE_T)p_size) {
+		p_stream->m_current_data += p_size;
+		/* it is safe to cast p_size to OPJ_SIZE_T since it is <= m_bytes_in_buffer
+		which is of type OPJ_SIZE_T */
+		p_stream->m_bytes_in_buffer -= (OPJ_SIZE_T)p_size;
+		l_skip_nb_bytes += p_size;
+		p_stream->m_byte_offset += l_skip_nb_bytes;
+		return l_skip_nb_bytes;
+	}
+
+	/* we are now in the case when the remaining data if not sufficient */
+	if (p_stream->m_status & OPJ_STREAM_STATUS_END) {
+		l_skip_nb_bytes += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+		p_stream->m_current_data += p_stream->m_bytes_in_buffer;
+		p_stream->m_bytes_in_buffer = 0;
+		p_stream->m_byte_offset += l_skip_nb_bytes;
+		return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) -1;
+	}
+
+	/* the flag is not set, we copy data and then do an actual skip on the stream */
+	if (p_stream->m_bytes_in_buffer) {
+		l_skip_nb_bytes += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+		p_stream->m_current_data = p_stream->m_stored_data;
+		p_size -= (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
+		p_stream->m_bytes_in_buffer = 0;
+	}
+
+	while (p_size > 0) {
+		/* we should do an actual skip on the media */
+		l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
+		if (l_current_skip_nb_bytes == (OPJ_OFF_T) -1) {
+			opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
+
+			p_stream->m_status |= OPJ_STREAM_STATUS_END;
+			p_stream->m_byte_offset += l_skip_nb_bytes;
+			/* end if stream */
+			return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) -1;
+		}
+		p_size -= l_current_skip_nb_bytes;
+		l_skip_nb_bytes += l_current_skip_nb_bytes;
+	}
+
+	p_stream->m_byte_offset += l_skip_nb_bytes;
+	
+	return l_skip_nb_bytes;
+}
+
+OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
+{
+	OPJ_BOOL l_is_written = 0;
+	OPJ_OFF_T l_current_skip_nb_bytes = 0;
+	OPJ_OFF_T l_skip_nb_bytes = 0;
+
+	if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) {
+		return (OPJ_OFF_T) -1;
+	}
+
+	/* we should flush data */
+	l_is_written = opj_stream_flush (p_stream, p_event_mgr);
+	if (! l_is_written) {
+		p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
+		p_stream->m_bytes_in_buffer = 0;
+		return (OPJ_OFF_T) -1;
+	}
+	/* then skip */
+
+	while (p_size > 0) {
+		/* we should do an actual skip on the media */
+		l_current_skip_nb_bytes = p_stream->m_skip_fn(p_size, p_stream->m_user_data);
+		
+		if (l_current_skip_nb_bytes == (OPJ_OFF_T)-1) {
+			opj_event_msg(p_event_mgr, EVT_INFO, "Stream error!\n");
+
+			p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
+			p_stream->m_byte_offset += l_skip_nb_bytes;
+			/* end if stream */
+			return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T)-1;
+		}
+		p_size -= l_current_skip_nb_bytes;
+		l_skip_nb_bytes += l_current_skip_nb_bytes;
+	}
+
+	p_stream->m_byte_offset += l_skip_nb_bytes;
+	
+	return l_skip_nb_bytes;
+}
+
+OPJ_OFF_T opj_stream_tell (const opj_stream_private_t * p_stream)
+{
+	return p_stream->m_byte_offset;
+}
+
+OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream)
+{
+  assert( p_stream->m_byte_offset >= 0 );
+  assert( p_stream->m_user_data_length >= (OPJ_UINT64)p_stream->m_byte_offset);
+  return p_stream->m_user_data_length ?
+				(OPJ_OFF_T)(p_stream->m_user_data_length) - p_stream->m_byte_offset :
+				0;
+}
+
+OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
+{
+	assert(p_size >= 0);
+	return p_stream->m_opj_skip(p_stream,p_size,p_event_mgr);
+}
+
+OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
+{
+	OPJ_ARG_NOT_USED(p_event_mgr);
+	p_stream->m_current_data = p_stream->m_stored_data;
+	p_stream->m_bytes_in_buffer = 0;
+
+	if( !(p_stream->m_seek_fn(p_size,p_stream->m_user_data)) ) {
+		p_stream->m_status |= OPJ_STREAM_STATUS_END;
+		return OPJ_FALSE;
+	}
+	else {
+		/* reset stream status */
+		p_stream->m_status &= (~OPJ_STREAM_STATUS_END);
+		p_stream->m_byte_offset = p_size;
+
+	}
+
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
+{
+	if (! opj_stream_flush(p_stream,p_event_mgr)) {
+		p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
+		return OPJ_FALSE;
+	}
+
+	p_stream->m_current_data = p_stream->m_stored_data;
+	p_stream->m_bytes_in_buffer = 0;
+
+	if (! p_stream->m_seek_fn(p_size,p_stream->m_user_data)) {
+		p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
+		return OPJ_FALSE;
+	}
+	else {
+		p_stream->m_byte_offset = p_size;
+	}
+
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr)
+{
+	assert(p_size >= 0);
+	return p_stream->m_opj_seek(p_stream,p_size,p_event_mgr);
+}
+
+OPJ_BOOL opj_stream_has_seek (const opj_stream_private_t * p_stream)
+{
+	return p_stream->m_seek_fn != opj_stream_default_seek;
+}
+
+OPJ_SIZE_T opj_stream_default_read (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data)
+{
+	OPJ_ARG_NOT_USED(p_buffer);
+	OPJ_ARG_NOT_USED(p_nb_bytes);
+	OPJ_ARG_NOT_USED(p_user_data);
+	return (OPJ_SIZE_T) -1;
+}
+
+OPJ_SIZE_T opj_stream_default_write (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data)
+{
+	OPJ_ARG_NOT_USED(p_buffer);
+	OPJ_ARG_NOT_USED(p_nb_bytes);
+	OPJ_ARG_NOT_USED(p_user_data);
+	return (OPJ_SIZE_T) -1;
+}
+
+OPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data)
+{
+	OPJ_ARG_NOT_USED(p_nb_bytes);
+	OPJ_ARG_NOT_USED(p_user_data);
+	return (OPJ_OFF_T) -1;
+}
+
+OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data)
+{
+	OPJ_ARG_NOT_USED(p_nb_bytes);
+	OPJ_ARG_NOT_USED(p_user_data);
+	return OPJ_FALSE;
+}
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/cio.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/cio.h
new file mode 100644
index 0000000..4ea03ff
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/cio.h
@@ -0,0 +1,394 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __CIO_H
+#define __CIO_H
+/**
+ at file cio.h
+ at brief Implementation of a byte input-output process (CIO)
+
+The functions in CIO.C have for goal to realize a byte input / output process.
+*/
+
+/** @defgroup CIO CIO - byte input-output stream */
+/*@{*/
+
+#include "opj_config_private.h"
+
+/* ----------------------------------------------------------------------- */
+
+#if defined(OPJ_BIG_ENDIAN)
+	#define opj_write_bytes		opj_write_bytes_BE
+	#define opj_read_bytes		opj_read_bytes_BE
+	#define opj_write_double	opj_write_double_BE
+	#define opj_read_double		opj_read_double_BE
+	#define opj_write_float		opj_write_float_BE
+	#define opj_read_float		opj_read_float_BE
+#else
+	#define opj_write_bytes		opj_write_bytes_LE
+	#define opj_read_bytes		opj_read_bytes_LE
+	#define opj_write_double	opj_write_double_LE
+	#define opj_read_double		opj_read_double_LE
+	#define opj_write_float		opj_write_float_LE
+	#define opj_read_float		opj_read_float_LE
+#endif
+
+
+#define OPJ_STREAM_STATUS_OUTPUT  0x1U
+#define OPJ_STREAM_STATUS_INPUT   0x2U
+#define OPJ_STREAM_STATUS_END     0x4U
+#define OPJ_STREAM_STATUS_ERROR   0x8U
+
+/**
+Byte input-output stream.
+*/
+typedef struct opj_stream_private
+{
+	/**
+	 * User data, be it files, ... The actual data depends on the type of the stream.
+	 */
+	void *					m_user_data;
+
+	/**
+	 * Pointer to function to free m_user_data (NULL at initialization)
+	 * when destroying the stream. If pointer is NULL the function is not
+	 * called and the m_user_data is not freed (even if non-NULL).
+	 */
+	opj_stream_free_user_data_fn		m_free_user_data_fn;
+
+	/**
+	 * User data length
+	 */
+	OPJ_UINT64 				m_user_data_length;
+
+	/**
+	 * Pointer to actual read function (NULL at the initialization of the cio.
+	 */
+	opj_stream_read_fn		m_read_fn;
+
+	/**
+	 * Pointer to actual write function (NULL at the initialization of the cio.
+	 */
+	opj_stream_write_fn		m_write_fn;
+
+	/**
+	 * Pointer to actual skip function (NULL at the initialization of the cio.
+	 * There is no seek function to prevent from back and forth slow procedures.
+	 */
+	opj_stream_skip_fn		m_skip_fn;
+
+	/**
+	 * Pointer to actual seek function (if available).
+	 */
+	opj_stream_seek_fn		m_seek_fn;
+
+	/**
+	 * Actual data stored into the stream if readed from. Data is read by chunk of fixed size.
+	 * you should never access this data directly.
+	 */
+	OPJ_BYTE *					m_stored_data;
+
+	/**
+	 * Pointer to the current read data.
+	 */
+	OPJ_BYTE *					m_current_data;
+
+    /**
+    * FIXME DOC.
+    */
+	OPJ_OFF_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_OFF_T , struct opj_event_mgr *);
+
+    /**
+    * FIXME DOC.
+    */
+	OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *);
+
+	/**
+	 * number of bytes containing in the buffer.
+	 */
+	OPJ_SIZE_T			m_bytes_in_buffer;
+
+	/**
+	 * The number of bytes read/written from the beginning of the stream
+	 */
+	OPJ_OFF_T			m_byte_offset;
+
+	/**
+	 * The size of the buffer.
+	 */
+	OPJ_SIZE_T			m_buffer_size;
+
+	/**
+	 * Flags to tell the status of the stream.
+	 * Used with OPJ_STREAM_STATUS_* defines.
+	 */
+	OPJ_UINT32 m_status;
+
+}
+opj_stream_private_t;
+
+/** @name Exported functions (see also openjpeg.h) */
+/*@{*/
+/* ----------------------------------------------------------------------- */
+/**
+ * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
+ * @param p_buffer		pointer the data buffer to write data to.
+ * @param p_value		the value to write
+ * @param p_nb_bytes	the number of bytes to write
+*/
+void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
+
+/**
+ * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
+ * @param p_buffer		pointer the data buffer to read data from.
+ * @param p_value		pointer to the value that will store the data.
+ * @param p_nb_bytes	the nb bytes to read.
+ * @return				the number of bytes read or -1 if an error occurred.
+ */
+void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
+
+/**
+ * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
+ * @param p_buffer		pointer the data buffer to write data to.
+ * @param p_value		the value to write
+ * @param p_nb_bytes	the number of bytes to write
+ * @return				the number of bytes written or -1 if an error occurred
+*/
+void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
+
+/**
+ * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
+ * @param p_buffer		pointer the data buffer to read data from.
+ * @param p_value		pointer to the value that will store the data.
+ * @param p_nb_bytes	the nb bytes to read.
+ * @return				the number of bytes read or -1 if an error occurred.
+ */
+void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
+
+
+/**
+ * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
+ * @param p_buffer		pointer the data buffer to write data to.
+ * @param p_value		the value to write
+ */
+void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
+
+/***
+ * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
+ * @param p_buffer		pointer the data buffer to write data to.
+ * @param p_value		the value to write
+ */
+void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
+
+/**
+ * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
+ * @param p_buffer		pointer the data buffer to read data from.
+ * @param p_value		pointer to the value that will store the data.
+ */
+void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
+
+/**
+ * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
+ * @param p_buffer		pointer the data buffer to read data from.
+ * @param p_value		pointer to the value that will store the data.
+ */
+void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
+
+/**
+ * Reads some bytes from the given data buffer, this function is used in Little Endian cpus.
+ * @param p_buffer		pointer the data buffer to read data from.
+ * @param p_value		pointer to the value that will store the data.
+ */
+void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
+
+/**
+ * Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
+ * @param p_buffer		pointer the data buffer to read data from.
+ * @param p_value		pointer to the value that will store the data.
+ */
+void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
+
+/**
+ * Write some bytes to the given data buffer, this function is used in Little Endian cpus.
+ * @param p_buffer		pointer the data buffer to write data to.
+ * @param p_value		the value to write
+ */
+void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
+
+/***
+ * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
+ * @param p_buffer		pointer the data buffer to write data to.
+ * @param p_value		the value to write
+ */
+void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
+
+/**
+ * Reads some bytes from the stream.
+ * @param		p_stream	the stream to read data from.
+ * @param		p_buffer	pointer to the data buffer that will receive the data.
+ * @param		p_size		number of bytes to read.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		the number of bytes read, or -1 if an error occurred or if the stream is at the end.
+ */
+OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Writes some bytes to the stream.
+ * @param		p_stream	the stream to write data to.
+ * @param		p_buffer	pointer to the data buffer holds the data to be writtent.
+ * @param		p_size		number of bytes to write.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		the number of bytes writtent, or -1 if an error occurred.
+ */
+OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Writes the content of the stream buffer to the stream.
+ * @param		p_stream	the stream to write data to.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		true if the data could be flushed, false else.
+ */
+OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Skips a number of bytes from the stream.
+ * @param		p_stream	the stream to skip data from.
+ * @param		p_size		the number of bytes to skip.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		the number of bytes skipped, or -1 if an error occurred.
+ */
+OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Tells the byte offset on the stream (similar to ftell).
+ *
+ * @param		p_stream	the stream to get the information from.
+ *
+ * @return		the current position o fthe stream.
+ */
+OPJ_OFF_T opj_stream_tell (const opj_stream_private_t * p_stream);
+
+
+/**
+ * Get the number of bytes left before the end of the stream (similar to cio_numbytesleft).
+ *
+ * @param		p_stream	the stream to get the information from.
+ *
+ * @return		Number of bytes left before the end of the stream.
+ */
+OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream);
+
+/**
+ * Skips a number of bytes from the stream.
+ * @param		p_stream	the stream to skip data from.
+ * @param		p_size		the number of bytes to skip.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		the number of bytes skipped, or -1 if an error occurred.
+ */
+OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Skips a number of bytes from the stream.
+ * @param		p_stream	the stream to skip data from.
+ * @param		p_size		the number of bytes to skip.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		the number of bytes skipped, or -1 if an error occurred.
+ */
+OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Skips a number of bytes from the stream.
+ * @param		p_stream	the stream to skip data from.
+ * @param		p_size		the number of bytes to skip.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		OPJ_TRUE if success, or OPJ_FALSE if an error occurred.
+ */
+OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Skips a number of bytes from the stream.
+ * @param		p_stream	the stream to skip data from.
+ * @param		p_size		the number of bytes to skip.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		the number of bytes skipped, or -1 if an error occurred.
+ */
+OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Seeks a number of bytes from the stream.
+ * @param		p_stream	the stream to skip data from.
+ * @param		p_size		the number of bytes to skip.
+ * @param		p_event_mgr	the user event manager to be notified of special events.
+ * @return		true if the stream is seekable.
+ */
+OPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
+
+/**
+ * Tells if the given stream is seekable.
+ */
+OPJ_BOOL opj_stream_has_seek (const opj_stream_private_t * p_stream);
+
+/**
+ * FIXME DOC.
+ */
+OPJ_SIZE_T opj_stream_default_read (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
+
+/**
+ * FIXME DOC.
+ */
+OPJ_SIZE_T opj_stream_default_write (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
+
+/**
+ * FIXME DOC.
+ */
+OPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data);
+
+/**
+ * FIXME DOC.
+ */
+OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data);
+
+/* ----------------------------------------------------------------------- */
+/*@}*/
+
+/*@}*/
+
+
+#endif /* __CIO_H */
+
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/dwt.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/dwt.c
new file mode 100644
index 0000000..a4ff01b
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/dwt.c
@@ -0,0 +1,934 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2007, Jonathan Ballard <dzonatas at dzonux.net>
+ * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef __SSE__
+#include <xmmintrin.h>
+#endif
+
+#include "opj_includes.h"
+
+/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
+/*@{*/
+
+#define OPJ_WS(i) v->mem[(i)*2]
+#define OPJ_WD(i) v->mem[(1+(i)*2)]
+
+/** @name Local data structures */
+/*@{*/
+
+typedef struct dwt_local {
+	OPJ_INT32* mem;
+	OPJ_INT32 dn;
+	OPJ_INT32 sn;
+	OPJ_INT32 cas;
+} opj_dwt_t;
+
+typedef union {
+	OPJ_FLOAT32	f[4];
+} opj_v4_t;
+
+typedef struct v4dwt_local {
+	opj_v4_t*	wavelet ;
+	OPJ_INT32		dn ;
+	OPJ_INT32		sn ;
+	OPJ_INT32		cas ;
+} opj_v4dwt_t ;
+
+static const OPJ_FLOAT32 opj_dwt_alpha =  1.586134342f; /*  12994 */
+static const OPJ_FLOAT32 opj_dwt_beta  =  0.052980118f; /*    434 */
+static const OPJ_FLOAT32 opj_dwt_gamma = -0.882911075f; /*  -7233 */
+static const OPJ_FLOAT32 opj_dwt_delta = -0.443506852f; /*  -3633 */
+
+static const OPJ_FLOAT32 opj_K      = 1.230174105f; /*  10078 */
+static const OPJ_FLOAT32 opj_c13318 = 1.625732422f;
+
+/*@}*/
+
+/**
+Virtual function type for wavelet transform in 1-D 
+*/
+typedef void (*DWT1DFN)(opj_dwt_t* v);
+
+/** @name Local static functions */
+/*@{*/
+
+/**
+Forward lazy transform (horizontal)
+*/
+static void opj_dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
+/**
+Forward lazy transform (vertical)
+*/
+static void opj_dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas);
+/**
+Inverse lazy transform (horizontal)
+*/
+static void opj_dwt_interleave_h(opj_dwt_t* h, OPJ_INT32 *a);
+/**
+Inverse lazy transform (vertical)
+*/
+static void opj_dwt_interleave_v(opj_dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x);
+/**
+Forward 5-3 wavelet transform in 1-D
+*/
+static void opj_dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
+/**
+Inverse 5-3 wavelet transform in 1-D
+*/
+static void opj_dwt_decode_1(opj_dwt_t *v);
+static void opj_dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
+/**
+Forward 9-7 wavelet transform in 1-D
+*/
+static void opj_dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas);
+/**
+Explicit calculation of the Quantization Stepsizes 
+*/
+static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize);
+/**
+Inverse wavelet transform in 2-D.
+*/
+static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i, DWT1DFN fn);
+
+static OPJ_BOOL opj_dwt_encode_procedure(	opj_tcd_tilecomp_t * tilec,
+										    void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) );
+
+static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i);
+
+/* <summary>                             */
+/* Inverse 9-7 wavelet transform in 1-D. */
+/* </summary>                            */
+static void opj_v4dwt_decode(opj_v4dwt_t* restrict dwt);
+
+static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restrict a, OPJ_INT32 x, OPJ_INT32 size);
+
+static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x, OPJ_INT32 nb_elts_read);
+
+#ifdef __SSE__
+static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c);
+
+static void opj_v4dwt_decode_step2_sse(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c);
+
+#else
+static void opj_v4dwt_decode_step1(opj_v4_t* w, OPJ_INT32 count, const OPJ_FLOAT32 c);
+
+static void opj_v4dwt_decode_step2(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, OPJ_FLOAT32 c);
+
+#endif
+
+/*@}*/
+
+/*@}*/
+
+#define OPJ_S(i) a[(i)*2]
+#define OPJ_D(i) a[(1+(i)*2)]
+#define OPJ_S_(i) ((i)<0?OPJ_S(0):((i)>=sn?OPJ_S(sn-1):OPJ_S(i)))
+#define OPJ_D_(i) ((i)<0?OPJ_D(0):((i)>=dn?OPJ_D(dn-1):OPJ_D(i)))
+/* new */
+#define OPJ_SS_(i) ((i)<0?OPJ_S(0):((i)>=dn?OPJ_S(dn-1):OPJ_S(i)))
+#define OPJ_DD_(i) ((i)<0?OPJ_D(0):((i)>=sn?OPJ_D(sn-1):OPJ_D(i)))
+
+/* <summary>                                                              */
+/* This table contains the norms of the 5-3 wavelets for different bands. */
+/* </summary>                                                             */
+static const OPJ_FLOAT64 opj_dwt_norms[4][10] = {
+	{1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
+	{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
+	{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
+	{.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
+};
+
+/* <summary>                                                              */
+/* This table contains the norms of the 9-7 wavelets for different bands. */
+/* </summary>                                                             */
+static const OPJ_FLOAT64 opj_dwt_norms_real[4][10] = {
+	{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
+	{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
+	{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
+	{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
+};
+
+/* 
+==========================================================
+   local functions
+==========================================================
+*/
+
+/* <summary>			                 */
+/* Forward lazy transform (horizontal).  */
+/* </summary>                            */ 
+static void opj_dwt_deinterleave_h(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
+	OPJ_INT32 i;
+	OPJ_INT32 * l_dest = b;
+	OPJ_INT32 * l_src = a+cas;
+
+    for (i=0; i<sn; ++i) {
+		*l_dest++ = *l_src;
+		l_src += 2;
+	}
+	
+    l_dest = b + sn;
+	l_src = a + 1 - cas;
+
+    for	(i=0; i<dn; ++i)  {
+		*l_dest++=*l_src;
+		l_src += 2;
+	}
+}
+
+/* <summary>                             */  
+/* Forward lazy transform (vertical).    */
+/* </summary>                            */ 
+static void opj_dwt_deinterleave_v(OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas) {
+    OPJ_INT32 i = sn;
+	OPJ_INT32 * l_dest = b;
+	OPJ_INT32 * l_src = a+cas;
+
+    while (i--) {
+		*l_dest = *l_src;
+		l_dest += x;
+		l_src += 2;
+		} /* b[i*x]=a[2*i+cas]; */
+
+	l_dest = b + sn * x;
+	l_src = a + 1 - cas;
+	
+	i = dn;
+    while (i--) {
+		*l_dest = *l_src;
+		l_dest += x;
+		l_src += 2;
+        } /*b[(sn+i)*x]=a[(2*i+1-cas)];*/
+}
+
+/* <summary>                             */
+/* Inverse lazy transform (horizontal).  */
+/* </summary>                            */
+static void opj_dwt_interleave_h(opj_dwt_t* h, OPJ_INT32 *a) {
+    OPJ_INT32 *ai = a;
+    OPJ_INT32 *bi = h->mem + h->cas;
+    OPJ_INT32  i	= h->sn;
+    while( i-- ) {
+      *bi = *(ai++);
+	  bi += 2;
+    }
+    ai	= a + h->sn;
+    bi	= h->mem + 1 - h->cas;
+    i	= h->dn ;
+    while( i-- ) {
+      *bi = *(ai++);
+	  bi += 2;
+    }
+}
+
+/* <summary>                             */  
+/* Inverse lazy transform (vertical).    */
+/* </summary>                            */ 
+static void opj_dwt_interleave_v(opj_dwt_t* v, OPJ_INT32 *a, OPJ_INT32 x) {
+    OPJ_INT32 *ai = a;
+    OPJ_INT32 *bi = v->mem + v->cas;
+    OPJ_INT32  i = v->sn;
+    while( i-- ) {
+      *bi = *ai;
+	  bi += 2;
+	  ai += x;
+    }
+    ai = a + (v->sn * x);
+    bi = v->mem + 1 - v->cas;
+    i = v->dn ;
+    while( i-- ) {
+      *bi = *ai;
+	  bi += 2;  
+	  ai += x;
+    }
+}
+
+
+/* <summary>                            */
+/* Forward 5-3 wavelet transform in 1-D. */
+/* </summary>                           */
+static void opj_dwt_encode_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
+	OPJ_INT32 i;
+	
+	if (!cas) {
+		if ((dn > 0) || (sn > 1)) {	/* NEW :  CASE ONE ELEMENT */
+			for (i = 0; i < dn; i++) OPJ_D(i) -= (OPJ_S_(i) + OPJ_S_(i + 1)) >> 1;
+			for (i = 0; i < sn; i++) OPJ_S(i) += (OPJ_D_(i - 1) + OPJ_D_(i) + 2) >> 2;
+		}
+	} else {
+		if (!sn && dn == 1)		    /* NEW :  CASE ONE ELEMENT */
+			OPJ_S(0) *= 2;
+		else {
+			for (i = 0; i < dn; i++) OPJ_S(i) -= (OPJ_DD_(i) + OPJ_DD_(i - 1)) >> 1;
+			for (i = 0; i < sn; i++) OPJ_D(i) += (OPJ_SS_(i) + OPJ_SS_(i + 1) + 2) >> 2;
+		}
+	}
+}
+
+/* <summary>                            */
+/* Inverse 5-3 wavelet transform in 1-D. */
+/* </summary>                           */ 
+static void opj_dwt_decode_1_(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
+	OPJ_INT32 i;
+	
+	if (!cas) {
+		if ((dn > 0) || (sn > 1)) { /* NEW :  CASE ONE ELEMENT */
+			for (i = 0; i < sn; i++) OPJ_S(i) -= (OPJ_D_(i - 1) + OPJ_D_(i) + 2) >> 2;
+			for (i = 0; i < dn; i++) OPJ_D(i) += (OPJ_S_(i) + OPJ_S_(i + 1)) >> 1;
+		}
+	} else {
+		if (!sn  && dn == 1)          /* NEW :  CASE ONE ELEMENT */
+			OPJ_S(0) /= 2;
+		else {
+			for (i = 0; i < sn; i++) OPJ_D(i) -= (OPJ_SS_(i) + OPJ_SS_(i + 1) + 2) >> 2;
+			for (i = 0; i < dn; i++) OPJ_S(i) += (OPJ_DD_(i) + OPJ_DD_(i - 1)) >> 1;
+		}
+	}
+}
+
+/* <summary>                            */
+/* Inverse 5-3 wavelet transform in 1-D. */
+/* </summary>                           */ 
+static void opj_dwt_decode_1(opj_dwt_t *v) {
+	opj_dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
+}
+
+/* <summary>                             */
+/* Forward 9-7 wavelet transform in 1-D. */
+/* </summary>                            */
+static void opj_dwt_encode_1_real(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas) {
+	OPJ_INT32 i;
+	if (!cas) {
+		if ((dn > 0) || (sn > 1)) {	/* NEW :  CASE ONE ELEMENT */
+			for (i = 0; i < dn; i++)
+				OPJ_D(i) -= opj_int_fix_mul(OPJ_S_(i) + OPJ_S_(i + 1), 12993);
+			for (i = 0; i < sn; i++)
+				OPJ_S(i) -= opj_int_fix_mul(OPJ_D_(i - 1) + OPJ_D_(i), 434);
+			for (i = 0; i < dn; i++)
+				OPJ_D(i) += opj_int_fix_mul(OPJ_S_(i) + OPJ_S_(i + 1), 7233);
+			for (i = 0; i < sn; i++)
+				OPJ_S(i) += opj_int_fix_mul(OPJ_D_(i - 1) + OPJ_D_(i), 3633);
+			for (i = 0; i < dn; i++)
+				OPJ_D(i) = opj_int_fix_mul(OPJ_D(i), 5038);	/*5038 */
+			for (i = 0; i < sn; i++)
+				OPJ_S(i) = opj_int_fix_mul(OPJ_S(i), 6659);	/*6660 */
+		}
+	} else {
+		if ((sn > 0) || (dn > 1)) {	/* NEW :  CASE ONE ELEMENT */
+			for (i = 0; i < dn; i++)
+				OPJ_S(i) -= opj_int_fix_mul(OPJ_DD_(i) + OPJ_DD_(i - 1), 12993);
+			for (i = 0; i < sn; i++)
+				OPJ_D(i) -= opj_int_fix_mul(OPJ_SS_(i) + OPJ_SS_(i + 1), 434);
+			for (i = 0; i < dn; i++)
+				OPJ_S(i) += opj_int_fix_mul(OPJ_DD_(i) + OPJ_DD_(i - 1), 7233);
+			for (i = 0; i < sn; i++)
+				OPJ_D(i) += opj_int_fix_mul(OPJ_SS_(i) + OPJ_SS_(i + 1), 3633);
+			for (i = 0; i < dn; i++)
+				OPJ_S(i) = opj_int_fix_mul(OPJ_S(i), 5038);	/*5038 */
+			for (i = 0; i < sn; i++)
+				OPJ_D(i) = opj_int_fix_mul(OPJ_D(i), 6659);	/*6660 */
+		}
+	}
+}
+
+static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize) {
+	OPJ_INT32 p, n;
+	p = opj_int_floorlog2(stepsize) - 13;
+	n = 11 - opj_int_floorlog2(stepsize);
+	bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
+	bandno_stepsize->expn = numbps - p;
+}
+
+/* 
+==========================================================
+   DWT interface
+==========================================================
+*/
+
+
+/* <summary>                            */
+/* Forward 5-3 wavelet transform in 2-D. */
+/* </summary>                           */
+static INLINE OPJ_BOOL opj_dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) )
+{
+	OPJ_INT32 i, j, k;
+	OPJ_INT32 *a = 00;
+	OPJ_INT32 *aj = 00;
+	OPJ_INT32 *bj = 00;
+	OPJ_INT32 w, l;
+
+	OPJ_INT32 rw;			/* width of the resolution level computed   */
+	OPJ_INT32 rh;			/* height of the resolution level computed  */
+	OPJ_UINT32 l_data_size;
+
+	opj_tcd_resolution_t * l_cur_res = 0;
+	opj_tcd_resolution_t * l_last_res = 0;
+
+	w = tilec->x1-tilec->x0;
+	l = (OPJ_INT32)tilec->numresolutions-1;
+	a = tilec->data;
+
+	l_cur_res = tilec->resolutions + l;
+	l_last_res = l_cur_res - 1;
+
+	l_data_size = opj_dwt_max_resolution( tilec->resolutions,tilec->numresolutions) * (OPJ_UINT32)sizeof(OPJ_INT32);
+	bj = (OPJ_INT32*)opj_malloc((size_t)l_data_size);
+	/* l_data_size is equal to 0 when numresolutions == 1 but bj is not used */
+	/* in that case, so do not error out */
+	if (l_data_size != 0 && ! bj) {
+		return OPJ_FALSE;
+	}
+	i = l;
+
+	while (i--) {
+		OPJ_INT32 rw1;		/* width of the resolution level once lower than computed one                                       */
+		OPJ_INT32 rh1;		/* height of the resolution level once lower than computed one                                      */
+		OPJ_INT32 cas_col;	/* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
+		OPJ_INT32 cas_row;	/* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering   */
+		OPJ_INT32 dn, sn;
+
+		rw  = l_cur_res->x1 - l_cur_res->x0;
+		rh  = l_cur_res->y1 - l_cur_res->y0;
+		rw1 = l_last_res->x1 - l_last_res->x0;
+		rh1 = l_last_res->y1 - l_last_res->y0;
+
+		cas_row = l_cur_res->x0 & 1;
+		cas_col = l_cur_res->y0 & 1;
+
+		sn = rh1;
+		dn = rh - rh1;
+		for (j = 0; j < rw; ++j) {
+			aj = a + j;
+			for (k = 0; k < rh; ++k) {
+				bj[k] = aj[k*w];
+			}
+
+			(*p_function) (bj, dn, sn, cas_col);
+
+			opj_dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
+		}
+
+		sn = rw1;
+		dn = rw - rw1;
+
+		for (j = 0; j < rh; j++) {
+			aj = a + j * w;
+			for (k = 0; k < rw; k++)  bj[k] = aj[k];
+			(*p_function) (bj, dn, sn, cas_row);
+			opj_dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
+		}
+
+		l_cur_res = l_last_res;
+
+		--l_last_res;
+	}
+
+	opj_free(bj);
+	return OPJ_TRUE;
+}
+
+/* Forward 5-3 wavelet transform in 2-D. */
+/* </summary>                           */
+OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec)
+{
+	return opj_dwt_encode_procedure(tilec,opj_dwt_encode_1);
+}
+
+/* <summary>                            */
+/* Inverse 5-3 wavelet transform in 2-D. */
+/* </summary>                           */
+OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
+	return opj_dwt_decode_tile(tilec, numres, &opj_dwt_decode_1);
+}
+
+
+/* <summary>                          */
+/* Get gain of 5-3 wavelet transform. */
+/* </summary>                         */
+OPJ_UINT32 opj_dwt_getgain(OPJ_UINT32 orient) {
+	if (orient == 0)
+		return 0;
+	if (orient == 1 || orient == 2)
+		return 1;
+	return 2;
+}
+
+/* <summary>                */
+/* Get norm of 5-3 wavelet. */
+/* </summary>               */
+OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient) {
+	return opj_dwt_norms[orient][level];
+}
+
+/* <summary>                             */
+/* Forward 9-7 wavelet transform in 2-D. */
+/* </summary>                            */
+OPJ_BOOL opj_dwt_encode_real(opj_tcd_tilecomp_t * tilec)
+{
+	return opj_dwt_encode_procedure(tilec,opj_dwt_encode_1_real);
+}
+
+/* <summary>                          */
+/* Get gain of 9-7 wavelet transform. */
+/* </summary>                         */
+OPJ_UINT32 opj_dwt_getgain_real(OPJ_UINT32 orient) {
+	(void)orient;
+	return 0;
+}
+
+/* <summary>                */
+/* Get norm of 9-7 wavelet. */
+/* </summary>               */
+OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient) {
+	return opj_dwt_norms_real[orient][level];
+}
+
+void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec) {
+	OPJ_UINT32 numbands, bandno;
+	numbands = 3 * tccp->numresolutions - 2;
+	for (bandno = 0; bandno < numbands; bandno++) {
+		OPJ_FLOAT64 stepsize;
+		OPJ_UINT32 resno, level, orient, gain;
+
+		resno = (bandno == 0) ? 0 : ((bandno - 1) / 3 + 1);
+		orient = (bandno == 0) ? 0 : ((bandno - 1) % 3 + 1);
+		level = tccp->numresolutions - 1 - resno;
+		gain = (tccp->qmfbid == 0) ? 0 : ((orient == 0) ? 0 : (((orient == 1) || (orient == 2)) ? 1 : 2));
+		if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
+			stepsize = 1.0;
+		} else {
+			OPJ_FLOAT64 norm = opj_dwt_norms_real[orient][level];
+			stepsize = (1 << (gain)) / norm;
+		}
+		opj_dwt_encode_stepsize((OPJ_INT32) floor(stepsize * 8192.0), (OPJ_INT32)(prec + gain), &tccp->stepsizes[bandno]);
+	}
+}
+
+/* <summary>                             */
+/* Determine maximum computed resolution level for inverse wavelet transform */
+/* </summary>                            */
+static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i) {
+	OPJ_UINT32 mr	= 0;
+	OPJ_UINT32 w;
+	while( --i ) {
+		++r;
+		if( mr < ( w = (OPJ_UINT32)(r->x1 - r->x0) ) )
+			mr = w ;
+		if( mr < ( w = (OPJ_UINT32)(r->y1 - r->y0) ) )
+			mr = w ;
+	}
+	return mr ;
+}
+
+/* <summary>                            */
+/* Inverse wavelet transform in 2-D.     */
+/* </summary>                           */
+static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D) {
+	opj_dwt_t h;
+	opj_dwt_t v;
+
+	opj_tcd_resolution_t* tr = tilec->resolutions;
+
+	OPJ_UINT32 rw = (OPJ_UINT32)(tr->x1 - tr->x0);	/* width of the resolution level computed */
+	OPJ_UINT32 rh = (OPJ_UINT32)(tr->y1 - tr->y0);	/* height of the resolution level computed */
+
+	OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
+	
+	if (numres == 1U) {
+		return OPJ_TRUE;
+	}
+	h.mem = (OPJ_INT32*)opj_aligned_malloc(opj_dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32));
+	if (! h.mem){
+		/* FIXME event manager error callback */
+		return OPJ_FALSE;
+	}
+
+	v.mem = h.mem;
+
+	while( --numres) {
+		OPJ_INT32 * restrict tiledp = tilec->data;
+		OPJ_UINT32 j;
+
+		++tr;
+		h.sn = (OPJ_INT32)rw;
+		v.sn = (OPJ_INT32)rh;
+
+		rw = (OPJ_UINT32)(tr->x1 - tr->x0);
+		rh = (OPJ_UINT32)(tr->y1 - tr->y0);
+
+		h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
+		h.cas = tr->x0 % 2;
+
+		for(j = 0; j < rh; ++j) {
+			opj_dwt_interleave_h(&h, &tiledp[j*w]);
+			(dwt_1D)(&h);
+			memcpy(&tiledp[j*w], h.mem, rw * sizeof(OPJ_INT32));
+		}
+
+		v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
+		v.cas = tr->y0 % 2;
+
+		for(j = 0; j < rw; ++j){
+			OPJ_UINT32 k;
+			opj_dwt_interleave_v(&v, &tiledp[j], (OPJ_INT32)w);
+			(dwt_1D)(&v);
+			for(k = 0; k < rh; ++k) {
+				tiledp[k * w + j] = v.mem[k];
+			}
+		}
+	}
+	opj_aligned_free(h.mem);
+	return OPJ_TRUE;
+}
+
+static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restrict a, OPJ_INT32 x, OPJ_INT32 size){
+	OPJ_FLOAT32* restrict bi = (OPJ_FLOAT32*) (w->wavelet + w->cas);
+	OPJ_INT32 count = w->sn;
+	OPJ_INT32 i, k;
+
+	for(k = 0; k < 2; ++k){
+		if ( count + 3 * x < size && ((size_t) a & 0x0f) == 0 && ((size_t) bi & 0x0f) == 0 && (x & 0x0f) == 0 ) {
+			/* Fast code path */
+			for(i = 0; i < count; ++i){
+				OPJ_INT32 j = i;
+				bi[i*8    ] = a[j];
+				j += x;
+				bi[i*8 + 1] = a[j];
+				j += x;
+				bi[i*8 + 2] = a[j];
+				j += x;
+				bi[i*8 + 3] = a[j];
+			}
+		}
+		else {
+			/* Slow code path */
+			for(i = 0; i < count; ++i){
+				OPJ_INT32 j = i;
+				bi[i*8    ] = a[j];
+				j += x;
+				if(j >= size) continue;
+				bi[i*8 + 1] = a[j];
+				j += x;
+				if(j >= size) continue;
+				bi[i*8 + 2] = a[j];
+				j += x;
+				if(j >= size) continue;
+				bi[i*8 + 3] = a[j]; /* This one*/
+			}
+		}
+
+		bi = (OPJ_FLOAT32*) (w->wavelet + 1 - w->cas);
+		a += w->sn;
+		size -= w->sn;
+		count = w->dn;
+	}
+}
+
+static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x, OPJ_INT32 nb_elts_read){
+	opj_v4_t* restrict bi = v->wavelet + v->cas;
+	OPJ_INT32 i;
+
+	for(i = 0; i < v->sn; ++i){
+		memcpy(&bi[i*2], &a[i*x], (size_t)nb_elts_read * sizeof(OPJ_FLOAT32));
+	}
+
+	a += v->sn * x;
+	bi = v->wavelet + 1 - v->cas;
+
+	for(i = 0; i < v->dn; ++i){
+		memcpy(&bi[i*2], &a[i*x], (size_t)nb_elts_read * sizeof(OPJ_FLOAT32));
+	}
+}
+
+#ifdef __SSE__
+
+static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c){
+	__m128* restrict vw = (__m128*) w;
+	OPJ_INT32 i;
+	/* 4x unrolled loop */
+	for(i = 0; i < count >> 2; ++i){
+		*vw = _mm_mul_ps(*vw, c);
+		vw += 2;
+		*vw = _mm_mul_ps(*vw, c);
+		vw += 2;
+		*vw = _mm_mul_ps(*vw, c);
+		vw += 2;
+		*vw = _mm_mul_ps(*vw, c);
+		vw += 2;
+	}
+	count &= 3;
+	for(i = 0; i < count; ++i){
+		*vw = _mm_mul_ps(*vw, c);
+		vw += 2;
+	}
+}
+
+void opj_v4dwt_decode_step2_sse(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c){
+	__m128* restrict vl = (__m128*) l;
+	__m128* restrict vw = (__m128*) w;
+	OPJ_INT32 i;
+	__m128 tmp1, tmp2, tmp3;
+	tmp1 = vl[0];
+	for(i = 0; i < m; ++i){
+		tmp2 = vw[-1];
+		tmp3 = vw[ 0];
+		vw[-1] = _mm_add_ps(tmp2, _mm_mul_ps(_mm_add_ps(tmp1, tmp3), c));
+		tmp1 = tmp3;
+		vw += 2;
+	}
+	vl = vw - 2;
+	if(m >= k){
+		return;
+	}
+	c = _mm_add_ps(c, c);
+	c = _mm_mul_ps(c, vl[0]);
+	for(; m < k; ++m){
+		__m128 tmp = vw[-1];
+		vw[-1] = _mm_add_ps(tmp, c);
+		vw += 2;
+	}
+}
+
+#else
+
+static void opj_v4dwt_decode_step1(opj_v4_t* w, OPJ_INT32 count, const OPJ_FLOAT32 c)
+{
+	OPJ_FLOAT32* restrict fw = (OPJ_FLOAT32*) w;
+	OPJ_INT32 i;
+	for(i = 0; i < count; ++i){
+		OPJ_FLOAT32 tmp1 = fw[i*8    ];
+		OPJ_FLOAT32 tmp2 = fw[i*8 + 1];
+		OPJ_FLOAT32 tmp3 = fw[i*8 + 2];
+		OPJ_FLOAT32 tmp4 = fw[i*8 + 3];
+		fw[i*8    ] = tmp1 * c;
+		fw[i*8 + 1] = tmp2 * c;
+		fw[i*8 + 2] = tmp3 * c;
+		fw[i*8 + 3] = tmp4 * c;
+	}
+}
+
+static void opj_v4dwt_decode_step2(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, OPJ_FLOAT32 c)
+{
+	OPJ_FLOAT32* fl = (OPJ_FLOAT32*) l;
+	OPJ_FLOAT32* fw = (OPJ_FLOAT32*) w;
+	OPJ_INT32 i;
+	for(i = 0; i < m; ++i){
+		OPJ_FLOAT32 tmp1_1 = fl[0];
+		OPJ_FLOAT32 tmp1_2 = fl[1];
+		OPJ_FLOAT32 tmp1_3 = fl[2];
+		OPJ_FLOAT32 tmp1_4 = fl[3];
+		OPJ_FLOAT32 tmp2_1 = fw[-4];
+		OPJ_FLOAT32 tmp2_2 = fw[-3];
+		OPJ_FLOAT32 tmp2_3 = fw[-2];
+		OPJ_FLOAT32 tmp2_4 = fw[-1];
+		OPJ_FLOAT32 tmp3_1 = fw[0];
+		OPJ_FLOAT32 tmp3_2 = fw[1];
+		OPJ_FLOAT32 tmp3_3 = fw[2];
+		OPJ_FLOAT32 tmp3_4 = fw[3];
+		fw[-4] = tmp2_1 + ((tmp1_1 + tmp3_1) * c);
+		fw[-3] = tmp2_2 + ((tmp1_2 + tmp3_2) * c);
+		fw[-2] = tmp2_3 + ((tmp1_3 + tmp3_3) * c);
+		fw[-1] = tmp2_4 + ((tmp1_4 + tmp3_4) * c);
+		fl = fw;
+		fw += 8;
+	}
+	if(m < k){
+		OPJ_FLOAT32 c1;
+		OPJ_FLOAT32 c2;
+		OPJ_FLOAT32 c3;
+		OPJ_FLOAT32 c4;
+		c += c;
+		c1 = fl[0] * c;
+		c2 = fl[1] * c;
+		c3 = fl[2] * c;
+		c4 = fl[3] * c;
+		for(; m < k; ++m){
+			OPJ_FLOAT32 tmp1 = fw[-4];
+			OPJ_FLOAT32 tmp2 = fw[-3];
+			OPJ_FLOAT32 tmp3 = fw[-2];
+			OPJ_FLOAT32 tmp4 = fw[-1];
+			fw[-4] = tmp1 + c1;
+			fw[-3] = tmp2 + c2;
+			fw[-2] = tmp3 + c3;
+			fw[-1] = tmp4 + c4;
+			fw += 8;
+		}
+	}
+}
+
+#endif
+
+/* <summary>                             */
+/* Inverse 9-7 wavelet transform in 1-D. */
+/* </summary>                            */
+static void opj_v4dwt_decode(opj_v4dwt_t* restrict dwt)
+{
+	OPJ_INT32 a, b;
+	if(dwt->cas == 0) {
+		if(!((dwt->dn > 0) || (dwt->sn > 1))){
+			return;
+		}
+		a = 0;
+		b = 1;
+	}else{
+		if(!((dwt->sn > 0) || (dwt->dn > 1))) {
+			return;
+		}
+		a = 1;
+		b = 0;
+	}
+#ifdef __SSE__
+	opj_v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(opj_K));
+	opj_v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(opj_c13318));
+	opj_v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(opj_dwt_delta));
+	opj_v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(opj_dwt_gamma));
+	opj_v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(opj_dwt_beta));
+	opj_v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(opj_dwt_alpha));
+#else
+	opj_v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, opj_K);
+	opj_v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, opj_c13318);
+	opj_v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), opj_dwt_delta);
+	opj_v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), opj_dwt_gamma);
+	opj_v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), opj_dwt_beta);
+	opj_v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), opj_dwt_alpha);
+#endif
+}
+
+
+/* <summary>                             */
+/* Inverse 9-7 wavelet transform in 2-D. */
+/* </summary>                            */
+OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numres)
+{
+	opj_v4dwt_t h;
+	opj_v4dwt_t v;
+
+	opj_tcd_resolution_t* res = tilec->resolutions;
+
+	OPJ_UINT32 rw = (OPJ_UINT32)(res->x1 - res->x0);	/* width of the resolution level computed */
+	OPJ_UINT32 rh = (OPJ_UINT32)(res->y1 - res->y0);	/* height of the resolution level computed */
+
+	OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
+
+	h.wavelet = (opj_v4_t*) opj_aligned_malloc((opj_dwt_max_resolution(res, numres)+5) * sizeof(opj_v4_t));
+	if (!h.wavelet) {
+		/* FIXME event manager error callback */
+		return OPJ_FALSE;
+	}
+	v.wavelet = h.wavelet;
+
+	while( --numres) {
+		OPJ_FLOAT32 * restrict aj = (OPJ_FLOAT32*) tilec->data;
+		OPJ_UINT32 bufsize = (OPJ_UINT32)((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0));
+		OPJ_INT32 j;
+
+		h.sn = (OPJ_INT32)rw;
+		v.sn = (OPJ_INT32)rh;
+
+		++res;
+
+		rw = (OPJ_UINT32)(res->x1 - res->x0);	/* width of the resolution level computed */
+		rh = (OPJ_UINT32)(res->y1 - res->y0);	/* height of the resolution level computed */
+
+		h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
+		h.cas = res->x0 % 2;
+
+		for(j = (OPJ_INT32)rh; j > 3; j -= 4) {
+			OPJ_INT32 k;
+			opj_v4dwt_interleave_h(&h, aj, (OPJ_INT32)w, (OPJ_INT32)bufsize);
+			opj_v4dwt_decode(&h);
+
+			for(k = (OPJ_INT32)rw; --k >= 0;){
+				aj[k               ] = h.wavelet[k].f[0];
+				aj[k+(OPJ_INT32)w  ] = h.wavelet[k].f[1];
+				aj[k+(OPJ_INT32)w*2] = h.wavelet[k].f[2];
+				aj[k+(OPJ_INT32)w*3] = h.wavelet[k].f[3];
+			}
+
+			aj += w*4;
+			bufsize -= w*4;
+		}
+
+		if (rh & 0x03) {
+			OPJ_INT32 k;
+			j = rh & 0x03;
+			opj_v4dwt_interleave_h(&h, aj, (OPJ_INT32)w, (OPJ_INT32)bufsize);
+			opj_v4dwt_decode(&h);
+			for(k = (OPJ_INT32)rw; --k >= 0;){
+				switch(j) {
+					case 3: aj[k+(OPJ_INT32)w*2] = h.wavelet[k].f[2];
+					case 2: aj[k+(OPJ_INT32)w  ] = h.wavelet[k].f[1];
+					case 1: aj[k               ] = h.wavelet[k].f[0];
+				}
+			}
+		}
+
+		v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
+		v.cas = res->y0 % 2;
+
+		aj = (OPJ_FLOAT32*) tilec->data;
+		for(j = (OPJ_INT32)rw; j > 3; j -= 4){
+			OPJ_UINT32 k;
+
+			opj_v4dwt_interleave_v(&v, aj, (OPJ_INT32)w, 4);
+			opj_v4dwt_decode(&v);
+
+			for(k = 0; k < rh; ++k){
+				memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(OPJ_FLOAT32));
+			}
+			aj += 4;
+		}
+
+		if (rw & 0x03){
+			OPJ_UINT32 k;
+
+			j = rw & 0x03;
+
+			opj_v4dwt_interleave_v(&v, aj, (OPJ_INT32)w, j);
+			opj_v4dwt_decode(&v);
+
+			for(k = 0; k < rh; ++k){
+				memcpy(&aj[k*w], &v.wavelet[k], (size_t)j * sizeof(OPJ_FLOAT32));
+			}
+		}
+	}
+
+	opj_aligned_free(h.wavelet);
+	return OPJ_TRUE;
+}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/dwt.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/dwt.h
similarity index 76%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/dwt.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/dwt.h
index adf73e5..21fe942 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/dwt.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/dwt.h
@@ -1,9 +1,15 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
@@ -48,63 +54,66 @@ DWT.C are used by some function in TCD.C.
 /*@{*/
 /* ----------------------------------------------------------------------- */
 /**
-Forward 5-3 wavelet tranform in 2-D. 
+Forward 5-3 wavelet transform in 2-D.
 Apply a reversible DWT transform to a component of an image.
 @param tilec Tile component information (current tile)
 */
-void dwt_encode(opj_tcd_tilecomp_t * tilec);
+OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec);
+
 /**
-Inverse 5-3 wavelet tranform in 2-D.
+Inverse 5-3 wavelet transform in 2-D.
 Apply a reversible inverse DWT transform to a component of an image.
 @param tilec Tile component information (current tile)
 @param numres Number of resolution levels to decode
 */
-void dwt_decode(opj_tcd_tilecomp_t* tilec, int numres);
+OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres);
+
 /**
 Get the gain of a subband for the reversible 5-3 DWT.
 @param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
 @return Returns 0 if orient = 0, returns 1 if orient = 1 or 2, returns 2 otherwise
 */
-int dwt_getgain(int orient);
+OPJ_UINT32 opj_dwt_getgain(OPJ_UINT32 orient) ;
 /**
 Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT.
 @param level Level of the wavelet function
 @param orient Band of the wavelet function
 @return Returns the norm of the wavelet function
 */
-double dwt_getnorm(int level, int orient);
+OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient);
 /**
 Forward 9-7 wavelet transform in 2-D. 
 Apply an irreversible DWT transform to a component of an image.
 @param tilec Tile component information (current tile)
 */
-void dwt_encode_real(opj_tcd_tilecomp_t * tilec);
+OPJ_BOOL opj_dwt_encode_real(opj_tcd_tilecomp_t * tilec);
 /**
 Inverse 9-7 wavelet transform in 2-D. 
 Apply an irreversible inverse DWT transform to a component of an image.
 @param tilec Tile component information (current tile)
 @param numres Number of resolution levels to decode
 */
-void dwt_decode_real(opj_tcd_tilecomp_t* tilec, int numres);
+OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numres);
+
 /**
 Get the gain of a subband for the irreversible 9-7 DWT.
 @param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
 @return Returns the gain of the 9-7 wavelet transform
 */
-int dwt_getgain_real(int orient);
+OPJ_UINT32 opj_dwt_getgain_real(OPJ_UINT32 orient);
 /**
 Get the norm of a wavelet function of a subband at a specified level for the irreversible 9-7 DWT
 @param level Level of the wavelet function
 @param orient Band of the wavelet function
 @return Returns the norm of the 9-7 wavelet
 */
-double dwt_getnorm_real(int level, int orient);
+OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient);
 /**
 Explicit calculation of the Quantization Stepsizes 
 @param tccp Tile-component coding parameters
 @param prec Precint analyzed
 */
-void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec);
+void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/event.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/event.c
similarity index 56%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/event.c
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/event.c
index 953a997..b6034b4 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/event.c
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/event.c
@@ -1,5 +1,12 @@
 /*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,6 +37,7 @@
      Utility functions
    ==========================================================*/
 
+#ifdef OPJ_CODE_NOT_USED
 #ifndef _WIN32
 static char*
 i2a(unsigned i, char *a, unsigned r) {
@@ -58,64 +66,81 @@ _itoa(int i, char *a, int r) {
 }
 
 #endif /* !_WIN32 */
+#endif
 
 /* ----------------------------------------------------------------------- */
+/**
+ * Default callback function.
+ * Do nothing.
+ */
+static void opj_default_callback (const char *msg, void *client_data)
+{
+    OPJ_ARG_NOT_USED(msg);
+    OPJ_ARG_NOT_USED(client_data);
+}
 
-opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
-	if(cinfo) {
-		opj_event_mgr_t *previous = cinfo->event_mgr;
-		cinfo->event_mgr = event_mgr;
-		cinfo->client_data = context;
-		return previous;
-	}
+/* ----------------------------------------------------------------------- */
 
-	return NULL;
-}
 
-bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
-#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
-	opj_msg_callback msg_handler = NULL;
+/* ----------------------------------------------------------------------- */
+OPJ_BOOL opj_event_msg(opj_event_mgr_t* p_event_mgr, OPJ_INT32 event_type, const char *fmt, ...) {
+#define OPJ_MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
+	opj_msg_callback msg_handler = 00;
+	void * l_data = 00;
 
-	opj_event_mgr_t *event_mgr = cinfo->event_mgr;
-	if(event_mgr != NULL) {
+	if(p_event_mgr != 00) {
 		switch(event_type) {
 			case EVT_ERROR:
-				msg_handler = event_mgr->error_handler;
+				msg_handler = p_event_mgr->error_handler;
+				l_data = p_event_mgr->m_error_data;
 				break;
 			case EVT_WARNING:
-				msg_handler = event_mgr->warning_handler;
+				msg_handler = p_event_mgr->warning_handler;
+				l_data = p_event_mgr->m_warning_data;
 				break;
 			case EVT_INFO:
-				msg_handler = event_mgr->info_handler;
+				msg_handler = p_event_mgr->info_handler;
+				l_data = p_event_mgr->m_info_data;
 				break;
 			default:
 				break;
 		}
-		if(msg_handler == NULL) {
-			return false;
+		if(msg_handler == 00) {
+			return OPJ_FALSE;
 		}
 	} else {
-		return false;
+		return OPJ_FALSE;
 	}
 
-	if ((fmt != NULL) && (event_mgr != NULL)) {
+	if ((fmt != 00) && (p_event_mgr != 00)) {
 		va_list arg;
-		int str_length/*, i, j*/; /* UniPG */
-		char message[MSG_SIZE];
-		memset(message, 0, MSG_SIZE);
+		size_t str_length/*, i, j*/; /* UniPG */
+		char message[OPJ_MSG_SIZE];
+		memset(message, 0, OPJ_MSG_SIZE);
 		/* initialize the optional parameter list */
 		va_start(arg, fmt);
 		/* check the length of the format string */
-		str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt);
+		str_length = (strlen(fmt) > OPJ_MSG_SIZE) ? OPJ_MSG_SIZE : strlen(fmt);
+        (void)str_length;
 		/* parse the format string and put the result in 'message' */
-		vsprintf(message, fmt, arg); /* UniPG */
+		vsnprintf(message, OPJ_MSG_SIZE, fmt, arg); /* UniPG */
 		/* deinitialize the optional parameter list */
 		va_end(arg);
 
 		/* output the message to the user program */
-		msg_handler(message, cinfo->client_data);
+		msg_handler(message, l_data);
 	}
 
-	return true;
+	return OPJ_TRUE;
+}
+
+void opj_set_default_event_handler(opj_event_mgr_t * p_manager)
+{
+	p_manager->m_error_data = 00;
+	p_manager->m_warning_data = 00;
+	p_manager->m_info_data = 00;
+	p_manager->error_handler = opj_default_callback;
+	p_manager->info_handler = opj_default_callback;
+	p_manager->warning_handler = opj_default_callback;
 }
 
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/event.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/event.h
similarity index 53%
rename from Utilities/gdcmopenjpeg-v2/libopenjpeg/event.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/event.h
index f121a34..fa8604e 100644
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/event.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/event.h
@@ -1,6 +1,12 @@
 /*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,9 +32,6 @@
  */
 #ifndef __EVENT_H
 #define __EVENT_H
-
-#include "openjpeg.h"
-
 /**
 @file event.h
 @brief Implementation of a event callback system
@@ -37,32 +40,33 @@ The functions in EVENT.C have for goal to send output messages (errors, warnings
 */
 /**
 Message handler object
-used for
+used for 
 <ul>
 <li>Error messages
 <li>Warning messages
 <li>Debugging messages
 </ul>
 */
-typedef struct opj_event_mgr
+typedef struct opj_event_mgr 
 {
-  /** Data to call the event manager upon */
-  void *      m_error_data;
-  /** Data to call the event manager upon */
-  void *      m_warning_data;
-  /** Data to call the event manager upon */
-  void *      m_info_data;
-  /** Error message callback if available, NULL otherwise */
-  opj_msg_callback error_handler;
-  /** Warning message callback if available, NULL otherwise */
-  opj_msg_callback warning_handler;
-  /** Debug message callback if available, NULL otherwise */
-  opj_msg_callback info_handler;
+	/** Data to call the event manager upon */
+	void *			m_error_data;
+	/** Data to call the event manager upon */
+	void *			m_warning_data;
+	/** Data to call the event manager upon */
+	void *			m_info_data;
+	/** Error message callback if available, NULL otherwise */
+	opj_msg_callback error_handler;
+	/** Warning message callback if available, NULL otherwise */
+	opj_msg_callback warning_handler;
+	/** Debug message callback if available, NULL otherwise */
+	opj_msg_callback info_handler;
 } opj_event_mgr_t;
 
-#define EVT_ERROR  1  /**< Error event type */
-#define EVT_WARNING  2  /**< Warning event type */
-#define EVT_INFO  4  /**< Debug event type */
+
+#define EVT_ERROR	1	/**< Error event type */
+#define EVT_WARNING	2	/**< Warning event type */
+#define EVT_INFO	4	/**< Debug event type */
 
 /** @defgroup EVENT EVENT - Implementation of a event callback system */
 /*@{*/
@@ -70,15 +74,33 @@ typedef struct opj_event_mgr
 /** @name Exported functions (see also openjpeg.h) */
 /*@{*/
 /* ----------------------------------------------------------------------- */
+
+
+/* ----------------------------------------------------------------------- */
+
 /**
- * Writes formatted data to a string and send the string to a user callback.
- * @param p_event_mgr the event manager to display messages.
- * @param event_type Event type of the message
- * @param fmt Format-control string (plus optionnal arguments)
+ * Write formatted data to a string and send the string to a user callback.
+ *
+ * @param event_mgr			Event handler
+ * @param event_type 		Event type or callback to use to send the message
+ * @param fmt 				Format-control string (plus optional arguments)
+ *
  * @return Returns true if successful, returns false otherwise
-*/
-bool opj_event_msg(struct opj_event_mgr * p_event_mgr, OPJ_INT32 event_type, const OPJ_CHAR *fmt, ...);
+ */
+OPJ_BOOL opj_event_msg(opj_event_mgr_t* event_mgr, OPJ_INT32 event_type, const char *fmt, ...);
 /* ----------------------------------------------------------------------- */
+
+/**
+ * Set the event manager with the default callback function for the 3 levels.
+ */
+void opj_set_default_event_handler(opj_event_mgr_t * p_manager);
+
+/*
+#ifdef __GNUC__
+#pragma GCC poison printf fprintf
+#endif
+*/
+
 /*@}*/
 
 /*@}*/
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/function_list.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/function_list.c
new file mode 100644
index 0000000..a7ea11d
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/function_list.c
@@ -0,0 +1,117 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/**
+ * Default size of the validation list, if not sufficient, data will be reallocated with a double size.
+ */
+#define OPJ_VALIDATION_SIZE 10
+
+opj_procedure_list_t *  opj_procedure_list_create()
+{
+        /* memory allocation */
+        opj_procedure_list_t * l_validation = (opj_procedure_list_t *) opj_calloc(1,sizeof(opj_procedure_list_t));
+        if (! l_validation)
+        {
+                return 00;
+        }
+        /* initialization */
+        l_validation->m_nb_max_procedures = OPJ_VALIDATION_SIZE;
+        l_validation->m_procedures = (opj_procedure*)opj_calloc(OPJ_VALIDATION_SIZE, sizeof(opj_procedure));
+        if (! l_validation->m_procedures)
+        {
+                opj_free(l_validation);
+                return 00;
+        }
+        return l_validation;
+}
+
+void  opj_procedure_list_destroy(opj_procedure_list_t * p_list)
+{
+        if (! p_list)
+        {
+                return;
+        }
+        /* initialization */
+        if (p_list->m_procedures)
+        {
+                opj_free(p_list->m_procedures);
+        }
+        opj_free(p_list);
+}
+
+OPJ_BOOL opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager )
+{
+	
+        assert(p_manager != NULL);
+	
+        if (p_validation_list->m_nb_max_procedures == p_validation_list->m_nb_procedures)
+        {
+                opj_procedure * new_procedures;
+
+                p_validation_list->m_nb_max_procedures += OPJ_VALIDATION_SIZE;
+                new_procedures = (opj_procedure*)opj_realloc(
+                        p_validation_list->m_procedures,
+                        p_validation_list->m_nb_max_procedures * sizeof(opj_procedure));
+                if (! new_procedures)
+                {
+                        opj_free(p_validation_list->m_procedures);
+                        p_validation_list->m_nb_max_procedures = 0;
+                        p_validation_list->m_nb_procedures = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add a new validation procedure\n");
+                        return OPJ_FALSE;
+                }
+                else
+                {
+                        p_validation_list->m_procedures = new_procedures;
+                }
+        }
+        p_validation_list->m_procedures[p_validation_list->m_nb_procedures] = p_procedure;
+        ++p_validation_list->m_nb_procedures;
+
+        return OPJ_TRUE;
+}
+
+OPJ_UINT32 opj_procedure_list_get_nb_procedures (opj_procedure_list_t * p_validation_list)
+{
+        return p_validation_list->m_nb_procedures;
+}
+
+opj_procedure* opj_procedure_list_get_first_procedure (opj_procedure_list_t * p_validation_list)
+{
+        return p_validation_list->m_procedures;
+}
+
+void opj_procedure_list_clear (opj_procedure_list_t * p_validation_list)
+{
+        p_validation_list->m_nb_procedures = 0;
+}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/function_list.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/function_list.h
similarity index 67%
rename from Utilities/gdcmopenjpeg-v2/libopenjpeg/function_list.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/function_list.h
index e3e3915..ab091b7 100644
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/function_list.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/function_list.h
@@ -1,4 +1,9 @@
 /*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
  * All rights reserved.
  *
@@ -27,47 +32,42 @@
 #ifndef __FUNCTION_LIST_H
 #define __FUNCTION_LIST_H
 
-/**
+/** 
  * @file function_list.h
  * @brief Implementation of a list of procedures.
 
  * The functions in validation.c aims to have access to a list of procedures.
 */
 
-/** @defgroup validation validation procedure*/
+/** @defgroup VAL VAL - validation procedure*/
 /*@{*/
 
-#include "openjpeg.h"
 /**************************************************************************************************
  ***************************************** FORWARD DECLARATION ************************************
  **************************************************************************************************/
-struct opj_jp2;
 
 /**
- * ARGGGG, when will the template be added to the C language ???
- * in order not to have to duplicate the code in a vast number of times, use void * and downcast
- * it after => UGLY but faster and easier
- * TODO : make the class template in C++, use STL vector or duplicate code for each procedure type.
+ * declare a function pointer
  */
-typedef void * opj_procedure;
+typedef void (*opj_procedure)(void);
 
 /**
  * A list of procedures.
 */
-typedef struct opj_procedure_list
+typedef struct opj_procedure_list 
 {
-  /**
-   * The number of validation procedures.
-   */
-  OPJ_UINT32 m_nb_procedures;
-  /**
-   * The number of the array of validation procedures.
-   */
-  OPJ_UINT32 m_nb_max_procedures;
-  /**
-   * The array of procedures.
-   */
-  opj_procedure * m_procedures;
+	/**
+	 * The number of validation procedures.
+	 */
+	OPJ_UINT32 m_nb_procedures;
+	/**
+	 * The number of the array of validation procedures.
+	 */
+	OPJ_UINT32 m_nb_max_procedures;
+	/**
+	 * The array of procedures.
+	 */
+	opj_procedure * m_procedures;
 
 } opj_procedure_list_t;
 
@@ -76,9 +76,9 @@ typedef struct opj_procedure_list
 /**
  * Creates a validation list.
  *
- * @return  the newly created validation list.
+ * @return	the newly created validation list.
  */
-opj_procedure_list_t *  opj_procedure_list_create();
+opj_procedure_list_t *  opj_procedure_list_create(void);
 
 /**
  * Destroys a validation list.
@@ -90,17 +90,17 @@ void  opj_procedure_list_destroy(opj_procedure_list_t * p_list);
 /**
  * Adds a new validation procedure.
  *
- * @param  p_validation_list the list of procedure to modify.
- * @param  p_procedure    the procedure to add.
+ * @param	p_validation_list the list of procedure to modify.
+ * @param	p_procedure		the procedure to add.
  *
- * @return  true if the procedure could ne added.
+ * @return	OPJ_TRUE if the procedure could be added.
  */
-bool  opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure);
+OPJ_BOOL opj_procedure_list_add_procedure (opj_procedure_list_t * p_validation_list, opj_procedure p_procedure, opj_event_mgr_t* p_manager);
 
 /**
  * Gets the number of validation procedures.
  *
- * @param  p_validation_list the list of procedure to modify.
+ * @param	p_validation_list the list of procedure to modify.
  *
  * @return the number of validation procedures.
  */
@@ -111,9 +111,9 @@ OPJ_UINT32 opj_procedure_list_get_nb_procedures (opj_procedure_list_t * p_valida
  * iterator class to iterate through all the procedures inside the validation list.
  * the caller does not take ownership of the pointer.
  *
- * @param  p_validation_list the list of procedure to get the first procedure from.
+ * @param	p_validation_list the list of procedure to get the first procedure from.
  *
- * @return  a pointer to the first procedure.
+ * @return	a pointer to the first procedure.
  */
 opj_procedure* opj_procedure_list_get_first_procedure (opj_procedure_list_t * p_validation_list);
 
@@ -121,10 +121,11 @@ opj_procedure* opj_procedure_list_get_first_procedure (opj_procedure_list_t * p_
 /**
  * Clears the list of validation procedures.
  *
- * @param  p_validation_list the list of procedure to clear.
+ * @param	p_validation_list the list of procedure to clear.
  *
  */
-void  opj_procedure_list_clear (opj_procedure_list_t * p_validation_list);
-
+void opj_procedure_list_clear (opj_procedure_list_t * p_validation_list);
+/*@}*/
 
 #endif /* __FUNCTION_LIST_H */
+
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/image.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/image.c
new file mode 100644
index 0000000..23462f0
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/image.c
@@ -0,0 +1,242 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+opj_image_t* opj_image_create0(void) {
+	opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t));
+	return image;
+}
+
+opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
+	OPJ_UINT32 compno;
+	opj_image_t *image = NULL;
+
+	image = (opj_image_t*) opj_calloc(1, sizeof(opj_image_t));
+	if(image) {
+		image->color_space = clrspc;
+		image->numcomps = numcmpts;
+		/* allocate memory for the per-component information */
+		image->comps = (opj_image_comp_t*)opj_calloc(1,image->numcomps * sizeof(opj_image_comp_t));
+		if(!image->comps) {
+			/* TODO replace with event manager, breaks API */
+			/* fprintf(stderr,"Unable to allocate memory for image.\n"); */
+			opj_image_destroy(image);
+			return NULL;
+		}
+		/* create the individual image components */
+		for(compno = 0; compno < numcmpts; compno++) {
+			opj_image_comp_t *comp = &image->comps[compno];
+			comp->dx = cmptparms[compno].dx;
+			comp->dy = cmptparms[compno].dy;
+			comp->w = cmptparms[compno].w;
+			comp->h = cmptparms[compno].h;
+			comp->x0 = cmptparms[compno].x0;
+			comp->y0 = cmptparms[compno].y0;
+			comp->prec = cmptparms[compno].prec;
+			comp->bpp = cmptparms[compno].bpp;
+			comp->sgnd = cmptparms[compno].sgnd;
+			comp->data = (OPJ_INT32*) opj_calloc(comp->w * comp->h, sizeof(OPJ_INT32));
+			if(!comp->data) {
+				/* TODO replace with event manager, breaks API */
+				/* fprintf(stderr,"Unable to allocate memory for image.\n"); */
+				opj_image_destroy(image);
+				return NULL;
+			}
+		}
+	}
+
+	return image;
+}
+
+void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
+	if(image) {
+		if(image->comps) {
+			OPJ_UINT32 compno;
+
+			/* image components */
+			for(compno = 0; compno < image->numcomps; compno++) {
+				opj_image_comp_t *image_comp = &(image->comps[compno]);
+				if(image_comp->data) {
+					opj_free(image_comp->data);
+				}
+			}
+			opj_free(image->comps);
+		}
+
+		if(image->icc_profile_buf) {
+			opj_free(image->icc_profile_buf);
+		}
+
+		opj_free(image);
+	}
+}
+
+/**
+ * Updates the components characteristics of the image from the coding parameters.
+ *
+ * @param p_image_header	the image header to update.
+ * @param p_cp				the coding parameters from which to update the image.
+ */
+void opj_image_comp_header_update(opj_image_t * p_image_header, const struct opj_cp * p_cp)
+{
+	OPJ_UINT32 i, l_width, l_height;
+	OPJ_UINT32 l_x0, l_y0, l_x1, l_y1;
+	OPJ_UINT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1;
+	opj_image_comp_t* l_img_comp = NULL;
+
+	l_x0 = opj_uint_max(p_cp->tx0 , p_image_header->x0);
+	l_y0 = opj_uint_max(p_cp->ty0 , p_image_header->y0);
+	l_x1 = p_cp->tx0 + (p_cp->tw - 1U) * p_cp->tdx; /* validity of p_cp members used here checked in opj_j2k_read_siz. Can't overflow. */
+	l_y1 = p_cp->ty0 + (p_cp->th - 1U) * p_cp->tdy; /* can't overflow */
+	l_x1 = opj_uint_min(opj_uint_adds(l_x1, p_cp->tdx), p_image_header->x1); /* use add saturated to prevent overflow */
+	l_y1 = opj_uint_min(opj_uint_adds(l_y1, p_cp->tdy), p_image_header->y1); /* use add saturated to prevent overflow */
+
+	l_img_comp = p_image_header->comps;
+	for	(i = 0; i < p_image_header->numcomps; ++i) {
+		l_comp_x0 = opj_uint_ceildiv(l_x0, l_img_comp->dx);
+		l_comp_y0 = opj_uint_ceildiv(l_y0, l_img_comp->dy);
+		l_comp_x1 = opj_uint_ceildiv(l_x1, l_img_comp->dx);
+		l_comp_y1 = opj_uint_ceildiv(l_y1, l_img_comp->dy);
+		l_width   = opj_uint_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_comp->factor);
+		l_height  = opj_uint_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
+		l_img_comp->w = l_width;
+		l_img_comp->h = l_height;
+		l_img_comp->x0 = l_comp_x0;
+		l_img_comp->y0 = l_comp_y0;
+		++l_img_comp;
+	}
+}
+
+
+/**
+ * Copy only header of image and its component header (no data are copied)
+ * if dest image have data, they will be freed
+ *
+ * @param	p_image_src		the src image
+ * @param	p_image_dest	the dest image
+ *
+ */
+void opj_copy_image_header(const opj_image_t* p_image_src, opj_image_t* p_image_dest)
+{
+	OPJ_UINT32 compno;
+
+	/* preconditions */
+	assert(p_image_src != 00);
+	assert(p_image_dest != 00);
+
+	p_image_dest->x0 = p_image_src->x0;
+	p_image_dest->y0 = p_image_src->y0;
+	p_image_dest->x1 = p_image_src->x1;
+	p_image_dest->y1 = p_image_src->y1;
+
+	if (p_image_dest->comps){
+		for(compno = 0; compno < p_image_dest->numcomps; compno++) {
+			opj_image_comp_t *image_comp = &(p_image_dest->comps[compno]);
+			if(image_comp->data) {
+				opj_free(image_comp->data);
+			}
+		}
+		opj_free(p_image_dest->comps);
+		p_image_dest->comps = NULL;
+	}
+
+	p_image_dest->numcomps = p_image_src->numcomps;
+
+	p_image_dest->comps = (opj_image_comp_t*) opj_malloc(p_image_dest->numcomps * sizeof(opj_image_comp_t));
+	if (!p_image_dest->comps){
+		p_image_dest->comps = NULL;
+		p_image_dest->numcomps = 0;
+		return;
+	}
+
+	for (compno=0; compno < p_image_dest->numcomps; compno++){
+		memcpy( &(p_image_dest->comps[compno]),
+				&(p_image_src->comps[compno]),
+				sizeof(opj_image_comp_t));
+		p_image_dest->comps[compno].data = NULL;
+	}
+
+	p_image_dest->color_space = p_image_src->color_space;
+	p_image_dest->icc_profile_len = p_image_src->icc_profile_len;
+
+	if (p_image_dest->icc_profile_len) {
+		p_image_dest->icc_profile_buf = (OPJ_BYTE*)opj_malloc(p_image_dest->icc_profile_len);
+		if (!p_image_dest->icc_profile_buf){
+			p_image_dest->icc_profile_buf = NULL;
+			p_image_dest->icc_profile_len = 0;
+			return;
+		}
+		memcpy( p_image_dest->icc_profile_buf,
+				p_image_src->icc_profile_buf,
+				p_image_src->icc_profile_len);
+		}
+		else
+			p_image_dest->icc_profile_buf = NULL;
+
+	return;
+}
+
+opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
+	OPJ_UINT32 compno;
+	opj_image_t *image = 00;
+
+	image = (opj_image_t*) opj_calloc(1,sizeof(opj_image_t));
+	if (image)
+	{
+		
+		image->color_space = clrspc;
+		image->numcomps = numcmpts;
+		
+		/* allocate memory for the per-component information */
+		image->comps = (opj_image_comp_t*)opj_calloc(image->numcomps, sizeof(opj_image_comp_t));
+		if (!image->comps) {
+			opj_image_destroy(image);
+			return 00;
+		}
+		
+		/* create the individual image components */
+		for(compno = 0; compno < numcmpts; compno++) {
+			opj_image_comp_t *comp = &image->comps[compno];
+			comp->dx = cmptparms[compno].dx;
+			comp->dy = cmptparms[compno].dy;
+			comp->w = cmptparms[compno].w;
+			comp->h = cmptparms[compno].h;
+			comp->x0 = cmptparms[compno].x0;
+			comp->y0 = cmptparms[compno].y0;
+			comp->prec = cmptparms[compno].prec;
+			comp->sgnd = cmptparms[compno].sgnd;
+			comp->data = 0;
+		}
+	}
+
+	return image;
+}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/image.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/image.h
similarity index 66%
rename from Utilities/gdcmopenjpeg-v2/libopenjpeg/image.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/image.h
index e78df28..e0e2772 100644
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/image.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/image.h
@@ -1,6 +1,10 @@
 /*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,26 +36,33 @@
 
 The functions in IMAGE.C have for goal to realize operations on images.
 */
+
 struct opj_image;
 struct opj_cp;
+
 /** @defgroup IMAGE IMAGE - Implementation of operations on images */
 /*@{*/
 
 /**
-Create an empty image
- at todo this function should be removed
- at return returns an empty image if successful, returns NULL otherwise
-*/
-struct opj_image* opj_image_create0(void);
+ * Create an empty image
+ *
+ * @return returns an empty image if successful, returns NULL otherwise
+ */
+opj_image_t* opj_image_create0(void);
+
+
 
 /**
- * Updates the components of the image from the coding parameters.
+ * Updates the components characteristics of the image from the coding parameters.
  *
- * @param p_image    the image to update.
- * @param p_cp      the coding parameters from which to update the image.
+ * @param p_image_header		the image header to update.
+ * @param p_cp					the coding parameters from which to update the image.
  */
-void opj_image_comp_update(struct opj_image * p_image,const struct opj_cp * p_cp);
+void opj_image_comp_header_update(opj_image_t * p_image, const struct opj_cp* p_cp);
+
+void opj_copy_image_header(const opj_image_t* p_image_src, opj_image_t* p_image_dest);
 
 /*@}*/
 
 #endif /* __IMAGE_H */
+
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/indexbox_manager.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/indexbox_manager.h
new file mode 100644
index 0000000..ebcde8f
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/indexbox_manager.h
@@ -0,0 +1,148 @@
+/*
+ * $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara at gmail.com $
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*! \file
+ *  \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#ifndef  INDEXBOX_MANAGER_H_
+# define INDEXBOX_MANAGER_H_
+
+#include "openjpeg.h"
+#include "j2k.h" /* needed to use jp2.h */
+#include "jp2.h"
+
+#define JPIP_CIDX 0x63696478   /* Codestream index                */
+#define JPIP_CPTR 0x63707472   /* Codestream Finder Box           */
+#define JPIP_MANF 0x6d616e66   /* Manifest Box                    */
+#define JPIP_FAIX 0x66616978   /* Fragment array Index box        */
+#define JPIP_MHIX 0x6d686978   /* Main Header Index Table         */
+#define JPIP_TPIX 0x74706978   /* Tile-part Index Table box       */
+#define JPIP_THIX 0x74686978   /* Tile header Index Table box     */
+#define JPIP_PPIX 0x70706978   /* Precinct Packet Index Table box */
+#define JPIP_PHIX 0x70686978   /* Packet Header index Table       */
+#define JPIP_FIDX 0x66696478   /* File Index                      */
+#define JPIP_FPTR 0x66707472   /* File Finder                     */
+#define JPIP_PRXY 0x70727879   /* Proxy boxes                     */
+#define JPIP_IPTR 0x69707472   /* Index finder box                */
+#define JPIP_PHLD 0x70686c64   /* Place holder                    */
+
+
+/* 
+ * Write tile-part Index table box (superbox)
+ *
+ * @param[in] coff      offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] j2klen    length of j2k codestream
+ * @param[in] cio       file output handle
+ * @return              length of tpix box
+ */
+int opj_write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+
+/* 
+ * Write tile header index table box (superbox)
+ *
+ * @param[in] coff      offset of j2k codestream
+ * @param[in] cstr_info codestream information pointer
+ * @param[in] cio       file output handle
+ * @return              length of thix box
+ */
+int opj_write_thix( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio, opj_event_mgr_t * p_manager );
+
+
+/* 
+ * Write precinct packet index table box (superbox)
+ *
+ * @param[in] coff      offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused   true if EPH option used
+ * @param[in] j2klen    length of j2k codestream
+ * @param[in] cio       file output handle
+ * @return              length of ppix box
+ */
+int opj_write_ppix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+
+/* 
+ * Write packet header index table box (superbox)
+ *
+ * @param[in] coff      offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused   true if EPH option used
+ * @param[in] j2klen    length of j2k codestream
+ * @param[in] cio       file output handle
+ * @return              length of ppix box
+ */
+int opj_write_phix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+/* 
+ * Write manifest box (box)
+ *
+ * @param[in] second number to be visited
+ * @param[in] v      number of boxes
+ * @param[in] box    box to be manifested
+ * @param[in] cio    file output handle
+ */
+
+void opj_write_manf(int second, 
+                    int v, 
+                    opj_jp2_box_t *box, 
+                    opj_stream_private_t *cio,
+                    opj_event_mgr_t * p_manager );
+
+/* 
+ * Write main header index table (box)
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] cio  file output handle
+ * @return         length of mainmhix box
+ */
+int opj_write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+int opj_write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+int opj_write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+int opj_write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+int opj_write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager );
+
+#endif      /* !INDEXBOX_MANAGER_H_ */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/invert.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/invert.c
new file mode 100644
index 0000000..7efaf6e
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/invert.c
@@ -0,0 +1,294 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/** 
+ * LUP decomposition
+ */
+static OPJ_BOOL opj_lupDecompose(OPJ_FLOAT32 * matrix,
+                                 OPJ_UINT32 * permutations, 
+                                 OPJ_FLOAT32 * p_swap_area,
+                                 OPJ_UINT32 nb_compo);
+/** 
+ * LUP solving
+ */
+static void opj_lupSolve(OPJ_FLOAT32 * pResult, 
+                         OPJ_FLOAT32* pMatrix, 
+                         OPJ_FLOAT32* pVector, 
+                         OPJ_UINT32* pPermutations, 
+                         OPJ_UINT32 nb_compo,
+                         OPJ_FLOAT32 * p_intermediate_data);
+
+/** 
+ *LUP inversion (call with the result of lupDecompose)
+ */
+static void opj_lupInvert ( OPJ_FLOAT32 * pSrcMatrix,
+                            OPJ_FLOAT32 * pDestMatrix,
+                            OPJ_UINT32 nb_compo,
+                            OPJ_UINT32 * pPermutations,
+                            OPJ_FLOAT32 * p_src_temp,
+                            OPJ_FLOAT32 * p_dest_temp,
+                            OPJ_FLOAT32 * p_swap_area);
+
+/*
+==========================================================
+   Matric inversion interface
+==========================================================
+*/
+/**
+ * Matrix inversion.
+ */
+OPJ_BOOL opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,
+                                OPJ_FLOAT32 * pDestMatrix, 
+                                OPJ_UINT32 nb_compo)
+{
+	OPJ_BYTE * l_data = 00;
+	OPJ_UINT32 l_permutation_size = nb_compo * (OPJ_UINT32)sizeof(OPJ_UINT32);
+	OPJ_UINT32 l_swap_size = nb_compo * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
+	OPJ_UINT32 l_total_size = l_permutation_size + 3 * l_swap_size;
+	OPJ_UINT32 * lPermutations = 00;
+	OPJ_FLOAT32 * l_double_data = 00;
+
+	l_data = (OPJ_BYTE *) opj_malloc(l_total_size);
+	if (l_data == 0) {
+		return OPJ_FALSE;
+	}
+	lPermutations = (OPJ_UINT32 *) l_data;
+	l_double_data = (OPJ_FLOAT32 *) (l_data + l_permutation_size);
+	memset(lPermutations,0,l_permutation_size);
+
+	if(! opj_lupDecompose(pSrcMatrix,lPermutations,l_double_data,nb_compo)) {
+		opj_free(l_data);
+		return OPJ_FALSE;
+	}
+	
+    opj_lupInvert(pSrcMatrix,pDestMatrix,nb_compo,lPermutations,l_double_data,l_double_data + nb_compo,l_double_data + 2*nb_compo);
+	opj_free(l_data);
+	
+    return OPJ_TRUE;
+}
+
+
+/*
+==========================================================
+   Local functions
+==========================================================
+*/
+static OPJ_BOOL opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations,
+                          OPJ_FLOAT32 * p_swap_area,
+                          OPJ_UINT32 nb_compo) 
+{
+	OPJ_UINT32 * tmpPermutations = permutations;
+	OPJ_UINT32 * dstPermutations;
+	OPJ_UINT32 k2=0,t;
+	OPJ_FLOAT32 temp;
+	OPJ_UINT32 i,j,k;
+	OPJ_FLOAT32 p;
+	OPJ_UINT32 lLastColum = nb_compo - 1;
+	OPJ_UINT32 lSwapSize = nb_compo * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
+	OPJ_FLOAT32 * lTmpMatrix = matrix;
+	OPJ_FLOAT32 * lColumnMatrix,* lDestMatrix;
+	OPJ_UINT32 offset = 1;
+	OPJ_UINT32 lStride = nb_compo-1;
+
+	/*initialize permutations */
+	for (i = 0; i < nb_compo; ++i) 
+	{
+    	*tmpPermutations++ = i;
+	}
+	/* now make a pivot with column switch */
+	tmpPermutations = permutations;
+	for (k = 0; k < lLastColum; ++k) {
+		p = 0.0;
+
+		/* take the middle element */
+		lColumnMatrix = lTmpMatrix + k;
+		
+		/* make permutation with the biggest value in the column */
+        for (i = k; i < nb_compo; ++i) {
+			temp = ((*lColumnMatrix > 0) ? *lColumnMatrix : -(*lColumnMatrix));
+     		if (temp > p) {
+     			p = temp;
+     			k2 = i;
+     		}
+			/* next line */
+			lColumnMatrix += nb_compo;
+     	}
+
+     	/* a whole rest of 0 -> non singular */
+     	if (p == 0.0) {
+    		return OPJ_FALSE;
+		}
+
+		/* should we permute ? */
+		if (k2 != k) {
+			/*exchange of line */
+     		/* k2 > k */
+			dstPermutations = tmpPermutations + k2 - k;
+			/* swap indices */
+			t = *tmpPermutations;
+     		*tmpPermutations = *dstPermutations;
+     		*dstPermutations = t;
+
+			/* and swap entire line. */
+			lColumnMatrix = lTmpMatrix + (k2 - k) * nb_compo;
+			memcpy(p_swap_area,lColumnMatrix,lSwapSize);
+			memcpy(lColumnMatrix,lTmpMatrix,lSwapSize);
+			memcpy(lTmpMatrix,p_swap_area,lSwapSize);
+		}
+
+		/* now update data in the rest of the line and line after */
+		lDestMatrix = lTmpMatrix + k;
+		lColumnMatrix = lDestMatrix + nb_compo;
+		/* take the middle element */
+		temp = *(lDestMatrix++);
+
+		/* now compute up data (i.e. coeff up of the diagonal). */
+     	for (i = offset; i < nb_compo; ++i)  {
+			/*lColumnMatrix; */
+			/* divide the lower column elements by the diagonal value */
+
+			/* matrix[i][k] /= matrix[k][k]; */
+     		/* p = matrix[i][k] */
+			p = *lColumnMatrix / temp;
+			*(lColumnMatrix++) = p;
+     		
+            for (j = /* k + 1 */ offset; j < nb_compo; ++j) {
+				/* matrix[i][j] -= matrix[i][k] * matrix[k][j]; */
+     			*(lColumnMatrix++) -= p * (*(lDestMatrix++));
+			}
+			/* come back to the k+1th element */
+			lDestMatrix -= lStride;
+			/* go to kth element of the next line */
+			lColumnMatrix += k;
+     	}
+
+		/* offset is now k+2 */
+		++offset;
+		/* 1 element less for stride */
+		--lStride;
+		/* next line */
+		lTmpMatrix+=nb_compo;
+		/* next permutation element */
+		++tmpPermutations;
+	}
+    return OPJ_TRUE;
+}
+   		
+static void opj_lupSolve (OPJ_FLOAT32 * pResult,
+                   OPJ_FLOAT32 * pMatrix, 
+                   OPJ_FLOAT32 * pVector, 
+                   OPJ_UINT32* pPermutations, 
+                   OPJ_UINT32 nb_compo,OPJ_FLOAT32 * p_intermediate_data) 
+{
+	OPJ_INT32 k;
+    OPJ_UINT32 i,j;
+	OPJ_FLOAT32 sum;
+	OPJ_FLOAT32 u;
+    OPJ_UINT32 lStride = nb_compo+1;
+	OPJ_FLOAT32 * lCurrentPtr;
+	OPJ_FLOAT32 * lIntermediatePtr;
+	OPJ_FLOAT32 * lDestPtr;
+	OPJ_FLOAT32 * lTmpMatrix;
+	OPJ_FLOAT32 * lLineMatrix = pMatrix;
+	OPJ_FLOAT32 * lBeginPtr = pResult + nb_compo - 1;
+	OPJ_FLOAT32 * lGeneratedData;
+	OPJ_UINT32 * lCurrentPermutationPtr = pPermutations;
+
+	
+	lIntermediatePtr = p_intermediate_data;
+	lGeneratedData = p_intermediate_data + nb_compo - 1;
+	
+    for (i = 0; i < nb_compo; ++i) {
+       	sum = 0.0;
+		lCurrentPtr = p_intermediate_data;
+		lTmpMatrix = lLineMatrix;
+        for (j = 1; j <= i; ++j) 
+		{
+			/* sum += matrix[i][j-1] * y[j-1]; */
+        	sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
+        }
+		/*y[i] = pVector[pPermutations[i]] - sum; */
+        *(lIntermediatePtr++) = pVector[*(lCurrentPermutationPtr++)] - sum;
+		lLineMatrix += nb_compo;
+	}
+
+	/* we take the last point of the matrix */
+	lLineMatrix = pMatrix + nb_compo*nb_compo - 1;
+
+	/* and we take after the last point of the destination vector */
+	lDestPtr = pResult + nb_compo;
+
+
+    assert(nb_compo != 0);
+	for (k = (OPJ_INT32)nb_compo - 1; k != -1 ; --k) {
+		sum = 0.0;
+		lTmpMatrix = lLineMatrix;
+        u = *(lTmpMatrix++);
+		lCurrentPtr = lDestPtr--;
+        for (j = (OPJ_UINT32)(k + 1); j < nb_compo; ++j) {
+			/* sum += matrix[k][j] * x[j] */
+        	sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
+		}
+		/*x[k] = (y[k] - sum) / u; */
+        *(lBeginPtr--) = (*(lGeneratedData--) - sum) / u;
+		lLineMatrix -= lStride;
+	}
+}
+    
+
+static void opj_lupInvert (OPJ_FLOAT32 * pSrcMatrix,
+                    OPJ_FLOAT32 * pDestMatrix,
+                    OPJ_UINT32 nb_compo,
+                    OPJ_UINT32 * pPermutations,
+                    OPJ_FLOAT32 * p_src_temp,
+                    OPJ_FLOAT32 * p_dest_temp,
+                    OPJ_FLOAT32 * p_swap_area )
+{
+	OPJ_UINT32 j,i;
+	OPJ_FLOAT32 * lCurrentPtr;
+	OPJ_FLOAT32 * lLineMatrix = pDestMatrix;
+	OPJ_UINT32 lSwapSize = nb_compo * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
+
+	for (j = 0; j < nb_compo; ++j) {
+		lCurrentPtr = lLineMatrix++;
+        memset(p_src_temp,0,lSwapSize);
+    	p_src_temp[j] = 1.0;
+		opj_lupSolve(p_dest_temp,pSrcMatrix,p_src_temp, pPermutations, nb_compo , p_swap_area);
+
+		for (i = 0; i < nb_compo; ++i) {
+    		*(lCurrentPtr) = p_dest_temp[i];
+			lCurrentPtr+=nb_compo;
+    	}
+    }
+}
+
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/invert.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/invert.h
similarity index 60%
rename from Utilities/gdcmopenjpeg-v2/libopenjpeg/invert.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/invert.h
index a6ebe72..2fae8e5 100644
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/invert.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/invert.h
@@ -1,4 +1,9 @@
 /*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
  * All rights reserved.
  *
@@ -26,14 +31,34 @@
 
 #ifndef __INVERT_H
 #define __INVERT_H
-#include "openjpeg.h"
+/**
+ at file invert.h
+ at brief Implementation of the matrix inversion
+
+The function in INVERT.H compute a matrix inversion with a LUP method
+*/
+
+/** @defgroup INVERT INVERT - Implementation of a matrix inversion */
+/*@{*/
+/** @name Exported functions */
+/*@{*/
+/* ----------------------------------------------------------------------- */
+
 /**
  * Calculates a n x n double matrix inversion with a LUP method. Data is aligned, rows after rows (or columns after columns).
  * The function does not take ownership of any memory block, data must be fred by the user.
  *
- * @param pSrcMatrix  the matrix to invert.
- * @param pDestMatrix  data to store the inverted matrix.
- * @return 1 if the inversion is successful, 0 if the matrix is singular.
+ * @param pSrcMatrix	the matrix to invert.
+ * @param pDestMatrix	data to store the inverted matrix. 
+ * @param n size of the matrix
+ * @return OPJ_TRUE if the inversion is successful, OPJ_FALSE if the matrix is singular.
  */
-bool opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,OPJ_FLOAT32 * pDestMatrix, OPJ_UINT32 n);
-#endif
+OPJ_BOOL opj_matrix_inversion_f(OPJ_FLOAT32 * pSrcMatrix,
+                                OPJ_FLOAT32 * pDestMatrix, 
+                                OPJ_UINT32 nb_compo);
+/* ----------------------------------------------------------------------- */
+/*@}*/
+
+/*@}*/
+
+#endif /* __INVERT_H */ 
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.c
new file mode 100644
index 0000000..9eaa155
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.c
@@ -0,0 +1,10981 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * Copyright (c) 2006-2007, Parvatha Elangovan
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
+/*@{*/
+
+/** @name Local static functions */
+/*@{*/
+
+/**
+ * Sets up the procedures to do on reading header. Developpers wanting to extend the library can add their own reading procedures.
+ */
+static OPJ_BOOL opj_j2k_setup_header_reading (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
+
+/**
+ * The read header procedure.
+ */
+static OPJ_BOOL opj_j2k_read_header_procedure(  opj_j2k_t *p_j2k,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager);
+
+/**
+ * The default encoding validation procedure without any extension.
+ *
+ * @param       p_j2k                   the jpeg2000 codec to validate.
+ * @param       p_stream                the input stream to validate.
+ * @param       p_manager               the user event manager.
+ *
+ * @return true if the parameters are correct.
+ */
+static OPJ_BOOL opj_j2k_encoding_validation (   opj_j2k_t * p_j2k,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager );
+
+/**
+ * The default decoding validation procedure without any extension.
+ *
+ * @param       p_j2k                   the jpeg2000 codec to validate.
+ * @param       p_stream                                the input stream to validate.
+ * @param       p_manager               the user event manager.
+ *
+ * @return true if the parameters are correct.
+ */
+static OPJ_BOOL opj_j2k_decoding_validation (   opj_j2k_t * p_j2k,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager );
+
+/**
+ * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
+ * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ */
+static OPJ_BOOL opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
+
+/**
+ * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
+ * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ */
+static OPJ_BOOL opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
+
+/**
+ * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
+ * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ */
+static OPJ_BOOL opj_j2k_setup_end_compress (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
+
+/**
+ * The mct encoding validation procedure.
+ *
+ * @param       p_j2k                   the jpeg2000 codec to validate.
+ * @param       p_stream                                the input stream to validate.
+ * @param       p_manager               the user event manager.
+ *
+ * @return true if the parameters are correct.
+ */
+static OPJ_BOOL opj_j2k_mct_validation (opj_j2k_t * p_j2k,
+                                        opj_stream_private_t *p_stream,
+                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Builds the tcd decoder to use to decode tile.
+ */
+static OPJ_BOOL opj_j2k_build_decoder ( opj_j2k_t * p_j2k,
+                                        opj_stream_private_t *p_stream,
+                                        opj_event_mgr_t * p_manager );
+/**
+ * Builds the tcd encoder to use to encode tile.
+ */
+static OPJ_BOOL opj_j2k_build_encoder ( opj_j2k_t * p_j2k,
+                                        opj_stream_private_t *p_stream,
+                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Creates a tile-coder decoder.
+ *
+ * @param       p_stream                        the stream to write data to.
+ * @param       p_j2k                           J2K codec.
+ * @param       p_manager                   the user event manager.
+*/
+static OPJ_BOOL opj_j2k_create_tcd(     opj_j2k_t *p_j2k,
+                                                                    opj_stream_private_t *p_stream,
+                                                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Excutes the given procedures on the given codec.
+ *
+ * @param       p_procedure_list        the list of procedures to execute
+ * @param       p_j2k                           the jpeg2000 codec to execute the procedures on.
+ * @param       p_stream                        the stream to execute the procedures on.
+ * @param       p_manager                       the user manager.
+ *
+ * @return      true                            if all the procedures were successfully executed.
+ */
+static OPJ_BOOL opj_j2k_exec (  opj_j2k_t * p_j2k,
+                            opj_procedure_list_t * p_procedure_list,
+                            opj_stream_private_t *p_stream,
+                            opj_event_mgr_t * p_manager);
+
+/**
+ * Updates the rates of the tcp.
+ *
+ * @param       p_stream                                the stream to write data to.
+ * @param       p_j2k                           J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_update_rates(   opj_j2k_t *p_j2k,
+                                                                            opj_stream_private_t *p_stream,
+                                                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Copies the decoding tile parameters onto all the tile parameters.
+ * Creates also the tile decoder.
+ */
+static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd (       opj_j2k_t * p_j2k,
+                                                            opj_stream_private_t *p_stream,
+                                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Destroys the memory associated with the decoding of headers.
+ */
+static OPJ_BOOL opj_j2k_destroy_header_memory ( opj_j2k_t * p_j2k,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager );
+
+/**
+ * Reads the lookup table containing all the marker, status and action, and returns the handler associated
+ * with the marker value.
+ * @param       p_id            Marker value to look up
+ *
+ * @return      the handler associated with the id.
+*/
+static const struct opj_dec_memory_marker_handler * opj_j2k_get_marker_handler (OPJ_UINT32 p_id);
+
+/**
+ * Destroys a tile coding parameter structure.
+ *
+ * @param       p_tcp           the tile coding parameter to destroy.
+ */
+static void opj_j2k_tcp_destroy (opj_tcp_t *p_tcp);
+
+/**
+ * Destroys the data inside a tile coding parameter structure.
+ *
+ * @param       p_tcp           the tile coding parameter which contain data to destroy.
+ */
+static void opj_j2k_tcp_data_destroy (opj_tcp_t *p_tcp);
+
+/**
+ * Destroys a coding parameter structure.
+ *
+ * @param       p_cp            the coding parameter to destroy.
+ */
+static void opj_j2k_cp_destroy (opj_cp_t *p_cp);
+
+/**
+ * Compare 2 a SPCod/ SPCoc elements, i.e. the coding style of a given component of a tile.
+ *
+ * @param       p_j2k            J2K codec.
+ * @param       p_tile_no        Tile number
+ * @param       p_first_comp_no  The 1st component number to compare.
+ * @param       p_second_comp_no The 1st component number to compare.
+ *
+ * @return OPJ_TRUE if SPCdod are equals.
+ */
+static OPJ_BOOL opj_j2k_compare_SPCod_SPCoc(opj_j2k_t *p_j2k, OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
+
+/**
+ * Writes a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
+ *
+ * @param       p_j2k           J2K codec.
+ * @param       p_tile_no       FIXME DOC
+ * @param       p_comp_no       the component number to output.
+ * @param       p_data          FIXME DOC
+ * @param       p_header_size   FIXME DOC
+ * @param       p_manager       the user event manager.
+ *
+ * @return FIXME DOC
+*/
+static OPJ_BOOL opj_j2k_write_SPCod_SPCoc(      opj_j2k_t *p_j2k,
+                                                                                    OPJ_UINT32 p_tile_no,
+                                                                                    OPJ_UINT32 p_comp_no,
+                                                                                    OPJ_BYTE * p_data,
+                                                                                    OPJ_UINT32 * p_header_size,
+                                                                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Gets the size taken by writing a SPCod or SPCoc for the given tile and component.
+ *
+ * @param       p_j2k                   the J2K codec.
+ * @param       p_tile_no               the tile index.
+ * @param       p_comp_no               the component being outputted.
+ *
+ * @return      the number of bytes taken by the SPCod element.
+ */
+static OPJ_UINT32 opj_j2k_get_SPCod_SPCoc_size (opj_j2k_t *p_j2k,
+                                                                                            OPJ_UINT32 p_tile_no,
+                                                                                            OPJ_UINT32 p_comp_no );
+
+/**
+ * Reads a SPCod or SPCoc element, i.e. the coding style of a given component of a tile.
+ * @param       p_j2k           the jpeg2000 codec.
+ * @param       compno          FIXME DOC
+ * @param       p_header_data   the data contained in the COM box.
+ * @param       p_header_size   the size of the data contained in the COM marker.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_SPCod_SPCoc(   opj_j2k_t *p_j2k,
+                                            OPJ_UINT32 compno,
+                                            OPJ_BYTE * p_header_data,
+                                            OPJ_UINT32 * p_header_size,
+                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Gets the size taken by writing SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
+ *
+ * @param       p_tile_no               the tile index.
+ * @param       p_comp_no               the component being outputted.
+ * @param       p_j2k                   the J2K codec.
+ *
+ * @return      the number of bytes taken by the SPCod element.
+ */
+static OPJ_UINT32 opj_j2k_get_SQcd_SQcc_size (  opj_j2k_t *p_j2k,
+                                                                                    OPJ_UINT32 p_tile_no,
+                                                                                    OPJ_UINT32 p_comp_no );
+
+/**
+ * Compares 2 SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
+ *
+ * @param       p_j2k                   J2K codec.
+ * @param       p_tile_no               the tile to output.
+ * @param       p_first_comp_no         the first component number to compare.
+ * @param       p_second_comp_no        the second component number to compare.
+ *
+ * @return OPJ_TRUE if equals.
+ */
+static OPJ_BOOL opj_j2k_compare_SQcd_SQcc(opj_j2k_t *p_j2k, OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
+
+
+/**
+ * Writes a SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
+ *
+ * @param       p_tile_no               the tile to output.
+ * @param       p_comp_no               the component number to output.
+ * @param       p_data                  the data buffer.
+ * @param       p_header_size   pointer to the size of the data buffer, it is changed by the function.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+ *
+*/
+static OPJ_BOOL opj_j2k_write_SQcd_SQcc(opj_j2k_t *p_j2k,
+                                                                            OPJ_UINT32 p_tile_no,
+                                                                            OPJ_UINT32 p_comp_no,
+                                                                            OPJ_BYTE * p_data,
+                                                                            OPJ_UINT32 * p_header_size,
+                                                                            opj_event_mgr_t * p_manager);
+
+/**
+ * Updates the Tile Length Marker.
+ */
+static void opj_j2k_update_tlm ( opj_j2k_t * p_j2k, OPJ_UINT32 p_tile_part_size);
+
+/**
+ * Reads a SQcd or SQcc element, i.e. the quantization values of a band in the QCD or QCC.
+ *
+ * @param       p_j2k           J2K codec.
+ * @param       compno          the component number to output.
+ * @param       p_header_data   the data buffer.
+ * @param       p_header_size   pointer to the size of the data buffer, it is changed by the function.
+ * @param       p_manager       the user event manager.
+ *
+*/
+static OPJ_BOOL opj_j2k_read_SQcd_SQcc( opj_j2k_t *p_j2k,
+                                        OPJ_UINT32 compno,
+                                        OPJ_BYTE * p_header_data,
+                                        OPJ_UINT32 * p_header_size,
+                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Copies the tile component parameters of all the component from the first tile component.
+ *
+ * @param               p_j2k           the J2k codec.
+ */
+static void opj_j2k_copy_tile_component_parameters( opj_j2k_t *p_j2k );
+
+/**
+ * Copies the tile quantization parameters of all the component from the first tile component.
+ *
+ * @param               p_j2k           the J2k codec.
+ */
+static void opj_j2k_copy_tile_quantization_parameters( opj_j2k_t *p_j2k );
+
+/**
+ * Reads the tiles.
+ */
+static OPJ_BOOL opj_j2k_decode_tiles (  opj_j2k_t *p_j2k,
+                                        opj_stream_private_t *p_stream,
+                                        opj_event_mgr_t * p_manager);
+
+static OPJ_BOOL opj_j2k_pre_write_tile ( opj_j2k_t * p_j2k,
+                                                                             OPJ_UINT32 p_tile_index,
+                                                                             opj_stream_private_t *p_stream,
+                                                                             opj_event_mgr_t * p_manager );
+
+static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data, opj_image_t* p_output_image);
+
+static void opj_get_tile_dimensions(opj_image_t * l_image,
+																		opj_tcd_tilecomp_t * l_tilec,
+																		opj_image_comp_t * l_img_comp,
+																		OPJ_UINT32* l_size_comp,
+																		OPJ_UINT32* l_width,
+																		OPJ_UINT32* l_height,
+																		OPJ_UINT32* l_offset_x,
+																		OPJ_UINT32* l_offset_y,
+																		OPJ_UINT32* l_image_width,
+																		OPJ_UINT32* l_stride,
+																		OPJ_UINT32* l_tile_offset);
+
+static void opj_j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data);
+
+static OPJ_BOOL opj_j2k_post_write_tile (opj_j2k_t * p_j2k,
+                                                                             opj_stream_private_t *p_stream,
+                                                                             opj_event_mgr_t * p_manager );
+
+/**
+ * Sets up the procedures to do on writing header.
+ * Developers wanting to extend the library can add their own writing procedures.
+ */
+static OPJ_BOOL opj_j2k_setup_header_writing (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
+
+static OPJ_BOOL opj_j2k_write_first_tile_part(  opj_j2k_t *p_j2k,
+                                                                                            OPJ_BYTE * p_data,
+                                                                                            OPJ_UINT32 * p_data_written,
+                                                                                            OPJ_UINT32 p_total_data_size,
+                                                                                            opj_stream_private_t *p_stream,
+                                                                                            struct opj_event_mgr * p_manager );
+
+static OPJ_BOOL opj_j2k_write_all_tile_parts(   opj_j2k_t *p_j2k,
+                                                                                            OPJ_BYTE * p_data,
+                                                                                            OPJ_UINT32 * p_data_written,
+                                                                                            OPJ_UINT32 p_total_data_size,
+                                                                                            opj_stream_private_t *p_stream,
+                                                                                            struct opj_event_mgr * p_manager );
+
+/**
+ * Gets the offset of the header.
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_get_end_header( opj_j2k_t *p_j2k,
+                                        opj_stream_private_t *p_stream,
+                                        opj_event_mgr_t * p_manager );
+
+static OPJ_BOOL opj_j2k_allocate_tile_element_cstr_index(opj_j2k_t *p_j2k);
+
+/*
+ * -----------------------------------------------------------------------
+ * -----------------------------------------------------------------------
+ * -----------------------------------------------------------------------
+ */
+
+/**
+ * Writes the SOC marker (Start Of Codestream)
+ *
+ * @param       p_stream                        the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_soc(      opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a SOC marker (Start of Codestream)
+ * @param       p_j2k           the jpeg2000 file codec.
+ * @param       p_stream        XXX needs data
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_soc(   opj_j2k_t *p_j2k,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the SIZ marker (image and tile size)
+ *
+ * @param       p_j2k           J2K codec.
+ * @param       p_stream        the stream to write data to.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_siz(      opj_j2k_t *p_j2k,
+                                                                opj_stream_private_t *p_stream,
+                                                                opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a SIZ marker (image and tile size)
+ * @param       p_j2k           the jpeg2000 file codec.
+ * @param       p_header_data   the data contained in the SIZ box.
+ * @param       p_header_size   the size of the data contained in the SIZ marker.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
+                                 OPJ_BYTE * p_header_data,
+                                 OPJ_UINT32 p_header_size,
+                                 opj_event_mgr_t * p_manager);
+
+/**
+ * Writes the COM marker (comment)
+ *
+ * @param       p_stream                        the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_com(      opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a COM marker (comments)
+ * @param       p_j2k           the jpeg2000 file codec.
+ * @param       p_header_data   the data contained in the COM box.
+ * @param       p_header_size   the size of the data contained in the COM marker.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_com (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+/**
+ * Writes the COD marker (Coding style default)
+ *
+ * @param       p_stream                        the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_cod(      opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a COD marker (Coding Styke defaults)
+ * @param       p_header_data   the data contained in the COD box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the COD marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_cod (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager);
+
+/**
+ * Compares 2 COC markers (Coding style component)
+ *
+ * @param       p_j2k            J2K codec.
+ * @param       p_first_comp_no  the index of the first component to compare.
+ * @param       p_second_comp_no the index of the second component to compare.
+ *
+ * @return      OPJ_TRUE if equals
+ */
+static OPJ_BOOL opj_j2k_compare_coc(opj_j2k_t *p_j2k, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
+
+/**
+ * Writes the COC marker (Coding style component)
+ *
+ * @param       p_j2k       J2K codec.
+ * @param       p_comp_no   the index of the component to output.
+ * @param       p_stream    the stream to write data to.
+ * @param       p_manager   the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_coc(  opj_j2k_t *p_j2k,
+                                                                OPJ_UINT32 p_comp_no,
+                                                                opj_stream_private_t *p_stream,
+                                                                opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the COC marker (Coding style component)
+ *
+ * @param       p_j2k                   J2K codec.
+ * @param       p_comp_no               the index of the component to output.
+ * @param       p_data          FIXME DOC
+ * @param       p_data_written  FIXME DOC
+ * @param       p_manager               the user event manager.
+*/
+static void opj_j2k_write_coc_in_memory(opj_j2k_t *p_j2k,
+                                                                            OPJ_UINT32 p_comp_no,
+                                                                            OPJ_BYTE * p_data,
+                                                                            OPJ_UINT32 * p_data_written,
+                                                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Gets the maximum size taken by a coc.
+ *
+ * @param       p_j2k   the jpeg2000 codec to use.
+ */
+static OPJ_UINT32 opj_j2k_get_max_coc_size(opj_j2k_t *p_j2k);
+
+/**
+ * Reads a COC marker (Coding Style Component)
+ * @param       p_header_data   the data contained in the COC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the COC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_coc (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the QCD marker (quantization default)
+ *
+ * @param       p_j2k                   J2K codec.
+ * @param       p_stream                the stream to write data to.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_qcd(      opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a QCD marker (Quantization defaults)
+ * @param       p_header_data   the data contained in the QCD box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the QCD marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_qcd (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Compare QCC markers (quantization component)
+ *
+ * @param       p_j2k                 J2K codec.
+ * @param       p_first_comp_no       the index of the first component to compare.
+ * @param       p_second_comp_no      the index of the second component to compare.
+ *
+ * @return OPJ_TRUE if equals.
+ */
+static OPJ_BOOL opj_j2k_compare_qcc(opj_j2k_t *p_j2k, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no);
+
+/**
+ * Writes the QCC marker (quantization component)
+ *
+ * @param       p_comp_no       the index of the component to output.
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_qcc(      opj_j2k_t *p_j2k,
+                                                                        OPJ_UINT32 p_comp_no,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the QCC marker (quantization component)
+ *
+ * @param       p_j2k           J2K codec.
+ * @param       p_comp_no       the index of the component to output.
+ * @param       p_data          FIXME DOC
+ * @param       p_data_written  the stream to write data to.
+ * @param       p_manager       the user event manager.
+*/
+static void opj_j2k_write_qcc_in_memory(opj_j2k_t *p_j2k,
+                                                                            OPJ_UINT32 p_comp_no,
+                                                                            OPJ_BYTE * p_data,
+                                                                            OPJ_UINT32 * p_data_written,
+                                                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Gets the maximum size taken by a qcc.
+ */
+static OPJ_UINT32 opj_j2k_get_max_qcc_size (opj_j2k_t *p_j2k);
+
+/**
+ * Reads a QCC marker (Quantization component)
+ * @param       p_header_data   the data contained in the QCC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the QCC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_qcc(   opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager);
+/**
+ * Writes the POC marker (Progression Order Change)
+ *
+ * @param       p_stream                                the stream to write data to.
+ * @param       p_j2k                           J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_poc(      opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+/**
+ * Writes the POC marker (Progression Order Change)
+ *
+ * @param       p_j2k          J2K codec.
+ * @param       p_data         FIXME DOC
+ * @param       p_data_written the stream to write data to.
+ * @param       p_manager      the user event manager.
+ */
+static void opj_j2k_write_poc_in_memory(opj_j2k_t *p_j2k,
+                                                                            OPJ_BYTE * p_data,
+                                                                            OPJ_UINT32 * p_data_written,
+                                                                            opj_event_mgr_t * p_manager );
+/**
+ * Gets the maximum size taken by the writing of a POC.
+ */
+static OPJ_UINT32 opj_j2k_get_max_poc_size(opj_j2k_t *p_j2k);
+
+/**
+ * Reads a POC marker (Progression Order Change)
+ *
+ * @param       p_header_data   the data contained in the POC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the POC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_poc (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Gets the maximum size taken by the toc headers of all the tile parts of any given tile.
+ */
+static OPJ_UINT32 opj_j2k_get_max_toc_size (opj_j2k_t *p_j2k);
+
+/**
+ * Gets the maximum size taken by the headers of the SOT.
+ *
+ * @param       p_j2k   the jpeg2000 codec to use.
+ */
+static OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k);
+
+/**
+ * Reads a CRG marker (Component registration)
+ *
+ * @param       p_header_data   the data contained in the TLM box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the TLM marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_crg (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+/**
+ * Reads a TLM marker (Tile Length Marker)
+ *
+ * @param       p_header_data   the data contained in the TLM box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the TLM marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_tlm (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager);
+
+/**
+ * Writes the updated tlm.
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_updated_tlm(      opj_j2k_t *p_j2k,
+                                            opj_stream_private_t *p_stream,
+                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a PLM marker (Packet length, main header marker)
+ *
+ * @param       p_header_data   the data contained in the TLM box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the TLM marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_plm (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager);
+/**
+ * Reads a PLT marker (Packet length, tile-part header)
+ *
+ * @param       p_header_data   the data contained in the PLT box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the PLT marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_plt (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a PPM marker (Packed headers, main header)
+ *
+ * @param       p_header_data   the data contained in the POC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the POC marker.
+ * @param       p_manager               the user event manager.
+ */
+
+static OPJ_BOOL opj_j2k_read_ppm (
+																		 opj_j2k_t *p_j2k,
+																		 OPJ_BYTE * p_header_data,
+																		 OPJ_UINT32 p_header_size,
+																		 opj_event_mgr_t * p_manager );
+
+/**
+ * Merges all PPM markers read (Packed headers, main header)
+ *
+ * @param       p_cp      main coding parameters.
+ * @param       p_manager the user event manager.
+ */
+static OPJ_BOOL opj_j2k_merge_ppm ( opj_cp_t *p_cp, opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a PPT marker (Packed packet headers, tile-part header)
+ *
+ * @param       p_header_data   the data contained in the PPT box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the PPT marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_ppt (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Merges all PPT markers read (Packed headers, tile-part header)
+ *
+ * @param       p_tcp   the tile.
+ * @param       p_manager               the user event manager.
+ */
+static OPJ_BOOL opj_j2k_merge_ppt (  opj_tcp_t *p_tcp,
+																	   opj_event_mgr_t * p_manager );
+
+
+/**
+ * Writes the TLM marker (Tile Length Marker)
+ *
+ * @param       p_stream                                the stream to write data to.
+ * @param       p_j2k                           J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_tlm(      opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the SOT marker (Start of tile-part)
+ *
+ * @param       p_j2k            J2K codec.
+ * @param       p_data           FIXME DOC
+ * @param       p_data_written   FIXME DOC
+ * @param       p_stream         the stream to write data to.
+ * @param       p_manager        the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_sot(      opj_j2k_t *p_j2k,
+                                                                        OPJ_BYTE * p_data,
+                                                                        OPJ_UINT32 * p_data_written,
+                                                                        const opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Reads values from a SOT marker (Start of tile-part)
+ *
+ * the j2k decoder state is not affected. No side effects, no checks except for p_header_size.
+ *
+ * @param       p_header_data   the data contained in the SOT marker.
+ * @param       p_header_size   the size of the data contained in the SOT marker.
+ * @param       p_tile_no       Isot.
+ * @param       p_tot_len       Psot.
+ * @param       p_current_part  TPsot.
+ * @param       p_num_parts     TNsot.
+ * @param       p_manager       the user event manager.
+ */
+static OPJ_BOOL opj_j2k_get_sot_values(OPJ_BYTE *  p_header_data,
+																			 OPJ_UINT32  p_header_size,
+																			 OPJ_UINT32* p_tile_no,
+																			 OPJ_UINT32* p_tot_len,
+																			 OPJ_UINT32* p_current_part,
+																			 OPJ_UINT32* p_num_parts,
+																			 opj_event_mgr_t * p_manager );
+/**
+ * Reads a SOT marker (Start of tile-part)
+ *
+ * @param       p_header_data   the data contained in the SOT marker.
+ * @param       p_j2k           the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the PPT marker.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_sot (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+/**
+ * Writes the SOD marker (Start of data)
+ *
+ * @param       p_j2k               J2K codec.
+ * @param       p_tile_coder        FIXME DOC
+ * @param       p_data              FIXME DOC
+ * @param       p_data_written      FIXME DOC
+ * @param       p_total_data_size   FIXME DOC
+ * @param       p_stream            the stream to write data to.
+ * @param       p_manager           the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_sod(      opj_j2k_t *p_j2k,
+                                                                        opj_tcd_t * p_tile_coder,
+                                                                        OPJ_BYTE * p_data,
+                                                                        OPJ_UINT32 * p_data_written,
+                                                                        OPJ_UINT32 p_total_data_size,
+                                                                        const opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a SOD marker (Start Of Data)
+ *
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_stream                FIXME DOC
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_sod(   opj_j2k_t *p_j2k,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+static void opj_j2k_update_tlm (opj_j2k_t * p_j2k, OPJ_UINT32 p_tile_part_size )
+{
+        opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,p_j2k->m_current_tile_number,1);            /* PSOT */
+        ++p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current;
+
+        opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,p_tile_part_size,4);                                        /* PSOT */
+        p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 4;
+}
+
+/**
+ * Writes the RGN marker (Region Of Interest)
+ *
+ * @param       p_tile_no               the tile to output
+ * @param       p_comp_no               the component to output
+ * @param       nb_comps                the number of components
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_rgn(  opj_j2k_t *p_j2k,
+                                    OPJ_UINT32 p_tile_no,
+                                    OPJ_UINT32 p_comp_no,
+                                    OPJ_UINT32 nb_comps,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a RGN marker (Region Of Interest)
+ *
+ * @param       p_header_data   the data contained in the POC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the POC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_rgn (opj_j2k_t *p_j2k,
+                                  OPJ_BYTE * p_header_data,
+                                  OPJ_UINT32 p_header_size,
+                                  opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the EOC marker (End of Codestream)
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_eoc(      opj_j2k_t *p_j2k,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+#if 0
+/**
+ * Reads a EOC marker (End Of Codestream)
+ *
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_stream                FIXME DOC
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_eoc (      opj_j2k_t *p_j2k,
+                                                                opj_stream_private_t *p_stream,
+                                                                opj_event_mgr_t * p_manager );
+#endif
+
+/**
+ * Writes the CBD-MCT-MCC-MCO markers (Multi components transform)
+ *
+ * @param       p_stream                        the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_mct_data_group(   opj_j2k_t *p_j2k,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager );
+
+/**
+ * Inits the Info
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_init_info(      opj_j2k_t *p_j2k,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+Add main header marker information
+ at param cstr_index    Codestream information structure
+ at param type         marker type
+ at param pos          byte offset of marker segment
+ at param len          length of marker segment
+ */
+static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len) ;
+/**
+Add tile header marker information
+ at param tileno       tile index number
+ at param cstr_index   Codestream information structure
+ at param type         marker type
+ at param pos          byte offset of marker segment
+ at param len          length of marker segment
+ */
+static OPJ_BOOL opj_j2k_add_tlmarker(OPJ_UINT32 tileno, opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len);
+
+/**
+ * Reads an unknown marker
+ *
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_stream                the stream object to read from.
+ * @param       output_marker           FIXME DOC
+ * @param       p_manager               the user event manager.
+ *
+ * @return      true                    if the marker could be deduced.
+*/
+static OPJ_BOOL opj_j2k_read_unk( opj_j2k_t *p_j2k,
+                                  opj_stream_private_t *p_stream,
+                                  OPJ_UINT32 *output_marker,
+                                  opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the MCT marker (Multiple Component Transform)
+ *
+ * @param       p_j2k           J2K codec.
+ * @param       p_mct_record    FIXME DOC
+ * @param       p_stream        the stream to write data to.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_mct_record(       opj_j2k_t *p_j2k,
+                                                                                    opj_mct_data_t * p_mct_record,
+                                            opj_stream_private_t *p_stream,
+                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a MCT marker (Multiple Component Transform)
+ *
+ * @param       p_header_data   the data contained in the MCT box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the MCT marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_mct (      opj_j2k_t *p_j2k,
+                                                                    OPJ_BYTE * p_header_data,
+                                                                    OPJ_UINT32 p_header_size,
+                                                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the MCC marker (Multiple Component Collection)
+ *
+ * @param       p_j2k                   J2K codec.
+ * @param       p_mcc_record            FIXME DOC
+ * @param       p_stream                the stream to write data to.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_mcc_record(   opj_j2k_t *p_j2k,
+                                            opj_simple_mcc_decorrelation_data_t * p_mcc_record,
+                                            opj_stream_private_t *p_stream,
+                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a MCC marker (Multiple Component Collection)
+ *
+ * @param       p_header_data   the data contained in the MCC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the MCC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_mcc (      opj_j2k_t *p_j2k,
+                                                                    OPJ_BYTE * p_header_data,
+                                                                    OPJ_UINT32 p_header_size,
+                                                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the MCO marker (Multiple component transformation ordering)
+ *
+ * @param       p_stream                                the stream to write data to.
+ * @param       p_j2k                           J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_mco(      opj_j2k_t *p_j2k,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a MCO marker (Multiple Component Transform Ordering)
+ *
+ * @param       p_header_data   the data contained in the MCO box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the MCO marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_mco (      opj_j2k_t *p_j2k,
+                                                                    OPJ_BYTE * p_header_data,
+                                                                    OPJ_UINT32 p_header_size,
+                                                                    opj_event_mgr_t * p_manager );
+
+static OPJ_BOOL opj_j2k_add_mct(opj_tcp_t * p_tcp, opj_image_t * p_image, OPJ_UINT32 p_index);
+
+static void  opj_j2k_read_int16_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_read_int32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_read_float32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_read_float64_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+
+static void  opj_j2k_read_int16_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_read_int32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_read_float32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_read_float64_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+
+static void  opj_j2k_write_float_to_int16 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_write_float_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_write_float_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+static void  opj_j2k_write_float_to_float64 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+
+/**
+ * Ends the encoding, i.e. frees memory.
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_end_encoding(   opj_j2k_t *p_j2k,
+                                                                            opj_stream_private_t *p_stream,
+                                                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the CBD marker (Component bit depth definition)
+ *
+ * @param       p_stream                                the stream to write data to.
+ * @param       p_j2k                           J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_cbd(      opj_j2k_t *p_j2k,
+                                                                    opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a CBD marker (Component bit depth definition)
+ * @param       p_header_data   the data contained in the CBD box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the CBD marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_cbd (      opj_j2k_t *p_j2k,
+                                                                OPJ_BYTE * p_header_data,
+                                                                OPJ_UINT32 p_header_size,
+                                                                opj_event_mgr_t * p_manager);
+
+
+/**
+ * Writes COC marker for each component.
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_all_coc( opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Writes QCC marker for each component.
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_all_qcc( opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Writes regions of interests.
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_regions(  opj_j2k_t *p_j2k,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Writes EPC ????
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_write_epc(      opj_j2k_t *p_j2k,
+                                                                    opj_stream_private_t *p_stream,
+                                                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Checks the progression order changes values. Tells of the poc given as input are valid.
+ * A nice message is outputted at errors.
+ *
+ * @param       p_pocs                  the progression order changes.
+ * @param       p_nb_pocs               the number of progression order changes.
+ * @param       p_nb_resolutions        the number of resolutions.
+ * @param       numcomps                the number of components
+ * @param       numlayers               the number of layers.
+ * @param       p_manager               the user event manager.
+ *
+ * @return      true if the pocs are valid.
+ */
+static OPJ_BOOL opj_j2k_check_poc_val(  const opj_poc_t *p_pocs,
+                                                                            OPJ_UINT32 p_nb_pocs,
+                                                                            OPJ_UINT32 p_nb_resolutions,
+                                                                            OPJ_UINT32 numcomps,
+                                                                            OPJ_UINT32 numlayers,
+                                                                            opj_event_mgr_t * p_manager);
+
+/**
+ * Gets the number of tile parts used for the given change of progression (if any) and the given tile.
+ *
+ * @param               cp                      the coding parameters.
+ * @param               pino            the offset of the given poc (i.e. its position in the coding parameter).
+ * @param               tileno          the given tile.
+ *
+ * @return              the number of tile parts.
+ */
+static OPJ_UINT32 opj_j2k_get_num_tp( opj_cp_t *cp, OPJ_UINT32 pino, OPJ_UINT32 tileno);
+
+/**
+ * Calculates the total number of tile parts needed by the encoder to
+ * encode such an image. If not enough memory is available, then the function return false.
+ *
+ * @param       p_nb_tiles      pointer that will hold the number of tile parts.
+ * @param       cp                      the coding parameters for the image.
+ * @param       image           the image to encode.
+ * @param       p_j2k                   the p_j2k encoder.
+ * @param       p_manager       the user event manager.
+ *
+ * @return true if the function was successful, false else.
+ */
+static OPJ_BOOL opj_j2k_calculate_tp(   opj_j2k_t *p_j2k,
+                                                                            opj_cp_t *cp,
+                                                                            OPJ_UINT32 * p_nb_tiles,
+                                                                            opj_image_t *image,
+                                                                            opj_event_mgr_t * p_manager);
+
+static void opj_j2k_dump_MH_info(opj_j2k_t* p_j2k, FILE* out_stream);
+
+static void opj_j2k_dump_MH_index(opj_j2k_t* p_j2k, FILE* out_stream);
+
+static opj_codestream_index_t* opj_j2k_create_cstr_index(void);
+
+static OPJ_FLOAT32 opj_j2k_get_tp_stride (opj_tcp_t * p_tcp);
+
+static OPJ_FLOAT32 opj_j2k_get_default_stride (opj_tcp_t * p_tcp);
+
+static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres);
+
+static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t *p_manager);
+
+static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz, opj_event_mgr_t *p_manager);
+
+/**
+ * Checks for invalid number of tile-parts in SOT marker (TPsot==TNsot). See issue 254.
+ *
+ * @param       p_stream            the stream to read data from.
+ * @param       tile_no             tile number we're looking for.
+ * @param       p_correction_needed output value. if true, non conformant codestream needs TNsot correction.
+ * @param       p_manager       the user event manager.
+ *
+ * @return true if the function was successful, false else.
+ */
+static OPJ_BOOL opj_j2k_need_nb_tile_parts_correction(opj_stream_private_t *p_stream, OPJ_UINT32 tile_no, OPJ_BOOL* p_correction_needed, opj_event_mgr_t * p_manager );
+
+/*@}*/
+
+/*@}*/
+
+/* ----------------------------------------------------------------------- */
+typedef struct j2k_prog_order{
+        OPJ_PROG_ORDER enum_prog;
+        char str_prog[5];
+}j2k_prog_order_t;
+
+static j2k_prog_order_t j2k_prog_order_list[] = {
+        {OPJ_CPRL, "CPRL"},
+        {OPJ_LRCP, "LRCP"},
+        {OPJ_PCRL, "PCRL"},
+        {OPJ_RLCP, "RLCP"},
+        {OPJ_RPCL, "RPCL"},
+        {(OPJ_PROG_ORDER)-1, ""}
+};
+
+/**
+ * FIXME DOC
+ */
+static const OPJ_UINT32 MCT_ELEMENT_SIZE [] =
+{
+        2,
+        4,
+        4,
+        8
+};
+
+typedef void (* opj_j2k_mct_function) (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);
+
+static const opj_j2k_mct_function j2k_mct_read_functions_to_float [] =
+{
+        opj_j2k_read_int16_to_float,
+        opj_j2k_read_int32_to_float,
+        opj_j2k_read_float32_to_float,
+        opj_j2k_read_float64_to_float
+};
+
+static const opj_j2k_mct_function j2k_mct_read_functions_to_int32 [] =
+{
+        opj_j2k_read_int16_to_int32,
+        opj_j2k_read_int32_to_int32,
+        opj_j2k_read_float32_to_int32,
+        opj_j2k_read_float64_to_int32
+};
+
+static const opj_j2k_mct_function j2k_mct_write_functions_from_float [] =
+{
+        opj_j2k_write_float_to_int16,
+        opj_j2k_write_float_to_int32,
+        opj_j2k_write_float_to_float,
+        opj_j2k_write_float_to_float64
+};
+
+typedef struct opj_dec_memory_marker_handler
+{
+        /** marker value */
+        OPJ_UINT32 id;
+        /** value of the state when the marker can appear */
+        OPJ_UINT32 states;
+        /** action linked to the marker */
+        OPJ_BOOL (*handler) (   opj_j2k_t *p_j2k,
+                            OPJ_BYTE * p_header_data,
+                            OPJ_UINT32 p_header_size,
+                            opj_event_mgr_t * p_manager );
+}
+opj_dec_memory_marker_handler_t;
+
+static const opj_dec_memory_marker_handler_t j2k_memory_marker_handler_tab [] =
+{
+  {J2K_MS_SOT, J2K_STATE_MH | J2K_STATE_TPHSOT, opj_j2k_read_sot},
+  {J2K_MS_COD, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_cod},
+  {J2K_MS_COC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_coc},
+  {J2K_MS_RGN, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_rgn},
+  {J2K_MS_QCD, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_qcd},
+  {J2K_MS_QCC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_qcc},
+  {J2K_MS_POC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_poc},
+  {J2K_MS_SIZ, J2K_STATE_MHSIZ, opj_j2k_read_siz},
+  {J2K_MS_TLM, J2K_STATE_MH, opj_j2k_read_tlm},
+  {J2K_MS_PLM, J2K_STATE_MH, opj_j2k_read_plm},
+  {J2K_MS_PLT, J2K_STATE_TPH, opj_j2k_read_plt},
+  {J2K_MS_PPM, J2K_STATE_MH, opj_j2k_read_ppm},
+  {J2K_MS_PPT, J2K_STATE_TPH, opj_j2k_read_ppt},
+  {J2K_MS_SOP, 0, 0},
+  {J2K_MS_CRG, J2K_STATE_MH, opj_j2k_read_crg},
+  {J2K_MS_COM, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_com},
+  {J2K_MS_MCT, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mct},
+  {J2K_MS_CBD, J2K_STATE_MH , opj_j2k_read_cbd},
+  {J2K_MS_MCC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mcc},
+  {J2K_MS_MCO, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mco},
+#ifdef USE_JPWL
+#ifdef TODO_MS /* remove these functions which are not commpatible with the v2 API */
+  {J2K_MS_EPC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epc},
+  {J2K_MS_EPB, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epb},
+  {J2K_MS_ESD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_esd},
+  {J2K_MS_RED, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_red},
+#endif
+#endif /* USE_JPWL */
+#ifdef USE_JPSEC
+  {J2K_MS_SEC, J2K_DEC_STATE_MH, j2k_read_sec},
+  {J2K_MS_INSEC, 0, j2k_read_insec}
+#endif /* USE_JPSEC */
+  {J2K_MS_UNK, J2K_STATE_MH | J2K_STATE_TPH, 0}/*opj_j2k_read_unk is directly used*/
+};
+
+static void  opj_j2k_read_int16_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_bytes(l_src_data,&l_temp,2);
+
+                l_src_data+=sizeof(OPJ_INT16);
+
+                *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
+        }
+}
+
+static void  opj_j2k_read_int32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_bytes(l_src_data,&l_temp,4);
+
+                l_src_data+=sizeof(OPJ_INT32);
+
+                *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
+        }
+}
+
+static void  opj_j2k_read_float32_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_FLOAT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_float(l_src_data,&l_temp);
+
+                l_src_data+=sizeof(OPJ_FLOAT32);
+
+                *(l_dest_data++) = l_temp;
+        }
+}
+
+static void  opj_j2k_read_float64_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_FLOAT64 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_double(l_src_data,&l_temp);
+
+                l_src_data+=sizeof(OPJ_FLOAT64);
+
+                *(l_dest_data++) = (OPJ_FLOAT32) l_temp;
+        }
+}
+
+static void  opj_j2k_read_int16_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_bytes(l_src_data,&l_temp,2);
+
+                l_src_data+=sizeof(OPJ_INT16);
+
+                *(l_dest_data++) = (OPJ_INT32) l_temp;
+        }
+}
+
+static void  opj_j2k_read_int32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_bytes(l_src_data,&l_temp,4);
+
+                l_src_data+=sizeof(OPJ_INT32);
+
+                *(l_dest_data++) = (OPJ_INT32) l_temp;
+        }
+}
+
+static void  opj_j2k_read_float32_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_FLOAT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_float(l_src_data,&l_temp);
+
+                l_src_data+=sizeof(OPJ_FLOAT32);
+
+                *(l_dest_data++) = (OPJ_INT32) l_temp;
+        }
+}
+
+static void  opj_j2k_read_float64_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
+        OPJ_INT32 * l_dest_data = (OPJ_INT32 *) p_dest_data;
+        OPJ_UINT32 i;
+        OPJ_FLOAT64 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                opj_read_double(l_src_data,&l_temp);
+
+                l_src_data+=sizeof(OPJ_FLOAT64);
+
+                *(l_dest_data++) = (OPJ_INT32) l_temp;
+        }
+}
+
+static void  opj_j2k_write_float_to_int16 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
+        OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                l_temp = (OPJ_UINT32) *(l_src_data++);
+
+                opj_write_bytes(l_dest_data,l_temp,sizeof(OPJ_INT16));
+
+                l_dest_data+=sizeof(OPJ_INT16);
+        }
+}
+
+static void opj_j2k_write_float_to_int32 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
+        OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                l_temp = (OPJ_UINT32) *(l_src_data++);
+
+                opj_write_bytes(l_dest_data,l_temp,sizeof(OPJ_INT32));
+
+                l_dest_data+=sizeof(OPJ_INT32);
+        }
+}
+
+static void  opj_j2k_write_float_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
+        OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
+        OPJ_UINT32 i;
+        OPJ_FLOAT32 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                l_temp = (OPJ_FLOAT32) *(l_src_data++);
+
+                opj_write_float(l_dest_data,l_temp);
+
+                l_dest_data+=sizeof(OPJ_FLOAT32);
+        }
+}
+
+static void  opj_j2k_write_float_to_float64 (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem)
+{
+        OPJ_BYTE * l_dest_data = (OPJ_BYTE *) p_dest_data;
+        OPJ_FLOAT32 * l_src_data = (OPJ_FLOAT32 *) p_src_data;
+        OPJ_UINT32 i;
+        OPJ_FLOAT64 l_temp;
+
+        for (i=0;i<p_nb_elem;++i) {
+                l_temp = (OPJ_FLOAT64) *(l_src_data++);
+
+                opj_write_double(l_dest_data,l_temp);
+
+                l_dest_data+=sizeof(OPJ_FLOAT64);
+        }
+}
+
+char *opj_j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){
+        j2k_prog_order_t *po;
+        for(po = j2k_prog_order_list; po->enum_prog != -1; po++ ){
+                if(po->enum_prog == prg_order){
+                        return po->str_prog;
+                }
+        }
+        return po->str_prog;
+}
+
+static OPJ_BOOL opj_j2k_check_poc_val( const opj_poc_t *p_pocs,
+                                                        OPJ_UINT32 p_nb_pocs,
+                                                        OPJ_UINT32 p_nb_resolutions,
+                                                        OPJ_UINT32 p_num_comps,
+                                                        OPJ_UINT32 p_num_layers,
+                                                        opj_event_mgr_t * p_manager)
+{
+        OPJ_UINT32* packet_array;
+        OPJ_UINT32 index , resno, compno, layno;
+        OPJ_UINT32 i;
+        OPJ_UINT32 step_c = 1;
+        OPJ_UINT32 step_r = p_num_comps * step_c;
+        OPJ_UINT32 step_l = p_nb_resolutions * step_r;
+        OPJ_BOOL loss = OPJ_FALSE;
+        OPJ_UINT32 layno0 = 0;
+
+        packet_array = (OPJ_UINT32*) opj_calloc(step_l * p_num_layers, sizeof(OPJ_UINT32));
+        if (packet_array == 00) {
+                opj_event_msg(p_manager , EVT_ERROR, "Not enough memory for checking the poc values.\n");
+                return OPJ_FALSE;
+        }
+
+        if (p_nb_pocs == 0) {
+        opj_free(packet_array);
+                return OPJ_TRUE;
+        }
+
+        index = step_r * p_pocs->resno0;
+        /* take each resolution for each poc */
+        for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno)
+        {
+                OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
+
+                /* take each comp of each resolution for each poc */
+                for (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno) {
+                        OPJ_UINT32 comp_index = res_index + layno0 * step_l;
+
+                        /* and finally take each layer of each res of ... */
+                        for (layno = layno0; layno < p_pocs->layno1 ; ++layno) {
+                                /*index = step_r * resno + step_c * compno + step_l * layno;*/
+                                packet_array[comp_index] = 1;
+                                comp_index += step_l;
+                        }
+
+                        res_index += step_c;
+                }
+
+                index += step_r;
+        }
+        ++p_pocs;
+
+        /* iterate through all the pocs */
+        for (i = 1; i < p_nb_pocs ; ++i) {
+                OPJ_UINT32 l_last_layno1 = (p_pocs-1)->layno1 ;
+
+                layno0 = (p_pocs->layno1 > l_last_layno1)? l_last_layno1 : 0;
+                index = step_r * p_pocs->resno0;
+
+                /* take each resolution for each poc */
+                for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno) {
+                        OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
+
+                        /* take each comp of each resolution for each poc */
+                        for (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno) {
+                                OPJ_UINT32 comp_index = res_index + layno0 * step_l;
+
+                                /* and finally take each layer of each res of ... */
+                                for (layno = layno0; layno < p_pocs->layno1 ; ++layno) {
+                                        /*index = step_r * resno + step_c * compno + step_l * layno;*/
+                                        packet_array[comp_index] = 1;
+                                        comp_index += step_l;
+                                }
+
+                                res_index += step_c;
+                        }
+
+                        index += step_r;
+                }
+
+                ++p_pocs;
+        }
+
+        index = 0;
+        for (layno = 0; layno < p_num_layers ; ++layno) {
+                for (resno = 0; resno < p_nb_resolutions; ++resno) {
+                        for (compno = 0; compno < p_num_comps; ++compno) {
+                                loss |= (packet_array[index]!=1);
+                                /*index = step_r * resno + step_c * compno + step_l * layno;*/
+                                index += step_c;
+                        }
+                }
+        }
+
+        if (loss) {
+                opj_event_msg(p_manager , EVT_ERROR, "Missing packets possible loss of data\n");
+        }
+
+        opj_free(packet_array);
+
+        return !loss;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static OPJ_UINT32 opj_j2k_get_num_tp(opj_cp_t *cp, OPJ_UINT32 pino, OPJ_UINT32 tileno)
+{
+        const OPJ_CHAR *prog = 00;
+        OPJ_INT32 i;
+        OPJ_UINT32 tpnum = 1;
+        opj_tcp_t *tcp = 00;
+        opj_poc_t * l_current_poc = 00;
+
+        /*  preconditions */
+        assert(tileno < (cp->tw * cp->th));
+        assert(pino < (cp->tcps[tileno].numpocs + 1));
+
+        /* get the given tile coding parameter */
+        tcp = &cp->tcps[tileno];
+        assert(tcp != 00);
+
+        l_current_poc = &(tcp->pocs[pino]);
+        assert(l_current_poc != 0);
+
+        /* get the progression order as a character string */
+        prog = opj_j2k_convert_progression_order(tcp->prg);
+        assert(strlen(prog) > 0);
+
+        if (cp->m_specific_param.m_enc.m_tp_on == 1) {
+                for (i=0;i<4;++i) {
+                        switch (prog[i])
+                        {
+                                /* component wise */
+                                case 'C':
+                                        tpnum *= l_current_poc->compE;
+                                        break;
+                                /* resolution wise */
+                                case 'R':
+                                        tpnum *= l_current_poc->resE;
+                                        break;
+                                /* precinct wise */
+                                case 'P':
+                                        tpnum *= l_current_poc->prcE;
+                                        break;
+                                /* layer wise */
+                                case 'L':
+                                        tpnum *= l_current_poc->layE;
+                                        break;
+                        }
+                        /* whould we split here ? */
+                        if ( cp->m_specific_param.m_enc.m_tp_flag == prog[i] ) {
+                                cp->m_specific_param.m_enc.m_tp_pos=i;
+                                break;
+                        }
+                }
+        }
+        else {
+                tpnum=1;
+        }
+
+        return tpnum;
+}
+
+static OPJ_BOOL opj_j2k_calculate_tp(  opj_j2k_t *p_j2k,
+                                                        opj_cp_t *cp,
+                                                        OPJ_UINT32 * p_nb_tiles,
+                                                        opj_image_t *image,
+                                                        opj_event_mgr_t * p_manager
+                                )
+{
+        OPJ_UINT32 pino,tileno;
+        OPJ_UINT32 l_nb_tiles;
+        opj_tcp_t *tcp;
+
+        /* preconditions */
+        assert(p_nb_tiles != 00);
+        assert(cp != 00);
+        assert(image != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_nb_tiles = cp->tw * cp->th;
+        * p_nb_tiles = 0;
+        tcp = cp->tcps;
+
+        /* INDEX >> */
+        /* TODO mergeV2: check this part which use cstr_info */
+        /*if (p_j2k->cstr_info) {
+                opj_tile_info_t * l_info_tile_ptr = p_j2k->cstr_info->tile;
+
+                for (tileno = 0; tileno < l_nb_tiles; ++tileno) {
+                        OPJ_UINT32 cur_totnum_tp = 0;
+
+                        opj_pi_update_encoding_parameters(image,cp,tileno);
+
+                        for (pino = 0; pino <= tcp->numpocs; ++pino)
+                        {
+                                OPJ_UINT32 tp_num = opj_j2k_get_num_tp(cp,pino,tileno);
+
+                                *p_nb_tiles = *p_nb_tiles + tp_num;
+
+                                cur_totnum_tp += tp_num;
+                        }
+
+                        tcp->m_nb_tile_parts = cur_totnum_tp;
+
+                        l_info_tile_ptr->tp = (opj_tp_info_t *) opj_malloc(cur_totnum_tp * sizeof(opj_tp_info_t));
+                        if (l_info_tile_ptr->tp == 00) {
+                                return OPJ_FALSE;
+                        }
+
+                        memset(l_info_tile_ptr->tp,0,cur_totnum_tp * sizeof(opj_tp_info_t));
+
+                        l_info_tile_ptr->num_tps = cur_totnum_tp;
+
+                        ++l_info_tile_ptr;
+                        ++tcp;
+                }
+        }
+        else */{
+                for (tileno = 0; tileno < l_nb_tiles; ++tileno) {
+                        OPJ_UINT32 cur_totnum_tp = 0;
+
+                        opj_pi_update_encoding_parameters(image,cp,tileno);
+
+                        for (pino = 0; pino <= tcp->numpocs; ++pino) {
+                                OPJ_UINT32 tp_num = opj_j2k_get_num_tp(cp,pino,tileno);
+
+                                *p_nb_tiles = *p_nb_tiles + tp_num;
+
+                                cur_totnum_tp += tp_num;
+                        }
+                        tcp->m_nb_tile_parts = cur_totnum_tp;
+
+                        ++tcp;
+                }
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_soc(     opj_j2k_t *p_j2k,
+                                                opj_stream_private_t *p_stream,
+                                                    opj_event_mgr_t * p_manager )
+{
+        /* 2 bytes will be written */
+        OPJ_BYTE * l_start_stream = 00;
+
+        /* preconditions */
+        assert(p_stream != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_start_stream = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        /* write SOC identifier */
+        opj_write_bytes(l_start_stream,J2K_MS_SOC,2);
+
+        if (opj_stream_write_data(p_stream,l_start_stream,2,p_manager) != 2) {
+                return OPJ_FALSE;
+        }
+
+/* UniPG>> */
+#ifdef USE_JPWL
+        /* update markers struct */
+/*
+        OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOC, p_stream_tell(p_stream) - 2, 2);
+*/
+  assert( 0 && "TODO" );
+#endif /* USE_JPWL */
+/* <<UniPG */
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a SOC marker (Start of Codestream)
+ * @param       p_j2k           the jpeg2000 file codec.
+ * @param       p_stream        FIXME DOC
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_soc(   opj_j2k_t *p_j2k,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_BYTE l_data [2];
+        OPJ_UINT32 l_marker;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        if (opj_stream_read_data(p_stream,l_data,2,p_manager) != 2) {
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(l_data,&l_marker,2);
+        if (l_marker != J2K_MS_SOC) {
+                return OPJ_FALSE;
+        }
+
+        /* Next marker should be a SIZ marker in the main header */
+        p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSIZ;
+
+        /* FIXME move it in a index structure included in p_j2k*/
+        p_j2k->cstr_index->main_head_start = opj_stream_tell(p_stream) - 2;
+
+        opj_event_msg(p_manager, EVT_INFO, "Start to read j2k main header (%d).\n", p_j2k->cstr_index->main_head_start);
+
+        /* Add the marker to the codestream index*/
+        if (OPJ_FALSE == opj_j2k_add_mhmarker(p_j2k->cstr_index, J2K_MS_SOC, p_j2k->cstr_index->main_head_start, 2)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n");
+                return OPJ_FALSE;
+        }
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_siz(     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_size_len;
+        OPJ_BYTE * l_current_ptr;
+        opj_image_t * l_image = 00;
+        opj_cp_t *cp = 00;
+        opj_image_comp_t * l_img_comp = 00;
+
+        /* preconditions */
+        assert(p_stream != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_image = p_j2k->m_private_image;
+        cp = &(p_j2k->m_cp);
+        l_size_len = 40 + 3 * l_image->numcomps;
+        l_img_comp = l_image->comps;
+
+        if (l_size_len > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_size_len);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for the SIZ marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_size_len;
+        }
+
+        l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        /* write SOC identifier */
+        opj_write_bytes(l_current_ptr,J2K_MS_SIZ,2);    /* SIZ */
+        l_current_ptr+=2;
+
+        opj_write_bytes(l_current_ptr,l_size_len-2,2); /* L_SIZ */
+        l_current_ptr+=2;
+
+        opj_write_bytes(l_current_ptr, cp->rsiz, 2);    /* Rsiz (capabilities) */
+        l_current_ptr+=2;
+
+        opj_write_bytes(l_current_ptr, l_image->x1, 4); /* Xsiz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, l_image->y1, 4); /* Ysiz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, l_image->x0, 4); /* X0siz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, l_image->y0, 4); /* Y0siz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, cp->tdx, 4);             /* XTsiz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, cp->tdy, 4);             /* YTsiz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, cp->tx0, 4);             /* XT0siz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, cp->ty0, 4);             /* YT0siz */
+        l_current_ptr+=4;
+
+        opj_write_bytes(l_current_ptr, l_image->numcomps, 2);   /* Csiz */
+        l_current_ptr+=2;
+
+        for (i = 0; i < l_image->numcomps; ++i) {
+                /* TODO here with MCT ? */
+                opj_write_bytes(l_current_ptr, l_img_comp->prec - 1 + (l_img_comp->sgnd << 7), 1);      /* Ssiz_i */
+                ++l_current_ptr;
+
+                opj_write_bytes(l_current_ptr, l_img_comp->dx, 1);      /* XRsiz_i */
+                ++l_current_ptr;
+
+                opj_write_bytes(l_current_ptr, l_img_comp->dy, 1);      /* YRsiz_i */
+                ++l_current_ptr;
+
+                ++l_img_comp;
+        }
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_size_len,p_manager) != l_size_len) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a SIZ marker (image and tile size)
+ * @param       p_j2k           the jpeg2000 file codec.
+ * @param       p_header_data   the data contained in the SIZ box.
+ * @param       p_header_size   the size of the data contained in the SIZ marker.
+ * @param       p_manager       the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
+                                 OPJ_BYTE * p_header_data,
+                                 OPJ_UINT32 p_header_size,
+                                 opj_event_mgr_t * p_manager
+                                 )
+{
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_nb_comp;
+        OPJ_UINT32 l_nb_comp_remain;
+        OPJ_UINT32 l_remaining_size;
+        OPJ_UINT32 l_nb_tiles;
+        OPJ_UINT32 l_tmp, l_tx1, l_ty1;
+        opj_image_t *l_image = 00;
+        opj_cp_t *l_cp = 00;
+        opj_image_comp_t * l_img_comp = 00;
+        opj_tcp_t * l_current_tile_param = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_header_data != 00);
+
+        l_image = p_j2k->m_private_image;
+        l_cp = &(p_j2k->m_cp);
+
+        /* minimum size == 39 - 3 (= minimum component parameter) */
+        if (p_header_size < 36) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\n");
+                return OPJ_FALSE;
+        }
+
+        l_remaining_size = p_header_size - 36;
+        l_nb_comp = l_remaining_size / 3;
+        l_nb_comp_remain = l_remaining_size % 3;
+        if (l_nb_comp_remain != 0){
+                opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,&l_tmp ,2);                                                /* Rsiz (capabilities) */
+        p_header_data+=2;
+        l_cp->rsiz = (OPJ_UINT16) l_tmp;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x1, 4);   /* Xsiz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y1, 4);   /* Ysiz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x0, 4);   /* X0siz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y0, 4);   /* Y0siz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdx, 4);             /* XTsiz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdy, 4);             /* YTsiz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tx0, 4);             /* XT0siz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->ty0, 4);             /* YT0siz */
+        p_header_data+=4;
+        opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_tmp, 2);                 /* Csiz */
+        p_header_data+=2;
+        if (l_tmp < 16385)
+                l_image->numcomps = (OPJ_UINT16) l_tmp;
+        else {
+                opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: number of component is illegal -> %d\n", l_tmp);
+                return OPJ_FALSE;
+        }
+
+        if (l_image->numcomps != l_nb_comp) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: number of component is not compatible with the remaining number of parameters ( %d vs %d)\n", l_image->numcomps, l_nb_comp);
+                return OPJ_FALSE;
+        }
+
+        /* testcase 4035.pdf.SIGSEGV.d8b.3375 */
+        /* testcase issue427-null-image-size.jp2 */
+        if ((l_image->x0 >= l_image->x1) || (l_image->y0 >= l_image->y1)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: negative or zero image size (%" PRId64 " x %" PRId64 ")\n", (OPJ_INT64)l_image->x1 - l_image->x0, (OPJ_INT64)l_image->y1 - l_image->y0);
+                return OPJ_FALSE;
+        }
+        /* testcase 2539.pdf.SIGFPE.706.1712 (also 3622.pdf.SIGFPE.706.2916 and 4008.pdf.SIGFPE.706.3345 and maybe more) */
+        if ((l_cp->tdx == 0U) || (l_cp->tdy == 0U)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: invalid tile size (tdx: %d, tdy: %d)\n", l_cp->tdx, l_cp->tdy);
+                return OPJ_FALSE;
+        }
+
+        /* testcase 1610.pdf.SIGSEGV.59c.681 */
+        if ((0xFFFFFFFFU / l_image->x1) < l_image->y1) {
+                opj_event_msg(p_manager, EVT_ERROR, "Prevent buffer overflow (x1: %d, y1: %d)\n", l_image->x1, l_image->y1);
+                return OPJ_FALSE;
+        }
+
+        /* testcase issue427-illegal-tile-offset.jp2 */
+        l_tx1 = opj_uint_adds(l_cp->tx0, l_cp->tdx); /* manage overflow */
+        l_ty1 = opj_uint_adds(l_cp->ty0, l_cp->tdy); /* manage overflow */
+        if ((l_cp->tx0 > l_image->x0) || (l_cp->ty0 > l_image->y0) || (l_tx1 <= l_image->x0) || (l_ty1 <= l_image->y0) ) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: illegal tile offset\n");
+                return OPJ_FALSE;
+        }
+
+#ifdef USE_JPWL
+        if (l_cp->correct) {
+                /* if JPWL is on, we check whether TX errors have damaged
+                  too much the SIZ parameters */
+                if (!(l_image->x1 * l_image->y1)) {
+                        opj_event_msg(p_manager, EVT_ERROR,
+                                "JPWL: bad image size (%d x %d)\n",
+                                l_image->x1, l_image->y1);
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                }
+
+        /* FIXME check previously in the function so why keep this piece of code ? Need by the norm ?
+                if (l_image->numcomps != ((len - 38) / 3)) {
+                        opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
+                                "JPWL: Csiz is %d => space in SIZ only for %d comps.!!!\n",
+                                l_image->numcomps, ((len - 38) / 3));
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+        */              /* we try to correct */
+        /*              opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n");
+                        if (l_image->numcomps < ((len - 38) / 3)) {
+                                len = 38 + 3 * l_image->numcomps;
+                                opj_event_msg(p_manager, EVT_WARNING, "- setting Lsiz to %d => HYPOTHESIS!!!\n",
+                                        len);
+                        } else {
+                                l_image->numcomps = ((len - 38) / 3);
+                                opj_event_msg(p_manager, EVT_WARNING, "- setting Csiz to %d => HYPOTHESIS!!!\n",
+                                        l_image->numcomps);
+                        }
+                }
+        */
+
+                /* update components number in the jpwl_exp_comps filed */
+                l_cp->exp_comps = l_image->numcomps;
+        }
+#endif /* USE_JPWL */
+
+        /* Allocate the resulting image components */
+        l_image->comps = (opj_image_comp_t*) opj_calloc(l_image->numcomps, sizeof(opj_image_comp_t));
+        if (l_image->comps == 00){
+                l_image->numcomps = 0;
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
+                return OPJ_FALSE;
+        }
+
+        l_img_comp = l_image->comps;
+
+        /* Read the component information */
+        for (i = 0; i < l_image->numcomps; ++i){
+                OPJ_UINT32 tmp;
+                opj_read_bytes(p_header_data,&tmp,1);   /* Ssiz_i */
+                ++p_header_data;
+                l_img_comp->prec = (tmp & 0x7f) + 1;
+                l_img_comp->sgnd = tmp >> 7;
+                opj_read_bytes(p_header_data,&tmp,1);   /* XRsiz_i */
+                ++p_header_data;
+                l_img_comp->dx = (OPJ_UINT32)tmp; /* should be between 1 and 255 */
+                opj_read_bytes(p_header_data,&tmp,1);   /* YRsiz_i */
+                ++p_header_data;
+                l_img_comp->dy = (OPJ_UINT32)tmp; /* should be between 1 and 255 */
+                if( l_img_comp->dx < 1 || l_img_comp->dx > 255 ||
+                    l_img_comp->dy < 1 || l_img_comp->dy > 255 ) {
+                    opj_event_msg(p_manager, EVT_ERROR,
+                                  "Invalid values for comp = %d : dx=%u dy=%u (should be between 1 and 255 according to the JPEG2000 norm)\n",
+                                  i, l_img_comp->dx, l_img_comp->dy);
+                    return OPJ_FALSE;
+                }
+                if( l_img_comp->prec > 38) { /* TODO openjpeg won't handle more than ? */
+                    opj_event_msg(p_manager, EVT_ERROR,
+                                  "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm)\n",
+                                  i, l_img_comp->prec);
+                    return OPJ_FALSE;
+                }
+
+#ifdef USE_JPWL
+                if (l_cp->correct) {
+                /* if JPWL is on, we check whether TX errors have damaged
+                        too much the SIZ parameters, again */
+                        if (!(l_image->comps[i].dx * l_image->comps[i].dy)) {
+                                opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
+                                        "JPWL: bad XRsiz_%d/YRsiz_%d (%d x %d)\n",
+                                        i, i, l_image->comps[i].dx, l_image->comps[i].dy);
+                                if (!JPWL_ASSUME) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                        return OPJ_FALSE;
+                                }
+                                /* we try to correct */
+                                opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust them\n");
+                                if (!l_image->comps[i].dx) {
+                                        l_image->comps[i].dx = 1;
+                                        opj_event_msg(p_manager, EVT_WARNING, "- setting XRsiz_%d to %d => HYPOTHESIS!!!\n",
+                                                i, l_image->comps[i].dx);
+                                }
+                                if (!l_image->comps[i].dy) {
+                                        l_image->comps[i].dy = 1;
+                                        opj_event_msg(p_manager, EVT_WARNING, "- setting YRsiz_%d to %d => HYPOTHESIS!!!\n",
+                                                i, l_image->comps[i].dy);
+                                }
+                        }
+                }
+#endif /* USE_JPWL */
+                l_img_comp->resno_decoded = 0;                                                          /* number of resolution decoded */
+                l_img_comp->factor = l_cp->m_specific_param.m_dec.m_reduce; /* reducing factor per component */
+                ++l_img_comp;
+        }
+
+        /* Compute the number of tiles */
+        l_cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->x1 - l_cp->tx0), (OPJ_INT32)l_cp->tdx);
+        l_cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->y1 - l_cp->ty0), (OPJ_INT32)l_cp->tdy);
+
+        /* Check that the number of tiles is valid */
+        if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 / l_cp->th) {
+            opj_event_msg(  p_manager, EVT_ERROR, 
+                            "Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
+                            l_cp->tw, l_cp->th);
+            return OPJ_FALSE;
+        }
+        l_nb_tiles = l_cp->tw * l_cp->th;
+
+        /* Define the tiles which will be decoded */
+        if (p_j2k->m_specific_param.m_decoder.m_discard_tiles) {
+                p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_j2k->m_specific_param.m_decoder.m_start_tile_x - l_cp->tx0) / l_cp->tdx;
+                p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) / l_cp->tdy;
+                p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0), (OPJ_INT32)l_cp->tdx);
+                p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0), (OPJ_INT32)l_cp->tdy);
+        }
+        else {
+                p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
+                p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
+                p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
+                p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
+        }
+
+#ifdef USE_JPWL
+        if (l_cp->correct) {
+                /* if JPWL is on, we check whether TX errors have damaged
+                  too much the SIZ parameters */
+                if ((l_cp->tw < 1) || (l_cp->th < 1) || (l_cp->tw > l_cp->max_tiles) || (l_cp->th > l_cp->max_tiles)) {
+                        opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
+                                "JPWL: bad number of tiles (%d x %d)\n",
+                                l_cp->tw, l_cp->th);
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                        /* we try to correct */
+                        opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust them\n");
+                        if (l_cp->tw < 1) {
+                                l_cp->tw= 1;
+                                opj_event_msg(p_manager, EVT_WARNING, "- setting %d tiles in x => HYPOTHESIS!!!\n",
+                                                l_cp->tw);
+                        }
+                        if (l_cp->tw > l_cp->max_tiles) {
+                                l_cp->tw= 1;
+                                opj_event_msg(p_manager, EVT_WARNING, "- too large x, increase expectance of %d\n"
+                                        "- setting %d tiles in x => HYPOTHESIS!!!\n",
+                                        l_cp->max_tiles, l_cp->tw);
+                        }
+                        if (l_cp->th < 1) {
+                                l_cp->th= 1;
+                                opj_event_msg(p_manager, EVT_WARNING, "- setting %d tiles in y => HYPOTHESIS!!!\n",
+                                                l_cp->th);
+                        }
+                        if (l_cp->th > l_cp->max_tiles) {
+                                l_cp->th= 1;
+                                opj_event_msg(p_manager, EVT_WARNING, "- too large y, increase expectance of %d to continue\n",
+                                        "- setting %d tiles in y => HYPOTHESIS!!!\n",
+                                        l_cp->max_tiles, l_cp->th);
+                        }
+                }
+        }
+#endif /* USE_JPWL */
+
+        /* memory allocations */
+        l_cp->tcps = (opj_tcp_t*) opj_calloc(l_nb_tiles, sizeof(opj_tcp_t));
+        if (l_cp->tcps == 00) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
+                return OPJ_FALSE;
+        }
+
+#ifdef USE_JPWL
+        if (l_cp->correct) {
+                if (!l_cp->tcps) {
+                        opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
+                                "JPWL: could not alloc tcps field of cp\n");
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                }
+        }
+#endif /* USE_JPWL */
+
+        p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps =
+                        (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_tccp_t));
+        if(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps  == 00) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
+                return OPJ_FALSE;
+        }
+
+        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records =
+                        (opj_mct_data_t*)opj_calloc(OPJ_J2K_MCT_DEFAULT_NB_RECORDS ,sizeof(opj_mct_data_t));
+
+        if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
+                return OPJ_FALSE;
+        }
+        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records = OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
+
+        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records =
+                        (opj_simple_mcc_decorrelation_data_t*)
+                        opj_calloc(OPJ_J2K_MCC_DEFAULT_NB_RECORDS, sizeof(opj_simple_mcc_decorrelation_data_t));
+
+        if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
+                return OPJ_FALSE;
+        }
+        p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records = OPJ_J2K_MCC_DEFAULT_NB_RECORDS;
+
+        /* set up default dc level shift */
+        for (i=0;i<l_image->numcomps;++i) {
+                if (! l_image->comps[i].sgnd) {
+                        p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1 << (l_image->comps[i].prec - 1);
+                }
+        }
+
+        l_current_tile_param = l_cp->tcps;
+        for     (i = 0; i < l_nb_tiles; ++i) {
+                l_current_tile_param->tccps = (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_tccp_t));
+                if (l_current_tile_param->tccps == 00) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
+                        return OPJ_FALSE;
+                }
+
+                ++l_current_tile_param;
+        }
+
+        p_j2k->m_specific_param.m_decoder.m_state =  J2K_STATE_MH; /* FIXME J2K_DEC_STATE_MH; */
+        opj_image_comp_header_update(l_image,l_cp);
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_com(     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager
+                            )
+{
+        OPJ_UINT32 l_comment_size;
+        OPJ_UINT32 l_total_com_size;
+        const OPJ_CHAR *l_comment;
+        OPJ_BYTE * l_current_ptr = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        l_comment = p_j2k->m_cp.comment;
+        l_comment_size = (OPJ_UINT32)strlen(l_comment);
+        l_total_com_size = l_comment_size + 6;
+
+        if (l_total_com_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_total_com_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write the COM marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_total_com_size;
+        }
+
+        l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        opj_write_bytes(l_current_ptr,J2K_MS_COM , 2);  /* COM */
+        l_current_ptr+=2;
+
+        opj_write_bytes(l_current_ptr,l_total_com_size - 2 , 2);        /* L_COM */
+        l_current_ptr+=2;
+
+        opj_write_bytes(l_current_ptr,1 , 2);   /* General use (IS 8859-15:1999 (Latin) values) */
+        l_current_ptr+=2;
+
+        memcpy( l_current_ptr,l_comment,l_comment_size);
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_total_com_size,p_manager) != l_total_com_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a COM marker (comments)
+ * @param       p_j2k           the jpeg2000 file codec.
+ * @param       p_header_data   the data contained in the COM box.
+ * @param       p_header_size   the size of the data contained in the COM marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_com (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_header_data != 00);
+  (void)p_header_size;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_cod(     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager )
+{
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        OPJ_UINT32 l_code_size,l_remaining_size;
+        OPJ_BYTE * l_current_data = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
+        l_code_size = 9 + opj_j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,0);
+        l_remaining_size = l_code_size;
+
+        if (l_code_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_code_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write COD marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_code_size;
+        }
+
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_COD,2);             /* COD */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_code_size-2,2);          /* L_COD */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_tcp->csty,1);            /* Scod */
+        ++l_current_data;
+
+        opj_write_bytes(l_current_data,(OPJ_UINT32)l_tcp->prg,1); /* SGcod (A) */
+        ++l_current_data;
+
+        opj_write_bytes(l_current_data,l_tcp->numlayers,2);       /* SGcod (B) */
+        l_current_data+=2;
+
+        opj_write_bytes(l_current_data,l_tcp->mct,1);             /* SGcod (C) */
+        ++l_current_data;
+
+        l_remaining_size -= 9;
+
+        if (! opj_j2k_write_SPCod_SPCoc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_size,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error writing COD marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (l_remaining_size != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error writing COD marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_code_size,p_manager) != l_code_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a COD marker (Coding Styke defaults)
+ * @param       p_header_data   the data contained in the COD box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the COD marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_cod (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        /* loop */
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_tmp;
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_image_t *l_image = 00;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_image = p_j2k->m_private_image;
+        l_cp = &(p_j2k->m_cp);
+
+        /* If we are in the first tile-part header of the current tile */
+        l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
+                                &l_cp->tcps[p_j2k->m_current_tile_number] :
+                                p_j2k->m_specific_param.m_decoder.m_default_tcp;
+	
+        /* Only one COD per tile */
+        if (l_tcp->cod) {
+                opj_event_msg(p_manager, EVT_ERROR, "COD marker already read. No more than one COD marker per tile.\n");
+                return OPJ_FALSE;
+        }
+        l_tcp->cod = 1;
+	
+        /* Make sure room is sufficient */
+        if (p_header_size < 5) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,&l_tcp->csty,1);           /* Scod */
+        ++p_header_data;
+        /* Make sure we know how to decode this */
+        if ((l_tcp->csty & ~(OPJ_UINT32)(J2K_CP_CSTY_PRT | J2K_CP_CSTY_SOP | J2K_CP_CSTY_EPH)) != 0U) {
+                opj_event_msg(p_manager, EVT_ERROR, "Unknown Scod value in COD marker\n");
+                return OPJ_FALSE;
+        }
+        opj_read_bytes(p_header_data,&l_tmp,1);                         /* SGcod (A) */
+        ++p_header_data;
+        l_tcp->prg = (OPJ_PROG_ORDER) l_tmp;
+        /* Make sure progression order is valid */
+        if (l_tcp->prg > OPJ_CPRL ) {
+                opj_event_msg(p_manager, EVT_ERROR, "Unknown progression order in COD marker\n");
+                l_tcp->prg = OPJ_PROG_UNKNOWN;
+        }
+        opj_read_bytes(p_header_data,&l_tcp->numlayers,2);      /* SGcod (B) */
+        p_header_data+=2;
+	
+        if ((l_tcp->numlayers < 1U) || (l_tcp->numlayers > 65535U)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Invalid number of layers in COD marker : %d not in range [1-65535]\n", l_tcp->numlayers);
+                return OPJ_FALSE;
+        }
+
+        /* If user didn't set a number layer to decode take the max specify in the codestream. */
+        if      (l_cp->m_specific_param.m_dec.m_layer) {
+                l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_layer;
+        }
+        else {
+                l_tcp->num_layers_to_decode = l_tcp->numlayers;
+        }
+
+        opj_read_bytes(p_header_data,&l_tcp->mct,1);            /* SGcod (C) */
+        ++p_header_data;
+
+        p_header_size -= 5;
+        for     (i = 0; i < l_image->numcomps; ++i) {
+                l_tcp->tccps[i].csty = l_tcp->csty & J2K_CCP_CSTY_PRT;
+        }
+
+        if (! opj_j2k_read_SPCod_SPCoc(p_j2k,0,p_header_data,&p_header_size,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (p_header_size != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n");
+                return OPJ_FALSE;
+        }
+
+        /* Apply the coding style to other components of the current tile or the m_default_tcp*/
+        opj_j2k_copy_tile_component_parameters(p_j2k);
+
+        /* Index */
+#ifdef WIP_REMOVE_MSD
+        if (p_j2k->cstr_info) {
+                /*opj_codestream_info_t *l_cstr_info = p_j2k->cstr_info;*/
+                p_j2k->cstr_info->prog = l_tcp->prg;
+                p_j2k->cstr_info->numlayers = l_tcp->numlayers;
+                p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32));
+				if(!p_j2k->cstr_info->numdecompos){
+					return OPJ_FALSE;
+				}
+                for     (i = 0; i < l_image->numcomps; ++i) {
+                        p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1;
+                }
+        }
+#endif
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_coc( opj_j2k_t *p_j2k,
+                                                OPJ_UINT32 p_comp_no,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 l_coc_size,l_remaining_size;
+        OPJ_UINT32 l_comp_room;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_comp_room = (p_j2k->m_private_image->numcomps <= 256) ? 1 : 2;
+
+        l_coc_size = 5 + l_comp_room + opj_j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
+
+        if (l_coc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data;
+                /*p_j2k->m_specific_param.m_encoder.m_header_tile_data
+                        = (OPJ_BYTE*)opj_realloc(
+                                p_j2k->m_specific_param.m_encoder.m_header_tile_data,
+                                l_coc_size);*/
+
+                new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_coc_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write COC marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_coc_size;
+        }
+
+        opj_j2k_write_coc_in_memory(p_j2k,p_comp_no,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&l_remaining_size,p_manager);
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_coc_size,p_manager) != l_coc_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_compare_coc(opj_j2k_t *p_j2k, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
+{
+	opj_cp_t *l_cp = NULL;
+	opj_tcp_t *l_tcp = NULL;
+	
+	/* preconditions */
+	assert(p_j2k != 00);
+	
+	l_cp = &(p_j2k->m_cp);
+	l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
+	
+	if (l_tcp->tccps[p_first_comp_no].csty != l_tcp->tccps[p_second_comp_no].csty) {
+		return OPJ_FALSE;
+	}
+	
+	
+	return opj_j2k_compare_SPCod_SPCoc(p_j2k, p_j2k->m_current_tile_number, p_first_comp_no, p_second_comp_no);
+}
+
+static void opj_j2k_write_coc_in_memory(   opj_j2k_t *p_j2k,
+                                                OPJ_UINT32 p_comp_no,
+                                                OPJ_BYTE * p_data,
+                                                OPJ_UINT32 * p_data_written,
+                                                opj_event_mgr_t * p_manager
+                                    )
+{
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        OPJ_UINT32 l_coc_size,l_remaining_size;
+        OPJ_BYTE * l_current_data = 00;
+        opj_image_t *l_image = 00;
+        OPJ_UINT32 l_comp_room;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
+        l_image = p_j2k->m_private_image;
+        l_comp_room = (l_image->numcomps <= 256) ? 1 : 2;
+
+        l_coc_size = 5 + l_comp_room + opj_j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
+        l_remaining_size = l_coc_size;
+
+        l_current_data = p_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_COC,2);                           /* COC */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_coc_size-2,2);                         /* L_COC */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,p_comp_no, l_comp_room);         /* Ccoc */
+        l_current_data+=l_comp_room;
+
+        opj_write_bytes(l_current_data, l_tcp->tccps[p_comp_no].csty, 1);               /* Scoc */
+        ++l_current_data;
+
+        l_remaining_size -= (5 + l_comp_room);
+        opj_j2k_write_SPCod_SPCoc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_size,p_manager);
+        * p_data_written = l_coc_size;
+}
+
+static OPJ_UINT32 opj_j2k_get_max_coc_size(opj_j2k_t *p_j2k)
+{
+        OPJ_UINT32 i,j;
+        OPJ_UINT32 l_nb_comp;
+        OPJ_UINT32 l_nb_tiles;
+        OPJ_UINT32 l_max = 0;
+
+        /* preconditions */
+
+        l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;
+        l_nb_comp = p_j2k->m_private_image->numcomps;
+
+        for (i=0;i<l_nb_tiles;++i) {
+                for (j=0;j<l_nb_comp;++j) {
+                        l_max = opj_uint_max(l_max,opj_j2k_get_SPCod_SPCoc_size(p_j2k,i,j));
+                }
+        }
+
+        return 6 + l_max;
+}
+
+/**
+ * Reads a COC marker (Coding Style Component)
+ * @param       p_header_data   the data contained in the COC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the COC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_coc (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        opj_cp_t *l_cp = NULL;
+        opj_tcp_t *l_tcp = NULL;
+        opj_image_t *l_image = NULL;
+        OPJ_UINT32 l_comp_room;
+        OPJ_UINT32 l_comp_no;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ) ? /*FIXME J2K_DEC_STATE_TPH*/
+                                &l_cp->tcps[p_j2k->m_current_tile_number] :
+                                p_j2k->m_specific_param.m_decoder.m_default_tcp;
+        l_image = p_j2k->m_private_image;
+
+        l_comp_room = l_image->numcomps <= 256 ? 1 : 2;
+
+        /* make sure room is sufficient*/
+        if (p_header_size < l_comp_room + 1) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
+                return OPJ_FALSE;
+        }
+        p_header_size -= l_comp_room + 1;
+
+        opj_read_bytes(p_header_data,&l_comp_no,l_comp_room);                   /* Ccoc */
+        p_header_data += l_comp_room;
+        if (l_comp_no >= l_image->numcomps) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker (bad number of components)\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,&l_tcp->tccps[l_comp_no].csty,1);                  /* Scoc */
+        ++p_header_data ;
+
+        if (! opj_j2k_read_SPCod_SPCoc(p_j2k,l_comp_no,p_header_data,&p_header_size,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (p_header_size != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading COC marker\n");
+                return OPJ_FALSE;
+        }
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_qcd(     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager
+                            )
+{
+        OPJ_UINT32 l_qcd_size,l_remaining_size;
+        OPJ_BYTE * l_current_data = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_qcd_size = 4 + opj_j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,0);
+        l_remaining_size = l_qcd_size;
+
+        if (l_qcd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_qcd_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write QCD marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcd_size;
+        }
+
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_QCD,2);           /* QCD */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_qcd_size-2,2);         /* L_QCD */
+        l_current_data += 2;
+
+        l_remaining_size -= 4;
+
+        if (! opj_j2k_write_SQcd_SQcc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_size,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error writing QCD marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (l_remaining_size != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error writing QCD marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (opj_stream_write_data(p_stream, p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_qcd_size,p_manager) != l_qcd_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a QCD marker (Quantization defaults)
+ * @param       p_header_data   the data contained in the QCD box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the QCD marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_qcd (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (! opj_j2k_read_SQcd_SQcc(p_j2k,0,p_header_data,&p_header_size,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading QCD marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (p_header_size != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading QCD marker\n");
+                return OPJ_FALSE;
+        }
+
+        /* Apply the quantization parameters to other components of the current tile or the m_default_tcp */
+        opj_j2k_copy_tile_quantization_parameters(p_j2k);
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_qcc(     opj_j2k_t *p_j2k,
+                                                OPJ_UINT32 p_comp_no,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager
+                            )
+{
+        OPJ_UINT32 l_qcc_size,l_remaining_size;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_qcc_size = 5 + opj_j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
+        l_qcc_size += p_j2k->m_private_image->numcomps <= 256 ? 0:1;
+        l_remaining_size = l_qcc_size;
+
+        if (l_qcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_qcc_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write QCC marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcc_size;
+        }
+
+        opj_j2k_write_qcc_in_memory(p_j2k,p_comp_no,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&l_remaining_size,p_manager);
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_qcc_size,p_manager) != l_qcc_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_compare_qcc(opj_j2k_t *p_j2k, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
+{
+	return opj_j2k_compare_SQcd_SQcc(p_j2k,p_j2k->m_current_tile_number,p_first_comp_no, p_second_comp_no);
+}
+
+static void opj_j2k_write_qcc_in_memory(   opj_j2k_t *p_j2k,
+                                                                OPJ_UINT32 p_comp_no,
+                                                                OPJ_BYTE * p_data,
+                                                                OPJ_UINT32 * p_data_written,
+                                                                opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 l_qcc_size,l_remaining_size;
+        OPJ_BYTE * l_current_data = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_qcc_size = 6 + opj_j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
+        l_remaining_size = l_qcc_size;
+
+        l_current_data = p_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_QCC,2);           /* QCC */
+        l_current_data += 2;
+
+        if (p_j2k->m_private_image->numcomps <= 256) {
+                --l_qcc_size;
+
+                opj_write_bytes(l_current_data,l_qcc_size-2,2);         /* L_QCC */
+                l_current_data += 2;
+
+                opj_write_bytes(l_current_data, p_comp_no, 1);  /* Cqcc */
+                ++l_current_data;
+
+                /* in the case only one byte is sufficient the last byte allocated is useless -> still do -6 for available */
+                l_remaining_size -= 6;
+        }
+        else {
+                opj_write_bytes(l_current_data,l_qcc_size-2,2);         /* L_QCC */
+                l_current_data += 2;
+
+                opj_write_bytes(l_current_data, p_comp_no, 2);  /* Cqcc */
+                l_current_data+=2;
+
+                l_remaining_size -= 6;
+        }
+
+        opj_j2k_write_SQcd_SQcc(p_j2k,p_j2k->m_current_tile_number,p_comp_no,l_current_data,&l_remaining_size,p_manager);
+
+        *p_data_written = l_qcc_size;
+}
+
+static OPJ_UINT32 opj_j2k_get_max_qcc_size (opj_j2k_t *p_j2k)
+{
+        return opj_j2k_get_max_coc_size(p_j2k);
+}
+
+/**
+ * Reads a QCC marker (Quantization component)
+ * @param       p_header_data   the data contained in the QCC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the QCC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_qcc(   opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 l_num_comp,l_comp_no;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_num_comp = p_j2k->m_private_image->numcomps;
+
+        if (l_num_comp <= 256) {
+                if (p_header_size < 1) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
+                        return OPJ_FALSE;
+                }
+                opj_read_bytes(p_header_data,&l_comp_no,1);
+                ++p_header_data;
+                --p_header_size;
+        }
+        else {
+                if (p_header_size < 2) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
+                        return OPJ_FALSE;
+                }
+                opj_read_bytes(p_header_data,&l_comp_no,2);
+                p_header_data+=2;
+                p_header_size-=2;
+        }
+
+#ifdef USE_JPWL
+        if (p_j2k->m_cp.correct) {
+
+                static OPJ_UINT32 backup_compno = 0;
+
+                /* compno is negative or larger than the number of components!!! */
+                if (/*(l_comp_no < 0) ||*/ (l_comp_no >= l_num_comp)) {
+                        opj_event_msg(p_manager, EVT_ERROR,
+                                "JPWL: bad component number in QCC (%d out of a maximum of %d)\n",
+                                l_comp_no, l_num_comp);
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                        /* we try to correct */
+                        l_comp_no = backup_compno % l_num_comp;
+                        opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n"
+                                "- setting component number to %d\n",
+                                l_comp_no);
+                }
+
+                /* keep your private count of tiles */
+                backup_compno++;
+        };
+#endif /* USE_JPWL */
+
+        if (l_comp_no >= p_j2k->m_private_image->numcomps) {
+                opj_event_msg(p_manager, EVT_ERROR,
+                              "Invalid component number: %d, regarding the number of components %d\n",
+                              l_comp_no, p_j2k->m_private_image->numcomps);
+                return OPJ_FALSE;
+        }
+
+        if (! opj_j2k_read_SQcd_SQcc(p_j2k,l_comp_no,p_header_data,&p_header_size,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
+                return OPJ_FALSE;
+        }
+
+        if (p_header_size != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading QCC marker\n");
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_poc(     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager
+                            )
+{
+        OPJ_UINT32 l_nb_comp;
+        OPJ_UINT32 l_nb_poc;
+        OPJ_UINT32 l_poc_size;
+        OPJ_UINT32 l_written_size = 0;
+        opj_tcp_t *l_tcp = 00;
+        OPJ_UINT32 l_poc_room;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number];
+        l_nb_comp = p_j2k->m_private_image->numcomps;
+        l_nb_poc = 1 + l_tcp->numpocs;
+
+        if (l_nb_comp <= 256) {
+                l_poc_room = 1;
+        }
+        else {
+                l_poc_room = 2;
+        }
+        l_poc_size = 4 + (5 + 2 * l_poc_room) * l_nb_poc;
+
+        if (l_poc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_poc_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write POC marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_poc_size;
+        }
+
+        opj_j2k_write_poc_in_memory(p_j2k,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&l_written_size,p_manager);
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_poc_size,p_manager) != l_poc_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static void opj_j2k_write_poc_in_memory(   opj_j2k_t *p_j2k,
+                                                                OPJ_BYTE * p_data,
+                                                                OPJ_UINT32 * p_data_written,
+                                                                opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 i;
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_UINT32 l_nb_comp;
+        OPJ_UINT32 l_nb_poc;
+        OPJ_UINT32 l_poc_size;
+        opj_image_t *l_image = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_tccp_t *l_tccp = 00;
+        opj_poc_t *l_current_poc = 00;
+        OPJ_UINT32 l_poc_room;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number];
+        l_tccp = &l_tcp->tccps[0];
+        l_image = p_j2k->m_private_image;
+        l_nb_comp = l_image->numcomps;
+        l_nb_poc = 1 + l_tcp->numpocs;
+
+        if (l_nb_comp <= 256) {
+                l_poc_room = 1;
+        }
+        else {
+                l_poc_room = 2;
+        }
+
+        l_poc_size = 4 + (5 + 2 * l_poc_room) * l_nb_poc;
+
+        l_current_data = p_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_POC,2);                                   /* POC  */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_poc_size-2,2);                                 /* Lpoc */
+        l_current_data += 2;
+
+        l_current_poc =  l_tcp->pocs;
+        for (i = 0; i < l_nb_poc; ++i) {
+                opj_write_bytes(l_current_data,l_current_poc->resno0,1);                                /* RSpoc_i */
+                ++l_current_data;
+
+                opj_write_bytes(l_current_data,l_current_poc->compno0,l_poc_room);              /* CSpoc_i */
+                l_current_data+=l_poc_room;
+
+                opj_write_bytes(l_current_data,l_current_poc->layno1,2);                                /* LYEpoc_i */
+                l_current_data+=2;
+
+                opj_write_bytes(l_current_data,l_current_poc->resno1,1);                                /* REpoc_i */
+                ++l_current_data;
+
+                opj_write_bytes(l_current_data,l_current_poc->compno1,l_poc_room);              /* CEpoc_i */
+                l_current_data+=l_poc_room;
+
+                opj_write_bytes(l_current_data, (OPJ_UINT32)l_current_poc->prg,1);    /* Ppoc_i */
+                ++l_current_data;
+
+                /* change the value of the max layer according to the actual number of layers in the file, components and resolutions*/
+                l_current_poc->layno1 = (OPJ_UINT32)opj_int_min((OPJ_INT32)l_current_poc->layno1, (OPJ_INT32)l_tcp->numlayers);
+                l_current_poc->resno1 = (OPJ_UINT32)opj_int_min((OPJ_INT32)l_current_poc->resno1, (OPJ_INT32)l_tccp->numresolutions);
+                l_current_poc->compno1 = (OPJ_UINT32)opj_int_min((OPJ_INT32)l_current_poc->compno1, (OPJ_INT32)l_nb_comp);
+
+                ++l_current_poc;
+        }
+
+        *p_data_written = l_poc_size;
+}
+
+static OPJ_UINT32 opj_j2k_get_max_poc_size(opj_j2k_t *p_j2k)
+{
+        opj_tcp_t * l_tcp = 00;
+        OPJ_UINT32 l_nb_tiles = 0;
+        OPJ_UINT32 l_max_poc = 0;
+        OPJ_UINT32 i;
+
+        l_tcp = p_j2k->m_cp.tcps;
+        l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
+
+        for (i=0;i<l_nb_tiles;++i) {
+                l_max_poc = opj_uint_max(l_max_poc,l_tcp->numpocs);
+                ++l_tcp;
+        }
+
+        ++l_max_poc;
+
+        return 4 + 9 * l_max_poc;
+}
+
+static OPJ_UINT32 opj_j2k_get_max_toc_size (opj_j2k_t *p_j2k)
+{
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_nb_tiles;
+        OPJ_UINT32 l_max = 0;
+        opj_tcp_t * l_tcp = 00;
+
+        l_tcp = p_j2k->m_cp.tcps;
+        l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;
+
+        for (i=0;i<l_nb_tiles;++i) {
+                l_max = opj_uint_max(l_max,l_tcp->m_nb_tile_parts);
+
+                ++l_tcp;
+        }
+
+        return 12 * l_max;
+}
+
+static OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k)
+{
+        OPJ_UINT32 l_nb_bytes = 0;
+        OPJ_UINT32 l_nb_comps;
+        OPJ_UINT32 l_coc_bytes,l_qcc_bytes;
+
+        l_nb_comps = p_j2k->m_private_image->numcomps - 1;
+        l_nb_bytes += opj_j2k_get_max_toc_size(p_j2k);
+
+        if (!(OPJ_IS_CINEMA(p_j2k->m_cp.rsiz))) {
+                l_coc_bytes = opj_j2k_get_max_coc_size(p_j2k);
+                l_nb_bytes += l_nb_comps * l_coc_bytes;
+
+                l_qcc_bytes = opj_j2k_get_max_qcc_size(p_j2k);
+                l_nb_bytes += l_nb_comps * l_qcc_bytes;
+        }
+
+        l_nb_bytes += opj_j2k_get_max_poc_size(p_j2k);
+
+        /*** DEVELOPER CORNER, Add room for your headers ***/
+
+        return l_nb_bytes;
+}
+
+/**
+ * Reads a POC marker (Progression Order Change)
+ *
+ * @param       p_header_data   the data contained in the POC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the POC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_poc (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 i, l_nb_comp, l_tmp;
+        opj_image_t * l_image = 00;
+        OPJ_UINT32 l_old_poc_nb, l_current_poc_nb, l_current_poc_remaining;
+        OPJ_UINT32 l_chunk_size, l_comp_room;
+
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_poc_t *l_current_poc = 00;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_image = p_j2k->m_private_image;
+        l_nb_comp = l_image->numcomps;
+        if (l_nb_comp <= 256) {
+                l_comp_room = 1;
+        }
+        else {
+                l_comp_room = 2;
+        }
+        l_chunk_size = 5 + 2 * l_comp_room;
+        l_current_poc_nb = p_header_size / l_chunk_size;
+        l_current_poc_remaining = p_header_size % l_chunk_size;
+
+        if ((l_current_poc_nb <= 0) || (l_current_poc_remaining != 0)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading POC marker\n");
+                return OPJ_FALSE;
+        }
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
+                                &l_cp->tcps[p_j2k->m_current_tile_number] :
+                                p_j2k->m_specific_param.m_decoder.m_default_tcp;
+        l_old_poc_nb = l_tcp->POC ? l_tcp->numpocs + 1 : 0;
+        l_current_poc_nb += l_old_poc_nb;
+
+        if(l_current_poc_nb >= 32)
+          {
+          opj_event_msg(p_manager, EVT_ERROR, "Too many POCs %d\n", l_current_poc_nb);
+          return OPJ_FALSE;
+          }
+        assert(l_current_poc_nb < 32);
+
+        /* now poc is in use.*/
+        l_tcp->POC = 1;
+
+        l_current_poc = &l_tcp->pocs[l_old_poc_nb];
+        for     (i = l_old_poc_nb; i < l_current_poc_nb; ++i) {
+                opj_read_bytes(p_header_data,&(l_current_poc->resno0),1);                               /* RSpoc_i */
+                ++p_header_data;
+                opj_read_bytes(p_header_data,&(l_current_poc->compno0),l_comp_room);    /* CSpoc_i */
+                p_header_data+=l_comp_room;
+                opj_read_bytes(p_header_data,&(l_current_poc->layno1),2);                               /* LYEpoc_i */
+                /* make sure layer end is in acceptable bounds */
+                l_current_poc->layno1 = opj_uint_min(l_current_poc->layno1, l_tcp->numlayers);
+                p_header_data+=2;
+                opj_read_bytes(p_header_data,&(l_current_poc->resno1),1);                               /* REpoc_i */
+                ++p_header_data;
+                opj_read_bytes(p_header_data,&(l_current_poc->compno1),l_comp_room);    /* CEpoc_i */
+                p_header_data+=l_comp_room;
+                opj_read_bytes(p_header_data,&l_tmp,1);                                                                 /* Ppoc_i */
+                ++p_header_data;
+                l_current_poc->prg = (OPJ_PROG_ORDER) l_tmp;
+                /* make sure comp is in acceptable bounds */
+                l_current_poc->compno1 = opj_uint_min(l_current_poc->compno1, l_nb_comp);
+                ++l_current_poc;
+        }
+
+        l_tcp->numpocs = l_current_poc_nb - 1;
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a CRG marker (Component registration)
+ *
+ * @param       p_header_data   the data contained in the TLM box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the TLM marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_crg (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 l_nb_comp;
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_nb_comp = p_j2k->m_private_image->numcomps;
+
+        if (p_header_size != l_nb_comp *4) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading CRG marker\n");
+                return OPJ_FALSE;
+        }
+        /* Do not care of this at the moment since only local variables are set here */
+        /*
+        for
+                (i = 0; i < l_nb_comp; ++i)
+        {
+                opj_read_bytes(p_header_data,&l_Xcrg_i,2);                              // Xcrg_i
+                p_header_data+=2;
+                opj_read_bytes(p_header_data,&l_Ycrg_i,2);                              // Xcrg_i
+                p_header_data+=2;
+        }
+        */
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a TLM marker (Tile Length Marker)
+ *
+ * @param       p_header_data   the data contained in the TLM box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the TLM marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_tlm (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 l_Ztlm, l_Stlm, l_ST, l_SP, l_tot_num_tp_remaining, l_quotient, l_Ptlm_size;
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (p_header_size < 2) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading TLM marker\n");
+                return OPJ_FALSE;
+        }
+        p_header_size -= 2;
+
+        opj_read_bytes(p_header_data,&l_Ztlm,1);                                /* Ztlm */
+        ++p_header_data;
+        opj_read_bytes(p_header_data,&l_Stlm,1);                                /* Stlm */
+        ++p_header_data;
+
+        l_ST = ((l_Stlm >> 4) & 0x3);
+        l_SP = (l_Stlm >> 6) & 0x1;
+
+        l_Ptlm_size = (l_SP + 1) * 2;
+        l_quotient = l_Ptlm_size + l_ST;
+
+        l_tot_num_tp_remaining = p_header_size % l_quotient;
+
+        if (l_tot_num_tp_remaining != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading TLM marker\n");
+                return OPJ_FALSE;
+        }
+        /* FIXME Do not care of this at the moment since only local variables are set here */
+        /*
+        for
+                (i = 0; i < l_tot_num_tp; ++i)
+        {
+                opj_read_bytes(p_header_data,&l_Ttlm_i,l_ST);                           // Ttlm_i
+                p_header_data += l_ST;
+                opj_read_bytes(p_header_data,&l_Ptlm_i,l_Ptlm_size);            // Ptlm_i
+                p_header_data += l_Ptlm_size;
+        }*/
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a PLM marker (Packet length, main header marker)
+ *
+ * @param       p_header_data   the data contained in the TLM box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the TLM marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_plm (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (p_header_size < 1) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
+                return OPJ_FALSE;
+        }
+        /* Do not care of this at the moment since only local variables are set here */
+        /*
+        opj_read_bytes(p_header_data,&l_Zplm,1);                                        // Zplm
+        ++p_header_data;
+        --p_header_size;
+
+        while
+                (p_header_size > 0)
+        {
+                opj_read_bytes(p_header_data,&l_Nplm,1);                                // Nplm
+                ++p_header_data;
+                p_header_size -= (1+l_Nplm);
+                if
+                        (p_header_size < 0)
+                {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
+                        return false;
+                }
+                for
+                        (i = 0; i < l_Nplm; ++i)
+                {
+                        opj_read_bytes(p_header_data,&l_tmp,1);                         // Iplm_ij
+                        ++p_header_data;
+                        // take only the last seven bytes
+                        l_packet_len |= (l_tmp & 0x7f);
+                        if
+                                (l_tmp & 0x80)
+                        {
+                                l_packet_len <<= 7;
+                        }
+                        else
+                        {
+                // store packet length and proceed to next packet
+                                l_packet_len = 0;
+                        }
+                }
+                if
+                        (l_packet_len != 0)
+                {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading PLM marker\n");
+                        return false;
+                }
+        }
+        */
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a PLT marker (Packet length, tile-part header)
+ *
+ * @param       p_header_data   the data contained in the PLT box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the PLT marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_plt (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 l_Zplt, l_tmp, l_packet_len = 0, i;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (p_header_size < 1) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading PLT marker\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,&l_Zplt,1);                /* Zplt */
+        ++p_header_data;
+        --p_header_size;
+
+        for (i = 0; i < p_header_size; ++i) {
+                opj_read_bytes(p_header_data,&l_tmp,1);         /* Iplt_ij */
+                ++p_header_data;
+                /* take only the last seven bytes */
+                l_packet_len |= (l_tmp & 0x7f);
+                if (l_tmp & 0x80) {
+                        l_packet_len <<= 7;
+                }
+                else {
+            /* store packet length and proceed to next packet */
+                        l_packet_len = 0;
+                }
+        }
+
+        if (l_packet_len != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading PLT marker\n");
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a PPM marker (Packed packet headers, main header)
+ *
+ * @param       p_header_data   the data contained in the POC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the POC marker.
+ * @param       p_manager               the user event manager.
+ */
+
+static OPJ_BOOL opj_j2k_read_ppm (
+																	opj_j2k_t *p_j2k,
+																	OPJ_BYTE * p_header_data,
+																	OPJ_UINT32 p_header_size,
+																	opj_event_mgr_t * p_manager )
+{
+	opj_cp_t *l_cp = 00;
+	OPJ_UINT32 l_Z_ppm;
+	
+	/* preconditions */
+	assert(p_header_data != 00);
+	assert(p_j2k != 00);
+	assert(p_manager != 00);
+	
+	/* We need to have the Z_ppm element + 1 byte of Nppm/Ippm at minimum */
+	if (p_header_size < 2) {
+		opj_event_msg(p_manager, EVT_ERROR, "Error reading PPM marker\n");
+		return OPJ_FALSE;
+	}
+	
+	l_cp = &(p_j2k->m_cp);
+	l_cp->ppm = 1;
+	
+	opj_read_bytes(p_header_data,&l_Z_ppm,1);               /* Z_ppm */
+	++p_header_data;
+	--p_header_size;
+	
+	/* check allocation needed */
+	if (l_cp->ppm_markers == NULL) { /* first PPM marker */
+		OPJ_UINT32 l_newCount = l_Z_ppm + 1U; /* can't overflow, l_Z_ppm is UINT8 */
+		assert(l_cp->ppm_markers_count == 0U);
+		
+		l_cp->ppm_markers = (opj_ppx *) opj_calloc(l_newCount, sizeof(opj_ppx));
+		if (l_cp->ppm_markers == NULL) {
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
+			return OPJ_FALSE;
+		}
+		l_cp->ppm_markers_count = l_newCount;
+	} else if (l_cp->ppm_markers_count <= l_Z_ppm) {
+		OPJ_UINT32 l_newCount = l_Z_ppm + 1U; /* can't overflow, l_Z_ppm is UINT8 */
+		opj_ppx *new_ppm_markers;
+		new_ppm_markers = (opj_ppx *) opj_realloc(l_cp->ppm_markers, l_newCount * sizeof(opj_ppx));
+		if (new_ppm_markers == NULL) {
+			/* clean up to be done on l_cp destruction */
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
+			return OPJ_FALSE;
+		}
+		l_cp->ppm_markers = new_ppm_markers;
+		memset(l_cp->ppm_markers + l_cp->ppm_markers_count, 0, (l_newCount - l_cp->ppm_markers_count) * sizeof(opj_ppx));
+		l_cp->ppm_markers_count = l_newCount;
+	}
+	
+	if (l_cp->ppm_markers[l_Z_ppm].m_data != NULL) {
+		/* clean up to be done on l_cp destruction */
+		opj_event_msg(p_manager, EVT_ERROR, "Zppm %u already read\n", l_Z_ppm);
+		return OPJ_FALSE;
+	}
+	
+	l_cp->ppm_markers[l_Z_ppm].m_data = (OPJ_BYTE *) opj_malloc(p_header_size);
+	if (l_cp->ppm_markers[l_Z_ppm].m_data == NULL) {
+		/* clean up to be done on l_cp destruction */
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
+		return OPJ_FALSE;
+	}
+	l_cp->ppm_markers[l_Z_ppm].m_data_size = p_header_size;
+	memcpy(l_cp->ppm_markers[l_Z_ppm].m_data, p_header_data, p_header_size);
+
+	return OPJ_TRUE;
+}
+
+/**
+ * Merges all PPM markers read (Packed headers, main header)
+ *
+ * @param       p_cp      main coding parameters.
+ * @param       p_manager the user event manager.
+ */
+static OPJ_BOOL opj_j2k_merge_ppm ( opj_cp_t *p_cp, opj_event_mgr_t * p_manager )
+{
+	OPJ_UINT32 i, l_ppm_data_size, l_N_ppm_remaining;
+	
+	/* preconditions */
+	assert(p_cp != 00);
+	assert(p_manager != 00);
+	assert(p_cp->ppm_buffer == NULL);
+	
+	if (p_cp->ppm == 0U) {
+		return OPJ_TRUE;
+	}
+	
+	l_ppm_data_size = 0U;
+	l_N_ppm_remaining = 0U;
+	for (i = 0U; i < p_cp->ppm_markers_count; ++i) {
+		if (p_cp->ppm_markers[i].m_data != NULL) { /* standard doesn't seem to require contiguous Zppm */
+			OPJ_UINT32 l_N_ppm;
+			OPJ_UINT32 l_data_size = p_cp->ppm_markers[i].m_data_size;
+			const OPJ_BYTE* l_data = p_cp->ppm_markers[i].m_data;
+			
+			if (l_N_ppm_remaining >= l_data_size) {
+				l_N_ppm_remaining -= l_data_size;
+				l_data_size = 0U;
+			} else {
+				l_data += l_N_ppm_remaining;
+				l_data_size -= l_N_ppm_remaining;
+				l_N_ppm_remaining = 0U;
+			}
+			
+			if (l_data_size > 0U) {
+				do
+				{
+					/* read Nppm */
+					if (l_data_size < 4U) {
+						/* clean up to be done on l_cp destruction */
+						opj_event_msg(p_manager, EVT_ERROR, "Not enough bytes to read Nppm\n");
+						return OPJ_FALSE;
+					}
+					opj_read_bytes(l_data, &l_N_ppm, 4);
+					l_data+=4;
+					l_data_size-=4;
+					l_ppm_data_size += l_N_ppm; /* can't overflow, max 256 markers of max 65536 bytes, that is when PPM markers are not corrupted which is checked elsewhere */
+					
+					if (l_data_size >= l_N_ppm) {
+						l_data_size -= l_N_ppm;
+						l_data += l_N_ppm;
+					} else {
+						l_N_ppm_remaining = l_N_ppm - l_data_size;
+						l_data_size = 0U;
+					}
+				} while (l_data_size > 0U);
+			}
+		}
+	}
+	
+	if (l_N_ppm_remaining != 0U) {
+		/* clean up to be done on l_cp destruction */
+		opj_event_msg(p_manager, EVT_ERROR, "Corrupted PPM markers\n");
+		return OPJ_FALSE;
+	}
+	
+	p_cp->ppm_buffer = (OPJ_BYTE *) opj_malloc(l_ppm_data_size);
+	if (p_cp->ppm_buffer == 00) {
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n");
+		return OPJ_FALSE;
+	}
+	p_cp->ppm_len = l_ppm_data_size;
+	l_ppm_data_size = 0U;
+	l_N_ppm_remaining = 0U;
+	for (i = 0U; i < p_cp->ppm_markers_count; ++i) {
+		if (p_cp->ppm_markers[i].m_data != NULL) { /* standard doesn't seem to require contiguous Zppm */
+			OPJ_UINT32 l_N_ppm;
+			OPJ_UINT32 l_data_size = p_cp->ppm_markers[i].m_data_size;
+			const OPJ_BYTE* l_data = p_cp->ppm_markers[i].m_data;
+			
+			if (l_N_ppm_remaining >= l_data_size) {
+				memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_data_size);
+				l_ppm_data_size += l_data_size;
+				l_N_ppm_remaining -= l_data_size;
+				l_data_size = 0U;
+			} else {
+				memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_N_ppm_remaining);
+				l_ppm_data_size += l_N_ppm_remaining;
+				l_data += l_N_ppm_remaining;
+				l_data_size -= l_N_ppm_remaining;
+				l_N_ppm_remaining = 0U;
+			}
+
+			if (l_data_size > 0U) {
+				do
+				{
+					/* read Nppm */
+					if (l_data_size < 4U) {
+						/* clean up to be done on l_cp destruction */
+						opj_event_msg(p_manager, EVT_ERROR, "Not enough bytes to read Nppm\n");
+						return OPJ_FALSE;
+					}
+					opj_read_bytes(l_data, &l_N_ppm, 4);
+					l_data+=4;
+					l_data_size-=4;
+					
+					if (l_data_size >= l_N_ppm) {
+						memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_N_ppm);
+						l_ppm_data_size += l_N_ppm;
+						l_data_size -= l_N_ppm;
+						l_data += l_N_ppm;
+					} else {
+						memcpy(p_cp->ppm_buffer + l_ppm_data_size, l_data, l_data_size);
+						l_ppm_data_size += l_data_size;
+						l_N_ppm_remaining = l_N_ppm - l_data_size;
+						l_data_size = 0U;
+					}
+				} while (l_data_size > 0U);
+			}
+			opj_free(p_cp->ppm_markers[i].m_data);
+			p_cp->ppm_markers[i].m_data = NULL;
+			p_cp->ppm_markers[i].m_data_size = 0U;
+		}
+	}
+	
+	p_cp->ppm_data = p_cp->ppm_buffer;
+	p_cp->ppm_data_size = p_cp->ppm_len;
+	
+	p_cp->ppm_markers_count = 0U;
+	opj_free(p_cp->ppm_markers);
+	p_cp->ppm_markers = NULL;
+	
+	return OPJ_TRUE;
+}
+
+/**
+ * Reads a PPT marker (Packed packet headers, tile-part header)
+ *
+ * @param       p_header_data   the data contained in the PPT box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the PPT marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_ppt (  opj_j2k_t *p_j2k,
+                                    OPJ_BYTE * p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+	opj_cp_t *l_cp = 00;
+	opj_tcp_t *l_tcp = 00;
+	OPJ_UINT32 l_Z_ppt;
+
+	/* preconditions */
+	assert(p_header_data != 00);
+	assert(p_j2k != 00);
+	assert(p_manager != 00);
+
+	/* We need to have the Z_ppt element + 1 byte of Ippt at minimum */
+	if (p_header_size < 2) {
+		opj_event_msg(p_manager, EVT_ERROR, "Error reading PPT marker\n");
+		return OPJ_FALSE;
+	}
+
+	l_cp = &(p_j2k->m_cp);
+	if (l_cp->ppm){
+		opj_event_msg(p_manager, EVT_ERROR, "Error reading PPT marker: packet header have been previously found in the main header (PPM marker).\n");
+		return OPJ_FALSE;
+	}
+
+	l_tcp = &(l_cp->tcps[p_j2k->m_current_tile_number]);
+	l_tcp->ppt = 1;
+
+	opj_read_bytes(p_header_data,&l_Z_ppt,1);               /* Z_ppt */
+	++p_header_data;
+	--p_header_size;
+	
+	/* check allocation needed */
+	if (l_tcp->ppt_markers == NULL) { /* first PPT marker */
+		OPJ_UINT32 l_newCount = l_Z_ppt + 1U; /* can't overflow, l_Z_ppt is UINT8 */
+		assert(l_tcp->ppt_markers_count == 0U);
+		
+		l_tcp->ppt_markers = (opj_ppx *) opj_calloc(l_newCount, sizeof(opj_ppx));
+		if (l_tcp->ppt_markers == NULL) {
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
+			return OPJ_FALSE;
+		}
+		l_tcp->ppt_markers_count = l_newCount;
+	} else if (l_tcp->ppt_markers_count <= l_Z_ppt) {
+		OPJ_UINT32 l_newCount = l_Z_ppt + 1U; /* can't overflow, l_Z_ppt is UINT8 */
+		opj_ppx *new_ppt_markers;
+		new_ppt_markers = (opj_ppx *) opj_realloc(l_tcp->ppt_markers, l_newCount * sizeof(opj_ppx));
+		if (new_ppt_markers == NULL) {
+			/* clean up to be done on l_tcp destruction */
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
+			return OPJ_FALSE;
+		}
+		l_tcp->ppt_markers = new_ppt_markers;
+		memset(l_tcp->ppt_markers + l_tcp->ppt_markers_count, 0, (l_newCount - l_tcp->ppt_markers_count) * sizeof(opj_ppx));
+		l_tcp->ppt_markers_count = l_newCount;
+	}
+	
+	if (l_tcp->ppt_markers[l_Z_ppt].m_data != NULL) {
+		/* clean up to be done on l_tcp destruction */
+		opj_event_msg(p_manager, EVT_ERROR, "Zppt %u already read\n", l_Z_ppt);
+		return OPJ_FALSE;
+	}
+	
+	l_tcp->ppt_markers[l_Z_ppt].m_data = (OPJ_BYTE *) opj_malloc(p_header_size);
+	if (l_tcp->ppt_markers[l_Z_ppt].m_data == NULL) {
+		/* clean up to be done on l_tcp destruction */
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
+		return OPJ_FALSE;
+	}
+	l_tcp->ppt_markers[l_Z_ppt].m_data_size = p_header_size;
+	memcpy(l_tcp->ppt_markers[l_Z_ppt].m_data, p_header_data, p_header_size);
+	return OPJ_TRUE;
+}
+
+/**
+ * Merges all PPT markers read (Packed packet headers, tile-part header)
+ *
+ * @param       p_tcp   the tile.
+ * @param       p_manager               the user event manager.
+ */
+static OPJ_BOOL opj_j2k_merge_ppt(opj_tcp_t *p_tcp, opj_event_mgr_t * p_manager)
+{
+	OPJ_UINT32 i, l_ppt_data_size;
+	/* preconditions */
+	assert(p_tcp != 00);
+	assert(p_manager != 00);
+	assert(p_tcp->ppt_buffer == NULL);
+	
+	if (p_tcp->ppt == 0U) {
+		return OPJ_TRUE;
+	}
+	
+	l_ppt_data_size = 0U;
+	for (i = 0U; i < p_tcp->ppt_markers_count; ++i) {
+		l_ppt_data_size += p_tcp->ppt_markers[i].m_data_size; /* can't overflow, max 256 markers of max 65536 bytes */
+	}
+	
+	p_tcp->ppt_buffer = (OPJ_BYTE *) opj_malloc(l_ppt_data_size);
+	if (p_tcp->ppt_buffer == 00) {
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n");
+		return OPJ_FALSE;
+	}
+	p_tcp->ppt_len = l_ppt_data_size;
+	l_ppt_data_size = 0U;
+	for (i = 0U; i < p_tcp->ppt_markers_count; ++i) {
+		if (p_tcp->ppt_markers[i].m_data != NULL) { /* standard doesn't seem to require contiguous Zppt */
+			memcpy(p_tcp->ppt_buffer + l_ppt_data_size, p_tcp->ppt_markers[i].m_data, p_tcp->ppt_markers[i].m_data_size);
+			l_ppt_data_size += p_tcp->ppt_markers[i].m_data_size; /* can't overflow, max 256 markers of max 65536 bytes */
+			
+			opj_free(p_tcp->ppt_markers[i].m_data);
+			p_tcp->ppt_markers[i].m_data = NULL;
+			p_tcp->ppt_markers[i].m_data_size = 0U;
+		}
+	}
+	
+	p_tcp->ppt_markers_count = 0U;
+	opj_free(p_tcp->ppt_markers);
+	p_tcp->ppt_markers = NULL;
+	
+	p_tcp->ppt_data = p_tcp->ppt_buffer;
+	p_tcp->ppt_data_size = p_tcp->ppt_len;
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_tlm(     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager
+                            )
+{
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_UINT32 l_tlm_size;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_tlm_size = 6 + (5*p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
+
+        if (l_tlm_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_tlm_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write TLM marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_tlm_size;
+        }
+
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        /* change the way data is written to avoid seeking if possible */
+        /* TODO */
+        p_j2k->m_specific_param.m_encoder.m_tlm_start = opj_stream_tell(p_stream);
+
+        opj_write_bytes(l_current_data,J2K_MS_TLM,2);                                   /* TLM */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_tlm_size-2,2);                                 /* Lpoc */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,0,1);                                                    /* Ztlm=0*/
+        ++l_current_data;
+
+        opj_write_bytes(l_current_data,0x50,1);                                                 /* Stlm ST=1(8bits-255 tiles max),SP=1(Ptlm=32bits) */
+        ++l_current_data;
+
+        /* do nothing on the 5 * l_j2k->m_specific_param.m_encoder.m_total_tile_parts remaining data */
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_tlm_size,p_manager) != l_tlm_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_sot(     opj_j2k_t *p_j2k,
+                                                        OPJ_BYTE * p_data,
+                                                        OPJ_UINT32 * p_data_written,
+                                                        const opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager
+                            )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        opj_write_bytes(p_data,J2K_MS_SOT,2);                                   /* SOT */
+        p_data += 2;
+
+        opj_write_bytes(p_data,10,2);                                                   /* Lsot */
+        p_data += 2;
+
+        opj_write_bytes(p_data, p_j2k->m_current_tile_number,2);                        /* Isot */
+        p_data += 2;
+
+        /* Psot  */
+        p_data += 4;
+
+        opj_write_bytes(p_data, p_j2k->m_specific_param.m_encoder.m_current_tile_part_number,1);                        /* TPsot */
+        ++p_data;
+
+        opj_write_bytes(p_data, p_j2k->m_cp.tcps[p_j2k->m_current_tile_number].m_nb_tile_parts,1);                      /* TNsot */
+        ++p_data;
+
+        /* UniPG>> */
+#ifdef USE_JPWL
+        /* update markers struct */
+/*
+        OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOT, p_j2k->sot_start, len + 2);
+*/
+  assert( 0 && "TODO" );
+#endif /* USE_JPWL */
+
+        * p_data_written = 12;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_get_sot_values(OPJ_BYTE *  p_header_data,
+																			 OPJ_UINT32  p_header_size,
+																			 OPJ_UINT32* p_tile_no,
+																			 OPJ_UINT32* p_tot_len,
+																			 OPJ_UINT32* p_current_part,
+																			 OPJ_UINT32* p_num_parts,
+																			 opj_event_mgr_t * p_manager )
+{
+	/* preconditions */
+	assert(p_header_data != 00);
+	assert(p_manager != 00);
+	
+	/* Size of this marker is fixed = 12 (we have already read marker and its size)*/
+	if (p_header_size != 8) {
+		opj_event_msg(p_manager, EVT_ERROR, "Error reading SOT marker\n");
+		return OPJ_FALSE;
+	}
+	
+	opj_read_bytes(p_header_data,p_tile_no,2);      /* Isot */
+	p_header_data+=2;
+	opj_read_bytes(p_header_data,p_tot_len,4);      /* Psot */
+	p_header_data+=4;
+	opj_read_bytes(p_header_data,p_current_part,1); /* TPsot */
+	++p_header_data;
+	opj_read_bytes(p_header_data,p_num_parts ,1);   /* TNsot */
+	++p_header_data;
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k,
+                            OPJ_BYTE * p_header_data,
+                            OPJ_UINT32 p_header_size,
+                            opj_event_mgr_t * p_manager )
+{
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        OPJ_UINT32 l_tot_len, l_num_parts = 0;
+        OPJ_UINT32 l_current_part;
+        OPJ_UINT32 l_tile_x,l_tile_y;
+
+        /* preconditions */
+	
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+	
+        if (! opj_j2k_get_sot_values(p_header_data, p_header_size, &(p_j2k->m_current_tile_number), &l_tot_len, &l_current_part, &l_num_parts, p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading SOT marker\n");
+                return OPJ_FALSE;
+        }
+
+        l_cp = &(p_j2k->m_cp);
+
+        /* testcase 2.pdf.SIGFPE.706.1112 */
+        if (p_j2k->m_current_tile_number >= l_cp->tw * l_cp->th) {
+                opj_event_msg(p_manager, EVT_ERROR, "Invalid tile number %d\n", p_j2k->m_current_tile_number);
+                return OPJ_FALSE;
+        }
+
+        l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
+        l_tile_x = p_j2k->m_current_tile_number % l_cp->tw;
+        l_tile_y = p_j2k->m_current_tile_number / l_cp->tw;
+
+#ifdef USE_JPWL
+        if (l_cp->correct) {
+
+                OPJ_UINT32 tileno = p_j2k->m_current_tile_number;
+                static OPJ_UINT32 backup_tileno = 0;
+
+                /* tileno is negative or larger than the number of tiles!!! */
+                if (tileno > (l_cp->tw * l_cp->th)) {
+                        opj_event_msg(p_manager, EVT_ERROR,
+                                        "JPWL: bad tile number (%d out of a maximum of %d)\n",
+                                        tileno, (l_cp->tw * l_cp->th));
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                        /* we try to correct */
+                        tileno = backup_tileno;
+                        opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n"
+                                        "- setting tile number to %d\n",
+                                        tileno);
+                }
+
+                /* keep your private count of tiles */
+                backup_tileno++;
+        };
+#endif /* USE_JPWL */
+
+        /* look for the tile in the list of already processed tile (in parts). */
+        /* Optimization possible here with a more complex data structure and with the removing of tiles */
+        /* since the time taken by this function can only grow at the time */
+
+        /* PSot should be equal to zero or >=14 or <= 2^32-1 */
+        if ((l_tot_len !=0 ) && (l_tot_len < 14) )
+        {
+            if (l_tot_len == 12 ) /* MSD: Special case for the PHR data which are read by kakadu*/
+            {
+                opj_event_msg(p_manager, EVT_WARNING, "Empty SOT marker detected: Psot=%d.\n", l_tot_len);
+            }
+            else
+            {
+                opj_event_msg(p_manager, EVT_ERROR, "Psot value is not correct regards to the JPEG2000 norm: %d.\n", l_tot_len);
+                return OPJ_FALSE;
+            }
+        }
+
+#ifdef USE_JPWL
+        if (l_cp->correct) {
+
+                /* totlen is negative or larger than the bytes left!!! */
+                if (/*(l_tot_len < 0) ||*/ (l_tot_len > p_header_size ) ) { /* FIXME it seems correct; for info in V1 -> (p_stream_numbytesleft(p_stream) + 8))) { */
+                        opj_event_msg(p_manager, EVT_ERROR,
+                                        "JPWL: bad tile byte size (%d bytes against %d bytes left)\n",
+                                        l_tot_len, p_header_size ); /* FIXME it seems correct; for info in V1 -> p_stream_numbytesleft(p_stream) + 8); */
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                        /* we try to correct */
+                        l_tot_len = 0;
+                        opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust this\n"
+                                        "- setting Psot to %d => assuming it is the last tile\n",
+                                        l_tot_len);
+                }
+                };
+#endif /* USE_JPWL */
+
+                /* Ref A.4.2: Psot could be equal zero if it is the last tile-part of the codestream.*/
+                if (!l_tot_len) {
+                        opj_event_msg(p_manager, EVT_INFO, "Psot value of the current tile-part is equal to zero, "
+                                        "we assuming it is the last tile-part of the codestream.\n");
+                        p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
+                }
+
+                if (l_num_parts != 0) { /* Number of tile-part header is provided by this tile-part header */
+                        l_num_parts += p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction;
+                        /* Useful to manage the case of textGBR.jp2 file because two values of TNSot are allowed: the correct numbers of
+                         * tile-parts for that tile and zero (A.4.2 of 15444-1 : 2002). */
+                        if (l_tcp->m_nb_tile_parts) {
+                                if (l_current_part >= l_tcp->m_nb_tile_parts){
+                                        opj_event_msg(p_manager, EVT_ERROR, "In SOT marker, TPSot (%d) is not valid regards to the current "
+                                                        "number of tile-part (%d), giving up\n", l_current_part, l_tcp->m_nb_tile_parts );
+                                        p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
+                                        return OPJ_FALSE;
+                                }
+                        }
+                        if( l_current_part >= l_num_parts ) {
+                          /* testcase 451.pdf.SIGSEGV.ce9.3723 */
+                          opj_event_msg(p_manager, EVT_ERROR, "In SOT marker, TPSot (%d) is not valid regards to the current "
+                            "number of tile-part (header) (%d), giving up\n", l_current_part, l_num_parts );
+                          p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
+                          return OPJ_FALSE;
+                        }
+                        l_tcp->m_nb_tile_parts = l_num_parts;
+                }
+
+                /* If know the number of tile part header we will check if we didn't read the last*/
+                if (l_tcp->m_nb_tile_parts) {
+                        if (l_tcp->m_nb_tile_parts == (l_current_part+1)) {
+                                p_j2k->m_specific_param.m_decoder.m_can_decode = 1; /* Process the last tile-part header*/
+                        }
+                }
+
+                if (!p_j2k->m_specific_param.m_decoder.m_last_tile_part){
+                        /* Keep the size of data to skip after this marker */
+                        p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12; /* SOT_marker_size = 12 */
+                }
+                else {
+                        /* FIXME: need to be computed from the number of bytes remaining in the codestream */
+                        p_j2k->m_specific_param.m_decoder.m_sot_length = 0;
+                }
+
+                p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPH;
+
+                /* Check if the current tile is outside the area we want decode or not corresponding to the tile index*/
+                if (p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec == -1) {
+                        p_j2k->m_specific_param.m_decoder.m_skip_data =
+                                (l_tile_x < p_j2k->m_specific_param.m_decoder.m_start_tile_x)
+                                ||      (l_tile_x >= p_j2k->m_specific_param.m_decoder.m_end_tile_x)
+                                ||  (l_tile_y < p_j2k->m_specific_param.m_decoder.m_start_tile_y)
+                                ||      (l_tile_y >= p_j2k->m_specific_param.m_decoder.m_end_tile_y);
+                }
+                else {
+                        assert( p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec >= 0 );
+                        p_j2k->m_specific_param.m_decoder.m_skip_data =
+                                (p_j2k->m_current_tile_number != (OPJ_UINT32)p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec);
+                }
+
+                /* Index */
+                if (p_j2k->cstr_index)
+                {
+                        assert(p_j2k->cstr_index->tile_index != 00);
+                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tileno = p_j2k->m_current_tile_number;
+                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_tpsno = l_current_part;
+
+                        if (l_num_parts != 0){
+                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].nb_tps = l_num_parts;
+                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = l_num_parts;
+
+                                if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
+                                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index =
+                                                (opj_tp_index_t*)opj_calloc(l_num_parts, sizeof(opj_tp_index_t));
+                                        if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
+                                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\n");
+                                                return OPJ_FALSE;
+																				}
+                                }
+                                else {
+                                        opj_tp_index_t *new_tp_index = (opj_tp_index_t *) opj_realloc(
+                                                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index, l_num_parts* sizeof(opj_tp_index_t));
+                                        if (! new_tp_index) {
+                                                opj_free(p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index);
+                                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = NULL;
+                                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\n");
+                                                return OPJ_FALSE;
+                                        }
+                                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = new_tp_index;
+                                }
+                        }
+                        else{
+                                /*if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index)*/ {
+
+                                        if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
+                                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 10;
+                                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index =
+                                                        (opj_tp_index_t*)opj_calloc( p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps,
+                                                                        sizeof(opj_tp_index_t));
+																								if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) {
+                                                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 0;
+                                                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\n");
+                                                        return OPJ_FALSE;
+																				        }
+                                        }
+
+                                        if ( l_current_part >= p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps ){
+                                                opj_tp_index_t *new_tp_index;
+                                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = l_current_part + 1;
+                                                new_tp_index = (opj_tp_index_t *) opj_realloc(
+                                                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index,
+                                                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps * sizeof(opj_tp_index_t));
+                                                if (! new_tp_index) {
+                                                        opj_free(p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index);
+                                                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = NULL;
+                                                        p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 0;
+                                                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\n");
+                                                        return OPJ_FALSE;
+                                                }
+                                                p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = new_tp_index;
+                                        }
+                                }
+
+                        }
+
+                }
+
+                /* FIXME move this onto a separate method to call before reading any SOT, remove part about main_end header, use a index struct inside p_j2k */
+                /* if (p_j2k->cstr_info) {
+                   if (l_tcp->first) {
+                   if (tileno == 0) {
+                   p_j2k->cstr_info->main_head_end = p_stream_tell(p_stream) - 13;
+                   }
+
+                   p_j2k->cstr_info->tile[tileno].tileno = tileno;
+                   p_j2k->cstr_info->tile[tileno].start_pos = p_stream_tell(p_stream) - 12;
+                   p_j2k->cstr_info->tile[tileno].end_pos = p_j2k->cstr_info->tile[tileno].start_pos + totlen - 1;
+                   p_j2k->cstr_info->tile[tileno].num_tps = numparts;
+
+                   if (numparts) {
+                   p_j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t));
+                   }
+                   else {
+                   p_j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10)
+                   }
+                   }
+                   else {
+                   p_j2k->cstr_info->tile[tileno].end_pos += totlen;
+                   }
+
+                   p_j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = p_stream_tell(p_stream) - 12;
+                   p_j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos =
+                   p_j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1;
+                   }*/
+                return OPJ_TRUE;
+        }
+
+static OPJ_BOOL opj_j2k_write_sod(     opj_j2k_t *p_j2k,
+                                                        opj_tcd_t * p_tile_coder,
+                                                        OPJ_BYTE * p_data,
+                                                        OPJ_UINT32 * p_data_written,
+                                                        OPJ_UINT32 p_total_data_size,
+                                                        const opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager
+                            )
+{
+        opj_codestream_info_t *l_cstr_info = 00;
+        OPJ_UINT32 l_remaining_data;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        opj_write_bytes(p_data,J2K_MS_SOD,2);                                   /* SOD */
+        p_data += 2;
+
+        /* make room for the EOF marker */
+        l_remaining_data =  p_total_data_size - 4;
+
+        /* update tile coder */
+        p_tile_coder->tp_num = p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number ;
+        p_tile_coder->cur_tp_num = p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
+
+         /* INDEX >> */
+        /* TODO mergeV2: check this part which use cstr_info */
+        /*l_cstr_info = p_j2k->cstr_info;
+        if (l_cstr_info) {
+                if (!p_j2k->m_specific_param.m_encoder.m_current_tile_part_number ) {
+                        //TODO cstr_info->tile[p_j2k->m_current_tile_number].end_header = p_stream_tell(p_stream) + p_j2k->pos_correction - 1;
+                        l_cstr_info->tile[p_j2k->m_current_tile_number].tileno = p_j2k->m_current_tile_number;
+                }
+                else {*/
+                        /*
+                        TODO
+                        if
+                                (cstr_info->tile[p_j2k->m_current_tile_number].packet[cstr_info->packno - 1].end_pos < p_stream_tell(p_stream))
+                        {
+                                cstr_info->tile[p_j2k->m_current_tile_number].packet[cstr_info->packno].start_pos = p_stream_tell(p_stream);
+                        }*/
+                /*}*/
+                /* UniPG>> */
+#ifdef USE_JPWL
+                /* update markers struct */
+                /*OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_SOD, p_j2k->sod_start, 2);
+*/
+  assert( 0 && "TODO" );
+#endif /* USE_JPWL */
+                /* <<UniPG */
+        /*}*/
+        /* << INDEX */
+
+        if (p_j2k->m_specific_param.m_encoder.m_current_tile_part_number == 0) {
+                p_tile_coder->tcd_image->tiles->packno = 0;
+                if (l_cstr_info) {
+                        l_cstr_info->packno = 0;
+                }
+        }
+
+        *p_data_written = 0;
+
+        if (! opj_tcd_encode_tile(p_tile_coder, p_j2k->m_current_tile_number, p_data, p_data_written, l_remaining_data , l_cstr_info)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Cannot encode tile\n");
+                return OPJ_FALSE;
+        }
+
+        *p_data_written += 2;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_read_sod (opj_j2k_t *p_j2k,
+                           opj_stream_private_t *p_stream,
+                                                   opj_event_mgr_t * p_manager
+                           )
+{
+        OPJ_SIZE_T l_current_read_size;
+        opj_codestream_index_t * l_cstr_index = 00;
+        OPJ_BYTE ** l_current_data = 00;
+        opj_tcp_t * l_tcp = 00;
+        OPJ_UINT32 * l_tile_len = 00;
+        OPJ_BOOL l_sot_length_pb_detected = OPJ_FALSE;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
+
+        if (p_j2k->m_specific_param.m_decoder.m_last_tile_part) {
+                /* opj_stream_get_number_byte_left returns OPJ_OFF_T
+                // but we are in the last tile part,
+                // so its result will fit on OPJ_UINT32 unless we find
+                // a file with a single tile part of more than 4 GB...*/
+                p_j2k->m_specific_param.m_decoder.m_sot_length = (OPJ_UINT32)(opj_stream_get_number_byte_left(p_stream) - 2);
+        }
+        else {
+            /* Check to avoid pass the limit of OPJ_UINT32 */
+            if (p_j2k->m_specific_param.m_decoder.m_sot_length >= 2 )
+                p_j2k->m_specific_param.m_decoder.m_sot_length -= 2;
+            else {
+                /* MSD: case commented to support empty SOT marker (PHR data) */
+            }
+        }
+
+        l_current_data = &(l_tcp->m_data);
+        l_tile_len = &l_tcp->m_data_size;
+
+        /* Patch to support new PHR data */
+        if (p_j2k->m_specific_param.m_decoder.m_sot_length) {
+            /* If we are here, we'll try to read the data after allocation */
+            /* Check enough bytes left in stream before allocation */
+            if ((OPJ_OFF_T)p_j2k->m_specific_param.m_decoder.m_sot_length > opj_stream_get_number_byte_left(p_stream)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Tile part length size inconsistent with stream length\n");
+                return OPJ_FALSE;
+            }
+            if (! *l_current_data) {
+                /* LH: oddly enough, in this path, l_tile_len!=0.
+                 * TODO: If this was consistent, we could simplify the code to only use realloc(), as realloc(0,...) default to malloc(0,...).
+                 */
+                *l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param.m_decoder.m_sot_length);
+            }
+            else {
+                OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length);
+                if (! l_new_current_data) {
+                        opj_free(*l_current_data);
+                        /*nothing more is done as l_current_data will be set to null, and just
+                          afterward we enter in the error path
+                          and the actual tile_len is updated (committed) at the end of the
+                          function. */
+                }
+                *l_current_data = l_new_current_data;
+            }
+            
+            if (*l_current_data == 00) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to decode tile\n");
+                return OPJ_FALSE;
+            }
+        }
+        else {
+            l_sot_length_pb_detected = OPJ_TRUE;
+        }
+
+        /* Index */
+        l_cstr_index = p_j2k->cstr_index;
+        if (l_cstr_index) {
+                OPJ_OFF_T l_current_pos = opj_stream_tell(p_stream) - 2;
+
+                OPJ_UINT32 l_current_tile_part = l_cstr_index->tile_index[p_j2k->m_current_tile_number].current_tpsno;
+                l_cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index[l_current_tile_part].end_header =
+                                l_current_pos;
+                l_cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index[l_current_tile_part].end_pos =
+                                l_current_pos + p_j2k->m_specific_param.m_decoder.m_sot_length + 2;
+
+                if (OPJ_FALSE == opj_j2k_add_tlmarker(p_j2k->m_current_tile_number,
+                                        l_cstr_index,
+                                        J2K_MS_SOD,
+                                        l_current_pos,
+                                        p_j2k->m_specific_param.m_decoder.m_sot_length + 2)) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add tl marker\n");
+                        return OPJ_FALSE;
+                }
+
+                /*l_cstr_index->packno = 0;*/
+        }
+
+        /* Patch to support new PHR data */
+        if (!l_sot_length_pb_detected) {
+            l_current_read_size = opj_stream_read_data(
+                        p_stream,
+                        *l_current_data + *l_tile_len,
+                        p_j2k->m_specific_param.m_decoder.m_sot_length,
+                        p_manager);
+        }
+        else
+        {
+            l_current_read_size = 0;
+        }
+
+        if (l_current_read_size != p_j2k->m_specific_param.m_decoder.m_sot_length) {
+                p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
+        }
+        else {
+                p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
+        }
+
+        *l_tile_len += (OPJ_UINT32)l_current_read_size;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_rgn(opj_j2k_t *p_j2k,
+                            OPJ_UINT32 p_tile_no,
+                            OPJ_UINT32 p_comp_no,
+                            OPJ_UINT32 nb_comps,
+                            opj_stream_private_t *p_stream,
+                            opj_event_mgr_t * p_manager
+                            )
+{
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_UINT32 l_rgn_size;
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_tccp_t *l_tccp = 00;
+        OPJ_UINT32 l_comp_room;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = &l_cp->tcps[p_tile_no];
+        l_tccp = &l_tcp->tccps[p_comp_no];
+
+        if (nb_comps <= 256) {
+                l_comp_room = 1;
+        }
+        else {
+                l_comp_room = 2;
+        }
+
+        l_rgn_size = 6 + l_comp_room;
+
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_RGN,2);                                   /* RGN  */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_rgn_size-2,2);                                 /* Lrgn */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,p_comp_no,l_comp_room);                          /* Crgn */
+        l_current_data+=l_comp_room;
+
+        opj_write_bytes(l_current_data, 0,1);                                           /* Srgn */
+        ++l_current_data;
+
+        opj_write_bytes(l_current_data, (OPJ_UINT32)l_tccp->roishift,1);                            /* SPrgn */
+        ++l_current_data;
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_rgn_size,p_manager) != l_rgn_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_eoc(     opj_j2k_t *p_j2k,
+                            opj_stream_private_t *p_stream,
+                            opj_event_mgr_t * p_manager
+                            )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_header_tile_data,J2K_MS_EOC,2);                                     /* EOC */
+
+/* UniPG>> */
+#ifdef USE_JPWL
+        /* update markers struct */
+        /*
+        OPJ_BOOL res = j2k_add_marker(p_j2k->cstr_info, J2K_MS_EOC, p_stream_tell(p_stream) - 2, 2);
+*/
+#endif /* USE_JPWL */
+
+        if ( opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,2,p_manager) != 2) {
+                return OPJ_FALSE;
+        }
+
+        if ( ! opj_stream_flush(p_stream,p_manager) ) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a RGN marker (Region Of Interest)
+ *
+ * @param       p_header_data   the data contained in the POC box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the POC marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_rgn (opj_j2k_t *p_j2k,
+                                  OPJ_BYTE * p_header_data,
+                                  OPJ_UINT32 p_header_size,
+                                  opj_event_mgr_t * p_manager
+                                  )
+{
+        OPJ_UINT32 l_nb_comp;
+        opj_image_t * l_image = 00;
+
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        OPJ_UINT32 l_comp_room, l_comp_no, l_roi_sty;
+
+        /* preconditions*/
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_image = p_j2k->m_private_image;
+        l_nb_comp = l_image->numcomps;
+
+        if (l_nb_comp <= 256) {
+                l_comp_room = 1; }
+        else {
+                l_comp_room = 2; }
+
+        if (p_header_size != 2 + l_comp_room) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading RGN marker\n");
+                return OPJ_FALSE;
+        }
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
+                                &l_cp->tcps[p_j2k->m_current_tile_number] :
+                                p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        opj_read_bytes(p_header_data,&l_comp_no,l_comp_room);           /* Crgn */
+        p_header_data+=l_comp_room;
+        opj_read_bytes(p_header_data,&l_roi_sty,1);                                     /* Srgn */
+        ++p_header_data;
+
+#ifdef USE_JPWL
+        if (l_cp->correct) {
+                /* totlen is negative or larger than the bytes left!!! */
+                if (l_comp_room >= l_nb_comp) {
+                        opj_event_msg(p_manager, EVT_ERROR,
+                                "JPWL: bad component number in RGN (%d when there are only %d)\n",
+                                l_comp_room, l_nb_comp);
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                }
+        };
+#endif /* USE_JPWL */
+
+        /* testcase 3635.pdf.asan.77.2930 */
+        if (l_comp_no >= l_nb_comp) {
+                opj_event_msg(p_manager, EVT_ERROR,
+                        "bad component number in RGN (%d when there are only %d)\n",
+                        l_comp_no, l_nb_comp);
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,(OPJ_UINT32 *) (&(l_tcp->tccps[l_comp_no].roishift)),1);   /* SPrgn */
+        ++p_header_data;
+
+        return OPJ_TRUE;
+
+}
+
+static OPJ_FLOAT32 opj_j2k_get_tp_stride (opj_tcp_t * p_tcp)
+{
+        return (OPJ_FLOAT32) ((p_tcp->m_nb_tile_parts - 1) * 14);
+}
+
+static OPJ_FLOAT32 opj_j2k_get_default_stride (opj_tcp_t * p_tcp)
+{
+    (void)p_tcp;
+    return 0;
+}
+
+static OPJ_BOOL opj_j2k_update_rates(  opj_j2k_t *p_j2k,
+                                                            opj_stream_private_t *p_stream,
+                                                            opj_event_mgr_t * p_manager )
+{
+        opj_cp_t * l_cp = 00;
+        opj_image_t * l_image = 00;
+        opj_tcp_t * l_tcp = 00;
+        opj_image_comp_t * l_img_comp = 00;
+
+        OPJ_UINT32 i,j,k;
+        OPJ_INT32 l_x0,l_y0,l_x1,l_y1;
+        OPJ_FLOAT32 * l_rates = 0;
+        OPJ_FLOAT32 l_sot_remove;
+        OPJ_UINT32 l_bits_empty, l_size_pixel;
+        OPJ_UINT32 l_tile_size = 0;
+        OPJ_UINT32 l_last_res;
+        OPJ_FLOAT32 (* l_tp_stride_func)(opj_tcp_t *) = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_image = p_j2k->m_private_image;
+        l_tcp = l_cp->tcps;
+
+        l_bits_empty = 8 * l_image->comps->dx * l_image->comps->dy;
+        l_size_pixel = l_image->numcomps * l_image->comps->prec;
+        l_sot_remove = (OPJ_FLOAT32) opj_stream_tell(p_stream) / (OPJ_FLOAT32)(l_cp->th * l_cp->tw);
+
+        if (l_cp->m_specific_param.m_enc.m_tp_on) {
+                l_tp_stride_func = opj_j2k_get_tp_stride;
+        }
+        else {
+                l_tp_stride_func = opj_j2k_get_default_stride;
+        }
+
+        for (i=0;i<l_cp->th;++i) {
+                for (j=0;j<l_cp->tw;++j) {
+                        OPJ_FLOAT32 l_offset = (OPJ_FLOAT32)(*l_tp_stride_func)(l_tcp) / (OPJ_FLOAT32)l_tcp->numlayers;
+
+                        /* 4 borders of the tile rescale on the image if necessary */
+                        l_x0 = opj_int_max((OPJ_INT32)(l_cp->tx0 + j * l_cp->tdx), (OPJ_INT32)l_image->x0);
+                        l_y0 = opj_int_max((OPJ_INT32)(l_cp->ty0 + i * l_cp->tdy), (OPJ_INT32)l_image->y0);
+                        l_x1 = opj_int_min((OPJ_INT32)(l_cp->tx0 + (j + 1) * l_cp->tdx), (OPJ_INT32)l_image->x1);
+                        l_y1 = opj_int_min((OPJ_INT32)(l_cp->ty0 + (i + 1) * l_cp->tdy), (OPJ_INT32)l_image->y1);
+
+                        l_rates = l_tcp->rates;
+
+                        /* Modification of the RATE >> */
+                        if (*l_rates > 0.0f) {
+                                *l_rates =              (( (OPJ_FLOAT32) (l_size_pixel * (OPJ_UINT32)(l_x1 - l_x0) * (OPJ_UINT32)(l_y1 - l_y0)))
+                                                                /
+                                                                ((*l_rates) * (OPJ_FLOAT32)l_bits_empty)
+                                                                )
+                                                                -
+                                                                l_offset;
+                        }
+
+                        ++l_rates;
+
+                        for (k = 1; k < l_tcp->numlayers; ++k) {
+                                if (*l_rates > 0.0f) {
+                                        *l_rates =              (( (OPJ_FLOAT32) (l_size_pixel * (OPJ_UINT32)(l_x1 - l_x0) * (OPJ_UINT32)(l_y1 - l_y0)))
+                                                                        /
+                                                                                ((*l_rates) * (OPJ_FLOAT32)l_bits_empty)
+                                                                        )
+                                                                        -
+                                                                        l_offset;
+                                }
+
+                                ++l_rates;
+                        }
+
+                        ++l_tcp;
+
+                }
+        }
+
+        l_tcp = l_cp->tcps;
+
+        for (i=0;i<l_cp->th;++i) {
+                for     (j=0;j<l_cp->tw;++j) {
+                        l_rates = l_tcp->rates;
+
+                        if (*l_rates > 0.0f) {
+                                *l_rates -= l_sot_remove;
+
+                                if (*l_rates < 30.0f) {
+                                        *l_rates = 30.0f;
+                                }
+                        }
+
+                        ++l_rates;
+
+                        l_last_res = l_tcp->numlayers - 1;
+
+                        for (k = 1; k < l_last_res; ++k) {
+
+                                if (*l_rates > 0.0f) {
+                                        *l_rates -= l_sot_remove;
+
+                                        if (*l_rates < *(l_rates - 1) + 10.0f) {
+                                                *l_rates  = (*(l_rates - 1)) + 20.0f;
+                                        }
+                                }
+
+                                ++l_rates;
+                        }
+
+                        if (*l_rates > 0.0f) {
+                                *l_rates -= (l_sot_remove + 2.f);
+
+                                if (*l_rates < *(l_rates - 1) + 10.0f) {
+                                        *l_rates  = (*(l_rates - 1)) + 20.0f;
+                                }
+                        }
+
+                        ++l_tcp;
+                }
+        }
+
+        l_img_comp = l_image->comps;
+        l_tile_size = 0;
+
+        for (i=0;i<l_image->numcomps;++i) {
+                l_tile_size += (        opj_uint_ceildiv(l_cp->tdx,l_img_comp->dx)
+                                                        *
+                                                        opj_uint_ceildiv(l_cp->tdy,l_img_comp->dy)
+                                                        *
+                                                        l_img_comp->prec
+                                                );
+
+                ++l_img_comp;
+        }
+
+        l_tile_size = (OPJ_UINT32) (l_tile_size * 0.1625); /* 1.3/8 = 0.1625 */
+
+        l_tile_size += opj_j2k_get_specific_header_sizes(p_j2k);
+
+        p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = l_tile_size;
+        p_j2k->m_specific_param.m_encoder.m_encoded_tile_data =
+                        (OPJ_BYTE *) opj_malloc(p_j2k->m_specific_param.m_encoder.m_encoded_tile_size);
+        if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data == 00) {
+                return OPJ_FALSE;
+        }
+
+        if (OPJ_IS_CINEMA(l_cp->rsiz)) {
+                p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer =
+                                (OPJ_BYTE *) opj_malloc(5*p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
+                if (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
+                        return OPJ_FALSE;
+                }
+
+                p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current =
+                                p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer;
+        }
+
+        return OPJ_TRUE;
+}
+
+#if 0
+static OPJ_BOOL opj_j2k_read_eoc (     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 i;
+        opj_tcd_t * l_tcd = 00;
+        OPJ_UINT32 l_nb_tiles;
+        opj_tcp_t * l_tcp = 00;
+        OPJ_BOOL l_success;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
+        l_tcp = p_j2k->m_cp.tcps;
+
+        l_tcd = opj_tcd_create(OPJ_TRUE);
+        if (l_tcd == 00) {
+                opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
+                return OPJ_FALSE;
+        }
+
+        for (i = 0; i < l_nb_tiles; ++i) {
+                if (l_tcp->m_data) {
+                        if (! opj_tcd_init_decode_tile(l_tcd, i)) {
+                                opj_tcd_destroy(l_tcd);
+                                opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
+                                return OPJ_FALSE;
+                        }
+
+                        l_success = opj_tcd_decode_tile(l_tcd, l_tcp->m_data, l_tcp->m_data_size, i, p_j2k->cstr_index);
+                        /* cleanup */
+
+                        if (! l_success) {
+                                p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_ERR;
+                                break;
+                        }
+                }
+
+                opj_j2k_tcp_destroy(l_tcp);
+                ++l_tcp;
+        }
+
+        opj_tcd_destroy(l_tcd);
+        return OPJ_TRUE;
+}
+#endif
+
+static OPJ_BOOL opj_j2k_get_end_header(opj_j2k_t *p_j2k,
+                                                        struct opj_stream_private *p_stream,
+                                                        struct opj_event_mgr * p_manager )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        p_j2k->cstr_index->main_head_end = opj_stream_tell(p_stream);
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_mct_data_group(  opj_j2k_t *p_j2k,
+                                                                        struct opj_stream_private *p_stream,
+                                                                        struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 i;
+        opj_simple_mcc_decorrelation_data_t * l_mcc_record;
+        opj_mct_data_t * l_mct_record;
+        opj_tcp_t * l_tcp;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        if (! opj_j2k_write_cbd(p_j2k,p_stream,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
+        l_mct_record = l_tcp->m_mct_records;
+
+        for (i=0;i<l_tcp->m_nb_mct_records;++i) {
+
+                if (! opj_j2k_write_mct_record(p_j2k,l_mct_record,p_stream,p_manager)) {
+                        return OPJ_FALSE;
+                }
+
+                ++l_mct_record;
+        }
+
+        l_mcc_record = l_tcp->m_mcc_records;
+
+        for     (i=0;i<l_tcp->m_nb_mcc_records;++i) {
+
+                if (! opj_j2k_write_mcc_record(p_j2k,l_mcc_record,p_stream,p_manager)) {
+                        return OPJ_FALSE;
+                }
+
+                ++l_mcc_record;
+        }
+
+        if (! opj_j2k_write_mco(p_j2k,p_stream,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_all_coc(
+	opj_j2k_t *p_j2k,
+	struct opj_stream_private *p_stream,
+	struct opj_event_mgr * p_manager )
+{
+	OPJ_UINT32 compno;
+	
+	/* preconditions */
+	assert(p_j2k != 00);
+	assert(p_manager != 00);
+	assert(p_stream != 00);
+	
+	for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno)
+	{
+		/* cod is first component of first tile */
+		if (! opj_j2k_compare_coc(p_j2k, 0, compno)) {
+			if (! opj_j2k_write_coc(p_j2k,compno,p_stream, p_manager)) {
+				return OPJ_FALSE;
+			}
+		}
+	}
+	
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_all_qcc(
+	opj_j2k_t *p_j2k,
+	struct opj_stream_private *p_stream,
+	struct opj_event_mgr * p_manager )
+{
+	OPJ_UINT32 compno;
+	
+	/* preconditions */
+	assert(p_j2k != 00);
+	assert(p_manager != 00);
+	assert(p_stream != 00);
+	
+	for (compno = 1; compno < p_j2k->m_private_image->numcomps; ++compno)
+	{
+		/* qcd is first component of first tile */
+		if (! opj_j2k_compare_qcc(p_j2k, 0, compno)) {
+			if (! opj_j2k_write_qcc(p_j2k,compno,p_stream, p_manager)) {
+				return OPJ_FALSE;
+			}
+		}
+	}
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_regions( opj_j2k_t *p_j2k,
+                                                        struct opj_stream_private *p_stream,
+                                                        struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 compno;
+        const opj_tccp_t *l_tccp = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_tccp = p_j2k->m_cp.tcps->tccps;
+
+        for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno)  {
+                if (l_tccp->roishift) {
+
+                        if (! opj_j2k_write_rgn(p_j2k,0,compno,p_j2k->m_private_image->numcomps,p_stream,p_manager)) {
+                                return OPJ_FALSE;
+                        }
+                }
+
+                ++l_tccp;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_epc(     opj_j2k_t *p_j2k,
+                                                struct opj_stream_private *p_stream,
+                                                struct opj_event_mgr * p_manager )
+{
+        opj_codestream_index_t * l_cstr_index = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_cstr_index = p_j2k->cstr_index;
+        if (l_cstr_index) {
+                l_cstr_index->codestream_size = (OPJ_UINT64)opj_stream_tell(p_stream);
+                /* UniPG>> */
+                /* The following adjustment is done to adjust the codestream size */
+                /* if SOD is not at 0 in the buffer. Useful in case of JP2, where */
+                /* the first bunch of bytes is not in the codestream              */
+                l_cstr_index->codestream_size -= (OPJ_UINT64)l_cstr_index->main_head_start;
+                /* <<UniPG */
+        }
+
+#ifdef USE_JPWL
+        /* preparation of JPWL marker segments */
+#if 0
+        if(cp->epc_on) {
+
+                /* encode according to JPWL */
+                jpwl_encode(p_j2k, p_stream, image);
+
+        }
+#endif
+  assert( 0 && "TODO" );
+#endif /* USE_JPWL */
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_read_unk (     opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        OPJ_UINT32 *output_marker,
+                                                        opj_event_mgr_t * p_manager
+                                                        )
+{
+        OPJ_UINT32 l_unknown_marker;
+        const opj_dec_memory_marker_handler_t * l_marker_handler;
+        OPJ_UINT32 l_size_unk = 2;
+
+        /* preconditions*/
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        opj_event_msg(p_manager, EVT_WARNING, "Unknown marker\n");
+
+		for (;;) {
+                /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer*/
+                if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                        return OPJ_FALSE;
+                }
+
+                /* read 2 bytes as the new marker ID*/
+                opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_unknown_marker,2);
+
+                if (!(l_unknown_marker < 0xff00)) {
+
+                        /* Get the marker handler from the marker ID*/
+                        l_marker_handler = opj_j2k_get_marker_handler(l_unknown_marker);
+
+                        if (!(p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states)) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
+                                return OPJ_FALSE;
+                        }
+                        else {
+                                if (l_marker_handler->id != J2K_MS_UNK) {
+                                        /* Add the marker to the codestream index*/
+                                        if (l_marker_handler->id != J2K_MS_SOT)
+                                        {
+                                                OPJ_BOOL res = opj_j2k_add_mhmarker(p_j2k->cstr_index, J2K_MS_UNK,
+                                                                (OPJ_UINT32) opj_stream_tell(p_stream) - l_size_unk,
+                                                                l_size_unk);
+                                                if (res == OPJ_FALSE) {
+                                                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n");
+                                                        return OPJ_FALSE;
+                                                }
+                                        }
+                                        break; /* next marker is known and well located */
+                                }
+                                else
+                                        l_size_unk += 2;
+                        }
+                }
+        }
+
+        *output_marker = l_marker_handler->id ;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_mct_record(      opj_j2k_t *p_j2k,
+                                                                opj_mct_data_t * p_mct_record,
+                                                                struct opj_stream_private *p_stream,
+                                                                struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 l_mct_size;
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_UINT32 l_tmp;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_mct_size = 10 + p_mct_record->m_data_size;
+
+        if (l_mct_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mct_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write MCT marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mct_size;
+        }
+
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_MCT,2);                                   /* MCT */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_mct_size-2,2);                                 /* Lmct */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,0,2);                                                    /* Zmct */
+        l_current_data += 2;
+
+        /* only one marker atm */
+        l_tmp = (p_mct_record->m_index & 0xff) | (p_mct_record->m_array_type << 8) | (p_mct_record->m_element_type << 10);
+
+        opj_write_bytes(l_current_data,l_tmp,2);
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,0,2);                                                    /* Ymct */
+        l_current_data+=2;
+
+        memcpy(l_current_data,p_mct_record->m_data,p_mct_record->m_data_size);
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mct_size,p_manager) != l_mct_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a MCT marker (Multiple Component Transform)
+ *
+ * @param       p_header_data   the data contained in the MCT box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the MCT marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_mct (      opj_j2k_t *p_j2k,
+                                                                    OPJ_BYTE * p_header_data,
+                                                                    OPJ_UINT32 p_header_size,
+                                                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 i;
+        opj_tcp_t *l_tcp = 00;
+        OPJ_UINT32 l_tmp;
+        OPJ_UINT32 l_indix;
+        opj_mct_data_t * l_mct_data;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+
+        l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
+                        &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] :
+                        p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        if (p_header_size < 2) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
+                return OPJ_FALSE;
+        }
+
+        /* first marker */
+        opj_read_bytes(p_header_data,&l_tmp,2);                         /* Zmct */
+        p_header_data += 2;
+        if (l_tmp != 0) {
+                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge mct data within multiple MCT records\n");
+                return OPJ_TRUE;
+        }
+
+        if(p_header_size <= 6) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
+                return OPJ_FALSE;
+        }
+
+        /* Imct -> no need for other values, take the first, type is double with decorrelation x0000 1101 0000 0000*/
+        opj_read_bytes(p_header_data,&l_tmp,2);                         /* Imct */
+        p_header_data += 2;
+
+        l_indix = l_tmp & 0xff;
+        l_mct_data = l_tcp->m_mct_records;
+
+        for (i=0;i<l_tcp->m_nb_mct_records;++i) {
+                if (l_mct_data->m_index == l_indix) {
+                        break;
+                }
+                ++l_mct_data;
+        }
+
+        /* NOT FOUND */
+        if (i == l_tcp->m_nb_mct_records) {
+                if (l_tcp->m_nb_mct_records == l_tcp->m_nb_max_mct_records) {
+                        opj_mct_data_t *new_mct_records;
+                        l_tcp->m_nb_max_mct_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
+
+                        new_mct_records = (opj_mct_data_t *) opj_realloc(l_tcp->m_mct_records, l_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
+                        if (! new_mct_records) {
+                                opj_free(l_tcp->m_mct_records);
+                                l_tcp->m_mct_records = NULL;
+                                l_tcp->m_nb_max_mct_records = 0;
+                                l_tcp->m_nb_mct_records = 0;
+                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read MCT marker\n");
+                                return OPJ_FALSE;
+                        }
+                        l_tcp->m_mct_records = new_mct_records;
+                        l_mct_data = l_tcp->m_mct_records + l_tcp->m_nb_mct_records;
+                        memset(l_mct_data ,0,(l_tcp->m_nb_max_mct_records - l_tcp->m_nb_mct_records) * sizeof(opj_mct_data_t));
+                }
+
+                l_mct_data = l_tcp->m_mct_records + l_tcp->m_nb_mct_records;
+                ++l_tcp->m_nb_mct_records;
+        }
+
+        if (l_mct_data->m_data) {
+                opj_free(l_mct_data->m_data);
+                l_mct_data->m_data = 00;
+        }
+
+        l_mct_data->m_index = l_indix;
+        l_mct_data->m_array_type = (J2K_MCT_ARRAY_TYPE)((l_tmp  >> 8) & 3);
+        l_mct_data->m_element_type = (J2K_MCT_ELEMENT_TYPE)((l_tmp  >> 10) & 3);
+
+        opj_read_bytes(p_header_data,&l_tmp,2);                         /* Ymct */
+        p_header_data+=2;
+        if (l_tmp != 0) {
+                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple MCT markers\n");
+                return OPJ_TRUE;
+        }
+
+        p_header_size -= 6;
+
+        l_mct_data->m_data = (OPJ_BYTE*)opj_malloc(p_header_size);
+        if (! l_mct_data->m_data) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCT marker\n");
+                return OPJ_FALSE;
+        }
+        memcpy(l_mct_data->m_data,p_header_data,p_header_size);
+
+        l_mct_data->m_data_size = p_header_size;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_mcc_record(      opj_j2k_t *p_j2k,
+                                                                struct opj_simple_mcc_decorrelation_data * p_mcc_record,
+                                                                struct opj_stream_private *p_stream,
+                                                                struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_mcc_size;
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_UINT32 l_nb_bytes_for_comp;
+        OPJ_UINT32 l_mask;
+        OPJ_UINT32 l_tmcc;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        if (p_mcc_record->m_nb_comps > 255 ) {
+        l_nb_bytes_for_comp = 2;
+                l_mask = 0x8000;
+        }
+        else {
+                l_nb_bytes_for_comp = 1;
+                l_mask = 0;
+        }
+
+        l_mcc_size = p_mcc_record->m_nb_comps * 2 * l_nb_bytes_for_comp + 19;
+        if (l_mcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size)
+        {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mcc_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write MCC marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mcc_size;
+        }
+
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_MCC,2);                                   /* MCC */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_mcc_size-2,2);                                 /* Lmcc */
+        l_current_data += 2;
+
+        /* first marker */
+        opj_write_bytes(l_current_data,0,2);                                    /* Zmcc */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,p_mcc_record->m_index,1);                                        /* Imcc -> no need for other values, take the first */
+        ++l_current_data;
+
+        /* only one marker atm */
+        opj_write_bytes(l_current_data,0,2);                                    /* Ymcc */
+        l_current_data+=2;
+
+        opj_write_bytes(l_current_data,1,2);                                    /* Qmcc -> number of collections -> 1 */
+        l_current_data+=2;
+
+        opj_write_bytes(l_current_data,0x1,1);                                  /* Xmcci type of component transformation -> array based decorrelation */
+        ++l_current_data;
+
+        opj_write_bytes(l_current_data,p_mcc_record->m_nb_comps | l_mask,2);    /* Nmcci number of input components involved and size for each component offset = 8 bits */
+        l_current_data+=2;
+
+        for (i=0;i<p_mcc_record->m_nb_comps;++i) {
+                opj_write_bytes(l_current_data,i,l_nb_bytes_for_comp);                          /* Cmccij Component offset*/
+                l_current_data+=l_nb_bytes_for_comp;
+        }
+
+        opj_write_bytes(l_current_data,p_mcc_record->m_nb_comps|l_mask,2);      /* Mmcci number of output components involved and size for each component offset = 8 bits */
+        l_current_data+=2;
+
+        for (i=0;i<p_mcc_record->m_nb_comps;++i)
+        {
+                opj_write_bytes(l_current_data,i,l_nb_bytes_for_comp);                          /* Wmccij Component offset*/
+                l_current_data+=l_nb_bytes_for_comp;
+        }
+
+        l_tmcc = ((!p_mcc_record->m_is_irreversible) & 1U) << 16;
+
+        if (p_mcc_record->m_decorrelation_array) {
+                l_tmcc |= p_mcc_record->m_decorrelation_array->m_index;
+        }
+
+        if (p_mcc_record->m_offset_array) {
+                l_tmcc |= ((p_mcc_record->m_offset_array->m_index)<<8);
+        }
+
+        opj_write_bytes(l_current_data,l_tmcc,3);       /* Tmcci : use MCT defined as number 1 and irreversible array based. */
+        l_current_data+=3;
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mcc_size,p_manager) != l_mcc_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_read_mcc (     opj_j2k_t *p_j2k,
+                                                OPJ_BYTE * p_header_data,
+                                                OPJ_UINT32 p_header_size,
+                                                opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 i,j;
+        OPJ_UINT32 l_tmp;
+        OPJ_UINT32 l_indix;
+        opj_tcp_t * l_tcp;
+        opj_simple_mcc_decorrelation_data_t * l_mcc_record;
+        opj_mct_data_t * l_mct_data;
+        OPJ_UINT32 l_nb_collections;
+        OPJ_UINT32 l_nb_comps;
+        OPJ_UINT32 l_nb_bytes_by_comp;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
+                        &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] :
+                        p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        if (p_header_size < 2) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                return OPJ_FALSE;
+        }
+
+        /* first marker */
+        opj_read_bytes(p_header_data,&l_tmp,2);                         /* Zmcc */
+        p_header_data += 2;
+        if (l_tmp != 0) {
+                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple data spanning\n");
+                return OPJ_TRUE;
+        }
+
+        if (p_header_size < 7) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,&l_indix,1); /* Imcc -> no need for other values, take the first */
+        ++p_header_data;
+
+        l_mcc_record = l_tcp->m_mcc_records;
+
+        for(i=0;i<l_tcp->m_nb_mcc_records;++i) {
+                if (l_mcc_record->m_index == l_indix) {
+                        break;
+                }
+                ++l_mcc_record;
+        }
+
+        /** NOT FOUND */
+        if (i == l_tcp->m_nb_mcc_records) {
+                if (l_tcp->m_nb_mcc_records == l_tcp->m_nb_max_mcc_records) {
+                        opj_simple_mcc_decorrelation_data_t *new_mcc_records;
+                        l_tcp->m_nb_max_mcc_records += OPJ_J2K_MCC_DEFAULT_NB_RECORDS;
+
+                        new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
+                                        l_tcp->m_mcc_records, l_tcp->m_nb_max_mcc_records * sizeof(opj_simple_mcc_decorrelation_data_t));
+                        if (! new_mcc_records) {
+                                opj_free(l_tcp->m_mcc_records);
+                                l_tcp->m_mcc_records = NULL;
+                                l_tcp->m_nb_max_mcc_records = 0;
+                                l_tcp->m_nb_mcc_records = 0;
+                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read MCC marker\n");
+                                return OPJ_FALSE;
+                        }
+                        l_tcp->m_mcc_records = new_mcc_records;
+                        l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
+                        memset(l_mcc_record,0,(l_tcp->m_nb_max_mcc_records-l_tcp->m_nb_mcc_records) * sizeof(opj_simple_mcc_decorrelation_data_t));
+                }
+                l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
+        }
+        l_mcc_record->m_index = l_indix;
+
+        /* only one marker atm */
+        opj_read_bytes(p_header_data,&l_tmp,2);                         /* Ymcc */
+        p_header_data+=2;
+        if (l_tmp != 0) {
+                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple data spanning\n");
+                return OPJ_TRUE;
+        }
+
+        opj_read_bytes(p_header_data,&l_nb_collections,2);                              /* Qmcc -> number of collections -> 1 */
+        p_header_data+=2;
+
+        if (l_nb_collections > 1) {
+                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple collections\n");
+                return OPJ_TRUE;
+        }
+
+        p_header_size -= 7;
+
+        for (i=0;i<l_nb_collections;++i) {
+                if (p_header_size < 3) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                        return OPJ_FALSE;
+                }
+
+                opj_read_bytes(p_header_data,&l_tmp,1); /* Xmcci type of component transformation -> array based decorrelation */
+                ++p_header_data;
+
+                if (l_tmp != 1) {
+                        opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections other than array decorrelation\n");
+                        return OPJ_TRUE;
+                }
+
+                opj_read_bytes(p_header_data,&l_nb_comps,2);
+
+                p_header_data+=2;
+                p_header_size-=3;
+
+                l_nb_bytes_by_comp = 1 + (l_nb_comps>>15);
+                l_mcc_record->m_nb_comps = l_nb_comps & 0x7fff;
+
+                if (p_header_size < (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 2)) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                        return OPJ_FALSE;
+                }
+
+                p_header_size -= (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 2);
+
+                for (j=0;j<l_mcc_record->m_nb_comps;++j) {
+                        opj_read_bytes(p_header_data,&l_tmp,l_nb_bytes_by_comp);        /* Cmccij Component offset*/
+                        p_header_data+=l_nb_bytes_by_comp;
+
+                        if (l_tmp != j) {
+                                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections with indix shuffle\n");
+                                return OPJ_TRUE;
+                        }
+                }
+
+                opj_read_bytes(p_header_data,&l_nb_comps,2);
+                p_header_data+=2;
+
+                l_nb_bytes_by_comp = 1 + (l_nb_comps>>15);
+                l_nb_comps &= 0x7fff;
+
+                if (l_nb_comps != l_mcc_record->m_nb_comps) {
+                        opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections without same number of indixes\n");
+                        return OPJ_TRUE;
+                }
+
+                if (p_header_size < (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 3)) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                        return OPJ_FALSE;
+                }
+
+                p_header_size -= (l_nb_bytes_by_comp * l_mcc_record->m_nb_comps + 3);
+
+                for (j=0;j<l_mcc_record->m_nb_comps;++j) {
+                        opj_read_bytes(p_header_data,&l_tmp,l_nb_bytes_by_comp);        /* Wmccij Component offset*/
+                        p_header_data+=l_nb_bytes_by_comp;
+
+                        if (l_tmp != j) {
+                                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge collections with indix shuffle\n");
+                                return OPJ_TRUE;
+                        }
+                }
+
+                opj_read_bytes(p_header_data,&l_tmp,3); /* Wmccij Component offset*/
+                p_header_data += 3;
+
+                l_mcc_record->m_is_irreversible = ! ((l_tmp>>16) & 1);
+                l_mcc_record->m_decorrelation_array = 00;
+                l_mcc_record->m_offset_array = 00;
+
+                l_indix = l_tmp & 0xff;
+                if (l_indix != 0) {
+                        l_mct_data = l_tcp->m_mct_records;
+                        for (j=0;j<l_tcp->m_nb_mct_records;++j) {
+                                if (l_mct_data->m_index == l_indix) {
+                                        l_mcc_record->m_decorrelation_array = l_mct_data;
+                                        break;
+                                }
+                                ++l_mct_data;
+                        }
+
+                        if (l_mcc_record->m_decorrelation_array == 00) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                                return OPJ_FALSE;
+                        }
+                }
+
+                l_indix = (l_tmp >> 8) & 0xff;
+                if (l_indix != 0) {
+                        l_mct_data = l_tcp->m_mct_records;
+                        for (j=0;j<l_tcp->m_nb_mct_records;++j) {
+                                if (l_mct_data->m_index == l_indix) {
+                                        l_mcc_record->m_offset_array = l_mct_data;
+                                        break;
+                                }
+                                ++l_mct_data;
+                        }
+
+                        if (l_mcc_record->m_offset_array == 00) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                                return OPJ_FALSE;
+                        }
+                }
+        }
+
+        if (p_header_size != 0) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCC marker\n");
+                return OPJ_FALSE;
+        }
+
+        ++l_tcp->m_nb_mcc_records;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_mco(     opj_j2k_t *p_j2k,
+                                                struct opj_stream_private *p_stream,
+                                                struct opj_event_mgr * p_manager
+                                  )
+{
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_UINT32 l_mco_size;
+        opj_tcp_t * l_tcp = 00;
+        opj_simple_mcc_decorrelation_data_t * l_mcc_record;
+        OPJ_UINT32 i;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_tcp =&(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]);
+	
+        l_mco_size = 5 + l_tcp->m_nb_mcc_records;
+        if (l_mco_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_mco_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write MCO marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mco_size;
+        }
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+
+        opj_write_bytes(l_current_data,J2K_MS_MCO,2);                   /* MCO */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_mco_size-2,2);                 /* Lmco */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_tcp->m_nb_mcc_records,1);      /* Nmco : only one transform stage*/
+        ++l_current_data;
+
+        l_mcc_record = l_tcp->m_mcc_records;
+        for (i=0;i<l_tcp->m_nb_mcc_records;++i) {
+                opj_write_bytes(l_current_data,l_mcc_record->m_index,1);/* Imco -> use the mcc indicated by 1*/
+                ++l_current_data;
+                ++l_mcc_record;
+        }
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mco_size,p_manager) != l_mco_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a MCO marker (Multiple Component Transform Ordering)
+ *
+ * @param       p_header_data   the data contained in the MCO box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the MCO marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_mco (      opj_j2k_t *p_j2k,
+                                                                    OPJ_BYTE * p_header_data,
+                                                                    OPJ_UINT32 p_header_size,
+                                                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 l_tmp, i;
+        OPJ_UINT32 l_nb_stages;
+        opj_tcp_t * l_tcp;
+        opj_tccp_t * l_tccp;
+        opj_image_t * l_image;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_image = p_j2k->m_private_image;
+        l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
+                        &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] :
+                        p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        if (p_header_size < 1) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading MCO marker\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,&l_nb_stages,1);                           /* Nmco : only one transform stage*/
+        ++p_header_data;
+
+        if (l_nb_stages > 1) {
+                opj_event_msg(p_manager, EVT_WARNING, "Cannot take in charge multiple transformation stages.\n");
+                return OPJ_TRUE;
+        }
+
+        if (p_header_size != l_nb_stages + 1) {
+                opj_event_msg(p_manager, EVT_WARNING, "Error reading MCO marker\n");
+                return OPJ_FALSE;
+        }
+
+        l_tccp = l_tcp->tccps;
+
+        for (i=0;i<l_image->numcomps;++i) {
+                l_tccp->m_dc_level_shift = 0;
+                ++l_tccp;
+        }
+
+        if (l_tcp->m_mct_decoding_matrix) {
+                opj_free(l_tcp->m_mct_decoding_matrix);
+                l_tcp->m_mct_decoding_matrix = 00;
+        }
+
+        for (i=0;i<l_nb_stages;++i) {
+                opj_read_bytes(p_header_data,&l_tmp,1);
+                ++p_header_data;
+
+                if (! opj_j2k_add_mct(l_tcp,p_j2k->m_private_image,l_tmp)) {
+                        return OPJ_FALSE;
+                }
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_add_mct(opj_tcp_t * p_tcp, opj_image_t * p_image, OPJ_UINT32 p_index)
+{
+        OPJ_UINT32 i;
+        opj_simple_mcc_decorrelation_data_t * l_mcc_record;
+        opj_mct_data_t * l_deco_array, * l_offset_array;
+        OPJ_UINT32 l_data_size,l_mct_size, l_offset_size;
+        OPJ_UINT32 l_nb_elem;
+        OPJ_UINT32 * l_offset_data, * l_current_offset_data;
+        opj_tccp_t * l_tccp;
+
+        /* preconditions */
+        assert(p_tcp != 00);
+
+        l_mcc_record = p_tcp->m_mcc_records;
+
+        for (i=0;i<p_tcp->m_nb_mcc_records;++i) {
+                if (l_mcc_record->m_index == p_index) {
+                        break;
+                }
+        }
+
+        if (i==p_tcp->m_nb_mcc_records) {
+                /** element discarded **/
+                return OPJ_TRUE;
+        }
+
+        if (l_mcc_record->m_nb_comps != p_image->numcomps) {
+                /** do not support number of comps != image */
+                return OPJ_TRUE;
+        }
+
+        l_deco_array = l_mcc_record->m_decorrelation_array;
+
+        if (l_deco_array) {
+                l_data_size = MCT_ELEMENT_SIZE[l_deco_array->m_element_type] * p_image->numcomps * p_image->numcomps;
+                if (l_deco_array->m_data_size != l_data_size) {
+                        return OPJ_FALSE;
+                }
+
+                l_nb_elem = p_image->numcomps * p_image->numcomps;
+                l_mct_size = l_nb_elem * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
+                p_tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(l_mct_size);
+
+                if (! p_tcp->m_mct_decoding_matrix ) {
+                        return OPJ_FALSE;
+                }
+
+                j2k_mct_read_functions_to_float[l_deco_array->m_element_type](l_deco_array->m_data,p_tcp->m_mct_decoding_matrix,l_nb_elem);
+        }
+
+        l_offset_array = l_mcc_record->m_offset_array;
+
+        if (l_offset_array) {
+                l_data_size = MCT_ELEMENT_SIZE[l_offset_array->m_element_type] * p_image->numcomps;
+                if (l_offset_array->m_data_size != l_data_size) {
+                        return OPJ_FALSE;
+                }
+
+                l_nb_elem = p_image->numcomps;
+                l_offset_size = l_nb_elem * (OPJ_UINT32)sizeof(OPJ_UINT32);
+                l_offset_data = (OPJ_UINT32*)opj_malloc(l_offset_size);
+
+                if (! l_offset_data ) {
+                        return OPJ_FALSE;
+                }
+
+                j2k_mct_read_functions_to_int32[l_offset_array->m_element_type](l_offset_array->m_data,l_offset_data,l_nb_elem);
+
+                l_tccp = p_tcp->tccps;
+                l_current_offset_data = l_offset_data;
+
+                for (i=0;i<p_image->numcomps;++i) {
+                        l_tccp->m_dc_level_shift = (OPJ_INT32)*(l_current_offset_data++);
+                        ++l_tccp;
+                }
+
+                opj_free(l_offset_data);
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_cbd( opj_j2k_t *p_j2k,
+                                                struct opj_stream_private *p_stream,
+                                                struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_cbd_size;
+        OPJ_BYTE * l_current_data = 00;
+        opj_image_t *l_image = 00;
+        opj_image_comp_t * l_comp = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_image = p_j2k->m_private_image;
+        l_cbd_size = 6 + p_j2k->m_private_image->numcomps;
+
+        if (l_cbd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
+                OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_cbd_size);
+                if (! new_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to write CBD marker\n");
+                        return OPJ_FALSE;
+                }
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_cbd_size;
+        }
+
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
+
+        opj_write_bytes(l_current_data,J2K_MS_CBD,2);                   /* CBD */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_cbd_size-2,2);                 /* L_CBD */
+        l_current_data += 2;
+
+        opj_write_bytes(l_current_data,l_image->numcomps, 2);           /* Ncbd */
+        l_current_data+=2;
+
+        l_comp = l_image->comps;
+
+        for (i=0;i<l_image->numcomps;++i) {
+                opj_write_bytes(l_current_data, (l_comp->sgnd << 7) | (l_comp->prec - 1), 1);           /* Component bit depth */
+                ++l_current_data;
+
+                ++l_comp;
+        }
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_cbd_size,p_manager) != l_cbd_size) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Reads a CBD marker (Component bit depth definition)
+ * @param       p_header_data   the data contained in the CBD box.
+ * @param       p_j2k                   the jpeg2000 codec.
+ * @param       p_header_size   the size of the data contained in the CBD marker.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_read_cbd (      opj_j2k_t *p_j2k,
+                                                                OPJ_BYTE * p_header_data,
+                                                                OPJ_UINT32 p_header_size,
+                                                                opj_event_mgr_t * p_manager
+                                    )
+{
+        OPJ_UINT32 l_nb_comp,l_num_comp;
+        OPJ_UINT32 l_comp_def;
+        OPJ_UINT32 i;
+        opj_image_comp_t * l_comp = 00;
+
+        /* preconditions */
+        assert(p_header_data != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        l_num_comp = p_j2k->m_private_image->numcomps;
+
+        if (p_header_size != (p_j2k->m_private_image->numcomps + 2)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Crror reading CBD marker\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(p_header_data,&l_nb_comp,2);                             /* Ncbd */
+        p_header_data+=2;
+
+        if (l_nb_comp != l_num_comp) {
+                opj_event_msg(p_manager, EVT_ERROR, "Crror reading CBD marker\n");
+                return OPJ_FALSE;
+        }
+
+        l_comp = p_j2k->m_private_image->comps;
+        for (i=0;i<l_num_comp;++i) {
+                opj_read_bytes(p_header_data,&l_comp_def,1);                    /* Component bit depth */
+                ++p_header_data;
+        l_comp->sgnd = (l_comp_def>>7) & 1;
+                l_comp->prec = (l_comp_def&0x7f) + 1;
+                ++l_comp;
+        }
+
+        return OPJ_TRUE;
+}
+
+/* ----------------------------------------------------------------------- */
+/* J2K / JPT decoder interface                                             */
+/* ----------------------------------------------------------------------- */
+
+void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
+{
+        if(j2k && parameters) {
+                j2k->m_cp.m_specific_param.m_dec.m_layer = parameters->cp_layer;
+                j2k->m_cp.m_specific_param.m_dec.m_reduce = parameters->cp_reduce;
+
+#ifdef USE_JPWL
+                j2k->m_cp.correct = parameters->jpwl_correct;
+                j2k->m_cp.exp_comps = parameters->jpwl_exp_comps;
+                j2k->m_cp.max_tiles = parameters->jpwl_max_tiles;
+#endif /* USE_JPWL */
+        }
+}
+
+/* ----------------------------------------------------------------------- */
+/* J2K encoder interface                                                       */
+/* ----------------------------------------------------------------------- */
+
+opj_j2k_t* opj_j2k_create_compress(void)
+{
+        opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1,sizeof(opj_j2k_t));
+        if (!l_j2k) {
+                return NULL;
+        }
+
+
+        l_j2k->m_is_decoder = 0;
+        l_j2k->m_cp.m_is_decoder = 0;
+
+        l_j2k->m_specific_param.m_encoder.m_header_tile_data = (OPJ_BYTE *) opj_malloc(OPJ_J2K_DEFAULT_HEADER_SIZE);
+        if (! l_j2k->m_specific_param.m_encoder.m_header_tile_data) {
+                opj_j2k_destroy(l_j2k);
+                return NULL;
+        }
+
+        l_j2k->m_specific_param.m_encoder.m_header_tile_data_size = OPJ_J2K_DEFAULT_HEADER_SIZE;
+
+        /* validation list creation*/
+        l_j2k->m_validation_list = opj_procedure_list_create();
+        if (! l_j2k->m_validation_list) {
+                opj_j2k_destroy(l_j2k);
+                return NULL;
+        }
+
+        /* execution list creation*/
+        l_j2k->m_procedure_list = opj_procedure_list_create();
+        if (! l_j2k->m_procedure_list) {
+                opj_j2k_destroy(l_j2k);
+                return NULL;
+        }
+
+        return l_j2k;
+}
+
+static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres){
+    POC[0].tile  = 1;
+    POC[0].resno0  = 0;
+    POC[0].compno0 = 0;
+    POC[0].layno1  = 1;
+    POC[0].resno1  = (OPJ_UINT32)(numres-1);
+    POC[0].compno1 = 3;
+    POC[0].prg1 = OPJ_CPRL;
+    POC[1].tile  = 1;
+    POC[1].resno0  = (OPJ_UINT32)(numres-1);
+    POC[1].compno0 = 0;
+    POC[1].layno1  = 1;
+    POC[1].resno1  = (OPJ_UINT32)numres;
+    POC[1].compno1 = 3;
+    POC[1].prg1 = OPJ_CPRL;
+    return 2;
+}
+
+static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t *p_manager)
+{
+    /* Configure cinema parameters */
+    int i;
+
+    /* No tiling */
+    parameters->tile_size_on = OPJ_FALSE;
+    parameters->cp_tdx=1;
+    parameters->cp_tdy=1;
+
+    /* One tile part for each component */
+    parameters->tp_flag = 'C';
+    parameters->tp_on = 1;
+
+    /* Tile and Image shall be at (0,0) */
+    parameters->cp_tx0 = 0;
+    parameters->cp_ty0 = 0;
+    parameters->image_offset_x0 = 0;
+    parameters->image_offset_y0 = 0;
+
+    /* Codeblock size= 32*32 */
+    parameters->cblockw_init = 32;
+    parameters->cblockh_init = 32;
+
+    /* Codeblock style: no mode switch enabled */
+    parameters->mode = 0;
+
+    /* No ROI */
+    parameters->roi_compno = -1;
+
+    /* No subsampling */
+    parameters->subsampling_dx = 1;
+    parameters->subsampling_dy = 1;
+
+    /* 9-7 transform */
+    parameters->irreversible = 1;
+
+    /* Number of layers */
+    if (parameters->tcp_numlayers > 1){
+        opj_event_msg(p_manager, EVT_WARNING,
+                "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
+                "1 single quality layer"
+                "-> Number of layers forced to 1 (rather than %d)\n"
+                "-> Rate of the last layer (%3.1f) will be used",
+                parameters->tcp_numlayers, parameters->tcp_rates[parameters->tcp_numlayers-1]);
+        parameters->tcp_rates[0] = parameters->tcp_rates[parameters->tcp_numlayers-1];
+        parameters->tcp_numlayers = 1;
+    }
+
+    /* Resolution levels */
+    switch (parameters->rsiz){
+    case OPJ_PROFILE_CINEMA_2K:
+        if(parameters->numresolution > 6){
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
+                    "Number of decomposition levels <= 5\n"
+                    "-> Number of decomposition levels forced to 5 (rather than %d)\n",
+                    parameters->numresolution+1);
+            parameters->numresolution = 6;
+        }
+        break;
+    case OPJ_PROFILE_CINEMA_4K:
+        if(parameters->numresolution < 2){
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Profile-4 (4k dc profile) requires:\n"
+                    "Number of decomposition levels >= 1 && <= 6\n"
+                    "-> Number of decomposition levels forced to 1 (rather than %d)\n",
+                    parameters->numresolution+1);
+            parameters->numresolution = 1;
+        }else if(parameters->numresolution > 7){
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Profile-4 (4k dc profile) requires:\n"
+                    "Number of decomposition levels >= 1 && <= 6\n"
+                    "-> Number of decomposition levels forced to 6 (rather than %d)\n",
+                    parameters->numresolution+1);
+            parameters->numresolution = 7;
+        }
+        break;
+    default :
+        break;
+    }
+
+    /* Precincts */
+    parameters->csty |= 0x01;
+    parameters->res_spec = parameters->numresolution-1;
+    for (i = 0; i<parameters->res_spec; i++) {
+        parameters->prcw_init[i] = 256;
+        parameters->prch_init[i] = 256;
+    }
+
+    /* The progression order shall be CPRL */
+    parameters->prog_order = OPJ_CPRL;
+
+    /* Progression order changes for 4K, disallowed for 2K */
+    if (parameters->rsiz == OPJ_PROFILE_CINEMA_4K) {
+        parameters->numpocs = (OPJ_UINT32)opj_j2k_initialise_4K_poc(parameters->POC,parameters->numresolution);
+    } else {
+        parameters->numpocs = 0;
+    }
+
+    /* Limited bit-rate */
+    parameters->cp_disto_alloc = 1;
+    if (parameters->max_cs_size <= 0) {
+        /* No rate has been introduced, 24 fps is assumed */
+        parameters->max_cs_size = OPJ_CINEMA_24_CS;
+        opj_event_msg(p_manager, EVT_WARNING,
+                      "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
+                      "Maximum 1302083 compressed bytes @ 24fps\n"
+                      "As no rate has been given, this limit will be used.\n");
+    } else if (parameters->max_cs_size > OPJ_CINEMA_24_CS) {
+        opj_event_msg(p_manager, EVT_WARNING,
+                      "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
+                      "Maximum 1302083 compressed bytes @ 24fps\n"
+                      "-> Specified rate exceeds this limit. Rate will be forced to 1302083 bytes.\n");
+        parameters->max_cs_size = OPJ_CINEMA_24_CS;
+    }
+
+    if (parameters->max_comp_size <= 0) {
+        /* No rate has been introduced, 24 fps is assumed */
+        parameters->max_comp_size = OPJ_CINEMA_24_COMP;
+        opj_event_msg(p_manager, EVT_WARNING,
+                      "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
+                      "Maximum 1041666 compressed bytes @ 24fps\n"
+                      "As no rate has been given, this limit will be used.\n");
+    } else if (parameters->max_comp_size > OPJ_CINEMA_24_COMP) {
+        opj_event_msg(p_manager, EVT_WARNING,
+                      "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n"
+                      "Maximum 1041666 compressed bytes @ 24fps\n"
+                      "-> Specified rate exceeds this limit. Rate will be forced to 1041666 bytes.\n");
+        parameters->max_comp_size = OPJ_CINEMA_24_COMP;
+    }
+
+    parameters->tcp_rates[0] = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
+            (OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->comps[0].dx * image->comps[0].dy);
+
+}
+
+static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz, opj_event_mgr_t *p_manager)
+{
+    OPJ_UINT32 i;
+
+    /* Number of components */
+    if (image->numcomps != 3){
+        opj_event_msg(p_manager, EVT_WARNING,
+                "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
+                "3 components"
+                "-> Number of components of input image (%d) is not compliant\n"
+                "-> Non-profile-3 codestream will be generated\n",
+                image->numcomps);
+        return OPJ_FALSE;
+    }
+
+    /* Bitdepth */
+    for (i = 0; i < image->numcomps; i++) {
+        if ((image->comps[i].bpp != 12) | (image->comps[i].sgnd)){
+            char signed_str[] = "signed";
+            char unsigned_str[] = "unsigned";
+            char *tmp_str = image->comps[i].sgnd?signed_str:unsigned_str;
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
+                    "Precision of each component shall be 12 bits unsigned"
+                    "-> At least component %d of input image (%d bits, %s) is not compliant\n"
+                    "-> Non-profile-3 codestream will be generated\n",
+                    i,image->comps[i].bpp, tmp_str);
+            return OPJ_FALSE;
+        }
+    }
+
+    /* Image size */
+    switch (rsiz){
+    case OPJ_PROFILE_CINEMA_2K:
+        if (((image->comps[0].w > 2048) | (image->comps[0].h > 1080))){
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Profile-3 (2k dc profile) requires:\n"
+                    "width <= 2048 and height <= 1080\n"
+                    "-> Input image size %d x %d is not compliant\n"
+                    "-> Non-profile-3 codestream will be generated\n",
+                    image->comps[0].w,image->comps[0].h);
+            return OPJ_FALSE;
+        }
+        break;
+    case OPJ_PROFILE_CINEMA_4K:
+        if (((image->comps[0].w > 4096) | (image->comps[0].h > 2160))){
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Profile-4 (4k dc profile) requires:\n"
+                    "width <= 4096 and height <= 2160\n"
+                    "-> Image size %d x %d is not compliant\n"
+                    "-> Non-profile-4 codestream will be generated\n",
+                    image->comps[0].w,image->comps[0].h);
+            return OPJ_FALSE;
+        }
+        break;
+    default :
+        break;
+    }
+
+    return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_setup_encoder(     opj_j2k_t *p_j2k,
+                                                    opj_cparameters_t *parameters,
+                                                    opj_image_t *image,
+                                                    opj_event_mgr_t * p_manager)
+{
+        OPJ_UINT32 i, j, tileno, numpocs_tile;
+        opj_cp_t *cp = 00;
+
+        if(!p_j2k || !parameters || ! image) {
+                return OPJ_FALSE;
+        }
+
+        if ((parameters->numresolution <= 0) || (parameters->numresolution > OPJ_J2K_MAXRLVLS)) {
+            opj_event_msg(p_manager, EVT_ERROR, "Invalid number of resolutions : %d not in range [1,%d]\n", parameters->numresolution, OPJ_J2K_MAXRLVLS);
+            return OPJ_FALSE;
+        }
+
+        /* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
+        cp = &(p_j2k->m_cp);
+
+        /* set default values for cp */
+        cp->tw = 1;
+        cp->th = 1;
+
+        /* FIXME ADE: to be removed once deprecated cp_cinema and cp_rsiz have been removed */
+        if (parameters->rsiz == OPJ_PROFILE_NONE) { /* consider deprecated fields only if RSIZ has not been set */
+            OPJ_BOOL deprecated_used = OPJ_FALSE;
+            switch (parameters->cp_cinema){
+            case OPJ_CINEMA2K_24:
+                parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
+                parameters->max_cs_size = OPJ_CINEMA_24_CS;
+                parameters->max_comp_size = OPJ_CINEMA_24_COMP;
+                deprecated_used = OPJ_TRUE;
+                break;
+            case OPJ_CINEMA2K_48:
+                parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
+                parameters->max_cs_size = OPJ_CINEMA_48_CS;
+                parameters->max_comp_size = OPJ_CINEMA_48_COMP;
+                deprecated_used = OPJ_TRUE;
+                break;
+            case OPJ_CINEMA4K_24:
+                parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
+                parameters->max_cs_size = OPJ_CINEMA_24_CS;
+                parameters->max_comp_size = OPJ_CINEMA_24_COMP;
+                deprecated_used = OPJ_TRUE;
+                break;
+            case OPJ_OFF:
+            default:
+                break;
+            }
+            switch (parameters->cp_rsiz){
+            case OPJ_CINEMA2K:
+                parameters->rsiz = OPJ_PROFILE_CINEMA_2K;
+                deprecated_used = OPJ_TRUE;
+                break;
+            case OPJ_CINEMA4K:
+                parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
+                deprecated_used = OPJ_TRUE;
+                break;
+            case OPJ_MCT:
+                parameters->rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT;
+                deprecated_used = OPJ_TRUE;
+            case OPJ_STD_RSIZ:
+            default:
+                break;
+            }
+            if (deprecated_used) {
+                opj_event_msg(p_manager, EVT_WARNING,
+                        "Deprecated fields cp_cinema or cp_rsiz are used\n"
+                        "Please consider using only the rsiz field\n"
+                        "See openjpeg.h documentation for more details\n");
+            }
+        }
+
+        /* see if max_codestream_size does limit input rate */
+        if (parameters->max_cs_size <= 0) {
+            if (parameters->tcp_rates[parameters->tcp_numlayers-1] > 0) {
+                OPJ_FLOAT32 temp_size;
+                temp_size =(OPJ_FLOAT32)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
+                        (parameters->tcp_rates[parameters->tcp_numlayers-1] * 8 * (OPJ_FLOAT32)image->comps[0].dx * (OPJ_FLOAT32)image->comps[0].dy);
+                parameters->max_cs_size = (int) floor(temp_size);
+            } else {
+                parameters->max_cs_size = 0;
+            }
+        } else {
+            OPJ_FLOAT32 temp_rate;
+            OPJ_BOOL cap = OPJ_FALSE;
+            temp_rate = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/
+                    (OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->comps[0].dx * image->comps[0].dy);
+            for (i = 0; i < (OPJ_UINT32) parameters->tcp_numlayers; i++) {
+                if (parameters->tcp_rates[i] < temp_rate) {
+                    parameters->tcp_rates[i] = temp_rate;
+                    cap = OPJ_TRUE;
+                }
+            }
+            if (cap) {
+                opj_event_msg(p_manager, EVT_WARNING,
+                        "The desired maximum codestream size has limited\n"
+                        "at least one of the desired quality layers\n");
+            }
+        }
+
+        /* Manage profiles and applications and set RSIZ */
+        /* set cinema parameters if required */
+        if (OPJ_IS_CINEMA(parameters->rsiz)){
+            if ((parameters->rsiz == OPJ_PROFILE_CINEMA_S2K)
+                    || (parameters->rsiz == OPJ_PROFILE_CINEMA_S4K)){
+                opj_event_msg(p_manager, EVT_WARNING,
+                        "JPEG 2000 Scalable Digital Cinema profiles not yet supported\n");
+                parameters->rsiz = OPJ_PROFILE_NONE;
+            } else {
+                opj_j2k_set_cinema_parameters(parameters,image,p_manager);
+                if (!opj_j2k_is_cinema_compliant(image,parameters->rsiz,p_manager)) {
+                    parameters->rsiz = OPJ_PROFILE_NONE;
+                }
+            }
+        } else if (OPJ_IS_STORAGE(parameters->rsiz)) {
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Long Term Storage profile not yet supported\n");
+            parameters->rsiz = OPJ_PROFILE_NONE;
+        } else if (OPJ_IS_BROADCAST(parameters->rsiz)) {
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 Broadcast profiles not yet supported\n");
+            parameters->rsiz = OPJ_PROFILE_NONE;
+        } else if (OPJ_IS_IMF(parameters->rsiz)) {
+            opj_event_msg(p_manager, EVT_WARNING,
+                    "JPEG 2000 IMF profiles not yet supported\n");
+            parameters->rsiz = OPJ_PROFILE_NONE;
+        } else if (OPJ_IS_PART2(parameters->rsiz)) {
+            if (parameters->rsiz == ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_NONE))) {
+                opj_event_msg(p_manager, EVT_WARNING,
+                              "JPEG 2000 Part-2 profile defined\n"
+                              "but no Part-2 extension enabled.\n"
+                              "Profile set to NONE.\n");
+                parameters->rsiz = OPJ_PROFILE_NONE;
+            } else if (parameters->rsiz != ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT))) {
+                opj_event_msg(p_manager, EVT_WARNING,
+                              "Unsupported Part-2 extension enabled\n"
+                              "Profile set to NONE.\n");
+                parameters->rsiz = OPJ_PROFILE_NONE;
+            }
+        }
+
+        /*
+        copy user encoding parameters
+        */
+        cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)parameters->max_comp_size;
+        cp->rsiz = parameters->rsiz;
+        cp->m_specific_param.m_enc.m_disto_alloc = (OPJ_UINT32)parameters->cp_disto_alloc & 1u;
+        cp->m_specific_param.m_enc.m_fixed_alloc = (OPJ_UINT32)parameters->cp_fixed_alloc & 1u;
+        cp->m_specific_param.m_enc.m_fixed_quality = (OPJ_UINT32)parameters->cp_fixed_quality & 1u;
+
+        /* mod fixed_quality */
+        if (parameters->cp_fixed_alloc && parameters->cp_matrice) {
+                size_t array_size = (size_t)parameters->tcp_numlayers * (size_t)parameters->numresolution * 3 * sizeof(OPJ_INT32);
+                cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(array_size);
+								if (!cp->m_specific_param.m_enc.m_matrice) {
+								        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate copy of user encoding parameters matrix \n");
+								        return OPJ_FALSE;
+								}
+                memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matrice, array_size);
+        }
+
+        /* tiles */
+        cp->tdx = (OPJ_UINT32)parameters->cp_tdx;
+        cp->tdy = (OPJ_UINT32)parameters->cp_tdy;
+
+        /* tile offset */
+        cp->tx0 = (OPJ_UINT32)parameters->cp_tx0;
+        cp->ty0 = (OPJ_UINT32)parameters->cp_ty0;
+
+        /* comment string */
+        if(parameters->cp_comment) {
+                cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) + 1U);
+								if(!cp->comment) {
+								        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate copy of comment string\n");
+								        return OPJ_FALSE;
+								}
+                strcpy(cp->comment, parameters->cp_comment);
+        } else {
+                /* Create default comment for codestream */
+                const char comment[] = "Created by OpenJPEG version ";
+                const size_t clen = strlen(comment);
+                const char *version = opj_version();
+
+                /* UniPG>> */
+#ifdef USE_JPWL
+                cp->comment = (char*)opj_malloc(clen+strlen(version)+11);
+								if(!cp->comment) {
+								        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate comment string\n");
+								        return OPJ_FALSE;
+								}
+                sprintf(cp->comment,"%s%s with JPWL", comment, version);
+#else
+                cp->comment = (char*)opj_malloc(clen+strlen(version)+1);
+								if(!cp->comment) {
+								        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate comment string\n");
+								        return OPJ_FALSE;
+								}
+                sprintf(cp->comment,"%s%s", comment, version);
+#endif
+                /* <<UniPG */
+				}
+
+        /*
+        calculate other encoding parameters
+        */
+
+        if (parameters->tile_size_on) {
+                cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp->tx0), (OPJ_INT32)cp->tdx);
+                cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp->ty0), (OPJ_INT32)cp->tdy);
+        } else {
+                cp->tdx = image->x1 - cp->tx0;
+                cp->tdy = image->y1 - cp->ty0;
+        }
+
+        if (parameters->tp_on) {
+                cp->m_specific_param.m_enc.m_tp_flag = (OPJ_BYTE)parameters->tp_flag;
+                cp->m_specific_param.m_enc.m_tp_on = 1;
+        }
+
+#ifdef USE_JPWL
+        /*
+        calculate JPWL encoding parameters
+        */
+
+        if (parameters->jpwl_epc_on) {
+                OPJ_INT32 i;
+
+                /* set JPWL on */
+                cp->epc_on = OPJ_TRUE;
+                cp->info_on = OPJ_FALSE; /* no informative technique */
+
+                /* set EPB on */
+                if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) {
+                        cp->epb_on = OPJ_TRUE;
+
+                        cp->hprot_MH = parameters->jpwl_hprot_MH;
+                        for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
+                                cp->hprot_TPH_tileno[i] = parameters->jpwl_hprot_TPH_tileno[i];
+                                cp->hprot_TPH[i] = parameters->jpwl_hprot_TPH[i];
+                        }
+                        /* if tile specs are not specified, copy MH specs */
+                        if (cp->hprot_TPH[0] == -1) {
+                                cp->hprot_TPH_tileno[0] = 0;
+                                cp->hprot_TPH[0] = parameters->jpwl_hprot_MH;
+                        }
+                        for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
+                                cp->pprot_tileno[i] = parameters->jpwl_pprot_tileno[i];
+                                cp->pprot_packno[i] = parameters->jpwl_pprot_packno[i];
+                                cp->pprot[i] = parameters->jpwl_pprot[i];
+                        }
+                }
+
+                /* set ESD writing */
+                if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) {
+                        cp->esd_on = OPJ_TRUE;
+
+                        cp->sens_size = parameters->jpwl_sens_size;
+                        cp->sens_addr = parameters->jpwl_sens_addr;
+                        cp->sens_range = parameters->jpwl_sens_range;
+
+                        cp->sens_MH = parameters->jpwl_sens_MH;
+                        for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
+                                cp->sens_TPH_tileno[i] = parameters->jpwl_sens_TPH_tileno[i];
+                                cp->sens_TPH[i] = parameters->jpwl_sens_TPH[i];
+                        }
+                }
+
+                /* always set RED writing to false: we are at the encoder */
+                cp->red_on = OPJ_FALSE;
+
+        } else {
+                cp->epc_on = OPJ_FALSE;
+        }
+#endif /* USE_JPWL */
+
+        /* initialize the mutiple tiles */
+        /* ---------------------------- */
+        cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
+        if (!cp->tcps) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate tile coding parameters\n");
+                return OPJ_FALSE;
+        }
+        if (parameters->numpocs) {
+                /* initialisation of POC */
+                opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, (OPJ_UINT32)parameters->numresolution, image->numcomps, (OPJ_UINT32)parameters->tcp_numlayers, p_manager);
+                /* TODO MSD use the return value*/
+        }
+
+        for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
+                opj_tcp_t *tcp = &cp->tcps[tileno];
+                tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers;
+
+                for (j = 0; j < tcp->numlayers; j++) {
+                        if(OPJ_IS_CINEMA(cp->rsiz)){
+                                if (cp->m_specific_param.m_enc.m_fixed_quality) {
+                                        tcp->distoratio[j] = parameters->tcp_distoratio[j];
+                                }
+                                tcp->rates[j] = parameters->tcp_rates[j];
+                        }else{
+                                if (cp->m_specific_param.m_enc.m_fixed_quality) {       /* add fixed_quality */
+                                        tcp->distoratio[j] = parameters->tcp_distoratio[j];
+                                } else {
+                                        tcp->rates[j] = parameters->tcp_rates[j];
+                                }
+                        }
+                }
+
+                tcp->csty = (OPJ_UINT32)parameters->csty;
+                tcp->prg = parameters->prog_order;
+                tcp->mct = (OPJ_UINT32)parameters->tcp_mct;
+
+                numpocs_tile = 0;
+                tcp->POC = 0;
+
+                if (parameters->numpocs) {
+                        /* initialisation of POC */
+                        tcp->POC = 1;
+                        for (i = 0; i < parameters->numpocs; i++) {
+                                if (tileno + 1 == parameters->POC[i].tile )  {
+                                        opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
+
+                                        tcp_poc->resno0         = parameters->POC[numpocs_tile].resno0;
+                                        tcp_poc->compno0        = parameters->POC[numpocs_tile].compno0;
+                                        tcp_poc->layno1         = parameters->POC[numpocs_tile].layno1;
+                                        tcp_poc->resno1         = parameters->POC[numpocs_tile].resno1;
+                                        tcp_poc->compno1        = parameters->POC[numpocs_tile].compno1;
+                                        tcp_poc->prg1           = parameters->POC[numpocs_tile].prg1;
+                                        tcp_poc->tile           = parameters->POC[numpocs_tile].tile;
+
+                                        numpocs_tile++;
+                                }
+                        }
+
+                        tcp->numpocs = numpocs_tile -1 ;
+                }else{
+                        tcp->numpocs = 0;
+                }
+
+                tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(opj_tccp_t));
+                if (!tcp->tccps) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate tile component coding parameters\n");
+                        return OPJ_FALSE;
+                }
+                if (parameters->mct_data) {
+                      
+                    OPJ_UINT32 lMctSize = image->numcomps * image->numcomps * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
+                    OPJ_FLOAT32 * lTmpBuf = (OPJ_FLOAT32*)opj_malloc(lMctSize);
+                    OPJ_INT32 * l_dc_shift = (OPJ_INT32 *) ((OPJ_BYTE *) parameters->mct_data + lMctSize);
+
+										if (!lTmpBuf) {
+                            opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate temp buffer\n");
+                            return OPJ_FALSE;
+                    }
+
+                    tcp->mct = 2;
+                    tcp->m_mct_coding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize);
+										if (! tcp->m_mct_coding_matrix) {
+                            opj_free(lTmpBuf);
+														lTmpBuf = NULL;
+                            opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate encoder MCT coding matrix \n");
+                            return OPJ_FALSE;
+                    }
+                    memcpy(tcp->m_mct_coding_matrix,parameters->mct_data,lMctSize);
+                    memcpy(lTmpBuf,parameters->mct_data,lMctSize);
+
+                    tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize);
+										if (! tcp->m_mct_decoding_matrix) {
+														opj_free(lTmpBuf);
+														lTmpBuf = NULL;
+                            opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate encoder MCT decoding matrix \n");
+                            return OPJ_FALSE;
+                    }
+                    if(opj_matrix_inversion_f(lTmpBuf,(tcp->m_mct_decoding_matrix),image->numcomps) == OPJ_FALSE) {
+                            opj_free(lTmpBuf);
+														lTmpBuf = NULL;
+                            opj_event_msg(p_manager, EVT_ERROR, "Failed to inverse encoder MCT decoding matrix \n");
+                            return OPJ_FALSE;
+										}
+
+                    tcp->mct_norms = (OPJ_FLOAT64*)
+                                    opj_malloc(image->numcomps * sizeof(OPJ_FLOAT64));
+										if (! tcp->mct_norms) {
+                            opj_free(lTmpBuf);
+														lTmpBuf = NULL;
+                            opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to allocate encoder MCT norms \n");
+                            return OPJ_FALSE;
+                    }
+                    opj_calculate_norms(tcp->mct_norms,image->numcomps,tcp->m_mct_decoding_matrix);
+                    opj_free(lTmpBuf);
+
+                    for (i = 0; i < image->numcomps; i++) {
+                            opj_tccp_t *tccp = &tcp->tccps[i];
+                            tccp->m_dc_level_shift = l_dc_shift[i];
+                    }
+
+                    if (opj_j2k_setup_mct_encoding(tcp,image) == OPJ_FALSE) {
+                        /* free will be handled by opj_j2k_destroy */
+												opj_event_msg(p_manager, EVT_ERROR, "Failed to setup j2k mct encoding\n");
+                        return OPJ_FALSE;
+                    }
+                }
+                else {
+                    if(tcp->mct==1 && image->numcomps >= 3) { /* RGB->YCC MCT is enabled */
+                        if ((image->comps[0].dx != image->comps[1].dx) ||
+                                (image->comps[0].dx != image->comps[2].dx) ||
+                                (image->comps[0].dy != image->comps[1].dy) ||
+                                (image->comps[0].dy != image->comps[2].dy)) {
+                            opj_event_msg(p_manager, EVT_WARNING, "Cannot perform MCT on components with different sizes. Disabling MCT.\n");
+                            tcp->mct = 0;
+                        }
+                    }
+                        for (i = 0; i < image->numcomps; i++) {
+                                opj_tccp_t *tccp = &tcp->tccps[i];
+                                opj_image_comp_t * l_comp = &(image->comps[i]);
+
+                                if (! l_comp->sgnd) {
+                                        tccp->m_dc_level_shift = 1 << (l_comp->prec - 1);
+                                }
+                        }
+                }
+
+                for (i = 0; i < image->numcomps; i++) {
+                        opj_tccp_t *tccp = &tcp->tccps[i];
+
+                        tccp->csty = parameters->csty & 0x01;   /* 0 => one precinct || 1 => custom precinct  */
+                        tccp->numresolutions = (OPJ_UINT32)parameters->numresolution;
+                        tccp->cblkw = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockw_init);
+                        tccp->cblkh = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockh_init);
+                        tccp->cblksty = (OPJ_UINT32)parameters->mode;
+                        tccp->qmfbid = parameters->irreversible ? 0 : 1;
+                        tccp->qntsty = parameters->irreversible ? J2K_CCP_QNTSTY_SEQNT : J2K_CCP_QNTSTY_NOQNT;
+                        tccp->numgbits = 2;
+
+                        if ((OPJ_INT32)i == parameters->roi_compno) {
+                                tccp->roishift = parameters->roi_shift;
+                        } else {
+                                tccp->roishift = 0;
+                        }
+
+                                if (parameters->csty & J2K_CCP_CSTY_PRT) {
+                                        OPJ_INT32 p = 0, it_res;
+                                        assert( tccp->numresolutions > 0 );
+                                        for (it_res = (OPJ_INT32)tccp->numresolutions - 1; it_res >= 0; it_res--) {
+                                                if (p < parameters->res_spec) {
+
+                                                        if (parameters->prcw_init[p] < 1) {
+                                                                tccp->prcw[it_res] = 1;
+                                                        } else {
+                                                                tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prcw_init[p]);
+                                                        }
+
+                                                        if (parameters->prch_init[p] < 1) {
+                                                                tccp->prch[it_res] = 1;
+                                                        }else {
+                                                                tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prch_init[p]);
+                                                        }
+
+                                                } else {
+                                                        OPJ_INT32 res_spec = parameters->res_spec;
+                                                        OPJ_INT32 size_prcw = 0;
+                                                        OPJ_INT32 size_prch = 0;
+
+                                                        assert(res_spec>0); /* issue 189 */
+                                                        size_prcw = parameters->prcw_init[res_spec - 1] >> (p - (res_spec - 1));
+                                                        size_prch = parameters->prch_init[res_spec - 1] >> (p - (res_spec - 1));
+
+
+                                                        if (size_prcw < 1) {
+                                                                tccp->prcw[it_res] = 1;
+                                                        } else {
+                                                                tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prcw);
+                                                        }
+
+                                                        if (size_prch < 1) {
+                                                                tccp->prch[it_res] = 1;
+                                                        } else {
+                                                                tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prch);
+                                                        }
+                                                }
+                                                p++;
+                                                /*printf("\nsize precinct for level %d : %d,%d\n", it_res,tccp->prcw[it_res], tccp->prch[it_res]); */
+                                        }       /*end for*/
+                                } else {
+                                        for (j = 0; j < tccp->numresolutions; j++) {
+                                                tccp->prcw[j] = 15;
+                                                tccp->prch[j] = 15;
+                                        }
+                                }
+
+                        opj_dwt_calc_explicit_stepsizes(tccp, image->comps[i].prec);
+                }
+        }
+
+        if (parameters->mct_data) {
+                opj_free(parameters->mct_data);
+                parameters->mct_data = 00;
+        }
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len)
+{
+        assert(cstr_index != 00);
+
+        /* expand the list? */
+        if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) {
+                opj_marker_info_t *new_marker;
+                cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_index->maxmarknum);
+                new_marker = (opj_marker_info_t *) opj_realloc(cstr_index->marker, cstr_index->maxmarknum *sizeof(opj_marker_info_t));
+                if (! new_marker) {
+                        opj_free(cstr_index->marker);
+                        cstr_index->marker = NULL;
+                        cstr_index->maxmarknum = 0;
+                        cstr_index->marknum = 0;
+                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n"); */
+                        return OPJ_FALSE;
+                }
+                cstr_index->marker = new_marker;
+        }
+
+        /* add the marker */
+        cstr_index->marker[cstr_index->marknum].type = (OPJ_UINT16)type;
+        cstr_index->marker[cstr_index->marknum].pos = (OPJ_INT32)pos;
+        cstr_index->marker[cstr_index->marknum].len = (OPJ_INT32)len;
+        cstr_index->marknum++;
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_add_tlmarker(OPJ_UINT32 tileno, opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len)
+{
+        assert(cstr_index != 00);
+        assert(cstr_index->tile_index != 00);
+
+        /* expand the list? */
+        if ((cstr_index->tile_index[tileno].marknum + 1) > cstr_index->tile_index[tileno].maxmarknum) {
+                opj_marker_info_t *new_marker;
+                cstr_index->tile_index[tileno].maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_index->tile_index[tileno].maxmarknum);
+                new_marker = (opj_marker_info_t *) opj_realloc(
+                                cstr_index->tile_index[tileno].marker,
+                                cstr_index->tile_index[tileno].maxmarknum *sizeof(opj_marker_info_t));
+                if (! new_marker) {
+                        opj_free(cstr_index->tile_index[tileno].marker);
+                        cstr_index->tile_index[tileno].marker = NULL;
+                        cstr_index->tile_index[tileno].maxmarknum = 0;
+                        cstr_index->tile_index[tileno].marknum = 0;
+                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add tl marker\n"); */
+                        return OPJ_FALSE;
+                }
+                cstr_index->tile_index[tileno].marker = new_marker;
+        }
+
+        /* add the marker */
+        cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].type = (OPJ_UINT16)type;
+        cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].pos = (OPJ_INT32)pos;
+        cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].len = (OPJ_INT32)len;
+        cstr_index->tile_index[tileno].marknum++;
+
+        if (type == J2K_MS_SOT) {
+                OPJ_UINT32 l_current_tile_part = cstr_index->tile_index[tileno].current_tpsno;
+
+                if (cstr_index->tile_index[tileno].tp_index)
+                        cstr_index->tile_index[tileno].tp_index[l_current_tile_part].start_pos = pos;
+
+        }
+        return OPJ_TRUE;
+}
+
+/*
+ * -----------------------------------------------------------------------
+ * -----------------------------------------------------------------------
+ * -----------------------------------------------------------------------
+ */
+
+OPJ_BOOL opj_j2k_end_decompress(opj_j2k_t *p_j2k,
+                                opj_stream_private_t *p_stream,
+                                opj_event_mgr_t * p_manager
+                                )
+{
+    (void)p_j2k;
+    (void)p_stream;
+    (void)p_manager;
+    return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_read_header(   opj_stream_private_t *p_stream,
+                                                            opj_j2k_t* p_j2k,
+                                                            opj_image_t** p_image,
+                                                            opj_event_mgr_t* p_manager )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        /* create an empty image header */
+        p_j2k->m_private_image = opj_image_create0();
+        if (! p_j2k->m_private_image) {
+                return OPJ_FALSE;
+        }
+
+        /* customization of the validation */
+        if (! opj_j2k_setup_decoding_validation(p_j2k, p_manager)) {
+                opj_image_destroy(p_j2k->m_private_image);
+                p_j2k->m_private_image = NULL;
+                return OPJ_FALSE;
+        }
+
+        /* validation of the parameters codec */
+        if (! opj_j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream,p_manager)) {
+                opj_image_destroy(p_j2k->m_private_image);
+                p_j2k->m_private_image = NULL;
+                return OPJ_FALSE;
+        }
+
+        /* customization of the encoding */
+        if (! opj_j2k_setup_header_reading(p_j2k, p_manager)) {
+                opj_image_destroy(p_j2k->m_private_image);
+                p_j2k->m_private_image = NULL;
+                return OPJ_FALSE;
+        }
+
+        /* read header */
+        if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
+                opj_image_destroy(p_j2k->m_private_image);
+                p_j2k->m_private_image = NULL;
+                return OPJ_FALSE;
+        }
+
+        *p_image = opj_image_create0();
+        if (! (*p_image)) {
+                return OPJ_FALSE;
+        }
+
+        /* Copy codestream image information to the output image */
+        opj_copy_image_header(p_j2k->m_private_image, *p_image);
+
+    /*Allocate and initialize some elements of codestrem index*/
+        if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)){
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_setup_header_reading (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
+{
+        /* preconditions*/
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_read_header_procedure, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        /* DEVELOPER CORNER, add your custom procedures */
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_copy_default_tcp_and_create_tcd, p_manager))  {
+                return OPJ_FALSE;
+        }
+	
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
+{
+        /* preconditions*/
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,(opj_procedure)opj_j2k_build_decoder, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,(opj_procedure)opj_j2k_decoding_validation, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        /* DEVELOPER CORNER, add your custom validation procedure */
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_mct_validation (       opj_j2k_t * p_j2k,
+                                                                opj_stream_private_t *p_stream,
+                                                                opj_event_mgr_t * p_manager )
+{
+        OPJ_BOOL l_is_valid = OPJ_TRUE;
+        OPJ_UINT32 i,j;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        if ((p_j2k->m_cp.rsiz & 0x8200) == 0x8200) {
+                OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
+                opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
+
+                for (i=0;i<l_nb_tiles;++i) {
+                        if (l_tcp->mct == 2) {
+                                opj_tccp_t * l_tccp = l_tcp->tccps;
+                                l_is_valid &= (l_tcp->m_mct_coding_matrix != 00);
+
+                                for (j=0;j<p_j2k->m_private_image->numcomps;++j) {
+                                        l_is_valid &= ! (l_tccp->qmfbid & 1);
+                                        ++l_tccp;
+                                }
+                        }
+                        ++l_tcp;
+                }
+        }
+
+        return l_is_valid;
+}
+
+OPJ_BOOL opj_j2k_setup_mct_encoding(opj_tcp_t * p_tcp, opj_image_t * p_image)
+{
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_indix = 1;
+        opj_mct_data_t * l_mct_deco_data = 00,* l_mct_offset_data = 00;
+        opj_simple_mcc_decorrelation_data_t * l_mcc_data;
+        OPJ_UINT32 l_mct_size,l_nb_elem;
+        OPJ_FLOAT32 * l_data, * l_current_data;
+        opj_tccp_t * l_tccp;
+
+        /* preconditions */
+        assert(p_tcp != 00);
+
+        if (p_tcp->mct != 2) {
+                return OPJ_TRUE;
+        }
+
+        if (p_tcp->m_mct_decoding_matrix) {
+                if (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records) {
+                        opj_mct_data_t *new_mct_records;
+                        p_tcp->m_nb_max_mct_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
+
+                        new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records, p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
+                        if (! new_mct_records) {
+                                opj_free(p_tcp->m_mct_records);
+                                p_tcp->m_mct_records = NULL;
+                                p_tcp->m_nb_max_mct_records = 0;
+                                p_tcp->m_nb_mct_records = 0;
+                                /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup mct encoding\n"); */
+                                return OPJ_FALSE;
+                        }
+                        p_tcp->m_mct_records = new_mct_records;
+                        l_mct_deco_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
+
+                        memset(l_mct_deco_data ,0,(p_tcp->m_nb_max_mct_records - p_tcp->m_nb_mct_records) * sizeof(opj_mct_data_t));
+                }
+                l_mct_deco_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
+
+                if (l_mct_deco_data->m_data) {
+                        opj_free(l_mct_deco_data->m_data);
+                        l_mct_deco_data->m_data = 00;
+                }
+
+                l_mct_deco_data->m_index = l_indix++;
+                l_mct_deco_data->m_array_type = MCT_TYPE_DECORRELATION;
+                l_mct_deco_data->m_element_type = MCT_TYPE_FLOAT;
+                l_nb_elem = p_image->numcomps * p_image->numcomps;
+                l_mct_size = l_nb_elem * MCT_ELEMENT_SIZE[l_mct_deco_data->m_element_type];
+                l_mct_deco_data->m_data = (OPJ_BYTE*)opj_malloc(l_mct_size );
+
+                if (! l_mct_deco_data->m_data) {
+                        return OPJ_FALSE;
+                }
+
+                j2k_mct_write_functions_from_float[l_mct_deco_data->m_element_type](p_tcp->m_mct_decoding_matrix,l_mct_deco_data->m_data,l_nb_elem);
+
+                l_mct_deco_data->m_data_size = l_mct_size;
+                ++p_tcp->m_nb_mct_records;
+        }
+
+        if (p_tcp->m_nb_mct_records == p_tcp->m_nb_max_mct_records) {
+                opj_mct_data_t *new_mct_records;
+                p_tcp->m_nb_max_mct_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
+                new_mct_records = (opj_mct_data_t *) opj_realloc(p_tcp->m_mct_records, p_tcp->m_nb_max_mct_records * sizeof(opj_mct_data_t));
+                if (! new_mct_records) {
+                        opj_free(p_tcp->m_mct_records);
+                        p_tcp->m_mct_records = NULL;
+                        p_tcp->m_nb_max_mct_records = 0;
+                        p_tcp->m_nb_mct_records = 0;
+                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup mct encoding\n"); */
+                        return OPJ_FALSE;
+                }
+                p_tcp->m_mct_records = new_mct_records;
+                l_mct_offset_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
+
+                memset(l_mct_offset_data ,0,(p_tcp->m_nb_max_mct_records - p_tcp->m_nb_mct_records) * sizeof(opj_mct_data_t));
+
+                if (l_mct_deco_data) {
+                        l_mct_deco_data = l_mct_offset_data - 1;
+                }
+        }
+
+        l_mct_offset_data = p_tcp->m_mct_records + p_tcp->m_nb_mct_records;
+
+        if (l_mct_offset_data->m_data) {
+                opj_free(l_mct_offset_data->m_data);
+                l_mct_offset_data->m_data = 00;
+        }
+
+        l_mct_offset_data->m_index = l_indix++;
+        l_mct_offset_data->m_array_type = MCT_TYPE_OFFSET;
+        l_mct_offset_data->m_element_type = MCT_TYPE_FLOAT;
+        l_nb_elem = p_image->numcomps;
+        l_mct_size = l_nb_elem * MCT_ELEMENT_SIZE[l_mct_offset_data->m_element_type];
+        l_mct_offset_data->m_data = (OPJ_BYTE*)opj_malloc(l_mct_size );
+
+        if (! l_mct_offset_data->m_data) {
+                return OPJ_FALSE;
+        }
+
+        l_data = (OPJ_FLOAT32*)opj_malloc(l_nb_elem * sizeof(OPJ_FLOAT32));
+        if (! l_data) {
+                opj_free(l_mct_offset_data->m_data);
+                l_mct_offset_data->m_data = 00;
+                return OPJ_FALSE;
+        }
+
+        l_tccp = p_tcp->tccps;
+        l_current_data = l_data;
+
+        for (i=0;i<l_nb_elem;++i) {
+                *(l_current_data++) = (OPJ_FLOAT32) (l_tccp->m_dc_level_shift);
+                ++l_tccp;
+        }
+
+        j2k_mct_write_functions_from_float[l_mct_offset_data->m_element_type](l_data,l_mct_offset_data->m_data,l_nb_elem);
+
+        opj_free(l_data);
+
+        l_mct_offset_data->m_data_size = l_mct_size;
+
+        ++p_tcp->m_nb_mct_records;
+
+        if (p_tcp->m_nb_mcc_records == p_tcp->m_nb_max_mcc_records) {
+                opj_simple_mcc_decorrelation_data_t *new_mcc_records;
+                p_tcp->m_nb_max_mcc_records += OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
+                new_mcc_records = (opj_simple_mcc_decorrelation_data_t *) opj_realloc(
+                                p_tcp->m_mcc_records, p_tcp->m_nb_max_mcc_records * sizeof(opj_simple_mcc_decorrelation_data_t));
+                if (! new_mcc_records) {
+                        opj_free(p_tcp->m_mcc_records);
+                        p_tcp->m_mcc_records = NULL;
+                        p_tcp->m_nb_max_mcc_records = 0;
+                        p_tcp->m_nb_mcc_records = 0;
+                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup mct encoding\n"); */
+                        return OPJ_FALSE;
+                }
+                p_tcp->m_mcc_records = new_mcc_records;
+                l_mcc_data = p_tcp->m_mcc_records + p_tcp->m_nb_mcc_records;
+                memset(l_mcc_data ,0,(p_tcp->m_nb_max_mcc_records - p_tcp->m_nb_mcc_records) * sizeof(opj_simple_mcc_decorrelation_data_t));
+
+        }
+
+        l_mcc_data = p_tcp->m_mcc_records + p_tcp->m_nb_mcc_records;
+        l_mcc_data->m_decorrelation_array = l_mct_deco_data;
+        l_mcc_data->m_is_irreversible = 1;
+        l_mcc_data->m_nb_comps = p_image->numcomps;
+        l_mcc_data->m_index = l_indix++;
+        l_mcc_data->m_offset_array = l_mct_offset_data;
+        ++p_tcp->m_nb_mcc_records;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_build_decoder (opj_j2k_t * p_j2k,
+                                                            opj_stream_private_t *p_stream,
+                                                            opj_event_mgr_t * p_manager )
+{
+        /* add here initialization of cp
+           copy paste of setup_decoder */
+  (void)p_j2k;
+  (void)p_stream;
+  (void)p_manager;
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_build_encoder (opj_j2k_t * p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager )
+{
+        /* add here initialization of cp
+           copy paste of setup_encoder */
+  (void)p_j2k;
+  (void)p_stream;
+  (void)p_manager;
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_encoding_validation (  opj_j2k_t * p_j2k,
+                                                                            opj_stream_private_t *p_stream,
+                                                                            opj_event_mgr_t * p_manager )
+{
+        OPJ_BOOL l_is_valid = OPJ_TRUE;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        /* STATE checking */
+        /* make sure the state is at 0 */
+        l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NONE);
+
+        /* POINTER validation */
+        /* make sure a p_j2k codec is present */
+        l_is_valid &= (p_j2k->m_procedure_list != 00);
+        /* make sure a validation list is present */
+        l_is_valid &= (p_j2k->m_validation_list != 00);
+
+        /* ISO 15444-1:2004 states between 1 & 33 (0 -> 32) */
+        /* 33 (32) would always fail the check below (if a cast to 64bits was done) */
+        /* FIXME Shall we change OPJ_J2K_MAXRLVLS to 32 ? */
+        if ((p_j2k->m_cp.tcps->tccps->numresolutions <= 0) || (p_j2k->m_cp.tcps->tccps->numresolutions > 32)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is too high in comparison to the size of tiles\n");
+                return OPJ_FALSE;
+        }
+
+        if ((p_j2k->m_cp.tdx) < (OPJ_UINT32) (1 << (p_j2k->m_cp.tcps->tccps->numresolutions - 1U))) {
+                opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is too high in comparison to the size of tiles\n");
+                return OPJ_FALSE;
+        }
+
+        if ((p_j2k->m_cp.tdy) < (OPJ_UINT32) (1 << (p_j2k->m_cp.tcps->tccps->numresolutions - 1U))) {
+                opj_event_msg(p_manager, EVT_ERROR, "Number of resolutions is too high in comparison to the size of tiles\n");
+                return OPJ_FALSE;
+        }
+
+        /* PARAMETER VALIDATION */
+        return l_is_valid;
+}
+
+static OPJ_BOOL opj_j2k_decoding_validation (  opj_j2k_t *p_j2k,
+                                        opj_stream_private_t *p_stream,
+                                        opj_event_mgr_t * p_manager
+                                        )
+{
+        OPJ_BOOL l_is_valid = OPJ_TRUE;
+
+        /* preconditions*/
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        /* STATE checking */
+        /* make sure the state is at 0 */
+#ifdef TODO_MSD
+        l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_NONE);
+#endif
+        l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == 0x0000);
+
+        /* POINTER validation */
+        /* make sure a p_j2k codec is present */
+        /* make sure a procedure list is present */
+        l_is_valid &= (p_j2k->m_procedure_list != 00);
+        /* make sure a validation list is present */
+        l_is_valid &= (p_j2k->m_validation_list != 00);
+
+        /* PARAMETER VALIDATION */
+        return l_is_valid;
+}
+
+static OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k,
+                                                                            opj_stream_private_t *p_stream,
+                                                                            opj_event_mgr_t * p_manager)
+{
+        OPJ_UINT32 l_current_marker;
+        OPJ_UINT32 l_marker_size;
+        const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
+        OPJ_BOOL l_has_siz = 0;
+        OPJ_BOOL l_has_cod = 0;
+        OPJ_BOOL l_has_qcd = 0;
+
+        /* preconditions */
+        assert(p_stream != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        /*  We enter in the main header */
+        p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSOC;
+
+        /* Try to read the SOC marker, the codestream must begin with SOC marker */
+        if (! opj_j2k_read_soc(p_j2k,p_stream,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Expected a SOC marker \n");
+                return OPJ_FALSE;
+        }
+
+        /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
+        if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                return OPJ_FALSE;
+        }
+
+        /* Read 2 bytes as the new marker ID */
+        opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
+
+        /* Try to read until the SOT is detected */
+        while (l_current_marker != J2K_MS_SOT) {
+
+                /* Check if the current marker ID is valid */
+                if (l_current_marker < 0xff00) {
+                        opj_event_msg(p_manager, EVT_ERROR, "A marker ID was expected (0xff--) instead of %.8x\n", l_current_marker);
+                        return OPJ_FALSE;
+                }
+
+                /* Get the marker handler from the marker ID */
+                l_marker_handler = opj_j2k_get_marker_handler(l_current_marker);
+
+                /* Manage case where marker is unknown */
+                if (l_marker_handler->id == J2K_MS_UNK) {
+                        if (! opj_j2k_read_unk(p_j2k, p_stream, &l_current_marker, p_manager)){
+                                opj_event_msg(p_manager, EVT_ERROR, "Unknow marker have been detected and generated error.\n");
+                                return OPJ_FALSE;
+                        }
+
+                        if (l_current_marker == J2K_MS_SOT)
+                                break; /* SOT marker is detected main header is completely read */
+                        else    /* Get the marker handler from the marker ID */
+                                l_marker_handler = opj_j2k_get_marker_handler(l_current_marker);
+                }
+
+                if (l_marker_handler->id == J2K_MS_SIZ) {
+                    /* Mark required SIZ marker as found */
+                    l_has_siz = 1;
+                }
+                if (l_marker_handler->id == J2K_MS_COD) {
+                    /* Mark required COD marker as found */
+                    l_has_cod = 1;
+                }
+                if (l_marker_handler->id == J2K_MS_QCD) {
+                    /* Mark required QCD marker as found */
+                    l_has_qcd = 1;
+                }
+
+                /* Check if the marker is known and if it is the right place to find it */
+                if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) ) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
+                        return OPJ_FALSE;
+                }
+
+                /* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
+                if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                        return OPJ_FALSE;
+                }
+
+                /* read 2 bytes as the marker size */
+                opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2);
+                l_marker_size -= 2; /* Subtract the size of the marker ID already read */
+
+                /* Check if the marker size is compatible with the header data size */
+                if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size) {
+                        OPJ_BYTE *new_header_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size);
+                        if (! new_header_data) {
+                                opj_free(p_j2k->m_specific_param.m_decoder.m_header_data);
+                                p_j2k->m_specific_param.m_decoder.m_header_data = NULL;
+                                p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
+                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read header\n");
+                                return OPJ_FALSE;
+                        }
+                        p_j2k->m_specific_param.m_decoder.m_header_data = new_header_data;
+                        p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size;
+                }
+
+                /* Try to read the rest of the marker segment from stream and copy them into the buffer */
+                if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager) != l_marker_size) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                        return OPJ_FALSE;
+                }
+
+                /* Read the marker segment with the correct marker handler */
+                if (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager)) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Marker handler function failed to read the marker segment\n");
+                        return OPJ_FALSE;
+                }
+
+                /* Add the marker to the codestream index*/
+                if (OPJ_FALSE == opj_j2k_add_mhmarker(
+                                        p_j2k->cstr_index,
+                                        l_marker_handler->id,
+                                        (OPJ_UINT32) opj_stream_tell(p_stream) - l_marker_size - 4,
+                                        l_marker_size + 4 )) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n");
+                        return OPJ_FALSE;
+                }
+
+                /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
+                if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                        return OPJ_FALSE;
+                }
+
+                /* read 2 bytes as the new marker ID */
+                opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
+        }
+
+        if (l_has_siz == 0) {
+            opj_event_msg(p_manager, EVT_ERROR, "required SIZ marker not found in main header\n");
+            return OPJ_FALSE;
+        }
+        if (l_has_cod == 0) {
+            opj_event_msg(p_manager, EVT_ERROR, "required COD marker not found in main header\n");
+            return OPJ_FALSE;
+        }
+        if (l_has_qcd == 0) {
+            opj_event_msg(p_manager, EVT_ERROR, "required QCD marker not found in main header\n");
+            return OPJ_FALSE;
+        }
+	
+        if (! opj_j2k_merge_ppm(&(p_j2k->m_cp), p_manager)) {
+            opj_event_msg(p_manager, EVT_ERROR, "Failed to merge PPM data\n");
+            return OPJ_FALSE;
+        }
+
+        opj_event_msg(p_manager, EVT_INFO, "Main header has been correctly decoded.\n");
+
+        /* Position of the last element if the main header */
+        p_j2k->cstr_index->main_head_end = (OPJ_UINT32) opj_stream_tell(p_stream) - 2;
+
+        /* Next step: read a tile-part header */
+        p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_exec ( opj_j2k_t * p_j2k,
+                                        opj_procedure_list_t * p_procedure_list,
+                                        opj_stream_private_t *p_stream,
+                                        opj_event_mgr_t * p_manager )
+{
+        OPJ_BOOL (** l_procedure) (opj_j2k_t * ,opj_stream_private_t *,opj_event_mgr_t *) = 00;
+        OPJ_BOOL l_result = OPJ_TRUE;
+        OPJ_UINT32 l_nb_proc, i;
+
+        /* preconditions*/
+        assert(p_procedure_list != 00);
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        l_nb_proc = opj_procedure_list_get_nb_procedures(p_procedure_list);
+        l_procedure = (OPJ_BOOL (**) (opj_j2k_t * ,opj_stream_private_t *,opj_event_mgr_t *)) opj_procedure_list_get_first_procedure(p_procedure_list);
+
+        for     (i=0;i<l_nb_proc;++i) {
+                l_result = l_result && ((*l_procedure) (p_j2k,p_stream,p_manager));
+                ++l_procedure;
+        }
+
+        /* and clear the procedure list at the end.*/
+        opj_procedure_list_clear(p_procedure_list);
+        return l_result;
+}
+
+/* FIXME DOC*/
+static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd (       opj_j2k_t * p_j2k,
+                                                            opj_stream_private_t *p_stream,
+                                                            opj_event_mgr_t * p_manager
+                                                            )
+{
+        opj_tcp_t * l_tcp = 00;
+        opj_tcp_t * l_default_tcp = 00;
+        OPJ_UINT32 l_nb_tiles;
+        OPJ_UINT32 i,j;
+        opj_tccp_t *l_current_tccp = 00;
+        OPJ_UINT32 l_tccp_size;
+        OPJ_UINT32 l_mct_size;
+        opj_image_t * l_image;
+        OPJ_UINT32 l_mcc_records_size,l_mct_records_size;
+        opj_mct_data_t * l_src_mct_rec, *l_dest_mct_rec;
+        opj_simple_mcc_decorrelation_data_t * l_src_mcc_rec, *l_dest_mcc_rec;
+        OPJ_UINT32 l_offset;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        l_image = p_j2k->m_private_image;
+        l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
+        l_tcp = p_j2k->m_cp.tcps;
+        l_tccp_size = l_image->numcomps * (OPJ_UINT32)sizeof(opj_tccp_t);
+        l_default_tcp = p_j2k->m_specific_param.m_decoder.m_default_tcp;
+        l_mct_size = l_image->numcomps * l_image->numcomps * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
+
+        /* For each tile */
+        for (i=0; i<l_nb_tiles; ++i) {
+                /* keep the tile-compo coding parameters pointer of the current tile coding parameters*/
+                l_current_tccp = l_tcp->tccps;
+                /*Copy default coding parameters into the current tile coding parameters*/
+                memcpy(l_tcp, l_default_tcp, sizeof(opj_tcp_t));
+                /* Initialize some values of the current tile coding parameters*/
+                l_tcp->cod = 0;
+                l_tcp->ppt = 0;
+                l_tcp->ppt_data = 00;
+                /* Remove memory not owned by this tile in case of early error return. */
+                l_tcp->m_mct_decoding_matrix = 00;
+                l_tcp->m_nb_max_mct_records = 0;
+                l_tcp->m_mct_records = 00;
+                l_tcp->m_nb_max_mcc_records = 0;
+                l_tcp->m_mcc_records = 00;
+                /* Reconnect the tile-compo coding parameters pointer to the current tile coding parameters*/
+                l_tcp->tccps = l_current_tccp;
+
+                /* Get the mct_decoding_matrix of the dflt_tile_cp and copy them into the current tile cp*/
+                if (l_default_tcp->m_mct_decoding_matrix) {
+                        l_tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(l_mct_size);
+                        if (! l_tcp->m_mct_decoding_matrix ) {
+                                return OPJ_FALSE;
+                        }
+                        memcpy(l_tcp->m_mct_decoding_matrix,l_default_tcp->m_mct_decoding_matrix,l_mct_size);
+                }
+
+                /* Get the mct_record of the dflt_tile_cp and copy them into the current tile cp*/
+                l_mct_records_size = l_default_tcp->m_nb_max_mct_records * (OPJ_UINT32)sizeof(opj_mct_data_t);
+                l_tcp->m_mct_records = (opj_mct_data_t*)opj_malloc(l_mct_records_size);
+                if (! l_tcp->m_mct_records) {
+                        return OPJ_FALSE;
+                }
+                memcpy(l_tcp->m_mct_records, l_default_tcp->m_mct_records,l_mct_records_size);
+
+                /* Copy the mct record data from dflt_tile_cp to the current tile*/
+                l_src_mct_rec = l_default_tcp->m_mct_records;
+                l_dest_mct_rec = l_tcp->m_mct_records;
+
+                for (j=0;j<l_default_tcp->m_nb_mct_records;++j) {
+
+                        if (l_src_mct_rec->m_data) {
+
+                                l_dest_mct_rec->m_data = (OPJ_BYTE*) opj_malloc(l_src_mct_rec->m_data_size);
+                                if(! l_dest_mct_rec->m_data) {
+                                        return OPJ_FALSE;
+                                }
+                                memcpy(l_dest_mct_rec->m_data,l_src_mct_rec->m_data,l_src_mct_rec->m_data_size);
+                        }
+
+                        ++l_src_mct_rec;
+                        ++l_dest_mct_rec;
+                        /* Update with each pass to free exactly what has been allocated on early return. */
+                        l_tcp->m_nb_max_mct_records += 1;
+                }
+
+                /* Get the mcc_record of the dflt_tile_cp and copy them into the current tile cp*/
+                l_mcc_records_size = l_default_tcp->m_nb_max_mcc_records * (OPJ_UINT32)sizeof(opj_simple_mcc_decorrelation_data_t);
+                l_tcp->m_mcc_records = (opj_simple_mcc_decorrelation_data_t*) opj_malloc(l_mcc_records_size);
+                if (! l_tcp->m_mcc_records) {
+                        return OPJ_FALSE;
+                }
+                memcpy(l_tcp->m_mcc_records,l_default_tcp->m_mcc_records,l_mcc_records_size);
+                l_tcp->m_nb_max_mcc_records = l_default_tcp->m_nb_max_mcc_records;
+
+                /* Copy the mcc record data from dflt_tile_cp to the current tile*/
+                l_src_mcc_rec = l_default_tcp->m_mcc_records;
+                l_dest_mcc_rec = l_tcp->m_mcc_records;
+
+                for (j=0;j<l_default_tcp->m_nb_max_mcc_records;++j) {
+
+                        if (l_src_mcc_rec->m_decorrelation_array) {
+                                l_offset = (OPJ_UINT32)(l_src_mcc_rec->m_decorrelation_array - l_default_tcp->m_mct_records);
+                                l_dest_mcc_rec->m_decorrelation_array = l_tcp->m_mct_records + l_offset;
+                        }
+
+                        if (l_src_mcc_rec->m_offset_array) {
+                                l_offset = (OPJ_UINT32)(l_src_mcc_rec->m_offset_array - l_default_tcp->m_mct_records);
+                                l_dest_mcc_rec->m_offset_array = l_tcp->m_mct_records + l_offset;
+                        }
+
+                        ++l_src_mcc_rec;
+                        ++l_dest_mcc_rec;
+                }
+
+                /* Copy all the dflt_tile_compo_cp to the current tile cp */
+                memcpy(l_current_tccp,l_default_tcp->tccps,l_tccp_size);
+
+                /* Move to next tile cp*/
+                ++l_tcp;
+        }
+
+        /* Create the current tile decoder*/
+        p_j2k->m_tcd = (opj_tcd_t*)opj_tcd_create(OPJ_TRUE); /* FIXME why a cast ? */
+        if (! p_j2k->m_tcd ) {
+                return OPJ_FALSE;
+        }
+
+        if ( !opj_tcd_init(p_j2k->m_tcd, l_image, &(p_j2k->m_cp)) ) {
+                opj_tcd_destroy(p_j2k->m_tcd);
+                p_j2k->m_tcd = 00;
+                opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static const opj_dec_memory_marker_handler_t * opj_j2k_get_marker_handler (OPJ_UINT32 p_id)
+{
+        const opj_dec_memory_marker_handler_t *e;
+        for (e = j2k_memory_marker_handler_tab; e->id != 0; ++e) {
+                if (e->id == p_id) {
+                        break; /* we find a handler corresponding to the marker ID*/
+                }
+        }
+        return e;
+}
+
+void opj_j2k_destroy (opj_j2k_t *p_j2k)
+{
+        if (p_j2k == 00) {
+                return;
+        }
+
+        if (p_j2k->m_is_decoder) {
+
+                if (p_j2k->m_specific_param.m_decoder.m_default_tcp != 00) {
+                        opj_j2k_tcp_destroy(p_j2k->m_specific_param.m_decoder.m_default_tcp);
+                        opj_free(p_j2k->m_specific_param.m_decoder.m_default_tcp);
+                        p_j2k->m_specific_param.m_decoder.m_default_tcp = 00;
+                }
+
+                if (p_j2k->m_specific_param.m_decoder.m_header_data != 00) {
+                        opj_free(p_j2k->m_specific_param.m_decoder.m_header_data);
+                        p_j2k->m_specific_param.m_decoder.m_header_data = 00;
+                        p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
+                }
+        }
+        else {
+
+                if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 00;
+                }
+
+                if (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer);
+                        p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 00;
+                        p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 00;
+                }
+
+                if (p_j2k->m_specific_param.m_encoder.m_header_tile_data) {
+                        opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data = 00;
+                        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+                }
+        }
+
+        opj_tcd_destroy(p_j2k->m_tcd);
+
+        opj_j2k_cp_destroy(&(p_j2k->m_cp));
+        memset(&(p_j2k->m_cp),0,sizeof(opj_cp_t));
+
+        opj_procedure_list_destroy(p_j2k->m_procedure_list);
+        p_j2k->m_procedure_list = 00;
+
+        opj_procedure_list_destroy(p_j2k->m_validation_list);
+        p_j2k->m_procedure_list = 00;
+
+        j2k_destroy_cstr_index(p_j2k->cstr_index);
+        p_j2k->cstr_index = NULL;
+
+        opj_image_destroy(p_j2k->m_private_image);
+        p_j2k->m_private_image = NULL;
+
+        opj_image_destroy(p_j2k->m_output_image);
+        p_j2k->m_output_image = NULL;
+
+        opj_free(p_j2k);
+}
+
+void j2k_destroy_cstr_index (opj_codestream_index_t *p_cstr_ind)
+{
+        if (p_cstr_ind) {
+
+                if (p_cstr_ind->marker) {
+                        opj_free(p_cstr_ind->marker);
+                        p_cstr_ind->marker = NULL;
+                }
+
+                if (p_cstr_ind->tile_index) {
+                        OPJ_UINT32 it_tile = 0;
+
+                        for (it_tile=0; it_tile < p_cstr_ind->nb_of_tiles; it_tile++) {
+
+                                if(p_cstr_ind->tile_index[it_tile].packet_index) {
+                                        opj_free(p_cstr_ind->tile_index[it_tile].packet_index);
+                                        p_cstr_ind->tile_index[it_tile].packet_index = NULL;
+                                }
+
+                                if(p_cstr_ind->tile_index[it_tile].tp_index){
+                                        opj_free(p_cstr_ind->tile_index[it_tile].tp_index);
+                                        p_cstr_ind->tile_index[it_tile].tp_index = NULL;
+                                }
+
+                                if(p_cstr_ind->tile_index[it_tile].marker){
+                                        opj_free(p_cstr_ind->tile_index[it_tile].marker);
+                                        p_cstr_ind->tile_index[it_tile].marker = NULL;
+
+                                }
+                        }
+
+                        opj_free( p_cstr_ind->tile_index);
+                        p_cstr_ind->tile_index = NULL;
+                }
+
+                opj_free(p_cstr_ind);
+        }
+}
+
+static void opj_j2k_tcp_destroy (opj_tcp_t *p_tcp)
+{
+	if (p_tcp == 00) {
+		return;
+	}
+	
+	if (p_tcp->ppt_markers != 00) {
+		OPJ_UINT32 i;
+		for (i = 0U; i < p_tcp->ppt_markers_count; ++i) {
+			if (p_tcp->ppt_markers[i].m_data != NULL) {
+				opj_free(p_tcp->ppt_markers[i].m_data);
+			}
+		}
+		p_tcp->ppt_markers_count = 0U;
+		opj_free(p_tcp->ppt_markers);
+		p_tcp->ppt_markers = NULL;
+	}
+	
+	if (p_tcp->ppt_buffer != 00) {
+		opj_free(p_tcp->ppt_buffer);
+		p_tcp->ppt_buffer = 00;
+	}
+	
+	if (p_tcp->tccps != 00) {
+		opj_free(p_tcp->tccps);
+		p_tcp->tccps = 00;
+	}
+	
+	if (p_tcp->m_mct_coding_matrix != 00) {
+		opj_free(p_tcp->m_mct_coding_matrix);
+		p_tcp->m_mct_coding_matrix = 00;
+	}
+	
+	if (p_tcp->m_mct_decoding_matrix != 00) {
+		opj_free(p_tcp->m_mct_decoding_matrix);
+		p_tcp->m_mct_decoding_matrix = 00;
+	}
+	
+	if (p_tcp->m_mcc_records) {
+		opj_free(p_tcp->m_mcc_records);
+		p_tcp->m_mcc_records = 00;
+		p_tcp->m_nb_max_mcc_records = 0;
+		p_tcp->m_nb_mcc_records = 0;
+	}
+	
+	if (p_tcp->m_mct_records) {
+		opj_mct_data_t * l_mct_data = p_tcp->m_mct_records;
+		OPJ_UINT32 i;
+		
+		for (i=0;i<p_tcp->m_nb_mct_records;++i) {
+			if (l_mct_data->m_data) {
+				opj_free(l_mct_data->m_data);
+				l_mct_data->m_data = 00;
+			}
+			
+			++l_mct_data;
+		}
+		
+		opj_free(p_tcp->m_mct_records);
+		p_tcp->m_mct_records = 00;
+	}
+
+	if (p_tcp->mct_norms != 00) {
+		opj_free(p_tcp->mct_norms);
+		p_tcp->mct_norms = 00;
+	}
+
+	opj_j2k_tcp_data_destroy(p_tcp);
+
+}
+
+static void opj_j2k_tcp_data_destroy (opj_tcp_t *p_tcp)
+{
+        if (p_tcp->m_data) {
+                opj_free(p_tcp->m_data);
+                p_tcp->m_data = NULL;
+                p_tcp->m_data_size = 0;
+        }
+}
+
+static void opj_j2k_cp_destroy (opj_cp_t *p_cp)
+{
+	OPJ_UINT32 l_nb_tiles;
+	opj_tcp_t * l_current_tile = 00;
+
+	if (p_cp == 00)
+	{
+		return;
+	}
+	if (p_cp->tcps != 00)
+	{
+		OPJ_UINT32 i;
+		l_current_tile = p_cp->tcps;
+		l_nb_tiles = p_cp->th * p_cp->tw;
+		
+		for (i = 0U; i < l_nb_tiles; ++i)
+		{
+			opj_j2k_tcp_destroy(l_current_tile);
+			++l_current_tile;
+		}
+		opj_free(p_cp->tcps);
+		p_cp->tcps = 00;
+	}
+	if (p_cp->ppm_markers != 00) {
+		OPJ_UINT32 i;
+		for (i = 0U; i < p_cp->ppm_markers_count; ++i) {
+			if (p_cp->ppm_markers[i].m_data != NULL) {
+				opj_free(p_cp->ppm_markers[i].m_data);
+			}
+		}
+		p_cp->ppm_markers_count = 0U;
+		opj_free(p_cp->ppm_markers);
+		p_cp->ppm_markers = NULL;
+	}
+	opj_free(p_cp->ppm_buffer);
+	p_cp->ppm_buffer = 00;
+	p_cp->ppm_data = NULL; /* ppm_data belongs to the allocated buffer pointed by ppm_buffer */
+	opj_free(p_cp->comment);
+	p_cp->comment = 00;
+	if (! p_cp->m_is_decoder)
+	{
+		opj_free(p_cp->m_specific_param.m_enc.m_matrice);
+		p_cp->m_specific_param.m_enc.m_matrice = 00;
+	}
+}
+
+static OPJ_BOOL opj_j2k_need_nb_tile_parts_correction(opj_stream_private_t *p_stream, OPJ_UINT32 tile_no, OPJ_BOOL* p_correction_needed, opj_event_mgr_t * p_manager )
+{
+	OPJ_BYTE   l_header_data[10];
+	OPJ_OFF_T  l_stream_pos_backup;
+	OPJ_UINT32 l_current_marker;
+	OPJ_UINT32 l_marker_size;
+	OPJ_UINT32 l_tile_no, l_tot_len, l_current_part, l_num_parts;
+	
+	/* initialize to no correction needed */
+	*p_correction_needed = OPJ_FALSE;
+	
+	if (!opj_stream_has_seek(p_stream)) {
+		/* We can't do much in this case, seek is needed */
+		return OPJ_TRUE;
+	}
+	
+	l_stream_pos_backup = opj_stream_tell(p_stream);
+	if (l_stream_pos_backup == -1) {
+		/* let's do nothing */
+		return OPJ_TRUE;
+	}
+	
+	for (;;) {
+		/* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
+		if (opj_stream_read_data(p_stream,l_header_data, 2, p_manager) != 2) {
+			/* assume all is OK */
+			if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
+				return OPJ_FALSE;
+			}
+			return OPJ_TRUE;
+		}
+		
+		/* Read 2 bytes from buffer as the new marker ID */
+		opj_read_bytes(l_header_data, &l_current_marker, 2);
+		
+		if (l_current_marker != J2K_MS_SOT) {
+			/* assume all is OK */
+			if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
+				return OPJ_FALSE;
+			}
+			return OPJ_TRUE;
+		}
+		
+		/* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
+		if (opj_stream_read_data(p_stream, l_header_data, 2, p_manager) != 2) {
+			opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+			return OPJ_FALSE;
+		}
+		
+		/* Read 2 bytes from the buffer as the marker size */
+		opj_read_bytes(l_header_data, &l_marker_size, 2);
+		
+		/* Check marker size for SOT Marker */
+		if (l_marker_size != 10) {
+			opj_event_msg(p_manager, EVT_ERROR, "Inconsistent marker size\n");
+			return OPJ_FALSE;
+		}
+		l_marker_size -= 2;
+		
+		if (opj_stream_read_data(p_stream, l_header_data, l_marker_size, p_manager) != l_marker_size) {
+			opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+			return OPJ_FALSE;
+		}
+		
+		if (! opj_j2k_get_sot_values(l_header_data, l_marker_size, &l_tile_no, &l_tot_len, &l_current_part, &l_num_parts, p_manager)) {
+			return OPJ_FALSE;
+		}
+		
+		if (l_tile_no == tile_no) {
+			/* we found what we were looking for */
+			break;
+		}
+		
+		if ((l_tot_len == 0U) || (l_tot_len < 14U)) {
+			/* last SOT until EOC or invalid Psot value */
+			/* assume all is OK */
+			if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
+				return OPJ_FALSE;
+			}
+			return OPJ_TRUE;
+		}
+		l_tot_len -= 12U;
+		/* look for next SOT marker */
+		if (opj_stream_skip(p_stream, (OPJ_OFF_T)(l_tot_len), p_manager) != (OPJ_OFF_T)(l_tot_len)) {
+			/* assume all is OK */
+			if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
+				return OPJ_FALSE;
+			}
+			return OPJ_TRUE;
+		}
+	}
+	
+	/* check for correction */
+	if (l_current_part == l_num_parts) {
+		*p_correction_needed = OPJ_TRUE;
+	}
+	
+	if (! opj_stream_seek(p_stream, l_stream_pos_backup, p_manager)) {
+		return OPJ_FALSE;
+	}
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_read_tile_header(      opj_j2k_t * p_j2k,
+                                                                    OPJ_UINT32 * p_tile_index,
+                                                                    OPJ_UINT32 * p_data_size,
+                                                                    OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
+                                                                    OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
+                                                                    OPJ_UINT32 * p_nb_comps,
+                                                                    OPJ_BOOL * p_go_on,
+                                                                    opj_stream_private_t *p_stream,
+                                                                    opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 l_current_marker = J2K_MS_SOT;
+        OPJ_UINT32 l_marker_size;
+        const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
+        opj_tcp_t * l_tcp = NULL;
+
+        /* preconditions */
+        assert(p_stream != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        /* Reach the End Of Codestream ?*/
+        if (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_EOC){
+                l_current_marker = J2K_MS_EOC;
+        }
+        /* We need to encounter a SOT marker (a new tile-part header) */
+        else if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT){
+                return OPJ_FALSE;
+        }
+
+        /* Read into the codestream until reach the EOC or ! can_decode ??? FIXME */
+        while ( (!p_j2k->m_specific_param.m_decoder.m_can_decode) && (l_current_marker != J2K_MS_EOC) ) {
+
+                /* Try to read until the Start Of Data is detected */
+                while (l_current_marker != J2K_MS_SOD) {
+                    
+                    if(opj_stream_get_number_byte_left(p_stream) == 0)
+                    {
+                        p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
+                        break;
+                    }
+
+                        /* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
+                        if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                                return OPJ_FALSE;
+                        }
+
+                        /* Read 2 bytes from the buffer as the marker size */
+                        opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2);
+
+                        /* Check marker size (does not include marker ID but includes marker size) */
+                        if (l_marker_size < 2) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Inconsistent marker size\n");
+                                return OPJ_FALSE;
+                        }
+
+                        /* cf. https://code.google.com/p/openjpeg/issues/detail?id=226 */
+                        if (l_current_marker == 0x8080 && opj_stream_get_number_byte_left(p_stream) == 0) {
+                                p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
+                                break;
+                        }
+
+                        /* Why this condition? FIXME */
+                        if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH){
+                                p_j2k->m_specific_param.m_decoder.m_sot_length -= (l_marker_size + 2);
+                        }
+                        l_marker_size -= 2; /* Subtract the size of the marker ID already read */
+
+                        /* Get the marker handler from the marker ID */
+                        l_marker_handler = opj_j2k_get_marker_handler(l_current_marker);
+
+                        /* Check if the marker is known and if it is the right place to find it */
+                        if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) ) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
+                                return OPJ_FALSE;
+                        }
+/* FIXME manage case of unknown marker as in the main header ? */
+
+                        /* Check if the marker size is compatible with the header data size */
+                        if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size) {
+                                OPJ_BYTE *new_header_data = NULL;
+                                /* If we are here, this means we consider this marker as known & we will read it */
+                                /* Check enough bytes left in stream before allocation */
+                                if ((OPJ_OFF_T)l_marker_size >  opj_stream_get_number_byte_left(p_stream)) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "Marker size inconsistent with stream length\n");
+                                        return OPJ_FALSE;
+                                }
+                                new_header_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_decoder.m_header_data, l_marker_size);
+                                if (! new_header_data) {
+                                        opj_free(p_j2k->m_specific_param.m_decoder.m_header_data);
+                                        p_j2k->m_specific_param.m_decoder.m_header_data = NULL;
+                                        p_j2k->m_specific_param.m_decoder.m_header_data_size = 0;
+                                        opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read header\n");
+                                        return OPJ_FALSE;
+                                }
+                                p_j2k->m_specific_param.m_decoder.m_header_data = new_header_data;
+                                p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size;
+                        }
+
+                        /* Try to read the rest of the marker segment from stream and copy them into the buffer */
+                        if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager) != l_marker_size) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                                return OPJ_FALSE;
+                        }
+
+                        if (!l_marker_handler->handler) {
+                                /* See issue #175 */
+                                opj_event_msg(p_manager, EVT_ERROR, "Not sure how that happened.\n");
+                                return OPJ_FALSE;
+                        }
+                        /* Read the marker segment with the correct marker handler */
+                        if (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager)) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Fail to read the current marker segment (%#x)\n", l_current_marker);
+                                return OPJ_FALSE;
+                        }
+
+                        /* Add the marker to the codestream index*/
+                        if (OPJ_FALSE == opj_j2k_add_tlmarker(p_j2k->m_current_tile_number,
+                                                p_j2k->cstr_index,
+                                                l_marker_handler->id,
+                                                (OPJ_UINT32) opj_stream_tell(p_stream) - l_marker_size - 4,
+                                                l_marker_size + 4 )) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add tl marker\n");
+                                return OPJ_FALSE;
+                        }
+
+                        /* Keep the position of the last SOT marker read */
+                        if ( l_marker_handler->id == J2K_MS_SOT ) {
+                                OPJ_UINT32 sot_pos = (OPJ_UINT32) opj_stream_tell(p_stream) - l_marker_size - 4 ;
+                                if (sot_pos > p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos)
+                                {
+                                        p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = sot_pos;
+                                }
+                        }
+
+                        if (p_j2k->m_specific_param.m_decoder.m_skip_data) {
+                                /* Skip the rest of the tile part header*/
+                                if (opj_stream_skip(p_stream,p_j2k->m_specific_param.m_decoder.m_sot_length,p_manager) != p_j2k->m_specific_param.m_decoder.m_sot_length) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                                        return OPJ_FALSE;
+                                }
+                                l_current_marker = J2K_MS_SOD; /* Normally we reached a SOD */
+                        }
+                        else {
+                                /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer*/
+                                if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                                        return OPJ_FALSE;
+                                }
+                                /* Read 2 bytes from the buffer as the new marker ID */
+                                opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
+                        }
+                }
+                if(opj_stream_get_number_byte_left(p_stream) == 0
+                    && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC)
+                    break;
+
+                /* If we didn't skip data before, we need to read the SOD marker*/
+                if (! p_j2k->m_specific_param.m_decoder.m_skip_data) {
+                        /* Try to read the SOD marker and skip data ? FIXME */
+                        if (! opj_j2k_read_sod(p_j2k, p_stream, p_manager)) {
+                                return OPJ_FALSE;
+                        }
+                        if (p_j2k->m_specific_param.m_decoder.m_can_decode && !p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked) {
+                                /* Issue 254 */
+                                OPJ_BOOL l_correction_needed;
+													
+                                p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1;
+                                if(!opj_j2k_need_nb_tile_parts_correction(p_stream, p_j2k->m_current_tile_number, &l_correction_needed, p_manager)) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "opj_j2k_apply_nb_tile_parts_correction error\n");
+                                        return OPJ_FALSE;
+                                }
+                                if (l_correction_needed) {
+                                        OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th;
+                                        OPJ_UINT32 l_tile_no;
+
+                                        p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
+                                        p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction = 1;
+                                        /* correct tiles */
+                                        for (l_tile_no = 0U; l_tile_no < l_nb_tiles; ++l_tile_no) {
+                                                if (p_j2k->m_cp.tcps[l_tile_no].m_nb_tile_parts != 0U) {
+                                                        p_j2k->m_cp.tcps[l_tile_no].m_nb_tile_parts+=1;
+                                                }
+                                        }
+                                        opj_event_msg(p_manager, EVT_WARNING, "Non conformant codestream TPsot==TNsot.\n");
+                                }
+                        }
+                        if (! p_j2k->m_specific_param.m_decoder.m_can_decode){
+                                /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
+                                if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                                        return OPJ_FALSE;
+                                }
+
+                                /* Read 2 bytes from buffer as the new marker ID */
+                                opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
+                        }
+                }
+                else {
+                        /* Indicate we will try to read a new tile-part header*/
+                        p_j2k->m_specific_param.m_decoder.m_skip_data = 0;
+                        p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
+                        p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
+
+                        /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
+                        if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                                return OPJ_FALSE;
+                        }
+
+                        /* Read 2 bytes from buffer as the new marker ID */
+                        opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
+                }
+        }
+
+        /* Current marker is the EOC marker ?*/
+        if (l_current_marker == J2K_MS_EOC) {
+                if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC ){
+                        p_j2k->m_current_tile_number = 0;
+                        p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
+                }
+        }
+
+        /* FIXME DOC ???*/
+        if ( ! p_j2k->m_specific_param.m_decoder.m_can_decode) {
+                OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
+                l_tcp = p_j2k->m_cp.tcps + p_j2k->m_current_tile_number;
+
+                while( (p_j2k->m_current_tile_number < l_nb_tiles) && (l_tcp->m_data == 00) ) {
+                        ++p_j2k->m_current_tile_number;
+                        ++l_tcp;
+                }
+
+                if (p_j2k->m_current_tile_number == l_nb_tiles) {
+                        *p_go_on = OPJ_FALSE;
+                        return OPJ_TRUE;
+                }
+        }
+
+        if (! opj_j2k_merge_ppt(p_j2k->m_cp.tcps + p_j2k->m_current_tile_number, p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Failed to merge PPT data\n");
+                return OPJ_FALSE;
+        }
+        /*FIXME ???*/
+        if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number, p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
+                return OPJ_FALSE;
+        }
+
+        opj_event_msg(p_manager, EVT_INFO, "Header of tile %d / %d has been read.\n",
+                        p_j2k->m_current_tile_number+1, (p_j2k->m_cp.th * p_j2k->m_cp.tw));
+
+        *p_tile_index = p_j2k->m_current_tile_number;
+        *p_go_on = OPJ_TRUE;
+        *p_data_size = opj_tcd_get_decoded_tile_size(p_j2k->m_tcd);
+        *p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0;
+        *p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0;
+        *p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1;
+        *p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1;
+        *p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps;
+
+         p_j2k->m_specific_param.m_decoder.m_state |= 0x0080;/* FIXME J2K_DEC_STATE_DATA;*/
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_decode_tile (  opj_j2k_t * p_j2k,
+                                                        OPJ_UINT32 p_tile_index,
+                                                        OPJ_BYTE * p_data,
+                                                        OPJ_UINT32 p_data_size,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 l_current_marker;
+        OPJ_BYTE l_data [2];
+        opj_tcp_t * l_tcp;
+
+        /* preconditions */
+        assert(p_stream != 00);
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if ( !(p_j2k->m_specific_param.m_decoder.m_state & 0x0080/*FIXME J2K_DEC_STATE_DATA*/)
+                || (p_tile_index != p_j2k->m_current_tile_number) ) {
+                return OPJ_FALSE;
+        }
+
+        l_tcp = &(p_j2k->m_cp.tcps[p_tile_index]);
+        if (! l_tcp->m_data) {
+                opj_j2k_tcp_destroy(l_tcp);
+                return OPJ_FALSE;
+        }
+
+        if (! opj_tcd_decode_tile(      p_j2k->m_tcd,
+                                                                l_tcp->m_data,
+                                                                l_tcp->m_data_size,
+                                                                p_tile_index,
+                                                                p_j2k->cstr_index, p_manager) ) {
+                opj_j2k_tcp_destroy(l_tcp);
+                p_j2k->m_specific_param.m_decoder.m_state |= 0x8000;/*FIXME J2K_DEC_STATE_ERR;*/
+                opj_event_msg(p_manager, EVT_ERROR, "Failed to decode.\n");
+                return OPJ_FALSE;
+        }
+
+        if (! opj_tcd_update_tile_data(p_j2k->m_tcd,p_data,p_data_size)) {
+                return OPJ_FALSE;
+        }
+
+        /* To avoid to destroy the tcp which can be useful when we try to decode a tile decoded before (cf j2k_random_tile_access)
+         * we destroy just the data which will be re-read in read_tile_header*/
+        /*opj_j2k_tcp_destroy(l_tcp);
+        p_j2k->m_tcd->tcp = 0;*/
+        opj_j2k_tcp_data_destroy(l_tcp);
+
+        p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
+        p_j2k->m_specific_param.m_decoder.m_state &= (~ (0x0080u));/* FIXME J2K_DEC_STATE_DATA);*/
+
+        if(opj_stream_get_number_byte_left(p_stream) == 0 
+            && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC){
+            return OPJ_TRUE;
+        }
+
+        if (p_j2k->m_specific_param.m_decoder.m_state != 0x0100){ /*FIXME J2K_DEC_STATE_EOC)*/
+                if (opj_stream_read_data(p_stream,l_data,2,p_manager) != 2) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
+                        return OPJ_FALSE;
+                }
+
+                opj_read_bytes(l_data,&l_current_marker,2);
+
+                if (l_current_marker == J2K_MS_EOC) {
+                        p_j2k->m_current_tile_number = 0;
+                        p_j2k->m_specific_param.m_decoder.m_state =  0x0100;/*FIXME J2K_DEC_STATE_EOC;*/
+                }
+                else if (l_current_marker != J2K_MS_SOT)
+                {       
+                        if(opj_stream_get_number_byte_left(p_stream) == 0) {
+                            p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
+                            opj_event_msg(p_manager, EVT_WARNING, "Stream does not end with EOC\n");
+                            return OPJ_TRUE;
+                        }
+                        opj_event_msg(p_manager, EVT_ERROR, "Stream too short, expected SOT\n");
+                        return OPJ_FALSE;
+                }
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data, opj_image_t* p_output_image)
+{
+        OPJ_UINT32 i,j,k = 0;
+        OPJ_UINT32 l_width_src,l_height_src;
+        OPJ_UINT32 l_width_dest,l_height_dest;
+        OPJ_INT32 l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src;
+        OPJ_SIZE_T l_start_offset_src, l_line_offset_src, l_end_offset_src ;
+        OPJ_UINT32 l_start_x_dest , l_start_y_dest;
+        OPJ_UINT32 l_x0_dest, l_y0_dest, l_x1_dest, l_y1_dest;
+        OPJ_SIZE_T l_start_offset_dest, l_line_offset_dest;
+
+        opj_image_comp_t * l_img_comp_src = 00;
+        opj_image_comp_t * l_img_comp_dest = 00;
+
+        opj_tcd_tilecomp_t * l_tilec = 00;
+        opj_image_t * l_image_src = 00;
+        OPJ_UINT32 l_size_comp, l_remaining;
+        OPJ_INT32 * l_dest_ptr;
+        opj_tcd_resolution_t* l_res= 00;
+
+        l_tilec = p_tcd->tcd_image->tiles->comps;
+        l_image_src = p_tcd->image;
+        l_img_comp_src = l_image_src->comps;
+
+        l_img_comp_dest = p_output_image->comps;
+
+        for (i=0; i<l_image_src->numcomps; i++) {
+
+                /* Allocate output component buffer if necessary */
+                if (!l_img_comp_dest->data) {
+
+                        l_img_comp_dest->data = (OPJ_INT32*) opj_calloc((OPJ_SIZE_T)l_img_comp_dest->w * (OPJ_SIZE_T)l_img_comp_dest->h, sizeof(OPJ_INT32));
+                        if (! l_img_comp_dest->data) {
+                                return OPJ_FALSE;
+                        }
+                }
+
+                /* Copy info from decoded comp image to output image */
+                l_img_comp_dest->resno_decoded = l_img_comp_src->resno_decoded;
+
+                /*-----*/
+                /* Compute the precision of the output buffer */
+                l_size_comp = l_img_comp_src->prec >> 3; /*(/ 8)*/
+                l_remaining = l_img_comp_src->prec & 7;  /* (%8) */
+                l_res = l_tilec->resolutions + l_img_comp_src->resno_decoded;
+
+                if (l_remaining) {
+                        ++l_size_comp;
+                }
+
+                if (l_size_comp == 3) {
+                        l_size_comp = 4;
+                }
+                /*-----*/
+
+                /* Current tile component size*/
+                /*if (i == 0) {
+                fprintf(stdout, "SRC: l_res_x0=%d, l_res_x1=%d, l_res_y0=%d, l_res_y1=%d\n",
+                                l_res->x0, l_res->x1, l_res->y0, l_res->y1);
+                }*/
+
+                l_width_src = (OPJ_UINT32)(l_res->x1 - l_res->x0);
+                l_height_src = (OPJ_UINT32)(l_res->y1 - l_res->y0);
+
+                /* Border of the current output component*/
+                l_x0_dest = opj_uint_ceildivpow2(l_img_comp_dest->x0, l_img_comp_dest->factor);
+                l_y0_dest = opj_uint_ceildivpow2(l_img_comp_dest->y0, l_img_comp_dest->factor);
+                l_x1_dest = l_x0_dest + l_img_comp_dest->w; /* can't overflow given that image->x1 is uint32 */
+                l_y1_dest = l_y0_dest + l_img_comp_dest->h;
+
+                /*if (i == 0) {
+                fprintf(stdout, "DEST: l_x0_dest=%d, l_x1_dest=%d, l_y0_dest=%d, l_y1_dest=%d (%d)\n",
+                                l_x0_dest, l_x1_dest, l_y0_dest, l_y1_dest, l_img_comp_dest->factor );
+                }*/
+
+                /*-----*/
+                /* Compute the area (l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src)
+                 * of the input buffer (decoded tile component) which will be move
+                 * in the output buffer. Compute the area of the output buffer (l_start_x_dest,
+                 * l_start_y_dest, l_width_dest, l_height_dest)  which will be modified
+                 * by this input area.
+                 * */
+                assert( l_res->x0 >= 0);
+                assert( l_res->x1 >= 0);
+                if ( l_x0_dest < (OPJ_UINT32)l_res->x0 ) {
+                        l_start_x_dest = (OPJ_UINT32)l_res->x0 - l_x0_dest;
+                        l_offset_x0_src = 0;
+
+                        if ( l_x1_dest >= (OPJ_UINT32)l_res->x1 ) {
+                                l_width_dest = l_width_src;
+                                l_offset_x1_src = 0;
+                        }
+                        else {
+                                l_width_dest = l_x1_dest - (OPJ_UINT32)l_res->x0 ;
+                                l_offset_x1_src = (OPJ_INT32)(l_width_src - l_width_dest);
+                        }
+                }
+                else {
+                        l_start_x_dest = 0U;
+                        l_offset_x0_src = (OPJ_INT32)l_x0_dest - l_res->x0;
+
+                        if ( l_x1_dest >= (OPJ_UINT32)l_res->x1 ) {
+                                l_width_dest = l_width_src - (OPJ_UINT32)l_offset_x0_src;
+                                l_offset_x1_src = 0;
+                        }
+                        else {
+                                l_width_dest = l_img_comp_dest->w ;
+                                l_offset_x1_src = l_res->x1 - (OPJ_INT32)l_x1_dest;
+                        }
+                }
+
+                if ( l_y0_dest < (OPJ_UINT32)l_res->y0 ) {
+                        l_start_y_dest = (OPJ_UINT32)l_res->y0 - l_y0_dest;
+                        l_offset_y0_src = 0;
+
+                        if ( l_y1_dest >= (OPJ_UINT32)l_res->y1 ) {
+                                l_height_dest = l_height_src;
+                                l_offset_y1_src = 0;
+                        }
+                        else {
+                                l_height_dest = l_y1_dest - (OPJ_UINT32)l_res->y0 ;
+                                l_offset_y1_src =  (OPJ_INT32)(l_height_src - l_height_dest);
+                        }
+                }
+                else {
+                        l_start_y_dest = 0U;
+                        l_offset_y0_src = (OPJ_INT32)l_y0_dest - l_res->y0;
+
+                        if ( l_y1_dest >= (OPJ_UINT32)l_res->y1 ) {
+                                l_height_dest = l_height_src - (OPJ_UINT32)l_offset_y0_src;
+                                l_offset_y1_src = 0;
+                        }
+                        else {
+                                l_height_dest = l_img_comp_dest->h ;
+                                l_offset_y1_src = l_res->y1 - (OPJ_INT32)l_y1_dest;
+                        }
+                }
+
+                if( (l_offset_x0_src < 0 ) || (l_offset_y0_src < 0 ) || (l_offset_x1_src < 0 ) || (l_offset_y1_src < 0 ) ){
+                        return OPJ_FALSE;
+                }
+                /* testcase 2977.pdf.asan.67.2198 */
+                if ((OPJ_INT32)l_width_dest < 0 || (OPJ_INT32)l_height_dest < 0) {
+                        return OPJ_FALSE;
+                }
+                /*-----*/
+
+                /* Compute the input buffer offset */
+                l_start_offset_src = (OPJ_SIZE_T)l_offset_x0_src + (OPJ_SIZE_T)l_offset_y0_src * (OPJ_SIZE_T)l_width_src;
+                l_line_offset_src  = (OPJ_SIZE_T)l_offset_x1_src + (OPJ_SIZE_T)l_offset_x0_src;
+                l_end_offset_src   = (OPJ_SIZE_T)l_offset_y1_src * (OPJ_SIZE_T)l_width_src - (OPJ_SIZE_T)l_offset_x0_src;
+
+                /* Compute the output buffer offset */
+                l_start_offset_dest = (OPJ_SIZE_T)l_start_x_dest + (OPJ_SIZE_T)l_start_y_dest * (OPJ_SIZE_T)l_img_comp_dest->w;
+                l_line_offset_dest  = (OPJ_SIZE_T)l_img_comp_dest->w - (OPJ_SIZE_T)l_width_dest;
+
+                /* Move the output buffer to the first place where we will write*/
+                l_dest_ptr = l_img_comp_dest->data + l_start_offset_dest;
+
+                /*if (i == 0) {
+                        fprintf(stdout, "COMPO[%d]:\n",i);
+                        fprintf(stdout, "SRC: l_start_x_src=%d, l_start_y_src=%d, l_width_src=%d, l_height_src=%d\n"
+                                        "\t tile offset:%d, %d, %d, %d\n"
+                                        "\t buffer offset: %d; %d, %d\n",
+                                        l_res->x0, l_res->y0, l_width_src, l_height_src,
+                                        l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src,
+                                        l_start_offset_src, l_line_offset_src, l_end_offset_src);
+
+                        fprintf(stdout, "DEST: l_start_x_dest=%d, l_start_y_dest=%d, l_width_dest=%d, l_height_dest=%d\n"
+                                        "\t start offset: %d, line offset= %d\n",
+                                        l_start_x_dest, l_start_y_dest, l_width_dest, l_height_dest, l_start_offset_dest, l_line_offset_dest);
+                }*/
+
+                switch (l_size_comp) {
+                        case 1:
+                                {
+                                        OPJ_CHAR * l_src_ptr = (OPJ_CHAR*) p_data;
+                                        l_src_ptr += l_start_offset_src; /* Move to the first place where we will read*/
+
+                                        if (l_img_comp_src->sgnd) {
+                                                for (j = 0 ; j < l_height_dest ; ++j) {
+                                                        for ( k = 0 ; k < l_width_dest ; ++k) {
+                                                                *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++)); /* Copy only the data needed for the output image */
+                                                        }
+
+                                                        l_dest_ptr+= l_line_offset_dest; /* Move to the next place where we will write */
+                                                        l_src_ptr += l_line_offset_src ; /* Move to the next place where we will read */
+                                                }
+                                        }
+                                        else {
+                                                for ( j = 0 ; j < l_height_dest ; ++j ) {
+                                                        for ( k = 0 ; k < l_width_dest ; ++k) {
+                                                                *(l_dest_ptr++) = (OPJ_INT32) ((*(l_src_ptr++))&0xff);
+                                                        }
+
+                                                        l_dest_ptr+= l_line_offset_dest;
+                                                        l_src_ptr += l_line_offset_src;
+                                                }
+                                        }
+
+                                        l_src_ptr += l_end_offset_src; /* Move to the end of this component-part of the input buffer */
+                                        p_data = (OPJ_BYTE*) l_src_ptr; /* Keep the current position for the next component-part */
+                                }
+                                break;
+                        case 2:
+                                {
+                                        OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_data;
+                                        l_src_ptr += l_start_offset_src;
+
+                                        if (l_img_comp_src->sgnd) {
+                                                for (j=0;j<l_height_dest;++j) {
+                                                        for (k=0;k<l_width_dest;++k) {
+                                                                *(l_dest_ptr++) = *(l_src_ptr++);
+                                                        }
+
+                                                        l_dest_ptr+= l_line_offset_dest;
+                                                        l_src_ptr += l_line_offset_src ;
+                                                }
+                                        }
+                                        else {
+                                                for (j=0;j<l_height_dest;++j) {
+                                                        for (k=0;k<l_width_dest;++k) {
+                                                                *(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
+                                                        }
+
+                                                        l_dest_ptr+= l_line_offset_dest;
+                                                        l_src_ptr += l_line_offset_src ;
+                                                }
+                                        }
+
+                                        l_src_ptr += l_end_offset_src;
+                                        p_data = (OPJ_BYTE*) l_src_ptr;
+                                }
+                                break;
+                        case 4:
+                                {
+                                        OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_data;
+                                        l_src_ptr += l_start_offset_src;
+
+                                        for (j=0;j<l_height_dest;++j) {
+                                                for (k=0;k<l_width_dest;++k) {
+                                                        *(l_dest_ptr++) = (*(l_src_ptr++));
+                                                }
+
+                                                l_dest_ptr+= l_line_offset_dest;
+                                                l_src_ptr += l_line_offset_src ;
+                                        }
+
+                                        l_src_ptr += l_end_offset_src;
+                                        p_data = (OPJ_BYTE*) l_src_ptr;
+                                }
+                                break;
+                }
+
+                ++l_img_comp_dest;
+                ++l_img_comp_src;
+                ++l_tilec;
+        }
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_set_decode_area(       opj_j2k_t *p_j2k,
+                                                                    opj_image_t* p_image,
+                                                                    OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
+                                                                    OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
+                                                                    opj_event_mgr_t * p_manager )
+{
+        opj_cp_t * l_cp = &(p_j2k->m_cp);
+        opj_image_t * l_image = p_j2k->m_private_image;
+
+        OPJ_UINT32 it_comp;
+        OPJ_INT32 l_comp_x1, l_comp_y1;
+        opj_image_comp_t* l_img_comp = NULL;
+
+        /* Check if we are read the main header */
+        if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT) { /* FIXME J2K_DEC_STATE_TPHSOT)*/
+                opj_event_msg(p_manager, EVT_ERROR, "Need to decode the main header before begin to decode the remaining codestream");
+                return OPJ_FALSE;
+        }
+
+        if ( !p_start_x && !p_start_y && !p_end_x && !p_end_y){
+                opj_event_msg(p_manager, EVT_INFO, "No decoded area parameters, set the decoded area to the whole image\n");
+
+                p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
+                p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
+                p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
+                p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
+
+                return OPJ_TRUE;
+        }
+
+        /* ----- */
+        /* Check if the positions provided by the user are correct */
+
+        /* Left */
+        assert(p_start_x >= 0 );
+        assert(p_start_y >= 0 );
+
+        if ((OPJ_UINT32)p_start_x > l_image->x1 ) {
+                opj_event_msg(p_manager, EVT_ERROR,
+                        "Left position of the decoded area (region_x0=%d) is outside the image area (Xsiz=%d).\n",
+                        p_start_x, l_image->x1);
+                return OPJ_FALSE;
+        }
+        else if ((OPJ_UINT32)p_start_x < l_image->x0){
+                opj_event_msg(p_manager, EVT_WARNING,
+                                "Left position of the decoded area (region_x0=%d) is outside the image area (XOsiz=%d).\n",
+                                p_start_x, l_image->x0);
+                p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
+                p_image->x0 = l_image->x0;
+        }
+        else {
+                p_j2k->m_specific_param.m_decoder.m_start_tile_x = ((OPJ_UINT32)p_start_x - l_cp->tx0) / l_cp->tdx;
+                p_image->x0 = (OPJ_UINT32)p_start_x;
+        }
+
+        /* Up */
+        if ((OPJ_UINT32)p_start_y > l_image->y1){
+                opj_event_msg(p_manager, EVT_ERROR,
+                                "Up position of the decoded area (region_y0=%d) is outside the image area (Ysiz=%d).\n",
+                                p_start_y, l_image->y1);
+                return OPJ_FALSE;
+        }
+        else if ((OPJ_UINT32)p_start_y < l_image->y0){
+                opj_event_msg(p_manager, EVT_WARNING,
+                                "Up position of the decoded area (region_y0=%d) is outside the image area (YOsiz=%d).\n",
+                                p_start_y, l_image->y0);
+                p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
+                p_image->y0 = l_image->y0;
+        }
+        else {
+                p_j2k->m_specific_param.m_decoder.m_start_tile_y = ((OPJ_UINT32)p_start_y - l_cp->ty0) / l_cp->tdy;
+                p_image->y0 = (OPJ_UINT32)p_start_y;
+        }
+
+        /* Right */
+        assert((OPJ_UINT32)p_end_x > 0);
+        assert((OPJ_UINT32)p_end_y > 0);
+        if ((OPJ_UINT32)p_end_x < l_image->x0) {
+                opj_event_msg(p_manager, EVT_ERROR,
+                        "Right position of the decoded area (region_x1=%d) is outside the image area (XOsiz=%d).\n",
+                        p_end_x, l_image->x0);
+                return OPJ_FALSE;
+        }
+        else if ((OPJ_UINT32)p_end_x > l_image->x1) {
+                opj_event_msg(p_manager, EVT_WARNING,
+                        "Right position of the decoded area (region_x1=%d) is outside the image area (Xsiz=%d).\n",
+                        p_end_x, l_image->x1);
+                p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
+                p_image->x1 = l_image->x1;
+        }
+        else {
+                p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv(p_end_x - (OPJ_INT32)l_cp->tx0, (OPJ_INT32)l_cp->tdx);
+                p_image->x1 = (OPJ_UINT32)p_end_x;
+        }
+
+        /* Bottom */
+        if ((OPJ_UINT32)p_end_y < l_image->y0) {
+                opj_event_msg(p_manager, EVT_ERROR,
+                        "Bottom position of the decoded area (region_y1=%d) is outside the image area (YOsiz=%d).\n",
+                        p_end_y, l_image->y0);
+                return OPJ_FALSE;
+        }
+        if ((OPJ_UINT32)p_end_y > l_image->y1){
+                opj_event_msg(p_manager, EVT_WARNING,
+                        "Bottom position of the decoded area (region_y1=%d) is outside the image area (Ysiz=%d).\n",
+                        p_end_y, l_image->y1);
+                p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
+                p_image->y1 = l_image->y1;
+        }
+        else{
+                p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv(p_end_y - (OPJ_INT32)l_cp->ty0, (OPJ_INT32)l_cp->tdy);
+                p_image->y1 = (OPJ_UINT32)p_end_y;
+        }
+        /* ----- */
+
+        p_j2k->m_specific_param.m_decoder.m_discard_tiles = 1;
+
+        l_img_comp = p_image->comps;
+        for (it_comp=0; it_comp < p_image->numcomps; ++it_comp)
+        {
+                OPJ_INT32 l_h,l_w;
+
+                l_img_comp->x0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->x0, (OPJ_INT32)l_img_comp->dx);
+                l_img_comp->y0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->y0, (OPJ_INT32)l_img_comp->dy);
+                l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
+                l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
+
+                l_w = opj_int_ceildivpow2(l_comp_x1, (OPJ_INT32)l_img_comp->factor)
+                                - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->x0, (OPJ_INT32)l_img_comp->factor);
+                if (l_w < 0){
+                        opj_event_msg(p_manager, EVT_ERROR,
+                                "Size x of the decoded component image is incorrect (comp[%d].w=%d).\n",
+                                it_comp, l_w);
+                        return OPJ_FALSE;
+                }
+                l_img_comp->w = (OPJ_UINT32)l_w;
+
+                l_h = opj_int_ceildivpow2(l_comp_y1, (OPJ_INT32)l_img_comp->factor)
+                                - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->y0, (OPJ_INT32)l_img_comp->factor);
+                if (l_h < 0){
+                        opj_event_msg(p_manager, EVT_ERROR,
+                                "Size y of the decoded component image is incorrect (comp[%d].h=%d).\n",
+                                it_comp, l_h);
+                        return OPJ_FALSE;
+                }
+                l_img_comp->h = (OPJ_UINT32)l_h;
+
+                l_img_comp++;
+        }
+
+        opj_event_msg( p_manager, EVT_INFO,"Setting decoding area to %d,%d,%d,%d\n",
+                        p_image->x0, p_image->y0, p_image->x1, p_image->y1);
+
+        return OPJ_TRUE;
+}
+
+opj_j2k_t* opj_j2k_create_decompress(void)
+{
+        opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1,sizeof(opj_j2k_t));
+        if (!l_j2k) {
+                return 00;
+        }
+
+        l_j2k->m_is_decoder = 1;
+        l_j2k->m_cp.m_is_decoder = 1;
+
+#ifdef OPJ_DISABLE_TPSOT_FIX
+        l_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1;
+#endif
+
+        l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_t*) opj_calloc(1,sizeof(opj_tcp_t));
+        if (!l_j2k->m_specific_param.m_decoder.m_default_tcp) {
+                opj_j2k_destroy(l_j2k);
+                return 00;
+        }
+
+        l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_calloc(1,OPJ_J2K_DEFAULT_HEADER_SIZE);
+        if (! l_j2k->m_specific_param.m_decoder.m_header_data) {
+                opj_j2k_destroy(l_j2k);
+                return 00;
+        }
+
+        l_j2k->m_specific_param.m_decoder.m_header_data_size = OPJ_J2K_DEFAULT_HEADER_SIZE;
+
+        l_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = -1 ;
+
+        l_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = 0 ;
+
+        /* codestream index creation */
+        l_j2k->cstr_index = opj_j2k_create_cstr_index();
+        if (!l_j2k->cstr_index){
+                opj_j2k_destroy(l_j2k);
+                return 00;
+        }
+
+        /* validation list creation */
+        l_j2k->m_validation_list = opj_procedure_list_create();
+        if (! l_j2k->m_validation_list) {
+                opj_j2k_destroy(l_j2k);
+                return 00;
+        }
+
+        /* execution list creation */
+        l_j2k->m_procedure_list = opj_procedure_list_create();
+        if (! l_j2k->m_procedure_list) {
+                opj_j2k_destroy(l_j2k);
+                return 00;
+        }
+
+        return l_j2k;
+}
+
+static opj_codestream_index_t* opj_j2k_create_cstr_index(void)
+{
+        opj_codestream_index_t* cstr_index = (opj_codestream_index_t*)
+                        opj_calloc(1,sizeof(opj_codestream_index_t));
+        if (!cstr_index)
+                return NULL;
+
+        cstr_index->maxmarknum = 100;
+        cstr_index->marknum = 0;
+        cstr_index->marker = (opj_marker_info_t*)
+                        opj_calloc(cstr_index->maxmarknum, sizeof(opj_marker_info_t));
+        if (!cstr_index-> marker) {
+                opj_free(cstr_index);
+                return NULL;
+        }
+
+        cstr_index->tile_index = NULL;
+
+        return cstr_index;
+}
+
+static OPJ_UINT32 opj_j2k_get_SPCod_SPCoc_size (       opj_j2k_t *p_j2k,
+                                                                                OPJ_UINT32 p_tile_no,
+                                                                                OPJ_UINT32 p_comp_no )
+{
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_tccp_t *l_tccp = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = &l_cp->tcps[p_tile_no];
+        l_tccp = &l_tcp->tccps[p_comp_no];
+
+        /* preconditions again */
+        assert(p_tile_no < (l_cp->tw * l_cp->th));
+        assert(p_comp_no < p_j2k->m_private_image->numcomps);
+
+        if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
+                return 5 + l_tccp->numresolutions;
+        }
+        else {
+                return 5;
+        }
+}
+
+static OPJ_BOOL opj_j2k_compare_SPCod_SPCoc(opj_j2k_t *p_j2k, OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
+{
+	OPJ_UINT32 i;
+	opj_cp_t *l_cp = NULL;
+	opj_tcp_t *l_tcp = NULL;
+	opj_tccp_t *l_tccp0 = NULL;
+	opj_tccp_t *l_tccp1 = NULL;
+	
+	/* preconditions */
+	assert(p_j2k != 00);
+	
+	l_cp = &(p_j2k->m_cp);
+	l_tcp = &l_cp->tcps[p_tile_no];
+	l_tccp0 = &l_tcp->tccps[p_first_comp_no];
+	l_tccp1 = &l_tcp->tccps[p_second_comp_no];
+	
+	if (l_tccp0->numresolutions != l_tccp1->numresolutions) {
+		return OPJ_FALSE;
+	}
+	if (l_tccp0->cblkw != l_tccp1->cblkw) {
+		return OPJ_FALSE;
+	}
+	if (l_tccp0->cblkh != l_tccp1->cblkh) {
+		return OPJ_FALSE;
+	}
+	if (l_tccp0->cblksty != l_tccp1->cblksty) {
+		return OPJ_FALSE;
+	}
+	if (l_tccp0->qmfbid != l_tccp1->qmfbid) {
+		return OPJ_FALSE;
+	}
+	if ((l_tccp0->csty & J2K_CCP_CSTY_PRT) != (l_tccp1->csty & J2K_CCP_CSTY_PRT)) {
+		return OPJ_FALSE;
+	}
+	
+	for (i = 0U; i < l_tccp0->numresolutions; ++i) {
+		if (l_tccp0->prcw[i] != l_tccp1->prcw[i]) {
+			return OPJ_FALSE;
+		}
+		if (l_tccp0->prch[i] != l_tccp1->prch[i]) {
+			return OPJ_FALSE;
+		}
+	}
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_SPCod_SPCoc(     opj_j2k_t *p_j2k,
+                                                                    OPJ_UINT32 p_tile_no,
+                                                                    OPJ_UINT32 p_comp_no,
+                                                                    OPJ_BYTE * p_data,
+                                                                    OPJ_UINT32 * p_header_size,
+                                                                    struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 i;
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_tccp_t *l_tccp = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_header_size != 00);
+        assert(p_manager != 00);
+        assert(p_data != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = &l_cp->tcps[p_tile_no];
+        l_tccp = &l_tcp->tccps[p_comp_no];
+
+        /* preconditions again */
+        assert(p_tile_no < (l_cp->tw * l_cp->th));
+        assert(p_comp_no <(p_j2k->m_private_image->numcomps));
+
+        if (*p_header_size < 5) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error writing SPCod SPCoc element\n");
+                return OPJ_FALSE;
+        }
+
+        opj_write_bytes(p_data,l_tccp->numresolutions - 1, 1);  /* SPcoc (D) */
+        ++p_data;
+
+        opj_write_bytes(p_data,l_tccp->cblkw - 2, 1);                   /* SPcoc (E) */
+        ++p_data;
+
+        opj_write_bytes(p_data,l_tccp->cblkh - 2, 1);                   /* SPcoc (F) */
+        ++p_data;
+
+        opj_write_bytes(p_data,l_tccp->cblksty, 1);                             /* SPcoc (G) */
+        ++p_data;
+
+        opj_write_bytes(p_data,l_tccp->qmfbid, 1);                              /* SPcoc (H) */
+        ++p_data;
+
+        *p_header_size = *p_header_size - 5;
+
+        if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
+
+                if (*p_header_size < l_tccp->numresolutions) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error writing SPCod SPCoc element\n");
+                        return OPJ_FALSE;
+                }
+
+                for (i = 0; i < l_tccp->numresolutions; ++i) {
+                        opj_write_bytes(p_data,l_tccp->prcw[i] + (l_tccp->prch[i] << 4), 1);    /* SPcoc (I_i) */
+                        ++p_data;
+                }
+
+                *p_header_size = *p_header_size - l_tccp->numresolutions;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_read_SPCod_SPCoc(  opj_j2k_t *p_j2k,
+                                                                OPJ_UINT32 compno,
+                                                                OPJ_BYTE * p_header_data,
+                                                                OPJ_UINT32 * p_header_size,
+                                                                opj_event_mgr_t * p_manager)
+{
+        OPJ_UINT32 i, l_tmp;
+        opj_cp_t *l_cp = NULL;
+        opj_tcp_t *l_tcp = NULL;
+        opj_tccp_t *l_tccp = NULL;
+        OPJ_BYTE * l_current_ptr = NULL;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_header_data != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
+                                &l_cp->tcps[p_j2k->m_current_tile_number] :
+                                p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        /* precondition again */
+        assert(compno < p_j2k->m_private_image->numcomps);
+
+        l_tccp = &l_tcp->tccps[compno];
+        l_current_ptr = p_header_data;
+
+        /* make sure room is sufficient */
+        if (*p_header_size < 5) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(l_current_ptr, &l_tccp->numresolutions ,1);              /* SPcox (D) */
+        ++l_tccp->numresolutions;                                                                               /* tccp->numresolutions = read() + 1 */
+        if (l_tccp->numresolutions > OPJ_J2K_MAXRLVLS) {
+                opj_event_msg(p_manager, EVT_ERROR,
+                              "Invalid value for numresolutions : %d, max value is set in openjpeg.h at %d\n",
+                              l_tccp->numresolutions, OPJ_J2K_MAXRLVLS);
+                return OPJ_FALSE;
+        }
+        ++l_current_ptr;
+
+        /* If user wants to remove more resolutions than the codestream contains, return error */
+        if (l_cp->m_specific_param.m_dec.m_reduce >= l_tccp->numresolutions) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number "
+                                        "of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
+                p_j2k->m_specific_param.m_decoder.m_state |= 0x8000;/* FIXME J2K_DEC_STATE_ERR;*/
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(l_current_ptr,&l_tccp->cblkw ,1);                /* SPcoc (E) */
+        ++l_current_ptr;
+        l_tccp->cblkw += 2;
+
+        opj_read_bytes(l_current_ptr,&l_tccp->cblkh ,1);                /* SPcoc (F) */
+        ++l_current_ptr;
+        l_tccp->cblkh += 2;
+
+        if ((l_tccp->cblkw > 10) || (l_tccp->cblkh > 10) || ((l_tccp->cblkw + l_tccp->cblkh) > 12)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element, Invalid cblkw/cblkh combination\n");
+                return OPJ_FALSE;
+        }
+	
+
+        opj_read_bytes(l_current_ptr,&l_tccp->cblksty ,1);              /* SPcoc (G) */
+        ++l_current_ptr;
+        if (l_tccp->cblksty & 0xC0U) { /* 2 msb are reserved, assume we can't read */
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element, Invalid code-block style found\n");
+                return OPJ_FALSE;
+        }
+
+        opj_read_bytes(l_current_ptr,&l_tccp->qmfbid ,1);               /* SPcoc (H) */
+        ++l_current_ptr;
+
+        *p_header_size = *p_header_size - 5;
+
+        /* use custom precinct size ? */
+        if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
+                if (*p_header_size < l_tccp->numresolutions) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element\n");
+                        return OPJ_FALSE;
+                }
+
+                for     (i = 0; i < l_tccp->numresolutions; ++i) {
+                        opj_read_bytes(l_current_ptr,&l_tmp ,1);                /* SPcoc (I_i) */
+                        ++l_current_ptr;
+                        /* Precinct exponent 0 is only allowed for lowest resolution level (Table A.21) */
+                        if ((i != 0) && (((l_tmp & 0xf) == 0) || ((l_tmp >> 4) == 0))) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Invalid precinct size\n");
+                                return OPJ_FALSE;
+                        }
+                        l_tccp->prcw[i] = l_tmp & 0xf;
+                        l_tccp->prch[i] = l_tmp >> 4;
+                }
+
+                *p_header_size = *p_header_size - l_tccp->numresolutions;
+        }
+        else {
+                /* set default size for the precinct width and height */
+                for     (i = 0; i < l_tccp->numresolutions; ++i) {
+                        l_tccp->prcw[i] = 15;
+                        l_tccp->prch[i] = 15;
+                }
+        }
+
+#ifdef WIP_REMOVE_MSD
+        /* INDEX >> */
+        if (p_j2k->cstr_info && compno == 0) {
+                OPJ_UINT32 l_data_size = l_tccp->numresolutions * sizeof(OPJ_UINT32);
+
+                p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkh = l_tccp->cblkh;
+                p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkw = l_tccp->cblkw;
+                p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].numresolutions = l_tccp->numresolutions;
+                p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblksty = l_tccp->cblksty;
+                p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].qmfbid = l_tccp->qmfbid;
+
+                memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdx,l_tccp->prcw, l_data_size);
+                memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdy,l_tccp->prch, l_data_size);
+        }
+        /* << INDEX */
+#endif
+
+        return OPJ_TRUE;
+}
+
+static void opj_j2k_copy_tile_component_parameters( opj_j2k_t *p_j2k )
+{
+        /* loop */
+        OPJ_UINT32 i;
+        opj_cp_t *l_cp = NULL;
+        opj_tcp_t *l_tcp = NULL;
+        opj_tccp_t *l_ref_tccp = NULL, *l_copied_tccp = NULL;
+        OPJ_UINT32 l_prc_size;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? /* FIXME J2K_DEC_STATE_TPH*/
+                                &l_cp->tcps[p_j2k->m_current_tile_number] :
+                                p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        l_ref_tccp = &l_tcp->tccps[0];
+        l_copied_tccp = l_ref_tccp + 1;
+        l_prc_size = l_ref_tccp->numresolutions * (OPJ_UINT32)sizeof(OPJ_UINT32);
+
+        for     (i=1; i<p_j2k->m_private_image->numcomps; ++i) {
+                l_copied_tccp->numresolutions = l_ref_tccp->numresolutions;
+                l_copied_tccp->cblkw = l_ref_tccp->cblkw;
+                l_copied_tccp->cblkh = l_ref_tccp->cblkh;
+                l_copied_tccp->cblksty = l_ref_tccp->cblksty;
+                l_copied_tccp->qmfbid = l_ref_tccp->qmfbid;
+                memcpy(l_copied_tccp->prcw,l_ref_tccp->prcw,l_prc_size);
+                memcpy(l_copied_tccp->prch,l_ref_tccp->prch,l_prc_size);
+                ++l_copied_tccp;
+        }
+}
+
+static OPJ_UINT32 opj_j2k_get_SQcd_SQcc_size ( opj_j2k_t *p_j2k,
+                                                                        OPJ_UINT32 p_tile_no,
+                                                                        OPJ_UINT32 p_comp_no )
+{
+        OPJ_UINT32 l_num_bands;
+
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_tccp_t *l_tccp = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = &l_cp->tcps[p_tile_no];
+        l_tccp = &l_tcp->tccps[p_comp_no];
+
+        /* preconditions again */
+        assert(p_tile_no < l_cp->tw * l_cp->th);
+        assert(p_comp_no < p_j2k->m_private_image->numcomps);
+
+        l_num_bands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 : (l_tccp->numresolutions * 3 - 2);
+
+        if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT)  {
+                return 1 + l_num_bands;
+        }
+        else {
+                return 1 + 2*l_num_bands;
+        }
+}
+
+static OPJ_BOOL opj_j2k_compare_SQcd_SQcc(opj_j2k_t *p_j2k, OPJ_UINT32 p_tile_no, OPJ_UINT32 p_first_comp_no, OPJ_UINT32 p_second_comp_no)
+{
+	opj_cp_t *l_cp = NULL;
+	opj_tcp_t *l_tcp = NULL;
+	opj_tccp_t *l_tccp0 = NULL;
+	opj_tccp_t *l_tccp1 = NULL;
+	OPJ_UINT32 l_band_no, l_num_bands;
+	
+	/* preconditions */
+	assert(p_j2k != 00);
+	
+	l_cp = &(p_j2k->m_cp);
+	l_tcp = &l_cp->tcps[p_tile_no];
+	l_tccp0 = &l_tcp->tccps[p_first_comp_no];
+	l_tccp1 = &l_tcp->tccps[p_second_comp_no];
+	
+	if (l_tccp0->qntsty != l_tccp1->qntsty ) {
+		return OPJ_FALSE;
+	}
+	if (l_tccp0->numgbits != l_tccp1->numgbits ) {
+		return OPJ_FALSE;
+	}
+	if (l_tccp0->qntsty == J2K_CCP_QNTSTY_SIQNT) {
+		l_num_bands = 1U;
+	} else {
+		l_num_bands = l_tccp0->numresolutions * 3U - 2U;
+		if (l_num_bands != (l_tccp1->numresolutions * 3U - 2U)) {
+			return OPJ_FALSE;
+		}
+	}
+	
+	for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
+		if (l_tccp0->stepsizes[l_band_no].expn != l_tccp1->stepsizes[l_band_no].expn ) {
+			return OPJ_FALSE;
+		}
+	}
+	if (l_tccp0->qntsty != J2K_CCP_QNTSTY_NOQNT)
+	{
+		for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
+			if (l_tccp0->stepsizes[l_band_no].mant != l_tccp1->stepsizes[l_band_no].mant ) {
+				return OPJ_FALSE;
+			}
+		}
+	}
+	return OPJ_TRUE;
+}
+
+
+static OPJ_BOOL opj_j2k_write_SQcd_SQcc(       opj_j2k_t *p_j2k,
+                                                                OPJ_UINT32 p_tile_no,
+                                                                OPJ_UINT32 p_comp_no,
+                                                                OPJ_BYTE * p_data,
+                                                                OPJ_UINT32 * p_header_size,
+                                                                struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 l_header_size;
+        OPJ_UINT32 l_band_no, l_num_bands;
+        OPJ_UINT32 l_expn,l_mant;
+
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_tccp_t *l_tccp = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_header_size != 00);
+        assert(p_manager != 00);
+        assert(p_data != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = &l_cp->tcps[p_tile_no];
+        l_tccp = &l_tcp->tccps[p_comp_no];
+
+        /* preconditions again */
+        assert(p_tile_no < l_cp->tw * l_cp->th);
+        assert(p_comp_no <p_j2k->m_private_image->numcomps);
+
+        l_num_bands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 : (l_tccp->numresolutions * 3 - 2);
+
+        if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT)  {
+                l_header_size = 1 + l_num_bands;
+
+                if (*p_header_size < l_header_size) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error writing SQcd SQcc element\n");
+                        return OPJ_FALSE;
+                }
+
+                opj_write_bytes(p_data,l_tccp->qntsty + (l_tccp->numgbits << 5), 1);    /* Sqcx */
+                ++p_data;
+
+                for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
+                        l_expn = (OPJ_UINT32)l_tccp->stepsizes[l_band_no].expn;
+                        opj_write_bytes(p_data, l_expn << 3, 1);        /* SPqcx_i */
+                        ++p_data;
+                }
+        }
+        else {
+                l_header_size = 1 + 2*l_num_bands;
+
+                if (*p_header_size < l_header_size) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error writing SQcd SQcc element\n");
+                        return OPJ_FALSE;
+                }
+
+                opj_write_bytes(p_data,l_tccp->qntsty + (l_tccp->numgbits << 5), 1);    /* Sqcx */
+                ++p_data;
+
+                for (l_band_no = 0; l_band_no < l_num_bands; ++l_band_no) {
+                        l_expn = (OPJ_UINT32)l_tccp->stepsizes[l_band_no].expn;
+                        l_mant = (OPJ_UINT32)l_tccp->stepsizes[l_band_no].mant;
+
+                        opj_write_bytes(p_data, (l_expn << 11) + l_mant, 2);    /* SPqcx_i */
+                        p_data += 2;
+                }
+        }
+
+        *p_header_size = *p_header_size - l_header_size;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_read_SQcd_SQcc(opj_j2k_t *p_j2k,
+                                                            OPJ_UINT32 p_comp_no,
+                                                            OPJ_BYTE* p_header_data,
+                                                            OPJ_UINT32 * p_header_size,
+                                                            opj_event_mgr_t * p_manager
+                                                            )
+{
+        /* loop*/
+        OPJ_UINT32 l_band_no;
+        opj_cp_t *l_cp = 00;
+        opj_tcp_t *l_tcp = 00;
+        opj_tccp_t *l_tccp = 00;
+        OPJ_BYTE * l_current_ptr = 00;
+        OPJ_UINT32 l_tmp, l_num_band;
+
+        /* preconditions*/
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_header_data != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        /* come from tile part header or main header ?*/
+        l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? /*FIXME J2K_DEC_STATE_TPH*/
+                                &l_cp->tcps[p_j2k->m_current_tile_number] :
+                                p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        /* precondition again*/
+        assert(p_comp_no <  p_j2k->m_private_image->numcomps);
+
+        l_tccp = &l_tcp->tccps[p_comp_no];
+        l_current_ptr = p_header_data;
+
+        if (*p_header_size < 1) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error reading SQcd or SQcc element\n");
+                return OPJ_FALSE;
+        }
+        *p_header_size -= 1;
+
+        opj_read_bytes(l_current_ptr, &l_tmp ,1);                       /* Sqcx */
+        ++l_current_ptr;
+
+        l_tccp->qntsty = l_tmp & 0x1f;
+        l_tccp->numgbits = l_tmp >> 5;
+        if (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) {
+        l_num_band = 1;
+        }
+        else {
+                l_num_band = (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) ?
+                        (*p_header_size) :
+                        (*p_header_size) / 2;
+
+                if( l_num_band > OPJ_J2K_MAXBANDS ) {
+                        opj_event_msg(p_manager, EVT_WARNING, "While reading CCP_QNTSTY element inside QCD or QCC marker segment, "
+                                "number of subbands (%d) is greater to OPJ_J2K_MAXBANDS (%d). So we limit the number of elements stored to "
+                                "OPJ_J2K_MAXBANDS (%d) and skip the rest. \n", l_num_band, OPJ_J2K_MAXBANDS, OPJ_J2K_MAXBANDS);
+                        /*return OPJ_FALSE;*/
+                }
+        }
+
+#ifdef USE_JPWL
+        if (l_cp->correct) {
+
+                /* if JPWL is on, we check whether there are too many subbands */
+                if (/*(l_num_band < 0) ||*/ (l_num_band >= OPJ_J2K_MAXBANDS)) {
+                        opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
+                                "JPWL: bad number of subbands in Sqcx (%d)\n",
+                                l_num_band);
+                        if (!JPWL_ASSUME) {
+                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                return OPJ_FALSE;
+                        }
+                        /* we try to correct */
+                        l_num_band = 1;
+                        opj_event_msg(p_manager, EVT_WARNING, "- trying to adjust them\n"
+                                "- setting number of bands to %d => HYPOTHESIS!!!\n",
+                                l_num_band);
+                };
+
+        };
+#endif /* USE_JPWL */
+
+        if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
+                for     (l_band_no = 0; l_band_no < l_num_band; l_band_no++) {
+                        opj_read_bytes(l_current_ptr, &l_tmp ,1);                       /* SPqcx_i */
+                        ++l_current_ptr;
+                        if (l_band_no < OPJ_J2K_MAXBANDS){
+                                l_tccp->stepsizes[l_band_no].expn = (OPJ_INT32)(l_tmp >> 3);
+                                l_tccp->stepsizes[l_band_no].mant = 0;
+                        }
+                }
+                *p_header_size = *p_header_size - l_num_band;
+        }
+        else {
+                for     (l_band_no = 0; l_band_no < l_num_band; l_band_no++) {
+                        opj_read_bytes(l_current_ptr, &l_tmp ,2);                       /* SPqcx_i */
+                        l_current_ptr+=2;
+                        if (l_band_no < OPJ_J2K_MAXBANDS){
+                                l_tccp->stepsizes[l_band_no].expn = (OPJ_INT32)(l_tmp >> 11);
+                                l_tccp->stepsizes[l_band_no].mant = l_tmp & 0x7ff;
+                        }
+                }
+                *p_header_size = *p_header_size - 2*l_num_band;
+        }
+
+        /* Add Antonin : if scalar_derived -> compute other stepsizes */
+        if (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) {
+                for (l_band_no = 1; l_band_no < OPJ_J2K_MAXBANDS; l_band_no++) {
+                        l_tccp->stepsizes[l_band_no].expn =
+                                ((OPJ_INT32)(l_tccp->stepsizes[0].expn) - (OPJ_INT32)((l_band_no - 1) / 3) > 0) ?
+                                        (OPJ_INT32)(l_tccp->stepsizes[0].expn) - (OPJ_INT32)((l_band_no - 1) / 3) : 0;
+                        l_tccp->stepsizes[l_band_no].mant = l_tccp->stepsizes[0].mant;
+                }
+        }
+
+        return OPJ_TRUE;
+}
+
+static void opj_j2k_copy_tile_quantization_parameters( opj_j2k_t *p_j2k )
+{
+        OPJ_UINT32 i;
+        opj_cp_t *l_cp = NULL;
+        opj_tcp_t *l_tcp = NULL;
+        opj_tccp_t *l_ref_tccp = NULL;
+        opj_tccp_t *l_copied_tccp = NULL;
+        OPJ_UINT32 l_size;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ?
+                        &l_cp->tcps[p_j2k->m_current_tile_number] :
+                        p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        l_ref_tccp = &l_tcp->tccps[0];
+        l_copied_tccp = l_ref_tccp + 1;
+        l_size = OPJ_J2K_MAXBANDS * sizeof(opj_stepsize_t);
+
+        for     (i=1;i<p_j2k->m_private_image->numcomps;++i) {
+                l_copied_tccp->qntsty = l_ref_tccp->qntsty;
+                l_copied_tccp->numgbits = l_ref_tccp->numgbits;
+                memcpy(l_copied_tccp->stepsizes,l_ref_tccp->stepsizes,l_size);
+                ++l_copied_tccp;
+        }
+}
+
+static void opj_j2k_dump_tile_info( opj_tcp_t * l_default_tile,OPJ_INT32 numcomps,FILE* out_stream)
+{
+        if (l_default_tile)
+        {
+                OPJ_INT32 compno;
+
+                fprintf(out_stream, "\t default tile {\n");
+                fprintf(out_stream, "\t\t csty=%#x\n", l_default_tile->csty);
+                fprintf(out_stream, "\t\t prg=%#x\n", l_default_tile->prg);
+                fprintf(out_stream, "\t\t numlayers=%d\n", l_default_tile->numlayers);
+                fprintf(out_stream, "\t\t mct=%x\n", l_default_tile->mct);
+
+                for (compno = 0; compno < numcomps; compno++) {
+                        opj_tccp_t *l_tccp = &(l_default_tile->tccps[compno]);
+                        OPJ_UINT32 resno;
+      OPJ_INT32 bandno, numbands;
+
+                        /* coding style*/
+                        fprintf(out_stream, "\t\t comp %d {\n", compno);
+                        fprintf(out_stream, "\t\t\t csty=%#x\n", l_tccp->csty);
+                        fprintf(out_stream, "\t\t\t numresolutions=%d\n", l_tccp->numresolutions);
+                        fprintf(out_stream, "\t\t\t cblkw=2^%d\n", l_tccp->cblkw);
+                        fprintf(out_stream, "\t\t\t cblkh=2^%d\n", l_tccp->cblkh);
+                        fprintf(out_stream, "\t\t\t cblksty=%#x\n", l_tccp->cblksty);
+                        fprintf(out_stream, "\t\t\t qmfbid=%d\n", l_tccp->qmfbid);
+
+                        fprintf(out_stream, "\t\t\t preccintsize (w,h)=");
+                        for (resno = 0; resno < l_tccp->numresolutions; resno++) {
+                                fprintf(out_stream, "(%d,%d) ", l_tccp->prcw[resno], l_tccp->prch[resno]);
+                        }
+                        fprintf(out_stream, "\n");
+
+                        /* quantization style*/
+                        fprintf(out_stream, "\t\t\t qntsty=%d\n", l_tccp->qntsty);
+                        fprintf(out_stream, "\t\t\t numgbits=%d\n", l_tccp->numgbits);
+                        fprintf(out_stream, "\t\t\t stepsizes (m,e)=");
+                        numbands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 : (OPJ_INT32)l_tccp->numresolutions * 3 - 2;
+                        for (bandno = 0; bandno < numbands; bandno++) {
+                                fprintf(out_stream, "(%d,%d) ", l_tccp->stepsizes[bandno].mant,
+                                        l_tccp->stepsizes[bandno].expn);
+                        }
+                        fprintf(out_stream, "\n");
+
+                        /* RGN value*/
+                        fprintf(out_stream, "\t\t\t roishift=%d\n", l_tccp->roishift);
+
+                        fprintf(out_stream, "\t\t }\n");
+                } /*end of component of default tile*/
+                fprintf(out_stream, "\t }\n"); /*end of default tile*/
+            }
+}
+
+void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream)
+{
+        /* Check if the flag is compatible with j2k file*/
+        if ( (flag & OPJ_JP2_INFO) || (flag & OPJ_JP2_IND)){
+                fprintf(out_stream, "Wrong flag\n");
+                return;
+        }
+
+        /* Dump the image_header */
+        if (flag & OPJ_IMG_INFO){
+                if (p_j2k->m_private_image)
+                        j2k_dump_image_header(p_j2k->m_private_image, 0, out_stream);
+        }
+
+        /* Dump the codestream info from main header */
+        if (flag & OPJ_J2K_MH_INFO){
+                if (p_j2k->m_private_image)
+                        opj_j2k_dump_MH_info(p_j2k, out_stream);
+        }
+        /* Dump all tile/codestream info */
+        if (flag & OPJ_J2K_TCH_INFO){
+          OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
+          OPJ_UINT32 i;
+          opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
+          if (p_j2k->m_private_image) {
+            for (i=0;i<l_nb_tiles;++i) {
+              opj_j2k_dump_tile_info( l_tcp,(OPJ_INT32)p_j2k->m_private_image->numcomps, out_stream);
+              ++l_tcp;
+            }
+          }
+        }
+
+        /* Dump the codestream info of the current tile */
+        if (flag & OPJ_J2K_TH_INFO){
+
+        }
+
+        /* Dump the codestream index from main header */
+        if (flag & OPJ_J2K_MH_IND){
+                opj_j2k_dump_MH_index(p_j2k, out_stream);
+        }
+
+        /* Dump the codestream index of the current tile */
+        if (flag & OPJ_J2K_TH_IND){
+
+        }
+
+}
+
+static void opj_j2k_dump_MH_index(opj_j2k_t* p_j2k, FILE* out_stream)
+{
+        opj_codestream_index_t* cstr_index = p_j2k->cstr_index;
+        OPJ_UINT32 it_marker, it_tile, it_tile_part;
+
+        fprintf(out_stream, "Codestream index from main header: {\n");
+
+        fprintf(out_stream, "\t Main header start position=%" PRIi64 "\n"
+                                    "\t Main header end position=%" PRIi64 "\n",
+                        cstr_index->main_head_start, cstr_index->main_head_end);
+
+        fprintf(out_stream, "\t Marker list: {\n");
+
+        if (cstr_index->marker){
+                for (it_marker=0; it_marker < cstr_index->marknum ; it_marker++){
+                        fprintf(out_stream, "\t\t type=%#x, pos=%" PRIi64 ", len=%d\n",
+                                        cstr_index->marker[it_marker].type,
+                                        cstr_index->marker[it_marker].pos,
+                                        cstr_index->marker[it_marker].len );
+                }
+        }
+
+        fprintf(out_stream, "\t }\n");
+
+        if (cstr_index->tile_index){
+
+        /* Simple test to avoid to write empty information*/
+        OPJ_UINT32 l_acc_nb_of_tile_part = 0;
+        for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++){
+                        l_acc_nb_of_tile_part += cstr_index->tile_index[it_tile].nb_tps;
+        }
+
+        if (l_acc_nb_of_tile_part)
+        {
+            fprintf(out_stream, "\t Tile index: {\n");
+
+                    for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++){
+                            OPJ_UINT32 nb_of_tile_part = cstr_index->tile_index[it_tile].nb_tps;
+
+                            fprintf(out_stream, "\t\t nb of tile-part in tile [%d]=%d\n", it_tile, nb_of_tile_part);
+
+                            if (cstr_index->tile_index[it_tile].tp_index){
+                                    for (it_tile_part =0; it_tile_part < nb_of_tile_part; it_tile_part++){
+                                            fprintf(out_stream, "\t\t\t tile-part[%d]: star_pos=%" PRIi64 ", end_header=%" PRIi64 ", end_pos=%" PRIi64 ".\n",
+                                                            it_tile_part,
+                                                            cstr_index->tile_index[it_tile].tp_index[it_tile_part].start_pos,
+                                                            cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_header,
+                                                            cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_pos);
+                                    }
+                            }
+
+                            if (cstr_index->tile_index[it_tile].marker){
+                                    for (it_marker=0; it_marker < cstr_index->tile_index[it_tile].marknum ; it_marker++){
+                                            fprintf(out_stream, "\t\t type=%#x, pos=%" PRIi64 ", len=%d\n",
+                                                            cstr_index->tile_index[it_tile].marker[it_marker].type,
+                                                            cstr_index->tile_index[it_tile].marker[it_marker].pos,
+                                                            cstr_index->tile_index[it_tile].marker[it_marker].len );
+                                    }
+                            }
+                    }
+                    fprintf(out_stream,"\t }\n");
+        }
+        }
+
+        fprintf(out_stream,"}\n");
+
+}
+
+
+static void opj_j2k_dump_MH_info(opj_j2k_t* p_j2k, FILE* out_stream)
+{
+
+        fprintf(out_stream, "Codestream info from main header: {\n");
+
+        fprintf(out_stream, "\t tx0=%d, ty0=%d\n", p_j2k->m_cp.tx0, p_j2k->m_cp.ty0);
+        fprintf(out_stream, "\t tdx=%d, tdy=%d\n", p_j2k->m_cp.tdx, p_j2k->m_cp.tdy);
+        fprintf(out_stream, "\t tw=%d, th=%d\n", p_j2k->m_cp.tw, p_j2k->m_cp.th);
+        opj_j2k_dump_tile_info(p_j2k->m_specific_param.m_decoder.m_default_tcp,(OPJ_INT32)p_j2k->m_private_image->numcomps, out_stream);
+        fprintf(out_stream, "}\n");
+}
+
+void j2k_dump_image_header(opj_image_t* img_header, OPJ_BOOL dev_dump_flag, FILE* out_stream)
+{
+        char tab[2];
+
+        if (dev_dump_flag){
+                fprintf(stdout, "[DEV] Dump an image_header struct {\n");
+                tab[0] = '\0';
+        }
+        else {
+                fprintf(out_stream, "Image info {\n");
+                tab[0] = '\t';tab[1] = '\0';
+        }
+
+        fprintf(out_stream, "%s x0=%d, y0=%d\n", tab, img_header->x0, img_header->y0);
+        fprintf(out_stream,     "%s x1=%d, y1=%d\n", tab, img_header->x1, img_header->y1);
+        fprintf(out_stream, "%s numcomps=%d\n", tab, img_header->numcomps);
+
+        if (img_header->comps){
+                OPJ_UINT32 compno;
+                for (compno = 0; compno < img_header->numcomps; compno++) {
+                        fprintf(out_stream, "%s\t component %d {\n", tab, compno);
+                        j2k_dump_image_comp_header(&(img_header->comps[compno]), dev_dump_flag, out_stream);
+                        fprintf(out_stream,"%s}\n",tab);
+                }
+        }
+
+        fprintf(out_stream, "}\n");
+}
+
+void j2k_dump_image_comp_header(opj_image_comp_t* comp_header, OPJ_BOOL dev_dump_flag, FILE* out_stream)
+{
+        char tab[3];
+
+        if (dev_dump_flag){
+                fprintf(stdout, "[DEV] Dump an image_comp_header struct {\n");
+                tab[0] = '\0';
+        }       else {
+                tab[0] = '\t';tab[1] = '\t';tab[2] = '\0';
+        }
+
+        fprintf(out_stream, "%s dx=%d, dy=%d\n", tab, comp_header->dx, comp_header->dy);
+        fprintf(out_stream, "%s prec=%d\n", tab, comp_header->prec);
+        fprintf(out_stream, "%s sgnd=%d\n", tab, comp_header->sgnd);
+
+        if (dev_dump_flag)
+                fprintf(out_stream, "}\n");
+}
+
+opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k)
+{
+        OPJ_UINT32 compno;
+        OPJ_UINT32 numcomps = p_j2k->m_private_image->numcomps;
+        opj_tcp_t *l_default_tile;
+        opj_codestream_info_v2_t* cstr_info = (opj_codestream_info_v2_t*) opj_calloc(1,sizeof(opj_codestream_info_v2_t));
+		if (!cstr_info)
+			return NULL;
+
+        cstr_info->nbcomps = p_j2k->m_private_image->numcomps;
+
+        cstr_info->tx0 = p_j2k->m_cp.tx0;
+        cstr_info->ty0 = p_j2k->m_cp.ty0;
+        cstr_info->tdx = p_j2k->m_cp.tdx;
+        cstr_info->tdy = p_j2k->m_cp.tdy;
+        cstr_info->tw = p_j2k->m_cp.tw;
+        cstr_info->th = p_j2k->m_cp.th;
+
+        cstr_info->tile_info = NULL; /* Not fill from the main header*/
+
+        l_default_tile = p_j2k->m_specific_param.m_decoder.m_default_tcp;
+
+        cstr_info->m_default_tile_info.csty = l_default_tile->csty;
+        cstr_info->m_default_tile_info.prg = l_default_tile->prg;
+        cstr_info->m_default_tile_info.numlayers = l_default_tile->numlayers;
+        cstr_info->m_default_tile_info.mct = l_default_tile->mct;
+
+        cstr_info->m_default_tile_info.tccp_info = (opj_tccp_info_t*) opj_calloc(cstr_info->nbcomps, sizeof(opj_tccp_info_t));
+		if (!cstr_info->m_default_tile_info.tccp_info)
+		{
+			opj_destroy_cstr_info(&cstr_info);
+			return NULL;
+		}
+
+        for (compno = 0; compno < numcomps; compno++) {
+                opj_tccp_t *l_tccp = &(l_default_tile->tccps[compno]);
+                opj_tccp_info_t *l_tccp_info = &(cstr_info->m_default_tile_info.tccp_info[compno]);
+                OPJ_INT32 bandno, numbands;
+
+                /* coding style*/
+                l_tccp_info->csty = l_tccp->csty;
+                l_tccp_info->numresolutions = l_tccp->numresolutions;
+                l_tccp_info->cblkw = l_tccp->cblkw;
+                l_tccp_info->cblkh = l_tccp->cblkh;
+                l_tccp_info->cblksty = l_tccp->cblksty;
+                l_tccp_info->qmfbid = l_tccp->qmfbid;
+                if (l_tccp->numresolutions < OPJ_J2K_MAXRLVLS)
+                {
+                        memcpy(l_tccp_info->prch, l_tccp->prch, l_tccp->numresolutions);
+                        memcpy(l_tccp_info->prcw, l_tccp->prcw, l_tccp->numresolutions);
+                }
+
+                /* quantization style*/
+                l_tccp_info->qntsty = l_tccp->qntsty;
+                l_tccp_info->numgbits = l_tccp->numgbits;
+
+                numbands = (l_tccp->qntsty == J2K_CCP_QNTSTY_SIQNT) ? 1 : (OPJ_INT32)l_tccp->numresolutions * 3 - 2;
+                if (numbands < OPJ_J2K_MAXBANDS) {
+                        for (bandno = 0; bandno < numbands; bandno++) {
+                                l_tccp_info->stepsizes_mant[bandno] = (OPJ_UINT32)l_tccp->stepsizes[bandno].mant;
+                                l_tccp_info->stepsizes_expn[bandno] = (OPJ_UINT32)l_tccp->stepsizes[bandno].expn;
+                        }
+                }
+
+                /* RGN value*/
+                l_tccp_info->roishift = l_tccp->roishift;
+        }
+
+        return cstr_info;
+}
+
+opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k)
+{
+        opj_codestream_index_t* l_cstr_index = (opj_codestream_index_t*)
+                        opj_calloc(1,sizeof(opj_codestream_index_t));
+        if (!l_cstr_index)
+                return NULL;
+
+        l_cstr_index->main_head_start = p_j2k->cstr_index->main_head_start;
+        l_cstr_index->main_head_end = p_j2k->cstr_index->main_head_end;
+        l_cstr_index->codestream_size = p_j2k->cstr_index->codestream_size;
+
+        l_cstr_index->marknum = p_j2k->cstr_index->marknum;
+        l_cstr_index->marker = (opj_marker_info_t*)opj_malloc(l_cstr_index->marknum*sizeof(opj_marker_info_t));
+        if (!l_cstr_index->marker){
+                opj_free( l_cstr_index);
+                return NULL;
+        }
+
+        if (p_j2k->cstr_index->marker)
+                memcpy(l_cstr_index->marker, p_j2k->cstr_index->marker, l_cstr_index->marknum * sizeof(opj_marker_info_t) );
+        else{
+                opj_free(l_cstr_index->marker);
+                l_cstr_index->marker = NULL;
+        }
+
+        l_cstr_index->nb_of_tiles = p_j2k->cstr_index->nb_of_tiles;
+        l_cstr_index->tile_index = (opj_tile_index_t*)opj_calloc(l_cstr_index->nb_of_tiles, sizeof(opj_tile_index_t) );
+        if (!l_cstr_index->tile_index){
+                opj_free( l_cstr_index->marker);
+                opj_free( l_cstr_index);
+                return NULL;
+        }
+
+        if (!p_j2k->cstr_index->tile_index){
+                opj_free(l_cstr_index->tile_index);
+                l_cstr_index->tile_index = NULL;
+        }
+        else {
+                OPJ_UINT32 it_tile = 0;
+                for (it_tile = 0; it_tile < l_cstr_index->nb_of_tiles; it_tile++ ){
+
+                        /* Tile Marker*/
+                        l_cstr_index->tile_index[it_tile].marknum = p_j2k->cstr_index->tile_index[it_tile].marknum;
+
+                        l_cstr_index->tile_index[it_tile].marker =
+                                (opj_marker_info_t*)opj_malloc(l_cstr_index->tile_index[it_tile].marknum*sizeof(opj_marker_info_t));
+
+                        if (!l_cstr_index->tile_index[it_tile].marker) {
+                                OPJ_UINT32 it_tile_free;
+
+                                for (it_tile_free=0; it_tile_free < it_tile; it_tile_free++){
+                                        opj_free(l_cstr_index->tile_index[it_tile_free].marker);
+                                }
+
+                                opj_free( l_cstr_index->tile_index);
+                                opj_free( l_cstr_index->marker);
+                                opj_free( l_cstr_index);
+                                return NULL;
+                        }
+
+                        if (p_j2k->cstr_index->tile_index[it_tile].marker)
+                                memcpy( l_cstr_index->tile_index[it_tile].marker,
+                                                p_j2k->cstr_index->tile_index[it_tile].marker,
+                                                l_cstr_index->tile_index[it_tile].marknum * sizeof(opj_marker_info_t) );
+                        else{
+                                opj_free(l_cstr_index->tile_index[it_tile].marker);
+                                l_cstr_index->tile_index[it_tile].marker = NULL;
+                        }
+
+                        /* Tile part index*/
+                        l_cstr_index->tile_index[it_tile].nb_tps = p_j2k->cstr_index->tile_index[it_tile].nb_tps;
+
+                        l_cstr_index->tile_index[it_tile].tp_index =
+                                (opj_tp_index_t*)opj_malloc(l_cstr_index->tile_index[it_tile].nb_tps*sizeof(opj_tp_index_t));
+
+                        if(!l_cstr_index->tile_index[it_tile].tp_index){
+                                OPJ_UINT32 it_tile_free;
+
+                                for (it_tile_free=0; it_tile_free < it_tile; it_tile_free++){
+                                        opj_free(l_cstr_index->tile_index[it_tile_free].marker);
+                                        opj_free(l_cstr_index->tile_index[it_tile_free].tp_index);
+                                }
+
+                                opj_free( l_cstr_index->tile_index);
+                                opj_free( l_cstr_index->marker);
+                                opj_free( l_cstr_index);
+                                return NULL;
+                        }
+
+                        if (p_j2k->cstr_index->tile_index[it_tile].tp_index){
+                                memcpy( l_cstr_index->tile_index[it_tile].tp_index,
+                                                p_j2k->cstr_index->tile_index[it_tile].tp_index,
+                                                l_cstr_index->tile_index[it_tile].nb_tps * sizeof(opj_tp_index_t) );
+                        }
+                        else{
+                                opj_free(l_cstr_index->tile_index[it_tile].tp_index);
+                                l_cstr_index->tile_index[it_tile].tp_index = NULL;
+                        }
+
+                        /* Packet index (NOT USED)*/
+                        l_cstr_index->tile_index[it_tile].nb_packet = 0;
+                        l_cstr_index->tile_index[it_tile].packet_index = NULL;
+
+                }
+        }
+
+        return l_cstr_index;
+}
+
+static OPJ_BOOL opj_j2k_allocate_tile_element_cstr_index(opj_j2k_t *p_j2k)
+{
+        OPJ_UINT32 it_tile=0;
+
+        p_j2k->cstr_index->nb_of_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th;
+        p_j2k->cstr_index->tile_index = (opj_tile_index_t*)opj_calloc(p_j2k->cstr_index->nb_of_tiles, sizeof(opj_tile_index_t));
+        if (!p_j2k->cstr_index->tile_index)
+                return OPJ_FALSE;
+
+        for (it_tile=0; it_tile < p_j2k->cstr_index->nb_of_tiles; it_tile++){
+                p_j2k->cstr_index->tile_index[it_tile].maxmarknum = 100;
+                p_j2k->cstr_index->tile_index[it_tile].marknum = 0;
+                p_j2k->cstr_index->tile_index[it_tile].marker = (opj_marker_info_t*)
+                                opj_calloc(p_j2k->cstr_index->tile_index[it_tile].maxmarknum, sizeof(opj_marker_info_t));
+                if (!p_j2k->cstr_index->tile_index[it_tile].marker)
+                        return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_decode_tiles ( opj_j2k_t *p_j2k,
+                                                            opj_stream_private_t *p_stream,
+                                                            opj_event_mgr_t * p_manager)
+{
+        OPJ_BOOL l_go_on = OPJ_TRUE;
+        OPJ_UINT32 l_current_tile_no;
+        OPJ_UINT32 l_data_size,l_max_data_size;
+        OPJ_INT32 l_tile_x0,l_tile_y0,l_tile_x1,l_tile_y1;
+        OPJ_UINT32 l_nb_comps;
+        OPJ_BYTE * l_current_data;
+        OPJ_UINT32 nr_tiles = 0;
+
+        l_current_data = (OPJ_BYTE*)opj_malloc(1000);
+        if (! l_current_data) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to decode tiles\n");
+                return OPJ_FALSE;
+        }
+        l_max_data_size = 1000;
+
+		for (;;) {
+                if (! opj_j2k_read_tile_header( p_j2k,
+                                        &l_current_tile_no,
+                                        &l_data_size,
+                                        &l_tile_x0, &l_tile_y0,
+                                        &l_tile_x1, &l_tile_y1,
+                                        &l_nb_comps,
+                                        &l_go_on,
+                                        p_stream,
+                                        p_manager)) {
+                        opj_free(l_current_data);
+                        return OPJ_FALSE;
+                }
+
+                if (! l_go_on) {
+                        break;
+                }
+
+                if (l_data_size > l_max_data_size) {
+                        OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(l_current_data, l_data_size);
+                        if (! l_new_current_data) {
+                                opj_free(l_current_data);
+                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to decode tile %d/%d\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
+                                return OPJ_FALSE;
+                        }
+                        l_current_data = l_new_current_data;
+                        l_max_data_size = l_data_size;
+                }
+
+                if (! opj_j2k_decode_tile(p_j2k,l_current_tile_no,l_current_data,l_data_size,p_stream,p_manager)) {
+                        opj_free(l_current_data);
+                        opj_event_msg(p_manager, EVT_ERROR, "Failed to decode tile %d/%d\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
+                        return OPJ_FALSE;
+                }
+                opj_event_msg(p_manager, EVT_INFO, "Tile %d/%d has been decoded.\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
+
+                if (! opj_j2k_update_image_data(p_j2k->m_tcd,l_current_data, p_j2k->m_output_image)) {
+                        opj_free(l_current_data);
+                        return OPJ_FALSE;
+                }
+                opj_event_msg(p_manager, EVT_INFO, "Image data has been updated with tile %d.\n\n", l_current_tile_no + 1);
+                
+                if(opj_stream_get_number_byte_left(p_stream) == 0  
+                    && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC)
+                    break;
+                if(++nr_tiles ==  p_j2k->m_cp.th * p_j2k->m_cp.tw) 
+                    break;
+        }
+
+        opj_free(l_current_data);
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Sets up the procedures to do on decoding data. Developpers wanting to extend the library can add their own reading procedures.
+ */
+static OPJ_BOOL opj_j2k_setup_decoding (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
+{
+        /* preconditions*/
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_tiles, p_manager)) {
+                return OPJ_FALSE;
+        }
+        /* DEVELOPER CORNER, add your custom procedures */
+
+        return OPJ_TRUE;
+}
+
+/*
+ * Read and decode one tile.
+ */
+static OPJ_BOOL opj_j2k_decode_one_tile (       opj_j2k_t *p_j2k,
+                                                                            opj_stream_private_t *p_stream,
+                                                                            opj_event_mgr_t * p_manager)
+{
+        OPJ_BOOL l_go_on = OPJ_TRUE;
+        OPJ_UINT32 l_current_tile_no;
+        OPJ_UINT32 l_tile_no_to_dec;
+        OPJ_UINT32 l_data_size,l_max_data_size;
+        OPJ_INT32 l_tile_x0,l_tile_y0,l_tile_x1,l_tile_y1;
+        OPJ_UINT32 l_nb_comps;
+        OPJ_BYTE * l_current_data;
+
+        l_current_data = (OPJ_BYTE*)opj_malloc(1000);
+        if (! l_current_data) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to decode one tile\n");
+                return OPJ_FALSE;
+        }
+        l_max_data_size = 1000;
+
+        /*Allocate and initialize some elements of codestrem index if not already done*/
+        if( !p_j2k->cstr_index->tile_index)
+        {
+                if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)){
+                        opj_free(l_current_data);
+                        return OPJ_FALSE;
+                }
+        }
+        /* Move into the codestream to the first SOT used to decode the desired tile */
+        l_tile_no_to_dec = (OPJ_UINT32)p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec;
+        if (p_j2k->cstr_index->tile_index)
+                if(p_j2k->cstr_index->tile_index->tp_index)
+                {
+                        if ( ! p_j2k->cstr_index->tile_index[l_tile_no_to_dec].nb_tps) {
+                                /* the index for this tile has not been built,
+                                 *  so move to the last SOT read */
+                                if ( !(opj_stream_read_seek(p_stream, p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos+2, p_manager)) ){
+                                        opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
+                                        opj_free(l_current_data);
+                                        return OPJ_FALSE;
+                                }
+                        }
+                        else{
+                                if ( !(opj_stream_read_seek(p_stream, p_j2k->cstr_index->tile_index[l_tile_no_to_dec].tp_index[0].start_pos+2, p_manager)) ) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
+                                        opj_free(l_current_data);
+                                        return OPJ_FALSE;
+                                }
+                        }
+                        /* Special case if we have previously read the EOC marker (if the previous tile getted is the last ) */
+                        if(p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_EOC)
+                                p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
+                }
+
+		for (;;) {
+                if (! opj_j2k_read_tile_header( p_j2k,
+                                        &l_current_tile_no,
+                                        &l_data_size,
+                                        &l_tile_x0, &l_tile_y0,
+                                        &l_tile_x1, &l_tile_y1,
+                                        &l_nb_comps,
+                                        &l_go_on,
+                                        p_stream,
+                                        p_manager)) {
+                        opj_free(l_current_data);
+                        return OPJ_FALSE;
+                }
+
+                if (! l_go_on) {
+                        break;
+                }
+
+                if (l_data_size > l_max_data_size) {
+                        OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(l_current_data, l_data_size);
+                        if (! l_new_current_data) {
+                                opj_free(l_current_data);
+                                l_current_data = NULL;
+                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to decode tile %d/%d\n", l_current_tile_no+1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
+                                return OPJ_FALSE;
+                        }
+                        l_current_data = l_new_current_data;
+                        l_max_data_size = l_data_size;
+                }
+
+                if (! opj_j2k_decode_tile(p_j2k,l_current_tile_no,l_current_data,l_data_size,p_stream,p_manager)) {
+                        opj_free(l_current_data);
+                        return OPJ_FALSE;
+                }
+                opj_event_msg(p_manager, EVT_INFO, "Tile %d/%d has been decoded.\n", l_current_tile_no+1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
+
+                if (! opj_j2k_update_image_data(p_j2k->m_tcd,l_current_data, p_j2k->m_output_image)) {
+                        opj_free(l_current_data);
+                        return OPJ_FALSE;
+                }
+                opj_event_msg(p_manager, EVT_INFO, "Image data has been updated with tile %d.\n\n", l_current_tile_no+1);
+
+                if(l_current_tile_no == l_tile_no_to_dec)
+                {
+                        /* move into the codestream to the first SOT (FIXME or not move?)*/
+                        if (!(opj_stream_read_seek(p_stream, p_j2k->cstr_index->main_head_end + 2, p_manager) ) ) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
+                                opj_free(l_current_data);
+                                return OPJ_FALSE;
+                        }
+                        break;
+                }
+                else {
+                        opj_event_msg(p_manager, EVT_WARNING, "Tile read, decoded and updated is not the desired one (%d vs %d).\n", l_current_tile_no+1, l_tile_no_to_dec+1);
+                }
+
+        }
+
+        opj_free(l_current_data);
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Sets up the procedures to do on decoding one tile. Developpers wanting to extend the library can add their own reading procedures.
+ */
+static OPJ_BOOL opj_j2k_setup_decoding_tile (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
+{
+        /* preconditions*/
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_one_tile, p_manager)) {
+                return OPJ_FALSE;
+        }
+        /* DEVELOPER CORNER, add your custom procedures */
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_decode(opj_j2k_t * p_j2k,
+                                                opj_stream_private_t * p_stream,
+                                                opj_image_t * p_image,
+                                                opj_event_mgr_t * p_manager)
+{
+        OPJ_UINT32 compno;
+
+        if (!p_image)
+                return OPJ_FALSE;
+	
+        p_j2k->m_output_image = opj_image_create0();
+        if (! (p_j2k->m_output_image)) {
+                return OPJ_FALSE;
+        }
+        opj_copy_image_header(p_image, p_j2k->m_output_image);
+
+        /* customization of the decoding */
+        opj_j2k_setup_decoding(p_j2k, p_manager);
+
+        /* Decode the codestream */
+        if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
+                opj_image_destroy(p_j2k->m_private_image);
+                p_j2k->m_private_image = NULL;
+                return OPJ_FALSE;
+        }
+
+        /* Move data and copy one information from codec to output image*/
+        for (compno = 0; compno < p_image->numcomps; compno++) {
+                p_image->comps[compno].resno_decoded = p_j2k->m_output_image->comps[compno].resno_decoded;
+                p_image->comps[compno].data = p_j2k->m_output_image->comps[compno].data;
+#if 0
+                char fn[256];
+                sprintf( fn, "/tmp/%d.raw", compno );
+                FILE *debug = fopen( fn, "wb" );
+                fwrite( p_image->comps[compno].data, sizeof(OPJ_INT32), p_image->comps[compno].w * p_image->comps[compno].h, debug );
+                fclose( debug );
+#endif
+                p_j2k->m_output_image->comps[compno].data = NULL;
+        }
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_get_tile(      opj_j2k_t *p_j2k,
+                                                    opj_stream_private_t *p_stream,
+                                                    opj_image_t* p_image,
+                                                    opj_event_mgr_t * p_manager,
+                                                    OPJ_UINT32 tile_index )
+{
+        OPJ_UINT32 compno;
+        OPJ_UINT32 l_tile_x, l_tile_y;
+        opj_image_comp_t* l_img_comp;
+
+        if (!p_image) {
+                opj_event_msg(p_manager, EVT_ERROR, "We need an image previously created.\n");
+                return OPJ_FALSE;
+        }
+
+        if ( /*(tile_index < 0) &&*/ (tile_index >= p_j2k->m_cp.tw * p_j2k->m_cp.th) ){
+                opj_event_msg(p_manager, EVT_ERROR, "Tile index provided by the user is incorrect %d (max = %d) \n", tile_index, (p_j2k->m_cp.tw * p_j2k->m_cp.th) - 1);
+                return OPJ_FALSE;
+        }
+
+        /* Compute the dimension of the desired tile*/
+        l_tile_x = tile_index % p_j2k->m_cp.tw;
+        l_tile_y = tile_index / p_j2k->m_cp.tw;
+
+        p_image->x0 = l_tile_x * p_j2k->m_cp.tdx + p_j2k->m_cp.tx0;
+        if (p_image->x0 < p_j2k->m_private_image->x0)
+                p_image->x0 = p_j2k->m_private_image->x0;
+        p_image->x1 = (l_tile_x + 1) * p_j2k->m_cp.tdx + p_j2k->m_cp.tx0;
+        if (p_image->x1 > p_j2k->m_private_image->x1)
+                p_image->x1 = p_j2k->m_private_image->x1;
+
+        p_image->y0 = l_tile_y * p_j2k->m_cp.tdy + p_j2k->m_cp.ty0;
+        if (p_image->y0 < p_j2k->m_private_image->y0)
+                p_image->y0 = p_j2k->m_private_image->y0;
+        p_image->y1 = (l_tile_y + 1) * p_j2k->m_cp.tdy + p_j2k->m_cp.ty0;
+        if (p_image->y1 > p_j2k->m_private_image->y1)
+                p_image->y1 = p_j2k->m_private_image->y1;
+
+        l_img_comp = p_image->comps;
+        for (compno=0; compno < p_image->numcomps; ++compno)
+        {
+                OPJ_INT32 l_comp_x1, l_comp_y1;
+
+                l_img_comp->factor = p_j2k->m_private_image->comps[compno].factor;
+
+                l_img_comp->x0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->x0, (OPJ_INT32)l_img_comp->dx);
+                l_img_comp->y0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->y0, (OPJ_INT32)l_img_comp->dy);
+                l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
+                l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
+
+                l_img_comp->w = (OPJ_UINT32)(opj_int_ceildivpow2(l_comp_x1, (OPJ_INT32)l_img_comp->factor) - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->x0, (OPJ_INT32)l_img_comp->factor));
+                l_img_comp->h = (OPJ_UINT32)(opj_int_ceildivpow2(l_comp_y1, (OPJ_INT32)l_img_comp->factor) - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->y0, (OPJ_INT32)l_img_comp->factor));
+
+                l_img_comp++;
+        }
+
+        /* Destroy the previous output image*/
+        if (p_j2k->m_output_image)
+                opj_image_destroy(p_j2k->m_output_image);
+
+        /* Create the ouput image from the information previously computed*/
+        p_j2k->m_output_image = opj_image_create0();
+        if (! (p_j2k->m_output_image)) {
+                return OPJ_FALSE;
+        }
+        opj_copy_image_header(p_image, p_j2k->m_output_image);
+
+        p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = (OPJ_INT32)tile_index;
+
+        /* customization of the decoding */
+        opj_j2k_setup_decoding_tile(p_j2k, p_manager);
+
+        /* Decode the codestream */
+        if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
+                opj_image_destroy(p_j2k->m_private_image);
+                p_j2k->m_private_image = NULL;
+                return OPJ_FALSE;
+        }
+
+        /* Move data and copy one information from codec to output image*/
+        for (compno = 0; compno < p_image->numcomps; compno++) {
+                p_image->comps[compno].resno_decoded = p_j2k->m_output_image->comps[compno].resno_decoded;
+
+                if (p_image->comps[compno].data)
+                        opj_free(p_image->comps[compno].data);
+
+                p_image->comps[compno].data = p_j2k->m_output_image->comps[compno].data;
+
+                p_j2k->m_output_image->comps[compno].data = NULL;
+        }
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k,
+                                               OPJ_UINT32 res_factor,
+                                               opj_event_mgr_t * p_manager)
+{
+        OPJ_UINT32 it_comp;
+
+        p_j2k->m_cp.m_specific_param.m_dec.m_reduce = res_factor;
+
+        if (p_j2k->m_private_image) {
+                if (p_j2k->m_private_image->comps) {
+                        if (p_j2k->m_specific_param.m_decoder.m_default_tcp) {
+                                if (p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps) {
+                                        for (it_comp = 0 ; it_comp < p_j2k->m_private_image->numcomps; it_comp++) {
+                                                OPJ_UINT32 max_res = p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[it_comp].numresolutions;
+                                                if ( res_factor >= max_res){
+                                                        opj_event_msg(p_manager, EVT_ERROR, "Resolution factor is greater than the maximum resolution in the component.\n");
+                                                        return OPJ_FALSE;
+                                                }
+                                                p_j2k->m_private_image->comps[it_comp].factor = res_factor;
+                                        }
+                                        return OPJ_TRUE;
+                                }
+                        }
+                }
+        }
+
+        return OPJ_FALSE;
+}
+
+OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k,
+                        opj_stream_private_t *p_stream,
+                        opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 i, j;
+        OPJ_UINT32 l_nb_tiles;
+        OPJ_UINT32 l_max_tile_size = 0, l_current_tile_size;
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_BOOL l_reuse_data = OPJ_FALSE;
+        opj_tcd_t* p_tcd = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+	
+        p_tcd = p_j2k->m_tcd;
+
+        l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
+        if (l_nb_tiles == 1) {
+                l_reuse_data = OPJ_TRUE;
+#ifdef __SSE__
+                for (j=0;j<p_j2k->m_tcd->image->numcomps;++j) {
+                        opj_image_comp_t * l_img_comp = p_tcd->image->comps + j;
+                        if (((size_t)l_img_comp->data & 0xFU) != 0U) { /* tile data shall be aligned on 16 bytes */
+												        l_reuse_data = OPJ_FALSE;
+                        }
+                }
+#endif
+        }
+        for (i=0;i<l_nb_tiles;++i) {
+                if (! opj_j2k_pre_write_tile(p_j2k,i,p_stream,p_manager)) {
+                        if (l_current_data) {
+                                opj_free(l_current_data);
+                        }
+                        return OPJ_FALSE;
+                }
+
+                /* if we only have one tile, then simply set tile component data equal to image component data */
+                /* otherwise, allocate the data */
+                for (j=0;j<p_j2k->m_tcd->image->numcomps;++j) {
+                        opj_tcd_tilecomp_t* l_tilec = p_tcd->tcd_image->tiles->comps + j;
+                        if (l_reuse_data) {
+												        opj_image_comp_t * l_img_comp = p_tcd->image->comps + j;
+												        l_tilec->data  =  l_img_comp->data;
+												        l_tilec->ownsData = OPJ_FALSE;
+                        } else {
+												        if(! opj_alloc_tile_component_data(l_tilec)) {
+												                opj_event_msg(p_manager, EVT_ERROR, "Error allocating tile component data." );
+												                if (l_current_data) {
+												                        opj_free(l_current_data);
+												                }
+												                return OPJ_FALSE;
+												        }
+                        }
+                }
+                l_current_tile_size = opj_tcd_get_encoded_tile_size(p_j2k->m_tcd);
+                if (!l_reuse_data) {
+                        if (l_current_tile_size > l_max_tile_size) {
+												        OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(l_current_data, l_current_tile_size);
+												        if (! l_new_current_data) {
+												                if (l_current_data) {
+												                        opj_free(l_current_data);
+												                }
+												                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to encode all tiles\n");
+												                return OPJ_FALSE;
+																}
+																l_current_data = l_new_current_data;
+																l_max_tile_size = l_current_tile_size;
+                        }
+
+                        /* copy image data (32 bit) to l_current_data as contiguous, all-component, zero offset buffer */
+                        /* 32 bit components @ 8 bit precision get converted to 8 bit */
+                        /* 32 bit components @ 16 bit precision get converted to 16 bit */
+                        opj_j2k_get_tile_data(p_j2k->m_tcd,l_current_data);
+
+                        /* now copy this data into the tile component */
+                        if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,l_current_data,l_current_tile_size)) {
+																opj_event_msg(p_manager, EVT_ERROR, "Size mismatch between tile data and sent data." );
+																opj_free(l_current_data);
+																return OPJ_FALSE;
+                        }
+                }
+
+                if (! opj_j2k_post_write_tile (p_j2k,p_stream,p_manager)) {
+                        if (l_current_data) {
+                                opj_free(l_current_data);
+                        }
+                        return OPJ_FALSE;
+                }
+        }
+
+        if (l_current_data) {
+                opj_free(l_current_data);
+        }
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_end_compress(  opj_j2k_t *p_j2k,
+                                                        opj_stream_private_t *p_stream,
+                                                        opj_event_mgr_t * p_manager)
+{
+        /* customization of the encoding */
+        if (! opj_j2k_setup_end_compress(p_j2k, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        if (! opj_j2k_exec (p_j2k, p_j2k->m_procedure_list, p_stream, p_manager))
+        {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k,
+                                                            opj_stream_private_t *p_stream,
+                                                            opj_image_t * p_image,
+                                                            opj_event_mgr_t * p_manager)
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        p_j2k->m_private_image = opj_image_create0();
+        if (! p_j2k->m_private_image) {
+                opj_event_msg(p_manager, EVT_ERROR, "Failed to allocate image header." );
+                return OPJ_FALSE;
+        }
+        opj_copy_image_header(p_image, p_j2k->m_private_image);
+
+        /* TODO_MSD: Find a better way */
+        if (p_image->comps) {
+                OPJ_UINT32 it_comp;
+                for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) {
+                        if (p_image->comps[it_comp].data) {
+                                p_j2k->m_private_image->comps[it_comp].data =p_image->comps[it_comp].data;
+                                p_image->comps[it_comp].data = NULL;
+
+                        }
+                }
+        }
+
+        /* customization of the validation */
+        if (! opj_j2k_setup_encoding_validation (p_j2k, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        /* validation of the parameters codec */
+        if (! opj_j2k_exec(p_j2k,p_j2k->m_validation_list,p_stream,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        /* customization of the encoding */
+        if (! opj_j2k_setup_header_writing(p_j2k, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        /* write header */
+        if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_pre_write_tile (       opj_j2k_t * p_j2k,
+                                                                OPJ_UINT32 p_tile_index,
+                                                                opj_stream_private_t *p_stream,
+                                                                opj_event_mgr_t * p_manager )
+{
+  (void)p_stream;
+        if (p_tile_index != p_j2k->m_current_tile_number) {
+                opj_event_msg(p_manager, EVT_ERROR, "The given tile index does not match." );
+                return OPJ_FALSE;
+        }
+
+        opj_event_msg(p_manager, EVT_INFO, "tile number %d / %d\n", p_j2k->m_current_tile_number + 1, p_j2k->m_cp.tw * p_j2k->m_cp.th);
+
+        p_j2k->m_specific_param.m_encoder.m_current_tile_part_number = 0;
+        p_j2k->m_tcd->cur_totnum_tp = p_j2k->m_cp.tcps[p_tile_index].m_nb_tile_parts;
+        p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
+
+        /* initialisation before tile encoding  */
+        if (! opj_tcd_init_encode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static void opj_get_tile_dimensions(opj_image_t * l_image,
+                             opj_tcd_tilecomp_t * l_tilec,
+                             opj_image_comp_t * l_img_comp,
+                             OPJ_UINT32* l_size_comp,
+                             OPJ_UINT32* l_width,
+                             OPJ_UINT32* l_height,
+                             OPJ_UINT32* l_offset_x,
+                             OPJ_UINT32* l_offset_y,
+                             OPJ_UINT32* l_image_width,
+                             OPJ_UINT32* l_stride,
+                             OPJ_UINT32* l_tile_offset) {
+	OPJ_UINT32 l_remaining;
+	*l_size_comp = l_img_comp->prec >> 3; /* (/8) */
+	l_remaining = l_img_comp->prec & 7;  /* (%8) */
+	if (l_remaining) {
+		*l_size_comp += 1;
+	}
+
+	if (*l_size_comp == 3) {
+		*l_size_comp = 4;
+	}
+
+	*l_width  = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
+	*l_height = (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0);
+	*l_offset_x = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)l_image->x0, (OPJ_INT32)l_img_comp->dx);
+	*l_offset_y = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)l_image->y0, (OPJ_INT32)l_img_comp->dy);
+	*l_image_width = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)l_image->x1 - (OPJ_INT32)l_image->x0, (OPJ_INT32)l_img_comp->dx);
+	*l_stride = *l_image_width - *l_width;
+	*l_tile_offset = ((OPJ_UINT32)l_tilec->x0 - *l_offset_x) + ((OPJ_UINT32)l_tilec->y0 - *l_offset_y) * *l_image_width;
+}
+
+static void opj_j2k_get_tile_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data)
+{
+        OPJ_UINT32 i,j,k = 0;
+
+        for (i=0;i<p_tcd->image->numcomps;++i) {
+                opj_image_t * l_image =  p_tcd->image;
+                OPJ_INT32 * l_src_ptr;
+                opj_tcd_tilecomp_t * l_tilec = p_tcd->tcd_image->tiles->comps + i;
+                opj_image_comp_t * l_img_comp = l_image->comps + i;
+                OPJ_UINT32 l_size_comp,l_width,l_height,l_offset_x,l_offset_y, l_image_width,l_stride,l_tile_offset;
+
+                opj_get_tile_dimensions(l_image,
+                                        l_tilec,
+                                        l_img_comp,
+                                        &l_size_comp,
+                                        &l_width,
+                                        &l_height,
+                                        &l_offset_x,
+                                        &l_offset_y,
+                                        &l_image_width,
+                                        &l_stride,
+                                        &l_tile_offset);
+
+                l_src_ptr = l_img_comp->data + l_tile_offset;
+
+                switch (l_size_comp) {
+                        case 1:
+                                {
+                                        OPJ_CHAR * l_dest_ptr = (OPJ_CHAR*) p_data;
+                                        if (l_img_comp->sgnd) {
+                                                for     (j=0;j<l_height;++j) {
+                                                        for (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr) = (OPJ_CHAR) (*l_src_ptr);
+                                                                ++l_dest_ptr;
+                                                                ++l_src_ptr;
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+                                        else {
+                                                for (j=0;j<l_height;++j) {
+                                                        for (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr) = (OPJ_CHAR)((*l_src_ptr)&0xff);
+                                                                ++l_dest_ptr;
+                                                                ++l_src_ptr;
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+
+                                        p_data = (OPJ_BYTE*) l_dest_ptr;
+                                }
+                                break;
+                        case 2:
+                                {
+                                        OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_data;
+                                        if (l_img_comp->sgnd) {
+                                                for (j=0;j<l_height;++j) {
+                                                        for (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr++) = (OPJ_INT16) (*(l_src_ptr++));
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+                                        else {
+                                                for (j=0;j<l_height;++j) {
+                                                        for (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr++) = (OPJ_INT16)((*(l_src_ptr++)) & 0xffff);
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+
+                                        p_data = (OPJ_BYTE*) l_dest_ptr;
+                                }
+                                break;
+                        case 4:
+                                {
+                                        OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_data;
+                                        for (j=0;j<l_height;++j) {
+                                                for (k=0;k<l_width;++k) {
+                                                        *(l_dest_ptr++) = *(l_src_ptr++);
+                                                }
+                                                l_src_ptr += l_stride;
+                                        }
+
+                                        p_data = (OPJ_BYTE*) l_dest_ptr;
+                                }
+                                break;
+                }
+        }
+}
+
+static OPJ_BOOL opj_j2k_post_write_tile (      opj_j2k_t * p_j2k,
+                                                                opj_stream_private_t *p_stream,
+                                                                opj_event_mgr_t * p_manager )
+{
+        OPJ_UINT32 l_nb_bytes_written;
+        OPJ_BYTE * l_current_data = 00;
+        OPJ_UINT32 l_tile_size = 0;
+        OPJ_UINT32 l_available_data;
+
+        /* preconditions */
+        assert(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
+
+        l_tile_size = p_j2k->m_specific_param.m_encoder.m_encoded_tile_size;
+        l_available_data = l_tile_size;
+        l_current_data = p_j2k->m_specific_param.m_encoder.m_encoded_tile_data;
+
+        l_nb_bytes_written = 0;
+        if (! opj_j2k_write_first_tile_part(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_stream,p_manager)) {
+                return OPJ_FALSE;
+        }
+        l_current_data += l_nb_bytes_written;
+        l_available_data -= l_nb_bytes_written;
+
+        l_nb_bytes_written = 0;
+        if (! opj_j2k_write_all_tile_parts(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_stream,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        l_available_data -= l_nb_bytes_written;
+        l_nb_bytes_written = l_tile_size - l_available_data;
+
+        if ( opj_stream_write_data(     p_stream,
+                                                                p_j2k->m_specific_param.m_encoder.m_encoded_tile_data,
+                                                                l_nb_bytes_written,p_manager) != l_nb_bytes_written) {
+                return OPJ_FALSE;
+        }
+
+        ++p_j2k->m_current_tile_number;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_setup_end_compress (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        /* DEVELOPER CORNER, insert your custom procedures */
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_eoc, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) {
+                if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_updated_tlm, p_manager)) {
+                        return OPJ_FALSE;
+                }
+        }
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_epc, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_end_encoding, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_destroy_header_memory, p_manager)) {
+                return OPJ_FALSE;
+        }
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_build_encoder, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_encoding_validation, p_manager)) {
+                return OPJ_FALSE;
+				}
+
+        /* DEVELOPER CORNER, add your custom validation procedure */
+        if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_mct_validation, p_manager)) {
+                return OPJ_FALSE;
+        }
+	
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_setup_header_writing (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager)
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_init_info, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_soc, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_siz, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_cod, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_qcd, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_coc, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_all_qcc, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) {
+                if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_tlm, p_manager)) {
+                        return OPJ_FALSE;
+                }
+
+                if (p_j2k->m_cp.rsiz == OPJ_PROFILE_CINEMA_4K) {
+                        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_poc, p_manager)) {
+                                return OPJ_FALSE;
+                        }
+                }
+        }
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_regions, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        if (p_j2k->m_cp.comment != 00)  {
+                if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_com, p_manager)) {
+                        return OPJ_FALSE;
+                }
+        }
+
+        /* DEVELOPER CORNER, insert your custom procedures */
+        if (p_j2k->m_cp.rsiz & OPJ_EXTENSION_MCT) {
+                if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_mct_data_group, p_manager)) {
+                        return OPJ_FALSE;
+                }
+        }
+        /* End of Developer Corner */
+
+        if (p_j2k->cstr_index) {
+                if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_get_end_header, p_manager)) {
+                        return OPJ_FALSE;
+                }
+        }
+
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_create_tcd, p_manager)) {
+                return OPJ_FALSE;
+        }
+        if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_update_rates, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_first_tile_part (opj_j2k_t *p_j2k,
+                                                                        OPJ_BYTE * p_data,
+                                                                        OPJ_UINT32 * p_data_written,
+                                                                        OPJ_UINT32 p_total_data_size,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 l_nb_bytes_written = 0;
+        OPJ_UINT32 l_current_nb_bytes_written;
+        OPJ_BYTE * l_begin_data = 00;
+
+        opj_tcd_t * l_tcd = 00;
+        opj_cp_t * l_cp = 00;
+
+        l_tcd = p_j2k->m_tcd;
+        l_cp = &(p_j2k->m_cp);
+
+        l_tcd->cur_pino = 0;
+
+        /*Get number of tile parts*/
+        p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0;
+
+        /* INDEX >> */
+        /* << INDEX */
+
+        l_current_nb_bytes_written = 0;
+        l_begin_data = p_data;
+        if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager))
+        {
+                return OPJ_FALSE;
+        }
+
+        l_nb_bytes_written += l_current_nb_bytes_written;
+        p_data += l_current_nb_bytes_written;
+        p_total_data_size -= l_current_nb_bytes_written;
+
+        if (!OPJ_IS_CINEMA(l_cp->rsiz)) {
+#if 0
+                for (compno = 1; compno < p_j2k->m_private_image->numcomps; compno++) {
+                        l_current_nb_bytes_written = 0;
+                        opj_j2k_write_coc_in_memory(p_j2k,compno,p_data,&l_current_nb_bytes_written,p_manager);
+                        l_nb_bytes_written += l_current_nb_bytes_written;
+                        p_data += l_current_nb_bytes_written;
+                        p_total_data_size -= l_current_nb_bytes_written;
+
+                        l_current_nb_bytes_written = 0;
+                        opj_j2k_write_qcc_in_memory(p_j2k,compno,p_data,&l_current_nb_bytes_written,p_manager);
+                        l_nb_bytes_written += l_current_nb_bytes_written;
+                        p_data += l_current_nb_bytes_written;
+                        p_total_data_size -= l_current_nb_bytes_written;
+                }
+#endif
+                if (l_cp->tcps[p_j2k->m_current_tile_number].numpocs) {
+                        l_current_nb_bytes_written = 0;
+                        opj_j2k_write_poc_in_memory(p_j2k,p_data,&l_current_nb_bytes_written,p_manager);
+                        l_nb_bytes_written += l_current_nb_bytes_written;
+                        p_data += l_current_nb_bytes_written;
+                        p_total_data_size -= l_current_nb_bytes_written;
+                }
+        }
+
+        l_current_nb_bytes_written = 0;
+        if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        l_nb_bytes_written += l_current_nb_bytes_written;
+        * p_data_written = l_nb_bytes_written;
+
+        /* Writing Psot in SOT marker */
+        opj_write_bytes(l_begin_data + 6,l_nb_bytes_written,4);                                 /* PSOT */
+
+        if (OPJ_IS_CINEMA(l_cp->rsiz)){
+                opj_j2k_update_tlm(p_j2k,l_nb_bytes_written);
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_all_tile_parts(  opj_j2k_t *p_j2k,
+                                                                        OPJ_BYTE * p_data,
+                                                                        OPJ_UINT32 * p_data_written,
+                                                                        OPJ_UINT32 p_total_data_size,
+                                                                        opj_stream_private_t *p_stream,
+                                                                        struct opj_event_mgr * p_manager
+                                                                )
+{
+        OPJ_UINT32 tilepartno=0;
+        OPJ_UINT32 l_nb_bytes_written = 0;
+        OPJ_UINT32 l_current_nb_bytes_written;
+        OPJ_UINT32 l_part_tile_size;
+        OPJ_UINT32 tot_num_tp;
+        OPJ_UINT32 pino;
+
+        OPJ_BYTE * l_begin_data;
+        opj_tcp_t *l_tcp = 00;
+        opj_tcd_t * l_tcd = 00;
+        opj_cp_t * l_cp = 00;
+
+        l_tcd = p_j2k->m_tcd;
+        l_cp = &(p_j2k->m_cp);
+        l_tcp = l_cp->tcps + p_j2k->m_current_tile_number;
+
+        /*Get number of tile parts*/
+        tot_num_tp = opj_j2k_get_num_tp(l_cp,0,p_j2k->m_current_tile_number);
+
+        /* start writing remaining tile parts */
+        ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
+        for (tilepartno = 1; tilepartno < tot_num_tp ; ++tilepartno) {
+                p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;
+                l_current_nb_bytes_written = 0;
+                l_part_tile_size = 0;
+                l_begin_data = p_data;
+
+                if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager)) {
+                        return OPJ_FALSE;
+                }
+
+                l_nb_bytes_written += l_current_nb_bytes_written;
+                p_data += l_current_nb_bytes_written;
+                p_total_data_size -= l_current_nb_bytes_written;
+                l_part_tile_size += l_current_nb_bytes_written;
+
+                l_current_nb_bytes_written = 0;
+                if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,p_manager)) {
+                        return OPJ_FALSE;
+                }
+
+                p_data += l_current_nb_bytes_written;
+                l_nb_bytes_written += l_current_nb_bytes_written;
+                p_total_data_size -= l_current_nb_bytes_written;
+                l_part_tile_size += l_current_nb_bytes_written;
+
+                /* Writing Psot in SOT marker */
+                opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);                                   /* PSOT */
+
+                if (OPJ_IS_CINEMA(l_cp->rsiz)) {
+                        opj_j2k_update_tlm(p_j2k,l_part_tile_size);
+                }
+
+                ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
+        }
+
+        for (pino = 1; pino <= l_tcp->numpocs; ++pino) {
+                l_tcd->cur_pino = pino;
+
+                /*Get number of tile parts*/
+                tot_num_tp = opj_j2k_get_num_tp(l_cp,pino,p_j2k->m_current_tile_number);
+                for (tilepartno = 0; tilepartno < tot_num_tp ; ++tilepartno) {
+                        p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno;
+                        l_current_nb_bytes_written = 0;
+                        l_part_tile_size = 0;
+                        l_begin_data = p_data;
+
+                        if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager)) {
+                                return OPJ_FALSE;
+                        }
+
+                        l_nb_bytes_written += l_current_nb_bytes_written;
+                        p_data += l_current_nb_bytes_written;
+                        p_total_data_size -= l_current_nb_bytes_written;
+                        l_part_tile_size += l_current_nb_bytes_written;
+
+                        l_current_nb_bytes_written = 0;
+
+                        if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,p_manager)) {
+                                return OPJ_FALSE;
+                        }
+
+                        l_nb_bytes_written += l_current_nb_bytes_written;
+                        p_data += l_current_nb_bytes_written;
+                        p_total_data_size -= l_current_nb_bytes_written;
+                        l_part_tile_size += l_current_nb_bytes_written;
+
+                        /* Writing Psot in SOT marker */
+                        opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);                                   /* PSOT */
+
+                        if (OPJ_IS_CINEMA(l_cp->rsiz)) {
+                                opj_j2k_update_tlm(p_j2k,l_part_tile_size);
+                        }
+
+                        ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number;
+                }
+        }
+
+        *p_data_written = l_nb_bytes_written;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_write_updated_tlm( opj_j2k_t *p_j2k,
+                                                                    struct opj_stream_private *p_stream,
+                                                                    struct opj_event_mgr * p_manager )
+{
+        OPJ_UINT32 l_tlm_size;
+        OPJ_OFF_T l_tlm_position, l_current_position;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        l_tlm_size = 5 * p_j2k->m_specific_param.m_encoder.m_total_tile_parts;
+        l_tlm_position = 6 + p_j2k->m_specific_param.m_encoder.m_tlm_start;
+        l_current_position = opj_stream_tell(p_stream);
+
+        if (! opj_stream_seek(p_stream,l_tlm_position,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer,l_tlm_size,p_manager) != l_tlm_size) {
+                return OPJ_FALSE;
+        }
+
+        if (! opj_stream_seek(p_stream,l_current_position,p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_end_encoding(  opj_j2k_t *p_j2k,
+                                                        struct opj_stream_private *p_stream,
+                                                        struct opj_event_mgr * p_manager )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        opj_tcd_destroy(p_j2k->m_tcd);
+        p_j2k->m_tcd = 00;
+
+        if (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
+                opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer);
+                p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 0;
+                p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 0;
+        }
+
+        if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) {
+                opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data);
+                p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 0;
+        }
+
+        p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = 0;
+
+        return OPJ_TRUE;
+}
+
+/**
+ * Destroys the memory associated with the decoding of headers.
+ */
+static OPJ_BOOL opj_j2k_destroy_header_memory ( opj_j2k_t * p_j2k,
+                                                opj_stream_private_t *p_stream,
+                                                opj_event_mgr_t * p_manager
+                                                )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_stream != 00);
+        assert(p_manager != 00);
+
+        if (p_j2k->m_specific_param.m_encoder.m_header_tile_data) {
+                opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
+                p_j2k->m_specific_param.m_encoder.m_header_tile_data = 0;
+        }
+
+        p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_j2k_init_info(     opj_j2k_t *p_j2k,
+                                                struct opj_stream_private *p_stream,
+                                                struct opj_event_mgr * p_manager )
+{
+        opj_codestream_info_t * l_cstr_info = 00;
+
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+  (void)l_cstr_info;
+
+        /* TODO mergeV2: check this part which use cstr_info */
+        /*l_cstr_info = p_j2k->cstr_info;
+
+        if (l_cstr_info)  {
+                OPJ_UINT32 compno;
+                l_cstr_info->tile = (opj_tile_info_t *) opj_malloc(p_j2k->m_cp.tw * p_j2k->m_cp.th * sizeof(opj_tile_info_t));
+
+                l_cstr_info->image_w = p_j2k->m_image->x1 - p_j2k->m_image->x0;
+                l_cstr_info->image_h = p_j2k->m_image->y1 - p_j2k->m_image->y0;
+
+                l_cstr_info->prog = (&p_j2k->m_cp.tcps[0])->prg;
+
+                l_cstr_info->tw = p_j2k->m_cp.tw;
+                l_cstr_info->th = p_j2k->m_cp.th;
+
+                l_cstr_info->tile_x = p_j2k->m_cp.tdx;*/        /* new version parser */
+                /*l_cstr_info->tile_y = p_j2k->m_cp.tdy;*/      /* new version parser */
+                /*l_cstr_info->tile_Ox = p_j2k->m_cp.tx0;*/     /* new version parser */
+                /*l_cstr_info->tile_Oy = p_j2k->m_cp.ty0;*/     /* new version parser */
+
+                /*l_cstr_info->numcomps = p_j2k->m_image->numcomps;
+
+                l_cstr_info->numlayers = (&p_j2k->m_cp.tcps[0])->numlayers;
+
+                l_cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(p_j2k->m_image->numcomps * sizeof(OPJ_INT32));
+
+                for (compno=0; compno < p_j2k->m_image->numcomps; compno++) {
+                        l_cstr_info->numdecompos[compno] = (&p_j2k->m_cp.tcps[0])->tccps->numresolutions - 1;
+                }
+
+                l_cstr_info->D_max = 0.0;       */      /* ADD Marcela */
+
+                /*l_cstr_info->main_head_start = opj_stream_tell(p_stream);*/ /* position of SOC */
+
+                /*l_cstr_info->maxmarknum = 100;
+                l_cstr_info->marker = (opj_marker_info_t *) opj_malloc(l_cstr_info->maxmarknum * sizeof(opj_marker_info_t));
+                l_cstr_info->marknum = 0;
+        }*/
+
+        return opj_j2k_calculate_tp(p_j2k,&(p_j2k->m_cp),&p_j2k->m_specific_param.m_encoder.m_total_tile_parts,p_j2k->m_private_image,p_manager);
+}
+
+/**
+ * Creates a tile-coder decoder.
+ *
+ * @param       p_stream                the stream to write data to.
+ * @param       p_j2k                   J2K codec.
+ * @param       p_manager               the user event manager.
+*/
+static OPJ_BOOL opj_j2k_create_tcd(     opj_j2k_t *p_j2k,
+                                                                    opj_stream_private_t *p_stream,
+                                                                    opj_event_mgr_t * p_manager
+                                    )
+{
+        /* preconditions */
+        assert(p_j2k != 00);
+        assert(p_manager != 00);
+        assert(p_stream != 00);
+
+        p_j2k->m_tcd = opj_tcd_create(OPJ_FALSE);
+
+        if (! p_j2k->m_tcd) {
+                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to create Tile Coder\n");
+                return OPJ_FALSE;
+        }
+
+        if (!opj_tcd_init(p_j2k->m_tcd,p_j2k->m_private_image,&p_j2k->m_cp)) {
+                opj_tcd_destroy(p_j2k->m_tcd);
+                p_j2k->m_tcd = 00;
+                return OPJ_FALSE;
+        }
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_j2k_write_tile (opj_j2k_t * p_j2k,
+                                                 OPJ_UINT32 p_tile_index,
+                                                 OPJ_BYTE * p_data,
+                                                 OPJ_UINT32 p_data_size,
+                                                 opj_stream_private_t *p_stream,
+                                                 opj_event_mgr_t * p_manager )
+{
+        if (! opj_j2k_pre_write_tile(p_j2k,p_tile_index,p_stream,p_manager)) {
+                opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k_pre_write_tile with tile index = %d\n", p_tile_index);
+                return OPJ_FALSE;
+        }
+        else {
+                OPJ_UINT32 j;
+                /* Allocate data */
+                for (j=0;j<p_j2k->m_tcd->image->numcomps;++j) {
+                        opj_tcd_tilecomp_t* l_tilec = p_j2k->m_tcd->tcd_image->tiles->comps + j;
+
+                        if(! opj_alloc_tile_component_data(l_tilec)) {
+												        opj_event_msg(p_manager, EVT_ERROR, "Error allocating tile component data." );
+                                return OPJ_FALSE;
+                        }
+                }
+
+                /* now copy data into the tile component */
+                if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,p_data,p_data_size)) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Size mismatch between tile data and sent data." );
+                        return OPJ_FALSE;
+                }
+                if (! opj_j2k_post_write_tile(p_j2k,p_stream,p_manager)) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k_post_write_tile with tile index = %d\n", p_tile_index);
+                        return OPJ_FALSE;
+                }
+        }
+
+        return OPJ_TRUE;
+}
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.h
new file mode 100644
index 0000000..358e073
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/j2k.h
@@ -0,0 +1,863 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2006-2007, Parvatha Elangovan
+ * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __J2K_H
+#define __J2K_H
+/**
+ at file j2k.h
+ at brief The JPEG-2000 Codestream Reader/Writer (J2K)
+
+The functions in J2K.C have for goal to read/write the several parts of the codestream: markers and data.
+*/
+
+/** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */
+/*@{*/
+
+#define J2K_CP_CSTY_PRT 0x01
+#define J2K_CP_CSTY_SOP 0x02
+#define J2K_CP_CSTY_EPH 0x04
+#define J2K_CCP_CSTY_PRT 0x01
+#define J2K_CCP_CBLKSTY_LAZY 0x01     /**< Selective arithmetic coding bypass */
+#define J2K_CCP_CBLKSTY_RESET 0x02    /**< Reset context probabilities on coding pass boundaries */
+#define J2K_CCP_CBLKSTY_TERMALL 0x04  /**< Termination on each coding pass */
+#define J2K_CCP_CBLKSTY_VSC 0x08      /**< Vertically stripe causal context */
+#define J2K_CCP_CBLKSTY_PTERM 0x10    /**< Predictable termination */
+#define J2K_CCP_CBLKSTY_SEGSYM 0x20   /**< Segmentation symbols are used */
+#define J2K_CCP_QNTSTY_NOQNT 0
+#define J2K_CCP_QNTSTY_SIQNT 1
+#define J2K_CCP_QNTSTY_SEQNT 2
+
+#define OPJ_J2K_DEFAULT_CBLK_DATA_SIZE 8192
+
+/* ----------------------------------------------------------------------- */
+
+#define J2K_MS_SOC 0xff4f	/**< SOC marker value */
+#define J2K_MS_SOT 0xff90	/**< SOT marker value */
+#define J2K_MS_SOD 0xff93	/**< SOD marker value */
+#define J2K_MS_EOC 0xffd9	/**< EOC marker value */
+#define J2K_MS_SIZ 0xff51	/**< SIZ marker value */
+#define J2K_MS_COD 0xff52	/**< COD marker value */
+#define J2K_MS_COC 0xff53	/**< COC marker value */
+#define J2K_MS_RGN 0xff5e	/**< RGN marker value */
+#define J2K_MS_QCD 0xff5c	/**< QCD marker value */
+#define J2K_MS_QCC 0xff5d	/**< QCC marker value */
+#define J2K_MS_POC 0xff5f	/**< POC marker value */
+#define J2K_MS_TLM 0xff55	/**< TLM marker value */
+#define J2K_MS_PLM 0xff57	/**< PLM marker value */
+#define J2K_MS_PLT 0xff58	/**< PLT marker value */
+#define J2K_MS_PPM 0xff60	/**< PPM marker value */
+#define J2K_MS_PPT 0xff61	/**< PPT marker value */
+#define J2K_MS_SOP 0xff91	/**< SOP marker value */
+#define J2K_MS_EPH 0xff92	/**< EPH marker value */
+#define J2K_MS_CRG 0xff63	/**< CRG marker value */
+#define J2K_MS_COM 0xff64	/**< COM marker value */
+#define J2K_MS_CBD 0xff78	/**< CBD marker value */
+#define J2K_MS_MCC 0xff75	/**< MCC marker value */
+#define J2K_MS_MCT 0xff74	/**< MCT marker value */
+#define J2K_MS_MCO 0xff77	/**< MCO marker value */
+
+#define J2K_MS_UNK 0		/**< UNKNOWN marker value */
+
+/* UniPG>> */
+#ifdef USE_JPWL
+#define J2K_MS_EPC 0xff68	/**< EPC marker value (Part 11: JPEG 2000 for Wireless) */
+#define J2K_MS_EPB 0xff66	/**< EPB marker value (Part 11: JPEG 2000 for Wireless) */ 
+#define J2K_MS_ESD 0xff67	/**< ESD marker value (Part 11: JPEG 2000 for Wireless) */ 
+#define J2K_MS_RED 0xff69	/**< RED marker value (Part 11: JPEG 2000 for Wireless) */
+#endif /* USE_JPWL */
+#ifdef USE_JPSEC
+#define J2K_MS_SEC 0xff65    /**< SEC marker value (Part 8: Secure JPEG 2000) */
+#define J2K_MS_INSEC 0xff94  /**< INSEC marker value (Part 8: Secure JPEG 2000) */
+#endif /* USE_JPSEC */
+/* <<UniPG */
+
+/* ----------------------------------------------------------------------- */
+
+/**
+ * Values that specify the status of the decoding process when decoding the main header.
+ * These values may be combined with a | operator.
+ * */
+typedef enum J2K_STATUS {
+	J2K_STATE_NONE  =  0x0000, /**< a SOC marker is expected */
+	J2K_STATE_MHSOC  = 0x0001, /**< a SOC marker is expected */
+	J2K_STATE_MHSIZ  = 0x0002, /**< a SIZ marker is expected */
+	J2K_STATE_MH     = 0x0004, /**< the decoding process is in the main header */
+	J2K_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */
+	J2K_STATE_TPH    = 0x0010, /**< the decoding process is in a tile part header */
+	J2K_STATE_MT     = 0x0020, /**< the EOC marker has just been read */
+	J2K_STATE_NEOC   = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
+
+	J2K_STATE_EOC	 = 0x0100, /**< the decoding process has encountered the EOC marker */
+	J2K_STATE_ERR    = 0x8000  /**< the decoding process has encountered an error (FIXME warning V1 = 0x0080)*/
+} J2K_STATUS;
+
+/**
+ * Type of elements storing in the MCT data
+ */
+typedef enum MCT_ELEMENT_TYPE
+{
+	MCT_TYPE_INT16 = 0,		/** MCT data is stored as signed shorts*/
+	MCT_TYPE_INT32 = 1,		/** MCT data is stored as signed integers*/
+	MCT_TYPE_FLOAT = 2,		/** MCT data is stored as floats*/
+	MCT_TYPE_DOUBLE = 3		/** MCT data is stored as doubles*/
+} J2K_MCT_ELEMENT_TYPE;
+
+/**
+ * Type of MCT array
+ */
+typedef enum MCT_ARRAY_TYPE
+{
+	MCT_TYPE_DEPENDENCY = 0,
+	MCT_TYPE_DECORRELATION = 1,
+	MCT_TYPE_OFFSET = 2
+} J2K_MCT_ARRAY_TYPE;
+
+/* ----------------------------------------------------------------------- */
+
+/** 
+T2 encoding mode 
+*/
+typedef enum T2_MODE {
+	THRESH_CALC = 0,	/** Function called in Rate allocation process*/
+	FINAL_PASS = 1		/** Function called in Tier 2 process*/
+}J2K_T2_MODE;
+
+/**
+ * Quantization stepsize
+ */
+typedef struct opj_stepsize {
+	/** exponent */
+	OPJ_INT32 expn;
+	/** mantissa */
+	OPJ_INT32 mant;
+} opj_stepsize_t;
+
+/**
+Tile-component coding parameters
+*/
+typedef struct opj_tccp
+{
+	/** coding style */
+	OPJ_UINT32 csty;
+	/** number of resolutions */
+	OPJ_UINT32 numresolutions;
+	/** code-blocks width */
+	OPJ_UINT32 cblkw;
+	/** code-blocks height */
+	OPJ_UINT32 cblkh;
+	/** code-block coding style */
+	OPJ_UINT32 cblksty;
+	/** discrete wavelet transform identifier */
+	OPJ_UINT32 qmfbid;
+	/** quantisation style */
+	OPJ_UINT32 qntsty;
+	/** stepsizes used for quantization */
+	opj_stepsize_t stepsizes[OPJ_J2K_MAXBANDS];
+	/** number of guard bits */
+	OPJ_UINT32 numgbits;
+	/** Region Of Interest shift */
+	OPJ_INT32 roishift;
+	/** precinct width */
+	OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
+	/** precinct height */
+	OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
+	/** the dc_level_shift **/
+	OPJ_INT32 m_dc_level_shift;
+}
+opj_tccp_t;
+
+
+
+/**
+ * FIXME DOC
+ */
+typedef struct opj_mct_data
+{
+	J2K_MCT_ELEMENT_TYPE m_element_type;
+	J2K_MCT_ARRAY_TYPE	 m_array_type;
+	OPJ_UINT32			 m_index;
+	OPJ_BYTE *			 m_data;
+	OPJ_UINT32			 m_data_size;
+}
+opj_mct_data_t;
+
+/**
+ * FIXME DOC
+ */
+typedef struct opj_simple_mcc_decorrelation_data
+{
+	OPJ_UINT32			 m_index;
+	OPJ_UINT32			 m_nb_comps;
+	opj_mct_data_t *	 m_decorrelation_array;
+	opj_mct_data_t *	 m_offset_array;
+	OPJ_UINT32			 m_is_irreversible : 1;
+}
+opj_simple_mcc_decorrelation_data_t;
+
+typedef struct opj_ppx_struct
+{
+	OPJ_BYTE*   m_data; /* m_data == NULL => Zppx not read yet */
+	OPJ_UINT32	m_data_size;
+} opj_ppx;
+
+/**
+Tile coding parameters :
+this structure is used to store coding/decoding parameters common to all
+tiles (information like COD, COC in main header)
+*/
+typedef struct opj_tcp
+{
+	/** coding style */
+	OPJ_UINT32 csty;
+	/** progression order */
+	OPJ_PROG_ORDER prg;
+	/** number of layers */
+	OPJ_UINT32 numlayers;
+	OPJ_UINT32 num_layers_to_decode;
+	/** multi-component transform identifier */
+	OPJ_UINT32 mct;
+	/** rates of layers */
+	OPJ_FLOAT32 rates[100];
+	/** number of progression order changes */
+	OPJ_UINT32 numpocs;
+	/** progression order changes */
+	opj_poc_t pocs[32];
+	
+	/** number of ppt markers (reserved size) */
+	OPJ_UINT32 ppt_markers_count;
+	/** ppt markers data (table indexed by Zppt) */
+	opj_ppx* ppt_markers;
+	
+	/** packet header store there for future use in t2_decode_packet */
+	OPJ_BYTE *ppt_data;
+	/** used to keep a track of the allocated memory */
+	OPJ_BYTE *ppt_buffer;
+	/** Number of bytes stored inside ppt_data*/
+	OPJ_UINT32 ppt_data_size;
+	/** size of ppt_data*/
+	OPJ_UINT32 ppt_len;
+	/** add fixed_quality */
+	OPJ_FLOAT32 distoratio[100];
+	/** tile-component coding parameters */
+	opj_tccp_t *tccps;
+	/** number of tile parts for the tile. */
+	OPJ_UINT32 m_nb_tile_parts;
+	/** data for the tile */
+	OPJ_BYTE *		m_data;
+	/** size of data */
+	OPJ_UINT32		m_data_size;
+	/** encoding norms */
+	OPJ_FLOAT64 *	mct_norms;
+	/** the mct decoding matrix */
+	OPJ_FLOAT32 *	m_mct_decoding_matrix;
+	/** the mct coding matrix */
+	OPJ_FLOAT32 *	m_mct_coding_matrix;
+	/** mct records */
+	opj_mct_data_t * m_mct_records;
+	/** the number of mct records. */
+	OPJ_UINT32 m_nb_mct_records;
+	/** the max number of mct records. */
+	OPJ_UINT32 m_nb_max_mct_records;
+	/** mcc records */
+	opj_simple_mcc_decorrelation_data_t * m_mcc_records;
+	/** the number of mct records. */
+	OPJ_UINT32 m_nb_mcc_records;
+	/** the max number of mct records. */
+	OPJ_UINT32 m_nb_max_mcc_records;
+
+
+	/***** FLAGS *******/
+	/** If cod == 1 --> there was a COD marker for the present tile */
+	OPJ_UINT32 cod : 1;
+	/** If ppt == 1 --> there was a PPT marker for the present tile */
+	OPJ_UINT32 ppt : 1;
+	/** indicates if a POC marker has been used O:NO, 1:YES */
+	OPJ_UINT32 POC : 1;
+} opj_tcp_t;
+
+
+
+
+typedef struct opj_encoding_param
+{
+	/** Maximum rate for each component. If == 0, component size limitation is not considered */
+	OPJ_UINT32 m_max_comp_size;
+	/** Position of tile part flag in progression order*/
+	OPJ_INT32 m_tp_pos;
+	/** fixed layer */
+	OPJ_INT32 *m_matrice;
+	/** Flag determining tile part generation*/
+	OPJ_BYTE m_tp_flag;
+	/** allocation by rate/distortion */
+	OPJ_UINT32 m_disto_alloc : 1;
+	/** allocation by fixed layer */
+	OPJ_UINT32 m_fixed_alloc : 1;
+	/** add fixed_quality */
+	OPJ_UINT32 m_fixed_quality : 1;
+	/** Enabling Tile part generation*/
+	OPJ_UINT32 m_tp_on : 1;
+}
+opj_encoding_param_t;
+
+typedef struct opj_decoding_param
+{
+	/** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
+	OPJ_UINT32 m_reduce;
+	/** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
+	OPJ_UINT32 m_layer;
+}
+opj_decoding_param_t;
+
+
+/**
+ * Coding parameters
+ */
+typedef struct opj_cp
+{
+	/** Size of the image in bits*/
+	/*int img_size;*/
+	/** Rsiz*/
+    OPJ_UINT16 rsiz;
+	/** XTOsiz */
+	OPJ_UINT32 tx0; /* MSD see norm */
+	/** YTOsiz */
+	OPJ_UINT32 ty0; /* MSD see norm */
+	/** XTsiz */
+	OPJ_UINT32 tdx;
+	/** YTsiz */
+	OPJ_UINT32 tdy;
+	/** comment */
+	OPJ_CHAR *comment;
+	/** number of tiles in width */
+	OPJ_UINT32 tw;
+	/** number of tiles in heigth */
+	OPJ_UINT32 th;
+
+	/** number of ppm markers (reserved size) */
+	OPJ_UINT32 ppm_markers_count;
+	/** ppm markers data (table indexed by Zppm) */
+	opj_ppx* ppm_markers;
+	
+	/** packet header store there for future use in t2_decode_packet */
+	OPJ_BYTE *ppm_data;
+	/** size of the ppm_data*/
+	OPJ_UINT32 ppm_len;
+	/** size of the ppm_data*/
+	OPJ_UINT32 ppm_data_read;
+
+	OPJ_BYTE *ppm_data_current;
+
+	/** packet header storage original buffer */
+	OPJ_BYTE *ppm_buffer;
+	/** pointer remaining on the first byte of the first header if ppm is used */
+	OPJ_BYTE *ppm_data_first;
+	/** Number of bytes actually stored inside the ppm_data */
+	OPJ_UINT32 ppm_data_size;
+	/** use in case of multiple marker PPM (number of info already store) */
+	OPJ_INT32 ppm_store;
+	/** use in case of multiple marker PPM (case on non-finished previous info) */
+	OPJ_INT32 ppm_previous;
+
+	/** tile coding parameters */
+	opj_tcp_t *tcps;
+
+	union
+	{
+		opj_decoding_param_t m_dec;
+		opj_encoding_param_t m_enc;
+	}
+	m_specific_param;
+
+
+/* UniPG>> */
+#ifdef USE_JPWL
+	/** enables writing of EPC in MH, thus activating JPWL */
+	OPJ_BOOL epc_on;
+	/** enables writing of EPB, in case of activated JPWL */
+	OPJ_BOOL epb_on;
+	/** enables writing of ESD, in case of activated JPWL */
+	OPJ_BOOL esd_on;
+	/** enables writing of informative techniques of ESD, in case of activated JPWL */
+	OPJ_BOOL info_on;
+	/** enables writing of RED, in case of activated JPWL */
+	OPJ_BOOL red_on;
+	/** error protection method for MH (0,1,16,32,37-128) */
+	int hprot_MH;
+	/** tile number of header protection specification (>=0) */
+	int hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
+	/** error protection methods for TPHs (0,1,16,32,37-128) */
+	int hprot_TPH[JPWL_MAX_NO_TILESPECS];
+	/** tile number of packet protection specification (>=0) */
+	int pprot_tileno[JPWL_MAX_NO_PACKSPECS];
+	/** packet number of packet protection specification (>=0) */
+	int pprot_packno[JPWL_MAX_NO_PACKSPECS];
+	/** error protection methods for packets (0,1,16,32,37-128) */
+	int pprot[JPWL_MAX_NO_PACKSPECS];
+	/** enables writing of ESD, (0/2/4 bytes) */
+	int sens_size;
+	/** sensitivity addressing size (0=auto/2/4 bytes) */
+	int sens_addr;
+	/** sensitivity range (0-3) */
+	int sens_range;
+	/** sensitivity method for MH (-1,0-7) */
+	int sens_MH;
+	/** tile number of sensitivity specification (>=0) */
+	int sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
+	/** sensitivity methods for TPHs (-1,0-7) */
+	int sens_TPH[JPWL_MAX_NO_TILESPECS];
+	/** enables JPWL correction at the decoder */
+	OPJ_BOOL correct;
+	/** expected number of components at the decoder */
+	int exp_comps;
+	/** maximum number of tiles at the decoder */
+	OPJ_UINT32 max_tiles;
+#endif /* USE_JPWL */
+
+	/******** FLAGS *********/
+	/** if ppm == 1 --> there was a PPM marker*/
+	OPJ_UINT32 ppm : 1;
+	/** tells if the parameter is a coding or decoding one */
+	OPJ_UINT32 m_is_decoder : 1;
+/* <<UniPG */
+} opj_cp_t;
+
+
+typedef struct opj_j2k_dec
+{
+	/** locate in which part of the codestream the decoder is (main header, tile header, end) */
+	OPJ_UINT32 m_state;
+	/**
+	 * store decoding parameters common to all tiles (information like COD, COC in main header)
+	 */
+	opj_tcp_t *m_default_tcp;
+	OPJ_BYTE  *m_header_data;
+	OPJ_UINT32 m_header_data_size;
+	/** to tell the tile part length */
+	OPJ_UINT32 m_sot_length;
+	/** Only tiles index in the correct range will be decoded.*/
+	OPJ_UINT32 m_start_tile_x;
+	OPJ_UINT32 m_start_tile_y;
+	OPJ_UINT32 m_end_tile_x;
+	OPJ_UINT32 m_end_tile_y;
+	/**
+	 * Decoded area set by the user
+	 */
+	OPJ_UINT32 m_DA_x0;
+	OPJ_UINT32 m_DA_y0;
+	OPJ_UINT32 m_DA_x1;
+	OPJ_UINT32 m_DA_y1;
+
+	/** Index of the tile to decode (used in get_tile) */
+	OPJ_INT32 m_tile_ind_to_dec;
+	/** Position of the last SOT marker read */
+	OPJ_OFF_T m_last_sot_read_pos;
+
+	/**
+	 * Indicate that the current tile-part is assume as the last tile part of the codestream.
+	 * It is useful in the case of PSot is equal to zero. The sot length will be compute in the
+	 * SOD reader function. FIXME NOT USED for the moment
+	 */
+	OPJ_BOOL   m_last_tile_part;
+	/** to tell that a tile can be decoded. */
+	OPJ_UINT32 m_can_decode			: 1;
+	OPJ_UINT32 m_discard_tiles		: 1;
+	OPJ_UINT32 m_skip_data			: 1;
+	/** TNsot correction : see issue 254 **/
+	OPJ_UINT32 m_nb_tile_parts_correction_checked : 1;
+	OPJ_UINT32 m_nb_tile_parts_correction : 1;
+
+} opj_j2k_dec_t;
+
+typedef struct opj_j2k_enc
+{
+	/** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/
+	OPJ_UINT32 m_current_poc_tile_part_number; /* tp_num */
+
+	/** Tile part number currently coding, taking into account POC. m_current_tile_part_number holds the total number of tile parts while encoding the last tile part.*/
+	OPJ_UINT32 m_current_tile_part_number; /*cur_tp_num */
+
+	/**
+	locate the start position of the TLM marker
+	after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length.
+	*/
+    OPJ_OFF_T m_tlm_start;
+	/**
+	 * Stores the sizes of the tlm.
+	 */
+	OPJ_BYTE * m_tlm_sot_offsets_buffer;
+	/**
+	 * The current offset of the tlm buffer.
+	 */
+	OPJ_BYTE * m_tlm_sot_offsets_current;
+
+	/** Total num of tile parts in whole image = num tiles* num tileparts in each tile*/
+	/** used in TLMmarker*/
+	OPJ_UINT32 m_total_tile_parts;	 /* totnum_tp */
+
+	/* encoded data for a tile */
+	OPJ_BYTE * m_encoded_tile_data;
+
+	/* size of the encoded_data */
+	OPJ_UINT32 m_encoded_tile_size;
+
+	/* encoded data for a tile */
+	OPJ_BYTE * m_header_tile_data;
+
+	/* size of the encoded_data */
+	OPJ_UINT32 m_header_tile_data_size;
+
+
+} opj_j2k_enc_t;
+
+
+
+struct opj_tcd;
+/**
+JPEG-2000 codestream reader/writer
+*/
+typedef struct opj_j2k
+{
+	/* J2K codestream is decoded*/
+	OPJ_BOOL m_is_decoder;
+
+	/* FIXME DOC*/
+	union
+	{
+		opj_j2k_dec_t m_decoder;
+		opj_j2k_enc_t m_encoder;
+	}
+	m_specific_param;
+
+	/** pointer to the internal/private encoded / decoded image */
+	opj_image_t* m_private_image;
+
+	/* pointer to the output image (decoded)*/
+	opj_image_t* m_output_image;
+
+	/** Coding parameters */
+	opj_cp_t m_cp;
+
+	/** the list of procedures to exec **/
+	opj_procedure_list_t *	m_procedure_list;
+
+	/** the list of validation procedures to follow to make sure the code is valid **/
+	opj_procedure_list_t *	m_validation_list;
+
+	/** helper used to write the index file */
+	opj_codestream_index_t *cstr_index;
+
+	/** number of the tile curently concern by coding/decoding */
+	OPJ_UINT32 m_current_tile_number;
+
+	/** the current tile coder/decoder **/
+	struct opj_tcd *	m_tcd;
+}
+opj_j2k_t;
+
+
+
+
+/** @name Exported functions */
+/*@{*/
+/* ----------------------------------------------------------------------- */
+
+/**
+Setup the decoder decoding parameters using user parameters.
+Decoding parameters are returned in j2k->cp. 
+ at param j2k J2K decompressor handle
+ at param parameters decompression parameters
+*/
+void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
+
+/**
+ * Creates a J2K compression structure
+ *
+ * @return Returns a handle to a J2K compressor if successful, returns NULL otherwise
+*/
+opj_j2k_t* opj_j2k_create_compress(void);
+
+
+OPJ_BOOL opj_j2k_setup_encoder(	opj_j2k_t *p_j2k,
+						    opj_cparameters_t *parameters,
+						    opj_image_t *image,
+						    opj_event_mgr_t * p_manager);
+
+/**
+Converts an enum type progression order to string type
+*/
+char *opj_j2k_convert_progression_order(OPJ_PROG_ORDER prg_order);
+
+/* ----------------------------------------------------------------------- */
+/*@}*/
+
+/*@}*/
+
+/**
+ * Ends the decompression procedures and possibiliy add data to be read after the
+ * codestream.
+ */
+OPJ_BOOL opj_j2k_end_decompress(opj_j2k_t *j2k,
+                                opj_stream_private_t *p_stream,
+                                opj_event_mgr_t * p_manager);
+
+/**
+ * Reads a jpeg2000 codestream header structure.
+ *
+ * @param p_stream the stream to read data from.
+ * @param p_j2k the jpeg2000 codec.
+ * @param p_image FIXME DOC
+ * @param p_manager the user event manager.
+ *
+ * @return true if the box is valid.
+ */
+OPJ_BOOL opj_j2k_read_header(	opj_stream_private_t *p_stream,
+                                opj_j2k_t* p_j2k,
+                                opj_image_t** p_image,
+                                opj_event_mgr_t* p_manager );
+
+
+/**
+ * Destroys a jpeg2000 codec.
+ *
+ * @param	p_j2k	the jpeg20000 structure to destroy.
+ */
+void opj_j2k_destroy (opj_j2k_t *p_j2k);
+
+/**
+ * Destroys a codestream index structure.
+ *
+ * @param	p_cstr_ind	the codestream index parameter to destroy.
+ */
+void j2k_destroy_cstr_index (opj_codestream_index_t *p_cstr_ind);
+
+/**
+ * Decode tile data.
+ * @param	p_j2k		the jpeg2000 codec.
+ * @param	p_tile_index
+ * @param p_data       FIXME DOC
+ * @param p_data_size  FIXME DOC
+ * @param	p_stream			the stream to write data to.
+ * @param	p_manager	the user event manager.
+ */
+OPJ_BOOL opj_j2k_decode_tile (  opj_j2k_t * p_j2k,
+                                OPJ_UINT32 p_tile_index,
+                                OPJ_BYTE * p_data,
+                                OPJ_UINT32 p_data_size,
+                                opj_stream_private_t *p_stream,
+                                opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a tile header.
+ * @param	p_j2k		the jpeg2000 codec.
+ * @param	p_tile_index FIXME DOC
+ * @param	p_data_size FIXME DOC
+ * @param	p_tile_x0 FIXME DOC
+ * @param	p_tile_y0 FIXME DOC
+ * @param	p_tile_x1 FIXME DOC
+ * @param	p_tile_y1 FIXME DOC
+ * @param	p_nb_comps FIXME DOC
+ * @param	p_go_on FIXME DOC
+ * @param	p_stream			the stream to write data to.
+ * @param	p_manager	the user event manager.
+ */
+OPJ_BOOL opj_j2k_read_tile_header ( opj_j2k_t * p_j2k,
+                                    OPJ_UINT32 * p_tile_index,
+                                    OPJ_UINT32 * p_data_size,
+                                    OPJ_INT32 * p_tile_x0,
+                                    OPJ_INT32 * p_tile_y0,
+                                    OPJ_INT32 * p_tile_x1,
+                                    OPJ_INT32 * p_tile_y1,
+                                    OPJ_UINT32 * p_nb_comps,
+                                    OPJ_BOOL * p_go_on,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+
+/**
+ * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
+ *
+ * @param	p_j2k			the jpeg2000 codec.
+ * @param	p_image     FIXME DOC
+ * @param	p_start_x		the left position of the rectangle to decode (in image coordinates).
+ * @param	p_start_y		the up position of the rectangle to decode (in image coordinates).
+ * @param	p_end_x			the right position of the rectangle to decode (in image coordinates).
+ * @param	p_end_y			the bottom position of the rectangle to decode (in image coordinates).
+ * @param	p_manager		the user event manager
+ *
+ * @return	true			if the area could be set.
+ */
+OPJ_BOOL opj_j2k_set_decode_area(	opj_j2k_t *p_j2k,
+								    opj_image_t* p_image,
+								    OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
+								    OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
+								    opj_event_mgr_t * p_manager );
+
+/**
+ * Creates a J2K decompression structure.
+ *
+ * @return a handle to a J2K decompressor if successful, NULL otherwise.
+ */
+opj_j2k_t* opj_j2k_create_decompress(void);
+
+
+/**
+ * Dump some elements from the J2K decompression structure .
+ *
+ *@param p_j2k				the jpeg2000 codec.
+ *@param flag				flag to describe what elments are dump.
+ *@param out_stream			output stream where dump the elements.
+ *
+*/
+void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream);
+
+
+
+/**
+ * Dump an image header structure.
+ *
+ *@param image			the image header to dump.
+ *@param dev_dump_flag		flag to describe if we are in the case of this function is use outside j2k_dump function
+ *@param out_stream			output stream where dump the elements.
+ */
+void j2k_dump_image_header(opj_image_t* image, OPJ_BOOL dev_dump_flag, FILE* out_stream);
+
+/**
+ * Dump a component image header structure.
+ *
+ *@param comp		the component image header to dump.
+ *@param dev_dump_flag		flag to describe if we are in the case of this function is use outside j2k_dump function
+ *@param out_stream			output stream where dump the elements.
+ */
+void j2k_dump_image_comp_header(opj_image_comp_t* comp, OPJ_BOOL dev_dump_flag, FILE* out_stream);
+
+/**
+ * Get the codestream info from a JPEG2000 codec.
+ *
+ *@param	p_j2k				the component image header to dump.
+ *
+ *@return	the codestream information extract from the jpg2000 codec
+ */
+opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k);
+
+/**
+ * Get the codestream index from a JPEG2000 codec.
+ *
+ *@param	p_j2k				the component image header to dump.
+ *
+ *@return	the codestream index extract from the jpg2000 codec
+ */
+opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k);
+
+/**
+ * Decode an image from a JPEG-2000 codestream
+ * @param j2k J2K decompressor handle
+ * @param p_stream  FIXME DOC
+ * @param p_image   FIXME DOC
+ * @param p_manager FIXME DOC
+ * @return FIXME DOC
+*/
+OPJ_BOOL opj_j2k_decode(opj_j2k_t *j2k,
+                        opj_stream_private_t *p_stream,
+                        opj_image_t *p_image,
+                        opj_event_mgr_t *p_manager);
+
+
+OPJ_BOOL opj_j2k_get_tile(	opj_j2k_t *p_j2k,
+			    			opj_stream_private_t *p_stream,
+				    		opj_image_t* p_image,
+					    	opj_event_mgr_t * p_manager,
+						    OPJ_UINT32 tile_index );
+
+OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k, 
+                                               OPJ_UINT32 res_factor,
+                                               opj_event_mgr_t * p_manager);
+
+
+/**
+ * Writes a tile.
+ * @param	p_j2k		the jpeg2000 codec.
+ * @param p_tile_index FIXME DOC
+ * @param p_data FIXME DOC
+ * @param p_data_size FIXME DOC
+ * @param	p_stream			the stream to write data to.
+ * @param	p_manager	the user event manager.
+ */
+OPJ_BOOL opj_j2k_write_tile (	opj_j2k_t * p_j2k,
+							    OPJ_UINT32 p_tile_index,
+							    OPJ_BYTE * p_data,
+							    OPJ_UINT32 p_data_size,
+							    opj_stream_private_t *p_stream,
+							    opj_event_mgr_t * p_manager );
+
+/**
+ * Encodes an image into a JPEG-2000 codestream
+ */
+OPJ_BOOL opj_j2k_encode(	opj_j2k_t * p_j2k,
+			    			opj_stream_private_t *cio,
+				    		opj_event_mgr_t * p_manager );
+
+/**
+ * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
+ *
+ * @param	p_j2k		the jpeg2000 codec.
+ * @param	p_stream			the stream object.
+ * @param	p_image FIXME DOC
+ * @param	p_manager	the user event manager.
+ *
+ * @return true if the codec is valid.
+ */
+OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k,
+							    opj_stream_private_t *p_stream,
+							    opj_image_t * p_image,
+							    opj_event_mgr_t * p_manager);
+
+/**
+ * Ends the compression procedures and possibiliy add data to be read after the
+ * codestream.
+ */
+OPJ_BOOL opj_j2k_end_compress( 	opj_j2k_t *p_j2k,
+							    opj_stream_private_t *cio,
+							    opj_event_mgr_t * p_manager);
+
+OPJ_BOOL opj_j2k_setup_mct_encoding (opj_tcp_t * p_tcp, opj_image_t * p_image);
+
+
+#endif /* __J2K_H */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.c
new file mode 100644
index 0000000..a607c8a
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.c
@@ -0,0 +1,3168 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "opj_includes.h"
+
+/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
+/*@{*/
+
+#define OPJ_BOX_SIZE	1024
+
+/** @name Local static functions */
+/*@{*/
+
+/*static void jp2_write_url(opj_cio_t *cio, char *Idx_file);*/
+
+/**
+ * Reads a IHDR box - Image Header box
+ *
+ * @param	p_image_header_data			pointer to actual data (already read from file)
+ * @param	jp2							the jpeg2000 file codec.
+ * @param	p_image_header_size			the size of the image header
+ * @param	p_manager					the user event manager.
+ *
+ * @return	true if the image header is valid, false else.
+ */
+static OPJ_BOOL opj_jp2_read_ihdr(  opj_jp2_t *jp2,
+                                    OPJ_BYTE *p_image_header_data,
+                                    OPJ_UINT32 p_image_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the Image Header box - Image Header box.
+ *
+ * @param jp2					jpeg2000 file codec.
+ * @param p_nb_bytes_written	pointer to store the nb of bytes written by the function.
+ *
+ * @return	the data being copied.
+*/
+static OPJ_BYTE * opj_jp2_write_ihdr(opj_jp2_t *jp2,
+                                     OPJ_UINT32 * p_nb_bytes_written );
+
+/**
+ * Writes the Bit per Component box.
+ *
+ * @param	jp2						jpeg2000 file codec.
+ * @param	p_nb_bytes_written		pointer to store the nb of bytes written by the function.
+ *
+ * @return	the data being copied.
+*/
+static OPJ_BYTE * opj_jp2_write_bpcc(	opj_jp2_t *jp2,
+								        OPJ_UINT32 * p_nb_bytes_written );
+
+/**
+ * Reads a Bit per Component box.
+ *
+ * @param	p_bpc_header_data			pointer to actual data (already read from file)
+ * @param	jp2							the jpeg2000 file codec.
+ * @param	p_bpc_header_size			the size of the bpc header
+ * @param	p_manager					the user event manager.
+ *
+ * @return	true if the bpc header is valid, false else.
+ */
+static OPJ_BOOL opj_jp2_read_bpcc(  opj_jp2_t *jp2,
+                                    OPJ_BYTE * p_bpc_header_data,
+                                    OPJ_UINT32 p_bpc_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+static OPJ_BOOL opj_jp2_read_cdef(	opj_jp2_t * jp2,
+                                    OPJ_BYTE * p_cdef_header_data,
+									OPJ_UINT32 p_cdef_header_size,
+									opj_event_mgr_t * p_manager );
+
+static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *);
+
+/**
+ * Writes the Channel Definition box.
+ *
+ * @param jp2					jpeg2000 file codec.
+ * @param p_nb_bytes_written	pointer to store the nb of bytes written by the function.
+ *
+ * @return	the data being copied.
+ */
+static OPJ_BYTE * opj_jp2_write_cdef(   opj_jp2_t *jp2,
+																		 OPJ_UINT32 * p_nb_bytes_written );
+
+/**
+ * Writes the Colour Specification box.
+ *
+ * @param jp2					jpeg2000 file codec.
+ * @param p_nb_bytes_written	pointer to store the nb of bytes written by the function.
+ *
+ * @return	the data being copied.
+*/
+static OPJ_BYTE * opj_jp2_write_colr(   opj_jp2_t *jp2,
+									    OPJ_UINT32 * p_nb_bytes_written );
+
+/**
+ * Writes a FTYP box - File type box
+ *
+ * @param	cio			the stream to write data to.
+ * @param	jp2			the jpeg2000 file codec.
+ * @param	p_manager	the user event manager.
+ *
+ * @return	true if writing was successful.
+ */
+static OPJ_BOOL opj_jp2_write_ftyp(	opj_jp2_t *jp2,
+									opj_stream_private_t *cio,
+									opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a a FTYP box - File type box
+ *
+ * @param	p_header_data	the data contained in the FTYP box.
+ * @param	jp2				the jpeg2000 file codec.
+ * @param	p_header_size	the size of the data contained in the FTYP box.
+ * @param	p_manager		the user event manager.
+ *
+ * @return true if the FTYP box is valid.
+ */
+static OPJ_BOOL opj_jp2_read_ftyp(	opj_jp2_t *jp2,
+									OPJ_BYTE * p_header_data,
+									OPJ_UINT32 p_header_size,
+									opj_event_mgr_t * p_manager );
+
+static OPJ_BOOL opj_jp2_skip_jp2c(	opj_jp2_t *jp2,
+						    opj_stream_private_t *cio,
+						    opj_event_mgr_t * p_manager );
+
+/**
+ * Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
+ *
+ * @param	p_header_data	the data contained in the file header box.
+ * @param	jp2				the jpeg2000 file codec.
+ * @param	p_header_size	the size of the data contained in the file header box.
+ * @param	p_manager		the user event manager.
+ *
+ * @return true if the JP2 Header box was successfully recognized.
+*/
+static OPJ_BOOL opj_jp2_read_jp2h(  opj_jp2_t *jp2,
+                                    OPJ_BYTE *p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
+ *
+ * @param  jp2      the jpeg2000 file codec.
+ * @param  stream      the stream to write data to.
+ * @param  p_manager  user event manager.
+ *
+ * @return true if writing was successful.
+ */
+static OPJ_BOOL opj_jp2_write_jp2h(opj_jp2_t *jp2,
+														opj_stream_private_t *stream,
+														opj_event_mgr_t * p_manager );
+
+/**
+ * Writes the Jpeg2000 codestream Header box - JP2C Header box. This function must be called AFTER the coding has been done.
+ *
+ * @param	cio			the stream to write data to.
+ * @param	jp2			the jpeg2000 file codec.
+ * @param	p_manager	user event manager.
+ *
+ * @return true if writing was successful.
+*/
+static OPJ_BOOL opj_jp2_write_jp2c(	opj_jp2_t *jp2,
+								    opj_stream_private_t *cio,
+								    opj_event_mgr_t * p_manager );
+
+#ifdef USE_JPIP
+/**
+ * Write index Finder box
+ * @param cio     the stream to write to.
+ * @param	jp2			the jpeg2000 file codec.
+ * @param	p_manager	user event manager.
+*/
+static OPJ_BOOL opj_jpip_write_iptr(	opj_jp2_t *jp2,
+								    opj_stream_private_t *cio,
+								    opj_event_mgr_t * p_manager );
+
+/**
+ * Write index Finder box
+ * @param cio     the stream to write to.
+ * @param	jp2			the jpeg2000 file codec.
+ * @param	p_manager	user event manager.
+ */
+static OPJ_BOOL opj_jpip_write_cidx(opj_jp2_t *jp2,
+  opj_stream_private_t *cio,
+  opj_event_mgr_t * p_manager );
+
+/**
+ * Write file Index (superbox)
+ * @param cio     the stream to write to.
+ * @param	jp2			the jpeg2000 file codec.
+ * @param	p_manager	user event manager.
+ */
+static OPJ_BOOL opj_jpip_write_fidx(opj_jp2_t *jp2,
+  opj_stream_private_t *cio,
+  opj_event_mgr_t * p_manager );
+#endif /* USE_JPIP */
+
+/**
+ * Reads a jpeg2000 file signature box.
+ *
+ * @param	p_header_data	the data contained in the signature box.
+ * @param	jp2				the jpeg2000 file codec.
+ * @param	p_header_size	the size of the data contained in the signature box.
+ * @param	p_manager		the user event manager.
+ *
+ * @return true if the file signature box is valid.
+ */
+static OPJ_BOOL opj_jp2_read_jp(opj_jp2_t *jp2,
+                                OPJ_BYTE * p_header_data,
+                                OPJ_UINT32 p_header_size,
+                                opj_event_mgr_t * p_manager);
+
+/**
+ * Writes a jpeg2000 file signature box.
+ *
+ * @param cio the stream to write data to.
+ * @param	jp2			the jpeg2000 file codec.
+ * @param p_manager the user event manager.
+ *
+ * @return true if writing was successful.
+ */
+static OPJ_BOOL opj_jp2_write_jp(	opj_jp2_t *jp2,
+			    	        	    opj_stream_private_t *cio,
+				            		opj_event_mgr_t * p_manager );
+
+/**
+Apply collected palette data
+ at param color Collector for profile, cdef and pclr data
+ at param image
+*/
+static void opj_jp2_apply_pclr(opj_image_t *image, opj_jp2_color_t *color);
+
+static void opj_jp2_free_pclr(opj_jp2_color_t *color);
+
+/**
+ * Collect palette data
+ *
+ * @param jp2 JP2 handle
+ * @param p_pclr_header_data    FIXME DOC
+ * @param p_pclr_header_size    FIXME DOC
+ * @param p_manager
+ *
+ * @return Returns true if successful, returns false otherwise
+*/
+static OPJ_BOOL opj_jp2_read_pclr(	opj_jp2_t *jp2,
+                                    OPJ_BYTE * p_pclr_header_data,
+                                    OPJ_UINT32 p_pclr_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Collect component mapping data
+ *
+ * @param jp2                 JP2 handle
+ * @param p_cmap_header_data  FIXME DOC
+ * @param p_cmap_header_size  FIXME DOC
+ * @param p_manager           FIXME DOC
+ *
+ * @return Returns true if successful, returns false otherwise
+*/
+
+static OPJ_BOOL opj_jp2_read_cmap(	opj_jp2_t * jp2,
+                                    OPJ_BYTE * p_cmap_header_data,
+                                    OPJ_UINT32 p_cmap_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Reads the Color Specification box.
+ *
+ * @param	p_colr_header_data			pointer to actual data (already read from file)
+ * @param	jp2							the jpeg2000 file codec.
+ * @param	p_colr_header_size			the size of the color header
+ * @param	p_manager					the user event manager.
+ *
+ * @return	true if the bpc header is valid, false else.
+*/
+static OPJ_BOOL opj_jp2_read_colr(  opj_jp2_t *jp2,
+                                    OPJ_BYTE * p_colr_header_data,
+                                    OPJ_UINT32 p_colr_header_size,
+                                    opj_event_mgr_t * p_manager );
+
+/*@}*/
+
+/*@}*/
+
+/**
+ * Sets up the procedures to do on writing header after the codestream.
+ * Developpers wanting to extend the library can add their own writing procedures.
+ */
+static OPJ_BOOL opj_jp2_setup_end_header_writing (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
+
+/**
+ * Sets up the procedures to do on reading header after the codestream.
+ * Developpers wanting to extend the library can add their own writing procedures.
+ */
+static OPJ_BOOL opj_jp2_setup_end_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
+
+/**
+ * Reads a jpeg2000 file header structure.
+ *
+ * @param jp2 the jpeg2000 file header structure.
+ * @param stream the stream to read data from.
+ * @param p_manager the user event manager.
+ *
+ * @return true if the box is valid.
+ */
+static OPJ_BOOL opj_jp2_read_header_procedure(  opj_jp2_t *jp2,
+                                                opj_stream_private_t *stream,
+                                                opj_event_mgr_t * p_manager );
+
+/**
+ * Excutes the given procedures on the given codec.
+ *
+ * @param	p_procedure_list	the list of procedures to execute
+ * @param	jp2					the jpeg2000 file codec to execute the procedures on.
+ * @param	stream					the stream to execute the procedures on.
+ * @param	p_manager			the user manager.
+ *
+ * @return	true				if all the procedures were successfully executed.
+ */
+static OPJ_BOOL opj_jp2_exec (  opj_jp2_t * jp2,
+                                opj_procedure_list_t * p_procedure_list,
+                                opj_stream_private_t *stream,
+                                opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure.
+ *
+ * @param	cio						the input stream to read data from.
+ * @param	box						the box structure to fill.
+ * @param	p_number_bytes_read		pointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
+ * @param	p_manager				user event manager.
+ *
+ * @return	true if the box is recognized, false otherwise
+*/
+static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
+                                    OPJ_UINT32 * p_number_bytes_read,
+                                    opj_stream_private_t *cio,
+                                    opj_event_mgr_t * p_manager);
+
+/**
+ * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
+ * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ */
+static OPJ_BOOL opj_jp2_setup_encoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
+
+/**
+ * Sets up the procedures to do on writing header. Developpers wanting to extend the library can add their own writing procedures.
+ */
+static OPJ_BOOL opj_jp2_setup_header_writing (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
+
+static OPJ_BOOL opj_jp2_default_validation (	opj_jp2_t * jp2,
+                                        opj_stream_private_t *cio,
+                                        opj_event_mgr_t * p_manager );
+
+/**
+ * Finds the image execution function related to the given box id.
+ *
+ * @param	p_id	the id of the handler to fetch.
+ *
+ * @return	the given handler or NULL if it could not be found.
+ */
+static const opj_jp2_header_handler_t * opj_jp2_img_find_handler (OPJ_UINT32 p_id);
+
+/**
+ * Finds the execution function related to the given box id.
+ *
+ * @param	p_id	the id of the handler to fetch.
+ *
+ * @return	the given handler or NULL if it could not be found.
+ */
+static const opj_jp2_header_handler_t * opj_jp2_find_handler (OPJ_UINT32 p_id );
+
+static const opj_jp2_header_handler_t jp2_header [] =
+{
+	{JP2_JP,opj_jp2_read_jp},
+	{JP2_FTYP,opj_jp2_read_ftyp},
+	{JP2_JP2H,opj_jp2_read_jp2h}
+};
+
+static const opj_jp2_header_handler_t jp2_img_header [] =
+{
+	{JP2_IHDR,opj_jp2_read_ihdr},
+	{JP2_COLR,opj_jp2_read_colr},
+	{JP2_BPCC,opj_jp2_read_bpcc},
+	{JP2_PCLR,opj_jp2_read_pclr},
+	{JP2_CMAP,opj_jp2_read_cmap},
+	{JP2_CDEF,opj_jp2_read_cdef}
+
+};
+
+/**
+ * Reads a box header. The box is the way data is packed inside a jpeg2000 file structure. Data is read from a character string
+ *
+ * @param	box						the box structure to fill.
+ * @param	p_data					the character string to read data from.
+ * @param	p_number_bytes_read		pointer to an int that will store the number of bytes read from the stream (shoul usually be 2).
+ * @param	p_box_max_size			the maximum number of bytes in the box.
+ * @param	p_manager         FIXME DOC
+ *
+ * @return	true if the box is recognized, false otherwise
+*/
+static OPJ_BOOL opj_jp2_read_boxhdr_char(   opj_jp2_box_t *box,
+                                            OPJ_BYTE * p_data,
+                                            OPJ_UINT32 * p_number_bytes_read,
+                                            OPJ_UINT32 p_box_max_size,
+                                            opj_event_mgr_t * p_manager );
+
+/**
+ * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
+ * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ */
+static OPJ_BOOL opj_jp2_setup_decoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
+
+/**
+ * Sets up the procedures to do on reading header.
+ * Developpers wanting to extend the library can add their own writing procedures.
+ */
+static OPJ_BOOL opj_jp2_setup_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager);
+
+/* ----------------------------------------------------------------------- */
+static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
+                              OPJ_UINT32 * p_number_bytes_read,
+                              opj_stream_private_t *cio,
+                              opj_event_mgr_t * p_manager )
+{
+	/* read header from file */
+	OPJ_BYTE l_data_header [8];
+
+	/* preconditions */
+	assert(cio != 00);
+	assert(box != 00);
+	assert(p_number_bytes_read != 00);
+	assert(p_manager != 00);
+
+	*p_number_bytes_read = (OPJ_UINT32)opj_stream_read_data(cio,l_data_header,8,p_manager);
+	if (*p_number_bytes_read != 8) {
+		return OPJ_FALSE;
+	}
+
+	/* process read data */
+	opj_read_bytes(l_data_header,&(box->length), 4);
+	opj_read_bytes(l_data_header+4,&(box->type), 4);
+    
+  if(box->length == 0)/* last box */
+  {
+    const OPJ_OFF_T bleft = opj_stream_get_number_byte_left(cio);
+    if (bleft > (OPJ_OFF_T)(0xFFFFFFFFU - 8U)) {
+      opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
+      return OPJ_FALSE;
+    }
+    box->length = (OPJ_UINT32)bleft + 8U;
+    assert( (OPJ_OFF_T)box->length == bleft + 8 );
+    return OPJ_TRUE;
+  }
+
+	/* do we have a "special very large box ?" */
+	/* read then the XLBox */
+	if (box->length == 1) {
+		OPJ_UINT32 l_xl_part_size;
+
+		OPJ_UINT32 l_nb_bytes_read = (OPJ_UINT32)opj_stream_read_data(cio,l_data_header,8,p_manager);
+		if (l_nb_bytes_read != 8) {
+			if (l_nb_bytes_read > 0) {
+				*p_number_bytes_read += l_nb_bytes_read;
+			}
+
+			return OPJ_FALSE;
+		}
+
+        *p_number_bytes_read = 16;
+		opj_read_bytes(l_data_header,&l_xl_part_size, 4);
+		if (l_xl_part_size != 0) {
+			opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
+			return OPJ_FALSE;
+		}
+		opj_read_bytes(l_data_header+4,&(box->length), 4);
+	}
+    return OPJ_TRUE;
+}
+
+#if 0
+static void jp2_write_url(opj_cio_t *cio, char *Idx_file) {
+	OPJ_UINT32 i;
+	opj_jp2_box_t box;
+
+	box.init_pos = cio_tell(cio);
+	cio_skip(cio, 4);
+	cio_write(cio, JP2_URL, 4);	/* DBTL */
+	cio_write(cio, 0, 1);		/* VERS */
+	cio_write(cio, 0, 3);		/* FLAG */
+
+	if(Idx_file) {
+		for (i = 0; i < strlen(Idx_file); i++) {
+			cio_write(cio, Idx_file[i], 1);
+		}
+	}
+
+	box.length = cio_tell(cio) - box.init_pos;
+	cio_seek(cio, box.init_pos);
+	cio_write(cio, box.length, 4);	/* L */
+	cio_seek(cio, box.init_pos + box.length);
+}
+#endif
+
+static OPJ_BOOL opj_jp2_read_ihdr( opj_jp2_t *jp2,
+                            OPJ_BYTE *p_image_header_data,
+                            OPJ_UINT32 p_image_header_size,
+                            opj_event_mgr_t * p_manager )
+{
+	/* preconditions */
+	assert(p_image_header_data != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	if (p_image_header_size != 14) {
+		opj_event_msg(p_manager, EVT_ERROR, "Bad image header box (bad size)\n");
+		return OPJ_FALSE;
+	}
+
+	opj_read_bytes(p_image_header_data,&(jp2->h),4);			/* HEIGHT */
+	p_image_header_data += 4;
+	opj_read_bytes(p_image_header_data,&(jp2->w),4);			/* WIDTH */
+	p_image_header_data += 4;
+	opj_read_bytes(p_image_header_data,&(jp2->numcomps),2);		/* NC */
+	p_image_header_data += 2;
+
+	/* allocate memory for components */
+	jp2->comps = (opj_jp2_comps_t*) opj_calloc(jp2->numcomps, sizeof(opj_jp2_comps_t));
+	if (jp2->comps == 0) {
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle image header (ihdr)\n");
+		return OPJ_FALSE;
+	}
+
+	opj_read_bytes(p_image_header_data,&(jp2->bpc),1);			/* BPC */
+	++ p_image_header_data;
+
+	opj_read_bytes(p_image_header_data,&(jp2->C),1);			/* C */
+	++ p_image_header_data;
+
+	/* Should be equal to 7 cf. chapter about image header box of the norm */
+	if (jp2->C != 7){
+		opj_event_msg(p_manager, EVT_INFO, "JP2 IHDR box: compression type indicate that the file is not a conforming JP2 file (%d) \n", jp2->C);
+	}
+
+	opj_read_bytes(p_image_header_data,&(jp2->UnkC),1);			/* UnkC */
+	++ p_image_header_data;
+	opj_read_bytes(p_image_header_data,&(jp2->IPR),1);			/* IPR */
+	++ p_image_header_data;
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BYTE * opj_jp2_write_ihdr(opj_jp2_t *jp2,
+                              OPJ_UINT32 * p_nb_bytes_written
+                              )
+{
+	OPJ_BYTE * l_ihdr_data,* l_current_ihdr_ptr;
+	
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_nb_bytes_written != 00);
+
+	/* default image header is 22 bytes wide */
+	l_ihdr_data = (OPJ_BYTE *) opj_calloc(1,22);
+	if (l_ihdr_data == 00) {
+		return 00;
+	}
+
+	l_current_ihdr_ptr = l_ihdr_data;
+	
+	opj_write_bytes(l_current_ihdr_ptr,22,4);				/* write box size */
+	l_current_ihdr_ptr+=4;
+
+	opj_write_bytes(l_current_ihdr_ptr,JP2_IHDR, 4);		/* IHDR */
+	l_current_ihdr_ptr+=4;
+	
+	opj_write_bytes(l_current_ihdr_ptr,jp2->h, 4);		/* HEIGHT */
+	l_current_ihdr_ptr+=4;
+	
+	opj_write_bytes(l_current_ihdr_ptr, jp2->w, 4);		/* WIDTH */
+	l_current_ihdr_ptr+=4;
+	
+	opj_write_bytes(l_current_ihdr_ptr, jp2->numcomps, 2);		/* NC */
+	l_current_ihdr_ptr+=2;
+	
+	opj_write_bytes(l_current_ihdr_ptr, jp2->bpc, 1);		/* BPC */
+	++l_current_ihdr_ptr;
+	
+	opj_write_bytes(l_current_ihdr_ptr, jp2->C, 1);		/* C : Always 7 */
+	++l_current_ihdr_ptr;
+	
+	opj_write_bytes(l_current_ihdr_ptr, jp2->UnkC, 1);		/* UnkC, colorspace unknown */
+	++l_current_ihdr_ptr;
+	
+	opj_write_bytes(l_current_ihdr_ptr, jp2->IPR, 1);		/* IPR, no intellectual property */
+	++l_current_ihdr_ptr;
+	
+	*p_nb_bytes_written = 22;
+	
+	return l_ihdr_data;
+}
+
+static OPJ_BYTE * opj_jp2_write_bpcc(	opj_jp2_t *jp2,
+						        OPJ_UINT32 * p_nb_bytes_written
+                                )
+{
+	OPJ_UINT32 i;
+	/* room for 8 bytes for box and 1 byte for each component */
+	OPJ_UINT32 l_bpcc_size;
+	OPJ_BYTE * l_bpcc_data,* l_current_bpcc_ptr;
+	
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_nb_bytes_written != 00);
+	l_bpcc_size = 8 + jp2->numcomps;
+
+	l_bpcc_data = (OPJ_BYTE *) opj_calloc(1,l_bpcc_size);
+	if (l_bpcc_data == 00) {
+		return 00;
+	}
+
+	l_current_bpcc_ptr = l_bpcc_data;
+
+	opj_write_bytes(l_current_bpcc_ptr,l_bpcc_size,4);				/* write box size */
+	l_current_bpcc_ptr += 4;
+	
+	opj_write_bytes(l_current_bpcc_ptr,JP2_BPCC,4);					/* BPCC */
+	l_current_bpcc_ptr += 4;
+
+	for (i = 0; i < jp2->numcomps; ++i)  {
+		opj_write_bytes(l_current_bpcc_ptr, jp2->comps[i].bpcc, 1); /* write each component information */
+		++l_current_bpcc_ptr;
+	}
+
+	*p_nb_bytes_written = l_bpcc_size;
+	
+	return l_bpcc_data;
+}
+
+static OPJ_BOOL opj_jp2_read_bpcc( opj_jp2_t *jp2,
+                            OPJ_BYTE * p_bpc_header_data,
+                            OPJ_UINT32 p_bpc_header_size,
+                            opj_event_mgr_t * p_manager
+                            )
+{
+	OPJ_UINT32 i;
+
+	/* preconditions */
+	assert(p_bpc_header_data != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	
+	if (jp2->bpc != 255 ){
+		opj_event_msg(p_manager, EVT_WARNING, "A BPCC header box is available although BPC given by the IHDR box (%d) indicate components bit depth is constant\n",jp2->bpc);
+	}
+
+	/* and length is relevant */
+	if (p_bpc_header_size != jp2->numcomps) {
+		opj_event_msg(p_manager, EVT_ERROR, "Bad BPCC header box (bad size)\n");
+		return OPJ_FALSE;
+	}
+
+	/* read info for each component */
+	for (i = 0; i < jp2->numcomps; ++i) {
+		opj_read_bytes(p_bpc_header_data,&jp2->comps[i].bpcc ,1);	/* read each BPCC component */
+		++p_bpc_header_data;
+	}
+
+	return OPJ_TRUE;
+}
+static OPJ_BYTE * opj_jp2_write_cdef(opj_jp2_t *jp2, OPJ_UINT32 * p_nb_bytes_written)
+{
+	/* room for 8 bytes for box, 2 for n */
+	OPJ_UINT32 l_cdef_size = 10;
+	OPJ_BYTE * l_cdef_data,* l_current_cdef_ptr;
+	OPJ_UINT32 l_value;
+	OPJ_UINT16 i;
+
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_nb_bytes_written != 00);
+	assert(jp2->color.jp2_cdef != 00);
+	assert(jp2->color.jp2_cdef->info != 00);
+	assert(jp2->color.jp2_cdef->n > 0U);
+
+	l_cdef_size += 6U * jp2->color.jp2_cdef->n;
+
+	l_cdef_data = (OPJ_BYTE *) opj_malloc(l_cdef_size);
+	if (l_cdef_data == 00) {
+		return 00;
+	}
+
+	l_current_cdef_ptr = l_cdef_data;
+	
+	opj_write_bytes(l_current_cdef_ptr,l_cdef_size,4);			/* write box size */
+	l_current_cdef_ptr += 4;
+
+	opj_write_bytes(l_current_cdef_ptr,JP2_CDEF,4);					/* BPCC */
+	l_current_cdef_ptr += 4;
+
+	l_value = jp2->color.jp2_cdef->n;
+	opj_write_bytes(l_current_cdef_ptr,l_value,2);					/* N */
+	l_current_cdef_ptr += 2;
+
+	for (i = 0U; i < jp2->color.jp2_cdef->n; ++i) {
+		l_value = jp2->color.jp2_cdef->info[i].cn;
+		opj_write_bytes(l_current_cdef_ptr,l_value,2);					/* Cni */
+		l_current_cdef_ptr += 2;
+		l_value = jp2->color.jp2_cdef->info[i].typ;
+		opj_write_bytes(l_current_cdef_ptr,l_value,2);					/* Typi */
+		l_current_cdef_ptr += 2;
+		l_value = jp2->color.jp2_cdef->info[i].asoc;
+		opj_write_bytes(l_current_cdef_ptr,l_value,2);					/* Asoci */
+		l_current_cdef_ptr += 2;
+	}
+	*p_nb_bytes_written = l_cdef_size;
+
+	return l_cdef_data;
+}
+
+static OPJ_BYTE * opj_jp2_write_colr(  opj_jp2_t *jp2,
+							    OPJ_UINT32 * p_nb_bytes_written
+                                )
+{
+	/* room for 8 bytes for box 3 for common data and variable upon profile*/
+	OPJ_UINT32 l_colr_size = 11;
+	OPJ_BYTE * l_colr_data,* l_current_colr_ptr;
+
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_nb_bytes_written != 00);
+    assert(jp2->meth == 1 || jp2->meth == 2);
+
+	switch (jp2->meth) { 
+		case 1 :
+			l_colr_size += 4; /* EnumCS */
+			break;
+		case 2 :
+            assert(jp2->color.icc_profile_len);	/* ICC profile */
+            l_colr_size += jp2->color.icc_profile_len;
+			break;
+		default :
+			return 00;
+	}
+
+	l_colr_data = (OPJ_BYTE *) opj_calloc(1,l_colr_size);
+	if (l_colr_data == 00) {
+		return 00;
+	}
+	
+	l_current_colr_ptr = l_colr_data;
+
+	opj_write_bytes(l_current_colr_ptr,l_colr_size,4);				/* write box size */
+	l_current_colr_ptr += 4;
+	
+	opj_write_bytes(l_current_colr_ptr,JP2_COLR,4);					/* BPCC */
+	l_current_colr_ptr += 4;
+	
+	opj_write_bytes(l_current_colr_ptr, jp2->meth,1);				/* METH */
+	++l_current_colr_ptr;
+	
+	opj_write_bytes(l_current_colr_ptr, jp2->precedence,1);			/* PRECEDENCE */
+	++l_current_colr_ptr;
+	
+	opj_write_bytes(l_current_colr_ptr, jp2->approx,1);				/* APPROX */
+	++l_current_colr_ptr;
+	
+	if (jp2->meth == 1) { /* Meth value is restricted to 1 or 2 (Table I.9 of part 1) */
+        opj_write_bytes(l_current_colr_ptr, jp2->enumcs,4); }       /* EnumCS */
+    else {
+        if (jp2->meth == 2) {                                      /* ICC profile */
+            OPJ_UINT32 i;
+            for(i = 0; i < jp2->color.icc_profile_len; ++i) {
+                opj_write_bytes(l_current_colr_ptr, jp2->color.icc_profile_buf[i], 1);
+                ++l_current_colr_ptr;
+            }
+        }
+	}
+
+	*p_nb_bytes_written = l_colr_size;
+	
+	return l_colr_data;
+}
+
+static void opj_jp2_free_pclr(opj_jp2_color_t *color)
+{
+    opj_free(color->jp2_pclr->channel_sign);
+    opj_free(color->jp2_pclr->channel_size);
+    opj_free(color->jp2_pclr->entries);
+
+	if(color->jp2_pclr->cmap) opj_free(color->jp2_pclr->cmap);
+
+    opj_free(color->jp2_pclr); color->jp2_pclr = NULL;
+}
+
+static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *p_manager)
+{
+	OPJ_UINT16 i;
+
+	/* testcase 4149.pdf.SIGSEGV.cf7.3501 */
+	if (color->jp2_cdef) {
+		opj_jp2_cdef_info_t *info = color->jp2_cdef->info;
+		OPJ_UINT16 n = color->jp2_cdef->n;
+		OPJ_UINT32 nr_channels = image->numcomps; /* FIXME image->numcomps == jp2->numcomps before color is applied ??? */
+
+		/* cdef applies to cmap channels if any */
+		if (color->jp2_pclr && color->jp2_pclr->cmap) {
+			nr_channels = (OPJ_UINT32)color->jp2_pclr->nr_channels;
+		}
+
+		for (i = 0; i < n; i++) {
+			if (info[i].cn >= nr_channels) {
+				opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n", info[i].cn, nr_channels);
+				return OPJ_FALSE;
+			}
+			if (info[i].asoc == 65535U) continue;
+
+			if (info[i].asoc > 0 && (OPJ_UINT32)(info[i].asoc - 1) >= nr_channels) {
+				opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n", info[i].asoc - 1, nr_channels);
+				return OPJ_FALSE;
+			}
+		}
+
+		/* issue 397 */
+		/* ISO 15444-1 states that if cdef is present, it shall contain a complete list of channel definitions. */
+		while (nr_channels > 0)
+		{
+			for(i = 0; i < n; ++i) {
+				if ((OPJ_UINT32)info[i].cn == (nr_channels - 1U)) {
+					break;
+				}
+			}
+			if (i == n) {
+				opj_event_msg(p_manager, EVT_ERROR, "Incomplete channel definitions.\n");
+				return OPJ_FALSE;
+			}
+			--nr_channels;
+		}
+	}
+
+	/* testcases 451.pdf.SIGSEGV.f4c.3723, 451.pdf.SIGSEGV.5b5.3723 and
+	   66ea31acbb0f23a2bbc91f64d69a03f5_signal_sigsegv_13937c0_7030_5725.pdf */
+	if (color->jp2_pclr && color->jp2_pclr->cmap) {
+		OPJ_UINT16 nr_channels = color->jp2_pclr->nr_channels;
+		opj_jp2_cmap_comp_t *cmap = color->jp2_pclr->cmap;
+		OPJ_BOOL *pcol_usage, is_sane = OPJ_TRUE;
+
+		/* verify that all original components match an existing one */
+		for (i = 0; i < nr_channels; i++) {
+			if (cmap[i].cmp >= image->numcomps) {
+				opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n", cmap[i].cmp, image->numcomps);
+				is_sane = OPJ_FALSE;
+			}
+		}
+
+		pcol_usage = (OPJ_BOOL *) opj_calloc(nr_channels, sizeof(OPJ_BOOL));
+		if (!pcol_usage) {
+			opj_event_msg(p_manager, EVT_ERROR, "Unexpected OOM.\n");
+			return OPJ_FALSE;
+		}
+		/* verify that no component is targeted more than once */
+		for (i = 0; i < nr_channels; i++) {
+      OPJ_UINT16 pcol = cmap[i].pcol;
+      assert(cmap[i].mtyp == 0 || cmap[i].mtyp == 1);
+			if (pcol >= nr_channels) {
+				opj_event_msg(p_manager, EVT_ERROR, "Invalid component/palette index for direct mapping %d.\n", pcol);
+				is_sane = OPJ_FALSE;
+			}
+			else if (pcol_usage[pcol] && cmap[i].mtyp == 1) {
+				opj_event_msg(p_manager, EVT_ERROR, "Component %d is mapped twice.\n", pcol);
+				is_sane = OPJ_FALSE;
+			}
+      else if (cmap[i].mtyp == 0 && cmap[i].pcol != 0) {
+        /* I.5.3.5 PCOL: If the value of the MTYP field for this channel is 0, then
+         * the value of this field shall be 0. */
+				opj_event_msg(p_manager, EVT_ERROR, "Direct use at #%d however pcol=%d.\n", i, pcol);
+				is_sane = OPJ_FALSE;
+      }
+			else
+				pcol_usage[pcol] = OPJ_TRUE;
+		}
+		/* verify that all components are targeted at least once */
+		for (i = 0; i < nr_channels; i++) {
+			if (!pcol_usage[i] && cmap[i].mtyp != 0) {
+				opj_event_msg(p_manager, EVT_ERROR, "Component %d doesn't have a mapping.\n", i);
+				is_sane = OPJ_FALSE;
+			}
+		}
+		/* Issue 235/447 weird cmap */
+		if (1 && is_sane && (image->numcomps==1U)) {
+			for (i = 0; i < nr_channels; i++) {
+				if (!pcol_usage[i]) {
+					is_sane = 0U;
+					opj_event_msg(p_manager, EVT_WARNING, "Component mapping seems wrong. Trying to correct.\n", i);
+					break;
+				}
+			}
+			if (!is_sane) {
+				is_sane = OPJ_TRUE;
+				for (i = 0; i < nr_channels; i++) {
+					cmap[i].mtyp = 1U;
+					cmap[i].pcol = (OPJ_BYTE) i;
+				}
+			}
+		}
+		opj_free(pcol_usage);
+		if (!is_sane) {
+			return OPJ_FALSE;
+		}
+	}
+
+	return OPJ_TRUE;
+}
+
+/* file9.jp2 */
+static void opj_jp2_apply_pclr(opj_image_t *image, opj_jp2_color_t *color)
+{
+	opj_image_comp_t *old_comps, *new_comps;
+	OPJ_BYTE *channel_size, *channel_sign;
+	OPJ_UINT32 *entries;
+	opj_jp2_cmap_comp_t *cmap;
+	OPJ_INT32 *src, *dst;
+	OPJ_UINT32 j, max;
+	OPJ_UINT16 i, nr_channels, cmp, pcol;
+	OPJ_INT32 k, top_k;
+
+	channel_size = color->jp2_pclr->channel_size;
+	channel_sign = color->jp2_pclr->channel_sign;
+	entries = color->jp2_pclr->entries;
+	cmap = color->jp2_pclr->cmap;
+	nr_channels = color->jp2_pclr->nr_channels;
+
+	old_comps = image->comps;
+	new_comps = (opj_image_comp_t*)
+			opj_malloc(nr_channels * sizeof(opj_image_comp_t));
+	if (!new_comps) {
+		/* FIXME no error code for opj_jp2_apply_pclr */
+		/* FIXME event manager error callback */
+		return;
+	}
+	for(i = 0; i < nr_channels; ++i) {
+		pcol = cmap[i].pcol; cmp = cmap[i].cmp;
+
+		/* Direct use */
+    if(cmap[i].mtyp == 0){
+      assert( pcol == 0 );
+      new_comps[i] = old_comps[cmp];
+    } else {
+      assert( i == pcol );
+      new_comps[pcol] = old_comps[cmp];
+    }
+
+		/* Palette mapping: */
+		new_comps[i].data = (OPJ_INT32*)
+				opj_malloc(old_comps[cmp].w * old_comps[cmp].h * sizeof(OPJ_INT32));
+		if (!new_comps[i].data) {
+			opj_free(new_comps);
+			new_comps = NULL;
+			/* FIXME no error code for opj_jp2_apply_pclr */
+			/* FIXME event manager error callback */
+			return;
+		}
+		new_comps[i].prec = channel_size[i];
+		new_comps[i].sgnd = channel_sign[i];
+	}
+
+	top_k = color->jp2_pclr->nr_entries - 1;
+
+	for(i = 0; i < nr_channels; ++i) {
+		/* Palette mapping: */
+		cmp = cmap[i].cmp; pcol = cmap[i].pcol;
+		src = old_comps[cmp].data;
+    assert( src );
+		max = new_comps[pcol].w * new_comps[pcol].h;
+
+		/* Direct use: */
+    if(cmap[i].mtyp == 0) {
+      assert( cmp == 0 );
+      dst = new_comps[i].data;
+      assert( dst );
+      for(j = 0; j < max; ++j) {
+        dst[j] = src[j];
+      }
+    }
+    else {
+      assert( i == pcol );
+      dst = new_comps[pcol].data;
+      assert( dst );
+      for(j = 0; j < max; ++j) {
+        /* The index */
+        if((k = src[j]) < 0) k = 0; else if(k > top_k) k = top_k;
+
+        /* The colour */
+        dst[j] = (OPJ_INT32)entries[k * nr_channels + pcol];
+        }
+    }
+	}
+
+	max = image->numcomps;
+	for(i = 0; i < max; ++i) {
+		if(old_comps[i].data) opj_free(old_comps[i].data);
+	}
+
+	opj_free(old_comps);
+	image->comps = new_comps;
+	image->numcomps = nr_channels;
+
+	opj_jp2_free_pclr(color);
+
+}/* apply_pclr() */
+
+static OPJ_BOOL opj_jp2_read_pclr(	opj_jp2_t *jp2,
+                            OPJ_BYTE * p_pclr_header_data,
+                            OPJ_UINT32 p_pclr_header_size,
+                            opj_event_mgr_t * p_manager
+                            )
+{
+	opj_jp2_pclr_t *jp2_pclr;
+	OPJ_BYTE *channel_size, *channel_sign;
+	OPJ_UINT32 *entries;
+	OPJ_UINT16 nr_entries,nr_channels;
+	OPJ_UINT16 i, j;
+	OPJ_UINT32 l_value;
+	OPJ_BYTE *orig_header_data = p_pclr_header_data;
+
+	/* preconditions */
+	assert(p_pclr_header_data != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+    (void)p_pclr_header_size;
+
+	if(jp2->color.jp2_pclr)
+		return OPJ_FALSE;
+
+	if (p_pclr_header_size < 3)
+		return OPJ_FALSE;
+
+	opj_read_bytes(p_pclr_header_data, &l_value , 2);	/* NE */
+	p_pclr_header_data += 2;
+	nr_entries = (OPJ_UINT16) l_value;
+	if ((nr_entries == 0U) || (nr_entries > 1024U)) {
+		opj_event_msg(p_manager, EVT_ERROR, "Invalid PCLR box. Reports %d entries\n", (int)nr_entries);
+		return OPJ_FALSE;
+	}
+
+	opj_read_bytes(p_pclr_header_data, &l_value , 1);	/* NPC */
+	++p_pclr_header_data;
+	nr_channels = (OPJ_UINT16) l_value;
+	if (nr_channels == 0U) {
+		opj_event_msg(p_manager, EVT_ERROR, "Invalid PCLR box. Reports 0 palette columns\n");
+		return OPJ_FALSE;
+	}
+
+	if (p_pclr_header_size < 3 + (OPJ_UINT32)nr_channels)
+		return OPJ_FALSE;
+
+	entries = (OPJ_UINT32*) opj_malloc((size_t)nr_channels * nr_entries * sizeof(OPJ_UINT32));
+    if (!entries)
+        return OPJ_FALSE;
+	channel_size = (OPJ_BYTE*) opj_malloc(nr_channels);
+    if (!channel_size)
+    {
+        opj_free(entries);
+        return OPJ_FALSE;
+    }
+	channel_sign = (OPJ_BYTE*) opj_malloc(nr_channels);
+	if (!channel_sign)
+	{
+        opj_free(entries);
+        opj_free(channel_size);
+        return OPJ_FALSE;
+	}
+
+	jp2_pclr = (opj_jp2_pclr_t*)opj_malloc(sizeof(opj_jp2_pclr_t));
+    if (!jp2_pclr)
+    {
+        opj_free(entries);
+        opj_free(channel_size);
+        opj_free(channel_sign);
+        return OPJ_FALSE;
+    }
+
+	jp2_pclr->channel_sign = channel_sign;
+	jp2_pclr->channel_size = channel_size;
+	jp2_pclr->entries = entries;
+	jp2_pclr->nr_entries = nr_entries;
+	jp2_pclr->nr_channels = (OPJ_BYTE) l_value;
+	jp2_pclr->cmap = NULL;
+
+	jp2->color.jp2_pclr = jp2_pclr;
+
+	for(i = 0; i < nr_channels; ++i) {
+		opj_read_bytes(p_pclr_header_data, &l_value , 1);	/* Bi */
+		++p_pclr_header_data;
+
+		channel_size[i] = (OPJ_BYTE)((l_value & 0x7f) + 1);
+		channel_sign[i] = (l_value & 0x80) ? 1 : 0;
+	}
+
+	for(j = 0; j < nr_entries; ++j) {
+		for(i = 0; i < nr_channels; ++i) {
+			OPJ_UINT32 bytes_to_read = (OPJ_UINT32)((channel_size[i]+7)>>3);
+
+			if (bytes_to_read > sizeof(OPJ_UINT32))
+				bytes_to_read = sizeof(OPJ_UINT32);
+			if ((ptrdiff_t)p_pclr_header_size < (ptrdiff_t)(p_pclr_header_data - orig_header_data) + (ptrdiff_t)bytes_to_read)
+				return OPJ_FALSE;
+
+			opj_read_bytes(p_pclr_header_data, &l_value , bytes_to_read);	/* Cji */
+			p_pclr_header_data += bytes_to_read;
+			*entries = (OPJ_UINT32) l_value;
+			entries++;
+		}
+	}
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_read_cmap(	opj_jp2_t * jp2,
+                            OPJ_BYTE * p_cmap_header_data,
+                            OPJ_UINT32 p_cmap_header_size,
+                            opj_event_mgr_t * p_manager
+                            )
+{
+	opj_jp2_cmap_comp_t *cmap;
+	OPJ_BYTE i, nr_channels;
+	OPJ_UINT32 l_value;
+
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_cmap_header_data != 00);
+	assert(p_manager != 00);
+    (void)p_cmap_header_size;
+
+	/* Need nr_channels: */
+	if(jp2->color.jp2_pclr == NULL) {
+		opj_event_msg(p_manager, EVT_ERROR, "Need to read a PCLR box before the CMAP box.\n");
+		return OPJ_FALSE;
+	}
+
+	/* Part 1, I.5.3.5: 'There shall be at most one Component Mapping box
+	 * inside a JP2 Header box' :
+	*/
+	if(jp2->color.jp2_pclr->cmap) {
+		opj_event_msg(p_manager, EVT_ERROR, "Only one CMAP box is allowed.\n");
+		return OPJ_FALSE;
+	}
+
+	nr_channels = jp2->color.jp2_pclr->nr_channels;
+	if (p_cmap_header_size < (OPJ_UINT32)nr_channels * 4) {
+		opj_event_msg(p_manager, EVT_ERROR, "Insufficient data for CMAP box.\n");
+		return OPJ_FALSE;
+	}
+
+	cmap = (opj_jp2_cmap_comp_t*) opj_malloc(nr_channels * sizeof(opj_jp2_cmap_comp_t));
+    if (!cmap)
+        return OPJ_FALSE;
+
+
+	for(i = 0; i < nr_channels; ++i) {
+		opj_read_bytes(p_cmap_header_data, &l_value, 2);			/* CMP^i */
+		p_cmap_header_data +=2;
+		cmap[i].cmp = (OPJ_UINT16) l_value;
+
+		opj_read_bytes(p_cmap_header_data, &l_value, 1);			/* MTYP^i */
+		++p_cmap_header_data;
+		cmap[i].mtyp = (OPJ_BYTE) l_value;
+
+		opj_read_bytes(p_cmap_header_data, &l_value, 1);			/* PCOL^i */
+		++p_cmap_header_data;
+		cmap[i].pcol = (OPJ_BYTE) l_value;
+	}
+
+	jp2->color.jp2_pclr->cmap = cmap;
+
+	return OPJ_TRUE;
+}
+
+static void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color, opj_event_mgr_t *manager)
+{
+	opj_jp2_cdef_info_t *info;
+	OPJ_UINT16 i, n, cn, asoc, acn;
+	
+	info = color->jp2_cdef->info;
+	n = color->jp2_cdef->n;
+	
+	for(i = 0; i < n; ++i)
+	{
+		/* WATCH: acn = asoc - 1 ! */
+		asoc = info[i].asoc;
+		cn = info[i].cn;
+		
+		if( cn >= image->numcomps)
+		{
+			opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: cn=%d, numcomps=%d\n", cn, image->numcomps);
+			continue;
+		}
+		if(asoc == 0 || asoc == 65535)
+		{
+			image->comps[cn].alpha = info[i].typ;
+			continue;
+		}
+		
+		acn = (OPJ_UINT16)(asoc - 1);
+		if( acn >= image->numcomps )
+		{
+			opj_event_msg(manager, EVT_WARNING, "opj_jp2_apply_cdef: acn=%d, numcomps=%d\n", acn, image->numcomps);
+			continue;
+		}
+		
+		/* Swap only if color channel */
+		if((cn != acn) && (info[i].typ == 0))
+		{
+			opj_image_comp_t saved;
+			OPJ_UINT16 j;
+			
+			memcpy(&saved, &image->comps[cn], sizeof(opj_image_comp_t));
+			memcpy(&image->comps[cn], &image->comps[acn], sizeof(opj_image_comp_t));
+			memcpy(&image->comps[acn], &saved, sizeof(opj_image_comp_t));
+			
+			/* Swap channels in following channel definitions, don't bother with j <= i that are already processed */
+			for (j = (OPJ_UINT16)(i + 1U); j < n ; ++j)
+			{
+				if (info[j].cn == cn) {
+					info[j].cn = acn;
+				}
+				else if (info[j].cn == acn) {
+					info[j].cn = cn;
+				}
+				/* asoc is related to color index. Do not update. */
+			}
+		}
+		
+		image->comps[cn].alpha = info[i].typ;
+	}
+	
+	if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info);
+	
+	opj_free(color->jp2_cdef); color->jp2_cdef = NULL;
+	
+}/* jp2_apply_cdef() */
+
+static OPJ_BOOL opj_jp2_read_cdef(	opj_jp2_t * jp2,
+                            OPJ_BYTE * p_cdef_header_data,
+							OPJ_UINT32 p_cdef_header_size,
+							opj_event_mgr_t * p_manager
+                            )
+{
+	opj_jp2_cdef_info_t *cdef_info;
+	OPJ_UINT16 i;
+	OPJ_UINT32 l_value;
+
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_cdef_header_data != 00);
+	assert(p_manager != 00);
+    (void)p_cdef_header_size;
+
+	/* Part 1, I.5.3.6: 'The shall be at most one Channel Definition box
+	 * inside a JP2 Header box.'*/
+	if(jp2->color.jp2_cdef) return OPJ_FALSE;
+
+	if (p_cdef_header_size < 2) {
+		opj_event_msg(p_manager, EVT_ERROR, "Insufficient data for CDEF box.\n");
+		return OPJ_FALSE;
+	}
+
+	opj_read_bytes(p_cdef_header_data,&l_value ,2);			/* N */
+	p_cdef_header_data+= 2;
+
+	if ( (OPJ_UINT16)l_value == 0){ /* szukw000: FIXME */
+		opj_event_msg(p_manager, EVT_ERROR, "Number of channel description is equal to zero in CDEF box.\n");
+		return OPJ_FALSE;
+	}
+
+	if (p_cdef_header_size < 2 + (OPJ_UINT32)(OPJ_UINT16)l_value * 6) {
+		opj_event_msg(p_manager, EVT_ERROR, "Insufficient data for CDEF box.\n");
+		return OPJ_FALSE;
+	}
+
+	cdef_info = (opj_jp2_cdef_info_t*) opj_malloc(l_value * sizeof(opj_jp2_cdef_info_t));
+	if (!cdef_info)
+		return OPJ_FALSE;
+
+	jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
+	if(!jp2->color.jp2_cdef)
+	{
+		opj_free(cdef_info);
+		return OPJ_FALSE;
+	}
+	jp2->color.jp2_cdef->info = cdef_info;
+	jp2->color.jp2_cdef->n = (OPJ_UINT16) l_value;
+
+	for(i = 0; i < jp2->color.jp2_cdef->n; ++i) {
+		opj_read_bytes(p_cdef_header_data, &l_value, 2);			/* Cn^i */
+		p_cdef_header_data +=2;
+		cdef_info[i].cn = (OPJ_UINT16) l_value;
+
+		opj_read_bytes(p_cdef_header_data, &l_value, 2);			/* Typ^i */
+		p_cdef_header_data +=2;
+		cdef_info[i].typ = (OPJ_UINT16) l_value;
+
+		opj_read_bytes(p_cdef_header_data, &l_value, 2);			/* Asoc^i */
+		p_cdef_header_data +=2;
+		cdef_info[i].asoc = (OPJ_UINT16) l_value;
+   }
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
+                            OPJ_BYTE * p_colr_header_data,
+                            OPJ_UINT32 p_colr_header_size,
+                            opj_event_mgr_t * p_manager
+                            )
+{
+	OPJ_UINT32 l_value;
+
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_colr_header_data != 00);
+	assert(p_manager != 00);
+
+	if (p_colr_header_size < 3) {
+		opj_event_msg(p_manager, EVT_ERROR, "Bad COLR header box (bad size)\n");
+		return OPJ_FALSE;
+	}
+
+	/* Part 1, I.5.3.3 : 'A conforming JP2 reader shall ignore all Colour
+	 * Specification boxes after the first.'
+	*/
+	if(jp2->color.jp2_has_colr) {
+		opj_event_msg(p_manager, EVT_INFO, "A conforming JP2 reader shall ignore all Colour Specification boxes after the first, so we ignore this one.\n");
+		p_colr_header_data += p_colr_header_size;
+		return OPJ_TRUE;
+	}
+
+	opj_read_bytes(p_colr_header_data,&jp2->meth ,1);			/* METH */
+	++p_colr_header_data;
+
+	opj_read_bytes(p_colr_header_data,&jp2->precedence ,1);		/* PRECEDENCE */
+	++p_colr_header_data;
+
+	opj_read_bytes(p_colr_header_data,&jp2->approx ,1);			/* APPROX */
+	++p_colr_header_data;
+
+	if (jp2->meth == 1) {
+		if (p_colr_header_size < 7) {
+			opj_event_msg(p_manager, EVT_ERROR, "Bad COLR header box (bad size: %d)\n", p_colr_header_size);
+			return OPJ_FALSE;
+		}
+		if ((p_colr_header_size > 7) && (jp2->enumcs != 14)) { /* handled below for CIELab) */
+			/* testcase Altona_Technical_v20_x4.pdf */
+			opj_event_msg(p_manager, EVT_WARNING, "Bad COLR header box (bad size: %d)\n", p_colr_header_size);
+		}
+
+		opj_read_bytes(p_colr_header_data,&jp2->enumcs ,4);			/* EnumCS */
+
+		p_colr_header_data += 4;
+
+		if(jp2->enumcs == 14)/* CIELab */
+		{
+			OPJ_UINT32 *cielab;
+			OPJ_UINT32 rl, ol, ra, oa, rb, ob, il;
+
+			cielab = (OPJ_UINT32*)opj_malloc(9 * sizeof(OPJ_UINT32));
+			if(cielab == NULL){
+				opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for cielab\n");
+				return OPJ_FALSE;
+			}
+			cielab[0] = 14; /* enumcs */
+			
+			/* default values */
+			rl = ra = rb = ol = oa = ob = 0;
+			il = 0x00443530; /* D50 */
+			cielab[1] = 0x44454600;/* DEF */
+
+			if(p_colr_header_size == 35)
+			{
+				opj_read_bytes(p_colr_header_data, &rl, 4);
+				p_colr_header_data += 4;
+				opj_read_bytes(p_colr_header_data, &ol, 4);
+				p_colr_header_data += 4;
+				opj_read_bytes(p_colr_header_data, &ra, 4);
+				p_colr_header_data += 4;
+				opj_read_bytes(p_colr_header_data, &oa, 4);
+				p_colr_header_data += 4;
+				opj_read_bytes(p_colr_header_data, &rb, 4);
+				p_colr_header_data += 4;
+				opj_read_bytes(p_colr_header_data, &ob, 4);
+				p_colr_header_data += 4;
+				opj_read_bytes(p_colr_header_data, &il, 4);
+				p_colr_header_data += 4;
+				
+				cielab[1] = 0;
+			}
+			else if(p_colr_header_size != 7)
+			{
+				opj_event_msg(p_manager, EVT_WARNING, "Bad COLR header box (CIELab, bad size: %d)\n", p_colr_header_size);
+			}
+			cielab[2] = rl; cielab[4] = ra; cielab[6] = rb;
+			cielab[3] = ol; cielab[5] = oa; cielab[7] = ob;
+			cielab[8] = il;
+
+			jp2->color.icc_profile_buf = (OPJ_BYTE*)cielab;
+			jp2->color.icc_profile_len = 0;
+		}
+		jp2->color.jp2_has_colr = 1;
+	}
+	else if (jp2->meth == 2) {
+		/* ICC profile */
+		OPJ_INT32 it_icc_value = 0;
+		OPJ_INT32 icc_len = (OPJ_INT32)p_colr_header_size - 3;
+
+		jp2->color.icc_profile_len = (OPJ_UINT32)icc_len;
+		jp2->color.icc_profile_buf = (OPJ_BYTE*) opj_calloc(1,(size_t)icc_len);
+		if (!jp2->color.icc_profile_buf)
+		{
+			jp2->color.icc_profile_len = 0;
+			return OPJ_FALSE;
+		}
+
+		for (it_icc_value = 0; it_icc_value < icc_len; ++it_icc_value)
+		{
+			opj_read_bytes(p_colr_header_data,&l_value,1);		/* icc values */
+			++p_colr_header_data;
+			jp2->color.icc_profile_buf[it_icc_value] = (OPJ_BYTE) l_value;
+		}
+	    
+		jp2->color.jp2_has_colr = 1;
+	}
+	else if (jp2->meth > 2)
+	{
+		/*	ISO/IEC 15444-1:2004 (E), Table I.9 Legal METH values:
+		conforming JP2 reader shall ignore the entire Colour Specification box.*/
+		opj_event_msg(p_manager, EVT_INFO, "COLR BOX meth value is not a regular value (%d), "
+			"so we will ignore the entire Colour Specification box. \n", jp2->meth);
+	}
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
+                        opj_stream_private_t *p_stream,
+                        opj_image_t* p_image,
+                        opj_event_mgr_t * p_manager)
+{
+	if (!p_image)
+		return OPJ_FALSE;
+
+	/* J2K decoding */
+	if( ! opj_j2k_decode(jp2->j2k, p_stream, p_image, p_manager) ) {
+		opj_event_msg(p_manager, EVT_ERROR, "Failed to decode the codestream in the JP2 file\n");
+		return OPJ_FALSE;
+	}
+
+	if (!jp2->ignore_pclr_cmap_cdef){
+		if (!opj_jp2_check_color(p_image, &(jp2->color), p_manager)) {
+			return OPJ_FALSE;
+		}
+
+		/* Set Image Color Space */
+		if (jp2->enumcs == 16)
+			p_image->color_space = OPJ_CLRSPC_SRGB;
+		else if (jp2->enumcs == 17)
+			p_image->color_space = OPJ_CLRSPC_GRAY;
+		else if (jp2->enumcs == 18)
+			p_image->color_space = OPJ_CLRSPC_SYCC;
+		else if (jp2->enumcs == 24)
+			p_image->color_space = OPJ_CLRSPC_EYCC;
+		else if (jp2->enumcs == 12)
+			p_image->color_space = OPJ_CLRSPC_CMYK;
+		else
+			p_image->color_space = OPJ_CLRSPC_UNKNOWN;
+
+		if(jp2->color.jp2_pclr) {
+			/* Part 1, I.5.3.4: Either both or none : */
+			if( !jp2->color.jp2_pclr->cmap)
+				opj_jp2_free_pclr(&(jp2->color));
+			else
+				opj_jp2_apply_pclr(p_image, &(jp2->color));
+		}
+
+		/* Apply the color space if needed */
+		if(jp2->color.jp2_cdef) {
+			opj_jp2_apply_cdef(p_image, &(jp2->color), p_manager);
+		}
+
+		if(jp2->color.icc_profile_buf) {
+			p_image->icc_profile_buf = jp2->color.icc_profile_buf;
+			p_image->icc_profile_len = jp2->color.icc_profile_len;
+			jp2->color.icc_profile_buf = NULL;
+		}
+	}
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_write_jp2h(opj_jp2_t *jp2,
+                            opj_stream_private_t *stream,
+                            opj_event_mgr_t * p_manager
+                            )
+{
+	opj_jp2_img_header_writer_handler_t l_writers [4];
+	opj_jp2_img_header_writer_handler_t * l_current_writer;
+
+	OPJ_INT32 i, l_nb_pass;
+	/* size of data for super box*/
+	OPJ_UINT32 l_jp2h_size = 8;
+	OPJ_BOOL l_result = OPJ_TRUE;
+
+	/* to store the data of the super box */
+	OPJ_BYTE l_jp2h_data [8];
+	
+	/* preconditions */
+	assert(stream != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	memset(l_writers,0,sizeof(l_writers));
+
+	if (jp2->bpc == 255) {
+		l_nb_pass = 3;
+		l_writers[0].handler = opj_jp2_write_ihdr;
+		l_writers[1].handler = opj_jp2_write_bpcc;
+		l_writers[2].handler = opj_jp2_write_colr;
+	}
+	else {
+		l_nb_pass = 2;
+		l_writers[0].handler = opj_jp2_write_ihdr;
+		l_writers[1].handler = opj_jp2_write_colr;
+	}
+	
+	if (jp2->color.jp2_cdef != NULL) {
+		l_writers[l_nb_pass].handler = opj_jp2_write_cdef;
+		l_nb_pass++;
+	}
+	
+	/* write box header */
+	/* write JP2H type */
+	opj_write_bytes(l_jp2h_data+4,JP2_JP2H,4);
+
+	l_current_writer = l_writers;
+	for (i=0;i<l_nb_pass;++i) {
+		l_current_writer->m_data = l_current_writer->handler(jp2,&(l_current_writer->m_size));
+		if (l_current_writer->m_data == 00) {
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to hold JP2 Header data\n");
+			l_result = OPJ_FALSE;
+			break;
+		}
+
+		l_jp2h_size += l_current_writer->m_size;
+		++l_current_writer;
+	}
+
+	if (! l_result) {
+		l_current_writer = l_writers;
+		for (i=0;i<l_nb_pass;++i) {
+			if (l_current_writer->m_data != 00) {
+				opj_free(l_current_writer->m_data );
+			}
+			++l_current_writer;
+		}
+
+		return OPJ_FALSE;
+	}
+
+	/* write super box size */
+	opj_write_bytes(l_jp2h_data,l_jp2h_size,4);
+	
+	/* write super box data on stream */
+	if (opj_stream_write_data(stream,l_jp2h_data,8,p_manager) != 8) {
+		opj_event_msg(p_manager, EVT_ERROR, "Stream error while writing JP2 Header box\n");
+		l_result = OPJ_FALSE;
+	}
+	
+	if (l_result) {
+		l_current_writer = l_writers;
+		for (i=0;i<l_nb_pass;++i) {
+			if (opj_stream_write_data(stream,l_current_writer->m_data,l_current_writer->m_size,p_manager) != l_current_writer->m_size) {
+				opj_event_msg(p_manager, EVT_ERROR, "Stream error while writing JP2 Header box\n");
+				l_result = OPJ_FALSE;
+				break;
+			}
+			++l_current_writer;
+		}
+	}
+
+	l_current_writer = l_writers;
+	
+	/* cleanup */
+	for (i=0;i<l_nb_pass;++i) {
+		if (l_current_writer->m_data != 00) {
+			opj_free(l_current_writer->m_data );
+		}
+		++l_current_writer;
+	}
+
+	return l_result;
+}
+
+static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
+							opj_stream_private_t *cio,
+							opj_event_mgr_t * p_manager )
+{
+	OPJ_UINT32 i;
+	OPJ_UINT32 l_ftyp_size;
+	OPJ_BYTE * l_ftyp_data, * l_current_data_ptr;
+	OPJ_BOOL l_result;
+
+	/* preconditions */
+	assert(cio != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+	l_ftyp_size = 16 + 4 * jp2->numcl;
+
+	l_ftyp_data = (OPJ_BYTE *) opj_calloc(1,l_ftyp_size);
+	
+	if (l_ftyp_data == 00) {
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle ftyp data\n");
+		return OPJ_FALSE;
+	}
+
+	l_current_data_ptr = l_ftyp_data;
+
+	opj_write_bytes(l_current_data_ptr, l_ftyp_size,4); /* box size */
+	l_current_data_ptr += 4;
+
+	opj_write_bytes(l_current_data_ptr, JP2_FTYP,4); /* FTYP */
+	l_current_data_ptr += 4;
+
+	opj_write_bytes(l_current_data_ptr, jp2->brand,4); /* BR */
+	l_current_data_ptr += 4;
+
+	opj_write_bytes(l_current_data_ptr, jp2->minversion,4); /* MinV */
+	l_current_data_ptr += 4;
+
+	for (i = 0; i < jp2->numcl; i++)  {
+		opj_write_bytes(l_current_data_ptr, jp2->cl[i],4);	/* CL */
+	}
+	
+	l_result = (opj_stream_write_data(cio,l_ftyp_data,l_ftyp_size,p_manager) == l_ftyp_size);
+	if (! l_result)
+	{
+		opj_event_msg(p_manager, EVT_ERROR, "Error while writing ftyp data to stream\n");
+	}
+
+	opj_free(l_ftyp_data);
+	
+	return l_result;
+}
+
+static OPJ_BOOL opj_jp2_write_jp2c(opj_jp2_t *jp2,
+							opj_stream_private_t *cio,
+							opj_event_mgr_t * p_manager )
+{
+	OPJ_OFF_T j2k_codestream_exit;
+	OPJ_BYTE l_data_header [8];
+	
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(cio != 00);
+	assert(p_manager != 00);
+	assert(opj_stream_has_seek(cio));
+	
+	j2k_codestream_exit = opj_stream_tell(cio);
+	opj_write_bytes(l_data_header,
+                    (OPJ_UINT32) (j2k_codestream_exit - jp2->j2k_codestream_offset),
+                    4); /* size of codestream */
+	opj_write_bytes(l_data_header + 4,JP2_JP2C,4);									   /* JP2C */
+
+	if (! opj_stream_seek(cio,jp2->j2k_codestream_offset,p_manager)) {
+		opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+		return OPJ_FALSE;
+	}
+	
+	if (opj_stream_write_data(cio,l_data_header,8,p_manager) != 8) {
+		opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+		return OPJ_FALSE;
+	}
+
+	if (! opj_stream_seek(cio,j2k_codestream_exit,p_manager)) {
+		opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+		return OPJ_FALSE;
+	}
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_write_jp(	opj_jp2_t *jp2,
+			    		    opj_stream_private_t *cio,
+				    		opj_event_mgr_t * p_manager )
+{
+	/* 12 bytes will be read */
+	OPJ_BYTE l_signature_data [12];
+
+	/* preconditions */
+	assert(cio != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	/* write box length */
+	opj_write_bytes(l_signature_data,12,4);
+	/* writes box type */
+	opj_write_bytes(l_signature_data+4,JP2_JP,4);
+	/* writes magic number*/
+	opj_write_bytes(l_signature_data+8,0x0d0a870a,4);
+	
+	if (opj_stream_write_data(cio,l_signature_data,12,p_manager) != 12) {
+		return OPJ_FALSE;
+	}
+
+	return OPJ_TRUE;
+}
+
+/* ----------------------------------------------------------------------- */
+/* JP2 decoder interface                                             */
+/* ----------------------------------------------------------------------- */
+
+void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
+{
+	/* setup the J2K codec */
+	opj_j2k_setup_decoder(jp2->j2k, parameters);
+
+	/* further JP2 initializations go here */
+	jp2->color.jp2_has_colr = 0;
+    jp2->ignore_pclr_cmap_cdef = parameters->flags & OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
+}
+
+/* ----------------------------------------------------------------------- */
+/* JP2 encoder interface                                             */
+/* ----------------------------------------------------------------------- */
+
+OPJ_BOOL opj_jp2_setup_encoder(	opj_jp2_t *jp2,
+                            opj_cparameters_t *parameters,
+                            opj_image_t *image,
+                            opj_event_mgr_t * p_manager)
+{
+	OPJ_UINT32 i;
+	OPJ_UINT32 depth_0;
+  OPJ_UINT32 sign;
+	OPJ_UINT32 alpha_count;
+	OPJ_UINT32 color_channels = 0U;
+	OPJ_UINT32 alpha_channel = 0U;
+	
+
+	if(!jp2 || !parameters || !image)
+		return OPJ_FALSE;
+
+	/* setup the J2K codec */
+	/* ------------------- */
+
+	/* Check if number of components respects standard */
+	if (image->numcomps < 1 || image->numcomps > 16384) {
+		opj_event_msg(p_manager, EVT_ERROR, "Invalid number of components specified while setting up JP2 encoder\n");
+		return OPJ_FALSE;
+	}
+
+	if (opj_j2k_setup_encoder(jp2->j2k, parameters, image, p_manager ) == OPJ_FALSE) {
+		return OPJ_FALSE;
+	}
+
+	/* setup the JP2 codec */
+	/* ------------------- */
+	
+	/* Profile box */
+
+	jp2->brand = JP2_JP2;	/* BR */
+	jp2->minversion = 0;	/* MinV */
+	jp2->numcl = 1;
+	jp2->cl = (OPJ_UINT32*) opj_malloc(jp2->numcl * sizeof(OPJ_UINT32));
+	if (!jp2->cl){
+		jp2->cl = NULL;
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory when setup the JP2 encoder\n");
+		return OPJ_FALSE;
+	}
+	jp2->cl[0] = JP2_JP2;	/* CL0 : JP2 */
+
+	/* Image Header box */
+
+	jp2->numcomps = image->numcomps;	/* NC */
+	jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
+	if (!jp2->comps) {
+		jp2->comps = NULL;
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory when setup the JP2 encoder\n");
+		/* Memory of jp2->cl will be freed by opj_jp2_destroy */
+		return OPJ_FALSE;
+	}
+
+	jp2->h = image->y1 - image->y0;		/* HEIGHT */
+	jp2->w = image->x1 - image->x0;		/* WIDTH */
+	/* BPC */
+	depth_0 = image->comps[0].prec - 1;
+	sign = image->comps[0].sgnd;
+	jp2->bpc = depth_0 + (sign << 7);
+	for (i = 1; i < image->numcomps; i++) {
+		OPJ_UINT32 depth = image->comps[i].prec - 1;
+		sign = image->comps[i].sgnd;
+		if (depth_0 != depth)
+			jp2->bpc = 255;
+	}
+	jp2->C = 7;			/* C : Always 7 */
+	jp2->UnkC = 0;		/* UnkC, colorspace specified in colr box */
+	jp2->IPR = 0;		/* IPR, no intellectual property */
+	
+	/* BitsPerComponent box */
+	for (i = 0; i < image->numcomps; i++) {
+		jp2->comps[i].bpcc = image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
+	}
+
+	/* Colour Specification box */
+    if(image->icc_profile_len) {
+        jp2->meth = 2;
+        jp2->enumcs = 0;
+    } 
+    else {
+        jp2->meth = 1;
+        if (image->color_space == 1)
+            jp2->enumcs = 16;	/* sRGB as defined by IEC 61966-2-1 */
+        else if (image->color_space == 2)
+            jp2->enumcs = 17;	/* greyscale */
+        else if (image->color_space == 3)
+            jp2->enumcs = 18;	/* YUV */
+    }
+
+	/* Channel Definition box */
+	/* FIXME not provided by parameters */
+	/* We try to do what we can... */
+	alpha_count = 0U;
+	for (i = 0; i < image->numcomps; i++) {
+		if (image->comps[i].alpha != 0) {
+			alpha_count++;
+			alpha_channel = i;
+		}
+	}
+	if (alpha_count == 1U) { /* no way to deal with more than 1 alpha channel */
+		switch (jp2->enumcs) {
+			case 16:
+			case 18:
+				color_channels = 3;
+				break;
+			case 17:
+				color_channels = 1;
+				break;
+			default:
+				alpha_count = 0U;
+				break;
+		}
+		if (alpha_count == 0U) {
+			opj_event_msg(p_manager, EVT_WARNING, "Alpha channel specified but unknown enumcs. No cdef box will be created.\n");
+		} else if (image->numcomps < (color_channels+1)) {
+			opj_event_msg(p_manager, EVT_WARNING, "Alpha channel specified but not enough image components for an automatic cdef box creation.\n");
+			alpha_count = 0U;
+		} else if ((OPJ_UINT32)alpha_channel < color_channels) {
+			opj_event_msg(p_manager, EVT_WARNING, "Alpha channel position conflicts with color channel. No cdef box will be created.\n");
+			alpha_count = 0U;
+		}
+	} else if (alpha_count > 1) {
+		opj_event_msg(p_manager, EVT_WARNING, "Multiple alpha channels specified. No cdef box will be created.\n");
+	}
+	if (alpha_count == 1U) { /* if here, we know what we can do */
+		jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
+		if(!jp2->color.jp2_cdef) {
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup the JP2 encoder\n");
+			return OPJ_FALSE;
+		}
+		/* no memset needed, all values will be overwritten except if jp2->color.jp2_cdef->info allocation fails, */
+		/* in which case jp2->color.jp2_cdef->info will be NULL => valid for destruction */
+		jp2->color.jp2_cdef->info = (opj_jp2_cdef_info_t*) opj_malloc(image->numcomps * sizeof(opj_jp2_cdef_info_t));
+		if (!jp2->color.jp2_cdef->info) {
+			/* memory will be freed by opj_jp2_destroy */
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup the JP2 encoder\n");
+			return OPJ_FALSE;
+		}
+		jp2->color.jp2_cdef->n = (OPJ_UINT16) image->numcomps; /* cast is valid : image->numcomps [1,16384] */
+		for (i = 0U; i < color_channels; i++) {
+			jp2->color.jp2_cdef->info[i].cn = (OPJ_UINT16)i; /* cast is valid : image->numcomps [1,16384] */
+			jp2->color.jp2_cdef->info[i].typ = 0U;
+			jp2->color.jp2_cdef->info[i].asoc = (OPJ_UINT16)(i+1U); /* No overflow + cast is valid : image->numcomps [1,16384] */
+		}
+		for (; i < image->numcomps; i++) {
+			if (image->comps[i].alpha != 0) { /* we'll be here exactly once */
+				jp2->color.jp2_cdef->info[i].cn = (OPJ_UINT16)i; /* cast is valid : image->numcomps [1,16384] */
+				jp2->color.jp2_cdef->info[i].typ = 1U; /* Opacity channel */
+				jp2->color.jp2_cdef->info[i].asoc = 0U; /* Apply alpha channel to the whole image */
+			} else {
+				/* Unknown channel */
+				jp2->color.jp2_cdef->info[i].cn = (OPJ_UINT16)i; /* cast is valid : image->numcomps [1,16384] */
+				jp2->color.jp2_cdef->info[i].typ = 65535U;
+				jp2->color.jp2_cdef->info[i].asoc = 65535U;
+			}
+		}
+	}
+
+	jp2->precedence = 0;	/* PRECEDENCE */
+	jp2->approx = 0;		/* APPROX */
+
+	jp2->jpip_on = parameters->jpip_on;
+
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_jp2_encode(opj_jp2_t *jp2,
+						opj_stream_private_t *stream,
+						opj_event_mgr_t * p_manager)
+{
+	return opj_j2k_encode(jp2->j2k, stream, p_manager);
+}
+
+OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2,
+                                opj_stream_private_t *cio,
+                                opj_event_mgr_t * p_manager
+                                )
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(cio != 00);
+	assert(p_manager != 00);
+
+	/* customization of the end encoding */
+	if (! opj_jp2_setup_end_header_reading(jp2, p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* write header */
+	if (! opj_jp2_exec (jp2,jp2->m_procedure_list,cio,p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	return opj_j2k_end_decompress(jp2->j2k, cio, p_manager);
+}
+
+OPJ_BOOL opj_jp2_end_compress(	opj_jp2_t *jp2,
+							    opj_stream_private_t *cio,
+							    opj_event_mgr_t * p_manager
+                                )
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(cio != 00);
+	assert(p_manager != 00);
+
+	/* customization of the end encoding */
+	if (! opj_jp2_setup_end_header_writing(jp2, p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	if (! opj_j2k_end_compress(jp2->j2k,cio,p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* write header */
+	return opj_jp2_exec(jp2,jp2->m_procedure_list,cio,p_manager);
+}
+
+static OPJ_BOOL opj_jp2_setup_end_header_writing (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+#ifdef USE_JPIP
+	if( jp2->jpip_on ) {
+		if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_iptr, p_manager)) {
+			return OPJ_FALSE;
+		}
+	}
+#endif
+	if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp2c, p_manager)) {
+		return OPJ_FALSE;
+	}
+	/* DEVELOPER CORNER, add your custom procedures */
+#ifdef USE_JPIP
+  if( jp2->jpip_on )
+	{
+		if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_cidx, p_manager)) {
+			return OPJ_FALSE;
+		}
+		if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_write_fidx, p_manager)) {
+			return OPJ_FALSE;
+		}
+	}
+#endif
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_setup_end_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+	
+	if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_read_header_procedure, p_manager)) {
+		return OPJ_FALSE;
+	}
+	/* DEVELOPER CORNER, add your custom procedures */
+	
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_default_validation (	opj_jp2_t * jp2,
+                                        opj_stream_private_t *cio,
+                                        opj_event_mgr_t * p_manager
+                                        )
+{
+	OPJ_BOOL l_is_valid = OPJ_TRUE;
+	OPJ_UINT32 i;
+
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(cio != 00);
+	assert(p_manager != 00);
+
+	/* JPEG2000 codec validation */
+
+	/* STATE checking */
+	/* make sure the state is at 0 */
+	l_is_valid &= (jp2->jp2_state == JP2_STATE_NONE);
+
+	/* make sure not reading a jp2h ???? WEIRD */
+	l_is_valid &= (jp2->jp2_img_state == JP2_IMG_STATE_NONE);
+
+	/* POINTER validation */
+	/* make sure a j2k codec is present */
+	l_is_valid &= (jp2->j2k != 00);
+
+	/* make sure a procedure list is present */
+	l_is_valid &= (jp2->m_procedure_list != 00);
+
+	/* make sure a validation list is present */
+	l_is_valid &= (jp2->m_validation_list != 00);
+
+	/* PARAMETER VALIDATION */
+	/* number of components */
+	l_is_valid &= (jp2->numcl > 0);
+	/* width */
+	l_is_valid &= (jp2->h > 0);
+	/* height */
+	l_is_valid &= (jp2->w > 0);
+	/* precision */
+	for (i = 0; i < jp2->numcomps; ++i)	{
+		l_is_valid &= ((jp2->comps[i].bpcc & 0x7FU) < 38U); /* 0 is valid, ignore sign for check */
+	}
+
+	/* METH */
+	l_is_valid &= ((jp2->meth > 0) && (jp2->meth < 3));
+
+	/* stream validation */
+	/* back and forth is needed */
+	l_is_valid &= opj_stream_has_seek(cio);
+
+	return l_is_valid;
+}
+
+static OPJ_BOOL opj_jp2_read_header_procedure(  opj_jp2_t *jp2,
+                                                opj_stream_private_t *stream,
+                                                opj_event_mgr_t * p_manager
+                                                )
+{
+	opj_jp2_box_t box;
+	OPJ_UINT32 l_nb_bytes_read;
+	const opj_jp2_header_handler_t * l_current_handler;
+	const opj_jp2_header_handler_t * l_current_handler_misplaced;
+	OPJ_UINT32 l_last_data_size = OPJ_BOX_SIZE;
+	OPJ_UINT32 l_current_data_size;
+	OPJ_BYTE * l_current_data = 00;
+
+	/* preconditions */
+	assert(stream != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	l_current_data = (OPJ_BYTE*)opj_calloc(1,l_last_data_size);
+
+	if (l_current_data == 00) {
+		opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle jpeg2000 file header\n");
+		return OPJ_FALSE;
+	}
+
+	while (opj_jp2_read_boxhdr(&box,&l_nb_bytes_read,stream,p_manager)) {
+		/* is it the codestream box ? */
+		if (box.type == JP2_JP2C) {
+			if (jp2->jp2_state & JP2_STATE_HEADER) {
+				jp2->jp2_state |= JP2_STATE_CODESTREAM;
+				opj_free(l_current_data);
+				return OPJ_TRUE;
+			}
+			else {
+				opj_event_msg(p_manager, EVT_ERROR, "bad placed jpeg codestream\n");
+				opj_free(l_current_data);
+				return OPJ_FALSE;
+			}
+		}
+		else if	(box.length == 0) {
+			opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
+			opj_free(l_current_data);
+			return OPJ_FALSE;
+		}
+		/* testcase 1851.pdf.SIGSEGV.ce9.948 */
+		else if (box.length < l_nb_bytes_read) {
+			opj_event_msg(p_manager, EVT_ERROR, "invalid box size %d (%x)\n", box.length, box.type);
+			opj_free(l_current_data);
+			return OPJ_FALSE;
+		}
+
+		l_current_handler = opj_jp2_find_handler(box.type);
+		l_current_handler_misplaced = opj_jp2_img_find_handler(box.type);
+		l_current_data_size = box.length - l_nb_bytes_read;
+
+		if ((l_current_handler != 00) || (l_current_handler_misplaced != 00)) {
+			if (l_current_handler == 00) {
+				opj_event_msg(p_manager, EVT_WARNING, "Found a misplaced '%c%c%c%c' box outside jp2h box\n", (OPJ_BYTE)(box.type>>24), (OPJ_BYTE)(box.type>>16), (OPJ_BYTE)(box.type>>8), (OPJ_BYTE)(box.type>>0));
+				if (jp2->jp2_state & JP2_STATE_HEADER) {
+					/* read anyway, we already have jp2h */
+					l_current_handler = l_current_handler_misplaced;
+				} else {
+					opj_event_msg(p_manager, EVT_WARNING, "JPEG2000 Header box not read yet, '%c%c%c%c' box will be ignored\n", (OPJ_BYTE)(box.type>>24), (OPJ_BYTE)(box.type>>16), (OPJ_BYTE)(box.type>>8), (OPJ_BYTE)(box.type>>0));
+					jp2->jp2_state |= JP2_STATE_UNKNOWN;
+					if (opj_stream_skip(stream,l_current_data_size,p_manager) != l_current_data_size) {
+							opj_event_msg(p_manager, EVT_ERROR, "Problem with skipping JPEG2000 box, stream error\n");
+							opj_free(l_current_data);
+							return OPJ_FALSE;
+					}
+					continue;
+				}
+			}
+			if ((OPJ_OFF_T)l_current_data_size > opj_stream_get_number_byte_left(stream)) {
+				/* do not even try to malloc if we can't read */
+				opj_event_msg(p_manager, EVT_ERROR, "Invalid box size %d for box '%c%c%c%c'. Need %d bytes, %d bytes remaining \n", box.length, (OPJ_BYTE)(box.type>>24), (OPJ_BYTE)(box.type>>16), (OPJ_BYTE)(box.type>>8), (OPJ_BYTE)(box.type>>0), l_current_data_size, (OPJ_UINT32)opj_stream_get_number_byte_left(stream));
+				opj_free(l_current_data);
+				return OPJ_FALSE;
+			}
+			if (l_current_data_size > l_last_data_size) {
+				OPJ_BYTE* new_current_data = (OPJ_BYTE*)opj_realloc(l_current_data,l_current_data_size);
+				if (!new_current_data) {
+					opj_free(l_current_data);
+                    opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle jpeg2000 box\n");
+					return OPJ_FALSE;
+				}
+                l_current_data = new_current_data;
+				l_last_data_size = l_current_data_size;
+			}
+
+			l_nb_bytes_read = (OPJ_UINT32)opj_stream_read_data(stream,l_current_data,l_current_data_size,p_manager);
+			if (l_nb_bytes_read != l_current_data_size) {
+				opj_event_msg(p_manager, EVT_ERROR, "Problem with reading JPEG2000 box, stream error\n");
+                opj_free(l_current_data);                
+				return OPJ_FALSE;
+			}
+
+			if (! l_current_handler->handler(jp2,l_current_data,l_current_data_size,p_manager)) {
+				opj_free(l_current_data);
+				return OPJ_FALSE;
+			}
+		}
+		else {
+			if (!(jp2->jp2_state & JP2_STATE_SIGNATURE)) {
+				opj_event_msg(p_manager, EVT_ERROR, "Malformed JP2 file format: first box must be JPEG 2000 signature box\n");
+				opj_free(l_current_data);
+				return OPJ_FALSE;
+			}
+			if (!(jp2->jp2_state & JP2_STATE_FILE_TYPE)) {
+				opj_event_msg(p_manager, EVT_ERROR, "Malformed JP2 file format: second box must be file type box\n");
+				opj_free(l_current_data);
+				return OPJ_FALSE;
+			}
+			jp2->jp2_state |= JP2_STATE_UNKNOWN;
+			if (opj_stream_skip(stream,l_current_data_size,p_manager) != l_current_data_size) {
+				opj_event_msg(p_manager, EVT_ERROR, "Problem with skipping JPEG2000 box, stream error\n");
+				opj_free(l_current_data);
+				return OPJ_FALSE;
+			}
+		}
+	}
+
+	opj_free(l_current_data);
+
+	return OPJ_TRUE;
+}
+
+/**
+ * Excutes the given procedures on the given codec.
+ *
+ * @param	p_procedure_list	the list of procedures to execute
+ * @param	jp2					the jpeg2000 file codec to execute the procedures on.
+ * @param	stream					the stream to execute the procedures on.
+ * @param	p_manager			the user manager.
+ *
+ * @return	true				if all the procedures were successfully executed.
+ */
+static OPJ_BOOL opj_jp2_exec (  opj_jp2_t * jp2,
+                                opj_procedure_list_t * p_procedure_list,
+                                opj_stream_private_t *stream,
+                                opj_event_mgr_t * p_manager
+                                )
+
+{
+	OPJ_BOOL (** l_procedure) (opj_jp2_t * jp2, opj_stream_private_t *, opj_event_mgr_t *) = 00;
+	OPJ_BOOL l_result = OPJ_TRUE;
+	OPJ_UINT32 l_nb_proc, i;
+
+	/* preconditions */
+	assert(p_procedure_list != 00);
+	assert(jp2 != 00);
+	assert(stream != 00);
+	assert(p_manager != 00);
+
+	l_nb_proc = opj_procedure_list_get_nb_procedures(p_procedure_list);
+	l_procedure = (OPJ_BOOL (**) (opj_jp2_t * jp2, opj_stream_private_t *, opj_event_mgr_t *)) opj_procedure_list_get_first_procedure(p_procedure_list);
+
+	for	(i=0;i<l_nb_proc;++i) {
+		l_result = l_result && (*l_procedure) (jp2,stream,p_manager);
+		++l_procedure;
+	}
+
+	/* and clear the procedure list at the end. */
+	opj_procedure_list_clear(p_procedure_list);
+	return l_result;
+}
+
+OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2,
+                                opj_stream_private_t *stream,
+                                opj_image_t * p_image,
+                                opj_event_mgr_t * p_manager
+                                )
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(stream != 00);
+	assert(p_manager != 00);
+
+	/* customization of the validation */
+	if (! opj_jp2_setup_encoding_validation (jp2, p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* validation of the parameters codec */
+	if (! opj_jp2_exec(jp2,jp2->m_validation_list,stream,p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* customization of the encoding */
+	if (! opj_jp2_setup_header_writing(jp2, p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* write header */
+	if (! opj_jp2_exec (jp2,jp2->m_procedure_list,stream,p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	return opj_j2k_start_compress(jp2->j2k,stream,p_image,p_manager);
+}
+
+static const opj_jp2_header_handler_t * opj_jp2_find_handler (OPJ_UINT32 p_id)
+{
+	OPJ_UINT32 i, l_handler_size = sizeof(jp2_header) / sizeof(opj_jp2_header_handler_t);
+
+	for (i=0;i<l_handler_size;++i) {
+		if (jp2_header[i].id == p_id) {
+			return &jp2_header[i];
+		}
+	}
+	return NULL;
+}
+
+/**
+ * Finds the image execution function related to the given box id.
+ *
+ * @param	p_id	the id of the handler to fetch.
+ *
+ * @return	the given handler or 00 if it could not be found.
+ */
+static const opj_jp2_header_handler_t * opj_jp2_img_find_handler (OPJ_UINT32 p_id)
+{
+	OPJ_UINT32 i, l_handler_size = sizeof(jp2_img_header) / sizeof(opj_jp2_header_handler_t);
+	for (i=0;i<l_handler_size;++i)
+	{
+		if (jp2_img_header[i].id == p_id) {
+			return &jp2_img_header[i];
+		}
+	}
+
+	return NULL;
+}
+
+/**
+ * Reads a jpeg2000 file signature box.
+ *
+ * @param	p_header_data	the data contained in the signature box.
+ * @param	jp2				the jpeg2000 file codec.
+ * @param	p_header_size	the size of the data contained in the signature box.
+ * @param	p_manager		the user event manager.
+ *
+ * @return true if the file signature box is valid.
+ */
+static OPJ_BOOL opj_jp2_read_jp(opj_jp2_t *jp2,
+                                OPJ_BYTE * p_header_data,
+                                OPJ_UINT32 p_header_size,
+                                opj_event_mgr_t * p_manager
+                                )
+
+{
+	OPJ_UINT32 l_magic_number;
+
+	/* preconditions */
+	assert(p_header_data != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	if (jp2->jp2_state != JP2_STATE_NONE) {
+		opj_event_msg(p_manager, EVT_ERROR, "The signature box must be the first box in the file.\n");
+		return OPJ_FALSE;
+	}
+
+	/* assure length of data is correct (4 -> magic number) */
+	if (p_header_size != 4) {
+		opj_event_msg(p_manager, EVT_ERROR, "Error with JP signature Box size\n");
+		return OPJ_FALSE;
+	}
+
+	/* rearrange data */
+	opj_read_bytes(p_header_data,&l_magic_number,4);
+	if (l_magic_number != 0x0d0a870a ) {
+		opj_event_msg(p_manager, EVT_ERROR, "Error with JP Signature : bad magic number\n");
+		return OPJ_FALSE;
+	}
+
+	jp2->jp2_state |= JP2_STATE_SIGNATURE;
+
+	return OPJ_TRUE;
+}
+
+/**
+ * Reads a a FTYP box - File type box
+ *
+ * @param	p_header_data	the data contained in the FTYP box.
+ * @param	jp2				the jpeg2000 file codec.
+ * @param	p_header_size	the size of the data contained in the FTYP box.
+ * @param	p_manager		the user event manager.
+ *
+ * @return true if the FTYP box is valid.
+ */
+static OPJ_BOOL opj_jp2_read_ftyp(	opj_jp2_t *jp2,
+									OPJ_BYTE * p_header_data,
+									OPJ_UINT32 p_header_size,
+									opj_event_mgr_t * p_manager
+                                    )
+{
+	OPJ_UINT32 i, l_remaining_bytes;
+
+	/* preconditions */
+	assert(p_header_data != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	if (jp2->jp2_state != JP2_STATE_SIGNATURE) {
+		opj_event_msg(p_manager, EVT_ERROR, "The ftyp box must be the second box in the file.\n");
+		return OPJ_FALSE;
+	}
+
+	/* assure length of data is correct */
+	if (p_header_size < 8) {
+		opj_event_msg(p_manager, EVT_ERROR, "Error with FTYP signature Box size\n");
+		return OPJ_FALSE;
+	}
+
+	opj_read_bytes(p_header_data,&jp2->brand,4);		/* BR */
+	p_header_data += 4;
+
+	opj_read_bytes(p_header_data,&jp2->minversion,4);		/* MinV */
+	p_header_data += 4;
+
+	l_remaining_bytes = p_header_size - 8;
+
+	/* the number of remaining bytes should be a multiple of 4 */
+	if ((l_remaining_bytes & 0x3) != 0) {
+		opj_event_msg(p_manager, EVT_ERROR, "Error with FTYP signature Box size\n");
+		return OPJ_FALSE;
+	}
+
+	/* div by 4 */
+	jp2->numcl = l_remaining_bytes >> 2;
+	if (jp2->numcl) {
+		jp2->cl = (OPJ_UINT32 *) opj_calloc(jp2->numcl, sizeof(OPJ_UINT32));
+		if (jp2->cl == 00) {
+			opj_event_msg(p_manager, EVT_ERROR, "Not enough memory with FTYP Box\n");
+			return OPJ_FALSE;
+		}
+	}
+
+	for (i = 0; i < jp2->numcl; ++i)
+	{
+		opj_read_bytes(p_header_data,&jp2->cl[i],4);		/* CLi */
+		p_header_data += 4;
+	}
+
+	jp2->jp2_state |= JP2_STATE_FILE_TYPE;
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_skip_jp2c(	opj_jp2_t *jp2,
+					    	opj_stream_private_t *stream,
+					    	opj_event_mgr_t * p_manager )
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(stream != 00);
+	assert(p_manager != 00);
+
+	jp2->j2k_codestream_offset = opj_stream_tell(stream);
+
+	if (opj_stream_skip(stream,8,p_manager) != 8) {
+		return OPJ_FALSE;
+	}
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jpip_skip_iptr(	opj_jp2_t *jp2,
+  opj_stream_private_t *stream,
+  opj_event_mgr_t * p_manager )
+{
+  /* preconditions */
+  assert(jp2 != 00);
+  assert(stream != 00);
+  assert(p_manager != 00);
+
+  jp2->jpip_iptr_offset = opj_stream_tell(stream);
+
+  if (opj_stream_skip(stream,24,p_manager) != 24) {
+    return OPJ_FALSE;
+  }
+
+  return OPJ_TRUE;
+}
+
+/**
+ * Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
+ *
+ * @param	p_header_data	the data contained in the file header box.
+ * @param	jp2				the jpeg2000 file codec.
+ * @param	p_header_size	the size of the data contained in the file header box.
+ * @param	p_manager		the user event manager.
+ *
+ * @return true if the JP2 Header box was successfully recognized.
+*/
+static OPJ_BOOL opj_jp2_read_jp2h(  opj_jp2_t *jp2,
+                                    OPJ_BYTE *p_header_data,
+                                    OPJ_UINT32 p_header_size,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+	OPJ_UINT32 l_box_size=0, l_current_data_size = 0;
+	opj_jp2_box_t box;
+	const opj_jp2_header_handler_t * l_current_handler;
+	OPJ_BOOL l_has_ihdr = 0;
+
+	/* preconditions */
+	assert(p_header_data != 00);
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	/* make sure the box is well placed */
+	if ((jp2->jp2_state & JP2_STATE_FILE_TYPE) != JP2_STATE_FILE_TYPE ) {
+		opj_event_msg(p_manager, EVT_ERROR, "The  box must be the first box in the file.\n");
+		return OPJ_FALSE;
+	}
+
+	jp2->jp2_img_state = JP2_IMG_STATE_NONE;
+
+	/* iterate while remaining data */
+	while (p_header_size > 0) {
+
+		if (! opj_jp2_read_boxhdr_char(&box,p_header_data,&l_box_size,p_header_size, p_manager)) {
+			opj_event_msg(p_manager, EVT_ERROR, "Stream error while reading JP2 Header box\n");
+			return OPJ_FALSE;
+		}
+
+		if (box.length > p_header_size) {
+			opj_event_msg(p_manager, EVT_ERROR, "Stream error while reading JP2 Header box: box length is inconsistent.\n");
+			return OPJ_FALSE;
+		}
+
+		l_current_handler = opj_jp2_img_find_handler(box.type);
+		l_current_data_size = box.length - l_box_size;
+		p_header_data += l_box_size;
+
+		if (l_current_handler != 00) {
+			if (! l_current_handler->handler(jp2,p_header_data,l_current_data_size,p_manager)) {
+				return OPJ_FALSE;
+			}
+		}
+		else {
+			jp2->jp2_img_state |= JP2_IMG_STATE_UNKNOWN;
+		}
+
+		if (box.type == JP2_IHDR) {
+			l_has_ihdr = 1;
+		}
+
+		p_header_data += l_current_data_size;
+		p_header_size -= box.length;
+	}
+
+	if (l_has_ihdr == 0) {
+		opj_event_msg(p_manager, EVT_ERROR, "Stream error while reading JP2 Header box: no 'ihdr' box.\n");
+		return OPJ_FALSE;
+	}
+
+	jp2->jp2_state |= JP2_STATE_HEADER;
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_read_boxhdr_char(   opj_jp2_box_t *box,
+                                     OPJ_BYTE * p_data,
+                                     OPJ_UINT32 * p_number_bytes_read,
+                                     OPJ_UINT32 p_box_max_size,
+                                     opj_event_mgr_t * p_manager
+                                     )
+{
+	OPJ_UINT32 l_value;
+
+	/* preconditions */
+	assert(p_data != 00);
+	assert(box != 00);
+	assert(p_number_bytes_read != 00);
+	assert(p_manager != 00);
+
+	if (p_box_max_size < 8) {
+		opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of less than 8 bytes\n");
+		return OPJ_FALSE;
+	}
+
+	/* process read data */
+	opj_read_bytes(p_data, &l_value, 4);
+	p_data += 4;
+	box->length = (OPJ_UINT32)(l_value);
+
+	opj_read_bytes(p_data, &l_value, 4);
+	p_data += 4;
+	box->type = (OPJ_UINT32)(l_value);
+
+	*p_number_bytes_read = 8;
+
+	/* do we have a "special very large box ?" */
+	/* read then the XLBox */
+	if (box->length == 1) {
+		OPJ_UINT32 l_xl_part_size;
+
+		if (p_box_max_size < 16) {
+			opj_event_msg(p_manager, EVT_ERROR, "Cannot handle XL box of less than 16 bytes\n");
+			return OPJ_FALSE;
+		}
+
+		opj_read_bytes(p_data,&l_xl_part_size, 4);
+		p_data += 4;
+		*p_number_bytes_read += 4;
+
+		if (l_xl_part_size != 0) {
+			opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n");
+			return OPJ_FALSE;
+		}
+
+		opj_read_bytes(p_data, &l_value, 4);
+		*p_number_bytes_read += 4;
+		box->length = (OPJ_UINT32)(l_value);
+
+		if (box->length == 0) {
+			opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
+			return OPJ_FALSE;
+		}
+	}
+	else if (box->length == 0) {
+		opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
+		return OPJ_FALSE;
+	}
+	if (box->length < *p_number_bytes_read) {
+		opj_event_msg(p_manager, EVT_ERROR, "Box length is inconsistent.\n");
+		return OPJ_FALSE;
+	}
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_jp2_read_header(	opj_stream_private_t *p_stream,
+                                opj_jp2_t *jp2,
+                                opj_image_t ** p_image,
+                                opj_event_mgr_t * p_manager
+                                )
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_stream != 00);
+	assert(p_manager != 00);
+
+	/* customization of the validation */
+	if (! opj_jp2_setup_decoding_validation (jp2, p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* customization of the encoding */
+	if (! opj_jp2_setup_header_reading(jp2, p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* validation of the parameters codec */
+	if (! opj_jp2_exec(jp2,jp2->m_validation_list,p_stream,p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* read header */
+	if (! opj_jp2_exec (jp2,jp2->m_procedure_list,p_stream,p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	return opj_j2k_read_header(	p_stream,
+							jp2->j2k,
+							p_image,
+							p_manager);
+}
+
+static OPJ_BOOL opj_jp2_setup_encoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	if (! opj_procedure_list_add_procedure(jp2->m_validation_list, (opj_procedure)opj_jp2_default_validation, p_manager)) {
+		return OPJ_FALSE;
+	}
+	/* DEVELOPER CORNER, add your custom validation procedure */
+	
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_setup_decoding_validation (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+	
+	/* DEVELOPER CORNER, add your custom validation procedure */
+	
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_setup_header_writing (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp, p_manager)) {
+		return OPJ_FALSE;
+	}
+	if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_ftyp, p_manager)) {
+		return OPJ_FALSE;
+	}
+	if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_write_jp2h, p_manager)) {
+		return OPJ_FALSE;
+	}
+	if( jp2->jpip_on ) {
+		if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jpip_skip_iptr, p_manager)) {
+			return OPJ_FALSE;
+		}
+	}
+	if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_skip_jp2c,p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* DEVELOPER CORNER, insert your custom procedures */
+
+	return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jp2_setup_header_reading (opj_jp2_t *jp2, opj_event_mgr_t * p_manager)
+{
+	/* preconditions */
+	assert(jp2 != 00);
+	assert(p_manager != 00);
+
+	if (! opj_procedure_list_add_procedure(jp2->m_procedure_list,(opj_procedure)opj_jp2_read_header_procedure, p_manager)) {
+		return OPJ_FALSE;
+	}
+	
+	/* DEVELOPER CORNER, add your custom procedures */
+	
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_jp2_read_tile_header ( opj_jp2_t * p_jp2,
+                                    OPJ_UINT32 * p_tile_index,
+                                    OPJ_UINT32 * p_data_size,
+                                    OPJ_INT32 * p_tile_x0,
+                                    OPJ_INT32 * p_tile_y0,
+                                    OPJ_INT32 * p_tile_x1,
+                                    OPJ_INT32 * p_tile_y1,
+                                    OPJ_UINT32 * p_nb_comps,
+                                    OPJ_BOOL * p_go_on,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager
+                                    )
+{
+	return opj_j2k_read_tile_header(p_jp2->j2k,
+								p_tile_index,
+								p_data_size,
+								p_tile_x0, p_tile_y0,
+								p_tile_x1, p_tile_y1,
+								p_nb_comps,
+								p_go_on,
+								p_stream,
+								p_manager);
+}
+
+OPJ_BOOL opj_jp2_write_tile (	opj_jp2_t *p_jp2,
+					 	 	    OPJ_UINT32 p_tile_index,
+					 	 	    OPJ_BYTE * p_data,
+					 	 	    OPJ_UINT32 p_data_size,
+					 	 	    opj_stream_private_t *p_stream,
+					 	 	    opj_event_mgr_t * p_manager
+                                )
+
+{
+	return opj_j2k_write_tile (p_jp2->j2k,p_tile_index,p_data,p_data_size,p_stream,p_manager);
+}
+
+OPJ_BOOL opj_jp2_decode_tile (  opj_jp2_t * p_jp2,
+                                OPJ_UINT32 p_tile_index,
+                                OPJ_BYTE * p_data,
+                                OPJ_UINT32 p_data_size,
+                                opj_stream_private_t *p_stream,
+                                opj_event_mgr_t * p_manager
+                                )
+{
+	return opj_j2k_decode_tile (p_jp2->j2k,p_tile_index,p_data,p_data_size,p_stream,p_manager);
+}
+
+void opj_jp2_destroy(opj_jp2_t *jp2)
+{
+	if (jp2) {
+		/* destroy the J2K codec */
+		opj_j2k_destroy(jp2->j2k);
+		jp2->j2k = 00;
+
+		if (jp2->comps) {
+			opj_free(jp2->comps);
+			jp2->comps = 00;
+		}
+
+		if (jp2->cl) {
+			opj_free(jp2->cl);
+			jp2->cl = 00;
+		}
+
+		if (jp2->color.icc_profile_buf) {
+			opj_free(jp2->color.icc_profile_buf);
+			jp2->color.icc_profile_buf = 00;
+		}
+
+		if (jp2->color.jp2_cdef) {
+			if (jp2->color.jp2_cdef->info) {
+				opj_free(jp2->color.jp2_cdef->info);
+				jp2->color.jp2_cdef->info = NULL;
+			}
+
+			opj_free(jp2->color.jp2_cdef);
+			jp2->color.jp2_cdef = 00;
+		}
+
+		if (jp2->color.jp2_pclr) {
+			if (jp2->color.jp2_pclr->cmap) {
+				opj_free(jp2->color.jp2_pclr->cmap);
+				jp2->color.jp2_pclr->cmap = NULL;
+			}
+			if (jp2->color.jp2_pclr->channel_sign) {
+				opj_free(jp2->color.jp2_pclr->channel_sign);
+				jp2->color.jp2_pclr->channel_sign = NULL;
+			}
+			if (jp2->color.jp2_pclr->channel_size) {
+				opj_free(jp2->color.jp2_pclr->channel_size);
+				jp2->color.jp2_pclr->channel_size = NULL;
+			}
+			if (jp2->color.jp2_pclr->entries) {
+				opj_free(jp2->color.jp2_pclr->entries);
+				jp2->color.jp2_pclr->entries = NULL;
+			}
+
+			opj_free(jp2->color.jp2_pclr);
+			jp2->color.jp2_pclr = 00;
+		}
+
+		if (jp2->m_validation_list) {
+			opj_procedure_list_destroy(jp2->m_validation_list);
+			jp2->m_validation_list = 00;
+		}
+
+		if (jp2->m_procedure_list) {
+			opj_procedure_list_destroy(jp2->m_procedure_list);
+			jp2->m_procedure_list = 00;
+		}
+
+		opj_free(jp2);
+	}
+}
+
+OPJ_BOOL opj_jp2_set_decode_area(	opj_jp2_t *p_jp2,
+								    opj_image_t* p_image,
+								    OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
+								    OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
+								    opj_event_mgr_t * p_manager
+                                    )
+{
+	return opj_j2k_set_decode_area(p_jp2->j2k, p_image, p_start_x, p_start_y, p_end_x, p_end_y, p_manager);
+}
+
+OPJ_BOOL opj_jp2_get_tile(	opj_jp2_t *p_jp2,
+                            opj_stream_private_t *p_stream,
+                            opj_image_t* p_image,
+                            opj_event_mgr_t * p_manager,
+                            OPJ_UINT32 tile_index
+                            )
+{
+	if (!p_image)
+		return OPJ_FALSE;
+
+	opj_event_msg(p_manager, EVT_WARNING, "JP2 box which are after the codestream will not be read by this function.\n");
+
+	if (! opj_j2k_get_tile(p_jp2->j2k, p_stream, p_image, p_manager, tile_index) ){
+		opj_event_msg(p_manager, EVT_ERROR, "Failed to decode the codestream in the JP2 file\n");
+		return OPJ_FALSE;
+	}
+
+	if (!opj_jp2_check_color(p_image, &(p_jp2->color), p_manager)) {
+		return OPJ_FALSE;
+	}
+
+	/* Set Image Color Space */
+	if (p_jp2->enumcs == 16)
+		p_image->color_space = OPJ_CLRSPC_SRGB;
+	else if (p_jp2->enumcs == 17)
+		p_image->color_space = OPJ_CLRSPC_GRAY;
+	else if (p_jp2->enumcs == 18)
+		p_image->color_space = OPJ_CLRSPC_SYCC;
+	else if (p_jp2->enumcs == 24)
+		p_image->color_space = OPJ_CLRSPC_EYCC;
+	else if (p_jp2->enumcs == 12)
+		p_image->color_space = OPJ_CLRSPC_CMYK;
+	else
+		p_image->color_space = OPJ_CLRSPC_UNKNOWN;
+
+	if(p_jp2->color.jp2_pclr) {
+		/* Part 1, I.5.3.4: Either both or none : */
+		if( !p_jp2->color.jp2_pclr->cmap)
+			opj_jp2_free_pclr(&(p_jp2->color));
+		else
+			opj_jp2_apply_pclr(p_image, &(p_jp2->color));
+	}
+	
+	/* Apply the color space if needed */
+	if(p_jp2->color.jp2_cdef) {
+		opj_jp2_apply_cdef(p_image, &(p_jp2->color), p_manager);
+	}
+
+	if(p_jp2->color.icc_profile_buf) {
+		p_image->icc_profile_buf = p_jp2->color.icc_profile_buf;
+		p_image->icc_profile_len = p_jp2->color.icc_profile_len;
+		p_jp2->color.icc_profile_buf = NULL;
+	}
+
+	return OPJ_TRUE;
+}
+
+/* ----------------------------------------------------------------------- */
+/* JP2 encoder interface                                             */
+/* ----------------------------------------------------------------------- */
+
+opj_jp2_t* opj_jp2_create(OPJ_BOOL p_is_decoder)
+{
+	opj_jp2_t *jp2 = (opj_jp2_t*)opj_calloc(1,sizeof(opj_jp2_t));
+	if (jp2) {
+
+		/* create the J2K codec */
+		if (! p_is_decoder) {
+			jp2->j2k = opj_j2k_create_compress();
+		}
+		else {
+			jp2->j2k = opj_j2k_create_decompress();
+		}
+
+		if (jp2->j2k == 00) {
+			opj_jp2_destroy(jp2);
+			return 00;
+		}
+
+		/* Color structure */
+		jp2->color.icc_profile_buf = NULL;
+		jp2->color.icc_profile_len = 0;
+		jp2->color.jp2_cdef = NULL;
+		jp2->color.jp2_pclr = NULL;
+		jp2->color.jp2_has_colr = 0;
+
+		/* validation list creation */
+		jp2->m_validation_list = opj_procedure_list_create();
+		if (! jp2->m_validation_list) {
+			opj_jp2_destroy(jp2);
+			return 00;
+		}
+
+		/* execution list creation */
+		jp2->m_procedure_list = opj_procedure_list_create();
+		if (! jp2->m_procedure_list) {
+			opj_jp2_destroy(jp2);
+			return 00;
+		}
+	}
+
+	return jp2;
+}
+
+void jp2_dump(opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream)
+{
+	/* preconditions */
+	assert(p_jp2 != 00);
+
+	j2k_dump(p_jp2->j2k,
+					flag,
+					out_stream);
+}
+
+opj_codestream_index_t* jp2_get_cstr_index(opj_jp2_t* p_jp2)
+{
+	return j2k_get_cstr_index(p_jp2->j2k);
+}
+
+opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_t* p_jp2)
+{
+	return j2k_get_cstr_info(p_jp2->j2k);
+}
+
+OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2,
+                                               OPJ_UINT32 res_factor,
+                                               opj_event_mgr_t * p_manager)
+{
+	return opj_j2k_set_decoded_resolution_factor(p_jp2->j2k, res_factor, p_manager);
+}
+
+/* JPIP specific */
+
+#ifdef USE_JPIP
+static OPJ_BOOL opj_jpip_write_iptr(opj_jp2_t *jp2,
+  opj_stream_private_t *cio,
+  opj_event_mgr_t * p_manager )
+{
+  OPJ_OFF_T j2k_codestream_exit;
+  OPJ_BYTE l_data_header [24];
+
+  /* preconditions */
+  assert(jp2 != 00);
+  assert(cio != 00);
+  assert(p_manager != 00);
+  assert(opj_stream_has_seek(cio));
+
+  j2k_codestream_exit = opj_stream_tell(cio);
+  opj_write_bytes(l_data_header, 24, 4); /* size of iptr */
+  opj_write_bytes(l_data_header + 4,JPIP_IPTR,4);									   /* IPTR */
+#if 0
+  opj_write_bytes(l_data_header + 4 + 4, 0, 8); /* offset */
+  opj_write_bytes(l_data_header + 8 + 8, 0, 8); /* length */
+#else
+  opj_write_double(l_data_header + 4 + 4, 0); /* offset */
+  opj_write_double(l_data_header + 8 + 8, 0); /* length */
+#endif
+
+  if (! opj_stream_seek(cio,jp2->jpip_iptr_offset,p_manager)) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  if (opj_stream_write_data(cio,l_data_header,24,p_manager) != 24) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  if (! opj_stream_seek(cio,j2k_codestream_exit,p_manager)) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jpip_write_fidx(opj_jp2_t *jp2,
+  opj_stream_private_t *cio,
+  opj_event_mgr_t * p_manager )
+{
+  OPJ_OFF_T j2k_codestream_exit;
+  OPJ_BYTE l_data_header [24];
+
+  /* preconditions */
+  assert(jp2 != 00);
+  assert(cio != 00);
+  assert(p_manager != 00);
+  assert(opj_stream_has_seek(cio));
+
+  opj_write_bytes(l_data_header, 24, 4); /* size of iptr */
+  opj_write_bytes(l_data_header + 4,JPIP_FIDX,4);									   /* IPTR */
+  opj_write_double(l_data_header + 4 + 4, 0); /* offset */
+  opj_write_double(l_data_header + 8 + 8, 0); /* length */
+
+  if (opj_stream_write_data(cio,l_data_header,24,p_manager) != 24) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  j2k_codestream_exit = opj_stream_tell(cio);
+  if (! opj_stream_seek(cio,j2k_codestream_exit,p_manager)) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_jpip_write_cidx(opj_jp2_t *jp2,
+  opj_stream_private_t *cio,
+  opj_event_mgr_t * p_manager )
+{
+  OPJ_OFF_T j2k_codestream_exit;
+  OPJ_BYTE l_data_header [24];
+
+  /* preconditions */
+  assert(jp2 != 00);
+  assert(cio != 00);
+  assert(p_manager != 00);
+  assert(opj_stream_has_seek(cio));
+
+  j2k_codestream_exit = opj_stream_tell(cio);
+  opj_write_bytes(l_data_header, 24, 4); /* size of iptr */
+  opj_write_bytes(l_data_header + 4,JPIP_CIDX,4);									   /* IPTR */
+#if 0
+  opj_write_bytes(l_data_header + 4 + 4, 0, 8); /* offset */
+  opj_write_bytes(l_data_header + 8 + 8, 0, 8); /* length */
+#else
+  opj_write_double(l_data_header + 4 + 4, 0); /* offset */
+  opj_write_double(l_data_header + 8 + 8, 0); /* length */
+#endif
+
+  if (! opj_stream_seek(cio,j2k_codestream_exit,p_manager)) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  if (opj_stream_write_data(cio,l_data_header,24,p_manager) != 24) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  j2k_codestream_exit = opj_stream_tell(cio);
+  if (! opj_stream_seek(cio,j2k_codestream_exit,p_manager)) {
+    opj_event_msg(p_manager, EVT_ERROR, "Failed to seek in the stream.\n");
+    return OPJ_FALSE;
+  }
+
+  return OPJ_TRUE;
+}
+
+#if 0
+static void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_stream_private_t *cio,
+  opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [8];
+  OPJ_OFF_T len, lenp;
+
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip(cio, 4, p_manager);         /* L [at the end] */
+  opj_write_bytes(l_data_header,JPIP_PRXY,4); /* IPTR           */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+  opj_write_bytes( l_data_header, offset_jp2c, 8); /* OOFF           */
+  opj_stream_write_data(cio,l_data_header,8,p_manager);
+  opj_write_bytes( l_data_header, length_jp2c, 4); /* OBH part 1     */
+  opj_write_bytes( l_data_header+4, JP2_JP2C, 4);  /* OBH part 2     */
+  opj_stream_write_data(cio,l_data_header,8,p_manager);
+
+  opj_write_bytes( l_data_header, 1, 1);/* NI             */
+  opj_stream_write_data(cio,l_data_header,1,p_manager);
+
+  opj_write_bytes( l_data_header, offset_idx, 8);  /* IOFF           */
+  opj_stream_write_data(cio,l_data_header,8,p_manager);
+  opj_write_bytes( l_data_header, length_idx, 4);  /* IBH part 1     */
+  opj_write_bytes( l_data_header+4, JPIP_CIDX, 4);   /* IBH part 2     */
+  opj_stream_write_data(cio,l_data_header,8,p_manager);
+
+  len = opj_stream_tell(cio)-lenp;
+  opj_stream_skip(cio, lenp, p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L              */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+}
+#endif
+
+
+#if 0
+static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_stream_private_t *cio,
+  opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [4];
+  OPJ_OFF_T len, lenp;
+
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip(cio, 4, p_manager);
+  opj_write_bytes(l_data_header,JPIP_FIDX,4); /* FIDX */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+  write_prxy( offset_jp2c, length_jp2c, offset_idx, length_idx, cio,p_manager);
+
+  len = opj_stream_tell(cio)-lenp;
+  opj_stream_skip(cio, lenp, p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L              */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+
+  return len;
+}
+#endif
+#endif /* USE_JPIP */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.h
new file mode 100644
index 0000000..9413883
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/jp2.h
@@ -0,0 +1,483 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __JP2_H
+#define __JP2_H
+/**
+ at file jp2.h
+ at brief The JPEG-2000 file format Reader/Writer (JP2)
+
+*/
+
+/** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */
+/*@{*/
+
+/*#define JPIP_JPIP 0x6a706970*/
+
+#define     JP2_JP   0x6a502020    /**< JPEG 2000 signature box */
+#define     JP2_FTYP 0x66747970    /**< File type box */
+#define     JP2_JP2H 0x6a703268    /**< JP2 header box (super-box) */
+#define     JP2_IHDR 0x69686472    /**< Image header box */
+#define     JP2_COLR 0x636f6c72    /**< Colour specification box */
+#define     JP2_JP2C 0x6a703263    /**< Contiguous codestream box */
+#define     JP2_URL  0x75726c20    /**< Data entry URL box */
+#define     JP2_PCLR 0x70636c72    /**< Palette box */
+#define     JP2_CMAP 0x636d6170    /**< Component Mapping box */
+#define     JP2_CDEF 0x63646566    /**< Channel Definition box */
+#define     JP2_DTBL 0x6474626c    /**< Data Reference box */
+#define     JP2_BPCC 0x62706363    /**< Bits per component box */
+#define     JP2_JP2  0x6a703220    /**< File type fields */
+
+/* For the future */
+/* #define JP2_RES 0x72657320 */  /**< Resolution box (super-box) */
+/* #define JP2_JP2I 0x6a703269 */  /**< Intellectual property box */
+/* #define JP2_XML  0x786d6c20 */  /**< XML box */
+/* #define JP2_UUID 0x75756994 */  /**< UUID box */
+/* #define JP2_UINF 0x75696e66 */  /**< UUID info box (super-box) */
+/* #define JP2_ULST 0x756c7374 */  /**< UUID list box */
+
+/* ----------------------------------------------------------------------- */
+
+typedef enum
+{
+  JP2_STATE_NONE            = 0x0,
+  JP2_STATE_SIGNATURE       = 0x1,
+  JP2_STATE_FILE_TYPE       = 0x2,
+  JP2_STATE_HEADER          = 0x4,
+  JP2_STATE_CODESTREAM      = 0x8,
+  JP2_STATE_END_CODESTREAM  = 0x10,
+  JP2_STATE_UNKNOWN         = 0x7fffffff /* ISO C restricts enumerator values to range of 'int' */
+}
+JP2_STATE;
+
+typedef enum
+{
+  JP2_IMG_STATE_NONE        = 0x0,
+  JP2_IMG_STATE_UNKNOWN     = 0x7fffffff
+}
+JP2_IMG_STATE;
+
+/** 
+Channel description: channel index, type, association
+*/
+typedef struct opj_jp2_cdef_info
+{
+    OPJ_UINT16 cn, typ, asoc;
+} opj_jp2_cdef_info_t;
+
+/** 
+Channel descriptions and number of descriptions
+*/
+typedef struct opj_jp2_cdef
+{
+    opj_jp2_cdef_info_t *info;
+    OPJ_UINT16 n;
+} opj_jp2_cdef_t;
+
+/** 
+Component mappings: channel index, mapping type, palette index
+*/
+typedef struct opj_jp2_cmap_comp
+{
+    OPJ_UINT16 cmp;
+    OPJ_BYTE mtyp, pcol;
+} opj_jp2_cmap_comp_t;
+
+/** 
+Palette data: table entries, palette columns
+*/
+typedef struct opj_jp2_pclr
+{
+    OPJ_UINT32 *entries;
+    OPJ_BYTE *channel_sign;
+    OPJ_BYTE *channel_size;
+    opj_jp2_cmap_comp_t *cmap;
+    OPJ_UINT16 nr_entries;
+    OPJ_BYTE nr_channels;
+} opj_jp2_pclr_t;
+
+/** 
+Collector for ICC profile, palette, component mapping, channel description 
+*/
+typedef struct opj_jp2_color
+{
+    OPJ_BYTE *icc_profile_buf;
+    OPJ_UINT32 icc_profile_len;
+
+    opj_jp2_cdef_t *jp2_cdef;
+    opj_jp2_pclr_t *jp2_pclr;
+    OPJ_BYTE jp2_has_colr;
+} opj_jp2_color_t;
+
+/** 
+JP2 component
+*/
+typedef struct opj_jp2_comps {
+  OPJ_UINT32 depth;      
+  OPJ_UINT32 sgnd;       
+  OPJ_UINT32 bpcc;
+} opj_jp2_comps_t;
+
+/**
+JPEG-2000 file format reader/writer
+*/
+typedef struct opj_jp2
+{
+  /** handle to the J2K codec  */
+  opj_j2k_t *j2k;
+  /** list of validation procedures */
+  struct opj_procedure_list * m_validation_list;
+  /** list of execution procedures */
+  struct opj_procedure_list * m_procedure_list;
+
+  /* width of image */
+  OPJ_UINT32 w;
+  /* height of image */
+  OPJ_UINT32 h;
+  /* number of components in the image */
+  OPJ_UINT32 numcomps;
+  OPJ_UINT32 bpc;
+  OPJ_UINT32 C;
+  OPJ_UINT32 UnkC;
+  OPJ_UINT32 IPR;
+  OPJ_UINT32 meth;
+  OPJ_UINT32 approx;
+  OPJ_UINT32 enumcs;
+  OPJ_UINT32 precedence;
+  OPJ_UINT32 brand;
+  OPJ_UINT32 minversion;
+  OPJ_UINT32 numcl;
+  OPJ_UINT32 *cl;
+  opj_jp2_comps_t *comps;
+  /* FIXME: The following two variables are used to save offset
+    as we write out a JP2 file to disk. This mecanism is not flexible
+    as codec writers will need to extand those fields as new part
+    of the standard are implemented.
+  */
+    OPJ_OFF_T j2k_codestream_offset;
+    OPJ_OFF_T jpip_iptr_offset;
+	OPJ_BOOL jpip_on;
+  OPJ_UINT32 jp2_state;
+  OPJ_UINT32 jp2_img_state;
+
+  opj_jp2_color_t color;
+    
+    OPJ_BOOL ignore_pclr_cmap_cdef;
+}
+opj_jp2_t;
+
+/**
+JP2 Box
+*/
+typedef struct opj_jp2_box {
+    OPJ_UINT32 length;
+    OPJ_UINT32 type;
+    OPJ_INT32 init_pos;
+} opj_jp2_box_t;
+
+typedef struct opj_jp2_header_handler
+{
+  /* marker value */
+  OPJ_UINT32 id;
+  /* action linked to the marker */
+  OPJ_BOOL (*handler) (     opj_jp2_t *jp2, 
+                            OPJ_BYTE *p_header_data, 
+                            OPJ_UINT32 p_header_size, 
+                            opj_event_mgr_t * p_manager);
+}
+opj_jp2_header_handler_t;
+
+
+typedef struct opj_jp2_img_header_writer_handler 
+{
+  /* action to perform */
+  OPJ_BYTE*   (*handler) (opj_jp2_t *jp2, OPJ_UINT32 * p_data_size);
+  /* result of the action : data */
+  OPJ_BYTE*   m_data;
+  /* size of data */
+  OPJ_UINT32  m_size;
+} 
+opj_jp2_img_header_writer_handler_t;
+
+/** @name Exported functions */
+/*@{*/
+/* ----------------------------------------------------------------------- */
+
+/**
+Setup the decoder decoding parameters using user parameters.
+Decoding parameters are returned in jp2->j2k->cp.
+ at param jp2 JP2 decompressor handle
+ at param parameters decompression parameters
+*/
+void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
+
+/**
+ * Decode an image from a JPEG-2000 file stream
+ * @param jp2 JP2 decompressor handle
+ * @param p_stream  FIXME DOC
+ * @param p_image   FIXME DOC
+ * @param p_manager FIXME DOC
+ *
+ * @return Returns a decoded image if successful, returns NULL otherwise
+*/
+OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
+                        opj_stream_private_t *p_stream,
+            opj_image_t* p_image,
+            opj_event_mgr_t * p_manager);
+
+/**
+ * Setup the encoder parameters using the current image and using user parameters. 
+ * Coding parameters are returned in jp2->j2k->cp. 
+ *
+ * @param jp2 JP2 compressor handle
+ * @param parameters compression parameters
+ * @param image input filled image
+ * @param p_manager  FIXME DOC
+ * @return OPJ_TRUE if successful, OPJ_FALSE otherwise
+*/
+OPJ_BOOL opj_jp2_setup_encoder(  opj_jp2_t *jp2, 
+                            opj_cparameters_t *parameters, 
+                            opj_image_t *image, 
+                            opj_event_mgr_t * p_manager);
+
+/**
+Encode an image into a JPEG-2000 file stream
+ at param jp2      JP2 compressor handle
+ at param stream    Output buffer stream
+ at param p_manager  event manager
+ at return Returns true if successful, returns false otherwise
+*/
+OPJ_BOOL opj_jp2_encode(  opj_jp2_t *jp2, 
+              opj_stream_private_t *stream, 
+              opj_event_mgr_t * p_manager);
+
+
+/**
+ * Starts a compression scheme, i.e. validates the codec parameters, writes the header.
+ *
+ * @param  jp2    the jpeg2000 file codec.
+ * @param  stream    the stream object.
+ * @param  p_image   FIXME DOC
+ * @param p_manager FIXME DOC
+ *
+ * @return true if the codec is valid.
+ */
+OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2,
+                                opj_stream_private_t *stream,
+                                opj_image_t * p_image,
+                                opj_event_mgr_t * p_manager);
+
+
+/**
+ * Ends the compression procedures and possibiliy add data to be read after the
+ * codestream.
+ */
+OPJ_BOOL opj_jp2_end_compress(  opj_jp2_t *jp2,
+                  opj_stream_private_t *cio,
+                  opj_event_mgr_t * p_manager);
+
+/* ----------------------------------------------------------------------- */
+
+/**
+ * Ends the decompression procedures and possibiliy add data to be read after the
+ * codestream.
+ */
+OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2, 
+                                opj_stream_private_t *cio,
+                                opj_event_mgr_t * p_manager);
+
+/**
+ * Reads a jpeg2000 file header structure.
+ *
+ * @param p_stream the stream to read data from.
+ * @param jp2 the jpeg2000 file header structure.
+ * @param p_image   FIXME DOC
+ * @param p_manager the user event manager.
+ *
+ * @return true if the box is valid.
+ */
+OPJ_BOOL opj_jp2_read_header(  opj_stream_private_t *p_stream,
+                                opj_jp2_t *jp2,
+                                opj_image_t ** p_image,
+                                opj_event_mgr_t * p_manager );
+
+/**
+ * Reads a tile header.
+ * @param  p_jp2         the jpeg2000 codec.
+ * @param  p_tile_index  FIXME DOC
+ * @param  p_data_size   FIXME DOC
+ * @param  p_tile_x0     FIXME DOC
+ * @param  p_tile_y0     FIXME DOC
+ * @param  p_tile_x1     FIXME DOC
+ * @param  p_tile_y1     FIXME DOC
+ * @param  p_nb_comps    FIXME DOC
+ * @param  p_go_on       FIXME DOC
+ * @param  p_stream      the stream to write data to.
+ * @param  p_manager     the user event manager.
+ */
+OPJ_BOOL opj_jp2_read_tile_header ( opj_jp2_t * p_jp2,
+                                    OPJ_UINT32 * p_tile_index,
+                                    OPJ_UINT32 * p_data_size,
+                                    OPJ_INT32 * p_tile_x0,
+                                    OPJ_INT32 * p_tile_y0,
+                                    OPJ_INT32 * p_tile_x1,
+                                    OPJ_INT32 * p_tile_y1,
+                                    OPJ_UINT32 * p_nb_comps,
+                                    OPJ_BOOL * p_go_on,
+                                    opj_stream_private_t *p_stream,
+                                    opj_event_mgr_t * p_manager );
+
+/**
+ * Writes a tile.
+ *
+ * @param  p_jp2    the jpeg2000 codec.
+ * @param p_tile_index  FIXME DOC
+ * @param p_data        FIXME DOC
+ * @param p_data_size   FIXME DOC
+ * @param  p_stream      the stream to write data to.
+ * @param  p_manager  the user event manager.
+ */
+OPJ_BOOL opj_jp2_write_tile (  opj_jp2_t *p_jp2,
+                    OPJ_UINT32 p_tile_index,
+                    OPJ_BYTE * p_data,
+                    OPJ_UINT32 p_data_size,
+                    opj_stream_private_t *p_stream,
+                    opj_event_mgr_t * p_manager );
+
+/**
+ * Decode tile data.
+ * @param  p_jp2    the jpeg2000 codec.
+ * @param  p_tile_index FIXME DOC
+ * @param  p_data       FIXME DOC
+ * @param  p_data_size  FIXME DOC
+ * @param  p_stream      the stream to write data to.
+ * @param  p_manager  the user event manager.
+ *
+ * @return FIXME DOC
+ */
+OPJ_BOOL opj_jp2_decode_tile (  opj_jp2_t * p_jp2,
+                                OPJ_UINT32 p_tile_index,
+                                OPJ_BYTE * p_data,
+                                OPJ_UINT32 p_data_size,
+                                opj_stream_private_t *p_stream,
+                                opj_event_mgr_t * p_manager );
+
+/**
+ * Creates a jpeg2000 file decompressor.
+ *
+ * @return  an empty jpeg2000 file codec.
+ */
+opj_jp2_t* opj_jp2_create (OPJ_BOOL p_is_decoder);
+
+/**
+Destroy a JP2 decompressor handle
+ at param jp2 JP2 decompressor handle to destroy
+*/
+void opj_jp2_destroy(opj_jp2_t *jp2);
+
+
+/**
+ * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
+ *
+ * @param  p_jp2      the jpeg2000 codec.
+ * @param  p_image     FIXME DOC
+ * @param  p_start_x   the left position of the rectangle to decode (in image coordinates).
+ * @param  p_start_y    the up position of the rectangle to decode (in image coordinates).
+ * @param  p_end_x      the right position of the rectangle to decode (in image coordinates).
+ * @param  p_end_y      the bottom position of the rectangle to decode (in image coordinates).
+ * @param  p_manager    the user event manager
+ *
+ * @return  true      if the area could be set.
+ */
+OPJ_BOOL opj_jp2_set_decode_area(  opj_jp2_t *p_jp2,
+                    opj_image_t* p_image,
+                    OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
+                    OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
+                    opj_event_mgr_t * p_manager );
+
+ /**
+ * 
+ */
+OPJ_BOOL opj_jp2_get_tile(  opj_jp2_t *p_jp2,
+                            opj_stream_private_t *p_stream,
+                            opj_image_t* p_image,
+                            opj_event_mgr_t * p_manager,
+                            OPJ_UINT32 tile_index );
+
+
+/**
+ * 
+ */
+OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2, 
+                                               OPJ_UINT32 res_factor, 
+                                               opj_event_mgr_t * p_manager);
+
+
+/* TODO MSD: clean these 3 functions */
+/**
+ * Dump some elements from the JP2 decompression structure .
+ *
+ *@param p_jp2        the jp2 codec.
+ *@param flag        flag to describe what elments are dump.
+ *@param out_stream      output stream where dump the elements.
+ *
+*/
+void jp2_dump (opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream);
+
+/**
+ * Get the codestream info from a JPEG2000 codec.
+ *
+ *@param  p_jp2        jp2 codec.
+ *
+ *@return  the codestream information extract from the jpg2000 codec
+ */
+opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_t* p_jp2);
+
+/**
+ * Get the codestream index from a JPEG2000 codec.
+ *
+ *@param  p_jp2        jp2 codec.
+ *
+ *@return  the codestream index extract from the jpg2000 codec
+ */
+opj_codestream_index_t* jp2_get_cstr_index(opj_jp2_t* p_jp2);
+
+
+/*@}*/
+
+/*@}*/
+
+#endif /* __JP2_H */
+
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/libopenjp2.pc.cmake.in b/Utilities/gdcmopenjpeg/src/lib/openjp2/libopenjp2.pc.cmake.in
new file mode 100644
index 0000000..62159b0
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/libopenjp2.pc.cmake.in
@@ -0,0 +1,14 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+bindir=${prefix}/@OPENJPEG_INSTALL_BIN_DIR@
+mandir=${prefix}/@OPENJPEG_INSTALL_MAN_DIR@
+docdir=${prefix}/@OPENJPEG_INSTALL_DOC_DIR@
+libdir=${prefix}/@OPENJPEG_INSTALL_LIB_DIR@
+includedir=${prefix}/@OPENJPEG_INSTALL_INCLUDE_DIR@
+
+Name: openjp2
+Description: JPEG2000 library (Part 1 and 2)
+URL: http://www.openjpeg.org/
+Version: @OPENJPEG_VERSION@
+Libs: -L${libdir} -lopenjp2
+Libs.private: -lm
+Cflags: -I${includedir}
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/mct.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/mct.c
new file mode 100644
index 0000000..0225967
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/mct.c
@@ -0,0 +1,557 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef __SSE__
+#include <xmmintrin.h>
+#endif
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+#ifdef __SSE4_1__
+#include <smmintrin.h>
+#endif
+
+#include "opj_includes.h"
+
+/* <summary> */
+/* This table contains the norms of the basis function of the reversible MCT. */
+/* </summary> */
+static const OPJ_FLOAT64 opj_mct_norms[3] = { 1.732, .8292, .8292 };
+
+/* <summary> */
+/* This table contains the norms of the basis function of the irreversible MCT. */
+/* </summary> */
+static const OPJ_FLOAT64 opj_mct_norms_real[3] = { 1.732, 1.805, 1.573 };
+
+const OPJ_FLOAT64 * opj_mct_get_mct_norms ()
+{
+	return opj_mct_norms;
+}
+
+const OPJ_FLOAT64 * opj_mct_get_mct_norms_real ()
+{
+	return opj_mct_norms_real;
+}
+
+/* <summary> */
+/* Forward reversible MCT. */
+/* </summary> */
+#ifdef __SSE2__
+void opj_mct_encode(
+		OPJ_INT32* restrict c0,
+		OPJ_INT32* restrict c1,
+		OPJ_INT32* restrict c2,
+		OPJ_UINT32 n)
+{
+	OPJ_SIZE_T i;
+	const OPJ_SIZE_T len = n;
+	/* buffer are aligned on 16 bytes */
+	assert( ((size_t)c0 & 0xf) == 0 );
+	assert( ((size_t)c1 & 0xf) == 0 );
+	assert( ((size_t)c2 & 0xf) == 0 );
+	
+	for(i = 0; i < (len & ~3U); i += 4) {
+		__m128i y, u, v;
+		__m128i r = _mm_load_si128((const __m128i *)&(c0[i]));
+		__m128i g = _mm_load_si128((const __m128i *)&(c1[i]));
+		__m128i b = _mm_load_si128((const __m128i *)&(c2[i]));
+		y = _mm_add_epi32(g, g);
+		y = _mm_add_epi32(y, b);
+		y = _mm_add_epi32(y, r);
+		y = _mm_srai_epi32(y, 2);
+		u = _mm_sub_epi32(b, g);
+		v = _mm_sub_epi32(r, g);
+		_mm_store_si128((__m128i *)&(c0[i]), y);
+		_mm_store_si128((__m128i *)&(c1[i]), u);
+		_mm_store_si128((__m128i *)&(c2[i]), v);
+	}
+	
+	for(; i < len; ++i) {
+		OPJ_INT32 r = c0[i];
+		OPJ_INT32 g = c1[i];
+		OPJ_INT32 b = c2[i];
+		OPJ_INT32 y = (r + (g * 2) + b) >> 2;
+		OPJ_INT32 u = b - g;
+		OPJ_INT32 v = r - g;
+		c0[i] = y;
+		c1[i] = u;
+		c2[i] = v;
+	}
+}
+#else
+void opj_mct_encode(
+		OPJ_INT32* restrict c0,
+		OPJ_INT32* restrict c1,
+		OPJ_INT32* restrict c2,
+		OPJ_UINT32 n)
+{
+	OPJ_SIZE_T i;
+	const OPJ_SIZE_T len = n;
+	
+	for(i = 0; i < len; ++i) {
+		OPJ_INT32 r = c0[i];
+		OPJ_INT32 g = c1[i];
+		OPJ_INT32 b = c2[i];
+		OPJ_INT32 y = (r + (g * 2) + b) >> 2;
+		OPJ_INT32 u = b - g;
+		OPJ_INT32 v = r - g;
+		c0[i] = y;
+		c1[i] = u;
+		c2[i] = v;
+	}
+}
+#endif
+
+/* <summary> */
+/* Inverse reversible MCT. */
+/* </summary> */
+#ifdef __SSE2__
+void opj_mct_decode(
+		OPJ_INT32* restrict c0,
+		OPJ_INT32* restrict c1,
+		OPJ_INT32* restrict c2,
+		OPJ_UINT32 n)
+{
+	OPJ_SIZE_T i;
+	const OPJ_SIZE_T len = n;
+	
+	for(i = 0; i < (len & ~3U); i += 4) {
+		__m128i r, g, b;
+		__m128i y = _mm_load_si128((const __m128i *)&(c0[i]));
+		__m128i u = _mm_load_si128((const __m128i *)&(c1[i]));
+		__m128i v = _mm_load_si128((const __m128i *)&(c2[i]));
+		g = y;
+		g = _mm_sub_epi32(g, _mm_srai_epi32(_mm_add_epi32(u, v), 2));
+		r = _mm_add_epi32(v, g);
+		b = _mm_add_epi32(u, g);
+		_mm_store_si128((__m128i *)&(c0[i]), r);
+		_mm_store_si128((__m128i *)&(c1[i]), g);
+		_mm_store_si128((__m128i *)&(c2[i]), b);
+	}
+	for (; i < len; ++i) {
+		OPJ_INT32 y = c0[i];
+		OPJ_INT32 u = c1[i];
+		OPJ_INT32 v = c2[i];
+		OPJ_INT32 g = y - ((u + v) >> 2);
+		OPJ_INT32 r = v + g;
+		OPJ_INT32 b = u + g;
+		c0[i] = r;
+		c1[i] = g;
+		c2[i] = b;
+	}
+}
+#else
+void opj_mct_decode(
+		OPJ_INT32* restrict c0,
+		OPJ_INT32* restrict c1, 
+		OPJ_INT32* restrict c2, 
+		OPJ_UINT32 n)
+{
+	OPJ_UINT32 i;
+	for (i = 0; i < n; ++i) {
+		OPJ_INT32 y = c0[i];
+		OPJ_INT32 u = c1[i];
+		OPJ_INT32 v = c2[i];
+		OPJ_INT32 g = y - ((u + v) >> 2);
+		OPJ_INT32 r = v + g;
+		OPJ_INT32 b = u + g;
+		c0[i] = r;
+		c1[i] = g;
+		c2[i] = b;
+	}
+}
+#endif
+
+/* <summary> */
+/* Get norm of basis function of reversible MCT. */
+/* </summary> */
+OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno) {
+	return opj_mct_norms[compno];
+}
+
+/* <summary> */
+/* Forward irreversible MCT. */
+/* </summary> */
+#ifdef __SSE4_1__
+void opj_mct_encode_real(
+												 OPJ_INT32* restrict c0,
+												 OPJ_INT32* restrict c1,
+												 OPJ_INT32* restrict c2,
+												 OPJ_UINT32 n)
+{
+	OPJ_SIZE_T i;
+	const OPJ_SIZE_T len = n;
+	
+	const __m128i ry = _mm_set1_epi32(2449);
+	const __m128i gy = _mm_set1_epi32(4809);
+	const __m128i by = _mm_set1_epi32(934);
+	const __m128i ru = _mm_set1_epi32(1382);
+	const __m128i gu = _mm_set1_epi32(2714);
+	/* const __m128i bu = _mm_set1_epi32(4096); */
+	/* const __m128i rv = _mm_set1_epi32(4096); */
+	const __m128i gv = _mm_set1_epi32(3430);
+	const __m128i bv = _mm_set1_epi32(666);
+	const __m128i mulround = _mm_shuffle_epi32(_mm_cvtsi32_si128(4096), _MM_SHUFFLE(1, 0, 1, 0));
+	
+	for(i = 0; i < (len & ~3U); i += 4) {
+		__m128i lo, hi;
+		__m128i y, u, v;
+		__m128i r = _mm_load_si128((const __m128i *)&(c0[i]));
+		__m128i g = _mm_load_si128((const __m128i *)&(c1[i]));
+		__m128i b = _mm_load_si128((const __m128i *)&(c2[i]));
+		
+		lo = r;
+		hi = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, ry);
+		hi = _mm_mul_epi32(hi, ry);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		y = _mm_blend_epi16(lo, hi, 0xCC);
+		
+		lo = g;
+		hi = _mm_shuffle_epi32(g, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, gy);
+		hi = _mm_mul_epi32(hi, gy);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		y = _mm_add_epi32(y, _mm_blend_epi16(lo, hi, 0xCC));
+		
+		lo = b;
+		hi = _mm_shuffle_epi32(b, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, by);
+		hi = _mm_mul_epi32(hi, by);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		y = _mm_add_epi32(y, _mm_blend_epi16(lo, hi, 0xCC));
+		_mm_store_si128((__m128i *)&(c0[i]), y);
+		
+		/*lo = b;
+		hi = _mm_shuffle_epi32(b, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, mulround);
+		hi = _mm_mul_epi32(hi, mulround);*/
+		lo = _mm_cvtepi32_epi64(_mm_shuffle_epi32(b, _MM_SHUFFLE(3, 2, 2, 0)));
+		hi = _mm_cvtepi32_epi64(_mm_shuffle_epi32(b, _MM_SHUFFLE(3, 2, 3, 1)));
+		lo = _mm_slli_epi64(lo, 12);
+		hi = _mm_slli_epi64(hi, 12);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		u = _mm_blend_epi16(lo, hi, 0xCC);
+		
+		lo = r;
+		hi = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, ru);
+		hi = _mm_mul_epi32(hi, ru);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		u = _mm_sub_epi32(u, _mm_blend_epi16(lo, hi, 0xCC));
+		
+		lo = g;
+		hi = _mm_shuffle_epi32(g, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, gu);
+		hi = _mm_mul_epi32(hi, gu);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		u = _mm_sub_epi32(u, _mm_blend_epi16(lo, hi, 0xCC));
+		_mm_store_si128((__m128i *)&(c1[i]), u);
+		
+		/*lo = r;
+		hi = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, mulround);
+		hi = _mm_mul_epi32(hi, mulround);*/
+		lo = _mm_cvtepi32_epi64(_mm_shuffle_epi32(r, _MM_SHUFFLE(3, 2, 2, 0)));
+		hi = _mm_cvtepi32_epi64(_mm_shuffle_epi32(r, _MM_SHUFFLE(3, 2, 3, 1)));
+		lo = _mm_slli_epi64(lo, 12);
+		hi = _mm_slli_epi64(hi, 12);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		v = _mm_blend_epi16(lo, hi, 0xCC);
+		
+		lo = g;
+		hi = _mm_shuffle_epi32(g, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, gv);
+		hi = _mm_mul_epi32(hi, gv);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		v = _mm_sub_epi32(v, _mm_blend_epi16(lo, hi, 0xCC));
+		
+		lo = b;
+		hi = _mm_shuffle_epi32(b, _MM_SHUFFLE(3, 3, 1, 1));
+		lo = _mm_mul_epi32(lo, bv);
+		hi = _mm_mul_epi32(hi, bv);
+		lo = _mm_add_epi64(lo, mulround);
+		hi = _mm_add_epi64(hi, mulround);
+		lo = _mm_srli_epi64(lo, 13);
+		hi = _mm_slli_epi64(hi, 32-13);
+		v = _mm_sub_epi32(v, _mm_blend_epi16(lo, hi, 0xCC));
+		_mm_store_si128((__m128i *)&(c2[i]), v);
+	}
+	for(; i < len; ++i) {
+		OPJ_INT32 r = c0[i];
+		OPJ_INT32 g = c1[i];
+		OPJ_INT32 b = c2[i];
+		OPJ_INT32 y =  opj_int_fix_mul(r, 2449) + opj_int_fix_mul(g, 4809) + opj_int_fix_mul(b, 934);
+		OPJ_INT32 u = -opj_int_fix_mul(r, 1382) - opj_int_fix_mul(g, 2714) + opj_int_fix_mul(b, 4096);
+		OPJ_INT32 v =  opj_int_fix_mul(r, 4096) - opj_int_fix_mul(g, 3430) - opj_int_fix_mul(b, 666);
+		c0[i] = y;
+		c1[i] = u;
+		c2[i] = v;
+	}
+}
+#else
+void opj_mct_encode_real(
+		OPJ_INT32* restrict c0,
+		OPJ_INT32* restrict c1,
+		OPJ_INT32* restrict c2,
+		OPJ_UINT32 n)
+{
+	OPJ_UINT32 i;
+	for(i = 0; i < n; ++i) {
+		OPJ_INT32 r = c0[i];
+		OPJ_INT32 g = c1[i];
+		OPJ_INT32 b = c2[i];
+		OPJ_INT32 y =  opj_int_fix_mul(r, 2449) + opj_int_fix_mul(g, 4809) + opj_int_fix_mul(b, 934);
+		OPJ_INT32 u = -opj_int_fix_mul(r, 1382) - opj_int_fix_mul(g, 2714) + opj_int_fix_mul(b, 4096);
+		OPJ_INT32 v =  opj_int_fix_mul(r, 4096) - opj_int_fix_mul(g, 3430) - opj_int_fix_mul(b, 666);
+		c0[i] = y;
+		c1[i] = u;
+		c2[i] = v;
+	}
+}
+#endif
+
+/* <summary> */
+/* Inverse irreversible MCT. */
+/* </summary> */
+void opj_mct_decode_real(
+		OPJ_FLOAT32* restrict c0,
+		OPJ_FLOAT32* restrict c1,
+		OPJ_FLOAT32* restrict c2,
+		OPJ_UINT32 n)
+{
+	OPJ_UINT32 i;
+#ifdef __SSE__
+	__m128 vrv, vgu, vgv, vbu;
+	vrv = _mm_set1_ps(1.402f);
+	vgu = _mm_set1_ps(0.34413f);
+	vgv = _mm_set1_ps(0.71414f);
+	vbu = _mm_set1_ps(1.772f);
+	for (i = 0; i < (n >> 3); ++i) {
+		__m128 vy, vu, vv;
+		__m128 vr, vg, vb;
+
+		vy = _mm_load_ps(c0);
+		vu = _mm_load_ps(c1);
+		vv = _mm_load_ps(c2);
+		vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv));
+		vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv));
+		vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu));
+		_mm_store_ps(c0, vr);
+		_mm_store_ps(c1, vg);
+		_mm_store_ps(c2, vb);
+		c0 += 4;
+		c1 += 4;
+		c2 += 4;
+
+		vy = _mm_load_ps(c0);
+		vu = _mm_load_ps(c1);
+		vv = _mm_load_ps(c2);
+		vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv));
+		vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv));
+		vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu));
+		_mm_store_ps(c0, vr);
+		_mm_store_ps(c1, vg);
+		_mm_store_ps(c2, vb);
+		c0 += 4;
+		c1 += 4;
+		c2 += 4;
+	}
+	n &= 7;
+#endif
+	for(i = 0; i < n; ++i) {
+		OPJ_FLOAT32 y = c0[i];
+		OPJ_FLOAT32 u = c1[i];
+		OPJ_FLOAT32 v = c2[i];
+		OPJ_FLOAT32 r = y + (v * 1.402f);
+		OPJ_FLOAT32 g = y - (u * 0.34413f) - (v * (0.71414f));
+		OPJ_FLOAT32 b = y + (u * 1.772f);
+		c0[i] = r;
+		c1[i] = g;
+		c2[i] = b;
+	}
+}
+
+/* <summary> */
+/* Get norm of basis function of irreversible MCT. */
+/* </summary> */
+OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno) {
+	return opj_mct_norms_real[compno];
+}
+
+
+OPJ_BOOL opj_mct_encode_custom(
+					   OPJ_BYTE * pCodingdata,
+					   OPJ_UINT32 n,
+					   OPJ_BYTE ** pData,
+					   OPJ_UINT32 pNbComp,
+					   OPJ_UINT32 isSigned)
+{
+	OPJ_FLOAT32 * lMct = (OPJ_FLOAT32 *) pCodingdata;
+	OPJ_UINT32 i;
+	OPJ_UINT32 j;
+	OPJ_UINT32 k;
+	OPJ_UINT32 lNbMatCoeff = pNbComp * pNbComp;
+	OPJ_INT32 * lCurrentData = 00;
+	OPJ_INT32 * lCurrentMatrix = 00;
+	OPJ_INT32 ** lData = (OPJ_INT32 **) pData;
+	OPJ_UINT32 lMultiplicator = 1 << 13;
+	OPJ_INT32 * lMctPtr;
+
+    OPJ_ARG_NOT_USED(isSigned);
+
+	lCurrentData = (OPJ_INT32 *) opj_malloc((pNbComp + lNbMatCoeff) * sizeof(OPJ_INT32));
+	if (! lCurrentData) {
+		return OPJ_FALSE;
+	}
+
+	lCurrentMatrix = lCurrentData + pNbComp;
+
+	for (i =0;i<lNbMatCoeff;++i) {
+		lCurrentMatrix[i] = (OPJ_INT32) (*(lMct++) * (OPJ_FLOAT32)lMultiplicator);
+	}
+
+	for (i = 0; i < n; ++i)  {
+		lMctPtr = lCurrentMatrix;
+		for (j=0;j<pNbComp;++j) {
+			lCurrentData[j] = (*(lData[j]));
+		}
+
+		for (j=0;j<pNbComp;++j) {
+			*(lData[j]) = 0;
+			for (k=0;k<pNbComp;++k) {
+				*(lData[j]) += opj_int_fix_mul(*lMctPtr, lCurrentData[k]);
+				++lMctPtr;
+			}
+
+			++lData[j];
+		}
+	}
+
+	opj_free(lCurrentData);
+
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_mct_decode_custom(
+					   OPJ_BYTE * pDecodingData,
+					   OPJ_UINT32 n,
+					   OPJ_BYTE ** pData,
+					   OPJ_UINT32 pNbComp,
+					   OPJ_UINT32 isSigned)
+{
+	OPJ_FLOAT32 * lMct;
+	OPJ_UINT32 i;
+	OPJ_UINT32 j;
+	OPJ_UINT32 k;
+
+	OPJ_FLOAT32 * lCurrentData = 00;
+	OPJ_FLOAT32 * lCurrentResult = 00;
+	OPJ_FLOAT32 ** lData = (OPJ_FLOAT32 **) pData;
+
+    OPJ_ARG_NOT_USED(isSigned);
+
+	lCurrentData = (OPJ_FLOAT32 *) opj_malloc (2 * pNbComp * sizeof(OPJ_FLOAT32));
+	if (! lCurrentData) {
+		return OPJ_FALSE;
+	}
+	lCurrentResult = lCurrentData + pNbComp;
+
+	for (i = 0; i < n; ++i) {
+		lMct = (OPJ_FLOAT32 *) pDecodingData;
+		for (j=0;j<pNbComp;++j) {
+			lCurrentData[j] = (OPJ_FLOAT32) (*(lData[j]));
+		}
+		for (j=0;j<pNbComp;++j) {
+			lCurrentResult[j] = 0;
+			for	(k=0;k<pNbComp;++k)	{
+				lCurrentResult[j] += *(lMct++) * lCurrentData[k];
+			}
+			*(lData[j]++) = (OPJ_FLOAT32) (lCurrentResult[j]);
+		}
+	}
+	opj_free(lCurrentData);
+	return OPJ_TRUE;
+}
+
+void opj_calculate_norms(	OPJ_FLOAT64 * pNorms,
+							OPJ_UINT32 pNbComps,
+							OPJ_FLOAT32 * pMatrix)
+{
+	OPJ_UINT32 i,j,lIndex;
+	OPJ_FLOAT32 lCurrentValue;
+	OPJ_FLOAT64 * lNorms = (OPJ_FLOAT64 *) pNorms;
+	OPJ_FLOAT32 * lMatrix = (OPJ_FLOAT32 *) pMatrix;
+
+	for	(i=0;i<pNbComps;++i) {
+		lNorms[i] = 0;
+		lIndex = i;
+
+		for	(j=0;j<pNbComps;++j) {
+			lCurrentValue = lMatrix[lIndex];
+			lIndex += pNbComps;
+			lNorms[i] += lCurrentValue * lCurrentValue;
+		}
+		lNorms[i] = sqrt(lNorms[i]);
+	}
+}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mct.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/mct.h
similarity index 57%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/mct.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/mct.h
index 84e3f8a..1c1f4d0 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mct.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/mct.h
@@ -1,10 +1,18 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -52,7 +60,7 @@ Apply a reversible multi-component transform to an image
 @param c2 Samples blue component
 @param n Number of samples for each component
 */
-void mct_encode(int *c0, int *c1, int *c2, int n);
+void opj_mct_encode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
 /**
 Apply a reversible multi-component inverse transform to an image
 @param c0 Samples for luminance component
@@ -60,13 +68,13 @@ Apply a reversible multi-component inverse transform to an image
 @param c2 Samples for blue chrominance component
 @param n Number of samples for each component
 */
-void mct_decode(int *c0, int *c1, int *c2, int n);
+void opj_mct_decode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
 /**
 Get norm of the basis function used for the reversible multi-component transform
 @param compno Number of the component (0->Y, 1->U, 2->V)
 @return 
 */
-double mct_getnorm(int compno);
+OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno);
 
 /**
 Apply an irreversible multi-component transform to an image
@@ -75,7 +83,7 @@ Apply an irreversible multi-component transform to an image
 @param c2 Samples blue component
 @param n Number of samples for each component
 */
-void mct_encode_real(int *c0, int *c1, int *c2, int n);
+void opj_mct_encode_real(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
 /**
 Apply an irreversible multi-component inverse transform to an image
 @param c0 Samples for luminance component
@@ -83,13 +91,62 @@ Apply an irreversible multi-component inverse transform to an image
 @param c2 Samples for blue chrominance component
 @param n Number of samples for each component
 */
-void mct_decode_real(float* c0, float* c1, float* c2, int n);
+void opj_mct_decode_real(OPJ_FLOAT32* c0, OPJ_FLOAT32* c1, OPJ_FLOAT32* c2, OPJ_UINT32 n);
 /**
 Get norm of the basis function used for the irreversible multi-component transform
 @param compno Number of the component (0->Y, 1->U, 2->V)
 @return 
 */
-double mct_getnorm_real(int compno);
+OPJ_FLOAT64 opj_mct_getnorm_real(OPJ_UINT32 compno);
+
+/**
+FIXME DOC
+ at param p_coding_data    MCT data
+ at param n                size of components
+ at param p_data           components
+ at param p_nb_comp        nb of components (i.e. size of p_data)
+ at param is_signed        tells if the data is signed
+ at return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise
+*/
+OPJ_BOOL opj_mct_encode_custom(
+					   OPJ_BYTE * p_coding_data,
+					   OPJ_UINT32 n,
+					   OPJ_BYTE ** p_data,
+					   OPJ_UINT32 p_nb_comp,
+					   OPJ_UINT32 is_signed);
+/**
+FIXME DOC
+ at param pDecodingData    MCT data
+ at param n                size of components
+ at param pData            components
+ at param pNbComp          nb of components (i.e. size of p_data)
+ at param isSigned         tells if the data is signed
+ at return OPJ_FALSE if function encounter a problem, OPJ_TRUE otherwise
+*/
+OPJ_BOOL opj_mct_decode_custom(
+					   OPJ_BYTE * pDecodingData,
+					   OPJ_UINT32 n,
+					   OPJ_BYTE ** pData,
+					   OPJ_UINT32 pNbComp,
+					   OPJ_UINT32 isSigned);
+/**
+FIXME DOC
+ at param pNorms           MCT data
+ at param p_nb_comps       size of components
+ at param pMatrix          components
+ at return 
+*/
+void opj_calculate_norms(   OPJ_FLOAT64 * pNorms,
+                            OPJ_UINT32 p_nb_comps,
+                            OPJ_FLOAT32 * pMatrix);
+/**
+FIXME DOC 
+*/
+const OPJ_FLOAT64 * opj_mct_get_mct_norms (void);
+/**
+FIXME DOC 
+*/
+const OPJ_FLOAT64 * opj_mct_get_mct_norms_real (void);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mqc.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/mqc.c
similarity index 68%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/mqc.c
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/mqc.c
index 5d25238..4e409a7 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mqc.c
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/mqc.c
@@ -1,10 +1,17 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,49 +49,49 @@ Output a byte, doing bit-stuffing if necessary.
 After a 0xff byte, the next byte must be smaller than 0x90.
 @param mqc MQC handle
 */
-static void mqc_byteout(opj_mqc_t *mqc);
+static void opj_mqc_byteout(opj_mqc_t *mqc);
 /**
 Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000
 @param mqc MQC handle
 */
-static void mqc_renorme(opj_mqc_t *mqc);
+static void opj_mqc_renorme(opj_mqc_t *mqc);
 /**
 Encode the most probable symbol
 @param mqc MQC handle
 */
-static void mqc_codemps(opj_mqc_t *mqc);
+static void opj_mqc_codemps(opj_mqc_t *mqc);
 /**
 Encode the most least symbol
 @param mqc MQC handle
 */
-static void mqc_codelps(opj_mqc_t *mqc);
+static void opj_mqc_codelps(opj_mqc_t *mqc);
 /**
 Fill mqc->c with 1's for flushing
 @param mqc MQC handle
 */
-static void mqc_setbits(opj_mqc_t *mqc);
+static void opj_mqc_setbits(opj_mqc_t *mqc);
 /**
-FIXME: documentation ???
+FIXME DOC
 @param mqc MQC handle
 @return 
 */
-static INLINE int mqc_mpsexchange(opj_mqc_t *const mqc);
+static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc);
 /**
-FIXME: documentation ???
+FIXME DOC
 @param mqc MQC handle
 @return 
 */
-static INLINE int mqc_lpsexchange(opj_mqc_t *const mqc);
+static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc);
 /**
 Input a byte
 @param mqc MQC handle
 */
-static INLINE void mqc_bytein(opj_mqc_t *const mqc);
+static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc);
 /**
 Renormalize mqc->a and mqc->c while decoding
 @param mqc MQC handle
 */
-static INLINE void mqc_renormd(opj_mqc_t *const mqc);
+static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc);
 /*@}*/
 
 /*@}*/
@@ -195,16 +202,23 @@ static opj_mqc_state_t mqc_states[47 * 2] = {
 ==========================================================
 */
 
-static void mqc_byteout(opj_mqc_t *mqc) {
-	if (*mqc->bp == 0xff) {
+static void opj_mqc_byteout(opj_mqc_t *mqc) {
+	/* avoid accessing uninitialized memory*/
+	if (mqc->bp == mqc->start-1) {
 		mqc->bp++;
-		*mqc->bp = mqc->c >> 20;
+		*mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
+		mqc->c &= 0x7ffff;
+		mqc->ct = 8;
+	}
+	else if (*mqc->bp == 0xff) {
+		mqc->bp++;
+		*mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
 		mqc->c &= 0xfffff;
 		mqc->ct = 7;
 	} else {
-		if ((mqc->c & 0x8000000) == 0) {	/* ((mqc->c&0x8000000)==0) CHANGE */
+		if ((mqc->c & 0x8000000) == 0) {	
 			mqc->bp++;
-			*mqc->bp = mqc->c >> 19;
+			*mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
 			mqc->c &= 0x7ffff;
 			mqc->ct = 8;
 		} else {
@@ -212,12 +226,12 @@ static void mqc_byteout(opj_mqc_t *mqc) {
 			if (*mqc->bp == 0xff) {
 				mqc->c &= 0x7ffffff;
 				mqc->bp++;
-				*mqc->bp = mqc->c >> 20;
+				*mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
 				mqc->c &= 0xfffff;
 				mqc->ct = 7;
 			} else {
 				mqc->bp++;
-				*mqc->bp = mqc->c >> 19;
+				*mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
 				mqc->c &= 0x7ffff;
 				mqc->ct = 8;
 			}
@@ -225,18 +239,18 @@ static void mqc_byteout(opj_mqc_t *mqc) {
 	}
 }
 
-static void mqc_renorme(opj_mqc_t *mqc) {
+static void opj_mqc_renorme(opj_mqc_t *mqc) {
 	do {
 		mqc->a <<= 1;
 		mqc->c <<= 1;
 		mqc->ct--;
 		if (mqc->ct == 0) {
-			mqc_byteout(mqc);
+			opj_mqc_byteout(mqc);
 		}
 	} while ((mqc->a & 0x8000) == 0);
 }
 
-static void mqc_codemps(opj_mqc_t *mqc) {
+static void opj_mqc_codemps(opj_mqc_t *mqc) {
 	mqc->a -= (*mqc->curctx)->qeval;
 	if ((mqc->a & 0x8000) == 0) {
 		if (mqc->a < (*mqc->curctx)->qeval) {
@@ -245,13 +259,13 @@ static void mqc_codemps(opj_mqc_t *mqc) {
 			mqc->c += (*mqc->curctx)->qeval;
 		}
 		*mqc->curctx = (*mqc->curctx)->nmps;
-		mqc_renorme(mqc);
+		opj_mqc_renorme(mqc);
 	} else {
 		mqc->c += (*mqc->curctx)->qeval;
 	}
 }
 
-static void mqc_codelps(opj_mqc_t *mqc) {
+static void opj_mqc_codelps(opj_mqc_t *mqc) {
 	mqc->a -= (*mqc->curctx)->qeval;
 	if (mqc->a < (*mqc->curctx)->qeval) {
 		mqc->c += (*mqc->curctx)->qeval;
@@ -259,39 +273,39 @@ static void mqc_codelps(opj_mqc_t *mqc) {
 		mqc->a = (*mqc->curctx)->qeval;
 	}
 	*mqc->curctx = (*mqc->curctx)->nlps;
-	mqc_renorme(mqc);
+	opj_mqc_renorme(mqc);
 }
 
-static void mqc_setbits(opj_mqc_t *mqc) {
-	unsigned int tempc = mqc->c + mqc->a;
+static void opj_mqc_setbits(opj_mqc_t *mqc) {
+	OPJ_UINT32 tempc = mqc->c + mqc->a;
 	mqc->c |= 0xffff;
 	if (mqc->c >= tempc) {
 		mqc->c -= 0x8000;
 	}
 }
 
-static INLINE int mqc_mpsexchange(opj_mqc_t *const mqc) {
-	int d;
+static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) {
+	OPJ_INT32 d;
 	if (mqc->a < (*mqc->curctx)->qeval) {
-		d = 1 - (*mqc->curctx)->mps;
+		d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
 		*mqc->curctx = (*mqc->curctx)->nlps;
 	} else {
-		d = (*mqc->curctx)->mps;
+		d = (OPJ_INT32)(*mqc->curctx)->mps;
 		*mqc->curctx = (*mqc->curctx)->nmps;
 	}
 	
 	return d;
 }
 
-static INLINE int mqc_lpsexchange(opj_mqc_t *const mqc) {
-	int d;
+static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc) {
+	OPJ_INT32 d;
 	if (mqc->a < (*mqc->curctx)->qeval) {
 		mqc->a = (*mqc->curctx)->qeval;
-		d = (*mqc->curctx)->mps;
+		d = (OPJ_INT32)(*mqc->curctx)->mps;
 		*mqc->curctx = (*mqc->curctx)->nmps;
 	} else {
 		mqc->a = (*mqc->curctx)->qeval;
-		d = 1 - (*mqc->curctx)->mps;
+		d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
 		*mqc->curctx = (*mqc->curctx)->nlps;
 	}
 	
@@ -299,16 +313,16 @@ static INLINE int mqc_lpsexchange(opj_mqc_t *const mqc) {
 }
 
 #ifdef MQC_PERF_OPT
-static INLINE void mqc_bytein(opj_mqc_t *const mqc) {
+static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) {
 	unsigned int i = *((unsigned int *) mqc->bp);
 	mqc->c += i & 0xffff00;
 	mqc->ct = i & 0x0f;
 	mqc->bp += (i >> 2) & 0x04;
 }
 #else
-static void mqc_bytein(opj_mqc_t *const mqc) {
+static void opj_mqc_bytein(opj_mqc_t *const mqc) {
 	if (mqc->bp != mqc->end) {
-		unsigned int c;
+		OPJ_UINT32 c;
 		if (mqc->bp + 1 != mqc->end) {
 			c = *(mqc->bp + 1);
 		} else {
@@ -335,10 +349,10 @@ static void mqc_bytein(opj_mqc_t *const mqc) {
 }
 #endif
 
-static INLINE void mqc_renormd(opj_mqc_t *const mqc) {
+static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc) {
 	do {
 		if (mqc->ct == 0) {
-			mqc_bytein(mqc);
+			opj_mqc_bytein(mqc);
 		}
 		mqc->a <<= 1;
 		mqc->c <<= 1;
@@ -352,15 +366,17 @@ static INLINE void mqc_renormd(opj_mqc_t *const mqc) {
 ==========================================================
 */
 
-opj_mqc_t* mqc_create(void) {
+opj_mqc_t* opj_mqc_create(void) {
 	opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
 #ifdef MQC_PERF_OPT
-	mqc->buffer = NULL;
+	if (mqc) {
+		mqc->buffer = NULL;
+	}
 #endif
 	return mqc;
 }
 
-void mqc_destroy(opj_mqc_t *mqc) {
+void opj_mqc_destroy(opj_mqc_t *mqc) {
 	if(mqc) {
 #ifdef MQC_PERF_OPT
 		if (mqc->buffer) {
@@ -371,43 +387,45 @@ void mqc_destroy(opj_mqc_t *mqc) {
 	}
 }
 
-int mqc_numbytes(opj_mqc_t *mqc) {
-	return mqc->bp - mqc->start;
+OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc) {
+	const ptrdiff_t diff = mqc->bp - mqc->start;
+#if 0
+  assert( diff <= 0xffffffff && diff >= 0 ); /* UINT32_MAX */
+#endif
+	return (OPJ_UINT32)diff;
 }
 
-void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp) {
-	mqc_setcurctx(mqc, 0);
+void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) {
+    /* TODO MSD: need to take a look to the v2 version */
+	opj_mqc_setcurctx(mqc, 0);
 	mqc->a = 0x8000;
 	mqc->c = 0;
 	mqc->bp = bp - 1;
 	mqc->ct = 12;
-	if (*mqc->bp == 0xff) {
-		mqc->ct = 13;
-	}
 	mqc->start = bp;
 }
 
-void mqc_encode(opj_mqc_t *mqc, int d) {
+void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d) {
 	if ((*mqc->curctx)->mps == d) {
-		mqc_codemps(mqc);
+		opj_mqc_codemps(mqc);
 	} else {
-		mqc_codelps(mqc);
+		opj_mqc_codelps(mqc);
 	}
 }
 
-void mqc_flush(opj_mqc_t *mqc) {
-	mqc_setbits(mqc);
+void opj_mqc_flush(opj_mqc_t *mqc) {
+	opj_mqc_setbits(mqc);
 	mqc->c <<= mqc->ct;
-	mqc_byteout(mqc);
+	opj_mqc_byteout(mqc);
 	mqc->c <<= mqc->ct;
-	mqc_byteout(mqc);
+	opj_mqc_byteout(mqc);
 	
 	if (*mqc->bp != 0xff) {
 		mqc->bp++;
 	}
 }
 
-void mqc_bypass_init_enc(opj_mqc_t *mqc) {
+void opj_mqc_bypass_init_enc(opj_mqc_t *mqc) {
 	mqc->c = 0;
 	mqc->ct = 8;
 	/*if (*mqc->bp == 0xff) {
@@ -415,12 +433,12 @@ void mqc_bypass_init_enc(opj_mqc_t *mqc) {
      } */
 }
 
-void mqc_bypass_enc(opj_mqc_t *mqc, int d) {
+void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d) {
 	mqc->ct--;
 	mqc->c = mqc->c + (d << mqc->ct);
 	if (mqc->ct == 0) {
 		mqc->bp++;
-		*mqc->bp = mqc->c;
+		*mqc->bp = (OPJ_BYTE)mqc->c;
 		mqc->ct = 8;
 		if (*mqc->bp == 0xff) {
 			mqc->ct = 7;
@@ -429,19 +447,19 @@ void mqc_bypass_enc(opj_mqc_t *mqc, int d) {
 	}
 }
 
-int mqc_bypass_flush_enc(opj_mqc_t *mqc) {
-	unsigned char bit_padding;
+OPJ_UINT32 opj_mqc_bypass_flush_enc(opj_mqc_t *mqc) {
+	OPJ_BYTE bit_padding;
 	
 	bit_padding = 0;
 	
 	if (mqc->ct != 0) {
 		while (mqc->ct > 0) {
 			mqc->ct--;
-			mqc->c += bit_padding << mqc->ct;
+			mqc->c += (OPJ_UINT32)(bit_padding << mqc->ct);
 			bit_padding = (bit_padding + 1) & 0x01;
 		}
 		mqc->bp++;
-		*mqc->bp = mqc->c;
+		*mqc->bp = (OPJ_BYTE)mqc->c;
 		mqc->ct = 8;
 		mqc->c = 0;
 	}
@@ -449,32 +467,32 @@ int mqc_bypass_flush_enc(opj_mqc_t *mqc) {
 	return 1;
 }
 
-void mqc_reset_enc(opj_mqc_t *mqc) {
-	mqc_resetstates(mqc);
-	mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
-	mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
-	mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
+void opj_mqc_reset_enc(opj_mqc_t *mqc) {
+	opj_mqc_resetstates(mqc);
+	opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
+	opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
+	opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
 }
 
-int mqc_restart_enc(opj_mqc_t *mqc) {
-	int correction = 1;
+OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc) {
+	OPJ_UINT32 correction = 1;
 	
 	/* <flush part> */
-	int n = 27 - 15 - mqc->ct;
+	OPJ_INT32 n = (OPJ_INT32)(27 - 15 - mqc->ct);
 	mqc->c <<= mqc->ct;
 	while (n > 0) {
-		mqc_byteout(mqc);
-		n -= mqc->ct;
+		opj_mqc_byteout(mqc);
+		n -= (OPJ_INT32)mqc->ct;
 		mqc->c <<= mqc->ct;
 	}
-	mqc_byteout(mqc);
+	opj_mqc_byteout(mqc);
 	
 	return correction;
 }
 
-void mqc_restart_init_enc(opj_mqc_t *mqc) {
+void opj_mqc_restart_init_enc(opj_mqc_t *mqc) {
 	/* <Re-init part> */
-	mqc_setcurctx(mqc, 0);
+	opj_mqc_setcurctx(mqc, 0);
 	mqc->a = 0x8000;
 	mqc->c = 0;
 	mqc->ct = 12;
@@ -484,59 +502,65 @@ void mqc_restart_init_enc(opj_mqc_t *mqc) {
 	}
 }
 
-void mqc_erterm_enc(opj_mqc_t *mqc) {
-	int k = 11 - mqc->ct + 1;
+void opj_mqc_erterm_enc(opj_mqc_t *mqc) {
+	OPJ_INT32 k = (OPJ_INT32)(11 - mqc->ct + 1);
 	
 	while (k > 0) {
 		mqc->c <<= mqc->ct;
 		mqc->ct = 0;
-		mqc_byteout(mqc);
-		k -= mqc->ct;
+		opj_mqc_byteout(mqc);
+		k -= (OPJ_INT32)mqc->ct;
 	}
 	
 	if (*mqc->bp != 0xff) {
-		mqc_byteout(mqc);
+		opj_mqc_byteout(mqc);
 	}
 }
 
-void mqc_segmark_enc(opj_mqc_t *mqc) {
-	int i;
-	mqc_setcurctx(mqc, 18);
+void opj_mqc_segmark_enc(opj_mqc_t *mqc) {
+	OPJ_UINT32 i;
+	opj_mqc_setcurctx(mqc, 18);
 	
 	for (i = 1; i < 5; i++) {
-		mqc_encode(mqc, i % 2);
+		opj_mqc_encode(mqc, i % 2);
 	}
 }
 
-void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) {
-	mqc_setcurctx(mqc, 0);
+OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len) {
+	opj_mqc_setcurctx(mqc, 0);
 	mqc->start = bp;
 	mqc->end = bp + len;
 	mqc->bp = bp;
 	if (len==0) mqc->c = 0xff << 16;
-	else mqc->c = *mqc->bp << 16;
+	else mqc->c = (OPJ_UINT32)(*mqc->bp << 16);
 
-#ifdef MQC_PERF_OPT
+#ifdef MQC_PERF_OPT /* TODO_MSD: check this option and put in experimental */
 	{
-		unsigned int c;
-		unsigned int *ip;
-		unsigned char *end = mqc->end - 1;
-		mqc->buffer = opj_realloc(mqc->buffer, (2 * len + 1) * sizeof(unsigned int));
-		ip = (unsigned int *) mqc->buffer;
-
-		while (bp != end) {
+        OPJ_UINT32 c;
+		OPJ_UINT32 *ip;
+		OPJ_BYTE *end = mqc->end - 1;
+        void* new_buffer = opj_realloc(mqc->buffer, (len + 1) * sizeof(OPJ_UINT32));
+        if (! new_buffer) {
+            opj_free(mqc->buffer);
+            mqc->buffer = NULL;
+            return OPJ_FALSE;
+        }
+        mqc->buffer = new_buffer;
+		
+        ip = (OPJ_UINT32 *) mqc->buffer;
+
+		while (bp < end) {
 			c = *(bp + 1);
 			if (*bp == 0xff) {
 				if (c > 0x8f) {
-					*ip = 0x0000ff18;
+					break;
 				} else {
-					bp++;
 					*ip = 0x00000017 | (c << 9);
 				}
 			} else {
-				bp++;
 				*ip = 0x00000018 | (c << 8);
 			}
+			bp++;
 			ip++;
 		}
 
@@ -554,40 +578,41 @@ void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) {
 		mqc->bp = mqc->buffer;
 	}
 #endif
-	mqc_bytein(mqc);
+	opj_mqc_bytein(mqc);
 	mqc->c <<= 7;
 	mqc->ct -= 7;
 	mqc->a = 0x8000;
+        return OPJ_TRUE;
 }
 
-int mqc_decode(opj_mqc_t *const mqc) {
-	int d;
+OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc) {
+	OPJ_INT32 d;
 	mqc->a -= (*mqc->curctx)->qeval;
 	if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
-		d = mqc_lpsexchange(mqc);
-		mqc_renormd(mqc);
+		d = opj_mqc_lpsexchange(mqc);
+		opj_mqc_renormd(mqc);
 	} else {
 		mqc->c -= (*mqc->curctx)->qeval << 16;
 		if ((mqc->a & 0x8000) == 0) {
-			d = mqc_mpsexchange(mqc);
-			mqc_renormd(mqc);
+			d = opj_mqc_mpsexchange(mqc);
+			opj_mqc_renormd(mqc);
 		} else {
-			d = (*mqc->curctx)->mps;
+			d = (OPJ_INT32)(*mqc->curctx)->mps;
 		}
 	}
 
 	return d;
 }
 
-void mqc_resetstates(opj_mqc_t *mqc) {
-	int i;
+void opj_mqc_resetstates(opj_mqc_t *mqc) {
+	OPJ_UINT32 i;
 	for (i = 0; i < MQC_NUMCTXS; i++) {
 		mqc->ctxs[i] = mqc_states;
 	}
 }
 
-void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob) {
-	mqc->ctxs[ctxno] = &mqc_states[msb + (prob << 1)];
+void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob) {
+	mqc->ctxs[ctxno] = &mqc_states[msb + (OPJ_UINT32)(prob << 1)];
 }
 
 
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mqc.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/mqc.h
similarity index 74%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/mqc.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/mqc.h
index d00cd10..69a2d46 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/mqc.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/mqc.h
@@ -1,10 +1,17 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,9 +54,9 @@ This struct defines the state of a context.
 */
 typedef struct opj_mqc_state {
 	/** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */
-	unsigned int qeval;
+	OPJ_UINT32 qeval;
 	/** the Most Probable Symbol (0 or 1) */
-	int mps;
+	OPJ_UINT32 mps;
 	/** next state if the next encoded symbol is the MPS */
 	struct opj_mqc_state *nmps;
 	/** next state if the next encoded symbol is the LPS */
@@ -62,12 +69,12 @@ typedef struct opj_mqc_state {
 MQ coder
 */
 typedef struct opj_mqc {
-	unsigned int c;
-	unsigned int a;
-	unsigned int ct;
-	unsigned char *bp;
-	unsigned char *start;
-	unsigned char *end;
+	OPJ_UINT32 c;
+	OPJ_UINT32 a;
+	OPJ_UINT32 ct;
+	OPJ_BYTE *bp;
+	OPJ_BYTE *start;
+	OPJ_BYTE *end;
 	opj_mqc_state_t *ctxs[MQC_NUMCTXS];
 	opj_mqc_state_t **curctx;
 #ifdef MQC_PERF_OPT
@@ -82,24 +89,24 @@ typedef struct opj_mqc {
 Create a new MQC handle 
 @return Returns a new MQC handle if successful, returns NULL otherwise
 */
-opj_mqc_t* mqc_create(void);
+opj_mqc_t* opj_mqc_create(void);
 /**
 Destroy a previously created MQC handle
 @param mqc MQC handle to destroy
 */
-void mqc_destroy(opj_mqc_t *mqc);
+void opj_mqc_destroy(opj_mqc_t *mqc);
 /**
 Return the number of bytes written/read since initialisation
 @param mqc MQC handle
 @return Returns the number of bytes already encoded
 */
-int mqc_numbytes(opj_mqc_t *mqc);
+OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc);
 /**
 Reset the states of all the context of the coder/decoder 
 (each context is set to a state where 0 and 1 are more or less equiprobable)
 @param mqc MQC handle
 */
-void mqc_resetstates(opj_mqc_t *mqc);
+void opj_mqc_resetstates(opj_mqc_t *mqc);
 /**
 Set the state of a particular context
 @param mqc MQC handle
@@ -107,37 +114,37 @@ Set the state of a particular context
 @param msb The MSB of the new state of the context
 @param prob Number that identifies the probability of the symbols for the new state of the context
 */
-void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob);
+void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob);
 /**
 Initialize the encoder
 @param mqc MQC handle
 @param bp Pointer to the start of the buffer where the bytes will be written
 */
-void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp);
+void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp);
 /**
 Set the current context used for coding/decoding
 @param mqc MQC handle
 @param ctxno Number that identifies the context
 */
-#define mqc_setcurctx(mqc, ctxno)	(mqc)->curctx = &(mqc)->ctxs[(int)(ctxno)]
+#define opj_mqc_setcurctx(mqc, ctxno)	(mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)]
 /**
 Encode a symbol using the MQ-coder
 @param mqc MQC handle
 @param d The symbol to be encoded (0 or 1)
 */
-void mqc_encode(opj_mqc_t *mqc, int d);
+void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d);
 /**
 Flush the encoder, so that all remaining data is written
 @param mqc MQC handle
 */
-void mqc_flush(opj_mqc_t *mqc);
+void opj_mqc_flush(opj_mqc_t *mqc);
 /**
 BYPASS mode switch, initialization operation. 
 JPEG 2000 p 505. 
 <h2>Not fully implemented and tested !!</h2>
 @param mqc MQC handle
 */
-void mqc_bypass_init_enc(opj_mqc_t *mqc);
+void opj_mqc_bypass_init_enc(opj_mqc_t *mqc);
 /**
 BYPASS mode switch, coding operation. 
 JPEG 2000 p 505. 
@@ -145,53 +152,53 @@ JPEG 2000 p 505.
 @param mqc MQC handle
 @param d The symbol to be encoded (0 or 1)
 */
-void mqc_bypass_enc(opj_mqc_t *mqc, int d);
+void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d);
 /**
 BYPASS mode switch, flush operation
 <h2>Not fully implemented and tested !!</h2>
 @param mqc MQC handle
 @return Returns 1 (always)
 */
-int mqc_bypass_flush_enc(opj_mqc_t *mqc);
+OPJ_UINT32 opj_mqc_bypass_flush_enc(opj_mqc_t *mqc);
 /**
 RESET mode switch
 @param mqc MQC handle
 */
-void mqc_reset_enc(opj_mqc_t *mqc);
+void opj_mqc_reset_enc(opj_mqc_t *mqc);
 /**
 RESTART mode switch (TERMALL)
 @param mqc MQC handle
 @return Returns 1 (always)
 */
-int mqc_restart_enc(opj_mqc_t *mqc);
+OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc);
 /**
 RESTART mode switch (TERMALL) reinitialisation
 @param mqc MQC handle
 */
-void mqc_restart_init_enc(opj_mqc_t *mqc);
+void opj_mqc_restart_init_enc(opj_mqc_t *mqc);
 /**
 ERTERM mode switch (PTERM)
 @param mqc MQC handle
 */
-void mqc_erterm_enc(opj_mqc_t *mqc);
+void opj_mqc_erterm_enc(opj_mqc_t *mqc);
 /**
 SEGMARK mode switch (SEGSYM)
 @param mqc MQC handle
 */
-void mqc_segmark_enc(opj_mqc_t *mqc);
+void opj_mqc_segmark_enc(opj_mqc_t *mqc);
 /**
 Initialize the decoder
 @param mqc MQC handle
 @param bp Pointer to the start of the buffer from which the bytes will be read
 @param len Length of the input buffer
 */
-void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len);
+OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len);
 /**
 Decode a symbol
 @param mqc MQC handle
 @return Returns the decoded symbol (0 or 1)
 */
-int mqc_decode(opj_mqc_t *const mqc);
+OPJ_INT32 opj_mqc_decode(opj_mqc_t * const mqc);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.c
new file mode 100644
index 0000000..5114cc1
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.c
@@ -0,0 +1,960 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef _WIN32
+#include <windows.h>
+#endif /* _WIN32 */
+
+#include "opj_includes.h"
+
+
+/* ---------------------------------------------------------------------- */
+/* Functions to set the message handlers */
+
+OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(	opj_codec_t * p_codec, 
+											opj_msg_callback p_callback,
+											void * p_user_data)
+{
+	opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+	if(! l_codec){
+		return OPJ_FALSE;
+	}
+	
+	l_codec->m_event_mgr.info_handler = p_callback;
+	l_codec->m_event_mgr.m_info_data = p_user_data;
+	
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(	opj_codec_t * p_codec, 
+												opj_msg_callback p_callback,
+												void * p_user_data)
+{
+	opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+	if (! l_codec) {
+		return OPJ_FALSE;
+	}
+	
+	l_codec->m_event_mgr.warning_handler = p_callback;
+	l_codec->m_event_mgr.m_warning_data = p_user_data;
+	
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, 
+											opj_msg_callback p_callback,
+											void * p_user_data)
+{
+	opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+	if (! l_codec) {
+		return OPJ_FALSE;
+	}
+	
+	l_codec->m_event_mgr.error_handler = p_callback;
+	l_codec->m_event_mgr.m_error_data = p_user_data;
+	
+	return OPJ_TRUE;
+}
+
+/* ---------------------------------------------------------------------- */
+
+static OPJ_SIZE_T opj_read_from_file (void * p_buffer, OPJ_SIZE_T p_nb_bytes, FILE * p_file)
+{
+	OPJ_SIZE_T l_nb_read = fread(p_buffer,1,p_nb_bytes,p_file);
+	return l_nb_read ? l_nb_read : (OPJ_SIZE_T)-1;
+}
+
+static OPJ_UINT64 opj_get_data_length_from_file (FILE * p_file)
+{
+	OPJ_OFF_T file_length = 0;
+
+	OPJ_FSEEK(p_file, 0, SEEK_END);
+	file_length = (OPJ_OFF_T)OPJ_FTELL(p_file);
+	OPJ_FSEEK(p_file, 0, SEEK_SET);
+
+	return (OPJ_UINT64)file_length;
+}
+
+static OPJ_SIZE_T opj_write_from_file (void * p_buffer, OPJ_SIZE_T p_nb_bytes, FILE * p_file)
+{
+	return fwrite(p_buffer,1,p_nb_bytes,p_file);
+}
+
+static OPJ_OFF_T opj_skip_from_file (OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
+{
+	if (OPJ_FSEEK(p_user_data,p_nb_bytes,SEEK_CUR)) {
+		return -1;
+	}
+
+	return p_nb_bytes;
+}
+
+static OPJ_BOOL opj_seek_from_file (OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
+{
+	if (OPJ_FSEEK(p_user_data,p_nb_bytes,SEEK_SET)) {
+		return OPJ_FALSE;
+	}
+
+	return OPJ_TRUE;
+}
+
+/* ---------------------------------------------------------------------- */
+#ifdef _WIN32
+#ifndef OPJ_STATIC
+BOOL APIENTRY
+DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
+
+	OPJ_ARG_NOT_USED(lpReserved);
+	OPJ_ARG_NOT_USED(hModule);
+
+	switch (ul_reason_for_call) {
+		case DLL_PROCESS_ATTACH :
+			break;
+		case DLL_PROCESS_DETACH :
+			break;
+		case DLL_THREAD_ATTACH :
+		case DLL_THREAD_DETACH :
+			break;
+    }
+
+    return TRUE;
+}
+#endif /* OPJ_STATIC */
+#endif /* _WIN32 */
+
+/* ---------------------------------------------------------------------- */
+
+const char* OPJ_CALLCONV opj_version(void) {
+    return OPJ_PACKAGE_VERSION;
+}
+
+/* ---------------------------------------------------------------------- */
+/* DECOMPRESSION FUNCTIONS*/
+
+opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
+{
+	opj_codec_private_t *l_codec = 00;
+
+	l_codec = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t));
+	if (!l_codec){
+		return 00;
+	}
+
+	l_codec->is_decompressor = 1;
+
+	switch (p_format) {
+		case OPJ_CODEC_J2K:
+			l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) j2k_dump;
+
+			l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) j2k_get_cstr_info;
+
+			l_codec->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) j2k_get_cstr_index;
+
+			l_codec->m_codec_data.m_decompression.opj_decode =
+					(OPJ_BOOL (*) (	void *,
+									struct opj_stream_private *,
+									opj_image_t*, struct opj_event_mgr * )) opj_j2k_decode;
+
+			l_codec->m_codec_data.m_decompression.opj_end_decompress =
+					(OPJ_BOOL (*) (	void *,
+									struct opj_stream_private *,
+									struct opj_event_mgr *)) opj_j2k_end_decompress;
+
+			l_codec->m_codec_data.m_decompression.opj_read_header =
+					(OPJ_BOOL (*) (	struct opj_stream_private *,
+									void *,
+									opj_image_t **,
+									struct opj_event_mgr * )) opj_j2k_read_header;
+
+			l_codec->m_codec_data.m_decompression.opj_destroy =
+					(void (*) (void *))opj_j2k_destroy;
+
+			l_codec->m_codec_data.m_decompression.opj_setup_decoder =
+					(void (*) (void * , opj_dparameters_t * )) opj_j2k_setup_decoder;
+
+			l_codec->m_codec_data.m_decompression.opj_read_tile_header =
+					(OPJ_BOOL (*) (	void *,
+									OPJ_UINT32*,
+									OPJ_UINT32*,
+									OPJ_INT32*, OPJ_INT32*,
+									OPJ_INT32*, OPJ_INT32*,
+									OPJ_UINT32*,
+									OPJ_BOOL*,
+									struct opj_stream_private *,
+									struct opj_event_mgr * )) opj_j2k_read_tile_header;
+
+			l_codec->m_codec_data.m_decompression.opj_decode_tile_data =
+					(OPJ_BOOL (*) ( void *, 
+                                    OPJ_UINT32, 
+                                    OPJ_BYTE*, 
+                                    OPJ_UINT32, 
+                                    struct opj_stream_private *,
+                                    struct opj_event_mgr *)) opj_j2k_decode_tile;
+
+			l_codec->m_codec_data.m_decompression.opj_set_decode_area =
+					(OPJ_BOOL (*) ( void *, 
+                                    opj_image_t*, 
+                                    OPJ_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32, 
+                                    struct opj_event_mgr *)) opj_j2k_set_decode_area;
+
+			l_codec->m_codec_data.m_decompression.opj_get_decoded_tile = 
+                    (OPJ_BOOL (*) ( void *p_codec,
+								    opj_stream_private_t *p_cio,
+								    opj_image_t *p_image,
+								    struct opj_event_mgr * p_manager,
+								    OPJ_UINT32 tile_index)) opj_j2k_get_tile;
+
+			l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = 
+                    (OPJ_BOOL (*) ( void * p_codec,
+									OPJ_UINT32 res_factor,
+									struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_resolution_factor;
+
+			l_codec->m_codec = opj_j2k_create_decompress();
+
+			if (! l_codec->m_codec) {
+				opj_free(l_codec);
+				return NULL;
+			}
+
+			break;
+
+		case OPJ_CODEC_JP2:
+			/* get a JP2 decoder handle */
+			l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, FILE*)) jp2_dump;
+
+			l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*) (void*) ) jp2_get_cstr_info;
+
+			l_codec->opj_get_codec_index = (opj_codestream_index_t* (*) (void*) ) jp2_get_cstr_index;
+
+			l_codec->m_codec_data.m_decompression.opj_decode =
+					(OPJ_BOOL (*) (	void *,
+									struct opj_stream_private *,
+									opj_image_t*,
+									struct opj_event_mgr * )) opj_jp2_decode;
+
+			l_codec->m_codec_data.m_decompression.opj_end_decompress =  
+                    (OPJ_BOOL (*) ( void *,
+                                    struct opj_stream_private *,
+                                    struct opj_event_mgr *)) opj_jp2_end_decompress;
+
+			l_codec->m_codec_data.m_decompression.opj_read_header =  
+                    (OPJ_BOOL (*) ( struct opj_stream_private *,
+					                void *,
+					                opj_image_t **,
+					                struct opj_event_mgr * )) opj_jp2_read_header;
+
+			l_codec->m_codec_data.m_decompression.opj_read_tile_header = 
+                    (OPJ_BOOL (*) ( void *,
+					                OPJ_UINT32*,
+					                OPJ_UINT32*,
+					                OPJ_INT32*,
+					                OPJ_INT32*,
+					                OPJ_INT32 * ,
+					                OPJ_INT32 * ,
+					                OPJ_UINT32 * ,
+					                OPJ_BOOL *,
+					                struct opj_stream_private *,
+					                struct opj_event_mgr * )) opj_jp2_read_tile_header;
+
+			l_codec->m_codec_data.m_decompression.opj_decode_tile_data = 
+                    (OPJ_BOOL (*) ( void *,
+                                    OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,
+                                    struct opj_stream_private *,
+                                    struct opj_event_mgr * )) opj_jp2_decode_tile;
+
+			l_codec->m_codec_data.m_decompression.opj_destroy = (void (*) (void *))opj_jp2_destroy;
+
+			l_codec->m_codec_data.m_decompression.opj_setup_decoder = 
+                    (void (*) (void * ,opj_dparameters_t * )) opj_jp2_setup_decoder;
+
+			l_codec->m_codec_data.m_decompression.opj_set_decode_area = 
+                    (OPJ_BOOL (*) ( void *,
+                                    opj_image_t*, 
+                                    OPJ_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32,
+                                    struct opj_event_mgr * )) opj_jp2_set_decode_area;
+
+			l_codec->m_codec_data.m_decompression.opj_get_decoded_tile = 
+                    (OPJ_BOOL (*) ( void *p_codec,
+									opj_stream_private_t *p_cio,
+									opj_image_t *p_image,
+									struct opj_event_mgr * p_manager,
+									OPJ_UINT32 tile_index)) opj_jp2_get_tile;
+
+			l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor = 
+                    (OPJ_BOOL (*) ( void * p_codec,
+						    		OPJ_UINT32 res_factor,
+							    	opj_event_mgr_t * p_manager)) opj_jp2_set_decoded_resolution_factor;
+
+			l_codec->m_codec = opj_jp2_create(OPJ_TRUE);
+
+			if (! l_codec->m_codec) {
+				opj_free(l_codec);
+				return 00;
+			}
+
+			break;
+		case OPJ_CODEC_UNKNOWN:
+		case OPJ_CODEC_JPT:
+		default:
+			opj_free(l_codec);
+			return 00;
+	}
+
+	opj_set_default_event_handler(&(l_codec->m_event_mgr));
+	return (opj_codec_t*) l_codec;
+}
+
+void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
+	if(parameters) {
+		memset(parameters, 0, sizeof(opj_dparameters_t));
+		/* default decoding parameters */
+		parameters->cp_layer = 0;
+		parameters->cp_reduce = 0;
+
+		parameters->decod_format = -1;
+		parameters->cod_format = -1;
+		parameters->flags = 0;		
+/* UniPG>> */
+#ifdef USE_JPWL
+		parameters->jpwl_correct = OPJ_FALSE;
+		parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
+		parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
+#endif /* USE_JPWL */
+/* <<UniPG */
+	}
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
+                                        opj_dparameters_t *parameters 
+										)
+{
+	if (p_codec && parameters) { 
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+
+		if (! l_codec->is_decompressor) {
+			opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR, 
+                "Codec provided to the opj_setup_decoder function is not a decompressor handler.\n");
+			return OPJ_FALSE;
+		}
+
+		l_codec->m_codec_data.m_decompression.opj_setup_decoder(l_codec->m_codec,
+																parameters);
+		return OPJ_TRUE;
+	}
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_read_header (	opj_stream_t *p_stream,
+										opj_codec_t *p_codec,
+										opj_image_t **p_image )
+{
+	if (p_codec && p_stream) {
+		opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
+		opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
+
+		if(! l_codec->is_decompressor) {
+			opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR, 
+                "Codec provided to the opj_read_header function is not a decompressor handler.\n");
+			return OPJ_FALSE;
+		}
+
+		return l_codec->m_codec_data.m_decompression.opj_read_header(	l_stream,
+																		l_codec->m_codec,
+																		p_image,
+																		&(l_codec->m_event_mgr) );
+	}
+
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_decode(   opj_codec_t *p_codec,
+                                    opj_stream_t *p_stream,
+                                    opj_image_t* p_image)
+{
+	if (p_codec && p_stream) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return OPJ_FALSE;
+		}
+
+		return l_codec->m_codec_data.m_decompression.opj_decode(l_codec->m_codec,
+																l_stream,
+																p_image,
+																&(l_codec->m_event_mgr) );
+	}
+
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(	opj_codec_t *p_codec,
+											opj_image_t* p_image,
+											OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
+											OPJ_INT32 p_end_x, OPJ_INT32 p_end_y
+											)
+{
+	if (p_codec) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		
+		if (! l_codec->is_decompressor) {
+			return OPJ_FALSE;
+		}
+
+		return  l_codec->m_codec_data.m_decompression.opj_set_decode_area(	l_codec->m_codec,
+																			p_image,
+																			p_start_x, p_start_y,
+																			p_end_x, p_end_y,
+																			&(l_codec->m_event_mgr) );
+	}
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(	opj_codec_t *p_codec,
+											opj_stream_t * p_stream,
+											OPJ_UINT32 * p_tile_index,
+											OPJ_UINT32 * p_data_size,
+											OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
+											OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
+											OPJ_UINT32 * p_nb_comps,
+											OPJ_BOOL * p_should_go_on)
+{
+	if (p_codec && p_stream && p_data_size && p_tile_index) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return OPJ_FALSE;
+		}
+
+		return l_codec->m_codec_data.m_decompression.opj_read_tile_header(	l_codec->m_codec,
+																			p_tile_index,
+																			p_data_size,
+																			p_tile_x0, p_tile_y0,
+																			p_tile_x1, p_tile_y1,
+																			p_nb_comps,
+																			p_should_go_on,
+																			l_stream,
+																			&(l_codec->m_event_mgr));
+	}
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(	opj_codec_t *p_codec,
+											OPJ_UINT32 p_tile_index,
+											OPJ_BYTE * p_data,
+											OPJ_UINT32 p_data_size,
+											opj_stream_t *p_stream
+											)
+{
+	if (p_codec && p_data && p_stream) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return OPJ_FALSE;
+		}
+
+		return l_codec->m_codec_data.m_decompression.opj_decode_tile_data(	l_codec->m_codec,
+																			p_tile_index,
+																			p_data,
+																			p_data_size,
+																			l_stream,
+																			&(l_codec->m_event_mgr) );
+	}
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(	opj_codec_t *p_codec,
+											opj_stream_t *p_stream,
+											opj_image_t *p_image,
+											OPJ_UINT32 tile_index)
+{
+	if (p_codec && p_stream) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return OPJ_FALSE;
+		}
+		
+		return l_codec->m_codec_data.m_decompression.opj_get_decoded_tile(	l_codec->m_codec,
+																			l_stream,
+																			p_image,
+																			&(l_codec->m_event_mgr),
+																			tile_index);
+	}
+
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, 
+														OPJ_UINT32 res_factor )
+{
+	opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+
+	if ( !l_codec ){
+		return OPJ_FALSE;
+	}
+
+	return l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor(l_codec->m_codec,
+																			res_factor,
+																			&(l_codec->m_event_mgr) );
+}
+
+/* ---------------------------------------------------------------------- */
+/* COMPRESSION FUNCTIONS*/
+
+opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
+{
+	opj_codec_private_t *l_codec = 00;
+
+	l_codec = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t));
+	if (!l_codec) {
+		return 00;
+	}
+	
+	l_codec->is_decompressor = 0;
+
+	switch(p_format) {
+		case OPJ_CODEC_J2K:
+			l_codec->m_codec_data.m_compression.opj_encode = (OPJ_BOOL (*) (void *,
+																			struct opj_stream_private *,
+																			struct opj_event_mgr * )) opj_j2k_encode;
+
+			l_codec->m_codec_data.m_compression.opj_end_compress = (OPJ_BOOL (*) (	void *,
+																					struct opj_stream_private *,
+																					struct opj_event_mgr *)) opj_j2k_end_compress;
+
+			l_codec->m_codec_data.m_compression.opj_start_compress = (OPJ_BOOL (*) (void *,
+																					struct opj_stream_private *,
+																					struct opj_image * ,
+																					struct opj_event_mgr *)) opj_j2k_start_compress;
+
+			l_codec->m_codec_data.m_compression.opj_write_tile = (OPJ_BOOL (*) (void *,
+																				OPJ_UINT32,
+																				OPJ_BYTE*,
+																				OPJ_UINT32,
+																				struct opj_stream_private *,
+																				struct opj_event_mgr *) ) opj_j2k_write_tile;
+
+			l_codec->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) opj_j2k_destroy;
+
+			l_codec->m_codec_data.m_compression.opj_setup_encoder = (OPJ_BOOL (*) (	void *,
+																				opj_cparameters_t *,
+																				struct opj_image *,
+																				struct opj_event_mgr * )) opj_j2k_setup_encoder;
+
+			l_codec->m_codec = opj_j2k_create_compress();
+			if (! l_codec->m_codec) {
+				opj_free(l_codec);
+				return 00;
+			}
+
+			break;
+
+		case OPJ_CODEC_JP2:
+			/* get a JP2 decoder handle */
+			l_codec->m_codec_data.m_compression.opj_encode = (OPJ_BOOL (*) (void *,
+																			struct opj_stream_private *,
+																			struct opj_event_mgr * )) opj_jp2_encode;
+
+			l_codec->m_codec_data.m_compression.opj_end_compress = (OPJ_BOOL (*) (	void *,
+																					struct opj_stream_private *,
+																					struct opj_event_mgr *)) opj_jp2_end_compress;
+
+			l_codec->m_codec_data.m_compression.opj_start_compress = (OPJ_BOOL (*) (void *,
+																					struct opj_stream_private *,
+																					struct opj_image * ,
+																					struct opj_event_mgr *))  opj_jp2_start_compress;
+
+			l_codec->m_codec_data.m_compression.opj_write_tile = (OPJ_BOOL (*) (void *,
+																				OPJ_UINT32,
+																				OPJ_BYTE*,
+																				OPJ_UINT32,
+																				struct opj_stream_private *,
+																				struct opj_event_mgr *)) opj_jp2_write_tile;
+
+			l_codec->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) opj_jp2_destroy;
+
+			l_codec->m_codec_data.m_compression.opj_setup_encoder = (OPJ_BOOL (*) (	void *,
+																				opj_cparameters_t *,
+																				struct opj_image *,
+																				struct opj_event_mgr * )) opj_jp2_setup_encoder;
+
+			l_codec->m_codec = opj_jp2_create(OPJ_FALSE);
+			if (! l_codec->m_codec) {
+				opj_free(l_codec);
+				return 00;
+			}
+
+			break;
+
+		case OPJ_CODEC_UNKNOWN:
+		case OPJ_CODEC_JPT:
+		default:
+			opj_free(l_codec);
+			return 00;
+	}
+
+	opj_set_default_event_handler(&(l_codec->m_event_mgr));
+	return (opj_codec_t*) l_codec;
+}
+
+void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
+	if(parameters) {
+		memset(parameters, 0, sizeof(opj_cparameters_t));
+		/* default coding parameters */
+        parameters->cp_cinema = OPJ_OFF; /* DEPRECATED */
+        parameters->rsiz = OPJ_PROFILE_NONE;
+		parameters->max_comp_size = 0;
+		parameters->numresolution = 6;
+        parameters->cp_rsiz = OPJ_STD_RSIZ; /* DEPRECATED */
+		parameters->cblockw_init = 64;
+		parameters->cblockh_init = 64;
+		parameters->prog_order = OPJ_LRCP;
+		parameters->roi_compno = -1;		/* no ROI */
+		parameters->subsampling_dx = 1;
+		parameters->subsampling_dy = 1;
+		parameters->tp_on = 0;
+		parameters->decod_format = -1;
+		parameters->cod_format = -1;
+		parameters->tcp_rates[0] = 0;   
+		parameters->tcp_numlayers = 0;
+		parameters->cp_disto_alloc = 0;
+		parameters->cp_fixed_alloc = 0;
+		parameters->cp_fixed_quality = 0;
+		parameters->jpip_on = OPJ_FALSE;
+/* UniPG>> */
+#ifdef USE_JPWL
+		parameters->jpwl_epc_on = OPJ_FALSE;
+		parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
+		{
+			int i;
+			for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
+				parameters->jpwl_hprot_TPH_tileno[i] = -1; /* unassigned */
+				parameters->jpwl_hprot_TPH[i] = 0; /* absent */
+			}
+		};
+		{
+			int i;
+			for (i = 0; i < JPWL_MAX_NO_PACKSPECS; i++) {
+				parameters->jpwl_pprot_tileno[i] = -1; /* unassigned */
+				parameters->jpwl_pprot_packno[i] = -1; /* unassigned */
+				parameters->jpwl_pprot[i] = 0; /* absent */
+			}
+		};
+		parameters->jpwl_sens_size = 0; /* 0 means no ESD */
+		parameters->jpwl_sens_addr = 0; /* 0 means auto */
+		parameters->jpwl_sens_range = 0; /* 0 means packet */
+		parameters->jpwl_sens_MH = -1; /* -1 means unassigned */
+		{
+			int i;
+			for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
+				parameters->jpwl_sens_TPH_tileno[i] = -1; /* unassigned */
+				parameters->jpwl_sens_TPH[i] = -1; /* absent */
+			}
+		};
+#endif /* USE_JPWL */
+/* <<UniPG */
+	}
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec, 
+										opj_cparameters_t *parameters, 
+										opj_image_t *p_image)
+{
+	if (p_codec && parameters && p_image) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+
+		if (! l_codec->is_decompressor) {
+			return l_codec->m_codec_data.m_compression.opj_setup_encoder(	l_codec->m_codec,
+																	parameters,
+																	p_image,
+																	&(l_codec->m_event_mgr) );
+		}
+	}
+
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_start_compress (	opj_codec_t *p_codec,
+											opj_image_t * p_image,
+											opj_stream_t *p_stream)
+{
+	if (p_codec && p_stream) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return l_codec->m_codec_data.m_compression.opj_start_compress(	l_codec->m_codec,
+																			l_stream,
+																			p_image,
+																			&(l_codec->m_event_mgr));
+		}
+	}
+
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_info, opj_stream_t *p_stream)
+{
+	if (p_info && p_stream) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_info;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return l_codec->m_codec_data.m_compression.opj_encode(	l_codec->m_codec,
+															l_stream,
+															&(l_codec->m_event_mgr));
+		}
+	}
+
+	return OPJ_FALSE;
+
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec,
+										opj_stream_t *p_stream)
+{
+	if (p_codec && p_stream) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return l_codec->m_codec_data.m_compression.opj_end_compress(l_codec->m_codec,
+																		l_stream,
+																		&(l_codec->m_event_mgr));
+		}
+	}
+	return OPJ_FALSE;
+
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_end_decompress (	opj_codec_t *p_codec,
+											opj_stream_t *p_stream)
+{
+	if (p_codec && p_stream) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (! l_codec->is_decompressor) {
+			return OPJ_FALSE;
+		}
+		
+		return l_codec->m_codec_data.m_decompression.opj_end_decompress(l_codec->m_codec,
+																		l_stream,
+																		&(l_codec->m_event_mgr) );
+	}
+
+	return OPJ_FALSE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
+                                  OPJ_FLOAT32 * pEncodingMatrix,
+                                  OPJ_INT32 * p_dc_shift,OPJ_UINT32 pNbComp)
+{
+	OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
+	OPJ_UINT32 l_dc_shift_size = pNbComp * (OPJ_UINT32)sizeof(OPJ_INT32);
+	OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
+
+	/* add MCT capability */
+    if (OPJ_IS_PART2(parameters->rsiz)) {
+        parameters->rsiz |= OPJ_EXTENSION_MCT;
+    } else {
+        parameters->rsiz = ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT));
+    }
+	parameters->irreversible = 1;
+
+	/* use array based MCT */
+	parameters->tcp_mct = 2;
+	parameters->mct_data = opj_malloc(l_mct_total_size);
+	if (! parameters->mct_data) {
+		return OPJ_FALSE;
+	}
+
+	memcpy(parameters->mct_data,pEncodingMatrix,l_matrix_size);
+	memcpy(((OPJ_BYTE *) parameters->mct_data) +  l_matrix_size,p_dc_shift,l_dc_shift_size);
+
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL OPJ_CALLCONV opj_write_tile (	opj_codec_t *p_codec,
+										OPJ_UINT32 p_tile_index,
+										OPJ_BYTE * p_data,
+										OPJ_UINT32 p_data_size,
+										opj_stream_t *p_stream )
+{
+	if (p_codec && p_stream && p_data) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+		opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
+
+		if (l_codec->is_decompressor) {
+			return OPJ_FALSE;
+		}
+
+		return l_codec->m_codec_data.m_compression.opj_write_tile(	l_codec->m_codec,
+																	p_tile_index,
+																	p_data,
+																	p_data_size,
+																	l_stream,
+																	&(l_codec->m_event_mgr) );
+	}
+
+	return OPJ_FALSE;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec)
+{
+	if (p_codec) {
+		opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+
+		if (l_codec->is_decompressor) {
+			l_codec->m_codec_data.m_decompression.opj_destroy(l_codec->m_codec);
+		}
+		else {
+			l_codec->m_codec_data.m_compression.opj_destroy(l_codec->m_codec);
+		}
+
+		l_codec->m_codec = 00;
+		opj_free(l_codec);
+	}
+}
+
+/* ---------------------------------------------------------------------- */
+
+void OPJ_CALLCONV opj_dump_codec(	opj_codec_t *p_codec,
+									OPJ_INT32 info_flag,
+									FILE* output_stream)
+{
+	if (p_codec) {
+		opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
+
+		l_codec->opj_dump_codec(l_codec->m_codec, info_flag, output_stream);
+		return;
+	}
+
+	/* TODO return error */
+	/* fprintf(stderr, "[ERROR] Input parameter of the dump_codec function are incorrect.\n"); */
+	return;
+}
+
+opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec)
+{
+	if (p_codec) {
+		opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
+
+		return l_codec->opj_get_codec_info(l_codec->m_codec);
+	}
+
+	return NULL;
+}
+
+void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info) {
+	if (cstr_info) {
+
+		if ((*cstr_info)->m_default_tile_info.tccp_info){
+			opj_free((*cstr_info)->m_default_tile_info.tccp_info);
+		}
+
+		if ((*cstr_info)->tile_info){
+			/* FIXME not used for the moment*/
+		}
+
+		opj_free((*cstr_info));
+		(*cstr_info) = NULL;
+	}
+}
+
+opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec)
+{
+	if (p_codec) {
+		opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
+
+		return l_codec->opj_get_codec_index(l_codec->m_codec);
+	}
+
+	return NULL;
+}
+
+void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index)
+{
+	if (*p_cstr_index){
+		j2k_destroy_cstr_index(*p_cstr_index);
+		(*p_cstr_index) = NULL;
+	}
+}
+
+opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream)
+{
+    return opj_stream_create_file_stream(fname, OPJ_J2K_STREAM_CHUNK_SIZE, p_is_read_stream);
+}
+
+opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (
+        const char *fname, 
+		OPJ_SIZE_T p_size, 
+        OPJ_BOOL p_is_read_stream)
+{
+    opj_stream_t* l_stream = 00;
+    FILE *p_file;
+    const char *mode;
+
+    if (! fname) {
+        return NULL;
+    }
+    
+    if(p_is_read_stream) mode = "rb"; else mode = "wb";
+
+    p_file = fopen(fname, mode);
+
+    if (! p_file) {
+	    return NULL;
+    }
+
+    l_stream = opj_stream_create(p_size,p_is_read_stream);
+    if (! l_stream) {
+        fclose(p_file);
+        return NULL;
+    }
+
+    opj_stream_set_user_data(l_stream, p_file, (opj_stream_free_user_data_fn) fclose);
+    opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(p_file));
+    opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_file);
+    opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);
+    opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_file);
+    opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_file);
+
+    return l_stream;
+}
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.h
new file mode 100644
index 0000000..c4f6832
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg.h
@@ -0,0 +1,1564 @@
+ /*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2006-2007, Parvatha Elangovan
+ * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef OPENJPEG_H
+#define OPENJPEG_H
+
+
+/* 
+==========================================================
+   Compiler directives
+==========================================================
+*/
+
+/*
+The inline keyword is supported by C99 but not by C90. 
+Most compilers implement their own version of this keyword ... 
+*/
+#ifndef INLINE
+	#if defined(_MSC_VER)
+		#define INLINE __forceinline
+	#elif defined(__GNUC__)
+		#define INLINE __inline__
+	#elif defined(__MWERKS__)
+		#define INLINE inline
+	#else 
+		/* add other compilers here ... */
+		#define INLINE 
+	#endif /* defined(<Compiler>) */
+#endif /* INLINE */
+
+/* deprecated attribute */
+#ifdef __GNUC__
+	#define OPJ_DEPRECATED(func) func __attribute__ ((deprecated))
+#elif defined(_MSC_VER)
+	#define OPJ_DEPRECATED(func) __declspec(deprecated) func
+#else
+	#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
+	#define OPJ_DEPRECATED(func) func
+#endif
+
+#if defined(OPJ_STATIC) || !defined(_WIN32)
+/* http://gcc.gnu.org/wiki/Visibility */
+#	if __GNUC__ >= 4
+#		if defined(OPJ_STATIC) /* static library uses "hidden" */
+#			define OPJ_API    __attribute__ ((visibility ("hidden")))
+#		else
+#			define OPJ_API    __attribute__ ((visibility ("default")))
+#		endif
+#		define OPJ_LOCAL  __attribute__ ((visibility ("hidden")))
+#	else
+#		define OPJ_API
+#		define OPJ_LOCAL
+#	endif
+#	define OPJ_CALLCONV
+#else
+#	define OPJ_CALLCONV __stdcall
+/*
+The following ifdef block is the standard way of creating macros which make exporting 
+from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
+symbol defined on the command line. this symbol should not be defined on any project
+that uses this DLL. This way any other project whose source files include this file see 
+OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols
+defined with this macro as being exported.
+*/
+#	if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
+#		define OPJ_API __declspec(dllexport)
+#	else
+#		define OPJ_API __declspec(dllimport)
+#	endif /* OPJ_EXPORTS */
+#endif /* !OPJ_STATIC || !_WIN32 */
+
+typedef int OPJ_BOOL;
+#define OPJ_TRUE 1
+#define OPJ_FALSE 0
+
+typedef char          OPJ_CHAR;
+typedef float         OPJ_FLOAT32;
+typedef double        OPJ_FLOAT64;
+typedef unsigned char OPJ_BYTE;
+
+#include "openjpeg_mangle.h"
+#include "opj_stdint.h"
+
+typedef int8_t   OPJ_INT8;
+typedef uint8_t  OPJ_UINT8;
+typedef int16_t  OPJ_INT16;
+typedef uint16_t OPJ_UINT16;
+typedef int32_t  OPJ_INT32;
+typedef uint32_t OPJ_UINT32;
+typedef int64_t  OPJ_INT64;
+typedef uint64_t OPJ_UINT64;
+
+typedef int64_t  OPJ_OFF_T; /* 64-bit file offset type */
+
+#include <stdio.h>
+typedef size_t   OPJ_SIZE_T;
+
+/* Avoid compile-time warning because parameter is not used */
+#define OPJ_ARG_NOT_USED(x) (void)(x)
+
+/* 
+==========================================================
+   Useful constant definitions
+==========================================================
+*/
+
+#define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
+
+#define OPJ_J2K_MAXRLVLS 33					/**< Number of maximum resolution level authorized */
+#define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2)	/**< Number of maximum sub-band linked to number of resolution level */
+
+#define OPJ_J2K_DEFAULT_NB_SEGS				10
+#define OPJ_J2K_STREAM_CHUNK_SIZE			0x100000 /** 1 mega by default */
+#define OPJ_J2K_DEFAULT_HEADER_SIZE			1000
+#define OPJ_J2K_MCC_DEFAULT_NB_RECORDS		10
+#define OPJ_J2K_MCT_DEFAULT_NB_RECORDS		10
+
+/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
+#define JPWL_MAX_NO_TILESPECS	16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
+#define JPWL_MAX_NO_PACKSPECS	16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
+#define JPWL_MAX_NO_MARKERS	512 /**< Maximum number of JPWL markers: increase at your will */
+#define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
+#define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
+#define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
+#define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
+#define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
+/* <<UniPG */
+
+/**
+ * EXPERIMENTAL FOR THE MOMENT
+ * Supported options about file information used only in j2k_dump
+*/
+#define OPJ_IMG_INFO		1	/**< Basic image information provided to the user */
+#define OPJ_J2K_MH_INFO		2	/**< Codestream information based only on the main header */
+#define OPJ_J2K_TH_INFO		4	/**< Tile information based on the current tile header */
+#define OPJ_J2K_TCH_INFO	8	/**< Tile/Component information of all tiles */
+#define OPJ_J2K_MH_IND		16	/**< Codestream index based only on the main header */
+#define OPJ_J2K_TH_IND		32	/**< Tile index based on the current tile */
+/*FIXME #define OPJ_J2K_CSTR_IND	48*/	/**<  */
+#define OPJ_JP2_INFO		128	/**< JP2 file information */
+#define OPJ_JP2_IND			256	/**< JP2 file index */
+
+/**
+ * JPEG 2000 Profiles, see Table A.10 from 15444-1 (updated in various AMD)
+ * These values help chosing the RSIZ value for the J2K codestream.
+ * The RSIZ value triggers various encoding options, as detailed in Table A.10.
+ * If OPJ_PROFILE_PART2 is chosen, it has to be combined with one or more extensions
+ * described hereunder.
+ *   Example: rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT;
+ * For broadcast profiles, the OPJ_PROFILE value has to be combined with the targeted
+ * mainlevel (3-0 LSB, value between 0 and 11):
+ *   Example: rsiz = OPJ_PROFILE_BC_MULTI | 0x0005; (here mainlevel 5)
+ * For IMF profiles, the OPJ_PROFILE value has to be combined with the targeted mainlevel
+ * (3-0 LSB, value between 0 and 11) and sublevel (7-4 LSB, value between 0 and 9):
+ *   Example: rsiz = OPJ_PROFILE_IMF_2K | 0x0040 | 0x0005; (here main 5 and sublevel 4)
+ * */
+#define OPJ_PROFILE_NONE        0x0000 /** no profile, conform to 15444-1 */
+#define OPJ_PROFILE_0           0x0001 /** Profile 0 as described in 15444-1,Table A.45 */
+#define OPJ_PROFILE_1           0x0002 /** Profile 1 as described in 15444-1,Table A.45 */
+#define OPJ_PROFILE_PART2       0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */
+#define OPJ_PROFILE_CINEMA_2K   0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */
+#define OPJ_PROFILE_CINEMA_4K   0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */
+#define OPJ_PROFILE_CINEMA_S2K  0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */
+#define OPJ_PROFILE_CINEMA_S4K  0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */
+#define OPJ_PROFILE_CINEMA_LTS  0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */
+#define OPJ_PROFILE_BC_SINGLE   0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */
+#define OPJ_PROFILE_BC_MULTI    0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */
+#define OPJ_PROFILE_BC_MULTI_R  0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */
+#define OPJ_PROFILE_IMF_2K      0x0400 /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
+#define OPJ_PROFILE_IMF_4K      0x0401 /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
+#define OPJ_PROFILE_IMF_8K      0x0402 /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
+#define OPJ_PROFILE_IMF_2K_R    0x0403 /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
+#define OPJ_PROFILE_IMF_4K_R    0x0800 /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
+#define OPJ_PROFILE_IMF_8K_R    0x0801  /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
+
+/**
+ * JPEG 2000 Part-2 extensions
+ * */
+#define OPJ_EXTENSION_NONE      0x0000 /** No Part-2 extension */
+#define OPJ_EXTENSION_MCT       0x0100  /** Custom MCT support */
+
+/**
+ * JPEG 2000 profile macros
+ * */
+#define OPJ_IS_CINEMA(v)     (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K))
+#define OPJ_IS_STORAGE(v)    ((v) == OPJ_PROFILE_CINEMA_LTS)
+#define OPJ_IS_BROADCAST(v)  (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b))))
+#define OPJ_IS_IMF(v)        (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b))))
+#define OPJ_IS_PART2(v)      ((v) & OPJ_PROFILE_PART2)
+
+/**
+ * JPEG 2000 codestream and component size limits in cinema profiles
+ * */
+#define OPJ_CINEMA_24_CS     1302083   	/** Maximum codestream length for 24fps */
+#define OPJ_CINEMA_48_CS     651041     /** Maximum codestream length for 48fps */
+#define OPJ_CINEMA_24_COMP   1041666    /** Maximum size per color component for 2K & 4K @ 24fps */
+#define OPJ_CINEMA_48_COMP   520833		/** Maximum size per color component for 2K @ 48fps */
+
+/* 
+==========================================================
+   enum definitions
+==========================================================
+*/
+
+/**
+ * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
+ * Rsiz Capabilities
+ * */
+typedef enum RSIZ_CAPABILITIES {
+    OPJ_STD_RSIZ = 0,		/** Standard JPEG2000 profile*/
+    OPJ_CINEMA2K = 3,		/** Profile name for a 2K image*/
+    OPJ_CINEMA4K = 4,		/** Profile name for a 4K image*/
+    OPJ_MCT = 0x8100
+} OPJ_RSIZ_CAPABILITIES;
+
+/**
+ * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
+ * Digital cinema operation mode
+ * */
+typedef enum CINEMA_MODE {
+    OPJ_OFF = 0,			/** Not Digital Cinema*/
+    OPJ_CINEMA2K_24 = 1,	/** 2K Digital Cinema at 24 fps*/
+    OPJ_CINEMA2K_48 = 2,	/** 2K Digital Cinema at 48 fps*/
+    OPJ_CINEMA4K_24 = 3		/** 4K Digital Cinema at 24 fps*/
+}OPJ_CINEMA_MODE;
+
+/** 
+ * Progression order
+ * */
+typedef enum PROG_ORDER {
+	OPJ_PROG_UNKNOWN = -1,	/**< place-holder */
+	OPJ_LRCP = 0,			/**< layer-resolution-component-precinct order */
+	OPJ_RLCP = 1,			/**< resolution-layer-component-precinct order */
+	OPJ_RPCL = 2,			/**< resolution-precinct-component-layer order */
+	OPJ_PCRL = 3,			/**< precinct-component-resolution-layer order */
+	OPJ_CPRL = 4			/**< component-precinct-resolution-layer order */
+} OPJ_PROG_ORDER;
+
+/**
+ * Supported image color spaces
+*/
+typedef enum COLOR_SPACE {
+    OPJ_CLRSPC_UNKNOWN = -1,	/**< not supported by the library */
+    OPJ_CLRSPC_UNSPECIFIED = 0,	/**< not specified in the codestream */
+    OPJ_CLRSPC_SRGB = 1,		/**< sRGB */
+    OPJ_CLRSPC_GRAY = 2,		/**< grayscale */
+    OPJ_CLRSPC_SYCC = 3,		/**< YUV */
+    OPJ_CLRSPC_EYCC = 4,        /**< e-YCC */
+    OPJ_CLRSPC_CMYK = 5         /**< CMYK */
+} OPJ_COLOR_SPACE;
+
+/**
+ * Supported codec
+*/
+typedef enum CODEC_FORMAT {
+	OPJ_CODEC_UNKNOWN = -1,	/**< place-holder */
+	OPJ_CODEC_J2K  = 0,		/**< JPEG-2000 codestream : read/write */
+	OPJ_CODEC_JPT  = 1,		/**< JPT-stream (JPEG 2000, JPIP) : read only */
+    OPJ_CODEC_JP2  = 2,		/**< JP2 file format : read/write */
+    OPJ_CODEC_JPP  = 3,		/**< JPP-stream (JPEG 2000, JPIP) : to be coded */
+    OPJ_CODEC_JPX  = 4		/**< JPX file format (JPEG 2000 Part-2) : to be coded */
+} OPJ_CODEC_FORMAT;
+
+
+/* 
+==========================================================
+   event manager typedef definitions
+==========================================================
+*/
+
+/**
+ * Callback function prototype for events
+ * @param msg               Event message
+ * @param client_data       Client object where will be return the event message 
+ * */
+typedef void (*opj_msg_callback) (const char *msg, void *client_data);
+
+/* 
+==========================================================
+   codec typedef definitions
+==========================================================
+*/
+
+/**
+ * Progression order changes
+ * 
+ */
+typedef struct opj_poc {
+	/** Resolution num start, Component num start, given by POC */
+	OPJ_UINT32 resno0, compno0;
+	/** Layer num end,Resolution num end, Component num end, given by POC */
+	OPJ_UINT32 layno1, resno1, compno1;
+	/** Layer num start,Precinct num start, Precinct num end */
+	OPJ_UINT32 layno0, precno0, precno1;
+	/** Progression order enum*/
+	OPJ_PROG_ORDER prg1,prg;
+	/** Progression order string*/
+	OPJ_CHAR progorder[5];
+	/** Tile number */
+	OPJ_UINT32 tile;
+	/** Start and end values for Tile width and height*/
+	OPJ_INT32 tx0,tx1,ty0,ty1;
+	/** Start value, initialised in pi_initialise_encode*/
+	OPJ_UINT32 layS, resS, compS, prcS;
+	/** End value, initialised in pi_initialise_encode */
+	OPJ_UINT32 layE, resE, compE, prcE;
+	/** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
+	OPJ_UINT32 txS,txE,tyS,tyE,dx,dy;
+	/** Temporary values for Tile parts, initialised in pi_create_encode */
+	OPJ_UINT32 lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
+} opj_poc_t;
+
+/**
+ * Compression parameters
+ * */
+typedef struct opj_cparameters {
+	/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
+	OPJ_BOOL tile_size_on;
+	/** XTOsiz */
+	int cp_tx0;
+	/** YTOsiz */
+	int cp_ty0;
+	/** XTsiz */
+	int cp_tdx;
+	/** YTsiz */
+	int cp_tdy;
+	/** allocation by rate/distortion */
+	int cp_disto_alloc;
+	/** allocation by fixed layer */
+	int cp_fixed_alloc;
+	/** add fixed_quality */
+	int cp_fixed_quality;
+	/** fixed layer */
+	int *cp_matrice;
+	/** comment for coding */
+	char *cp_comment;
+	/** csty : coding style */
+	int csty;
+	/** progression order (default OPJ_LRCP) */
+	OPJ_PROG_ORDER prog_order;
+	/** progression order changes */
+	opj_poc_t POC[32];
+	/** number of progression order changes (POC), default to 0 */
+	OPJ_UINT32 numpocs;
+	/** number of layers */
+	int tcp_numlayers;
+    /** rates of layers - might be subsequently limited by the max_cs_size field */
+	float tcp_rates[100];
+	/** different psnr for successive layers */
+	float tcp_distoratio[100];
+	/** number of resolutions */
+	int numresolution;
+	/** initial code block width, default to 64 */
+ 	int cblockw_init;
+	/** initial code block height, default to 64 */
+	int cblockh_init;
+	/** mode switch (cblk_style) */
+	int mode;
+	/** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
+	int irreversible;
+	/** region of interest: affected component in [0..3], -1 means no ROI */
+	int roi_compno;
+	/** region of interest: upshift value */
+	int roi_shift;
+	/* number of precinct size specifications */
+	int res_spec;
+	/** initial precinct width */
+	int prcw_init[OPJ_J2K_MAXRLVLS];
+	/** initial precinct height */
+	int prch_init[OPJ_J2K_MAXRLVLS];
+
+	/**@name command line encoder parameters (not used inside the library) */
+	/*@{*/
+	/** input file name */
+	char infile[OPJ_PATH_LEN];
+	/** output file name */
+	char outfile[OPJ_PATH_LEN];
+	/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
+	int index_on;
+	/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
+	char index[OPJ_PATH_LEN];
+	/** subimage encoding: origin image offset in x direction */
+	int image_offset_x0;
+	/** subimage encoding: origin image offset in y direction */
+	int image_offset_y0;
+	/** subsampling value for dx */
+	int subsampling_dx;
+	/** subsampling value for dy */
+	int subsampling_dy;
+	/** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
+	int decod_format;
+	/** output file format 0: J2K, 1: JP2, 2: JPT */
+	int cod_format;
+	/*@}*/
+
+/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
+	/**@name JPWL encoding parameters */
+	/*@{*/
+	/** enables writing of EPC in MH, thus activating JPWL */
+	OPJ_BOOL jpwl_epc_on;
+	/** error protection method for MH (0,1,16,32,37-128) */
+	int jpwl_hprot_MH;
+	/** tile number of header protection specification (>=0) */
+	int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
+	/** error protection methods for TPHs (0,1,16,32,37-128) */
+	int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
+	/** tile number of packet protection specification (>=0) */
+	int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
+	/** packet number of packet protection specification (>=0) */
+	int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
+	/** error protection methods for packets (0,1,16,32,37-128) */
+	int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
+	/** enables writing of ESD, (0=no/1/2 bytes) */
+	int jpwl_sens_size;
+	/** sensitivity addressing size (0=auto/2/4 bytes) */
+	int jpwl_sens_addr;
+	/** sensitivity range (0-3) */
+	int jpwl_sens_range;
+	/** sensitivity method for MH (-1=no,0-7) */
+	int jpwl_sens_MH;
+	/** tile number of sensitivity specification (>=0) */
+	int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
+	/** sensitivity methods for TPHs (-1=no,0-7) */
+	int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
+	/*@}*/
+/* <<UniPG */
+
+    /**
+     * DEPRECATED: use RSIZ, OPJ_PROFILE_* and MAX_COMP_SIZE instead
+     * Digital Cinema compliance 0-not compliant, 1-compliant
+     * */
+    OPJ_CINEMA_MODE cp_cinema;
+    /**
+     * Maximum size (in bytes) for each component.
+     * If == 0, component size limitation is not considered
+     * */
+	int max_comp_size;
+    /**
+     * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead
+     * Profile name
+     * */
+    OPJ_RSIZ_CAPABILITIES cp_rsiz;
+	/** Tile part generation*/
+	char tp_on;
+	/** Flag for Tile part generation*/
+	char tp_flag;
+	/** MCT (multiple component transform) */
+	char tcp_mct;
+	/** Enable JPIP indexing*/
+	OPJ_BOOL jpip_on;
+	/** Naive implementation of MCT restricted to a single reversible array based 
+        encoding without offset concerning all the components. */
+	void * mct_data;
+    /**
+     * Maximum size (in bytes) for the whole codestream.
+     * If == 0, codestream size limitation is not considered
+     * If it does not comply with tcp_rates, max_cs_size prevails
+     * and a warning is issued.
+     * */
+    int max_cs_size;
+    /** RSIZ value
+        To be used to combine OPJ_PROFILE_*, OPJ_EXTENSION_* and (sub)levels values. */
+    OPJ_UINT16 rsiz;
+} opj_cparameters_t;  
+
+#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG	0x0001
+
+/**
+ * Decompression parameters
+ * */
+typedef struct opj_dparameters {
+	/** 
+	Set the number of highest resolution levels to be discarded. 
+	The image resolution is effectively divided by 2 to the power of the number of discarded levels. 
+	The reduce factor is limited by the smallest total number of decomposition levels among tiles.
+	if != 0, then original dimension divided by 2^(reduce); 
+	if == 0 or not used, image is decoded to the full resolution 
+	*/
+	OPJ_UINT32 cp_reduce;
+	/** 
+	Set the maximum number of quality layers to decode. 
+	If there are less quality layers than the specified number, all the quality layers are decoded.
+	if != 0, then only the first "layer" layers are decoded; 
+	if == 0 or not used, all the quality layers are decoded 
+	*/
+	OPJ_UINT32 cp_layer;
+
+	/**@name command line decoder parameters (not used inside the library) */
+	/*@{*/
+	/** input file name */
+	char infile[OPJ_PATH_LEN];
+	/** output file name */
+	char outfile[OPJ_PATH_LEN];
+	/** input file format 0: J2K, 1: JP2, 2: JPT */
+	int decod_format;
+	/** output file format 0: PGX, 1: PxM, 2: BMP */
+	int cod_format;
+
+	/** Decoding area left boundary */
+	OPJ_UINT32 DA_x0;
+	/** Decoding area right boundary */
+	OPJ_UINT32 DA_x1;
+	/** Decoding area up boundary */
+	OPJ_UINT32 DA_y0;
+	/** Decoding area bottom boundary */
+	OPJ_UINT32 DA_y1;
+	/** Verbose mode */
+	OPJ_BOOL m_verbose;
+
+	/** tile number ot the decoded tile*/
+	OPJ_UINT32 tile_index;
+	/** Nb of tile to decode */
+	OPJ_UINT32 nb_tile_to_decode;
+
+	/*@}*/
+
+/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
+	/**@name JPWL decoding parameters */
+	/*@{*/
+	/** activates the JPWL correction capabilities */
+	OPJ_BOOL jpwl_correct;
+	/** expected number of components */
+	int jpwl_exp_comps;
+	/** maximum number of tiles */
+	int jpwl_max_tiles;
+	/*@}*/
+/* <<UniPG */
+
+	unsigned int flags;
+
+} opj_dparameters_t;
+
+
+/**
+ * JPEG2000 codec V2.
+ * */
+typedef void * opj_codec_t;
+
+/* 
+==========================================================
+   I/O stream typedef definitions
+==========================================================
+*/
+
+/**
+ * Stream open flags.
+ * */
+/** The stream was opened for reading. */
+#define OPJ_STREAM_READ	OPJ_TRUE
+/** The stream was opened for writing. */
+#define OPJ_STREAM_WRITE OPJ_FALSE
+
+/*
+ * Callback function prototype for read function
+ */
+typedef OPJ_SIZE_T (* opj_stream_read_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
+
+/*
+ * Callback function prototype for write function
+ */
+typedef OPJ_SIZE_T (* opj_stream_write_fn) (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ;
+
+/*
+ * Callback function prototype for skip function
+ */
+typedef OPJ_OFF_T (* opj_stream_skip_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
+
+/*
+ * Callback function prototype for seek function
+ */
+typedef OPJ_BOOL (* opj_stream_seek_fn) (OPJ_OFF_T p_nb_bytes, void * p_user_data) ;
+
+/*
+ * Callback function prototype for free user data function
+ */
+typedef void (* opj_stream_free_user_data_fn) (void * p_user_data) ;
+
+/*
+ * JPEG2000 Stream.
+ */
+typedef void * opj_stream_t;
+
+/* 
+==========================================================
+   image typedef definitions
+==========================================================
+*/
+
+/**
+ * Defines a single image component
+ * */
+typedef struct opj_image_comp {
+	/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
+	OPJ_UINT32 dx;
+	/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
+	OPJ_UINT32 dy;
+	/** data width */
+	OPJ_UINT32 w;
+	/** data height */
+	OPJ_UINT32 h;
+	/** x component offset compared to the whole image */
+	OPJ_UINT32 x0;
+	/** y component offset compared to the whole image */
+	OPJ_UINT32 y0;
+	/** precision */
+	OPJ_UINT32 prec;
+	/** image depth in bits */
+	OPJ_UINT32 bpp;
+	/** signed (1) / unsigned (0) */
+	OPJ_UINT32 sgnd;
+	/** number of decoded resolution */
+	OPJ_UINT32 resno_decoded;
+	/** number of division by 2 of the out image compared to the original size of image */
+	OPJ_UINT32 factor;
+	/** image component data */
+	OPJ_INT32 *data;
+  /** alpha channel */
+  OPJ_UINT16 alpha;
+} opj_image_comp_t;
+
+/** 
+ * Defines image data and characteristics
+ * */
+typedef struct opj_image {
+	/** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
+	OPJ_UINT32 x0;
+	/** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
+	OPJ_UINT32 y0;
+	/** Xsiz: width of the reference grid */
+	OPJ_UINT32 x1;
+	/** Ysiz: height of the reference grid */
+	OPJ_UINT32 y1;
+	/** number of components in the image */
+	OPJ_UINT32 numcomps;
+	/** color space: sRGB, Greyscale or YUV */
+	OPJ_COLOR_SPACE color_space;
+	/** image components */
+	opj_image_comp_t *comps;
+	/** 'restricted' ICC profile */
+	OPJ_BYTE *icc_profile_buf;
+	/** size of ICC profile */
+	OPJ_UINT32 icc_profile_len;
+} opj_image_t;
+
+
+/**
+ * Component parameters structure used by the opj_image_create function
+ * */
+typedef struct opj_image_comptparm {
+	/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
+	OPJ_UINT32 dx;
+	/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
+	OPJ_UINT32 dy;
+	/** data width */
+	OPJ_UINT32 w;
+	/** data height */
+	OPJ_UINT32 h;
+	/** x component offset compared to the whole image */
+	OPJ_UINT32 x0;
+	/** y component offset compared to the whole image */
+	OPJ_UINT32 y0;
+	/** precision */
+	OPJ_UINT32 prec;
+	/** image depth in bits */
+	OPJ_UINT32 bpp;
+	/** signed (1) / unsigned (0) */
+	OPJ_UINT32 sgnd;
+} opj_image_cmptparm_t;
+
+
+/* 
+==========================================================
+   Information on the JPEG 2000 codestream
+==========================================================
+*/
+/* QUITE EXPERIMENTAL FOR THE MOMENT */
+
+/**
+ * Index structure : Information concerning a packet inside tile
+ * */
+typedef struct opj_packet_info {
+	/** packet start position (including SOP marker if it exists) */
+	OPJ_OFF_T start_pos;
+	/** end of packet header position (including EPH marker if it exists)*/
+	OPJ_OFF_T end_ph_pos;
+	/** packet end position */
+	OPJ_OFF_T end_pos;
+	/** packet distorsion */
+	double disto;
+} opj_packet_info_t;
+
+
+/* UniPG>> */
+/**
+ * Marker structure
+ * */
+typedef struct opj_marker_info {
+	/** marker type */
+	unsigned short int type;
+	/** position in codestream */
+	OPJ_OFF_T pos;
+	/** length, marker val included */
+	int len;
+} opj_marker_info_t;
+/* <<UniPG */
+
+/**
+ * Index structure : Information concerning tile-parts
+*/
+typedef struct opj_tp_info {
+	/** start position of tile part */
+	int tp_start_pos;
+	/** end position of tile part header */
+	int tp_end_header;
+	/** end position of tile part */
+	int tp_end_pos;
+	/** start packet of tile part */
+	int tp_start_pack;
+	/** number of packets of tile part */
+	int tp_numpacks;
+} opj_tp_info_t;
+
+/**
+ * Index structure : information regarding tiles
+*/
+typedef struct opj_tile_info {
+	/** value of thresh for each layer by tile cfr. Marcela   */
+	double *thresh;
+	/** number of tile */
+	int tileno;
+	/** start position */
+	int start_pos;
+	/** end position of the header */
+	int end_header;
+	/** end position */
+	int end_pos;
+	/** precinct number for each resolution level (width) */
+	int pw[33];
+	/** precinct number for each resolution level (height) */
+	int ph[33];
+	/** precinct size (in power of 2), in X for each resolution level */
+	int pdx[33];
+	/** precinct size (in power of 2), in Y for each resolution level */
+	int pdy[33];
+	/** information concerning packets inside tile */
+	opj_packet_info_t *packet;
+	/** add fixed_quality */
+	int numpix;
+	/** add fixed_quality */
+	double distotile;
+  	/** number of markers */
+	int marknum;
+	/** list of markers */
+	opj_marker_info_t *marker;
+	/** actual size of markers array */
+	int maxmarknum;
+	/** number of tile parts */
+	int num_tps;
+	/** information concerning tile parts */
+	opj_tp_info_t *tp;
+} opj_tile_info_t;
+
+/**
+ * Index structure of the codestream
+*/
+typedef struct opj_codestream_info {
+	/** maximum distortion reduction on the whole image (add for Marcela) */
+	double D_max;
+	/** packet number */
+	int packno;
+	/** writing the packet in the index with t2_encode_packets */
+	int index_write;
+	/** image width */
+	int image_w;
+	/** image height */
+	int image_h;
+	/** progression order */
+	OPJ_PROG_ORDER prog;
+	/** tile size in x */
+	int tile_x;
+	/** tile size in y */
+	int tile_y;
+	/** */
+	int tile_Ox;
+	/** */
+	int tile_Oy;
+	/** number of tiles in X */
+	int tw;
+	/** number of tiles in Y */
+	int th;
+	/** component numbers */
+	int numcomps;
+	/** number of layer */
+	int numlayers;
+	/** number of decomposition for each component */
+	int *numdecompos;
+/* UniPG>> */
+	/** number of markers */
+	int marknum;
+	/** list of markers */
+	opj_marker_info_t *marker;
+	/** actual size of markers array */
+	int maxmarknum;
+/* <<UniPG */
+	/** main header position */
+	int main_head_start;
+	/** main header position */
+	int main_head_end;
+	/** codestream's size */
+	int codestream_size;
+	/** information regarding tiles inside image */
+	opj_tile_info_t *tile;
+} opj_codestream_info_t;
+
+/* <----------------------------------------------------------- */
+/* new output management of the codestream information and index */
+
+/**
+ * Tile-component coding parameters information
+ */
+typedef struct opj_tccp_info
+{
+	/** component index */
+	OPJ_UINT32 compno;
+	/** coding style */
+	OPJ_UINT32 csty;
+	/** number of resolutions */
+	OPJ_UINT32 numresolutions;
+	/** code-blocks width */
+	OPJ_UINT32 cblkw;
+	/** code-blocks height */
+	OPJ_UINT32 cblkh;
+	/** code-block coding style */
+	OPJ_UINT32 cblksty;
+	/** discrete wavelet transform identifier */
+	OPJ_UINT32 qmfbid;
+	/** quantisation style */
+	OPJ_UINT32 qntsty;
+	/** stepsizes used for quantization */
+	OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS];
+	/** stepsizes used for quantization */
+	OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS];
+	/** number of guard bits */
+	OPJ_UINT32 numgbits;
+	/** Region Of Interest shift */
+	OPJ_INT32 roishift;
+	/** precinct width */
+	OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS];
+	/** precinct height */
+	OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS];
+}
+opj_tccp_info_t;
+
+/**
+ * Tile coding parameters information
+ */
+typedef struct opj_tile_v2_info {
+
+	/** number (index) of tile */
+	int tileno;
+	/** coding style */
+	OPJ_UINT32 csty;
+	/** progression order */
+	OPJ_PROG_ORDER prg;
+	/** number of layers */
+	OPJ_UINT32 numlayers;
+	/** multi-component transform identifier */
+	OPJ_UINT32 mct;
+
+	/** information concerning tile component parameters*/
+	opj_tccp_info_t *tccp_info;
+
+} opj_tile_info_v2_t;
+
+/**
+ * Information structure about the codestream (FIXME should be expand and enhance)
+ */
+typedef struct opj_codestream_info_v2 {
+	/* Tile info */
+	/** tile origin in x = XTOsiz */
+	OPJ_UINT32 tx0;
+	/** tile origin in y = YTOsiz */
+	OPJ_UINT32 ty0;
+	/** tile size in x = XTsiz */
+	OPJ_UINT32 tdx;
+	/** tile size in y = YTsiz */
+	OPJ_UINT32 tdy;
+	/** number of tiles in X */
+	OPJ_UINT32 tw;
+	/** number of tiles in Y */
+	OPJ_UINT32 th;
+
+	/** number of components*/
+	OPJ_UINT32 nbcomps;
+
+	/** Default information regarding tiles inside image */
+	opj_tile_info_v2_t m_default_tile_info;
+
+	/** information regarding tiles inside image */
+	opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */
+
+} opj_codestream_info_v2_t;
+
+
+/**
+ * Index structure about a tile part
+ */
+typedef struct opj_tp_index {
+	/** start position */
+	OPJ_OFF_T start_pos;
+	/** end position of the header */
+	OPJ_OFF_T end_header;
+	/** end position */
+	OPJ_OFF_T end_pos;
+
+} opj_tp_index_t;
+
+/**
+ * Index structure about a tile
+ */
+typedef struct opj_tile_index {
+	/** tile index */
+	OPJ_UINT32 tileno;
+
+	/** number of tile parts */
+	OPJ_UINT32 nb_tps;
+	/** current nb of tile part (allocated)*/
+	OPJ_UINT32 current_nb_tps;
+	/** current tile-part index */
+	OPJ_UINT32 current_tpsno;
+	/** information concerning tile parts */
+	opj_tp_index_t *tp_index;
+
+	/* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
+		/** number of markers */
+		OPJ_UINT32 marknum;
+		/** list of markers */
+		opj_marker_info_t *marker;
+		/** actual size of markers array */
+		OPJ_UINT32 maxmarknum;
+	/* <<UniPG */
+
+	/** packet number */
+	OPJ_UINT32 nb_packet;
+	/** information concerning packets inside tile */
+	opj_packet_info_t *packet_index;
+
+} opj_tile_index_t;
+
+/**
+ * Index structure of the codestream (FIXME should be expand and enhance)
+ */
+typedef struct opj_codestream_index {
+	/** main header start position (SOC position) */
+	OPJ_OFF_T main_head_start;
+	/** main header end position (first SOT position) */
+	OPJ_OFF_T main_head_end;
+
+	/** codestream's size */
+	OPJ_UINT64 codestream_size;
+
+/* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */
+	/** number of markers */
+	OPJ_UINT32 marknum;
+	/** list of markers */
+	opj_marker_info_t *marker;
+	/** actual size of markers array */
+	OPJ_UINT32 maxmarknum;
+/* <<UniPG */
+
+	/** */
+	OPJ_UINT32 nb_of_tiles;
+	/** */
+	opj_tile_index_t *tile_index; /* FIXME not used for the moment */
+
+}opj_codestream_index_t;
+/* -----------------------------------------------------------> */
+
+/*
+==========================================================
+   Metadata from the JP2file
+==========================================================
+*/
+
+/**
+ * Info structure of the JP2 file
+ * EXPERIMENTAL FOR THE MOMENT
+ */
+typedef struct opj_jp2_metadata {
+	/** */
+	OPJ_INT32	not_used;
+
+} opj_jp2_metadata_t;
+
+/**
+ * Index structure of the JP2 file
+ * EXPERIMENTAL FOR THE MOMENT
+ */
+typedef struct opj_jp2_index {
+	/** */
+	OPJ_INT32	not_used;
+
+} opj_jp2_index_t;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* 
+==========================================================
+   openjpeg version
+==========================================================
+*/
+
+/* Get the version of the openjpeg library*/
+OPJ_API const char * OPJ_CALLCONV opj_version(void);
+
+/* 
+==========================================================
+   image functions definitions
+==========================================================
+*/
+
+/**
+ * Create an image
+ *
+ * @param numcmpts      number of components
+ * @param cmptparms     components parameters
+ * @param clrspc        image color space
+ * @return returns      a new image structure if successful, returns NULL otherwise
+ * */
+OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
+
+/**
+ * Deallocate any resources associated with an image
+ *
+ * @param image         image to be destroyed
+ */
+OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
+
+/**
+ * Creates an image without allocating memory for the image (used in the new version of the library).
+ *
+ * @param	numcmpts    the number of components
+ * @param	cmptparms   the components parameters
+ * @param	clrspc      the image color space
+ *
+ * @return	a new image structure if successful, NULL otherwise.
+*/
+OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
+
+/* 
+==========================================================
+   stream functions definitions
+==========================================================
+*/
+
+/**
+ * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
+ *
+ * @param	p_is_input		if set to true then the stream will be an input stream, an output stream else.
+ *
+ * @return	a stream object.
+*/
+OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create(OPJ_BOOL p_is_input);
+
+/**
+ * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
+ *
+ * @param	p_buffer_size  FIXME DOC
+ * @param	p_is_input		if set to true then the stream will be an input stream, an output stream else.
+ *
+ * @return	a stream object.
+*/
+OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, OPJ_BOOL p_is_input);
+
+/**
+ * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must
+ * close its own implementation of the stream.
+ *
+ * @param	p_stream	the stream to destroy.
+ */
+OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream);
+ 
+/**
+ * Sets the given function to be used as a read function.
+ * @param		p_stream	the stream to modify
+ * @param		p_function	the function to use a read function.
+*/
+OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_stream_read_fn p_function);
+
+/**
+ * Sets the given function to be used as a write function.
+ * @param		p_stream	the stream to modify
+ * @param		p_function	the function to use a write function.
+*/
+OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stream_write_fn p_function);
+
+/**
+ * Sets the given function to be used as a skip function.
+ * @param		p_stream	the stream to modify
+ * @param		p_function	the function to use a skip function.
+*/
+OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_stream_skip_fn p_function);
+
+/**
+ * Sets the given function to be used as a seek function, the stream is then seekable.
+ * @param		p_stream	the stream to modify
+ * @param		p_function	the function to use a skip function.
+*/
+OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function);
+
+/**
+ * Sets the given data to be used as a user data for the stream.
+ * @param		p_stream	the stream to modify
+ * @param		p_data		the data to set.
+ * @param		p_function	the function to free p_data when opj_stream_destroy() is called.
+*/
+OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function);
+
+/**
+ * Sets the length of the user data for the stream.
+ *
+ * @param p_stream    the stream to modify
+ * @param data_length length of the user_data.
+*/
+OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t* p_stream, OPJ_UINT64 data_length);
+
+/**
+ * Create a stream from a file identified with its filename with default parameters (helper function)
+ * @param fname             the filename of the file to stream
+ * @param p_is_read_stream  whether the stream is a read stream (true) or not (false)
+*/
+OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream);
+ 
+/** Create a stream from a file identified with its filename with a specific buffer size
+ * @param fname             the filename of the file to stream
+ * @param p_buffer_size     size of the chunk used to stream
+ * @param p_is_read_stream  whether the stream is a read stream (true) or not (false)
+*/
+OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (const char *fname,
+                                                                     OPJ_SIZE_T p_buffer_size,
+                                                                     OPJ_BOOL p_is_read_stream);
+ 
+/* 
+==========================================================
+   event manager functions definitions
+==========================================================
+*/
+/**
+ * Set the info handler use by openjpeg.
+ * @param p_codec       the codec previously initialise
+ * @param p_callback    the callback function which will be used
+ * @param p_user_data   client object where will be returned the message
+*/
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, 
+                                                   opj_msg_callback p_callback,
+                                                   void * p_user_data);
+/**
+ * Set the warning handler use by openjpeg.
+ * @param p_codec       the codec previously initialise
+ * @param p_callback    the callback function which will be used
+ * @param p_user_data   client object where will be returned the message
+*/
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
+                                                      opj_msg_callback p_callback,
+                                                      void * p_user_data);
+/**
+ * Set the error handler use by openjpeg.
+ * @param p_codec       the codec previously initialise
+ * @param p_callback    the callback function which will be used
+ * @param p_user_data   client object where will be returned the message
+*/
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, 
+                                                    opj_msg_callback p_callback,
+                                                    void * p_user_data);
+
+/* 
+==========================================================
+   codec functions definitions
+==========================================================
+*/
+
+/**
+ * Creates a J2K/JP2 decompression structure
+ * @param format 		Decoder to select
+ *
+ * @return Returns a handle to a decompressor if successful, returns NULL otherwise
+ * */
+OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
+
+/**
+ * Destroy a decompressor handle
+ *
+ * @param	p_codec			decompressor handle to destroy
+ */
+OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec);
+
+/**
+ * Read after the codestream if necessary
+ * @param	p_codec			the JPEG2000 codec to read.
+ * @param	p_stream		the JPEG2000 stream.
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress (	opj_codec_t *p_codec,
+													opj_stream_t *p_stream);
+
+
+/**
+ * Set decoding parameters to default values
+ * @param parameters Decompression parameters
+ */
+OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
+
+/**
+ * Setup the decoder with decompression parameters provided by the user and with the message handler
+ * provided by the user.
+ *
+ * @param p_codec 		decompressor handler
+ * @param parameters 	decompression parameters
+ *
+ * @return true			if the decoder is correctly set
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
+												opj_dparameters_t *parameters );
+
+/**
+ * Decodes an image header.
+ *
+ * @param	p_stream		the jpeg2000 stream.
+ * @param	p_codec			the jpeg2000 codec to read.
+ * @param	p_image			the image structure initialized with the characteristics of encoded image.
+ *
+ * @return true				if the main header of the codestream and the JP2 header is correctly read.
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header (	opj_stream_t *p_stream,
+												opj_codec_t *p_codec,
+												opj_image_t **p_image);
+
+/**
+ * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ * @param	p_image         the decoded image previously setted by opj_read_header
+ * @param	p_start_x		the left position of the rectangle to decode (in image coordinates).
+ * @param	p_end_x			the right position of the rectangle to decode (in image coordinates).
+ * @param	p_start_y		the up position of the rectangle to decode (in image coordinates).
+ * @param	p_end_y			the bottom position of the rectangle to decode (in image coordinates).
+ *
+ * @return	true			if the area could be set.
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(	opj_codec_t *p_codec,
+													opj_image_t* p_image,
+													OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
+													OPJ_INT32 p_end_x, OPJ_INT32 p_end_y );
+
+/**
+ * Decode an image from a JPEG-2000 codestream
+ *
+ * @param p_decompressor 	decompressor handle
+ * @param p_stream			Input buffer stream
+ * @param p_image 			the decoded image
+ * @return 					true if success, otherwise false
+ * */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(   opj_codec_t *p_decompressor,
+                                            opj_stream_t *p_stream,
+                                            opj_image_t *p_image);
+
+/**
+ * Get the decoded tile from the codec
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ * @param	p_stream		input streamm
+ * @param	p_image			output image
+ * @param	tile_index		index of the tile which will be decode
+ *
+ * @return					true if success, otherwise false
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(	opj_codec_t *p_codec,
+													opj_stream_t *p_stream,
+													opj_image_t *p_image,
+													OPJ_UINT32 tile_index);
+
+/**
+ * Set the resolution factor of the decoded image
+ * @param	p_codec			the jpeg2000 codec.
+ * @param	res_factor		resolution factor to set
+ *
+ * @return					true if success, otherwise false
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor);
+
+/**
+ * Writes a tile with the given data.
+ *
+ * @param	p_codec		        the jpeg2000 codec.
+ * @param	p_tile_index		the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
+ * @param	p_data				pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
+ * @param	p_data_size			this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of 
+ *                              tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
+ * @param	p_stream			the stream to write data to.
+ *
+ * @return	true if the data could be written.
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile (	opj_codec_t *p_codec,
+												OPJ_UINT32 p_tile_index,
+												OPJ_BYTE * p_data,
+												OPJ_UINT32 p_data_size,
+												opj_stream_t *p_stream );
+
+/**
+ * Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded.
+ * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ * @param	p_tile_index	pointer to a value that will hold the index of the tile being decoded, in case of success.
+ * @param	p_data_size		pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
+ *							of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
+ *							as depicted in opj_write_tile.
+ * @param	p_tile_x0		pointer to a value that will hold the x0 pos of the tile (in the image).
+ * @param	p_tile_y0		pointer to a value that will hold the y0 pos of the tile (in the image).
+ * @param	p_tile_x1		pointer to a value that will hold the x1 pos of the tile (in the image).
+ * @param	p_tile_y1		pointer to a value that will hold the y1 pos of the tile (in the image).
+ * @param	p_nb_comps		pointer to a value that will hold the number of components in the tile.
+ * @param	p_should_go_on	pointer to a boolean that will hold the fact that the decoding should go on. In case the
+ *							codestream is over at the time of the call, the value will be set to false. The user should then stop
+ *							the decoding.
+ * @param	p_stream		the stream to decode.
+ * @return	true			if the tile header could be decoded. In case the decoding should end, the returned value is still true.
+ *							returning false may be the result of a shortage of memory or an internal error.
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(	opj_codec_t *p_codec,
+												opj_stream_t * p_stream,
+												OPJ_UINT32 * p_tile_index,
+												OPJ_UINT32 * p_data_size,
+												OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
+												OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
+												OPJ_UINT32 * p_nb_comps,
+												OPJ_BOOL * p_should_go_on );
+
+/**
+ * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
+ * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ * @param	p_tile_index	the index of the tile being decoded, this should be the value set by opj_read_tile_header.
+ * @param	p_data			pointer to a memory block that will hold the decoded data.
+ * @param	p_data_size		size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
+ * @param	p_stream		the stream to decode.
+ *
+ * @return	true			if the data could be decoded.
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(	opj_codec_t *p_codec,
+													OPJ_UINT32 p_tile_index,
+													OPJ_BYTE * p_data,
+													OPJ_UINT32 p_data_size,
+													opj_stream_t *p_stream );
+
+/* COMPRESSION FUNCTIONS*/
+
+/**
+ * Creates a J2K/JP2 compression structure
+ * @param 	format 		Coder to select
+ * @return 				Returns a handle to a compressor if successful, returns NULL otherwise
+ */
+OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
+
+/**
+Set encoding parameters to default values, that means : 
+<ul>
+<li>Lossless
+<li>1 tile
+<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
+<li>Size of code-block : 64 x 64
+<li>Number of resolutions: 6
+<li>No SOP marker in the codestream
+<li>No EPH marker in the codestream
+<li>No sub-sampling in x or y direction
+<li>No mode switch activated
+<li>Progression order: LRCP
+<li>No index file
+<li>No ROI upshifted
+<li>No offset of the origin of the image
+<li>No offset of the origin of the tiles
+<li>Reversible DWT 5-3
+</ul>
+ at param parameters Compression parameters
+*/
+OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
+
+/**
+ * Setup the encoder parameters using the current image and using user parameters.
+ * @param p_codec 		Compressor handle
+ * @param parameters 	Compression parameters
+ * @param image 		Input filled image
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec, 
+												opj_cparameters_t *parameters, 
+												opj_image_t *image);
+
+/**
+ * Start to compress the current image.
+ * @param p_codec 		Compressor handle
+ * @param image 	    Input filled image
+ * @param p_stream 		Input stgream
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress (	opj_codec_t *p_codec,
+													opj_image_t * p_image,
+													opj_stream_t *p_stream);
+
+/**
+ * End to compress the current image.
+ * @param p_codec 		Compressor handle
+ * @param p_stream 		Input stgream
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress (opj_codec_t *p_codec,
+												opj_stream_t *p_stream);
+
+/**
+ * Encode an image into a JPEG-2000 codestream
+ * @param p_codec 		compressor handle
+ * @param p_stream 		Output buffer stream
+ *
+ * @return 				Returns true if successful, returns false otherwise
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec,
+                                         opj_stream_t *p_stream);
+/*
+==========================================================
+   codec output functions definitions
+==========================================================
+*/
+/* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/
+
+/**
+Destroy Codestream information after compression or decompression
+ at param cstr_info Codestream information structure
+*/
+OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info);
+
+
+/**
+ * Dump the codec information into the output stream
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ * @param	info_flag		type of information dump.
+ * @param	output_stream	output stream where dump the informations get from the codec.
+ *
+ */
+OPJ_API void OPJ_CALLCONV opj_dump_codec(	opj_codec_t *p_codec,
+											OPJ_INT32 info_flag,
+											FILE* output_stream);
+
+/**
+ * Get the codestream information from the codec
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ *
+ * @return					a pointer to a codestream information structure.
+ *
+ */
+OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec);
+
+/**
+ * Get the codestream index from the codec
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ *
+ * @return					a pointer to a codestream index structure.
+ *
+ */
+OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec);
+
+OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index);
+
+
+/**
+ * Get the JP2 file information from the codec FIXME
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ *
+ * @return					a pointer to a JP2 metadata structure.
+ *
+ */
+OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata(opj_codec_t *p_codec);
+
+/**
+ * Get the JP2 file index from the codec FIXME
+ *
+ * @param	p_codec			the jpeg2000 codec.
+ *
+ * @return					a pointer to a JP2 index structure.
+ *
+ */
+OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec);
+
+
+/*
+==========================================================
+   MCT functions
+==========================================================
+*/
+
+/**
+ * Sets the MCT matrix to use.
+ *
+ * @param	parameters		the parameters to change.
+ * @param	pEncodingMatrix	the encoding matrix.
+ * @param	p_dc_shift		the dc shift coefficients to use.
+ * @param	pNbComp			the number of components of the image.
+ *
+ * @return	true if the parameters could be set.
+ */
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT( opj_cparameters_t *parameters,
+		                               	   OPJ_FLOAT32 * pEncodingMatrix,
+		                               	   OPJ_INT32 * p_dc_shift,
+		                               	   OPJ_UINT32 pNbComp);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPENJPEG_H */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg_mangle.h.in b/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg_mangle.h.in
new file mode 100644
index 0000000..cec65db
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/openjpeg_mangle.h.in
@@ -0,0 +1,61 @@
+/* This file was generated by CMake http://www.cmake.org */
+
+#ifndef @MANGLE_PREFIX at _mangle_h
+#define @MANGLE_PREFIX at _mangle_h
+
+/*
+ * This header file mangles all symbols exported from the openjpeg library.
+ * It is included in all files while building the openjpeg library.  Due to
+ * namespace pollution, no openjpeg headers should be included in .h files in
+ * GDCM.
+ *
+ * The following command was used to obtain the symbol list:
+ *
+ * nm lib at MANGLE_PREFIX@.a | grep " [RT] "
+ */
+
+#define  opj_create_compress                   @MANGLE_PREFIX at opj_create_compress
+#define  opj_create_decompress                 @MANGLE_PREFIX at opj_create_decompress
+#define  opj_decode                            @MANGLE_PREFIX at opj_decode
+#define  opj_decode_tile_data                  @MANGLE_PREFIX at opj_decode_tile_data
+#define  opj_destroy_codec                     @MANGLE_PREFIX at opj_destroy_codec
+#define  opj_destroy_cstr_index                @MANGLE_PREFIX at opj_destroy_cstr_index
+#define  opj_destroy_cstr_info                 @MANGLE_PREFIX at opj_destroy_cstr_info
+#define  opj_dump_codec                        @MANGLE_PREFIX at opj_dump_codec
+#define  opj_encode                            @MANGLE_PREFIX at opj_encode
+#define  opj_end_compress                      @MANGLE_PREFIX at opj_end_compress
+#define  opj_end_decompress                    @MANGLE_PREFIX at opj_end_decompress
+#define  opj_get_cstr_index                    @MANGLE_PREFIX at opj_get_cstr_index
+#define  opj_get_cstr_info                     @MANGLE_PREFIX at opj_get_cstr_info
+#define  opj_get_decoded_tile                  @MANGLE_PREFIX at opj_get_decoded_tile
+#define  opj_image_create                      @MANGLE_PREFIX at opj_image_create
+#define  opj_image_destroy                     @MANGLE_PREFIX at opj_image_destroy
+#define  opj_image_tile_create                 @MANGLE_PREFIX at opj_image_tile_create
+#define  opj_read_header                       @MANGLE_PREFIX at opj_read_header
+#define  opj_read_tile_header                  @MANGLE_PREFIX at opj_read_tile_header
+#define  opj_set_decode_area                   @MANGLE_PREFIX at opj_set_decode_area
+#define  opj_set_decoded_resolution_factor     @MANGLE_PREFIX at opj_set_decoded_resolution_factor
+#define  opj_set_default_decoder_parameters    @MANGLE_PREFIX at opj_set_default_decoder_parameters
+#define  opj_set_default_encoder_parameters    @MANGLE_PREFIX at opj_set_default_encoder_parameters
+#define  opj_set_error_handler                 @MANGLE_PREFIX at opj_set_error_handler
+#define  opj_set_info_handler                  @MANGLE_PREFIX at opj_set_info_handler
+#define  opj_set_MCT                           @MANGLE_PREFIX at opj_set_MCT
+#define  opj_setup_decoder                     @MANGLE_PREFIX at opj_setup_decoder
+#define  opj_setup_encoder                     @MANGLE_PREFIX at opj_setup_encoder
+#define  opj_set_warning_handler               @MANGLE_PREFIX at opj_set_warning_handler
+#define  opj_start_compress                    @MANGLE_PREFIX at opj_start_compress
+#define  opj_stream_create                     @MANGLE_PREFIX at opj_stream_create
+#define  opj_stream_create_default_file_stream @MANGLE_PREFIX at opj_stream_create_default_file_stream
+#define  opj_stream_create_file_stream         @MANGLE_PREFIX at opj_stream_create_file_stream
+#define  opj_stream_default_create             @MANGLE_PREFIX at opj_stream_default_create
+#define  opj_stream_destroy                    @MANGLE_PREFIX at opj_stream_destroy
+#define  opj_stream_set_read_function          @MANGLE_PREFIX at opj_stream_set_read_function
+#define  opj_stream_set_seek_function          @MANGLE_PREFIX at opj_stream_set_seek_function
+#define  opj_stream_set_skip_function          @MANGLE_PREFIX at opj_stream_set_skip_function
+#define  opj_stream_set_user_data              @MANGLE_PREFIX at opj_stream_set_user_data
+#define  opj_stream_set_user_data_length       @MANGLE_PREFIX at opj_stream_set_user_data_length
+#define  opj_stream_set_write_function         @MANGLE_PREFIX at opj_stream_set_write_function
+#define  opj_version                           @MANGLE_PREFIX at opj_version
+#define  opj_write_tile                        @MANGLE_PREFIX at opj_write_tile
+
+#endif
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k_lib.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_clock.c
similarity index 78%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k_lib.c
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/opj_clock.c
index d815f16..bb4cae7 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/j2k_lib.c
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_clock.c
@@ -1,5 +1,10 @@
 /*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,6 +29,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opj_includes.h"
+
 #ifdef _WIN32
 #include <windows.h>
 #else
@@ -31,9 +38,8 @@
 #include <sys/resource.h>
 #include <sys/times.h>
 #endif /* _WIN32 */
-#include "opj_includes.h"
 
-double opj_clock(void) {
+OPJ_FLOAT64 opj_clock(void) {
 #ifdef _WIN32
 	/* _WIN32: use QueryPerformance (very accurate) */
     LARGE_INTEGER freq , t ;
@@ -42,18 +48,18 @@ double opj_clock(void) {
 	/* cout << "freq = " << ((double) freq.QuadPart) << endl; */
     /* t is the high resolution performance counter (see MSDN) */
     QueryPerformanceCounter ( & t ) ;
-    return ( t.QuadPart /(double) freq.QuadPart ) ;
+    return ( t.QuadPart /(OPJ_FLOAT64) freq.QuadPart ) ;
 #else
 	/* Unix or Linux: use resource usage */
     struct rusage t;
-    double procTime;
+    OPJ_FLOAT64 procTime;
     /* (1) Get the rusage data structure at this moment (man getrusage) */
     getrusage(0,&t);
     /* (2) What is the elapsed time ? - CPU time = User time + System time */
 	/* (2a) Get the seconds */
-    procTime = t.ru_utime.tv_sec + t.ru_stime.tv_sec;
+    procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec);
     /* (2b) More precisely! Get the microseconds part ! */
-    return ( procTime + (t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
+    return ( procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
 #endif
 }
 
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k_lib.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_clock.h
similarity index 77%
rename from Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k_lib.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/opj_clock.h
index 7885f99..6f5168b 100644
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/j2k_lib.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_clock.h
@@ -1,5 +1,10 @@
 /*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,15 +28,15 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef __J2K_LIB_H
-#define __J2K_LIB_H
+#ifndef __OPJ_CLOCK_H
+#define __OPJ_CLOCK_H
 /**
- at file j2k_lib.h
- at brief Internal functions
+ at file opj_clock.h
+ at brief Internal function for timing
 
-The functions in J2K_LIB.C are internal utilities mainly used for timing.
+The functions in OPJ_CLOCK.C are internal utilities mainly used for timing.
 */
-#include "openjpeg.h"
+
 /** @defgroup MISC MISC - Miscellaneous internal functions */
 /*@{*/
 
@@ -50,4 +55,5 @@ OPJ_FLOAT64 opj_clock(void);
 
 /*@}*/
 
-#endif /* __J2K_LIB_H */
+#endif /* __OPJ_CLOCK_H */
+
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_codec.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_codec.h
new file mode 100644
index 0000000..6bd791f
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_codec.h
@@ -0,0 +1,165 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __OPJ_CODEC_H
+#define __OPJ_CODEC_H
+/**
+ at file opj_codec.h
+*/
+
+
+/**
+ * Main codec handler used for compression or decompression.
+ */
+typedef struct opj_codec_private
+{
+    /** FIXME DOC */
+    union
+    {
+        /**
+         * Decompression handler.
+         */
+        struct opj_decompression
+        {
+            /** Main header reading function handler */
+            OPJ_BOOL (*opj_read_header) ( struct opj_stream_private * cio,
+                                          void * p_codec,
+                                          opj_image_t **p_image,
+                                          struct opj_event_mgr * p_manager);
+
+            /** Decoding function */
+            OPJ_BOOL (*opj_decode) ( void * p_codec,
+                                     struct opj_stream_private * p_cio,
+                                     opj_image_t * p_image,
+                                     struct opj_event_mgr * p_manager);
+
+            /** FIXME DOC */
+            OPJ_BOOL (*opj_read_tile_header)( void * p_codec,
+                                              OPJ_UINT32 * p_tile_index,
+                                              OPJ_UINT32 * p_data_size,
+                                              OPJ_INT32 * p_tile_x0,
+                                              OPJ_INT32 * p_tile_y0,
+                                              OPJ_INT32 * p_tile_x1,
+                                              OPJ_INT32 * p_tile_y1,
+                                              OPJ_UINT32 * p_nb_comps,
+                                              OPJ_BOOL * p_should_go_on,
+                                              struct opj_stream_private * p_cio,
+                                              struct opj_event_mgr * p_manager);
+
+            /** FIXME DOC */
+            OPJ_BOOL (*opj_decode_tile_data)( void * p_codec,
+                                              OPJ_UINT32 p_tile_index,
+                                              OPJ_BYTE * p_data,
+                                              OPJ_UINT32 p_data_size,
+                                              struct opj_stream_private * p_cio,
+                                              struct opj_event_mgr * p_manager);
+
+            /** Reading function used after codestream if necessary */
+            OPJ_BOOL (* opj_end_decompress) ( void *p_codec,
+                                              struct opj_stream_private * cio,
+                                              struct opj_event_mgr * p_manager);
+
+            /** Codec destroy function handler */
+            void (*opj_destroy) (void * p_codec);
+
+            /** Setup decoder function handler */
+            void (*opj_setup_decoder) ( void * p_codec, opj_dparameters_t * p_param);
+
+            /** Set decode area function handler */
+            OPJ_BOOL (*opj_set_decode_area) ( void * p_codec,
+                                              opj_image_t * p_image,
+                                              OPJ_INT32 p_start_x,
+                                              OPJ_INT32 p_end_x,
+                                              OPJ_INT32 p_start_y,
+                                              OPJ_INT32 p_end_y,
+                                              struct opj_event_mgr * p_manager);
+
+            /** Get tile function */
+            OPJ_BOOL (*opj_get_decoded_tile) ( void *p_codec,
+                                               opj_stream_private_t * p_cio,
+                                               opj_image_t *p_image,
+                                               struct opj_event_mgr * p_manager,
+                                               OPJ_UINT32 tile_index);
+
+            /** Set the decoded resolution factor */
+            OPJ_BOOL (*opj_set_decoded_resolution_factor) ( void * p_codec,
+                                                            OPJ_UINT32 res_factor,
+                                                            opj_event_mgr_t * p_manager);
+        } m_decompression;
+
+        /**
+         * Compression handler. FIXME DOC
+         */
+        struct opj_compression
+        {
+            OPJ_BOOL (* opj_start_compress) ( void *p_codec,
+                                              struct opj_stream_private * cio,
+                                              struct opj_image * p_image,
+                                              struct opj_event_mgr * p_manager);
+
+            OPJ_BOOL (* opj_encode) ( void * p_codec,
+                                      struct opj_stream_private *p_cio,
+                                      struct opj_event_mgr * p_manager);
+
+            OPJ_BOOL (* opj_write_tile) ( void * p_codec,
+                                          OPJ_UINT32 p_tile_index,
+                                          OPJ_BYTE * p_data,
+                                          OPJ_UINT32 p_data_size,
+                                          struct opj_stream_private * p_cio,
+                                          struct opj_event_mgr * p_manager);
+
+            OPJ_BOOL (* opj_end_compress) (	void * p_codec,
+                                            struct opj_stream_private * p_cio,
+                                            struct opj_event_mgr * p_manager);
+
+            void (* opj_destroy) (void * p_codec);
+
+            OPJ_BOOL (* opj_setup_encoder) ( void * p_codec,
+                                             opj_cparameters_t * p_param,
+                                             struct opj_image * p_image,
+                                             struct opj_event_mgr * p_manager);
+        } m_compression;
+    } m_codec_data;
+    /** FIXME DOC*/
+    void * m_codec;
+    /** Event handler */
+    opj_event_mgr_t m_event_mgr;
+    /** Flag to indicate if the codec is used to decode or encode*/
+    OPJ_BOOL is_decompressor;
+    void (*opj_dump_codec) (void * p_codec, OPJ_INT32 info_flag, FILE* output_stream);
+    opj_codestream_info_v2_t* (*opj_get_codec_info)(void* p_codec);
+    opj_codestream_index_t* (*opj_get_codec_index)(void* p_codec);
+}
+opj_codec_private_t;
+
+
+#endif /* __OPJ_CODEC_H */
+
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_config.h.cmake.in b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_config.h.cmake.in
new file mode 100644
index 0000000..5f762ca
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_config.h.cmake.in
@@ -0,0 +1,10 @@
+/* create opj_config.h for CMake */
+#cmakedefine OPJ_HAVE_STDINT_H 		@OPJ_HAVE_STDINT_H@
+
+/*--------------------------------------------------------------------------*/
+/* OpenJPEG Versioning                                                      */
+
+/* Version number. */
+#define OPJ_VERSION_MAJOR @OPENJPEG_VERSION_MAJOR@
+#define OPJ_VERSION_MINOR @OPENJPEG_VERSION_MINOR@
+#define OPJ_VERSION_BUILD @OPENJPEG_VERSION_BUILD@
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_config_private.h.cmake.in b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_config_private.h.cmake.in
new file mode 100644
index 0000000..c41f906
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_config_private.h.cmake.in
@@ -0,0 +1,49 @@
+/* create opj_config_private.h for CMake */
+#cmakedefine OPJ_HAVE_INTTYPES_H 	@OPJ_HAVE_INTTYPES_H@
+
+#define OPJ_PACKAGE_VERSION "@PACKAGE_VERSION@"
+
+/* Not used by openjp2*/
+/*#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@*/
+/*#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@*/
+/*#cmakedefine HAVE_STRINGS_H @HAVE_STRINGS_H@*/
+/*#cmakedefine HAVE_STRING_H @HAVE_STRING_H@*/
+/*#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@*/
+/*#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@ */
+/*#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@*/
+
+#cmakedefine _LARGEFILE_SOURCE
+#cmakedefine _LARGE_FILES
+#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
+#cmakedefine OPJ_HAVE_FSEEKO @OPJ_HAVE_FSEEKO@
+
+/* find whether or not have <malloc.h> */
+#cmakedefine OPJ_HAVE_MALLOC_H
+/* check if function `aligned_alloc` exists */
+#cmakedefine OPJ_HAVE_ALIGNED_ALLOC
+/* check if function `_aligned_malloc` exists */
+#cmakedefine OPJ_HAVE__ALIGNED_MALLOC
+/* check if function `memalign` exists */
+#cmakedefine OPJ_HAVE_MEMALIGN
+/* check if function `posix_memalign` exists */
+#cmakedefine OPJ_HAVE_POSIX_MEMALIGN
+
+#if !defined(_POSIX_C_SOURCE)
+#if defined(OPJ_HAVE_FSEEKO) || defined(OPJ_HAVE_POSIX_MEMALIGN)
+/* Get declarations of fseeko, ftello, posix_memalign. */
+#define _POSIX_C_SOURCE 200112L
+#endif
+#endif
+
+/* Byte order.  */
+/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or
+__LITTLE_ENDIAN__ to match the endianness of the architecture being
+compiled for. This is not necessarily the same as the architecture of the
+machine doing the building. In order to support Universal Binaries on
+Mac OS X, we prefer those defines to decide the endianness.
+On other platforms we use the result of the TRY_RUN. */
+#if !defined(__APPLE__)
+#cmakedefine OPJ_BIG_ENDIAN
+#elif defined(__BIG_ENDIAN__)
+# define OPJ_BIG_ENDIAN
+#endif
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_includes.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_includes.h
new file mode 100644
index 0000000..58a5a9a
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_includes.h
@@ -0,0 +1,218 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef OPJ_INCLUDES_H
+#define OPJ_INCLUDES_H
+
+/*
+ * This must be included before any system headers,
+ * since they can react to macro defined there
+ */
+#include "opj_config_private.h"
+
+/*
+ ==========================================================
+   Standard includes used by the library
+ ==========================================================
+*/
+#include <memory.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <float.h>
+#include <time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <assert.h>
+
+/*
+  Use fseeko() and ftello() if they are available since they use
+  'off_t' rather than 'long'.  It is wrong to use fseeko() and
+  ftello() only on systems with special LFS support since some systems
+  (e.g. FreeBSD) support a 64-bit off_t by default.
+*/
+#if defined(OPJ_HAVE_FSEEKO) && !defined(fseek)
+#  define fseek  fseeko
+#  define ftell  ftello
+#endif
+
+
+#if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \
+  !(defined(_MSC_VER) && _MSC_VER < 1400) && \
+  !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800)
+  /*
+    Windows '95 and Borland C do not support _lseeki64
+    Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release.
+    Without these interfaces, files over 2GB in size are not supported for Windows.
+  */
+#  define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
+#  define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
+#  define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream)
+#  define OPJ_STAT_STRUCT_T struct _stati64
+#  define OPJ_STAT(path,stat_buff) _stati64(path,/* struct _stati64 */ stat_buff)
+#else
+#  define OPJ_FSEEK(stream,offset,whence) fseek(stream,offset,whence)
+#  define OPJ_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff)
+#  define OPJ_FTELL(stream) ftell(stream)
+#  define OPJ_STAT_STRUCT_T struct stat
+#  define OPJ_STAT(path,stat_buff) stat(path,stat_buff)
+#endif
+
+
+/*
+ ==========================================================
+   OpenJPEG interface
+ ==========================================================
+ */
+#include "openjpeg.h"
+
+/*
+ ==========================================================
+   OpenJPEG modules
+ ==========================================================
+*/
+
+/* Are restricted pointers available? (C99) */
+#if (__STDC_VERSION__ != 199901L)
+	/* Not a C99 compiler */
+	#ifdef __GNUC__
+		#define restrict __restrict__
+	#else
+		#define restrict /* restrict */
+	#endif
+#endif
+
+#ifdef __has_attribute
+	#if __has_attribute(no_sanitize)
+		#define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind)))
+	#endif
+#endif
+#ifndef OPJ_NOSANITIZE
+	#define OPJ_NOSANITIZE(kind)
+#endif
+
+
+/* MSVC before 2013 and Borland C do not have lrintf */
+#if defined(_MSC_VER)
+#include <intrin.h>
+static INLINE long opj_lrintf(float f){
+#ifdef _M_X64
+	return _mm_cvt_ss2si(_mm_load_ss(&f));
+
+	/* commented out line breaks many tests */
+  /* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */
+#elif defined(_M_IX86)
+    int i;
+     _asm{
+        fld f
+        fistp i
+    };
+ 
+    return i;
+#else 
+	return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f));
+#endif
+}
+#elif defined(__BORLANDC__)
+static INLINE long opj_lrintf(float f) {
+#ifdef _M_X64
+     return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
+#else
+	int i;
+
+	_asm {
+		fld f
+			fistp i
+	};
+
+	return i;
+#endif
+}
+#else
+static INLINE long opj_lrintf(float f) {
+	return lrintf(f);
+}
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER < 1400)
+	#define vsnprintf _vsnprintf
+#endif
+
+/* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
+#	include <intrin.h>
+#	pragma intrinsic(__emul)
+#endif
+
+#include "opj_inttypes.h"
+#include "opj_clock.h"
+#include "opj_malloc.h"
+#include "event.h"
+#include "function_list.h"
+#include "bio.h"
+#include "cio.h"
+
+#include "image.h"
+#include "invert.h"
+#include "j2k.h"
+#include "jp2.h"
+
+#include "mqc.h"
+#include "raw.h"
+#include "bio.h"
+
+#include "pi.h"
+#include "tgt.h"
+#include "tcd.h"
+#include "t1.h"
+#include "dwt.h"
+#include "t2.h"
+#include "mct.h"
+#include "opj_intmath.h"
+
+#ifdef USE_JPIP
+#include "cidx_manager.h"
+#include "indexbox_manager.h"
+#endif
+
+/* JPWL>> */
+#ifdef USE_JPWL
+#include "openjpwl/jpwl.h"
+#endif /* USE_JPWL */
+/* <<JPWL */
+
+/* V2 */
+#include "opj_codec.h"
+
+
+#endif /* OPJ_INCLUDES_H */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_intmath.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_intmath.h
new file mode 100644
index 0000000..3f7934c
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_intmath.h
@@ -0,0 +1,223 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __INT_H
+#define __INT_H
+/**
+ at file opj_intmath.h
+ at brief Implementation of operations on integers (INT)
+
+The functions in OPJ_INTMATH.H have for goal to realize operations on integers.
+*/
+
+/** @defgroup OPJ_INTMATH OPJ_INTMATH - Implementation of operations on integers */
+/*@{*/
+
+/** @name Exported functions (see also openjpeg.h) */
+/*@{*/
+/* ----------------------------------------------------------------------- */
+/**
+Get the minimum of two integers
+ at return Returns a if a < b else b
+*/
+static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b) {
+	return a < b ? a : b;
+}
+
+/**
+Get the minimum of two integers
+ at return Returns a if a < b else b
+*/
+static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b) {
+	return a < b ? a : b;
+}
+
+/**
+Get the maximum of two integers
+ at return Returns a if a > b else b
+*/
+static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b) {
+	return (a > b) ? a : b;
+}
+
+/**
+Get the maximum of two integers
+ at return Returns a if a > b else b
+*/
+static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32  a, OPJ_UINT32  b) {
+	return (a > b) ? a : b;
+}
+
+/**
+ Get the saturated sum of two unsigned integers
+ @return Returns saturated sum of a+b
+ */
+static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) {
+	OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b;
+	return (OPJ_UINT32)(-(OPJ_INT32)(sum >> 32)) | (OPJ_UINT32)sum;
+}
+
+/**
+Clamp an integer inside an interval
+ at return
+<ul>
+<li>Returns a if (min < a < max)
+<li>Returns max if (a > max)
+<li>Returns min if (a < min) 
+</ul>
+*/
+static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) {
+	if (a < min)
+		return min;
+	if (a > max)
+		return max;
+	return a;
+}
+/**
+ at return Get absolute value of integer
+*/
+static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a) {
+	return a < 0 ? -a : a;
+}
+/**
+Divide an integer and round upwards
+ at return Returns a divided by b
+*/
+static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
+	assert(b);
+	return (a + b - 1) / b;
+}
+
+/**
+Divide an integer and round upwards
+ at return Returns a divided by b
+*/
+static INLINE OPJ_UINT32  opj_uint_ceildiv(OPJ_UINT32  a, OPJ_UINT32  b) {
+	assert(b);
+	return (a + b - 1) / b;
+}
+
+/**
+Divide an integer by a power of 2 and round upwards
+ at return Returns a divided by 2^b
+*/
+static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
+	return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
+}
+
+/**
+ Divide a 64bits integer by a power of 2 and round upwards
+ @return Returns a divided by 2^b
+ */
+static INLINE OPJ_INT32 opj_int64_ceildivpow2(OPJ_INT64 a, OPJ_INT32 b) {
+	return (OPJ_INT32)((a + ((OPJ_INT64)1 << b) - 1) >> b);
+}
+
+/**
+ Divide an integer by a power of 2 and round upwards
+ @return Returns a divided by 2^b
+ */
+static INLINE OPJ_UINT32 opj_uint_ceildivpow2(OPJ_UINT32 a, OPJ_UINT32 b) {
+	return (OPJ_UINT32)((a + ((OPJ_UINT64)1U << b) - 1U) >> b);
+}
+
+/**
+Divide an integer by a power of 2 and round downwards
+ at return Returns a divided by 2^b
+*/
+static INLINE OPJ_INT32 opj_int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b) {
+	return a >> b;
+}
+/**
+Get logarithm of an integer and round downwards
+ at return Returns log2(a)
+*/
+static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a) {
+	OPJ_INT32 l;
+	for (l = 0; a > 1; l++) {
+		a >>= 1;
+	}
+	return l;
+}
+/**
+Get logarithm of an integer and round downwards
+ at return Returns log2(a)
+*/
+static INLINE OPJ_UINT32  opj_uint_floorlog2(OPJ_UINT32  a) {
+	OPJ_UINT32  l;
+	for (l = 0; a > 1; ++l)
+	{
+		a >>= 1;
+	}
+	return l;
+}
+
+/**
+Multiply two fixed-precision rational numbers.
+ at param a
+ at param b
+ at return Returns a * b
+*/
+static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
+	OPJ_INT64 temp = __emul(a, b);
+#else
+	OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
+#endif
+	temp += 4096;
+	assert((temp >> 13) <= (OPJ_INT64)0x7FFFFFFF);
+	assert((temp >> 13) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1));
+	return (OPJ_INT32) (temp >> 13);
+}
+
+static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b) {
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
+	OPJ_INT64 temp = __emul(a, b);
+#else
+	OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
+#endif
+	temp += 4096;
+	assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) <= (OPJ_INT64)0x7FFFFFFF);
+	assert((temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) >= (-(OPJ_INT64)0x7FFFFFFF - (OPJ_INT64)1));
+	return (OPJ_INT32) (temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) ;
+}
+
+/* ----------------------------------------------------------------------- */
+/*@}*/
+
+/*@}*/
+
+#endif
diff --git a/Utilities/gdcmopenjpeg-v2/codec/index.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_inttypes.h
similarity index 67%
rename from Utilities/gdcmopenjpeg-v2/codec/index.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/opj_inttypes.h
index 511789d..e74aed6 100644
--- a/Utilities/gdcmopenjpeg-v2/codec/index.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_inttypes.h
@@ -1,7 +1,10 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2012, Mathieu Malaterre <mathieu.malaterre at gmail.com>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,24 +28,21 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#ifndef OPJ_INTTYPES_H
+#define OPJ_INTTYPES_H
 
-#ifndef __J2K_INDEX_H
-#define __J2K_INDEX_H
-
-#ifdef __cplusplus
-extern "C" {
+#include "opj_config_private.h"
+#ifdef OPJ_HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#if defined(_WIN32)
+#define PRId64 "I64d"
+#define PRIi64 "I64i"
+#define PRIu64 "I64u"
+#define PRIx64 "I64x"
+#else
+#error unsupported platform
 #endif
-
-/**
-Write a structured index to a file
- at param cstr_info Codestream information
- at param index Index filename
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int write_index_file(opj_codestream_info_t *cstr_info, char *index);
-
-#ifdef __cplusplus
-}
 #endif
 
-#endif /* __J2K_INDEX_H */
+#endif /* OPJ_INTTYPES_H */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_malloc.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_malloc.c
new file mode 100644
index 0000000..4f8b1d6
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_malloc.c
@@ -0,0 +1,239 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses
+ * BSD License, included below. This software may be subject to other third
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2015, Mathieu Malaterre <mathieu.malaterre at gmail.com>
+ * Copyright (c) 2015, Matthieu Darbois
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#define OPJ_SKIP_POISON
+#include "opj_includes.h"
+
+#if defined(OPJ_HAVE_MALLOC_H) && defined(OPJ_HAVE_MEMALIGN)
+# include <malloc.h>
+#endif
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+static INLINE void *opj_aligned_alloc_n(size_t alignment, size_t size)
+{
+  void* ptr;
+
+  /* alignment shall be power of 2 */
+  assert( (alignment != 0U) && ((alignment & (alignment - 1U)) == 0U));
+  /* alignment shall be at least sizeof(void*) */
+  assert( alignment >= sizeof(void*));
+
+  if (size == 0U) { /* prevent implementation defined behavior of realloc */
+    return NULL;
+  }
+
+#if defined(OPJ_HAVE_POSIX_MEMALIGN)
+  /* aligned_alloc requires c11, restrict to posix_memalign for now. Quote:
+   * This function was introduced in POSIX 1003.1d. Although this function is
+   * superseded by aligned_alloc, it is more portable to older POSIX systems
+   * that do not support ISO C11.  */
+  if (posix_memalign (&ptr, alignment, size))
+  {
+    ptr = NULL;
+  }
+  /* older linux */
+#elif defined(OPJ_HAVE_MEMALIGN)
+  ptr = memalign( alignment, size );
+/* _MSC_VER */
+#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
+  ptr = _aligned_malloc(size, alignment);
+#else
+  /*
+   * Generic aligned malloc implementation.
+   * Uses size_t offset for the integer manipulation of the pointer,
+   * as uintptr_t is not available in C89 to do
+   * bitwise operations on the pointer itself.
+   */
+  alignment--;
+  {
+    size_t offset;
+    OPJ_UINT8 *mem;
+
+    /* Room for padding and extra pointer stored in front of allocated area */
+    size_t overhead = alignment + sizeof(void *);
+
+    /* let's be extra careful */
+    assert(alignment <= (SIZE_MAX - sizeof(void *)));
+
+    /* Avoid integer overflow */
+    if (size > (SIZE_MAX - overhead)) {
+      return NULL;
+    }
+
+    mem = (OPJ_UINT8*)malloc(size + overhead);
+    if (mem == NULL) {
+      return mem;
+    }
+    /* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
+    /* Use the fact that alignment + 1U is a power of 2 */
+    offset = ((alignment ^ ((size_t)(mem + sizeof(void*)) & alignment)) + 1U) & alignment;
+    ptr = (void *)(mem + sizeof(void*) + offset);
+    ((void**) ptr)[-1] = mem;
+  }
+#endif
+  return ptr;
+}
+static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment, size_t new_size)
+{
+  void *r_ptr;
+
+  /* alignment shall be power of 2 */
+  assert( (alignment != 0U) && ((alignment & (alignment - 1U)) == 0U));
+  /* alignment shall be at least sizeof(void*) */
+  assert( alignment >= sizeof(void*));
+
+  if (new_size == 0U) { /* prevent implementation defined behavior of realloc */
+    return NULL;
+  }
+
+/* no portable aligned realloc */
+#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
+  /* glibc doc states one can mix aligned malloc with realloc */
+  r_ptr = realloc( ptr, new_size ); /* fast path */
+  /* we simply use `size_t` to cast, since we are only interest in binary AND
+   * operator */
+  if( ((size_t)r_ptr & (alignment - 1U)) != 0U ) {
+    /* this is non-trivial to implement a portable aligned realloc, so use a
+     * simple approach where we do not need a function that return the size of an
+     * allocated array (eg. _msize on Windows, malloc_size on MacOS,
+     * malloc_usable_size on systems with glibc) */
+    void *a_ptr = opj_aligned_alloc_n(alignment, new_size);
+    if (a_ptr != NULL) {
+      memcpy(a_ptr, r_ptr, new_size);
+    }
+    free( r_ptr );
+    r_ptr = a_ptr;
+  }
+/* _MSC_VER */
+#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
+  r_ptr = _aligned_realloc( ptr, new_size, alignment );
+#else
+  if (ptr == NULL) {
+    return opj_aligned_alloc_n(alignment, new_size);
+  }
+  alignment--;
+  {
+    void *oldmem;
+    OPJ_UINT8 *newmem;
+    size_t overhead = alignment + sizeof(void *);
+
+    /* let's be extra careful */
+    assert(alignment <= (SIZE_MAX - sizeof(void *)));
+
+    /* Avoid integer overflow */
+    if (new_size > SIZE_MAX - overhead) {
+      return NULL;
+    }
+
+    oldmem = ((void**) ptr)[-1];
+    newmem = (OPJ_UINT8*)realloc(oldmem, new_size + overhead);
+    if (newmem == NULL) {
+      return newmem;
+    }
+
+    if (newmem == oldmem) {
+      r_ptr = ptr;
+    }
+    else {
+      size_t old_offset;
+      size_t new_offset;
+
+      /* realloc created a new copy, realign the copied memory block */
+      old_offset = (size_t)((OPJ_UINT8*)ptr - (OPJ_UINT8*)oldmem);
+
+      /* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
+      /* Use the fact that alignment + 1U is a power of 2 */
+      new_offset  = ((alignment ^ ((size_t)(newmem + sizeof(void*)) & alignment)) + 1U) & alignment;
+			new_offset += sizeof(void*);
+      r_ptr = (void *)(newmem + new_offset);
+
+      if (new_offset != old_offset) {
+        memmove(newmem + new_offset, newmem + old_offset, new_size);
+      }
+      ((void**) r_ptr)[-1] = newmem;
+    }
+  }
+#endif
+	return r_ptr;
+}
+void * opj_malloc(size_t size)
+{
+  if (size == 0U) { /* prevent implementation defined behavior of realloc */
+    return NULL;
+  }
+  return malloc(size);
+}
+void * opj_calloc(size_t num, size_t size)
+{
+  if (num == 0 || size == 0) {
+    /* prevent implementation defined behavior of realloc */
+    return NULL;
+  }
+  return calloc(num, size);
+}
+
+void *opj_aligned_malloc(size_t size)
+{
+  return opj_aligned_alloc_n(16U, size);
+}
+void * opj_aligned_realloc(void *ptr, size_t size)
+{
+  return opj_aligned_realloc_n(ptr, 16U, size);
+}
+
+void opj_aligned_free(void* ptr)
+{
+#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
+  free( ptr );
+#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
+  _aligned_free( ptr );
+#else
+  /* Generic implementation has malloced pointer stored in front of used area */
+  if (ptr != NULL) {
+    free(((void**) ptr)[-1]);
+  }
+#endif
+}
+
+void * opj_realloc(void *ptr, size_t new_size)
+{
+  if (new_size == 0U) { /* prevent implementation defined behavior of realloc */
+    return NULL;
+  }
+  return realloc(ptr, new_size);
+}
+void opj_free(void *ptr)
+{
+  free(ptr);
+}
diff --git a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d_lib.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_malloc.h
old mode 100755
new mode 100644
similarity index 56%
rename from Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d_lib.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/opj_malloc.h
index 45b2830..1b3fced
--- a/Utilities/gdcmopenjpeg-v1/jp3d/libjp3dvm/jp3d_lib.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_malloc.h
@@ -1,75 +1,98 @@
-/*
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __J3D_LIB_H
-#define __J3D_LIB_H
-/**
- at file jp3d_lib.h
- at brief Internal functions
-
-The functions in JP3D_LIB.C are internal utilities mainly used for memory management.
-*/
-
-/** @defgroup MISC MISC - Miscellaneous internal functions */
-/*@{*/
-
-/** @name Funciones generales */
-/*@{*/
-/* ----------------------------------------------------------------------- */
-
-/**
-Difference in successive opj_clock() calls tells you the elapsed time
- at return Returns time in seconds
-*/
-double opj_clock();
-
-/**
-Allocate a memory block with elements initialized to 0
- at param size Bytes to allocate
- at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
-*/
-void* opj_malloc( size_t size );
-
-/**
-Reallocate memory blocks.
- at param memblock Pointer to previously allocated memory block
- at param size New size in bytes
- at return Returns a void pointer to the reallocated (and possibly moved) memory block
-*/
-void* opj_realloc( void *memblock, size_t size );
-
-/**
-Deallocates or frees a memory block.
- at param memblock Previously allocated memory block to be freed
-*/
-void opj_free( void *memblock );
-
-/* ----------------------------------------------------------------------- */
-/*@}*/
-
-/*@}*/
-
-#endif /* __J3D_LIB_H */
-
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __OPJ_MALLOC_H
+#define __OPJ_MALLOC_H
+
+#include <stddef.h>
+/**
+ at file opj_malloc.h
+ at brief Internal functions
+
+The functions in opj_malloc.h are internal utilities used for memory management.
+*/
+
+/** @defgroup MISC MISC - Miscellaneous internal functions */
+/*@{*/
+
+/** @name Exported functions */
+/*@{*/
+/* ----------------------------------------------------------------------- */
+
+/**
+Allocate an uninitialized memory block
+ at param size Bytes to allocate
+ at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
+*/
+void * opj_malloc(size_t size);
+
+/**
+Allocate a memory block with elements initialized to 0
+ at param num Blocks to allocate
+ at param size Bytes per block to allocate
+ at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
+*/
+void * opj_calloc(size_t numOfElements, size_t sizeOfElements);
+
+/**
+Allocate memory aligned to a 16 byte boundary
+ at param size Bytes to allocate
+ at return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
+*/
+void * opj_aligned_malloc(size_t size);
+void * opj_aligned_realloc(void *ptr, size_t size);
+void opj_aligned_free(void* ptr);
+
+/**
+Reallocate memory blocks.
+ at param m Pointer to previously allocated memory block
+ at param s New size in bytes
+ at return Returns a void pointer to the reallocated (and possibly moved) memory block
+*/
+void * opj_realloc(void * m, size_t s);
+
+/**
+Deallocates or frees a memory block.
+ at param m Previously allocated memory block to be freed
+*/
+void opj_free(void * m);
+
+#if defined(__GNUC__) && !defined(OPJ_SKIP_POISON)
+#pragma GCC poison malloc calloc realloc free
+#endif
+
+/* ----------------------------------------------------------------------- */
+/*@}*/
+
+/*@}*/
+
+#endif /* __OPJ_MALLOC_H */
+
diff --git a/Utilities/gdcmopenjpeg-v1/codec/index.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_stdint.h
similarity index 62%
rename from Utilities/gdcmopenjpeg-v1/codec/index.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/opj_stdint.h
index 29f673a..b8556a1 100644
--- a/Utilities/gdcmopenjpeg-v1/codec/index.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/opj_stdint.h
@@ -1,49 +1,52 @@
-/*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __J2K_INDEX_H
-#define __J2K_INDEX_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-Write a structured index to a file
- at param cstr_info Codestream information 
- at param index Index filename
- at return Returns 0 if successful, returns 1 otherwise
-*/
-int write_index_file(opj_codestream_info_t *cstr_info, char *index);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __J2K_INDEX_H */
-
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2012, Mathieu Malaterre <mathieu.malaterre at gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef OPJ_STDINT_H
+#define OPJ_STDINT_H
+
+#include "opj_config.h"
+#ifdef OPJ_HAVE_STDINT_H
+#include <stdint.h>
+#else
+#if defined(_WIN32)
+typedef   signed __int8   int8_t;
+typedef unsigned __int8   uint8_t;
+typedef   signed __int16  int16_t;
+typedef unsigned __int16  uint16_t;
+typedef   signed __int32  int32_t;
+typedef unsigned __int32  uint32_t;
+typedef   signed __int64  int64_t;
+typedef unsigned __int64  uint64_t;
+#else
+#error unsupported platform
+#endif
+#endif
+
+#endif /* OPJ_STDINT_H */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/phix_manager.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/phix_manager.c
new file mode 100644
index 0000000..45e559d
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/phix_manager.c
@@ -0,0 +1,193 @@
+/*
+ * $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara at gmail.com $
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*! \file
+ *  \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+
+/* 
+ * Write faix box of phix
+ *
+ * @param[in] coff      offset of j2k codestream
+ * @param[in] compno    component number
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused   true if if EPH option used
+ * @param[in] j2klen    length of j2k codestream
+ * @param[in] cio       file output handle
+ * @return              length of faix box
+ */
+
+int opj_write_phix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [8];
+  OPJ_UINT32 len, compno, i;
+  opj_jp2_box_t *box;
+  OPJ_OFF_T lenp = 0;
+
+  box = (opj_jp2_box_t *)opj_calloc( (size_t)cstr_info.numcomps, sizeof(opj_jp2_box_t));
+  if(box == NULL){
+		return 0;
+  }
+  for( i=0;i<2;i++){
+    if (i)
+      opj_stream_seek( cio, lenp, p_manager);
+      
+    lenp = opj_stream_tell(cio);
+    opj_stream_skip(cio, 4, p_manager);         /* L [at the end]      */
+    opj_write_bytes(l_data_header,JPIP_PHIX,4); /* PHIX */
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+      
+    opj_write_manf( (int)i, cstr_info.numcomps, box, cio, p_manager );
+
+    for( compno=0; compno<(OPJ_UINT32)cstr_info.numcomps; compno++){       
+      box[compno].length = (OPJ_UINT32)opj_write_phixfaix( coff, (int)compno, cstr_info, EPHused, j2klen, cio,p_manager);
+      box[compno].type = JPIP_FAIX;
+    }
+
+    len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+    opj_stream_seek(cio, 4, p_manager);
+    opj_write_bytes(l_data_header,len,4);/* L              */
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+    opj_stream_seek( cio, lenp+len,p_manager);
+  }
+
+  opj_free(box);
+
+  return (int)len;
+}
+
+
+int opj_write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_UINT32 tileno, version, i, nmax, size_of_coding; /* 4 or 8 */
+  opj_tile_info_t *tile_Idx;
+  opj_packet_info_t packet;
+  int resno, precno, layno;
+  OPJ_UINT32 num_packet;
+  int numOfres, numOfprec, numOflayers;
+  OPJ_BYTE l_data_header [8];
+  OPJ_OFF_T lenp;
+  OPJ_UINT32 len;
+
+  packet.end_ph_pos = packet.start_pos = -1;
+  (void)EPHused; /* unused ? */
+
+
+  if( j2klen > pow( 2, 32)){
+    size_of_coding =  8;
+    version = 1;
+  }
+  else{
+    size_of_coding = 4;
+    version = 0;
+  }
+
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip(cio, 4, p_manager);         /* L [at the end]      */
+  opj_write_bytes(l_data_header,JPIP_FAIX,4); /* FAIX */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_write_bytes(l_data_header,version,1);   /* Version 0 = 4 bytes */
+  opj_stream_write_data(cio,l_data_header,1,p_manager);
+
+  nmax = 0;
+  for( i=0; i<=(OPJ_UINT32)cstr_info.numdecompos[compno]; i++)
+    nmax += (OPJ_UINT32)(cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers);
+  
+  opj_write_bytes(l_data_header,nmax,size_of_coding);         /* NMAX           */
+  opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+  opj_write_bytes(l_data_header,(OPJ_UINT32)(cstr_info.tw*cstr_info.th),size_of_coding);  /* M              */
+  opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+  
+  for( tileno=0; tileno<(OPJ_UINT32)(cstr_info.tw*cstr_info.th); tileno++){
+    tile_Idx = &cstr_info.tile[ tileno];
+    
+    num_packet = 0;
+    numOfres = cstr_info.numdecompos[compno] + 1;
+
+    for( resno=0; resno<numOfres ; resno++){
+      numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
+      for( precno=0; precno<numOfprec; precno++){
+	numOflayers = cstr_info.numlayers;
+	for( layno=0; layno<numOflayers; layno++){
+	  
+	  switch ( cstr_info.prog){
+	  case OPJ_LRCP:
+	    packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
+	    break;
+	  case OPJ_RLCP:
+	    packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
+	    break;
+	  case OPJ_RPCL:
+	    packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
+	    break;
+	  case OPJ_PCRL:
+	    packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
+	    break;
+	  case OPJ_CPRL:
+	    packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
+	    break;
+	  default:
+	    fprintf( stderr, "failed to ppix indexing\n");
+	  }
+
+    opj_write_bytes(l_data_header,(OPJ_UINT32)(packet.start_pos-coff),size_of_coding);            /* start position */
+    opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+    opj_write_bytes(l_data_header,(OPJ_UINT32)(packet.end_ph_pos-packet.start_pos+1),size_of_coding); /* length         */
+    opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+	  
+	  num_packet++;
+	}
+      }
+    }
+
+    /* PADDING */
+    while( num_packet < nmax){
+      opj_write_bytes(l_data_header,0,size_of_coding);/* start position            */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+      opj_write_bytes(l_data_header,0,size_of_coding);/* length                    */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+      num_packet++;
+    }
+  }
+
+  len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+  opj_stream_seek(cio, lenp,p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L  */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+
+  return (int)len;
+}
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/pi.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/pi.c
new file mode 100644
index 0000000..cffad66
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/pi.c
@@ -0,0 +1,1878 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2006-2007, Parvatha Elangovan
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/** @defgroup PI PI - Implementation of a packet iterator */
+/*@{*/
+
+/** @name Local static functions */
+/*@{*/
+
+/**
+Get next packet in layer-resolution-component-precinct order.
+ at param pi packet iterator to modify
+ at return returns false if pi pointed to the last packet or else returns true
+*/
+static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi);
+/**
+Get next packet in resolution-layer-component-precinct order.
+ at param pi packet iterator to modify
+ at return returns false if pi pointed to the last packet or else returns true
+*/
+static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi);
+/**
+Get next packet in resolution-precinct-component-layer order.
+ at param pi packet iterator to modify
+ at return returns false if pi pointed to the last packet or else returns true
+*/
+static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi);
+/**
+Get next packet in precinct-component-resolution-layer order.
+ at param pi packet iterator to modify
+ at return returns false if pi pointed to the last packet or else returns true
+*/
+static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi);
+/**
+Get next packet in component-precinct-resolution-layer order.
+ at param pi packet iterator to modify
+ at return returns false if pi pointed to the last packet or else returns true
+*/
+static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi);
+
+/**
+ * Updates the coding parameters if the encoding is used with Progression order changes and final (or cinema parameters are used).
+ *
+ * @param	p_cp		the coding parameters to modify
+ * @param	p_tileno	the tile index being concerned.
+ * @param	p_tx0		X0 parameter for the tile
+ * @param	p_tx1		X1 parameter for the tile
+ * @param	p_ty0		Y0 parameter for the tile
+ * @param	p_ty1		Y1 parameter for the tile
+ * @param	p_max_prec	the maximum precision for all the bands of the tile
+ * @param	p_max_res	the maximum number of resolutions for all the poc inside the tile.
+ * @param	p_dx_min		the minimum dx of all the components of all the resolutions for the tile.
+ * @param	p_dy_min		the minimum dy of all the components of all the resolutions for the tile.
+ */
+static void opj_pi_update_encode_poc_and_final ( opj_cp_t *p_cp,
+                                                 OPJ_UINT32 p_tileno,
+                                                 OPJ_INT32 p_tx0,
+                                                 OPJ_INT32 p_tx1,
+                                                 OPJ_INT32 p_ty0,
+                                                 OPJ_INT32 p_ty1,
+                                                 OPJ_UINT32 p_max_prec,
+                                                 OPJ_UINT32 p_max_res,
+                                                 OPJ_UINT32 p_dx_min,
+                                                 OPJ_UINT32 p_dy_min);
+
+/**
+ * Updates the coding parameters if the encoding is not used with Progression order changes and final (and cinema parameters are used).
+ *
+ * @param	p_cp		the coding parameters to modify
+ * @param	p_num_comps		the number of components
+ * @param	p_tileno	the tile index being concerned.
+ * @param	p_tx0		X0 parameter for the tile
+ * @param	p_tx1		X1 parameter for the tile
+ * @param	p_ty0		Y0 parameter for the tile
+ * @param	p_ty1		Y1 parameter for the tile
+ * @param	p_max_prec	the maximum precision for all the bands of the tile
+ * @param	p_max_res	the maximum number of resolutions for all the poc inside the tile.
+ * @param	p_dx_min		the minimum dx of all the components of all the resolutions for the tile.
+ * @param	p_dy_min		the minimum dy of all the components of all the resolutions for the tile.
+ */
+static void opj_pi_update_encode_not_poc (  opj_cp_t *p_cp,
+                                            OPJ_UINT32 p_num_comps,
+                                            OPJ_UINT32 p_tileno,
+                                            OPJ_INT32 p_tx0,
+                                            OPJ_INT32 p_tx1,
+                                            OPJ_INT32 p_ty0,
+                                            OPJ_INT32 p_ty1,
+                                            OPJ_UINT32 p_max_prec,
+                                            OPJ_UINT32 p_max_res,
+                                            OPJ_UINT32 p_dx_min,
+                                            OPJ_UINT32 p_dy_min);
+/**
+ * Gets the encoding parameters needed to update the coding parameters and all the pocs.
+ * 
+ * @param	p_image			the image being encoded.
+ * @param	p_cp			the coding parameters.
+ * @param	tileno			the tile index of the tile being encoded.
+ * @param	p_tx0			pointer that will hold the X0 parameter for the tile
+ * @param	p_tx1			pointer that will hold the X1 parameter for the tile
+ * @param	p_ty0			pointer that will hold the Y0 parameter for the tile
+ * @param	p_ty1			pointer that will hold the Y1 parameter for the tile
+ * @param	p_max_prec		pointer that will hold the maximum precision for all the bands of the tile
+ * @param	p_max_res		pointer that will hold the maximum number of resolutions for all the poc inside the tile.
+ * @param	p_dx_min			pointer that will hold the minimum dx of all the components of all the resolutions for the tile.
+ * @param	p_dy_min			pointer that will hold the minimum dy of all the components of all the resolutions for the tile.
+ */
+static void opj_get_encoding_parameters(const opj_image_t *p_image,
+                                        const opj_cp_t *p_cp,
+                                        OPJ_UINT32  tileno,
+                                        OPJ_INT32  * p_tx0,
+                                        OPJ_INT32 * p_tx1,
+                                        OPJ_INT32 * p_ty0,
+                                        OPJ_INT32 * p_ty1,
+                                        OPJ_UINT32 * p_dx_min,
+                                        OPJ_UINT32 * p_dy_min,
+                                        OPJ_UINT32 * p_max_prec,
+                                        OPJ_UINT32 * p_max_res );
+
+/**
+ * Gets the encoding parameters needed to update the coding parameters and all the pocs.
+ * The precinct widths, heights, dx and dy for each component at each resolution will be stored as well.
+ * the last parameter of the function should be an array of pointers of size nb components, each pointer leading
+ * to an area of size 4 * max_res. The data is stored inside this area with the following pattern :
+ * dx_compi_res0 , dy_compi_res0 , w_compi_res0, h_compi_res0 , dx_compi_res1 , dy_compi_res1 , w_compi_res1, h_compi_res1 , ...
+ *
+ * @param	p_image			the image being encoded.
+ * @param	p_cp			the coding parameters.
+ * @param	tileno			the tile index of the tile being encoded.
+ * @param	p_tx0			pointer that will hold the X0 parameter for the tile
+ * @param	p_tx1			pointer that will hold the X1 parameter for the tile
+ * @param	p_ty0			pointer that will hold the Y0 parameter for the tile
+ * @param	p_ty1			pointer that will hold the Y1 parameter for the tile
+ * @param	p_max_prec		pointer that will hold the maximum precision for all the bands of the tile
+ * @param	p_max_res		pointer that will hold the maximum number of resolutions for all the poc inside the tile.
+ * @param	p_dx_min		pointer that will hold the minimum dx of all the components of all the resolutions for the tile.
+ * @param	p_dy_min		pointer that will hold the minimum dy of all the components of all the resolutions for the tile.
+ * @param	p_resolutions	pointer to an area corresponding to the one described above.
+ */
+static void opj_get_all_encoding_parameters(const opj_image_t *p_image,
+                                            const opj_cp_t *p_cp,
+                                            OPJ_UINT32 tileno,
+                                            OPJ_INT32 * p_tx0,
+                                            OPJ_INT32 * p_tx1,
+                                            OPJ_INT32 * p_ty0,
+                                            OPJ_INT32 * p_ty1,
+                                            OPJ_UINT32 * p_dx_min,
+                                            OPJ_UINT32 * p_dy_min,
+                                            OPJ_UINT32 * p_max_prec,
+                                            OPJ_UINT32 * p_max_res,
+                                            OPJ_UINT32 ** p_resolutions );
+/**
+ * Allocates memory for a packet iterator. Data and data sizes are set by this operation.
+ * No other data is set. The include section of the packet  iterator is not allocated.
+ * 
+ * @param	p_image		the image used to initialize the packet iterator (in fact only the number of components is relevant.
+ * @param	p_cp		the coding parameters.
+ * @param	tileno	the index of the tile from which creating the packet iterator.
+ */
+static opj_pi_iterator_t * opj_pi_create(	const opj_image_t *p_image,
+                                            const opj_cp_t *p_cp,
+                                            OPJ_UINT32 tileno );
+/**
+ * FIXME DOC
+ */
+static void opj_pi_update_decode_not_poc (opj_pi_iterator_t * p_pi,
+                                          opj_tcp_t * p_tcp,
+                                          OPJ_UINT32 p_max_precision,
+                                          OPJ_UINT32 p_max_res);
+/**
+ * FIXME DOC
+ */
+static void opj_pi_update_decode_poc (  opj_pi_iterator_t * p_pi,
+                                        opj_tcp_t * p_tcp,
+                                        OPJ_UINT32 p_max_precision,
+                                        OPJ_UINT32 p_max_res);
+
+/**
+ * FIXME DOC
+ */
+static OPJ_BOOL opj_pi_check_next_level(	OPJ_INT32 pos,
+								opj_cp_t *cp,
+								OPJ_UINT32 tileno,
+								OPJ_UINT32 pino,
+								const OPJ_CHAR *prog);
+
+/*@}*/
+
+/*@}*/
+
+/*
+==========================================================
+   local functions
+==========================================================
+*/
+
+static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi) {
+	opj_pi_comp_t *comp = NULL;
+	opj_pi_resolution_t *res = NULL;
+	OPJ_UINT32 index = 0;
+	
+	if (!pi->first) {
+		comp = &pi->comps[pi->compno];
+		res = &comp->resolutions[pi->resno];
+		goto LABEL_SKIP;
+	} else {
+		pi->first = 0;
+	}
+
+	for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
+		for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
+		pi->resno++) {
+			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
+				comp = &pi->comps[pi->compno];
+				if (pi->resno >= comp->numresolutions) {
+					continue;
+				}
+				res = &comp->resolutions[pi->resno];
+				if (!pi->tp_on){
+					pi->poc.precno1 = res->pw * res->ph;
+				}
+				for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
+					index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
+					if (!pi->include[index]) {
+						pi->include[index] = 1;
+						return OPJ_TRUE;
+					}
+LABEL_SKIP:;
+				}
+			}
+		}
+	}
+	
+	return OPJ_FALSE;
+}
+
+static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi) {
+	opj_pi_comp_t *comp = NULL;
+	opj_pi_resolution_t *res = NULL;
+	OPJ_UINT32 index = 0;
+
+	if (!pi->first) {
+		comp = &pi->comps[pi->compno];
+		res = &comp->resolutions[pi->resno];
+		goto LABEL_SKIP;
+	} else {
+		pi->first = 0;
+	}
+
+	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
+		for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
+			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
+				comp = &pi->comps[pi->compno];
+				if (pi->resno >= comp->numresolutions) {
+					continue;
+				}
+				res = &comp->resolutions[pi->resno];
+				if(!pi->tp_on){
+					pi->poc.precno1 = res->pw * res->ph;
+				}
+				for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
+					index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
+					if (!pi->include[index]) {
+						pi->include[index] = 1;
+						return OPJ_TRUE;
+					}
+LABEL_SKIP:;
+				}
+			}
+		}
+	}
+	
+	return OPJ_FALSE;
+}
+
+static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi) {
+	opj_pi_comp_t *comp = NULL;
+	opj_pi_resolution_t *res = NULL;
+	OPJ_UINT32 index = 0;
+
+	if (!pi->first) {
+		goto LABEL_SKIP;
+	} else {
+		OPJ_UINT32 compno, resno;
+		pi->first = 0;
+		pi->dx = 0;
+		pi->dy = 0;
+		for (compno = 0; compno < pi->numcomps; compno++) {
+			comp = &pi->comps[compno];
+			for (resno = 0; resno < comp->numresolutions; resno++) {
+				OPJ_UINT32 dx, dy;
+				res = &comp->resolutions[resno];
+				dx = comp->dx * (1u << (res->pdx + comp->numresolutions - 1 - resno));
+				dy = comp->dy * (1u << (res->pdy + comp->numresolutions - 1 - resno));
+				pi->dx = !pi->dx ? dx : opj_uint_min(pi->dx, dx);
+				pi->dy = !pi->dy ? dy : opj_uint_min(pi->dy, dy);
+			}
+		}
+	}
+if (!pi->tp_on){
+			pi->poc.ty0 = pi->ty0;
+			pi->poc.tx0 = pi->tx0;
+			pi->poc.ty1 = pi->ty1;
+			pi->poc.tx1 = pi->tx1;
+		}
+	for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
+		for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += (OPJ_INT32)(pi->dy - (OPJ_UINT32)(pi->y % (OPJ_INT32)pi->dy))) {
+			for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += (OPJ_INT32)(pi->dx - (OPJ_UINT32)(pi->x % (OPJ_INT32)pi->dx))) {
+				for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
+					OPJ_UINT32 levelno;
+					OPJ_INT32 trx0, try0;
+					OPJ_INT32  trx1, try1;
+					OPJ_UINT32  rpx, rpy;
+					OPJ_INT32  prci, prcj;
+					comp = &pi->comps[pi->compno];
+					if (pi->resno >= comp->numresolutions) {
+						continue;
+					}
+					res = &comp->resolutions[pi->resno];
+					levelno = comp->numresolutions - 1 - pi->resno;
+					trx0 = opj_int_ceildiv(pi->tx0, (OPJ_INT32)(comp->dx << levelno));
+					try0 = opj_int_ceildiv(pi->ty0, (OPJ_INT32)(comp->dy << levelno));
+					trx1 = opj_int_ceildiv(pi->tx1, (OPJ_INT32)(comp->dx << levelno));
+					try1 = opj_int_ceildiv(pi->ty1, (OPJ_INT32)(comp->dy << levelno));
+					rpx = res->pdx + levelno;
+					rpy = res->pdy + levelno;
+					if (!((pi->y % (OPJ_INT32)(comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
+						continue;	
+					}
+					if (!((pi->x % (OPJ_INT32)(comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
+						continue;
+					}
+					
+					if ((res->pw==0)||(res->ph==0)) continue;
+					
+					if ((trx0==trx1)||(try0==try1)) continue;
+					
+					prci = opj_int_floordivpow2(opj_int_ceildiv(pi->x, (OPJ_INT32)(comp->dx << levelno)), (OPJ_INT32)res->pdx)
+						 - opj_int_floordivpow2(trx0, (OPJ_INT32)res->pdx);
+					prcj = opj_int_floordivpow2(opj_int_ceildiv(pi->y, (OPJ_INT32)(comp->dy << levelno)), (OPJ_INT32)res->pdy)
+						 - opj_int_floordivpow2(try0, (OPJ_INT32)res->pdy);
+					pi->precno = (OPJ_UINT32)(prci + prcj * (OPJ_INT32)res->pw);
+					for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
+						index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
+						if (!pi->include[index]) {
+							pi->include[index] = 1;
+							return OPJ_TRUE;
+						}
+LABEL_SKIP:;
+					}
+				}
+			}
+		}
+	}
+	
+	return OPJ_FALSE;
+}
+
+static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi) {
+	opj_pi_comp_t *comp = NULL;
+	opj_pi_resolution_t *res = NULL;
+	OPJ_UINT32 index = 0;
+
+	if (!pi->first) {
+		comp = &pi->comps[pi->compno];
+		goto LABEL_SKIP;
+	} else {
+		OPJ_UINT32 compno, resno;
+		pi->first = 0;
+		pi->dx = 0;
+		pi->dy = 0;
+		for (compno = 0; compno < pi->numcomps; compno++) {
+			comp = &pi->comps[compno];
+			for (resno = 0; resno < comp->numresolutions; resno++) {
+				OPJ_UINT32 dx, dy;
+				res = &comp->resolutions[resno];
+				dx = comp->dx * (1u << (res->pdx + comp->numresolutions - 1 - resno));
+				dy = comp->dy * (1u << (res->pdy + comp->numresolutions - 1 - resno));
+				pi->dx = !pi->dx ? dx : opj_uint_min(pi->dx, dx);
+				pi->dy = !pi->dy ? dy : opj_uint_min(pi->dy, dy);
+			}
+		}
+	}
+	if (!pi->tp_on){
+			pi->poc.ty0 = pi->ty0;
+			pi->poc.tx0 = pi->tx0;
+			pi->poc.ty1 = pi->ty1;
+			pi->poc.tx1 = pi->tx1;
+		}
+	for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += (OPJ_INT32)(pi->dy - (OPJ_UINT32)(pi->y % (OPJ_INT32)pi->dy))) {
+		for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += (OPJ_INT32)(pi->dx - (OPJ_UINT32)(pi->x % (OPJ_INT32)pi->dx))) {
+			for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
+				comp = &pi->comps[pi->compno];
+				for (pi->resno = pi->poc.resno0; pi->resno < opj_uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
+					OPJ_UINT32 levelno;
+					OPJ_INT32 trx0, try0;
+					OPJ_INT32 trx1, try1;
+					OPJ_UINT32 rpx, rpy;
+					OPJ_INT32 prci, prcj;
+					res = &comp->resolutions[pi->resno];
+					levelno = comp->numresolutions - 1 - pi->resno;
+					trx0 = opj_int_ceildiv(pi->tx0, (OPJ_INT32)(comp->dx << levelno));
+					try0 = opj_int_ceildiv(pi->ty0, (OPJ_INT32)(comp->dy << levelno));
+					trx1 = opj_int_ceildiv(pi->tx1, (OPJ_INT32)(comp->dx << levelno));
+					try1 = opj_int_ceildiv(pi->ty1, (OPJ_INT32)(comp->dy << levelno));
+					rpx = res->pdx + levelno;
+					rpy = res->pdy + levelno;
+					if (!((pi->y % (OPJ_INT32)(comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
+						continue;	
+					}
+					if (!((pi->x % (OPJ_INT32)(comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
+						continue;
+					}
+					
+					if ((res->pw==0)||(res->ph==0)) continue;
+					
+					if ((trx0==trx1)||(try0==try1)) continue;
+					
+					prci = opj_int_floordivpow2(opj_int_ceildiv(pi->x, (OPJ_INT32)(comp->dx << levelno)), (OPJ_INT32)res->pdx)
+						 - opj_int_floordivpow2(trx0, (OPJ_INT32)res->pdx);
+					prcj = opj_int_floordivpow2(opj_int_ceildiv(pi->y, (OPJ_INT32)(comp->dy << levelno)), (OPJ_INT32)res->pdy)
+						 - opj_int_floordivpow2(try0, (OPJ_INT32)res->pdy);
+					pi->precno = (OPJ_UINT32)(prci + prcj * (OPJ_INT32)res->pw);
+					for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
+						index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
+						if (!pi->include[index]) {
+							pi->include[index] = 1;
+							return OPJ_TRUE;
+						}	
+LABEL_SKIP:;
+					}
+				}
+			}
+		}
+	}
+	
+	return OPJ_FALSE;
+}
+
+static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi) {
+	opj_pi_comp_t *comp = NULL;
+	opj_pi_resolution_t *res = NULL;
+	OPJ_UINT32 index = 0;
+
+	if (!pi->first) {
+		comp = &pi->comps[pi->compno];
+		goto LABEL_SKIP;
+	} else {
+		pi->first = 0;
+	}
+
+	for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
+		OPJ_UINT32 resno;
+		comp = &pi->comps[pi->compno];
+		pi->dx = 0;
+		pi->dy = 0;
+		for (resno = 0; resno < comp->numresolutions; resno++) {
+			OPJ_UINT32 dx, dy;
+			res = &comp->resolutions[resno];
+			dx = comp->dx * (1u << (res->pdx + comp->numresolutions - 1 - resno));
+			dy = comp->dy * (1u << (res->pdy + comp->numresolutions - 1 - resno));
+			pi->dx = !pi->dx ? dx : opj_uint_min(pi->dx, dx);
+			pi->dy = !pi->dy ? dy : opj_uint_min(pi->dy, dy);
+		}
+		if (!pi->tp_on){
+			pi->poc.ty0 = pi->ty0;
+			pi->poc.tx0 = pi->tx0;
+			pi->poc.ty1 = pi->ty1;
+			pi->poc.tx1 = pi->tx1;
+		}
+		for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += (OPJ_INT32)(pi->dy - (OPJ_UINT32)(pi->y % (OPJ_INT32)pi->dy))) {
+			for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += (OPJ_INT32)(pi->dx - (OPJ_UINT32)(pi->x % (OPJ_INT32)pi->dx))) {
+				for (pi->resno = pi->poc.resno0; pi->resno < opj_uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
+					OPJ_UINT32 levelno;
+					OPJ_INT32 trx0, try0;
+					OPJ_INT32 trx1, try1;
+					OPJ_UINT32 rpx, rpy;
+					OPJ_INT32 prci, prcj;
+					res = &comp->resolutions[pi->resno];
+					levelno = comp->numresolutions - 1 - pi->resno;
+					trx0 = opj_int_ceildiv(pi->tx0, (OPJ_INT32)(comp->dx << levelno));
+					try0 = opj_int_ceildiv(pi->ty0, (OPJ_INT32)(comp->dy << levelno));
+					trx1 = opj_int_ceildiv(pi->tx1, (OPJ_INT32)(comp->dx << levelno));
+					try1 = opj_int_ceildiv(pi->ty1, (OPJ_INT32)(comp->dy << levelno));
+					rpx = res->pdx + levelno;
+					rpy = res->pdy + levelno;
+					if (!((pi->y % (OPJ_INT32)(comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
+						continue;	
+					}
+					if (!((pi->x % (OPJ_INT32)(comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){
+						continue;
+					}
+					
+					if ((res->pw==0)||(res->ph==0)) continue;
+					
+					if ((trx0==trx1)||(try0==try1)) continue;
+					
+					prci = opj_int_floordivpow2(opj_int_ceildiv(pi->x, (OPJ_INT32)(comp->dx << levelno)), (OPJ_INT32)res->pdx)
+						 - opj_int_floordivpow2(trx0, (OPJ_INT32)res->pdx);
+					prcj = opj_int_floordivpow2(opj_int_ceildiv(pi->y, (OPJ_INT32)(comp->dy << levelno)), (OPJ_INT32)res->pdy)
+						 - opj_int_floordivpow2(try0, (OPJ_INT32)res->pdy);
+					pi->precno = (OPJ_UINT32)(prci + prcj * (OPJ_INT32)res->pw);
+					for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
+						index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
+						if (!pi->include[index]) {
+							pi->include[index] = 1;
+							return OPJ_TRUE;
+						}
+LABEL_SKIP:;
+					}
+				}
+			}
+		}
+	}
+	
+	return OPJ_FALSE;
+}
+
+static void opj_get_encoding_parameters(	const opj_image_t *p_image,
+                                    const opj_cp_t *p_cp,
+                                    OPJ_UINT32 p_tileno,
+                                    OPJ_INT32 * p_tx0,
+                                    OPJ_INT32  * p_tx1,
+                                    OPJ_INT32  * p_ty0,
+                                    OPJ_INT32  * p_ty1,
+                                    OPJ_UINT32 * p_dx_min,
+                                    OPJ_UINT32 * p_dy_min,
+                                    OPJ_UINT32 * p_max_prec,
+                                    OPJ_UINT32 * p_max_res )
+{
+	/* loop */
+	OPJ_UINT32  compno, resno;
+	/* pointers */
+	const opj_tcp_t *l_tcp = 00;
+	const opj_tccp_t * l_tccp = 00;
+	const opj_image_comp_t * l_img_comp = 00;
+
+	/* position in x and y of tile */
+	OPJ_UINT32 p, q;
+
+	/* preconditions */
+	assert(p_cp != 00);
+	assert(p_image != 00);
+	assert(p_tileno < p_cp->tw * p_cp->th);
+
+	/* initializations */
+	l_tcp = &p_cp->tcps [p_tileno];
+	l_img_comp = p_image->comps;
+	l_tccp = l_tcp->tccps;
+
+	/* here calculation of tx0, tx1, ty0, ty1, maxprec, dx and dy */
+	p = p_tileno % p_cp->tw;
+	q = p_tileno / p_cp->tw;
+
+	/* find extent of tile */
+	*p_tx0 = opj_int_max((OPJ_INT32)(p_cp->tx0 + p * p_cp->tdx), (OPJ_INT32)p_image->x0);
+	*p_tx1 = opj_int_min((OPJ_INT32)(p_cp->tx0 + (p + 1) * p_cp->tdx), (OPJ_INT32)p_image->x1);
+	*p_ty0 = opj_int_max((OPJ_INT32)(p_cp->ty0 + q * p_cp->tdy), (OPJ_INT32)p_image->y0);
+	*p_ty1 = opj_int_min((OPJ_INT32)(p_cp->ty0 + (q + 1) * p_cp->tdy), (OPJ_INT32)p_image->y1);
+
+	/* max precision is 0 (can only grow) */
+	*p_max_prec = 0;
+	*p_max_res = 0;
+
+	/* take the largest value for dx_min and dy_min */
+	*p_dx_min = 0x7fffffff;
+	*p_dy_min  = 0x7fffffff;
+
+	for (compno = 0; compno < p_image->numcomps; ++compno) {
+		/* arithmetic variables to calculate */
+		OPJ_UINT32 l_level_no;
+		OPJ_INT32 l_rx0, l_ry0, l_rx1, l_ry1;
+		OPJ_INT32 l_px0, l_py0, l_px1, py1;
+		OPJ_UINT32 l_pdx, l_pdy;
+		OPJ_UINT32 l_pw, l_ph;
+		OPJ_UINT32 l_product;
+		OPJ_INT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1;
+
+		l_tcx0 = opj_int_ceildiv(*p_tx0, (OPJ_INT32)l_img_comp->dx);
+		l_tcy0 = opj_int_ceildiv(*p_ty0, (OPJ_INT32)l_img_comp->dy);
+		l_tcx1 = opj_int_ceildiv(*p_tx1, (OPJ_INT32)l_img_comp->dx);
+		l_tcy1 = opj_int_ceildiv(*p_ty1, (OPJ_INT32)l_img_comp->dy);
+
+		if (l_tccp->numresolutions > *p_max_res) {
+			*p_max_res = l_tccp->numresolutions;
+		}
+
+		/* use custom size for precincts */
+		for (resno = 0; resno < l_tccp->numresolutions; ++resno) {
+			OPJ_UINT32 l_dx, l_dy;
+
+			/* precinct width and height */
+			l_pdx = l_tccp->prcw[resno];
+			l_pdy = l_tccp->prch[resno];
+
+			l_dx = l_img_comp->dx * (1u << (l_pdx + l_tccp->numresolutions - 1 - resno));
+			l_dy = l_img_comp->dy * (1u << (l_pdy + l_tccp->numresolutions - 1 - resno));
+
+			/* take the minimum size for dx for each comp and resolution */
+			*p_dx_min = opj_uint_min(*p_dx_min, l_dx);
+			*p_dy_min = opj_uint_min(*p_dy_min, l_dy);
+
+			/* various calculations of extents */
+			l_level_no = l_tccp->numresolutions - 1 - resno;
+
+			l_rx0 = opj_int_ceildivpow2(l_tcx0, (OPJ_INT32)l_level_no);
+			l_ry0 = opj_int_ceildivpow2(l_tcy0, (OPJ_INT32)l_level_no);
+			l_rx1 = opj_int_ceildivpow2(l_tcx1, (OPJ_INT32)l_level_no);
+			l_ry1 = opj_int_ceildivpow2(l_tcy1, (OPJ_INT32)l_level_no);
+
+			l_px0 = opj_int_floordivpow2(l_rx0, (OPJ_INT32)l_pdx) << l_pdx;
+			l_py0 = opj_int_floordivpow2(l_ry0, (OPJ_INT32)l_pdy) << l_pdy;
+			l_px1 = opj_int_ceildivpow2(l_rx1, (OPJ_INT32)l_pdx) << l_pdx;
+
+			py1 = opj_int_ceildivpow2(l_ry1, (OPJ_INT32)l_pdy) << l_pdy;
+
+			l_pw = (l_rx0==l_rx1)?0:(OPJ_UINT32)((l_px1 - l_px0) >> l_pdx);
+			l_ph = (l_ry0==l_ry1)?0:(OPJ_UINT32)((py1 - l_py0) >> l_pdy);
+
+			l_product = l_pw * l_ph;
+
+			/* update precision */
+			if (l_product > *p_max_prec) {
+				*p_max_prec = l_product;
+			}
+		}
+		++l_img_comp;
+		++l_tccp;
+	}
+}
+
+
+static void opj_get_all_encoding_parameters(   const opj_image_t *p_image,
+                                        const opj_cp_t *p_cp,
+                                        OPJ_UINT32 tileno,
+                                        OPJ_INT32 * p_tx0,
+                                        OPJ_INT32 * p_tx1,
+                                        OPJ_INT32 * p_ty0,
+                                        OPJ_INT32 * p_ty1,
+                                        OPJ_UINT32 * p_dx_min,
+                                        OPJ_UINT32 * p_dy_min,
+                                        OPJ_UINT32 * p_max_prec,
+                                        OPJ_UINT32 * p_max_res,
+                                        OPJ_UINT32 ** p_resolutions )
+{
+	/* loop*/
+	OPJ_UINT32 compno, resno;
+
+	/* pointers*/
+	const opj_tcp_t *tcp = 00;
+	const opj_tccp_t * l_tccp = 00;
+	const opj_image_comp_t * l_img_comp = 00;
+
+	/* to store l_dx, l_dy, w and h for each resolution and component.*/
+	OPJ_UINT32 * lResolutionPtr;
+
+	/* position in x and y of tile*/
+	OPJ_UINT32 p, q;
+
+	/* non-corrected (in regard to image offset) tile offset */
+	OPJ_UINT32 l_tx0, l_ty0;
+
+	/* preconditions in debug*/
+	assert(p_cp != 00);
+	assert(p_image != 00);
+	assert(tileno < p_cp->tw * p_cp->th);
+
+	/* initializations*/
+	tcp = &p_cp->tcps [tileno];
+	l_tccp = tcp->tccps;
+	l_img_comp = p_image->comps;
+
+	/* position in x and y of tile*/
+	p = tileno % p_cp->tw;
+	q = tileno / p_cp->tw;
+
+	/* here calculation of tx0, tx1, ty0, ty1, maxprec, l_dx and l_dy */
+	l_tx0 = p_cp->tx0 + p * p_cp->tdx; /* can't be greater than p_image->x1 so won't overflow */
+	*p_tx0 = (OPJ_INT32)opj_uint_max(l_tx0, p_image->x0);
+	*p_tx1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, p_cp->tdx), p_image->x1);
+	l_ty0 = p_cp->ty0 + q * p_cp->tdy; /* can't be greater than p_image->y1 so won't overflow */
+	*p_ty0 = (OPJ_INT32)opj_uint_max(l_ty0, p_image->y0);
+	*p_ty1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, p_cp->tdy), p_image->y1);
+
+	/* max precision and resolution is 0 (can only grow)*/
+	*p_max_prec = 0;
+	*p_max_res = 0;
+
+	/* take the largest value for dx_min and dy_min*/
+	*p_dx_min = 0x7fffffff;
+	*p_dy_min = 0x7fffffff;
+
+	for (compno = 0; compno < p_image->numcomps; ++compno) {
+		/* aritmetic variables to calculate*/
+		OPJ_UINT32 l_level_no;
+		OPJ_INT32 l_rx0, l_ry0, l_rx1, l_ry1;
+		OPJ_INT32 l_px0, l_py0, l_px1, py1;
+		OPJ_UINT32 l_product;
+		OPJ_INT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1;
+		OPJ_UINT32 l_pdx, l_pdy , l_pw , l_ph;
+
+		lResolutionPtr = p_resolutions[compno];
+
+		l_tcx0 = opj_int_ceildiv(*p_tx0, (OPJ_INT32)l_img_comp->dx);
+		l_tcy0 = opj_int_ceildiv(*p_ty0, (OPJ_INT32)l_img_comp->dy);
+		l_tcx1 = opj_int_ceildiv(*p_tx1, (OPJ_INT32)l_img_comp->dx);
+		l_tcy1 = opj_int_ceildiv(*p_ty1, (OPJ_INT32)l_img_comp->dy);
+
+		if (l_tccp->numresolutions > *p_max_res) {
+			*p_max_res = l_tccp->numresolutions;
+		}
+
+		/* use custom size for precincts*/
+		l_level_no = l_tccp->numresolutions;
+		for (resno = 0; resno < l_tccp->numresolutions; ++resno) {
+			OPJ_UINT32 l_dx, l_dy;
+
+			--l_level_no;
+			
+			/* precinct width and height*/
+			l_pdx = l_tccp->prcw[resno];
+			l_pdy = l_tccp->prch[resno];
+			*lResolutionPtr++ = l_pdx;
+			*lResolutionPtr++ = l_pdy;
+			l_dx = l_img_comp->dx * (1u << (l_pdx + l_level_no));
+			l_dy = l_img_comp->dy * (1u << (l_pdy + l_level_no));
+			/* take the minimum size for l_dx for each comp and resolution*/
+			*p_dx_min = (OPJ_UINT32)opj_int_min((OPJ_INT32)*p_dx_min, (OPJ_INT32)l_dx);
+			*p_dy_min = (OPJ_UINT32)opj_int_min((OPJ_INT32)*p_dy_min, (OPJ_INT32)l_dy);
+
+			/* various calculations of extents*/
+			l_rx0 = opj_int_ceildivpow2(l_tcx0, (OPJ_INT32)l_level_no);
+			l_ry0 = opj_int_ceildivpow2(l_tcy0, (OPJ_INT32)l_level_no);
+			l_rx1 = opj_int_ceildivpow2(l_tcx1, (OPJ_INT32)l_level_no);
+			l_ry1 = opj_int_ceildivpow2(l_tcy1, (OPJ_INT32)l_level_no);
+			l_px0 = opj_int_floordivpow2(l_rx0, (OPJ_INT32)l_pdx) << l_pdx;
+			l_py0 = opj_int_floordivpow2(l_ry0, (OPJ_INT32)l_pdy) << l_pdy;
+			l_px1 = opj_int_ceildivpow2(l_rx1, (OPJ_INT32)l_pdx) << l_pdx;
+			py1 = opj_int_ceildivpow2(l_ry1, (OPJ_INT32)l_pdy) << l_pdy;
+			l_pw = (l_rx0==l_rx1)?0:(OPJ_UINT32)((l_px1 - l_px0) >> l_pdx);
+			l_ph = (l_ry0==l_ry1)?0:(OPJ_UINT32)((py1 - l_py0) >> l_pdy);
+			*lResolutionPtr++ = l_pw;
+			*lResolutionPtr++ = l_ph;
+			l_product = l_pw * l_ph;
+			
+            /* update precision*/
+			if (l_product > *p_max_prec) {
+				*p_max_prec = l_product;
+			}
+
+		}
+		++l_tccp;
+		++l_img_comp;
+	}
+}
+
+static opj_pi_iterator_t * opj_pi_create(	const opj_image_t *image,
+                                    const opj_cp_t *cp,
+                                    OPJ_UINT32 tileno )
+{
+	/* loop*/
+	OPJ_UINT32 pino, compno;
+	/* number of poc in the p_pi*/
+	OPJ_UINT32 l_poc_bound;
+
+	/* pointers to tile coding parameters and components.*/
+	opj_pi_iterator_t *l_pi = 00;
+	opj_tcp_t *tcp = 00;
+	const opj_tccp_t *tccp = 00;
+
+	/* current packet iterator being allocated*/
+	opj_pi_iterator_t *l_current_pi = 00;
+
+	/* preconditions in debug*/
+	assert(cp != 00);
+	assert(image != 00);
+	assert(tileno < cp->tw * cp->th);
+
+	/* initializations*/
+	tcp = &cp->tcps[tileno];
+	l_poc_bound = tcp->numpocs+1;
+
+	/* memory allocations*/
+	l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound), sizeof(opj_pi_iterator_t));
+	if (!l_pi) {
+		return NULL;
+	}
+
+	l_current_pi = l_pi;
+	for (pino = 0; pino < l_poc_bound ; ++pino) {
+
+		l_current_pi->comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
+		if (! l_current_pi->comps) {
+			opj_pi_destroy(l_pi, l_poc_bound);
+			return NULL;
+		}
+
+		l_current_pi->numcomps = image->numcomps;
+
+		for (compno = 0; compno < image->numcomps; ++compno) {
+			opj_pi_comp_t *comp = &l_current_pi->comps[compno];
+
+			tccp = &tcp->tccps[compno];
+
+			comp->resolutions = (opj_pi_resolution_t*) opj_calloc(tccp->numresolutions, sizeof(opj_pi_resolution_t));
+			if (!comp->resolutions) {
+				opj_pi_destroy(l_pi, l_poc_bound);
+				return 00;
+			}
+
+			comp->numresolutions = tccp->numresolutions;
+		}
+		++l_current_pi;
+	}
+	return l_pi;
+}
+
+static void opj_pi_update_encode_poc_and_final (   opj_cp_t *p_cp,
+                                            OPJ_UINT32 p_tileno,
+                                            OPJ_INT32 p_tx0,
+                                            OPJ_INT32 p_tx1,
+                                            OPJ_INT32 p_ty0,
+                                            OPJ_INT32 p_ty1,
+                                            OPJ_UINT32 p_max_prec,
+                                            OPJ_UINT32 p_max_res,
+                                            OPJ_UINT32 p_dx_min,
+                                            OPJ_UINT32 p_dy_min)
+{
+	/* loop*/
+	OPJ_UINT32 pino;
+	/* tile coding parameter*/
+	opj_tcp_t *l_tcp = 00;
+	/* current poc being updated*/
+	opj_poc_t * l_current_poc = 00;
+
+	/* number of pocs*/
+	OPJ_UINT32 l_poc_bound;
+
+    OPJ_ARG_NOT_USED(p_max_res);
+
+	/* preconditions in debug*/
+	assert(p_cp != 00);
+	assert(p_tileno < p_cp->tw * p_cp->th);
+
+	/* initializations*/
+	l_tcp = &p_cp->tcps [p_tileno];
+	/* number of iterations in the loop */
+	l_poc_bound = l_tcp->numpocs+1;
+
+	/* start at first element, and to make sure the compiler will not make a calculation each time in the loop
+	   store a pointer to the current element to modify rather than l_tcp->pocs[i]*/
+	l_current_poc = l_tcp->pocs;
+
+	l_current_poc->compS = l_current_poc->compno0;
+	l_current_poc->compE = l_current_poc->compno1;
+	l_current_poc->resS = l_current_poc->resno0;
+	l_current_poc->resE = l_current_poc->resno1;
+	l_current_poc->layE = l_current_poc->layno1;
+
+	/* special treatment for the first element*/
+	l_current_poc->layS = 0;
+	l_current_poc->prg  = l_current_poc->prg1;
+	l_current_poc->prcS = 0;
+
+	l_current_poc->prcE = p_max_prec;
+	l_current_poc->txS = (OPJ_UINT32)p_tx0;
+	l_current_poc->txE = (OPJ_UINT32)p_tx1;
+	l_current_poc->tyS = (OPJ_UINT32)p_ty0;
+	l_current_poc->tyE = (OPJ_UINT32)p_ty1;
+	l_current_poc->dx = p_dx_min;
+	l_current_poc->dy = p_dy_min;
+
+	++ l_current_poc;
+	for (pino = 1;pino < l_poc_bound ; ++pino) {
+		l_current_poc->compS = l_current_poc->compno0;
+		l_current_poc->compE= l_current_poc->compno1;
+		l_current_poc->resS = l_current_poc->resno0;
+		l_current_poc->resE = l_current_poc->resno1;
+		l_current_poc->layE = l_current_poc->layno1;
+		l_current_poc->prg  = l_current_poc->prg1;
+		l_current_poc->prcS = 0;
+		/* special treatment here different from the first element*/
+		l_current_poc->layS = (l_current_poc->layE > (l_current_poc-1)->layE) ? l_current_poc->layE : 0;
+
+		l_current_poc->prcE = p_max_prec;
+		l_current_poc->txS = (OPJ_UINT32)p_tx0;
+		l_current_poc->txE = (OPJ_UINT32)p_tx1;
+		l_current_poc->tyS = (OPJ_UINT32)p_ty0;
+		l_current_poc->tyE = (OPJ_UINT32)p_ty1;
+		l_current_poc->dx = p_dx_min;
+		l_current_poc->dy = p_dy_min;
+		++ l_current_poc;
+	}
+}
+
+static void opj_pi_update_encode_not_poc (	opj_cp_t *p_cp,
+                                    OPJ_UINT32 p_num_comps,
+                                    OPJ_UINT32 p_tileno,
+                                    OPJ_INT32 p_tx0,
+                                    OPJ_INT32 p_tx1,
+                                    OPJ_INT32 p_ty0,
+                                    OPJ_INT32 p_ty1,
+                                    OPJ_UINT32 p_max_prec,
+                                    OPJ_UINT32 p_max_res,
+                                    OPJ_UINT32 p_dx_min,
+                                    OPJ_UINT32 p_dy_min)
+{
+	/* loop*/
+	OPJ_UINT32 pino;
+	/* tile coding parameter*/
+	opj_tcp_t *l_tcp = 00;
+	/* current poc being updated*/
+	opj_poc_t * l_current_poc = 00;
+	/* number of pocs*/
+	OPJ_UINT32 l_poc_bound;
+
+	/* preconditions in debug*/
+	assert(p_cp != 00);
+	assert(p_tileno < p_cp->tw * p_cp->th);
+
+	/* initializations*/
+	l_tcp = &p_cp->tcps [p_tileno];
+
+	/* number of iterations in the loop */
+	l_poc_bound = l_tcp->numpocs+1;
+
+	/* start at first element, and to make sure the compiler will not make a calculation each time in the loop
+	   store a pointer to the current element to modify rather than l_tcp->pocs[i]*/
+	l_current_poc = l_tcp->pocs;
+
+	for (pino = 0; pino < l_poc_bound ; ++pino) {
+		l_current_poc->compS = 0;
+		l_current_poc->compE = p_num_comps;/*p_image->numcomps;*/
+		l_current_poc->resS = 0;
+		l_current_poc->resE = p_max_res;
+		l_current_poc->layS = 0;
+		l_current_poc->layE = l_tcp->numlayers;
+		l_current_poc->prg  = l_tcp->prg;
+		l_current_poc->prcS = 0;
+		l_current_poc->prcE = p_max_prec;
+		l_current_poc->txS = (OPJ_UINT32)p_tx0;
+		l_current_poc->txE = (OPJ_UINT32)p_tx1;
+		l_current_poc->tyS = (OPJ_UINT32)p_ty0;
+		l_current_poc->tyE = (OPJ_UINT32)p_ty1;
+		l_current_poc->dx = p_dx_min;
+		l_current_poc->dy = p_dy_min;
+		++ l_current_poc;
+	}
+}
+
+static void opj_pi_update_decode_poc (opj_pi_iterator_t * p_pi,
+                               opj_tcp_t * p_tcp,
+                               OPJ_UINT32 p_max_precision,
+                               OPJ_UINT32 p_max_res)
+{
+	/* loop*/
+	OPJ_UINT32 pino;
+
+	/* encoding prameters to set*/
+	OPJ_UINT32 l_bound;
+
+	opj_pi_iterator_t * l_current_pi = 00;
+	opj_poc_t* l_current_poc = 0;
+
+    OPJ_ARG_NOT_USED(p_max_res);
+
+	/* preconditions in debug*/
+	assert(p_pi != 00);
+	assert(p_tcp != 00);
+
+	/* initializations*/
+	l_bound = p_tcp->numpocs+1;
+	l_current_pi = p_pi;
+	l_current_poc = p_tcp->pocs;
+
+	for	(pino = 0;pino<l_bound;++pino) {
+		l_current_pi->poc.prg = l_current_poc->prg; /* Progression Order #0 */
+		l_current_pi->first = 1;
+
+		l_current_pi->poc.resno0 = l_current_poc->resno0; /* Resolution Level Index #0 (Start) */
+		l_current_pi->poc.compno0 = l_current_poc->compno0; /* Component Index #0 (Start) */
+		l_current_pi->poc.layno0 = 0;
+		l_current_pi->poc.precno0 = 0;
+		l_current_pi->poc.resno1 = l_current_poc->resno1; /* Resolution Level Index #0 (End) */
+		l_current_pi->poc.compno1 = l_current_poc->compno1; /* Component Index #0 (End) */
+		l_current_pi->poc.layno1 = l_current_poc->layno1; /* Layer Index #0 (End) */
+		l_current_pi->poc.precno1 = p_max_precision;
+		++l_current_pi;
+		++l_current_poc;
+	}
+}
+
+static void opj_pi_update_decode_not_poc (opj_pi_iterator_t * p_pi,
+                                   opj_tcp_t * p_tcp,
+                                   OPJ_UINT32 p_max_precision,
+                                   OPJ_UINT32 p_max_res)
+{
+	/* loop*/
+	OPJ_UINT32 pino;
+
+	/* encoding prameters to set*/
+	OPJ_UINT32 l_bound;
+
+	opj_pi_iterator_t * l_current_pi = 00;
+	/* preconditions in debug*/
+	assert(p_tcp != 00);
+	assert(p_pi != 00);
+
+	/* initializations*/
+	l_bound = p_tcp->numpocs+1;
+	l_current_pi = p_pi;
+
+	for (pino = 0;pino<l_bound;++pino) {
+		l_current_pi->poc.prg = p_tcp->prg;
+		l_current_pi->first = 1;
+		l_current_pi->poc.resno0 = 0;
+		l_current_pi->poc.compno0 = 0;
+		l_current_pi->poc.layno0 = 0;
+		l_current_pi->poc.precno0 = 0;
+		l_current_pi->poc.resno1 = p_max_res;
+		l_current_pi->poc.compno1 = l_current_pi->numcomps;
+		l_current_pi->poc.layno1 = p_tcp->numlayers;
+		l_current_pi->poc.precno1 = p_max_precision;
+		++l_current_pi;
+	}
+}
+
+
+
+static OPJ_BOOL opj_pi_check_next_level(	OPJ_INT32 pos,
+								opj_cp_t *cp,
+								OPJ_UINT32 tileno,
+								OPJ_UINT32 pino,
+								const OPJ_CHAR *prog)
+{
+	OPJ_INT32 i;
+	opj_tcp_t *tcps =&cp->tcps[tileno];
+	opj_poc_t *tcp = &tcps->pocs[pino];
+
+	if(pos>=0){
+		for(i=pos;pos>=0;i--){
+			switch(prog[i]){
+		    case 'R':
+			    if(tcp->res_t==tcp->resE){
+				    if(opj_pi_check_next_level(pos-1,cp,tileno,pino,prog)){
+					    return OPJ_TRUE;
+				    }else{
+					    return OPJ_FALSE;
+				    }
+			    }else{
+				    return OPJ_TRUE;
+			    }
+			    break;
+		    case 'C':
+			    if(tcp->comp_t==tcp->compE){
+				    if(opj_pi_check_next_level(pos-1,cp,tileno,pino,prog)){
+					    return OPJ_TRUE;
+				    }else{
+					    return OPJ_FALSE;
+				    }
+			    }else{
+				    return OPJ_TRUE;
+			    }
+			    break;
+		    case 'L':
+			    if(tcp->lay_t==tcp->layE){
+				    if(opj_pi_check_next_level(pos-1,cp,tileno,pino,prog)){
+					    return OPJ_TRUE;
+				    }else{
+					    return OPJ_FALSE;
+				    }
+			    }else{
+				    return OPJ_TRUE;
+			    }
+			    break;
+		    case 'P':
+			    switch(tcp->prg){
+                    case OPJ_LRCP: /* fall through */
+                    case OPJ_RLCP:
+					    if(tcp->prc_t == tcp->prcE){
+						    if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
+							    return OPJ_TRUE;
+						    }else{
+							    return OPJ_FALSE;
+						    }
+					    }else{
+						    return OPJ_TRUE;
+					    }
+					    break;
+			    default:
+				    if(tcp->tx0_t == tcp->txE){
+					    /*TY*/
+					    if(tcp->ty0_t == tcp->tyE){
+						    if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
+							    return OPJ_TRUE;
+						    }else{
+							    return OPJ_FALSE;
+						    }
+					    }else{
+						    return OPJ_TRUE;
+					    }/*TY*/
+				    }else{
+					    return OPJ_TRUE;
+				    }
+				    break;
+			    }/*end case P*/
+		    }/*end switch*/
+		}/*end for*/
+	}/*end if*/
+	return OPJ_FALSE;
+}
+
+
+/*
+==========================================================
+   Packet iterator interface
+==========================================================
+*/
+opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
+										opj_cp_t *p_cp,
+										OPJ_UINT32 p_tile_no)
+{
+	/* loop */
+	OPJ_UINT32 pino;
+	OPJ_UINT32 compno, resno;
+
+	/* to store w, h, dx and dy fro all components and resolutions */
+	OPJ_UINT32 * l_tmp_data;
+	OPJ_UINT32 ** l_tmp_ptr;
+
+	/* encoding prameters to set */
+	OPJ_UINT32 l_max_res;
+	OPJ_UINT32 l_max_prec;
+	OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
+	OPJ_UINT32 l_dx_min,l_dy_min;
+	OPJ_UINT32 l_bound;
+	OPJ_UINT32 l_step_p , l_step_c , l_step_r , l_step_l ;
+	OPJ_UINT32 l_data_stride;
+
+	/* pointers */
+	opj_pi_iterator_t *l_pi = 00;
+	opj_tcp_t *l_tcp = 00;
+	const opj_tccp_t *l_tccp = 00;
+	opj_pi_comp_t *l_current_comp = 00;
+	opj_image_comp_t * l_img_comp = 00;
+	opj_pi_iterator_t * l_current_pi = 00;
+	OPJ_UINT32 * l_encoding_value_ptr = 00;
+
+	/* preconditions in debug */
+	assert(p_cp != 00);
+	assert(p_image != 00);
+	assert(p_tile_no < p_cp->tw * p_cp->th);
+
+	/* initializations */
+	l_tcp = &p_cp->tcps[p_tile_no];
+	l_bound = l_tcp->numpocs+1;
+
+	l_data_stride = 4 * OPJ_J2K_MAXRLVLS;
+	l_tmp_data = (OPJ_UINT32*)opj_malloc(
+		l_data_stride * p_image->numcomps * sizeof(OPJ_UINT32));
+	if
+		(! l_tmp_data)
+	{
+		return 00;
+	}
+	l_tmp_ptr = (OPJ_UINT32**)opj_malloc(
+		p_image->numcomps * sizeof(OPJ_UINT32 *));
+	if
+		(! l_tmp_ptr)
+	{
+		opj_free(l_tmp_data);
+		return 00;
+	}
+
+	/* memory allocation for pi */
+	l_pi = opj_pi_create(p_image, p_cp, p_tile_no);
+	if (!l_pi) {
+		opj_free(l_tmp_data);
+		opj_free(l_tmp_ptr);
+		return 00;
+	}
+
+	l_encoding_value_ptr = l_tmp_data;
+	/* update pointer array */
+	for
+		(compno = 0; compno < p_image->numcomps; ++compno)
+	{
+		l_tmp_ptr[compno] = l_encoding_value_ptr;
+		l_encoding_value_ptr += l_data_stride;
+	}
+	/* get encoding parameters */
+	opj_get_all_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res,l_tmp_ptr);
+
+	/* step calculations */
+	l_step_p = 1;
+	l_step_c = l_max_prec * l_step_p;
+	l_step_r = p_image->numcomps * l_step_c;
+	l_step_l = l_max_res * l_step_r;
+
+	/* set values for first packet iterator */
+	l_current_pi = l_pi;
+
+	/* memory allocation for include */
+	l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
+	if
+		(!l_current_pi->include)
+	{
+		opj_free(l_tmp_data);
+		opj_free(l_tmp_ptr);
+		opj_pi_destroy(l_pi, l_bound);
+		return 00;
+	}
+
+	/* special treatment for the first packet iterator */
+	l_current_comp = l_current_pi->comps;
+	l_img_comp = p_image->comps;
+	l_tccp = l_tcp->tccps;
+
+	l_current_pi->tx0 = l_tx0;
+	l_current_pi->ty0 = l_ty0;
+	l_current_pi->tx1 = l_tx1;
+	l_current_pi->ty1 = l_ty1;
+
+	/*l_current_pi->dx = l_img_comp->dx;*/
+	/*l_current_pi->dy = l_img_comp->dy;*/
+
+	l_current_pi->step_p = l_step_p;
+	l_current_pi->step_c = l_step_c;
+	l_current_pi->step_r = l_step_r;
+	l_current_pi->step_l = l_step_l;
+
+	/* allocation for components and number of components has already been calculated by opj_pi_create */
+	for
+		(compno = 0; compno < l_current_pi->numcomps; ++compno)
+	{
+		opj_pi_resolution_t *l_res = l_current_comp->resolutions;
+		l_encoding_value_ptr = l_tmp_ptr[compno];
+
+		l_current_comp->dx = l_img_comp->dx;
+		l_current_comp->dy = l_img_comp->dy;
+		/* resolutions have already been initialized */
+		for
+			(resno = 0; resno < l_current_comp->numresolutions; resno++)
+		{
+			l_res->pdx = *(l_encoding_value_ptr++);
+			l_res->pdy = *(l_encoding_value_ptr++);
+			l_res->pw =  *(l_encoding_value_ptr++);
+			l_res->ph =  *(l_encoding_value_ptr++);
+			++l_res;
+		}
+		++l_current_comp;
+		++l_img_comp;
+		++l_tccp;
+	}
+	++l_current_pi;
+
+	for (pino = 1 ; pino<l_bound ; ++pino )
+	{
+		l_current_comp = l_current_pi->comps;
+		l_img_comp = p_image->comps;
+		l_tccp = l_tcp->tccps;
+
+		l_current_pi->tx0 = l_tx0;
+		l_current_pi->ty0 = l_ty0;
+		l_current_pi->tx1 = l_tx1;
+		l_current_pi->ty1 = l_ty1;
+		/*l_current_pi->dx = l_dx_min;*/
+		/*l_current_pi->dy = l_dy_min;*/
+		l_current_pi->step_p = l_step_p;
+		l_current_pi->step_c = l_step_c;
+		l_current_pi->step_r = l_step_r;
+		l_current_pi->step_l = l_step_l;
+
+		/* allocation for components and number of components has already been calculated by opj_pi_create */
+		for
+			(compno = 0; compno < l_current_pi->numcomps; ++compno)
+		{
+			opj_pi_resolution_t *l_res = l_current_comp->resolutions;
+			l_encoding_value_ptr = l_tmp_ptr[compno];
+
+			l_current_comp->dx = l_img_comp->dx;
+			l_current_comp->dy = l_img_comp->dy;
+			/* resolutions have already been initialized */
+			for
+				(resno = 0; resno < l_current_comp->numresolutions; resno++)
+			{
+				l_res->pdx = *(l_encoding_value_ptr++);
+				l_res->pdy = *(l_encoding_value_ptr++);
+				l_res->pw =  *(l_encoding_value_ptr++);
+				l_res->ph =  *(l_encoding_value_ptr++);
+				++l_res;
+			}
+			++l_current_comp;
+			++l_img_comp;
+			++l_tccp;
+		}
+		/* special treatment*/
+		l_current_pi->include = (l_current_pi-1)->include;
+		++l_current_pi;
+	}
+	opj_free(l_tmp_data);
+	l_tmp_data = 00;
+	opj_free(l_tmp_ptr);
+	l_tmp_ptr = 00;
+	if
+		(l_tcp->POC)
+	{
+		opj_pi_update_decode_poc (l_pi,l_tcp,l_max_prec,l_max_res);
+	}
+	else
+	{
+		opj_pi_update_decode_not_poc(l_pi,l_tcp,l_max_prec,l_max_res);
+	}
+	return l_pi;
+}
+
+
+
+opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
+                                            opj_cp_t *p_cp,
+                                            OPJ_UINT32 p_tile_no,
+                                            J2K_T2_MODE p_t2_mode )
+{
+	/* loop*/
+	OPJ_UINT32 pino;
+	OPJ_UINT32 compno, resno;
+
+	/* to store w, h, dx and dy fro all components and resolutions*/
+	OPJ_UINT32 * l_tmp_data;
+	OPJ_UINT32 ** l_tmp_ptr;
+
+	/* encoding prameters to set*/
+	OPJ_UINT32 l_max_res;
+	OPJ_UINT32 l_max_prec;
+	OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
+	OPJ_UINT32 l_dx_min,l_dy_min;
+	OPJ_UINT32 l_bound;
+	OPJ_UINT32 l_step_p , l_step_c , l_step_r , l_step_l ;
+	OPJ_UINT32 l_data_stride;
+
+	/* pointers*/
+	opj_pi_iterator_t *l_pi = 00;
+	opj_tcp_t *l_tcp = 00;
+	const opj_tccp_t *l_tccp = 00;
+	opj_pi_comp_t *l_current_comp = 00;
+	opj_image_comp_t * l_img_comp = 00;
+	opj_pi_iterator_t * l_current_pi = 00;
+	OPJ_UINT32 * l_encoding_value_ptr = 00;
+
+	/* preconditions in debug*/
+	assert(p_cp != 00);
+	assert(p_image != 00);
+	assert(p_tile_no < p_cp->tw * p_cp->th);
+
+	/* initializations*/
+	l_tcp = &p_cp->tcps[p_tile_no];
+	l_bound = l_tcp->numpocs+1;
+
+	l_data_stride = 4 * OPJ_J2K_MAXRLVLS;
+	l_tmp_data = (OPJ_UINT32*)opj_malloc(
+		l_data_stride * p_image->numcomps * sizeof(OPJ_UINT32));
+	if (! l_tmp_data) {
+		return 00;
+	}
+
+	l_tmp_ptr = (OPJ_UINT32**)opj_malloc(
+		p_image->numcomps * sizeof(OPJ_UINT32 *));
+	if (! l_tmp_ptr) {
+		opj_free(l_tmp_data);
+		return 00;
+	}
+
+	/* memory allocation for pi*/
+	l_pi = opj_pi_create(p_image,p_cp,p_tile_no);
+	if (!l_pi) {
+		opj_free(l_tmp_data);
+		opj_free(l_tmp_ptr);
+		return 00;
+	}
+
+	l_encoding_value_ptr = l_tmp_data;
+	/* update pointer array*/
+	for (compno = 0; compno < p_image->numcomps; ++compno) {
+		l_tmp_ptr[compno] = l_encoding_value_ptr;
+		l_encoding_value_ptr += l_data_stride;
+	}
+
+	/* get encoding parameters*/
+	opj_get_all_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res,l_tmp_ptr);
+
+	/* step calculations*/
+	l_step_p = 1;
+	l_step_c = l_max_prec * l_step_p;
+	l_step_r = p_image->numcomps * l_step_c;
+	l_step_l = l_max_res * l_step_r;
+
+	/* set values for first packet iterator*/
+	l_pi->tp_on = (OPJ_BYTE)p_cp->m_specific_param.m_enc.m_tp_on;
+	l_current_pi = l_pi;
+
+	/* memory allocation for include*/
+	l_current_pi->include = (OPJ_INT16*) opj_calloc(l_tcp->numlayers * l_step_l, sizeof(OPJ_INT16));
+	if (!l_current_pi->include) {
+		opj_free(l_tmp_data);
+		opj_free(l_tmp_ptr);
+		opj_pi_destroy(l_pi, l_bound);
+		return 00;
+	}
+
+	/* special treatment for the first packet iterator*/
+	l_current_comp = l_current_pi->comps;
+	l_img_comp = p_image->comps;
+	l_tccp = l_tcp->tccps;
+	l_current_pi->tx0 = l_tx0;
+	l_current_pi->ty0 = l_ty0;
+	l_current_pi->tx1 = l_tx1;
+	l_current_pi->ty1 = l_ty1;
+	l_current_pi->dx = l_dx_min;
+	l_current_pi->dy = l_dy_min;
+	l_current_pi->step_p = l_step_p;
+	l_current_pi->step_c = l_step_c;
+	l_current_pi->step_r = l_step_r;
+	l_current_pi->step_l = l_step_l;
+
+	/* allocation for components and number of components has already been calculated by opj_pi_create */
+	for (compno = 0; compno < l_current_pi->numcomps; ++compno) {
+		opj_pi_resolution_t *l_res = l_current_comp->resolutions;
+		l_encoding_value_ptr = l_tmp_ptr[compno];
+
+		l_current_comp->dx = l_img_comp->dx;
+		l_current_comp->dy = l_img_comp->dy;
+
+		/* resolutions have already been initialized */
+		for (resno = 0; resno < l_current_comp->numresolutions; resno++) {
+			l_res->pdx = *(l_encoding_value_ptr++);
+			l_res->pdy = *(l_encoding_value_ptr++);
+			l_res->pw =  *(l_encoding_value_ptr++);
+			l_res->ph =  *(l_encoding_value_ptr++);
+			++l_res;
+		}
+
+		++l_current_comp;
+		++l_img_comp;
+		++l_tccp;
+	}
+	++l_current_pi;
+
+	for (pino = 1 ; pino<l_bound ; ++pino ) {
+		l_current_comp = l_current_pi->comps;
+		l_img_comp = p_image->comps;
+		l_tccp = l_tcp->tccps;
+
+		l_current_pi->tx0 = l_tx0;
+		l_current_pi->ty0 = l_ty0;
+		l_current_pi->tx1 = l_tx1;
+		l_current_pi->ty1 = l_ty1;
+		l_current_pi->dx = l_dx_min;
+		l_current_pi->dy = l_dy_min;
+		l_current_pi->step_p = l_step_p;
+		l_current_pi->step_c = l_step_c;
+		l_current_pi->step_r = l_step_r;
+		l_current_pi->step_l = l_step_l;
+
+		/* allocation for components and number of components has already been calculated by opj_pi_create */
+		for (compno = 0; compno < l_current_pi->numcomps; ++compno) {
+			opj_pi_resolution_t *l_res = l_current_comp->resolutions;
+			l_encoding_value_ptr = l_tmp_ptr[compno];
+
+			l_current_comp->dx = l_img_comp->dx;
+			l_current_comp->dy = l_img_comp->dy;
+			/* resolutions have already been initialized */
+			for (resno = 0; resno < l_current_comp->numresolutions; resno++) {
+				l_res->pdx = *(l_encoding_value_ptr++);
+				l_res->pdy = *(l_encoding_value_ptr++);
+				l_res->pw =  *(l_encoding_value_ptr++);
+				l_res->ph =  *(l_encoding_value_ptr++);
+				++l_res;
+			}
+			++l_current_comp;
+			++l_img_comp;
+			++l_tccp;
+		}
+
+		/* special treatment*/
+		l_current_pi->include = (l_current_pi-1)->include;
+		++l_current_pi;
+	}
+
+	opj_free(l_tmp_data);
+	l_tmp_data = 00;
+	opj_free(l_tmp_ptr);
+	l_tmp_ptr = 00;
+
+    if (l_tcp->POC && (OPJ_IS_CINEMA(p_cp->rsiz) || p_t2_mode == FINAL_PASS)) {
+		opj_pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
+	}
+	else {
+		opj_pi_update_encode_not_poc(p_cp,p_image->numcomps,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
+	}
+
+	return l_pi;
+}
+
+void opj_pi_create_encode( 	opj_pi_iterator_t *pi,
+							opj_cp_t *cp,
+							OPJ_UINT32 tileno,
+							OPJ_UINT32 pino,
+							OPJ_UINT32 tpnum,
+							OPJ_INT32 tppos,
+							J2K_T2_MODE t2_mode)
+{
+	const OPJ_CHAR *prog;
+	OPJ_INT32 i;
+	OPJ_UINT32 incr_top=1,resetX=0;
+	opj_tcp_t *tcps =&cp->tcps[tileno];
+	opj_poc_t *tcp= &tcps->pocs[pino];
+
+	prog = opj_j2k_convert_progression_order(tcp->prg);
+
+	pi[pino].first = 1;
+	pi[pino].poc.prg = tcp->prg;
+
+    if(!(cp->m_specific_param.m_enc.m_tp_on && ((!OPJ_IS_CINEMA(cp->rsiz) && (t2_mode == FINAL_PASS)) || OPJ_IS_CINEMA(cp->rsiz)))){
+		pi[pino].poc.resno0 = tcp->resS;
+		pi[pino].poc.resno1 = tcp->resE;
+		pi[pino].poc.compno0 = tcp->compS;
+		pi[pino].poc.compno1 = tcp->compE;
+		pi[pino].poc.layno0 = tcp->layS;
+		pi[pino].poc.layno1 = tcp->layE;
+		pi[pino].poc.precno0 = tcp->prcS;
+		pi[pino].poc.precno1 = tcp->prcE;
+		pi[pino].poc.tx0 = (OPJ_INT32)tcp->txS;
+		pi[pino].poc.ty0 = (OPJ_INT32)tcp->tyS;
+		pi[pino].poc.tx1 = (OPJ_INT32)tcp->txE;
+		pi[pino].poc.ty1 = (OPJ_INT32)tcp->tyE;
+	}else {
+		for(i=tppos+1;i<4;i++){
+			switch(prog[i]){
+			case 'R':
+				pi[pino].poc.resno0 = tcp->resS;
+				pi[pino].poc.resno1 = tcp->resE;
+				break;
+			case 'C':
+				pi[pino].poc.compno0 = tcp->compS;
+				pi[pino].poc.compno1 = tcp->compE;
+				break;
+			case 'L':
+				pi[pino].poc.layno0 = tcp->layS;
+				pi[pino].poc.layno1 = tcp->layE;
+				break;
+			case 'P':
+				switch(tcp->prg){
+				case OPJ_LRCP:
+				case OPJ_RLCP:
+					pi[pino].poc.precno0 = tcp->prcS;
+					pi[pino].poc.precno1 = tcp->prcE;
+					break;
+				default:
+					pi[pino].poc.tx0 = (OPJ_INT32)tcp->txS;
+					pi[pino].poc.ty0 = (OPJ_INT32)tcp->tyS;
+					pi[pino].poc.tx1 = (OPJ_INT32)tcp->txE;
+					pi[pino].poc.ty1 = (OPJ_INT32)tcp->tyE;
+					break;
+				}
+				break;
+			}
+		}
+
+		if(tpnum==0){
+			for(i=tppos;i>=0;i--){
+				switch(prog[i]){
+				case 'C':
+					tcp->comp_t = tcp->compS;
+					pi[pino].poc.compno0 = tcp->comp_t;
+					pi[pino].poc.compno1 = tcp->comp_t+1;
+					tcp->comp_t+=1;
+					break;
+				case 'R':
+					tcp->res_t = tcp->resS;
+					pi[pino].poc.resno0 = tcp->res_t;
+					pi[pino].poc.resno1 = tcp->res_t+1;
+					tcp->res_t+=1;
+					break;
+				case 'L':
+					tcp->lay_t = tcp->layS;
+					pi[pino].poc.layno0 = tcp->lay_t;
+					pi[pino].poc.layno1 = tcp->lay_t+1;
+					tcp->lay_t+=1;
+					break;
+				case 'P':
+					switch(tcp->prg){
+					case OPJ_LRCP:
+					case OPJ_RLCP:
+						tcp->prc_t = tcp->prcS;
+						pi[pino].poc.precno0 = tcp->prc_t;
+						pi[pino].poc.precno1 = tcp->prc_t+1;
+						tcp->prc_t+=1;
+						break;
+					default:
+						tcp->tx0_t = tcp->txS;
+						tcp->ty0_t = tcp->tyS;
+						pi[pino].poc.tx0 = (OPJ_INT32)tcp->tx0_t;
+						pi[pino].poc.tx1 = (OPJ_INT32)(tcp->tx0_t + tcp->dx - (tcp->tx0_t % tcp->dx));
+						pi[pino].poc.ty0 = (OPJ_INT32)tcp->ty0_t;
+						pi[pino].poc.ty1 = (OPJ_INT32)(tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy));
+						tcp->tx0_t = (OPJ_UINT32)pi[pino].poc.tx1;
+						tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
+						break;
+					}
+					break;
+				}
+			}
+			incr_top=1;
+		}else{
+			for(i=tppos;i>=0;i--){
+				switch(prog[i]){
+				case 'C':
+					pi[pino].poc.compno0 = tcp->comp_t-1;
+					pi[pino].poc.compno1 = tcp->comp_t;
+					break;
+				case 'R':
+					pi[pino].poc.resno0 = tcp->res_t-1;
+					pi[pino].poc.resno1 = tcp->res_t;
+					break;
+				case 'L':
+					pi[pino].poc.layno0 = tcp->lay_t-1;
+					pi[pino].poc.layno1 = tcp->lay_t;
+					break;
+				case 'P':
+					switch(tcp->prg){
+					case OPJ_LRCP:
+					case OPJ_RLCP:
+						pi[pino].poc.precno0 = tcp->prc_t-1;
+						pi[pino].poc.precno1 = tcp->prc_t;
+						break;
+					default:
+						pi[pino].poc.tx0 = (OPJ_INT32)(tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx));
+						pi[pino].poc.tx1 = (OPJ_INT32)tcp->tx0_t ;
+						pi[pino].poc.ty0 = (OPJ_INT32)(tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy));
+						pi[pino].poc.ty1 = (OPJ_INT32)tcp->ty0_t ;
+						break;
+					}
+					break;
+				}
+				if(incr_top==1){
+					switch(prog[i]){
+					case 'R':
+						if(tcp->res_t==tcp->resE){
+							if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
+								tcp->res_t = tcp->resS;
+								pi[pino].poc.resno0 = tcp->res_t;
+								pi[pino].poc.resno1 = tcp->res_t+1;
+								tcp->res_t+=1;
+								incr_top=1;
+							}else{
+								incr_top=0;
+							}
+						}else{
+							pi[pino].poc.resno0 = tcp->res_t;
+							pi[pino].poc.resno1 = tcp->res_t+1;
+							tcp->res_t+=1;
+							incr_top=0;
+						}
+						break;
+					case 'C':
+						if(tcp->comp_t ==tcp->compE){
+							if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
+								tcp->comp_t = tcp->compS;
+								pi[pino].poc.compno0 = tcp->comp_t;
+								pi[pino].poc.compno1 = tcp->comp_t+1;
+								tcp->comp_t+=1;
+								incr_top=1;
+							}else{
+								incr_top=0;
+							}
+						}else{
+							pi[pino].poc.compno0 = tcp->comp_t;
+							pi[pino].poc.compno1 = tcp->comp_t+1;
+							tcp->comp_t+=1;
+							incr_top=0;
+						}
+						break;
+					case 'L':
+						if(tcp->lay_t == tcp->layE){
+							if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
+								tcp->lay_t = tcp->layS;
+								pi[pino].poc.layno0 = tcp->lay_t;
+								pi[pino].poc.layno1 = tcp->lay_t+1;
+								tcp->lay_t+=1;
+								incr_top=1;
+							}else{
+								incr_top=0;
+							}
+						}else{
+							pi[pino].poc.layno0 = tcp->lay_t;
+							pi[pino].poc.layno1 = tcp->lay_t+1;
+							tcp->lay_t+=1;
+							incr_top=0;
+						}
+						break;
+					case 'P':
+						switch(tcp->prg){
+						case OPJ_LRCP:
+						case OPJ_RLCP:
+							if(tcp->prc_t == tcp->prcE){
+								if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
+									tcp->prc_t = tcp->prcS;
+									pi[pino].poc.precno0 = tcp->prc_t;
+									pi[pino].poc.precno1 = tcp->prc_t+1;
+									tcp->prc_t+=1;
+									incr_top=1;
+								}else{
+									incr_top=0;
+								}
+							}else{
+								pi[pino].poc.precno0 = tcp->prc_t;
+								pi[pino].poc.precno1 = tcp->prc_t+1;
+								tcp->prc_t+=1;
+								incr_top=0;
+							}
+							break;
+						default:
+							if(tcp->tx0_t >= tcp->txE){
+								if(tcp->ty0_t >= tcp->tyE){
+									if(opj_pi_check_next_level(i-1,cp,tileno,pino,prog)){
+										tcp->ty0_t = tcp->tyS;
+										pi[pino].poc.ty0 = (OPJ_INT32)tcp->ty0_t;
+										pi[pino].poc.ty1 = (OPJ_INT32)(tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy));
+										tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
+										incr_top=1;resetX=1;
+									}else{
+										incr_top=0;resetX=0;
+									}
+								}else{
+									pi[pino].poc.ty0 = (OPJ_INT32)tcp->ty0_t;
+									pi[pino].poc.ty1 = (OPJ_INT32)(tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy));
+									tcp->ty0_t = (OPJ_UINT32)pi[pino].poc.ty1;
+									incr_top=0;resetX=1;
+								}
+								if(resetX==1){
+									tcp->tx0_t = tcp->txS;
+									pi[pino].poc.tx0 = (OPJ_INT32)tcp->tx0_t;
+									pi[pino].poc.tx1 = (OPJ_INT32)(tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx));
+									tcp->tx0_t = (OPJ_UINT32)pi[pino].poc.tx1;
+								}
+							}else{
+								pi[pino].poc.tx0 = (OPJ_INT32)tcp->tx0_t;
+								pi[pino].poc.tx1 = (OPJ_INT32)(tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx));
+								tcp->tx0_t = (OPJ_UINT32)pi[pino].poc.tx1;
+								incr_top=0;
+							}
+							break;
+						}
+						break;
+					}
+				}
+			}
+		}
+	}
+}
+
+void opj_pi_destroy(opj_pi_iterator_t *p_pi,
+                    OPJ_UINT32 p_nb_elements)
+{
+	OPJ_UINT32 compno, pino;
+	opj_pi_iterator_t *l_current_pi = p_pi;
+    if (p_pi) {
+		if (p_pi->include) {
+			opj_free(p_pi->include);
+			p_pi->include = 00;
+		}
+		for (pino = 0; pino < p_nb_elements; ++pino){
+			if(l_current_pi->comps) {
+				opj_pi_comp_t *l_current_component = l_current_pi->comps;
+                for (compno = 0; compno < l_current_pi->numcomps; compno++){
+                    if(l_current_component->resolutions) {
+						opj_free(l_current_component->resolutions);
+						l_current_component->resolutions = 00;
+					}
+
+					++l_current_component;
+				}
+				opj_free(l_current_pi->comps);
+				l_current_pi->comps = 0;
+			}
+			++l_current_pi;
+		}
+		opj_free(p_pi);
+	}
+}
+
+
+
+void opj_pi_update_encoding_parameters(	const opj_image_t *p_image,
+                                        opj_cp_t *p_cp,
+                                        OPJ_UINT32 p_tile_no )
+{
+	/* encoding parameters to set */
+	OPJ_UINT32 l_max_res;
+	OPJ_UINT32 l_max_prec;
+	OPJ_INT32 l_tx0,l_tx1,l_ty0,l_ty1;
+	OPJ_UINT32 l_dx_min,l_dy_min;
+
+	/* pointers */
+	opj_tcp_t *l_tcp = 00;
+
+	/* preconditions */
+	assert(p_cp != 00);
+	assert(p_image != 00);
+	assert(p_tile_no < p_cp->tw * p_cp->th);
+
+	l_tcp = &(p_cp->tcps[p_tile_no]);
+
+	/* get encoding parameters */
+	opj_get_encoding_parameters(p_image,p_cp,p_tile_no,&l_tx0,&l_tx1,&l_ty0,&l_ty1,&l_dx_min,&l_dy_min,&l_max_prec,&l_max_res);
+
+	if (l_tcp->POC) {
+		opj_pi_update_encode_poc_and_final(p_cp,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
+	}
+	else {
+		opj_pi_update_encode_not_poc(p_cp,p_image->numcomps,p_tile_no,l_tx0,l_tx1,l_ty0,l_ty1,l_max_prec,l_max_res,l_dx_min,l_dy_min);
+	}
+}
+
+OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi) {
+	switch (pi->poc.prg) {
+		case OPJ_LRCP:
+			return opj_pi_next_lrcp(pi);
+		case OPJ_RLCP:
+			return opj_pi_next_rlcp(pi);
+		case OPJ_RPCL:
+			return opj_pi_next_rpcl(pi);
+		case OPJ_PCRL:
+			return opj_pi_next_pcrl(pi);
+		case OPJ_CPRL:
+			return opj_pi_next_cprl(pi);
+		case OPJ_PROG_UNKNOWN:
+			return OPJ_FALSE;
+	}
+	
+	return OPJ_FALSE;
+}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/pi.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/pi.h
similarity index 64%
rename from Utilities/gdcmopenjpeg-v2/libopenjpeg/pi.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/pi.h
index 0ddd0ba..265d5b1 100644
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/pi.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/pi.h
@@ -1,11 +1,16 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
- * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,16 +45,12 @@ The functions in PI.C have for goal to realize a packet iterator that permits to
 packet following the progression order and change of it. The functions in PI.C are used
 by some function in T2.C.
 */
-#include "openjpeg.h"
-#include "t2.h"
+
 /** @defgroup PI PI - Implementation of a packet iterator */
 /*@{*/
-struct opj_poc;
-struct opj_image;
-struct opj_cp;
 
 /**
-FIXME: documentation
+FIXME DOC
 */
 typedef struct opj_pi_resolution {
   OPJ_UINT32 pdx, pdy;
@@ -57,7 +58,7 @@ typedef struct opj_pi_resolution {
 } opj_pi_resolution_t;
 
 /**
-FIXME: documentation
+FIXME DOC
 */
 typedef struct opj_pi_comp {
   OPJ_UINT32 dx, dy;
@@ -72,7 +73,7 @@ Packet iterator
 typedef struct opj_pi_iterator {
   /** Enabling Tile part generation*/
   OPJ_BYTE tp_on;
-  /** precise if the packet has been already used (usefull for progression order change) */
+  /** precise if the packet has been already used (useful for progression order change) */
   OPJ_INT16 *include;
   /** layer step used to localize the packet in the include vector */
   OPJ_UINT32 step_l;
@@ -90,17 +91,20 @@ typedef struct opj_pi_iterator {
   OPJ_UINT32 precno;
   /** layer that identify the packet */
   OPJ_UINT32 layno;
+  /** 0 if the first packet */
+  OPJ_BOOL first;
   /** progression order change information */
-  struct opj_poc poc;
+  opj_poc_t poc;
   /** number of components in the image */
   OPJ_UINT32 numcomps;
   /** Components*/
   opj_pi_comp_t *comps;
+  /** FIXME DOC*/
   OPJ_INT32 tx0, ty0, tx1, ty1;
+  /** FIXME DOC*/
   OPJ_INT32 x, y;
+  /** FIXME DOC*/
   OPJ_UINT32 dx, dy;
-  /** 0 if the first packet */
-  OPJ_UINT32 first : 1;
 } opj_pi_iterator_t;
 
 /** @name Exported functions */
@@ -109,39 +113,46 @@ typedef struct opj_pi_iterator {
 /**
  * Creates a packet iterator for encoding.
  *
- * @param  p_image    the image being encoded.
- * @param  p_cp    the coding parameters.
- * @param  p_tile_no  index of the tile being encoded.
- * @param  p_t2_mode  the type of pass for generating the packet iterator
- * @return  a list of packet iterator that points to the first packet of the tile (not true).
+ * @param	image		the image being encoded.
+ * @param	cp		the coding parameters.
+ * @param	tileno	index of the tile being encoded.
+ * @param	t2_mode	the type of pass for generating the packet iterator
+ *
+ * @return	a list of packet iterator that points to the first packet of the tile (not true).
 */
-opj_pi_iterator_t *pi_initialise_encode(const struct opj_image *image,struct opj_cp *cp, OPJ_UINT32 tileno,J2K_T2_MODE t2_mode);
+opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *image,
+                                            opj_cp_t *cp,
+                                            OPJ_UINT32 tileno,
+                                            J2K_T2_MODE t2_mode);
 
 /**
  * Updates the encoding parameters of the codec.
  *
- * @param  p_image    the image being encoded.
- * @param  p_cp    the coding parameters.
- * @param  p_tile_no  index of the tile being encoded.
+ * @param	p_image		the image being encoded.
+ * @param	p_cp		the coding parameters.
+ * @param	p_tile_no	index of the tile being encoded.
 */
-void pi_update_encoding_parameters(
-                    const struct opj_image *p_image,
-                    struct opj_cp *p_cp,
-                    OPJ_UINT32 p_tile_no
-                    );
-
-
+void opj_pi_update_encoding_parameters(	const opj_image_t *p_image,
+                                        opj_cp_t *p_cp,
+                                        OPJ_UINT32 p_tile_no );
 
 /**
 Modify the packet iterator for enabling tile part generation
 @param pi Handle to the packet iterator generated in pi_initialise_encode
 @param cp Coding parameters
 @param tileno Number that identifies the tile for which to list the packets
+ at param pino   FIXME DOC
 @param tpnum Tile part number of the current tile
 @param tppos The position of the tile part flag in the progression order
+ at param t2_mode FIXME DOC
 */
-void pi_create_encode( opj_pi_iterator_t *pi, struct opj_cp *cp,OPJ_UINT32 tileno, OPJ_UINT32 pino,OPJ_UINT32 tpnum, OPJ_INT32 tppos, J2K_T2_MODE t2_mode);
-
+void opj_pi_create_encode(  opj_pi_iterator_t *pi, 
+                            opj_cp_t *cp,
+                            OPJ_UINT32 tileno, 
+                            OPJ_UINT32 pino,
+                            OPJ_UINT32 tpnum, 
+                            OPJ_INT32 tppos, 
+                            J2K_T2_MODE t2_mode);
 
 /**
 Create a packet iterator for Decoder
@@ -149,30 +160,26 @@ Create a packet iterator for Decoder
 @param cp Coding parameters
 @param tileno Number that identifies the tile for which to list the packets
 @return Returns a packet iterator that points to the first packet of the tile
- at see pi_destroy
+ at see opj_pi_destroy
 */
-opj_pi_iterator_t *pi_create_decode(struct opj_image * image, struct opj_cp * cp, OPJ_UINT32 tileno);
-
-
-
+opj_pi_iterator_t *opj_pi_create_decode(opj_image_t * image, 
+                                        opj_cp_t * cp,
+                                        OPJ_UINT32 tileno);
 /**
  * Destroys a packet iterator array.
  *
- * @param  p_pi      the packet iterator array to destroy.
- * @param  p_nb_elements  the number of elements in the array.
+ * @param	p_pi			the packet iterator array to destroy.
+ * @param	p_nb_elements	the number of elements in the array.
  */
-void pi_destroy(
-        opj_pi_iterator_t *p_pi,
-        OPJ_UINT32 p_nb_elements);
+void opj_pi_destroy(opj_pi_iterator_t *p_pi,
+                    OPJ_UINT32 p_nb_elements);
 
 /**
 Modify the packet iterator to point to the next packet
 @param pi Packet iterator to modify
 @return Returns false if pi pointed to the last packet or else returns true
 */
-bool pi_next(opj_pi_iterator_t * pi);
-
-
+OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/ppix_manager.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/ppix_manager.c
new file mode 100644
index 0000000..018a881
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/ppix_manager.c
@@ -0,0 +1,196 @@
+/*
+ * $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara at gmail.com $
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*! \file
+ *  \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+/* 
+ * Write faix box of ppix
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] compno    component number
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused   true if if EPH option used
+ * @param[in] j2klen    length of j2k codestream
+ * @param[in] cio       file output handle
+ * @return              length of faix box
+ */
+
+
+int opj_write_ppix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [4];
+  int compno, i;
+  opj_jp2_box_t *box;
+  OPJ_OFF_T lenp;
+  OPJ_UINT32 len;
+
+  /*  printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */
+
+  lenp = -1;
+  box = (opj_jp2_box_t *)opj_calloc( (size_t)cstr_info.numcomps, sizeof(opj_jp2_box_t));
+  if(box == NULL){
+	return 0;
+  }
+  for (i=0;i<2;i++){
+    if (i)
+
+      opj_stream_seek( cio, lenp, p_manager);
+    
+    lenp = (OPJ_UINT32)(opj_stream_tell(cio));
+    opj_stream_skip( cio, 4, p_manager);       /* L [at the end] */
+    opj_write_bytes(l_data_header,JPIP_PPIX,4);/* PPIX           */
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+    opj_write_manf( i, cstr_info.numcomps, box, cio, p_manager);
+    
+    for (compno=0; compno<cstr_info.numcomps; compno++){
+      box[compno].length = (OPJ_UINT32)opj_write_ppixfaix( coff, compno, cstr_info, EPHused, j2klen, cio,p_manager);
+      box[compno].type = JPIP_FAIX;
+    }
+   
+
+  len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+  opj_stream_seek(cio, lenp,p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L              */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+  }
+  
+  opj_free(box);
+
+  return (int)len;
+}
+
+
+
+int opj_write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [8];
+  OPJ_UINT32 tileno, version, i, nmax, size_of_coding; /* 4 or 8*/
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+  opj_tile_info_t *tile_Idx;
+  opj_packet_info_t packet;
+  int resno, precno, layno;
+  OPJ_UINT32 num_packet;
+  int numOfres, numOfprec, numOflayers;
+  packet.end_pos = packet.end_ph_pos = packet.start_pos = -1;
+  (void)EPHused; /* unused ? */
+
+  if( j2klen > pow( 2, 32)){
+    size_of_coding =  8;
+    version = 1;
+  }
+  else{
+    size_of_coding = 4;
+    version = 0;
+  }
+  
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip(cio, 4, p_manager);         /* L [at the end]      */
+  opj_write_bytes(l_data_header,JPIP_FAIX,4); /* FAIX */
+  opj_write_bytes(l_data_header,version,1);
+  opj_stream_write_data(cio,l_data_header,1,p_manager);/* Version 0 = 4 bytes */
+
+  nmax = 0;
+  for( i=0; i<=(OPJ_UINT32)cstr_info.numdecompos[compno]; i++)
+    nmax += (OPJ_UINT32)(cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers);
+  
+  opj_write_bytes(l_data_header,nmax,size_of_coding);         /* NMAX           */
+  opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+  opj_write_bytes(l_data_header,(OPJ_UINT32)(cstr_info.tw*cstr_info.th),size_of_coding);  /* M              */
+  opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+
+  for( tileno=0; tileno<(OPJ_UINT32)(cstr_info.tw*cstr_info.th); tileno++){
+    tile_Idx = &cstr_info.tile[ tileno];
+ 
+    num_packet=0;
+    numOfres = cstr_info.numdecompos[compno] + 1;
+  
+    for( resno=0; resno<numOfres ; resno++){
+      numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
+      for( precno=0; precno<numOfprec; precno++){
+	numOflayers = cstr_info.numlayers;
+	for( layno=0; layno<numOflayers; layno++){
+
+	  switch ( cstr_info.prog){
+	  case OPJ_LRCP:
+	    packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
+	    break;
+	  case OPJ_RLCP:
+	    packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
+	    break;
+	  case OPJ_RPCL:
+	    packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
+	    break;
+	  case OPJ_PCRL:
+	    packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
+	    break;
+	  case OPJ_CPRL:
+	    packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
+	    break;
+	  default:
+	    fprintf( stderr, "failed to ppix indexing\n");
+	  }
+
+    opj_write_bytes(l_data_header,(OPJ_UINT32)(packet.start_pos-coff),size_of_coding);            /* start position */
+    opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+    opj_write_bytes(l_data_header,(OPJ_UINT32)(packet.end_pos-packet.start_pos+1),size_of_coding); /* length         */
+    opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+	  
+	  num_packet++;
+	}
+      }
+    }
+  
+    while( num_packet < nmax){     /* PADDING */
+      opj_write_bytes(l_data_header,0,size_of_coding);/* start position            */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+      opj_write_bytes(l_data_header,0,size_of_coding);/* length                    */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+      num_packet++;
+    }   
+  }
+
+  len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+  opj_stream_seek(cio, lenp,p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L  */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+
+  return (int)len;
+}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/raw.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/raw.c
similarity index 69%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/raw.c
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/raw.c
index 3d231bf..d3581d1 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/raw.c
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/raw.c
@@ -1,7 +1,13 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
@@ -42,22 +48,24 @@
 ==========================================================
 */
 
-opj_raw_t* raw_create(void) {
+opj_raw_t* opj_raw_create(void) {
 	opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
 	return raw;
 }
 
-void raw_destroy(opj_raw_t *raw) {
+void opj_raw_destroy(opj_raw_t *raw) {
 	if(raw) {
 		opj_free(raw);
 	}
 }
 
-int raw_numbytes(opj_raw_t *raw) {
-	return raw->bp - raw->start;
+OPJ_UINT32 opj_raw_numbytes(opj_raw_t *raw) {
+	const ptrdiff_t diff = raw->bp - raw->start;
+  assert( diff <= (ptrdiff_t)0xffffffff && diff >= 0 ); /* UINT32_MAX */
+	return (OPJ_UINT32)diff;
 }
 
-void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) {
+void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len) {
 	raw->start = bp;
 	raw->lenmax = len;
 	raw->len = 0;
@@ -65,8 +73,8 @@ void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) {
 	raw->ct = 0;
 }
 
-int raw_decode(opj_raw_t *raw) {
-	int d;
+OPJ_UINT32 opj_raw_decode(opj_raw_t *raw) {
+	OPJ_UINT32 d;
 	if (raw->ct == 0) {
 		raw->ct = 8;
 		if (raw->len == raw->lenmax) {
@@ -80,7 +88,7 @@ int raw_decode(opj_raw_t *raw) {
 		}
 	}
 	raw->ct--;
-	d = (raw->c >> raw->ct) & 0x01;
+	d = ((OPJ_UINT32)raw->c >> raw->ct) & 0x01U;
 	
 	return d;
 }
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/raw.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/raw.h
similarity index 77%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/raw.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/raw.h
index 3c4b372..572c666 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/raw.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/raw.h
@@ -1,7 +1,13 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
@@ -45,19 +51,19 @@ RAW encoding operations
 */
 typedef struct opj_raw {
 	/** temporary buffer where bits are coded or decoded */
-	unsigned char c;
+	OPJ_BYTE c;
 	/** number of bits already read or free to write */
-	unsigned int ct;
+	OPJ_UINT32 ct;
 	/** maximum length to decode */
-	unsigned int lenmax;
+	OPJ_UINT32 lenmax;
 	/** length decoded */
-	unsigned int len;
+	OPJ_UINT32 len;
 	/** pointer to the current position in the buffer */
-	unsigned char *bp;
+	OPJ_BYTE *bp;
 	/** pointer to the start of the buffer */
-	unsigned char *start;
+	OPJ_BYTE *start;
 	/** pointer to the end of the buffer */
-	unsigned char *end;
+	OPJ_BYTE *end;
 } opj_raw_t;
 
 /** @name Exported functions */
@@ -67,31 +73,31 @@ typedef struct opj_raw {
 Create a new RAW handle 
 @return Returns a new RAW handle if successful, returns NULL otherwise
 */
-opj_raw_t* raw_create(void);
+opj_raw_t* opj_raw_create(void);
 /**
 Destroy a previously created RAW handle
 @param raw RAW handle to destroy
 */
-void raw_destroy(opj_raw_t *raw);
+void opj_raw_destroy(opj_raw_t *raw);
 /**
 Return the number of bytes written/read since initialisation
 @param raw RAW handle to destroy
 @return Returns the number of bytes already encoded
 */
-int raw_numbytes(opj_raw_t *raw);
+OPJ_UINT32 opj_raw_numbytes(opj_raw_t *raw);
 /**
 Initialize the decoder
 @param raw RAW handle
 @param bp Pointer to the start of the buffer from which the bytes will be read
 @param len Length of the input buffer
 */
-void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len);
+void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len);
 /**
 Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
 @param raw RAW handle
 @return Returns the decoded symbol (0 or 1)
 */
-int raw_decode(opj_raw_t *raw);
+OPJ_UINT32 opj_raw_decode(opj_raw_t *raw);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/t1.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1.c
new file mode 100644
index 0000000..1bf7205
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1.c
@@ -0,0 +1,1767 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+#include "t1_luts.h"
+
+/** @defgroup T1 T1 - Implementation of the tier-1 coding */
+/*@{*/
+
+/** @name Local static functions */
+/*@{*/
+
+static INLINE OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient);
+static OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f);
+static INLINE OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f);
+static OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f);
+static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos);
+static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos);
+static void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride);
+/**
+Encode significant pass
+*/
+static void opj_t1_enc_sigpass_step(opj_t1_t *t1,
+                                    opj_flag_t *flagsp,
+                                    OPJ_INT32 *datap,
+                                    OPJ_UINT32 orient,
+                                    OPJ_INT32 bpno,
+                                    OPJ_INT32 one,
+                                    OPJ_INT32 *nmsedec,
+                                    OPJ_BYTE type,
+                                    OPJ_UINT32 vsc);
+
+/**
+Decode significant pass
+*/
+#if 0
+static void opj_t1_dec_sigpass_step(opj_t1_t *t1,
+                                    opj_flag_t *flagsp,
+                                    OPJ_INT32 *datap,
+                                    OPJ_UINT32 orient,
+                                    OPJ_INT32 oneplushalf,
+                                    OPJ_BYTE type,
+                                    OPJ_UINT32 vsc);
+#endif
+
+static INLINE void opj_t1_dec_sigpass_step_raw(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 orient,
+                OPJ_INT32 oneplushalf,
+                OPJ_INT32 vsc);
+static INLINE void opj_t1_dec_sigpass_step_mqc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 orient,
+                OPJ_INT32 oneplushalf);
+static INLINE void opj_t1_dec_sigpass_step_mqc_vsc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 orient,
+                OPJ_INT32 oneplushalf,
+                OPJ_INT32 vsc);
+
+
+/**
+Encode significant pass
+*/
+static void opj_t1_enc_sigpass( opj_t1_t *t1,
+                                OPJ_INT32 bpno,
+                                OPJ_UINT32 orient,
+                                OPJ_INT32 *nmsedec,
+                                OPJ_BYTE type,
+                                OPJ_UINT32 cblksty);
+
+/**
+Decode significant pass
+*/
+static void opj_t1_dec_sigpass_raw(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 orient,
+                OPJ_INT32 cblksty);
+static void opj_t1_dec_sigpass_mqc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 orient);
+static void opj_t1_dec_sigpass_mqc_vsc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 orient);
+
+
+
+/**
+Encode refinement pass
+*/
+static void opj_t1_enc_refpass_step(opj_t1_t *t1,
+                                    opj_flag_t *flagsp,
+                                    OPJ_INT32 *datap,
+                                    OPJ_INT32 bpno,
+                                    OPJ_INT32 one,
+                                    OPJ_INT32 *nmsedec,
+                                    OPJ_BYTE type,
+                                    OPJ_UINT32 vsc);
+
+
+/**
+Encode refinement pass
+*/
+static void opj_t1_enc_refpass( opj_t1_t *t1,
+                                OPJ_INT32 bpno,
+                                OPJ_INT32 *nmsedec,
+                                OPJ_BYTE type,
+                                OPJ_UINT32 cblksty);
+
+/**
+Decode refinement pass
+*/
+static void opj_t1_dec_refpass_raw(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 cblksty);
+static void opj_t1_dec_refpass_mqc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno);
+static void opj_t1_dec_refpass_mqc_vsc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno);
+
+
+/**
+Decode refinement pass
+*/
+#if 0
+static void opj_t1_dec_refpass_step(opj_t1_t *t1,
+                                    opj_flag_t *flagsp,
+                                    OPJ_INT32 *datap,
+                                    OPJ_INT32 poshalf,
+                                    OPJ_INT32 neghalf,
+                                    OPJ_BYTE type,
+                                    OPJ_UINT32 vsc);
+#endif
+
+static INLINE void  opj_t1_dec_refpass_step_raw(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 poshalf,
+                OPJ_INT32 neghalf,
+                OPJ_INT32 vsc);
+static INLINE void opj_t1_dec_refpass_step_mqc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 poshalf,
+                OPJ_INT32 neghalf);
+static INLINE void opj_t1_dec_refpass_step_mqc_vsc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 poshalf,
+                OPJ_INT32 neghalf,
+                OPJ_INT32 vsc);
+
+
+
+/**
+Encode clean-up pass
+*/
+static void opj_t1_enc_clnpass_step(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_UINT32 orient,
+		OPJ_INT32 bpno,
+		OPJ_INT32 one,
+		OPJ_INT32 *nmsedec,
+		OPJ_UINT32 partial,
+		OPJ_UINT32 vsc);
+/**
+Decode clean-up pass
+*/
+static void opj_t1_dec_clnpass_step_partial(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_INT32 orient,
+		OPJ_INT32 oneplushalf);
+static void opj_t1_dec_clnpass_step(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_INT32 orient,
+		OPJ_INT32 oneplushalf);
+static void opj_t1_dec_clnpass_step_vsc(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_INT32 orient,
+		OPJ_INT32 oneplushalf,
+		OPJ_INT32 partial,
+		OPJ_INT32 vsc);
+/**
+Encode clean-up pass
+*/
+static void opj_t1_enc_clnpass(
+		opj_t1_t *t1,
+		OPJ_INT32 bpno,
+		OPJ_UINT32 orient,
+		OPJ_INT32 *nmsedec,
+		OPJ_UINT32 cblksty);
+/**
+Decode clean-up pass
+*/
+static void opj_t1_dec_clnpass(
+		opj_t1_t *t1,
+		OPJ_INT32 bpno,
+		OPJ_INT32 orient,
+		OPJ_INT32 cblksty);
+
+static OPJ_FLOAT64 opj_t1_getwmsedec(
+		OPJ_INT32 nmsedec,
+		OPJ_UINT32 compno,
+		OPJ_UINT32 level,
+		OPJ_UINT32 orient,
+		OPJ_INT32 bpno,
+		OPJ_UINT32 qmfbid,
+		OPJ_FLOAT64 stepsize,
+		OPJ_UINT32 numcomps,
+		const OPJ_FLOAT64 * mct_norms,
+		OPJ_UINT32 mct_numcomps);
+
+static void opj_t1_encode_cblk( opj_t1_t *t1,
+                                opj_tcd_cblk_enc_t* cblk,
+                                OPJ_UINT32 orient,
+                                OPJ_UINT32 compno,
+                                OPJ_UINT32 level,
+                                OPJ_UINT32 qmfbid,
+                                OPJ_FLOAT64 stepsize,
+                                OPJ_UINT32 cblksty,
+                                OPJ_UINT32 numcomps,
+                                opj_tcd_tile_t * tile,
+                                const OPJ_FLOAT64 * mct_norms,
+                                OPJ_UINT32 mct_numcomps);
+
+/**
+Decode 1 code-block
+ at param t1 T1 handle
+ at param cblk Code-block coding parameters
+ at param orient
+ at param roishift Region of interest shifting value
+ at param cblksty Code-block style
+*/
+static OPJ_BOOL opj_t1_decode_cblk( opj_t1_t *t1,
+                                    opj_tcd_cblk_dec_t* cblk,
+                                    OPJ_UINT32 orient,
+                                    OPJ_UINT32 roishift,
+                                    OPJ_UINT32 cblksty);
+
+static OPJ_BOOL opj_t1_allocate_buffers(   opj_t1_t *t1,
+                                    OPJ_UINT32 w,
+                                    OPJ_UINT32 h);
+
+/*@}*/
+
+/*@}*/
+
+/* ----------------------------------------------------------------------- */
+
+static OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient) {
+	return lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)];
+}
+
+static OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f) {
+	return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
+}
+
+static OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f) {
+	OPJ_UINT32 tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG;
+	OPJ_UINT32 tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1;
+	return (tmp2);
+}
+
+static OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f) {
+	return lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
+}
+
+static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
+	if (bitpos > 0) {
+		return lut_nmsedec_sig[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS) - 1)];
+	}
+	
+	return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
+}
+
+static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
+	if (bitpos > 0) {
+		return lut_nmsedec_ref[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS) - 1)];
+	}
+
+    return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
+}
+
+static void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride) {
+	opj_flag_t *np = flagsp - stride;
+	opj_flag_t *sp = flagsp + stride;
+
+	static const opj_flag_t mod[] = {
+		T1_SIG_S, T1_SIG_S|T1_SGN_S,
+		T1_SIG_E, T1_SIG_E|T1_SGN_E,
+		T1_SIG_W, T1_SIG_W|T1_SGN_W,
+		T1_SIG_N, T1_SIG_N|T1_SGN_N
+	};
+
+	np[-1] |= T1_SIG_SE;
+	np[0]  |= mod[s];
+	np[1]  |= T1_SIG_SW;
+
+	flagsp[-1] |= mod[s+2];
+	flagsp[0]  |= T1_SIG;
+	flagsp[1]  |= mod[s+4];
+
+	sp[-1] |= T1_SIG_NE;
+	sp[0]  |= mod[s+6];
+	sp[1]  |= T1_SIG_NW;
+}
+
+static void opj_t1_enc_sigpass_step(   opj_t1_t *t1,
+                                opj_flag_t *flagsp,
+                                OPJ_INT32 *datap,
+                                OPJ_UINT32 orient,
+                                OPJ_INT32 bpno,
+                                OPJ_INT32 one,
+                                OPJ_INT32 *nmsedec,
+                                OPJ_BYTE type,
+                                OPJ_UINT32 vsc
+                                )
+{
+	OPJ_INT32 v;
+    OPJ_UINT32 flag;
+	
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (OPJ_UINT32)(*flagsp);
+	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
+		v = (opj_int_abs(*datap) & one) ? 1 : 0;
+		opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));	/* ESSAI */
+		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
+			opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v);
+		} else {
+			opj_mqc_encode(mqc, (OPJ_UINT32)v);
+		}
+		if (v) {
+			v = *datap < 0 ? 1 : 0;
+			*nmsedec +=	opj_t1_getnmsedec_sig((OPJ_UINT32)opj_int_abs(*datap), (OPJ_UINT32)(bpno));
+			opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));	/* ESSAI */
+			if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
+				opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v);
+			} else {
+				opj_mqc_encode(mqc, (OPJ_UINT32)(v ^ opj_t1_getspb((OPJ_UINT32)flag)));
+			}
+			opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+		}
+		*flagsp |= T1_VISIT;
+	}
+}
+
+
+static INLINE void opj_t1_dec_sigpass_step_raw(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 orient,
+                OPJ_INT32 oneplushalf,
+                OPJ_INT32 vsc)
+{
+        OPJ_INT32 v, flag;
+        opj_raw_t *raw = t1->raw;       /* RAW component */
+        OPJ_ARG_NOT_USED(orient);
+       
+        flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+        if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
+                        if (opj_raw_decode(raw)) {
+                                v = (OPJ_INT32)opj_raw_decode(raw);    /* ESSAI */
+                                *datap = v ? -oneplushalf : oneplushalf;
+                                opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+                        }
+                *flagsp |= T1_VISIT;
+        }
+}      
+
+static INLINE void opj_t1_dec_sigpass_step_mqc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 orient,
+                OPJ_INT32 oneplushalf)
+{
+        OPJ_INT32 v, flag;
+       
+        opj_mqc_t *mqc = t1->mqc;       /* MQC component */
+       
+        flag = *flagsp;
+        if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
+                        opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)flag, (OPJ_UINT32)orient));
+                        if (opj_mqc_decode(mqc)) {
+                                opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)flag));
+                                v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag);
+                                *datap = v ? -oneplushalf : oneplushalf;
+                                opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+                        }
+                *flagsp |= T1_VISIT;
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+static INLINE void opj_t1_dec_sigpass_step_mqc_vsc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 orient,
+                OPJ_INT32 oneplushalf,
+                OPJ_INT32 vsc)
+{
+        OPJ_INT32 v, flag;
+       
+        opj_mqc_t *mqc = t1->mqc;       /* MQC component */
+       
+        flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+        if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
+                opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)flag, (OPJ_UINT32)orient));
+                if (opj_mqc_decode(mqc)) {
+                        opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)flag));
+                        v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag);
+                        *datap = v ? -oneplushalf : oneplushalf;
+                        opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+                }
+                *flagsp |= T1_VISIT;
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+
+
+static void opj_t1_enc_sigpass(opj_t1_t *t1,
+                        OPJ_INT32 bpno,
+                        OPJ_UINT32 orient,
+                        OPJ_INT32 *nmsedec,
+                        OPJ_BYTE type,
+                        OPJ_UINT32 cblksty
+                        )
+{
+	OPJ_UINT32 i, j, k, vsc; 
+    OPJ_INT32 one;
+
+	*nmsedec = 0;
+	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
+	for (k = 0; k < t1->h; k += 4) {
+		for (i = 0; i < t1->w; ++i) {
+			for (j = k; j < k + 4 && j < t1->h; ++j) {
+				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+				opj_t1_enc_sigpass_step(
+						t1,
+						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
+						&t1->data[(j * t1->data_stride) + i],
+						orient,
+						bpno,
+						one,
+						nmsedec,
+						type,
+						vsc);
+			}
+		}
+	}
+}
+
+static void opj_t1_dec_sigpass_raw(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 orient,
+                OPJ_INT32 cblksty)
+{
+        OPJ_INT32 one, half, oneplushalf, vsc;
+        OPJ_UINT32 i, j, k; 
+        one = 1 << bpno;
+        half = one >> 1;
+        oneplushalf = one | half;
+        for (k = 0; k < t1->h; k += 4) {
+                for (i = 0; i < t1->w; ++i) {
+                        for (j = k; j < k + 4 && j < t1->h; ++j) {
+                                vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+                                opj_t1_dec_sigpass_step_raw(
+                                                t1,
+                                                &t1->flags[((j+1) * t1->flags_stride) + i + 1],
+                                                &t1->data[(j * t1->w) + i],
+                                                orient,
+                                                oneplushalf,
+                                                vsc);
+                        }
+                }
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+static void opj_t1_dec_sigpass_mqc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 orient)
+{
+        OPJ_INT32 one, half, oneplushalf;
+        OPJ_UINT32 i, j, k;
+        OPJ_INT32 *data1 = t1->data;
+        opj_flag_t *flags1 = &t1->flags[1];
+        one = 1 << bpno;
+        half = one >> 1;
+        oneplushalf = one | half;
+        for (k = 0; k < (t1->h & ~3u); k += 4) {
+                for (i = 0; i < t1->w; ++i) {
+                        OPJ_INT32 *data2 = data1 + i;
+                        opj_flag_t *flags2 = flags1 + i;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
+                        data2 += t1->w;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
+                        data2 += t1->w;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
+                        data2 += t1->w;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
+                        data2 += t1->w;
+                }
+                data1 += t1->w << 2;
+                flags1 += t1->flags_stride << 2;
+        }
+        for (i = 0; i < t1->w; ++i) {
+                OPJ_INT32 *data2 = data1 + i;
+                opj_flag_t *flags2 = flags1 + i;
+                for (j = k; j < t1->h; ++j) {
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
+                        data2 += t1->w;
+                }
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+static void opj_t1_dec_sigpass_mqc_vsc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 orient)
+{
+        OPJ_INT32 one, half, oneplushalf, vsc;
+        OPJ_UINT32 i, j, k;
+        one = 1 << bpno;
+        half = one >> 1;
+        oneplushalf = one | half;
+        for (k = 0; k < t1->h; k += 4) {
+                for (i = 0; i < t1->w; ++i) {
+                        for (j = k; j < k + 4 && j < t1->h; ++j) {
+                                vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0;
+                                opj_t1_dec_sigpass_step_mqc_vsc(
+                                                t1,
+                                                &t1->flags[((j+1) * t1->flags_stride) + i + 1],
+                                                &t1->data[(j * t1->w) + i],
+                                                orient,
+                                                oneplushalf,
+                                                vsc);
+                        }
+                }
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+
+
+static void opj_t1_enc_refpass_step(   opj_t1_t *t1,
+                                opj_flag_t *flagsp,
+                                OPJ_INT32 *datap,
+                                OPJ_INT32 bpno,
+                                OPJ_INT32 one,
+                                OPJ_INT32 *nmsedec,
+                                OPJ_BYTE type,
+                                OPJ_UINT32 vsc)
+{
+	OPJ_INT32 v;
+	OPJ_UINT32 flag;
+	
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (OPJ_UINT32)(*flagsp);
+	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
+		*nmsedec += opj_t1_getnmsedec_ref((OPJ_UINT32)opj_int_abs(*datap), (OPJ_UINT32)(bpno));
+		v = (opj_int_abs(*datap) & one) ? 1 : 0;
+		opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag));	/* ESSAI */
+		if (type == T1_TYPE_RAW) {	/* BYPASS/LAZY MODE */
+			opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v);
+		} else {
+			opj_mqc_encode(mqc, (OPJ_UINT32)v);
+		}
+		*flagsp |= T1_REFINE;
+	}
+}
+
+static INLINE void opj_t1_dec_refpass_step_raw(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 poshalf,
+                OPJ_INT32 neghalf,
+                OPJ_INT32 vsc)
+{
+        OPJ_INT32 v, t, flag;
+       
+        opj_raw_t *raw = t1->raw;       /* RAW component */
+       
+        flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+        if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
+                        v = (OPJ_INT32)opj_raw_decode(raw);
+                t = v ? poshalf : neghalf;
+                *datap += *datap < 0 ? -t : t;
+                *flagsp |= T1_REFINE;
+        }
+}                               /* VSC and  BYPASS by Antonin  */
+
+static INLINE void opj_t1_dec_refpass_step_mqc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 poshalf,
+                OPJ_INT32 neghalf)
+{
+        OPJ_INT32 v, t, flag;
+       
+        opj_mqc_t *mqc = t1->mqc;       /* MQC component */
+       
+        flag = *flagsp;
+        if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
+                opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag((OPJ_UINT32)flag));      /* ESSAI */
+                        v = opj_mqc_decode(mqc);
+                t = v ? poshalf : neghalf;
+                *datap += *datap < 0 ? -t : t;
+                *flagsp |= T1_REFINE;
+                }
+}                               /* VSC and  BYPASS by Antonin  */
+
+static INLINE void opj_t1_dec_refpass_step_mqc_vsc(
+                opj_t1_t *t1,
+                opj_flag_t *flagsp,
+                OPJ_INT32 *datap,
+                OPJ_INT32 poshalf,
+                OPJ_INT32 neghalf,
+                OPJ_INT32 vsc)
+{
+        OPJ_INT32 v, t, flag;
+       
+        opj_mqc_t *mqc = t1->mqc;       /* MQC component */
+       
+        flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+        if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
+                opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag((OPJ_UINT32)flag));      /* ESSAI */
+                v = opj_mqc_decode(mqc);
+                t = v ? poshalf : neghalf;
+                *datap += *datap < 0 ? -t : t;
+                *flagsp |= T1_REFINE;
+        }
+}                               /* VSC and  BYPASS by Antonin  */
+
+
+static void opj_t1_enc_refpass(
+		opj_t1_t *t1,
+		OPJ_INT32 bpno,
+		OPJ_INT32 *nmsedec,
+		OPJ_BYTE type,
+		OPJ_UINT32 cblksty)
+{
+	OPJ_UINT32 i, j, k, vsc;
+    OPJ_INT32 one;
+
+	*nmsedec = 0;
+	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
+	for (k = 0; k < t1->h; k += 4) {
+		for (i = 0; i < t1->w; ++i) {
+			for (j = k; j < k + 4 && j < t1->h; ++j) {
+				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+				opj_t1_enc_refpass_step(
+						t1,
+						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
+						&t1->data[(j * t1->data_stride) + i],
+						bpno,
+						one,
+						nmsedec,
+						type,
+						vsc);
+			}
+		}
+	}
+}
+
+static void opj_t1_dec_refpass_raw(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno,
+                OPJ_INT32 cblksty)
+{
+        OPJ_INT32 one, poshalf, neghalf;
+        OPJ_UINT32 i, j, k;
+        OPJ_INT32 vsc;
+        one = 1 << bpno;
+        poshalf = one >> 1;
+        neghalf = bpno > 0 ? -poshalf : -1;
+        for (k = 0; k < t1->h; k += 4) {
+                for (i = 0; i < t1->w; ++i) {
+                        for (j = k; j < k + 4 && j < t1->h; ++j) {
+                                vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+                                opj_t1_dec_refpass_step_raw(
+                                                t1,
+                                                &t1->flags[((j+1) * t1->flags_stride) + i + 1],
+                                                &t1->data[(j * t1->w) + i],
+                                                poshalf,
+                                                neghalf,
+                                                vsc);
+                        }
+                }
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+static void opj_t1_dec_refpass_mqc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno)
+{
+        OPJ_INT32 one, poshalf, neghalf;
+        OPJ_UINT32 i, j, k;
+        OPJ_INT32 *data1 = t1->data;
+        opj_flag_t *flags1 = &t1->flags[1];
+        one = 1 << bpno;
+        poshalf = one >> 1;
+        neghalf = bpno > 0 ? -poshalf : -1;
+        for (k = 0; k < (t1->h & ~3u); k += 4) {
+                for (i = 0; i < t1->w; ++i) {
+                        OPJ_INT32 *data2 = data1 + i;
+                        opj_flag_t *flags2 = flags1 + i;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
+                        data2 += t1->w;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
+                        data2 += t1->w;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
+                        data2 += t1->w;
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
+                        data2 += t1->w;
+                }
+                data1 += t1->w << 2;
+                flags1 += t1->flags_stride << 2;
+        }
+        for (i = 0; i < t1->w; ++i) {
+                OPJ_INT32 *data2 = data1 + i;
+                opj_flag_t *flags2 = flags1 + i;
+                for (j = k; j < t1->h; ++j) {
+                        flags2 += t1->flags_stride;
+                        opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
+                        data2 += t1->w;
+                }
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+static void opj_t1_dec_refpass_mqc_vsc(
+                opj_t1_t *t1,
+                OPJ_INT32 bpno)
+{
+        OPJ_INT32 one, poshalf, neghalf;
+        OPJ_UINT32 i, j, k;
+        OPJ_INT32 vsc;
+        one = 1 << bpno;
+        poshalf = one >> 1;
+        neghalf = bpno > 0 ? -poshalf : -1;
+        for (k = 0; k < t1->h; k += 4) {
+                for (i = 0; i < t1->w; ++i) {
+                        for (j = k; j < k + 4 && j < t1->h; ++j) {
+                                vsc = ((j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+                                opj_t1_dec_refpass_step_mqc_vsc(
+                                                t1,
+                                                &t1->flags[((j+1) * t1->flags_stride) + i + 1],
+                                                &t1->data[(j * t1->w) + i],
+                                                poshalf,
+                                                neghalf,
+                                                vsc);
+                        }
+                }
+        }
+}                               /* VSC and  BYPASS by Antonin */
+
+
+static void opj_t1_enc_clnpass_step(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_UINT32 orient,
+		OPJ_INT32 bpno,
+		OPJ_INT32 one,
+		OPJ_INT32 *nmsedec,
+		OPJ_UINT32 partial,
+		OPJ_UINT32 vsc)
+{
+	OPJ_INT32 v;
+	OPJ_UINT32 flag;
+	
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (OPJ_UINT32)(*flagsp);
+	if (partial) {
+		goto LABEL_PARTIAL;
+	}
+	if (!(*flagsp & (T1_SIG | T1_VISIT))) {
+		opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
+		v = (opj_int_abs(*datap) & one) ? 1 : 0;
+		opj_mqc_encode(mqc, (OPJ_UINT32)v);
+		if (v) {
+LABEL_PARTIAL:
+			*nmsedec += opj_t1_getnmsedec_sig((OPJ_UINT32)opj_int_abs(*datap), (OPJ_UINT32)(bpno));
+			opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
+			v = *datap < 0 ? 1 : 0;
+			opj_mqc_encode(mqc, (OPJ_UINT32)(v ^ opj_t1_getspb((OPJ_UINT32)flag)));
+			opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+		}
+	}
+	*flagsp &= ~T1_VISIT;
+}
+
+static void opj_t1_dec_clnpass_step_partial(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_INT32 orient,
+		OPJ_INT32 oneplushalf)
+{
+	OPJ_INT32 v, flag;
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	OPJ_ARG_NOT_USED(orient);
+	
+	flag = *flagsp;
+	opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)flag));
+	v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag);
+	*datap = v ? -oneplushalf : oneplushalf;
+	opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+	*flagsp &= ~T1_VISIT;
+}				/* VSC and  BYPASS by Antonin */
+
+static void opj_t1_dec_clnpass_step(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_INT32 orient,
+		OPJ_INT32 oneplushalf)
+{
+	OPJ_INT32 v, flag;
+	
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	flag = *flagsp;
+	if (!(flag & (T1_SIG | T1_VISIT))) {
+		opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)flag, (OPJ_UINT32)orient));
+		if (opj_mqc_decode(mqc)) {
+			opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)flag));
+			v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag);
+			*datap = v ? -oneplushalf : oneplushalf;
+			opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+		}
+	}
+	*flagsp &= ~T1_VISIT;
+}				/* VSC and  BYPASS by Antonin */
+
+static void opj_t1_dec_clnpass_step_vsc(
+		opj_t1_t *t1,
+		opj_flag_t *flagsp,
+		OPJ_INT32 *datap,
+		OPJ_INT32 orient,
+		OPJ_INT32 oneplushalf,
+		OPJ_INT32 partial,
+		OPJ_INT32 vsc)
+{
+	OPJ_INT32 v, flag;
+	
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+	if (partial) {
+		goto LABEL_PARTIAL;
+	}
+	if (!(flag & (T1_SIG | T1_VISIT))) {
+		opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)flag, (OPJ_UINT32)orient));
+		if (opj_mqc_decode(mqc)) {
+LABEL_PARTIAL:
+			opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)flag));
+			v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag);
+			*datap = v ? -oneplushalf : oneplushalf;
+			opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stride);
+		}
+	}
+	*flagsp &= ~T1_VISIT;
+}
+
+static void opj_t1_enc_clnpass(
+		opj_t1_t *t1,
+		OPJ_INT32 bpno,
+		OPJ_UINT32 orient,
+		OPJ_INT32 *nmsedec,
+		OPJ_UINT32 cblksty)
+{
+	OPJ_UINT32 i, j, k;
+	OPJ_INT32 one;
+	OPJ_UINT32 agg, runlen, vsc;
+	
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	*nmsedec = 0;
+	one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
+	for (k = 0; k < t1->h; k += 4) {
+		for (i = 0; i < t1->w; ++i) {
+			if (k + 3 < t1->h) {
+				if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+					agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+						|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+						|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+						|| (MACRO_t1_flags(1 + k + 3,1 + i) 
+						& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |	T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+				} else {
+					agg = !((MACRO_t1_flags(1 + k,1 + i) | 
+						    MACRO_t1_flags(1 + k + 1,1 + i) |
+						    MACRO_t1_flags(1 + k + 2,1 + i) | 
+						     MACRO_t1_flags(1 + k + 3,1 + i)) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+				}
+			} else {
+				agg = 0;
+			}
+			if (agg) {
+				for (runlen = 0; runlen < 4; ++runlen) {
+					if (opj_int_abs(t1->data[((k + runlen)*t1->data_stride) + i]) & one)
+						break;
+				}
+				opj_mqc_setcurctx(mqc, T1_CTXNO_AGG);
+				opj_mqc_encode(mqc, runlen != 4);
+				if (runlen == 4) {
+					continue;
+				}
+				opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
+				opj_mqc_encode(mqc, runlen >> 1);
+				opj_mqc_encode(mqc, runlen & 1);
+			} else {
+				runlen = 0;
+			}
+			for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
+				vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
+				opj_t1_enc_clnpass_step(
+						t1,
+						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
+						&t1->data[(j * t1->data_stride) + i],
+						orient,
+						bpno,
+						one,
+						nmsedec,
+						agg && (j == k + runlen),
+						vsc);
+			}
+		}
+	}
+}
+
+static void opj_t1_dec_clnpass(
+		opj_t1_t *t1,
+		OPJ_INT32 bpno,
+		OPJ_INT32 orient,
+		OPJ_INT32 cblksty)
+{
+	OPJ_INT32 one, half, oneplushalf, agg, runlen, vsc;
+    OPJ_UINT32 i, j, k;
+	OPJ_INT32 segsym = cblksty & J2K_CCP_CBLKSTY_SEGSYM;
+	
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	
+	one = 1 << bpno;
+	half = one >> 1;
+	oneplushalf = one | half;
+	if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+	for (k = 0; k < t1->h; k += 4) {
+		for (i = 0; i < t1->w; ++i) {
+			if (k + 3 < t1->h) {
+					agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+						|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+						|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
+						|| (MACRO_t1_flags(1 + k + 3,1 + i) 
+						& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW |	T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+				} else {
+				agg = 0;
+			}
+			if (agg) {
+				opj_mqc_setcurctx(mqc, T1_CTXNO_AGG);
+				if (!opj_mqc_decode(mqc)) {
+					continue;
+				}
+				opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
+				runlen = opj_mqc_decode(mqc);
+				runlen = (runlen << 1) | opj_mqc_decode(mqc);
+			} else {
+				runlen = 0;
+			}
+			for (j = k + (OPJ_UINT32)runlen; j < k + 4 && j < t1->h; ++j) {
+					vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0;
+					opj_t1_dec_clnpass_step_vsc(
+						t1,
+						&t1->flags[((j+1) * t1->flags_stride) + i + 1],
+						&t1->data[(j * t1->w) + i],
+						orient,
+						oneplushalf,
+						agg && (j == k + (OPJ_UINT32)runlen),
+						vsc);
+			}
+		}
+	}
+	} else {
+		OPJ_INT32 *data1 = t1->data;
+		opj_flag_t *flags1 = &t1->flags[1];
+		for (k = 0; k < (t1->h & ~3u); k += 4) {
+			for (i = 0; i < t1->w; ++i) {
+				OPJ_INT32 *data2 = data1 + i;
+				opj_flag_t *flags2 = flags1 + i;
+				agg = !((MACRO_t1_flags(1 + k, 1 + i) |
+							MACRO_t1_flags(1 + k + 1, 1 + i) |
+							MACRO_t1_flags(1 + k + 2, 1 + i) |
+							MACRO_t1_flags(1 + k + 3, 1 + i)) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
+				if (agg) {
+					opj_mqc_setcurctx(mqc, T1_CTXNO_AGG);
+					if (!opj_mqc_decode(mqc)) {
+						continue;
+					}
+					opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
+					runlen = opj_mqc_decode(mqc);
+					runlen = (runlen << 1) | opj_mqc_decode(mqc);
+					flags2 += (OPJ_UINT32)runlen * t1->flags_stride;
+					data2 += (OPJ_UINT32)runlen * t1->w;
+					for (j = (OPJ_UINT32)runlen; j < 4 && j < t1->h; ++j) {
+						flags2 += t1->flags_stride;
+						if (agg && (j == (OPJ_UINT32)runlen)) {
+							opj_t1_dec_clnpass_step_partial(t1, flags2, data2, orient, oneplushalf);
+						} else {
+							opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
+						}
+						data2 += t1->w;
+					}
+				} else {
+					flags2 += t1->flags_stride;
+					opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
+					data2 += t1->w;
+					flags2 += t1->flags_stride;
+					opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
+					data2 += t1->w;
+					flags2 += t1->flags_stride;
+					opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
+					data2 += t1->w;
+					flags2 += t1->flags_stride;
+					opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
+					data2 += t1->w;
+				}
+			}
+			data1 += t1->w << 2;
+			flags1 += t1->flags_stride << 2;
+		}
+		for (i = 0; i < t1->w; ++i) {
+			OPJ_INT32 *data2 = data1 + i;
+			opj_flag_t *flags2 = flags1 + i;
+			for (j = k; j < t1->h; ++j) {
+				flags2 += t1->flags_stride;
+				opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
+				data2 += t1->w;
+			}
+		}
+	}
+
+	if (segsym) {
+		OPJ_INT32 v = 0;
+		opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
+		v = opj_mqc_decode(mqc);
+		v = (v << 1) | opj_mqc_decode(mqc);
+		v = (v << 1) | opj_mqc_decode(mqc);
+		v = (v << 1) | opj_mqc_decode(mqc);
+		/*
+		if (v!=0xa) {
+			opj_event_msg(t1->cinfo, EVT_WARNING, "Bad segmentation symbol %x\n", v);
+		} 
+		*/
+	}
+}				/* VSC and  BYPASS by Antonin */
+
+
+/** mod fixed_quality */
+static OPJ_FLOAT64 opj_t1_getwmsedec(
+		OPJ_INT32 nmsedec,
+		OPJ_UINT32 compno,
+		OPJ_UINT32 level,
+		OPJ_UINT32 orient,
+		OPJ_INT32 bpno,
+		OPJ_UINT32 qmfbid,
+		OPJ_FLOAT64 stepsize,
+		OPJ_UINT32 numcomps,
+		const OPJ_FLOAT64 * mct_norms,
+		OPJ_UINT32 mct_numcomps)
+{
+	OPJ_FLOAT64 w1 = 1, w2, wmsedec;
+	OPJ_ARG_NOT_USED(numcomps);
+
+	if (mct_norms && (compno < mct_numcomps)) {
+		w1 = mct_norms[compno];
+	}
+
+	if (qmfbid == 1) {
+		w2 = opj_dwt_getnorm(level, orient);
+	} else {	/* if (qmfbid == 0) */
+		w2 = opj_dwt_getnorm_real(level, orient);
+	}
+
+	wmsedec = w1 * w2 * stepsize * (1 << bpno);
+	wmsedec *= wmsedec * nmsedec / 8192.0;
+
+	return wmsedec;
+}
+
+static OPJ_BOOL opj_t1_allocate_buffers(
+		opj_t1_t *t1,
+		OPJ_UINT32 w,
+		OPJ_UINT32 h)
+{
+	OPJ_UINT32 datasize=w * h;
+	OPJ_UINT32 flagssize;
+
+	/* encoder uses tile buffer, so no need to allocate */
+	if (!t1->encoder) {
+		if(datasize > t1->datasize){
+			opj_aligned_free(t1->data);
+			t1->data = (OPJ_INT32*) opj_aligned_malloc(datasize * sizeof(OPJ_INT32));
+			if(!t1->data){
+				/* FIXME event manager error callback */
+				return OPJ_FALSE;
+			}
+			t1->datasize=datasize;
+		}
+		/* memset first arg is declared to never be null by gcc */
+		if (t1->data != NULL) {
+			memset(t1->data,0,datasize * sizeof(OPJ_INT32));
+		}
+	}
+	t1->flags_stride=w+2;
+	flagssize=t1->flags_stride * (h+2);
+
+	if(flagssize > t1->flagssize){
+		opj_aligned_free(t1->flags);
+		t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize * sizeof(opj_flag_t));
+		if(!t1->flags){
+			/* FIXME event manager error callback */
+			return OPJ_FALSE;
+		}
+		t1->flagssize=flagssize;
+	}
+	memset(t1->flags,0,flagssize * sizeof(opj_flag_t));
+
+	t1->w=w;
+	t1->h=h;
+
+	return OPJ_TRUE;
+}
+
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/**
+ * Creates a new Tier 1 handle
+ * and initializes the look-up tables of the Tier-1 coder/decoder
+ * @return a new T1 handle if successful, returns NULL otherwise
+*/
+opj_t1_t* opj_t1_create(OPJ_BOOL isEncoder)
+{
+	opj_t1_t *l_t1 = 00;
+
+	l_t1 = (opj_t1_t*) opj_calloc(1,sizeof(opj_t1_t));
+	if (!l_t1) {
+		return 00;
+	}
+
+	/* create MQC and RAW handles */
+	l_t1->mqc = opj_mqc_create();
+	if (! l_t1->mqc) {
+		opj_t1_destroy(l_t1);
+		return 00;
+	}
+
+	l_t1->raw = opj_raw_create();
+	if (! l_t1->raw) {
+		opj_t1_destroy(l_t1);
+		return 00;
+	}
+	l_t1->encoder = isEncoder;
+
+	return l_t1;
+}
+
+
+/**
+ * Destroys a previously created T1 handle
+ *
+ * @param p_t1 Tier 1 handle to destroy
+*/
+void opj_t1_destroy(opj_t1_t *p_t1)
+{
+	if (! p_t1) {
+		return;
+	}
+
+	/* destroy MQC and RAW handles */
+	opj_mqc_destroy(p_t1->mqc);
+	p_t1->mqc = 00;
+	opj_raw_destroy(p_t1->raw);
+	p_t1->raw = 00;
+	
+	/* encoder uses tile buffer, so no need to free */
+	if (!p_t1->encoder && p_t1->data) {
+		opj_aligned_free(p_t1->data);
+		p_t1->data = 00;
+	}
+
+	if (p_t1->flags) {
+		opj_aligned_free(p_t1->flags);
+		p_t1->flags = 00;
+	}
+
+	opj_free(p_t1);
+}
+
+OPJ_BOOL opj_t1_decode_cblks(   opj_t1_t* t1,
+                            opj_tcd_tilecomp_t* tilec,
+                            opj_tccp_t* tccp
+                            )
+{
+	OPJ_UINT32 resno, bandno, precno, cblkno;
+	OPJ_UINT32 tile_w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
+
+	for (resno = 0; resno < tilec->minimum_num_resolutions; ++resno) {
+		opj_tcd_resolution_t* res = &tilec->resolutions[resno];
+
+		for (bandno = 0; bandno < res->numbands; ++bandno) {
+			opj_tcd_band_t* restrict band = &res->bands[bandno];
+
+			for (precno = 0; precno < res->pw * res->ph; ++precno) {
+				opj_tcd_precinct_t* precinct = &band->precincts[precno];
+
+				for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
+					opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
+					OPJ_INT32* restrict datap;
+					OPJ_UINT32 cblk_w, cblk_h;
+					OPJ_INT32 x, y;
+					OPJ_UINT32 i, j;
+
+                    if (OPJ_FALSE == opj_t1_decode_cblk(
+                                            t1,
+                                            cblk,
+                                            band->bandno,
+                                            (OPJ_UINT32)tccp->roishift,
+                                            tccp->cblksty)) {
+                            return OPJ_FALSE;
+                    }
+
+					x = cblk->x0 - band->x0;
+					y = cblk->y0 - band->y0;
+					if (band->bandno & 1) {
+						opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
+						x += pres->x1 - pres->x0;
+					}
+					if (band->bandno & 2) {
+						opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
+						y += pres->y1 - pres->y0;
+					}
+
+					datap=t1->data;
+					cblk_w = t1->w;
+					cblk_h = t1->h;
+
+					if (tccp->roishift) {
+						OPJ_INT32 thresh = 1 << tccp->roishift;
+						for (j = 0; j < cblk_h; ++j) {
+							for (i = 0; i < cblk_w; ++i) {
+								OPJ_INT32 val = datap[(j * cblk_w) + i];
+								OPJ_INT32 mag = abs(val);
+								if (mag >= thresh) {
+									mag >>= tccp->roishift;
+									datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;
+								}
+							}
+						}
+					}
+					if (tccp->qmfbid == 1) {
+                        OPJ_INT32* restrict tiledp = &tilec->data[(OPJ_UINT32)y * tile_w + (OPJ_UINT32)x];
+						for (j = 0; j < cblk_h; ++j) {
+							for (i = 0; i < cblk_w; ++i) {
+								OPJ_INT32 tmp = datap[(j * cblk_w) + i];
+								((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp/2;
+							}
+						}
+					} else {		/* if (tccp->qmfbid == 0) */
+                        OPJ_FLOAT32* restrict tiledp = (OPJ_FLOAT32*) &tilec->data[(OPJ_UINT32)y * tile_w + (OPJ_UINT32)x];
+						for (j = 0; j < cblk_h; ++j) {
+                            OPJ_FLOAT32* restrict tiledp2 = tiledp;
+							for (i = 0; i < cblk_w; ++i) {
+                                OPJ_FLOAT32 tmp = (OPJ_FLOAT32)*datap * band->stepsize;
+                                *tiledp2 = tmp;
+                                datap++;
+                                tiledp2++;
+							}
+                            tiledp += tile_w;
+						}
+					}
+				} /* cblkno */
+			} /* precno */
+		} /* bandno */
+	} /* resno */
+        return OPJ_TRUE;
+}
+
+
+static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
+                            opj_tcd_cblk_dec_t* cblk,
+                            OPJ_UINT32 orient,
+                            OPJ_UINT32 roishift,
+                            OPJ_UINT32 cblksty)
+{
+	opj_raw_t *raw = t1->raw;	/* RAW component */
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+
+	OPJ_INT32 bpno_plus_one;
+	OPJ_UINT32 passtype;
+	OPJ_UINT32 segno, passno;
+	OPJ_BYTE type = T1_TYPE_MQ; /* BYPASS mode */
+
+	if(!opj_t1_allocate_buffers(
+				t1,
+				(OPJ_UINT32)(cblk->x1 - cblk->x0),
+				(OPJ_UINT32)(cblk->y1 - cblk->y0)))
+	{
+		return OPJ_FALSE;
+	}
+
+	bpno_plus_one = (OPJ_INT32)(roishift + cblk->numbps);
+	passtype = 2;
+
+	opj_mqc_resetstates(mqc);
+	opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
+	opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
+	opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
+
+	for (segno = 0; segno < cblk->real_num_segs; ++segno) {
+		opj_tcd_seg_t *seg = &cblk->segs[segno];
+
+		/* BYPASS mode */
+		type = ((bpno_plus_one <= ((OPJ_INT32) (cblk->numbps)) - 4) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
+		/* FIXME: slviewer gets here with a null pointer. Why? Partially downloaded and/or corrupt textures? */
+		if(seg->data == 00){
+			continue;
+		}
+		if (type == T1_TYPE_RAW) {
+			opj_raw_init_dec(raw, (*seg->data) + seg->dataindex, seg->len);
+		} else {
+            if (OPJ_FALSE == opj_mqc_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len)) {
+                    return OPJ_FALSE;
+            }
+		}
+
+		for (passno = 0; (passno < seg->real_num_passes) && (bpno_plus_one >= 1); ++passno) {
+            switch (passtype) {
+                case 0:
+                    if (type == T1_TYPE_RAW) {
+                        opj_t1_dec_sigpass_raw(t1, bpno_plus_one, (OPJ_INT32)orient, (OPJ_INT32)cblksty);
+                    } else {
+                        if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+                            opj_t1_dec_sigpass_mqc_vsc(t1, bpno_plus_one, (OPJ_INT32)orient);
+                        } else {
+                            opj_t1_dec_sigpass_mqc(t1, bpno_plus_one, (OPJ_INT32)orient);
+                        }
+                    }
+                    break;
+                case 1:
+                    if (type == T1_TYPE_RAW) {
+                            opj_t1_dec_refpass_raw(t1, bpno_plus_one, (OPJ_INT32)cblksty);
+                    } else {
+                        if (cblksty & J2K_CCP_CBLKSTY_VSC) {
+                            opj_t1_dec_refpass_mqc_vsc(t1, bpno_plus_one);
+                        } else {
+                            opj_t1_dec_refpass_mqc(t1, bpno_plus_one);
+                        }
+                    }
+                    break;
+                case 2:
+                    opj_t1_dec_clnpass(t1, bpno_plus_one, (OPJ_INT32)orient, (OPJ_INT32)cblksty);
+                    break;
+            }
+
+			if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
+				opj_mqc_resetstates(mqc);
+				opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
+				opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
+				opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
+			}
+			if (++passtype == 3) {
+				passtype = 0;
+				bpno_plus_one--;
+			}
+		}
+	}
+    return OPJ_TRUE;
+}
+
+
+
+
+OPJ_BOOL opj_t1_encode_cblks(   opj_t1_t *t1,
+                                opj_tcd_tile_t *tile,
+                                opj_tcp_t *tcp,
+                                const OPJ_FLOAT64 * mct_norms,
+                                OPJ_UINT32 mct_numcomps
+                                )
+{
+	OPJ_UINT32 compno, resno, bandno, precno, cblkno;
+
+	tile->distotile = 0;		/* fixed_quality */
+
+	for (compno = 0; compno < tile->numcomps; ++compno) {
+		opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
+		opj_tccp_t* tccp = &tcp->tccps[compno];
+		OPJ_UINT32 tile_w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
+
+		for (resno = 0; resno < tilec->numresolutions; ++resno) {
+			opj_tcd_resolution_t *res = &tilec->resolutions[resno];
+
+			for (bandno = 0; bandno < res->numbands; ++bandno) {
+				opj_tcd_band_t* restrict band = &res->bands[bandno];
+                OPJ_INT32 bandconst = 8192 * 8192 / ((OPJ_INT32) floor(band->stepsize * 8192));
+
+				for (precno = 0; precno < res->pw * res->ph; ++precno) {
+					opj_tcd_precinct_t *prc = &band->precincts[precno];
+
+					for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
+						opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
+						OPJ_INT32* restrict tiledp;
+						OPJ_UINT32 cblk_w;
+						OPJ_UINT32 cblk_h;
+						OPJ_UINT32 i, j, tileIndex=0, tileLineAdvance;
+
+						OPJ_INT32 x = cblk->x0 - band->x0;
+						OPJ_INT32 y = cblk->y0 - band->y0;
+						if (band->bandno & 1) {
+							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
+							x += pres->x1 - pres->x0;
+						}
+						if (band->bandno & 2) {
+							opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
+							y += pres->y1 - pres->y0;
+						}
+
+						if(!opj_t1_allocate_buffers(
+									t1,
+									(OPJ_UINT32)(cblk->x1 - cblk->x0),
+									(OPJ_UINT32)(cblk->y1 - cblk->y0)))
+						{
+							return OPJ_FALSE;
+						}
+
+						cblk_w = t1->w;
+						cblk_h = t1->h;
+						tileLineAdvance = tile_w - cblk_w;
+
+						tiledp=&tilec->data[(OPJ_UINT32)y * tile_w + (OPJ_UINT32)x];
+						t1->data = tiledp;
+						t1->data_stride = tile_w;
+						if (tccp->qmfbid == 1) {
+							for (j = 0; j < cblk_h; ++j) {
+								for (i = 0; i < cblk_w; ++i) {
+									tiledp[tileIndex] *= (1 << T1_NMSEDEC_FRACBITS);
+									tileIndex++;
+								}
+								tileIndex += tileLineAdvance;
+							}
+						} else {		/* if (tccp->qmfbid == 0) */
+							for (j = 0; j < cblk_h; ++j) {
+								for (i = 0; i < cblk_w; ++i) {
+									OPJ_INT32 tmp = tiledp[tileIndex];
+									tiledp[tileIndex] =
+										opj_int_fix_mul_t1(
+										tmp,
+										bandconst);
+									tileIndex++;
+								}
+								tileIndex += tileLineAdvance;
+							}
+						}
+
+						opj_t1_encode_cblk(
+								t1,
+								cblk,
+								band->bandno,
+								compno,
+								tilec->numresolutions - 1 - resno,
+								tccp->qmfbid,
+								band->stepsize,
+								tccp->cblksty,
+								tile->numcomps,
+								tile,
+								mct_norms,
+								mct_numcomps);
+
+					} /* cblkno */
+				} /* precno */
+			} /* bandno */
+		} /* resno  */
+	} /* compno  */
+	return OPJ_TRUE;
+}
+
+/** mod fixed_quality */
+static void opj_t1_encode_cblk(opj_t1_t *t1,
+                        opj_tcd_cblk_enc_t* cblk,
+                        OPJ_UINT32 orient,
+                        OPJ_UINT32 compno,
+                        OPJ_UINT32 level,
+                        OPJ_UINT32 qmfbid,
+                        OPJ_FLOAT64 stepsize,
+                        OPJ_UINT32 cblksty,
+                        OPJ_UINT32 numcomps,
+                        opj_tcd_tile_t * tile,
+                        const OPJ_FLOAT64 * mct_norms,
+                        OPJ_UINT32 mct_numcomps)
+{
+	OPJ_FLOAT64 cumwmsedec = 0.0;
+
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+
+	OPJ_UINT32 passno;
+	OPJ_INT32 bpno;
+	OPJ_UINT32 passtype;
+	OPJ_INT32 nmsedec = 0;
+	OPJ_INT32 max;
+	OPJ_UINT32 i, j;
+	OPJ_BYTE type = T1_TYPE_MQ;
+	OPJ_FLOAT64 tempwmsedec;
+
+	max = 0;
+	for (i = 0; i < t1->w; ++i) {
+		for (j = 0; j < t1->h; ++j) {
+			OPJ_INT32 tmp = abs(t1->data[i + j*t1->data_stride]);
+			max = opj_int_max(max, tmp);
+		}
+	}
+
+	cblk->numbps = max ? (OPJ_UINT32)((opj_int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS) : 0;
+
+	bpno = (OPJ_INT32)(cblk->numbps - 1);
+	passtype = 2;
+
+	opj_mqc_resetstates(mqc);
+	opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
+	opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
+	opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
+	opj_mqc_init_enc(mqc, cblk->data);
+
+	for (passno = 0; bpno >= 0; ++passno) {
+		opj_tcd_pass_t *pass = &cblk->passes[passno];
+		OPJ_UINT32 correction = 3;
+		type = ((bpno < ((OPJ_INT32) (cblk->numbps) - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
+
+		switch (passtype) {
+			case 0:
+				opj_t1_enc_sigpass(t1, bpno, orient, &nmsedec, type, cblksty);
+				break;
+			case 1:
+				opj_t1_enc_refpass(t1, bpno, &nmsedec, type, cblksty);
+				break;
+			case 2:
+				opj_t1_enc_clnpass(t1, bpno, orient, &nmsedec, cblksty);
+				/* code switch SEGMARK (i.e. SEGSYM) */
+				if (cblksty & J2K_CCP_CBLKSTY_SEGSYM)
+					opj_mqc_segmark_enc(mqc);
+				break;
+		}
+
+		/* fixed_quality */
+		tempwmsedec = opj_t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps,mct_norms, mct_numcomps) ;
+		cumwmsedec += tempwmsedec;
+		tile->distotile += tempwmsedec;
+
+		/* Code switch "RESTART" (i.e. TERMALL) */
+		if ((cblksty & J2K_CCP_CBLKSTY_TERMALL)	&& !((passtype == 2) && (bpno - 1 < 0))) {
+			if (type == T1_TYPE_RAW) {
+				opj_mqc_flush(mqc);
+				correction = 1;
+				/* correction = mqc_bypass_flush_enc(); */
+			} else {			/* correction = mqc_restart_enc(); */
+				opj_mqc_flush(mqc);
+				correction = 1;
+			}
+			pass->term = 1;
+		} else {
+			if (((bpno < ((OPJ_INT32) (cblk->numbps) - 4) && (passtype > 0))
+				|| ((bpno == ((OPJ_INT32)cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) {
+				if (type == T1_TYPE_RAW) {
+					opj_mqc_flush(mqc);
+					correction = 1;
+					/* correction = mqc_bypass_flush_enc(); */
+				} else {		/* correction = mqc_restart_enc(); */
+					opj_mqc_flush(mqc);
+					correction = 1;
+				}
+				pass->term = 1;
+			} else {
+				pass->term = 0;
+			}
+		}
+
+		if (++passtype == 3) {
+			passtype = 0;
+			bpno--;
+		}
+
+		if (pass->term && bpno > 0) {
+			type = ((bpno < ((OPJ_INT32) (cblk->numbps) - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
+			if (type == T1_TYPE_RAW)
+				opj_mqc_bypass_init_enc(mqc);
+			else
+				opj_mqc_restart_init_enc(mqc);
+		}
+
+		pass->distortiondec = cumwmsedec;
+		pass->rate = opj_mqc_numbytes(mqc) + correction;	/* FIXME */
+
+		/* Code-switch "RESET" */
+		if (cblksty & J2K_CCP_CBLKSTY_RESET)
+			opj_mqc_reset_enc(mqc);
+	}
+
+	/* Code switch "ERTERM" (i.e. PTERM) */
+	if (cblksty & J2K_CCP_CBLKSTY_PTERM)
+		opj_mqc_erterm_enc(mqc);
+	else /* Default coding */ if (!(cblksty & J2K_CCP_CBLKSTY_LAZY))
+		opj_mqc_flush(mqc);
+
+	cblk->totalpasses = passno;
+
+	for (passno = 0; passno<cblk->totalpasses; passno++) {
+		opj_tcd_pass_t *pass = &cblk->passes[passno];
+		if (pass->rate > opj_mqc_numbytes(mqc))
+			pass->rate = opj_mqc_numbytes(mqc);
+		/*Preventing generation of FF as last data byte of a pass*/
+		if((pass->rate>1) && (cblk->data[pass->rate - 1] == 0xFF)){
+			pass->rate--;
+		}
+		pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);
+	}
+}
+
+#if 0
+static void opj_t1_dec_refpass_step(   opj_t1_t *t1,
+                                opj_flag_t *flagsp,
+                                OPJ_INT32 *datap,
+                                OPJ_INT32 poshalf,
+                                OPJ_INT32 neghalf,
+                                OPJ_BYTE type,
+                                OPJ_UINT32 vsc)
+{
+	OPJ_INT32  t;
+	OPJ_UINT32 v,flag;
+
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+	opj_raw_t *raw = t1->raw;	/* RAW component */
+
+	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+	if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
+		opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag));	/* ESSAI */
+		if (type == T1_TYPE_RAW) {
+			v = opj_raw_decode(raw);
+		} else {
+			v = opj_mqc_decode(mqc);
+		}
+		t = v ? poshalf : neghalf;
+		*datap += *datap < 0 ? -t : t;
+		*flagsp |= T1_REFINE;
+	}
+}				/* VSC and  BYPASS by Antonin  */
+#endif
+
+
+
+#if 0
+static void opj_t1_dec_sigpass_step(   opj_t1_t *t1,
+                                opj_flag_t *flagsp,
+                                OPJ_INT32 *datap,
+                                OPJ_UINT32 orient,
+                                OPJ_INT32 oneplushalf,
+                                OPJ_BYTE type,
+                                OPJ_UINT32 vsc)
+{
+	OPJ_UINT32 v, flag;
+
+	opj_raw_t *raw = t1->raw;	/* RAW component */
+	opj_mqc_t *mqc = t1->mqc;	/* MQC component */
+
+	flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
+	if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
+		if (type == T1_TYPE_RAW) {
+			if (opj_raw_decode(raw)) {
+				v = opj_raw_decode(raw);	/* ESSAI */
+				*datap = v ? -oneplushalf : oneplushalf;
+				opj_t1_updateflags(flagsp, v, t1->flags_stride);
+			}
+		} else {
+			opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
+			if (opj_mqc_decode(mqc)) {
+				opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
+				v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag);
+				*datap = v ? -oneplushalf : oneplushalf;
+				opj_t1_updateflags(flagsp, v, t1->flags_stride);
+			}
+		}
+		*flagsp |= T1_VISIT;
+	}
+}				/* VSC and  BYPASS by Antonin */
+#endif
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1.h
similarity index 73%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/t1.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/t1.h
index 572ec88..3bc0ad9 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1.h
@@ -1,9 +1,15 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * All rights reserved.
  *
@@ -85,27 +91,27 @@ in T1.C are used by some function in TCD.C.
 
 /* ----------------------------------------------------------------------- */
 
-typedef short flag_t;
+typedef OPJ_INT16 opj_flag_t;
 
 /**
 Tier-1 coding (coding of code-block coefficients)
 */
 typedef struct opj_t1 {
-	/** codec context */
-	opj_common_ptr cinfo;
 
 	/** MQC component */
 	opj_mqc_t *mqc;
 	/** RAW component */
 	opj_raw_t *raw;
 
-	int *data;
-	flag_t *flags;
-	int w;
-	int h;
-	int datasize;
-	int flagssize;
-	int flags_stride;
+	OPJ_INT32  *data;
+	opj_flag_t *flags;
+	OPJ_UINT32 w;
+	OPJ_UINT32 h;
+	OPJ_UINT32 datasize;
+	OPJ_UINT32 flagssize;
+	OPJ_UINT32 flags_stride;
+	OPJ_UINT32 data_stride;
+	OPJ_BOOL   encoder;
 } opj_t1_t;
 
 #define MACRO_t1_flags(x,y) t1->flags[((x)*(t1->flags_stride))+(y)]
@@ -113,32 +119,46 @@ typedef struct opj_t1 {
 /** @name Exported functions */
 /*@{*/
 /* ----------------------------------------------------------------------- */
-/**
-Create a new T1 handle 
-and initialize the look-up tables of the Tier-1 coder/decoder
- at return Returns a new T1 handle if successful, returns NULL otherwise
- at see t1_init_luts
-*/
-opj_t1_t* t1_create(opj_common_ptr cinfo);
-/**
-Destroy a previously created T1 handle
- at param t1 T1 handle to destroy
-*/
-void t1_destroy(opj_t1_t *t1);
+
 /**
 Encode the code-blocks of a tile
 @param t1 T1 handle
 @param tile The tile to encode
 @param tcp Tile coding parameters
+ at param mct_norms  FIXME DOC
+ at param mct_numcomps Number of components used for MCT
 */
-void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
+OPJ_BOOL opj_t1_encode_cblks(   opj_t1_t *t1,
+                                opj_tcd_tile_t *tile,
+                                opj_tcp_t *tcp,
+                                const OPJ_FLOAT64 * mct_norms,
+                                OPJ_UINT32 mct_numcomps);
+
 /**
 Decode the code-blocks of a tile
 @param t1 T1 handle
 @param tilec The tile to decode
 @param tccp Tile coding parameters
 */
-void t1_decode_cblks(opj_t1_t* t1, opj_tcd_tilecomp_t* tilec, opj_tccp_t* tccp);
+OPJ_BOOL opj_t1_decode_cblks(   opj_t1_t* t1,
+                                opj_tcd_tilecomp_t* tilec,
+                                opj_tccp_t* tccp);
+
+
+
+/**
+ * Creates a new Tier 1 handle
+ * and initializes the look-up tables of the Tier-1 coder/decoder
+ * @return a new T1 handle if successful, returns NULL otherwise
+*/
+opj_t1_t* opj_t1_create(OPJ_BOOL isEncoder);
+
+/**
+ * Destroys a previously created T1 handle
+ *
+ * @param p_t1 Tier 1 handle to destroy
+*/
+void opj_t1_destroy(opj_t1_t *p_t1);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1_generate_luts.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1_generate_luts.c
similarity index 78%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/t1_generate_luts.c
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/t1_generate_luts.c
index 3988041..cba7245 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1_generate_luts.c
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1_generate_luts.c
@@ -1,9 +1,15 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * Copyright (c) 2007, Callum Lerwick <seg at haxxed.com>
  * All rights reserved.
@@ -31,14 +37,15 @@
  */
 
 #include "opj_includes.h"
-#include <math.h>
 
 static int t1_init_ctxno_zc(int f, int orient) {
 	int h, v, d, n, t, hv;
-	n = 0;
 	h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0);
 	v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0);
 	d = ((f & T1_SIG_NW) != 0) + ((f & T1_SIG_NE) != 0) + ((f & T1_SIG_SE) != 0) + ((f & T1_SIG_SW) != 0);
+	n = 0;
+	t = 0;
+	hv = 0;
 
 	switch (orient) {
 		case 2:
@@ -109,16 +116,16 @@ static int t1_init_ctxno_sc(int f) {
 	int hc, vc, n;
 	n = 0;
 
-	hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+	hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
 				T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
-			1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+			1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
 					(T1_SIG_E | T1_SGN_E)) +
 				((f & (T1_SIG_W | T1_SGN_W)) ==
 				 (T1_SIG_W | T1_SGN_W)), 1);
 
-	vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+	vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
 				T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
-			1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+			1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
 					(T1_SIG_N | T1_SGN_N)) +
 				((f & (T1_SIG_S | T1_SGN_S)) ==
 				 (T1_SIG_S | T1_SGN_S)), 1);
@@ -149,16 +156,16 @@ static int t1_init_ctxno_sc(int f) {
 static int t1_init_spb(int f) {
 	int hc, vc, n;
 
-	hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+	hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
 				T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
-			1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+			1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
 					(T1_SIG_E | T1_SGN_E)) +
 				((f & (T1_SIG_W | T1_SGN_W)) ==
 				 (T1_SIG_W | T1_SGN_W)), 1);
 
-	vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+	vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
 				T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
-			1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+			1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
 					(T1_SIG_N | T1_SGN_N)) +
 				((f & (T1_SIG_S | T1_SGN_S)) ==
 				 (T1_SIG_S | T1_SGN_S)), 1);
@@ -171,7 +178,7 @@ static int t1_init_spb(int f) {
 	return n;
 }
 
-void dump_array16(int array[],int size){
+static void dump_array16(int array[],int size){
 	int i;
 	--size;
 	for (i = 0; i < size; ++i) {
@@ -182,7 +189,8 @@ void dump_array16(int array[],int size){
 	printf("0x%04x\n};\n\n", array[size]);
 }
 
-int main(){
+int main(int argc, char **argv)
+{
 	int i, j;
 	double u, v, t;
 
@@ -191,10 +199,11 @@ int main(){
 	int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
 	int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
 	int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
+  (void)argc; (void)argv;
 
 	printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
 
-	// lut_ctxno_zc
+	/* lut_ctxno_zc */
 	for (j = 0; j < 4; ++j) {
 		for (i = 0; i < 256; ++i) {
 			int orient = j;
@@ -207,7 +216,7 @@ int main(){
 		}
 	}
 
-	printf("static char lut_ctxno_zc[1024] = {\n  ");
+	printf("static OPJ_BYTE lut_ctxno_zc[1024] = {\n  ");
 	for (i = 0; i < 1023; ++i) {
 		printf("%i, ", lut_ctxno_zc[i]);
 		if(!((i+1)&0x1f))
@@ -215,8 +224,8 @@ int main(){
 	}
 	printf("%i\n};\n\n", lut_ctxno_zc[1023]);
 
-	// lut_ctxno_sc
-	printf("static char lut_ctxno_sc[256] = {\n  ");
+	/* lut_ctxno_sc */
+	printf("static OPJ_BYTE lut_ctxno_sc[256] = {\n  ");
 	for (i = 0; i < 255; ++i) {
 		printf("0x%x, ", t1_init_ctxno_sc(i << 4));
 		if(!((i+1)&0xf))
@@ -224,8 +233,8 @@ int main(){
 	}
 	printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4));
 
-	// lut_spb
-	printf("static char lut_spb[256] = {\n  ");
+	/* lut_spb */
+	printf("static OPJ_BYTE lut_spb[256] = {\n  ");
 	for (i = 0; i < 255; ++i) {
 		printf("%i, ", t1_init_spb(i << 4));
 		if(!((i+1)&0x1f))
@@ -240,10 +249,10 @@ int main(){
 		u = t;
 		v = t - 1.5;
 		lut_nmsedec_sig[i] = 
-			int_max(0, 
+			opj_int_max(0, 
 					(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
 		lut_nmsedec_sig0[i] =
-			int_max(0,
+			opj_int_max(0,
 					(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
 		u = t - 1.0;
 		if (i & (1 << (T1_NMSEDEC_BITS - 1))) {
@@ -252,23 +261,23 @@ int main(){
 			v = t - 0.5;
 		}
 		lut_nmsedec_ref[i] =
-			int_max(0,
+			opj_int_max(0,
 					(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
 		lut_nmsedec_ref0[i] =
-			int_max(0,
+			opj_int_max(0,
 					(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
 	}
 
-	printf("static short lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n  ");
+	printf("static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n  ");
 	dump_array16(lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS);
 
-	printf("static short lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n  ");
+	printf("static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n  ");
 	dump_array16(lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS);
 
-	printf("static short lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n  ");
+	printf("static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n  ");
 	dump_array16(lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS);
 
-	printf("static short lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n  ");
+	printf("static OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n  ");
 	dump_array16(lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS);
 
 	return 0;
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1_luts.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1_luts.h
similarity index 96%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/t1_luts.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/t1_luts.h
index e5e33f6..37776b6 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t1_luts.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/t1_luts.h
@@ -1,6 +1,6 @@
 /* This file was automatically generated by t1_generate_luts.c */
 
-static char lut_ctxno_zc[1024] = {
+static OPJ_BYTE lut_ctxno_zc[1024] = {
   0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
   5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 
   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
@@ -35,7 +35,7 @@ static char lut_ctxno_zc[1024] = {
   2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8
 };
 
-static char lut_ctxno_sc[256] = {
+static OPJ_BYTE lut_ctxno_sc[256] = {
   0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd, 
   0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc, 
   0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa, 
@@ -54,7 +54,7 @@ static char lut_ctxno_sc[256] = {
   0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd
 };
 
-static char lut_spb[256] = {
+static OPJ_BYTE lut_spb[256] = {
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
   0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 
   0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
@@ -65,7 +65,7 @@ static char lut_spb[256] = {
   0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
 };
 
-static short lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
+static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
@@ -84,7 +84,7 @@ static short lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
   0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680
 };
 
-static short lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
+static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080, 
   0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200, 
   0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400, 
@@ -103,7 +103,7 @@ static short lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
   0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00
 };
 
-static short lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
+static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
   0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480, 
   0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080, 
   0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80, 
@@ -122,7 +122,7 @@ static short lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
   0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780
 };
 
-static short lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {
+static OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {
   0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980, 
   0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300, 
   0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00, 
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/t2.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/t2.c
new file mode 100644
index 0000000..5a8d440
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/t2.c
@@ -0,0 +1,1386 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/** @defgroup T2 T2 - Implementation of a tier-2 coding */
+/*@{*/
+
+/** @name Local static functions */
+/*@{*/
+
+static void opj_t2_putcommacode(opj_bio_t *bio, OPJ_INT32 n);
+
+static OPJ_UINT32 opj_t2_getcommacode(opj_bio_t *bio); 
+/**
+Variable length code for signalling delta Zil (truncation point)
+ at param bio  Bit Input/Output component
+ at param n    delta Zil
+*/
+static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n);
+static OPJ_UINT32 opj_t2_getnumpasses(opj_bio_t *bio);
+
+/**
+Encode a packet of a tile to a destination buffer
+ at param tileno Number of the tile encoded
+ at param tile Tile for which to write the packets
+ at param tcp Tile coding parameters
+ at param pi Packet identity
+ at param dest Destination buffer
+ at param p_data_written   FIXME DOC
+ at param len Length of the destination buffer
+ at param cstr_info Codestream information structure
+ at return
+*/
+static OPJ_BOOL opj_t2_encode_packet(   OPJ_UINT32 tileno,
+                                        opj_tcd_tile_t *tile,
+                                        opj_tcp_t *tcp,
+                                        opj_pi_iterator_t *pi,
+                                        OPJ_BYTE *dest,
+                                        OPJ_UINT32 * p_data_written,
+                                        OPJ_UINT32 len,
+                                        opj_codestream_info_t *cstr_info);
+
+/**
+Decode a packet of a tile from a source buffer
+ at param t2 T2 handle
+ at param tile Tile for which to write the packets
+ at param tcp Tile coding parameters
+ at param pi Packet identity
+ at param src Source buffer
+ at param data_read   FIXME DOC
+ at param max_length  FIXME DOC
+ at param pack_info Packet information
+
+ at return  FIXME DOC
+*/
+static OPJ_BOOL opj_t2_decode_packet(   opj_t2_t* t2,
+                                        opj_tcd_tile_t *tile,
+                                        opj_tcp_t *tcp,
+                                        opj_pi_iterator_t *pi,
+                                        OPJ_BYTE *src,
+                                        OPJ_UINT32 * data_read,
+                                        OPJ_UINT32 max_length,
+                                        opj_packet_info_t *pack_info,
+                                        opj_event_mgr_t *p_manager);
+
+static OPJ_BOOL opj_t2_skip_packet( opj_t2_t* p_t2,
+                                    opj_tcd_tile_t *p_tile,
+                                    opj_tcp_t *p_tcp,
+                                    opj_pi_iterator_t *p_pi,
+                                    OPJ_BYTE *p_src,
+                                    OPJ_UINT32 * p_data_read,
+                                    OPJ_UINT32 p_max_length,
+                                    opj_packet_info_t *p_pack_info,
+                                    opj_event_mgr_t *p_manager);
+
+static OPJ_BOOL opj_t2_read_packet_header(  opj_t2_t* p_t2,
+                                            opj_tcd_tile_t *p_tile,
+                                            opj_tcp_t *p_tcp,
+                                            opj_pi_iterator_t *p_pi,
+                                            OPJ_BOOL * p_is_data_present,
+                                            OPJ_BYTE *p_src_data,
+                                            OPJ_UINT32 * p_data_read,
+                                            OPJ_UINT32 p_max_length,
+                                            opj_packet_info_t *p_pack_info,
+                                            opj_event_mgr_t *p_manager);
+
+static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
+                                        opj_tcd_tile_t *p_tile,
+                                        opj_pi_iterator_t *p_pi,
+                                        OPJ_BYTE *p_src_data,
+                                        OPJ_UINT32 * p_data_read,
+                                        OPJ_UINT32 p_max_length,
+                                        opj_packet_info_t *pack_info,
+                                        opj_event_mgr_t *p_manager);
+
+static OPJ_BOOL opj_t2_skip_packet_data(opj_t2_t* p_t2,
+                                        opj_tcd_tile_t *p_tile,
+                                        opj_pi_iterator_t *p_pi,
+                                        OPJ_UINT32 * p_data_read,
+                                        OPJ_UINT32 p_max_length,
+                                        opj_packet_info_t *pack_info,
+                                        opj_event_mgr_t *p_manager);
+
+/**
+ at param cblk
+ at param index
+ at param cblksty
+ at param first
+*/
+static OPJ_BOOL opj_t2_init_seg(    opj_tcd_cblk_dec_t* cblk,
+                                    OPJ_UINT32 index,
+                                    OPJ_UINT32 cblksty,
+                                    OPJ_UINT32 first);
+
+/*@}*/
+
+/*@}*/
+
+/* ----------------------------------------------------------------------- */
+
+/* #define RESTART 0x04 */
+static void opj_t2_putcommacode(opj_bio_t *bio, OPJ_INT32 n) {
+        while (--n >= 0) {
+                opj_bio_write(bio, 1, 1);
+        }
+        opj_bio_write(bio, 0, 1);
+}
+
+static OPJ_UINT32 opj_t2_getcommacode(opj_bio_t *bio)
+{
+    OPJ_UINT32 n = 0;
+    while (opj_bio_read(bio, 1)) {
+	    ++n;
+    }
+    return n;
+}
+
+static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n) {
+        if (n == 1) {
+                opj_bio_write(bio, 0, 1);
+        } else if (n == 2) {
+                opj_bio_write(bio, 2, 2);
+        } else if (n <= 5) {
+                opj_bio_write(bio, 0xc | (n - 3), 4);
+        } else if (n <= 36) {
+                opj_bio_write(bio, 0x1e0 | (n - 6), 9);
+        } else if (n <= 164) {
+                opj_bio_write(bio, 0xff80 | (n - 37), 16);
+        }
+}
+
+static OPJ_UINT32 opj_t2_getnumpasses(opj_bio_t *bio) {
+        OPJ_UINT32 n;
+        if (!opj_bio_read(bio, 1))
+                return 1;
+        if (!opj_bio_read(bio, 1))
+                return 2;
+        if ((n = opj_bio_read(bio, 2)) != 3)
+                return (3 + n);
+        if ((n = opj_bio_read(bio, 5)) != 31)
+                return (6 + n);
+        return (37 + opj_bio_read(bio, 7));
+}
+
+/* ----------------------------------------------------------------------- */
+
+OPJ_BOOL opj_t2_encode_packets( opj_t2_t* p_t2,
+                                OPJ_UINT32 p_tile_no,
+                                opj_tcd_tile_t *p_tile,
+                                OPJ_UINT32 p_maxlayers,
+                                OPJ_BYTE *p_dest,
+                                OPJ_UINT32 * p_data_written,
+                                OPJ_UINT32 p_max_len,
+                                opj_codestream_info_t *cstr_info,
+                                OPJ_UINT32 p_tp_num,
+                                OPJ_INT32 p_tp_pos,
+                                OPJ_UINT32 p_pino,
+                                J2K_T2_MODE p_t2_mode)
+{
+        OPJ_BYTE *l_current_data = p_dest;
+        OPJ_UINT32 l_nb_bytes = 0;
+        OPJ_UINT32 compno;
+        OPJ_UINT32 poc;
+        opj_pi_iterator_t *l_pi = 00;
+        opj_pi_iterator_t *l_current_pi = 00;
+        opj_image_t *l_image = p_t2->image;
+        opj_cp_t *l_cp = p_t2->cp;
+        opj_tcp_t *l_tcp = &l_cp->tcps[p_tile_no];
+        OPJ_UINT32 pocno = (l_cp->rsiz == OPJ_PROFILE_CINEMA_4K)? 2: 1;
+        OPJ_UINT32 l_max_comp = l_cp->m_specific_param.m_enc.m_max_comp_size > 0 ? l_image->numcomps : 1;
+        OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1;
+
+        l_pi = opj_pi_initialise_encode(l_image, l_cp, p_tile_no, p_t2_mode);
+        if (!l_pi) {
+                return OPJ_FALSE;
+        }
+
+        * p_data_written = 0;
+
+        if (p_t2_mode == THRESH_CALC ){ /* Calculating threshold */
+                l_current_pi = l_pi;
+
+                for     (compno = 0; compno < l_max_comp; ++compno) {
+                        OPJ_UINT32 l_comp_len = 0;
+                        l_current_pi = l_pi;
+
+                        for (poc = 0; poc < pocno ; ++poc) {
+                                OPJ_UINT32 l_tp_num = compno;
+
+                                /* TODO MSD : check why this function cannot fail (cf. v1) */
+                                opj_pi_create_encode(l_pi, l_cp,p_tile_no,poc,l_tp_num,p_tp_pos,p_t2_mode);
+
+                                if (l_current_pi->poc.prg == OPJ_PROG_UNKNOWN) {
+                                    /* TODO ADE : add an error */
+                                    opj_pi_destroy(l_pi, l_nb_pocs);
+                                    return OPJ_FALSE;
+                                }
+                                while (opj_pi_next(l_current_pi)) {
+                                        if (l_current_pi->layno < p_maxlayers) {
+                                                l_nb_bytes = 0;
+
+                                                if (! opj_t2_encode_packet(p_tile_no,p_tile, l_tcp, l_current_pi, l_current_data, &l_nb_bytes, p_max_len, cstr_info)) {
+                                                        opj_pi_destroy(l_pi, l_nb_pocs);
+                                                        return OPJ_FALSE;
+                                                }
+
+                                                l_comp_len += l_nb_bytes;
+                                                l_current_data += l_nb_bytes;
+                                                p_max_len -= l_nb_bytes;
+
+                                                * p_data_written += l_nb_bytes;
+                                        }
+                                }
+
+                                if (l_cp->m_specific_param.m_enc.m_max_comp_size) {
+                                        if (l_comp_len > l_cp->m_specific_param.m_enc.m_max_comp_size) {
+                                                opj_pi_destroy(l_pi, l_nb_pocs);
+                                                return OPJ_FALSE;
+                                        }
+                                }
+
+                                ++l_current_pi;
+                        }
+                }
+        }
+        else {  /* t2_mode == FINAL_PASS  */
+                opj_pi_create_encode(l_pi, l_cp,p_tile_no,p_pino,p_tp_num,p_tp_pos,p_t2_mode);
+
+                l_current_pi = &l_pi[p_pino];
+                if (l_current_pi->poc.prg == OPJ_PROG_UNKNOWN) {
+                    /* TODO ADE : add an error */
+                    opj_pi_destroy(l_pi, l_nb_pocs);
+                    return OPJ_FALSE;
+                }
+                while (opj_pi_next(l_current_pi)) {
+                        if (l_current_pi->layno < p_maxlayers) {
+                                l_nb_bytes=0;
+
+                                if (! opj_t2_encode_packet(p_tile_no,p_tile, l_tcp, l_current_pi, l_current_data, &l_nb_bytes, p_max_len, cstr_info)) {
+                                        opj_pi_destroy(l_pi, l_nb_pocs);
+                                        return OPJ_FALSE;
+                                }
+
+                                l_current_data += l_nb_bytes;
+                                p_max_len -= l_nb_bytes;
+
+                                * p_data_written += l_nb_bytes;
+
+                                /* INDEX >> */
+                                if(cstr_info) {
+                                        if(cstr_info->index_write) {
+                                                opj_tile_info_t *info_TL = &cstr_info->tile[p_tile_no];
+                                                opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
+                                                if (!cstr_info->packno) {
+                                                        info_PK->start_pos = info_TL->end_header + 1;
+                                                } else {
+                                                        info_PK->start_pos = ((l_cp->m_specific_param.m_enc.m_tp_on | l_tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
+                                                }
+                                                info_PK->end_pos = info_PK->start_pos + l_nb_bytes - 1;
+                                                info_PK->end_ph_pos += info_PK->start_pos - 1;  /* End of packet header which now only represents the distance
+                                                                                                                                                                                                                                                   to start of packet is incremented by value of start of packet*/
+                                        }
+
+                                        cstr_info->packno++;
+                                }
+                                /* << INDEX */
+                                ++p_tile->packno;
+                        }
+                }
+        }
+
+        opj_pi_destroy(l_pi, l_nb_pocs);
+
+        return OPJ_TRUE;
+}
+
+/* see issue 80 */
+#if 0
+#define JAS_FPRINTF fprintf
+#else
+/* issue 290 */
+static void opj_null_jas_fprintf(FILE* file, const char * format, ...)
+{
+  (void)file;
+  (void)format;
+}
+#define JAS_FPRINTF opj_null_jas_fprintf
+#endif
+
+OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2,
+                                OPJ_UINT32 p_tile_no,
+                                opj_tcd_tile_t *p_tile,
+                                OPJ_BYTE *p_src,
+                                OPJ_UINT32 * p_data_read,
+                                OPJ_UINT32 p_max_len,
+                                opj_codestream_index_t *p_cstr_index,
+                                opj_event_mgr_t *p_manager)
+{
+        OPJ_BYTE *l_current_data = p_src;
+        opj_pi_iterator_t *l_pi = 00;
+        OPJ_UINT32 pino;
+        opj_image_t *l_image = p_t2->image;
+        opj_cp_t *l_cp = p_t2->cp;
+        opj_tcp_t *l_tcp = &(p_t2->cp->tcps[p_tile_no]);
+        OPJ_UINT32 l_nb_bytes_read;
+        OPJ_UINT32 l_nb_pocs = l_tcp->numpocs + 1;
+        opj_pi_iterator_t *l_current_pi = 00;
+#ifdef TODO_MSD
+        OPJ_UINT32 curtp = 0;
+        OPJ_UINT32 tp_start_packno;
+#endif 
+        opj_packet_info_t *l_pack_info = 00;
+        opj_image_comp_t* l_img_comp = 00;
+
+        OPJ_ARG_NOT_USED(p_cstr_index);
+
+#ifdef TODO_MSD
+        if (p_cstr_index) {
+                l_pack_info = p_cstr_index->tile_index[p_tile_no].packet;
+        }
+#endif
+
+        /* create a packet iterator */
+        l_pi = opj_pi_create_decode(l_image, l_cp, p_tile_no);
+        if (!l_pi) {
+                return OPJ_FALSE;
+        }
+
+
+        l_current_pi = l_pi;
+
+        for     (pino = 0; pino <= l_tcp->numpocs; ++pino) {
+
+                /* if the resolution needed is too low, one dim of the tilec could be equal to zero
+                 * and no packets are used to decode this resolution and
+                 * l_current_pi->resno is always >= p_tile->comps[l_current_pi->compno].minimum_num_resolutions
+                 * and no l_img_comp->resno_decoded are computed
+                 */
+                OPJ_BOOL* first_pass_failed = NULL;
+					
+                if (l_current_pi->poc.prg == OPJ_PROG_UNKNOWN) {
+                    /* TODO ADE : add an error */
+                    opj_pi_destroy(l_pi, l_nb_pocs);
+                    return OPJ_FALSE;
+                }
+					
+                first_pass_failed = (OPJ_BOOL*)opj_malloc(l_image->numcomps * sizeof(OPJ_BOOL));
+                if (!first_pass_failed)
+                {
+                    opj_pi_destroy(l_pi,l_nb_pocs);
+                    return OPJ_FALSE;
+                }
+                memset(first_pass_failed, OPJ_TRUE, l_image->numcomps * sizeof(OPJ_BOOL));
+
+                while (opj_pi_next(l_current_pi)) {
+                  JAS_FPRINTF( stderr, "packet offset=00000166 prg=%d cmptno=%02d rlvlno=%02d prcno=%03d lyrno=%02d\n\n",
+                    l_current_pi->poc.prg1, l_current_pi->compno, l_current_pi->resno, l_current_pi->precno, l_current_pi->layno );
+
+                        if (l_tcp->num_layers_to_decode > l_current_pi->layno
+                                        && l_current_pi->resno < p_tile->comps[l_current_pi->compno].minimum_num_resolutions) {
+                                l_nb_bytes_read = 0;
+
+                                first_pass_failed[l_current_pi->compno] = OPJ_FALSE;
+
+                                if (! opj_t2_decode_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info, p_manager)) {
+                                        opj_pi_destroy(l_pi,l_nb_pocs);
+                                        opj_free(first_pass_failed);
+                                        return OPJ_FALSE;
+                                }
+
+                                l_img_comp = &(l_image->comps[l_current_pi->compno]);
+                                l_img_comp->resno_decoded = opj_uint_max(l_current_pi->resno, l_img_comp->resno_decoded);
+                        }
+                        else {
+                                l_nb_bytes_read = 0;
+                                if (! opj_t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info, p_manager)) {
+                                        opj_pi_destroy(l_pi,l_nb_pocs);
+                                        opj_free(first_pass_failed);
+                                        return OPJ_FALSE;
+                                }
+                        }
+
+                        if (first_pass_failed[l_current_pi->compno]) {
+                                l_img_comp = &(l_image->comps[l_current_pi->compno]);
+                                if (l_img_comp->resno_decoded == 0)
+                                        l_img_comp->resno_decoded = p_tile->comps[l_current_pi->compno].minimum_num_resolutions - 1;
+                        }
+
+                        l_current_data += l_nb_bytes_read;
+                        p_max_len -= l_nb_bytes_read;
+
+                        /* INDEX >> */
+#ifdef TODO_MSD
+                        if(p_cstr_info) {
+                                opj_tile_info_v2_t *info_TL = &p_cstr_info->tile[p_tile_no];
+                                opj_packet_info_t *info_PK = &info_TL->packet[p_cstr_info->packno];
+                                tp_start_packno = 0;
+                                if (!p_cstr_info->packno) {
+                                        info_PK->start_pos = info_TL->end_header + 1;
+                                } else if (info_TL->packet[p_cstr_info->packno-1].end_pos >= (OPJ_INT32)p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_pos){ /* New tile part */
+                                        info_TL->tp[curtp].tp_numpacks = p_cstr_info->packno - tp_start_packno; /* Number of packets in previous tile-part */
+                                        tp_start_packno = p_cstr_info->packno;
+                                        curtp++;
+                                        info_PK->start_pos = p_cstr_info->tile[p_tile_no].tp[curtp].tp_end_header+1;
+                                } else {
+                                        info_PK->start_pos = (l_cp->m_specific_param.m_enc.m_tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[p_cstr_info->packno - 1].end_pos + 1;
+                                }
+                                info_PK->end_pos = info_PK->start_pos + l_nb_bytes_read - 1;
+                                info_PK->end_ph_pos += info_PK->start_pos - 1;  /* End of packet header which now only represents the distance */
+                                ++p_cstr_info->packno;
+                        }
+#endif
+                        /* << INDEX */
+                }
+                ++l_current_pi;
+
+                opj_free(first_pass_failed);
+        }
+        /* INDEX >> */
+#ifdef TODO_MSD
+        if
+                (p_cstr_info) {
+                p_cstr_info->tile[p_tile_no].tp[curtp].tp_numpacks = p_cstr_info->packno - tp_start_packno; /* Number of packets in last tile-part */
+        }
+#endif
+        /* << INDEX */
+
+        /* don't forget to release pi */
+        opj_pi_destroy(l_pi,l_nb_pocs);
+        *p_data_read = (OPJ_UINT32)(l_current_data - p_src);
+        return OPJ_TRUE;
+}
+
+/* ----------------------------------------------------------------------- */
+
+/**
+ * Creates a Tier 2 handle
+ *
+ * @param       p_image         Source or destination image
+ * @param       p_cp            Image coding parameters.
+ * @return              a new T2 handle if successful, NULL otherwise.
+*/
+opj_t2_t* opj_t2_create(opj_image_t *p_image, opj_cp_t *p_cp)
+{
+        /* create the t2 structure */
+        opj_t2_t *l_t2 = (opj_t2_t*)opj_calloc(1,sizeof(opj_t2_t));
+        if (!l_t2) {
+                return NULL;
+        }
+
+        l_t2->image = p_image;
+        l_t2->cp = p_cp;
+
+        return l_t2;
+}
+
+void opj_t2_destroy(opj_t2_t *t2) {
+        if(t2) {
+                opj_free(t2);
+        }
+}
+
+static OPJ_BOOL opj_t2_decode_packet(  opj_t2_t* p_t2,
+                                opj_tcd_tile_t *p_tile,
+                                opj_tcp_t *p_tcp,
+                                opj_pi_iterator_t *p_pi,
+                                OPJ_BYTE *p_src,
+                                OPJ_UINT32 * p_data_read,
+                                OPJ_UINT32 p_max_length,
+                                opj_packet_info_t *p_pack_info,
+                                opj_event_mgr_t *p_manager)
+{
+        OPJ_BOOL l_read_data;
+        OPJ_UINT32 l_nb_bytes_read = 0;
+        OPJ_UINT32 l_nb_total_bytes_read = 0;
+
+        *p_data_read = 0;
+
+        if (! opj_t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        p_src += l_nb_bytes_read;
+        l_nb_total_bytes_read += l_nb_bytes_read;
+        p_max_length -= l_nb_bytes_read;
+
+        /* we should read data for the packet */
+        if (l_read_data) {
+                l_nb_bytes_read = 0;
+
+                if (! opj_t2_read_packet_data(p_t2,p_tile,p_pi,p_src,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
+                        return OPJ_FALSE;
+                }
+
+                l_nb_total_bytes_read += l_nb_bytes_read;
+        }
+
+        *p_data_read = l_nb_total_bytes_read;
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_t2_encode_packet(  OPJ_UINT32 tileno,
+                                opj_tcd_tile_t * tile,
+                                opj_tcp_t * tcp,
+                                opj_pi_iterator_t *pi,
+                                OPJ_BYTE *dest,
+                                OPJ_UINT32 * p_data_written,
+                                OPJ_UINT32 length,
+                                opj_codestream_info_t *cstr_info)
+{
+        OPJ_UINT32 bandno, cblkno;
+        OPJ_BYTE* c = dest;
+        OPJ_UINT32 l_nb_bytes;
+        OPJ_UINT32 compno = pi->compno;     /* component value */
+        OPJ_UINT32 resno  = pi->resno;      /* resolution level value */
+        OPJ_UINT32 precno = pi->precno;     /* precinct value */
+        OPJ_UINT32 layno  = pi->layno;      /* quality layer value */
+        OPJ_UINT32 l_nb_blocks;
+        opj_tcd_band_t *band = 00;
+        opj_tcd_cblk_enc_t* cblk = 00;
+        opj_tcd_pass_t *pass = 00;
+
+        opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
+        opj_tcd_resolution_t *res = &tilec->resolutions[resno];
+
+        opj_bio_t *bio = 00;    /* BIO component */
+
+        /* <SOP 0xff91> */
+        if (tcp->csty & J2K_CP_CSTY_SOP) {
+                c[0] = 255;
+                c[1] = 145;
+                c[2] = 0;
+                c[3] = 4;
+#if 0
+                c[4] = (tile->packno % 65536) / 256;
+                c[5] = (tile->packno % 65536) % 256;
+#else
+                c[4] = (tile->packno >> 8) & 0xff; /* packno is uint32_t */
+                c[5] = tile->packno & 0xff;
+#endif
+                c += 6;
+                length -= 6;
+        }
+        /* </SOP> */
+
+        if (!layno) {
+                band = res->bands;
+
+                for(bandno = 0; bandno < res->numbands; ++bandno) {
+                        opj_tcd_precinct_t *prc = &band->precincts[precno];
+
+                        opj_tgt_reset(prc->incltree);
+                        opj_tgt_reset(prc->imsbtree);
+
+                        l_nb_blocks = prc->cw * prc->ch;
+                        for     (cblkno = 0; cblkno < l_nb_blocks; ++cblkno) {
+                                cblk = &prc->cblks.enc[cblkno];
+
+                                cblk->numpasses = 0;
+                                opj_tgt_setvalue(prc->imsbtree, cblkno, band->numbps - (OPJ_INT32)cblk->numbps);
+                        }
+                        ++band;
+                }
+        }
+
+        bio = opj_bio_create();
+        if (!bio) {
+                /* FIXME event manager error callback */
+                return OPJ_FALSE;
+        }
+        opj_bio_init_enc(bio, c, length);
+        opj_bio_write(bio, 1, 1);           /* Empty header bit */
+
+        /* Writing Packet header */
+        band = res->bands;
+        for (bandno = 0; bandno < res->numbands; ++bandno)      {
+                opj_tcd_precinct_t *prc = &band->precincts[precno];
+
+                l_nb_blocks = prc->cw * prc->ch;
+                cblk = prc->cblks.enc;
+
+                for (cblkno = 0; cblkno < l_nb_blocks; ++cblkno) {
+                        opj_tcd_layer_t *layer = &cblk->layers[layno];
+
+                        if (!cblk->numpasses && layer->numpasses) {
+                                opj_tgt_setvalue(prc->incltree, cblkno, (OPJ_INT32)layno);
+                        }
+
+                        ++cblk;
+                }
+
+                cblk = prc->cblks.enc;
+                for (cblkno = 0; cblkno < l_nb_blocks; cblkno++) {
+                        opj_tcd_layer_t *layer = &cblk->layers[layno];
+                        OPJ_UINT32 increment = 0;
+                        OPJ_UINT32 nump = 0;
+                        OPJ_UINT32 len = 0, passno;
+                        OPJ_UINT32 l_nb_passes;
+
+                        /* cblk inclusion bits */
+                        if (!cblk->numpasses) {
+                                opj_tgt_encode(bio, prc->incltree, cblkno, (OPJ_INT32)(layno + 1));
+                        } else {
+                                opj_bio_write(bio, layer->numpasses != 0, 1);
+                        }
+
+                        /* if cblk not included, go to the next cblk  */
+                        if (!layer->numpasses) {
+                                ++cblk;
+                                continue;
+                        }
+
+                        /* if first instance of cblk --> zero bit-planes information */
+                        if (!cblk->numpasses) {
+                                cblk->numlenbits = 3;
+                                opj_tgt_encode(bio, prc->imsbtree, cblkno, 999);
+                        }
+
+                        /* number of coding passes included */
+                        opj_t2_putnumpasses(bio, layer->numpasses);
+                        l_nb_passes = cblk->numpasses + layer->numpasses;
+                        pass = cblk->passes +  cblk->numpasses;
+
+                        /* computation of the increase of the length indicator and insertion in the header     */
+                        for (passno = cblk->numpasses; passno < l_nb_passes; ++passno) {
+                                ++nump;
+                                len += pass->len;
+
+                                if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
+                                  increment = (OPJ_UINT32)opj_int_max((OPJ_INT32)increment, opj_int_floorlog2((OPJ_INT32)len) + 1
+                                    - ((OPJ_INT32)cblk->numlenbits + opj_int_floorlog2((OPJ_INT32)nump)));
+                                        len = 0;
+                                        nump = 0;
+                                }
+
+                                ++pass;
+                        }
+                        opj_t2_putcommacode(bio, (OPJ_INT32)increment);
+
+                        /* computation of the new Length indicator */
+                        cblk->numlenbits += increment;
+
+                        pass = cblk->passes +  cblk->numpasses;
+                        /* insertion of the codeword segment length */
+                        for (passno = cblk->numpasses; passno < l_nb_passes; ++passno) {
+                                nump++;
+                                len += pass->len;
+
+                                if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
+                                        opj_bio_write(bio, (OPJ_UINT32)len, cblk->numlenbits + (OPJ_UINT32)opj_int_floorlog2((OPJ_INT32)nump));
+                                        len = 0;
+                                        nump = 0;
+                                }
+                                ++pass;
+                        }
+
+                        ++cblk;
+                }
+
+                ++band;
+        }
+
+        if (!opj_bio_flush(bio)) {
+                opj_bio_destroy(bio);
+                return OPJ_FALSE;               /* modified to eliminate longjmp !! */
+        }
+
+        l_nb_bytes = (OPJ_UINT32)opj_bio_numbytes(bio);
+        c += l_nb_bytes;
+        length -= l_nb_bytes;
+
+        opj_bio_destroy(bio);
+
+        /* <EPH 0xff92> */
+        if (tcp->csty & J2K_CP_CSTY_EPH) {
+                c[0] = 255;
+                c[1] = 146;
+                c += 2;
+                length -= 2;
+        }
+        /* </EPH> */
+
+        /* << INDEX */
+        /* End of packet header position. Currently only represents the distance to start of packet
+           Will be updated later by incrementing with packet start value*/
+        if(cstr_info && cstr_info->index_write) {
+                opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
+                info_PK->end_ph_pos = (OPJ_INT32)(c - dest);
+        }
+        /* INDEX >> */
+
+        /* Writing the packet body */
+        band = res->bands;
+        for (bandno = 0; bandno < res->numbands; bandno++) {
+                opj_tcd_precinct_t *prc = &band->precincts[precno];
+
+                l_nb_blocks = prc->cw * prc->ch;
+                cblk = prc->cblks.enc;
+
+                for (cblkno = 0; cblkno < l_nb_blocks; ++cblkno) {
+                        opj_tcd_layer_t *layer = &cblk->layers[layno];
+
+                        if (!layer->numpasses) {
+                                ++cblk;
+                                continue;
+                        }
+
+                        if (layer->len > length) {
+                                return OPJ_FALSE;
+                        }
+
+                        memcpy(c, layer->data, layer->len);
+                        cblk->numpasses += layer->numpasses;
+                        c += layer->len;
+                        length -= layer->len;
+
+                        /* << INDEX */
+                        if(cstr_info && cstr_info->index_write) {
+                                opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
+                                info_PK->disto += layer->disto;
+                                if (cstr_info->D_max < info_PK->disto) {
+                                        cstr_info->D_max = info_PK->disto;
+                                }
+                        }
+
+                        ++cblk;
+                        /* INDEX >> */
+                }
+                ++band;
+        }
+
+        assert( c >= dest );
+        * p_data_written += (OPJ_UINT32)(c - dest);
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_t2_skip_packet( opj_t2_t* p_t2,
+                                    opj_tcd_tile_t *p_tile,
+                                    opj_tcp_t *p_tcp,
+                                    opj_pi_iterator_t *p_pi,
+                                    OPJ_BYTE *p_src,
+                                    OPJ_UINT32 * p_data_read,
+                                    OPJ_UINT32 p_max_length,
+                                    opj_packet_info_t *p_pack_info,
+                                    opj_event_mgr_t *p_manager)
+{
+        OPJ_BOOL l_read_data;
+        OPJ_UINT32 l_nb_bytes_read = 0;
+        OPJ_UINT32 l_nb_total_bytes_read = 0;
+
+        *p_data_read = 0;
+
+        if (! opj_t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
+                return OPJ_FALSE;
+        }
+
+        p_src += l_nb_bytes_read;
+        l_nb_total_bytes_read += l_nb_bytes_read;
+        p_max_length -= l_nb_bytes_read;
+
+        /* we should read data for the packet */
+        if (l_read_data) {
+                l_nb_bytes_read = 0;
+
+                if (! opj_t2_skip_packet_data(p_t2,p_tile,p_pi,&l_nb_bytes_read,p_max_length,p_pack_info, p_manager)) {
+                        return OPJ_FALSE;
+                }
+
+                l_nb_total_bytes_read += l_nb_bytes_read;
+        }
+        *p_data_read = l_nb_total_bytes_read;
+
+        return OPJ_TRUE;
+}
+
+
+static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
+                                    opj_tcd_tile_t *p_tile,
+                                    opj_tcp_t *p_tcp,
+                                    opj_pi_iterator_t *p_pi,
+                                    OPJ_BOOL * p_is_data_present,
+                                    OPJ_BYTE *p_src_data,
+                                    OPJ_UINT32 * p_data_read,
+                                    OPJ_UINT32 p_max_length,
+                                    opj_packet_info_t *p_pack_info,
+                                    opj_event_mgr_t *p_manager)
+
+{
+        /* loop */
+        OPJ_UINT32 bandno, cblkno;
+        OPJ_UINT32 l_nb_code_blocks;
+        OPJ_UINT32 l_remaining_length;
+        OPJ_UINT32 l_header_length;
+        OPJ_UINT32 * l_modified_length_ptr = 00;
+        OPJ_BYTE *l_current_data = p_src_data;
+        opj_cp_t *l_cp = p_t2->cp;
+        opj_bio_t *l_bio = 00;  /* BIO component */
+        opj_tcd_band_t *l_band = 00;
+        opj_tcd_cblk_dec_t* l_cblk = 00;
+        opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
+
+        OPJ_BYTE *l_header_data = 00;
+        OPJ_BYTE **l_header_data_start = 00;
+
+        OPJ_UINT32 l_present;
+
+        if (p_pi->layno == 0) {
+                l_band = l_res->bands;
+
+                /* reset tagtrees */
+                for (bandno = 0; bandno < l_res->numbands; ++bandno) {
+                        if ( ! ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) ) {
+                                opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
+                                if (!(p_pi->precno < (l_band->precincts_data_size / sizeof(opj_tcd_precinct_t)))) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "Invalid precinct\n");
+                                        return OPJ_FALSE;
+                                }
+													
+													
+                                opj_tgt_reset(l_prc->incltree);
+                                opj_tgt_reset(l_prc->imsbtree);
+                                l_cblk = l_prc->cblks.dec;
+
+                                l_nb_code_blocks = l_prc->cw * l_prc->ch;
+                                for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
+                                        l_cblk->numsegs = 0;
+                                        l_cblk->real_num_segs = 0;
+                                        ++l_cblk;
+                                }
+                        }
+
+                        ++l_band;
+                }
+        }
+
+        /* SOP markers */
+
+        if (p_tcp->csty & J2K_CP_CSTY_SOP) {
+                if (p_max_length < 6) {
+												opj_event_msg(p_manager, EVT_WARNING, "Not enough space for expected SOP marker\n");
+                } else if ((*l_current_data) != 0xff || (*(l_current_data + 1) != 0x91)) {
+                        opj_event_msg(p_manager, EVT_WARNING, "Expected SOP marker\n");
+                } else {
+                        l_current_data += 6;
+                }
+
+                /** TODO : check the Nsop value */
+        }
+
+        /*
+        When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
+        This part deal with this caracteristic
+        step 1: Read packet header in the saved structure
+        step 2: Return to codestream for decoding
+        */
+
+        l_bio = opj_bio_create();
+        if (! l_bio) {
+                return OPJ_FALSE;
+        }
+
+        if (l_cp->ppm == 1) { /* PPM */
+                l_header_data_start = &l_cp->ppm_data;
+                l_header_data = *l_header_data_start;
+                l_modified_length_ptr = &(l_cp->ppm_len);
+
+        }
+        else if (p_tcp->ppt == 1) { /* PPT */
+                l_header_data_start = &(p_tcp->ppt_data);
+                l_header_data = *l_header_data_start;
+                l_modified_length_ptr = &(p_tcp->ppt_len);
+        }
+        else {  /* Normal Case */
+                l_header_data_start = &(l_current_data);
+                l_header_data = *l_header_data_start;
+                l_remaining_length = (OPJ_UINT32)(p_src_data+p_max_length-l_header_data);
+                l_modified_length_ptr = &(l_remaining_length);
+        }
+
+        opj_bio_init_dec(l_bio, l_header_data,*l_modified_length_ptr);
+
+        l_present = opj_bio_read(l_bio, 1);
+        JAS_FPRINTF(stderr, "present=%d \n", l_present );
+        if (!l_present) {
+            /* TODO MSD: no test to control the output of this function*/
+                opj_bio_inalign(l_bio);
+                l_header_data += opj_bio_numbytes(l_bio);
+                opj_bio_destroy(l_bio);
+
+                /* EPH markers */
+                if (p_tcp->csty & J2K_CP_CSTY_EPH) {
+                        if ((*l_modified_length_ptr - (OPJ_UINT32)(l_header_data - *l_header_data_start)) < 2U) {
+                                opj_event_msg(p_manager, EVT_WARNING, "Not enough space for expected EPH marker\n");
+                        } else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
+                                opj_event_msg(p_manager, EVT_WARNING, "Expected EPH marker\n");
+                        } else {
+                                l_header_data += 2;
+                        }
+                }
+
+                l_header_length = (OPJ_UINT32)(l_header_data - *l_header_data_start);
+                *l_modified_length_ptr -= l_header_length;
+                *l_header_data_start += l_header_length;
+
+                /* << INDEX */
+                /* End of packet header position. Currently only represents the distance to start of packet
+                   Will be updated later by incrementing with packet start value */
+                if (p_pack_info) {
+                        p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
+                }
+                /* INDEX >> */
+
+                * p_is_data_present = OPJ_FALSE;
+                *p_data_read = (OPJ_UINT32)(l_current_data - p_src_data);
+                return OPJ_TRUE;
+        }
+
+        l_band = l_res->bands;
+        for (bandno = 0; bandno < l_res->numbands; ++bandno) {
+                opj_tcd_precinct_t *l_prc = &(l_band->precincts[p_pi->precno]);
+
+                if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) {
+                        ++l_band;
+                        continue;
+                }
+
+                l_nb_code_blocks = l_prc->cw * l_prc->ch;
+                l_cblk = l_prc->cblks.dec;
+                for (cblkno = 0; cblkno < l_nb_code_blocks; cblkno++) {
+                        OPJ_UINT32 l_included,l_increment, l_segno;
+                        OPJ_INT32 n;
+
+                        /* if cblk not yet included before --> inclusion tagtree */
+                        if (!l_cblk->numsegs) {
+                                l_included = opj_tgt_decode(l_bio, l_prc->incltree, cblkno, (OPJ_INT32)(p_pi->layno + 1));
+                                /* else one bit */
+                        }
+                        else {
+                                l_included = opj_bio_read(l_bio, 1);
+                        }
+
+                        /* if cblk not included */
+                        if (!l_included) {
+                                l_cblk->numnewpasses = 0;
+                                ++l_cblk;
+                                JAS_FPRINTF(stderr, "included=%d \n", l_included);
+                                continue;
+                        }
+
+                        /* if cblk not yet included --> zero-bitplane tagtree */
+                        if (!l_cblk->numsegs) {
+                                OPJ_UINT32 i = 0;
+
+                                while (!opj_tgt_decode(l_bio, l_prc->imsbtree, cblkno, (OPJ_INT32)i)) {
+                                        ++i;
+                                }
+
+                                l_cblk->numbps = (OPJ_UINT32)l_band->numbps + 1 - i;
+                                l_cblk->numlenbits = 3;
+                        }
+
+                        /* number of coding passes */
+                        l_cblk->numnewpasses = opj_t2_getnumpasses(l_bio);
+                        l_increment = opj_t2_getcommacode(l_bio);
+
+                        /* length indicator increment */
+                        l_cblk->numlenbits += l_increment;
+                        l_segno = 0;
+
+                        if (!l_cblk->numsegs) {
+                                if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 1)) {
+                                        opj_bio_destroy(l_bio);
+                                        return OPJ_FALSE;
+                                }
+                        }
+                        else {
+                                l_segno = l_cblk->numsegs - 1;
+                                if (l_cblk->segs[l_segno].numpasses == l_cblk->segs[l_segno].maxpasses) {
+                                        ++l_segno;
+                                        if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
+                                                opj_bio_destroy(l_bio);
+                                                return OPJ_FALSE;
+                                        }
+                                }
+                        }
+                        n = (OPJ_INT32)l_cblk->numnewpasses;
+
+                        do {
+                                l_cblk->segs[l_segno].numnewpasses = (OPJ_UINT32)opj_int_min((OPJ_INT32)(l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses), n);
+                                l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, l_cblk->numlenbits + opj_uint_floorlog2(l_cblk->segs[l_segno].numnewpasses));
+                                        JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n", l_included, l_cblk->segs[l_segno].numnewpasses, l_increment, l_cblk->segs[l_segno].newlen );
+
+                                n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
+                                if (n > 0) {
+                                        ++l_segno;
+
+                                        if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
+                                                opj_bio_destroy(l_bio);
+                                                return OPJ_FALSE;
+                                        }
+                                }
+                        } while (n > 0);
+
+                        ++l_cblk;
+                }
+
+                ++l_band;
+        }
+
+        if (!opj_bio_inalign(l_bio)) {
+                opj_bio_destroy(l_bio);
+                return OPJ_FALSE;
+        }
+
+        l_header_data += opj_bio_numbytes(l_bio);
+        opj_bio_destroy(l_bio);
+
+        /* EPH markers */
+        if (p_tcp->csty & J2K_CP_CSTY_EPH) {
+                if ((*l_modified_length_ptr - (OPJ_UINT32)(l_header_data - *l_header_data_start)) < 2U) {
+                        opj_event_msg(p_manager, EVT_WARNING, "Not enough space for expected EPH marker\n");
+                } else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
+                        opj_event_msg(p_manager, EVT_WARNING, "Expected EPH marker\n");
+                } else {
+                        l_header_data += 2;
+                }
+        }
+
+        l_header_length = (OPJ_UINT32)(l_header_data - *l_header_data_start);
+        JAS_FPRINTF( stderr, "hdrlen=%d \n", l_header_length );
+        JAS_FPRINTF( stderr, "packet body\n");
+        *l_modified_length_ptr -= l_header_length;
+        *l_header_data_start += l_header_length;
+
+        /* << INDEX */
+        /* End of packet header position. Currently only represents the distance to start of packet
+         Will be updated later by incrementing with packet start value */
+        if (p_pack_info) {
+                p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
+        }
+        /* INDEX >> */
+
+        *p_is_data_present = OPJ_TRUE;
+        *p_data_read = (OPJ_UINT32)(l_current_data - p_src_data);
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_t2_read_packet_data(   opj_t2_t* p_t2,
+                                    opj_tcd_tile_t *p_tile,
+                                    opj_pi_iterator_t *p_pi,
+                                    OPJ_BYTE *p_src_data,
+                                    OPJ_UINT32 * p_data_read,
+                                    OPJ_UINT32 p_max_length,
+                                    opj_packet_info_t *pack_info,
+                                    opj_event_mgr_t* p_manager)
+{
+        OPJ_UINT32 bandno, cblkno;
+        OPJ_UINT32 l_nb_code_blocks;
+        OPJ_BYTE *l_current_data = p_src_data;
+        opj_tcd_band_t *l_band = 00;
+        opj_tcd_cblk_dec_t* l_cblk = 00;
+        opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
+
+        OPJ_ARG_NOT_USED(p_t2);
+        OPJ_ARG_NOT_USED(pack_info);
+
+        l_band = l_res->bands;
+        for (bandno = 0; bandno < l_res->numbands; ++bandno) {
+                opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
+
+                if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) {
+                        ++l_band;
+                        continue;
+                }
+
+                l_nb_code_blocks = l_prc->cw * l_prc->ch;
+                l_cblk = l_prc->cblks.dec;
+
+                for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
+                        opj_tcd_seg_t *l_seg = 00;
+
+                        if (!l_cblk->numnewpasses) {
+                                /* nothing to do */
+                                ++l_cblk;
+                                continue;
+                        }
+
+                        if (!l_cblk->numsegs) {
+                                l_seg = l_cblk->segs;
+                                ++l_cblk->numsegs;
+                                l_cblk->data_current_size = 0;
+                        }
+                        else {
+                                l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
+
+                                if (l_seg->numpasses == l_seg->maxpasses) {
+                                        ++l_seg;
+                                        ++l_cblk->numsegs;
+                                }
+                        }
+
+                        do {
+                                /* Check possible overflow (on l_current_data only, assumes input args already checked) then size */
+                                if ((((OPJ_SIZE_T)l_current_data + (OPJ_SIZE_T)l_seg->newlen) < (OPJ_SIZE_T)l_current_data) || (l_current_data + l_seg->newlen > p_src_data + p_max_length)) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+																								l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
+                                        return OPJ_FALSE;
+                                }
+
+#ifdef USE_JPWL
+                        /* we need here a j2k handle to verify if making a check to
+                        the validity of cblocks parameters is selected from user (-W) */
+
+                                /* let's check that we are not exceeding */
+                                if ((l_cblk->len + l_seg->newlen) > 8192) {
+                                        opj_event_msg(p_manager, EVT_WARNING,
+                                                "JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+                                                l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
+                                        if (!JPWL_ASSUME) {
+                                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                                return OPJ_FALSE;
+                                        }
+                                        l_seg->newlen = 8192 - l_cblk->len;
+                                        opj_event_msg(p_manager, EVT_WARNING, "      - truncating segment to %d\n", l_seg->newlen);
+                                        break;
+                                };
+
+#endif /* USE_JPWL */
+                                /* Check possible overflow on size */
+                                if ((l_cblk->data_current_size + l_seg->newlen) < l_cblk->data_current_size) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "read: segment too long (%d) with current size (%d > %d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+                                                l_seg->newlen, l_cblk->data_current_size, 0xFFFFFFFF - l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
+                                        return OPJ_FALSE;
+                                }
+                                /* Check if the cblk->data have allocated enough memory */
+                                if ((l_cblk->data_current_size + l_seg->newlen) > l_cblk->data_max_size) {
+                                    OPJ_BYTE* new_cblk_data = (OPJ_BYTE*) opj_realloc(l_cblk->data, l_cblk->data_current_size + l_seg->newlen);
+                                    if(! new_cblk_data) {
+                                        opj_free(l_cblk->data);
+                                        l_cblk->data = NULL;
+                                        l_cblk->data_max_size = 0;
+                                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to realloc code block cata!\n"); */
+                                        return OPJ_FALSE;
+                                    }
+                                    l_cblk->data_max_size = l_cblk->data_current_size + l_seg->newlen;
+                                    l_cblk->data = new_cblk_data;
+                                }
+                               
+                                memcpy(l_cblk->data + l_cblk->data_current_size, l_current_data, l_seg->newlen);
+
+                                if (l_seg->numpasses == 0) {
+                                        l_seg->data = &l_cblk->data;
+                                        l_seg->dataindex = l_cblk->data_current_size;
+                                }
+
+                                l_current_data += l_seg->newlen;
+                                l_seg->numpasses += l_seg->numnewpasses;
+                                l_cblk->numnewpasses -= l_seg->numnewpasses;
+
+                                l_seg->real_num_passes = l_seg->numpasses;
+                                l_cblk->data_current_size += l_seg->newlen;
+                                l_seg->len += l_seg->newlen;
+
+                                if (l_cblk->numnewpasses > 0) {
+                                        ++l_seg;
+                                        ++l_cblk->numsegs;
+                                }
+                        } while (l_cblk->numnewpasses > 0);
+
+                        l_cblk->real_num_segs = l_cblk->numsegs;
+                        ++l_cblk;
+                } /* next code_block */
+
+                ++l_band;
+        }
+
+        *(p_data_read) = (OPJ_UINT32)(l_current_data - p_src_data);
+
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_t2_skip_packet_data(   opj_t2_t* p_t2,
+                                    opj_tcd_tile_t *p_tile,
+                                    opj_pi_iterator_t *p_pi,
+                                    OPJ_UINT32 * p_data_read,
+                                    OPJ_UINT32 p_max_length,
+                                    opj_packet_info_t *pack_info,
+                                    opj_event_mgr_t *p_manager)
+{
+        OPJ_UINT32 bandno, cblkno;
+        OPJ_UINT32 l_nb_code_blocks;
+        opj_tcd_band_t *l_band = 00;
+        opj_tcd_cblk_dec_t* l_cblk = 00;
+        opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
+
+        OPJ_ARG_NOT_USED(p_t2);
+        OPJ_ARG_NOT_USED(pack_info);
+
+        *p_data_read = 0;
+        l_band = l_res->bands;
+
+        for (bandno = 0; bandno < l_res->numbands; ++bandno) {
+                opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
+
+                if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) {
+                        ++l_band;
+                        continue;
+                }
+
+                l_nb_code_blocks = l_prc->cw * l_prc->ch;
+                l_cblk = l_prc->cblks.dec;
+
+                for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
+                        opj_tcd_seg_t *l_seg = 00;
+
+                        if (!l_cblk->numnewpasses) {
+                                /* nothing to do */
+                                ++l_cblk;
+                                continue;
+                        }
+
+                        if (!l_cblk->numsegs) {
+                                l_seg = l_cblk->segs;
+                                ++l_cblk->numsegs;
+                                l_cblk->data_current_size = 0;
+                        }
+                        else {
+                                l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
+
+                                if (l_seg->numpasses == l_seg->maxpasses) {
+                                        ++l_seg;
+                                        ++l_cblk->numsegs;
+                                }
+                        }
+
+                        do {
+                                /* Check possible overflow then size */
+                                if (((*p_data_read + l_seg->newlen) < (*p_data_read)) || ((*p_data_read + l_seg->newlen) > p_max_length)) {
+                                        opj_event_msg(p_manager, EVT_ERROR, "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+                                                l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
+                                        return OPJ_FALSE;
+                                }
+
+#ifdef USE_JPWL
+                        /* we need here a j2k handle to verify if making a check to
+                        the validity of cblocks parameters is selected from user (-W) */
+
+                                /* let's check that we are not exceeding */
+                                if ((l_cblk->len + l_seg->newlen) > 8192) {
+                                        opj_event_msg(p_manager, EVT_WARNING,
+                                                "JPWL: segment too long (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+                                                l_seg->newlen, cblkno, p_pi->precno, bandno, p_pi->resno, p_pi->compno);
+                                        if (!JPWL_ASSUME) {
+                                                opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
+                                                return -999;
+                                        }
+                                        l_seg->newlen = 8192 - l_cblk->len;
+                                        opj_event_msg(p_manager, EVT_WARNING, "      - truncating segment to %d\n", l_seg->newlen);
+                                        break;
+                                };
+
+#endif /* USE_JPWL */
+                                        JAS_FPRINTF(stderr, "p_data_read (%d) newlen (%d) \n", *p_data_read, l_seg->newlen );
+                                *(p_data_read) += l_seg->newlen;
+
+                                l_seg->numpasses += l_seg->numnewpasses;
+                                l_cblk->numnewpasses -= l_seg->numnewpasses;
+                                if (l_cblk->numnewpasses > 0)
+                                {
+                                        ++l_seg;
+                                        ++l_cblk->numsegs;
+                                }
+                        } while (l_cblk->numnewpasses > 0);
+
+                        ++l_cblk;
+                }
+
+                ++l_band;
+        }
+
+        return OPJ_TRUE;
+}
+
+
+static OPJ_BOOL opj_t2_init_seg(   opj_tcd_cblk_dec_t* cblk,
+                            OPJ_UINT32 index, 
+                            OPJ_UINT32 cblksty, 
+                            OPJ_UINT32 first)
+{
+        opj_tcd_seg_t* seg = 00;
+        OPJ_UINT32 l_nb_segs = index + 1;
+
+        if (l_nb_segs > cblk->m_current_max_segs) {
+                opj_tcd_seg_t* new_segs;
+                cblk->m_current_max_segs += OPJ_J2K_DEFAULT_NB_SEGS;
+
+                new_segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, cblk->m_current_max_segs * sizeof(opj_tcd_seg_t));
+                if(! new_segs) {
+                        opj_free(cblk->segs);
+                        cblk->segs = NULL;
+                        cblk->m_current_max_segs = 0;
+                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to initialize segment %d\n", l_nb_segs); */
+                        return OPJ_FALSE;
+                }
+                cblk->segs = new_segs;
+        }
+
+        seg = &cblk->segs[index];
+        memset(seg,0,sizeof(opj_tcd_seg_t));
+
+        if (cblksty & J2K_CCP_CBLKSTY_TERMALL) {
+                seg->maxpasses = 1;
+        }
+        else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
+                if (first) {
+                        seg->maxpasses = 10;
+                } else {
+                        seg->maxpasses = (((seg - 1)->maxpasses == 1) || ((seg - 1)->maxpasses == 10)) ? 2 : 1;
+                }
+        } else {
+                seg->maxpasses = 109;
+        }
+
+        return OPJ_TRUE;
+}
diff --git a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t2.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/t2.h
similarity index 50%
rename from Utilities/gdcmopenjpeg-v1/libopenjpeg/t2.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/t2.h
index 2151ba6..3b652ee 100644
--- a/Utilities/gdcmopenjpeg-v1/libopenjpeg/t2.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/t2.h
@@ -1,10 +1,18 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,8 +51,6 @@
 Tier-2 coding
 */
 typedef struct opj_t2 {
-	/** codec context */
-	opj_common_ptr cinfo;
 
 	/** Encoding: pointer to the src image. Decoding: pointer to the dst image. */
 	opj_image_t *image;
@@ -58,44 +64,67 @@ typedef struct opj_t2 {
 
 /**
 Encode the packets of a tile to a destination buffer
- at param t2 T2 handle
- at param tileno number of the tile encoded
- at param tile the tile for which to write the packets
- at param maxlayers maximum number of layers
- at param dest the destination buffer
- at param len the length of the destination buffer
- at param cstr_info Codestream information structure 
- at param tpnum Tile part number of the current tile
- at param tppos The position of the tile part flag in the progression order
- at param pino 
- at param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
- at param cur_totnum_tp The total number of tile parts in the current tile
+ at param t2               T2 handle
+ at param tileno           number of the tile encoded
+ at param tile             the tile for which to write the packets
+ at param maxlayers        maximum number of layers
+ at param dest             the destination buffer
+ at param p_data_written   FIXME DOC
+ at param len              the length of the destination buffer
+ at param cstr_info        Codestream information structure
+ at param tpnum            Tile part number of the current tile
+ at param tppos            The position of the tile part flag in the progression order
+ at param pino             FIXME DOC
+ at param t2_mode          If == 0 In Threshold calculation ,If == 1 Final pass
 */
-int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_codestream_info_t *cstr_info,int tpnum, int tppos,int pino,J2K_T2_MODE t2_mode,int cur_totnum_tp);
+OPJ_BOOL opj_t2_encode_packets(	opj_t2_t* t2,
+								OPJ_UINT32 tileno,
+								opj_tcd_tile_t *tile,
+								OPJ_UINT32 maxlayers,
+								OPJ_BYTE *dest,
+								OPJ_UINT32 * p_data_written,
+								OPJ_UINT32 len,
+								opj_codestream_info_t *cstr_info,
+								OPJ_UINT32 tpnum,
+								OPJ_INT32 tppos,
+								OPJ_UINT32 pino,
+								J2K_T2_MODE t2_mode);
+
 /**
 Decode the packets of a tile from a source buffer
 @param t2 T2 handle
- at param src the source buffer
- at param len length of the source buffer
 @param tileno number that identifies the tile for which to decode the packets
 @param tile tile for which to decode the packets
- at param cstr_info Codestream information structure
+ at param src         FIXME DOC
+ at param p_data_read the source buffer
+ at param len length of the source buffer
+ at param cstr_info   FIXME DOC
+
+ at return FIXME DOC
  */
-int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile, opj_codestream_info_t *cstr_info);
+OPJ_BOOL opj_t2_decode_packets(	opj_t2_t *t2,
+                                OPJ_UINT32 tileno,
+                                opj_tcd_tile_t *tile,
+                                OPJ_BYTE *src,
+                                OPJ_UINT32 * p_data_read,
+                                OPJ_UINT32 len,
+                                opj_codestream_index_t *cstr_info,
+                                opj_event_mgr_t *p_manager);
 
 /**
-Create a T2 handle
- at param cinfo Codec context info
- at param image Source or destination image
- at param cp Image coding parameters
- at return Returns a new T2 handle if successful, returns NULL otherwise
+ * Creates a Tier 2 handle
+ *
+ * @param	p_image		Source or destination image
+ * @param	p_cp		Image coding parameters.
+ * @return		a new T2 handle if successful, NULL otherwise.
 */
-opj_t2_t* t2_create(opj_common_ptr cinfo, opj_image_t *image, opj_cp_t *cp);
+opj_t2_t* opj_t2_create(opj_image_t *p_image, opj_cp_t *p_cp);
+
 /**
 Destroy a T2 handle
 @param t2 T2 handle to destroy
 */
-void t2_destroy(opj_t2_t *t2);
+void opj_t2_destroy(opj_t2_t *t2);
 
 /* ----------------------------------------------------------------------- */
 /*@}*/
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.c
new file mode 100644
index 0000000..b8cd307
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.c
@@ -0,0 +1,2194 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2006-2007, Parvatha Elangovan
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/* ----------------------------------------------------------------------- */
+
+/* TODO MSD: */
+#ifdef TODO_MSD 
+void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
+        int tileno, compno, resno, bandno, precno;/*, cblkno;*/
+
+        fprintf(fd, "image {\n");
+        fprintf(fd, "  tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", 
+                img->tw, img->th, tcd->image->x0, tcd->image->x1, tcd->image->y0, tcd->image->y1);
+
+        for (tileno = 0; tileno < img->th * img->tw; tileno++) {
+                opj_tcd_tile_t *tile = &tcd->tcd_image->tiles[tileno];
+                fprintf(fd, "  tile {\n");
+                fprintf(fd, "    x0=%d, y0=%d, x1=%d, y1=%d, numcomps=%d\n",
+                        tile->x0, tile->y0, tile->x1, tile->y1, tile->numcomps);
+                for (compno = 0; compno < tile->numcomps; compno++) {
+                        opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
+                        fprintf(fd, "    tilec {\n");
+                        fprintf(fd,
+                                "      x0=%d, y0=%d, x1=%d, y1=%d, numresolutions=%d\n",
+                                tilec->x0, tilec->y0, tilec->x1, tilec->y1, tilec->numresolutions);
+                        for (resno = 0; resno < tilec->numresolutions; resno++) {
+                                opj_tcd_resolution_t *res = &tilec->resolutions[resno];
+                                fprintf(fd, "\n   res {\n");
+                                fprintf(fd,
+                                        "          x0=%d, y0=%d, x1=%d, y1=%d, pw=%d, ph=%d, numbands=%d\n",
+                                        res->x0, res->y0, res->x1, res->y1, res->pw, res->ph, res->numbands);
+                                for (bandno = 0; bandno < res->numbands; bandno++) {
+                                        opj_tcd_band_t *band = &res->bands[bandno];
+                                        fprintf(fd, "        band {\n");
+                                        fprintf(fd,
+                                                "          x0=%d, y0=%d, x1=%d, y1=%d, stepsize=%f, numbps=%d\n",
+                                                band->x0, band->y0, band->x1, band->y1, band->stepsize, band->numbps);
+                                        for (precno = 0; precno < res->pw * res->ph; precno++) {
+                                                opj_tcd_precinct_t *prec = &band->precincts[precno];
+                                                fprintf(fd, "          prec {\n");
+                                                fprintf(fd,
+                                                        "            x0=%d, y0=%d, x1=%d, y1=%d, cw=%d, ch=%d\n",
+                                                        prec->x0, prec->y0, prec->x1, prec->y1, prec->cw, prec->ch);
+                                                /*
+                                                for (cblkno = 0; cblkno < prec->cw * prec->ch; cblkno++) {
+                                                        opj_tcd_cblk_t *cblk = &prec->cblks[cblkno];
+                                                        fprintf(fd, "            cblk {\n");
+                                                        fprintf(fd,
+                                                                "              x0=%d, y0=%d, x1=%d, y1=%d\n",
+                                                                cblk->x0, cblk->y0, cblk->x1, cblk->y1);
+                                                        fprintf(fd, "            }\n");
+                                                }
+                                                */
+                                                fprintf(fd, "          }\n");
+                                        }
+                                        fprintf(fd, "        }\n");
+                                }
+                                fprintf(fd, "      }\n");
+                        }
+                        fprintf(fd, "    }\n");
+                }
+                fprintf(fd, "  }\n");
+        }
+        fprintf(fd, "}\n");
+}
+#endif
+
+/**
+ * Initializes tile coding/decoding
+ */
+static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block, opj_event_mgr_t* manager);
+
+/**
+* Allocates memory for a decoding code block.
+*/
+static OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block);
+
+/**
+ * Deallocates the decoding data of the given precinct.
+ */
+static void opj_tcd_code_block_dec_deallocate (opj_tcd_precinct_t * p_precinct);
+
+/**
+ * Allocates memory for an encoding code block (but not data).
+ */
+static OPJ_BOOL opj_tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_block);
+
+/**
+ * Allocates data for an encoding code block
+ */
+static OPJ_BOOL opj_tcd_code_block_enc_allocate_data (opj_tcd_cblk_enc_t * p_code_block);
+
+/**
+ * Deallocates the encoding data of the given precinct.
+ */
+static void opj_tcd_code_block_enc_deallocate (opj_tcd_precinct_t * p_precinct);
+
+
+/**
+Free the memory allocated for encoding
+ at param tcd TCD handle
+*/
+static void opj_tcd_free_tile(opj_tcd_t *tcd);
+
+
+static OPJ_BOOL opj_tcd_t2_decode ( opj_tcd_t *p_tcd,
+                                    OPJ_BYTE * p_src_data,
+                                    OPJ_UINT32 * p_data_read,
+                                    OPJ_UINT32 p_max_src_size,
+                                    opj_codestream_index_t *p_cstr_index,
+                                    opj_event_mgr_t *p_manager);
+
+static OPJ_BOOL opj_tcd_t1_decode (opj_tcd_t *p_tcd);
+
+static OPJ_BOOL opj_tcd_dwt_decode (opj_tcd_t *p_tcd);
+
+static OPJ_BOOL opj_tcd_mct_decode (opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager);
+
+static OPJ_BOOL opj_tcd_dc_level_shift_decode (opj_tcd_t *p_tcd);
+
+
+static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd );
+
+static OPJ_BOOL opj_tcd_mct_encode ( opj_tcd_t *p_tcd );
+
+static OPJ_BOOL opj_tcd_dwt_encode ( opj_tcd_t *p_tcd );
+
+static OPJ_BOOL opj_tcd_t1_encode ( opj_tcd_t *p_tcd );
+
+static OPJ_BOOL opj_tcd_t2_encode (     opj_tcd_t *p_tcd,
+                                                                    OPJ_BYTE * p_dest_data,
+                                                                    OPJ_UINT32 * p_data_written,
+                                                                    OPJ_UINT32 p_max_dest_size,
+                                                                    opj_codestream_info_t *p_cstr_info );
+
+static OPJ_BOOL opj_tcd_rate_allocate_encode(   opj_tcd_t *p_tcd,
+                                                                                        OPJ_BYTE * p_dest_data,
+                                                                                        OPJ_UINT32 p_max_dest_size,
+                                                                                        opj_codestream_info_t *p_cstr_info );
+
+/* ----------------------------------------------------------------------- */
+
+/**
+Create a new TCD handle
+*/
+opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder)
+{
+        opj_tcd_t *l_tcd = 00;
+
+        /* create the tcd structure */
+        l_tcd = (opj_tcd_t*) opj_calloc(1,sizeof(opj_tcd_t));
+        if (!l_tcd) {
+                return 00;
+        }
+
+        l_tcd->m_is_decoder = p_is_decoder ? 1 : 0;
+
+        l_tcd->tcd_image = (opj_tcd_image_t*)opj_calloc(1,sizeof(opj_tcd_image_t));
+        if (!l_tcd->tcd_image) {
+                opj_free(l_tcd);
+                return 00;
+        }
+
+        return l_tcd;
+}
+
+
+/* ----------------------------------------------------------------------- */
+
+void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd) {
+        OPJ_UINT32 layno;
+
+        for (layno = 0; layno < tcd->tcp->numlayers; layno++) {
+                opj_tcd_makelayer_fixed(tcd, layno, 1);
+        }
+}
+
+
+void opj_tcd_makelayer( opj_tcd_t *tcd,
+                                                OPJ_UINT32 layno,
+                                                OPJ_FLOAT64 thresh,
+                                                OPJ_UINT32 final)
+{
+        OPJ_UINT32 compno, resno, bandno, precno, cblkno;
+        OPJ_UINT32 passno;
+
+        opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
+
+        tcd_tile->distolayer[layno] = 0;        /* fixed_quality */
+
+        for (compno = 0; compno < tcd_tile->numcomps; compno++) {
+                opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
+
+                for (resno = 0; resno < tilec->numresolutions; resno++) {
+                        opj_tcd_resolution_t *res = &tilec->resolutions[resno];
+
+                        for (bandno = 0; bandno < res->numbands; bandno++) {
+                                opj_tcd_band_t *band = &res->bands[bandno];
+
+                                for (precno = 0; precno < res->pw * res->ph; precno++) {
+                                        opj_tcd_precinct_t *prc = &band->precincts[precno];
+
+                                        for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
+                                                opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
+                                                opj_tcd_layer_t *layer = &cblk->layers[layno];
+                                                OPJ_UINT32 n;
+
+                                                if (layno == 0) {
+                                                        cblk->numpassesinlayers = 0;
+                                                }
+
+                                                n = cblk->numpassesinlayers;
+
+                                                for (passno = cblk->numpassesinlayers; passno < cblk->totalpasses; passno++) {
+                                                        OPJ_UINT32 dr;
+                                                        OPJ_FLOAT64 dd;
+                                                        opj_tcd_pass_t *pass = &cblk->passes[passno];
+
+                                                        if (n == 0) {
+                                                                dr = pass->rate;
+                                                                dd = pass->distortiondec;
+                                                        } else {
+                                                                dr = pass->rate - cblk->passes[n - 1].rate;
+                                                                dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
+                                                        }
+
+                                                        if (!dr) {
+                                                                if (dd != 0)
+                                                                        n = passno + 1;
+                                                                continue;
+                                                        }
+                                                        if (thresh - (dd / dr) < DBL_EPSILON) /* do not rely on float equality, check with DBL_EPSILON margin */
+                                                                n = passno + 1;
+                                                }
+
+                                                layer->numpasses = n - cblk->numpassesinlayers;
+
+                                                if (!layer->numpasses) {
+                                                        layer->disto = 0;
+                                                        continue;
+                                                }
+
+                                                if (cblk->numpassesinlayers == 0) {
+                                                        layer->len = cblk->passes[n - 1].rate;
+                                                        layer->data = cblk->data;
+                                                        layer->disto = cblk->passes[n - 1].distortiondec;
+                                                } else {
+                                                        layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers - 1].rate;
+                                                        layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
+                                                        layer->disto = cblk->passes[n - 1].distortiondec - cblk->passes[cblk->numpassesinlayers - 1].distortiondec;
+                                                }
+
+                                                tcd_tile->distolayer[layno] += layer->disto;    /* fixed_quality */
+
+                                                if (final)
+                                                        cblk->numpassesinlayers = n;
+                                        }
+                                }
+                        }
+                }
+        }
+}
+
+void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final) {
+        OPJ_UINT32 compno, resno, bandno, precno, cblkno;
+        OPJ_INT32 value;                        /*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3]; */
+        OPJ_INT32 matrice[10][10][3];
+        OPJ_UINT32 i, j, k;
+
+        opj_cp_t *cp = tcd->cp;
+        opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
+        opj_tcp_t *tcd_tcp = tcd->tcp;
+
+        for (compno = 0; compno < tcd_tile->numcomps; compno++) {
+                opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
+
+                for (i = 0; i < tcd_tcp->numlayers; i++) {
+                        for (j = 0; j < tilec->numresolutions; j++) {
+                                for (k = 0; k < 3; k++) {
+                                        matrice[i][j][k] =
+                                                (OPJ_INT32) ((OPJ_FLOAT32)cp->m_specific_param.m_enc.m_matrice[i * tilec->numresolutions * 3 + j * 3 + k]
+                                                * (OPJ_FLOAT32) (tcd->image->comps[compno].prec / 16.0));
+                                }
+                        }
+                }
+
+                for (resno = 0; resno < tilec->numresolutions; resno++) {
+                        opj_tcd_resolution_t *res = &tilec->resolutions[resno];
+
+                        for (bandno = 0; bandno < res->numbands; bandno++) {
+                                opj_tcd_band_t *band = &res->bands[bandno];
+
+                                for (precno = 0; precno < res->pw * res->ph; precno++) {
+                                        opj_tcd_precinct_t *prc = &band->precincts[precno];
+
+                                        for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
+                                                opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
+                                                opj_tcd_layer_t *layer = &cblk->layers[layno];
+                                                OPJ_UINT32 n;
+                                                OPJ_INT32 imsb = (OPJ_INT32)(tcd->image->comps[compno].prec - cblk->numbps); /* number of bit-plan equal to zero */
+
+                                                /* Correction of the matrix of coefficient to include the IMSB information */
+                                                if (layno == 0) {
+                                                        value = matrice[layno][resno][bandno];
+                                                        if (imsb >= value) {
+                                                                value = 0;
+                                                        } else {
+                                                                value -= imsb;
+                                                        }
+                                                } else {
+                                                        value = matrice[layno][resno][bandno] - matrice[layno - 1][resno][bandno];
+                                                        if (imsb >= matrice[layno - 1][resno][bandno]) {
+                                                                value -= (imsb - matrice[layno - 1][resno][bandno]);
+                                                                if (value < 0) {
+                                                                        value = 0;
+                                                                }
+                                                        }
+                                                }
+
+                                                if (layno == 0) {
+                                                        cblk->numpassesinlayers = 0;
+                                                }
+
+                                                n = cblk->numpassesinlayers;
+                                                if (cblk->numpassesinlayers == 0) {
+                                                        if (value != 0) {
+                                                                n = 3 * (OPJ_UINT32)value - 2 + cblk->numpassesinlayers;
+                                                        } else {
+                                                                n = cblk->numpassesinlayers;
+                                                        }
+                                                } else {
+                                                        n = 3 * (OPJ_UINT32)value + cblk->numpassesinlayers;
+                                                }
+
+                                                layer->numpasses = n - cblk->numpassesinlayers;
+
+                                                if (!layer->numpasses)
+                                                        continue;
+
+                                                if (cblk->numpassesinlayers == 0) {
+                                                        layer->len = cblk->passes[n - 1].rate;
+                                                        layer->data = cblk->data;
+                                                } else {
+                                                        layer->len = cblk->passes[n - 1].rate - cblk->passes[cblk->numpassesinlayers - 1].rate;
+                                                        layer->data = cblk->data + cblk->passes[cblk->numpassesinlayers - 1].rate;
+                                                }
+
+                                                if (final)
+                                                        cblk->numpassesinlayers = n;
+                                        }
+                                }
+                        }
+                }
+        }
+}
+
+OPJ_BOOL opj_tcd_rateallocate(  opj_tcd_t *tcd,
+                                                                OPJ_BYTE *dest,
+                                                                OPJ_UINT32 * p_data_written,
+                                                                OPJ_UINT32 len,
+                                                                opj_codestream_info_t *cstr_info)
+{
+        OPJ_UINT32 compno, resno, bandno, precno, cblkno, layno;
+        OPJ_UINT32 passno;
+        OPJ_FLOAT64 min, max;
+        OPJ_FLOAT64 cumdisto[100];      /* fixed_quality */
+        const OPJ_FLOAT64 K = 1;                /* 1.1; fixed_quality */
+        OPJ_FLOAT64 maxSE = 0;
+
+        opj_cp_t *cp = tcd->cp;
+        opj_tcd_tile_t *tcd_tile = tcd->tcd_image->tiles;
+        opj_tcp_t *tcd_tcp = tcd->tcp;
+
+        min = DBL_MAX;
+        max = 0;
+
+        tcd_tile->numpix = 0;           /* fixed_quality */
+
+        for (compno = 0; compno < tcd_tile->numcomps; compno++) {
+                opj_tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
+                tilec->numpix = 0;
+
+                for (resno = 0; resno < tilec->numresolutions; resno++) {
+                        opj_tcd_resolution_t *res = &tilec->resolutions[resno];
+
+                        for (bandno = 0; bandno < res->numbands; bandno++) {
+                                opj_tcd_band_t *band = &res->bands[bandno];
+
+                                for (precno = 0; precno < res->pw * res->ph; precno++) {
+                                        opj_tcd_precinct_t *prc = &band->precincts[precno];
+
+                                        for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
+                                                opj_tcd_cblk_enc_t *cblk = &prc->cblks.enc[cblkno];
+
+                                                for (passno = 0; passno < cblk->totalpasses; passno++) {
+                                                        opj_tcd_pass_t *pass = &cblk->passes[passno];
+                                                        OPJ_INT32 dr;
+                                                        OPJ_FLOAT64 dd, rdslope;
+
+                                                        if (passno == 0) {
+                                                                dr = (OPJ_INT32)pass->rate;
+                                                                dd = pass->distortiondec;
+                                                        } else {
+                                                                dr = (OPJ_INT32)(pass->rate - cblk->passes[passno - 1].rate);
+                                                                dd = pass->distortiondec - cblk->passes[passno - 1].distortiondec;
+                                                        }
+
+                                                        if (dr == 0) {
+                                                                continue;
+                                                        }
+
+                                                        rdslope = dd / dr;
+                                                        if (rdslope < min) {
+                                                                min = rdslope;
+                                                        }
+
+                                                        if (rdslope > max) {
+                                                                max = rdslope;
+                                                        }
+                                                } /* passno */
+
+                                                /* fixed_quality */
+                                                tcd_tile->numpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0));
+                                                tilec->numpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0));
+                                        } /* cbklno */
+                                } /* precno */
+                        } /* bandno */
+                } /* resno */
+
+                maxSE += (((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) - 1.0)
+                        * ((OPJ_FLOAT64)(1 << tcd->image->comps[compno].prec) -1.0))
+                        * ((OPJ_FLOAT64)(tilec->numpix));
+        } /* compno */
+
+        /* index file */
+        if(cstr_info) {
+                opj_tile_info_t *tile_info = &cstr_info->tile[tcd->tcd_tileno];
+                tile_info->numpix = tcd_tile->numpix;
+                tile_info->distotile = tcd_tile->distotile;
+                tile_info->thresh = (OPJ_FLOAT64 *) opj_malloc(tcd_tcp->numlayers * sizeof(OPJ_FLOAT64));
+                if (!tile_info->thresh) {
+                        /* FIXME event manager error callback */
+                        return OPJ_FALSE;
+                }
+        }
+
+        for (layno = 0; layno < tcd_tcp->numlayers; layno++) {
+                OPJ_FLOAT64 lo = min;
+                OPJ_FLOAT64 hi = max;
+                OPJ_UINT32 maxlen = tcd_tcp->rates[layno] > 0.0f ? opj_uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
+                OPJ_FLOAT64 goodthresh = 0;
+                OPJ_FLOAT64 stable_thresh = 0;
+                OPJ_UINT32 i;
+                OPJ_FLOAT64 distotarget;                /* fixed_quality */
+
+                /* fixed_quality */
+                distotarget = tcd_tile->distotile - ((K * maxSE) / pow((OPJ_FLOAT32)10, tcd_tcp->distoratio[layno] / 10));
+
+                /* Don't try to find an optimal threshold but rather take everything not included yet, if
+                  -r xx,yy,zz,0   (disto_alloc == 1 and rates == 0)
+                  -q xx,yy,zz,0   (fixed_quality == 1 and distoratio == 0)
+                  ==> possible to have some lossy layers and the last layer for sure lossless */
+                if ( ((cp->m_specific_param.m_enc.m_disto_alloc==1) && (tcd_tcp->rates[layno]>0.0f)) || ((cp->m_specific_param.m_enc.m_fixed_quality==1) && (tcd_tcp->distoratio[layno]>0.0))) {
+                        opj_t2_t*t2 = opj_t2_create(tcd->image, cp);
+                        OPJ_FLOAT64 thresh = 0;
+
+                        if (t2 == 00) {
+                                return OPJ_FALSE;
+                        }
+
+                        for     (i = 0; i < 128; ++i) {
+                                OPJ_FLOAT64 distoachieved = 0;  /* fixed_quality */
+
+                                thresh = (lo + hi) / 2;
+
+                                opj_tcd_makelayer(tcd, layno, thresh, 0);
+
+                                if (cp->m_specific_param.m_enc.m_fixed_quality) {       /* fixed_quality */
+                                        if(OPJ_IS_CINEMA(cp->rsiz)){
+                                                if (! opj_t2_encode_packets(t2,tcd->tcd_tileno, tcd_tile, layno + 1, dest, p_data_written, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC)) {
+
+                                                        lo = thresh;
+                                                        continue;
+                                                }
+                                                else {
+                                                        distoachieved = layno == 0 ?
+                                                                        tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno];
+
+                                                        if (distoachieved < distotarget) {
+                                                                hi=thresh;
+                                                                stable_thresh = thresh;
+                                                                continue;
+                                                        }else{
+                                                                lo=thresh;
+                                                        }
+                                                }
+                                        }else{
+                                                distoachieved = (layno == 0) ?
+                                                                tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
+
+                                                if (distoachieved < distotarget) {
+                                                        hi = thresh;
+                                                        stable_thresh = thresh;
+                                                        continue;
+                                                }
+                                                lo = thresh;
+                                        }
+                                } else {
+                                        if (! opj_t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest,p_data_written, maxlen, cstr_info,tcd->cur_tp_num,tcd->tp_pos,tcd->cur_pino,THRESH_CALC))
+                                        {
+                                                /* TODO: what to do with l ??? seek / tell ??? */
+                                                /* opj_event_msg(tcd->cinfo, EVT_INFO, "rate alloc: len=%d, max=%d\n", l, maxlen); */
+                                                lo = thresh;
+                                                continue;
+                                        }
+
+                                        hi = thresh;
+                                        stable_thresh = thresh;
+                                }
+                        }
+
+                        goodthresh = stable_thresh == 0? thresh : stable_thresh;
+
+                        opj_t2_destroy(t2);
+                } else {
+                        goodthresh = min;
+                }
+
+                if(cstr_info) { /* Threshold for Marcela Index */
+                        cstr_info->tile[tcd->tcd_tileno].thresh[layno] = goodthresh;
+                }
+
+                opj_tcd_makelayer(tcd, layno, goodthresh, 1);
+
+                /* fixed_quality */
+                cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
+        }
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
+                                           opj_image_t * p_image,
+                                           opj_cp_t * p_cp )
+{
+        p_tcd->image = p_image;
+        p_tcd->cp = p_cp;
+
+        p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(1,sizeof(opj_tcd_tile_t));
+        if (! p_tcd->tcd_image->tiles) {
+                return OPJ_FALSE;
+        }
+
+        p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_calloc(p_image->numcomps,sizeof(opj_tcd_tilecomp_t));
+        if (! p_tcd->tcd_image->tiles->comps ) {
+                return OPJ_FALSE;
+        }
+
+        p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
+        p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;
+
+        return OPJ_TRUE;
+}
+
+/**
+Destroy a previously created TCD handle
+*/
+void opj_tcd_destroy(opj_tcd_t *tcd) {
+        if (tcd) {
+                opj_tcd_free_tile(tcd);
+
+                if (tcd->tcd_image) {
+                        opj_free(tcd->tcd_image);
+                        tcd->tcd_image = 00;
+                }
+                opj_free(tcd);
+        }
+}
+
+OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec)
+{
+	if ((l_tilec->data == 00) || ((l_tilec->data_size_needed > l_tilec->data_size) && (l_tilec->ownsData == OPJ_FALSE))) {
+		l_tilec->data = (OPJ_INT32 *) opj_aligned_malloc(l_tilec->data_size_needed);
+		if (! l_tilec->data ) {
+			return OPJ_FALSE;
+		}
+		/*fprintf(stderr, "tAllocate data of tilec (int): %d x OPJ_UINT32n",l_data_size);*/
+		l_tilec->data_size = l_tilec->data_size_needed;
+		l_tilec->ownsData = OPJ_TRUE;
+	}
+	else if (l_tilec->data_size_needed > l_tilec->data_size) {
+		/* We don't need to keep old data */
+		opj_aligned_free(l_tilec->data);
+		l_tilec->data = (OPJ_INT32 *) opj_aligned_malloc(l_tilec->data_size_needed);
+		if (! l_tilec->data ) {
+			l_tilec->data_size = 0;
+			l_tilec->data_size_needed = 0;
+			l_tilec->ownsData = OPJ_FALSE;
+			return OPJ_FALSE;
+		}
+		/*fprintf(stderr, "tReallocate data of tilec (int): from %d to %d x OPJ_UINT32n", l_tilec->data_size, l_data_size);*/
+		l_tilec->data_size = l_tilec->data_size_needed;
+		l_tilec->ownsData = OPJ_TRUE;
+	}
+	return OPJ_TRUE;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, OPJ_BOOL isEncoder, OPJ_FLOAT32 fraction, OPJ_SIZE_T sizeof_block, opj_event_mgr_t* manager)
+{
+	OPJ_UINT32 (*l_gain_ptr)(OPJ_UINT32) = 00;
+	OPJ_UINT32 compno, resno, bandno, precno, cblkno;
+	opj_tcp_t * l_tcp = 00;
+	opj_cp_t * l_cp = 00;
+	opj_tcd_tile_t * l_tile = 00;
+	opj_tccp_t *l_tccp = 00;
+	opj_tcd_tilecomp_t *l_tilec = 00;
+	opj_image_comp_t * l_image_comp = 00;
+	opj_tcd_resolution_t *l_res = 00;
+	opj_tcd_band_t *l_band = 00;
+	opj_stepsize_t * l_step_size = 00;
+	opj_tcd_precinct_t *l_current_precinct = 00;
+	opj_image_t *l_image = 00;
+	OPJ_UINT32 p,q;
+	OPJ_UINT32 l_level_no;
+	OPJ_UINT32 l_pdx, l_pdy;
+	OPJ_UINT32 l_gain;
+	OPJ_INT32 l_x0b, l_y0b;
+	OPJ_UINT32 l_tx0, l_ty0;
+	/* extent of precincts , top left, bottom right**/
+	OPJ_INT32 l_tl_prc_x_start, l_tl_prc_y_start, l_br_prc_x_end, l_br_prc_y_end;
+	/* number of precinct for a resolution */
+	OPJ_UINT32 l_nb_precincts;
+	/* room needed to store l_nb_precinct precinct for a resolution */
+	OPJ_UINT32 l_nb_precinct_size;
+	/* number of code blocks for a precinct*/
+	OPJ_UINT32 l_nb_code_blocks;
+	/* room needed to store l_nb_code_blocks code blocks for a precinct*/
+	OPJ_UINT32 l_nb_code_blocks_size;
+	/* size of data for a tile */
+	OPJ_UINT32 l_data_size;
+	
+	l_cp = p_tcd->cp;
+	l_tcp = &(l_cp->tcps[p_tile_no]);
+	l_tile = p_tcd->tcd_image->tiles;
+	l_tccp = l_tcp->tccps;
+	l_tilec = l_tile->comps;
+	l_image = p_tcd->image;
+	l_image_comp = p_tcd->image->comps;
+	
+	p = p_tile_no % l_cp->tw;       /* tile coordinates */
+	q = p_tile_no / l_cp->tw;
+	/*fprintf(stderr, "Tile coordinate = %d,%d\n", p, q);*/
+	
+	/* 4 borders of the tile rescale on the image if necessary */
+	l_tx0 = l_cp->tx0 + p * l_cp->tdx; /* can't be greater than l_image->x1 so won't overflow */
+	l_tile->x0 = (OPJ_INT32)opj_uint_max(l_tx0, l_image->x0);
+	l_tile->x1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, l_cp->tdx), l_image->x1);
+	l_ty0 = l_cp->ty0 + q * l_cp->tdy; /* can't be greater than l_image->y1 so won't overflow */
+	l_tile->y0 = (OPJ_INT32)opj_uint_max(l_ty0, l_image->y0);
+	l_tile->y1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, l_cp->tdy), l_image->y1);
+
+	/* testcase 1888.pdf.asan.35.988 */
+	if (l_tccp->numresolutions == 0) {
+		opj_event_msg(manager, EVT_ERROR, "tiles require at least one resolution\n");
+		return OPJ_FALSE;
+	}
+	/*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,l_tile->x1,l_tile->y1);*/
+	
+	/*tile->numcomps = image->numcomps; */
+	for (compno = 0; compno < l_tile->numcomps; ++compno) {
+		/*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);*/
+		l_image_comp->resno_decoded = 0;
+		/* border of each l_tile component (global) */
+		l_tilec->x0 = opj_int_ceildiv(l_tile->x0, (OPJ_INT32)l_image_comp->dx);
+		l_tilec->y0 = opj_int_ceildiv(l_tile->y0, (OPJ_INT32)l_image_comp->dy);
+		l_tilec->x1 = opj_int_ceildiv(l_tile->x1, (OPJ_INT32)l_image_comp->dx);
+		l_tilec->y1 = opj_int_ceildiv(l_tile->y1, (OPJ_INT32)l_image_comp->dy);
+		/*fprintf(stderr, "\tTile compo border = %d,%d,%d,%d\n", l_tilec->x0, l_tilec->y0,l_tilec->x1,l_tilec->y1);*/
+		
+		/* compute l_data_size with overflow check */
+		l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
+		/* issue 733, l_data_size == 0U, probably something wrong should be checked before getting here */
+		if ((l_data_size > 0U) && ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0))) {
+			opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
+			return OPJ_FALSE;
+		}
+		l_data_size = l_data_size * (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0);
+		
+		if ((((OPJ_UINT32)-1) / (OPJ_UINT32)sizeof(OPJ_UINT32)) < l_data_size) {
+			opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
+			return OPJ_FALSE;
+		}
+		l_data_size = l_data_size * (OPJ_UINT32)sizeof(OPJ_UINT32);
+		l_tilec->numresolutions = l_tccp->numresolutions;
+		if (l_tccp->numresolutions < l_cp->m_specific_param.m_dec.m_reduce) {
+			l_tilec->minimum_num_resolutions = 1;
+		}
+		else {
+			l_tilec->minimum_num_resolutions = l_tccp->numresolutions - l_cp->m_specific_param.m_dec.m_reduce;
+		}
+		
+		l_tilec->data_size_needed = l_data_size;
+		if (p_tcd->m_is_decoder && !opj_alloc_tile_component_data(l_tilec)) {
+			opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
+			return OPJ_FALSE;
+		}
+		
+		l_data_size = l_tilec->numresolutions * (OPJ_UINT32)sizeof(opj_tcd_resolution_t);
+		
+		if (l_tilec->resolutions == 00) {
+			l_tilec->resolutions = (opj_tcd_resolution_t *) opj_malloc(l_data_size);
+			if (! l_tilec->resolutions ) {
+				return OPJ_FALSE;
+			}
+			/*fprintf(stderr, "\tAllocate resolutions of tilec (opj_tcd_resolution_t): %d\n",l_data_size);*/
+			l_tilec->resolutions_size = l_data_size;
+			memset(l_tilec->resolutions,0,l_data_size);
+		}
+		else if (l_data_size > l_tilec->resolutions_size) {
+			opj_tcd_resolution_t* new_resolutions = (opj_tcd_resolution_t *) opj_realloc(l_tilec->resolutions, l_data_size);
+			if (! new_resolutions) {
+				opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile resolutions\n");
+				opj_free(l_tilec->resolutions);
+				l_tilec->resolutions = NULL;
+				l_tilec->resolutions_size = 0;
+				return OPJ_FALSE;
+			}
+			l_tilec->resolutions = new_resolutions;
+			/*fprintf(stderr, "\tReallocate data of tilec (int): from %d to %d x OPJ_UINT32\n", l_tilec->resolutions_size, l_data_size);*/
+			memset(((OPJ_BYTE*) l_tilec->resolutions)+l_tilec->resolutions_size,0,l_data_size - l_tilec->resolutions_size);
+			l_tilec->resolutions_size = l_data_size;
+		}
+		
+		l_level_no = l_tilec->numresolutions;
+		l_res = l_tilec->resolutions;
+		l_step_size = l_tccp->stepsizes;
+		if (l_tccp->qmfbid == 0) {
+			l_gain_ptr = &opj_dwt_getgain_real;
+		}
+		else {
+			l_gain_ptr  = &opj_dwt_getgain;
+		}
+		/*fprintf(stderr, "\tlevel_no=%d\n",l_level_no);*/
+		
+		for (resno = 0; resno < l_tilec->numresolutions; ++resno) {
+			/*fprintf(stderr, "\t\tresno = %d/%d\n", resno, l_tilec->numresolutions);*/
+			OPJ_INT32 tlcbgxstart, tlcbgystart /*, brcbgxend, brcbgyend*/;
+			OPJ_UINT32 cbgwidthexpn, cbgheightexpn;
+			OPJ_UINT32 cblkwidthexpn, cblkheightexpn;
+			
+			--l_level_no;
+			
+			/* border for each resolution level (global) */
+			l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no);
+			l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
+			l_res->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)l_level_no);
+			l_res->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)l_level_no);
+			/*fprintf(stderr, "\t\t\tres_x0= %d, res_y0 =%d, res_x1=%d, res_y1=%d\n", l_res->x0, l_res->y0, l_res->x1, l_res->y1);*/
+			/* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */
+			l_pdx = l_tccp->prcw[resno];
+			l_pdy = l_tccp->prch[resno];
+			/*fprintf(stderr, "\t\t\tpdx=%d, pdy=%d\n", l_pdx, l_pdy);*/
+			/* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000)  */
+			l_tl_prc_x_start = opj_int_floordivpow2(l_res->x0, (OPJ_INT32)l_pdx) << l_pdx;
+			l_tl_prc_y_start = opj_int_floordivpow2(l_res->y0, (OPJ_INT32)l_pdy) << l_pdy;
+			l_br_prc_x_end = opj_int_ceildivpow2(l_res->x1, (OPJ_INT32)l_pdx) << l_pdx;
+			l_br_prc_y_end = opj_int_ceildivpow2(l_res->y1, (OPJ_INT32)l_pdy) << l_pdy;
+			/*fprintf(stderr, "\t\t\tprc_x_start=%d, prc_y_start=%d, br_prc_x_end=%d, br_prc_y_end=%d \n", l_tl_prc_x_start, l_tl_prc_y_start, l_br_prc_x_end ,l_br_prc_y_end );*/
+			
+			l_res->pw = (l_res->x0 == l_res->x1) ? 0 : (OPJ_UINT32)((l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx);
+			l_res->ph = (l_res->y0 == l_res->y1) ? 0 : (OPJ_UINT32)((l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);
+			/*fprintf(stderr, "\t\t\tres_pw=%d, res_ph=%d\n", l_res->pw, l_res->ph );*/
+			
+			l_nb_precincts = l_res->pw * l_res->ph;
+			l_nb_precinct_size = l_nb_precincts * (OPJ_UINT32)sizeof(opj_tcd_precinct_t);
+			if (resno == 0) {
+				tlcbgxstart = l_tl_prc_x_start;
+				tlcbgystart = l_tl_prc_y_start;
+				/*brcbgxend = l_br_prc_x_end;*/
+				/* brcbgyend = l_br_prc_y_end;*/
+				cbgwidthexpn = l_pdx;
+				cbgheightexpn = l_pdy;
+				l_res->numbands = 1;
+			}
+			else {
+				tlcbgxstart = opj_int_ceildivpow2(l_tl_prc_x_start, 1);
+				tlcbgystart = opj_int_ceildivpow2(l_tl_prc_y_start, 1);
+				/*brcbgxend = opj_int_ceildivpow2(l_br_prc_x_end, 1);*/
+				/*brcbgyend = opj_int_ceildivpow2(l_br_prc_y_end, 1);*/
+				cbgwidthexpn = l_pdx - 1;
+				cbgheightexpn = l_pdy - 1;
+				l_res->numbands = 3;
+			}
+			
+			cblkwidthexpn = opj_uint_min(l_tccp->cblkw, cbgwidthexpn);
+			cblkheightexpn = opj_uint_min(l_tccp->cblkh, cbgheightexpn);
+			l_band = l_res->bands;
+			
+			for (bandno = 0; bandno < l_res->numbands; ++bandno) {
+				OPJ_INT32 numbps;
+				/*fprintf(stderr, "\t\t\tband_no=%d/%d\n", bandno, l_res->numbands );*/
+				
+				if (resno == 0) {
+					l_band->bandno = 0 ;
+					l_band->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no);
+					l_band->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
+					l_band->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)l_level_no);
+					l_band->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)l_level_no);
+				}
+				else {
+					l_band->bandno = bandno + 1;
+					/* x0b = 1 if bandno = 1 or 3 */
+					l_x0b = l_band->bandno&1;
+					/* y0b = 1 if bandno = 2 or 3 */
+					l_y0b = (OPJ_INT32)((l_band->bandno)>>1);
+					/* l_band border (global) */
+					l_band->x0 = opj_int64_ceildivpow2(l_tilec->x0 - ((OPJ_INT64)l_x0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
+					l_band->y0 = opj_int64_ceildivpow2(l_tilec->y0 - ((OPJ_INT64)l_y0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
+					l_band->x1 = opj_int64_ceildivpow2(l_tilec->x1 - ((OPJ_INT64)l_x0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
+					l_band->y1 = opj_int64_ceildivpow2(l_tilec->y1 - ((OPJ_INT64)l_y0b << l_level_no), (OPJ_INT32)(l_level_no + 1));
+				}
+				
+				/** avoid an if with storing function pointer */
+				l_gain = (*l_gain_ptr) (l_band->bandno);
+				numbps = (OPJ_INT32)(l_image_comp->prec + l_gain);
+				l_band->stepsize = (OPJ_FLOAT32)(((1.0 + l_step_size->mant / 2048.0) * pow(2.0, (OPJ_INT32) (numbps - l_step_size->expn)))) * fraction;
+				l_band->numbps = l_step_size->expn + (OPJ_INT32)l_tccp->numgbits - 1;      /* WHY -1 ? */
+				
+				if (!l_band->precincts && (l_nb_precincts > 0U)) {
+					l_band->precincts = (opj_tcd_precinct_t *) opj_malloc( /*3 * */ l_nb_precinct_size);
+					if (! l_band->precincts) {
+						return OPJ_FALSE;
+					}
+					/*fprintf(stderr, "\t\t\t\tAllocate precincts of a band (opj_tcd_precinct_t): %d\n",l_nb_precinct_size);     */
+					memset(l_band->precincts,0,l_nb_precinct_size);
+					l_band->precincts_data_size = l_nb_precinct_size;
+				}
+				else if (l_band->precincts_data_size < l_nb_precinct_size) {
+					
+					opj_tcd_precinct_t * new_precincts = (opj_tcd_precinct_t *) opj_realloc(l_band->precincts,/*3 * */ l_nb_precinct_size);
+					if (! new_precincts) {
+						opj_event_msg(manager, EVT_ERROR, "Not enough memory to handle band precints\n");
+						opj_free(l_band->precincts);
+						l_band->precincts = NULL;
+						l_band->precincts_data_size = 0;
+						return OPJ_FALSE;
+					}
+					l_band->precincts = new_precincts;
+					/*fprintf(stderr, "\t\t\t\tReallocate precincts of a band (opj_tcd_precinct_t): from %d to %d\n",l_band->precincts_data_size, l_nb_precinct_size);*/
+					memset(((OPJ_BYTE *) l_band->precincts) + l_band->precincts_data_size,0,l_nb_precinct_size - l_band->precincts_data_size);
+					l_band->precincts_data_size = l_nb_precinct_size;
+				}
+				
+				l_current_precinct = l_band->precincts;
+				for (precno = 0; precno < l_nb_precincts; ++precno) {
+					OPJ_INT32 tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;
+					OPJ_INT32 cbgxstart = tlcbgxstart + (OPJ_INT32)(precno % l_res->pw) * (1 << cbgwidthexpn);
+					OPJ_INT32 cbgystart = tlcbgystart + (OPJ_INT32)(precno / l_res->pw) * (1 << cbgheightexpn);
+					OPJ_INT32 cbgxend = cbgxstart + (1 << cbgwidthexpn);
+					OPJ_INT32 cbgyend = cbgystart + (1 << cbgheightexpn);
+					/*fprintf(stderr, "\t precno=%d; bandno=%d, resno=%d; compno=%d\n", precno, bandno , resno, compno);*/
+					/*fprintf(stderr, "\t tlcbgxstart(=%d) + (precno(=%d) percent res->pw(=%d)) * (1 << cbgwidthexpn(=%d)) \n",tlcbgxstart,precno,l_res->pw,cbgwidthexpn);*/
+					
+					/* precinct size (global) */
+					/*fprintf(stderr, "\t cbgxstart=%d, l_band->x0 = %d \n",cbgxstart, l_band->x0);*/
+					
+					l_current_precinct->x0 = opj_int_max(cbgxstart, l_band->x0);
+					l_current_precinct->y0 = opj_int_max(cbgystart, l_band->y0);
+					l_current_precinct->x1 = opj_int_min(cbgxend, l_band->x1);
+					l_current_precinct->y1 = opj_int_min(cbgyend, l_band->y1);
+					/*fprintf(stderr, "\t prc_x0=%d; prc_y0=%d, prc_x1=%d; prc_y1=%d\n",l_current_precinct->x0, l_current_precinct->y0 ,l_current_precinct->x1, l_current_precinct->y1);*/
+					
+					tlcblkxstart = opj_int_floordivpow2(l_current_precinct->x0, (OPJ_INT32)cblkwidthexpn) << cblkwidthexpn;
+					/*fprintf(stderr, "\t tlcblkxstart =%d\n",tlcblkxstart );*/
+					tlcblkystart = opj_int_floordivpow2(l_current_precinct->y0, (OPJ_INT32)cblkheightexpn) << cblkheightexpn;
+					/*fprintf(stderr, "\t tlcblkystart =%d\n",tlcblkystart );*/
+					brcblkxend = opj_int_ceildivpow2(l_current_precinct->x1, (OPJ_INT32)cblkwidthexpn) << cblkwidthexpn;
+					/*fprintf(stderr, "\t brcblkxend =%d\n",brcblkxend );*/
+					brcblkyend = opj_int_ceildivpow2(l_current_precinct->y1, (OPJ_INT32)cblkheightexpn) << cblkheightexpn;
+					/*fprintf(stderr, "\t brcblkyend =%d\n",brcblkyend );*/
+					l_current_precinct->cw = (OPJ_UINT32)((brcblkxend - tlcblkxstart) >> cblkwidthexpn);
+					l_current_precinct->ch = (OPJ_UINT32)((brcblkyend - tlcblkystart) >> cblkheightexpn);
+					
+					l_nb_code_blocks = l_current_precinct->cw * l_current_precinct->ch;
+					/*fprintf(stderr, "\t\t\t\t precinct_cw = %d x recinct_ch = %d\n",l_current_precinct->cw, l_current_precinct->ch);      */
+					l_nb_code_blocks_size = l_nb_code_blocks * (OPJ_UINT32)sizeof_block;
+					
+					if (!l_current_precinct->cblks.blocks && (l_nb_code_blocks > 0U)) {
+						l_current_precinct->cblks.blocks = opj_malloc(l_nb_code_blocks_size);
+						if (! l_current_precinct->cblks.blocks ) {
+							return OPJ_FALSE;
+						}
+						/*fprintf(stderr, "\t\t\t\tAllocate cblks of a precinct (opj_tcd_cblk_dec_t): %d\n",l_nb_code_blocks_size);*/
+						
+						memset(l_current_precinct->cblks.blocks,0,l_nb_code_blocks_size);
+						
+						l_current_precinct->block_size = l_nb_code_blocks_size;
+					}
+					else if (l_nb_code_blocks_size > l_current_precinct->block_size) {
+						void *new_blocks = opj_realloc(l_current_precinct->cblks.blocks, l_nb_code_blocks_size);
+						if (! new_blocks) {
+							opj_free(l_current_precinct->cblks.blocks);
+							l_current_precinct->cblks.blocks = NULL;
+							l_current_precinct->block_size = 0;
+							opj_event_msg(manager, EVT_ERROR, "Not enough memory for current precinct codeblock element\n");
+							return OPJ_FALSE;
+						}
+						l_current_precinct->cblks.blocks = new_blocks;
+						/*fprintf(stderr, "\t\t\t\tReallocate cblks of a precinct (opj_tcd_cblk_dec_t): from %d to %d\n",l_current_precinct->block_size, l_nb_code_blocks_size);     */
+						
+						memset(((OPJ_BYTE *) l_current_precinct->cblks.blocks) + l_current_precinct->block_size
+									 ,0
+									 ,l_nb_code_blocks_size - l_current_precinct->block_size);
+						
+						l_current_precinct->block_size = l_nb_code_blocks_size;
+					}
+					
+					if (! l_current_precinct->incltree) {
+						l_current_precinct->incltree = opj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager);
+					}
+					else{
+						l_current_precinct->incltree = opj_tgt_init(l_current_precinct->incltree, l_current_precinct->cw, l_current_precinct->ch, manager);
+					}
+
+					if (! l_current_precinct->incltree)     {
+						opj_event_msg(manager, EVT_WARNING, "No incltree created.\n");
+						/*return OPJ_FALSE;*/
+					}
+
+					if (! l_current_precinct->imsbtree) {
+						l_current_precinct->imsbtree = opj_tgt_create(l_current_precinct->cw, l_current_precinct->ch, manager);
+					}
+					else {
+						l_current_precinct->imsbtree = opj_tgt_init(l_current_precinct->imsbtree, l_current_precinct->cw, l_current_precinct->ch, manager);
+					}
+
+					if (! l_current_precinct->imsbtree) {
+						opj_event_msg(manager, EVT_WARNING, "No imsbtree created.\n");
+						/*return OPJ_FALSE;*/
+					}
+
+					for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
+						OPJ_INT32 cblkxstart = tlcblkxstart + (OPJ_INT32)(cblkno % l_current_precinct->cw) * (1 << cblkwidthexpn);
+						OPJ_INT32 cblkystart = tlcblkystart + (OPJ_INT32)(cblkno / l_current_precinct->cw) * (1 << cblkheightexpn);
+						OPJ_INT32 cblkxend = cblkxstart + (1 << cblkwidthexpn);
+						OPJ_INT32 cblkyend = cblkystart + (1 << cblkheightexpn);
+						
+						if (isEncoder) {
+							opj_tcd_cblk_enc_t* l_code_block = l_current_precinct->cblks.enc + cblkno;
+							
+							if (! opj_tcd_code_block_enc_allocate(l_code_block)) {
+								return OPJ_FALSE;
+							}
+							/* code-block size (global) */
+							l_code_block->x0 = opj_int_max(cblkxstart, l_current_precinct->x0);
+							l_code_block->y0 = opj_int_max(cblkystart, l_current_precinct->y0);
+							l_code_block->x1 = opj_int_min(cblkxend, l_current_precinct->x1);
+							l_code_block->y1 = opj_int_min(cblkyend, l_current_precinct->y1);
+							
+							if (! opj_tcd_code_block_enc_allocate_data(l_code_block)) {
+								return OPJ_FALSE;
+							}
+						} else {
+							opj_tcd_cblk_dec_t* l_code_block = l_current_precinct->cblks.dec + cblkno;
+							
+							if (! opj_tcd_code_block_dec_allocate(l_code_block)) {
+								return OPJ_FALSE;
+							}
+							/* code-block size (global) */
+							l_code_block->x0 = opj_int_max(cblkxstart, l_current_precinct->x0);
+							l_code_block->y0 = opj_int_max(cblkystart, l_current_precinct->y0);
+							l_code_block->x1 = opj_int_min(cblkxend, l_current_precinct->x1);
+							l_code_block->y1 = opj_int_min(cblkyend, l_current_precinct->y1);
+						}
+					}
+					++l_current_precinct;
+				} /* precno */
+				++l_band;
+				++l_step_size;
+			} /* bandno */
+			++l_res;
+		} /* resno */
+		++l_tccp;
+		++l_tilec;
+		++l_image_comp;
+	} /* compno */
+	return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_tcd_init_encode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager)
+{
+	return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_TRUE, 1.0F, sizeof(opj_tcd_cblk_enc_t), p_manager);
+}
+
+OPJ_BOOL opj_tcd_init_decode_tile (opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager)
+{
+	return opj_tcd_init_tile(p_tcd, p_tile_no, OPJ_FALSE, 0.5F, sizeof(opj_tcd_cblk_dec_t), p_manager);
+}
+
+/**
+ * Allocates memory for an encoding code block (but not data memory).
+ */
+static OPJ_BOOL opj_tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_block)
+{
+	if (! p_code_block->layers) {
+		/* no memset since data */
+		p_code_block->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
+		if (! p_code_block->layers) {
+			return OPJ_FALSE;
+		}
+	}
+	if (! p_code_block->passes) {
+		p_code_block->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
+		if (! p_code_block->passes) {
+			return OPJ_FALSE;
+		}
+	}
+	return OPJ_TRUE;
+}
+
+/**
+ * Allocates data memory for an encoding code block.
+ */
+static OPJ_BOOL opj_tcd_code_block_enc_allocate_data (opj_tcd_cblk_enc_t * p_code_block)
+{
+	OPJ_UINT32 l_data_size;
+	
+	l_data_size = (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) * (p_code_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32));
+	
+	if (l_data_size > p_code_block->data_size) {
+		if (p_code_block->data) {
+			opj_free(p_code_block->data - 1); /* again, why -1 */
+		}
+		p_code_block->data = (OPJ_BYTE*) opj_malloc(l_data_size+1);
+		if(! p_code_block->data) {
+			p_code_block->data_size = 0U;
+			return OPJ_FALSE;
+		}
+		p_code_block->data_size = l_data_size;
+		
+		p_code_block->data[0] = 0;
+		p_code_block->data+=1;   /*why +1 ?*/
+	}
+	return OPJ_TRUE;
+}
+
+/**
+ * Allocates memory for a decoding code block.
+ */
+static OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block)
+{
+        if (! p_code_block->data) {
+
+                p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK_DATA_SIZE);
+                if (! p_code_block->data) {
+                        return OPJ_FALSE;
+                }
+                p_code_block->data_max_size = OPJ_J2K_DEFAULT_CBLK_DATA_SIZE;
+                /*fprintf(stderr, "Allocate 8192 elements of code_block->data\n");*/
+
+                p_code_block->segs = (opj_tcd_seg_t *) opj_calloc(OPJ_J2K_DEFAULT_NB_SEGS,sizeof(opj_tcd_seg_t));
+                if (! p_code_block->segs) {
+                        return OPJ_FALSE;
+                }
+                /*fprintf(stderr, "Allocate %d elements of code_block->data\n", OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t));*/
+
+                p_code_block->m_current_max_segs = OPJ_J2K_DEFAULT_NB_SEGS;
+                /*fprintf(stderr, "m_current_max_segs of code_block->data = %d\n", p_code_block->m_current_max_segs);*/
+        } else {
+					/* sanitize */
+					OPJ_BYTE* l_data = p_code_block->data;
+					OPJ_UINT32 l_data_max_size = p_code_block->data_max_size;
+					opj_tcd_seg_t * l_segs = p_code_block->segs;
+					OPJ_UINT32 l_current_max_segs = p_code_block->m_current_max_segs;
+
+					memset(p_code_block, 0, sizeof(opj_tcd_cblk_dec_t));
+					p_code_block->data = l_data;
+					p_code_block->data_max_size = l_data_max_size;
+					p_code_block->segs = l_segs;
+					p_code_block->m_current_max_segs = l_current_max_segs;
+				}
+
+        return OPJ_TRUE;
+}
+
+OPJ_UINT32 opj_tcd_get_decoded_tile_size ( opj_tcd_t *p_tcd )
+{
+        OPJ_UINT32 i;
+        OPJ_UINT32 l_data_size = 0;
+        opj_image_comp_t * l_img_comp = 00;
+        opj_tcd_tilecomp_t * l_tile_comp = 00;
+        opj_tcd_resolution_t * l_res = 00;
+        OPJ_UINT32 l_size_comp, l_remaining;
+
+        l_tile_comp = p_tcd->tcd_image->tiles->comps;
+        l_img_comp = p_tcd->image->comps;
+
+        for (i=0;i<p_tcd->image->numcomps;++i) {
+                l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
+                l_remaining = l_img_comp->prec & 7;  /* (%8) */
+
+                if(l_remaining) {
+                        ++l_size_comp;
+                }
+
+                if (l_size_comp == 3) {
+                        l_size_comp = 4;
+                }
+
+                l_res = l_tile_comp->resolutions + l_tile_comp->minimum_num_resolutions - 1;
+                l_data_size += l_size_comp * (OPJ_UINT32)((l_res->x1 - l_res->x0) * (l_res->y1 - l_res->y0));
+                ++l_img_comp;
+                ++l_tile_comp;
+        }
+
+        return l_data_size;
+}
+
+OPJ_BOOL opj_tcd_encode_tile(   opj_tcd_t *p_tcd,
+                                                        OPJ_UINT32 p_tile_no,
+                                                        OPJ_BYTE *p_dest,
+                                                        OPJ_UINT32 * p_data_written,
+                                                        OPJ_UINT32 p_max_length,
+                                                        opj_codestream_info_t *p_cstr_info)
+{
+
+        if (p_tcd->cur_tp_num == 0) {
+
+                p_tcd->tcd_tileno = p_tile_no;
+                p_tcd->tcp = &p_tcd->cp->tcps[p_tile_no];
+
+                /* INDEX >> "Precinct_nb_X et Precinct_nb_Y" */
+                if(p_cstr_info)  {
+                        OPJ_UINT32 l_num_packs = 0;
+                        OPJ_UINT32 i;
+                        opj_tcd_tilecomp_t *l_tilec_idx = &p_tcd->tcd_image->tiles->comps[0];        /* based on component 0 */
+                        opj_tccp_t *l_tccp = p_tcd->tcp->tccps; /* based on component 0 */
+
+                        for (i = 0; i < l_tilec_idx->numresolutions; i++) {
+                                opj_tcd_resolution_t *l_res_idx = &l_tilec_idx->resolutions[i];
+
+                                p_cstr_info->tile[p_tile_no].pw[i] = (int)l_res_idx->pw;
+                                p_cstr_info->tile[p_tile_no].ph[i] = (int)l_res_idx->ph;
+
+                                l_num_packs += l_res_idx->pw * l_res_idx->ph;
+                                p_cstr_info->tile[p_tile_no].pdx[i] = (int)l_tccp->prcw[i];
+                                p_cstr_info->tile[p_tile_no].pdy[i] = (int)l_tccp->prch[i];
+                        }
+                        p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t*) opj_calloc((size_t)p_cstr_info->numcomps * (size_t)p_cstr_info->numlayers * l_num_packs, sizeof(opj_packet_info_t));
+                        if (!p_cstr_info->tile[p_tile_no].packet) {
+                                /* FIXME event manager error callback */
+                                return OPJ_FALSE;
+                        }
+                }
+                /* << INDEX */
+
+                /* FIXME _ProfStart(PGROUP_DC_SHIFT); */
+                /*---------------TILE-------------------*/
+                if (! opj_tcd_dc_level_shift_encode(p_tcd)) {
+                        return OPJ_FALSE;
+                }
+                /* FIXME _ProfStop(PGROUP_DC_SHIFT); */
+
+                /* FIXME _ProfStart(PGROUP_MCT); */
+                if (! opj_tcd_mct_encode(p_tcd)) {
+                        return OPJ_FALSE;
+                }
+                /* FIXME _ProfStop(PGROUP_MCT); */
+
+                /* FIXME _ProfStart(PGROUP_DWT); */
+                if (! opj_tcd_dwt_encode(p_tcd)) {
+                        return OPJ_FALSE;
+                }
+                /* FIXME  _ProfStop(PGROUP_DWT); */
+
+                /* FIXME  _ProfStart(PGROUP_T1); */
+                if (! opj_tcd_t1_encode(p_tcd)) {
+                        return OPJ_FALSE;
+                }
+                /* FIXME _ProfStop(PGROUP_T1); */
+
+                /* FIXME _ProfStart(PGROUP_RATE); */
+                if (! opj_tcd_rate_allocate_encode(p_tcd,p_dest,p_max_length,p_cstr_info)) {
+                        return OPJ_FALSE;
+                }
+                /* FIXME _ProfStop(PGROUP_RATE); */
+
+        }
+        /*--------------TIER2------------------*/
+
+        /* INDEX */
+        if (p_cstr_info) {
+                p_cstr_info->index_write = 1;
+        }
+        /* FIXME _ProfStart(PGROUP_T2); */
+
+        if (! opj_tcd_t2_encode(p_tcd,p_dest,p_data_written,p_max_length,p_cstr_info)) {
+                return OPJ_FALSE;
+        }
+        /* FIXME _ProfStop(PGROUP_T2); */
+
+        /*---------------CLEAN-------------------*/
+
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_tcd_decode_tile(   opj_tcd_t *p_tcd,
+                                OPJ_BYTE *p_src,
+                                OPJ_UINT32 p_max_length,
+                                OPJ_UINT32 p_tile_no,
+                                opj_codestream_index_t *p_cstr_index,
+                                opj_event_mgr_t *p_manager
+                                )
+{
+        OPJ_UINT32 l_data_read;
+        p_tcd->tcd_tileno = p_tile_no;
+        p_tcd->tcp = &(p_tcd->cp->tcps[p_tile_no]);
+
+#ifdef TODO_MSD /* FIXME */
+        /* INDEX >>  */
+        if(p_cstr_info) {
+                OPJ_UINT32 resno, compno, numprec = 0;
+                for (compno = 0; compno < (OPJ_UINT32) p_cstr_info->numcomps; compno++) {
+                        opj_tcp_t *tcp = &p_tcd->cp->tcps[0];
+                        opj_tccp_t *tccp = &tcp->tccps[compno];
+                        opj_tcd_tilecomp_t *tilec_idx = &p_tcd->tcd_image->tiles->comps[compno];
+                        for (resno = 0; resno < tilec_idx->numresolutions; resno++) {
+                                opj_tcd_resolution_t *res_idx = &tilec_idx->resolutions[resno];
+                                p_cstr_info->tile[p_tile_no].pw[resno] = res_idx->pw;
+                                p_cstr_info->tile[p_tile_no].ph[resno] = res_idx->ph;
+                                numprec += res_idx->pw * res_idx->ph;
+                                p_cstr_info->tile[p_tile_no].pdx[resno] = tccp->prcw[resno];
+                                p_cstr_info->tile[p_tile_no].pdy[resno] = tccp->prch[resno];
+                        }
+                }
+                p_cstr_info->tile[p_tile_no].packet = (opj_packet_info_t *) opj_malloc(p_cstr_info->numlayers * numprec * sizeof(opj_packet_info_t));
+                p_cstr_info->packno = 0;
+        }
+        /* << INDEX */
+#endif
+
+        /*--------------TIER2------------------*/
+        /* FIXME _ProfStart(PGROUP_T2); */
+        l_data_read = 0;
+        if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index, p_manager))
+        {
+                return OPJ_FALSE;
+        }
+        /* FIXME _ProfStop(PGROUP_T2); */
+
+        /*------------------TIER1-----------------*/
+
+        /* FIXME _ProfStart(PGROUP_T1); */
+        if
+                (! opj_tcd_t1_decode(p_tcd))
+        {
+                return OPJ_FALSE;
+        }
+        /* FIXME _ProfStop(PGROUP_T1); */
+
+        /*----------------DWT---------------------*/
+
+        /* FIXME _ProfStart(PGROUP_DWT); */
+        if
+                (! opj_tcd_dwt_decode(p_tcd))
+        {
+                return OPJ_FALSE;
+        }
+        /* FIXME _ProfStop(PGROUP_DWT); */
+
+        /*----------------MCT-------------------*/
+        /* FIXME _ProfStart(PGROUP_MCT); */
+        if
+                (! opj_tcd_mct_decode(p_tcd, p_manager))
+        {
+                return OPJ_FALSE;
+        }
+        /* FIXME _ProfStop(PGROUP_MCT); */
+
+        /* FIXME _ProfStart(PGROUP_DC_SHIFT); */
+        if
+                (! opj_tcd_dc_level_shift_decode(p_tcd))
+        {
+                return OPJ_FALSE;
+        }
+        /* FIXME _ProfStop(PGROUP_DC_SHIFT); */
+
+
+        /*---------------TILE-------------------*/
+        return OPJ_TRUE;
+}
+
+OPJ_BOOL opj_tcd_update_tile_data ( opj_tcd_t *p_tcd,
+                                    OPJ_BYTE * p_dest,
+                                    OPJ_UINT32 p_dest_length
+                                    )
+{
+        OPJ_UINT32 i,j,k,l_data_size = 0;
+        opj_image_comp_t * l_img_comp = 00;
+        opj_tcd_tilecomp_t * l_tilec = 00;
+        opj_tcd_resolution_t * l_res;
+        OPJ_UINT32 l_size_comp, l_remaining;
+        OPJ_UINT32 l_stride, l_width,l_height;
+
+        l_data_size = opj_tcd_get_decoded_tile_size(p_tcd);
+        if (l_data_size > p_dest_length) {
+                return OPJ_FALSE;
+        }
+
+        l_tilec = p_tcd->tcd_image->tiles->comps;
+        l_img_comp = p_tcd->image->comps;
+
+        for (i=0;i<p_tcd->image->numcomps;++i) {
+                l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
+                l_remaining = l_img_comp->prec & 7;  /* (%8) */
+                l_res = l_tilec->resolutions + l_img_comp->resno_decoded;
+                l_width = (OPJ_UINT32)(l_res->x1 - l_res->x0);
+                l_height = (OPJ_UINT32)(l_res->y1 - l_res->y0);
+                l_stride = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0) - l_width;
+
+                if (l_remaining) {
+                        ++l_size_comp;
+                }
+
+                if (l_size_comp == 3) {
+                        l_size_comp = 4;
+                }
+
+                switch (l_size_comp)
+                        {
+                        case 1:
+                                {
+                                        OPJ_CHAR * l_dest_ptr = (OPJ_CHAR *) p_dest;
+                                        const OPJ_INT32 * l_src_ptr = l_tilec->data;
+
+                                        if (l_img_comp->sgnd) {
+                                                for (j=0;j<l_height;++j) {
+                                                        for (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr++) = (OPJ_CHAR) (*(l_src_ptr++));
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+                                        else {
+                                                for (j=0;j<l_height;++j) {
+                                                        for     (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr++) = (OPJ_CHAR) ((*(l_src_ptr++))&0xff);
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+
+                                        p_dest = (OPJ_BYTE *)l_dest_ptr;
+                                }
+                                break;
+                        case 2:
+                                {
+                                        const OPJ_INT32 * l_src_ptr = l_tilec->data;
+                                        OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_dest;
+
+                                        if (l_img_comp->sgnd) {
+                                                for (j=0;j<l_height;++j) {
+                                                        for (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr++) = (OPJ_INT16) (*(l_src_ptr++));
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+                                        else {
+                                                for (j=0;j<l_height;++j) {
+                                                        for (k=0;k<l_width;++k) {
+                                                                *(l_dest_ptr++) = (OPJ_INT16) ((*(l_src_ptr++))&0xffff);
+                                                        }
+                                                        l_src_ptr += l_stride;
+                                                }
+                                        }
+
+                                        p_dest = (OPJ_BYTE*) l_dest_ptr;
+                                }
+                                break;
+                        case 4:
+                                {
+                                        OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_dest;
+                                        OPJ_INT32 * l_src_ptr = l_tilec->data;
+
+                                        for (j=0;j<l_height;++j) {
+                                                for (k=0;k<l_width;++k) {
+                                                        *(l_dest_ptr++) = (*(l_src_ptr++));
+                                                }
+                                                l_src_ptr += l_stride;
+                                        }
+
+                                        p_dest = (OPJ_BYTE*) l_dest_ptr;
+                                }
+                                break;
+                }
+
+                ++l_img_comp;
+                ++l_tilec;
+        }
+
+        return OPJ_TRUE;
+}
+
+
+
+
+static void opj_tcd_free_tile(opj_tcd_t *p_tcd)
+{
+        OPJ_UINT32 compno, resno, bandno, precno;
+        opj_tcd_tile_t *l_tile = 00;
+        opj_tcd_tilecomp_t *l_tile_comp = 00;
+        opj_tcd_resolution_t *l_res = 00;
+        opj_tcd_band_t *l_band = 00;
+        opj_tcd_precinct_t *l_precinct = 00;
+        OPJ_UINT32 l_nb_resolutions, l_nb_precincts;
+        void (* l_tcd_code_block_deallocate) (opj_tcd_precinct_t *) = 00;
+
+        if (! p_tcd) {
+                return;
+        }
+
+        if (! p_tcd->tcd_image) {
+                return;
+        }
+
+        if (p_tcd->m_is_decoder) {
+                l_tcd_code_block_deallocate = opj_tcd_code_block_dec_deallocate;
+        }
+        else {
+                l_tcd_code_block_deallocate = opj_tcd_code_block_enc_deallocate;
+        }
+
+        l_tile = p_tcd->tcd_image->tiles;
+        if (! l_tile) {
+                return;
+        }
+
+        l_tile_comp = l_tile->comps;
+
+        for (compno = 0; compno < l_tile->numcomps; ++compno) {
+                l_res = l_tile_comp->resolutions;
+                if (l_res) {
+
+                        l_nb_resolutions = l_tile_comp->resolutions_size / sizeof(opj_tcd_resolution_t);
+                        for (resno = 0; resno < l_nb_resolutions; ++resno) {
+                                l_band = l_res->bands;
+                                for     (bandno = 0; bandno < 3; ++bandno) {
+                                        l_precinct = l_band->precincts;
+                                        if (l_precinct) {
+
+                                                l_nb_precincts = l_band->precincts_data_size / sizeof(opj_tcd_precinct_t);
+                                                for (precno = 0; precno < l_nb_precincts; ++precno) {
+                                                        opj_tgt_destroy(l_precinct->incltree);
+                                                        l_precinct->incltree = 00;
+                                                        opj_tgt_destroy(l_precinct->imsbtree);
+                                                        l_precinct->imsbtree = 00;
+                                                        (*l_tcd_code_block_deallocate) (l_precinct);
+                                                        ++l_precinct;
+                                                }
+
+                                                opj_free(l_band->precincts);
+                                                l_band->precincts = 00;
+                                        }
+                                        ++l_band;
+                                } /* for (resno */
+                                ++l_res;
+                        }
+
+                        opj_free(l_tile_comp->resolutions);
+                        l_tile_comp->resolutions = 00;
+                }
+
+                if (l_tile_comp->ownsData && l_tile_comp->data) {
+                        opj_aligned_free(l_tile_comp->data);
+                        l_tile_comp->data = 00;
+                        l_tile_comp->ownsData = 0;
+                        l_tile_comp->data_size = 0;
+                        l_tile_comp->data_size_needed = 0;
+                }
+                ++l_tile_comp;
+        }
+
+        opj_free(l_tile->comps);
+        l_tile->comps = 00;
+        opj_free(p_tcd->tcd_image->tiles);
+        p_tcd->tcd_image->tiles = 00;
+}
+
+
+static OPJ_BOOL opj_tcd_t2_decode (opj_tcd_t *p_tcd,
+                            OPJ_BYTE * p_src_data,
+                            OPJ_UINT32 * p_data_read,
+                            OPJ_UINT32 p_max_src_size,
+                            opj_codestream_index_t *p_cstr_index,
+                            opj_event_mgr_t *p_manager
+                            )
+{
+        opj_t2_t * l_t2;
+
+        l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp);
+        if (l_t2 == 00) {
+                return OPJ_FALSE;
+        }
+
+        if (! opj_t2_decode_packets(
+                                        l_t2,
+                                        p_tcd->tcd_tileno,
+                                        p_tcd->tcd_image->tiles,
+                                        p_src_data,
+                                        p_data_read,
+                                        p_max_src_size,
+                                        p_cstr_index,
+                                        p_manager)) {
+                opj_t2_destroy(l_t2);
+                return OPJ_FALSE;
+        }
+
+        opj_t2_destroy(l_t2);
+
+        /*---------------CLEAN-------------------*/
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_tcd_t1_decode ( opj_tcd_t *p_tcd )
+{
+        OPJ_UINT32 compno;
+        opj_t1_t * l_t1;
+        opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
+        opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps;
+        opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
+
+
+        l_t1 = opj_t1_create(OPJ_FALSE);
+        if (l_t1 == 00) {
+                return OPJ_FALSE;
+        }
+
+        for (compno = 0; compno < l_tile->numcomps; ++compno) {
+                /* The +3 is headroom required by the vectorized DWT */
+                if (OPJ_FALSE == opj_t1_decode_cblks(l_t1, l_tile_comp, l_tccp)) {
+                        opj_t1_destroy(l_t1);
+                        return OPJ_FALSE;
+                }
+                ++l_tile_comp;
+                ++l_tccp;
+        }
+
+        opj_t1_destroy(l_t1);
+
+        return OPJ_TRUE;
+}
+
+
+static OPJ_BOOL opj_tcd_dwt_decode ( opj_tcd_t *p_tcd )
+{
+        OPJ_UINT32 compno;
+        opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
+        opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
+        opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
+        opj_image_comp_t * l_img_comp = p_tcd->image->comps;
+
+        for (compno = 0; compno < l_tile->numcomps; compno++) {
+                /*
+                if (tcd->cp->reduce != 0) {
+                        tcd->image->comps[compno].resno_decoded =
+                                tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
+                        if (tcd->image->comps[compno].resno_decoded < 0)
+                        {
+                                return false;
+                        }
+                }
+                numres2decode = tcd->image->comps[compno].resno_decoded + 1;
+                if(numres2decode > 0){
+                */
+
+                if (l_tccp->qmfbid == 1) {
+                        if (! opj_dwt_decode(l_tile_comp, l_img_comp->resno_decoded+1)) {
+                                return OPJ_FALSE;
+                        }
+                }
+                else {
+                        if (! opj_dwt_decode_real(l_tile_comp, l_img_comp->resno_decoded+1)) {
+                                return OPJ_FALSE;
+                        }
+                }
+
+                ++l_tile_comp;
+                ++l_img_comp;
+                ++l_tccp;
+        }
+
+        return OPJ_TRUE;
+}
+static OPJ_BOOL opj_tcd_mct_decode ( opj_tcd_t *p_tcd, opj_event_mgr_t *p_manager)
+{
+        opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
+        opj_tcp_t * l_tcp = p_tcd->tcp;
+        opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
+        OPJ_UINT32 l_samples,i;
+
+        if (! l_tcp->mct) {
+                return OPJ_TRUE;
+        }
+
+        l_samples = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_comp->y1 - l_tile_comp->y0));
+
+        if (l_tile->numcomps >= 3 ){
+                /* testcase 1336.pdf.asan.47.376 */
+                if ((l_tile->comps[0].x1 - l_tile->comps[0].x0) * (l_tile->comps[0].y1 - l_tile->comps[0].y0) < (OPJ_INT32)l_samples ||
+                    (l_tile->comps[1].x1 - l_tile->comps[1].x0) * (l_tile->comps[1].y1 - l_tile->comps[1].y0) < (OPJ_INT32)l_samples ||
+                    (l_tile->comps[2].x1 - l_tile->comps[2].x0) * (l_tile->comps[2].y1 - l_tile->comps[2].y0) < (OPJ_INT32)l_samples) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Tiles don't all have the same dimension. Skip the MCT step.\n");
+                        return OPJ_FALSE;
+                }
+                else if (l_tcp->mct == 2) {
+                        OPJ_BYTE ** l_data;
+
+                        if (! l_tcp->m_mct_decoding_matrix) {
+                                return OPJ_TRUE;
+                        }
+
+                        l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps*sizeof(OPJ_BYTE*));
+                        if (! l_data) {
+                                return OPJ_FALSE;
+                        }
+
+                        for (i=0;i<l_tile->numcomps;++i) {
+                                l_data[i] = (OPJ_BYTE*) l_tile_comp->data;
+                                ++l_tile_comp;
+                        }
+
+                        if (! opj_mct_decode_custom(/* MCT data */
+                                                                        (OPJ_BYTE*) l_tcp->m_mct_decoding_matrix,
+                                                                        /* size of components */
+                                                                        l_samples,
+                                                                        /* components */
+                                                                        l_data,
+                                                                        /* nb of components (i.e. size of pData) */
+                                                                        l_tile->numcomps,
+                                                                        /* tells if the data is signed */
+                                                                        p_tcd->image->comps->sgnd)) {
+                                opj_free(l_data);
+                                return OPJ_FALSE;
+                        }
+
+                        opj_free(l_data);
+                }
+                else {
+                        if (l_tcp->tccps->qmfbid == 1) {
+                                opj_mct_decode(     l_tile->comps[0].data,
+                                                        l_tile->comps[1].data,
+                                                        l_tile->comps[2].data,
+                                                        l_samples);
+                        }
+                        else {
+                            opj_mct_decode_real((OPJ_FLOAT32*)l_tile->comps[0].data,
+                                                (OPJ_FLOAT32*)l_tile->comps[1].data,
+                                                (OPJ_FLOAT32*)l_tile->comps[2].data,
+                                                l_samples);
+                        }
+                }
+        }
+        else {
+                opj_event_msg(p_manager, EVT_ERROR, "Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",l_tile->numcomps);
+        }
+
+        return OPJ_TRUE;
+}
+
+
+static OPJ_BOOL opj_tcd_dc_level_shift_decode ( opj_tcd_t *p_tcd )
+{
+        OPJ_UINT32 compno;
+        opj_tcd_tilecomp_t * l_tile_comp = 00;
+        opj_tccp_t * l_tccp = 00;
+        opj_image_comp_t * l_img_comp = 00;
+        opj_tcd_resolution_t* l_res = 00;
+        opj_tcd_tile_t * l_tile;
+        OPJ_UINT32 l_width,l_height,i,j;
+        OPJ_INT32 * l_current_ptr;
+        OPJ_INT32 l_min, l_max;
+        OPJ_UINT32 l_stride;
+
+        l_tile = p_tcd->tcd_image->tiles;
+        l_tile_comp = l_tile->comps;
+        l_tccp = p_tcd->tcp->tccps;
+        l_img_comp = p_tcd->image->comps;
+
+        for (compno = 0; compno < l_tile->numcomps; compno++) {
+                l_res = l_tile_comp->resolutions + l_img_comp->resno_decoded;
+                l_width = (OPJ_UINT32)(l_res->x1 - l_res->x0);
+                l_height = (OPJ_UINT32)(l_res->y1 - l_res->y0);
+                l_stride = (OPJ_UINT32)(l_tile_comp->x1 - l_tile_comp->x0) - l_width;
+
+                assert(l_height == 0 || l_width + l_stride <= l_tile_comp->data_size / l_height); /*MUPDF*/
+
+                if (l_img_comp->sgnd) {
+                        l_min = -(1 << (l_img_comp->prec - 1));
+                        l_max = (1 << (l_img_comp->prec - 1)) - 1;
+                }
+                else {
+            l_min = 0;
+                        l_max = (1 << l_img_comp->prec) - 1;
+                }
+
+                l_current_ptr = l_tile_comp->data;
+
+                if (l_tccp->qmfbid == 1) {
+                        for (j=0;j<l_height;++j) {
+                                for (i = 0; i < l_width; ++i) {
+                                        *l_current_ptr = opj_int_clamp(*l_current_ptr + l_tccp->m_dc_level_shift, l_min, l_max);
+                                        ++l_current_ptr;
+                                }
+                                l_current_ptr += l_stride;
+                        }
+                }
+                else {
+                        for (j=0;j<l_height;++j) {
+                                for (i = 0; i < l_width; ++i) {
+                                        OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *) l_current_ptr);
+                                        *l_current_ptr = opj_int_clamp((OPJ_INT32)opj_lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ;
+                                        ++l_current_ptr;
+                                }
+                                l_current_ptr += l_stride;
+                        }
+                }
+
+                ++l_img_comp;
+                ++l_tccp;
+                ++l_tile_comp;
+        }
+
+        return OPJ_TRUE;
+}
+
+
+
+/**
+ * Deallocates the encoding data of the given precinct.
+ */
+static void opj_tcd_code_block_dec_deallocate (opj_tcd_precinct_t * p_precinct)
+{
+        OPJ_UINT32 cblkno , l_nb_code_blocks;
+
+        opj_tcd_cblk_dec_t * l_code_block = p_precinct->cblks.dec;
+        if (l_code_block) {
+                /*fprintf(stderr,"deallocate codeblock:{\n");*/
+                /*fprintf(stderr,"\t x0=%d, y0=%d, x1=%d, y1=%d\n",l_code_block->x0, l_code_block->y0, l_code_block->x1, l_code_block->y1);*/
+                /*fprintf(stderr,"\t numbps=%d, numlenbits=%d, len=%d, numnewpasses=%d, real_num_segs=%d, m_current_max_segs=%d\n ",
+                                l_code_block->numbps, l_code_block->numlenbits, l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_code_block->m_current_max_segs );*/
+
+
+                l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_dec_t);
+                /*fprintf(stderr,"nb_code_blocks =%d\t}\n", l_nb_code_blocks);*/
+
+                for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
+
+                        if (l_code_block->data) {
+                                opj_free(l_code_block->data);
+                                l_code_block->data = 00;
+                        }
+
+                        if (l_code_block->segs) {
+                                opj_free(l_code_block->segs );
+                                l_code_block->segs = 00;
+                        }
+
+                        ++l_code_block;
+                }
+
+                opj_free(p_precinct->cblks.dec);
+                p_precinct->cblks.dec = 00;
+        }
+}
+
+/**
+ * Deallocates the encoding data of the given precinct.
+ */
+static void opj_tcd_code_block_enc_deallocate (opj_tcd_precinct_t * p_precinct)
+{       
+        OPJ_UINT32 cblkno , l_nb_code_blocks;
+
+        opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc;
+        if (l_code_block) {
+                l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_enc_t);
+                
+                for     (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)  {
+                        if (l_code_block->data) {
+                                opj_free(l_code_block->data - 1);
+                                l_code_block->data = 00;
+                        }
+
+                        if (l_code_block->layers) {
+                                opj_free(l_code_block->layers );
+                                l_code_block->layers = 00;
+                        }
+
+                        if (l_code_block->passes) {
+                                opj_free(l_code_block->passes );
+                                l_code_block->passes = 00;
+                        }
+                        ++l_code_block;
+                }
+
+                opj_free(p_precinct->cblks.enc);
+                
+                p_precinct->cblks.enc = 00;
+        }
+}
+
+OPJ_UINT32 opj_tcd_get_encoded_tile_size ( opj_tcd_t *p_tcd )
+{
+        OPJ_UINT32 i,l_data_size = 0;
+        opj_image_comp_t * l_img_comp = 00;
+        opj_tcd_tilecomp_t * l_tilec = 00;
+        OPJ_UINT32 l_size_comp, l_remaining;
+
+        l_tilec = p_tcd->tcd_image->tiles->comps;
+        l_img_comp = p_tcd->image->comps;
+        for (i=0;i<p_tcd->image->numcomps;++i) {
+                l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
+                l_remaining = l_img_comp->prec & 7;  /* (%8) */
+
+                if (l_remaining) {
+                        ++l_size_comp;
+                }
+
+                if (l_size_comp == 3) {
+                        l_size_comp = 4;
+                }
+
+                l_data_size += l_size_comp * (OPJ_UINT32)((l_tilec->x1 - l_tilec->x0) * (l_tilec->y1 - l_tilec->y0));
+                ++l_img_comp;
+                ++l_tilec;
+        }
+
+        return l_data_size;
+}
+                
+static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd )
+{
+        OPJ_UINT32 compno;
+        opj_tcd_tilecomp_t * l_tile_comp = 00;
+        opj_tccp_t * l_tccp = 00;
+        opj_image_comp_t * l_img_comp = 00;
+        opj_tcd_tile_t * l_tile;
+        OPJ_UINT32 l_nb_elem,i;
+        OPJ_INT32 * l_current_ptr;
+
+        l_tile = p_tcd->tcd_image->tiles;
+        l_tile_comp = l_tile->comps;
+        l_tccp = p_tcd->tcp->tccps;
+        l_img_comp = p_tcd->image->comps;
+
+        for (compno = 0; compno < l_tile->numcomps; compno++) {
+                l_current_ptr = l_tile_comp->data;
+                l_nb_elem = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_comp->y1 - l_tile_comp->y0));
+
+                if (l_tccp->qmfbid == 1) {
+                        for     (i = 0; i < l_nb_elem; ++i) {
+                                *l_current_ptr -= l_tccp->m_dc_level_shift ;
+                                ++l_current_ptr;
+                        }
+                }
+                else {
+                        for (i = 0; i < l_nb_elem; ++i) {
+                                *l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) * (1 << 11);
+                                ++l_current_ptr;
+                        }
+                }
+
+                ++l_img_comp;
+                ++l_tccp;
+                ++l_tile_comp;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_tcd_mct_encode ( opj_tcd_t *p_tcd )
+{
+        opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
+        opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps;
+        OPJ_UINT32 samples = (OPJ_UINT32)((l_tile_comp->x1 - l_tile_comp->x0) * (l_tile_comp->y1 - l_tile_comp->y0));
+        OPJ_UINT32 i;
+        OPJ_BYTE ** l_data = 00;
+        opj_tcp_t * l_tcp = p_tcd->tcp;
+
+        if(!p_tcd->tcp->mct) {
+                return OPJ_TRUE;
+        }
+
+        if (p_tcd->tcp->mct == 2) {
+                if (! p_tcd->tcp->m_mct_coding_matrix) {
+                        return OPJ_TRUE;
+                }
+
+        l_data = (OPJ_BYTE **) opj_malloc(l_tile->numcomps*sizeof(OPJ_BYTE*));
+                if (! l_data) {
+                        return OPJ_FALSE;
+                }
+
+                for (i=0;i<l_tile->numcomps;++i) {
+                        l_data[i] = (OPJ_BYTE*) l_tile_comp->data;
+                        ++l_tile_comp;
+                }
+
+                if (! opj_mct_encode_custom(/* MCT data */
+                                        (OPJ_BYTE*) p_tcd->tcp->m_mct_coding_matrix,
+                                        /* size of components */
+                                        samples,
+                                        /* components */
+                                        l_data,
+                                        /* nb of components (i.e. size of pData) */
+                                        l_tile->numcomps,
+                                        /* tells if the data is signed */
+                                        p_tcd->image->comps->sgnd) )
+                {
+            opj_free(l_data);
+                        return OPJ_FALSE;
+                }
+
+                opj_free(l_data);
+        }
+        else if (l_tcp->tccps->qmfbid == 0) {
+                opj_mct_encode_real(l_tile->comps[0].data, l_tile->comps[1].data, l_tile->comps[2].data, samples);
+        }
+        else {
+                opj_mct_encode(l_tile->comps[0].data, l_tile->comps[1].data, l_tile->comps[2].data, samples);
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_tcd_dwt_encode ( opj_tcd_t *p_tcd )
+{
+        opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
+        opj_tcd_tilecomp_t * l_tile_comp = p_tcd->tcd_image->tiles->comps;
+        opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
+        OPJ_UINT32 compno;
+
+        for (compno = 0; compno < l_tile->numcomps; ++compno) {
+                if (l_tccp->qmfbid == 1) {
+                        if (! opj_dwt_encode(l_tile_comp)) {
+                                return OPJ_FALSE;
+                        }
+                }
+                else if (l_tccp->qmfbid == 0) {
+                        if (! opj_dwt_encode_real(l_tile_comp)) {
+                                return OPJ_FALSE;
+                        }
+                }
+
+                ++l_tile_comp;
+                ++l_tccp;
+        }
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_tcd_t1_encode ( opj_tcd_t *p_tcd )
+{
+        opj_t1_t * l_t1;
+        const OPJ_FLOAT64 * l_mct_norms;
+        OPJ_UINT32 l_mct_numcomps = 0U;
+        opj_tcp_t * l_tcp = p_tcd->tcp;
+
+        l_t1 = opj_t1_create(OPJ_TRUE);
+        if (l_t1 == 00) {
+                return OPJ_FALSE;
+        }
+
+        if (l_tcp->mct == 1) {
+                l_mct_numcomps = 3U;
+                /* irreversible encoding */
+                if (l_tcp->tccps->qmfbid == 0) {
+                        l_mct_norms = opj_mct_get_mct_norms_real();
+                }
+                else {
+                        l_mct_norms = opj_mct_get_mct_norms();
+                }
+        }
+        else {
+                l_mct_numcomps = p_tcd->image->numcomps;
+                l_mct_norms = (const OPJ_FLOAT64 *) (l_tcp->mct_norms);
+        }
+
+        if (! opj_t1_encode_cblks(l_t1, p_tcd->tcd_image->tiles , l_tcp, l_mct_norms, l_mct_numcomps)) {
+        opj_t1_destroy(l_t1);
+                return OPJ_FALSE;
+        }
+
+        opj_t1_destroy(l_t1);
+
+        return OPJ_TRUE;
+}
+
+static OPJ_BOOL opj_tcd_t2_encode (opj_tcd_t *p_tcd,
+                                                OPJ_BYTE * p_dest_data,
+                                                OPJ_UINT32 * p_data_written,
+                                                OPJ_UINT32 p_max_dest_size,
+                                                opj_codestream_info_t *p_cstr_info )
+{
+        opj_t2_t * l_t2;
+
+        l_t2 = opj_t2_create(p_tcd->image, p_tcd->cp);
+        if (l_t2 == 00) {
+                return OPJ_FALSE;
+        }
+
+        if (! opj_t2_encode_packets(
+                                        l_t2,
+                                        p_tcd->tcd_tileno,
+                                        p_tcd->tcd_image->tiles,
+                                        p_tcd->tcp->numlayers,
+                                        p_dest_data,
+                                        p_data_written,
+                                        p_max_dest_size,
+                                        p_cstr_info,
+                                        p_tcd->tp_num,
+                                        p_tcd->tp_pos,
+                                        p_tcd->cur_pino,
+                                        FINAL_PASS))
+        {
+                opj_t2_destroy(l_t2);
+                return OPJ_FALSE;
+        }
+
+        opj_t2_destroy(l_t2);
+
+        /*---------------CLEAN-------------------*/
+        return OPJ_TRUE;
+}
+
+
+static OPJ_BOOL opj_tcd_rate_allocate_encode(  opj_tcd_t *p_tcd,
+                                                                            OPJ_BYTE * p_dest_data,
+                                                                            OPJ_UINT32 p_max_dest_size,
+                                                                            opj_codestream_info_t *p_cstr_info )
+{
+        opj_cp_t * l_cp = p_tcd->cp;
+        OPJ_UINT32 l_nb_written = 0;
+
+        if (p_cstr_info)  {
+                p_cstr_info->index_write = 0;
+        }
+
+        if (l_cp->m_specific_param.m_enc.m_disto_alloc|| l_cp->m_specific_param.m_enc.m_fixed_quality)  {
+                /* fixed_quality */
+                /* Normal Rate/distortion allocation */
+                if (! opj_tcd_rateallocate(p_tcd, p_dest_data,&l_nb_written, p_max_dest_size, p_cstr_info)) {
+                        return OPJ_FALSE;
+                }
+        }
+        else {
+                /* Fixed layer allocation */
+                opj_tcd_rateallocate_fixed(p_tcd);
+        }
+
+        return OPJ_TRUE;
+}
+
+
+OPJ_BOOL opj_tcd_copy_tile_data (       opj_tcd_t *p_tcd,
+                                                                    OPJ_BYTE * p_src,
+                                                                    OPJ_UINT32 p_src_length )
+{
+        OPJ_UINT32 i,j,l_data_size = 0;
+        opj_image_comp_t * l_img_comp = 00;
+        opj_tcd_tilecomp_t * l_tilec = 00;
+        OPJ_UINT32 l_size_comp, l_remaining;
+        OPJ_UINT32 l_nb_elem;
+
+        l_data_size = opj_tcd_get_encoded_tile_size(p_tcd);
+        if (l_data_size != p_src_length) {
+                return OPJ_FALSE;
+        }
+
+        l_tilec = p_tcd->tcd_image->tiles->comps;
+        l_img_comp = p_tcd->image->comps;
+        for (i=0;i<p_tcd->image->numcomps;++i) {
+                l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
+                l_remaining = l_img_comp->prec & 7;  /* (%8) */
+                l_nb_elem = (OPJ_UINT32)((l_tilec->x1 - l_tilec->x0) * (l_tilec->y1 - l_tilec->y0));
+
+                if (l_remaining) {
+                        ++l_size_comp;
+                }
+
+                if (l_size_comp == 3) {
+                        l_size_comp = 4;
+                }
+
+                switch (l_size_comp) {
+                        case 1:
+                                {
+                                        OPJ_CHAR * l_src_ptr = (OPJ_CHAR *) p_src;
+                                        OPJ_INT32 * l_dest_ptr = l_tilec->data;
+
+                                        if (l_img_comp->sgnd) {
+                                                for (j=0;j<l_nb_elem;++j) {
+                                                        *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
+                                                }
+                                        }
+                                        else {
+                                                for (j=0;j<l_nb_elem;++j) {
+                                                        *(l_dest_ptr++) = (*(l_src_ptr++))&0xff;
+                                                }
+                                        }
+
+                                        p_src = (OPJ_BYTE*) l_src_ptr;
+                                }
+                                break;
+                        case 2:
+                                {
+                                        OPJ_INT32 * l_dest_ptr = l_tilec->data;
+                                        OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_src;
+
+                                        if (l_img_comp->sgnd) {
+                                                for (j=0;j<l_nb_elem;++j) {
+                                                        *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
+                                                }
+                                        }
+                                        else {
+                                                for (j=0;j<l_nb_elem;++j) {
+                                                        *(l_dest_ptr++) = (*(l_src_ptr++))&0xffff;
+                                                }
+                                        }
+
+                                        p_src = (OPJ_BYTE*) l_src_ptr;
+                                }
+                                break;
+                        case 4:
+                                {
+                                        OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_src;
+                                        OPJ_INT32 * l_dest_ptr = l_tilec->data;
+
+                                        for (j=0;j<l_nb_elem;++j) {
+                                                *(l_dest_ptr++) = (OPJ_INT32) (*(l_src_ptr++));
+                                        }
+
+                                        p_src = (OPJ_BYTE*) l_src_ptr;
+                                }
+                                break;
+                }
+
+                ++l_img_comp;
+                ++l_tilec;
+        }
+
+        return OPJ_TRUE;
+}
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.h
new file mode 100644
index 0000000..07f8379
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/tcd.h
@@ -0,0 +1,369 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __TCD_H
+#define __TCD_H
+/**
+ at file tcd.h
+ at brief Implementation of a tile coder/decoder (TCD)
+
+The functions in TCD.C encode or decode each tile independently from
+each other. The functions in TCD.C are used by other functions in J2K.C.
+*/
+
+/** @defgroup TCD TCD - Implementation of a tile coder/decoder */
+/*@{*/
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_seg {
+	OPJ_BYTE ** data;
+	OPJ_UINT32 dataindex;
+	OPJ_UINT32 numpasses;
+	OPJ_UINT32 real_num_passes;
+	OPJ_UINT32 len;
+	OPJ_UINT32 maxpasses;
+	OPJ_UINT32 numnewpasses;
+	OPJ_UINT32 newlen;
+} opj_tcd_seg_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_pass {
+	OPJ_UINT32 rate;
+	OPJ_FLOAT64 distortiondec;
+	OPJ_UINT32 len;
+	OPJ_UINT32 term : 1;
+} opj_tcd_pass_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_layer {
+	OPJ_UINT32 numpasses;		/* Number of passes in the layer */
+	OPJ_UINT32 len;				/* len of information */
+	OPJ_FLOAT64 disto;			/* add for index (Cfr. Marcela) */
+	OPJ_BYTE *data;				/* data */
+} opj_tcd_layer_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_cblk_enc {
+	OPJ_BYTE* data;               /* Data */
+	opj_tcd_layer_t* layers;      /* layer information */
+	opj_tcd_pass_t* passes;       /* information about the passes */
+	OPJ_INT32 x0, y0, x1, y1;     /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
+	OPJ_UINT32 numbps;
+	OPJ_UINT32 numlenbits;
+	OPJ_UINT32 data_size;         /* Size of allocated data buffer */
+	OPJ_UINT32 numpasses;         /* number of pass already done for the code-blocks */
+	OPJ_UINT32 numpassesinlayers; /* number of passes in the layer */
+	OPJ_UINT32 totalpasses;	      /* total number of passes */
+} opj_tcd_cblk_enc_t;
+
+
+typedef struct opj_tcd_cblk_dec {
+	OPJ_BYTE * data;				/* Data */
+	opj_tcd_seg_t* segs;			/* segments information */
+	OPJ_INT32 x0, y0, x1, y1;		/* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
+	OPJ_UINT32 numbps;
+	OPJ_UINT32 numlenbits;
+	OPJ_UINT32 data_max_size;		/* Size of allocated data buffer */
+	OPJ_UINT32 data_current_size;	/* Size of used data buffer */
+	OPJ_UINT32 numnewpasses;		/* number of pass added to the code-blocks */
+	OPJ_UINT32 numsegs;				/* number of segments */
+	OPJ_UINT32 real_num_segs;
+	OPJ_UINT32 m_current_max_segs;
+} opj_tcd_cblk_dec_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_precinct {
+	OPJ_INT32 x0, y0, x1, y1;		/* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
+	OPJ_UINT32 cw, ch;				/* number of precinct in width and height */
+	union{							/* code-blocks information */
+		opj_tcd_cblk_enc_t* enc;
+		opj_tcd_cblk_dec_t* dec;
+		void*               blocks;
+	} cblks;
+	OPJ_UINT32 block_size;			/* size taken by cblks (in bytes) */
+	opj_tgt_tree_t *incltree;	    /* inclusion tree */
+	opj_tgt_tree_t *imsbtree;	    /* IMSB tree */
+} opj_tcd_precinct_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_band {
+	OPJ_INT32 x0, y0, x1, y1;		/* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
+	OPJ_UINT32 bandno;
+	opj_tcd_precinct_t *precincts;	/* precinct information */
+	OPJ_UINT32 precincts_data_size;	/* size of data taken by precincts */
+	OPJ_INT32 numbps;
+	OPJ_FLOAT32 stepsize;
+} opj_tcd_band_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_resolution {
+	OPJ_INT32 x0, y0, x1, y1;		/* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */
+	OPJ_UINT32 pw, ph;
+	OPJ_UINT32 numbands;			/* number sub-band for the resolution level */
+	opj_tcd_band_t bands[3];		/* subband information */
+} opj_tcd_resolution_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_tilecomp
+{
+	OPJ_INT32 x0, y0, x1, y1;           /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
+	OPJ_UINT32 numresolutions;          /* number of resolutions level */
+	OPJ_UINT32 minimum_num_resolutions; /* number of resolutions level to decode (at max)*/
+	opj_tcd_resolution_t *resolutions;  /* resolutions information */
+	OPJ_UINT32 resolutions_size;        /* size of data for resolutions (in bytes) */
+	OPJ_INT32 *data;                    /* data of the component */
+	OPJ_BOOL  ownsData;                 /* if true, then need to free after usage, otherwise do not free */
+	OPJ_UINT32 data_size_needed;        /* we may either need to allocate this amount of data, or re-use image data and ignore this value */
+	OPJ_UINT32 data_size;               /* size of the data of the component */
+	OPJ_INT32 numpix;                   /* add fixed_quality */
+} opj_tcd_tilecomp_t;
+
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_tile {
+	OPJ_INT32 x0, y0, x1, y1;		/* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */
+	OPJ_UINT32 numcomps;			/* number of components in tile */
+	opj_tcd_tilecomp_t *comps;	/* Components information */
+	OPJ_INT32 numpix;				/* add fixed_quality */
+	OPJ_FLOAT64 distotile;			/* add fixed_quality */
+	OPJ_FLOAT64 distolayer[100];	/* add fixed_quality */
+	OPJ_UINT32 packno;              /* packet number */
+} opj_tcd_tile_t;
+
+/**
+FIXME DOC
+*/
+typedef struct opj_tcd_image
+{
+	opj_tcd_tile_t *tiles;		/* Tiles information */
+}
+opj_tcd_image_t;
+
+
+/**
+Tile coder/decoder
+*/
+typedef struct opj_tcd
+{
+	/** Position of the tilepart flag in Progression order*/
+	OPJ_INT32 tp_pos;
+	/** Tile part number*/
+	OPJ_UINT32 tp_num;
+	/** Current tile part number*/
+	OPJ_UINT32 cur_tp_num;
+	/** Total number of tileparts of the current tile*/
+	OPJ_UINT32 cur_totnum_tp;
+	/** Current Packet iterator number */
+	OPJ_UINT32 cur_pino;
+	/** info on each image tile */
+	opj_tcd_image_t *tcd_image;
+	/** image header */
+	opj_image_t *image;
+	/** coding parameters */
+	opj_cp_t *cp;
+	/** coding/decoding parameters common to all tiles */
+	opj_tcp_t *tcp;
+	/** current encoded/decoded tile */
+	OPJ_UINT32 tcd_tileno;
+	/** tell if the tcd is a decoder. */
+	OPJ_UINT32 m_is_decoder : 1;
+} opj_tcd_t;
+
+/** @name Exported functions */
+/*@{*/
+/* ----------------------------------------------------------------------- */
+
+/**
+Dump the content of a tcd structure
+*/
+/*void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);*/ /* TODO MSD shoul use the new v2 structures */ 
+
+/**
+Create a new TCD handle
+ at param p_is_decoder FIXME DOC
+ at return Returns a new TCD handle if successful returns NULL otherwise
+*/
+opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder);
+
+/**
+Destroy a previously created TCD handle
+ at param tcd TCD handle to destroy
+*/
+void opj_tcd_destroy(opj_tcd_t *tcd);
+
+/**
+ * Initialize the tile coder and may reuse some memory.
+ * @param	p_tcd		TCD handle.
+ * @param	p_image		raw image.
+ * @param	p_cp		coding parameters.
+ *
+ * @return true if the encoding values could be set (false otherwise).
+*/
+OPJ_BOOL opj_tcd_init(	opj_tcd_t *p_tcd,
+						opj_image_t * p_image,
+						opj_cp_t * p_cp );
+
+/**
+ * Allocates memory for decoding a specific tile.
+ *
+ * @param	p_tcd		the tile decoder.
+ * @param	p_tile_no	the index of the tile received in sequence. This not necessarily lead to the
+ * tile at index p_tile_no.
+ * @param p_manager the event manager.
+ *
+ * @return	true if the remaining data is sufficient.
+ */
+OPJ_BOOL opj_tcd_init_decode_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager);
+
+void opj_tcd_makelayer_fixed(opj_tcd_t *tcd, OPJ_UINT32 layno, OPJ_UINT32 final);
+
+void opj_tcd_rateallocate_fixed(opj_tcd_t *tcd);
+
+void opj_tcd_makelayer(	opj_tcd_t *tcd,
+						OPJ_UINT32 layno,
+						OPJ_FLOAT64 thresh,
+						OPJ_UINT32 final);
+
+OPJ_BOOL opj_tcd_rateallocate(	opj_tcd_t *tcd,
+								OPJ_BYTE *dest,
+								OPJ_UINT32 * p_data_written,
+								OPJ_UINT32 len,
+								opj_codestream_info_t *cstr_info);
+
+/**
+ * Gets the maximum tile size that will be taken by the tile once decoded.
+ */
+OPJ_UINT32 opj_tcd_get_decoded_tile_size (opj_tcd_t *p_tcd );
+
+/**
+ * Encodes a tile from the raw image into the given buffer.
+ * @param	p_tcd			Tile Coder handle
+ * @param	p_tile_no		Index of the tile to encode.
+ * @param	p_dest			Destination buffer
+ * @param	p_data_written	pointer to an int that is incremented by the number of bytes really written on p_dest
+ * @param	p_len			Maximum length of the destination buffer
+ * @param	p_cstr_info		Codestream information structure
+ * @return  true if the coding is successful.
+*/
+OPJ_BOOL opj_tcd_encode_tile(   opj_tcd_t *p_tcd,
+							    OPJ_UINT32 p_tile_no,
+							    OPJ_BYTE *p_dest,
+							    OPJ_UINT32 * p_data_written,
+							    OPJ_UINT32 p_len,
+							    struct opj_codestream_info *p_cstr_info);
+
+
+/**
+Decode a tile from a buffer into a raw image
+ at param tcd TCD handle
+ at param src Source buffer
+ at param len Length of source buffer
+ at param tileno Number that identifies one of the tiles to be decoded
+ at param cstr_info  FIXME DOC
+ at param manager the event manager.
+*/
+OPJ_BOOL opj_tcd_decode_tile(   opj_tcd_t *tcd,
+							    OPJ_BYTE *src,
+							    OPJ_UINT32 len,
+							    OPJ_UINT32 tileno,
+							    opj_codestream_index_t *cstr_info,
+							    opj_event_mgr_t *manager);
+
+
+/**
+ * Copies tile data from the system onto the given memory block.
+ */
+OPJ_BOOL opj_tcd_update_tile_data (	opj_tcd_t *p_tcd,
+								    OPJ_BYTE * p_dest,
+								    OPJ_UINT32 p_dest_length );
+
+/**
+ *
+ */
+OPJ_UINT32 opj_tcd_get_encoded_tile_size ( opj_tcd_t *p_tcd );
+
+/**
+ * Initialize the tile coder and may reuse some meory.
+ *
+ * @param	p_tcd		TCD handle.
+ * @param	p_tile_no	current tile index to encode.
+ * @param p_manager the event manager.
+ *
+ * @return true if the encoding values could be set (false otherwise).
+*/
+OPJ_BOOL opj_tcd_init_encode_tile (	opj_tcd_t *p_tcd,
+								    OPJ_UINT32 p_tile_no, opj_event_mgr_t* p_manager );
+
+/**
+ * Copies tile data from the given memory block onto the system.
+ */
+OPJ_BOOL opj_tcd_copy_tile_data (opj_tcd_t *p_tcd,
+                                 OPJ_BYTE * p_src,
+                                 OPJ_UINT32 p_src_length );
+
+/**
+ * Allocates tile component data
+ *
+ *
+ */
+OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec);
+
+/* ----------------------------------------------------------------------- */
+/*@}*/
+
+/*@}*/
+
+#endif /* __TCD_H */
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/tgt.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/tgt.c
new file mode 100644
index 0000000..5e34aa9
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/tgt.c
@@ -0,0 +1,335 @@
+/*
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
+ * Copyright (c) 2012, CS Systemes d'Information, France
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opj_includes.h"
+
+/* 
+==========================================================
+   Tag-tree coder interface
+==========================================================
+*/
+
+opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, opj_event_mgr_t *manager) {
+        OPJ_INT32 nplh[32];
+        OPJ_INT32 nplv[32];
+        opj_tgt_node_t *node = 00;
+        opj_tgt_node_t *l_parent_node = 00;
+        opj_tgt_node_t *l_parent_node0 = 00;
+        opj_tgt_tree_t *tree = 00;
+        OPJ_UINT32 i;
+        OPJ_INT32  j,k;
+        OPJ_UINT32 numlvls;
+        OPJ_UINT32 n;
+
+        tree = (opj_tgt_tree_t *) opj_calloc(1,sizeof(opj_tgt_tree_t));
+        if(!tree) {
+                opj_event_msg(manager, EVT_ERROR, "Not enough memory to create Tag-tree\n");
+                return 00;
+        }
+
+        tree->numleafsh = numleafsh;
+        tree->numleafsv = numleafsv;
+
+        numlvls = 0;
+        nplh[0] = (OPJ_INT32)numleafsh;
+        nplv[0] = (OPJ_INT32)numleafsv;
+        tree->numnodes = 0;
+        do {
+                n = (OPJ_UINT32)(nplh[numlvls] * nplv[numlvls]);
+                nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
+                nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
+                tree->numnodes += n;
+                ++numlvls;
+        } while (n > 1);
+
+        /* ADD */
+        if (tree->numnodes == 0) {
+                opj_free(tree);
+                opj_event_msg(manager, EVT_WARNING, "tgt_create tree->numnodes == 0, no tree created.\n");
+                return 00;
+        }
+
+        tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes, sizeof(opj_tgt_node_t));
+        if(!tree->nodes) {
+                opj_event_msg(manager, EVT_ERROR, "Not enough memory to create Tag-tree nodes\n");
+                opj_free(tree);
+                return 00;
+        }
+        tree->nodes_size = tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node_t);
+
+        node = tree->nodes;
+        l_parent_node = &tree->nodes[tree->numleafsh * tree->numleafsv];
+        l_parent_node0 = l_parent_node;
+
+        for (i = 0; i < numlvls - 1; ++i) {
+                for (j = 0; j < nplv[i]; ++j) {
+                        k = nplh[i];
+                        while (--k >= 0) {
+                                node->parent = l_parent_node;
+                                ++node;
+                                if (--k >= 0) {
+                                        node->parent = l_parent_node;
+                                        ++node;
+                                }
+                                ++l_parent_node;
+                        }
+                        if ((j & 1) || j == nplv[i] - 1) {
+                                l_parent_node0 = l_parent_node;
+                        } else {
+                                l_parent_node = l_parent_node0;
+                                l_parent_node0 += nplh[i];
+                        }
+                }
+        }
+        node->parent = 0;
+        opj_tgt_reset(tree);
+        return tree;
+}
+
+/**
+ * Reinitialises a tag-tree from an existing one.
+ *
+ * @param       p_tree                          the tree to reinitialize.
+ * @param       p_num_leafs_h           the width of the array of leafs of the tree
+ * @param       p_num_leafs_v           the height of the array of leafs of the tree
+ * @return      a new tag-tree if successful, NULL otherwise
+*/
+opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, OPJ_UINT32 p_num_leafs_v, opj_event_mgr_t *p_manager)
+{
+        OPJ_INT32 l_nplh[32];
+        OPJ_INT32 l_nplv[32];
+        opj_tgt_node_t *l_node = 00;
+        opj_tgt_node_t *l_parent_node = 00;
+        opj_tgt_node_t *l_parent_node0 = 00;
+        OPJ_UINT32 i;
+        OPJ_INT32 j,k;
+        OPJ_UINT32 l_num_levels;
+        OPJ_UINT32 n;
+        OPJ_UINT32 l_node_size;
+
+        if (! p_tree){
+                return 00;
+        }
+
+        if ((p_tree->numleafsh != p_num_leafs_h) || (p_tree->numleafsv != p_num_leafs_v)) {
+                p_tree->numleafsh = p_num_leafs_h;
+                p_tree->numleafsv = p_num_leafs_v;
+
+                l_num_levels = 0;
+                l_nplh[0] = (OPJ_INT32)p_num_leafs_h;
+                l_nplv[0] = (OPJ_INT32)p_num_leafs_v;
+                p_tree->numnodes = 0;
+                do
+                {
+                        n = (OPJ_UINT32)(l_nplh[l_num_levels] * l_nplv[l_num_levels]);
+                        l_nplh[l_num_levels + 1] = (l_nplh[l_num_levels] + 1) / 2;
+                        l_nplv[l_num_levels + 1] = (l_nplv[l_num_levels] + 1) / 2;
+                        p_tree->numnodes += n;
+                        ++l_num_levels;
+                }
+                while (n > 1);
+
+                /* ADD */
+                if (p_tree->numnodes == 0) {
+                        opj_tgt_destroy(p_tree);
+                        return 00;
+                }
+                l_node_size = p_tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node_t);
+                
+                if (l_node_size > p_tree->nodes_size) {
+                        opj_tgt_node_t* new_nodes = (opj_tgt_node_t*) opj_realloc(p_tree->nodes, l_node_size);
+                        if (! new_nodes) {
+                                opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to reinitialize the tag tree\n");
+                                opj_tgt_destroy(p_tree);
+                                return 00;
+                        }
+                        p_tree->nodes = new_nodes;
+                        memset(((char *) p_tree->nodes) + p_tree->nodes_size, 0 , l_node_size - p_tree->nodes_size);
+                        p_tree->nodes_size = l_node_size;
+                }
+                l_node = p_tree->nodes;
+                l_parent_node = &p_tree->nodes[p_tree->numleafsh * p_tree->numleafsv];
+                l_parent_node0 = l_parent_node;
+
+                for (i = 0; i < l_num_levels - 1; ++i) {
+                        for (j = 0; j < l_nplv[i]; ++j) {
+                                k = l_nplh[i];
+                                while (--k >= 0) {
+                                        l_node->parent = l_parent_node;
+                                        ++l_node;
+                                        if (--k >= 0) {
+                                                l_node->parent = l_parent_node;
+                                                ++l_node;
+                                        }
+                                        ++l_parent_node;
+                                        }
+                                if ((j & 1) || j == l_nplv[i] - 1)
+                                {
+                                        l_parent_node0 = l_parent_node;
+                                }
+                                else
+                                {
+                                        l_parent_node = l_parent_node0;
+                                        l_parent_node0 += l_nplh[i];
+                                }
+                        }
+                }
+                l_node->parent = 0;
+        }
+        opj_tgt_reset(p_tree);
+
+        return p_tree;
+}
+
+void opj_tgt_destroy(opj_tgt_tree_t *p_tree)
+{
+        if (! p_tree) {
+                return;
+        }
+
+        if (p_tree->nodes) {
+                opj_free(p_tree->nodes);
+                p_tree->nodes = 00;
+        }
+        opj_free(p_tree);
+}
+
+void opj_tgt_reset(opj_tgt_tree_t *p_tree) {
+        OPJ_UINT32 i;
+        opj_tgt_node_t * l_current_node = 00;;
+
+        if (! p_tree) {
+                return;
+        }
+
+        l_current_node = p_tree->nodes;
+        for     (i = 0; i < p_tree->numnodes; ++i)
+        {
+                l_current_node->value = 999;
+                l_current_node->low = 0;
+                l_current_node->known = 0;
+                ++l_current_node;
+        }
+}
+
+void opj_tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value) {
+        opj_tgt_node_t *node;
+        node = &tree->nodes[leafno];
+        while (node && node->value > value) {
+                node->value = value;
+                node = node->parent;
+        }
+}
+
+void opj_tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
+        opj_tgt_node_t *stk[31];
+        opj_tgt_node_t **stkptr;
+        opj_tgt_node_t *node;
+        OPJ_INT32 low;
+
+        stkptr = stk;
+        node = &tree->nodes[leafno];
+        while (node->parent) {
+                *stkptr++ = node;
+                node = node->parent;
+        }
+        
+        low = 0;
+        for (;;) {
+                if (low > node->low) {
+                        node->low = low;
+                } else {
+                        low = node->low;
+                }
+                
+                while (low < threshold) {
+                        if (low >= node->value) {
+                                if (!node->known) {
+                                        opj_bio_write(bio, 1, 1);
+                                        node->known = 1;
+                                }
+                                break;
+                        }
+                        opj_bio_write(bio, 0, 1);
+                        ++low;
+                }
+                
+                node->low = low;
+                if (stkptr == stk)
+                        break;
+                node = *--stkptr;
+        }
+}
+
+OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold) {
+        opj_tgt_node_t *stk[31];
+        opj_tgt_node_t **stkptr;
+        opj_tgt_node_t *node;
+        OPJ_INT32 low;
+
+        stkptr = stk;
+        node = &tree->nodes[leafno];
+        while (node->parent) {
+                *stkptr++ = node;
+                node = node->parent;
+        }
+        
+        low = 0;
+        for (;;) {
+                if (low > node->low) {
+                        node->low = low;
+                } else {
+                        low = node->low;
+                }
+                while (low < threshold && low < node->value) {
+                        if (opj_bio_read(bio, 1)) {
+                                node->value = low;
+                        } else {
+                                ++low;
+                        }
+                }
+                node->low = low;
+                if (stkptr == stk) {
+                        break;
+                }
+                node = *--stkptr;
+        }
+        
+        return (node->value < threshold) ? 1 : 0;
+}
diff --git a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tgt.h b/Utilities/gdcmopenjpeg/src/lib/openjp2/tgt.h
similarity index 62%
rename from Utilities/gdcmopenjpeg-v2/libopenjpeg/tgt.h
rename to Utilities/gdcmopenjpeg/src/lib/openjp2/tgt.h
index 2aa8dc9..1022380 100644
--- a/Utilities/gdcmopenjpeg-v2/libopenjpeg/tgt.h
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/tgt.h
@@ -1,11 +1,19 @@
 /*
- * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2007, Professor Benoit Macq
+ * The copyright in this software is being made available under the 2-clauses 
+ * BSD License, included below. This software may be subject to other third 
+ * party and contributor rights, including patent rights, and no such rights
+ * are granted under this license.
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
  * Copyright (c) 2001-2003, David Janssens
  * Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux 
+ * Copyright (c) 2003-2014, Antonin Descampe
  * Copyright (c) 2005, Herve Drolon, FreeImage Team
  * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes at c-s.fr>
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
+ * Copyright (c) 2012, CS Systemes d'Information, France
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -39,20 +47,18 @@
 The functions in TGT.C have for goal to realize a tag-tree coder. The functions in TGT.C
 are used by some function in T2.C.
 */
-#include "openjpeg.h"
+
 /** @defgroup TGT TGT - Implementation of a tag-tree coder */
 /*@{*/
-struct opj_bio;
 
 /**
 Tag node
 */
-typedef struct opj_tgt_node
-{
-  struct opj_tgt_node *parent;
-  OPJ_INT32 value;
-  OPJ_INT32 low;
-  OPJ_UINT32 known : 1;
+typedef struct opj_tgt_node {
+    struct opj_tgt_node *parent;
+    OPJ_INT32 value;
+    OPJ_INT32 low;
+    OPJ_UINT32 known;
 } opj_tgt_node_t;
 
 /**
@@ -60,13 +66,14 @@ Tag tree
 */
 typedef struct opj_tgt_tree
 {
-  OPJ_UINT32  numleafsh;
-  OPJ_UINT32  numleafsv;
-  OPJ_UINT32 numnodes;
-  opj_tgt_node_t *nodes;
-  OPJ_UINT32  nodes_size;    /* maximum size taken by nodes */
+	OPJ_UINT32  numleafsh;
+	OPJ_UINT32  numleafsv;
+	OPJ_UINT32 numnodes;
+	opj_tgt_node_t *nodes;
+	OPJ_UINT32  nodes_size;		/* maximum size taken by nodes */
 } opj_tgt_tree_t;
 
+
 /** @name Exported functions */
 /*@{*/
 /* ----------------------------------------------------------------------- */
@@ -76,35 +83,39 @@ Create a tag-tree
 @param numleafsv Height of the array of leafs of the tree
 @return Returns a new tag-tree if successful, returns NULL otherwise
 */
-opj_tgt_tree_t *tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv);
+opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, opj_event_mgr_t *manager);
 
 /**
  * Reinitialises a tag-tree from an exixting one.
  *
- * @param  p_tree        the tree to reinitialize.
- * @param  p_num_leafs_h    the width of the array of leafs of the tree
- * @param  p_num_leafs_v    the height of the array of leafs of the tree
- * @return  a new tag-tree if successful, NULL otherwise
+ * @param	p_tree				the tree to reinitialize.
+ * @param	p_num_leafs_h		the width of the array of leafs of the tree
+ * @param	p_num_leafs_v		the height of the array of leafs of the tree
+ * @param p_manager       the event manager
+ * @return	a new tag-tree if successful, NULL otherwise
 */
-opj_tgt_tree_t *tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32  p_num_leafs_h, OPJ_UINT32  p_num_leafs_v);
-
+opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree, 
+                             OPJ_UINT32  p_num_leafs_h, 
+                             OPJ_UINT32  p_num_leafs_v, opj_event_mgr_t *p_manager);
 /**
 Destroy a tag-tree, liberating memory
 @param tree Tag-tree to destroy
 */
-void tgt_destroy(opj_tgt_tree_t *tree);
+void opj_tgt_destroy(opj_tgt_tree_t *tree);
 /**
 Reset a tag-tree (set all leaves to 0)
 @param tree Tag-tree to reset
 */
-void tgt_reset(opj_tgt_tree_t *tree);
+void opj_tgt_reset(opj_tgt_tree_t *tree);
 /**
 Set the value of a leaf of a tag-tree
 @param tree Tag-tree to modify
 @param leafno Number that identifies the leaf to modify
 @param value New value of the leaf
 */
-void tgt_setvalue(opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 value);
+void opj_tgt_setvalue(opj_tgt_tree_t *tree, 
+                      OPJ_UINT32 leafno, 
+                      OPJ_INT32 value);
 /**
 Encode the value of a leaf of the tag-tree up to a given threshold
 @param bio Pointer to a BIO handle
@@ -112,7 +123,10 @@ Encode the value of a leaf of the tag-tree up to a given threshold
 @param leafno Number that identifies the leaf to encode
 @param threshold Threshold to use when encoding value of the leaf
 */
-void tgt_encode(struct opj_bio *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold);
+void opj_tgt_encode(opj_bio_t *bio, 
+                    opj_tgt_tree_t *tree, 
+                    OPJ_UINT32 leafno, 
+                    OPJ_INT32 threshold);
 /**
 Decode the value of a leaf of the tag-tree up to a given threshold
 @param bio Pointer to a BIO handle
@@ -121,7 +135,10 @@ Decode the value of a leaf of the tag-tree up to a given threshold
 @param threshold Threshold to use when decoding value of the leaf
 @return Returns 1 if the node's value < threshold, returns 0 otherwise
 */
-OPJ_UINT32 tgt_decode(struct opj_bio *bio, opj_tgt_tree_t *tree, OPJ_UINT32 leafno, OPJ_INT32 threshold);
+OPJ_UINT32 opj_tgt_decode(opj_bio_t *bio, 
+                          opj_tgt_tree_t *tree, 
+                          OPJ_UINT32 leafno, 
+                          OPJ_INT32 threshold);
 /* ----------------------------------------------------------------------- */
 /*@}*/
 
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/thix_manager.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/thix_manager.c
new file mode 100644
index 0000000..0bd7989
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/thix_manager.c
@@ -0,0 +1,136 @@
+/*
+ * $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara at gmail.com $
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*! \file
+ *  \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+
+
+int opj_write_thix( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [4];
+  int i;
+  int tileno;
+  opj_jp2_box_t *box;
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+
+  lenp = 0;
+  box = (opj_jp2_box_t *)opj_calloc( (size_t)(cstr_info.tw*cstr_info.th), sizeof(opj_jp2_box_t));
+  if(box == NULL){
+	return 0;
+  }
+  for ( i = 0; i < 2 ; i++ ){
+    if (i)
+      opj_stream_seek( cio, lenp, p_manager);
+
+    lenp = opj_stream_tell(cio);
+    opj_stream_skip(cio, 4, p_manager);             /* L [at the end] */
+    opj_write_bytes(l_data_header,JPIP_THIX,4); /* THIX */
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+    opj_write_manf( i, cstr_info.tw*cstr_info.th, box, cio, p_manager);
+    
+    for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){
+      box[tileno].length = (OPJ_UINT32)opj_write_tilemhix( coff, cstr_info, tileno, cio,p_manager);
+      box[tileno].type = JPIP_MHIX;
+    }
+ 
+    len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+    opj_stream_seek(cio, lenp, p_manager);
+    opj_write_bytes(l_data_header,len,4); /* L              */
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+    opj_stream_seek( cio, lenp+len,p_manager);
+
+  }
+
+  opj_free(box);
+
+  return (int)len;
+}
+
+/* 
+ * Write tile-part headers mhix box
+ *
+ * @param[in] coff      offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] tileno    tile number
+ * @param[in] cio       file output handle
+ * @return              length of mhix box
+ */
+int opj_write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_stream_private_t *cio,
+              opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [8];
+  int i;
+  opj_tile_info_t tile;
+  opj_tp_info_t tp;
+  opj_marker_info_t *marker;
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+
+  lenp = opj_stream_tell (cio);
+  opj_stream_skip(cio, 4, p_manager);               /* L [at the end]                    */
+  opj_write_bytes(l_data_header,JPIP_MHIX,4);       /* MHIX                              */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+  tile = cstr_info.tile[tileno];
+  tp = tile.tp[0];
+
+  opj_write_bytes(l_data_header,(OPJ_UINT32)(tp.tp_end_header-tp.tp_start_pos+1), 8);        /* TLEN                              */
+  opj_stream_write_data(cio,l_data_header,8,p_manager);
+
+  marker = cstr_info.tile[tileno].marker;
+
+  for( i=0; i<cstr_info.tile[tileno].marknum; i++){             /* Marker restricted to 1 apparition */
+    opj_write_bytes( l_data_header, marker[i].type, 2);
+    opj_write_bytes( l_data_header+2, 0, 2);
+    opj_stream_write_data(cio,l_data_header,4,p_manager);
+    opj_write_bytes( l_data_header, (OPJ_UINT32)(marker[i].pos-coff), 8);
+    opj_stream_write_data(cio,l_data_header,8,p_manager);
+    opj_write_bytes( l_data_header, (OPJ_UINT32)marker[i].len, 2);
+    opj_stream_write_data(cio,l_data_header,2,p_manager);
+  }
+     
+  /*  free( marker);*/
+
+  len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+  opj_stream_seek(cio, lenp,p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L  */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+
+  return (int)len;
+}
diff --git a/Utilities/gdcmopenjpeg/src/lib/openjp2/tpix_manager.c b/Utilities/gdcmopenjpeg/src/lib/openjp2/tpix_manager.c
new file mode 100644
index 0000000..74c02ba
--- /dev/null
+++ b/Utilities/gdcmopenjpeg/src/lib/openjp2/tpix_manager.c
@@ -0,0 +1,185 @@
+/*
+ * $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara at gmail.com $
+ *
+ * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2014, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*! \file
+ *  \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+/* 
+ * Get number of maximum tile parts per tile
+ *
+ * @param[in] cstr_info codestream information
+ * @return              number of maximum tile parts per tile
+ */
+int get_num_max_tile_parts( opj_codestream_info_t cstr_info);
+
+
+/* 
+ * Write faix box of tpix
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] compno    component number
+ * @param[in] cstr_info codestream information
+ * @param[in] j2klen    length of j2k codestream
+ * @param[in] cio       file output handle
+ * @return              length of faix box
+ */
+
+int opj_write_tpix( int coff, 
+                    opj_codestream_info_t cstr_info, 
+                    int j2klen, opj_stream_private_t *cio,
+                    opj_event_mgr_t * p_manager )
+{
+  OPJ_BYTE l_data_header [4];
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip(cio, 4, p_manager);
+  opj_write_bytes(l_data_header,JPIP_TPIX,4); /* TPIX */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  
+  opj_write_tpixfaix( coff, 0, cstr_info, j2klen, cio,p_manager);
+
+  len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+ 
+  opj_stream_skip(cio, lenp, p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L              */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+
+  return (int)len;
+}
+
+int opj_write_tpixfaix( int coff,
+                        int compno, 
+                        opj_codestream_info_t cstr_info, 
+                        int j2klen, 
+                        opj_stream_private_t *cio,
+                        opj_event_mgr_t * p_manager )
+{
+  OPJ_UINT32 len;
+  OPJ_OFF_T lenp;
+  OPJ_UINT32 i, j;
+  OPJ_UINT32 Aux;
+  OPJ_UINT32 num_max_tile_parts;
+  OPJ_UINT32 size_of_coding; /* 4 or 8 */
+  opj_tp_info_t tp;
+  OPJ_BYTE l_data_header [8];
+  OPJ_UINT32 version;
+
+  num_max_tile_parts = (OPJ_UINT32)get_num_max_tile_parts( cstr_info);
+
+  if( j2klen > pow( 2, 32)){
+    size_of_coding =  8;
+    version = num_max_tile_parts == 1 ? 1:3;
+  }
+  else{
+    size_of_coding = 4;
+    version = num_max_tile_parts == 1 ? 0:2;
+  }
+
+  lenp = opj_stream_tell(cio);
+  opj_stream_skip(cio, 4, p_manager);         /* L [at the end]      */
+  opj_write_bytes(l_data_header,JPIP_FAIX,4); /* FAIX */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_write_bytes(l_data_header,version,1);   /* Version 0 = 4 bytes */
+  opj_stream_write_data(cio,l_data_header,1,p_manager);
+
+  opj_write_bytes(l_data_header,num_max_tile_parts,size_of_coding);         /* NMAX           */
+  opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+  opj_write_bytes(l_data_header,(OPJ_UINT32)(cstr_info.tw*cstr_info.th),size_of_coding);  /* M              */
+  opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+
+  for (i = 0; i < (OPJ_UINT32)(cstr_info.tw*cstr_info.th); i++)
+    {
+    for (j = 0; j < (OPJ_UINT32)cstr_info.tile[i].num_tps; j++)
+      {
+      tp = cstr_info.tile[i].tp[j];
+
+      opj_write_bytes(l_data_header,(OPJ_UINT32)(tp.tp_start_pos-coff),size_of_coding);            /* start position */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+      opj_write_bytes(l_data_header,(OPJ_UINT32)(tp.tp_end_pos-tp.tp_start_pos+1),size_of_coding); /* length         */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+
+      if (version & 0x02)
+        {
+        if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1)
+          Aux = (OPJ_UINT32)(cstr_info.numdecompos[compno] + 1);
+        else
+          Aux = j + 1;
+
+        opj_write_bytes(l_data_header,Aux,4);
+        opj_stream_write_data(cio,l_data_header,4,p_manager);
+
+        /*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */
+        /* fprintf(stderr,"AUX value %d\n",Aux);*/
+        }
+      /*cio_write(0,4);*/
+      }
+    /* PADDING */
+    while (j < num_max_tile_parts)
+      {
+
+          opj_write_bytes(l_data_header,0,size_of_coding);/* start position            */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+      opj_write_bytes(l_data_header,0,size_of_coding);/* length                    */
+      opj_stream_write_data(cio,l_data_header,size_of_coding,p_manager);
+
+      if (version & 0x02)
+      opj_write_bytes(l_data_header,0,4);      /* Aux_i,j : Auxiliary value */
+      opj_stream_write_data(cio,l_data_header,4,p_manager);
+      j++;
+      }
+    }
+  
+  len = (OPJ_UINT32)(opj_stream_tell(cio)-lenp);
+  opj_stream_seek(cio, lenp,p_manager);
+  opj_write_bytes(l_data_header,len,4);/* L  */
+  opj_stream_write_data(cio,l_data_header,4,p_manager);
+  opj_stream_seek(cio, lenp+len,p_manager);
+
+  return (int)len;
+}
+
+int get_num_max_tile_parts( opj_codestream_info_t cstr_info)
+{
+  int num_max_tp = 0, i;
+
+  for( i=0; i<cstr_info.tw*cstr_info.th; i++)
+    num_max_tp = MAX( cstr_info.tile[i].num_tps, num_max_tp);
+  
+  return num_max_tp;
+}
diff --git a/Utilities/gdcmutfcpp/README.GDCM.txt b/Utilities/gdcmutfcpp/README.GDCM.txt
index 38b1d10..c9420f2 100644
--- a/Utilities/gdcmutfcpp/README.GDCM.txt
+++ b/Utilities/gdcmutfcpp/README.GDCM.txt
@@ -1,5 +1,13 @@
 I was looking for a UTF-8 lightweight library with a license compatible with GDCM.
 
-I decided to pick utfcpp. Which still seems to be active (2.2.4 was released 23 days ago).
+I (Mathieu Malaterre) decided to pick utfcpp:
+http://sourceforge.net/projects/utfcpp/
+
+Version 2.3.4 is included here, with no changes.
+
+Source:
+http://sourceforge.net/projects/utfcpp/files/utf8cpp_2x/Release%202.3.4/utf8_v2_3_4.zip/download
+
+SHA 256 checksum:
+3373cebb25d88c662a2b960c4d585daf9ae7b396031ecd786e7bb31b15d010ef
 
--- Mathieu Malaterre  Mon Nov 23 18:30:46 CET 2009
diff --git a/Utilities/gdcmutfcpp/utf8.h b/Utilities/gdcmutfcpp/utf8.h
index 82b13f5..4e44514 100644
--- a/Utilities/gdcmutfcpp/utf8.h
+++ b/Utilities/gdcmutfcpp/utf8.h
@@ -1,34 +1,34 @@
-// Copyright 2006 Nemanja Trifunovic
-
-/*
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-*/
-
-
-#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
-#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
-
-#include "utf8/checked.h"
-#include "utf8/unchecked.h"
-
-#endif // header guard
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
+#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
+
+#include "utf8/checked.h"
+#include "utf8/unchecked.h"
+
+#endif // header guard
diff --git a/Utilities/gdcmutfcpp/utf8/checked.h b/Utilities/gdcmutfcpp/utf8/checked.h
old mode 100755
new mode 100644
index ff75eb7..1331155
--- a/Utilities/gdcmutfcpp/utf8/checked.h
+++ b/Utilities/gdcmutfcpp/utf8/checked.h
@@ -33,8 +33,12 @@ DEALINGS IN THE SOFTWARE.
 
 namespace utf8
 {
+    // Base for the exceptions that may be thrown from the library
+    class exception : public ::std::exception {
+    };
+
     // Exceptions that may be thrown from the library functions.
-    class invalid_code_point : public std::exception {
+    class invalid_code_point : public exception {
         uint32_t cp;
     public:
         invalid_code_point(uint32_t cp) : cp(cp) {}
@@ -42,7 +46,7 @@ namespace utf8
         uint32_t code_point() const {return cp;}
     };
 
-    class invalid_utf8 : public std::exception {
+    class invalid_utf8 : public exception {
         uint8_t u8;
     public:
         invalid_utf8 (uint8_t u) : u8(u) {}
@@ -50,7 +54,7 @@ namespace utf8
         uint8_t utf8_octet() const {return u8;}
     };
 
-    class invalid_utf16 : public std::exception {
+    class invalid_utf16 : public exception {
         uint16_t u16;
     public:
         invalid_utf16 (uint16_t u) : u16(u) {}
@@ -58,19 +62,45 @@ namespace utf8
         uint16_t utf16_word() const {return u16;}
     };
 
-    class not_enough_room : public std::exception {
+    class not_enough_room : public exception {
     public:
         virtual const char* what() const throw() { return "Not enough space"; }
     };
 
     /// The library API - functions intended to be called by the users
 
+    template <typename octet_iterator>
+    octet_iterator append(uint32_t cp, octet_iterator result)
+    {
+        if (!utf8::internal::is_code_point_valid(cp))
+            throw invalid_code_point(cp);
+
+        if (cp < 0x80)                        // one octet
+            *(result++) = static_cast<uint8_t>(cp);
+        else if (cp < 0x800) {                // two octets
+            *(result++) = static_cast<uint8_t>((cp >> 6)            | 0xc0);
+            *(result++) = static_cast<uint8_t>((cp & 0x3f)          | 0x80);
+        }
+        else if (cp < 0x10000) {              // three octets
+            *(result++) = static_cast<uint8_t>((cp >> 12)           | 0xe0);
+            *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f)   | 0x80);
+            *(result++) = static_cast<uint8_t>((cp & 0x3f)          | 0x80);
+        }
+        else {                                // four octets
+            *(result++) = static_cast<uint8_t>((cp >> 18)           | 0xf0);
+            *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)  | 0x80);
+            *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f)   | 0x80);
+            *(result++) = static_cast<uint8_t>((cp & 0x3f)          | 0x80);
+        }
+        return result;
+    }
+
     template <typename octet_iterator, typename output_iterator>
     output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
     {
         while (start != end) {
             octet_iterator sequence_start = start;
-            internal::utf_error err_code = internal::validate_next(start, end);
+            internal::utf_error err_code = utf8::internal::validate_next(start, end);
             switch (err_code) {
                 case internal::UTF8_OK :
                     for (octet_iterator it = sequence_start; it != start; ++it)
@@ -79,16 +109,16 @@ namespace utf8
                 case internal::NOT_ENOUGH_ROOM:
                     throw not_enough_room();
                 case internal::INVALID_LEAD:
-                    append (replacement, out);
+                    out = utf8::append (replacement, out);
                     ++start;
                     break;
                 case internal::INCOMPLETE_SEQUENCE:
                 case internal::OVERLONG_SEQUENCE:
                 case internal::INVALID_CODE_POINT:
-                    append (replacement, out);
+                    out = utf8::append (replacement, out);
                     ++start;
                     // just one replacement mark for the sequence
-                    while (internal::is_trail(*start) && start != end)
+                    while (start != end && utf8::internal::is_trail(*start))
                         ++start;
                     break;
             }
@@ -99,41 +129,15 @@ namespace utf8
     template <typename octet_iterator, typename output_iterator>
     inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
     {
-        static const uint32_t replacement_marker = internal::mask16(0xfffd);
-        return replace_invalid(start, end, out, replacement_marker);
-    }
-
-    template <typename octet_iterator>
-    octet_iterator append(uint32_t cp, octet_iterator result)
-    {
-        if (!internal::is_code_point_valid(cp))
-            throw invalid_code_point(cp);
-
-        if (cp < 0x80)                        // one octet
-            *(result++) = static_cast<uint8_t>(cp);
-        else if (cp < 0x800) {                // two octets
-            *(result++) = static_cast<uint8_t>((cp >> 6)            | 0xc0);
-            *(result++) = static_cast<uint8_t>((cp & 0x3f)          | 0x80);
-        }
-        else if (cp < 0x10000) {              // three octets
-            *(result++) = static_cast<uint8_t>((cp >> 12)           | 0xe0);
-            *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f)   | 0x80);
-            *(result++) = static_cast<uint8_t>((cp & 0x3f)          | 0x80);
-        }
-        else {      // four octets
-            *(result++) = static_cast<uint8_t>((cp >> 18)           | 0xf0);
-            *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)  | 0x80);
-            *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f)   | 0x80);
-            *(result++) = static_cast<uint8_t>((cp & 0x3f)          | 0x80);
-        }
-        return result;
+        static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
+        return utf8::replace_invalid(start, end, out, replacement_marker);
     }
 
     template <typename octet_iterator>
     uint32_t next(octet_iterator& it, octet_iterator end)
     {
         uint32_t cp = 0;
-        internal::utf_error err_code = internal::validate_next(it, end, &cp);
+        internal::utf_error err_code = utf8::internal::validate_next(it, end, cp);
         switch (err_code) {
             case internal::UTF8_OK :
                 break;
@@ -152,18 +156,22 @@ namespace utf8
     template <typename octet_iterator>
     uint32_t peek_next(octet_iterator it, octet_iterator end)
     {
-        return next(it, end);
+        return utf8::next(it, end);
     }
 
     template <typename octet_iterator>
     uint32_t prior(octet_iterator& it, octet_iterator start)
     {
+        // can't do much if it == start
+        if (it == start)
+            throw not_enough_room();
+
         octet_iterator end = it;
-        while (internal::is_trail(*(--it)))
-            if (it < start)
+        // Go back until we hit either a lead octet or start
+        while (utf8::internal::is_trail(*(--it)))
+            if (it == start)
                 throw invalid_utf8(*it); // error - no lead byte in the sequence
-        octet_iterator temp = it;
-        return next(temp, end);
+        return utf8::peek_next(it, end);
     }
 
     /// Deprecated in versions that include "prior"
@@ -171,18 +179,18 @@ namespace utf8
     uint32_t previous(octet_iterator& it, octet_iterator pass_start)
     {
         octet_iterator end = it;
-        while (internal::is_trail(*(--it)))
+        while (utf8::internal::is_trail(*(--it)))
             if (it == pass_start)
                 throw invalid_utf8(*it); // error - no lead byte in the sequence
         octet_iterator temp = it;
-        return next(temp, end);
+        return utf8::next(temp, end);
     }
 
     template <typename octet_iterator, typename distance_type>
     void advance (octet_iterator& it, distance_type n, octet_iterator end)
     {
         for (distance_type i = 0; i < n; ++i)
-            next(it, end);
+            utf8::next(it, end);
     }
 
     template <typename octet_iterator>
@@ -191,7 +199,7 @@ namespace utf8
     {
         typename std::iterator_traits<octet_iterator>::difference_type dist;
         for (dist = 0; first < last; ++dist)
-            next(first, last);
+            utf8::next(first, last);
         return dist;
     }
 
@@ -199,12 +207,12 @@ namespace utf8
     octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
     {
         while (start != end) {
-            uint32_t cp = internal::mask16(*start++);
+            uint32_t cp = utf8::internal::mask16(*start++);
             // Take care of surrogate pairs first
-            if (internal::is_lead_surrogate(cp)) {
+            if (utf8::internal::is_lead_surrogate(cp)) {
                 if (start != end) {
-                    uint32_t trail_surrogate = internal::mask16(*start++);
-                    if (internal::is_trail_surrogate(trail_surrogate))
+                    uint32_t trail_surrogate = utf8::internal::mask16(*start++);
+                    if (utf8::internal::is_trail_surrogate(trail_surrogate))
                         cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
                     else
                         throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
@@ -214,10 +222,10 @@ namespace utf8
 
             }
             // Lone trail surrogate
-            else if (internal::is_trail_surrogate(cp))
+            else if (utf8::internal::is_trail_surrogate(cp))
                 throw invalid_utf16(static_cast<uint16_t>(cp));
 
-            result = append(cp, result);
+            result = utf8::append(cp, result);
         }
         return result;
     }
@@ -226,7 +234,7 @@ namespace utf8
     u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
     {
         while (start != end) {
-            uint32_t cp = next(start, end);
+            uint32_t cp = utf8::next(start, end);
             if (cp > 0xffff) { //make a surrogate pair
                 *result++ = static_cast<uint16_t>((cp >> 10)   + internal::LEAD_OFFSET);
                 *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
@@ -241,7 +249,7 @@ namespace utf8
     octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
     {
         while (start != end)
-            result = append(*(start++), result);
+            result = utf8::append(*(start++), result);
 
         return result;
     }
@@ -249,8 +257,8 @@ namespace utf8
     template <typename octet_iterator, typename u32bit_iterator>
     u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
     {
-        while (start < end)
-            (*result++) = next(start, end);
+        while (start != end)
+            (*result++) = utf8::next(start, end);
 
         return result;
     }
@@ -262,7 +270,7 @@ namespace utf8
       octet_iterator range_start;
       octet_iterator range_end;
       public:
-      iterator () {};
+      iterator () {}
       explicit iterator (const octet_iterator& octet_it,
                          const octet_iterator& range_start,
                          const octet_iterator& range_end) :
@@ -276,7 +284,7 @@ namespace utf8
       uint32_t operator * () const
       {
           octet_iterator temp = it;
-          return next(temp, range_end);
+          return utf8::next(temp, range_end);
       }
       bool operator == (const iterator& rhs) const
       {
@@ -290,24 +298,24 @@ namespace utf8
       }
       iterator& operator ++ ()
       {
-          next(it, range_end);
+          utf8::next(it, range_end);
           return *this;
       }
       iterator operator ++ (int)
       {
           iterator temp = *this;
-          next(it, range_end);
+          utf8::next(it, range_end);
           return temp;
       }
       iterator& operator -- ()
       {
-          prior(it, range_start);
+          utf8::prior(it, range_start);
           return *this;
       }
       iterator operator -- (int)
       {
           iterator temp = *this;
-          prior(it, range_start);
+          utf8::prior(it, range_start);
           return temp;
       }
     }; // class iterator
diff --git a/Utilities/gdcmutfcpp/utf8/core.h b/Utilities/gdcmutfcpp/utf8/core.h
old mode 100755
new mode 100644
index 5a55f06..693d388
--- a/Utilities/gdcmutfcpp/utf8/core.h
+++ b/Utilities/gdcmutfcpp/utf8/core.h
@@ -68,7 +68,7 @@ namespace internal
     template<typename octet_type>
     inline bool is_trail(octet_type oc)
     {
-        return ((mask8(oc) >> 6) == 0x2);
+        return ((utf8::internal::mask8(oc) >> 6) == 0x2);
     }
 
     template <typename u16>
@@ -92,14 +92,14 @@ namespace internal
     template <typename u32>
     inline bool is_code_point_valid(u32 cp)
     {
-        return (cp <= CODE_POINT_MAX && !is_surrogate(cp) && cp != 0xfffe && cp != 0xffff);
+        return (cp <= CODE_POINT_MAX && !utf8::internal::is_surrogate(cp));
     }
 
     template <typename octet_iterator>
     inline typename std::iterator_traits<octet_iterator>::difference_type
     sequence_length(octet_iterator lead_it)
     {
-        uint8_t lead = mask8(*lead_it);
+        uint8_t lead = utf8::internal::mask8(*lead_it);
         if (lead < 0x80)
             return 1;
         else if ((lead >> 5) == 0x6)
@@ -112,7 +112,8 @@ namespace internal
             return 0;
     }
 
-    inline bool is_overlong_sequence(uint32_t cp, int length)
+    template <typename octet_difference_type>
+    inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length)
     {
         if (cp < 0x80) {
             if (length != 1) 
@@ -132,123 +133,94 @@ namespace internal
 
     enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT};
 
-    /// get_sequence_x functions decode utf-8 sequences of the length x
+    /// Helper for get_sequence_x
+    template <typename octet_iterator>
+    utf_error increase_safely(octet_iterator& it, octet_iterator end)
+    {
+        if (++it == end)
+            return NOT_ENOUGH_ROOM;
+
+        if (!utf8::internal::is_trail(*it))
+            return INCOMPLETE_SEQUENCE;
+        
+        return UTF8_OK;
+    }
 
+    #define UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(IT, END) {utf_error ret = increase_safely(IT, END); if (ret != UTF8_OK) return ret;}    
+
+    /// get_sequence_x functions decode utf-8 sequences of the length x
     template <typename octet_iterator>
-    utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+    utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t& code_point)
     {
-        if (it != end) {
-            if (code_point)
-                *code_point = mask8(*it);
-            return UTF8_OK;
-        }
-        return NOT_ENOUGH_ROOM;
+        if (it == end)
+            return NOT_ENOUGH_ROOM;
+
+        code_point = utf8::internal::mask8(*it);
+
+        return UTF8_OK;
     }
 
     template <typename octet_iterator>
-    utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+    utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t& code_point)
     {
-        utf_error ret_code = NOT_ENOUGH_ROOM;
+        if (it == end) 
+            return NOT_ENOUGH_ROOM;
+        
+        code_point = utf8::internal::mask8(*it);
 
-        if (it != end) {
-            uint32_t cp = mask8(*it);
-            if (++it != end) {
-                if (is_trail(*it)) {
-                    cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
+        UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
 
-                    if (code_point)
-                        *code_point = cp;
-                    ret_code = UTF8_OK;
-                }
-                else
-                    ret_code = INCOMPLETE_SEQUENCE;
-            }
-            else
-                ret_code = NOT_ENOUGH_ROOM;
-        }
+        code_point = ((code_point << 6) & 0x7ff) + ((*it) & 0x3f);
 
-        return ret_code;
+        return UTF8_OK;
     }
 
     template <typename octet_iterator>
-    utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+    utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t& code_point)
     {
-        utf_error ret_code = NOT_ENOUGH_ROOM;
-
-        if (it != end) {
-            uint32_t cp = mask8(*it);
-            if (++it != end) {
-                if (is_trail(*it)) {
-                    cp = ((cp << 12) & 0xffff) + ((mask8(*it) << 6) & 0xfff);
-                    if (++it != end) {
-                        if (is_trail(*it)) {
-                            cp += (*it) & 0x3f;
-
-                            if (code_point)
-                                *code_point = cp;
-                            ret_code = UTF8_OK;
-                        }
-                        else 
-                            ret_code = INCOMPLETE_SEQUENCE;
-                    }
-                    else
-                        ret_code = NOT_ENOUGH_ROOM;
-                }
-                else
-                    ret_code = INCOMPLETE_SEQUENCE;
-            }
-            else
-                ret_code = NOT_ENOUGH_ROOM;
-        }
+        if (it == end)
+            return NOT_ENOUGH_ROOM;
+            
+        code_point = utf8::internal::mask8(*it);
+
+        UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
 
-        return ret_code;
+        code_point = ((code_point << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
+
+        UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+        code_point += (*it) & 0x3f;
+
+        return UTF8_OK;
     }
 
     template <typename octet_iterator>
-    utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+    utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t& code_point)
     {
-        utf_error ret_code = NOT_ENOUGH_ROOM;
-
-        if (it != end) {
-            uint32_t cp = mask8(*it);
-            if (++it != end) {
-                if (is_trail(*it)) {
-                    cp = ((cp << 18) & 0x1fffff) + ((mask8(*it) << 12) & 0x3ffff);
-                    if (++it != end) {
-                        if (is_trail(*it)) {
-                            cp += (mask8(*it) << 6) & 0xfff;
-                            if (++it != end) {
-                                if (is_trail(*it)) {
-                                    cp += (*it) & 0x3f;
-
-                                    if (code_point)
-                                        *code_point = cp;
-                                    ret_code = UTF8_OK;
-                                }
-                                else
-                                    ret_code = INCOMPLETE_SEQUENCE;
-                            }
-                            else
-                                ret_code = NOT_ENOUGH_ROOM;
-                        }
-                        else
-                            ret_code = INCOMPLETE_SEQUENCE;
-                    }
-                    else
-                        ret_code = NOT_ENOUGH_ROOM;
-                }
-                else 
-                    ret_code = INCOMPLETE_SEQUENCE;
-            }
-            else
-                ret_code = NOT_ENOUGH_ROOM;
-        }
+        if (it == end)
+           return NOT_ENOUGH_ROOM;
+
+        code_point = utf8::internal::mask8(*it);
+
+        UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+        code_point = ((code_point << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
+
+        UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
 
-        return ret_code;
+        code_point += (utf8::internal::mask8(*it) << 6) & 0xfff;
+
+        UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+        code_point += (*it) & 0x3f;
+
+        return UTF8_OK;
     }
 
+    #undef UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR
+
     template <typename octet_iterator>
-    utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+    utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point)
     {
         // Save the original value of it so we can go back in case of failure
         // Of course, it does not make much sense with i.e. stream iterators
@@ -257,34 +229,33 @@ namespace internal
         uint32_t cp = 0;
         // Determine the sequence length based on the lead octet
         typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
-        octet_difference_type length = sequence_length(it);
-        if (length == 0)
-            return INVALID_LEAD;
+        const octet_difference_type length = utf8::internal::sequence_length(it);
 
-        // Now that we have a valid sequence length, get trail octets and calculate the code point
+        // Get trail octets and calculate the code point
         utf_error err = UTF8_OK;
         switch (length) {
+            case 0: 
+                return INVALID_LEAD;
             case 1:
-                err = get_sequence_1(it, end, &cp);
+                err = utf8::internal::get_sequence_1(it, end, cp);
                 break;
             case 2:
-                err = get_sequence_2(it, end, &cp);
+                err = utf8::internal::get_sequence_2(it, end, cp);
             break;
             case 3:
-                err = get_sequence_3(it, end, &cp);
+                err = utf8::internal::get_sequence_3(it, end, cp);
             break;
             case 4:
-                err = get_sequence_4(it, end, &cp);
+                err = utf8::internal::get_sequence_4(it, end, cp);
             break;
         }
 
         if (err == UTF8_OK) {
             // Decoding succeeded. Now, security checks...
-            if (is_code_point_valid(cp)) {
-                if (!is_overlong_sequence(cp, length)){
+            if (utf8::internal::is_code_point_valid(cp)) {
+                if (!utf8::internal::is_overlong_sequence(cp, length)){
                     // Passed! Return here.
-                    if (code_point)
-                        *code_point = cp;
+                    code_point = cp;
                     ++it;
                     return UTF8_OK;
                 }
@@ -302,7 +273,8 @@ namespace internal
 
     template <typename octet_iterator>
     inline utf_error validate_next(octet_iterator& it, octet_iterator end) {
-        return validate_next(it, end, 0);
+        uint32_t ignored;
+        return utf8::internal::validate_next(it, end, ignored);
     }
 
 } // namespace internal
@@ -317,7 +289,7 @@ namespace internal
     {
         octet_iterator result = start;
         while (result != end) {
-            internal::utf_error err_code = internal::validate_next(result, end);
+            utf8::internal::utf_error err_code = utf8::internal::validate_next(result, end);
             if (err_code != internal::UTF8_OK)
                 return result;
         }
@@ -327,16 +299,27 @@ namespace internal
     template <typename octet_iterator>
     inline bool is_valid(octet_iterator start, octet_iterator end)
     {
-        return (find_invalid(start, end) == end);
+        return (utf8::find_invalid(start, end) == end);
     }
 
     template <typename octet_iterator>
+    inline bool starts_with_bom (octet_iterator it, octet_iterator end)
+    {
+        return (
+            ((it != end) && (utf8::internal::mask8(*it++)) == bom[0]) &&
+            ((it != end) && (utf8::internal::mask8(*it++)) == bom[1]) &&
+            ((it != end) && (utf8::internal::mask8(*it))   == bom[2])
+           );
+    }
+	
+    //Deprecated in release 2.3 
+    template <typename octet_iterator>
     inline bool is_bom (octet_iterator it)
     {
         return (
-            (internal::mask8(*it++)) == bom[0] &&
-            (internal::mask8(*it++)) == bom[1] &&
-            (internal::mask8(*it))   == bom[2]
+            (utf8::internal::mask8(*it++)) == bom[0] &&
+            (utf8::internal::mask8(*it++)) == bom[1] &&
+            (utf8::internal::mask8(*it))   == bom[2]
            );
     }
 } // namespace utf8
diff --git a/Utilities/gdcmutfcpp/utf8/unchecked.h b/Utilities/gdcmutfcpp/utf8/unchecked.h
old mode 100755
new mode 100644
index d3110cb..cb24271
--- a/Utilities/gdcmutfcpp/utf8/unchecked.h
+++ b/Utilities/gdcmutfcpp/utf8/unchecked.h
@@ -60,7 +60,7 @@ namespace utf8
         template <typename octet_iterator>
         uint32_t next(octet_iterator& it)
         {
-            uint32_t cp = internal::mask8(*it);
+            uint32_t cp = utf8::internal::mask8(*it);
             typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
             switch (length) {
                 case 1:
@@ -71,15 +71,15 @@ namespace utf8
                     break;
                 case 3:
                     ++it; 
-                    cp = ((cp << 12) & 0xffff) + ((internal::mask8(*it) << 6) & 0xfff);
+                    cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
                     ++it;
                     cp += (*it) & 0x3f;
                     break;
                 case 4:
                     ++it;
-                    cp = ((cp << 18) & 0x1fffff) + ((internal::mask8(*it) << 12) & 0x3ffff);                
+                    cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);                
                     ++it;
-                    cp += (internal::mask8(*it) << 6) & 0xfff;
+                    cp += (utf8::internal::mask8(*it) << 6) & 0xfff;
                     ++it;
                     cp += (*it) & 0x3f; 
                     break;
@@ -91,29 +91,29 @@ namespace utf8
         template <typename octet_iterator>
         uint32_t peek_next(octet_iterator it)
         {
-            return next(it);    
+            return utf8::unchecked::next(it);    
         }
 
         template <typename octet_iterator>
         uint32_t prior(octet_iterator& it)
         {
-            while (internal::is_trail(*(--it))) ;
+            while (utf8::internal::is_trail(*(--it))) ;
             octet_iterator temp = it;
-            return next(temp);
+            return utf8::unchecked::next(temp);
         }
 
         // Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous)
         template <typename octet_iterator>
         inline uint32_t previous(octet_iterator& it)
         {
-            return prior(it);
+            return utf8::unchecked::prior(it);
         }
 
         template <typename octet_iterator, typename distance_type>
         void advance (octet_iterator& it, distance_type n)
         {
             for (distance_type i = 0; i < n; ++i)
-                next(it);
+                utf8::unchecked::next(it);
         }
 
         template <typename octet_iterator>
@@ -122,7 +122,7 @@ namespace utf8
         {
             typename std::iterator_traits<octet_iterator>::difference_type dist;
             for (dist = 0; first < last; ++dist) 
-                next(first);
+                utf8::unchecked::next(first);
             return dist;
         }
 
@@ -130,13 +130,13 @@ namespace utf8
         octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
         {       
             while (start != end) {
-                uint32_t cp = internal::mask16(*start++);
+                uint32_t cp = utf8::internal::mask16(*start++);
             // Take care of surrogate pairs first
-                if (internal::is_lead_surrogate(cp)) {
-                    uint32_t trail_surrogate = internal::mask16(*start++);
+                if (utf8::internal::is_lead_surrogate(cp)) {
+                    uint32_t trail_surrogate = utf8::internal::mask16(*start++);
                     cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
                 }
-                result = append(cp, result);
+                result = utf8::unchecked::append(cp, result);
             }
             return result;         
         }
@@ -144,8 +144,8 @@ namespace utf8
         template <typename u16bit_iterator, typename octet_iterator>
         u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
         {
-            while (start != end) {
-                uint32_t cp = next(start);
+            while (start < end) {
+                uint32_t cp = utf8::unchecked::next(start);
                 if (cp > 0xffff) { //make a surrogate pair
                     *result++ = static_cast<uint16_t>((cp >> 10)   + internal::LEAD_OFFSET);
                     *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
@@ -160,7 +160,7 @@ namespace utf8
         octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
         {
             while (start != end)
-                result = append(*(start++), result);
+                result = utf8::unchecked::append(*(start++), result);
 
             return result;
         }
@@ -169,7 +169,7 @@ namespace utf8
         u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
         {
             while (start < end)
-                (*result++) = next(start);
+                (*result++) = utf8::unchecked::next(start);
 
             return result;
         }
@@ -179,14 +179,14 @@ namespace utf8
           class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> { 
             octet_iterator it;
             public:
-            iterator () {};
+            iterator () {}
             explicit iterator (const octet_iterator& octet_it): it(octet_it) {}
             // the default "big three" are OK
             octet_iterator base () const { return it; }
             uint32_t operator * () const
             {
                 octet_iterator temp = it;
-                return next(temp);
+                return utf8::unchecked::next(temp);
             }
             bool operator == (const iterator& rhs) const 
             { 
@@ -198,24 +198,24 @@ namespace utf8
             }
             iterator& operator ++ () 
             {
-                std::advance(it, internal::sequence_length(it));
+                ::std::advance(it, utf8::internal::sequence_length(it));
                 return *this;
             }
             iterator operator ++ (int)
             {
                 iterator temp = *this;
-                std::advance(it, internal::sequence_length(it));
+                ::std::advance(it, utf8::internal::sequence_length(it));
                 return temp;
             }  
             iterator& operator -- ()
             {
-                prior(it);
+                utf8::unchecked::prior(it);
                 return *this;
             }
             iterator operator -- (int)
             {
                 iterator temp = *this;
-                prior(it);
+                utf8::unchecked::prior(it);
                 return temp;
             }
           }; // class iterator
diff --git a/Utilities/gdcmzlib/README.GDCM.txt b/Utilities/gdcmzlib/README.GDCM.txt
new file mode 100644
index 0000000..7394ead
--- /dev/null
+++ b/Utilities/gdcmzlib/README.GDCM.txt
@@ -0,0 +1,14 @@
+This is the venerable zlib:
+http://zlib.net/
+
+A subset of version 1.2.3 is included here.  There are a few small changes.
+
+Source:
+http://zlib.net/fossils/zlib-1.2.3.tar.gz
+
+SHA 256 checksum:
+1795c7d067a43174113fdf03447532f373e1c6c57c08d61d9e4e9be5e244b05e
+
+Changes:
+ - CMakeLists.txt added
+ - more...
diff --git a/Utilities/gdcmzlib/gzio.c b/Utilities/gdcmzlib/gzio.c
index 5cf50e0..7e90f49 100644
--- a/Utilities/gdcmzlib/gzio.c
+++ b/Utilities/gdcmzlib/gzio.c
@@ -256,7 +256,7 @@ int ZEXPORT gzsetparams (file, level, strategy)
 /* ===========================================================================
      Read a byte from a gz_stream; update next_in and avail_in. Return EOF
    for end of file.
-   IN assertion: the stream s has been successfully opened for reading.
+   IN assertion: the stream s has been sucessfully opened for reading.
 */
 local int get_byte(s)
     gz_stream *s;
@@ -281,7 +281,7 @@ local int get_byte(s)
     mode to transparent if the gzip magic header is not present; set s->err
     to Z_DATA_ERROR if the magic header is present but the rest of the header
     is incorrect.
-    IN assertion: the stream s has already been created successfully;
+    IN assertion: the stream s has already been created sucessfully;
        s->stream.avail_in is zero for the first time, but may be non-zero
        for concatenated .gz files.
 */
diff --git a/Utilities/rle/CMakeLists.txt b/Utilities/rle/CMakeLists.txt
deleted file mode 100644
index be28eba..0000000
--- a/Utilities/rle/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-project(RLE)
-
-add_library(rle rle.c rlelib.c)
-#set_target_properties(rle PROPERTIES ${GDCM_LIBRARY_PROPERTIES})
-
-add_executable(example example.c)
-target_link_libraries(example rle)
-install(TARGETS rle example
-  RUNTIME DESTINATION bin
-  LIBRARY DESTINATION lib
-  ARCHIVE DESTINATION lib/static
-  ${CPACK_NAMELINK_TYPE}
-  )
-
-add_executable(rledump rledump.c)
-target_link_libraries(rledump rle)
diff --git a/Utilities/rle/example.c b/Utilities/rle/example.c
deleted file mode 100644
index 90d2ff5..0000000
--- a/Utilities/rle/example.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*=========================================================================
-
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-#include <stdio.h>
-#include <stdlib.h> // abort
-
-#include "rlelib.h"
-
-void std_print_header(rle_compressed_frame * frame)
-{
-  rle_header *header = frame->header;
-  unsigned long ns = header->num_segments;
-  printf("%lu\n", ns);
-}
-
-
-int write_RLE_file(const char *filename)
-{
-  assert(0);
-  return 0;
-}
-
-
-int fill_input_buffer(rle_decompressed_frame * frame)
-{
-  return 1;
-}
-
-int read_RLE_file(const char *filename)
-{
-  assert(0);
-  return 1;
-}
-
-int main(int argc, char *argv[])
-{
-  rle_decompress_struct cinfo;
-  FILE * infile;
-
-  const char *filename;
-  if( argc < 2 )
-    {
-    return 1;
-    }
-  filename = argv[1];
-
-  if ((infile = fopen(filename, "rb")) == NULL) {
-    fprintf(stderr, "can't open %s\n", filename);
-    return 0;
-  }
-
-  rle_create_decompress(&cinfo);
-
-  int i;
-  int dims[2] = { 1760,1760 };
-  int bpp = 16;
-  rle_stdio_src(&cinfo, infile, dims);
-
-  printf("num segment: %d\n", cinfo.header->num_segments );
-  printf("offsets table:\n");
-  for(i = 0; i < 16; ++i)
-    printf("offset: %d\n", cinfo.header->offset[i] );
-
-  (void) rle_start_decompress(&cinfo);
-
-  char *buffer = (char*)malloc( dims[0] * (bpp / 8) );
-  while( cinfo.current_segment < cinfo.header->num_segments ) {
-    while (cinfo.output_scanline < cinfo.output_height) {
-      (void) rle_read_scanlines(&cinfo, buffer, 1);
-      /*put_scanline_someplace(buffer[0], row_stride);*/
-    }
-  }
-  free(buffer);
-
-  (void) rle_finish_decompress(&cinfo);
-
-  rle_destroy_decompress(&cinfo);
-
-  fclose(infile);
-
-  return 0;
-}
diff --git a/Utilities/rle/rle.c b/Utilities/rle/rle.c
deleted file mode 100644
index e549fd6..0000000
--- a/Utilities/rle/rle.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*=========================================================================
-
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-#include "rlelib.h"
-
-
-int rle_decode_init(rle_compressed_frame * frame)
-{
-  return 0;
-}
-
-int rle_decode_segment(rle_compressed_frame * frame)
-{
-  return 0;
-}
-
-int rle_decode_frame(rle_compressed_frame * frame)
-{
-  return 0;
-}
-
-int rle_decode_end()
-{
-  return 0;
-}
diff --git a/Utilities/rle/rledump.c b/Utilities/rle/rledump.c
deleted file mode 100644
index ded020b..0000000
--- a/Utilities/rle/rledump.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*=========================================================================
-
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-#include "rlelib.h"
-
-int main(int argc, char *argv[])
-{
-  rle_decompress_struct cinfo;
-  FILE * infile;
-  int i;
-
-  const char *filename;
-  if( argc < 2 )
-    {
-    return 1;
-    }
-  filename = argv[1];
-
-  if ((infile = fopen(filename, "rb")) == NULL) {
-    fprintf(stderr, "can't open %s\n", filename);
-    return 0;
-  }
-
-  rle_create_decompress(&cinfo);
-
-  /* Dimensions: (1760,1760,1)*/
-  int dims[2] = { 1760,1760 };
-  rle_stdio_src(&cinfo, infile, dims);
-
-  /*rle_header *h = cinfo.header;*/
-  printf("num segment: %d\n", cinfo.header->num_segments );
-  printf("offsets table:\n");
-  for(i = 0; i < 16; ++i)
-    printf("offset: %d\n", cinfo.header->offset[i] );
-
-  /* Simply dump the file info:*/
-
-  rle_destroy_decompress(&cinfo);
-
-  fclose(infile);
-
-  return 0;
-}
diff --git a/Utilities/rle/rlelib.c b/Utilities/rle/rlelib.c
deleted file mode 100644
index 876557b..0000000
--- a/Utilities/rle/rlelib.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*=========================================================================
-
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-#include "rlelib.h"
-
-void rle_stdio_src(rle_decompress_struct *cinfo, FILE *infile, int *dims)
-{
-  int i;
-  /*is.read((char*)(&Header), sizeof(uint32_t)*16);*/
-  size_t len = fread(cinfo->header, sizeof(uint32_t), 16, infile);
-  cinfo->row = dims[0];
-  cinfo->col = dims[1];
-  if( cinfo->header->num_segments > 16 || cinfo->header->num_segments < 1 )
-    {
-    /* Need to throw something here*/
-      assert(0);
-    }
-  if( cinfo->header->offset[0] != 64 )
-    {
-    /* Need to throw something here*/
-      assert(0);
-    }
-  for(i=1; i < cinfo->header->num_segments; ++i)
-    {
-    if( cinfo->header->offset[i-1] > cinfo->header->offset[i] )
-      {
-      /* Need to throw something here*/
-      assert(0);
-      }
-    }
-  for(i=cinfo->header->num_segments; i < 16; ++i)
-    {
-    if( cinfo->header->offset[i] != 0 )
-      {
-      /* Need to throw something here*/
-      /*assert(0);*/
-      fprintf(stderr, "Impossible : %d for offset # %d\n", cinfo->header->offset[i], i );
-      }
-    }
-  cinfo->stream = infile;
-
-  cinfo->output_height = dims[1];
-}
-
-/*
- * G.3.2 The RLE decoder
- * Pseudo code for the RLE decoder is shown below:
- * Loop until the number of output bytes equals the uncompressed segment size
- * Read the next source byte into n
- * If n> =0 and n <= 127 then
- * output the next n+1 bytes literally
- * Elseif n <= - 1 and n >= -127 then
- * output the next byte -n+1 times
- * Elseif n = - 128 then
- * output nothing
- * Endif
- * Endloop
- */
-
-int rle_start_decompress(rle_decompress_struct *cinfo)
-{
-  fseek(cinfo->stream, cinfo->header->offset[0], SEEK_SET );
-  cinfo->current_pos = 0;
-  return 1;
-}
-
-void rle_create_decompress(rle_decompress_struct *cinfo)
-{
-  int i;
-  cinfo->output_scanline = 0;
-  cinfo->output_height = 0;
-  cinfo->current_segment = 0;
-  cinfo->header = (rle_header*)malloc(sizeof(rle_header));
-  cinfo->header->num_segments = 0;
-  for(i = 0; i < 16; ++i)
-    cinfo->header->offset[i] = 0;
-}
-
-int rle_read_scanlines(rle_decompress_struct *cinfo, char *buffer, int f)
-{
-  signed char byte;
-  signed char nextbyte;
-  unsigned long length = cinfo->row * cinfo->col;
-  /* read too much ! */
-  printf("%d vs %d \n", cinfo->current_pos, length ) ;
-  printf("scan %d \n", cinfo->output_scanline ) ;
-  if( cinfo->current_segment > cinfo->header->num_segments )
-    {
-    return 0;
-    }
-
-  unsigned long noutbytes = 0;
-  char * p = buffer;
-  int c;
-  while( noutbytes < cinfo->row )
-    {
-    size_t s1 = fread(&byte, 1, 1, cinfo->stream);
-    if( byte >= 0 )
-      {
-      fread(p, (int)byte+1, 1, cinfo->stream);
-      p+=(int)byte+1;
-      noutbytes += (int)byte+1;
-      }
-    else if( byte < 0 && byte > -128 )
-      {
-      size_t s2 = fread(&nextbyte, 1, 1, cinfo->stream);
-      for( c = 0; c < (int)-byte + 1; ++c )
-        {
-        *p++ = nextbyte;
-        noutbytes++;
-        }
-      }
-    else
-      {
-      assert( byte == -128 );
-      }
-    }
-  assert( p - buffer == cinfo->row );
-  assert( noutbytes == cinfo->row );
-  cinfo->current_pos += cinfo->row;
-  long pos = ftell(cinfo->stream);
-  /*printf("pos: %d\n",pos);*/
-  cinfo->output_scanline++;
-
-  assert( cinfo->current_pos <= length );
-  if( cinfo->current_pos >= length )
-    {
-   /* if( cinfo->current_segment > cinfo->header->num_segments )
-      {
-      return 0;
-      }
-    else*/
-      {
-      cinfo->current_segment++;
-      cinfo->output_scanline = 0;
-      }
-    }
-
-  return 1;
-}
-
-int rle_finish_decompress(rle_decompress_struct *cinfo)
-{
-  return 1;
-}
-
-void rle_destroy_decompress(rle_decompress_struct *cinfo)
-{
-  cinfo->output_scanline = 0; /* why not*/
-  cinfo->output_height = 0; /* why not*/
-  free(cinfo->header);
-}
diff --git a/Utilities/rle/rlelib.h b/Utilities/rle/rlelib.h
deleted file mode 100644
index 401c93b..0000000
--- a/Utilities/rle/rlelib.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*=========================================================================
-
-  Program: GDCM (Grassroots DICOM). A DICOM library
-
-  Copyright (c) 2006-2011 Mathieu Malaterre
-  All rights reserved.
-  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-#ifndef RLELIB_H
-#define RLELIB_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#define RLE_LIB_VERSION 0.0.1
-
-typedef struct
-{
-  uint32_t num_segments;
-  uint32_t offset[15];
-  void (*print_header) (void);
-} rle_header;
-
-typedef struct
-{
-  rle_header * header;
-} rle_compressed_frame;
-
-typedef struct
-{
-  rle_header * header;
-} rle_decompressed_frame;
-
-typedef struct
-{
-  int (*fill_input_buffer) (rle_decompressed_frame*);
-} source_mgr;
-
-typedef struct
-{
-  int output_scanline;
-  int output_height;
-  /*int bits_allocated; // 8 or 16, when 16 need to do padded composite*/
-  int row;
-  int col;
-  FILE *stream;
-  int current_segment;
-  unsigned long current_pos;
-  rle_header *header;
-} rle_decompress_struct;
-
-
-void rle_stdio_src(rle_decompress_struct *cinfo, FILE *infile, int *dims);
-int rle_start_decompress(rle_decompress_struct *cinfo);
-void rle_create_decompress(rle_decompress_struct *cinfo);
-int rle_read_scanlines(rle_decompress_struct *cinfo, char *buffer, int f);
-int rle_finish_decompress(rle_decompress_struct *cinfo);
-void rle_destroy_decompress(rle_decompress_struct *cinfo);
-
-#endif /* RLELIB_H */
diff --git a/Utilities/wxWidgets/CMakeLists.txt b/Utilities/wxWidgets/CMakeLists.txt
deleted file mode 100644
index b6562fc..0000000
--- a/Utilities/wxWidgets/CMakeLists.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-cmake_minimum_required(VERSION 2.8.7)
-
-project(WXGDCM)
-# wxWidgets stuff changed a lot within the 2.4.2 to 2.4.3
-# I wonder if this has something to do with adding features on a stable branch?
-
-#-----------------------------------------------------------------------------
-find_package(VTK REQUIRED)
-include(${VTK_USE_FILE})
-
-if(WIN32)
-  set(GUI_EXECUTABLE WIN32)
-else()
-  if(APPLE)
-    set(GUI_EXECUTABLE MACOSX_BUNDLE)
-    if(VTK_USE_COCOA)
-      set_source_files_properties(
-        wxVTKRenderWindowInteractor.cxx
-        PROPERTIES COMPILE_FLAGS "-ObjC++")
-    endif()
-  else()
-    # Ok X11 for sure, but just check:
-    if(NOT VTK_USE_X)
-      message(FATAL_ERROR "You need to have VTK_USE_X")
-    endif()
-    # See also:
-    # FindGTK.cmake update
-    # http://www.cmake.org/Bug/bug.php?op=show&bugid=3582
-    #find_package(GTK REQUIRED)
-    #include_directories(${GTK_INCLUDE_DIR}
-    #  #/usr/lib/wx/include/gtk-2.4/
-    #)
-    find_package(PkgConfig)
-    pkg_check_modules (GTK2 gtk+-2.0)
-    #message("${GTK2_INCLUDE_DIRS}")
-    include_directories(${GTK2_INCLUDE_DIRS})
-    link_libraries(${GTK2_LIBRARIES})
-
-    # Can I require all my user to have the gl lib on linux, even if they do not really need it...
-    set(WXGLCANVASLIBS "gl")
-  endif()
-endif()
-
-# wxWidgets is required to build the project
-# For GTK we need a couple of stuff:
-# gl: GLCanvas
-# adv: wxSashLayoutWindow and such...
-find_package(wxWidgets COMPONENTS base core adv ${WXGLCANVASLIBS})
-
-if(wxWidgets_FOUND)
-  include( ${wxWidgets_USE_FILE} )
-endif()
-
-include_directories(
-  ${GDCM_BINARY_DIR}/Source/Common # gdcmConfigure.h
-  ${GDCM_SOURCE_DIR}/Source/Common
-  ${GDCM_SOURCE_DIR}/Utilities/VTK
-)
-
-add_executable(wxGDCM main.cpp wxGDCMFrame.cpp wxGDCMFrameBase.cpp wxVTKRenderWindowInteractor.cxx)
-target_link_libraries(wxGDCM vtkRendering ${wxWidgets_LIBRARIES} vtkgdcm)
-install(TARGETS wxGDCM
-  RUNTIME DESTINATION bin
-  LIBRARY DESTINATION lib
-  ARCHIVE DESTINATION lib/static
-  ${CPACK_NAMELINK_TYPE}
-  )
diff --git a/Utilities/wxWidgets/Copyright.txt b/Utilities/wxWidgets/Copyright.txt
deleted file mode 100644
index a4c072b..0000000
--- a/Utilities/wxWidgets/Copyright.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-/*=========================================================================
-
-  Program:   Visualization Toolkit
-  Module:    $RCSfile: wxVTKRenderWindowInteractor.h,v $
-  Language:  C++
-  Date:      $Date: 2008/08/10 22:58:28 $
-  Version:   $Revision: 1.21 $
-
-  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
-  All rights reserved.
-  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
diff --git a/Utilities/wxWidgets/MyDialog.cpp b/Utilities/wxWidgets/MyDialog.cpp
deleted file mode 100644
index 52d6d14..0000000
--- a/Utilities/wxWidgets/MyDialog.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// -*- C++ -*- generated by wxGlade 0.4.1 on Mon Aug 28 23:13:14 2006
-
-#include "MyDialog.h"
-
-
-MyDialog::MyDialog(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
-    wxDialog(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE)
-{
-    // begin wxGlade: MyDialog::MyDialog
-
-    set_properties();
-    do_layout();
-    // end wxGlade
-}
-
-
-void MyDialog::set_properties()
-{
-    // begin wxGlade: MyDialog::set_properties
-    SetTitle(wxT("About Dialog"));
-    // end wxGlade
-}
-
-
-void MyDialog::do_layout()
-{
-    // begin wxGlade: MyDialog::do_layout
-    Layout();
-    // end wxGlade
-}
diff --git a/Utilities/wxWidgets/MyDialog.h b/Utilities/wxWidgets/MyDialog.h
deleted file mode 100644
index 4aad2ed..0000000
--- a/Utilities/wxWidgets/MyDialog.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// -*- C++ -*- generated by wxGlade 0.4.1 on Mon Aug 28 23:13:14 2006
-
-#include <wx/wx.h>
-#include <wx/image.h>
-
-#ifndef MYDIALOG_H
-#define MYDIALOG_H
-
-// begin wxGlade: ::dependencies
-// end wxGlade
-
-
-class MyDialog: public wxDialog {
-public:
-    // begin wxGlade: MyDialog::ids
-    // end wxGlade
-
-    MyDialog(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE);
-
-private:
-    // begin wxGlade: MyDialog::methods
-    void set_properties();
-    void do_layout();
-    // end wxGlade
-
-protected:
-    // begin wxGlade: MyDialog::attributes
-    // end wxGlade
-}; // wxGlade: end class
-
-
-#endif // MYDIALOG_H
diff --git a/Utilities/wxWidgets/main.cpp b/Utilities/wxWidgets/main.cpp
deleted file mode 100644
index 9247e03..0000000
--- a/Utilities/wxWidgets/main.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// -*- C++ -*- generated by wxGlade 0.4.1 on Sat Aug 19 15:23:11 2006
-
-#include <wx/wx.h>
-#include <wx/image.h>
-#include "wxGDCMFrame.h"
-
-
-
-class wxGDCMApp: public wxApp {
-public:
-    bool OnInit();
-};
-
-IMPLEMENT_APP(wxGDCMApp)
-
-bool wxGDCMApp::OnInit()
-{
-    wxInitAllImageHandlers();
-    wxGDCMFrame* TopFrame = new wxGDCMFrame(0, -1, wxT(""));
-    SetTopWindow(TopFrame);
-    TopFrame->Show();
-    return true;
-}
diff --git a/Utilities/wxWidgets/wxGDCMFrame.cpp b/Utilities/wxWidgets/wxGDCMFrame.cpp
deleted file mode 100644
index f7e4376..0000000
--- a/Utilities/wxWidgets/wxGDCMFrame.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// -*- C++ -*- generated by wxGlade 0.4.1 on Sat Aug 19 15:28:55 2006
-
-#include "wxGDCMFrame.h"
-#include "wxVTKRenderWindowInteractor.h"
-#include "vtkImageViewer2.h"
-#include "vtkImageViewer.h"
-#include "vtkGDCMImageReader.h"
-#include "vtkImageColorViewer.h"
-#include "vtkImageData.h"
-#include "vtkTesting.h"
-#include "vtkTestUtilities.h"
-#include "vtkPNGReader.h"
-#include "vtkRenderer.h"
-
-BEGIN_EVENT_TABLE( wxGDCMFrame, wxGDCMFrameBase )
-    EVT_MENU(wxID_OPEN, wxGDCMFrame::OnOpen)
-    EVT_MENU(wxID_HELP, wxGDCMFrame::OnAbout)
-    EVT_MENU(wxID_EXIT, wxGDCMFrame::OnQuit)
-    EVT_CLOSE(          wxGDCMFrame::OnCloseFrame)
-END_EVENT_TABLE( );
-
-
-wxGDCMFrame::wxGDCMFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
-    wxGDCMFrameBase(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE)
-{
-
-    imageViewer = vtkImageColorViewer::New();
-    //imageViewer = vtkImageViewer::New();
-    //imageViewer->SetupInteractor( NULL );
-    //imageViewer->SetRenderWindow( VTKWindow->GetRenderWindow() );
-    //imageViewer->SetInput( vtkImageData::New() );
-  char* fname = vtkTestUtilities::ExpandDataFileName(0, 0, "Data/fullhead15.png");
-
-  //# Image pipeline
-vtkPNGReader*
-  reader = vtkPNGReader::New();
-  reader->SetDataSpacing (0.8, 0.8, 1.5);
-  reader->SetFileName ( fname );
-  delete[] fname;
-  imageViewer->SetInput ( reader->GetOutput());
-
-    imageViewer->SetupInteractor( VTKWindow );
-    int s[2]={200,200};
-    imageViewer->SetSize( s );
-    Reader      = vtkGDCMImageReader::New();
-    directory = wxT( "" );
-}
-
-wxGDCMFrame::~wxGDCMFrame()
-{
-  //VTKWindow->Delete();
-  imageViewer->Delete();
-  Reader->Delete();
-}
-
-
-void wxGDCMFrame::OnCloseFrame( wxCloseEvent& event )
-{
-  std::cerr << "Close" << std::endl;
-  Destroy();
-}
-
-void wxGDCMFrame::OnOpen(wxCommandEvent& event)
-{
-  std::cerr << "Open" << std::endl;
-  wxString filemask = wxT("DICOM files (*.dcm)|*.dcm");
-  wxFileDialog* dialog = new wxFileDialog( this, wxT("Open DICOM"), directory,
-	filename, filemask, wxOPEN );
-  dialog->CentreOnParent();
-  if ( dialog->ShowModal() == wxID_OK )
-  {
-    directory = dialog->GetDirectory();
-    filename  = dialog->GetFilename();
-    std::cerr << "Dir: " << directory.fn_str() << std::endl;
-    std::cerr << "File: " << filename.fn_str() << std::endl;
-    //wxString fn = dialog->GetFilename();
-    //std::cerr << "fn: " << fn.fn_str() << std::endl;
-    std::string fn = (const char*)directory.fn_str();
-    fn += "/";
-    fn += (const char *)filename.fn_str();
-    Reader->SetFileName( fn.c_str() );
-    Reader->Update();
-    Reader->GetOutput()->Print( std::cout );
-    //imageViewer->SetInputConnection( Reader->GetOutputPort(0) );
-    imageViewer->SetInput( Reader->GetOutput(0) );
-    imageViewer->Modified();
-    imageViewer->GetRenderer()->ResetCameraClippingRange();
-
-    imageViewer->Render();
-  }
-  dialog->Close();
-  dialog->Destroy();
-}
-
-void wxGDCMFrame::OnQuit( wxCommandEvent& event )
-{
-  std::cerr << "Quit" << std::endl;
-  Close(true);
-}
-
-void wxGDCMFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
-{
-    wxMessageBox( _T("This is the about box for wxGDCM"), _T("About wxGDCM"));
-/*
-  wxMessageDialog* msgDialog = new wxMessageDialog( this, wxString(
-	text.c_str(), wxConvUTF8 ), wxString( title.c_str(), wxConvUTF8 ), wxOK );
-  msgDialog->ShowModal();
-  msgDialog->Close();
-  msgDialog->Destroy();
-*/
-
-}
diff --git a/Utilities/wxWidgets/wxGDCMFrame.h b/Utilities/wxWidgets/wxGDCMFrame.h
deleted file mode 100644
index ac72d97..0000000
--- a/Utilities/wxWidgets/wxGDCMFrame.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef WXGDCMFRAME_H
-#define WXGDCMFRAME_H
-
-#include "wxGDCMFrameBase.h"
-class vtkImageColorViewer;
-class vtkImageViewer;
-class vtkGDCMImageReader;
-class wxGDCMFrame: public wxGDCMFrameBase
-{
-public:
-    wxGDCMFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE);
-    ~wxGDCMFrame();
-
-
-    void OnQuit( wxCommandEvent& event );
-    void OnOpen(wxCommandEvent& event);
-    void OnAbout(wxCommandEvent& event);
-    void OnCloseFrame( wxCloseEvent& event );
-
-private:
-    wxString	      directory;
-    wxString        filename;
-    vtkImageColorViewer *imageViewer;
-    //vtkImageViewer *imageViewer;
-    vtkGDCMImageReader  *Reader;
-
-    DECLARE_EVENT_TABLE( );
-}; // wxGlade: end class
-
-
-#endif // WXGDCMFRAME_H
diff --git a/Utilities/wxWidgets/wxGDCMFrameBase.cpp b/Utilities/wxWidgets/wxGDCMFrameBase.cpp
deleted file mode 100644
index a7efc74..0000000
--- a/Utilities/wxWidgets/wxGDCMFrameBase.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-// -*- C++ -*- generated by wxGlade 0.4.1 on Mon Aug 28 23:13:14 2006
-
-#include "wxGDCMFrameBase.h"
-#include "wxVTKRenderWindowInteractor.h"
-
-
-wxGDCMFrameBase::wxGDCMFrameBase(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
-    wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE)
-{
-    // begin wxGlade: wxGDCMFrameBase::wxGDCMFrameBase
-    Notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, 0);
-    TopFrameMenubar = new wxMenuBar();
-    SetMenuBar(TopFrameMenubar);
-    wxMenu* wxglade_tmp_menu_1 = new wxMenu();
-    wxglade_tmp_menu_1->Append(wxID_OPEN, wxT("&Open...\tCtrl+o"), wxT("Open DICOM file"), wxITEM_NORMAL);
-    wxglade_tmp_menu_1->Append(wxNewId(), wxT("&Rewrite...\tCtrl+r"), wxT("Rewrite DICOM file"), wxITEM_NORMAL);
-    wxglade_tmp_menu_1->Append(wxNewId(), wxT("&Save...\tCtrl+s"), wxT("Save DICOM File"), wxITEM_NORMAL);
-    wxglade_tmp_menu_1->AppendSeparator();
-    wxglade_tmp_menu_1->Append(wxID_EXIT, wxT("E&xit...\tCtrl+x"), wxT("Exit app"), wxITEM_NORMAL);
-    TopFrameMenubar->Append(wxglade_tmp_menu_1, wxT("File"));
-    wxMenu* wxglade_tmp_menu_2 = new wxMenu();
-    TopFrameMenubar->Append(wxglade_tmp_menu_2, wxT("Tools"));
-    wxMenu* wxglade_tmp_menu_3 = new wxMenu();
-    wxglade_tmp_menu_3->Append(wxID_HELP, wxT("&About...\tCtrl+a"), wxT("About Dialog"), wxITEM_NORMAL);
-    TopFrameMenubar->Append(wxglade_tmp_menu_3, wxT("Help"));
-    TopFrameStatusbar = CreateStatusBar(1, 0);
-    TopFrameToolbar = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxTB_TEXT);
-    SetToolBar(TopFrameToolbar);
-    TopFrameToolbar->AddTool(wxNewId(), wxT("tool"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
-    TopFrameToolbar->AddSeparator();
-    TopFrameToolbar->AddTool(wxNewId(), wxT("tool"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
-    TopFrameToolbar->AddSeparator();
-    TopFrameToolbar->AddTool(wxNewId(), wxT("tool"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxT(""), wxT(""));
-    TopFrameToolbar->Realize();
-    TreeCtrl = new wxTreeCtrl(this, -1, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS|wxTR_NO_LINES|wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER);
-    ListCtrl = new wxListCtrl(this, -1, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
-    VTKWindow = new wxVTKRenderWindowInteractor(Notebook, -1);
-    Grid = new wxGrid(Notebook, -1);
-
-    set_properties();
-    do_layout();
-    // end wxGlade
-}
-
-
-void wxGDCMFrameBase::set_properties()
-{
-    // begin wxGlade: wxGDCMFrameBase::set_properties
-    SetTitle(wxT("wxGDCM"));
-    SetSize(wxSize(725, 565));
-    int TopFrameStatusbar_widths[] = { -1 };
-    TopFrameStatusbar->SetStatusWidths(1, TopFrameStatusbar_widths);
-    const wxString TopFrameStatusbar_fields[] = {
-        wxT("frame_1_statusbar")
-    };
-    for(int i = 0; i < TopFrameStatusbar->GetFieldsCount(); ++i) {
-        TopFrameStatusbar->SetStatusText(TopFrameStatusbar_fields[i], i);
-    }
-    Grid->CreateGrid(10, 3);
-    // end wxGlade
-}
-
-
-void wxGDCMFrameBase::do_layout()
-{
-    // begin wxGlade: wxGDCMFrameBase::do_layout
-    wxBoxSizer* Sizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL);
-    sizer_1->Add(TreeCtrl, 1, wxEXPAND, 0);
-    sizer_1->Add(ListCtrl, 1, wxEXPAND, 0);
-    Sizer->Add(sizer_1, 1, wxEXPAND, 0);
-    Notebook->AddPage(VTKWindow, wxT("View"));
-    Notebook->AddPage(Grid, wxT("DICOM Tags"));
-    Sizer->Add(Notebook, 1, wxEXPAND, 0);
-    SetAutoLayout(true);
-    SetSizer(Sizer);
-    Layout();
-    // end wxGlade
-}
diff --git a/Utilities/wxWidgets/wxGDCMFrameBase.h b/Utilities/wxWidgets/wxGDCMFrameBase.h
deleted file mode 100644
index 3f303b5..0000000
--- a/Utilities/wxWidgets/wxGDCMFrameBase.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// -*- C++ -*- generated by wxGlade 0.4.1 on Mon Aug 28 23:13:14 2006
-
-#include <wx/wx.h>
-#include <wx/image.h>
-
-#ifndef WXGDCMFRAMEBASE_H
-#define WXGDCMFRAMEBASE_H
-
-// begin wxGlade: ::dependencies
-#include <wx/treectrl.h>
-#include <wx/listctrl.h>
-#include <wx/notebook.h>
-#include <wx/grid.h>
-// end wxGlade
-
-
-class wxVTKRenderWindowInteractor;
-class wxGDCMFrameBase: public wxFrame {
-public:
-    // begin wxGlade: wxGDCMFrameBase::ids
-    // end wxGlade
-
-    wxGDCMFrameBase(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE);
-
-private:
-    // begin wxGlade: wxGDCMFrameBase::methods
-    void set_properties();
-    void do_layout();
-    // end wxGlade
-
-protected:
-    // begin wxGlade: wxGDCMFrameBase::attributes
-    wxMenuBar* TopFrameMenubar;
-    wxStatusBar* TopFrameStatusbar;
-    wxToolBar* TopFrameToolbar;
-    wxTreeCtrl* TreeCtrl;
-    wxListCtrl* ListCtrl;
-    wxVTKRenderWindowInteractor* VTKWindow;
-    wxGrid* Grid;
-    wxNotebook* Notebook;
-    // end wxGlade
-}; // wxGlade: end class
-
-
-#endif // WXGDCMFRAMEBASE_H
diff --git a/Utilities/wxWidgets/wxVTKRenderWindowInteractor.cxx b/Utilities/wxWidgets/wxVTKRenderWindowInteractor.cxx
deleted file mode 100644
index df5c05e..0000000
--- a/Utilities/wxWidgets/wxVTKRenderWindowInteractor.cxx
+++ /dev/null
@@ -1,815 +0,0 @@
-/*=========================================================================
-
-  Program:   Visualization Toolkit
-  Module:    $RCSfile: wxVTKRenderWindowInteractor.cxx,v $
-  Language:  C++
-  Date:      $Date: 2008/08/25 00:27:39 $
-  Version:   $Revision: 1.42 $
-
-  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
-  All rights reserved.
-  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-
-#include <assert.h>
-
-#include "wxVTKRenderWindowInteractor.h"
-
-//This is needed for vtk 3.1 :
-#ifndef VTK_MAJOR_VERSION
-#  include "vtkVersion.h"
-#endif
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-#  include "vtkCommand.h"
-#else
-#  include "vtkInteractorStyle.h"
-#endif
-#include "vtkDebugLeaks.h"
-
-#ifdef __WXMAC__
-#ifdef __WXCOCOA__
-#include "vtkCocoaRenderWindow.h"
-#else
-#include "vtkCarbonRenderWindow.h"
-#endif
-#endif
-
-//Keep this for compatibilty reason, this was introduced in wxGTK 2.4.0
-#if (!wxCHECK_VERSION(2, 4, 0))
-wxWindow* wxGetTopLevelParent(wxWindow *win)
-{
-    while ( win && !win->IsTopLevel() )
-         win = win->GetParent();
-    return win;
-}
-#endif
-
-// To access objc calls on cocoa
-#ifdef __WXCOCOA__
-#ifdef VTK_USE_COCOA
-#import <Cocoa/Cocoa.h>
-// This trick is no longer need in VTK CVS, should get rid of that:
-#define id Id
-#else
-#error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work
-#endif //VTK_USE_COCOA
-#endif //__WXCOCOA__
-
-#ifdef __WXGTK__
-#    include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
-#    include "gdk/gdkprivate.h"
-#if wxCHECK_VERSION(2, 8, 0)
-#ifdef __WXGTK20__
-#include <wx/gtk/win_gtk.h>
-#else
-#include <wx/gtk1/win_gtk.h>
-#endif
-#else
-#include <wx/gtk/win_gtk.h>
-#endif
-#define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
-                          GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
-                          GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
-#endif
-
-#ifdef __WXX11__
-#include "wx/x11/privx.h"
-#define GetXWindow(wxwin)   ((Window)(wxwin)->GetHandle())
-#endif
-
-
-//For more info on this class please go to:
-//http://wxvtk.sf.net
-//This hack is for some buggy wxGTK version:
-#if wxCHECK_VERSION(2, 3, 2) && !wxCHECK_VERSION(2, 4, 1) && defined(__WXGTK__)
-#  define WX_USE_X_CAPTURE 0
-#else
-#  define WX_USE_X_CAPTURE 1
-#endif
-
-#define ID_wxVTKRenderWindowInteractor_TIMER 1001
-
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxGLCanvas)
-#else
-IMPLEMENT_DYNAMIC_CLASS(wxVTKRenderWindowInteractor, wxWindow)
-#endif  //__WXGTK__
-
-//---------------------------------------------------------------------------
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxGLCanvas)
-#else
-BEGIN_EVENT_TABLE(wxVTKRenderWindowInteractor, wxWindow)
-#endif //__WXGTK__
-  //refresh window by doing a Render
-  EVT_PAINT       (wxVTKRenderWindowInteractor::OnPaint)
-  EVT_ERASE_BACKGROUND(wxVTKRenderWindowInteractor::OnEraseBackground)
-  EVT_MOTION      (wxVTKRenderWindowInteractor::OnMotion)
-
-  //Bind the events to the event converters
-  EVT_LEFT_DOWN   (wxVTKRenderWindowInteractor::OnButtonDown)
-  EVT_MIDDLE_DOWN (wxVTKRenderWindowInteractor::OnButtonDown)
-  EVT_RIGHT_DOWN  (wxVTKRenderWindowInteractor::OnButtonDown)
-  EVT_LEFT_UP     (wxVTKRenderWindowInteractor::OnButtonUp)
-  EVT_MIDDLE_UP   (wxVTKRenderWindowInteractor::OnButtonUp)
-  EVT_RIGHT_UP    (wxVTKRenderWindowInteractor::OnButtonUp)
-#if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
-  EVT_ENTER_WINDOW(wxVTKRenderWindowInteractor::OnEnter)
-  EVT_LEAVE_WINDOW(wxVTKRenderWindowInteractor::OnLeave)
-  EVT_MOUSEWHEEL  (wxVTKRenderWindowInteractor::OnMouseWheel)
-#if wxCHECK_VERSION(2, 8, 0)
-  EVT_MOUSE_CAPTURE_LOST(wxVTKRenderWindowInteractor::OnMouseCaptureLost)
-#endif
-  EVT_KEY_DOWN    (wxVTKRenderWindowInteractor::OnKeyDown)
-  EVT_KEY_UP      (wxVTKRenderWindowInteractor::OnKeyUp)
-  EVT_CHAR        (wxVTKRenderWindowInteractor::OnChar)
-#endif
-  EVT_TIMER       (ID_wxVTKRenderWindowInteractor_TIMER, wxVTKRenderWindowInteractor::OnTimer)
-  EVT_SIZE        (wxVTKRenderWindowInteractor::OnSize)
-END_EVENT_TABLE()
-
-#if VTK_MAJOR_VERSION < 6
-vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision: 1.42 $")
-#else
-//vtkCxxRevisionMacro(wxVTKRenderWindowInteractor, "$Revision: 1.42 $")
-#endif
-vtkInstantiatorNewMacro(wxVTKRenderWindowInteractor)
-
-//---------------------------------------------------------------------------
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-#if (wxCHECK_VERSION(2, 8, 0))
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(0, -1, wxDefaultPosition), vtkRenderWindowInteractor()
-#else
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxGLCanvas(), vtkRenderWindowInteractor()
-#endif
-#else
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRenderWindowInteractor()
-#endif //__WXGTK__
-      , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
-      , ActiveButton(wxEVT_NULL)
-      , RenderAllowed(0)
-      , Stereo(0)
-      , Handle(0)
-      , Created(true)
-      , RenderWhenDisabled(1)
-      , UseCaptureMouse(0)
-{
-#ifdef VTK_DEBUG_LEAKS
-  vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
-#endif
-  this->RenderWindow = NULL;
-  this->SetRenderWindow(vtkRenderWindow::New());
-  this->RenderWindow->Delete();
-}
-//---------------------------------------------------------------------------
-wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
-                                                         wxWindowID id,
-                                                         const wxPoint &pos,
-                                                         const wxSize &size,
-                                                         long style,
-                                                         const wxString &name)
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-      : wxGLCanvas(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
-#else
-      : wxWindow(parent, id, pos, size, style, name), vtkRenderWindowInteractor()
-#endif //__WXGTK__
-      , timer(this, ID_wxVTKRenderWindowInteractor_TIMER)
-      , ActiveButton(wxEVT_NULL)
-      , RenderAllowed(0)
-      , Stereo(0)
-      , Handle(0)
-      , Created(true)
-      , RenderWhenDisabled(1)
-      , UseCaptureMouse(0)
-{
-#ifdef VTK_DEBUG_LEAKS
-  vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor");
-#endif
-  this->RenderWindow = NULL;
-  this->SetRenderWindow(vtkRenderWindow::New());
-  this->RenderWindow->Delete();
-#ifdef __WXMAC__
-  // On Mac (Carbon) we don't get notified of the initial window size with an EVT_SIZE event,
-  // so we update the size information of the interactor/renderwindow here
-  this->UpdateSize(size.x, size.y);
-#endif
-}
-//---------------------------------------------------------------------------
-wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
-{
-  SetRenderWindow(NULL);
-  SetInteractorStyle(NULL);
-}
-//---------------------------------------------------------------------------
-wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New()
-{
-  // we don't make use of the objectfactory, because we're not registered
-  return new wxVTKRenderWindowInteractor;
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::Initialize()
-{
-  int *size = RenderWindow->GetSize();
-  // enable everything and start rendering
-  Enable();
-  //RenderWindow->Start();
-
-  // set the size in the render window interactor
-  Size[0] = size[0];
-  Size[1] = size[1];
-
-  // this is initialized
-  Initialized = 1;
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::Enable()
-{
-  // if already enabled then done
-  if (Enabled)
-    return;
-
-  // that's it
-  Enabled = 1;
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-  SetCurrent();
-#endif
-  Modified();
-}
-//---------------------------------------------------------------------------
-bool wxVTKRenderWindowInteractor::Enable(bool enable)
-{
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-  return wxGLCanvas::Enable(enable);
-#else
-  return wxWindow::Enable(enable);
-#endif
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::Disable()
-{
-  // if already disabled then done
-  if (!Enabled)
-    return;
-
-  // that's it (we can't remove the event handler like it should be...)
-  Enabled = 0;
-  Modified();
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::Start()
-{
-  // the interactor cannot control the event loop
-  vtkErrorMacro( << "wxVTKRenderWindowInteractor::Start() "
-    "interactor cannot control event loop.");
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::UpdateSize(int x, int y)
-{
-  if( RenderWindow )
-  {
-    // if the size changed tell render window
-    if ( x != Size[0] || y != Size[1] )
-    {
-      // adjust our (vtkRenderWindowInteractor size)
-      Size[0] = x;
-      Size[1] = y;
-      // and our RenderWindow's size
-      RenderWindow->SetSize(x, y);
-    }
-  }
-}
-//---------------------------------------------------------------------------
-int wxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype))
-{
-  // it's a one shot timer
-  if (!timer.Start(10, TRUE))
-    assert(false);
-
-  return 1;
-
-}
-//---------------------------------------------------------------------------
-int wxVTKRenderWindowInteractor::DestroyTimer()
-{
-  // do nothing
-  return 1;
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event))
-{
-  if (!Enabled)
-    return;
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::TimerEvent, NULL);
-#else
-    // old style
-    InteractorStyle->OnTimer();
-#endif
-}
-
-//---------------------------------------------------------------------------
-// NOTE on implementation:
-// Bad luck you ended up in the only tricky place of this code.
-// A few note, wxWidgets still refuse to provide such convenient method
-// so I have to maintain it myself, eventhough this is completely integrated
-// in wxPython...
-// Anyway if this happen to break for you then compare to a recent version of wxPython
-// and look for the function long wxPyGetWinHandle(wxWindow* win)
-// in wxPython/src/helpers.cpp
-long wxVTKRenderWindowInteractor::GetHandleHack()
-{
-  //helper function to hide the MSW vs GTK stuff
-  long handle_tmp = 0;
-
-// __WXMSW__ is for Win32
-//__WXMAC__ stands for using Carbon C-headers, using either the CarbonLib/CFM or the native Mach-O builds (which then also use the latest features available)
-// __WXGTK__ is for both gtk 1.2.x and gtk 2.x
-#if defined(__WXMSW__) || defined(__WXMAC__)
-    handle_tmp = (long)this->GetHandle();
-#endif //__WXMSW__
-
-//__WXCOCOA__ stands for using the objective-c Cocoa API
-#ifdef __WXCOCOA__
-   // Here is how to find the NSWindow
-   wxTopLevelWindow* toplevel = dynamic_cast<wxTopLevelWindow*>(
-     wxGetTopLevelParent( this ) );
-   if (toplevel != NULL )
-   {
-     handle_tmp = (long)toplevel->GetNSWindow();
-   }
-   // The NSView will be deducted from
-   // [(NSWindow*)Handle contentView]
-   // if only I knew how to write that in c++
-#endif //__WXCOCOA__
-
-    // Find and return the actual X-Window.
-#if defined(__WXGTK__) || defined(__WXX11__)
-    return (long)GetXWindow(this);
-#endif
-
-//#ifdef __WXMOTIF__
-//    handle_tmp = (long)this->GetXWindow();
-//#endif
-
-  return handle_tmp;
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
-{
-  //must always be here
-  wxPaintDC pDC(this);
-
-  //do it here rather than in the cstor: this is safer.
-  if(!Handle)
-  {
-    Handle = GetHandleHack();
-    RenderWindow->SetWindowId(reinterpret_cast<void *>(Handle));
-// Cocoa
-// this->GetNSView() <-> DisplayId
-// this->GetTopLevel()->GetNSWindow() <-> WindowId
-#ifdef __WXMSW__
-    RenderWindow->SetParentId(reinterpret_cast<void *>(this->GetParent()->GetHWND()));
-#endif //__WXMSW__
-  }
-  // get vtk to render to the wxWindows
-  Render();
-#ifdef __WXMAC__
-  // This solves a problem with repainting after a window resize
-  // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
-#ifdef __WXCOCOA__
-  vtkCocoaRenderWindow * rwin = vtkCocoaRenderWindow::SafeDownCast(RenderWindow);
-  if( rwin )
-  {
-    rwin->UpdateContext();
-  }
-#else
-  vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
-  if( rwin )
-  {
-    rwin->UpdateGLRegion();
-  }
-#endif
-#endif
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
-{
-  //turn off background erase to reduce flickering on MSW
-  event.Skip(false);
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
-{
-  int w, h;
-  GetClientSize(&w, &h);
-  UpdateSize(w, h);
-
-  if (!Enabled)
-    {
-    return;
-    }
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-  InvokeEvent(vtkCommand::ConfigureEvent, NULL);
-#endif
-  //this will check for Handle
-  //Render();
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
-{
- if (!Enabled)
-    {
-    return;
-    }
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-  SetEventInformationFlipY(event.GetX(), event.GetY(),
-    event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
-
-  InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
-#else
-  InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(),
-    event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-}
-//---------------------------------------------------------------------------
-#if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
-void wxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event)
-{
-  if (!Enabled)
-    {
-    return;
-    }
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-  SetEventInformationFlipY(event.GetX(), event.GetY(),
-      event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
-
-  InvokeEvent(vtkCommand::EnterEvent, NULL);
-#else
-    // old style
-  InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event)
-{
-  if (!Enabled)
-    {
-    return;
-    }
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-  SetEventInformationFlipY(event.GetX(), event.GetY(),
-      event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
-
-  InvokeEvent(vtkCommand::LeaveEvent, NULL);
-#else
-    // old style
-  InteractorStyle->OnLeave(event.ControlDown(), event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event)
-{
-  if (!Enabled)
-    {
-    return;
-    }
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-  int keycode = event.GetKeyCode();
-  char key = '\0';
-  if (((unsigned int)keycode) < 256)
-  {
-    // TODO: Unicode in non-Unicode mode ??
-    key = (char)keycode;
-  }
-
-  // we don't get a valid mouse position inside the key event on every platform
-  // so we retrieve the mouse position explicitly and pass it along
-  wxPoint mousePos = ScreenToClient(wxGetMousePosition());
-  SetEventInformationFlipY(mousePos.x, mousePos.y,
-                           event.ControlDown(), event.ShiftDown(), key, 0, NULL);
-  InvokeEvent(vtkCommand::KeyPressEvent, NULL);
-#else
-  InteractorStyle->OnKeyDown(event.ControlDown(), event.ShiftDown(),
-    event.GetKeyCode(), 1);
-#endif
-  event.Skip();
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event)
-{
-  if (!Enabled)
-    {
-    return;
-    }
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-  int keycode = event.GetKeyCode();
-  char key = '\0';
-  if (((unsigned int)keycode) < 256)
-  {
-    // TODO: Unicode in non-Unicode mode ??
-    key = (char)keycode;
-  }
-
-  // we don't get a valid mouse position inside the key event on every platform
-  // so we retrieve the mouse position explicitly and pass it along
-  wxPoint mousePos = ScreenToClient(wxGetMousePosition());
-  SetEventInformationFlipY(mousePos.x, mousePos.y,
-                           event.ControlDown(), event.ShiftDown(), key, 0, NULL);
-  InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
-#else
-  InteractorStyle->OnKeyUp(event.ControlDown(), event.ShiftDown(),
-    event.GetKeyCode(), 1);
-#endif
-  event.Skip();
-}
-#endif //!(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
- //---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event)
-{
-  if (!Enabled)
-    {
-    return;
-    }
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-  // new style
-  int keycode = event.GetKeyCode();
-  char key = '\0';
-  if (((unsigned int)keycode) < 256)
-    {
-    // TODO: Unicode in non-Unicode mode ??
-    key = (char)keycode;
-    }
-
-  // we don't get a valid mouse position inside the key event on every platform
-  // so we retrieve the mouse position explicitly and pass it along
-  wxPoint mousePos = ScreenToClient(wxGetMousePosition());
-  SetEventInformationFlipY(mousePos.x, mousePos.y,
-                           event.ControlDown(), event.ShiftDown(), key, 0, NULL);
-  InvokeEvent(vtkCommand::CharEvent, NULL);
-#endif
-  event.Skip();
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnButtonDown(wxMouseEvent &event)
-{
-  if (!Enabled || (ActiveButton != wxEVT_NULL))
-    {
-    return;
-    }
-  ActiveButton = event.GetEventType();
-
-    // On Mac (Carbon) and Windows we don't automatically get the focus when
-    // you click inside the window
-    // we therefore set the focus explicitly
-    // Apparently we need that on linux (GTK) too:
-    this->SetFocus();
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-  SetEventInformationFlipY(event.GetX(), event.GetY(),
-    event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
-#endif
-
-  if(event.RightDown())
-  {
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
-#else
-    // old style
-    InteractorStyle->OnRightButtonDown(event.ControlDown(), event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-  }
-  else if(event.LeftDown())
-  {
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
-#else
-    // old style
-    InteractorStyle->OnLeftButtonDown(event.ControlDown(),  event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-  }
-  else if(event.MiddleDown())
-  {
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
-#else
-    // old style
-    InteractorStyle->OnMiddleButtonDown(event.ControlDown(), event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-  }
-  //save the button and capture mouse until the button is released
-  //Only if :
-  //1. it is possible (WX_USE_X_CAPTURE)
-  //2. user decided to.
-  if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
-  {
-    CaptureMouse();
-  }
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnButtonUp(wxMouseEvent &event)
-{
-  //EVT_xxx_DOWN == EVT_xxx_UP - 1
-  //This is only needed if two mouse buttons are pressed at the same time.
-  //In wxWindows 2.4 and later: better use of wxMOUSE_BTN_RIGHT or
-  //wxEVT_COMMAND_RIGHT_CLICK
-  if (!Enabled || (ActiveButton != (event.GetEventType()-1)))
-    {
-    return;
-    }
-
-  // See report by Shang Mu / Kerry Loux on wxVTK mailing list
-    this->SetFocus();
-
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-  SetEventInformationFlipY(event.GetX(), event.GetY(),
-    event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
-#endif
-
-  if(ActiveButton == wxEVT_RIGHT_DOWN)
-  {
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
-#else
-    // old style
-    InteractorStyle->OnRightButtonUp(event.ControlDown(), event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-  }
-  else if(ActiveButton == wxEVT_LEFT_DOWN)
-  {
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
-#else
-    // old style
-    InteractorStyle->OnLeftButtonUp(event.ControlDown(), event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-  }
-  else if(ActiveButton == wxEVT_MIDDLE_DOWN)
-  {
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-    // new style
-    InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
-#else
-    // old style
-    InteractorStyle->OnMiddleButtonUp(event.ControlDown(), event.ShiftDown(),
-      event.GetX(), Size[1] - event.GetY() - 1);
-#endif
-  }
-  //if the ActiveButton is realeased, then release mouse capture
-  if ((ActiveButton != wxEVT_NULL) && WX_USE_X_CAPTURE && UseCaptureMouse)
-  {
-    ReleaseMouse();
-  }
-  ActiveButton = wxEVT_NULL;
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event)
-{
-// Mouse wheel was only added after VTK 4.4 (I think...)
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
-  // new style
-  //Set vtk event information ... The numebr of wheel rotations is stored in
-  //the x varible.  y varible is zero
-  SetEventInformationFlipY(event.GetX() , event.GetY(),
-                           event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
-  if(event.GetWheelRotation() > 0)
-    {
-      //Send event to VTK
-      InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
-    }
-  else
-    {
-      //Send event to VTK
-      InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
-    }
-#endif
-
-}
-
-//---------------------------------------------------------------------------
-#if wxCHECK_VERSION(2, 8, 0)
-void wxVTKRenderWindowInteractor::OnMouseCaptureLost(wxMouseCaptureLostEvent& event)
-{
-   if (ActiveButton != wxEVT_NULL)
-   {
-       //Maybe also invoke the button release event here
-   }
-   // Reset ActiveButton so that
-   // 1. we do not process mouse button up events any more,
-   // 2. the next button down event will be processed and call CaptureMouse().
-   // Otherwise ReleaseMouse() will be called
-   // without a previous CaptureMouse().
-   ActiveButton = wxEVT_NULL;
-}
-#endif
-
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::Render()
-{
-  RenderAllowed = 1;
-  if (!RenderWhenDisabled)
-    {
-    //the user doesn't want us to render when the toplevel frame
-    //is disabled - first find the top level parent
-    wxWindow *topParent = wxGetTopLevelParent(this);
-    if (topParent)
-      {
-      //if it exists, check whether it's enabled
-      //if it's not enabeld, RenderAllowed will be false
-      RenderAllowed = topParent->IsEnabled();
-      }
-    }
-
-  if (RenderAllowed)
-    {
-    if(Handle && (Handle == GetHandleHack()) )
-      {
-      RenderWindow->Render();
-      }
-#if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2)
-    else if(GetHandleHack())
-      {
-      //this means the user has reparented us; let's adapt to the
-      //new situation by doing the WindowRemap dance
-      //store the new situation
-      Handle = GetHandleHack();
-      RenderWindow->SetNextWindowId(reinterpret_cast<void *>(Handle));
-      RenderWindow->WindowRemap();
-      RenderWindow->Render();
-      }
-#endif
-    }
-}
-//---------------------------------------------------------------------------
-void wxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue)
-{
-  //Change value of __RenderWhenDisabled ivar.
-  //If __RenderWhenDisabled is false (the default), this widget will not
-  //call Render() on the RenderWindow if the top level frame (i.e. the
-  //containing frame) has been disabled.
-
-  //This prevents recursive rendering during wxSafeYield() calls.
-  //wxSafeYield() can be called during the ProgressMethod() callback of
-  //a VTK object to have progress bars and other GUI elements updated -
-  //it does this by disabling all windows (disallowing user-input to
-  //prevent re-entrancy of code) and then handling all outstanding
-  //GUI events.
-
-  //However, this often triggers an OnPaint() method for wxVTKRWIs,
-  //resulting in a Render(), resulting in Update() being called whilst
-  //still in progress.
-
-  RenderWhenDisabled = (bool)newValue;
-}
-//---------------------------------------------------------------------------
-//
-// Set the variable that indicates that we want a stereo capable window
-// be created. This method can only be called before a window is realized.
-//
-void wxVTKRenderWindowInteractor::SetStereo(int capable)
-{
-  if (Stereo != capable)
-    {
-    Stereo = capable;
-    RenderWindow->StereoCapableWindowOn();
-    RenderWindow->SetStereoTypeToCrystalEyes();
-    Modified();
-    }
-}
-
-//---------------------------------------------------------------------------
-//
-//
-void wxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
-{
-  this->Superclass::PrintSelf(os, indent);
-}
diff --git a/Utilities/wxWidgets/wxVTKRenderWindowInteractor.h b/Utilities/wxWidgets/wxVTKRenderWindowInteractor.h
deleted file mode 100644
index a7aa888..0000000
--- a/Utilities/wxWidgets/wxVTKRenderWindowInteractor.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*=========================================================================
-
-  Program:   Visualization Toolkit
-  Module:    $RCSfile: wxVTKRenderWindowInteractor.h,v $
-  Language:  C++
-  Date:      $Date: 2008/08/10 22:58:28 $
-  Version:   $Revision: 1.21 $
-
-  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
-  All rights reserved.
-  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
-
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
-
-=========================================================================*/
-
-// .NAME  wxVTKRenderWindowInteractor - class to enable VTK to render to
-// and interact with wxWindow.
-// .SECTION Description
-//  wxVTKRenderWindowInteractor provide a VTK widget for wxWindow. This class
-// was completely rewrote to have the 'Look & Feel' of the python version:
-// wxVTKRenderWindowInteractor.py
-// .SECTION Caveats
-//  - There is a know bug that prevent this class to works for more info see
-// WX_USE_X_CAPTURE. This bug only affect wxGTK from 2.3.2 to wxGTK 2.4.0.
-//  - Furthermore this class is tempated over either wxWindows or wxGLCanvas,
-// in wxWindows 2.3.1 and earlier, the wxGLCanvas had scroll bars, you can avoid
-// this effect by playing with WX_BASE_CLASS at your risk (you might end up with
-// lot of flickering.)
-//  - This class might not be easily readable as it tried to work with VTK 3.2
-//  and 4.x. This class doesn't support reparenting with VTK 4.2 and earlier.
-// .SECTION see also
-// wxVTKRenderWindowInteractor.py wxVTKRenderWindow.py
-
-#ifndef _wxVTKRenderWindowInteractor_h_
-#define _wxVTKRenderWindowInteractor_h_
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-#  pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
-#include <wx/wx.h>
-#endif
-
-#include <wx/timer.h>
-#include <wx/dcclient.h>
-
-// vtk includes
-#include "vtkRenderWindowInteractor.h"
-#include "vtkRenderWindow.h"
-
-// Apparently since wxGTK 2.8.0 one can finally use wxWindow (just as in any
-// other port):
-// MM: tested on 2008/04/08: experienced some heavy flickering with wx-widget 2.6.0
-// using a wxWindow instead of wxGLCanvas fixed the symptoms
-//#if (!wxCHECK_VERSION(2, 6, 0))
-#if (!wxCHECK_VERSION(2, 8, 0))
-#define USE_WXGLCANVAS
-#endif
-
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-#  if wxUSE_GLCANVAS
-#    include <wx/glcanvas.h>
-#  else
-#    error "problem of wxGLCanvas, you need to build wxWidgets with opengl"
-#  endif //wxUSE_GLCANVAS
-#endif //__WXGTK__
-
-// Motif version (renamed into wxX11 for wxWindow 2.4 and newer)
-#if defined(__WXMOTIF__)
-# error This GUI is not supported by wxVTKRenderWindowInteractor for now
-#endif
-
-// wx forward declarations
-class wxPaintEvent;
-class wxMouseEvent;
-class wxTimerEvent;
-class wxKeyEvent;
-class wxSizeEvent;
-
-#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
-class wxVTKRenderWindowInteractor : public wxGLCanvas, public vtkRenderWindowInteractor
-#else
-class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInteractor
-#endif //__WXGTK__
-{
-  DECLARE_DYNAMIC_CLASS(wxVTKRenderWindowInteractor)
-
-  public:
-    //constructors
-    wxVTKRenderWindowInteractor();
-
-    wxVTKRenderWindowInteractor(wxWindow *parent,
-                                wxWindowID id,
-                                const wxPoint &pos = wxDefaultPosition,
-                                const wxSize &size = wxDefaultSize,
-                                long style = wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE,
-                                const wxString &name = wxPanelNameStr);
-#if VTK_MAJOR_VERSION < 6
-    vtkTypeRevisionMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor);
-#else
-    vtkTypeMacro(wxVTKRenderWindowInteractor,vtkRenderWindowInteractor);
-#endif
-    static wxVTKRenderWindowInteractor * New();
-    void PrintSelf(ostream& os, vtkIndent indent);
-
-    //destructor
-    ~wxVTKRenderWindowInteractor();
-
-    // vtkRenderWindowInteractor overrides
-    void Initialize();
-    void Enable();
-    bool Enable(bool enable);
-    void Disable();
-    void Start();
-    void UpdateSize(int x, int y);
-    int CreateTimer(int timertype);
-    int DestroyTimer();
-    void TerminateApp() {};
-
-    // event handlers
-    void OnPaint(wxPaintEvent &event);
-    void OnEraseBackground (wxEraseEvent& event);
-    void OnMotion(wxMouseEvent &event);
-
-    void OnButtonDown(wxMouseEvent &event);
-    void OnButtonUp(wxMouseEvent &event);
-#if !(VTK_MAJOR_VERSION == 3 && VTK_MINOR_VERSION == 1)
-    void OnEnter(wxMouseEvent &event);
-    void OnLeave(wxMouseEvent &event);
-    void OnMouseWheel(wxMouseEvent& event);
-#if wxCHECK_VERSION(2, 8, 0)
-    void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
-#endif
-    void OnKeyDown(wxKeyEvent &event);
-    void OnKeyUp(wxKeyEvent &event);
-    void OnChar(wxKeyEvent &event);
-#endif
-    void OnTimer(wxTimerEvent &event);
-    void OnSize(wxSizeEvent &event);
-
-    void Render();
-    void SetRenderWhenDisabled(int newValue);
-
-    // Description:
-    // Prescribe that the window be created in a stereo-capable mode. This
-    // method must be called before the window is realized. Default if off.
-    vtkGetMacro(Stereo,int);
-    vtkBooleanMacro(Stereo,int);
-    virtual void SetStereo(int capable);
-
-    // Description:
-    // As CaptureMouse could be a problem sometimes on a window box
-    // This method allow to set or not the CaptureMouse.
-    // This method actually will works only if WX_USE_X_CAPTURE was set to 1
-    vtkSetMacro(UseCaptureMouse,int);
-    vtkBooleanMacro(UseCaptureMouse,int);
-
-  protected:
-    wxTimer timer;
-    int ActiveButton;
-    int RenderAllowed;
-    long GetHandleHack();
-    int Stereo;
-
-  private:
-    long Handle;
-    bool Created;
-    int RenderWhenDisabled;
-    int UseCaptureMouse;
-
-    DECLARE_EVENT_TABLE()
-};
-
-#endif //_wxVTKRenderWindowInteractor_h_
diff --git a/Utilities/wxWidgets/wxgdcm.wxg b/Utilities/wxWidgets/wxgdcm.wxg
deleted file mode 100644
index 97762f1..0000000
--- a/Utilities/wxWidgets/wxgdcm.wxg
+++ /dev/null
@@ -1,180 +0,0 @@
-<?xml version="1.0"?>
-<!-- generated by wxGlade 0.4.1 on Mon Aug 28 23:13:12 2006 -->
-
-<application path="/home/mathieu/Projects/GDCM/gdcm/Utilities/wxWidgets/" name="wxGDCM" class="wxGDCMApp" option="1" language="C++" top_window="TopFrame" encoding="UTF-8" use_gettext="0" overwrite="1" use_new_namespace="1" for_version="2.6">
-    <object class="wxGDCMFrameBase" name="TopFrame" base="EditFrame">
-        <style>wxDEFAULT_FRAME_STYLE</style>
-        <title>wxGDCM</title>
-        <menubar>1</menubar>
-        <statusbar>1</statusbar>
-        <toolbar>1</toolbar>
-        <size>725, 565</size>
-        <object class="wxMenuBar" name="TopFrameMenubar" base="EditMenuBar">
-            <menus>
-                <menu name="" label="File">
-                    <item>
-                        <label>&Open...\tCtrl+o</label>
-                        <id>wxID_OPEN</id>
-                        <name>OpenName</name>
-                        <help_str>Open DICOM file</help_str>
-                        <handler>OpenEvt</handler>
-                    </item>
-                    <item>
-                        <label>&Rewrite...\tCtrl+r</label>
-                        <name>RewriteName</name>
-                        <help_str>Rewrite DICOM file</help_str>
-                        <handler>RewriteEvt</handler>
-                    </item>
-                    <item>
-                        <label>&Save...\tCtrl+s</label>
-                        <name>SaveName</name>
-                        <help_str>Save DICOM File</help_str>
-                        <handler>SaveEvt</handler>
-                    </item>
-                    <item>
-                        <label>---</label>
-                        <id>---</id>
-                        <name>---</name>
-                    </item>
-                    <item>
-                        <label>E&xit...\tCtrl+x</label>
-                        <id>wxID_EXIT</id>
-                        <name>ExitName</name>
-                        <help_str>Exit app</help_str>
-                        <handler>ExitEvt</handler>
-                    </item>
-                </menu>
-                <menu name="" label="Tools">
-                </menu>
-                <menu name="" label="Help">
-                    <item>
-                        <label>&About...\tCtrl+a</label>
-                        <id>wxID_HELP</id>
-                        <name>AboutName</name>
-                        <help_str>About Dialog</help_str>
-                        <handler>AboutEvt</handler>
-                    </item>
-                </menu>
-            </menus>
-        </object>
-        <object class="wxStatusBar" name="TopFrameStatusbar" base="EditStatusBar">
-            <fields>
-                <field width="-1">frame_1_statusbar</field>
-            </fields>
-        </object>
-        <object class="wxToolBar" name="TopFrameToolbar" base="EditToolBar">
-            <style>wxTB_TEXT</style>
-            <tools>
-                <tool>
-                    <id></id>
-                    <label>tool</label>
-                    <type>0</type>
-                    <short_help></short_help>
-                    <long_help></long_help>
-                    <bitmap1></bitmap1>
-                    <bitmap2></bitmap2>
-                </tool>
-                <tool>
-                    <id>---</id>
-                    <label>---</label>
-                    <type>0</type>
-                    <short_help>---</short_help>
-                    <long_help></long_help>
-                    <bitmap1>---</bitmap1>
-                    <bitmap2>---</bitmap2>
-                </tool>
-                <tool>
-                    <id></id>
-                    <label>tool</label>
-                    <type>0</type>
-                    <short_help></short_help>
-                    <long_help></long_help>
-                    <bitmap1></bitmap1>
-                    <bitmap2></bitmap2>
-                </tool>
-                <tool>
-                    <id>---</id>
-                    <label>---</label>
-                    <type>0</type>
-                    <short_help>---</short_help>
-                    <long_help></long_help>
-                    <bitmap1>---</bitmap1>
-                    <bitmap2>---</bitmap2>
-                </tool>
-                <tool>
-                    <id></id>
-                    <label>tool</label>
-                    <type>0</type>
-                    <short_help></short_help>
-                    <long_help></long_help>
-                    <bitmap1></bitmap1>
-                    <bitmap2></bitmap2>
-                </tool>
-            </tools>
-        </object>
-        <object class="wxBoxSizer" name="Sizer" base="EditBoxSizer">
-            <orient>wxHORIZONTAL</orient>
-            <object class="sizeritem">
-                <flag>wxEXPAND</flag>
-                <border>0</border>
-                <option>1</option>
-                <object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
-                    <orient>wxVERTICAL</orient>
-                    <object class="sizeritem">
-                        <flag>wxEXPAND</flag>
-                        <border>0</border>
-                        <option>1</option>
-                        <object class="wxTreeCtrl" name="TreeCtrl" base="EditTreeCtrl">
-                            <style>wxTR_HAS_BUTTONS|wxTR_NO_LINES|wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER</style>
-                        </object>
-                    </object>
-                    <object class="sizeritem">
-                        <flag>wxEXPAND</flag>
-                        <border>0</border>
-                        <option>1</option>
-                        <object class="wxListCtrl" name="ListCtrl" base="EditListCtrl">
-                            <style>wxLC_REPORT|wxSUNKEN_BORDER</style>
-                        </object>
-                    </object>
-                </object>
-            </object>
-            <object class="sizeritem">
-                <flag>wxEXPAND</flag>
-                <border>0</border>
-                <option>1</option>
-                <object class="wxNotebook" name="Notebook" base="EditNotebook">
-                    <style>0</style>
-                    <tabs>
-                        <tab window="VTKWindow">View</tab>
-                        <tab window="Grid">DICOM Tags</tab>
-                    </tabs>
-                    <object class="wxVTKRenderWindowInteractor" name="VTKWindow" base="CustomWidget">
-                        <arguments>
-                            <argument>$parent</argument>
-                            <argument>$id</argument>
-                        </arguments>
-                    </object>
-                    <object class="wxGrid" name="Grid" base="EditGrid">
-                        <rows_number>10</rows_number>
-                        <columns>
-                            <column size="-1">A</column>
-                            <column size="-1">B</column>
-                            <column size="-1">C</column>
-                        </columns>
-                        <selection_mode>wxGrid.wxGridSelectCells</selection_mode>
-                        <enable_grid_lines>1</enable_grid_lines>
-                        <enable_grid_resize>1</enable_grid_resize>
-                        <enable_editing>1</enable_editing>
-                        <create_grid>1</create_grid>
-                        <enable_row_resize>1</enable_row_resize>
-                        <enable_col_resize>1</enable_col_resize>
-                    </object>
-                </object>
-            </object>
-        </object>
-    </object>
-    <object class="MyDialog" name="AboutDialog" base="EditDialog">
-        <style>wxDEFAULT_DIALOG_STYLE</style>
-        <title>About Dialog</title>
-    </object>
-</application>
diff --git a/Wrapping/Python/docstrings.i b/Wrapping/Python/docstrings.i
index 0fe3e29..085cce3 100644
--- a/Wrapping/Python/docstrings.i
+++ b/Wrapping/Python/docstrings.i
@@ -6543,10 +6543,6 @@ In all other cases it will return an error
 
 C++ includes: gdcmMD5.h ";
 
-%feature("docstring")  gdcm::MD5::MD5 "gdcm::MD5::MD5() ";
-
-%feature("docstring")  gdcm::MD5::~MD5 "gdcm::MD5::~MD5() ";
-
 
 // File: classgdcm_1_1MediaStorage.xml
 %feature("docstring") gdcm::MediaStorage "
@@ -10424,6 +10420,13 @@ Print. ";
 %feature("docstring")  gdcm::Sorter::SetSortFunction "void
 gdcm::Sorter::SetSortFunction(SortFunction f) ";
 
+%feature("docstring")  gdcm::Sorter::SetTagsToRead "void
+gdcm::Sorter::SetTagsToRead(std::set< Tag > const &tags)
+
+Specify a set of tags to be read in during the sort procedure. By
+default this set is empty, in which case the entire image, including
+pixel data, is read in. ";
+
 %feature("docstring")  gdcm::Sorter::Sort "virtual bool
 gdcm::Sorter::Sort(std::vector< std::string > const &filenames)
 
@@ -10970,10 +10973,6 @@ attribute is not found (or an error in the XPATH query) You need to
 make sure that your XPATH query is syntatically correct ";
 
 %feature("docstring")  gdcm::StringFilter::FromString "std::string
-gdcm::StringFilter::FromString(const Tag &t, const char *value, VL
-const &vl) ";
-
-%feature("docstring")  gdcm::StringFilter::FromString "std::string
 gdcm::StringFilter::FromString(const Tag &t, const char *value, size_t
 len)
 
@@ -15385,6 +15384,9 @@ gdcm::terminal::setmode(Mode m) ";
 // File: DecompressPixmap_8java-example.xml
 
 
+// File: DeriveSeries_8cxx-example.xml
+
+
 // File: DiffFile_8cxx-example.xml
 
 
diff --git a/Wrapping/Python/gdcmswig.i b/Wrapping/Python/gdcmswig.i
index 7bf0027..d4f71ee 100644
--- a/Wrapping/Python/gdcmswig.i
+++ b/Wrapping/Python/gdcmswig.i
@@ -26,6 +26,7 @@
 // "There is no option to suppress all SWIG warning messages."
 #pragma SWIG nowarn=302,303,312,362,383,389,401,503,504,509,510,514,516
 %{
+#define SWIG_PYTHON_STRICT_BYTE_CHAR
 #include <cstddef> // ptrdiff_t
 #include "gdcmTypes.h"
 #include "gdcmASN1.h"
diff --git a/appveyor.yml b/appveyor.yml
index ceff370..81c986d 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -2,7 +2,7 @@
 # http://www.appveyor.com/docs/appveyor-yml
 
 # Set build version format here instead of in the admin panel.
-version: 2.6.4.{build}
+version: 2.8.0.{build}
 
 # http://www.appveyor.com/docs/build-cache#caching-chocolatey-packages
 # https://github.com/kvirc/KVIrc/blob/master/.appveyor.yml

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/gdcm.git



More information about the debian-med-commit mailing list