# HG changeset patch # User Benjamin Golinvaux # Date 1586965718 -7200 # Node ID 104e0b0f231657616202d6d2b9f1f3961c92b9b3 # Parent bd26e09903c0f2bd2282ca3e630ec507b18d339b Fixed the broken function, and left the unoptimized code with an #if for review. diff -r bd26e09903c0 -r 104e0b0f2316 Framework/Loaders/OrthancMultiframeVolumeLoader.cpp --- 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(writer.GetAccessor().GetRow(0)); + T* target = reinterpret_cast(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(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(targetAddrLine) + pitch; + targetAddrLine = reinterpret_cast(targetAddrLineBytes); } +#endif } } }