diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llkdu/llimagej2ckdu.cpp | 50 | ||||
-rw-r--r-- | indra/llkdu/llimagej2ckdu.h | 5 | ||||
-rw-r--r-- | indra/llkdu/llkdumem.cpp | 201 | ||||
-rw-r--r-- | indra/llkdu/llkdumem.h | 33 |
4 files changed, 20 insertions, 269 deletions
diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 21c91be1f7..1a286d1406 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -33,11 +33,13 @@ class kdc_flow_control { + public: // Member functions kdc_flow_control(kdu_image_in_base *img_in, kdu_codestream codestream); ~kdc_flow_control(); bool advance_components(); void process_components(); + private: // Data struct kdc_component_flow_control { @@ -58,7 +60,7 @@ private: // Data kdu_tile tile; int num_components; kdc_component_flow_control *components; - int count_delta; // Holds the minimum of the `vert_subsampling' fields. + int count_delta; // Holds the minimum of the `vert_subsampling' fields kdu_multi_analysis engine; kdu_long max_buffer_memory; }; @@ -132,11 +134,11 @@ public: void ll_kdu_error( void ) { // *FIX: This exception is bad, bad, bad. It gets thrown from a - // destructor which can lead imediate program termination! + // destructor which can lead to immediate program termination! throw "ll_kdu_error() throwing an exception"; } -// Stuff for new kdu error handling. +// Stuff for new kdu error handling class LLKDUMessageWarning : public kdu_message { public: @@ -210,7 +212,6 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod S32 data_size = base.getDataSize(); S32 max_bytes = base.getMaxBytes() ? base.getMaxBytes() : data_size; - ////////////// // // Initialization // @@ -228,11 +229,10 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod mCodeStreamp = NULL; } - if (!mInputp) { llassert(base.getData()); - // The compressed data has been loaded. + // The compressed data has been loaded // Setup the source for the codestrea mInputp = new LLKDUMemSource(base.getData(), data_size); } @@ -243,8 +243,7 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod mCodeStreamp->create(mInputp); - - // Set the maximum number of bytes to use from the codestrea + // Set the maximum number of bytes to use from the codestream mCodeStreamp->set_max_bytes(max_bytes); // If you want to flip or rotate the image for some reason, change @@ -257,11 +256,10 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod // can be decompressed multiple times, possibly with different appearance // parameters, you should call "kdu_codestream::set_persistent" here. // There are a variety of other features which must be enabled at - // this point if you want to take advantage of the See the + // this point if you want to take advantage of them. See the // descriptions appearing with the "kdu_codestream" interface functions // in "kdu_compressed.h" for an itemized account of these capabilities. - switch( mode ) { case MODE_FAST: @@ -338,27 +336,6 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco base.updateRawDiscardLevel(); setupCodeStream(base, TRUE, mode); - /* - // - // Not being used OpenJPEG doesn't support it, just deprecate it. - // - - // Find the Linden Lab comment in the chain of comments - kdu_codestream_comment comment; - comment = mCodeStreamp->get_comment(); - while (comment.get_text()) - { - const char* text = comment.get_text(); - if( text == strstr( text, LINDEN_J2C_COMMENT_PREFIX) ) - { - mCommentText = text; - break; - } - //llinfos << "CS comment: " << comment.get_text() << llendl; - comment = mCodeStreamp->get_comment(comment); - } - */ - mRawImagep = &raw_image; mCodeStreamp->change_appearance(false, true, false); mCodeStreamp->apply_input_restrictions(first_channel,max_channel_count,base.getRawDiscardLevel(),0,NULL); @@ -395,7 +372,6 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco return FALSE; } - return TRUE; } @@ -524,10 +500,9 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co try { // Set up input image files. - siz_params siz; + // Should set rate someplace here. - LLKDUMemIn mem_in(raw_image.getData(), raw_image.getDataSize(), raw_image.getWidth(), @@ -596,7 +571,6 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co num_layer_specs = 1; layer_bytes[0] = 0; } - else { // Rate is the argument passed into the LLImageJ2C which @@ -675,7 +649,6 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co delete record_stream; } - // Now that we're done encoding, create the new data buffer for the compressed // image and stick it there. @@ -717,10 +690,8 @@ BOOL LLImageJ2CKDU::getMetadata(LLImageJ2C &base) base.setLastError( "Unknown J2C error" ); return FALSE; } - } - void set_default_colour_weights(kdu_params *siz) { kdu_params *cod = siz->access_cluster(COD_params); @@ -776,7 +747,6 @@ void set_default_colour_weights(kdu_params *siz) "{0.8769},{0.9424},{0.9424},{1}"); } - /******************************************************************************/ /* transfer_bytes */ /******************************************************************************/ @@ -1088,7 +1058,9 @@ bool kdc_flow_control::advance_components() } } if (all_done) + { return false; + } } return true; } diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h index ac0443d8fc..03f289f8b1 100644 --- a/indra/llkdu/llimagej2ckdu.h +++ b/indra/llkdu/llimagej2ckdu.h @@ -30,9 +30,8 @@ #include "llimagej2c.h" // -// -// // KDU core header files +// #include "kdu_elementary.h" #include "kdu_messaging.h" #include "kdu_params.h" @@ -82,7 +81,7 @@ protected: #elif LL_LINUX # define LLSYMEXPORT __attribute__ ((visibility("default"))) #else -# define LLSYMEXPORT /**/ +# define LLSYMEXPORT #endif extern "C" LLSYMEXPORT const char* engineInfoLLImageJ2CKDU(); diff --git a/indra/llkdu/llkdumem.cpp b/indra/llkdu/llkdumem.cpp index 300b8e28af..1f549cbbe0 100644 --- a/indra/llkdu/llkdumem.cpp +++ b/indra/llkdu/llkdumem.cpp @@ -25,10 +25,7 @@ */ #include "linden_common.h" - #include "llkdumem.h" - -// Various image utility functions from kdu #include "llerror.h" #if defined(LL_WINDOWS) @@ -71,11 +68,11 @@ LLKDUMemIn::LLKDUMemIn(const U8 *data, mCurPos = 0; } - LLKDUMemIn::~LLKDUMemIn() { if ((num_unread_rows > 0) || (incomplete_lines != NULL)) - { kdu_warning w; + { + kdu_warning w; w << "Not all rows of image components " << first_comp_idx << " through " << first_comp_idx+num_components-1 @@ -197,197 +194,3 @@ bool LLKDUMemIn::get(int comp_idx, kdu_line_buf &line, int x_tnum) return true; } - - -/* -LLKDUMemOut::LLKDUMemOut(U8 *data, siz_params *siz, U8 in_num_components) -{ - int is_signed = 0; - int n; - - // Allocate memory segment - - first_comp_idx = 0; - if (!(siz->get(Scomponents,0,0,num_components) && - siz->get(Sdims,first_comp_idx,0,rows) && - siz->get(Sdims,first_comp_idx,1,cols) && - siz->get(Ssigned,first_comp_idx,0,is_signed))) - { - kdu_error e; e << "Attempting to create output image files before " - "all information is available concerning the image component " - "dimensions, bit-depth and signed/unsigned characteristics."; - } - num_components -= first_comp_idx; - - for (n=0; n < 3; n++) - { - precision[n] = 0; - } - - for (n=0; n < num_components; n++) - { - int prec; - - if (!(siz->compare(Sdims,first_comp_idx+n,0,rows) && - siz->compare(Sdims,first_comp_idx+n,1,cols) && - siz->compare(Ssigned,first_comp_idx+n,0,is_signed))) - { - assert(n > 0); - num_components = 1; - break; - } - if (!siz->get(Sprecision,first_comp_idx+n,0,prec)) - { - kdu_error e; e << "Attempting to create output image data before " - "all information is available concerning the image component " - "dimensions, bit-depth and signed/unsigned characteristics."; - } - llassert(n < 3); - precision[n] = prec; - } - if (is_signed) - { - kdu_warning w; - w << "Signed sample values will be written to the " - "BMP file as unsigned 8-bit quantities, centered about 128."; - } - - mCurPos = 0; - mData = data; - mDataSize = rows*cols*num_components; - - incomplete_lines = NULL; - free_lines = NULL; - num_unwritten_rows = rows; -} - -LLKDUMemOut::~LLKDUMemOut() -{ - if ((num_unwritten_rows > 0) || (incomplete_lines != NULL)) - { - kdu_warning w; - w << "Not all rows of image components " - << first_comp_idx << " through " - << first_comp_idx+num_components-1 - << " were completed!"; - } - image_line_buf *tmp; - - while ((tmp=incomplete_lines) != NULL) - { - incomplete_lines = tmp->next; - delete tmp; - } - - while ((tmp=free_lines) != NULL) - { - free_lines = tmp->next; - delete tmp; - } - - // Should either clean up or leave alone the data buffer... -// cout << "Done Destroying" << endl; -} - -void LLKDUMemOut::put(int comp_idx, kdu_line_buf &line, int x_tnum) -{ - int idx = 0; - - idx = comp_idx - this->first_comp_idx; - - assert((idx >= 0) && (idx < num_components)); - x_tnum = x_tnum*num_components+idx; - image_line_buf *scan, *prev=NULL; - for (scan=incomplete_lines; scan != NULL; prev=scan, scan=scan->next) - { - assert(scan->next_x_tnum >= x_tnum); - if (scan->next_x_tnum == x_tnum) - { - break; - } - } - if (scan == NULL) - { // Need to open a new line buffer - assert(x_tnum == 0); // Must consume in very specific order. - if ((scan = free_lines) == NULL) - { - scan = new image_line_buf(cols+3,num_components); - } - free_lines = scan->next; - if (prev == NULL) - { - incomplete_lines = scan; - } - else - { - prev->next = scan; - } - scan->accessed_samples = 0; - scan->next_x_tnum = 0; - } - - assert((cols-scan->accessed_samples) >= line.get_width()); - - int comp_offset = idx; - - if (line.get_buf32() != NULL) - { - if (line.is_absolute()) - { - convert_ints_to_bytes(line.get_buf32(), - scan->buf+num_components*scan->accessed_samples+comp_offset, - line.get_width(),precision[idx],num_components); - } - else - { - convert_floats_to_bytes(line.get_buf32(), - scan->buf+num_components*scan->accessed_samples+comp_offset, - line.get_width(),precision[idx],num_components); - } - } - else - { - if (line.is_absolute()) - { - convert_shorts_to_bytes(line.get_buf16(), - scan->buf+num_components*scan->accessed_samples+comp_offset, - line.get_width(),precision[idx],num_components); - } - else - { - convert_fixpoint_to_bytes(line.get_buf16(), - scan->buf+num_components*scan->accessed_samples+comp_offset, - line.get_width(),precision[idx],num_components); - } - } - - scan->next_x_tnum++; - if (idx == (num_components-1)) - { - scan->accessed_samples += line.get_width(); - } - if (scan->accessed_samples == cols) - { - // Write completed line and send it to the free list. - if (num_unwritten_rows == 0) - { - kdu_error e; e << "Attempting to write too many lines to image " - "file for components " << first_comp_idx << " through " - << first_comp_idx+num_components-1 << "."; - } - if ((mCurPos + cols*num_components) > mDataSize) - { - llerrs << "LLKDUMemOut::put() too much data" << llendl; - } - // Write the data to the output buffer. - memcpy(mData+mCurPos, scan->buf, cols*num_components); - mCurPos += cols*num_components; - - num_unwritten_rows--; - assert(scan == incomplete_lines); - incomplete_lines = scan->next; - scan->next = free_lines; - free_lines = scan; - } -} -*/ diff --git a/indra/llkdu/llkdumem.h b/indra/llkdu/llkdumem.h index b1b2516095..7064de4408 100644 --- a/indra/llkdu/llkdumem.h +++ b/indra/llkdu/llkdumem.h @@ -27,8 +27,7 @@ #ifndef LL_LLKDUMEM_H #define LL_LLKDUMEM_H -// Support classes for reading and writing from memory buffers -// for KDU +// Support classes for reading and writing from memory buffers in KDU #include "kdu_image.h" #include "kdu_elementary.h" #include "kdu_messaging.h" @@ -70,6 +69,7 @@ public: // Member functions { mCurPos = 0; } + private: // Data U8 *mData; U32 mSize; @@ -107,6 +107,7 @@ public: // Member functions *mOutputSize = mCurPos; return true; } + private: // Data U8 *mData; U32 mSize; @@ -114,7 +115,6 @@ private: // Data U32 *mOutputSize; }; - class LLKDUMemIn : public kdu_image_in_base { public: // Member functions @@ -125,10 +125,11 @@ public: // Member functions U8 in_num_components, siz_params *siz); ~LLKDUMemIn(); + bool get(int comp_idx, kdu_line_buf &line, int x_tnum); - const U8 *mData; private: // Data + const U8 *mData; int first_comp_idx; int num_components; int rows, cols; @@ -141,28 +142,4 @@ private: // Data U32 mCurPos; U32 mDataSize; }; - -/* -class LLKDUMemOut : public kdu_image_out_base -{ -public: // Member functions - LLKDUMemOut(U8 *data, siz_params *siz, U8 in_num_components); - LLKDUMemOut(siz_params *siz, U8 in_num_components); - ~LLKDUMemOut(); - void put(int comp_idx, kdu_line_buf &line, int x_tnum); - - U8 *mData; -private: // Data - int first_comp_idx; - int num_components; - int rows, cols; - int precision[3]; - image_line_buf *incomplete_lines; // Each "sample" represents a full pixel - image_line_buf *free_lines; - int num_unwritten_rows; - - U32 mCurPos; - U32 mDataSize; -}; -*/ #endif |