summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2010-12-24 11:36:15 -0800
committerMerov Linden <merov@lindenlab.com>2010-12-24 11:36:15 -0800
commit0c5bd3675babb0cbe6f3c7312350b71b8229e5d3 (patch)
treef5827f0e6d0222c2cc7d9ef908a6106f603a8ca3 /indra
parente874b156c5861226fcca9d7bfa7f6131790eaf0d (diff)
STORM-744 : Took code review into account, moving stuff back in protected or even private, fix things to work in debug mode, some clean up in j2coj also
Diffstat (limited to 'indra')
-rw-r--r--indra/llimagej2coj/llimagej2coj.cpp6
-rw-r--r--indra/llimagej2coj/llimagej2coj.h6
-rw-r--r--indra/llkdu/llimagej2ckdu.cpp2
-rw-r--r--indra/llkdu/llimagej2ckdu.h8
-rw-r--r--indra/llkdu/tests/llimagej2ckdu_test.cpp30
5 files changed, 35 insertions, 17 deletions
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp
index 95e0997d5b..13b12c0928 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -90,6 +90,12 @@ void info_callback(const char* msg, void*)
lldebugs << "LLImageJ2COJ: " << chomp(msg) << llendl;
}
+// Divide a by 2 to the power of b and round upwards
+int ceildivpow2(int a, int b)
+{
+ return (a + (1 << b) - 1) >> b;
+}
+
LLImageJ2COJ::LLImageJ2COJ()
: LLImageJ2CImpl()
diff --git a/indra/llimagej2coj/llimagej2coj.h b/indra/llimagej2coj/llimagej2coj.h
index 7edacbe97c..9476665ccb 100644
--- a/indra/llimagej2coj/llimagej2coj.h
+++ b/indra/llimagej2coj/llimagej2coj.h
@@ -34,17 +34,11 @@ class LLImageJ2COJ : public LLImageJ2CImpl
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,
BOOL reversible = FALSE);
- int ceildivpow2(int a, int b)
- {
- // Divide a by b to the power of 2 and round upwards.
- return (a + (1 << b) - 1) >> b;
- }
};
#endif
diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp
index 1a286d1406..efa75e4ebd 100644
--- a/indra/llkdu/llimagej2ckdu.cpp
+++ b/indra/llkdu/llimagej2ckdu.cpp
@@ -1017,7 +1017,7 @@ kdc_flow_control::kdc_flow_control (kdu_image_in_base *img_in, kdu_codestream co
comp->ratio_counter = 0;
comp->remaining_lines = comp->initial_lines = dims.size.y;
}
- assert(num_components > 0);
+ assert(num_components >= 0);
tile.set_components_of_interest(num_components);
max_buffer_memory = engine.create(codestream,tile,false,NULL,false,1,NULL,NULL,false);
diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h
index 86ca54491e..5628f69eeb 100644
--- a/indra/llkdu/llimagej2ckdu.h
+++ b/indra/llkdu/llimagej2ckdu.h
@@ -50,18 +50,16 @@ public:
MODE_RESILIENT = 1,
MODE_FUSSY = 2
};
-
-public:
LLImageJ2CKDU();
virtual ~LLImageJ2CKDU();
-
-public:
+
+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,
BOOL reversible=FALSE);
-protected:
+private:
void setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECodeStreamMode mode);
void cleanupCodeStream();
BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count );
diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp
index d02b51b6a1..5c567643a5 100644
--- a/indra/llkdu/tests/llimagej2ckdu_test.cpp
+++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp
@@ -50,7 +50,16 @@ void LLImageRaw::deleteData() { }
U8* LLImageRaw::reallocateData(S32 ) { return NULL; }
BOOL LLImageRaw::resize(U16, U16, S8) { return TRUE; } // this method always returns TRUE...
-LLImageBase::LLImageBase() : mMemType(LLMemType::MTYPE_IMAGEBASE) { }
+LLImageBase::LLImageBase()
+: mData(NULL),
+mDataSize(0),
+mWidth(0),
+mHeight(0),
+mComponents(0),
+mBadBufferAllocation(false),
+mAllowOverSize(false),
+mMemType(LLMemType::MTYPE_IMAGEBASE)
+{ }
LLImageBase::~LLImageBase() { }
U8* LLImageBase::allocateData(S32 ) { return NULL; }
void LLImageBase::deleteData() { }
@@ -165,6 +174,17 @@ namespace tut
// Derived test class
class LLTestImageJ2CKDU : public LLImageJ2CKDU
{
+ public:
+ // Provides public access to some protected methods for testing
+ BOOL callGetMetadata(LLImageJ2C &base) { return getMetadata(base); }
+ BOOL callDecodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count)
+ {
+ return decodeImpl(base, raw_image, decode_time, first_channel, max_channel_count);
+ }
+ BOOL callEncodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text)
+ {
+ return encodeImpl(base, raw_image, comment_text);
+ }
};
// Instance to be tested
LLTestImageJ2CKDU* mImage;
@@ -198,7 +218,7 @@ namespace tut
void llimagej2ckdu_object_t::test<1>()
{
LLImageJ2C* image = new LLImageJ2C();
- BOOL res = mImage->getMetadata(*image);
+ BOOL res = mImage->callGetMetadata(*image);
// Trying to set up a data stream with all NIL values will fail and return FALSE
ensure("getMetadata() test failed", res == FALSE);
}
@@ -209,7 +229,7 @@ namespace tut
{
LLImageJ2C* image = new LLImageJ2C();
LLImageRaw* raw = new LLImageRaw();
- BOOL res = mImage->decodeImpl(*image, *raw, 0.0, 0, 0);
+ BOOL res = mImage->callDecodeImpl(*image, *raw, 0.0, 0, 0);
// Decoding returns TRUE whenever there's nothing else to do, including if decoding failed, so we'll get TRUE here
ensure("decodeImpl() test failed", res == TRUE);
}
@@ -220,8 +240,8 @@ namespace tut
{
LLImageJ2C* image = new LLImageJ2C();
LLImageRaw* raw = new LLImageRaw();
- BOOL res = mImage->encodeImpl(*image, *raw, NULL);
- // Encoding returns TRUE unless and exception was raised, so we'll get TRUE here though nothing really was done
+ BOOL res = mImage->callEncodeImpl(*image, *raw, NULL);
+ // Encoding returns TRUE unless an exception was raised, so we'll get TRUE here though nothing really was done
ensure("encodeImpl() test failed", res == TRUE);
}
}