Skip to content
Snippets Groups Projects
Commit ea64ed2e authored by Julien Malik's avatar Julien Malik
Browse files

BUG: change variable type from std::stremoff to unint64_t

parent 9ada2383
Branches
Tags
No related merge requests found
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "itkLinearInterpolateImageFunction.h" #include "itkLinearInterpolateImageFunction.h"
#include "itkNearestNeighborInterpolateImageFunction.h" #include "itkNearestNeighborInterpolateImageFunction.h"
#include "stdint.h"
namespace otb namespace otb
{ {
...@@ -55,10 +57,10 @@ unsigned long StreamingTraitsBase<TImage> ...@@ -55,10 +57,10 @@ unsigned long StreamingTraitsBase<TImage>
{ {
const unsigned long bufferMemorySizeOctet = bufferMemorySize / 8; const unsigned long bufferMemorySizeOctet = bufferMemorySize / 8;
unsigned long numberColumnsOfRegion = region.GetSize()[0]; // X dimension unsigned long numberColumnsOfRegion = region.GetSize()[0]; // X dimension
const unsigned long sizeLine = numberColumnsOfRegion * \ const uint64_t sizeLine = static_cast<uint64_t>(numberColumnsOfRegion * \
image->GetNumberOfComponentsPerPixel() * \ image->GetNumberOfComponentsPerPixel() * \
sizeof(PixelType); sizeof(PixelType));
unsigned long regionSize = region.GetSize()[1] * sizeLine; uint64_t regionSize = static_cast<uint64_t>(region.GetSize()[1]) * sizeLine;
otbMsgDevMacro(<< "image->GetNumberOfComponentsPerPixel() = " << image->GetNumberOfComponentsPerPixel()); otbMsgDevMacro(<< "image->GetNumberOfComponentsPerPixel() = " << image->GetNumberOfComponentsPerPixel());
otbMsgDevMacro(<< "sizeof(PixelType) = " << sizeof(PixelType)); otbMsgDevMacro(<< "sizeof(PixelType) = " << sizeof(PixelType));
otbMsgDevMacro(<< "numberColumnsOfRegion = " << numberColumnsOfRegion); otbMsgDevMacro(<< "numberColumnsOfRegion = " << numberColumnsOfRegion);
...@@ -68,7 +70,7 @@ unsigned long StreamingTraitsBase<TImage> ...@@ -68,7 +70,7 @@ unsigned long StreamingTraitsBase<TImage>
otbMsgDevMacro(<< "bufferMemorySizeOctet = " << bufferMemorySizeOctet); otbMsgDevMacro(<< "bufferMemorySizeOctet = " << bufferMemorySizeOctet);
//Active streaming //Active streaming
if (regionSize > bufferMemorySizeOctet) if (regionSize > static_cast<uint64_t>(bufferMemorySizeOctet))
{ {
//The regionSize must be at list equal to the sizeLine //The regionSize must be at list equal to the sizeLine
if (regionSize < sizeLine) if (regionSize < sizeLine)
...@@ -115,13 +117,13 @@ unsigned long StreamingTraitsBase<TImage> ...@@ -115,13 +117,13 @@ unsigned long StreamingTraitsBase<TImage>
{ {
typedef otb::ConfigurationFile ConfigurationType; typedef otb::ConfigurationFile ConfigurationType;
ConfigurationType::Pointer conf = ConfigurationType::GetInstance(); ConfigurationType::Pointer conf = ConfigurationType::GetInstance();
std::streamoff streamMaxSizeBufferForStreamingInBytes; uint64_t streamMaxSizeBufferForStreamingInBytes;
std::streamoff streamImageSizeToActivateStreamingInBytes; uint64_t streamImageSizeToActivateStreamingInBytes;
try try
{ {
streamMaxSizeBufferForStreamingInBytes = conf->GetParameter<std::streamoff>( streamMaxSizeBufferForStreamingInBytes = conf->GetParameter<uint64_t>(
"OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING"); "OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING");
streamImageSizeToActivateStreamingInBytes = conf->GetParameter<std::streamoff>( streamImageSizeToActivateStreamingInBytes = conf->GetParameter<uint64_t>(
"OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING"); "OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING");
} }
catch(...) catch(...)
...@@ -129,15 +131,17 @@ unsigned long StreamingTraitsBase<TImage> ...@@ -129,15 +131,17 @@ unsigned long StreamingTraitsBase<TImage>
// We should never have to go here if the configuration file is // We should never have to go here if the configuration file is
// correct and found. In case it is not fallback on the cmake // correct and found. In case it is not fallback on the cmake
// defined constants. // defined constants.
streamMaxSizeBufferForStreamingInBytes = OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING; streamMaxSizeBufferForStreamingInBytes = static_cast<uint64_t>(OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING);
streamImageSizeToActivateStreamingInBytes = OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING; streamImageSizeToActivateStreamingInBytes = static_cast<uint64_t>(OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING);
} }
std::streamoff numberColumnsOfRegion = region.GetSize()[0]; // X dimension uint64_t numberColumnsOfRegion = region.GetSize()[0]; // X dimension
const std::streamoff sizeLineInBytes = static_cast<std::streamoff>(numberColumnsOfRegion) * \ const uint64_t sizeLineInBytes = static_cast<uint64_t>(numberColumnsOfRegion) * \
static_cast<std::streamoff>(image->GetNumberOfComponentsPerPixel()) * \ static_cast<uint64_t>(image->GetNumberOfComponentsPerPixel()) * \
static_cast<std::streamoff>(sizeof(PixelType)); static_cast<uint64_t>(sizeof(PixelType));
const std::streamoff regionSizeInBytes = region.GetSize()[1] * sizeLineInBytes; // Store in double, because std::streamoff = long which max value is 12.8e9.
// It happens that we loop the buffer
const uint64_t regionSizeInBytes = static_cast<uint64_t>(region.GetSize()[1]) * sizeLineInBytes;
otbMsgDevMacro(<< "streamImageSizeToActivateStreaming in Bytes = " << streamImageSizeToActivateStreamingInBytes); otbMsgDevMacro(<< "streamImageSizeToActivateStreaming in Bytes = " << streamImageSizeToActivateStreamingInBytes);
otbMsgDevMacro(<< "streamMaxSizeBufferForStreaming in Bytes = " << streamMaxSizeBufferForStreamingInBytes); otbMsgDevMacro(<< "streamMaxSizeBufferForStreaming in Bytes = " << streamMaxSizeBufferForStreamingInBytes);
otbMsgDevMacro(<< "image->GetNumberOfComponentsPerPixel() = " << image->GetNumberOfComponentsPerPixel()); otbMsgDevMacro(<< "image->GetNumberOfComponentsPerPixel() = " << image->GetNumberOfComponentsPerPixel());
...@@ -146,7 +150,7 @@ unsigned long StreamingTraitsBase<TImage> ...@@ -146,7 +150,7 @@ unsigned long StreamingTraitsBase<TImage>
otbMsgDevMacro(<< "sizeLine in Bytes = " << sizeLineInBytes); otbMsgDevMacro(<< "sizeLine in Bytes = " << sizeLineInBytes);
otbMsgDevMacro(<< "regionSizeInBytes = " << regionSizeInBytes); otbMsgDevMacro(<< "regionSizeInBytes = " << regionSizeInBytes);
if (regionSizeInBytes > streamImageSizeToActivateStreamingInBytes) if ( regionSizeInBytes > streamImageSizeToActivateStreamingInBytes )
{ {
// Activate streaming // Activate streaming
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment