summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/CMakeLists.txt16
-rw-r--r--indra/llimage/llimage.h2
-rw-r--r--indra/llimage/llimagej2c.cpp22
-rw-r--r--indra/llimage/llimagejpeg.h2
4 files changed, 22 insertions, 20 deletions
diff --git a/indra/llimage/CMakeLists.txt b/indra/llimage/CMakeLists.txt
index f55d9fdf5e..3abc85954b 100644
--- a/indra/llimage/CMakeLists.txt
+++ b/indra/llimage/CMakeLists.txt
@@ -67,15 +67,13 @@ target_link_libraries(llimage
ll::libjpeg
)
-if (NOT (USE_AUTOBUILD_3P OR USE_CONAN))
- if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- set_source_files_properties(llimageworker.cpp PROPERTIES COMPILE_FLAGS -Wno-int-in-bool-context)
- set_source_files_properties(
- llimage.cpp
- llimagefilter.cpp
- PROPERTIES COMPILE_FLAGS -Wno-stringop-overflow)
- endif()
-endif ()
+if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
+ set_source_files_properties(llimageworker.cpp PROPERTIES COMPILE_FLAGS -Wno-int-in-bool-context)
+ set_source_files_properties(
+ llimage.cpp
+ llimagefilter.cpp
+ PROPERTIES COMPILE_FLAGS -Wno-stringop-overflow)
+endif()
include(LibraryInstall)
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 8b966b8ea3..6b14b68c78 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -179,7 +179,7 @@ private:
public:
template<bool SHARED>
- class DataLock : LLSharedMutexLockTemplate<SHARED>
+ class DataLock : public LLSharedMutexLockTemplate<SHARED>
{
public:
DataLock(const LLImageBase* image)
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 4ec95bbcc3..aa161709a1 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -276,16 +276,20 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r
// Estimate the number of layers. This is consistent with what's done for j2c encoding in LLImageJ2CKDU::encodeImpl().
constexpr S32 precision = 8; // assumed bitrate per component channel, might change in future for HDR support
constexpr S32 max_components = 4; // assumed the file has four components; three color and alpha
- S32 nb_layers = 1;
- const S32 surface = w*h;
- S32 s = 64*64;
- S32 totalbytes = (S32)(s * max_components * precision * rate); // first level computed before loop
- while (surface > s)
+ // Use MAX_IMAGE_SIZE_DEFAULT (currently 2048) if either dimension is unknown (zero)
+ S32 width = (w > 0) ? w : 2048;
+ S32 height = (h > 0) ? h : 2048;
+ S32 max_dimension = llmax(width, height); // Find largest dimension
+ S32 block_area = MAX_BLOCK_SIZE * MAX_BLOCK_SIZE; // Calculated initial block area from established max block size (currently 64)
+ block_area *= llmax((max_dimension / MAX_BLOCK_SIZE / max_components), 1); // Adjust initial block area by ratio of largest dimension to block size per component
+ S32 totalbytes = (S32) (block_area * max_components * precision); // First block layer computed before loop without compression rate
+ S32 block_layers = 1; // Start at layer 1 since first block layer is computed outside loop
+ while (block_layers < 6) // Walk five layers for the five discards in JPEG2000
{
- if (nb_layers <= (5 - discard_level))
- totalbytes += (S32)(s * max_components * precision * rate);
- nb_layers++;
- s *= 4;
+ if (block_layers <= (5 - discard_level)) // Walk backwards from discard 5 to required discard layer.
+ totalbytes += (S32) (block_area * max_components * precision * rate); // Add each block layer reduced by assumed compression rate
+ block_layers++; // Move to next layer
+ block_area *= 4; // Increase block area by power of four
}
totalbytes /= 8; // to bytes
diff --git a/indra/llimage/llimagejpeg.h b/indra/llimage/llimagejpeg.h
index 012b87a42d..f6d9f19ba5 100644
--- a/indra/llimage/llimagejpeg.h
+++ b/indra/llimage/llimagejpeg.h
@@ -32,7 +32,7 @@
#include "llimage.h"
extern "C" {
-#ifdef LL_USESYSTEMLIBS
+#if 1
# include <jpeglib.h>
# include <jerror.h>
#else