summaryrefslogtreecommitdiff
path: root/indra/llkdu
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llkdu')
-rw-r--r--indra/llkdu/CMakeLists.txt8
-rw-r--r--indra/llkdu/include_kdu_xxxx.h40
-rw-r--r--indra/llkdu/llimagej2ckdu.cpp480
-rw-r--r--indra/llkdu/llimagej2ckdu.h94
-rw-r--r--indra/llkdu/llkdumem.cpp3
-rw-r--r--indra/llkdu/llkdumem.h36
-rw-r--r--indra/llkdu/tests/llimagej2ckdu_test.cpp67
7 files changed, 461 insertions, 267 deletions
diff --git a/indra/llkdu/CMakeLists.txt b/indra/llkdu/CMakeLists.txt
index b8f8b420c3..cb0e204e91 100644
--- a/indra/llkdu/CMakeLists.txt
+++ b/indra/llkdu/CMakeLists.txt
@@ -40,6 +40,14 @@ set_source_files_properties(${llkdu_HEADER_FILES}
list(APPEND llkdu_SOURCE_FILES ${llkdu_HEADER_FILES})
+# Our KDU package is built with KDU_X86_INTRINSICS in its .vcxproj file.
+# Unless that macro is also set for every consumer build, KDU freaks out,
+# spamming the viewer log with alignment FUD.
+set_source_files_properties(${llkdu_SOURCE_FILES}
+ PROPERTIES
+ COMPILE_DEFINITIONS
+ "KDU_X86_INTRINSICS")
+
if (USE_KDU)
add_library (llkdu ${llkdu_SOURCE_FILES})
diff --git a/indra/llkdu/include_kdu_xxxx.h b/indra/llkdu/include_kdu_xxxx.h
new file mode 100644
index 0000000000..a1dbced60b
--- /dev/null
+++ b/indra/llkdu/include_kdu_xxxx.h
@@ -0,0 +1,40 @@
+/**
+ * @file include_kdu_xxxx.h
+ * @author Nat Goodspeed
+ * @date 2016-04-25
+ * @brief
+ *
+ * $LicenseInfo:firstyear=2016&license=viewerlgpl$
+ * Copyright (c) 2016, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+// This file specifically omits #include guards of its own: it's sort of an
+// #include macro used to wrap KDU #includes with proper incantations. Usage:
+
+// #define kdu_xxxx "kdu_compressed.h" // or whichever KDU header
+// #include "include_kdu_xxxx.h"
+// // kdu_xxxx #undef'ed by include_kdu_xxxx.h
+
+#if LL_DARWIN
+// don't *really* want to rebuild KDU so turn off specific warnings for this header
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wself-assign-field"
+#pragma clang diagnostic ignored "-Wunused-private-field"
+#include kdu_xxxx
+#pragma clang diagnostic pop
+#elif LL_WINDOWS
+// With warnings-as-errors in effect, strange relationship between
+// jp2_output_box and its subclass jp2_target in kdu_compressed.h
+// causes build failures. Specifically:
+// warning C4263: 'void kdu_supp::jp2_target::open(kdu_supp::jp2_family_tgt *)' : member function does not override any base class virtual member function
+// warning C4264: 'void kdu_supp::jp2_output_box::open(kdu_core::kdu_uint32)' : no override available for virtual member function from base 'kdu_supp::jp2_output_box'; function is hidden
+#pragma warning(push)
+#pragma warning(disable : 4263 4264)
+#include kdu_xxxx
+#pragma warning(pop)
+#else // some other platform
+#include kdu_xxxx
+#endif
+
+#undef kdu_xxxx
diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp
index 282c859e9e..cb29da8f5f 100644
--- a/indra/llkdu/llimagej2ckdu.cpp
+++ b/indra/llkdu/llimagej2ckdu.cpp
@@ -1,4 +1,4 @@
- /**
+/**
* @file llimagej2ckdu.cpp
* @brief This is an implementation of JPEG2000 encode/decode using Kakadu
*
@@ -25,6 +25,7 @@
*/
#include "linden_common.h"
+
#include "llimagej2ckdu.h"
#include "lltimer.h"
@@ -32,12 +33,75 @@
#include "llmath.h"
#include "llkdumem.h"
-#include "kdu_block_coding.h"
+#define kdu_xxxx "kdu_block_coding.h"
+#include "include_kdu_xxxx.h"
+
+// Avoid ubiquitous necessity of kdu_core:: qualification
+using namespace kdu_core;
+
+#include "llexception.h"
+#include <boost/exception/diagnostic_information.hpp>
+#include <sstream>
+#include <iomanip>
+
+// stream kdu_dims to std::ostream
+// Turns out this must NOT be in the anonymous namespace!
+// It must also precede #include "stringize.h".
+inline
+std::ostream& operator<<(std::ostream& out, const kdu_dims& dims)
+{
+ return out << "(" << dims.pos.x << "," << dims.pos.y << "),"
+ "[" << dims.size.x << "x" << dims.size.y << "]";
+}
+
+#include "stringize.h"
+
+namespace {
+// Failure to load an image shouldn't crash the whole viewer.
+struct KDUError: public LLContinueError
+{
+ KDUError(const std::string& msg): LLContinueError(msg) {}
+};
+
+// KDU defines int error codes as hex values, so we should log them in hex
+// so we can grep KDU headers for the hex. However those hex values
+// generally "happen" to encode big-endian multibyte character sequences,
+// e.g. KDU_ERROR_EXCEPTION is 0x6b647545: 'kduE'
+// But beware because KDU_NULL_EXCEPTION is simply 0 -- which doesn't
+// preclude somebody from throwing it.
+std::string report_kdu_exception(kdu_exception mb)
+{
+ std::ostringstream out;
+ // always report mb in hex
+ out << "kdu_exception " << std::hex << mb;
+
+ // Also display as many chars as are encoded in the kdu_exception
+ // value. Make a char array; reserve 1 extra byte for nul terminator.
+ char bytes[sizeof(kdu_exception) + 1];
+ // Back up through 'bytes'
+ char *bptr = bytes + sizeof(bytes);
+ *(--bptr) = '\0';
+ while (mb)
+ {
+ // store low-order byte of mb in next-left char
+ *(--bptr) = char(mb & 0xFF);
+ // then shift mb right by one byte
+ mb >>= 8;
+ }
+ // did that produce any characters?
+ if (*bptr)
+ {
+ out << " (" << bptr << ')';
+ }
+
+ return out.str();
+}
+} // anonymous namespace
class kdc_flow_control {
public:
- kdc_flow_control(kdu_image_in_base *img_in, kdu_codestream codestream);
+ kdc_flow_control(kdu_supp::kdu_image_in_base *img_in, kdu_codestream codestream);
~kdc_flow_control();
bool advance_components();
void process_components();
@@ -46,7 +110,7 @@ private:
struct kdc_component_flow_control {
public:
- kdu_image_in_base *reader;
+ kdu_supp::kdu_image_in_base *reader;
int vert_subsampling;
int ratio_counter; /* Initialized to 0, decremented by `count_delta';
when < 0, a new line must be processed, after
@@ -72,49 +136,28 @@ private:
//
void set_default_colour_weights(kdu_params *siz);
-const char* engineInfoLLImageJ2CKDU()
-{
- static std::string version = llformat("KDU %s", KDU_CORE_VERSION);
- return version.c_str();
-}
-
-LLImageJ2CKDU* createLLImageJ2CKDU()
-{
- return new LLImageJ2CKDU();
-}
-
-void destroyLLImageJ2CKDU(LLImageJ2CKDU* kdu)
-{
- delete kdu;
- kdu = NULL;
-}
-
+// Factory function: see declaration in llimagej2c.cpp
LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl()
{
return new LLImageJ2CKDU();
}
-void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl)
-{
- delete impl;
- impl = NULL;
-}
-
-const char* fallbackEngineInfoLLImageJ2CImpl()
+std::string LLImageJ2CKDU::getEngineInfo() const
{
- return engineInfoLLImageJ2CKDU();
+ return llformat("KDU %s", KDU_CORE_VERSION);
}
class LLKDUDecodeState
{
public:
- LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap);
+ LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap,
+ kdu_codestream* codestreamp);
~LLKDUDecodeState();
- BOOL processTileDecode(F32 decode_time, BOOL limit_time = TRUE);
+ bool processTileDecode(F32 decode_time, bool limit_time = true);
private:
S32 mNumComponents;
- BOOL mUseYCC;
+ bool mUseYCC;
kdu_dims mDims;
kdu_sample_allocator mAllocator;
kdu_tile_comp mComps[4];
@@ -128,74 +171,91 @@ private:
S32 mRowGap;
};
-void ll_kdu_error( void )
-{
- // *FIX: This exception is bad, bad, bad. It gets thrown from a
- // destructor which can lead to immediate program termination!
- throw "ll_kdu_error() throwing an exception";
-}
-
// Stuff for new kdu error handling
-class LLKDUMessageWarning : public kdu_message
+class LLKDUMessage: public kdu_message
{
public:
- /*virtual*/ void put_text(const char *s);
- /*virtual*/ void put_text(const kdu_uint16 *s);
-
- static LLKDUMessageWarning sDefaultMessage;
-};
+ LLKDUMessage(const std::string& type):
+ mType(type)
+ {}
-class LLKDUMessageError : public kdu_message
-{
-public:
- /*virtual*/ void put_text(const char *s);
- /*virtual*/ void put_text(const kdu_uint16 *s);
- /*virtual*/ void flush(bool end_of_message = false);
- static LLKDUMessageError sDefaultMessage;
-};
-
-void LLKDUMessageWarning::put_text(const char *s)
-{
- LL_INFOS() << "KDU Warning: " << s << LL_ENDL;
-}
+ virtual void put_text(const char *s)
+ {
+ LL_INFOS() << "KDU " << mType << ": " << s << LL_ENDL;
+ }
-void LLKDUMessageWarning::put_text(const kdu_uint16 *s)
-{
- LL_INFOS() << "KDU Warning: " << s << LL_ENDL;
-}
+ virtual void put_text(const kdu_uint16 *s)
+ {
+ // The previous implementation simply streamed 's' to the log. So
+ // either this put_text() override was never called -- or it produced
+ // some baffling log messages -- because I assert that streaming a
+ // const kdu_uint16* to a std::ostream will display only the hex value
+ // of the pointer.
+ LL_INFOS() << "KDU " << mType << ": "
+ << utf16str_to_utf8str(llutf16string(s)) << LL_ENDL;
+ }
-void LLKDUMessageError::put_text(const char *s)
-{
- LL_INFOS() << "KDU Error: " << s << LL_ENDL;
-}
+private:
+ std::string mType;
+};
-void LLKDUMessageError::put_text(const kdu_uint16 *s)
+struct LLKDUMessageWarning : public LLKDUMessage
{
- LL_INFOS() << "KDU Error: " << s << LL_ENDL;
-}
+ LLKDUMessageWarning():
+ LLKDUMessage("Warning")
+ {
+ kdu_customize_warnings(this);
+ }
+};
+// Instantiating LLKDUMessageWarning calls kdu_customize_warnings() with the
+// new instance. Make it static so this only happens once.
+static LLKDUMessageWarning sWarningHandler;
-void LLKDUMessageError::flush(bool end_of_message)
+struct LLKDUMessageError : public LLKDUMessage
{
- if (end_of_message)
+ LLKDUMessageError():
+ LLKDUMessage("Error")
{
- throw "KDU throwing an exception";
+ kdu_customize_errors(this);
}
-}
-LLKDUMessageWarning LLKDUMessageWarning::sDefaultMessage;
-LLKDUMessageError LLKDUMessageError::sDefaultMessage;
-static bool kdu_message_initialized = false;
+ virtual void flush(bool end_of_message = false)
+ {
+ // According to the documentation nat found:
+ // http://pirlwww.lpl.arizona.edu/resources/guide/software/Kakadu/html_pages/globals__kdu$mize_errors.html
+ // "If a kdu_error object is destroyed, handler→flush will be called with
+ // an end_of_message argument equal to true and the process will
+ // subsequently be terminated through exit. The termination may be
+ // avoided, however, by throwing an exception from within the message
+ // terminating handler→flush call."
+ // So throwing an exception here isn't arbitrary: we MUST throw an
+ // exception if we want to recover from a KDU error.
+ // Because this confused me: the above quote specifically refers to
+ // the kdu_error class, which is constructed internally within KDU at
+ // the point where a fatal error is discovered and reported. It is NOT
+ // talking about the kdu_message subclass passed to
+ // kdu_customize_errors(). Destroying this static object at program
+ // shutdown will NOT engage the behavior described above.
+ if (end_of_message)
+ {
+ LLTHROW(KDUError("LLKDUMessageError::flush()"));
+ }
+ }
+};
+// Instantiating LLKDUMessageError calls kdu_customize_errors() with the new
+// instance. Make it static so this only happens once.
+static LLKDUMessageError sErrorHandler;
LLImageJ2CKDU::LLImageJ2CKDU() : LLImageJ2CImpl(),
-mInputp(NULL),
-mCodeStreamp(NULL),
-mTPosp(NULL),
-mTileIndicesp(NULL),
-mRawImagep(NULL),
-mDecodeState(NULL),
-mBlocksSize(-1),
-mPrecinctsSize(-1),
-mLevels(0)
+ mInputp(),
+ mCodeStreamp(),
+ mTPosp(),
+ mTileIndicesp(),
+ mRawImagep(NULL),
+ mDecodeState(),
+ mBlocksSize(-1),
+ mPrecinctsSize(-1),
+ mLevels(0)
{
}
@@ -207,7 +267,11 @@ LLImageJ2CKDU::~LLImageJ2CKDU()
// Stuff for new simple decode
void transfer_bytes(kdu_byte *dest, kdu_line_buf &src, int gap, int precision);
-void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECodeStreamMode mode)
+// This is called by the real (private) initDecode() (keep_codestream true)
+// and getMetadata() methods (keep_codestream false). As far as nat can tell,
+// mode is always MODE_FAST. It was called by findDiscardLevelsBoundaries()
+// as well, when that still existed, with keep_codestream true and MODE_FAST.
+void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECodeStreamMode mode)
{
S32 data_size = base.getDataSize();
S32 max_bytes = (base.getMaxBytes() ? base.getMaxBytes() : data_size);
@@ -215,38 +279,33 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod
//
// Initialization
//
- if (!kdu_message_initialized)
- {
- kdu_message_initialized = true;
- kdu_customize_errors(&LLKDUMessageError::sDefaultMessage);
- kdu_customize_warnings(&LLKDUMessageWarning::sDefaultMessage);
- }
-
- if (mCodeStreamp)
- {
- mCodeStreamp->destroy();
- delete mCodeStreamp;
- mCodeStreamp = NULL;
- }
-
+ mCodeStreamp.reset();
+
+ // It's not clear to nat under what circumstances we would reuse a
+ // pre-existing LLKDUMemSource instance. As of 2016-08-05, it consists of
+ // two U32s and a pointer, so it's not as if it would be a huge overhead
+ // to allocate a new one every time.
+ // Also -- why is base.getData() tested specifically here? If that returns
+ // NULL, shouldn't we bail out of the whole method?
if (!mInputp && base.getData())
{
// The compressed data has been loaded
// Setup the source for the codestream
- mInputp = new LLKDUMemSource(base.getData(), data_size);
+ mInputp.reset(new LLKDUMemSource(base.getData(), data_size));
}
if (mInputp)
{
+ // This is LLKDUMemSource::reset(), not boost::scoped_ptr::reset().
mInputp->reset();
}
- mCodeStreamp = new kdu_codestream;
- mCodeStreamp->create(mInputp);
+ mCodeStreamp->create(mInputp.get());
// Set the maximum number of bytes to use from the codestream
- // *TODO: This seems to be wrong. The base class should have no idea of how j2c compression works so no
- // good way of computing what's the byte range to be used.
+ // *TODO: This seems to be wrong. The base class should have no idea of
+ // how j2c compression works so no good way of computing what's the byte
+ // range to be used.
mCodeStreamp->set_max_bytes(max_bytes,true);
// If you want to flip or rotate the image for some reason, change
@@ -284,13 +343,19 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod
S32 components = mCodeStreamp->get_num_components();
- if (components >= 3)
- { // Check that components have consistent dimensions (for PPM file)
- kdu_dims dims1; mCodeStreamp->get_dims(1,dims1);
- kdu_dims dims2; mCodeStreamp->get_dims(2,dims2);
- if ((dims1 != dims) || (dims2 != dims))
+ // Check that components have consistent dimensions (for PPM file)
+ for (int idx = 1; idx < components; ++idx)
+ {
+ kdu_dims other_dims;
+ mCodeStreamp->get_dims(idx, other_dims);
+ if (other_dims != dims)
{
- LL_ERRS() << "Components don't have matching dimensions!" << LL_ENDL;
+ // This method is only called from methods that catch KDUError.
+ // We want to fail the image load, not crash the viewer.
+ LLTHROW(KDUError(STRINGIZE("Component " << idx << " dimensions "
+ << stringize(other_dims)
+ << " do not match component 0 dimensions "
+ << stringize(dims) << "!")));
}
}
@@ -303,42 +368,29 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod
if (!keep_codestream)
{
- mCodeStreamp->destroy();
- delete mCodeStreamp;
- mCodeStreamp = NULL;
- delete mInputp;
- mInputp = NULL;
+ mCodeStreamp.reset();
+ mInputp.reset();
}
}
void LLImageJ2CKDU::cleanupCodeStream()
{
- delete mInputp;
- mInputp = NULL;
-
- delete mDecodeState;
- mDecodeState = NULL;
-
- if (mCodeStreamp)
- {
- mCodeStreamp->destroy();
- delete mCodeStreamp;
- mCodeStreamp = NULL;
- }
-
- delete mTPosp;
- mTPosp = NULL;
-
- delete mTileIndicesp;
- mTileIndicesp = NULL;
+ mInputp.reset();
+ mDecodeState.reset();
+ mCodeStreamp.reset();
+ mTPosp.reset();
+ mTileIndicesp.reset();
}
-BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level, int* region)
+// This is the protected virtual method called by LLImageJ2C::initDecode().
+// However, as far as nat can tell, LLImageJ2C::initDecode() is called only by
+// llimage_libtest.cpp's load_image() function. No detectable production use.
+bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level, int* region)
{
return initDecode(base,raw_image,0.0f,MODE_FAST,0,4,discard_level,region);
}
-BOOL LLImageJ2CKDU::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size, int precincts_size, int levels)
+bool LLImageJ2CKDU::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size, int precincts_size, int levels)
{
mPrecinctsSize = precincts_size;
if (mPrecinctsSize != -1)
@@ -362,10 +414,13 @@ BOOL LLImageJ2CKDU::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int bloc
mLevels = llclamp(mLevels,MIN_DECOMPOSITION_LEVELS,MAX_DECOMPOSITION_LEVELS);
base.setLevels(mLevels);
}
- return TRUE;
+ return true;
}
-BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level, int* region)
+// This is the real (private) initDecode() called both by the protected
+// initDecode() method and by decodeImpl(). As far as nat can tell, only the
+// decodeImpl() usage matters for production.
+bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level, int* region)
{
base.resetLastError();
@@ -377,7 +432,7 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
//findDiscardLevelsBoundaries(base);
base.updateRawDiscardLevel();
- setupCodeStream(base, TRUE, mode);
+ setupCodeStream(base, true, mode);
mRawImagep = &raw_image;
mCodeStreamp->change_appearance(false, true, false);
@@ -412,45 +467,55 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
if (!mTileIndicesp)
{
- mTileIndicesp = new kdu_dims;
+ mTileIndicesp.reset(new kdu_dims);
}
mCodeStreamp->get_valid_tiles(*mTileIndicesp);
if (!mTPosp)
{
- mTPosp = new kdu_coords;
+ mTPosp.reset(new kdu_coords);
mTPosp->y = 0;
mTPosp->x = 0;
}
}
- catch (const char* msg)
+ catch (const KDUError& msg)
{
- base.setLastError(ll_safe_string(msg));
- return FALSE;
+ base.setLastError(msg.what());
+ return false;
+ }
+ catch (kdu_exception kdu_value)
+ {
+ // KDU internally throws kdu_exception. It's possible that such an
+ // exception might leak out into our code. Catch kdu_exception
+ // specially because boost::current_exception_diagnostic_information()
+ // could do nothing with it.
+ base.setLastError(report_kdu_exception(kdu_value));
+ return false;
}
catch (...)
{
- base.setLastError("Unknown J2C error");
- return FALSE;
+ base.setLastError("Unknown J2C error: " +
+ boost::current_exception_diagnostic_information());
+ return false;
}
- return TRUE;
+ return true;
}
-// Returns TRUE to mean done, whether successful or not.
-BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count)
+// Returns true to mean done, whether successful or not.
+bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count)
{
ECodeStreamMode mode = MODE_FAST;
LLTimer decode_timer;
- if (!mCodeStreamp)
+ if (!mCodeStreamp->exists())
{
if (!initDecode(base, raw_image, decode_time, mode, first_channel, max_channel_count))
{
// Initializing the J2C decode failed, bail out.
cleanupCodeStream();
- return TRUE; // done
+ return true; // done
}
}
@@ -460,6 +525,13 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
// Now we are ready to walk through the tiles processing them one-by-one.
kdu_byte *buffer = raw_image.getData();
+ if (!buffer)
+ {
+ base.setLastError("Memory error");
+ base.decodeFailed();
+ cleanupCodeStream();
+ return true; // done
+ }
while (mTPosp->y < mTileIndicesp->size.y)
{
@@ -495,36 +567,48 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
kdu_coords offset = tile_dims.pos - dims.pos;
int row_gap = channels*dims.size.x; // inter-row separation
kdu_byte *buf = buffer + offset.y*row_gap + offset.x*channels;
- mDecodeState = new LLKDUDecodeState(tile, buf, row_gap);
+ mDecodeState.reset(new LLKDUDecodeState(tile, buf, row_gap,
+ mCodeStreamp.get()));
}
// Do the actual processing
F32 remaining_time = decode_time - decode_timer.getElapsedTimeF32();
// This is where we do the actual decode. If we run out of time, return false.
if (mDecodeState->processTileDecode(remaining_time, (decode_time > 0.0f)))
{
- delete mDecodeState;
- mDecodeState = NULL;
+ mDecodeState.reset();
}
else
{
// Not finished decoding yet.
// setLastError("Ran out of time while decoding");
- return FALSE;
+ return false;
}
}
- catch (const char* msg)
+ catch (const KDUError& msg)
{
- base.setLastError(ll_safe_string(msg));
+ base.setLastError(msg.what());
base.decodeFailed();
cleanupCodeStream();
- return TRUE; // done
+ return true; // done
+ }
+ catch (kdu_exception kdu_value)
+ {
+ // KDU internally throws kdu_exception. It's possible that such an
+ // exception might leak out into our code. Catch kdu_exception
+ // specially because boost::current_exception_diagnostic_information()
+ // could do nothing with it.
+ base.setLastError(report_kdu_exception(kdu_value));
+ base.decodeFailed();
+ cleanupCodeStream();
+ return true; // done
}
catch (...)
{
- base.setLastError( "Unknown J2C error" );
+ base.setLastError("Unknown J2C error: " +
+ boost::current_exception_diagnostic_information());
base.decodeFailed();
cleanupCodeStream();
- return TRUE; // done
+ return true; // done
}
@@ -536,11 +620,11 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
cleanupCodeStream();
- return TRUE;
+ return true;
}
-BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time, BOOL reversible)
+bool LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time, bool reversible)
{
// Declare and set simple arguments
bool transpose = false;
@@ -705,39 +789,59 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co
base.updateData(); // set width, height
delete[] output_buffer;
}
- catch(const char* msg)
+ catch(const KDUError& msg)
{
- base.setLastError(ll_safe_string(msg));
- return FALSE;
+ base.setLastError(msg.what());
+ return false;
+ }
+ catch (kdu_exception kdu_value)
+ {
+ // KDU internally throws kdu_exception. It's possible that such an
+ // exception might leak out into our code. Catch kdu_exception
+ // specially because boost::current_exception_diagnostic_information()
+ // could do nothing with it.
+ base.setLastError(report_kdu_exception(kdu_value));
+ return false;
}
catch( ... )
{
- base.setLastError( "Unknown J2C error" );
- return FALSE;
+ base.setLastError("Unknown J2C error: " +
+ boost::current_exception_diagnostic_information());
+ return false;
}
- return TRUE;
+ return true;
}
-BOOL LLImageJ2CKDU::getMetadata(LLImageJ2C &base)
+bool LLImageJ2CKDU::getMetadata(LLImageJ2C &base)
{
// *FIX: kdu calls our callback function if there's an error, and
// then bombs. To regain control, we throw an exception, and
// catch it here.
try
{
- setupCodeStream(base, FALSE, MODE_FAST);
- return TRUE;
+ setupCodeStream(base, false, MODE_FAST);
+ return true;
}
- catch (const char* msg)
+ catch (const KDUError& msg)
{
- base.setLastError(ll_safe_string(msg));
- return FALSE;
+ base.setLastError(msg.what());
+ return false;
+ }
+ catch (kdu_exception kdu_value)
+ {
+ // KDU internally throws kdu_exception. It's possible that such an
+ // exception might leak out into our code. Catch kdu_exception
+ // specially because boost::current_exception_diagnostic_information()
+ // could do nothing with it.
+ base.setLastError(report_kdu_exception(kdu_value));
+ return false;
}
catch (...)
{
- base.setLastError( "Unknown J2C error" );
- return FALSE;
+ base.setLastError("Unknown J2C error: " +
+ boost::current_exception_diagnostic_information());
+ return false;
}
}
@@ -745,6 +849,8 @@ BOOL LLImageJ2CKDU::getMetadata(LLImageJ2C &base)
/* STATIC copy_block */
/*****************************************************************************/
+/*==========================================================================*|
+// Only called by copy_tile(), which is itself commented out
static void copy_block(kdu_block *in, kdu_block *out)
{
if (in->K_max_prime != out->K_max_prime)
@@ -773,11 +879,14 @@ static void copy_block(kdu_block *in, kdu_block *out)
out->set_max_bytes(num_bytes,false);
memcpy(out->byte_buffer,in->byte_buffer,(size_t) num_bytes);
}
+|*==========================================================================*/
/*****************************************************************************/
/* STATIC copy_tile */
/*****************************************************************************/
+/*==========================================================================*|
+// Only called by findDiscardLevelsBoundaries(), which is itself commented out
static void
copy_tile(kdu_tile tile_in, kdu_tile tile_out, int tnum_in, int tnum_out,
kdu_params *siz_in, kdu_params *siz_out, int skip_components,
@@ -834,10 +943,13 @@ copy_tile(kdu_tile tile_in, kdu_tile tile_out, int tnum_in, int tnum_out,
}
}
}
+|*==========================================================================*/
// Find the block boundary for each discard level in the input image.
// We parse the input blocks and copy them in a temporary output stream.
// For the moment, we do nothing more that parsing the raw list of blocks and outputing result.
+/*==========================================================================*|
+// See comments in header file for why this is commented out.
void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)
{
// We need the number of levels in that image before starting.
@@ -847,7 +959,7 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)
{
//std::cout << "Parsing discard level = " << discard_level << std::endl;
// Create the input codestream object.
- setupCodeStream(base, TRUE, MODE_FAST);
+ setupCodeStream(base, true, MODE_FAST);
mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, NULL);
mCodeStreamp->set_max_bytes(KDU_LONG_MAX,true);
siz_params *siz_in = mCodeStreamp->access_siz();
@@ -941,6 +1053,7 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)
}
return;
}
+|*==========================================================================*/
void set_default_colour_weights(kdu_params *siz)
{
@@ -1143,7 +1256,8 @@ all necessary level shifting, type conversion, rounding and truncation. */
}
}
-LLKDUDecodeState::LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap)
+LLKDUDecodeState::LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap,
+ kdu_codestream* codestreamp)
{
S32 c;
@@ -1189,7 +1303,7 @@ LLKDUDecodeState::LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap)
mEngines[c] = kdu_synthesis(res,&mAllocator,use_shorts);
}
}
- mAllocator.finalize(); // Actually creates buffering resources
+ mAllocator.finalize(*codestreamp); // Actually creates buffering resources
for (c = 0; c < mNumComponents; c++)
{
mLines[c].create(); // Grabs resources from the allocator.
@@ -1206,7 +1320,7 @@ LLKDUDecodeState::~LLKDUDecodeState()
mTile.close();
}
-BOOL LLKDUDecodeState::processTileDecode(F32 decode_time, BOOL limit_time)
+bool LLKDUDecodeState::processTileDecode(F32 decode_time, bool limit_time)
/* Decompresses a tile, writing the data into the supplied byte buffer.
The buffer contains interleaved image components, if there are any.
Although you may think of the buffer as belonging entirely to this tile,
@@ -1238,16 +1352,16 @@ separation between consecutive rows in the real buffer. */
{
if (limit_time && decode_timer.getElapsedTimeF32() > decode_time)
{
- return FALSE;
+ return false;
}
}
}
- return TRUE;
+ return true;
}
// kdc_flow_control
-kdc_flow_control::kdc_flow_control (kdu_image_in_base *img_in, kdu_codestream codestream)
+kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_codestream codestream)
{
int n;
diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h
index 02281152bf..b57e4cc40e 100644
--- a/indra/llkdu/llimagej2ckdu.h
+++ b/indra/llkdu/llimagej2ckdu.h
@@ -37,17 +37,12 @@
#include "kdu_messaging.h"
#include "kdu_params.h"
-// don't *really* want to rebuild KDU so turn off specific warnings for this header
-#if LL_DARWIN
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-private-field"
-#include "kdu_compressed.h"
-#pragma clang diagnostic pop
-#else
-#include "kdu_compressed.h"
-#endif
+#define kdu_xxxx "kdu_compressed.h"
+#include "include_kdu_xxxx.h"
#include "kdu_sample_processing.h"
+#include <boost/scoped_ptr.hpp>
+#include <boost/noncopyable.hpp>
class LLKDUDecodeState;
class LLKDUMemSource;
@@ -65,43 +60,72 @@ 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,
- 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);
- void findDiscardLevelsBoundaries(LLImageJ2C &base);
+ 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 std::string getEngineInfo() const;
private:
- BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level = -1, int* region = NULL);
- void setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECodeStreamMode mode);
+ bool initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level = -1, int* region = NULL);
+ void setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECodeStreamMode mode);
void cleanupCodeStream();
+ // This method was public, but the only call to it is commented out in our
+ // own initDecode() method. I (nat 2016-08-04) don't know what it does or
+ // why. Even if it should be uncommented, it should probably still be
+ // private.
+// void findDiscardLevelsBoundaries(LLImageJ2C &base);
+
+ // Helper class to hold a kdu_codestream, which is a handle to the
+ // underlying implementation object. When CodeStreamHolder is reset() or
+ // destroyed, it calls kdu_codestream::destroy() -- which kdu_codestream
+ // itself does not.
+ //
+ // Call through it like a smart pointer using operator->().
+ //
+ // Every RAII class must be noncopyable. For this we don't need move
+ // support.
+ class CodeStreamHolder: public boost::noncopyable
+ {
+ public:
+ ~CodeStreamHolder()
+ {
+ reset();
+ }
+
+ void reset()
+ {
+ if (mCodeStream.exists())
+ {
+ mCodeStream.destroy();
+ }
+ }
+
+ // for those few times when you need a raw kdu_codestream*
+ kdu_core::kdu_codestream* get() { return &mCodeStream; }
+ kdu_core::kdu_codestream* operator->() { return &mCodeStream; }
+
+ private:
+ kdu_core::kdu_codestream mCodeStream;
+ };
+
// Encode variable
- LLKDUMemSource *mInputp;
- kdu_codestream *mCodeStreamp;
- kdu_coords *mTPosp; // tile position
- kdu_dims *mTileIndicesp;
+ boost::scoped_ptr<LLKDUMemSource> mInputp;
+ CodeStreamHolder mCodeStreamp;
+ boost::scoped_ptr<kdu_core::kdu_coords> mTPosp; // tile position
+ boost::scoped_ptr<kdu_core::kdu_dims> mTileIndicesp;
int mBlocksSize;
int mPrecinctsSize;
int mLevels;
// Temporary variables for in-progress decodes...
+ // We don't own this LLImageRaw. We're simply pointing to an instance
+ // passed into initDecode().
LLImageRaw *mRawImagep;
- LLKDUDecodeState *mDecodeState;
+ boost::scoped_ptr<LLKDUDecodeState> mDecodeState;
};
-#if LL_WINDOWS
-# define LLSYMEXPORT __declspec(dllexport)
-#elif LL_LINUX
-# define LLSYMEXPORT __attribute__ ((visibility("default")))
-#else
-# define LLSYMEXPORT
-#endif
-
-extern "C" LLSYMEXPORT const char* engineInfoLLImageJ2CKDU();
-extern "C" LLSYMEXPORT LLImageJ2CKDU* createLLImageJ2CKDU();
-extern "C" LLSYMEXPORT void destroyLLImageJ2CKDU(LLImageJ2CKDU* kdu);
-
#endif
diff --git a/indra/llkdu/llkdumem.cpp b/indra/llkdu/llkdumem.cpp
index 0347475559..96e9da25d8 100644
--- a/indra/llkdu/llkdumem.cpp
+++ b/indra/llkdu/llkdumem.cpp
@@ -28,6 +28,9 @@
#include "llkdumem.h"
#include "llerror.h"
+using namespace kdu_core;
+using kd_supp_image_local::image_line_buf;
+
#if defined(LL_WINDOWS)
# pragma warning(disable: 4702) // unreachable code
#endif
diff --git a/indra/llkdu/llkdumem.h b/indra/llkdu/llkdumem.h
index fab913d93b..09d81f38de 100644
--- a/indra/llkdu/llkdumem.h
+++ b/indra/llkdu/llkdumem.h
@@ -29,26 +29,22 @@
// Support classes for reading and writing from memory buffers in KDU
#define KDU_NO_THREADS
-// don't *really* want to rebuild KDU so turn off specific warnings for this header
-#if LL_DARWIN
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wself-assign-field"
-#pragma clang diagnostic ignored "-Wunused-private-field"
-#include "kdu_image.h"
-#pragma clang diagnostic pop
-#else
-#include "kdu_image.h"
-#endif
+
+#define kdu_xxxx "kdu_image.h"
+#include "include_kdu_xxxx.h"
#include "kdu_elementary.h"
#include "kdu_messaging.h"
#include "kdu_params.h"
-#include "kdu_compressed.h"
+
+#define kdu_xxxx "kdu_compressed.h"
+#include "include_kdu_xxxx.h"
+
#include "kdu_sample_processing.h"
#include "image_local.h"
#include "stdtypes.h"
-class LLKDUMemSource: public kdu_compressed_source
+class LLKDUMemSource: public kdu_core::kdu_compressed_source
{
public:
LLKDUMemSource(U8 *input_buffer, U32 size)
@@ -62,7 +58,7 @@ public:
{
}
- int read(kdu_byte *buf, int num_bytes)
+ int read(kdu_core::kdu_byte *buf, int num_bytes)
{
U32 num_out;
num_out = num_bytes;
@@ -87,7 +83,7 @@ private:
U32 mCurPos;
};
-class LLKDUMemTarget: public kdu_compressed_target
+class LLKDUMemTarget: public kdu_core::kdu_compressed_target
{
public:
LLKDUMemTarget(U8 *output_buffer, U32 &output_size, const U32 buffer_size)
@@ -102,7 +98,7 @@ public:
{
}
- bool write(const kdu_byte *buf, int num_bytes)
+ bool write(const kdu_core::kdu_byte *buf, int num_bytes)
{
U32 num_out;
num_out = num_bytes;
@@ -126,7 +122,7 @@ private:
U32 *mOutputSize;
};
-class LLKDUMemIn : public kdu_image_in_base
+class LLKDUMemIn : public kdu_supp::kdu_image_in_base
{
public:
LLKDUMemIn(const U8 *data,
@@ -134,10 +130,10 @@ public:
const U16 rows,
const U16 cols,
U8 in_num_components,
- siz_params *siz);
+ kdu_core::siz_params *siz);
~LLKDUMemIn();
- bool get(int comp_idx, kdu_line_buf &line, int x_tnum);
+ bool get(int comp_idx, kdu_core::kdu_line_buf &line, int x_tnum);
private:
const U8 *mData;
@@ -146,8 +142,8 @@ private:
int rows, cols;
int alignment_bytes; // Number of 0's at end of each line.
int precision[3];
- image_line_buf *incomplete_lines; // Each "sample" represents a full pixel
- image_line_buf *free_lines;
+ kd_supp_image_local::image_line_buf *incomplete_lines; // Each "sample" represents a full pixel
+ kd_supp_image_local::image_line_buf *free_lines;
int num_unread_rows;
U32 mCurPos;
diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp
index 0605fad068..e386a9f71b 100644
--- a/indra/llkdu/tests/llimagej2ckdu_test.cpp
+++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp
@@ -30,6 +30,7 @@
#include "llimagej2ckdu.h"
#if LL_DARWIN
+// For this source, it's true that private fields in llkdumem.h are unused.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#include "llkdumem.h"
@@ -37,7 +38,6 @@
#else
#include "llkdumem.h"
#endif
-
#include "kdu_block_coding.h"
// Tut header
#include "lltut.h"
@@ -60,7 +60,7 @@ LLImageRaw::~LLImageRaw() { }
U8* LLImageRaw::allocateData(S32 ) { return NULL; }
void LLImageRaw::deleteData() { }
U8* LLImageRaw::reallocateData(S32 ) { return NULL; }
-BOOL LLImageRaw::resize(U16, U16, S8) { return TRUE; } // this method always returns TRUE...
+bool LLImageRaw::resize(U16, U16, S8) { return true; } // this method always returns true...
LLImageBase::LLImageBase()
: LLTrace::MemTrackable<LLImageBase>("LLImageBase"),
@@ -89,8 +89,8 @@ LLImageFormatted::~LLImageFormatted() { }
U8* LLImageFormatted::allocateData(S32 ) { return NULL; }
S32 LLImageFormatted::calcDataSize(S32 ) { return 0; }
S32 LLImageFormatted::calcDiscardLevelBytes(S32 ) { return 0; }
-BOOL LLImageFormatted::decodeChannels(LLImageRaw*, F32, S32, S32) { return FALSE; }
-BOOL LLImageFormatted::copyData(U8 *, S32) { return TRUE; } // this method always returns TRUE...
+bool LLImageFormatted::decodeChannels(LLImageRaw*, F32, S32, S32) { return false; }
+bool LLImageFormatted::copyData(U8 *, S32) { return true; } // this method always returns true...
void LLImageFormatted::deleteData() { }
void LLImageFormatted::dump() { }
U8* LLImageFormatted::reallocateData(S32 ) { return NULL; }
@@ -103,27 +103,29 @@ LLImageJ2C::~LLImageJ2C() { }
S32 LLImageJ2C::calcDataSize(S32 ) { return 0; }
S32 LLImageJ2C::calcDiscardLevelBytes(S32 ) { return 0; }
S32 LLImageJ2C::calcHeaderSize() { return 0; }
-BOOL LLImageJ2C::decode(LLImageRaw*, F32) { return FALSE; }
-BOOL LLImageJ2C::decodeChannels(LLImageRaw*, F32, S32, S32 ) { return FALSE; }
+bool LLImageJ2C::decode(LLImageRaw*, F32) { return false; }
+bool LLImageJ2C::decodeChannels(LLImageRaw*, F32, S32, S32 ) { return false; }
void LLImageJ2C::decodeFailed() { }
-BOOL LLImageJ2C::encode(const LLImageRaw*, F32) { return FALSE; }
+bool LLImageJ2C::encode(const LLImageRaw*, F32) { return false; }
S8 LLImageJ2C::getRawDiscardLevel() { return 0; }
void LLImageJ2C::resetLastError() { }
void LLImageJ2C::setLastError(const std::string&, const std::string&) { }
-BOOL LLImageJ2C::updateData() { return FALSE; }
+bool LLImageJ2C::updateData() { return false; }
void LLImageJ2C::updateRawDiscardLevel() { }
-LLKDUMemIn::LLKDUMemIn(const U8*, const U32, const U16, const U16, const U8, siz_params*) { }
+LLKDUMemIn::LLKDUMemIn(const U8*, const U32, const U16, const U16, const U8, kdu_core::siz_params*) { }
LLKDUMemIn::~LLKDUMemIn() { }
-bool LLKDUMemIn::get(int, kdu_line_buf&, int) { return false; }
+bool LLKDUMemIn::get(int, kdu_core::kdu_line_buf&, int) { return false; }
// Stub Kakadu Library calls
+// they're all namespaced now
+namespace kdu_core {
kdu_tile_comp kdu_tile::access_component(int ) { kdu_tile_comp a; return a; }
kdu_block_encoder::kdu_block_encoder() { }
kdu_block_decoder::kdu_block_decoder() { }
void kdu_block::set_max_passes(int , bool ) { }
void kdu_block::set_max_bytes(int , bool ) { }
-void kdu_tile::close(kdu_thread_env* ) { }
+void kdu_tile::close(kdu_thread_env *, bool) {}
int kdu_tile::get_num_components() { return 0; }
bool kdu_tile::get_ycc() { return false; }
void kdu_tile::set_components_of_interest(int , const int* ) { }
@@ -156,14 +158,14 @@ void kdu_codestream::set_fussy() { }
void kdu_codestream::get_dims(int, kdu_dims&, bool ) { }
int kdu_codestream::get_min_dwt_levels() { return 5; }
int kdu_codestream::get_max_tile_layers() { return 1; }
-void kdu_codestream::change_appearance(bool, bool, bool) { }
+void kdu_codestream::change_appearance(bool, bool, bool, kdu_thread_env *) {}
void kdu_codestream::get_tile_dims(kdu_coords, int, kdu_dims&, bool ) { }
void kdu_codestream::destroy() { }
void kdu_codestream::collect_timing_stats(int ) { }
void kdu_codestream::set_max_bytes(kdu_long, bool, bool ) { }
void kdu_codestream::get_valid_tiles(kdu_dims& ) { }
void kdu_codestream::create(kdu_compressed_source*, kdu_thread_env*) { }
-void kdu_codestream::apply_input_restrictions( int, int, int, int, kdu_dims*, kdu_component_access_mode ) { }
+void kdu_codestream::apply_input_restrictions(int, int, int, int, kdu_dims const *, kdu_component_access_mode, kdu_thread_env *, kdu_quality_limiter const *) {}
void kdu_codestream::get_subsampling(int , kdu_coords&, bool ) { }
void kdu_codestream::flush(kdu_long *, int, kdu_uint16 *, bool, bool, double, kdu_thread_env*, int) { }
void kdu_codestream::set_resilient(bool ) { }
@@ -178,13 +180,15 @@ siz_params* kdu_codestream::access_siz() { return NULL; }
kdu_tile kdu_codestream::open_tile(kdu_coords , kdu_thread_env* ) { kdu_tile a; return a; }
kdu_codestream_comment kdu_codestream::add_comment() { kdu_codestream_comment a; return a; }
void kdu_subband::close_block(kdu_block*, kdu_thread_env*) { }
-void kdu_subband::get_valid_blocks(kdu_dims &indices) { }
-kdu_block* kdu_subband::open_block(kdu_coords, int*, kdu_thread_env*) { return NULL; }
+void kdu_subband::get_valid_blocks(kdu_dims &indices) const { }
+kdu_block * kdu_subband::open_block(kdu_coords, int *, kdu_thread_env *, int, bool) { return NULL; }
bool kdu_codestream_comment::put_text(const char*) { return false; }
void kdu_customize_warnings(kdu_message*) { }
void kdu_customize_errors(kdu_message*) { }
-kdu_long kdu_multi_analysis::create(kdu_codestream, kdu_tile, kdu_thread_env*, kdu_thread_queue*, int, kdu_roi_image*, int) { kdu_long a = 0; return a; }
+kdu_long kdu_multi_analysis::create(kdu_codestream, kdu_tile, kdu_thread_env *,kdu_thread_queue *, int, kdu_roi_image *, int, kdu_sample_allocator *, kdu_push_pull_params const *) { return kdu_long(0); }
+void kdu_multi_analysis::destroy(kdu_thread_env *) {}
siz_params::siz_params() : kdu_params(NULL, false, false, false, false, false) { }
+siz_params::~siz_params() {}
void siz_params::finalize(bool ) { }
void siz_params::copy_with_xforms(kdu_params*, int, int, bool, bool, bool) { }
int siz_params::write_marker_segment(kdu_output*, kdu_params*, int) { return 0; }
@@ -193,10 +197,15 @@ bool siz_params::read_marker_segment(kdu_uint16, int, kdu_byte a[], int) { retur
kdu_decoder::kdu_decoder(kdu_subband , kdu_sample_allocator*, bool , float, int, kdu_thread_env*, kdu_thread_queue*, int) { }
void kdu_codestream::create(siz_params*, kdu_compressed_target*, kdu_dims*, int, kdu_long, kdu_thread_env* ) { }
+kdu_sample_allocator::~kdu_sample_allocator() {}
+void kdu_sample_allocator::do_finalize(kdu_codestream) {}
void (*kdu_convert_ycc_to_rgb_rev16)(kdu_int16*,kdu_int16*,kdu_int16*,int);
void (*kdu_convert_ycc_to_rgb_irrev16)(kdu_int16*,kdu_int16*,kdu_int16*,int);
void (*kdu_convert_ycc_to_rgb_rev32)(kdu_int32*,kdu_int32*,kdu_int32*,int);
void (*kdu_convert_ycc_to_rgb_irrev32)(float*,float*,float*,int);
+bool kdu_core_sample_alignment_checker(int, int, int, int, bool, bool) { return false; }
+void kdu_pull_ifc::destroy() {}
+} // namespace kdu_core
// -------------------------------------------------------------------------------------------
// TUT
@@ -212,12 +221,12 @@ namespace tut
{
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)
+ 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)
+ bool callEncodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text)
{
return encodeImpl(base, raw_image, comment_text);
}
@@ -254,10 +263,10 @@ namespace tut
void llimagej2ckdu_object_t::test<1>()
{
LLImageJ2C* image = new LLImageJ2C();
- BOOL res = mImage->callGetMetadata(*image);
- // Trying to set up a data stream with all NIL values and stubbed KDU will "work" and return TRUE
- // Note that is linking with KDU, that call will throw an exception and fail, returning FALSE
- ensure("getMetadata() test failed", res == TRUE);
+ bool res = mImage->callGetMetadata(*image);
+ // Trying to set up a data stream with all NIL values and stubbed KDU will "work" and return true
+ // Note that is linking with KDU, that call will throw an exception and fail, returning false
+ ensure("getMetadata() test failed", res);
}
// Test 2 : test decodeImpl()
@@ -266,9 +275,9 @@ namespace tut
{
LLImageJ2C* image = new LLImageJ2C();
LLImageRaw* raw = new LLImageRaw();
- 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);
+ 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);
}
// Test 3 : test encodeImpl()
@@ -277,8 +286,8 @@ namespace tut
{
LLImageJ2C* image = new LLImageJ2C();
LLImageRaw* raw = new LLImageRaw();
- 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);
+ 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);
}
}