summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2010-11-04 18:10:29 -0700
committerMerov Linden <merov@lindenlab.com>2010-11-04 18:10:29 -0700
commit4bbe823302427a705ea541d968f6058571a13c2f (patch)
treed932a7a3483b674a7600b0e4bff3d0bda3344b35 /indra/llimage
parentba3307b8d0f2ceb40454174a6593f3f98ce98b65 (diff)
parentf7af29ab40c2405504969a453eba3919be1af5c5 (diff)
merge with STORM-105
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimagedimensionsinfo.cpp16
-rw-r--r--indra/llimage/llimagej2c.cpp63
2 files changed, 49 insertions, 30 deletions
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;
}
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 2b4a2935e9..789a34a251 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -446,17 +446,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;
@@ -481,38 +481,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)