changeset 3871:5797d184de67 transcoding

fix the name of some transfer syntaxes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 29 Apr 2020 14:38:20 +0200
parents 09798f2b985f
children b40dfa6dc8da
files Core/Enumerations.h Resources/DicomTransferSyntaxes.json UnitTestsSources/FromDcmtkTests.cpp
diffstat 3 files changed, 71 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Enumerations.h	Wed Apr 29 12:26:51 2020 +0200
+++ b/Core/Enumerations.h	Wed Apr 29 14:38:20 2020 +0200
@@ -279,13 +279,13 @@
     DicomTransferSyntax_JPEG2000Multicomponent    /*!< JPEG 2000 part 2 multicomponent extensions (lossless or lossy) */,
     DicomTransferSyntax_JPIPReferenced    /*!< JPIP Referenced */,
     DicomTransferSyntax_JPIPReferencedDeflate    /*!< JPIP Referenced Deflate */,
-    DicomTransferSyntax_MPEG2MainProfileAtMainLevel    /*!< MPEG2 Main Profile at Main Level */,
-    DicomTransferSyntax_MPEG2MainProfileAtHighLevel    /*!< MPEG2 Main Profile at High Level */,
-    DicomTransferSyntax_MPEG4HighProfileLevel4_1    /*!< MPEG4 High Profile / Level 4.1 */,
-    DicomTransferSyntax_MPEG4BDcompatibleHighProfileLevel4_1    /*!< MPEG4 BD-compatible High Profile / Level 4.1 */,
-    DicomTransferSyntax_MPEG4HighProfileLevel4_2_For2DVideo    /*!< MPEG4 High Profile / Level 4.2 For 2D Video */,
-    DicomTransferSyntax_MPEG4HighProfileLevel4_2_For3DVideo    /*!< MPEG4 High Profile / Level 4.2 For 3D Video */,
-    DicomTransferSyntax_MPEG4StereoHighProfileLevel4_2    /*!< 1.2.840.10008.1.2.4.106 */,
+    DicomTransferSyntax_MPEG2MainProfileAtMainLevel    /*!< MPEG2 Main Profile / Main Level */,
+    DicomTransferSyntax_MPEG2MainProfileAtHighLevel    /*!< MPEG2 Main Profile / High Level */,
+    DicomTransferSyntax_MPEG4HighProfileLevel4_1    /*!< MPEG4 AVC/H.264 High Profile / Level 4.1 */,
+    DicomTransferSyntax_MPEG4BDcompatibleHighProfileLevel4_1    /*!< MPEG4 AVC/H.264 BD-compatible High Profile / Level 4.1 */,
+    DicomTransferSyntax_MPEG4HighProfileLevel4_2_For2DVideo    /*!< MPEG4 AVC/H.264 High Profile / Level 4.2 For 2D Video */,
+    DicomTransferSyntax_MPEG4HighProfileLevel4_2_For3DVideo    /*!< MPEG4 AVC/H.264 High Profile / Level 4.2 For 3D Video */,
+    DicomTransferSyntax_MPEG4StereoHighProfileLevel4_2    /*!< MPEG4 AVC/H.264 Stereo High Profile / Level 4.2 */,
     DicomTransferSyntax_HEVCMainProfileLevel5_1    /*!< HEVC/H.265 Main Profile / Level 5.1 */,
     DicomTransferSyntax_HEVCMain10ProfileLevel5_1    /*!< HEVC/H.265 Main 10 Profile / Level 5.1 */,
     DicomTransferSyntax_RLELossless    /*!< RLE - Run Length Encoding (lossless) */,
