summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llimage/llimagej2c.cpp30
-rw-r--r--indra/llimage/llimagej2c.h7
-rw-r--r--indra/llimagej2coj/llimagej2coj.cpp15
-rw-r--r--indra/llimagej2coj/llimagej2coj.h11
-rw-r--r--indra/llkdu/llimagej2ckdu.cpp12
-rw-r--r--indra/llkdu/llimagej2ckdu.h11
6 files changed, 34 insertions, 52 deletions
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 7cd59a2983..913313bf15 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -31,18 +31,13 @@
#include "llmath.h"
#include "llmemory.h"
#include "llsd.h"
+#include <boost/scoped_ptr.hpp>
-typedef LLImageJ2CImpl* (*CreateLLImageJ2CFunction)();
-typedef void (*DestroyLLImageJ2CFunction)(LLImageJ2CImpl*);
-typedef const char* (*EngineInfoLLImageJ2CFunction)();
-
-// 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.
+// Declare the prototype for this factory function here. It is implemented in
+// other files which define a LLImageJ2CImpl subclass, but only ONE static
+// library which has the implementation for this function should ever be
+// linked.
LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl();
-void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl);
-const char* fallbackEngineInfoLLImageJ2CImpl();
// Test data gathering handle
LLImageCompressionTester* LLImageJ2C::sTesterp = NULL ;
@@ -51,7 +46,10 @@ const std::string sTesterName("ImageCompressionTester");
//static
std::string LLImageJ2C::getEngineInfo()
{
- return fallbackEngineInfoLLImageJ2CImpl();
+ // All known LLImageJ2CImpl implementation subclasses are cheap to
+ // construct.
+ boost::scoped_ptr<LLImageJ2CImpl> impl(fallbackCreateLLImageJ2CImpl());
+ return impl->getEngineInfo();
}
LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C),
@@ -61,7 +59,7 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C),
mReversible(FALSE),
mAreaUsedForDataSizeCalcs(0)
{
- mImpl = fallbackCreateLLImageJ2CImpl();
+ mImpl.reset(fallbackCreateLLImageJ2CImpl());
claimMem(mImpl);
// Clear data size table
@@ -83,13 +81,7 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C),
}
// virtual
-LLImageJ2C::~LLImageJ2C()
-{
- if ( mImpl )
- {
- fallbackDestroyLLImageJ2CImpl(mImpl);
- }
-}
+LLImageJ2C::~LLImageJ2C() {}
// virtual
void LLImageJ2C::resetLastError()
diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h
index ce8195940d..bfaccdfd05 100644
--- a/indra/llimage/llimagej2c.h
+++ b/indra/llimage/llimagej2c.h
@@ -30,6 +30,7 @@
#include "llimage.h"
#include "llassettype.h"
#include "llmetricperformancetester.h"
+#include <boost/scoped_ptr.hpp>
// JPEG2000 : compression rate used in j2c conversion.
const F32 DEFAULT_COMPRESSION_RATE = 1.f/8.f;
@@ -94,7 +95,7 @@ protected:
S8 mRawDiscardLevel;
F32 mRate;
BOOL mReversible;
- LLImageJ2CImpl *mImpl;
+ boost::scoped_ptr<LLImageJ2CImpl> mImpl;
std::string mLastError;
// Image compression/decompression tester
@@ -124,11 +125,11 @@ protected:
virtual BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL) = 0;
virtual BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1, int levels = 0) = 0;
+ virtual std::string getEngineInfo() const = 0;
+
friend class LLImageJ2C;
};
-#define LINDEN_J2C_COMMENT_PREFIX "LL_"
-
//
// This class is used for performance data gathering only.
// Tracks the image compression / decompression data,
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp
index e98f677d9b..0152b879c2 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -33,23 +33,16 @@
#include "lltimer.h"
//#include "llmemory.h"
-const char* fallbackEngineInfoLLImageJ2CImpl()
-{
- static std::string version_string =
- std::string("OpenJPEG: " OPENJPEG_VERSION ", Runtime: ")
- + opj_version();
- return version_string.c_str();
-}
-
+// Factory function: see declaration in llimagej2c.cpp
LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl()
{
return new LLImageJ2COJ();
}
-void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl)
+std::string LLImageJ2COJ::getEngineInfo() const
{
- delete impl;
- impl = NULL;
+ return std::string("OpenJPEG: " OPENJPEG_VERSION ", Runtime: ")
+ + opj_version();
}
// Return string from message, eliminating final \n if present
diff --git a/indra/llimagej2coj/llimagej2coj.h b/indra/llimagej2coj/llimagej2coj.h
index 40ad4edb00..ae96a175a2 100644
--- a/indra/llimagej2coj/llimagej2coj.h
+++ b/indra/llimagej2coj/llimagej2coj.h
@@ -35,12 +35,13 @@ public:
LLImageJ2COJ();
virtual ~LLImageJ2COJ();
protected:
- /*virtual*/ BOOL getMetadata(LLImageJ2C &base);
- /*virtual*/ BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count);
- /*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0,
+ virtual BOOL getMetadata(LLImageJ2C &base);
+ virtual BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count);
+ virtual BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0,
BOOL reversible = FALSE);
- /*virtual*/ BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL);
- /*virtual*/ BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1, int levels = 0);
+ virtual BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL);
+ virtual BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1, int levels = 0);
+ virtual std::string getEngineInfo() const;
};
#endif
diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp
index 90b8d10ecc..0906fc894e 100644
--- a/indra/llkdu/llimagej2ckdu.cpp
+++ b/indra/llkdu/llimagej2ckdu.cpp
@@ -72,21 +72,15 @@ private:
//
void set_default_colour_weights(kdu_params *siz);
+// Factory function: see declaration in llimagej2c.cpp
LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl()
{
return new LLImageJ2CKDU();
}
-void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl)
+std::string LLImageJ2CKDU::getEngineInfo() const
{
- delete impl;
- impl = NULL;
-}
-
-const char* fallbackEngineInfoLLImageJ2CImpl()
-{
- static std::string version = llformat("KDU %s", KDU_CORE_VERSION);
- return version.c_str();
+ return llformat("KDU %s", KDU_CORE_VERSION);
}
class LLKDUDecodeState
diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h
index b123a6dd52..85dc408d4d 100644
--- a/indra/llkdu/llimagej2ckdu.h
+++ b/indra/llkdu/llimagej2ckdu.h
@@ -65,12 +65,13 @@ public:
virtual ~LLImageJ2CKDU();
protected:
- /*virtual*/ BOOL getMetadata(LLImageJ2C &base);
- /*virtual*/ BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count);
- /*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0,
+ virtual BOOL getMetadata(LLImageJ2C &base);
+ virtual BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count);
+ virtual BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0,
BOOL reversible=FALSE);
- /*virtual*/ BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL);
- /*virtual*/ BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1, int levels = 0);
+ virtual BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL);
+ virtual BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1, int levels = 0);
+ virtual std::string getEngineInfo() const;
void findDiscardLevelsBoundaries(LLImageJ2C &base);
private: