Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lzss.h File Reference
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
+ Include dependency graph for lzss.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LZSS
 

Functions

static int64_t lzss_position (LZSS *self)
 
static int lzss_mask (LZSS *self)
 
static int lzss_size (LZSS *self)
 
static uint8_t * lzss_window_pointer (LZSS *self)
 
static int lzss_offset_for_position (LZSS *self, int64_t pos)
 
static uint8_t * lzss_window_pointer_for_position (LZSS *self, int64_t pos)
 
static int lzss_current_window_offset (LZSS *self)
 
static uint8_t * lzss_current_window_pointer (LZSS *self)
 
static int64_t lzss_next_window_edge_after_position (LZSS *self, int64_t pos)
 
static int64_t lzss_next_window_edge (LZSS *self)
 
static uint8_t lzss_get_byte_from_window (LZSS *self, int64_t pos)
 
static void lzss_emit_literal (LZSS *self, uint8_t literal)
 
static void lzss_emit_match (LZSS *self, int offset, int length)
 
static void lzss_copy_bytes_from_window (LZSS *self, uint8_t *buffer, int64_t startpos, int length)
 
static bool lzss_initialize (LZSS *self, int windowsize)
 
static void lzss_cleanup (LZSS *self)
 

Function Documentation

static void lzss_cleanup ( LZSS self)
inlinestatic

Definition at line 86 of file lzss.h.

86 { free(self->window); }

+ Here is the caller graph for this function:

static void lzss_copy_bytes_from_window ( LZSS self,
uint8_t *  buffer,
int64_t  startpos,
int  length 
)
inlinestatic

Definition at line 61 of file lzss.h.

61  {
62  int windowoffs = lzss_offset_for_position(self, startpos);
63  int firstpart = lzss_size(self) - windowoffs;
64  if (length <= firstpart) {
65  /* Request fits inside window */
66  memcpy(buffer, &self->window[windowoffs], length);
67  }
68  else {
69  /* Request wraps around window */
70  memcpy(buffer, &self->window[windowoffs], firstpart);
71  memcpy(buffer + firstpart, &self->window[0], length - firstpart);
72  }
73 }

+ Here is the caller graph for this function:

static int lzss_current_window_offset ( LZSS self)
inlinestatic

Definition at line 36 of file lzss.h.

36 { return lzss_offset_for_position(self, self->position); }

+ Here is the caller graph for this function:

static uint8_t* lzss_current_window_pointer ( LZSS self)
inlinestatic

Definition at line 38 of file lzss.h.

38 { return lzss_window_pointer_for_position(self, self->position); }

+ Here is the caller graph for this function:

static void lzss_emit_literal ( LZSS self,
uint8_t  literal 
)
inlinestatic

Definition at line 46 of file lzss.h.

46  {
47  /* self->window[(self->position & self->mask)] = literal; */
48  *lzss_current_window_pointer(self) = literal;
49  self->position++;
50 }

+ Here is the caller graph for this function:

static void lzss_emit_match ( LZSS self,
int  offset,
int  length 
)
inlinestatic

Definition at line 52 of file lzss.h.

52  {
53  int windowoffs = lzss_current_window_offset(self);
54  int i;
55  for (i = 0; i < length; i++) {
56  self->window[(windowoffs + i) & lzss_mask(self)] = self->window[(windowoffs + i - offset) & lzss_mask(self)];
57  }
58  self->position += length;
59 }

+ Here is the caller graph for this function:

static uint8_t lzss_get_byte_from_window ( LZSS self,
int64_t  pos 
)
inlinestatic

Definition at line 44 of file lzss.h.

44 { return *lzss_window_pointer_for_position(self, pos); }
static bool lzss_initialize ( LZSS self,
int  windowsize 
)
inlinestatic

Definition at line 75 of file lzss.h.

75  {
76  self->window = malloc(windowsize);
77  if (!self->window)
78  return false;
79 
80  self->mask = windowsize - 1; /* Assume windows are power-of-two sized! */
81  memset(self->window, 0, lzss_size(self));
82  self->position = 0;
83  return true;
84 }

+ Here is the caller graph for this function:

static int lzss_mask ( LZSS self)
inlinestatic

Definition at line 26 of file lzss.h.

26 { return self->mask; }

+ Here is the caller graph for this function:

static int64_t lzss_next_window_edge ( LZSS self)
inlinestatic

Definition at line 42 of file lzss.h.

42 { return lzss_next_window_edge_after_position(self, self->position); }
static int64_t lzss_next_window_edge_after_position ( LZSS self,
int64_t  pos 
)
inlinestatic

Definition at line 40 of file lzss.h.

40 { return (pos + lzss_size(self)) & ~(int64_t)lzss_mask(self); }

+ Here is the caller graph for this function:

static int lzss_offset_for_position ( LZSS self,
int64_t  pos 
)
inlinestatic

Definition at line 32 of file lzss.h.

32 { return (int)(pos & self->mask); }

+ Here is the caller graph for this function:

static int64_t lzss_position ( LZSS self)
inlinestatic

Definition at line 24 of file lzss.h.

24 { return self->position; }

+ Here is the caller graph for this function:

static int lzss_size ( LZSS self)
inlinestatic

Definition at line 28 of file lzss.h.

28 { return self->mask + 1; }

+ Here is the caller graph for this function:

static uint8_t* lzss_window_pointer ( LZSS self)
inlinestatic

Definition at line 30 of file lzss.h.

30 { return self->window; }
static uint8_t* lzss_window_pointer_for_position ( LZSS self,
int64_t  pos 
)
inlinestatic

Definition at line 34 of file lzss.h.

34 { return &self->window[lzss_offset_for_position(self, pos)]; }

+ Here is the caller graph for this function: