From 39e5d2ecf04deceda92d6a53413298ca1c3bc0c7 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 8 Sep 2010 23:03:56 -0700 Subject: VWR-22761 : Rearchitecture of llmetricperformancetester and simple (non complete) implementation in llimagej2c --- indra/llimage/llimagej2c.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++ indra/llimage/llimagej2c.h | 40 +++++++++++++++++++++ 2 files changed, 126 insertions(+) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index c8c866b7f2..72aa253568 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -30,6 +30,7 @@ #include "lldir.h" #include "llimagej2c.h" #include "llmemtype.h" +#include "lltimer.h" typedef LLImageJ2CImpl* (*CreateLLImageJ2CFunction)(); typedef void (*DestroyLLImageJ2CFunction)(LLImageJ2CImpl*); @@ -51,6 +52,9 @@ LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl(); void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl); const char* fallbackEngineInfoLLImageJ2CImpl(); +// Test data gathering handle +LLImageCompressionTester* LLImageJ2C::sTesterp = NULL ; + //static //Loads the required "create", "destroy" and "engineinfo" functions needed void LLImageJ2C::openDSO() @@ -195,6 +199,16 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), { // Array size is MAX_DISCARD_LEVEL+1 mDataSizes[i] = 0; } + + if (LLFastTimer::sMetricLog && !LLImageJ2C::sTesterp) + { + LLImageJ2C::sTesterp = new LLImageCompressionTester() ; + if (!LLImageJ2C::sTesterp->isValid()) + { + delete LLImageJ2C::sTesterp; + LLImageJ2C::sTesterp = NULL; + } + } } // virtual @@ -297,7 +311,12 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir // Update the raw discard level updateRawDiscardLevel(); mDecoding = TRUE; + LLTimer elapsed; res = mImpl->decodeImpl(*this, *raw_imagep, decode_time, first_channel, max_channel_count); + if (LLImageJ2C::sTesterp) + { + LLImageJ2C::sTesterp->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize(), elapsed.getElapsedTimeF32()) ; + } } if (res) @@ -540,3 +559,70 @@ void LLImageJ2C::updateRawDiscardLevel() LLImageJ2CImpl::~LLImageJ2CImpl() { } + +//---------------------------------------------------------------------------------------------- +// Start of LLImageCompressionTester +//---------------------------------------------------------------------------------------------- +LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTesterBasic("ImageCompressionTester") +{ + addMetric("TotalBytesInDecompression"); + addMetric("TotalBytesOutDecompression"); + addMetric("TotalBytesInCompression"); + addMetric("TotalBytesOutCompression"); + + addMetric("TimeTimeDecompression"); + addMetric("TimeTimeCompression"); + + mTotalBytesInDecompression = 0; + mTotalBytesOutDecompression = 0; + mTotalBytesInCompression = 0; + mTotalBytesOutCompression = 0; + + + mTotalTimeDecompression = 0.0f; + mTotalTimeCompression = 0.0f; +} + +LLImageCompressionTester::~LLImageCompressionTester() +{ + LLImageJ2C::sTesterp = NULL; +} + +//virtual +void LLImageCompressionTester::outputTestRecord(LLSD *sd) +{ + std::string currentLabel = getCurrentLabelName(); + (*sd)[currentLabel]["TotalBytesInDecompression"] = (LLSD::Integer)mTotalBytesInDecompression; + (*sd)[currentLabel]["TotalBytesOutDecompression"] = (LLSD::Integer)mTotalBytesOutDecompression; + (*sd)[currentLabel]["TotalBytesInCompression"] = (LLSD::Integer)mTotalBytesInCompression; + (*sd)[currentLabel]["TotalBytesOutCompression"] = (LLSD::Integer)mTotalBytesOutCompression; + + (*sd)[currentLabel]["TimeTimeDecompression"] = (LLSD::Real)mTotalTimeDecompression; + (*sd)[currentLabel]["TimeTimeCompression"] = (LLSD::Real)mTotalTimeCompression; +} + +void LLImageCompressionTester::updateCompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) +{ + mTotalBytesInCompression += bytesIn; + mTotalBytesOutCompression += bytesOut; + mTotalTimeCompression += deltaTime; +} + +void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) +{ + mTotalBytesInDecompression += bytesIn; + mTotalBytesOutDecompression += bytesOut; + mTotalTimeDecompression += deltaTime; + if (mTotalBytesInDecompression > (5*1000000)) + { + outputTestResults(); + mTotalBytesInDecompression = 0; + mTotalBytesOutDecompression = 0; + mTotalTimeDecompression = 0.0f; + } +} + +//---------------------------------------------------------------------------------------------- +// End of LLTexturePipelineTester +//---------------------------------------------------------------------------------------------- + diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index cdb3faa207..eeb00de6d2 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -29,8 +29,11 @@ #include "llimage.h" #include "llassettype.h" +#include "llmetricperformancetester.h" class LLImageJ2CImpl; +class LLImageCompressionTester ; + class LLImageJ2C : public LLImageFormatted { protected: @@ -72,6 +75,9 @@ public: static void openDSO(); static void closeDSO(); static std::string getEngineInfo(); + + // Image compression/decompression tester + static LLImageCompressionTester* sTesterp ; protected: friend class LLImageJ2CImpl; @@ -118,4 +124,38 @@ protected: #define LINDEN_J2C_COMMENT_PREFIX "LL_" +// +// This class is used for performance data gathering only. +// Tracks the image compression / decompression data, +// records and outputs them to metric log files. +// + +class LLImageCompressionTester : public LLMetricPerformanceTesterBasic +{ + public: + LLImageCompressionTester(); + ~LLImageCompressionTester(); + + void updateDecompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) ; + void updateCompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) ; + + protected: + /*virtual*/ void outputTestRecord(LLSD* sd); + + private: + // + // Data size + // + U32 mTotalBytesInDecompression; // Total bytes fed to decompressor + U32 mTotalBytesOutDecompression; // Total bytes produced by decompressor + U32 mTotalBytesInCompression; // Total bytes fed to compressor + U32 mTotalBytesOutCompression; // Total bytes produced by compressor + + // + // Time + // + F32 mTotalTimeDecompression; // Total time spent in computing decompression + F32 mTotalTimeCompression; // Total time spent in computing compression + }; + #endif -- cgit v1.2.3 From 88e33d00cd189aec6ef9b5aa481d4d9a2777b1fb Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 17 Sep 2010 19:17:12 -0700 Subject: STORM-105 : Add compression data gathering, took partial decompression into account in stats --- indra/llimage/llimagej2c.cpp | 67 ++++++++++++++++++++++++++++++++++++-------- indra/llimage/llimagej2c.h | 12 ++++---- 2 files changed, 62 insertions(+), 17 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 72aa253568..207728d4d9 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -294,6 +294,7 @@ BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) // Returns TRUE to mean done, whether successful or not. BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count ) { + LLTimer elapsed; LLMemType mt1(mMemType); BOOL res = TRUE; @@ -311,12 +312,7 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir // Update the raw discard level updateRawDiscardLevel(); mDecoding = TRUE; - LLTimer elapsed; res = mImpl->decodeImpl(*this, *raw_imagep, decode_time, first_channel, max_channel_count); - if (LLImageJ2C::sTesterp) - { - LLImageJ2C::sTesterp->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize(), elapsed.getElapsedTimeF32()) ; - } } if (res) @@ -337,6 +333,20 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir LLImage::setLastError(mLastError); } + if (LLImageJ2C::sTesterp) + { + // Decompression stat gathering + // Note that we *do not* take into account the decompression failures data so we night overestimate the time spent processing + + // Always add the decompression time to the stat + LLImageJ2C::sTesterp->updateDecompressionStats(elapsed.getElapsedTimeF32()) ; + if (res) + { + // The whole data stream is finally decompressed when res is returned as TRUE + LLImageJ2C::sTesterp->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; + } + } + return res; } @@ -349,6 +359,7 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time) BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time) { + LLTimer elapsed; LLMemType mt1(mMemType); resetLastError(); BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible); @@ -356,6 +367,22 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, { LLImage::setLastError(mLastError); } + + if (LLImageJ2C::sTesterp) + { + // Compression stat gathering + // Note that we *do not* take into account the compression failures cases so we night overestimate the time spent processing + + // Always add the compression time to the stat + LLImageJ2C::sTesterp->updateCompressionStats(elapsed.getElapsedTimeF32()) ; + if (res) + { + // The whole data stream is finally compressed when res is returned as TRUE + LLImageJ2C::sTesterp->updateCompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; + } + } + + return res; } @@ -578,7 +605,6 @@ LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTester mTotalBytesInCompression = 0; mTotalBytesOutCompression = 0; - mTotalTimeDecompression = 0.0f; mTotalTimeCompression = 0.0f; } @@ -601,21 +627,40 @@ void LLImageCompressionTester::outputTestRecord(LLSD *sd) (*sd)[currentLabel]["TimeTimeCompression"] = (LLSD::Real)mTotalTimeCompression; } -void LLImageCompressionTester::updateCompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) +void LLImageCompressionTester::updateCompressionStats(const F32 deltaTime) { - mTotalBytesInCompression += bytesIn; - mTotalBytesOutCompression += bytesOut; mTotalTimeCompression += deltaTime; } -void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) +void LLImageCompressionTester::updateCompressionStats(const S32 bytesCompress, const S32 bytesRaw) +{ + mTotalBytesInCompression += bytesRaw; + mTotalBytesOutCompression += bytesCompress; + if (mTotalBytesInCompression > (1000000)) + { + // Output everything + outputTestResults(); + // Reset only the compression data + mTotalBytesInCompression = 0; + mTotalBytesOutCompression = 0; + mTotalTimeCompression = 0.0f; + } +} + +void LLImageCompressionTester::updateDecompressionStats(const F32 deltaTime) +{ + mTotalTimeDecompression += deltaTime; +} + +void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const S32 bytesOut) { mTotalBytesInDecompression += bytesIn; mTotalBytesOutDecompression += bytesOut; - mTotalTimeDecompression += deltaTime; if (mTotalBytesInDecompression > (5*1000000)) { + // Output everything outputTestResults(); + // Reset only the decompression data mTotalBytesInDecompression = 0; mTotalBytesOutDecompression = 0; mTotalTimeDecompression = 0.0f; diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index eeb00de6d2..adbfb9cdb3 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -127,18 +127,19 @@ protected: // // This class is used for performance data gathering only. // Tracks the image compression / decompression data, -// records and outputs them to metric log files. +// records and outputs them to metric.slp log files. // - class LLImageCompressionTester : public LLMetricPerformanceTesterBasic { public: LLImageCompressionTester(); ~LLImageCompressionTester(); - void updateDecompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) ; - void updateCompressionStats(const S32 bytesIn, const S32 bytesOut, const F32 deltaTime) ; - + void updateDecompressionStats(const F32 deltaTime) ; + void updateDecompressionStats(const S32 bytesIn, const S32 bytesOut) ; + void updateCompressionStats(const F32 deltaTime) ; + void updateCompressionStats(const S32 bytesIn, const S32 bytesOut) ; + protected: /*virtual*/ void outputTestRecord(LLSD* sd); @@ -150,7 +151,6 @@ 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 - // // Time // -- cgit v1.2.3 From 40979589afc5c91cab977307a1e400315b1c8a8f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 27 Oct 2010 23:15:22 -0700 Subject: STORM-105 : improve decompression perf gathering, allow perf name to be passed on the command line, fix crash in analysis phase --- indra/llimage/llimagej2c.cpp | 80 +++++++++++++++++++++++++++++++------------- indra/llimage/llimagej2c.h | 4 ++- 2 files changed, 60 insertions(+), 24 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 207728d4d9..08a5912c57 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -31,6 +31,7 @@ #include "llimagej2c.h" #include "llmemtype.h" #include "lltimer.h" +#include "llmath.h" typedef LLImageJ2CImpl* (*CreateLLImageJ2CFunction)(); typedef void (*DestroyLLImageJ2CFunction)(LLImageJ2CImpl*); @@ -54,6 +55,7 @@ const char* fallbackEngineInfoLLImageJ2CImpl(); // Test data gathering handle LLImageCompressionTester* LLImageJ2C::sTesterp = NULL ; +const std::string sTesterName("ImageCompressionTester"); //static //Loads the required "create", "destroy" and "engineinfo" functions needed @@ -200,7 +202,7 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mDataSizes[i] = 0; } - if (LLFastTimer::sMetricLog && !LLImageJ2C::sTesterp) + if (LLFastTimer::sMetricLog && !LLImageJ2C::sTesterp && ((LLFastTimer::sLogName == sTesterName) || (LLFastTimer::sLogName == "metric"))) { LLImageJ2C::sTesterp = new LLImageCompressionTester() ; if (!LLImageJ2C::sTesterp->isValid()) @@ -590,16 +592,23 @@ LLImageJ2CImpl::~LLImageJ2CImpl() //---------------------------------------------------------------------------------------------- // Start of LLImageCompressionTester //---------------------------------------------------------------------------------------------- -LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTesterBasic("ImageCompressionTester") +LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTesterBasic(sTesterName) { + addMetric("TotalTimeDecompression"); addMetric("TotalBytesInDecompression"); addMetric("TotalBytesOutDecompression"); + addMetric("RateDecompression"); + addMetric("PerfDecompression"); + + addMetric("TotalTimeCompression"); addMetric("TotalBytesInCompression"); addMetric("TotalBytesOutCompression"); - - addMetric("TimeTimeDecompression"); - addMetric("TimeTimeCompression"); - + addMetric("RateCompression"); + addMetric("PerfCompression"); + + mRunBytesInDecompression = 0; + mRunBytesInCompression = 0; + mTotalBytesInDecompression = 0; mTotalBytesOutDecompression = 0; mTotalBytesInCompression = 0; @@ -618,13 +627,40 @@ LLImageCompressionTester::~LLImageCompressionTester() void LLImageCompressionTester::outputTestRecord(LLSD *sd) { std::string currentLabel = getCurrentLabelName(); - (*sd)[currentLabel]["TotalBytesInDecompression"] = (LLSD::Integer)mTotalBytesInDecompression; - (*sd)[currentLabel]["TotalBytesOutDecompression"] = (LLSD::Integer)mTotalBytesOutDecompression; - (*sd)[currentLabel]["TotalBytesInCompression"] = (LLSD::Integer)mTotalBytesInCompression; - (*sd)[currentLabel]["TotalBytesOutCompression"] = (LLSD::Integer)mTotalBytesOutCompression; - - (*sd)[currentLabel]["TimeTimeDecompression"] = (LLSD::Real)mTotalTimeDecompression; - (*sd)[currentLabel]["TimeTimeCompression"] = (LLSD::Real)mTotalTimeCompression; + + F32 decompressionPerf = 0.0f; + F32 compressionPerf = 0.0f; + F32 decompressionRate = 0.0f; + F32 compressionRate = 0.0f; + + if (!is_approx_zero(mTotalTimeDecompression)) + { + decompressionPerf = (F32)(mTotalBytesInDecompression) / mTotalTimeDecompression; + } + if (mTotalBytesOutDecompression > 0) + { + decompressionRate = (F32)(mTotalBytesInDecompression) / (F32)(mTotalBytesOutDecompression); + } + if (!is_approx_zero(mTotalTimeCompression)) + { + compressionPerf = (F32)(mTotalBytesInCompression) / mTotalTimeCompression; + } + if (mTotalBytesOutCompression > 0) + { + compressionRate = (F32)(mTotalBytesInCompression) / (F32)(mTotalBytesOutCompression); + } + + (*sd)[currentLabel]["TotalTimeDecompression"] = (LLSD::Real)mTotalTimeDecompression; + (*sd)[currentLabel]["TotalBytesInDecompression"] = (LLSD::Integer)mTotalBytesInDecompression; + (*sd)[currentLabel]["TotalBytesOutDecompression"] = (LLSD::Integer)mTotalBytesOutDecompression; + (*sd)[currentLabel]["RateDecompression"] = (LLSD::Real)decompressionRate; + (*sd)[currentLabel]["PerfDecompression"] = (LLSD::Real)decompressionPerf; + + (*sd)[currentLabel]["TotalTimeCompression"] = (LLSD::Real)mTotalTimeCompression; + (*sd)[currentLabel]["TotalBytesInCompression"] = (LLSD::Integer)mTotalBytesInCompression; + (*sd)[currentLabel]["TotalBytesOutCompression"] = (LLSD::Integer)mTotalBytesOutCompression; + (*sd)[currentLabel]["RateCompression"] = (LLSD::Real)compressionRate; + (*sd)[currentLabel]["PerfCompression"] = (LLSD::Real)compressionPerf; } void LLImageCompressionTester::updateCompressionStats(const F32 deltaTime) @@ -635,15 +671,14 @@ void LLImageCompressionTester::updateCompressionStats(const F32 deltaTime) void LLImageCompressionTester::updateCompressionStats(const S32 bytesCompress, const S32 bytesRaw) { mTotalBytesInCompression += bytesRaw; + mRunBytesInCompression += bytesRaw; mTotalBytesOutCompression += bytesCompress; - if (mTotalBytesInCompression > (1000000)) + if (mRunBytesInCompression > (1000000)) { // Output everything outputTestResults(); - // Reset only the compression data - mTotalBytesInCompression = 0; - mTotalBytesOutCompression = 0; - mTotalTimeCompression = 0.0f; + // Reset the compression data of the run + mRunBytesInCompression = 0; } } @@ -655,15 +690,14 @@ void LLImageCompressionTester::updateDecompressionStats(const F32 deltaTime) void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const S32 bytesOut) { mTotalBytesInDecompression += bytesIn; + mRunBytesInDecompression += bytesIn; mTotalBytesOutDecompression += bytesOut; - if (mTotalBytesInDecompression > (5*1000000)) + if (mRunBytesInDecompression > (1000000)) { // Output everything outputTestResults(); - // Reset only the decompression data - mTotalBytesInDecompression = 0; - mTotalBytesOutDecompression = 0; - mTotalTimeDecompression = 0.0f; + // Reset the decompression data of the run + mRunBytesInDecompression = 0; } } diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index adbfb9cdb3..3933c9236f 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -127,7 +127,7 @@ protected: // // This class is used for performance data gathering only. // Tracks the image compression / decompression data, -// records and outputs them to metric.slp log files. +// records and outputs them to the log file. // class LLImageCompressionTester : public LLMetricPerformanceTesterBasic { @@ -151,6 +151,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 mRunBytesInCompression; // Bytes fed to compressor in this run // // Time // -- cgit v1.2.3 From dac53830f1a67c8657ced9c39eccedbadf149bd9 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 27 Oct 2010 23:40:35 -0700 Subject: STORM-104 : make kdu statically linked, suppress the need for llkdu --- indra/llimage/CMakeLists.txt | 1 - indra/llimage/llimage.cpp | 2 - indra/llimage/llimagej2c.cpp | 162 ++----------------------------------------- indra/llimage/llimagej2c.h | 2 - 4 files changed, 7 insertions(+), 160 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/CMakeLists.txt b/indra/llimage/CMakeLists.txt index a69621a57b..6834267d4b 100644 --- a/indra/llimage/CMakeLists.txt +++ b/indra/llimage/CMakeLists.txt @@ -57,7 +57,6 @@ add_library (llimage ${llimage_SOURCE_FILES}) # Sort by high-level to low-level target_link_libraries(llimage llcommon - llimagej2coj # *HACK: In theory a noop for KDU builds? ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 5c33b675ca..b46a99e030 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -52,13 +52,11 @@ LLMutex* LLImage::sMutex = NULL; void LLImage::initClass() { sMutex = new LLMutex(NULL); - LLImageJ2C::openDSO(); } //static void LLImage::cleanupClass() { - LLImageJ2C::closeDSO(); delete sMutex; sMutex = NULL; } diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 207728d4d9..840813fa75 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -24,9 +24,6 @@ */ #include "linden_common.h" -#include "apr_pools.h" -#include "apr_dso.h" - #include "lldir.h" #include "llimagej2c.h" #include "llmemtype.h" @@ -36,18 +33,10 @@ typedef LLImageJ2CImpl* (*CreateLLImageJ2CFunction)(); typedef void (*DestroyLLImageJ2CFunction)(LLImageJ2CImpl*); typedef const char* (*EngineInfoLLImageJ2CFunction)(); -//some "private static" variables so we only attempt to load -//dynamic libaries once -CreateLLImageJ2CFunction j2cimpl_create_func; -DestroyLLImageJ2CFunction j2cimpl_destroy_func; -EngineInfoLLImageJ2CFunction j2cimpl_engineinfo_func; -apr_pool_t *j2cimpl_dso_memory_pool; -apr_dso_handle_t *j2cimpl_dso_handle; - -//Declare the prototype for theses functions here, their functionality -//will be implemented in other files which define a derived LLImageJ2CImpl -//but only ONE static library which has the implementation for this -//function should ever be included +// Declare the prototype for theses functions here. Their functionality +// will be implemented in other files which define a derived LLImageJ2CImpl +// but only ONE static library which has the implementation for these +// functions should ever be included. LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl(); void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl); const char* fallbackEngineInfoLLImageJ2CImpl(); @@ -55,121 +44,10 @@ const char* fallbackEngineInfoLLImageJ2CImpl(); // Test data gathering handle LLImageCompressionTester* LLImageJ2C::sTesterp = NULL ; -//static -//Loads the required "create", "destroy" and "engineinfo" functions needed -void LLImageJ2C::openDSO() -{ - //attempt to load a DSO and get some functions from it - std::string dso_name; - std::string dso_path; - - bool all_functions_loaded = false; - apr_status_t rv; - -#if LL_WINDOWS - dso_name = "llkdu.dll"; -#elif LL_DARWIN - dso_name = "libllkdu.dylib"; -#else - dso_name = "libllkdu.so"; -#endif - - dso_path = gDirUtilp->findFile(dso_name, - gDirUtilp->getAppRODataDir(), - gDirUtilp->getExecutableDir()); - - j2cimpl_dso_handle = NULL; - j2cimpl_dso_memory_pool = NULL; - - //attempt to load the shared library - apr_pool_create(&j2cimpl_dso_memory_pool, NULL); - rv = apr_dso_load(&j2cimpl_dso_handle, - dso_path.c_str(), - j2cimpl_dso_memory_pool); - - //now, check for success - if ( rv == APR_SUCCESS ) - { - //found the dynamic library - //now we want to load the functions we're interested in - CreateLLImageJ2CFunction create_func = NULL; - DestroyLLImageJ2CFunction dest_func = NULL; - EngineInfoLLImageJ2CFunction engineinfo_func = NULL; - - rv = apr_dso_sym((apr_dso_handle_sym_t*)&create_func, - j2cimpl_dso_handle, - "createLLImageJ2CKDU"); - if ( rv == APR_SUCCESS ) - { - //we've loaded the create function ok - //we need to delete via the DSO too - //so lets check for a destruction function - rv = apr_dso_sym((apr_dso_handle_sym_t*)&dest_func, - j2cimpl_dso_handle, - "destroyLLImageJ2CKDU"); - if ( rv == APR_SUCCESS ) - { - //we've loaded the destroy function ok - rv = apr_dso_sym((apr_dso_handle_sym_t*)&engineinfo_func, - j2cimpl_dso_handle, - "engineInfoLLImageJ2CKDU"); - if ( rv == APR_SUCCESS ) - { - //ok, everything is loaded alright - j2cimpl_create_func = create_func; - j2cimpl_destroy_func = dest_func; - j2cimpl_engineinfo_func = engineinfo_func; - all_functions_loaded = true; - } - } - } - } - - if ( !all_functions_loaded ) - { - //something went wrong with the DSO or function loading.. - //fall back onto our satefy impl creation function - -#if 0 - // precious verbose debugging, sadly we can't use our - // 'llinfos' stream etc. this early in the initialisation seq. - char errbuf[256]; - fprintf(stderr, "failed to load syms from DSO %s (%s)\n", - dso_name.c_str(), dso_path.c_str()); - apr_strerror(rv, errbuf, sizeof(errbuf)); - fprintf(stderr, "error: %d, %s\n", rv, errbuf); - apr_dso_error(j2cimpl_dso_handle, errbuf, sizeof(errbuf)); - fprintf(stderr, "dso-error: %d, %s\n", rv, errbuf); -#endif - - if ( j2cimpl_dso_handle ) - { - apr_dso_unload(j2cimpl_dso_handle); - j2cimpl_dso_handle = NULL; - } - - if ( j2cimpl_dso_memory_pool ) - { - apr_pool_destroy(j2cimpl_dso_memory_pool); - j2cimpl_dso_memory_pool = NULL; - } - } -} - -//static -void LLImageJ2C::closeDSO() -{ - if ( j2cimpl_dso_handle ) apr_dso_unload(j2cimpl_dso_handle); - if (j2cimpl_dso_memory_pool) apr_pool_destroy(j2cimpl_dso_memory_pool); -} - //static std::string LLImageJ2C::getEngineInfo() { - if (!j2cimpl_engineinfo_func) - j2cimpl_engineinfo_func = fallbackEngineInfoLLImageJ2CImpl; - - return j2cimpl_engineinfo_func(); + return fallbackEngineInfoLLImageJ2CImpl(); } LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), @@ -179,20 +57,7 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mReversible(FALSE), mAreaUsedForDataSizeCalcs(0) { - //We assume here that if we wanted to create via - //a dynamic library that the approriate open calls were made - //before any calls to this constructor. - - //Therefore, a NULL creation function pointer here means - //we either did not want to create using functions from the dynamic - //library or there were issues loading it, either way - //use our fall back - if ( !j2cimpl_create_func ) - { - j2cimpl_create_func = fallbackCreateLLImageJ2CImpl; - } - - mImpl = j2cimpl_create_func(); + mImpl = fallbackCreateLLImageJ2CImpl(); // Clear data size table for( S32 i = 0; i <= MAX_DISCARD_LEVEL; i++) @@ -214,22 +79,9 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), // virtual LLImageJ2C::~LLImageJ2C() { - //We assume here that if we wanted to destroy via - //a dynamic library that the approriate open calls were made - //before any calls to this destructor. - - //Therefore, a NULL creation function pointer here means - //we either did not want to destroy using functions from the dynamic - //library or there were issues loading it, either way - //use our fall back - if ( !j2cimpl_destroy_func ) - { - j2cimpl_destroy_func = fallbackDestroyLLImageJ2CImpl; - } - if ( mImpl ) { - j2cimpl_destroy_func(mImpl); + fallbackDestroyLLImageJ2CImpl(mImpl); } } diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index adbfb9cdb3..9191d7886a 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -72,8 +72,6 @@ public: static S32 calcHeaderSizeJ2C(); static S32 calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate = 0.f); - static void openDSO(); - static void closeDSO(); static std::string getEngineInfo(); // Image compression/decompression tester -- cgit v1.2.3 From 9d97a16481528acbfa28f7681da68a6e485f9a22 Mon Sep 17 00:00:00 2001 From: Andrew Productengine Date: Wed, 3 Nov 2010 18:23:53 +0200 Subject: STORM-472 Fixed crash that happened while decoding jpg image. In case of files provided in ticket problem occured in libjpeg's jpeg_start_decompress(to be more specofic- inside it's _jinit_color_deconverter()) because if cinfo's out_color_space is RGB, then jpeg_color_space can't be JCS_YCCK (JCS_YCCK jpeg_color_space is possible for JCS_CMYK out_color_space). So when the combination of RGB and JCS_YCCK was encountered, jpeglib called ERREXIT() inside which exit() was called and viewer crashed. - Checking for this combination before calling jpeg_start_decompress() would solve this problem in this specific case, but there are a lot of possible error combinations which cause libjpeg to exit and thus crash viewer, so copypasting checks from it into viewer code would be cumbersome, uneffective and ugly. So another approach was used instead- by default libjpeg calls exit() after encountering an error, but user can provide his own error handling function instead. on_jpeg_error() function was added in fix for this. It sets true a boolean flag that is used to determine whether there were errors in getImageDimensionsJpeg(), and this function's return value depends on it. --- indra/llimage/llimagedimensionsinfo.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagedimensionsinfo.cpp b/indra/llimage/llimagedimensionsinfo.cpp index 5ea4a236b5..835664c60f 100644 --- a/indra/llimage/llimagedimensionsinfo.cpp +++ b/indra/llimage/llimagedimensionsinfo.cpp @@ -30,6 +30,9 @@ #include "llimagedimensionsinfo.h" +// Value is true if one of Libjpeg's functions has encountered an error while working. +static bool sJpegErrorEncountered = false; + bool LLImageDimensionsInfo::load(const std::string& src_filename,U32 codec) { clean(); @@ -101,9 +104,17 @@ bool LLImageDimensionsInfo::getImageDimensionsPng() return true; } +// Called instead of exit() if Libjpeg encounters an error. +void on_jpeg_error(j_common_ptr cinfo) +{ + (void) cinfo; + sJpegErrorEncountered = true; + llwarns << "Libjpeg has encountered an error!" << llendl; +} bool LLImageDimensionsInfo::getImageDimensionsJpeg() { + sJpegErrorEncountered = false; clean(); FILE *fp = fopen (mSrcFilename.c_str(), "rb"); if (fp == NULL) @@ -115,6 +126,9 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg() jpeg_error_mgr jerr; jpeg_decompress_struct cinfo; cinfo.err = jpeg_std_error(&jerr); + // Call our function instead of exit() if Libjpeg encounters an error. + // This is done to avoid crash in this case (STORM-472). + cinfo.err->error_exit = on_jpeg_error; jpeg_create_decompress (&cinfo); jpeg_stdio_src (&cinfo, fp); @@ -128,6 +142,6 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg() jpeg_destroy_decompress(&cinfo); fclose(fp); - return true; + return !sJpegErrorEncountered; } -- cgit v1.2.3 From c2500f808cd8e1957054d5ec1b3555e30698c2b3 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 4 Nov 2010 13:52:46 -0700 Subject: STORM-105 : Tweak the data labels to make them easier to read --- indra/llimage/llimagej2c.cpp | 63 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 08a5912c57..22610817e4 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -594,17 +594,17 @@ LLImageJ2CImpl::~LLImageJ2CImpl() //---------------------------------------------------------------------------------------------- LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTesterBasic(sTesterName) { - addMetric("TotalTimeDecompression"); - addMetric("TotalBytesInDecompression"); - addMetric("TotalBytesOutDecompression"); - addMetric("RateDecompression"); - addMetric("PerfDecompression"); - - addMetric("TotalTimeCompression"); - addMetric("TotalBytesInCompression"); - addMetric("TotalBytesOutCompression"); - addMetric("RateCompression"); - addMetric("PerfCompression"); + addMetric("Time Decompression (s)"); + addMetric("Volume In Decompression (kB)"); + addMetric("Volume Out Decompression (kB)"); + addMetric("Decompression Ratio (x:1)"); + addMetric("Perf Decompression (kB/s)"); + + addMetric("Time Compression (s)"); + addMetric("Volume In Compression (kB)"); + addMetric("Volume Out Compression (kB)"); + addMetric("Compression Ratio (x:1)"); + addMetric("Perf Compression (kB/s)"); mRunBytesInDecompression = 0; mRunBytesInCompression = 0; @@ -629,38 +629,43 @@ void LLImageCompressionTester::outputTestRecord(LLSD *sd) std::string currentLabel = getCurrentLabelName(); F32 decompressionPerf = 0.0f; - F32 compressionPerf = 0.0f; + F32 compressionPerf = 0.0f; F32 decompressionRate = 0.0f; - F32 compressionRate = 0.0f; + F32 compressionRate = 0.0f; + + F32 totalkBInDecompression = (F32)(mTotalBytesInDecompression) / 1000.0; + F32 totalkBOutDecompression = (F32)(mTotalBytesOutDecompression) / 1000.0; + F32 totalkBInCompression = (F32)(mTotalBytesInCompression) / 1000.0; + F32 totalkBOutCompression = (F32)(mTotalBytesOutCompression) / 1000.0; if (!is_approx_zero(mTotalTimeDecompression)) { - decompressionPerf = (F32)(mTotalBytesInDecompression) / mTotalTimeDecompression; + decompressionPerf = totalkBInDecompression / mTotalTimeDecompression; } - if (mTotalBytesOutDecompression > 0) + if (!is_approx_zero(totalkBInDecompression)) { - decompressionRate = (F32)(mTotalBytesInDecompression) / (F32)(mTotalBytesOutDecompression); + decompressionRate = totalkBOutDecompression / totalkBInDecompression; } if (!is_approx_zero(mTotalTimeCompression)) { - compressionPerf = (F32)(mTotalBytesInCompression) / mTotalTimeCompression; + compressionPerf = totalkBInCompression / mTotalTimeCompression; } - if (mTotalBytesOutCompression > 0) + if (!is_approx_zero(totalkBOutCompression)) { - compressionRate = (F32)(mTotalBytesInCompression) / (F32)(mTotalBytesOutCompression); + compressionRate = totalkBInCompression / totalkBOutCompression; } - (*sd)[currentLabel]["TotalTimeDecompression"] = (LLSD::Real)mTotalTimeDecompression; - (*sd)[currentLabel]["TotalBytesInDecompression"] = (LLSD::Integer)mTotalBytesInDecompression; - (*sd)[currentLabel]["TotalBytesOutDecompression"] = (LLSD::Integer)mTotalBytesOutDecompression; - (*sd)[currentLabel]["RateDecompression"] = (LLSD::Real)decompressionRate; - (*sd)[currentLabel]["PerfDecompression"] = (LLSD::Real)decompressionPerf; + (*sd)[currentLabel]["Time Decompression (s)"] = (LLSD::Real)mTotalTimeDecompression; + (*sd)[currentLabel]["Volume In Decompression (kB)"] = (LLSD::Real)totalkBInDecompression; + (*sd)[currentLabel]["Volume Out Decompression (kB)"]= (LLSD::Real)totalkBOutDecompression; + (*sd)[currentLabel]["Decompression Ratio (x:1)"] = (LLSD::Real)decompressionRate; + (*sd)[currentLabel]["Perf Decompression (kB/s)"] = (LLSD::Real)decompressionPerf; - (*sd)[currentLabel]["TotalTimeCompression"] = (LLSD::Real)mTotalTimeCompression; - (*sd)[currentLabel]["TotalBytesInCompression"] = (LLSD::Integer)mTotalBytesInCompression; - (*sd)[currentLabel]["TotalBytesOutCompression"] = (LLSD::Integer)mTotalBytesOutCompression; - (*sd)[currentLabel]["RateCompression"] = (LLSD::Real)compressionRate; - (*sd)[currentLabel]["PerfCompression"] = (LLSD::Real)compressionPerf; + (*sd)[currentLabel]["Time Compression (s)"] = (LLSD::Real)mTotalTimeCompression; + (*sd)[currentLabel]["Volume In Compression (kB)"] = (LLSD::Real)totalkBInCompression; + (*sd)[currentLabel]["Volume Out Compression (kB)"] = (LLSD::Real)totalkBOutCompression; + (*sd)[currentLabel]["Compression Ratio (x:1)"] = (LLSD::Real)compressionRate; + (*sd)[currentLabel]["Perf Compression (kB/s)"] = (LLSD::Real)compressionPerf; } void LLImageCompressionTester::updateCompressionStats(const F32 deltaTime) -- cgit v1.2.3 From 85509457c6dc6a0f3e56fa3d24ae872e1878c04f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 5 Nov 2010 18:40:08 -0700 Subject: STORM-105 : Take Vadim code review into account, code clean up --- indra/llimage/llimagej2c.cpp | 155 ++++++++++++++++++++++--------------------- indra/llimage/llimagej2c.h | 8 ++- 2 files changed, 85 insertions(+), 78 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 22610817e4..9173a331b3 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -77,8 +77,8 @@ void LLImageJ2C::openDSO() #endif dso_path = gDirUtilp->findFile(dso_name, - gDirUtilp->getAppRODataDir(), - gDirUtilp->getExecutableDir()); + gDirUtilp->getAppRODataDir(), + gDirUtilp->getExecutableDir()); j2cimpl_dso_handle = NULL; j2cimpl_dso_memory_pool = NULL; @@ -108,7 +108,7 @@ void LLImageJ2C::openDSO() //so lets check for a destruction function rv = apr_dso_sym((apr_dso_handle_sym_t*)&dest_func, j2cimpl_dso_handle, - "destroyLLImageJ2CKDU"); + "destroyLLImageJ2CKDU"); if ( rv == APR_SUCCESS ) { //we've loaded the destroy function ok @@ -174,6 +174,12 @@ std::string LLImageJ2C::getEngineInfo() return j2cimpl_engineinfo_func(); } +//static +bool LLImageJ2C::perfStatsEnabled() +{ + return (sTesterp != NULL); +} + LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mMaxBytes(0), mRawDiscardLevel(-1), @@ -202,14 +208,14 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mDataSizes[i] = 0; } - if (LLFastTimer::sMetricLog && !LLImageJ2C::sTesterp && ((LLFastTimer::sLogName == sTesterName) || (LLFastTimer::sLogName == "metric"))) + if (LLFastTimer::sMetricLog && !perfStatsEnabled() && ((LLFastTimer::sLogName == sTesterName) || (LLFastTimer::sLogName == "metric"))) { - LLImageJ2C::sTesterp = new LLImageCompressionTester() ; - if (!LLImageJ2C::sTesterp->isValid()) - { - delete LLImageJ2C::sTesterp; - LLImageJ2C::sTesterp = NULL; - } + sTesterp = new LLImageCompressionTester() ; + if (!sTesterp->isValid()) + { + delete sTesterp; + sTesterp = NULL; + } } } @@ -296,7 +302,7 @@ BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) // Returns TRUE to mean done, whether successful or not. BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count ) { - LLTimer elapsed; + LLTimer elapsed; LLMemType mt1(mMemType); BOOL res = TRUE; @@ -335,19 +341,19 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir LLImage::setLastError(mLastError); } - if (LLImageJ2C::sTesterp) - { - // Decompression stat gathering - // Note that we *do not* take into account the decompression failures data so we night overestimate the time spent processing - - // Always add the decompression time to the stat - LLImageJ2C::sTesterp->updateDecompressionStats(elapsed.getElapsedTimeF32()) ; - if (res) - { - // The whole data stream is finally decompressed when res is returned as TRUE - LLImageJ2C::sTesterp->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; - } - } + if (perfStatsEnabled()) + { + // Decompression stat gathering + // Note that we *do not* take into account the decompression failures data so we might overestimate the time spent processing + + // Always add the decompression time to the stat + sTesterp->updateDecompressionStats(elapsed.getElapsedTimeF32()) ; + if (res) + { + // The whole data stream is finally decompressed when res is returned as TRUE + sTesterp->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; + } + } return res; } @@ -361,7 +367,7 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time) BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time) { - LLTimer elapsed; + LLTimer elapsed; LLMemType mt1(mMemType); resetLastError(); BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible); @@ -370,21 +376,20 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, LLImage::setLastError(mLastError); } - if (LLImageJ2C::sTesterp) - { - // Compression stat gathering - // Note that we *do not* take into account the compression failures cases so we night overestimate the time spent processing - - // Always add the compression time to the stat - LLImageJ2C::sTesterp->updateCompressionStats(elapsed.getElapsedTimeF32()) ; - if (res) - { - // The whole data stream is finally compressed when res is returned as TRUE - LLImageJ2C::sTesterp->updateCompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; - } - } - - + if (perfStatsEnabled()) + { + // Compression stat gathering + // Note that we *do not* take into account the compression failures cases so we night overestimate the time spent processing + + // Always add the compression time to the stat + sTesterp->updateCompressionStats(elapsed.getElapsedTimeF32()) ; + if (res) + { + // The whole data stream is finally compressed when res is returned as TRUE + sTesterp->updateCompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; + } + } + return res; } @@ -607,15 +612,15 @@ LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTester addMetric("Perf Compression (kB/s)"); mRunBytesInDecompression = 0; - mRunBytesInCompression = 0; + mRunBytesInCompression = 0; - mTotalBytesInDecompression = 0; - mTotalBytesOutDecompression = 0; - mTotalBytesInCompression = 0; - mTotalBytesOutCompression = 0; + mTotalBytesInDecompression = 0; + mTotalBytesOutDecompression = 0; + mTotalBytesInCompression = 0; + mTotalBytesOutCompression = 0; - mTotalTimeDecompression = 0.0f; - mTotalTimeCompression = 0.0f; + mTotalTimeDecompression = 0.0f; + mTotalTimeCompression = 0.0f; } LLImageCompressionTester::~LLImageCompressionTester() @@ -626,13 +631,13 @@ LLImageCompressionTester::~LLImageCompressionTester() //virtual void LLImageCompressionTester::outputTestRecord(LLSD *sd) { - std::string currentLabel = getCurrentLabelName(); - + std::string currentLabel = getCurrentLabelName(); + F32 decompressionPerf = 0.0f; F32 compressionPerf = 0.0f; F32 decompressionRate = 0.0f; F32 compressionRate = 0.0f; - + F32 totalkBInDecompression = (F32)(mTotalBytesInDecompression) / 1000.0; F32 totalkBOutDecompression = (F32)(mTotalBytesOutDecompression) / 1000.0; F32 totalkBInCompression = (F32)(mTotalBytesInCompression) / 1000.0; @@ -654,56 +659,56 @@ void LLImageCompressionTester::outputTestRecord(LLSD *sd) { compressionRate = totalkBInCompression / totalkBOutCompression; } - + (*sd)[currentLabel]["Time Decompression (s)"] = (LLSD::Real)mTotalTimeDecompression; (*sd)[currentLabel]["Volume In Decompression (kB)"] = (LLSD::Real)totalkBInDecompression; (*sd)[currentLabel]["Volume Out Decompression (kB)"]= (LLSD::Real)totalkBOutDecompression; (*sd)[currentLabel]["Decompression Ratio (x:1)"] = (LLSD::Real)decompressionRate; (*sd)[currentLabel]["Perf Decompression (kB/s)"] = (LLSD::Real)decompressionPerf; - + (*sd)[currentLabel]["Time Compression (s)"] = (LLSD::Real)mTotalTimeCompression; (*sd)[currentLabel]["Volume In Compression (kB)"] = (LLSD::Real)totalkBInCompression; (*sd)[currentLabel]["Volume Out Compression (kB)"] = (LLSD::Real)totalkBOutCompression; - (*sd)[currentLabel]["Compression Ratio (x:1)"] = (LLSD::Real)compressionRate; + (*sd)[currentLabel]["Compression Ratio (x:1)"] = (LLSD::Real)compressionRate; (*sd)[currentLabel]["Perf Compression (kB/s)"] = (LLSD::Real)compressionPerf; } void LLImageCompressionTester::updateCompressionStats(const F32 deltaTime) { - mTotalTimeCompression += deltaTime; + mTotalTimeCompression += deltaTime; } void LLImageCompressionTester::updateCompressionStats(const S32 bytesCompress, const S32 bytesRaw) { - mTotalBytesInCompression += bytesRaw; - mRunBytesInCompression += bytesRaw; - mTotalBytesOutCompression += bytesCompress; - if (mRunBytesInCompression > (1000000)) - { - // Output everything - outputTestResults(); - // Reset the compression data of the run - mRunBytesInCompression = 0; - } + mTotalBytesInCompression += bytesRaw; + mRunBytesInCompression += bytesRaw; + mTotalBytesOutCompression += bytesCompress; + if (mRunBytesInCompression > (1000000)) + { + // Output everything + outputTestResults(); + // Reset the compression data of the run + mRunBytesInCompression = 0; + } } void LLImageCompressionTester::updateDecompressionStats(const F32 deltaTime) { - mTotalTimeDecompression += deltaTime; + mTotalTimeDecompression += deltaTime; } void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const S32 bytesOut) { - mTotalBytesInDecompression += bytesIn; - mRunBytesInDecompression += bytesIn; - mTotalBytesOutDecompression += bytesOut; - if (mRunBytesInDecompression > (1000000)) - { - // Output everything - outputTestResults(); - // Reset the decompression data of the run - mRunBytesInDecompression = 0; - } + mTotalBytesInDecompression += bytesIn; + mRunBytesInDecompression += bytesIn; + mTotalBytesOutDecompression += bytesOut; + if (mRunBytesInDecompression > (1000000)) + { + // Output everything + outputTestResults(); + // Reset the decompression data of the run + mRunBytesInDecompression = 0; + } } //---------------------------------------------------------------------------------------------- diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index 3933c9236f..7333f0370f 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -76,13 +76,11 @@ public: static void closeDSO(); static std::string getEngineInfo(); - // Image compression/decompression tester - static LLImageCompressionTester* sTesterp ; - protected: friend class LLImageJ2CImpl; friend class LLImageJ2COJ; friend class LLImageJ2CKDU; + friend class LLImageCompressionTester; void decodeFailed(); void updateRawDiscardLevel(); @@ -96,6 +94,10 @@ protected: BOOL mReversible; LLImageJ2CImpl *mImpl; std::string mLastError; + + // Image compression/decompression tester + static LLImageCompressionTester* sTesterp; + static bool perfStatsEnabled(); }; // Derive from this class to implement JPEG2000 decoding -- cgit v1.2.3 From b5df1d2abcef04ee5f491a7414189f4e82faaa1e Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 8 Nov 2010 17:16:31 -0800 Subject: STORM-105 : takes Vadim's comments into account, clean up use of static globals and magic strings, enforce naming conventions --- indra/llimage/llimagej2c.cpp | 23 ++++++++++------------- indra/llimage/llimagej2c.h | 1 - 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 9173a331b3..d005aaf29f 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -174,12 +174,6 @@ std::string LLImageJ2C::getEngineInfo() return j2cimpl_engineinfo_func(); } -//static -bool LLImageJ2C::perfStatsEnabled() -{ - return (sTesterp != NULL); -} - LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mMaxBytes(0), mRawDiscardLevel(-1), @@ -208,7 +202,8 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mDataSizes[i] = 0; } - if (LLFastTimer::sMetricLog && !perfStatsEnabled() && ((LLFastTimer::sLogName == sTesterName) || (LLFastTimer::sLogName == "metric"))) + // If that test log has ben requested but not yet created, create it + if (LLMetricPerformanceTesterBasic::isMetricLogRequested(sTesterName) && !LLMetricPerformanceTesterBasic::getTester(sTesterName)) { sTesterp = new LLImageCompressionTester() ; if (!sTesterp->isValid()) @@ -341,17 +336,18 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir LLImage::setLastError(mLastError); } - if (perfStatsEnabled()) + LLImageCompressionTester* tester = (LLImageCompressionTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); + if (tester) { // Decompression stat gathering // Note that we *do not* take into account the decompression failures data so we might overestimate the time spent processing // Always add the decompression time to the stat - sTesterp->updateDecompressionStats(elapsed.getElapsedTimeF32()) ; + tester->updateDecompressionStats(elapsed.getElapsedTimeF32()) ; if (res) { // The whole data stream is finally decompressed when res is returned as TRUE - sTesterp->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; + tester->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; } } @@ -376,17 +372,18 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, LLImage::setLastError(mLastError); } - if (perfStatsEnabled()) + LLImageCompressionTester* tester = (LLImageCompressionTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); + if (tester) { // Compression stat gathering // Note that we *do not* take into account the compression failures cases so we night overestimate the time spent processing // Always add the compression time to the stat - sTesterp->updateCompressionStats(elapsed.getElapsedTimeF32()) ; + tester->updateCompressionStats(elapsed.getElapsedTimeF32()) ; if (res) { // The whole data stream is finally compressed when res is returned as TRUE - sTesterp->updateCompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; + tester->updateCompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ; } } diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index 7333f0370f..cc3dabd7d8 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -97,7 +97,6 @@ protected: // Image compression/decompression tester static LLImageCompressionTester* sTesterp; - static bool perfStatsEnabled(); }; // Derive from this class to implement JPEG2000 decoding -- cgit v1.2.3 From 922f4e59ab2ab58192f9e8832b14fe7a63ee8fd8 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 17 Dec 2010 11:30:52 -0800 Subject: STORM-744 : Turn llimage/tests/ on again --- indra/llimage/CMakeLists.txt | 13 +++++++++++-- indra/llimage/tests/llimageworker_test.cpp | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/CMakeLists.txt b/indra/llimage/CMakeLists.txt index 6834267d4b..ea8c1a1107 100644 --- a/indra/llimage/CMakeLists.txt +++ b/indra/llimage/CMakeLists.txt @@ -3,12 +3,13 @@ project(llimage) include(00-Common) -include(LLAddBuildTest) include(LLCommon) include(LLImage) include(LLMath) include(LLVFS) include(ZLIB) +include(LLAddBuildTest) +include(Tut) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -63,4 +64,12 @@ target_link_libraries(llimage ) # Add tests -#ADD_BUILD_TEST(llimageworker llimage) +if (LL_TESTS) + SET(llimage_TEST_SOURCE_FILES + llimageworker.cpp + ) + LL_ADD_PROJECT_UNIT_TESTS(llimage "${llimage_TEST_SOURCE_FILES}") +endif (LL_TESTS) + + + diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index a109276709..08476fb72c 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -26,10 +26,8 @@ */ // Precompiled header: almost always required for newview cpp files -#include -#include -#include -// Class to test +#include "linden_common.h" +// Class to test #include "../llimageworker.h" // For timer class #include "../llcommon/lltimer.h" @@ -44,7 +42,17 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. -LLImageBase::LLImageBase() {} +LLImageBase::LLImageBase() +: mData(NULL), +mDataSize(0), +mWidth(0), +mHeight(0), +mComponents(0), +mBadBufferAllocation(false), +mAllowOverSize(false), +mMemType(LLMemType::MTYPE_IMAGEBASE) +{ +} LLImageBase::~LLImageBase() {} void LLImageBase::dump() { } void LLImageBase::sanityCheck() { } -- cgit v1.2.3