/* This file is part of libPPM, a library implementing a SSE PPM
* model for general purpose compression
* Copyright (C) 2004-2011 Niels Fröhling
*
* libPPM.hpp: global header
* Copyright 2004-2011 Niels Fröhling
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef NDEBUG
//#define LOG
#endif
#include "libstreamIO.hpp"
#include "libcoding.hpp"
#ifndef log2
#define log2(v) (log10(v) / log10(2.0))
#endif
#ifndef SLOG2
#define SLOG2
/* return the next power-of-2 number that can contain the given number:
* 32 -> 32
* 33 -> 64
*/
static inline int slog2(register int in) {
#if 1
int lg = 0;
in <<= 1;
in -= 1;
while ((in >>= 1) > 0)
lg++;
return lg;
#else
__asm {
bsf eax, eax
}
#endif
}
#endif
#ifndef _TRUE
#define _TRUE
typedef enum {
FALSE = 0,
TRUE = ~FALSE
} boolean;
#endif
#ifndef NULL
#define NULL (/*(void *)*/0)
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
/* these datatypes are optimized to the smallest size not the best speed */
#ifndef ORD_INITIAL
typedef short int ord;
#define ORD_MAX_BITS ((sizeof(ord) * 8) - 1)
#define ORD_SCALE_BITS ((sizeof(ord) * 8) - 2)
#define ORD_INVALID -1
#define ORD_INITIAL 0
#endif
#ifndef SYM_INITIAL
typedef short int sym;
#define SYM_MAX_BITS ((sizeof(sym) * 8) - 1)
#define SYM_SCALE_BITS ((sizeof(sym) * 8) - 2)
#define SYM_INVALID -1
#define SYM_INITIAL 0
#endif
#ifndef CNT_INITIAL
typedef unsigned short int cnt;
typedef unsigned short int fix;
#define CNT_MAX_BITS ((sizeof(cnt) * 8) - 1)
#define CNT_SCALE_BITS ((sizeof(cnt) * 8) - 2)
#define CNT_INVALID 0x7FFF
#define CNT_INITIAL 0
#endif
#ifndef HSH_INITIAL
typedef unsigned long int hsh;
#define HSH_MAX_BITS ((sizeof(hsh) * 8) - 0)
#define HSH_SCALE_BITS ((sizeof(hsh) * 8) - 1)
#define HSH_INVALID 0xFFFF
#define HSH_INITIAL 0
#endif
#ifndef PROB_INITIAL
typedef long int prob;
#define PROB_MAX_BITS ((sizeof(prob) * 8) - 1)
#define PROB_SCALE_BITS ((sizeof(prob) * 8) - 2)
#define PROB_INVALID 0x7FFFFFFF
#define PROB_INITIAL 0
#endif
typedef short int bits;
#include "libPPM-0.0.0/Context.hpp"
#include "libPPM-0.0.0/DecisionContext.hpp"
#include "libPPM-0.0.0/OverfitContext.hpp"
#include "libPPM-0.0.0/Predictor.hpp"
#include "libPPM-0.0.0/Stream.hpp"
//Concepts and Papers: