Skip to content

Commit 422bf02

Browse files
authored
Merge pull request #6520 from blowekamp/update_gdcm
ENH: Update GDCM to v3.2.8
2 parents 968bce1 + 2e3744f commit 422bf02

18 files changed

Lines changed: 915 additions & 63 deletions

Modules/ThirdParty/GDCM/UpdateFromUpstream.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ readonly name="GDCM"
88
readonly ownership="GDCM Upstream <gdcm-developers@lists.sourceforge.net>"
99
readonly subtree="Modules/ThirdParty/GDCM/src/gdcm"
1010
readonly repo="https://github.com/malaterre/GDCM.git"
11-
readonly tag="244fdbeadecbb03b29ace5542aa1c694d36195bb"
11+
readonly tag="v3.2.8"
1212
readonly shortlog=false
1313
readonly exact_tree_match=false
1414
readonly paths="

Modules/ThirdParty/GDCM/src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ set(GDCM_BUILD_TESTING_DEFAULT OFF)
3434
set(GDCM_USE_SYSTEM_EXPAT ON CACHE INTERNAL "")
3535
set(EXPAT_INCLUDE_DIR ${ITKExpat_INCLUDE_DIRS})
3636
set(EXPAT_LIBRARY ${ITKExpat_LIBRARIES})
37+
set(EXPAT_LIBRARIES ${ITKExpat_LIBRARIES})
3738
# OpenJPEG:
3839
set(GDCM_USE_SYSTEM_OPENJPEG ON CACHE INTERNAL "")
3940
set(GDCM_USE_OPENJPEG_V2 ON CACHE INTERNAL "")
@@ -42,7 +43,9 @@ set(OPENJPEG_LIBRARIES "ITK::ITKOpenJPEGModule")
4243
# ZLIB:
4344
set(GDCM_USE_SYSTEM_ZLIB ON CACHE INTERNAL "")
4445
set(ZLIB_INCLUDE_DIR ${ITKZLIB_INCLUDE_DIRS})
46+
set(ZLIB_INCLUDE_DIRS ${ITKZLIB_INCLUDE_DIRS})
4547
set(ZLIB_LIBRARY ${ITKZLIB_LIBRARIES})
48+
set(ZLIB_LIBRARIES ${ITKZLIB_LIBRARIES})
4649

4750
# Configure GDCM privately so its options do not appear to the user.
4851
set(GDCM_LEGACY_REMOVE OFF CACHE INTERNAL "Remove all legacy code completely.")

Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endif()
1010
#----------------------------------------------------------------------------
1111

1212
project(GDCM
13-
VERSION 3.3.0
13+
VERSION 3.2.8
1414
LANGUAGES CXX C
1515
)
1616
## NOTE: the "DESCRIPTION" feature of project() was introduced in cmake 3.10.0
@@ -86,7 +86,10 @@ if(GDCM_VERSION_MINOR MATCHES "[02468]$")
8686
# So unless the user *specifically* requested a particular cmake_build_type
8787
# do the work internally and append the NDEBUG def flag (hopefully portable)
8888
if(NOT CMAKE_BUILD_TYPE)
89-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG")
89+
get_cmake_property(is_multi_config_generator GENERATOR_IS_MULTI_CONFIG)
90+
if (NOT is_multi_config_generator)
91+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG")
92+
endif()
9093
endif()
9194
# Since we are on a release branch, chance is that people don't care about testing
9295
# let's disable it for them
@@ -334,8 +337,7 @@ option(GDCM_USE_SYSTEM_JSON "Use system json" OFF)
334337
option(GDCM_USE_SYSTEM_PAPYRUS3 "Use system papyrus3" OFF)
335338
option(GDCM_USE_SYSTEM_SOCKETXX "Use system socket++" OFF)
336339
option(GDCM_USE_SYSTEM_LJPEG "Use system ljpeg (ijg lib)" OFF)
337-
option(GDCM_USE_SYSTEM_OPENJPEG "Use system openjpeg" OFF)
338-
option(GDCM_USE_SYSTEM_CHARLS "Use system charls" OFF)
340+
option(GDCM_USE_JPEGTURBO "Use libjpeg-turbo instead of IJG for JPEG codec" OFF)
339341
mark_as_advanced(
340342
GDCM_USE_SYSTEM_ZLIB
341343
GDCM_USE_SYSTEM_OPENSSL
@@ -347,6 +349,7 @@ mark_as_advanced(
347349
GDCM_USE_SYSTEM_LJPEG
348350
GDCM_USE_SYSTEM_OPENJPEG
349351
GDCM_USE_SYSTEM_CHARLS
352+
GDCM_USE_JPEGTURBO
350353
)
351354
option(GDCM_USE_SYSTEM_POPPLER "Use system poppler (pdf)" OFF)
352355
if(GDCM_USE_SYSTEM_POPPLER)
@@ -361,6 +364,40 @@ endif()
361364
mark_as_advanced(GDCM_USE_SYSTEM_LIBXML2)
362365

363366
if(GDCM_USE_JPEGTURBO)
367+
if(NOT GDCM_JPEGTURBO_LIBRARIES)
368+
# libjpeg-turbo >= 3.0 is required for lossless JPEG and 12/16-bit support
369+
set(_gdcm_jpegturbo_min_version "3.0")
370+
find_package(libjpeg-turbo ${_gdcm_jpegturbo_min_version} QUIET)
371+
if(libjpeg-turbo_FOUND)
372+
set(GDCM_JPEGTURBO_INCLUDE_DIRS ${libjpeg-turbo_INCLUDE_DIRS})
373+
set(GDCM_JPEGTURBO_LIBRARIES ${libjpeg-turbo_LIBRARIES})
374+
# Modern config uses imported targets for libraries
375+
if(NOT GDCM_JPEGTURBO_LIBRARIES AND TARGET libjpeg-turbo::jpeg)
376+
set(GDCM_JPEGTURBO_LIBRARIES libjpeg-turbo::jpeg)
377+
endif()
378+
else()
379+
# Fall back to CMake's FindJPEG which works with system libjpeg-turbo
380+
find_package(JPEG REQUIRED)
381+
include(CheckSymbolExists)
382+
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIRS})
383+
check_symbol_exists(LIBJPEG_TURBO_VERSION "jconfig.h" JPEG_IS_TURBO)
384+
if(NOT JPEG_IS_TURBO)
385+
message(FATAL_ERROR "GDCM_USE_JPEGTURBO requires libjpeg-turbo, but found plain libjpeg")
386+
endif()
387+
# Verify version >= 3.0 by checking for jpeg_enable_lossless (added in 3.0)
388+
include(CheckSymbolExists)
389+
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIRS})
390+
set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
391+
check_symbol_exists(jpeg12_read_scanlines "jpeglib.h" JPEG_HAS_12BIT_API)
392+
if(NOT JPEG_HAS_12BIT_API)
393+
message(FATAL_ERROR
394+
"GDCM_USE_JPEGTURBO requires libjpeg-turbo >= ${_gdcm_jpegturbo_min_version} "
395+
"(for lossless JPEG and 12/16-bit support), but the installed version is too old.")
396+
endif()
397+
set(GDCM_JPEGTURBO_INCLUDE_DIRS ${JPEG_INCLUDE_DIRS})
398+
set(GDCM_JPEGTURBO_LIBRARIES JPEG::JPEG)
399+
endif()
400+
endif()
364401
set(GDCM_LJPEG_LIBRARIES "")
365402
elseif(GDCM_USE_SYSTEM_LJPEG)
366403
find_package(LJPEG REQUIRED)
@@ -377,6 +414,9 @@ else()
377414
set(GDCM_CHARLS_LIBRARIES gdcmcharls)
378415
endif()
379416

417+
option(GDCM_USE_SYSTEM_OPENJPEG "Use system openjpeg" OFF)
418+
option(GDCM_USE_SYSTEM_CHARLS "Use system charls" OFF)
419+
380420
if(GDCM_USE_SYSTEM_OPENJPEG)
381421
#find_package(OpenJPEG REQUIRED)
382422
set(GDCM_OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARIES})
@@ -416,9 +456,10 @@ if(GDCM_USE_KAKADU)
416456
endif()
417457

