Skip to content
Snippets Groups Projects
Commit ce3cc10a authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Fixing bug when number of tiles to decode is not a multiple of number of available threads

parent 2665ed10
No related branches found
No related tags found
No related merge requests found
......@@ -711,6 +711,11 @@ void JPEG2000ImageIO::Read(void* buffer)
{
opj_image_t * currentTile = itTile->second;
if(!currentTile)
{
itkExceptionMacro(<<"Tile "<<itTile->first<<" needed but not loaded.");
}
unsigned int lWidthSrc; // Width of the input pixel in nb of pixel
unsigned int lHeightDest; // Height of the area where write in nb of pixel
unsigned int lWidthDest; // Width of the area where write in nb of pixel
......@@ -866,6 +871,22 @@ ITK_THREAD_RETURN_TYPE JPEG2000ImageIO::ThreaderCallback( void *arg )
otbMsgDevMacro(<< " Tile " << tiles->at(i).first << " decoded by thread "<<threadId);
}
unsigned int lastTile = threadCount*tilesPerThread + threadId;
// TODO: check this last part
if(lastTile < tiles->size())
{
tiles->at(lastTile).second = readers.at(threadId)->DecodeTile(tiles->at(lastTile).first);
if(!tiles->at(lastTile).second)
{
readers.at(threadId)->Clean();
itkGenericExceptionMacro(" otbopenjpeg failed to decode the desired tile "<<tiles->at(lastTile).first << "!");
}
otbMsgDevMacro(<<" Tile " << tiles->at(lastTile).first << " decoded by thread "<<threadId);
}
return ITK_THREAD_RETURN_VALUE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment