diff options
-rw-r--r-- | TAO/ChangeLog | 14 | ||||
-rw-r--r-- | TAO/MPC/config/rlecompressor.mpb | 3 | ||||
-rw-r--r-- | TAO/tao/AnyTypeCode/Any.cpp | 7 | ||||
-rw-r--r-- | TAO/tao/AnyTypeCode/NVList.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/Compression/rle/RLECompressor.cpp | 131 | ||||
-rw-r--r-- | TAO/tao/Compression/rle/RLECompressor.mpc | 2 | ||||
-rw-r--r-- | TAO/tao/Compression/rle/RLECompressor_Factory.cpp | 5 | ||||
-rw-r--r-- | TAO/tao/Compression/rle/TAO_RLECompressor.rc | 1 | ||||
-rw-r--r-- | TAO/tests/Compression/RLECompressorTest.cpp | 51 |
9 files changed, 68 insertions, 150 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 806df69ff03..f991871b250 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,17 @@ +Thu Feb 23 08:00:29 UTC 2012 Johnny Willemsen <jwillemsen@remedy.nl> + + * MPC/config/rlecompressor.mpb: + * tao/Compression/rle/RLECompressor.cpp: + * tao/Compression/rle/RLECompressor.mpc: + * tao/Compression/rle/RLECompressor_Factory.cpp: + * tao/Compression/rle/TAO_RLECompressor.rc: + * tests/Compression/RLECompressorTest.cpp: + Updated for the move of the rle compressor to a new ACE library + + * tao/AnyTypeCode/Any.cpp: + * tao/AnyTypeCode/NVList.cpp: + Layout changes + Tue Feb 21 14:47:05 UTC 2012 Johnny Willemsen <jwillemsen@remedy.nl> * tao/Compression/Base_Compressor.h: diff --git a/TAO/MPC/config/rlecompressor.mpb b/TAO/MPC/config/rlecompressor.mpb index 525be1dc67b..4dc6951abe5 100644 --- a/TAO/MPC/config/rlecompressor.mpb +++ b/TAO/MPC/config/rlecompressor.mpb @@ -1,7 +1,6 @@ // -*- MPC -*- -// $Id$ -project : taolib, compression { +project : ace_rlecompressionlib, taolib, compression { after += RLECompressor libs += TAO_RLECompressor } diff --git a/TAO/tao/AnyTypeCode/Any.cpp b/TAO/tao/AnyTypeCode/Any.cpp index b3cc6a9e3b0..fa62d4235fd 100644 --- a/TAO/tao/AnyTypeCode/Any.cpp +++ b/TAO/tao/AnyTypeCode/Any.cpp @@ -129,8 +129,7 @@ CORBA::Any::_tao_byte_order (void) const } void -CORBA::Any::type (CORBA::TypeCode_ptr tc - ) +CORBA::Any::type (CORBA::TypeCode_ptr tc) { CORBA::Boolean equiv = false; @@ -782,9 +781,7 @@ namespace TAO { template<> CORBA::Boolean - Any_Impl_T<CORBA::Object>::to_object ( - CORBA::Object_ptr &_tao_elem - ) const + Any_Impl_T<CORBA::Object>::to_object (CORBA::Object_ptr &_tao_elem) const { _tao_elem = CORBA::Object::_duplicate (this->value_); return true; diff --git a/TAO/tao/AnyTypeCode/NVList.cpp b/TAO/tao/AnyTypeCode/NVList.cpp index 6b0ef8aabc5..8207d2a7efc 100644 --- a/TAO/tao/AnyTypeCode/NVList.cpp +++ b/TAO/tao/AnyTypeCode/NVList.cpp @@ -295,10 +295,10 @@ CORBA::NVList::_tao_encode (TAO_OutputCDR &cdr, int flag) { if (this->max_ == 0) { - // The list is empty aggresively reduce copies and just send + // The list is empty aggressively reduce copies and just send // the CDR stream, we assume that // TAO_Server_Request::init_reply - // has inserted appropiated padding already to make this + // has inserted appropriated padding already to make this // operation correct cdr.write_octet_array_mb (this->incoming_->start ()); return; diff --git a/TAO/tao/Compression/rle/RLECompressor.cpp b/TAO/tao/Compression/rle/RLECompressor.cpp index 3f04c38b4c0..47998fbf373 100644 --- a/TAO/tao/Compression/rle/RLECompressor.cpp +++ b/TAO/tao/Compression/rle/RLECompressor.cpp @@ -32,11 +32,13 @@ */ #include "RLECompressor.h" +#include "ace/Compression/rle/RLECompressor.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { + RLECompressor::RLECompressor(::Compression::CompressorFactory_ptr compressor_factory) : BaseCompressor (compressor_factory, 0) { @@ -45,94 +47,20 @@ RLECompressor::RLECompressor(::Compression::CompressorFactory_ptr compressor_fac void RLECompressor::compress(const ::Compression::Buffer &source, ::Compression::Buffer &target) { - size_t in_len = static_cast<size_t>(source.length()); - size_t out_len = static_cast<size_t>((in_len * 1.1) + 32); // Slightly bigger than input - - target.length(static_cast< ::CORBA::ULong>(out_len)); // Set a length - - const unsigned char *in_p = static_cast<const unsigned char*>(source.get_buffer()); - unsigned char *out_p = static_cast<unsigned char*>(target.get_buffer()); - - size_t out_index = 0; - size_t out_base = 0; - size_t run_count = 0; - size_t dup_count = 0; - - bool run_code = false; - unsigned char nxt_byte, cur_byte; - - if (in_p && out_p) while (in_len-- > 0) { - - if (run_code) switch (run_count) { - - default: - - out_p[out_index = out_base] = ::CORBA::Octet(run_count++ | 0x80); - out_p[++out_index] = cur_byte = *in_p++; - - if (in_len ? cur_byte == (nxt_byte = *in_p) : true) { - continue; - } - - // Fall Through - - case 128: - - if (++out_index >= out_len) { - throw ::Compression::CompressionException(); - } else if (in_len == 0) { - continue; - } + ACE_UINT64 in_len = source.length(); + ACE_UINT64 max_len = static_cast<ACE_UINT64>((in_len * 1.1) + 32U); // Slightly bigger than input - run_code = false; - out_p[out_base = out_index] = 0; - dup_count = run_count = 0; - continue; - } + target.length(static_cast< CORBA::ULong>(max_len)); // Ensure we set a length. - switch (run_count) { - - case 128: - - if (++out_index >= out_len) { - throw ::Compression::CompressionException(); - } - out_p[out_base = out_index] = 0; - dup_count = run_count = 0; - - // Fall Through - - default : - - cur_byte = *in_p++; - - if (in_len > 0) { - if (cur_byte == (nxt_byte = *in_p)) { - if (dup_count++ == 1) { - if (run_count >= dup_count) { - out_p[out_base] = static_cast<unsigned char>(run_count - dup_count); - out_base += run_count; - } - run_code = true; - run_count = dup_count - 1; - dup_count = 0; - out_p[out_index = out_base] = static_cast<unsigned char>(run_count++ | 0x80); - break; - } - } else dup_count = 0; - } - out_p[out_base] = char(run_count++); - break; - } - - if (++out_index >= out_len) { - throw ::Compression::CompressionException(); - } - - out_p[out_index] = cur_byte; + ACE_UINT64 out_len = ACE_RLECompression::instance()->compress( source.get_buffer(), + in_len, + target.get_buffer(), + max_len ); + if (ACE_UINT64(-1) == out_len) { // Overrun + throw ::Compression::CompressionException(); } - target.length(++out_index); + target.length(static_cast< CORBA::ULong>(out_len)); // Set Output Buffer to the right size now. // Update statistics for this compressor this->update_stats(source.length(), target.length()); @@ -141,35 +69,12 @@ RLECompressor::compress(const ::Compression::Buffer &source, ::Compression::Buff void RLECompressor::decompress(const ::Compression::Buffer &source, ::Compression::Buffer &target) { - size_t in_len = static_cast<size_t>(source.length()); - size_t max_len = static_cast<size_t>(target.length()); - - size_t out_len = 0; - - const unsigned char *in_p = static_cast<const unsigned char*>(source.get_buffer()); - unsigned char *out_p = static_cast<unsigned char*>(target.get_buffer()); - - if (in_p && out_p) while(in_len--) { - unsigned char cur_byte = *in_p++; - size_t cpy_len = size_t((cur_byte & 0x7F) + 1U); - - if (cpy_len > max_len) { - throw ::Compression::CompressionException(); - } else if (cur_byte & 0x80) { // compressed - if (in_len--) { - ACE_OS::memset(out_p, *in_p++, cpy_len); - } else { - throw ::Compression::CompressionException(); - } - } else if (in_len >= cpy_len) { - ACE_OS::memcpy(out_p, in_p, cpy_len); in_p += cpy_len; in_len -= cpy_len; - } else { - throw ::Compression::CompressionException(); - } - - out_p += cpy_len; - max_len -= cpy_len; - out_len += cpy_len; + ACE_UINT64 out_len = ACE_RLECompression::instance()->decompress(source.get_buffer(), + source.length(), + target.get_buffer(), + target.length() ); + if (ACE_UINT64(-1) == out_len) { // Overrun + throw ::Compression::CompressionException(); } target.length(static_cast<CORBA::ULong>(out_len)); diff --git a/TAO/tao/Compression/rle/RLECompressor.mpc b/TAO/tao/Compression/rle/RLECompressor.mpc index 8577e361d56..784f6c35eff 100644 --- a/TAO/tao/Compression/rle/RLECompressor.mpc +++ b/TAO/tao/Compression/rle/RLECompressor.mpc @@ -1,6 +1,6 @@ //$Id$ -project(RLECompressor) : taolib, tao_output, install, compression, taoidldefaults { +project(RLECompressor) : ace_rlecompressionlib, taolib, tao_output, install, compression, taoidldefaults { sharedname = TAO_RLECompressor dynamicflags += TAO_RLECOMPRESSOR_BUILD_DLL diff --git a/TAO/tao/Compression/rle/RLECompressor_Factory.cpp b/TAO/tao/Compression/rle/RLECompressor_Factory.cpp index e7cc0a19bd9..7ca12ad6e73 100644 --- a/TAO/tao/Compression/rle/RLECompressor_Factory.cpp +++ b/TAO/tao/Compression/rle/RLECompressor_Factory.cpp @@ -17,10 +17,13 @@ Compression::Compressor_ptr RLE_CompressorFactory::get_compressor(Compression::CompressionLevel) { if (::CORBA::is_nil(this->compressor_.in())) { - this->compressor_ = new ::TAO::RLECompressor(this); + ::Compression::Compressor_ptr compressor; + ACE_NEW_RETURN( compressor, ::TAO::RLECompressor(this), 0 ); + this->compressor_ = compressor; } return ::Compression::Compressor::_duplicate(this->compressor_.in()); } } TAO_END_VERSIONED_NAMESPACE_DECL + diff --git a/TAO/tao/Compression/rle/TAO_RLECompressor.rc b/TAO/tao/Compression/rle/TAO_RLECompressor.rc index 7d04dd8375e..25c1dda6d77 100644 --- a/TAO/tao/Compression/rle/TAO_RLECompressor.rc +++ b/TAO/tao/Compression/rle/TAO_RLECompressor.rc @@ -28,3 +28,4 @@ BEGIN VALUE "Translation", 0x409, 1200 END END + diff --git a/TAO/tests/Compression/RLECompressorTest.cpp b/TAO/tests/Compression/RLECompressorTest.cpp index 61b7d28c2d0..7a4b9acfd33 100644 --- a/TAO/tests/Compression/RLECompressorTest.cpp +++ b/TAO/tests/Compression/RLECompressorTest.cpp @@ -2,6 +2,7 @@ #include "ace/Log_Msg.h" #include "ace/High_Res_Timer.h" +#include "ace/Compression/rle/RLECompressor.h" #include "tao/ORB.h" #include "tao/objectid.h" @@ -27,6 +28,9 @@ 00 00 44 00 00 00 00 00 00 00 00 00 00 44 00 00 ..D..........D.. 00 45 00 00 00 00 00 00 00 00 00 00 00 00 45 00 .E............E. 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 F..............F + + ******** TEST RLE Compressor ************ + Compress Time - total 0.000033 secs Compressed Buffer - HEXDUMP 114 bytes 00 30 8d 00 02 30 00 31 8b 00 00 31 82 00 00 32 .0...0.1...1...2 89 00 00 32 84 00 00 33 87 00 00 33 86 00 00 34 ...2...3...3...4 @@ -36,25 +40,11 @@ 85 00 00 42 86 00 00 43 87 00 00 43 84 00 00 44 ...B...C...C...D 89 00 00 44 82 00 00 45 8b 00 02 45 00 46 8d 00 ...D...E...E.F.. 00 46 .F - Decompressed Buffer - HEXDUMP 256 bytes - 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 0..............0 - 00 31 00 00 00 00 00 00 00 00 00 00 00 00 31 00 .1............1. - 00 00 32 00 00 00 00 00 00 00 00 00 00 32 00 00 ..2..........2.. - 00 00 00 33 00 00 00 00 00 00 00 00 33 00 00 00 ...3........3... - 00 00 00 00 34 00 00 00 00 00 00 34 00 00 00 00 ....4......4.... - 00 00 00 00 00 35 00 00 00 00 35 00 00 00 00 00 .....5....5..... - 00 00 00 00 00 00 36 00 00 36 00 00 00 00 00 00 ......6..6...... - 00 00 00 00 00 00 00 37 37 00 00 00 00 00 00 00 .......77....... - 00 00 00 00 00 00 00 38 38 00 00 00 00 00 00 00 .......88....... - 00 00 00 00 00 00 39 00 00 39 00 00 00 00 00 00 ......9..9...... - 00 00 00 00 00 41 00 00 00 00 41 00 00 00 00 00 .....A....A..... - 00 00 00 00 42 00 00 00 00 00 00 42 00 00 00 00 ....B......B.... - 00 00 00 43 00 00 00 00 00 00 00 00 43 00 00 00 ...C........C... - 00 00 44 00 00 00 00 00 00 00 00 00 00 44 00 00 ..D..........D.. - 00 45 00 00 00 00 00 00 00 00 00 00 00 00 45 00 .E............E. - 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 F..............F - RLE Compression Ratio = 2.245614 : 1 - Blocking for 10 Seconds. + DeCompress Time - total 0.000002 secs + ********* END TEST ************ + ACE::RLECompression Ratio = 0.445313 : 1 + TAO::RLECompression Ratio = 0.445313 : 1 */ static char test_array[] = { @@ -123,8 +113,8 @@ static int test_compressor(const ::Compression::Compressor_var &compressor) ACE_TEXT("ERROR: nil Compressor.\n")),-1); } - ::CORBA::ULong in_len = static_cast< ::CORBA::ULong>(sizeof(test_array)); - ::CORBA::Octet* in_buf = reinterpret_cast< ::CORBA::Octet*>(test_array); + ::CORBA::ULong in_len = static_cast< CORBA::ULong>(sizeof(test_array)); + ::CORBA::Octet* in_buf = reinterpret_cast< CORBA::Octet*>(test_array); ::Compression::Buffer in_data(in_len, in_len, in_buf, false); @@ -137,8 +127,6 @@ static int test_compressor(const ::Compression::Compressor_var &compressor) compressor->compress(in_data, comp_out); } - Compression::CompressionRatio ratio = compressor->compression_ratio(); - ACE_HEX_DUMP(( LM_INFO, reinterpret_cast<const char*>(comp_out.get_buffer()), comp_out.length(), @@ -159,7 +147,7 @@ static int test_compressor(const ::Compression::Compressor_var &compressor) ACE_TEXT("ERROR: Did not Compress/Decompress correctly.\n")),-1); } - ACE_ERROR_RETURN((LM_INFO, ACE_TEXT("Compression Ratio = %f : 1\n\n"), ratio), 0); + ACE_ERROR_RETURN((LM_INFO, ACE_TEXT("\n********* END TEST ************\n")), 0); } int @@ -185,7 +173,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) ACE_TEXT("ERROR: nil compression manager.\n")),-1); } - ACE_HEX_DUMP((LM_INFO, + ACE_HEX_DUMP(( LM_INFO, test_array, sizeof(test_array), ACE_TEXT("Original Buffer") @@ -193,9 +181,19 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) ACE_DEBUG((LM_INFO, ACE_TEXT("\n******** TEST RLE Compressor ************\n"))); - test_compressor(::Compression::Compressor_var(manager->get_compressor(::Compression::COMPRESSORID_RLE, 0))); - ACE_DEBUG((LM_INFO, ACE_TEXT("\n********* END TEST - Block for 10 Seconds ************\n"))); + ::Compression::Compressor_var rleCompressor = manager->get_compressor(::Compression::COMPRESSORID_RLE, 0); + + if (::CORBA::is_nil(rleCompressor.in())) { + ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: Unable to locate TAO::RLECompressor - exiting.\n")),-1); + } else if (test_compressor(rleCompressor) == -1) { + ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: TAO::RLECompressor reported an error - exiting.\n")),-1); + } + + float ace_ratio = ACE_RLECompression::instance()->compression_ratio(); + ACE_DEBUG((LM_INFO, ACE_TEXT("ACE::RLECompression Ratio = %f : 1\n"), ace_ratio)); + float tao_ratio = rleCompressor->compression_ratio(); + ACE_DEBUG((LM_INFO, ACE_TEXT("TAO::RLECompression Ratio = %f : 1\n"), tao_ratio)); orb->shutdown (); @@ -206,3 +204,4 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) return 0; } + |