changeset 1362:104e0b0f2316 broker

Fixed the broken function, and left the unoptimized code with an #if for review.
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 Apr 2020 17:48:38 +0200
parents bd26e09903c0
children b497e1217aa5
files Framework/Loaders/OrthancMultiframeVolumeLoader.cpp
diffstat 1 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Loaders/OrthancMultiframeVolumeLoader.cpp	Wed Apr 15 15:46:27 2020 +0200
+++ b/Framework/Loaders/OrthancMultiframeVolumeLoader.cpp	Wed Apr 15 17:48:38 2020 +0200
@@ -312,25 +312,45 @@
 
         assert(writer.GetAccessor().GetWidth() == width &&
           writer.GetAccessor().GetHeight() == height);
+#if 0
+        for (unsigned int y = 0; y < height; y++)
+        {
+          assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat()));
 
-        T* targetAddr0 = reinterpret_cast<T*>(writer.GetAccessor().GetRow(0));
+          T* target = reinterpret_cast<T*>(writer.GetAccessor().GetRow(y));
+
+          for (unsigned int x = 0; x < width; x++)
+          {
+            CopyPixel(*target, source);
+
+            distribution[*target] += 1;
+
+            target++;
+            source += bpp;
+          }
+        }
+#else
+        // optimized version (fixed) as of 2020-04-15
         unsigned int pitch = writer.GetAccessor().GetPitch();
-        T* targetAddr = targetAddr0;
+        T* targetAddrLine = reinterpret_cast<T*>(writer.GetAccessor().GetRow(0));
         assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat()));
 
         for (unsigned int y = 0; y < height; y++)
         {
+          T* targetAddrPix = targetAddrLine;
           for (unsigned int x = 0; x < width; x++)
           {
-            CopyPixel(*targetAddr, source);
+            CopyPixel(*targetAddrPix, source);
 
-            distribution[*targetAddr] += 1;
+            distribution[*targetAddrPix] += 1;
 
-            targetAddr++;
+            targetAddrPix++;
             source += bpp;
           }
-          targetAddr += pitch;
+          uint8_t* targetAddrLineBytes = reinterpret_cast<uint8_t*>(targetAddrLine) + pitch;
+          targetAddrLine = reinterpret_cast<T*>(targetAddrLineBytes);
         }
+#endif
       }
     }
   }