/* egprs_rlc_compression.h * Routines for EGPRS RLC bitmap compression handling */ #include #include extern "C" { #include #include #include } #include #include #include #define MAX_CDWDTBL_LEN 79 /* total number of codewords */ #define BITS_TO_BYTES(X) ((X ? (X/8):0)+1) #define MOD8(X) (((X)+8) & (0x07)) typedef struct node { struct node *left; struct node *right; uint16_t *run_length; } Node; extern const char *one_run_len_code_list[MAX_CDWDTBL_LEN]; extern const char *zero_run_len_code_list[MAX_CDWDTBL_LEN]; /* Creating singleton class */ class egprs_compress { static egprs_compress *s_instance; egprs_compress() { ones_list = (Node *)malloc(sizeof(Node)); zeros_list = (Node *)malloc(sizeof(Node)); } void build_codeword(Node *root, const char *cdwd[]); public: static Node *ones_list; static Node *zeros_list; void decode_tree_init(void) { instance()->build_codeword( ones_list, one_run_len_code_list); instance()->build_codeword( zeros_list, zero_run_len_code_list); } static egprs_compress *instance() { if (!s_instance) s_instance = new egprs_compress; return s_instance; } };