summaryrefslogtreecommitdiff
path: root/indra/llimagej2coj/llimagej2coj.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2025-10-23 12:00:12 +0800
committerErik Kundiman <erik@megapahit.org>2025-10-25 20:03:33 +0800
commitab9976389fe5e4c254d3eb2c39fd2dff083d8d2d (patch)
treecf14ec0d25efd065a1471debb74080ef41763fbf /indra/llimagej2coj/llimagej2coj.cpp
parent790a7d1ccfa5b1a20a3b5295f839670793ced950 (diff)
parent01823996196c11aea905200fe267463d520d285b (diff)
Merge tag 'Second_Life_Release#01823996-2025.08' into 2025.08
Diffstat (limited to 'indra/llimagej2coj/llimagej2coj.cpp')
-rw-r--r--indra/llimagej2coj/llimagej2coj.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp
index 5b672bf171..9350901324 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -554,11 +554,6 @@ public:
}
- if (!opj_setup_encoder(encoder, &parameters, image))
- {
- return false;
- }
-
U32 width_tiles = (rawImageIn.getWidth() >> 6);
U32 height_tiles = (rawImageIn.getHeight() >> 6);
@@ -572,6 +567,19 @@ public:
height_tiles = 1;
}
+ if (width_tiles == 1 || height_tiles == 1)
+ {
+ // Images with either dimension less than 32 need less number of resolutions otherwise they error
+ int min_dim = rawImageIn.getWidth() < rawImageIn.getHeight() ? rawImageIn.getWidth() : rawImageIn.getHeight();
+ int max_res = 1 + (int)floor(log2(min_dim));
+ parameters.numresolution = max_res;
+ }
+
+ if (!opj_setup_encoder(encoder, &parameters, image))
+ {
+ return false;
+ }
+
U32 tile_count = width_tiles * height_tiles;
U32 data_size_guess = tile_count * TILE_SIZE;