changeset 3905:061f3d031b5d transcoding

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 08 May 2020 08:27:18 +0200
parents c62f84c7eda9
children f0dd5ded8927
files Core/DicomParsing/MemoryBufferTranscoder.cpp
diffstat 1 files changed, 24 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/MemoryBufferTranscoder.cpp	Thu May 07 17:21:20 2020 +0200
+++ b/Core/DicomParsing/MemoryBufferTranscoder.cpp	Fri May 08 08:27:18 2020 +0200
@@ -73,13 +73,16 @@
 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1
     if (useDcmtk_)
     {
-      return dcmtk_.TranscodeToBuffer(target, hasSopInstanceUidChanged, buffer, size, allowedSyntaxes, allowNewSopInstanceUid);
+      if (dcmtk_.TranscodeToBuffer(target, hasSopInstanceUidChanged, buffer,
+                                   size, allowedSyntaxes, allowNewSopInstanceUid))
+      {
+        return true;
+      }
     }
-    else
 #endif
-    {
-      return Transcode(target, hasSopInstanceUidChanged, buffer, size, allowedSyntaxes, allowNewSopInstanceUid);
-    }
+
+    return Transcode(target, hasSopInstanceUidChanged, buffer, size,
+                     allowedSyntaxes, allowNewSopInstanceUid);
   }
 
   
@@ -92,21 +95,25 @@
 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1
     if (useDcmtk_)
     {
-      return dcmtk_.TranscodeToParsed(hasSopInstanceUidChanged, buffer, size, allowedSyntaxes, allowNewSopInstanceUid);
+      std::unique_ptr<DcmFileFormat> transcoded(
+        dcmtk_.TranscodeToParsed(hasSopInstanceUidChanged, buffer, size,
+                                 allowedSyntaxes, allowNewSopInstanceUid));
+      if (transcoded.get() != NULL)
+      {
+        return transcoded.release();
+      }
+    }
+#endif
+
+    std::string transcoded;
+    if (Transcode(transcoded, hasSopInstanceUidChanged, buffer, size, allowedSyntaxes, allowNewSopInstanceUid))
+    {
+      return FromDcmtkBridge::LoadFromMemoryBuffer(
+        transcoded.empty() ? NULL : transcoded.c_str(), transcoded.size());
     }
     else
-#endif
     {
-      std::string transcoded;
-      if (Transcode(transcoded, hasSopInstanceUidChanged, buffer, size, allowedSyntaxes, allowNewSopInstanceUid))
-      {
-        return FromDcmtkBridge::LoadFromMemoryBuffer(
-          transcoded.empty() ? NULL : transcoded.c_str(), transcoded.size());
-      }
-      else
-      {
-        return NULL;
-      }
+      return NULL;
     }
   }