summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindra/llimage/llimagej2c.cpp6
-rw-r--r--indra/llimage/llimagej2c.h3
-rw-r--r--indra/llkdu/llimagej2ckdu.cpp49
3 files changed, 26 insertions, 32 deletions
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 4435e0d2a4..452aad25cb 100755
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -464,6 +464,7 @@ LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTester
addMetric("Perf Compression (kB/s)");
mRunBytesInDecompression = 0;
+ mRunBytesOutDecompression = 0;
mRunBytesInCompression = 0;
mTotalBytesInDecompression = 0;
@@ -556,13 +557,16 @@ void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const
mTotalBytesInDecompression += bytesIn;
mRunBytesInDecompression += bytesIn;
mTotalBytesOutDecompression += bytesOut;
+ mRunBytesOutDecompression += bytesOut;
//if (mRunBytesInDecompression > (1000000))
- if ((mTotalTimeDecompression - mRunTimeDecompression) >= (5.0f))
+ if (mRunBytesOutDecompression > (10000000))
+ //if ((mTotalTimeDecompression - mRunTimeDecompression) >= (5.0f))
{
// Output everything
outputTestResults();
// Reset the decompression data of the run
mRunBytesInDecompression = 0;
+ mRunBytesOutDecompression = 0;
mRunTimeDecompression = mTotalTimeDecompression;
}
}
diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h
index 42093e0e64..ce8195940d 100644
--- a/indra/llimage/llimagej2c.h
+++ b/indra/llimage/llimagej2c.h
@@ -156,7 +156,8 @@ class LLImageCompressionTester : public LLMetricPerformanceTesterBasic
U32 mTotalBytesOutDecompression; // Total bytes produced by decompressor
U32 mTotalBytesInCompression; // Total bytes fed to compressor
U32 mTotalBytesOutCompression; // Total bytes produced by compressor
- U32 mRunBytesInDecompression; // Bytes fed to decompressor in this run
+ U32 mRunBytesInDecompression; // Bytes fed to decompressor in this run
+ U32 mRunBytesOutDecompression; // Bytes produced by the decompressor in this run
U32 mRunBytesInCompression; // Bytes fed to compressor in this run
//
// Time
diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp
index cbfc34ebb8..cf88de12b4 100644
--- a/indra/llkdu/llimagej2ckdu.cpp
+++ b/indra/llkdu/llimagej2ckdu.cpp
@@ -609,53 +609,42 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co
llassert (base.mRate > 0.f);
max_bytes = (U32)((F32)(max_bytes) * base.mRate);
- // If the image is very small, code it in a lossless way.
- // Note: it'll also have only 1 layer which is fine as there's no point reordering blocks in that case.
- if (max_bytes < FIRST_PACKET_SIZE)
- {
- reversible = true;
- }
-
// This code is where we specify the target number of bytes for each quality layer.
// We're using a logarithmic spacing rule that fits with our way of fetching texture data.
// Note: For more info on this layers business, read kdu_codestream::flush() doc in kdu_compressed.h
- U32 i = FIRST_PACKET_SIZE;
+ layer_bytes[nb_layers++] = FIRST_PACKET_SIZE;
+ U32 i = MIN_LAYER_SIZE;
while ((i < max_bytes) && (nb_layers < (MAX_NB_LAYERS-1)))
{
- if (i == FIRST_PACKET_SIZE * 4)
- {
- // That really just means that the first layer is FIRST_PACKET_SIZE and the second is MIN_LAYER_SIZE
- i = MIN_LAYER_SIZE;
- }
- layer_bytes[nb_layers] = i;
- nb_layers++;
+ layer_bytes[nb_layers++] = i;
i *= 4;
}
+ // Note: for small images, we can have (max_bytes < FIRST_PACKET_SIZE), hence the test
+ if (layer_bytes[nb_layers-1] < max_bytes)
+ {
+ // Set the last quality layer so to fit the preset compression ratio
+ layer_bytes[nb_layers++] = max_bytes;
+ }
if (reversible)
{
+ // Use 0 for a last quality layer for reversible images so all remaining code blocks will be flushed
+ // Hack: KDU encoding for reversible images has a bug for small images that leads to j2c images that
+ // cannot be open or are very blurry. Avoiding that last layer prevents the problem to happen.
+ if ((base.getWidth() >= 32) || (base.getHeight() >= 32))
+ {
+ layer_bytes[nb_layers++] = 0;
+ }
codestream.access_siz()->parse_string("Creversible=yes");
- // *TODO: we should use yuv in reversible mode and one res level since those images are small.
- // Don't turn this on now though as both create problems on decoding for the moment
- //codestream.access_siz()->parse_string("Clevels=1");
+ // *TODO: we should use yuv in reversible mode
+ // Don't turn this on now though as it creates problems on decoding for the moment
//codestream.access_siz()->parse_string("Cycc=no");
- // In the reversible case, set the last entry of that table to 0 so that all generated bits will
- // indeed be output by the time the last quality layer is encountered.
- layer_bytes[nb_layers] = 0;
}
- else
- {
- // Truncate the last quality layer if necessary so to fit the set compression ratio
- layer_bytes[nb_layers] = max_bytes;
- }
- nb_layers++;
-
+
std::string layer_string = llformat("Clayers=%d",nb_layers);
codestream.access_siz()->parse_string(layer_string.c_str());
// Set up data ordering, markers, etc... if precincts or blocks specified
- // Note: This code is *not* used in the encoding made by the viewer. It is currently used only
- // by llimage_libtest to create various j2c and test alternative compression schemes.
if ((mBlocksSize != -1) || (mPrecinctsSize != -1))
{
if (mPrecinctsSize != -1)