00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef UT_COMPRESS_H
00022 #define UT_COMPRESS_H
00023
00024 #ifdef WIN32
00025 #pragma warning(disable:4251)
00026 #pragma warning(disable:4275)
00027 #endif
00028
00029
00030 template <class Type>
00031 class UT_Compress
00032 {
00033 public:
00034 UT_Compress();
00035 ~UT_Compress();
00036
00037
00038
00039 void setChunkSize(int size);
00040
00041
00042 int isConstant(const Type *data, int size = -1) const;
00043
00044
00045
00046
00047
00048 int prefilter(Type *data, int size = -1);
00049 void postfilter(Type *data, int size = -1);
00050
00051
00052
00053 void * encodeRLE(const Type *data, int &result_length, int size =-1,
00054 int stride = 1);
00055 int decodeRLE(const void *data,int size, Type *dest,int stride=1);
00056
00057
00058 void * compress(const void *data, int &result_length, int size =-1,
00059 int level = 1);
00060 int expand (const void *data,int size, void *dest);
00061
00062 unsigned char * getRLEBuf() { return myRLEBuf; }
00063 unsigned char * getCompressBuf() { return myCompressBuf; }
00064
00065 private:
00066 int repeatCount(const Type *data, int max_run, int stride);
00067
00068 int myChunkSize;
00069 unsigned char *myRLEBuf;
00070 unsigned char *myCompressBuf;
00071 };
00072
00073
00074
00075 #include "UT_Compress.C"
00076
00077 #endif