--- a/Resources/DicomTransferSyntaxes.json	Wed Apr 29 12:26:51 2020 +0200
+++ b/Resources/DicomTransferSyntaxes.json	Wed Apr 29 14:38:20 2020 +0200
@@ -274,7 +274,7 @@
 
   {
     "UID" : "1.2.840.10008.1.2.4.100",
-    "Name" : "MPEG2 Main Profile at Main Level",
+    "Name" : "MPEG2 Main Profile / Main Level",
     "Value" : "MPEG2MainProfileAtMainLevel",
     "Retired" : false,
     "DCMTK" : "EXS_MPEG2MainProfileAtMainLevel"
@@ -282,7 +282,7 @@
 
   {
     "UID" : "1.2.840.10008.1.2.4.101",
-    "Name" : "MPEG2 Main Profile at High Level",
+    "Name" : "MPEG2 Main Profile / High Level",
     "Value" : "MPEG2MainProfileAtHighLevel",
     "Retired" : false,
     "DCMTK" : "EXS_MPEG2MainProfileAtHighLevel"
@@ -290,7 +290,7 @@
 
   {
     "UID" : "1.2.840.10008.1.2.4.102",
-    "Name" : "MPEG4 High Profile / Level 4.1",
+    "Name" : "MPEG4 AVC/H.264 High Profile / Level 4.1",
     "Value" : "MPEG4HighProfileLevel4_1",
     "Retired" : false,
     "DCMTK" : "EXS_MPEG4HighProfileLevel4_1",
@@ -299,7 +299,7 @@
 
   {
     "UID" : "1.2.840.10008.1.2.4.103",
-    "Name" : "MPEG4 BD-compatible High Profile / Level 4.1",
+    "Name" : "MPEG4 AVC/H.264 BD-compatible High Profile / Level 4.1",
     "Value" : "MPEG4BDcompatibleHighProfileLevel4_1",
     "Retired" : false,
     "DCMTK" : "EXS_MPEG4BDcompatibleHighProfileLevel4_1",
@@ -308,7 +308,7 @@
 
   {
     "UID" : "1.2.840.10008.1.2.4.104",
-    "Name" : "MPEG4 High Profile / Level 4.2 For 2D Video",
+    "Name" : "MPEG4 AVC/H.264 High Profile / Level 4.2 For 2D Video",
     "Value" : "MPEG4HighProfileLevel4_2_For2DVideo",
     "Retired" : false,
     "DCMTK" : "EXS_MPEG4HighProfileLevel4_2_For2DVideo",
@@ -317,7 +317,7 @@
 
   {
     "UID" : "1.2.840.10008.1.2.4.105",
-    "Name" : "MPEG4 High Profile / Level 4.2 For 3D Video",
+    "Name" : "MPEG4 AVC/H.264 High Profile / Level 4.2 For 3D Video",
     "Value" : "MPEG4HighProfileLevel4_2_For3DVideo",
     "Retired" : false,
     "DCMTK" : "EXS_MPEG4HighProfileLevel4_2_For3DVideo",
@@ -326,7 +326,7 @@
 
   {
     "UID" : "1.2.840.10008.1.2.4.106",
-    "Name" : "1.2.840.10008.1.2.4.106",
+    "Name" : "MPEG4 AVC/H.264 Stereo High Profile / Level 4.2",
     "Value" : "MPEG4StereoHighProfileLevel4_2",
     "Retired" : false,
     "DCMTK" : "EXS_MPEG4StereoHighProfileLevel4_2",
--- a/UnitTestsSources/FromDcmtkTests.cpp	Wed Apr 29 12:26:51 2020 +0200
+++ b/UnitTestsSources/FromDcmtkTests.cpp	Wed Apr 29 14:38:20 2020 +0200
@@ -1933,6 +1933,16 @@
 #include <dcmtk/dcmjpeg/djrplol.h>    // for DJ_RPLossless
 
 
+#if !defined(ORTHANC_ENABLE_DCMTK_JPEG)
+#  error Macro ORTHANC_ENABLE_DCMTK_JPEG must be defined
+#endif
+
+#if !defined(ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS)
+#  error Macro ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS must be defined
+#endif
+
+
+
 namespace Orthanc
 {
   class IDicomTranscoder : public boost::noncopyable
@@ -1960,7 +1970,7 @@
     // NB: Transcoding can change the value of "GetSopInstanceUid()"
     // and "GetTransferSyntax()" if lossy compression is applied
     virtual bool Transcode(std::string& target,
-                           std::set<DicomTransferSyntax> syntaxes,
+                           DicomTransferSyntax syntax,
                            bool allowNewSopInstanceUid) = 0;
 
     virtual void WriteToMemoryBuffer(std::string& target) = 0;
@@ -2122,13 +2132,13 @@
     }
 
     virtual bool Transcode(std::string& target,
-                           std::set<DicomTransferSyntax> syntaxes,
+                           DicomTransferSyntax syntax,
                            bool allowNewSopInstanceUid) ORTHANC_OVERRIDE
     {
       assert(dicom_ != NULL &&
              dicom_->getDataset() != NULL);
       
-      if (syntaxes.find(GetTransferSyntax()) != syntaxes.end())
+      if (syntax == GetTransferSyntax())
       {
         printf("NO TRANSCODING\n");
         
@@ -2139,48 +2149,66 @@
       
       printf(">> %d\n", bitsStored_);
 
-      DJ_RPLossy rpLossy(lossyQuality_);
-
-      if (syntaxes.find(DicomTransferSyntax_LittleEndianImplicit) != syntaxes.end() &&
+      if (syntax == DicomTransferSyntax_LittleEndianImplicit &&
           FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_LittleEndianImplicit, NULL))
       {
         transferSyntax_ = DicomTransferSyntax_LittleEndianImplicit;
         return true;
       }
-      else if (syntaxes.find(DicomTransferSyntax_LittleEndianExplicit) != syntaxes.end() &&
-               FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_LittleEndianExplicit, NULL))
+
+      if (syntax == DicomTransferSyntax_LittleEndianExplicit &&
+          FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_LittleEndianExplicit, NULL))
       {
         transferSyntax_ = DicomTransferSyntax_LittleEndianExplicit;
         return true;
       }
-      else if (syntaxes.find(DicomTransferSyntax_BigEndianExplicit) != syntaxes.end() &&
-               FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_BigEndianExplicit, NULL))
+      
+      if (syntax == DicomTransferSyntax_BigEndianExplicit &&
+          FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_BigEndianExplicit, NULL))
       {
         transferSyntax_ = DicomTransferSyntax_BigEndianExplicit;
         return true;
       }
-      else if (syntaxes.find(DicomTransferSyntax_JPEGProcess1) != syntaxes.end() &&
-               allowNewSopInstanceUid &&
-               GetBitsStored() == 8 &&
-               FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_JPEGProcess1, &rpLossy))
+
+      if (syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit &&
+          FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_DeflatedLittleEndianExplicit, NULL))
       {
-        transferSyntax_ = DicomTransferSyntax_JPEGProcess1;
-        sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
+        transferSyntax_ = DicomTransferSyntax_DeflatedLittleEndianExplicit;
         return true;
       }
-      else if (syntaxes.find(DicomTransferSyntax_JPEGProcess2_4) != syntaxes.end() &&
-               allowNewSopInstanceUid &&
-               GetBitsStored() <= 12 &&
-               FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_JPEGProcess2_4, &rpLossy))
+
+#if ORTHANC_ENABLE_JPEG == 1
+      if (syntax == DicomTransferSyntax_JPEGProcess1 &&
+          allowNewSopInstanceUid &&
+          GetBitsStored() == 8)
       {
-        transferSyntax_ = DicomTransferSyntax_JPEGProcess2_4;
-        sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
-        return true;
+        DJ_RPLossy rpLossy(lossyQuality_);
+        
+        if (FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_JPEGProcess1, &rpLossy))
+        {
+          transferSyntax_ = DicomTransferSyntax_JPEGProcess1;
+          sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
+          return true;
+        }
       }
-      else
+#endif
+      
+#if ORTHANC_ENABLE_JPEG == 1
+      if (syntax == DicomTransferSyntax_JPEGProcess2_4 &&
+          allowNewSopInstanceUid &&
+          GetBitsStored() <= 12)
       {
-        return false;
+        DJ_RPLossy rpLossy(lossyQuality_);
+        if (FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_JPEGProcess2_4, &rpLossy))
+        {
+          transferSyntax_ = DicomTransferSyntax_JPEGProcess2_4;
+          sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
+          return true;
+        }
       }
+#endif
+
+      return false;
     }
   };
 }
@@ -2314,12 +2342,11 @@
     std::string a = transcoder.GetSopInstanceUid();
     DicomTransferSyntax b = transcoder.GetTransferSyntax();
     
-    std::set<DicomTransferSyntax> syntaxes;
-    syntaxes.insert(DicomTransferSyntax_JPEGProcess2_4);
-    //syntaxes.insert(DicomTransferSyntax_LittleEndianExplicit);
+    DicomTransferSyntax syntax = DicomTransferSyntax_JPEGProcess2_4;
+    //DicomTransferSyntax syntax = DicomTransferSyntax_LittleEndianExplicit;
 
     std::string t;
-    bool ok = transcoder.Transcode(t, syntaxes, true);
+    bool ok = transcoder.Transcode(t, syntax, true);
     printf("Transcoding: %d\n", ok);
 
     if (ok)
@@ -2343,7 +2370,7 @@
   printf("\n");
 }
 
-TEST(Toto, DISABLED_Transcode)
+TEST(Toto, Transcode)
 {
   //OFLog::configure(OFLogger::DEBUG_LOG_LEVEL);