summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2010-11-05 18:40:08 -0700
committerMerov Linden <merov@lindenlab.com>2010-11-05 18:40:08 -0700
commit85509457c6dc6a0f3e56fa3d24ae872e1878c04f (patch)
tree25965d736b6f3052c4bb1fbffc7f725edf97561b /indra/llimage
parenta680d4fc1c30828fac63b1b9c6caee497c8f992a (diff)
STORM-105 : Take Vadim code review into account, code clean up
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimagej2c.cpp155
-rw-r--r--indra/llimage/llimagej2c.h8
2 files changed, 85 insertions, 78 deletions
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