summaryrefslogtreecommitdiff
path: root/indra/llimage/llimagejpeg.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-05-30 14:19:53 -0700
committerMerov Linden <merov@lindenlab.com>2014-05-30 14:19:53 -0700
commit68b62747edb7073dd3f4975e2b38388ae80d801c (patch)
tree73730fdc31d3d74a2ba69ad156217299115cd810 /indra/llimage/llimagejpeg.cpp
parenta1afe50feb1c42cc21c7f89b4187a8f7abe0c9fc (diff)
parent644ca6a0f8a7759119814f88df93b8e838321a12 (diff)
Pull merge from lindenlab/viewer-release
Diffstat (limited to 'indra/llimage/llimagejpeg.cpp')
-rwxr-xr-xindra/llimage/llimagejpeg.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/indra/llimage/llimagejpeg.cpp b/indra/llimage/llimagejpeg.cpp
index b70f84efc8..e419c77ff2 100755
--- a/indra/llimage/llimagejpeg.cpp
+++ b/indra/llimage/llimagejpeg.cpp
@@ -32,8 +32,7 @@
jmp_buf LLImageJPEG::sSetjmpBuffer ;
LLImageJPEG::LLImageJPEG(S32 quality)
- :
- LLImageFormatted(IMG_CODEC_JPEG),
+: LLImageFormatted(IMG_CODEC_JPEG),
mOutputBuffer( NULL ),
mOutputBufferSize( 0 ),
mEncodeQuality( quality ) // on a scale from 1 to 100
@@ -374,7 +373,7 @@ boolean LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo )
U8* new_buffer = new U8[ new_buffer_size ];
if (!new_buffer)
{
- llerrs << "Out of memory in LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo )" << llendl;
+ LL_ERRS() << "Out of memory in LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo )" << LL_ENDL;
return FALSE;
}
memcpy( new_buffer, self->mOutputBuffer, self->mOutputBufferSize ); /* Flawfinder: ignore */
@@ -383,7 +382,9 @@ boolean LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo )
cinfo->dest->next_output_byte = self->mOutputBuffer + self->mOutputBufferSize;
cinfo->dest->free_in_buffer = self->mOutputBufferSize;
+ self->disclaimMem(self->mOutputBufferSize);
self->mOutputBufferSize = new_buffer_size;
+ self->claimMem(new_buffer_size);
return TRUE;
}
@@ -465,7 +466,7 @@ void LLImageJPEG::errorOutputMessage( j_common_ptr cinfo )
LLImage::setLastError(error);
BOOL is_decode = (cinfo->is_decompressor != 0);
- llwarns << "LLImageJPEG " << (is_decode ? "decode " : "encode ") << " failed: " << buffer << llendl;
+ LL_WARNS() << "LLImageJPEG " << (is_decode ? "decode " : "encode ") << " failed: " << buffer << LL_ENDL;
}
BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
@@ -489,7 +490,9 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
// Allocate a temporary buffer big enough to hold the entire compressed image (and then some)
// (Note: we make it bigger in emptyOutputBuffer() if we need to)
delete[] mOutputBuffer;
+ disclaimMem(mOutputBufferSize);
mOutputBufferSize = getWidth() * getHeight() * getComponents() + 1024;
+ claimMem(mOutputBufferSize);
mOutputBuffer = new U8[ mOutputBufferSize ];
const U8* raw_image_data = NULL;
@@ -526,6 +529,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
jpeg_destroy_compress(&cinfo);
delete[] mOutputBuffer;
mOutputBuffer = NULL;
+ disclaimMem(mOutputBufferSize);
mOutputBufferSize = 0;
return FALSE;
}
@@ -628,6 +632,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
// After finish_compress, we can release the temp output buffer.
delete[] mOutputBuffer;
mOutputBuffer = NULL;
+ disclaimMem(mOutputBufferSize);
mOutputBufferSize = 0;
////////////////////////////////////////
@@ -640,6 +645,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
jpeg_destroy_compress(&cinfo);
delete[] mOutputBuffer;
mOutputBuffer = NULL;
+ disclaimMem(mOutputBufferSize);
mOutputBufferSize = 0;
return FALSE;
}