diff options
Diffstat (limited to 'indra/llimagej2coj/llimagej2coj.cpp')
-rw-r--r-- | indra/llimagej2coj/llimagej2coj.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index e35f4ae0b7..4c1594ec98 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); @@ -554,7 +557,7 @@ public: { // "append" (set) the data we "streamed" (memcopied) for writing to the formatted image // with side-effect of setting the actually encoded size to same - compressedImageOut.allocateData(offset); + compressedImageOut.allocateData((S32)offset); memcpy(compressedImageOut.getData(), buffer, offset); compressedImageOut.updateData(); // update width, height etc from header } @@ -732,6 +735,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; @@ -786,7 +792,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; @@ -819,6 +825,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; |