Prusa MINI Firmware overview
|
|
#define | MAX_BL_BITS 7 |
|
#define | END_BLOCK 256 |
|
#define | REP_3_6 16 |
|
#define | REPZ_3_10 17 |
|
#define | REPZ_11_138 18 |
|
#define | DIST_CODE_LEN 512 /* see definition of array dist_code below */ |
|
#define | send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) |
|
#define | put_short(s, w) |
|
#define | send_bits(s, value, length) |
|
#define | SMALLEST 1 |
|
#define | pqremove(s, tree, top) |
|
#define | smaller(tree, n, m, depth) |
|
|
void tr_static_init | OF ((void)) |
|
void init_block | OF ((deflate_state *s)) |
|
void pqdownheap | OF ((deflate_state *s, ct_data *tree, int k)) |
|
void gen_bitlen | OF ((deflate_state *s, tree_desc *desc)) |
|
void gen_codes | OF ((ct_data *tree, int max_code, ushf *bl_count)) |
|
void scan_tree | OF ((deflate_state *s, ct_data *tree, int max_code)) |
|
void send_all_trees | OF ((deflate_state *s, int lcodes, int dcodes, int blcodes)) |
|
void compress_block | OF ((deflate_state *s, const ct_data *ltree, const ct_data *dtree)) |
|
unsigned bi_reverse | OF ((unsigned value, int length)) |
|
void | tr_static_init () |
|
void ZLIB_INTERNAL | _tr_init (deflate_state *s) |
|
void | init_block (deflate_state *s) |
|
void | pqdownheap (deflate_state *s, ct_data *tree, int k) |
|
void | gen_bitlen (deflate_state *s, tree_desc *desc) |
|
void | gen_codes (ct_data *tree, int max_code, ushf *bl_count) |
|
void | build_tree (deflate_state *s, tree_desc *desc) |
|
void | scan_tree (deflate_state *s, ct_data *tree, int max_code) |
|
void | send_tree (deflate_state *s, ct_data *tree, int max_code) |
|
int | build_bl_tree (deflate_state *s) |
|
void | send_all_trees (deflate_state *s, int lcodes, int dcodes, int blcodes) |
|
void ZLIB_INTERNAL | _tr_stored_block (deflate_state *s, charf *buf, ulg stored_len, int last) |
|
void ZLIB_INTERNAL | _tr_flush_bits (deflate_state *s) |
|
void ZLIB_INTERNAL | _tr_align (deflate_state *s) |
|
void ZLIB_INTERNAL | _tr_flush_block (deflate_state *s, charf *buf, ulg stored_len, int last) |
|
int ZLIB_INTERNAL | _tr_tally (deflate_state *s, unsigned dist, unsigned lc) |
|
void | compress_block (deflate_state *s, const ct_data *ltree, const ct_data *dtree) |
|
int | detect_data_type (deflate_state *s) |
|
unsigned | bi_reverse (unsigned code, int len) |
|
void | bi_flush (deflate_state *s) |
|
void | bi_windup (deflate_state *s) |
|
|
const int | extra_lbits [LENGTH_CODES] = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0} |
|
const int | extra_dbits [D_CODES] = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13} |
|
const int | extra_blbits [BL_CODES] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7} |
|
const uch | bl_order [BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15} |
|
ct_data | static_ltree [L_CODES+2] |
|
ct_data | static_dtree [D_CODES] |
|
uch | _dist_code [DIST_CODE_LEN] |
|
uch | _length_code [MAX_MATCH-MIN_MATCH+1] |
|
int | base_length [LENGTH_CODES] |
|
int | base_dist [D_CODES] |
|
const static_tree_desc | static_l_desc |
|
const static_tree_desc | static_d_desc |
|
const static_tree_desc | static_bl_desc |
|
◆ MAX_BL_BITS
◆ END_BLOCK
◆ REP_3_6
◆ REPZ_3_10
◆ REPZ_11_138
◆ DIST_CODE_LEN
#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ |
◆ send_code
◆ put_short
#define put_short |
( |
|
s, |
|
|
|
w |
|
) |
| |
Value:{ \
put_byte(s, (
uch)((w) & 0xff)); \
put_byte(s, (
uch)((
ush)(w) >> 8)); \
}
◆ send_bits
#define send_bits |
( |
|
s, |
|
|
|
value, |
|
|
|
length |
|
) |
| |
Value:
if (s->bi_valid > (
int)
Buf_size - len) {\
s->bi_buf |= (
ush)val << s->bi_valid;\
} else {\
s->bi_buf |= (
ush)(value) << s->bi_valid;\
s->bi_valid += len;\
}\
}
◆ SMALLEST
◆ pqremove
#define pqremove |
( |
|
s, |
|
|
|
tree, |
|
|
|
top |
|
) |
| |
Value:{\
s->heap[
SMALLEST] = s->heap[s->heap_len--]; \
}
◆ smaller
#define smaller |
( |
|
tree, |
|
|
|
n, |
|
|
|
m, |
|
|
|
depth |
|
) |
| |
Value:(tree[n].Freq < tree[m].Freq || \
(tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
◆ OF() [1/9]
◆ OF() [2/9]
◆ OF() [3/9]
◆ OF() [4/9]
◆ OF() [5/9]
◆ OF() [6/9]
◆ OF() [7/9]
◆ OF() [8/9]
◆ OF() [9/9]
◆ tr_static_init()
234 #if defined(GEN_TREES_H) || !defined(STDC)
235 static int static_init_done = 0;
244 if (static_init_done)
return;
247 #ifdef NO_INIT_GLOBAL_POINTERS
263 Assert (
length == 256,
"tr_static_init: length != 256");
278 Assert (dist == 256,
"tr_static_init: dist != 256");
286 Assert (dist == 256,
"tr_static_init: 256+dist != 512");
291 while (n <= 143)
static_ltree[n++].Len = 8, bl_count[8]++;
292 while (n <= 255)
static_ltree[n++].Len = 9, bl_count[9]++;
293 while (n <= 279)
static_ltree[n++].Len = 7, bl_count[7]++;
294 while (n <= 287)
static_ltree[n++].Len = 8, bl_count[8]++;
302 for (n = 0; n <
D_CODES; n++) {
306 static_init_done = 1;
◆ _tr_init()
396 s->compressed_len = 0
L;
◆ init_block()
◆ pqdownheap()
458 while (j <= s->heap_len) {
460 if (j < s->heap_len &&
◆ gen_bitlen()
512 bits = tree[tree[n].Dad].Len + 1;
513 if (
bits > max_length)
bits = max_length, overflow++;
517 if (n > max_code)
continue;
521 if (n >= base) xbits =
extra[n-base];
524 if (stree) s->
static_len += (
ulg)f * (
unsigned)(stree[n].Len + xbits);
526 if (overflow == 0)
return;
528 Tracev((stderr,
"\nbit length overflow\n"));
542 }
while (overflow > 0);
553 if (m > max_code)
continue;
554 if ((
unsigned) tree[m].
Len != (
unsigned)
bits) {
555 Tracev((stderr,
"code %d bits %d->%d\n", m, tree[m].
Len,
bits));
◆ gen_codes()
593 "inconsistent bit counts");
594 Tracev((stderr,
"\ngen_codes: max_code %d ", max_code));
596 for (n = 0; n <= max_code; n++) {
597 int len = tree[n].Len;
598 if (len == 0)
continue;
603 n, (isgraph(n) ? n :
' '), len, tree[n].
Code, next_code[len]-1));
◆ build_tree()
632 for (n = 0; n < elems; n++) {
633 if (tree[n].
Freq != 0) {
647 node = s->
heap[++(s->
heap_len)] = (max_code < 2 ? ++max_code : 0);
672 tree[node].Freq = tree[n].Freq + tree[m].Freq;
675 tree[n].Dad = tree[m].Dad = (
ush)node;
678 fprintf(stderr,
"\nnode %d(%d), sons %d(%d) %d(%d)",
679 node, tree[node].
Freq, n, tree[n].
Freq, m, tree[m].
Freq);
◆ scan_tree()
711 int nextlen = tree[0].Len;
716 if (nextlen == 0) max_count = 138, min_count = 3;
717 tree[max_code+1].Len = (
ush)0xffff;
719 for (n = 0; n <= max_code; n++) {
720 curlen = nextlen; nextlen = tree[n+1].Len;
721 if (++count < max_count && curlen == nextlen) {
723 }
else if (count < min_count) {
724 s->
bl_tree[curlen].Freq += count;
725 }
else if (curlen != 0) {
726 if (curlen != prevlen) s->
bl_tree[curlen].Freq++;
728 }
else if (count <= 10) {
733 count = 0; prevlen = curlen;
735 max_count = 138, min_count = 3;
736 }
else if (curlen == nextlen) {
737 max_count = 6, min_count = 3;
739 max_count = 7, min_count = 4;
◆ send_tree()
756 int nextlen = tree[0].Len;
762 if (nextlen == 0) max_count = 138, min_count = 3;
764 for (n = 0; n <= max_code; n++) {
765 curlen = nextlen; nextlen = tree[n+1].Len;
766 if (++count < max_count && curlen == nextlen) {
768 }
else if (count < min_count) {
771 }
else if (curlen != 0) {
772 if (curlen != prevlen) {
775 Assert(count >= 3 && count <= 6,
" 3_6?");
778 }
else if (count <= 10) {
784 count = 0; prevlen = curlen;
786 max_count = 138, min_count = 3;
787 }
else if (curlen == nextlen) {
788 max_count = 6, min_count = 3;
790 max_count = 7, min_count = 4;
◆ build_bl_tree()
818 for (max_blindex =
BL_CODES-1; max_blindex >= 3; max_blindex--) {
823 Tracev((stderr,
"\ndyn trees: dyn %ld, stat %ld",
◆ send_all_trees()
840 Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4,
"not enough codes");
843 Tracev((stderr,
"\nbl counts: "));
847 for (rank = 0; rank < blcodes; rank++) {
851 Tracev((stderr,
"\nbl tree: sent %ld", s->bits_sent));
854 Tracev((stderr,
"\nlit tree: sent %ld", s->bits_sent));
857 Tracev((stderr,
"\ndist tree: sent %ld", s->bits_sent));
◆ _tr_stored_block()
876 s->compressed_len = (s->compressed_len + 3 + 7) & (
ulg)~7
L;
877 s->compressed_len += (stored_len + 4) << 3;
878 s->bits_sent += 2*16;
879 s->bits_sent += stored_len<<3;
◆ _tr_flush_bits()
◆ _tr_align()
902 s->compressed_len += 10
L;
◆ _tr_flush_block()
917 ulg opt_lenb, static_lenb;
933 Tracev((stderr,
"\ndist data: dyn %ld, stat %ld", s->
opt_len,
945 opt_lenb = (s->
opt_len+3+7)>>3;
948 Tracev((stderr,
"\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
952 if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
955 Assert(buf != (
char*)0,
"lost buf");
956 opt_lenb = static_lenb = stored_len + 5;
960 if (buf != (
char*)0) {
962 if (stored_len+4 <= opt_lenb && buf != (
char*)0) {
974 }
else if (static_lenb >= 0) {
991 s->compressed_len += 3 + s->
opt_len;
994 Assert (s->compressed_len == s->bits_sent,
"bad compressed size");
1003 s->compressed_len += 7;
1006 Tracev((stderr,
"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
1007 s->compressed_len-7*
last));
◆ _tr_tally()
1036 #ifdef TRUNCATE_BLOCK
1043 for (dcode = 0; dcode <
D_CODES; dcode++) {
1048 Tracev((stderr,
"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
1049 s->
last_lit, in_length, out_length,
1050 100
L - out_length*100
L/in_length));
◆ compress_block()
1076 dist = s->
d_buf[lx];
1077 lc = s->
l_buf[lx++];
1080 Tracecv(isgraph(lc), (stderr,
" '%c' ", lc));
1104 "pendingBuf overflow");
1106 }
while (lx < s->last_lit);
◆ detect_data_type()
1131 unsigned long black_mask = 0xf3ffc07fUL;
1135 for (n = 0; n <= 31; n++, black_mask >>= 1)
1136 if ((black_mask & 1) && (s->
dyn_ltree[n].Freq != 0))
◆ bi_reverse()
unsigned bi_reverse |
( |
unsigned |
code, |
|
|
int |
len |
|
) |
| |
1162 register unsigned res = 0;
1165 code >>= 1, res <<= 1;
1166 }
while (--len > 0);
◆ bi_flush()
◆ bi_windup()
1201 s->bits_sent = (s->bits_sent+7) & ~7;
◆ extra_lbits
const int extra_lbits[LENGTH_CODES] = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0} |
◆ extra_dbits
const int extra_dbits[D_CODES] = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13} |
◆ extra_blbits
const int extra_blbits[BL_CODES] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7} |
◆ bl_order
const uch bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15} |
◆ static_ltree
◆ static_dtree
◆ _dist_code
◆ _length_code
◆ base_length
◆ base_dist
◆ static_l_desc
◆ static_d_desc
◆ static_bl_desc
Byte FAR Bytef
Definition: zconf.h:400
#define MAX_BITS
Definition: deflate.h:48
const static_tree_desc * stat_desc
Definition: deflate.h:89
void build_tree(deflate_state *s, tree_desc *desc)
Definition: trees.c:615
#define SMALLEST
Definition: trees.c:422
int heap_max
Definition: deflate.h:211
#define Assert(cond, msg)
Definition: zutil.h:248
#define send_bits(s, value, length)
Definition: trees.c:211
struct ct_data_s bl_tree[2 *BL_CODES+1]
Definition: deflate.h:200
void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree)
Definition: trees.c:1064
unsigned char uch
Definition: zutil.h:43
ulg opt_len
Definition: deflate.h:250
#define Tracecv(c, x)
Definition: zutil.h:253
ulg static_len
Definition: deflate.h:251
unsigned bi_reverse(unsigned code, int len)
Definition: trees.c:1158
void pqdownheap(deflate_state *s, ct_data *tree, int k)
Definition: trees.c:451
#define smaller(tree, n, m, depth)
Definition: trees.c:441
#define Z_UNKNOWN
Definition: zlib.h:206
const uch bl_order[BL_CODES]
Definition: trees.c:72
#define pqremove(s, tree, top)
Definition: trees.c:430
int heap[2 *L_CODES+1]
Definition: deflate.h:209
int build_bl_tree(deflate_state *s)
Definition: trees.c:799
#define STORED_BLOCK
Definition: zutil.h:72
const static_tree_desc static_bl_desc
Definition: trees.c:131
#define Z_BINARY
Definition: zlib.h:203
#define BL_CODES
Definition: deflate.h:42
Bytef * pending_buf
Definition: deflate.h:103
void scan_tree(deflate_state *s, ct_data *tree, int max_code)
Definition: trees.c:703
#define Tracev(x)
Definition: zutil.h:250
uchf * l_buf
Definition: deflate.h:220
const static_tree_desc static_d_desc
Definition: trees.c:128
void gen_codes(ct_data *tree, int max_code, ushf *bl_count)
Definition: trees.c:572
z_streamp strm
Definition: deflate.h:101
#define STATIC_TREES
Definition: zutil.h:73
uch _length_code[MAX_MATCH-MIN_MATCH+1]
Definition: trees.c:104
int detect_data_type(deflate_state *s)
Definition: trees.c:1124
#define REP_3_6
Definition: trees.c:53
#define REPZ_3_10
Definition: trees.c:56
ct_data static_ltree[L_CODES+2]
Definition: trees.c:86
uInt lit_bufsize
Definition: deflate.h:222
int base_length[LENGTH_CODES]
Definition: trees.c:107
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
Definition: trees.c:863
#define MAX_MATCH
Definition: zutil.h:78
#define LENGTH_CODES
Definition: deflate.h:30
void tr_static_init()
Definition: trees.c:232
int elems
Definition: trees.c:121
uch _dist_code[DIST_CODE_LEN]
Definition: trees.c:98
#define MAX_DIST(s)
Definition: deflate.h:289
uInt last_lit
Definition: deflate.h:242
#define MAX_BL_BITS
Definition: trees.c:47
unsigned char Byte
Definition: zconf.h:391
#define LITERALS
Definition: deflate.h:33
const intf * extra_bits
Definition: trees.c:119
unsigned short ush
Definition: zutil.h:45
#define DYN_TREES
Definition: zutil.h:74
unsigned bits
Definition: inflate.h:102
int level
Definition: deflate.h:188
const static_tree_desc static_l_desc
Definition: trees.c:125
struct ct_data_s dyn_ltree[HEAP_SIZE]
Definition: deflate.h:198
struct tree_desc_s d_desc
Definition: deflate.h:203
const ct_data * static_tree
Definition: trees.c:118
#define HEAP_SIZE
Definition: deflate.h:45
const int extra_blbits[BL_CODES]
Definition: trees.c:69
#define put_byte(s, c)
Definition: deflate.h:281
uInt strstart
Definition: deflate.h:162
#define Code
Definition: deflate.h:80
ushf * d_buf
Definition: deflate.h:244
unsigned extra
Definition: inflate.h:107
void bi_windup(deflate_state *s)
Definition: trees.c:1190
void bi_flush(deflate_state *s)
Definition: trees.c:1173
int max_code
Definition: deflate.h:88
#define Buf_size
Definition: deflate.h:51
#define d_code(dist)
Definition: deflate.h:308
ush bi_buf
Definition: deflate.h:260
#define REPZ_11_138
Definition: trees.c:59
#define L(CODE)
Definition: macros.h:76
#define Z_FIXED
Definition: zlib.h:199
int last
Definition: inflate.h:85
void gen_bitlen(deflate_state *s, tree_desc *desc)
Definition: trees.c:486
ush bl_count[MAX_BITS+1]
Definition: deflate.h:206
#define Freq
Definition: deflate.h:79
int bi_valid
Definition: deflate.h:264
#define send_code(s, c, tree)
Definition: trees.c:161
void init_block(deflate_state *s)
Definition: trees.c:407
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:149
int base_dist[D_CODES]
Definition: trees.c:110
struct ct_data_s dyn_dtree[2 *D_CODES+1]
Definition: deflate.h:199
struct tree_desc_s bl_desc
Definition: deflate.h:204
#define Len
Definition: deflate.h:82
int extra_base
Definition: trees.c:120
#define MIN_MATCH
Definition: zutil.h:77
int heap_len
Definition: deflate.h:210
const int extra_dbits[D_CODES]
Definition: trees.c:66
int
Definition: createSpeedLookupTable.py:15
struct tree_desc_s l_desc
Definition: deflate.h:202
#define L_CODES
Definition: deflate.h:36
ulg pending
Definition: deflate.h:106
int max_length
Definition: trees.c:122
unsigned int uInt
Definition: zconf.h:393
#define D_CODES
Definition: deflate.h:39
png_uint_32 length
Definition: png.c:2247
ct_data * dyn_tree
Definition: deflate.h:87
Definition: inftrees.h:24
uInt matches
Definition: deflate.h:252
ct_data static_dtree[D_CODES]
Definition: trees.c:93
void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes)
Definition: trees.c:834
#define put_short(s, w)
Definition: trees.c:174
#define END_BLOCK
Definition: trees.c:50
unsigned long ulg
Definition: zutil.h:47
long block_start
Definition: deflate.h:154
int strategy
Definition: deflate.h:189
void send_tree(deflate_state *s, ct_data *tree, int max_code)
Definition: trees.c:748
#define Z_TEXT
Definition: zlib.h:204
const int extra_lbits[LENGTH_CODES]
Definition: trees.c:63
int FAR intf
Definition: zconf.h:403
uch depth[2 *L_CODES+1]
Definition: deflate.h:216