forked from cellular-infrastructure/osmo-pcu
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
/* egprs_rlc_compression.h
|
|
* Routines for EGPRS RLC bitmap compression handling
|
|
*/
|
|
#include <gprs_rlcmac.h>
|
|
#include <gprs_debug.h>
|
|
|
|
extern "C" {
|
|
#include <osmocom/core/talloc.h>
|
|
#include <osmocom/core/msgb.h>
|
|
#include <osmocom/core/stats.h>
|
|
}
|
|
|
|
#include <arpa/inet.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
#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;
|
|
}
|
|
};
|