1
/* Copyright (C) 2001-2012 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied,
8
modified or distributed except as expressly authorized under the terms
9
of the license contained in the file LICENSE in this distribution.
11
Refer to licensing information at http://www.artifex.com or contact
12
Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
13
CA 94903, U.S.A., +1(415)492-9861, for further information.
17
/* Definitions for BWBlockSort (Burroughs-Wheeler) filters */
18
/* Requires scommon.h; strimpl.h if any templates are referenced */
20
#ifndef sbwbs_INCLUDED
21
# define sbwbs_INCLUDED
23
/* Common framework for streams that buffer a block for processing */
24
#define stream_buffered_state_common\
26
/* The client may set the following before initialization, */\
27
/* or the stream may set it later. */\
29
/* The init procedure sets the following, */\
30
/* if BlockSize has been set. */\
31
byte *buffer; /* [BlockSize] */\
32
/* The following are updated dynamically. */\
33
bool filling; /* true if filling buffer, */\
34
/* false if emptying */\
35
int bsize; /* size of current block (<= BlockSize) */\
36
int bpos /* current index within buffer */
37
typedef struct stream_buffered_state_s {
38
stream_buffered_state_common;
39
} stream_buffered_state;
41
#define private_st_buffered_state() /* in sbwbs.c */\
42
gs_private_st_ptrs1(st_buffered_state, stream_buffered_state,\
43
"stream_buffered state", sbuf_enum_ptrs, sbuf_reloc_ptrs, buffer)
45
/* BWBlockSortEncode/Decode */
49
typedef struct stream_BWBS_state_s {
50
stream_buffered_state_common;
51
/* The init procedure sets the following. */
52
void *offsets; /* permutation indices when writing, */
53
/* multi-level indices when reading */
54
/* The following are updated dynamically. */
55
int N; /* actual length of block */
56
/* The following are only used when decoding. */
57
int I; /* index of unrotated string */
58
int i; /* next index in encoded string */
60
typedef stream_BWBS_state stream_BWBSE_state;
61
typedef stream_BWBS_state stream_BWBSD_state;
63
#define private_st_BWBS_state() /* in sbwbs.c */\
64
gs_private_st_suffix_add1(st_BWBS_state, stream_BWBS_state,\
65
"BWBlockSortEncode/Decode state", bwbs_enum_ptrs, bwbs_reloc_ptrs,\
66
st_buffered_state, offsets)
67
extern const stream_template s_BWBSE_template;
68
extern const stream_template s_BWBSD_template;
70
#endif /* sbwbs_INCLUDED */