diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2012-02-23 07:57:08 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2012-02-23 07:57:08 +0000 |
commit | 35f6e6ab12347a5b1d0f8cb626fae4bf4b59b32e (patch) | |
tree | 1c7b19615a7a4c79126da6fc92258e2056b156ad | |
parent | a52d413f97fc4fbe3c5b7138f7522184d0a7ac57 (diff) | |
download | ATCD-35f6e6ab12347a5b1d0f8cb626fae4bf4b59b32e.tar.gz |
Thu Feb 23 07:52:58 UTC 2012 Johnny Willemsen <jwillemsen@remedy.nl>
* ace/Compression:
* ace/Compression/ACE_Compression.mpc:
* ace/Compression/ACE_Compression_export.h:
* ace/Compression/Compressor.h:
* ace/Compression/Compressor.inl:
* ace/Compression/Compressor.cpp:
* ace/Compression/rle:
* ace/Compression/rle/ACE_RLECompression.mpc:
* ace/Compression/rle/ACE_RLECompression_export.h:
* ace/Compression/rle/RLECompressor.h:
* ace/Compression/rle/RLECompressor.cpp:
* bin/MakeProjectCreator/config/ace_compressionlib.mpb:
* bin/MakeProjectCreator/config/ace_rlecompressionlib.mpb:
Added new ACE compression and rle compressor libraries. This code
was first part of TAO, but now moved to ACE because it provides
a basic run length encoding compressor that makes it possible to
compress data without depending on any external library
* docs/bczar/bczar.html:
Added package
-rw-r--r-- | ACE/ChangeLog | 23 | ||||
-rw-r--r-- | ACE/ace/Compression/ACE_Compression.mpc | 26 | ||||
-rw-r--r-- | ACE/ace/Compression/ACE_Compression_export.h | 58 | ||||
-rw-r--r-- | ACE/ace/Compression/Compressor.cpp | 59 | ||||
-rw-r--r-- | ACE/ace/Compression/Compressor.h | 135 | ||||
-rw-r--r-- | ACE/ace/Compression/Compressor.inl | 18 | ||||
-rw-r--r-- | ACE/ace/Compression/rle/ACE_RLECompression.mpc | 20 | ||||
-rw-r--r-- | ACE/ace/Compression/rle/ACE_RLECompression_export.h | 57 | ||||
-rw-r--r-- | ACE/ace/Compression/rle/RLECompressor.cpp | 154 | ||||
-rw-r--r-- | ACE/ace/Compression/rle/RLECompressor.h | 111 | ||||
-rw-r--r-- | ACE/bin/MakeProjectCreator/config/ace_compressionlib.mpb | 4 | ||||
-rw-r--r-- | ACE/bin/MakeProjectCreator/config/ace_rlecompressionlib.mpb | 4 | ||||
-rw-r--r-- | ACE/docs/bczar/bczar.html | 2 |
13 files changed, 670 insertions, 1 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 9c4f7f1e3b4..55c7d3ddff0 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,26 @@ +Thu Feb 23 07:52:58 UTC 2012 Johnny Willemsen <jwillemsen@remedy.nl> + + * ace/Compression: + * ace/Compression/ACE_Compression.mpc: + * ace/Compression/ACE_Compression_export.h: + * ace/Compression/Compressor.h: + * ace/Compression/Compressor.inl: + * ace/Compression/Compressor.cpp: + * ace/Compression/rle: + * ace/Compression/rle/ACE_RLECompression.mpc: + * ace/Compression/rle/ACE_RLECompression_export.h: + * ace/Compression/rle/RLECompressor.h: + * ace/Compression/rle/RLECompressor.cpp: + * bin/MakeProjectCreator/config/ace_compressionlib.mpb: + * bin/MakeProjectCreator/config/ace_rlecompressionlib.mpb: + Added new ACE compression and rle compressor libraries. This code + was first part of TAO, but now moved to ACE because it provides + a basic run length encoding compressor that makes it possible to + compress data without depending on any external library + + * docs/bczar/bczar.html: + Added package + Tue Feb 21 14:52:02 UTC 2012 Adam Mitz <mitza@ociweb.com> * ace/OS_NS_Thread.inl: diff --git a/ACE/ace/Compression/ACE_Compression.mpc b/ACE/ace/Compression/ACE_Compression.mpc new file mode 100644 index 00000000000..f8ccd21a89f --- /dev/null +++ b/ACE/ace/Compression/ACE_Compression.mpc @@ -0,0 +1,26 @@ +// -*- MPC -*- +// $Id: + +project(ACE_Compression) : acelib, install, ace_output { + sharedname = * + dynamicflags += ACE_COMPRESSION_BUILD_DLL + + //prebuild = perl $(ACE_ROOT)/bin/generate_export_file.pl ACE_Compression > ACE_Compression_export.h + + Source_Files { + Compressor.cpp + } + + Header_Files { + Compressor.h + ACE_Compression_export.h + } + + Inline_Files { + Compressor.inl + } + + specific { + install_dir = ace/lib + } +} diff --git a/ACE/ace/Compression/ACE_Compression_export.h b/ACE/ace/Compression/ACE_Compression_export.h new file mode 100644 index 00000000000..bccba30aa21 --- /dev/null +++ b/ACE/ace/Compression/ACE_Compression_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ACE_Compression +// ------------------------------ +#ifndef ACE_COMPRESSION_EXPORT_H +#define ACE_COMPRESSION_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (ACE_COMPRESSION_HAS_DLL) +# define ACE_COMPRESSION_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && ACE_COMPRESSION_HAS_DLL */ + +#if !defined (ACE_COMPRESSION_HAS_DLL) +# define ACE_COMPRESSION_HAS_DLL 1 +#endif /* ! ACE_COMPRESSION_HAS_DLL */ + +#if defined (ACE_COMPRESSION_HAS_DLL) && (ACE_COMPRESSION_HAS_DLL == 1) +# if defined (ACE_COMPRESSION_BUILD_DLL) +# define ACE_Compression_Export ACE_Proper_Export_Flag +# define ACE_COMPRESSION_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define ACE_COMPRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* ACE_COMPRESSION_BUILD_DLL */ +# define ACE_Compression_Export ACE_Proper_Import_Flag +# define ACE_COMPRESSION_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define ACE_COMPRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* ACE_COMPRESSION_BUILD_DLL */ +#else /* ACE_COMPRESSION_HAS_DLL == 1 */ +# define ACE_Compression_Export +# define ACE_COMPRESSION_SINGLETON_DECLARATION(T) +# define ACE_COMPRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* ACE_COMPRESSION_HAS_DLL == 1 */ + +// Set ACE_COMPRESSION_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (ACE_COMPRESSION_NTRACE) +# if (ACE_NTRACE == 1) +# define ACE_COMPRESSION_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define ACE_COMPRESSION_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !ACE_COMPRESSION_NTRACE */ + +#if (ACE_COMPRESSION_NTRACE == 1) +# define ACE_COMPRESSION_TRACE(X) +#else /* (ACE_COMPRESSION_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define ACE_COMPRESSION_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (ACE_COMPRESSION_NTRACE == 1) */ + +#endif /* ACE_COMPRESSION_EXPORT_H */ + +// End of auto generated file. diff --git a/ACE/ace/Compression/Compressor.cpp b/ACE/ace/Compression/Compressor.cpp new file mode 100644 index 00000000000..21408b9a455 --- /dev/null +++ b/ACE/ace/Compression/Compressor.cpp @@ -0,0 +1,59 @@ +// $Id$ + +#include "Compressor.h" + +#if !defined (__ACE_INLINE__) +#include "Compressor.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Compressor::ACE_Compressor( ACE_CompressorId compressor_id, + ACE_UINT32 compression_level ) + : compressor_id_ (compressor_id) + , compression_level_ (compression_level) + , compressed_bytes_ (0) + , uncompressed_bytes_ (0) +{} + +ACE_UINT64 +ACE_Compressor::compressed_bytes(void) const +{ + ACE_GUARD_RETURN( ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0 ); + return this->compressed_bytes_; +} + +ACE_UINT64 +ACE_Compressor::uncompressed_bytes(void) const +{ + ACE_GUARD_RETURN( ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0 ); + return this->uncompressed_bytes_; +} + +void +ACE_Compressor::reset_stats(void) +{ + ACE_GUARD( ACE_SYNCH_MUTEX, ace_mon, this->mutex_ ); + this->compressed_bytes_ = 0; + this->uncompressed_bytes_ = 0; +} + +void +ACE_Compressor::update_stats(ACE_UINT64 uncompressed_bytes, ACE_UINT64 compressed_bytes) +{ + ACE_GUARD( ACE_SYNCH_MUTEX, ace_mon, this->mutex_ ); + this->compressed_bytes_ += compressed_bytes; + this->uncompressed_bytes_ += uncompressed_bytes; +} + +float +ACE_Compressor::compression_ratio(void) const +{ + ACE_GUARD_RETURN( ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0.0f ); + if (this->uncompressed_bytes_ > 0) { + return static_cast<float>(this->compressed_bytes_) / this->uncompressed_bytes_; + } + return 0.0f; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Compression/Compressor.h b/ACE/ace/Compression/Compressor.h new file mode 100644 index 00000000000..12bc43226e4 --- /dev/null +++ b/ACE/ace/Compression/Compressor.h @@ -0,0 +1,135 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file Compressor.h + * + * $Id: Compressor.h + * + * @author ACE version by + * @author Derek Dominish <derek.dominish@dsto.defence.gov.au> + */ +//============================================================================= + +#ifndef ACE_COMPRESSOR_H +#define ACE_COMPRESSOR_H + +#include /**/ "ace/pre.h" + +#include /**/ "ACE_Compression_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Guard_T.h" +#include "ace/Thread_Mutex.h" +#include "ace/Synch_Traits.h" +#include "ace/Copy_Disabled.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * CompressorId from OMG Compression::CompressorId + * see $(TAO_ROOT)/tao/Compression.pidl + */ +enum ACE_CompressorId +{ + ACE_COMPRESSORID_NONE = 0, + ACE_COMPRESSORID_GZIP = 1, + ACE_COMPRESSORID_PKZIP = 2, + ACE_COMPRESSORID_BZIP2 = 3, + ACE_COMPRESSORID_ZLIB = 4, + ACE_COMPRESSORID_LZMA = 5, + ACE_COMPRESSORID_LZO = 6, + ACE_COMPRESSORID_RZIP = 7, + ACE_COMPRESSORID_7X = 8, + ACE_COMPRESSORID_XAR = 9, + ACE_COMPRESSORID_RLE = 10 +}; + +class ACE_Compression_Export ACE_Compressor : ACE_Copy_Disabled +{ +public: + + ACE_CompressorId get_compressor_id(void) const; + + ACE_UINT32 get_compression_level(void) const; + + /** + * Compress the @a in_ptr buffer for @a in_len into the + * @a dest_ptr buffer with a maximum @a max_out_len. If the + * @a max_out_len is exhausted through the compress process + * then a value of -1 will be returned from the function, + * otherwise the return value will indicate the resultant + * @a out_ptr compressed buffer length. + * + * NOTE: it is advisable that the @max_out_len be slightly + * larger of the input @a in_len (i.e. x 1.1F) to cater + * for the possibility that a reduced compressed length + * is not possible. + */ + virtual ACE_UINT64 compress( const void *in_ptr, + ACE_UINT64 in_len, + void *out_ptr, + ACE_UINT64 max_out_len ) = 0; + + /** + * DeCompress the @a in_ptr buffer for @a in_len into the + * @a out_ptr buffer with a maximum @a max_out_len. If the + * @a max_out_len is exhausted during decompression + * then a value of -1 will be returned from the function, + * otherwise the return value will indicate the resultant + * @a out_ptr decompressed buffer length. + */ + virtual ACE_UINT64 decompress( const void *in_ptr, + ACE_UINT64 in_len, + void *out_ptr, + ACE_UINT64 max_out_len ) = 0; + + /** + * Return the current compressed bytes statistics counter. + */ + virtual ACE_UINT64 compressed_bytes(void) const; + + /** + * Return the current uncompressed bytes statistics counter. + */ + virtual ACE_UINT64 uncompressed_bytes(void) const; + + /** + * Return the current compression ratio statistics. + */ + virtual float compression_ratio(void) const; + + /** + * Reset the statistics to zero. + */ + virtual void reset_stats(void); + +protected: + ACE_Compressor(ACE_CompressorId compressor_id, + ACE_UINT32 compression_level = 0); // Must be inherited. + + virtual void update_stats( ACE_UINT64 uncompressed_bytes, + ACE_UINT64 compressed_bytes ); + +private: + ACE_CompressorId compressor_id_; + ACE_UINT32 compression_level_; + + // Ensure we can lock with imutability (i.e. const) + mutable ACE_SYNCH_MUTEX mutex_; + + ACE_UINT64 compressed_bytes_; + ACE_UINT64 uncompressed_bytes_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "Compressor.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif // ACE_COMPRESSOR_H
\ No newline at end of file diff --git a/ACE/ace/Compression/Compressor.inl b/ACE/ace/Compression/Compressor.inl new file mode 100644 index 00000000000..4d0ed2bfbb3 --- /dev/null +++ b/ACE/ace/Compression/Compressor.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// $Id$ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_CompressorId +ACE_Compressor::get_compressor_id(void) const +{ + return this->compressor_id_; +} + +ACE_INLINE ACE_UINT32 +ACE_Compressor::get_compression_level(void) const +{ + return this->compression_level_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Compression/rle/ACE_RLECompression.mpc b/ACE/ace/Compression/rle/ACE_RLECompression.mpc new file mode 100644 index 00000000000..31316ea0740 --- /dev/null +++ b/ACE/ace/Compression/rle/ACE_RLECompression.mpc @@ -0,0 +1,20 @@ +// -*- MPC -*- +// $Id: + +project(ACE_RLECompression) : ace_compressionlib, install, ace_output { + sharedname = * + dynamicflags += ACE_RLECOMPRESSION_BUILD_DLL + + Source_Files { + RLECompressor.cpp + } + + Header_Files { + RLECompressor.h + ACE_RLECompression_export.h + } + + specific { + install_dir = ace/lib + } +} diff --git a/ACE/ace/Compression/rle/ACE_RLECompression_export.h b/ACE/ace/Compression/rle/ACE_RLECompression_export.h new file mode 100644 index 00000000000..85b20f0cbca --- /dev/null +++ b/ACE/ace/Compression/rle/ACE_RLECompression_export.h @@ -0,0 +1,57 @@ +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ACE_RLECompression +// ------------------------------ +#ifndef ACE_RLECOMPRESSION_EXPORT_H +#define ACE_RLECOMPRESSION_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (ACE_RLECOMPRESSION_HAS_DLL) +# define ACE_RLECOMPRESSION_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && ACE_RLECOMPRESSION_HAS_DLL */ + +#if !defined (ACE_RLECOMPRESSION_HAS_DLL) +# define ACE_RLECOMPRESSION_HAS_DLL 1 +#endif /* ! ACE_RLECOMPRESSION_HAS_DLL */ + +#if defined (ACE_RLECOMPRESSION_HAS_DLL) && (ACE_RLECOMPRESSION_HAS_DLL == 1) +# if defined (ACE_RLECOMPRESSION_BUILD_DLL) +# define ACE_RLECompression_Export ACE_Proper_Export_Flag +# define ACE_RLECOMPRESSION_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define ACE_RLECOMPRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* ACE_RLECOMPRESSION_BUILD_DLL */ +# define ACE_RLECompression_Export ACE_Proper_Import_Flag +# define ACE_RLECOMPRESSION_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define ACE_RLECOMPRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* ACE_RLECOMPRESSION_BUILD_DLL */ +#else /* ACE_RLECOMPRESSION_HAS_DLL == 1 */ +# define ACE_RLECompression_Export +# define ACE_RLECOMPRESSION_SINGLETON_DECLARATION(T) +# define ACE_RLECOMPRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* ACE_RLECOMPRESSION_HAS_DLL == 1 */ + +// Set ACE_RLECOMPRESSION_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (ACE_RLECOMPRESSION_NTRACE) +# if (ACE_NTRACE == 1) +# define ACE_RLECOMPRESSION_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define ACE_RLECOMPRESSION_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !ACE_RLECOMPRESSION_NTRACE */ + +#if (ACE_RLECOMPRESSION_NTRACE == 1) +# define ACE_RLECOMPRESSION_TRACE(X) +#else /* (ACE_RLECOMPRESSION_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define ACE_RLECOMPRESSION_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (ACE_RLECOMPRESSION_NTRACE == 1) */ + +#endif /* ACE_RLECOMPRESSION_EXPORT_H */ + +// End of auto generated file. diff --git a/ACE/ace/Compression/rle/RLECompressor.cpp b/ACE/ace/Compression/rle/RLECompressor.cpp new file mode 100644 index 00000000000..1d924aa0a05 --- /dev/null +++ b/ACE/ace/Compression/rle/RLECompressor.cpp @@ -0,0 +1,154 @@ +// $Id$ + +#include "RLECompressor.h" +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_RLECompressor::ACE_RLECompressor(void) + : ACE_Compressor(ACE_COMPRESSORID_RLE) +{ +} + +ACE_UINT64 +ACE_RLECompressor::compress( const void *in_ptr, + ACE_UINT64 in_len, + void *out_ptr, + ACE_UINT64 max_out_len ) +{ + const ACE_UINT8 *in_p = static_cast<const ACE_UINT8*>(in_ptr); + ACE_UINT8 *out_p = static_cast<ACE_UINT8*>(out_ptr); + + ACE_UINT64 src_len = in_len; // Save for stats + ACE_UINT64 out_len = 0; + ACE_UINT64 out_index = 0; + ACE_UINT64 out_base = 0; + + ACE_UINT32 run_count = 0; + ACE_UINT32 dup_count = 0; + + bool run_code = false; + + ACE_UINT8 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] = ACE_UINT8(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 >= max_out_len) { + return ACE_UINT64(-1); // Output Exhausted + } else if (in_len == 0) { + continue; + } + + run_code = false; + out_p[out_base = out_index] = 0; + dup_count = run_count = 0; + continue; + } + + switch (run_count) { + + case 128: + + if (++out_index >= max_out_len) { + return -1; // Output Exhausted + } + 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<ACE_UINT8>(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<ACE_UINT8>(run_count++ | 0x80); + break; + } + } else dup_count = 0; + } + out_p[out_base] = char(run_count++); + break; + } + + if (++out_index >= max_out_len) { + return ACE_UINT64(-1); // Output Exhausted + } + + out_p[out_index] = cur_byte; + } + + out_len = ++out_index; // Update our output length + + this->update_stats(src_len, out_len); + + return out_len; +} + +// Decompress using Run Length Encoding (RLE) +ACE_UINT64 +ACE_RLECompressor::decompress( const void *in_ptr, + ACE_UINT64 in_len, + void *out_ptr, + ACE_UINT64 max_out_len ) +{ + ACE_UINT64 out_len = 0; + + const ACE_UINT8 *in_p = static_cast<const ACE_UINT8*>(in_ptr); + ACE_UINT8 *out_p = static_cast<ACE_UINT8*>(out_ptr); + + if (in_p && out_p) while(in_len-- > 0) { + + ACE_UINT8 cur_byte = *in_p++; + ACE_UINT32 cpy_len = ACE_UINT32((cur_byte & 0x7F) + 1); + + if (cpy_len > max_out_len) { + return ACE_UINT64(-1); // Output Exhausted + } else if ((cur_byte & 0x80) != 0) { // compressed + if (in_len-- > 0) { + ACE_OS::memset(out_p, *in_p++, cpy_len); + } else { + return ACE_UINT64(-1); // Output Exhausted + } + } else if (in_len >= cpy_len) { + ACE_OS::memcpy(out_p, in_p, cpy_len); + in_p += cpy_len; + in_len -= cpy_len; + } else { + return ACE_UINT64(-1); // Output Exhausted + } + + out_p += cpy_len; + max_out_len -= cpy_len; + out_len += cpy_len; + } + + return out_len; +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Compression/rle/RLECompressor.h b/ACE/ace/Compression/rle/RLECompressor.h new file mode 100644 index 00000000000..db00eb12ee1 --- /dev/null +++ b/ACE/ace/Compression/rle/RLECompressor.h @@ -0,0 +1,111 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file RLECompressor.h + * + * $Id: RLECompressor.h + * + * @author TAO version by + * @author Derek Dominish <derek.dominish@dsto.defence.gov.au> + * @author ACE version by + * @author Derek Dominish <derek.dominish@dsto.defence.gov.au> + * + * Run-length encoding (RLE) is a very simple form of data compression + * in which runs of data (that is, sequences in which the same data value + * occurs in many consecutive data elements) are stored as a single data + * value and count, rather than as the original run. This is most useful + * on data that contains many such runs: for example, simple graphic + * images such as icons, line drawings, and animations. It is not useful + * with files that don't have many runs as it could slightly increase the + * output size. + * ALGORITHM: This algorithm is an optimised version of the traditional + * RLE algorithm in that it behaves better with very few runs. + * + * With a run of a character where that run is >= 3 this is + * replaced with the repeat indicator 0X80 and then the repeat count OR'd + * over this ident. This repeat count is therefore has a maximum value + * of 127 (0x7F) which is to be interpreted as the next charater repeated + * another 'repeat count' times (i.e. a maximum of 128 characters can be + * represented in any single dupal). if the repeat ident is not present + * then the count is to be interpreted as a copy of the next repeat count + * charaters + 1. + * + * EXAMPLE: the following arbitary string of 67 bytes:- + * WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW + * will produce (as a HEXDUMP) of 14 bytes + * 8B 57 00 42 8B 57 82 42 97 57 00 42 8D 57 .W.B.W.B.W.B.W + */ +//============================================================================= + +#ifndef ACE_RLECOMPRESSOR_H +#define ACE_RLECOMPRESSOR_H + +#include /**/ "ace/pre.h" + +#include "ACE_RLECompression_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Compression/Compressor.h" +#include "ace/Singleton.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_RLECompression_Export ACE_RLECompressor : public ACE_Compressor +{ +public: + /** + * Default constructor. Should use instance() to get global instance. + */ + ACE_RLECompressor(void); + + /** + * Compress the @a in_ptr buffer for @a in_len into the + * @a dest_ptr buffer with a maximum @a max_out_len using + * the Run Length Ecoding (RLE) algorithm. If the + * @a max_out_len is exhausted through the compress process + * then a value of -1 will be returned from the function, + * otherwise the return value will indicate the resultant + * @a out_ptr compressed buffer length. + * + * @note It is advisable that the @max_out_len be slightly + * larger of the input @a in_len (i.e. x 1.1F) to cater + * for the possibility that a reduced compressed length + * is not possible. + */ + virtual ACE_UINT64 compress( const void *in_ptr, + ACE_UINT64 in_len, + void *out_ptr, + ACE_UINT64 max_out_len ); + + /** + * DeCompress the @a in_ptr buffer for @a in_len into the + * @a out_ptr buffer with a maximum @a max_out_len using + * the Run Length Ecoding (RLE) algorithm. If the + * @a max_out_len is exhausted during decompression + * then a value of -1 will be returned from the function, + * otherwise the return value will indicate the resultant + * @a out_ptr decompressed buffer length. + */ + virtual ACE_UINT64 decompress( const void *in_ptr, + ACE_UINT64 in_len, + void *out_ptr, + ACE_UINT64 max_out_len ); +}; + +typedef class ACE_Singleton<ACE_RLECompressor, ACE_SYNCH_MUTEX> ACE_RLECompression; + +// This is needed to get only one of these defined across a set of DLLs and EXE +#if defined(ACE_RLECOMPRESSION_BUILD_DLL) + ACE_EXPORT_SINGLETON_DECLARE(ACE_Singleton, ACE_RLECompressor, ACE_SYNCH_MUTEX); +#else + ACE_IMPORT_SINGLETON_DECLARE(ACE_Singleton, ACE_RLECompressor, ACE_SYNCH_MUTEX); +#endif + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif // ACE_RLECOMPRESSOR_H
\ No newline at end of file diff --git a/ACE/bin/MakeProjectCreator/config/ace_compressionlib.mpb b/ACE/bin/MakeProjectCreator/config/ace_compressionlib.mpb new file mode 100644 index 00000000000..a67ad93fd81 --- /dev/null +++ b/ACE/bin/MakeProjectCreator/config/ace_compressionlib.mpb @@ -0,0 +1,4 @@ +project : acelib { + libs += ACE_Compression + after += ACE_Compression +}
\ No newline at end of file diff --git a/ACE/bin/MakeProjectCreator/config/ace_rlecompressionlib.mpb b/ACE/bin/MakeProjectCreator/config/ace_rlecompressionlib.mpb new file mode 100644 index 00000000000..62c20687e88 --- /dev/null +++ b/ACE/bin/MakeProjectCreator/config/ace_rlecompressionlib.mpb @@ -0,0 +1,4 @@ +project : ace_compressionlib { + libs += ACE_RLECompression + after += ACE_RLECompression +}
\ No newline at end of file diff --git a/ACE/docs/bczar/bczar.html b/ACE/docs/bczar/bczar.html index 509693b15a6..f6f6cc3fed2 100644 --- a/ACE/docs/bczar/bczar.html +++ b/ACE/docs/bczar/bczar.html @@ -107,7 +107,7 @@ </ul> If you want to perform a full build with qt support, than run: <ul> - <li><code>yum install gnuplot java-1.6.0-openjdk git-svn perl svn screen pysvn automake doxygen bzip2 tar gzip openssh graphviz zip libtool gcc-c++ boost-devel valgrind openssl-devel gcc qt4 fltk-devel bzip2-devel rsync openssl lzo-devel zziplib-devel acpid acpi nfs-utils java xerces-c xerces-c-devel mc qt qt-devel icecream ruby ruby-devel lksctp-tools-devel git glibc.i686 libstdc++.i686 ncurses-libs.i686 zlib.i686 telnet GitPython NetworkManager wget mailx</code></li> + <li><code>yum install lcov gnuplot java-1.6.0-openjdk git-svn perl svn screen pysvn automake doxygen bzip2 tar gzip openssh graphviz zip libtool gcc-c++ boost-devel valgrind openssl-devel gcc qt4 fltk-devel bzip2-devel rsync openssl lzo-devel zziplib-devel acpid acpi nfs-utils java xerces-c xerces-c-devel mc qt qt-devel icecream ruby ruby-devel lksctp-tools-devel git glibc.i686 libstdc++.i686 ncurses-libs.i686 zlib.i686 telnet GitPython NetworkManager wget mailx</code></li> </ul> </li> <li> |