33 #define COMPRESS_ONLY_K 34 #undef COMPRESS_ONLY_K 36 #define CREATE_HISTOGRAMS 37 #undef CREATE_HISTOGRAMS 42 #ifdef CREATE_HISTOGRAMS 73 else if (bits && bits < 32)
95 #ifdef CREATE_HISTOGRAMS 100 for (
int c = 0; c <= (1<<
k); c++)
135 else if (bits && bits < 32)
170 #ifndef COMPRESS_ONLY_K 184 #ifdef CREATE_HISTOGRAMS 187 int total_number = 0;
188 double total_entropy = 0.0f;
189 double total_raw = 0.0f;
194 for (
int c = 0; c <= (1<<
k); c++)
198 double prob,entropy = 0.0f;
199 for (c = 0; c <= (1<<
k); c++)
205 entropy -= log(prob)*prob/log(2.0);
208 fprintf(stderr,
"k: %d number: %d different: %d entropy: %lg raw: %1.1f\n",
k,number,different,entropy, (
float)(
k?
k:1));
209 total_number += number;
210 total_entropy += (entropy*number);
211 total_raw += ((k?
k:1)*number);
213 fprintf(stderr,
"TOTAL: number: %d entropy: %lg raw: %lg\n",total_number,total_entropy/total_number,total_raw/total_number);
232 #ifndef COMPRESS_ONLY_K 254 #ifndef COMPRESS_ONLY_K 267 I32 corr = real - pred;
288 #ifndef COMPRESS_ONLY_K 310 #ifndef COMPRESS_ONLY_K 373 c1 = (c <= 0 ? -c : c-1);
388 #ifdef COMPRESS_ONLY_K 391 assert((c != 0) && (c != 1));
399 #ifdef CREATE_HISTOGRAMS 407 #ifdef CREATE_HISTOGRAMS 415 assert((c == 0) || (c == 1));
417 #ifdef CREATE_HISTOGRAMS 421 #else // COMPRESS_ONLY_K 424 assert((c != 0) && (c != 1));
448 c1 = c & ((1<<k1) - 1);
460 assert((c == 0) || (c == 1));
463 #endif // COMPRESS_ONLY_K 476 #ifdef COMPRESS_ONLY_K 503 #else // COMPRESS_ONLY_K 545 #endif // COMPRESS_ONLY_K I32 decompress(I32 iPred, U32 context=0)
virtual void encodeSymbol(EntropyModel *model, U32 sym)=0
virtual void initBitModel(EntropyModel *model)=0
virtual U32 decodeSymbol(EntropyModel *model)=0
virtual void destroyBitModel(EntropyModel *model)=0
virtual void destroyBitModel(EntropyModel *model)=0
EntropyModel ** mCorrector
virtual void destroySymbolModel(EntropyModel *model)=0
virtual void destroySymbolModel(EntropyModel *model)=0
virtual EntropyModel * createBitModel()=0
virtual void encodeBit(EntropyModel *model, U32 bit)=0
virtual void initSymbolModel(EntropyModel *model, U32 *init=0)=0
IntegerCompressor(EntropyEncoder *enc, U32 bits=16, U32 contexts=1, U32 bits_high=8, U32 range=0)
I32 readCorrector(EntropyModel *model)
virtual EntropyModel * createSymbolModel(U32 n)=0
virtual U32 decodeBit(EntropyModel *model)=0
virtual EntropyModel * createSymbolModel(U32 n)=0
void writeCorrector(I32 c, EntropyModel *model)
void compress(I32 iPred, I32 iReal, U32 context=0)
virtual void initBitModel(EntropyModel *model)=0
virtual EntropyModel * createBitModel()=0
virtual void writeBits(U32 bits, U32 sym)=0
virtual void initSymbolModel(EntropyModel *model, U32 *init=0)=0
virtual U32 readBits(U32 bits)=0
virtual void writeBit(U32 sym)=0