summaryrefslogtreecommitdiff
path: root/indra/llimagej2coj/llimagej2coj.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimagej2coj/llimagej2coj.cpp')
-rw-r--r--indra/llimagej2coj/llimagej2coj.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp
index f5f151e27b..9a4e382183 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -172,7 +172,7 @@ static OPJ_OFF_T opj_skip(OPJ_OFF_T bytes, void* user_data)
JPEG2KBase* jpeg_codec = static_cast<JPEG2KBase*>(user_data);
jpeg_codec->offset += bytes;
- if (jpeg_codec->offset > jpeg_codec->size)
+ if (jpeg_codec->offset > (OPJ_OFF_T)jpeg_codec->size)
{
jpeg_codec->offset = jpeg_codec->size;
// Indicate end of stream
@@ -489,6 +489,9 @@ public:
bool encode(const LLImageRaw& rawImageIn, LLImageJ2C &compressedImageOut)
{
+ LLImageDataSharedLock lockIn(&rawImageIn);
+ LLImageDataLock lockOut(&compressedImageOut);
+
setImage(rawImageIn);
encoder = opj_create_compress(OPJ_CODEC_J2K);
@@ -733,6 +736,9 @@ bool LLImageJ2COJ::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int block
bool LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count)
{
+ LLImageDataLock lockIn(&base);
+ LLImageDataLock lockOut(&raw_image);
+
JPEG2KDecode decoder(0);
U32 image_channels = 0;
@@ -787,7 +793,7 @@ bool LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
S32 offset = dest;
for (S32 y = (height - 1); y >= 0; y--)
{
- for (S32 x = 0; x < width; x++)
+ for (U32 x = 0; x < width; x++)
{
rawp[offset] = image->comps[comp].data[y*comp_width + x];
offset += channels;
@@ -820,6 +826,8 @@ bool LLImageJ2COJ::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, con
bool LLImageJ2COJ::getMetadata(LLImageJ2C &base)
{
+ LLImageDataLock lock(&base);
+
JPEG2KDecode decode(0);
S32 width = 0;