Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Modules/ThirdParty/GDCM/itk-module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ else()
ITKZLIB
ITKExpat
ITKOpenJPEG
ITKJPEG
DESCRIPTION "${DOCUMENTATION}"
)
endif()
6 changes: 6 additions & 0 deletions Modules/ThirdParty/GDCM/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ set(
"Use pvrg lib, only turn it on if you know what you are doing."
)
set(GDCM_USE_SYSTEM_LJPEG OFF CACHE INTERNAL "Use system ljpeg (ijg lib)")
# Use ITK's libjpeg-turbo as the JPEG backend instead of GDCM's IJG 6b
set(GDCM_USE_JPEGTURBO ON CACHE INTERNAL "Use libjpeg-turbo for JPEG codec")
if(GDCM_USE_JPEGTURBO)
set(GDCM_JPEGTURBO_INCLUDE_DIRS ${ITKJPEG_INCLUDE_DIRS})
set(GDCM_JPEGTURBO_LIBRARIES ${ITKJPEG_LIBRARIES})
endif()
set(GDCM_USE_SYSTEM_OPENSSL OFF CACHE INTERNAL "Use system OpenSSL")
set(GDCM_USE_SYSTEM_PODOFO OFF CACHE INTERNAL "Use system podofo (pdf)")
set(GDCM_USE_SYSTEM_POPPLER OFF CACHE INTERNAL "Use system poppler (pdf)")
Expand Down
4 changes: 3 additions & 1 deletion Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ if(GDCM_USE_SYSTEM_LIBXML2)
endif()
mark_as_advanced(GDCM_USE_SYSTEM_LIBXML2)

if(GDCM_USE_SYSTEM_LJPEG)
if(GDCM_USE_JPEGTURBO)
set(GDCM_LJPEG_LIBRARIES "")
elseif(GDCM_USE_SYSTEM_LJPEG)
find_package(LJPEG REQUIRED)
set(GDCM_LJPEG_LIBRARIES ${LJPEG_LIBRARIES})
else()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,10 @@ set(MSFF_SRCS
gdcmImage.cxx
gdcmImageConverter.cxx
gdcmImageCodec.cxx
gdcmJPEG12Codec.cxx
gdcmRLECodec.cxx
gdcmPDFCodec.cxx
gdcmAudioCodec.cxx
gdcmJPEG16Codec.cxx
gdcmJPEGLSCodec.cxx
gdcmJPEG8Codec.cxx
gdcmJPEGCodec.cxx
gdcmPVRGCodec.cxx
gdcmKAKADUCodec.cxx
Expand Down Expand Up @@ -102,6 +99,19 @@ set(MSFF_SRCS
gdcmJPEG2000Codec.cxx
)

# Old per-bitdepth IJG codecs needed when not using libjpeg-turbo
if(GDCM_USE_JPEGTURBO)
list(APPEND MSFF_SRCS
gdcmJPEGTurboCodec.cxx
)
else()
list(APPEND MSFF_SRCS
gdcmJPEG8Codec.cxx
gdcmJPEG12Codec.cxx
gdcmJPEG16Codec.cxx
)
endif()

list(APPEND MSFF_SRCS
${GDCM_SOURCE_DIR}/Utilities/gdcmrle/rle.cxx
${GDCM_SOURCE_DIR}/Utilities/gdcmrle/info.cxx
Expand Down Expand Up @@ -178,6 +188,10 @@ endif()
if(GDCM_USE_SYSTEM_LJPEG)
include_directories(${LJPEG_INCLUDE_DIRS} )
endif()
if(GDCM_USE_JPEGTURBO)
include_directories(${GDCM_JPEGTURBO_INCLUDE_DIRS})
add_definitions(-DGDCM_USE_JPEGTURBO)
endif()
if(NOT GDCM_USE_SYSTEM_ZLIB)
include_directories(
"${GDCM_BINARY_DIR}/Utilities/gdcmzlib"
Expand Down Expand Up @@ -211,6 +225,9 @@ endif()
# main libs:
target_link_libraries(gdcmMSFF LINK_PUBLIC gdcmIOD gdcmDSED gdcmDICT)
target_link_libraries(gdcmMSFF LINK_PRIVATE ${GDCM_LJPEG_LIBRARIES} ${GDCM_OPENJPEG_LIBRARIES})
if(GDCM_USE_JPEGTURBO)
target_link_libraries(gdcmMSFF LINK_PRIVATE ${GDCM_JPEGTURBO_LIBRARIES})
endif()
if(GDCM_USE_JPEGLS)
target_link_libraries(gdcmMSFF LINK_PRIVATE ${GDCM_CHARLS_LIBRARIES})
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
#include "gdcmDataElement.h"
#include "gdcmSequenceOfFragments.h"
#include "gdcmSwapper.h"
#ifdef GDCM_USE_JPEGTURBO
#include "gdcmJPEGTurboCodec.h"
#else
#include "gdcmJPEG8Codec.h"
#include "gdcmJPEG12Codec.h"
#include "gdcmJPEG16Codec.h"
#endif

#include <cstring>
#include <numeric>
Expand Down Expand Up @@ -101,6 +105,18 @@ void JPEGCodec::SetupJPEGBitCodec(int bit)
{
BitSample = bit;
delete Internal; Internal = nullptr;
#ifdef GDCM_USE_JPEGTURBO
// libjpeg-turbo handles 8/12/16-bit in a single codec
if ( bit >= 1 && bit <= 16 )
{
gdcmDebugMacro( "Using JPEGTurbo" );
Internal = new JPEGTurboCodec;
}
else
{
gdcmWarningMacro( "Cannot instantiate JPEG codec for bit sample: " << bit );
}
#else
// what should I do with those single bit images ?
if ( BitSample <= 8 )
{
Expand All @@ -122,6 +138,7 @@ void JPEGCodec::SetupJPEGBitCodec(int bit)
// gdcmNonImageData/RT/RTDOSE.dcm
gdcmWarningMacro( "Cannot instantiate JPEG codec for bit sample: " << bit );
}
#endif
}

void JPEGCodec::SetBitSample(int bit)
Expand Down
Loading
Loading