2 Copyright (C) Arturo San Emeterio Campos 1999. All rights reserved.
3 Permission is granted to make verbatim copies of this file for private
4 use only. There is ABSOLUTELY NO WARRANTY. Use it at your OWN RISK.
6 This file is: "ppmcdata.h" (exclusions)
7 Email: arturo@arturocampos.com
8 Web: http://www.arturocampos.com
10 Part of the ppmc encoder and decoder.
12 This module contains externs definition for global data.
17 // Order-4 uses a hash table which points to the start of a linked list with
18 // the different context, which has the cump, the number of different symbols
19 // and a pointer to the linked list with the bytes and frequencies.
20 // Order-3 is almost the same, both take 262144 bytes.
21 extern struct context *order4_hasht[];
23 extern struct context *order3_hasht[];
26 // The array for order-2 is different, as we do directly hashing, and thus
27 // we have no need to do the stuff of linked lists for the context itself,
28 // so it contains the context used. This takes 1310720 bytes.
29 extern struct context_o2 order2_array[];
32 // Those are the multiple arrays for order-1. It takes 65536 bytes.
33 extern unsigned char order1_array[256][256];
34 extern unsigned int order1_defined_bytes_array[]; //the defined bytes in every context
35 extern unsigned int order1_max_cump_array[]; //max cump of every context
38 // This is the array for order-0. It takes 256 bytes.
39 extern unsigned char order0_array[];
40 extern unsigned int order0_defined_bytes;
41 extern unsigned int order0_max_cump;
44 // Those are the pointers and variables used for managing the mem pool for
45 // both context, and bytes and frequencies.
46 extern struct _byte_and_freq *_bytes_pool, //pointer to pool containing linked
47 //lists with bytes and frequencies
48 *_bytes_pool_max; //the maximum of this buffer
49 extern struct context *_context_pool; //pointer to pool containing contexts
50 extern struct context *_context_pool_max; //the same as with _bytes_pool
52 extern unsigned long _bytes_pool_index; //index in array of pointers
53 extern unsigned long _context_pool_index;
55 //the following is an array keeping pointers to different buffers. A new
56 //buffer is allocated when the current one is full, so we always have a
57 //buffer for linked lists. (without allocating a buffer for every element)
58 extern struct _byte_and_freq *_bytes_pool_array[_mempool_max_index];
59 extern struct context *_context_pool_array[_mempool_max_index];
61 extern char ppmc_out_of_memory; //0 if we have enough memory, 1 instead, any
62 //routine that needs to allocate memory must
67 // Variables which contain current byte to code and order
68 extern unsigned long //they are only bytes
69 byte, //current byte to code
70 o1_byte, //order-1 byte
71 o2_byte, //order-2 byte
72 o3_byte, //order-3 byte
73 o4_byte; //order-4 byte
75 extern unsigned long o2_cntxt; //used in the hash key of order-2
76 extern unsigned long o3_cntxt; //use as hash key for order-3
77 unsigned long o4_cntxt; //use as hash key for order-4
78 extern unsigned long full_o3_cntxt; //o1_byte, o2_byte and o3_byte together
79 extern unsigned long full_o4_cntxt; //order-4-3-2-1
81 extern unsigned long coded_in_order; //in which order the last byte was coded
82 //it's for update exclusion
83 //also used for decoding
84 // Variables used for coding
86 extern unsigned long //no need for negative values
87 total_cump, //the total cumulative probability
88 symb_cump, //the symbol cumulative probability
89 symb_prob; //the symbol frequency
91 extern rangecoder rc_coder; //state of range coder
92 extern rangecoder rc_decoder; //state of range decoder
96 FILE *file_input, //file to code
97 *file_output; //file where the coded data is placed
101 // Pointers to linked lists and context structures used for faster updating
102 // or creation of new nodes, because instead of reading again all the linked
103 // list till the end (in the case of creation) we have a pointer to the last
104 // element. In the case that a byte was present in the linked lists but it
105 // had a 0 count, we just have to update its probability. And in the case
106 // that it already was present and we coded it under that context or a lower
107 // one, we just have to update its probability.
110 extern struct _byte_and_freq *o2_ll_node;//pointer to linked lists under order-2
111 //where does it points depends in which
112 //order the byte was coded.
113 extern struct _byte_and_freq *o3_ll_node; //the same but for order-3
114 extern struct _byte_and_freq *o4_ll_node;
116 extern struct context *o3_context; //pointer to current order-3 context
117 extern struct context *o4_context; //pointer to current order-3 context
120 // the array for doing exclusion. Every routine from every order can
122 extern unsigned char excluded[256]; //if 0 it was not present, if it's 1 then
123 //it appeared in a higher order.
125 extern unsigned long exc_total_cump, //total cump of context (after exclusion)
126 exc_defined_bytes,//defined bytes in context (after exclusion)