27 #define BITS_TYPE struct qtmd_stream
29 #define BITS_ORDER_MSB
30 #define READ_BYTES do { \
31 unsigned char b0, b1; \
32 READ_IF_NEEDED; b0 = *i_ptr++; \
33 READ_IF_NEEDED; b1 = *i_ptr++; \
34 INJECT_BITS((b0 << 8) | b1, 16); \
67 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
68 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576, 32768, 49152,
69 65536, 98304, 131072, 196608, 262144, 393216, 524288, 786432, 1048576, 1572864
72 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
73 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19
76 0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 14, 18, 22, 26,
77 30, 38, 46, 54, 62, 78, 94, 110, 126, 158, 190, 222, 254
80 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
81 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
92 #define GET_SYMBOL(model, var) do { \
93 range = ((H - L) & 0xFFFF) + 1; \
94 symf = ((((C - L + 1) * model.syms[0].cumfreq)-1) / range) & 0xFFFF; \
96 for (i = 1; i < model.entries; i++) { \
97 if (model.syms[i].cumfreq <= symf) break; \
99 (var) = model.syms[i-1].sym; \
101 range = (H - L) + 1; \
102 symf = model.syms[0].cumfreq; \
103 H = L + ((model.syms[i-1].cumfreq * range) / symf) - 1; \
104 L = L + ((model.syms[i].cumfreq * range) / symf); \
106 do { model.syms[--i].cumfreq += 8; } while (i > 0); \
107 if (model.syms[0].cumfreq > 3800) qtmd_update_model(&model); \
110 if ((L & 0x8000) != (H & 0x8000)) { \
111 if ((L & 0x4000) && !(H & 0x4000)) { \
113 C ^= 0x4000; L &= 0x3FFF; H |= 0x4000; \
117 L <<= 1; H = (H << 1) | 1; \
119 C = (C << 1) | PEEK_BITS(1); \
151 for (j =
i + 1; j < model->
entries; j++) {
177 for (
i = 0;
i <=
len;
i++) {
189 int window_bits,
int input_buffer_size)
195 if (!system)
return NULL;
198 if (window_bits < 10 || window_bits > 21)
return NULL;
201 input_buffer_size = (input_buffer_size + 1) & -2;
202 if (input_buffer_size < 2)
return NULL;
211 qtm->
inbuf = (
unsigned char *) system->
alloc(system, (
size_t) input_buffer_size);
259 int i, j, selector, extra, sym, match_length;
260 unsigned short H,
L,
C, symf;
271 if ((
off_t)
i > out_bytes)
i = (
int) out_bytes;
291 while ((qtm->
o_end - qtm->
o_ptr) < out_bytes) {
312 struct qtmd_model *mdl = (selector == 0) ? &qtm->model0 :
313 ((selector == 1) ? &qtm->model1 :
314 ((selector == 2) ? &qtm->model2 :
317 window[window_posn++] = sym;
349 D((
"got %d from selector", selector))
353 rundest = &
window[window_posn];
354 frame_todo -= match_length;
359 if ((window_posn + match_length) > qtm->
window_size) {
362 j = window_posn - match_offset;
373 D((
"during window-wrap match; %d bytes to flush but only need %d",
388 window_posn = window_posn + match_length - qtm->
window_size;
397 if (match_offset > window_posn) {
399 j = match_offset - window_posn;
401 D((
"match offset beyond window boundaries"))
407 i -= j;
while (j-- > 0) *rundest++ = *runsrc++;
410 while (
i-- > 0) *rundest++ = *runsrc++;
413 runsrc = rundest - match_offset;
414 while (
i-- > 0) *rundest++ = *runsrc++;
416 window_posn += match_length;
426 D((
"overshot frame alignment"))
431 if (frame_todo == 0) {
450 if (
i >= out_bytes)
break;
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
int(* write)(struct mspack_file *file, void *buffer, int bytes)
void *(* alloc)(struct mspack_system *self, size_t bytes)
struct qtmd_modelsym * syms
struct qtmd_modelsym m1sym[64+1]
struct qtmd_modelsym m2sym[64+1]
struct qtmd_modelsym m6sym[42+1]
struct qtmd_modelsym m7sym[7+1]
struct mspack_system * sys
struct mspack_file * input
struct qtmd_model model0 model1 model2 model3
struct qtmd_modelsym m4sym[24+1]
struct mspack_file * output
struct qtmd_modelsym m6lsym[27+1]
struct qtmd_modelsym m3sym[64+1]
unsigned char header_read
struct qtmd_modelsym m5sym[36+1]
struct qtmd_model model4 model5 model6 model6len
struct qtmd_modelsym m0sym[64+1]
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)