summaryrefslogtreecommitdiff
path: root/indra/llimagej2coj
diff options
context:
space:
mode:
authorHecklezz <tj8@live.com.au>2025-04-21 01:37:47 +1000
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-04-29 00:02:16 +0300
commit1c72cd7e9d1cc99f2937d9b585a4cbdb2a15ea21 (patch)
treed41e7e186a7c18066e38a7e01151e7b35632e0e4 /indra/llimagej2coj
parent230244b7ea4843dbcefa3bc30862b5b02e178ee7 (diff)
Fix uploading small textures with OpenJPEG, and minor logging refactor.
Diffstat (limited to 'indra/llimagej2coj')
-rw-r--r--indra/llimagej2coj/llimagej2coj.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp
index f4bcb97a5d..c027aecfc9 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -551,7 +551,20 @@ public:
opj_set_warning_handler(encoder, opj_warn, this);
opj_set_error_handler(encoder, opj_error, this);
- U32 tile_count = (rawImageIn.getWidth() >> 6) * (rawImageIn.getHeight() >> 6);
+ U32 width_tiles = (rawImageIn.getWidth() >> 6);
+ U32 height_tiles = (rawImageIn.getHeight() >> 6);
+
+ // Allow images with a width or height that are MIN_IMAGE_SIZE <= x < 64
+ if (width_tiles == 0 && (rawImageIn.getWidth() >= MIN_IMAGE_SIZE))
+ {
+ width_tiles = 1;
+ }
+ if (height_tiles == 0 && (rawImageIn.getHeight() >= MIN_IMAGE_SIZE))
+ {
+ height_tiles = 1;
+ }
+
+ U32 tile_count = width_tiles * height_tiles;
U32 data_size_guess = tile_count * TILE_SIZE;
// will be freed in opj_free_user_data_write
@@ -857,12 +870,11 @@ bool LLImageJ2COJ::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, con
{
JPEG2KEncode encode(comment_text, reversible);
bool encoded = encode.encode(raw_image, base);
- if (encoded)
+ if (!encoded)
{
- LL_WARNS() << "Openjpeg encoding implementation isn't complete, returning false" << LL_ENDL;
+ LL_WARNS() << "Openjpeg encoding was unsuccessful, returning false" << LL_ENDL;
}
return encoded;
- //return false;
}
bool LLImageJ2COJ::getMetadata(LLImageJ2C &base)