Skip to content

Commit

Permalink
Fix to KakaduImage.cc to check for increases in stripe heights and ma…
Browse files Browse the repository at this point in the history
…ke sure sufficient memory is allocated
  • Loading branch information
ruven committed Mar 19, 2015
1 parent 39ea949 commit fb3244d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
19/03/2015:
- Fix to KakaduImage.cc to check for increases in stripe heights and make sure
sufficient memory is allocated.


13/02/2015:
- Added checks for NULL FCGX_GetParam results and to empty HTTP_IF_MODIFIED_SINCE.
See: https://github.com/ruven/iipsrv/issues/33 - thanks to Brian Helba.
Expand Down
25 changes: 24 additions & 1 deletion src/KakaduImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,35 @@ void KakaduImage::process( unsigned int res, int layers, int xoffset, int yoffse
buffer = new unsigned char[tw*th*channels];
}

// Keep track of changes in stripe heights
int previous_stripe_heights = stripe_heights[0];


while( continues ){


decompressor.get_recommended_stripe_heights( comp_dims.size.y,
1024, stripe_heights, NULL );


// If we have a larger stripe height, allocate new memory for this
if( stripe_heights[0] > previous_stripe_heights ){

// First delete then re-allocate our buffers
delete_buffer( stripe_buffer );
if( obpc == 16 ){
stripe_buffer = new kdu_uint16[tw*stripe_heights[0]*channels];
}
else if( obpc == 8 ){
stripe_buffer = new kdu_byte[tw*stripe_heights[0]*channels];
}

#ifdef DEBUG
logfile << "Kakadu :: Stripe height increase: re-allocating memory for height " << stripe_heights[0] << endl;
#endif
}


if( obpc == 16 ){
// Set these to false to get unsigned 16 bit values
bool s[3] = {false,false,false};
Expand Down Expand Up @@ -581,7 +604,7 @@ void KakaduImage::process( unsigned int res, int layers, int xoffset, int yoffse
if( res < virtual_levels ){

#ifdef DEBUG
logfile << "Kakadu :: resizing tile to virtual resolution" << endl;
logfile << "Kakadu :: resizing tile to virtual resolution with factor " << (1 << (virtual_levels-res)) << endl;
#endif

unsigned int n = 0;
Expand Down

0 comments on commit fb3244d

Please sign in to comment.