From 04adbdad4bb13cb98c77bba17fcc9a16e0f44203 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 12 Nov 2010 16:37:42 -0800 Subject: STORM-151 : Got decompression to work, compression disabled, simplified llkdu building --- indra/llkdu/CMakeLists.txt | 22 ++-------------------- indra/llkdu/llblockdecoder.cpp | 13 +++++-------- indra/llkdu/llblockencoder.cpp | 13 +++++-------- indra/llkdu/llimagej2ckdu.cpp | 26 ++++++++++++++++++-------- indra/llkdu/llimagej2ckdu.h | 10 +++++----- indra/llkdu/llkdumem.cpp | 3 ++- indra/llkdu/llkdumem.h | 13 +++++++------ 7 files changed, 44 insertions(+), 56 deletions(-) (limited to 'indra/llkdu') diff --git a/indra/llkdu/CMakeLists.txt b/indra/llkdu/CMakeLists.txt index 2806af26c3..0932d368b5 100644 --- a/indra/llkdu/CMakeLists.txt +++ b/indra/llkdu/CMakeLists.txt @@ -25,26 +25,12 @@ include_directories( ) set(llkdu_SOURCE_FILES - kdc_flow_control.cpp - kde_flow_control.cpp - kdu_image.cpp - llblockdata.cpp - llblockdecoder.cpp - llblockencoder.cpp llimagej2ckdu.cpp llkdumem.cpp ) set(llkdu_HEADER_FILES CMakeLists.txt - - kdc_flow_control.h - kde_flow_control.h - kdu_image.h - kdu_image_local.h - llblockdata.h - llblockdecoder.h - llblockencoder.h llimagej2ckdu.h llkdumem.h ) @@ -71,15 +57,11 @@ if (WINDOWS) endif (WINDOWS) if (LLKDU_LIBRARY) - add_library (${LLKDU_STATIC_LIBRARY} ${llkdu_SOURCE_FILES}) + add_library (${LLKDU_LIBRARY} ${llkdu_SOURCE_FILES}) target_link_libraries( - ${LLKDU_STATIC_LIBRARY} -# ${LLIMAGE_LIBRARIES} -# ${LLVFS_LIBRARIES} + ${LLKDU_LIBRARY} ${LLMATH_LIBRARIES} -# ${LLCOMMON_LIBRARIES} ${KDU_LIBRARY} -# ${WINDOWS_LIBRARIES} ) endif (LLKDU_LIBRARY) diff --git a/indra/llkdu/llblockdecoder.cpp b/indra/llkdu/llblockdecoder.cpp index b4ddb2fba2..3daa016591 100644 --- a/indra/llkdu/llblockdecoder.cpp +++ b/indra/llkdu/llblockdecoder.cpp @@ -29,14 +29,11 @@ #include "llblockdecoder.h" // KDU core header files -#include "kdu/kdu_elementary.h" -#include "kdu/kdu_messaging.h" -#include "kdu/kdu_params.h" -#include "kdu/kdu_compressed.h" -#include "kdu/kdu_sample_processing.h" - -// KDU utility functions. -#include "kde_flow_control.h" +#include "kdu_elementary.h" +#include "kdu_messaging.h" +#include "kdu_params.h" +#include "kdu_compressed.h" +#include "kdu_sample_processing.h" #include "llkdumem.h" diff --git a/indra/llkdu/llblockencoder.cpp b/indra/llkdu/llblockencoder.cpp index f19841e36f..759eaf65f9 100644 --- a/indra/llkdu/llblockencoder.cpp +++ b/indra/llkdu/llblockencoder.cpp @@ -29,14 +29,11 @@ #include "llblockencoder.h" // KDU core header files -#include "kdu/kdu_elementary.h" -#include "kdu/kdu_messaging.h" -#include "kdu/kdu_params.h" -#include "kdu/kdu_compressed.h" -#include "kdu/kdu_sample_processing.h" - -// KDU utility functions. -#include "kdc_flow_control.h" +#include "kdu_elementary.h" +#include "kdu_messaging.h" +#include "kdu_params.h" +#include "kdu_compressed.h" +#include "kdu_sample_processing.h" #include "llkdumem.h" diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 1785aa111d..147b9829c5 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -27,15 +27,10 @@ #include "linden_common.h" #include "llimagej2ckdu.h" -// KDU utility functions. -#include "kde_flow_control.h" -#include "kdc_flow_control.h" - #include "lltimer.h" #include "llpointer.h" #include "llkdumem.h" - // // Kakadu specific implementation // @@ -113,7 +108,8 @@ void ll_kdu_error( void ) class LLKDUMessageWarning : public kdu_message { public: - /*virtual*/ void put_text(const char *string); + /*virtual*/ void put_text(const char *s); + /*virtual*/ void put_text(const kdu_uint16 *s); static LLKDUMessageWarning sDefaultMessage; }; @@ -121,7 +117,8 @@ public: class LLKDUMessageError : public kdu_message { public: - /*virtual*/ void put_text(const char *string); + /*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; }; @@ -131,11 +128,21 @@ void LLKDUMessageWarning::put_text(const char *s) llinfos << "KDU Warning: " << s << llendl; } +void LLKDUMessageWarning::put_text(const kdu_uint16 *s) +{ + llinfos << "KDU Warning: " << s << llendl; +} + void LLKDUMessageError::put_text(const char *s) { llinfos << "KDU Error: " << s << llendl; } +void LLKDUMessageError::put_text(const kdu_uint16 *s) +{ + llinfos << "KDU Error: " << s << llendl; +} + void LLKDUMessageError::flush(bool end_of_message) { if( end_of_message ) @@ -467,7 +474,7 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time, BOOL reversible) { // Collect simple arguments. - +/* bool transpose, vflip, hflip; bool allow_rate_prediction, allow_shorts, mem, quiet, no_weights; int cpu_iterations; @@ -685,6 +692,9 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co } return TRUE; + */ + // Compression not implemented yet + return FALSE; } BOOL LLImageJ2CKDU::getMetadata(LLImageJ2C &base) diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h index 5794ebdc68..ac0443d8fc 100644 --- a/indra/llkdu/llimagej2ckdu.h +++ b/indra/llkdu/llimagej2ckdu.h @@ -33,11 +33,11 @@ // // // KDU core header files -#include "kdu/kdu_elementary.h" -#include "kdu/kdu_messaging.h" -#include "kdu/kdu_params.h" -#include "kdu/kdu_compressed.h" -#include "kdu/kdu_sample_processing.h" +#include "kdu_elementary.h" +#include "kdu_messaging.h" +#include "kdu_params.h" +#include "kdu_compressed.h" +#include "kdu_sample_processing.h" class LLKDUDecodeState; class LLKDUMemSource; diff --git a/indra/llkdu/llkdumem.cpp b/indra/llkdu/llkdumem.cpp index 80f4c444d1..811c5b52bb 100644 --- a/indra/llkdu/llkdumem.cpp +++ b/indra/llkdu/llkdumem.cpp @@ -199,7 +199,7 @@ bool LLKDUMemIn::get(int comp_idx, kdu_line_buf &line, int x_tnum) } - +/* LLKDUMemOut::LLKDUMemOut(U8 *data, siz_params *siz, U8 in_num_components) { int is_signed = 0; @@ -390,3 +390,4 @@ void LLKDUMemOut::put(int comp_idx, kdu_line_buf &line, int x_tnum) free_lines = scan; } } +*/ \ No newline at end of file diff --git a/indra/llkdu/llkdumem.h b/indra/llkdu/llkdumem.h index fecb4653db..f0580cf84f 100644 --- a/indra/llkdu/llkdumem.h +++ b/indra/llkdu/llkdumem.h @@ -30,11 +30,11 @@ // Support classes for reading and writing from memory buffers // for KDU #include "kdu_image.h" -#include "kdu/kdu_elementary.h" -#include "kdu/kdu_messaging.h" -#include "kdu/kdu_params.h" -#include "kdu/kdu_compressed.h" -#include "kdu/kdu_sample_processing.h" +#include "kdu_elementary.h" +#include "kdu_messaging.h" +#include "kdu_params.h" +#include "kdu_compressed.h" +#include "kdu_sample_processing.h" #include "kdu_image_local.h" #include "stdtypes.h" @@ -142,6 +142,7 @@ private: // Data U32 mDataSize; }; +/* class LLKDUMemOut : public kdu_image_out_base { public: // Member functions @@ -163,5 +164,5 @@ private: // Data U32 mCurPos; U32 mDataSize; }; - +*/ #endif -- cgit v1.2.3 From e3d95ddb9a3e6abc8e800edf77cf3b0e4f5c4b8f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 15 Nov 2010 21:28:16 -0800 Subject: STORM-151 : Make kdu decompression work without ugly hack in library header names --- indra/llkdu/llkdumem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llkdu') diff --git a/indra/llkdu/llkdumem.h b/indra/llkdu/llkdumem.h index f0580cf84f..b1b2516095 100644 --- a/indra/llkdu/llkdumem.h +++ b/indra/llkdu/llkdumem.h @@ -35,7 +35,7 @@ #include "kdu_params.h" #include "kdu_compressed.h" #include "kdu_sample_processing.h" -#include "kdu_image_local.h" +#include "image_local.h" #include "stdtypes.h" class LLKDUMemSource: public kdu_compressed_source -- cgit v1.2.3 From 9682b9b5db695643b90720f9da2c8d03e4559dd4 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 18 Nov 2010 15:26:49 -0800 Subject: STORM-151 : suppress the linux64 ref in install.xml and attempt to fix llkdumem.cpp linux compile issue --- indra/llkdu/llkdumem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llkdu') diff --git a/indra/llkdu/llkdumem.cpp b/indra/llkdu/llkdumem.cpp index 811c5b52bb..300b8e28af 100644 --- a/indra/llkdu/llkdumem.cpp +++ b/indra/llkdu/llkdumem.cpp @@ -390,4 +390,4 @@ void LLKDUMemOut::put(int comp_idx, kdu_line_buf &line, int x_tnum) free_lines = scan; } } -*/ \ No newline at end of file +*/ -- cgit v1.2.3 From 37626b32ffd23d848ce5e41abf6052445b6633e2 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 19 Nov 2010 18:06:56 -0800 Subject: STORM-151 : Modify llkdu cmake to point explicitely to static libs, simplify make (in progress, don't pull yet) --- indra/llkdu/CMakeLists.txt | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'indra/llkdu') diff --git a/indra/llkdu/CMakeLists.txt b/indra/llkdu/CMakeLists.txt index 0932d368b5..fe590c98f8 100644 --- a/indra/llkdu/CMakeLists.txt +++ b/indra/llkdu/CMakeLists.txt @@ -7,15 +7,13 @@ project(llkdu) # errors), even when the specific warnings that make it croak are # disabled. -set(VS_DISABLE_FATAL_WARNINGS ON) +#set(VS_DISABLE_FATAL_WARNINGS ON) include(00-Common) include(LLCommon) include(LLImage) include(LLKDU) include(LLMath) -#include(LLVFS) -#include(Linking) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -31,6 +29,7 @@ set(llkdu_SOURCE_FILES set(llkdu_HEADER_FILES CMakeLists.txt + llimagej2ckdu.h llkdumem.h ) @@ -40,28 +39,28 @@ set_source_files_properties(${llkdu_HEADER_FILES} list(APPEND llkdu_SOURCE_FILES ${llkdu_HEADER_FILES}) -if (WINDOWS) +#if (WINDOWS) # This turns off the warning about flow control ending in a destructor. - set_source_files_properties( - kdu_image.cpp llkdumem.cpp - PROPERTIES - COMPILE_FLAGS "/wd4702 /wd4722" - ) +# set_source_files_properties( +# kdu_image.cpp llkdumem.cpp +# PROPERTIES +# COMPILE_FLAGS "/wd4702 /wd4722" +# ) # This turns off the warning about sprintf in the following 2 files. - set_source_files_properties( - kde_flow_control.cpp kdc_flow_control.cpp - PROPERTIES - COMPILE_FLAGS /D_CRT_SECURE_NO_DEPRECATE - ) -endif (WINDOWS) +# set_source_files_properties( +# kde_flow_control.cpp kdc_flow_control.cpp +# PROPERTIES +# COMPILE_FLAGS /D_CRT_SECURE_NO_DEPRECATE +# ) +#endif (WINDOWS) -if (LLKDU_LIBRARY) - add_library (${LLKDU_LIBRARY} ${llkdu_SOURCE_FILES}) +if (USE_KDU) + add_library (${LLKDU_LIBRARIES} ${llkdu_SOURCE_FILES}) - target_link_libraries( - ${LLKDU_LIBRARY} - ${LLMATH_LIBRARIES} - ${KDU_LIBRARY} - ) -endif (LLKDU_LIBRARY) +# target_link_libraries( +# ${LLKDU_LIBRARY} +# ${LLMATH_LIBRARIES} +# ${KDU_LIBRARY} +# ) +endif (USE_KDU) -- cgit v1.2.3 From 3b18f813a81582628fe886b551024dc08a4b2450 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 22 Nov 2010 22:41:42 -0800 Subject: STORM-151 : Attempt to fix Windows static linking, simplified manifest --- indra/llkdu/CMakeLists.txt | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'indra/llkdu') diff --git a/indra/llkdu/CMakeLists.txt b/indra/llkdu/CMakeLists.txt index fe590c98f8..b8b44b44fc 100644 --- a/indra/llkdu/CMakeLists.txt +++ b/indra/llkdu/CMakeLists.txt @@ -39,28 +39,7 @@ set_source_files_properties(${llkdu_HEADER_FILES} list(APPEND llkdu_SOURCE_FILES ${llkdu_HEADER_FILES}) -#if (WINDOWS) - # This turns off the warning about flow control ending in a destructor. -# set_source_files_properties( -# kdu_image.cpp llkdumem.cpp -# PROPERTIES -# COMPILE_FLAGS "/wd4702 /wd4722" -# ) - - # This turns off the warning about sprintf in the following 2 files. -# set_source_files_properties( -# kde_flow_control.cpp kdc_flow_control.cpp -# PROPERTIES -# COMPILE_FLAGS /D_CRT_SECURE_NO_DEPRECATE -# ) -#endif (WINDOWS) - if (USE_KDU) add_library (${LLKDU_LIBRARIES} ${llkdu_SOURCE_FILES}) -# target_link_libraries( -# ${LLKDU_LIBRARY} -# ${LLMATH_LIBRARIES} -# ${KDU_LIBRARY} -# ) endif (USE_KDU) -- cgit v1.2.3 From 2ea7b1a05e2fd773962bb6495148f900d6640b00 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 2 Dec 2010 14:05:21 -0800 Subject: STORM-151 : Remove files we have no use of --- indra/llkdu/llblockdata.cpp | 162 -------------------- indra/llkdu/llblockdata.h | 107 ------------- indra/llkdu/llblockdecoder.cpp | 270 -------------------------------- indra/llkdu/llblockdecoder.h | 42 ----- indra/llkdu/llblockencoder.cpp | 340 ----------------------------------------- indra/llkdu/llblockencoder.h | 49 ------ 6 files changed, 970 deletions(-) delete mode 100644 indra/llkdu/llblockdata.cpp delete mode 100644 indra/llkdu/llblockdata.h delete mode 100644 indra/llkdu/llblockdecoder.cpp delete mode 100644 indra/llkdu/llblockdecoder.h delete mode 100644 indra/llkdu/llblockencoder.cpp delete mode 100644 indra/llkdu/llblockencoder.h (limited to 'indra/llkdu') diff --git a/indra/llkdu/llblockdata.cpp b/indra/llkdu/llblockdata.cpp deleted file mode 100644 index 6a7bc3e6c4..0000000000 --- a/indra/llkdu/llblockdata.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @file llblockdata.cpp - * @brief Image block structure - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llblockdata.h" -#include "llmath.h" - -LLBlockData::LLBlockData(const U32 type) -{ - mType = type; - mWidth = 0; - mHeight = 0; - mRowStride = 0; - mData = NULL; -} - -void LLBlockData::setData(U8 *data, const U32 width, const U32 height, const U32 row_stride) -{ - mData = data; - mWidth = width; - mHeight = height; - if (row_stride) - { - mRowStride = row_stride; - } - else - { - mRowStride = width * 4; - } -} - -U32 LLBlockData::getType() const -{ - return mType; -} - - -U8 *LLBlockData::getData() const -{ - return mData; -} - -U32 LLBlockData::getSize() const -{ - return mWidth*mHeight; -} - -U32 LLBlockData::getWidth() const -{ - return mWidth; -} -U32 LLBlockData::getHeight() const -{ - return mHeight; -} - -U32 LLBlockData::getRowStride() const -{ - return mRowStride; -} - -LLBlockDataU32::LLBlockDataU32() : LLBlockData(BLOCK_TYPE_U32) -{ - mPrecision = 32; -} - -void LLBlockDataU32::setData(U32 *data, const U32 width, const U32 height, const U32 row_stride) -{ - LLBlockData::setData((U8 *)data, width, height, row_stride); -} - -U32 LLBlockDataU32::getSize() const -{ - return mWidth*mHeight*4; -} - -void LLBlockDataU32::setPrecision(const U32 bits) -{ - mPrecision = bits; -} - -U32 LLBlockDataU32::getPrecision() const -{ - return mPrecision; -} - -void LLBlockDataF32::setPrecision(const U32 bits) -{ - mPrecision = bits; -} - -U32 LLBlockDataF32::getPrecision() const -{ - return mPrecision; -} - -void LLBlockDataF32::setData(F32 *data, const U32 width, const U32 height, const U32 row_stride) -{ - LLBlockData::setData((U8 *)data, width, height, row_stride); -} - -void LLBlockDataF32::setMin(const F32 min) -{ - mMin = min; -} - -void LLBlockDataF32::setMax(const F32 max) -{ - mMax = max; -} - -void LLBlockDataF32::calcMinMax() -{ - U32 x, y; - - mMin = *(F32*)mData; - mMax = mMin; - - for (y = 0; y < mHeight; y++) - { - for (x = 0; x < mWidth; x++) - { - F32 data = *(F32*)(mData + y*mRowStride + x*4); - mMin = llmin(data, mMin); - mMax = llmax(data, mMax); - } - } -} - -F32 LLBlockDataF32::getMin() const -{ - return mMin; -} - -F32 LLBlockDataF32::getMax() const -{ - return mMax; -} diff --git a/indra/llkdu/llblockdata.h b/indra/llkdu/llblockdata.h deleted file mode 100644 index dcc847e7e2..0000000000 --- a/indra/llkdu/llblockdata.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file llblockdata.h - * @brief Image block structure - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLBLOCKDATA_H -#define LL_LLBLOCKDATA_H - -#include "stdtypes.h" - -////////////////////////////////////////////////// -// -// This class stores all of the information about -// a single channel of raw data, either integer -// or floating point. -// -class LLBlockData -{ -protected: - U32 mType; - U32 mWidth; - U32 mHeight; - U32 mRowStride; - U8 *mData; -public: - enum - { - BLOCK_TYPE_U32 = 1, - BLOCK_TYPE_F32 = 2 - }; - - LLBlockData(const U32 type); - virtual ~LLBlockData() {} - - void setData(U8 *data, const U32 width, const U32 height, const U32 row_stride = 0); - - U32 getType() const; - U8 *getData() const; - virtual U32 getSize() const; - U32 getWidth() const; - U32 getHeight() const; - U32 getRowStride() const; -}; - -class LLBlockDataU32 : public LLBlockData -{ -protected: - U32 mPrecision; -public: - LLBlockDataU32(); - - void setData(U32 *data, const U32 width, const U32 height, const U32 row_stride = 0); - void setPrecision(const U32 bits); - - /*virtual*/ U32 getSize() const; - U32 getPrecision() const; -}; - -class LLBlockDataF32 : public LLBlockData -{ -protected: - U32 mPrecision; - F32 mMin; - F32 mMax; -public: - LLBlockDataF32() - : LLBlockData(LLBlockData::BLOCK_TYPE_F32), - mPrecision(0), - mMin(0.f), - mMax(0.f) - {}; - - void setData(F32 *data, const U32 width, const U32 height, const U32 row_stride = 0); - - void setPrecision(const U32 bits); - void setMin(const F32 min); - void setMax(const F32 max); - - void calcMinMax(); - - U32 getPrecision() const; - F32 getMin() const; - F32 getMax() const; -}; - -#endif // LL_LLBLOCKDATA_H diff --git a/indra/llkdu/llblockdecoder.cpp b/indra/llkdu/llblockdecoder.cpp deleted file mode 100644 index 3daa016591..0000000000 --- a/indra/llkdu/llblockdecoder.cpp +++ /dev/null @@ -1,270 +0,0 @@ - /** - * @file llblockdecoder.cpp - * @brief Image block decompression - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llblockdecoder.h" - -// KDU core header files -#include "kdu_elementary.h" -#include "kdu_messaging.h" -#include "kdu_params.h" -#include "kdu_compressed.h" -#include "kdu_sample_processing.h" - -#include "llkdumem.h" - -#include "llblockdata.h" -#include "llerror.h" - - -BOOL LLBlockDecoder::decodeU32(LLBlockDataU32 &block_data, U8 *source_data, const U32 source_size) const -{ - U32 width, height; - - llassert(source_data); - - LLKDUMemSource source(source_data, source_size); - - source.reset(); - - kdu_codestream codestream; - - codestream.create(&source); - codestream.set_fast(); - - kdu_dims dims; - codestream.get_dims(0,dims); - llassert(codestream.get_num_components() == 1); - - width = dims.size.x; - height = dims.size.y; - - // Assumes U32 data. - U8 *output = block_data.getData(); - - kdu_dims tile_indices; - codestream.get_valid_tiles(tile_indices); - - kdu_coords tpos; - tpos.x = 0; - tpos.y = 0; - - // Now we are ready to walk through the tiles processing them one-by-one. - while (tpos.y < tile_indices.size.y) - { - while (tpos.x < tile_indices.size.x) - { - kdu_tile tile = codestream.open_tile(tpos+tile_indices.pos); - - kdu_resolution res = tile.access_component(0).access_resolution(); - kdu_dims tile_dims; - res.get_dims(tile_dims); - kdu_coords offset = tile_dims.pos - dims.pos; - int row_gap = block_data.getRowStride(); // inter-row separation - kdu_byte *buf = output + offset.y*row_gap + offset.x*4; - - kdu_tile_comp tile_comp = tile.access_component(0); - bool reversible = tile_comp.get_reversible(); - U32 precision = tile_comp.get_bit_depth(); - U32 precision_scale = 1 << precision; - llassert(precision >= 8); // Else would have used 16 bit representation - - kdu_resolution comp_res = tile_comp.access_resolution(); // Get top resolution - kdu_dims comp_dims; - comp_res.get_dims(comp_dims); - - bool use_shorts = (tile_comp.get_bit_depth(true) <= 16); - - kdu_line_buf line; - kdu_sample_allocator allocator; - kdu_pull_ifc engine; - - line.pre_create(&allocator, comp_dims.size.x, reversible, use_shorts); - if (res.which() == 0) // No DWT levels used - { - engine = kdu_decoder(res.access_subband(LL_BAND), &allocator, use_shorts); - } - else - { - engine = kdu_synthesis(res, &allocator, use_shorts); - } - allocator.finalize(); // Actually creates buffering resources - - line.create(); // Grabs resources from the allocator. - - // Do the actual processing - while (tile_dims.size.y--) - { - engine.pull(line, true); - int width = line.get_width(); - - llassert(line.get_buf32()); - llassert(!line.is_absolute()); - // Decompressed samples have a 32-bit representation (integer or float) - kdu_sample32 *sp = line.get_buf32(); - // Transferring normalized floating point data. - U32 *dest_u32 = (U32 *)buf; - for (; width > 0; width--, sp++, dest_u32++) - { - if (sp->fval < -0.5f) - { - *dest_u32 = 0; - } - else - { - *dest_u32 = (U32)((sp->fval + 0.5f)*precision_scale); - } - } - buf += row_gap; - } - engine.destroy(); - tile.close(); - tpos.x++; - } - tpos.y++; - tpos.x = 0; - } - codestream.destroy(); - - return TRUE; -} - -BOOL LLBlockDecoder::decodeF32(LLBlockDataF32 &block_data, U8 *source_data, const U32 source_size, const F32 min, const F32 max) const -{ - U32 width, height; - F32 range, range_inv, float_offset; - bool use_shorts = false; - - range = max - min; - range_inv = 1.f / range; - float_offset = 0.5f*(max + min); - - llassert(source_data); - - LLKDUMemSource source(source_data, source_size); - - source.reset(); - - kdu_codestream codestream; - - codestream.create(&source); - codestream.set_fast(); - - kdu_dims dims; - codestream.get_dims(0,dims); - llassert(codestream.get_num_components() == 1); - - width = dims.size.x; - height = dims.size.y; - - // Assumes F32 data. - U8 *output = block_data.getData(); - - kdu_dims tile_indices; - codestream.get_valid_tiles(tile_indices); - - kdu_coords tpos; - tpos.x = 0; - tpos.y = 0; - - // Now we are ready to walk through the tiles processing them one-by-one. - while (tpos.y < tile_indices.size.y) - { - while (tpos.x < tile_indices.size.x) - { - kdu_tile tile = codestream.open_tile(tpos+tile_indices.pos); - - kdu_resolution res = tile.access_component(0).access_resolution(); - kdu_dims tile_dims; - res.get_dims(tile_dims); - kdu_coords offset = tile_dims.pos - dims.pos; - int row_gap = block_data.getRowStride(); // inter-row separation - kdu_byte *buf = output + offset.y*row_gap + offset.x*4; - - kdu_tile_comp tile_comp = tile.access_component(0); - bool reversible = tile_comp.get_reversible(); - - kdu_resolution comp_res = tile_comp.access_resolution(); // Get top resolution - kdu_dims comp_dims; - comp_res.get_dims(comp_dims); - - kdu_line_buf line; - kdu_sample_allocator allocator; - kdu_pull_ifc engine; - - line.pre_create(&allocator, comp_dims.size.x, reversible, use_shorts); - if (res.which() == 0) // No DWT levels used - { - engine = kdu_decoder(res.access_subband(LL_BAND), &allocator, use_shorts); - } - else - { - engine = kdu_synthesis(res, &allocator, use_shorts); - } - allocator.finalize(); // Actually creates buffering resources - - line.create(); // Grabs resources from the allocator. - - // Do the actual processing - while (tile_dims.size.y--) - { - engine.pull(line, true); - int width = line.get_width(); - - llassert(line.get_buf32()); - llassert(!line.is_absolute()); - // Decompressed samples have a 32-bit representation (integer or float) - kdu_sample32 *sp = line.get_buf32(); - // Transferring normalized floating point data. - F32 *dest_f32 = (F32 *)buf; - for (; width > 0; width--, sp++, dest_f32++) - { - if (sp->fval < -0.5f) - { - *dest_f32 = min; - } - else if (sp->fval > 0.5f) - { - *dest_f32 = max; - } - else - { - *dest_f32 = (sp->fval) * range + float_offset; - } - } - buf += row_gap; - } - engine.destroy(); - tile.close(); - tpos.x++; - } - tpos.y++; - tpos.x = 0; - } - codestream.destroy(); - return TRUE; -} diff --git a/indra/llkdu/llblockdecoder.h b/indra/llkdu/llblockdecoder.h deleted file mode 100644 index 97959d338e..0000000000 --- a/indra/llkdu/llblockdecoder.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file llblockdecoder.h - * @brief Image block decompression - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLBLOCKDECODER_H -#define LL_LLBLOCKDECODER_H - -#include "stdtypes.h" - -class LLBlockDataU32; -class LLBlockDataF32; - -class LLBlockDecoder -{ -public: - BOOL decodeU32(LLBlockDataU32 &block_data, U8 *source_data, const U32 source_size) const; - BOOL decodeF32(LLBlockDataF32 &block_data, U8 *source_data, const U32 source_size, const F32 min, const F32 max) const; -}; - -#endif // LL_LLBLOCKDECODER_H diff --git a/indra/llkdu/llblockencoder.cpp b/indra/llkdu/llblockencoder.cpp deleted file mode 100644 index 759eaf65f9..0000000000 --- a/indra/llkdu/llblockencoder.cpp +++ /dev/null @@ -1,340 +0,0 @@ - /** - * @file llblockencoder.cpp - * @brief Image block compression - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llblockencoder.h" - -// KDU core header files -#include "kdu_elementary.h" -#include "kdu_messaging.h" -#include "kdu_params.h" -#include "kdu_compressed.h" -#include "kdu_sample_processing.h" - -#include "llkdumem.h" - -#include "llblockdata.h" -#include "llerror.h" - -LLBlockEncoder::LLBlockEncoder() -{ - mBPP = 0.f; -} - -U8 *LLBlockEncoder::encode(const LLBlockData &block_data, U32 &output_size) const -{ - switch (block_data.getType()) - { - case LLBlockData::BLOCK_TYPE_U32: - { - LLBlockDataU32 &bd_u32 = (LLBlockDataU32 &)block_data; - return encodeU32(bd_u32, output_size); - } - case LLBlockData::BLOCK_TYPE_F32: - { - LLBlockDataF32 &bd_f32 = (LLBlockDataF32 &)block_data; - return encodeF32(bd_f32, output_size); - } - default: - llerrs << "Unsupported block type!" << llendl; - output_size = 0; - return NULL; - } -} - -U8 *LLBlockEncoder::encodeU32(const LLBlockDataU32 &block_data, U32 &output_size) const -{ - // OK, for now, just use the standard KDU encoder, with a single channel - // integer channel. - - // Collect simple arguments. - bool allow_rate_prediction, allow_shorts, mem, quiet, no_weights; - - allow_rate_prediction = true; - allow_shorts = false; - no_weights = false; - bool use_absolute = false; - mem = false; - quiet = false; - - // Set codestream options - siz_params siz; - S16 precision = block_data.getPrecision(); - - siz.set(Sdims,0,0,(U16)block_data.getHeight()); - siz.set(Sdims,0,1,(U16)block_data.getWidth()); - siz.set(Ssigned,0,0,false); - siz.set(Scomponents,0,0,1); - siz.set(Sprecision,0,0, precision); - - // Construct the `kdu_codestream' object and parse all remaining arguments. - output_size = block_data.getSize(); - if (output_size < 1000) - { - output_size = 1000; - } - - U8 *output_buffer = new U8[output_size]; - - LLKDUMemTarget output(output_buffer, output_size, block_data.getSize()); - - kdu_codestream codestream; - codestream.create(&siz,&output); - - codestream.access_siz()->parse_string("Clayers=1"); - codestream.access_siz()->finalize_all(); - - kdu_tile tile = codestream.open_tile(kdu_coords(0,0)); - - // Open tile-components and create processing engines and resources - kdu_dims dims; - kdu_sample_allocator allocator; - kdu_tile_comp tile_comp; - kdu_line_buf line; - kdu_push_ifc engine; - - tile_comp = tile.access_component(0); - kdu_resolution res = tile_comp.access_resolution(); // Get top resolution - - res.get_dims(dims); - - line.pre_create(&allocator,dims.size.x, use_absolute, allow_shorts); - - if (res.which() == 0) // No DWT levels (should not occur in this example) - { - engine = kdu_encoder(res.access_subband(LL_BAND),&allocator, use_absolute); - } - else - { - engine = kdu_analysis(res,&allocator, use_absolute); - } - - allocator.finalize(); // Actually creates buffering resources - line.create(); // Grabs resources from the allocator. - - // Now walk through the lines of the buffer, pushing them into the - // relevant tile-component processing engines. - - U32 *source_u32 = NULL; - F32 scale_inv = 1.f / (1 << precision); - - S32 y; - for (y = 0; y < dims.size.y; y++) - { - source_u32 = (U32*)(block_data.getData() + y * block_data.getRowStride()); - kdu_sample32 *dest = line.get_buf32(); - for (S32 n=dims.size.x; n > 0; n--, dest++, source_u32++) - { - // Just pack it in, for now. - dest->fval = (F32)(*source_u32) * scale_inv - 0.5f;// - 0.5f; - } - engine.push(line, true); - } - - // Cleanup - engine.destroy(); // engines are interfaces; no default destructors - - // Produce the final compressed output. - kdu_long layer_bytes[1] = {0}; - - layer_bytes[0] = (kdu_long) (mBPP*block_data.getWidth()*block_data.getHeight()); - // Here we are not requesting specific sizes for any of the 12 - // quality layers. As explained in the description of - // "kdu_codestream::flush" (see "kdu_compressed.h"), the rate allocator - // will then assign the layers in such a way as to achieve roughly - // two quality layers per octave change in bit-rate, with the final - // layer reaching true lossless quality. - - codestream.flush(layer_bytes,1); - // You can see how many bytes were assigned - // to each quality layer by looking at the entries of `layer_bytes' here. - // The flush function can do a lot of interesting things which you may - // want to spend some time looking into. In addition to targeting - // specific bit-rates for each quality layer, it can be configured to - // use rate-distortion slope thresholds of your choosing and to return - // the thresholds which it finds to be best for any particular set of - // target layer sizes. This opens the door to feedback-oriented rate - // control for video. You should also look into the - // "kdu_codestream::set_max_bytes" and - // "kdu_codestream::set_min_slope_threshold" functions which can be - // used to significantly speed up compression. - codestream.destroy(); // All done: simple as that. - - // Now that we're done encoding, create the new data buffer for the compressed - // image and stick it there. - - U8 *output_data = new U8[output_size]; - - memcpy(output_data, output_buffer, output_size); - - output.close(); // Not really necessary here. - - return output_data; -} - -U8 *LLBlockEncoder::encodeF32(const LLBlockDataF32 &block_data, U32 &output_size) const -{ - // OK, for now, just use the standard KDU encoder, with a single channel - // integer channel. - - // Collect simple arguments. - bool allow_rate_prediction, allow_shorts, mem, quiet, no_weights; - - allow_rate_prediction = true; - allow_shorts = false; - no_weights = false; - bool use_absolute = false; - mem = false; - quiet = false; - - F32 min, max, range, range_inv, offset; - min = block_data.getMin(); - max = block_data.getMax(); - range = max - min; - range_inv = 1.f / range; - offset = 0.5f*(max + min); - - // Set codestream options - siz_params siz; - S16 precision = block_data.getPrecision(); // Assume precision is always 32 bits for floating point. - - siz.set(Sdims,0,0,(U16)block_data.getHeight()); - siz.set(Sdims,0,1,(U16)block_data.getWidth()); - siz.set(Ssigned,0,0,false); - siz.set(Scomponents,0,0,1); - siz.set(Sprecision,0,0, precision); - - // Construct the `kdu_codestream' object and parse all remaining arguments. - output_size = block_data.getSize(); - if (output_size < 1000) - { - output_size = 1000; - } - - U8 *output_buffer = new U8[output_size*2]; - - LLKDUMemTarget output(output_buffer, output_size, block_data.getSize()); - - kdu_codestream codestream; - codestream.create(&siz,&output); - - codestream.access_siz()->parse_string("Clayers=1"); - codestream.access_siz()->finalize_all(); - - kdu_tile tile = codestream.open_tile(kdu_coords(0,0)); - - // Open tile-components and create processing engines and resources - kdu_dims dims; - kdu_sample_allocator allocator; - kdu_tile_comp tile_comp; - kdu_line_buf line; - kdu_push_ifc engine; - - tile_comp = tile.access_component(0); - kdu_resolution res = tile_comp.access_resolution(); // Get top resolution - - res.get_dims(dims); - - line.pre_create(&allocator,dims.size.x, use_absolute, allow_shorts); - - if (res.which() == 0) // No DWT levels (should not occur in this example) - { - engine = kdu_encoder(res.access_subband(LL_BAND),&allocator, use_absolute); - } - else - { - engine = kdu_analysis(res,&allocator, use_absolute); - } - - allocator.finalize(); // Actually creates buffering resources - line.create(); // Grabs resources from the allocator. - - // Now walk through the lines of the buffer, pushing them into the - // relevant tile-component processing engines. - - F32 *source_f32 = NULL; - - S32 y; - for (y = 0; y < dims.size.y; y++) - { - source_f32 = (F32*)(block_data.getData() + y * block_data.getRowStride()); - kdu_sample32 *dest = line.get_buf32(); - for (S32 n=dims.size.x; n > 0; n--, dest++, source_f32++) - { - dest->fval = ((*source_f32) - offset) * range_inv; - } - engine.push(line, true); - } - - // Cleanup - engine.destroy(); // engines are interfaces; no default destructors - - // Produce the final compressed output. - kdu_long layer_bytes[1] = {0}; - - layer_bytes[0] = (kdu_long) (mBPP*block_data.getWidth()*block_data.getHeight()); - // Here we are not requesting specific sizes for any of the 12 - // quality layers. As explained in the description of - // "kdu_codestream::flush" (see "kdu_compressed.h"), the rate allocator - // will then assign the layers in such a way as to achieve roughly - // two quality layers per octave change in bit-rate, with the final - // layer reaching true lossless quality. - - codestream.flush(layer_bytes,1); - // You can see how many bytes were assigned - // to each quality layer by looking at the entries of `layer_bytes' here. - // The flush function can do a lot of interesting things which you may - // want to spend some time looking into. In addition to targeting - // specific bit-rates for each quality layer, it can be configured to - // use rate-distortion slope thresholds of your choosing and to return - // the thresholds which it finds to be best for any particular set of - // target layer sizes. This opens the door to feedback-oriented rate - // control for video. You should also look into the - // "kdu_codestream::set_max_bytes" and - // "kdu_codestream::set_min_slope_threshold" functions which can be - // used to significantly speed up compression. - codestream.destroy(); // All done: simple as that. - - // Now that we're done encoding, create the new data buffer for the compressed - // image and stick it there. - - U8 *output_data = new U8[output_size]; - - memcpy(output_data, output_buffer, output_size); - - output.close(); // Not really necessary here. - - delete[] output_buffer; - - return output_data; -} - - -void LLBlockEncoder::setBPP(const F32 bpp) -{ - mBPP = bpp; -} diff --git a/indra/llkdu/llblockencoder.h b/indra/llkdu/llblockencoder.h deleted file mode 100644 index 21381a27fa..0000000000 --- a/indra/llkdu/llblockencoder.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file llblockencoder.h - * @brief Image block compression - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLBLOCKENCODER_H -#define LL_LLBLOCKENCODER_H - -#include "stdtypes.h" - -class LLBlockData; -class LLBlockDataU32; -class LLBlockDataF32; - -class LLBlockEncoder -{ - F32 mBPP; // bits per point -public: - LLBlockEncoder(); - U8 *encode(const LLBlockData &block_data, U32 &output_size) const; - U8 *encodeU32(const LLBlockDataU32 &block_data, U32 &output_size) const; - U8 *encodeF32(const LLBlockDataF32 &block_data, U32 &output_size) const; - - void setBPP(const F32 bpp); -}; - -#endif // LL_LLBLOCKENCODER_H - -- cgit v1.2.3 From abc13fb12faab4d6198fb4496da9559a8ca1d854 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 2 Dec 2010 22:26:49 -0800 Subject: STORM-151 : First shot at compression, not optimzed yet --- indra/llkdu/llimagej2ckdu.cpp | 196 +++++++++++++++++++++++++++++++----------- 1 file changed, 146 insertions(+), 50 deletions(-) (limited to 'indra/llkdu') diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 147b9829c5..21c91be1f7 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -31,6 +31,38 @@ #include "llpointer.h" #include "llkdumem.h" + +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 { + public: // Data + 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 + which it is incremented by `vert_subsampling'. */ + int initial_lines; + int remaining_lines; + kdu_line_buf *line; + }; + + kdu_codestream codestream; + kdu_dims valid_tile_indices; + kdu_coords tile_idx; + kdu_tile tile; + int num_components; + kdc_component_flow_control *components; + int count_delta; // Holds the minimum of the `vert_subsampling' fields. + kdu_multi_analysis engine; + kdu_long max_buffer_memory; +}; + // // Kakadu specific implementation // @@ -38,7 +70,7 @@ void set_default_colour_weights(kdu_params *siz); const char* engineInfoLLImageJ2CKDU() { - return "KDU"; + return "KDU v6.4.1"; } LLImageJ2CKDU* createLLImageJ2CKDU() @@ -474,16 +506,14 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time, BOOL reversible) { // Collect simple arguments. -/* bool transpose, vflip, hflip; - bool allow_rate_prediction, allow_shorts, mem, quiet, no_weights; + bool allow_rate_prediction, mem, quiet, no_weights; int cpu_iterations; std::ostream *record_stream; transpose = false; record_stream = NULL; allow_rate_prediction = true; - allow_shorts = true; no_weights = false; cpu_iterations = -1; mem = false; @@ -620,51 +650,24 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co codestream.change_appearance(transpose,vflip,hflip); // Now we are ready for sample data processing. - - int x_tnum; - kdu_dims tile_indices; codestream.get_valid_tiles(tile_indices); - kdc_flow_control **tile_flows = new kdc_flow_control *[tile_indices.size.x]; - for (x_tnum=0; x_tnum < tile_indices.size.x; x_tnum++) - { - tile_flows[x_tnum] = new kdc_flow_control(&mem_in,codestream,x_tnum,allow_shorts); - } - bool done = false; - - while (!done) - { - while (!done) - { // Process a row of tiles line by line. - done = true; - for (x_tnum=0; x_tnum < tile_indices.size.x; x_tnum++) - { - if (tile_flows[x_tnum]->advance_components()) - { - done = false; - tile_flows[x_tnum]->process_components(); - } - } - } - for (x_tnum=0; x_tnum < tile_indices.size.x; x_tnum++) - { - if (tile_flows[x_tnum]->advance_tile()) - { - done = false; - } - } - } - int sample_bytes = 0; - for (x_tnum=0; x_tnum < tile_indices.size.x; x_tnum++) - { - sample_bytes += tile_flows[x_tnum]->get_buffer_memory(); - delete tile_flows[x_tnum]; - } - delete [] tile_flows; - - // Produce the compressed output. - - codestream.flush(layer_bytes,num_layer_specs, NULL, true, false); + kdc_flow_control *tile = new kdc_flow_control(&mem_in,codestream); + bool done = false; + while (!done) + { + // Process line by line + done = true; + if (tile->advance_components()) + { + done = false; + tile->process_components(); + } + } + + // Produce the compressed output + codestream.flush(layer_bytes,num_layer_specs); // Cleanup + delete tile; codestream.destroy(); if (record_stream != NULL) @@ -692,9 +695,6 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co } return TRUE; - */ - // Compression not implemented yet - return FALSE; } BOOL LLImageJ2CKDU::getMetadata(LLImageJ2C &base) @@ -1014,3 +1014,99 @@ separation between consecutive rows in the real buffer. */ } return TRUE; } + +// kdc_flow_control + +kdc_flow_control::kdc_flow_control (kdu_image_in_base *img_in, kdu_codestream codestream) +{ + int n; + + this->codestream = codestream; + codestream.get_valid_tiles(valid_tile_indices); + tile_idx = valid_tile_indices.pos; + tile = codestream.open_tile(tile_idx,NULL); + + // Set up the individual components + num_components = codestream.get_num_components(true); + components = new kdc_component_flow_control[num_components]; + count_delta = 0; + kdc_component_flow_control *comp = components; + for (n = 0; n < num_components; n++, comp++) + { + comp->line = NULL; + comp->reader = img_in; + kdu_coords subsampling; + codestream.get_subsampling(n,subsampling,true); + kdu_dims dims; + codestream.get_tile_dims(tile_idx,n,dims,true); + comp->vert_subsampling = subsampling.y; + if ((n == 0) || (comp->vert_subsampling < count_delta)) + { + count_delta = comp->vert_subsampling; + } + comp->ratio_counter = 0; + comp->remaining_lines = comp->initial_lines = dims.size.y; + } + 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); +} + +kdc_flow_control::~kdc_flow_control() +{ + if (components != NULL) + delete[] components; + if (engine.exists()) + engine.destroy(); +} + +bool kdc_flow_control::advance_components() +{ + bool found_line = false; + while (!found_line) + { + bool all_done = true; + kdc_component_flow_control *comp = components; + for (int n = 0; n < num_components; n++, comp++) + { + assert(comp->ratio_counter >= 0); + if (comp->remaining_lines > 0) + { + all_done = false; + comp->ratio_counter -= count_delta; + if (comp->ratio_counter < 0) + { + found_line = true; + comp->line = engine.exchange_line(n,NULL,NULL); + assert(comp->line != NULL); + if (comp->line->get_width()) + { + comp->reader->get(n,*(comp->line),0); + } + } + } + } + if (all_done) + return false; + } + return true; +} + +void kdc_flow_control::process_components() +{ + kdc_component_flow_control *comp = components; + for (int n = 0; n < num_components; n++, comp++) + { + if (comp->ratio_counter < 0) + { + comp->ratio_counter += comp->vert_subsampling; + assert(comp->ratio_counter >= 0); + assert(comp->remaining_lines > 0); + comp->remaining_lines--; + assert(comp->line != NULL); + engine.exchange_line(n,comp->line,NULL); + comp->line = NULL; + } + } +} -- cgit v1.2.3 From 71fa0894981bacd26ed07b8a8ab542dcaf2e7ae2 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 15 Dec 2010 20:54:25 -0800 Subject: STORM-151 : Suppress unused code, clean up code formating, fix typos --- indra/llkdu/llimagej2ckdu.cpp | 50 +++-------- indra/llkdu/llimagej2ckdu.h | 5 +- indra/llkdu/llkdumem.cpp | 201 +----------------------------------------- indra/llkdu/llkdumem.h | 33 ++----- 4 files changed, 20 insertions(+), 269 deletions(-) (limited to 'indra/llkdu') 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 @@ -29,10 +29,9 @@ #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 -- cgit v1.2.3