summaryrefslogtreecommitdiff
path: root/indra/llimagej2coj
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-07-27 15:17:57 +0800
committerErik Kundiman <erik@megapahit.org>2024-07-28 08:24:59 +0800
commit96a81b5ecbe3bffb582ded930752c0523df5e80a (patch)
treea87a0bd09fd980562e88150dbfea3819d28d9f12 /indra/llimagej2coj
parent06e8f0c443c1ba7858d000c6d695b7e988e02053 (diff)
parented73208eb96b862b97fa285036edea1e792ca3c6 (diff)
Merge remote-tracking branch 'secondlife/release/2024.06-atlasaurus' into 2024.06-atlasaurus
Diffstat (limited to 'indra/llimagej2coj')
-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 b5f1df5507..969bf68b6d 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -178,7 +178,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
@@ -495,6 +495,9 @@ public:
bool encode(const LLImageRaw& rawImageIn, LLImageJ2C &compressedImageOut)
{
+ LLImageDataSharedLock lockIn(&rawImageIn);
+ LLImageDataLock lockOut(&compressedImageOut);
+
setImage(rawImageIn);
encoder = opj_create_compress(OPJ_CODEC_J2K);
@@ -738,6 +741,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;
@@ -792,7 +798,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;
@@ -825,6 +831,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;