13#define HASH_SIZE (1<< HASH_LOG)
14#define HASH_MASK (HASH_SIZE-1)
17#pragma GCC diagnostic ignored "-Wcast-align"
19#define UPDATE_HASH(v,p) { v = *((quint16*)p); v ^= *((quint16*)(p+1))^(v>>(16-HASH_LOG)); }
23#define MAX_DISTANCE 8192
30 const quint8* ip = (
const quint8*) input;
32 quint8* op = (quint8*) output;
45 for (hslot = htab; hslot < htab +
HASH_SIZE; hslot++)
53 while (ip < ip_limit) {
57 ref = (quint8*) * hslot;
67 if (*((quint16*)ref) != *((quint16*)ip))
91 if (*ref++ != *ip++)
break;
92 if (*ref++ != *ip++)
break;
93 if (*ref++ != *ip++)
break;
94 if (*ref++ != *ip++)
break;
95 if (*ref++ != *ip++)
break;
96 if (*ref++ != *ip++)
break;
97 if (*ref++ != *ip++)
break;
98 if (*ref++ != *ip++)
break;
111 anchor = anchor - copy - 1;
112 *(op - copy - 1) = copy - 1;
126 *op++ = (len << 5) + (
distance >> 8);
154 ip_limit = (
const quint8*)input +
length;
155 while (ip < ip_limit) {
166 *(op - copy - 1) = copy - 1;
170 return op - (quint8*)output;
175 const quint8* ip = (
const quint8*) input;
176 const quint8* ip_limit = ip +
length - 1;
177 quint8* op = (quint8*) output;
178 quint8* op_limit = op + maxout;
181 while (ip < ip_limit) {
182 quint32 ctrl = (*ip) + 1;
183 quint32 ofs = ((*ip) & 31) << 8;
184 quint32 len = (*ip++) >> 5;
188 if (op + ctrl > op_limit)
220 if (op + len + 3 > op_limit)
223 if (ref < (quint8 *)output)
235 return op - (quint8*)output;
255 return lzff_compress(input, inputLength, output, outputLength);
266 return dataSize + dataSize / 16 + 64 + 3;
qreal length(const QPointF &vec)
qreal distance(const QPointF &p1, const QPointF &p2)
qint32 compress(const quint8 *input, qint32 inputLength, quint8 *output, qint32 outputLength) override
qint32 decompress(const quint8 *input, qint32 inputLength, quint8 *output, qint32 outputLength) override
~KisLzfCompression() override
qint32 outputBufferSize(qint32 dataSize) override
int lzff_decompress(const void *input, int length, void *output, int maxout)
int lzff_compress(const void *input, int length, void *output, int)
#define UPDATE_HASH(v, p)