418458
if(GDCM_USE_SYSTEM_ZLIB)
419-
# If user say so, then this is a requirement !
420-
find_package(ZLIB REQUIRED)
421-
include_directories(${ZLIB_INCLUDE_DIR})
459+
if (NOT ZLIB_LIBRARIES)
460+
find_package(ZLIB REQUIRED)
461+
endif()
462+
include_directories(${ZLIB_INCLUDE_DIRS})
422463
set(GDCM_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
423464
else()
424465
set(GDCM_ZLIB_LIBRARIES "gdcmzlib")
@@ -437,8 +478,9 @@ else()
437478
endif()
438479

439480
if(GDCM_USE_SYSTEM_EXPAT)
440-
# If user say so, then this is a requirement !
441-
find_package(EXPAT REQUIRED)
481+
if (NOT EXPAT_LIBRARIES)
482+
find_package(EXPAT REQUIRED)
483+
endif()
442484
set(GDCM_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
443485
else()
444486
set(GDCM_EXPAT_LIBRARIES "gdcmexpat")
@@ -816,9 +858,11 @@ include(CMake/InstallRequiredVTKLibraries.cmake)
816858
endif()
817859
endif()
818860

819-
# Make sure to run doxygen after everything else (in particular vtkgdcm):
820-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/doxygen)
821-
add_subdirectory(Utilities/doxygen)
861+
if(GDCM_DOCUMENTATION)
862+
# Make sure to run doxygen after everything else (in particular vtkgdcm):
863+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/doxygen)
864+
add_subdirectory(Utilities/doxygen)
865+
endif()
822866
endif()
823867

824868
#-----------------------------------------------------------------------------

Modules/ThirdParty/GDCM/src/gdcm/Source/DataDictionary/gdcmPrivateDefaultDicts.cxx

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,104 @@ using DICT_ENTRY = struct
3838
};
3939

