changeset 4334:b2366bc023f8

Fix access to videos as a single raw frame
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Nov 2020 16:33:40 +0100
parents a85e74235a78
children 82652c5fc04f
files NEWS OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h OrthancFramework/Sources/DicomParsing/Internals/DicomFrameIndex.cpp
diffstat 4 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Nov 27 06:57:23 2020 +0100
+++ b/NEWS	Mon Nov 30 16:33:40 2020 +0100
@@ -18,6 +18,7 @@
 * C-GET SCP: Fix responses and handling of cancel
 * Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
 * Fix keep-alive in the embedded HTTP server by setting the "Keep-Alive" HTTP header
+* Fix access to videos as a single raw frame (feature broken since Orthanc 1.6.0)
 * REST API now returns 404 error if deleting an inexistent peer or modality
 * Upgraded dependencies for static builds (notably on Windows and LSB):
   - civetweb 1.13
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Fri Nov 27 06:57:23 2020 +0100
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon Nov 30 16:33:40 2020 +0100
@@ -2618,9 +2618,16 @@
     {
       throw OrthancException(ErrorCode_InternalError);
     }
-        
-    DcmDataset& dataset = *dicom.getDataset();
-
+    else
+    {
+      return LookupOrthancTransferSyntax(target, *dicom.getDataset());
+    }
+  }
+
+
+  bool FromDcmtkBridge::LookupOrthancTransferSyntax(DicomTransferSyntax& target,
+                                                    DcmDataset& dataset)
+  {
     E_TransferSyntax xfer = dataset.getCurrentXfer();
     if (xfer == EXS_Unknown)
     {
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h	Fri Nov 27 06:57:23 2020 +0100
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h	Mon Nov 30 16:33:40 2020 +0100
@@ -219,5 +219,8 @@
 
     static bool LookupOrthancTransferSyntax(DicomTransferSyntax& target,
                                             DcmFileFormat& dicom);
+
+    static bool LookupOrthancTransferSyntax(DicomTransferSyntax& target,
+                                            DcmDataset& dicom);
   };
 }
--- a/OrthancFramework/Sources/DicomParsing/Internals/DicomFrameIndex.cpp	Fri Nov 27 06:57:23 2020 +0100
+++ b/OrthancFramework/Sources/DicomParsing/Internals/DicomFrameIndex.cpp	Mon Nov 30 16:33:40 2020 +0100
@@ -311,6 +311,28 @@
 
   unsigned int DicomFrameIndex::GetFramesCount(DcmDataset& dicom)
   {
+    DicomTransferSyntax transferSyntax;
+    if (FromDcmtkBridge::LookupOrthancTransferSyntax(transferSyntax, dicom) &&
+        (transferSyntax == DicomTransferSyntax_MPEG2MainProfileAtMainLevel ||
+         transferSyntax == DicomTransferSyntax_MPEG2MainProfileAtHighLevel ||
+         transferSyntax == DicomTransferSyntax_MPEG4HighProfileLevel4_1 ||
+         transferSyntax == DicomTransferSyntax_MPEG4BDcompatibleHighProfileLevel4_1 ||
+         transferSyntax == DicomTransferSyntax_MPEG4HighProfileLevel4_2_For2DVideo ||
+         transferSyntax == DicomTransferSyntax_MPEG4HighProfileLevel4_2_For3DVideo ||
+         transferSyntax == DicomTransferSyntax_MPEG4StereoHighProfileLevel4_2 ||
+         transferSyntax == DicomTransferSyntax_HEVCMainProfileLevel5_1 ||
+         transferSyntax == DicomTransferSyntax_HEVCMain10ProfileLevel5_1))
+    {
+      /**
+       * Fixes an issue that was present from Orthanc 1.6.0 until
+       * 1.8.0 for the special case of the videos: In a video, the
+       * number of frames doesn't correspond to the number of
+       * fragments. We consider that there is one single frame (the
+       * video itself).
+       **/
+      return 1;
+    }            
+
     const char* tmp = NULL;
     if (!dicom.findAndGetString(DCM_NumberOfFrames, tmp).good() ||
         tmp == NULL)