4040
static const DICT_ENTRY DICOMV3DataDict [] = {
41+
// Major MRI vendors typically use identifiable creator names for a good reason...
42+
// BEGIN UIH
43+
// See https://github.com/rordenlab/dcm2niix/issues/225
44+
{0x0019,0x0018,"EPI Private Header",VR::IS,VM::VM1,"?",false },
45+
{0x0019,0x0028,"EPI Private Header",VR::FD,VM::VM1,"?",false },
46+
{0x0051,0x0011,"EPI Private Header",VR::LO,VM::VM1,"?",false },
47+
{0x0061,0x0002,"DB Dicom Private Creator",VR::US,VM::VM1,"Generate Private",false },
48+
{0x0061,0x0004,"EditStatus",VR::US,VM::VM1,"?",false },
49+
{0x0061,0x0001,"Common Private Header",VR::SH,VM::VM1,"?",false },
50+
{0x0061,0x0002,"Common Private Header",VR::SH,VM::VM1,"FOV",false },
51+
{0x0061,0x0003,"Common Private Header",VR::SH,VM::VM1,"?",false },
52+
{0x0061,0x0006,"PrivateCreator16",VR::ST,VM::VM1,"Radiopharmaceutical Information JSON",false },
53+
{0x0065,0x0000,"Image Private Header",VR::UL,VM::VM1,"MeasurmentUID",false },
54+
{0x0065,0x0002,"Image Private Header",VR::LO,VM::VM1,"ImageOrientationDisplayed",false },
55+
{0x0065,0x0003,"Image Private Header",VR::LO,VM::VM1,"ReceiveCoil",false },
56+
{0x0065,0x0004,"Image Private Header",VR::SH,VM::VM1,"Interpolation",false },
57+
{0x0065,0x0005,"Image Private Header",VR::SH,VM::VM1,"PE Direction Displayed",false },
58+
{0x0065,0x0006,"Image Private Header",VR::IS,VM::VM1,"Slice Group ID",false },
59+
{0x0065,0x0007,"Image Private Header",VR::OB,VM::VM1,"Uprotocol",false },
60+
{0x0065,0x0009,"Image Private Header",VR::FD,VM::VM1,"BActualValue",false },
61+
{0x0065,0x000a,"Image Private Header",VR::FD,VM::VM1,"BUserValue",false },
62+
{0x0065,0x000d,"Image Private Header",VR::SH,VM::VM1,"Parallel Information",false },
63+
{0x0065,0x000f,"Image Private Header",VR::SH,VM::VM1,"Slice Position",false },
64+
{0x0065,0x0011,"Image Private Header",VR::SH,VM::VM1,"Sections",false },
65+
{0x0065,0x0012,"Image Private Header",VR::LO,VM::VM1,"?",false },
66+
{0x0065,0x0013,"Image Private Header",VR::FD,VM::VM1,"InPlaneRotAngle",false },
67+
{0x0065,0x0014,"Image Private Header",VR::DS,VM::VM3,"SliceNormalVector",false },
68+
{0x0065,0x0015,"Image Private Header",VR::DS,VM::VM3,"SliceCenterPosition",false },
69+
{0x0065,0x0016,"Image Private Header",VR::UL,VM::VM1,"PixelRotateModel",false },
70+
{0x0065,0x0017,"Image Private Header",VR::LO,VM::VM1,"SAR Model",false },
71+
{0x0065,0x0018,"Image Private Header",VR::LO,VM::VM1,"dB/dt Model",false },
72+
{0x0065,0x0021,"Image Private Header",VR::SH,VM::VM1,"?",false },
73+
{0x0065,0x0023,"Image Private Header",VR::LO,VM::VM1,"TablePosition",false },
74+
{0x0065,0x0025,"Image Private Header",VR::DS,VM::VM1,"Slice Gap",false },
75+
{0x0065,0x0029,"Image Private Header",VR::SH,VM::VM1,"AcquisitionDuration",false },
76+
{0x0065,0x002b,"Image Private Header",VR::LT,VM::VM1,"ApplicationCategory",false },
77+
{0x0065,0x002c,"Image Private Header",VR::IS,VM::VM1,"RepeatitionIndex",false },
78+
{0x0065,0x002d,"Image Private Header",VR::ST,VM::VM1,"SequenceDisplayName",false },
79+
{0x0065,0x002e,"Image Private Header",VR::LO,VM::VM1,"NoiseDecovarFlag",false },
80+
{0x0065,0x002f,"Image Private Header",VR::FL,VM::VM1,"ScaleFactor",false },
81+
{0x0065,0x0030,"Image Private Header",VR::LO,VM::VM1,"?Customer?",false },
82+
{0x0065,0x0031,"Image Private Header",VR::SH,VM::VM1,"MRSequenceVariant",false },
83+
{0x0065,0x0032,"Image Private Header",VR::SH,VM::VM1,"MRKSpaceFilter",false },
84+
{0x0065,0x0033,"Image Private Header",VR::SH,VM::VM1,"MRTableMode",false },
85+
{0x0065,0x0036,"Image Private Header",VR::OB,VM::VM1,"MRDiscoParameter",false },
86+
{0x0065,0x0037,"Image Private Header",VR::FD,VM::VM3,"MRDiffusionGradOrientation",false },
87+
{0x0065,0x0038,"Image Private Header",VR::FD,VM::VM1,"MRPerfusionNoiseLevel",false },
88+
{0x0065,0x0039,"Image Private Header",VR::SH,VM::VM6,"MRGradRange",false },
89+
{0x0065,0x0040,"Image Private Header",VR::LO,VM::VM1,"?",false },
90+
{0x0065,0x0041,"Image Private Header",VR::LT,VM::VM1,"?NIN?",false },
91+
{0x0065,0x0048,"Image Private Header",VR::OB,VM::VM1,"?",false },
92+
{0x0065,0x0049,"Image Private Header",VR::DS,VM::VM3,"?",false },
93+
{0x0065,0x0050,"Image Private Header",VR::DS,VM::VM1,"MR Number Of Slice In Volume",false },
94+
{0x0065,0x0051,"Image Private Header",VR::SQ,VM::VM1,"MR VFrame Sequence",false },
95+
{0x0065,0x0052,"Image Private Header",VR::LO,VM::VM1_n,"?",false },
96+
{0x0065,0x0053,"Image Private Header",VR::DS,VM::VM3,"?",false },
97+
{0x0065,0x0055,"Image Private Header",VR::DS,VM::VM1,"?",false },
98+
{0x0065,0x0058,"Image Private Header",VR::IS,VM::VM1,"?",false },
99+
{0x0065,0x0059,"Image Private Header",VR::LO,VM::VM1,"?",false },
100+
{0x0065,0x0060,"Image Private Header",VR::LO,VM::VM1,"?",false },
101+
{0x0065,0x006a,"Image Private Header",VR::LO,VM::VM1,"?",false },
102+
{0x0065,0x006c,"Image Private Header",VR::OB,VM::VM1,"UIH serialized protocol",false },
103+
{0x0065,0x0071,"Image Private Header",VR::US,VM::VM1,"?",false },
104+
{0x0065,0x0073,"Image Private Header",VR::OB,VM::VM1,"?",false },
105+
{0x0065,0x0076,"Image Private Header",VR::SH,VM::VM1,"?",false },
106+
{0x0065,0x0077,"Image Private Header",VR::LO,VM::VM1,"?",false },
107+
{0x0065,0x0078,"Image Private Header",VR::LO,VM::VM1,"?",false },
108+
{0x0067,0x0004,"PrivateCreator10",VR::FD,VM::VM1,"?",false },
109+
{0x0067,0x0005,"PrivateCreator10",VR::FD,VM::VM2,"?",false },
110+
{0x0067,0x0007,"PrivateCreator10",VR::CS,VM::VM3,"?",false },
111+
{0x0067,0x0008,"PrivateCreator10",VR::LO,VM::VM1,"?",false },
112+
{0x0067,0x0009,"PrivateCreator10",VR::IS,VM::VM1,"?",false },
113+
{0x0067,0x000a,"PrivateCreator10",VR::IS,VM::VM1,"?",false },
114+
{0x0067,0x000b,"PrivateCreator10",VR::IS,VM::VM1,"?",false },
115+
{0x0067,0x000d,"PrivateCreator10",VR::SH,VM::VM1,"?",false },
116+
{0x0067,0x0010,"PrivateCreator10",VR::DT,VM::VM1,"?",false },
117+
{0x0067,0x0012,"PrivateCreator10",VR::DT,VM::VM1,"?",false },
118+
{0x0067,0x0014,"PrivateCreator10",VR::CS,VM::VM1,"?",false },
119+
{0x0067,0x0015,"PrivateCreator10",VR::CS,VM::VM1,"?",false },
120+
{0x0067,0x0017,"PrivateCreator10",VR::CS,VM::VM1,"?",false },
121+
{0x0067,0x0019,"PrivateCreator10",VR::CS,VM::VM1,"?",false },
122+
{0x0067,0x001a,"PrivateCreator10",VR::CS,VM::VM1,"?",false },
123+
{0x0067,0x001b,"PrivateCreator10",VR::CS,VM::VM1,"?",false },
124+
{0x0067,0x001c,"PrivateCreator10",VR::CS,VM::VM1,"?",false },
125+
{0x0067,0x001d,"PrivateCreator10",VR::IS,VM::VM1,"?",false },
126+
{0x0067,0x0020,"PrivateCreator10",VR::UT,VM::VM1,"?",false },
127+
{0x0067,0x0021,"PrivateCreator10",VR::SQ,VM::VM1,"?",false },
128+
{0x0067,0x002c,"PrivateCreator10",VR::ST,VM::VM1,"?",false },
129+
{0x0067,0x002f,"PrivateCreator10",VR::DS,VM::VM1,"?",false },
130+
{0x0067,0x0031,"PrivateCreator10",VR::UT,VM::VM1,"?",false },
131+
{0x0067,0x0001,"PrivateCreator11",VR::TM,VM::VM1,"?",false },
132+
{0x0067,0x0002,"PrivateCreator11",VR::DA,VM::VM1,"?",false },
133+
{0x0067,0x0003,"PrivateCreator11",VR::DS,VM::VM1,"?",false },
134+
{0x0067,0x0004,"PrivateCreator11",VR::TM,VM::VM1,"?",false },
135+
{0x0067,0x0005,"PrivateCreator11",VR::DA,VM::VM1,"?",false },
136+
{0x0067,0x0006,"PrivateCreator11",VR::DS,VM::VM1,"?",false },
137+
{0x0067,0x0007,"PrivateCreator11",VR::LO,VM::VM1,"?",false },
138+
// END UIH
41139
{0x0033,0x0001,"KONICA MINOLTA QA 1.4",VR::SQ,VM::VM1,"?Possibly PHI?",false },
42140
{0x0033,0x0004,"KONICA MINOLTA QA 1.4",VR::SS,VM::VM1,"?",false },
43141
{0x0033,0x0006,"KONICA MINOLTA QA 1.4",VR::SS,VM::VM1,"?",false },
@@ -1294,7 +1392,7 @@ static const DICT_ENTRY DICOMV3DataDict [] = {
12941392
{0x0021,0x008e,"SIEMENS MR SDI 02",VR::ST,VM::VM1,"?",false},
12951393
{0x0021,0x00fe,"SIEMENS MR SDI 02",VR::SQ,VM::VM1,"??",false},
12961394
{0x0021,0x00fe,"SIEMENS MR SDS 01",VR::SQ,VM::VM1,"Series Data Sequence",false},
1297-
{0x0089,0x0054,"SYNGO_IMAGING",VR::OW,VM::VM1,"??",false},
1395+
{0x0089,0x0054,"SYNGO_IMAGING",VR::OB,VM::VM1,"??",false},
12981396
{0x0095,0x00fa,"SIENET",VR::PN,VM::VM1,"?Some kind of Patient Name?",false},
12991397
{0x8ff1,0x0010,"SSI Image enhancement Group",VR::LO,VM::VM1,"SSI Image enhancement Group Version",false },
13001398
{0x8ff1,0x0020,"SSI Image enhancement Group",VR::IS,VM::VM256,"RGB LUT",false },

Modules/ThirdParty/GDCM/src/gdcm/Source/InformationObjectDefinition/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ include_directories(
3737
"${GDCM_SOURCE_DIR}/Source/DataStructureAndEncodingDefinition"
3838
"${GDCM_SOURCE_DIR}/Source/DataDictionary"
3939
"${GDCM_SOURCE_DIR}/Utilities"
40-
"${GDCM_BINARY_DIR}/Utilities/gdcmexpat" # expat_mangle.h
4140
)
42-
if(GDCM_USE_SYSTEM_EXPAT)
41+
if(NOT GDCM_USE_SYSTEM_EXPAT) # only needed _without_ find_package
4342
include_directories(
44-
${EXPAT_INCLUDE_DIRS}
43+
"${GDCM_BINARY_DIR}/Utilities/gdcmexpat" # expat_mangle.h
4544
)
4645
endif()
4746

Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set(MSFF_SRCS
4242
gdcmDICOMDIR.cxx
4343
gdcmSpectroscopy.cxx
4444
gdcmEncapsulatedDocument.cxx
45+
gdcmSplitGridFilter.cxx
4546
gdcmSplitMosaicFilter.cxx
4647
gdcmFiducials.cxx
4748
gdcmWaveform.cxx
@@ -99,7 +100,7 @@ set(MSFF_SRCS
99100
gdcmJPEG2000Codec.cxx
100101
)
101102

102-
# Old per-bitdepth IJG codecs needed when not using libjpeg-turbo
103+
# Per-bitdepth IJG codecs or single libjpeg-turbo codec
103104
if(GDCM_USE_JPEGTURBO)
104105
list(APPEND MSFF_SRCS
105106
gdcmJPEGTurboCodec.cxx

Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmBitmap.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -888,13 +888,13 @@ bool Bitmap::TryJPEG2000Codec(char *buffer, bool &lossyflag) const
888888
DataElement out;
889889
bool r = codec.Decode(PixelData, out);
890890
if(!r) return false;
891-
gdcm_assert( r );
892891
const ByteValue *outbv = out.GetByteValue();
893-
gdcm_assert( outbv );
894-
unsigned long check = outbv->GetLength(); // FIXME
895-
(void)check;
896-
gdcm_assert( len <= outbv->GetLength() );
897-
memcpy(buffer, outbv->GetPointer(), len /*outbv->GetLength()*/ ); // FIXME
892+
// A missing or short decoded buffer is a runtime condition (e.g. an
893+
// allocation failed while decoding), not a logic invariant: fail gracefully
894+
// rather than throwing out of GetBuffer, which is uncatchable across the
895+
// SWIG language bindings and aborts the host process.
896+
if( !outbv || outbv->GetLength() < len ) return false;
897+
memcpy(buffer, outbv->GetPointer(), len);
898898

899899
lossyflag = codec.IsLossy();
900900
if( codec.IsLossy() && !ts.IsLossy() )

Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmDirectionCosines.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ static inline double NormImpl(const double x[3])
103103
return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]);
104104
}
105105

106+
double DirectionCosines::Distance(const double x[3], const double y[3])
107+
{
108+
const double dx = x[0] - y[0];
109+
const double dy = x[1] - y[1];
110+
const double dz = x[2] - y[2];
111+
return std::sqrt(dx * dx + dy * dy + dz * dz);
112+
}
113+
106114
double DirectionCosines::Norm(const double v[3])
107115
{
108116
return NormImpl(v);

Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmDirectionCosines.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class GDCM_EXPORT DirectionCosines
4343
/// Compute Dot
4444
static double Dot(const double x[3], const double y[3]);
4545

46+
/// Compute Distance
47+
static double Distance(const double x[3], const double y[3]);
48+
4649
/// Normalize in-place
4750
void Normalize();
4851

0 commit comments

Comments
 (0)