Branch Coverage

zopfli-one.c
Criterion Covered Total %
branch 752 1220 61.6


line true false branch
2766 4 0 if (end - start < 1024) {
2770 94 4 for (i = start; i < end; i++) {
2772 7 87 if (v < best) {
2791 0 0 if (end - start <= NUM) break;
2793 0 0 for (i = 0; i < NUM; i++) {
2799 0 0 for (i = 1; i < NUM; i++) {
2800 0 0 if (vp[i] < best) {
2805 0 0 if (best > lastbest) break;
2807 0 0 start = besti == 0 ? start : p[besti - 1];
2808 0 0 end = besti == NUM - 1 ? end : p[besti + 1];
2853 1 0 ZOPFLI_APPEND_DATA(value, out, outsize);
1 0 ZOPFLI_APPEND_DATA(value, out, outsize);
2854 0 1 for (i = 0; i + 1 < *outsize; i++) {
2855 0 0 if ((*out)[i] > value) {
2857 0 0 for (j = *outsize - 1; j > i; j--) {
2878 0 0 if (nlz77points > 0) {
2879 0 0 for (i = 0; i < lz77->size; i++) {
2880 0 0 size_t length = lz77->dists[i] == 0 ? 1 : lz77->litlens[i];
2881 0 0 if (lz77splitpoints[npoints] == i) {
2882 0 0 ZOPFLI_APPEND_DATA(pos, &splitpoints, &npoints);
0 0 ZOPFLI_APPEND_DATA(pos, &splitpoints, &npoints);
2883 0 0 if (npoints == nlz77points) break;
2891 0 0 for (i = 0; i < npoints; i++) {
2895 0 0 for (i = 0; i < npoints; i++) {
2923 6 4 for (i = 0; i <= npoints; i++) {
2924 2 4 size_t start = i == 0 ? 0 : splitpoints[i - 1];
2925 4 2 size_t end = i == npoints ? lz77size - 1 : splitpoints[i];
2926 3 3 if (!done[start] && end - start > longest) {
3 0 if (!done[start] && end - start > longest) {
2946 0 3 if (lz77->size < 10) return; /* This code fails on tiny files. */
2949 0 3 if (!done) exit(-1); /* Allocation failed. */
2950 64 3 for (i = 0; i < lz77->size; i++) done[i] = 0;
2957 4 0 if (maxblocks > 0 && numblocks >= maxblocks) {
0 4 if (maxblocks > 0 && numblocks >= maxblocks) {
2972 1 3 if (splitcost > origcost || llpos == lstart + 1 || llpos == lend) {
1 0 if (splitcost > origcost || llpos == lstart + 1 || llpos == lend) {
0 1 if (splitcost > origcost || llpos == lstart + 1 || llpos == lend) {
2979 2 2 if (!FindLargestSplittableBlock(
2984 1 1 if (lend - lstart < 10) {
2989 0 3 if (options->verbose) {
3025 1 2 if (nlz77points > 0) {
3026 10 0 for (i = 0; i < store.size; i++) {
3027 1 9 size_t length = store.dists[i] == 0 ? 1 : store.litlens[i];
3028 1 9 if (lz77splitpoints[*npoints] == i) {
3029 1 0 ZOPFLI_APPEND_DATA(pos, splitpoints, npoints);
1 0 ZOPFLI_APPEND_DATA(pos, splitpoints, npoints);
3030 1 0 if (*npoints == nlz77points) break;
3048 0 0 while (i < inend) {
3049 0 0 ZOPFLI_APPEND_DATA(i, splitpoints, npoints);
0 0 ZOPFLI_APPEND_DATA(i, splitpoints, npoints);
3313 0 8 if(lmc->sublen == NULL) {
3322 18360 8 for (i = 0; i < blocksize; i++) lmc->length[i] = 1;
3323 18360 8 for (i = 0; i < blocksize; i++) lmc->dist[i] = 0;
3324 440640 8 for (i = 0; i < ZOPFLI_CACHE_LENGTH * blocksize * 3; i++) lmc->sublen[i] = 0;
3346 0 17468 if (length < 3) return;
3347 4471808 17468 for (i = 3; i <= length; i++) {
3348 4454340 17468 if (i == length || sublen[i] != sublen[i + 1]) {
0 4454340 if (i == length || sublen[i] != sublen[i + 1]) {
3354 0 17468 if (j >= ZOPFLI_CACHE_LENGTH) break;
3357 17468 0 if (j < ZOPFLI_CACHE_LENGTH) {
3376 0 122310 if (length < 3) return;
3378 122310 0 for (j = 0; j < ZOPFLI_CACHE_LENGTH; j++) {
3381 31678290 122310 for (i = prevlength; i <= length; i++) {
3384 122310 0 if (length == maxlength) break;
3400 0 244620 if (cache[1] == 0 && cache[2] == 0) return 0; /* No sublen cached. */
0 0 if (cache[1] == 0 && cache[2] == 0) return 0; /* No sublen cached. */
5985 16692 8487340 if (dist < 5) return 0;
5986 128 8487212 else if (dist < 9) return 1;
5987 8485804 1408 else if (dist < 17) return 2;
5988 128 1280 else if (dist < 33) return 3;
5989 128 1152 else if (dist < 65) return 4;
5990 128 1024 else if (dist < 129) return 5;
5991 128 896 else if (dist < 257) return 6;
5992 128 768 else if (dist < 513) return 7;
5993 128 640 else if (dist < 1025) return 8;
5994 128 512 else if (dist < 2049) return 9;
5995 128 384 else if (dist < 4097) return 10;
5996 128 256 else if (dist < 8193) return 11;
5997 128 128 else if (dist < 16385) return 12;
6012 0 37 if (dist < 5) return 0;
6013 0 37 else if (dist < 9) return (dist - 5) & 1;
6014 37 0 else if (dist < 17) return (dist - 9) & 3;
6015 0 0 else if (dist < 33) return (dist - 17) & 7;
6016 0 0 else if (dist < 65) return (dist - 33) & 15;
6017 0 0 else if (dist < 129) return (dist - 65) & 31;
6018 0 0 else if (dist < 257) return (dist - 129) & 63;
6019 0 0 else if (dist < 513) return (dist - 257) & 127;
6020 0 0 else if (dist < 1025) return (dist - 513) & 255;
6021 0 0 else if (dist < 2049) return (dist - 1025) & 511;
6022 0 0 else if (dist < 4097) return (dist - 2049) & 1023;
6023 0 0 else if (dist < 8193) return (dist - 4097) & 2047;
6024 0 0 else if (dist < 16385) return (dist - 8193) & 4095;
6040 7720171 900 if (dist < 193) {
6041 7719691 480 if (dist < 13) { /* dist 0..13. */
6042 15648 7704043 if (dist < 5) return dist - 1;
6043 60 7703983 else if (dist < 7) return 4;
6044 60 7703923 else if (dist < 9) return 5;
6047 60 420 if (dist < 17) return 7;
6048 60 360 else if (dist < 25) return 8;
6049 60 300 else if (dist < 33) return 9;
6050 60 240 else if (dist < 49) return 10;
6051 60 180 else if (dist < 65) return 11;
6052 60 120 else if (dist < 97) return 12;
6053 60 60 else if (dist < 129) return 13;
6057 420 480 if (dist < 2049) { /* dist 193..2049. */
6058 60 360 if (dist < 257) return 15;
6059 60 300 else if (dist < 385) return 16;
6060 60 240 else if (dist < 513) return 17;
6061 60 180 else if (dist < 769) return 18;
6062 60 120 else if (dist < 1025) return 19;
6063 60 60 else if (dist < 1537) return 20;
6066 60 420 if (dist < 3073) return 22;
6067 60 360 else if (dist < 4097) return 23;
6068 60 300 else if (dist < 6145) return 24;
6069 60 240 else if (dist < 8193) return 25;
6070 60 180 else if (dist < 12289) return 26;
6071 60 120 else if (dist < 16385) return 27;
6072 60 60 else if (dist < 24577) return 28;
6246 3 9 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
0 3 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
0 0 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
6255 179 99 for (i = 0; i < length; i++) {
6257 18 161 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
1 17 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
0 1 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
6272 356 115 for (i = 0; i < length; i++) {
6274 49 307 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
3 46 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
0 3 if (*bp == 0) ZOPFLI_APPEND_DATA(0, out, outsize);
6295 15660 522 for (i = 0; i < 30 /* Ignore the two unused codes from the spec */; i++) {
6296 434 15226 if (d_lengths[i]) num_dist_codes++;
6297 0 15660 if (num_dist_codes >= 2) return; /* Two or more codes is fine. */
6300 88 434 if (num_dist_codes == 0) {
6302 434 0 } else if (num_dist_codes == 1) {
6303 0 434 d_lengths[d_lengths[0] ? 1 : 0] = 1;
6337 79515 4185 for(i = 0; i < 19; i++) clcounts[i] = 0;
6340 30841 704 while (hlit > 0 && ll_lengths[257 + hlit - 1] == 0) hlit--;
27360 3481 while (hlit > 0 && ll_lengths[257 + hlit - 1] == 0) hlit--;
6341 103960 0 while (hdist > 0 && d_lengths[1 + hdist - 1] == 0) hdist--;
99775 4185 while (hdist > 0 && d_lengths[1 + hdist - 1] == 0) hdist--;
6346 190493 4185 for (i = 0; i < lld_total; i++) {
6348 178554 11939 unsigned char symbol = i < hlit2 ? ll_lengths[i] : d_lengths[i - hlit2];
6350 171513 18980 if(use_16 || (symbol == 0 && (use_17 || use_18))) {
150748 20765 if(use_16 || (symbol == 0 && (use_17 || use_18))) {
146374 4374 if(use_16 || (symbol == 0 && (use_17 || use_18))) {
2185 144189 if(use_16 || (symbol == 0 && (use_17 || use_18))) {
6351 1028279 2092 for (j = i + 1; j < lld_total && symbol ==
1004832 23447 for (j = i + 1; j < lld_total && symbol ==
6352 1008865 19414 (j < hlit2 ? ll_lengths[j] : d_lengths[j - hlit2]); j++) {
6359 159488 31005 if (symbol == 0 && count >= 3) {
13583 145905 if (symbol == 0 && count >= 3) {
6360 7763 5820 if (use_18) {
6361 5951 7763 while (count >= 11) {
6363 3 5948 if (!size_only) {
6364 2 1 ZOPFLI_APPEND_DATA(18, &rle, &rle_size);
1 1 ZOPFLI_APPEND_DATA(18, &rle, &rle_size);
6365 2 1 ZOPFLI_APPEND_DATA(count2 - 11, &rle_bits, &rle_bits_size);
1 1 ZOPFLI_APPEND_DATA(count2 - 11, &rle_bits, &rle_bits_size);
6371 7763 5820 if (use_17) {
6372 31469 7763 while (count >= 3) {
6374 1 31468 if (!size_only) {
6375 1 0 ZOPFLI_APPEND_DATA(17, &rle, &rle_size);
0 1 ZOPFLI_APPEND_DATA(17, &rle, &rle_size);
6376 1 0 ZOPFLI_APPEND_DATA(count2 - 3, &rle_bits, &rle_bits_size);
0 1 ZOPFLI_APPEND_DATA(count2 - 3, &rle_bits, &rle_bits_size);
6385 18980 171513 if (use_16 && count >= 4) {
3176 15804 if (use_16 && count >= 4) {
6388 0 3176 if (!size_only) {
6389 0 0 ZOPFLI_APPEND_DATA(symbol, &rle, &rle_size);
0 0 ZOPFLI_APPEND_DATA(symbol, &rle, &rle_size);
6390 0 0 ZOPFLI_APPEND_DATA(0, &rle_bits, &rle_bits_size);
0 0 ZOPFLI_APPEND_DATA(0, &rle_bits, &rle_bits_size);
6392 25911 3176 while (count >= 3) {
6394 0 25911 if (!size_only) {
6395 0 0 ZOPFLI_APPEND_DATA(16, &rle, &rle_size);
0 0 ZOPFLI_APPEND_DATA(16, &rle, &rle_size);
6396 0 0 ZOPFLI_APPEND_DATA(count2 - 3, &rle_bits, &rle_bits_size);
0 0 ZOPFLI_APPEND_DATA(count2 - 3, &rle_bits, &rle_bits_size);
6405 185908 190493 while (count > 0) {
6406 6 185902 if (!size_only) {
6407 2 4 ZOPFLI_APPEND_DATA(symbol, &rle, &rle_size);
0 2 ZOPFLI_APPEND_DATA(symbol, &rle, &rle_size);
6408 2 4 ZOPFLI_APPEND_DATA(0, &rle_bits, &rle_bits_size);
0 2 ZOPFLI_APPEND_DATA(0, &rle_bits, &rle_bits_size);
6415 1 4184 if (!size_only) ZopfliLengthsToSymbols(clcl, 19, 7, clsymbols);
6419 8370 0 while (hclen > 0 && clcounts[order[hclen + 4 - 1]] == 0) hclen--;
4185 4185 while (hclen > 0 && clcounts[order[hclen + 4 - 1]] == 0) hclen--;
6421 1 4184 if (!size_only) {
6426 18 1 for (i = 0; i < hclen + 4; i++) {
6430 10 1 for (i = 0; i < rle_size; i++) {
6434 0 10 if (rle[i] == 16) AddBits(rle_bits[i], 2, bp, out, outsize);
6435 1 9 else if (rle[i] == 17) AddBits(rle_bits[i], 3, bp, out, outsize);
6436 3 6 else if (rle[i] == 18) AddBits(rle_bits[i], 7, bp, out, outsize);
6442 79515 4185 for(i = 0; i < 19; i++) {
6465 8 1 for(i = 0; i < 8; i++) {
6469 7 1 if (bestsize == 0 || size < bestsize) {
4 3 if (bestsize == 0 || size < bestsize) {
6488 4176 522 for(i = 0; i < 8; i++) {
6492 3654 522 if (result == 0 || size < result) result = size;
2245 1409 if (result == 0 || size < result) result = size;
6513 64 4 for (i = lstart; i < lend; i++) {
6516 27 37 if (dist == 0) {
6543 29808 207 for (i = 0; i < 144; i++) ll_lengths[i] = 8;
6544 23184 207 for (i = 144; i < 256; i++) ll_lengths[i] = 9;
6545 4968 207 for (i = 256; i < 280; i++) ll_lengths[i] = 7;
6546 1656 207 for (i = 280; i < 288; i++) ll_lengths[i] = 8;
6547 6624 207 for (i = 0; i < 32; i++) d_lengths[i] = 5;
6560 12314 726 for (i = lstart; i < lend; i++) {
6563 2727 9587 if (lz77->dists[i] == 0) {
6589 522 0 if (lstart + ZOPFLI_NUM_LL * 3 > lend) {
6593 0 0 for (i = 0; i < 256; i++) {
6596 0 0 for (i = 257; i < 286; i++) {
6600 0 0 for (i = 0; i < 30; i++) {
6616 204 0 if (lstart + ZOPFLI_NUM_LL * 3 > lend) {
6629 790 1915 if (x > y)
6647 9587 0 for (; length >= 0; --length) {
6648 44 9543 if (length == 0) {
6651 478 9065 if (counts[length - 1] != 0) {
6659 74455 478 for (i = 0; i < length; ++i) good_for_rle[i] = 0;
6666 74933 478 for (i = 0; i < length + 1; ++i) {
6667 74455 478 if (i == length || counts[i] != symbol) {
2068 72387 if (i == length || counts[i] != symbol) {
6668 1273 1273 if ((symbol == 0 && stride >= 5) || (symbol != 0 && stride >= 7)) {
421 852 if ((symbol == 0 && stride >= 5) || (symbol != 0 && stride >= 7)) {
1273 421 if ((symbol == 0 && stride >= 5) || (symbol != 0 && stride >= 7)) {
0 1273 if ((symbol == 0 && stride >= 5) || (symbol != 0 && stride >= 7)) {
6669 71750 852 for (k = 0; k < stride; ++k) {
6674 2068 478 if (i != length) {
6686 74933 478 for (i = 0; i < length + 1; ++i) {
6687 74455 478 if (i == length || good_for_rle[i]
2705 71750 if (i == length || good_for_rle[i]
6689 348 2357 || AbsDiff(counts[i], limit) >= 4) {
6690 72441 135 if (stride >= 4 || (stride >= 3 && sum == 0)) {
7 72434 if (stride >= 4 || (stride >= 3 && sum == 0)) {
0 7 if (stride >= 4 || (stride >= 3 && sum == 0)) {
6693 36 99 if (count < 1) count = 1;
6694 0 135 if (sum == 0) {
6698 2011 135 for (k = 0; k < stride; ++k) {
6706 70916 1660 if (i < length - 3) {
6711 1182 478 } else if (i < length) {
6718 74455 478 if (i != length) {
6760 95 166 if (treesize2 + datasize2 < treesize + datasize) {
6797 200 464 if (btype == 0) {
6800 200 0 size_t blocks = length / 65535 + (rem ? 1 : 0);
6805 204 260 } if (btype == 1) {
6822 196 0 uncompressedcost : ZopfliCalculateBlockSize(lz77, lstart, lend, 1);
6824 0 0 return (uncompressedcost < fixedcost && uncompressedcost < dyncost)
6826 0 196 : (fixedcost < dyncost ? fixedcost : dyncost);
84 112 : (fixedcost < dyncost ? fixedcost : dyncost);
6844 0 0 if (pos + blocksize > inend) blocksize = inend - pos;
6849 0 0 AddBit(final && currentfinal, bp, out, outsize);
0 0 AddBit(final && currentfinal, bp, out, outsize);
6857 0 0 ZOPFLI_APPEND_DATA(blocksize % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA(blocksize % 256, out, outsize);
6858 0 0 ZOPFLI_APPEND_DATA((blocksize / 256) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((blocksize / 256) % 256, out, outsize);
6859 0 0 ZOPFLI_APPEND_DATA(nlen % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA(nlen % 256, out, outsize);
6860 0 0 ZOPFLI_APPEND_DATA((nlen / 256) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((nlen / 256) % 256, out, outsize);
6862 0 0 for (i = 0; i < blocksize; i++) {
6863 0 0 ZOPFLI_APPEND_DATA(in[pos + i], out, outsize);
0 0 ZOPFLI_APPEND_DATA(in[pos + i], out, outsize);
6866 0 0 if (currentfinal) break;
6902 0 4 if (btype == 0) {
6904 0 0 size_t pos = lstart == lend ? 0 : lz77->pos[lstart];
6915 3 1 if (btype == 1) {
6927 0 1 if (options->verbose) {
6942 64 4 for (i = lstart; i < lend; i++) {
6943 37 27 uncompressed_size += lz77->dists[i] == 0 ? 1 : lz77->litlens[i];
6946 0 4 if (options->verbose) {
6966 0 4 int expensivefixed = (lz77->size < 1000) || fixedcost <= dyncost * 1.1;
0 0 int expensivefixed = (lz77->size < 1000) || fixedcost <= dyncost * 1.1;
6969 0 4 if (lstart == lend) {
6977 4 0 if (expensivefixed) {
6989 0 4 if (uncompressedcost < fixedcost && uncompressedcost < dyncost) {
0 0 if (uncompressedcost < fixedcost && uncompressedcost < dyncost) {
6992 3 1 } else if (fixedcost < dyncost) {
6993 3 0 if (expensivefixed) {
7032 0 3 if (btype == 0) {
7035 0 3 } else if (btype == 1) {
7051 3 0 if (options->blocksplitting) {
7060 4 3 for (i = 0; i <= npoints; i++) {
7061 1 3 size_t start = i == 0 ? instart : splitpoints_uncompressed[i - 1];
7062 1 3 size_t end = i == npoints ? inend : splitpoints_uncompressed[i];
7071 1 3 if (i < npoints) splitpoints[i] = lz77.size;
7078 3 0 if (options->blocksplitting && npoints > 1) {
0 3 if (options->blocksplitting && npoints > 1) {
7086 0 0 for (i = 0; i <= npoints2; i++) {
7087 0 0 size_t start = i == 0 ? 0 : splitpoints2[i - 1];
7088 0 0 size_t end = i == npoints2 ? lz77.size : splitpoints2[i];
7092 0 0 if (totalcost2 < totalcost) {
7101 4 3 for (i = 0; i <= npoints; i++) {
7102 1 3 size_t start = i == 0 ? 0 : splitpoints[i - 1];
7103 3 1 size_t end = i == npoints ? lz77.size : splitpoints[i];
7104 3 1 AddLZ77BlockAutoType(options, i == npoints && final,
3 0 AddLZ77BlockAutoType(options, i == npoints && final,
7124 3 0 int final2 = final && masterfinal;
3 0 int final2 = final && masterfinal;
7125 3 0 size_t size = masterfinal ? insize - i : ZOPFLI_MASTER_BLOCK_SIZE;
7129 0 3 } while (i < insize);
7131 0 3 if (options->verbose) {
8404 9180 3 for (; size > 0; size--) {
8417 3 0 ZOPFLI_APPEND_DATA(31, out, outsize); /* ID1 */
3 0 ZOPFLI_APPEND_DATA(31, out, outsize); /* ID1 */
8418 3 0 ZOPFLI_APPEND_DATA(139, out, outsize); /* ID2 */
0 3 ZOPFLI_APPEND_DATA(139, out, outsize); /* ID2 */
8419 3 0 ZOPFLI_APPEND_DATA(8, out, outsize); /* CM */
0 3 ZOPFLI_APPEND_DATA(8, out, outsize); /* CM */
8420 0 3 ZOPFLI_APPEND_DATA(0, out, outsize); /* FLG */
0 0 ZOPFLI_APPEND_DATA(0, out, outsize); /* FLG */
8422 3 0 ZOPFLI_APPEND_DATA(0, out, outsize);
0 3 ZOPFLI_APPEND_DATA(0, out, outsize);
8423 0 3 ZOPFLI_APPEND_DATA(0, out, outsize);
0 0 ZOPFLI_APPEND_DATA(0, out, outsize);
8424 0 3 ZOPFLI_APPEND_DATA(0, out, outsize);
0 0 ZOPFLI_APPEND_DATA(0, out, outsize);
8425 0 3 ZOPFLI_APPEND_DATA(0, out, outsize);
0 0 ZOPFLI_APPEND_DATA(0, out, outsize);
8427 3 0 ZOPFLI_APPEND_DATA(2, out, outsize); /* XFL, 2 indicates best compression. */
0 3 ZOPFLI_APPEND_DATA(2, out, outsize); /* XFL, 2 indicates best compression. */
8428 0 3 ZOPFLI_APPEND_DATA(3, out, outsize); /* OS follows Unix conventions. */
0 0 ZOPFLI_APPEND_DATA(3, out, outsize); /* OS follows Unix conventions. */
8434 0 3 ZOPFLI_APPEND_DATA(crcvalue % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA(crcvalue % 256, out, outsize);
8435 0 3 ZOPFLI_APPEND_DATA((crcvalue >> 8) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((crcvalue >> 8) % 256, out, outsize);
8436 0 3 ZOPFLI_APPEND_DATA((crcvalue >> 16) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((crcvalue >> 16) % 256, out, outsize);
8437 0 3 ZOPFLI_APPEND_DATA((crcvalue >> 24) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((crcvalue >> 24) % 256, out, outsize);
8440 0 3 ZOPFLI_APPEND_DATA(insize % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA(insize % 256, out, outsize);
8441 0 3 ZOPFLI_APPEND_DATA((insize >> 8) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((insize >> 8) % 256, out, outsize);
8442 0 3 ZOPFLI_APPEND_DATA((insize >> 16) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((insize >> 16) % 256, out, outsize);
8443 0 3 ZOPFLI_APPEND_DATA((insize >> 24) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((insize >> 24) % 256, out, outsize);
8445 0 3 if (options->verbose) {
8733 8847360 135 for (i = 0; i < 65536; i++) {
8736 4423680 135 for (i = 0; i < window_size; i++) {
8742 4423680 135 for (i = 0; i < window_size; i++) {
8749 8847360 135 for (i = 0; i < 65536; i++) {
8752 4423680 135 for (i = 0; i < window_size; i++) {
8791 312147 270 UpdateHashValue(h, pos + ZOPFLI_MIN_MATCH <= end ?
8794 310998 1419 if (h->head[h->val] != -1 && h->hashval[h->head[h->val]] == h->val) {
310998 0 if (h->head[h->val] != -1 && h->hashval[h->head[h->val]] == h->val) {
8802 0 312417 if (h->same[(pos - 1) & ZOPFLI_WINDOW_MASK] > 1) {
8805 312282 135 while (pos + amount + 1 < end &&
0 312282 while (pos + amount + 1 < end &&
8806 0 0 array[pos] == array[pos + amount + 1] && amount < (unsigned short)(-1)) {
8815 310998 1419 if (h->head2[h->val2] != -1 && h->hashval2[h->head2[h->val2]] == h->val2) {
310998 0 if (h->head2[h->val2] != -1 && h->hashval2[h->head2[h->val2]] == h->val2) {
8826 135 0 if (pos + 1 < end) UpdateHashValue(h, array[pos + 1]);
8945 14148 78817 if (index == 0 && lastcount >= numsymbols) return;
5539 8609 if (index == 0 && lastcount >= numsymbols) return;
8955 8609 78817 if (index == 0) {
8960 69496 9321 if (lastcount < numsymbols && sum > leaves[lastcount].weight) {
43037 26459 if (lastcount < numsymbols && sum > leaves[lastcount].weight) {
8979 2274 1849 if (lastcount < numsymbols && sum > leaves[lastcount].weight) {
2274 0 if (lastcount < numsymbols && sum > leaves[lastcount].weight) {
9002 16605 4123 for (i = 0; i < maxbits; i++) {
9021 13428 4123 for (node = chain; node; node = node->tail) {
9026 13428 4123 while (ptr >= end) {
9027 21010 13428 for (; val > counts[ptr - 1]; val--) {
9058 246555 5229 for (i = 0; i < n; i++) {
9063 246555 5229 for (i = 0; i < n; i++) {
9064 22612 223943 if (frequencies[i]) {
9072 0 5229 if ((1 << maxbits) < numsymbols) {
9076 88 5141 if (numsymbols == 0) {
9080 434 4707 if (numsymbols == 1) {
9085 584 4123 if (numsymbols == 2) {
9094 21010 4123 for (i = 0; i < numsymbols; i++) {
9095 0 21010 if (leaves[i].weight >=
9103 21010 4123 for (i = 0; i < numsymbols; i++) {
9107 4012 111 if (numsymbols - 1 < maxbits) {
9121 21405 4123 for (i = 0; i < numBoundaryPMRuns - 1; i++) {
10301 4 0 if (!dest->litlens || !dest->dists) exit(-1);
0 4 if (!dest->litlens || !dest->dists) exit(-1);
10302 0 4 if (!dest->pos) exit(-1);
10303 4 0 if (!dest->ll_symbol || !dest->d_symbol) exit(-1);
0 4 if (!dest->ll_symbol || !dest->d_symbol) exit(-1);
10304 4 0 if (!dest->ll_counts || !dest->d_counts) exit(-1);
0 4 if (!dest->ll_counts || !dest->d_counts) exit(-1);
10307 64 4 for (i = 0; i < source->size; i++) {
10314 1152 4 for (i = 0; i < llsize; i++) {
10317 160 4 for (i = 0; i < dsize; i++) {
10337 74 1142 if (origsize % ZOPFLI_NUM_LL == 0) {
10339 21312 74 for (i = 0; i < ZOPFLI_NUM_LL; i++) {
10340 740 20572 ZOPFLI_APPEND_DATA(
74 666 ZOPFLI_APPEND_DATA(
0 21312 ZOPFLI_APPEND_DATA(
10345 93 1123 if (origsize % ZOPFLI_NUM_D == 0) {
10347 2976 93 for (i = 0; i < ZOPFLI_NUM_D; i++) {
10348 463 2513 ZOPFLI_APPEND_DATA(
74 389 ZOPFLI_APPEND_DATA(
608 2368 ZOPFLI_APPEND_DATA(
10354 408 808 ZOPFLI_APPEND_DATA(length, &store->litlens, &store->size);
74 334 ZOPFLI_APPEND_DATA(length, &store->litlens, &store->size);
10356 408 808 ZOPFLI_APPEND_DATA(dist, &store->dists, &store->size);
74 334 ZOPFLI_APPEND_DATA(dist, &store->dists, &store->size);
10358 408 808 ZOPFLI_APPEND_DATA(pos, &store->pos, &store->size);
74 334 ZOPFLI_APPEND_DATA(pos, &store->pos, &store->size);
10361 513 703 if (dist == 0) {
10363 285 228 ZOPFLI_APPEND_DATA(length, &store->ll_symbol, &store->size);
57 228 ZOPFLI_APPEND_DATA(length, &store->ll_symbol, &store->size);
10365 285 228 ZOPFLI_APPEND_DATA(0, &store->d_symbol, &store->size);
57 228 ZOPFLI_APPEND_DATA(0, &store->d_symbol, &store->size);
10369 123 580 ZOPFLI_APPEND_DATA(ZopfliGetLengthSymbol(length),
17 106 ZOPFLI_APPEND_DATA(ZopfliGetLengthSymbol(length),
10372 123 580 ZOPFLI_APPEND_DATA(ZopfliGetDistSymbol(dist),
17 106 ZOPFLI_APPEND_DATA(ZopfliGetDistSymbol(dist),
10382 64 4 for (i = 0; i < store->size; i++) {
10391 0 204 if (lstart == lend) return 0;
10392 174 30 return lz77->pos[l] + ((lz77->dists[l] == 0) ?
10403 0 0 for (i = 0; i < ZOPFLI_NUM_LL; i++) {
10406 0 0 for (i = lpos + 1; i < llpos + ZOPFLI_NUM_LL && i < lz77->size; i++) {
0 0 for (i = lpos + 1; i < llpos + ZOPFLI_NUM_LL && i < lz77->size; i++) {
10409 0 0 for (i = 0; i < ZOPFLI_NUM_D; i++) {
10412 0 0 for (i = lpos + 1; i < dpos + ZOPFLI_NUM_D && i < lz77->size; i++) {
0 0 for (i = lpos + 1; i < dpos + ZOPFLI_NUM_D && i < lz77->size; i++) {
10413 0 0 if (lz77->dists[i] != 0) d_counts[lz77->d_symbol[i]]--;
10421 261 0 if (lstart + ZOPFLI_NUM_LL * 3 > lend) {
10424 4415 261 for (i = lstart; i < lend; i++) {
10426 3380 1035 if (lz77->dists[i] != 0) d_counts[lz77->d_symbol[i]]++;
10432 0 0 if (lstart > 0) {
10437 0 0 for (i = 0; i < ZOPFLI_NUM_LL; i++) {
10440 0 0 for (i = 0; i < ZOPFLI_NUM_D; i++) {
10454 8 3 if (add_lmc) {
10465 8 3 if (s->lmc) {
10498 0 268 return distance > 1024 ? length - 1 : length;
10508 164754 666 for (i = 0; i < length; i++) {
10509 0 164754 if (data[pos - dist + i] != data[pos + i]) {
10532 636840 24170 while (scan < safe_end && *((size_t*)scan) == *((size_t*)match)) {
636840 0 while (scan < safe_end && *((size_t*)scan) == *((size_t*)match)) {
10554 64986 24170 while (scan != end && *scan == *match) {
64986 0 while (scan != end && *scan == *match) {
10577 147539 67 unsigned char cache_available = s->lmc && (s->lmc->length[lmcpos] == 0 ||
147539 0 unsigned char cache_available = s->lmc && (s->lmc->length[lmcpos] == 0 ||
122868 24671 unsigned char cache_available = s->lmc && (s->lmc->length[lmcpos] == 0 ||
10579 122868 24738 unsigned char limit_ok_for_cache = cache_available &&
14 122854 unsigned char limit_ok_for_cache = cache_available &&
10580 14 0 (*limit == ZOPFLI_MAX_MATCH || s->lmc->length[lmcpos] <= *limit ||
0 14 (*limit == ZOPFLI_MAX_MATCH || s->lmc->length[lmcpos] <= *limit ||
10581 0 0 (sublen && ZopfliMaxCachedSublen(s->lmc,
10584 147539 67 if (s->lmc && limit_ok_for_cache && cache_available) {
122854 24685 if (s->lmc && limit_ok_for_cache && cache_available) {
122854 0 if (s->lmc && limit_ok_for_cache && cache_available) {
10588 0 122854 if (*length > *limit) *length = *limit;
10589 122310 544 if (sublen) {
10592 122310 0 if (*limit == ZOPFLI_MAX_MATCH && *length >= ZOPFLI_MIN_MATCH) {
10622 24555 67 unsigned char cache_available = s->lmc && (s->lmc->length[lmcpos] == 0 ||
24555 0 unsigned char cache_available = s->lmc && (s->lmc->length[lmcpos] == 0 ||
14 24541 unsigned char cache_available = s->lmc && (s->lmc->length[lmcpos] == 0 ||
10625 24555 67 if (s->lmc && limit == ZOPFLI_MAX_MATCH && sublen && !cache_available) {
17468 7087 if (s->lmc && limit == ZOPFLI_MAX_MATCH && sublen && !cache_available) {
17468 0 if (s->lmc && limit == ZOPFLI_MAX_MATCH && sublen && !cache_available) {
17468 0 if (s->lmc && limit == ZOPFLI_MAX_MATCH && sublen && !cache_available) {
10627 17468 0 s->lmc->dist[lmcpos] = length < ZOPFLI_MIN_MATCH ? 0 : distance;
10628 17468 0 s->lmc->length[lmcpos] = length < ZOPFLI_MIN_MATCH ? 0 : length;
10658 122854 24752 if (TryGetFromLongestMatchCache(s, pos, &limit, sublen, distance, length)) {
10668 130 24622 if (size - pos < ZOPFLI_MIN_MATCH) {
10676 7063 17559 if (pos + limit > size) {
10689 24170 452 dist = p < pp ? pp - p : ((ZOPFLI_WINDOW_SIZE - p) + pp);
10692 24170 452 while (dist < ZOPFLI_WINDOW_SIZE) {
10699 24170 0 if (dist > 0) {
10706 24170 0 if (pos + bestlength >= size
10707 24170 0 || *(scan + bestlength) == *(match + bestlength)) {
10711 0 24170 if (same0 > 2 && *scan == *match) {
0 0 if (same0 > 2 && *scan == *match) {
10714 0 0 if (same > limit) same = limit;
10723 24170 0 if (currentlength > bestlength) {
10724 24122 48 if (sublen) {
10726 5129488 24122 for (j = bestlength + 1; j <= currentlength; j++) {
10732 24170 0 if (currentlength >= limit) break;
10739 0 0 if (hhead != h->head2 && bestlength >= h->same[hpos] &&
0 0 if (hhead != h->head2 && bestlength >= h->same[hpos] &&
0 0 if (hhead != h->head2 && bestlength >= h->same[hpos] &&
10751 0 0 if (p == pp) break; /* Uninited prev value. */
10753 0 0 dist += p < pp ? pp - p : ((ZOPFLI_WINDOW_SIZE - p) + pp);
10757 0 0 if (chain_counter <= 0) break;
10780 0 7 ? instart - ZOPFLI_WINDOW_SIZE : 0;
10791 0 7 if (instart == inend) return;
10795 9 7 for (i = windowstart; i < instart; i++) {
10799 134 7 for (i = instart; i < inend; i++) {
10809 6 128 if (match_available) {
10811 0 6 if (lengthscore > prevlengthscore + 1) {
10813 0 0 if (lengthscore >= ZOPFLI_MIN_MATCH && leng < ZOPFLI_MAX_MATCH) {
0 0 if (lengthscore >= ZOPFLI_MIN_MATCH && leng < ZOPFLI_MAX_MATCH) {
10827 750 6 for (j = 2; j < leng; j++) {
10835 74 54 else if (lengthscore >= ZOPFLI_MIN_MATCH && leng < ZOPFLI_MAX_MATCH) {
6 68 else if (lengthscore >= ZOPFLI_MIN_MATCH && leng < ZOPFLI_MAX_MATCH) {
10845 68 54 if (lengthscore >= ZOPFLI_MIN_MATCH) {
10852 17476 122 for (j = 1; j < leng; j++) {
13888 9216 32 for (i = 0; i < ZOPFLI_NUM_LL; i++) {
13892 1024 32 for (i = 0; i < ZOPFLI_NUM_D; i++) {
13917 11520 72 for (i = 0; i < n; i++) {
13918 3860 7660 if ((Ran(state) >> 4) % 3 == 0) freqs[i] = freqs[Ran(state) % n];
13930 17280 60 for (i = 0; i < ZOPFLI_NUM_LL; i++) stats->litlens[i] = 0;
13931 1920 60 for (i = 0; i < ZOPFLI_NUM_D; i++) stats->dists[i] = 0;
13946 9180 794546 if (dist == 0) {
13947 9180 0 if (litlen <= 143) return 8;
13954 43002 751544 if (lsym <= 279) cost += 7;
13967 137700 7709449 if (dist == 0) {
13999 16384 64 for (i = 3; i < 259; i++) {
14001 76 16308 if (c < mincost) {
14008 1920 64 for (i = 0; i < 30; i++) {
14010 78 1842 if (c < mincost) {
14049 0 64 ? instart - ZOPFLI_WINDOW_SIZE : 0;
14054 0 64 if (instart == inend) return 0;
14058 144 64 for (i = windowstart; i < instart; i++) {
14062 146880 64 for (i = 1; i < blocksize + 1; i++) costs[i] = ZOPFLI_LARGE_FLOAT;
14066 146880 64 for (i = instart; i < inend; i++) {
14073 0 146880 if (h->same[i & ZOPFLI_WINDOW_MASK] > ZOPFLI_MAX_MATCH * 2
14074 0 0 && i > instart + ZOPFLI_MAX_MATCH + 1
14075 0 0 && i + ZOPFLI_MAX_MATCH * 2 + 1 < inend
14076 0 0 && h->same[(i - ZOPFLI_MAX_MATCH) & ZOPFLI_WINDOW_MASK]
14082 0 0 for (k = 0; k < ZOPFLI_MAX_MATCH; k++) {
14096 146880 0 if (i + 1 <= inend) {
14099 1046 145834 if (newCost < costs[j + 1]) {
14107 36397824 146880 for (k = 3; k <= kend; k++) {
14112 27912197 8485627 if (costs[j + k] <= mincostaddcostj) continue;
14116 190816 8294811 if (newCost < costs[j + k]) {
14139 0 64 if (size == 0) return;
14141 352 672 ZOPFLI_APPEND_DATA(length_array[index], path, pathsize);
64 288 ZOPFLI_APPEND_DATA(length_array[index], path, pathsize);
14146 64 960 if (index == 0) break;
14150 496 64 for (index = 0; index < *pathsize / 2; index++) {
14163 0 64 ? instart - ZOPFLI_WINDOW_SIZE : 0;
14167 0 64 if (instart == inend) return;
14171 144 64 for (i = windowstart; i < instart; i++) {
14176 1024 64 for (i = 0; i < pathsize; i++) {
14185 592 432 if (length >= ZOPFLI_MIN_MATCH) {
14202 145856 1024 for (j = 1; j < length; j++) {
14219 1024 64 for (i = 0; i < store->size; i++) {
14220 432 592 if (store->dists[i] == 0) {
14288 0 4 if (!costs) exit(-1); /* Allocation failed. */
14289 0 4 if (!length_array) exit(-1); /* Allocation failed. */
14305 60 4 for (i = 0; i < numiterations; i++) {
14312 60 0 if (s->options->verbose_more || (s->options->verbose && cost < bestcost)) {
0 60 if (s->options->verbose_more || (s->options->verbose && cost < bestcost)) {
0 0 if (s->options->verbose_more || (s->options->verbose && cost < bestcost)) {
14315 4 56 if (cost < bestcost) {
14324 32 28 if (lastrandomstep != -1) {
14331 36 24 if (i > 5 && cost == lastcost) {
36 0 if (i > 5 && cost == lastcost) {
14362 0 4 if (!costs) exit(-1); /* Allocation failed. */
14363 0 4 if (!length_array) exit(-1); /* Allocation failed. */
14670 1299 9 for (i = 0; i < n; i++) {
14676 136 9 for (bits = 0; bits <= maxbits; bits++) {
14679 1299 9 for (i = 0; i < n; i++) {
14686 127 9 for (bits = 1; bits <= maxbits; bits++) {
14692 1299 9 for (i = 0; i < n; i++) {
14694 970 329 if (len != 0) {
14709 42240 264 for (i = 0; i < n; ++i) {
14712 36 228 log2sum = (sum == 0 ? log(n) : log(sum)) * kInvLog2;
14713 42240 264 for (i = 0; i < n; ++i) {
14717 40893 1347 if (count[i] == 0) bitlengths[i] = log2sum;
14724 0 42240 if (bitlengths[i] < 0 && bitlengths[i] > -1e-5) bitlengths[i] = 0;
0 0 if (bitlengths[i] < 0 && bitlengths[i] > -1e-5) bitlengths[i] = 0;
16248 0 0 while (size > 0) {
16251 0 0 while (amount > 0) {
16275 0 0 ZOPFLI_APPEND_DATA(cmfflg / 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA(cmfflg / 256, out, outsize);
16276 0 0 ZOPFLI_APPEND_DATA(cmfflg % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA(cmfflg % 256, out, outsize);
16281 0 0 ZOPFLI_APPEND_DATA((checksum >> 24) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((checksum >> 24) % 256, out, outsize);
16282 0 0 ZOPFLI_APPEND_DATA((checksum >> 16) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((checksum >> 16) % 256, out, outsize);
16283 0 0 ZOPFLI_APPEND_DATA((checksum >> 8) % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA((checksum >> 8) % 256, out, outsize);
16284 0 0 ZOPFLI_APPEND_DATA(checksum % 256, out, outsize);
0 0 ZOPFLI_APPEND_DATA(checksum % 256, out, outsize);
16286 0 0 if (options->verbose) {
17521 0 0 if (!file) return 0;
17525 0 0 if(*outsize > 2147483647) {
17533 0 0 if (*outsize && (*out)) {
0 0 if (*outsize && (*out)) {
17535 0 0 if (testsize != *outsize) {
17556 0 0 if (file == NULL) {
17576 0 0 if (!LoadFile(infilename, &in, &insize)) {
17583 0 0 if (outfilename) {
17603 0 0 if (!result) exit(-1); /* Allocation failed. */
17622 0 0 for (i = 1; i < argc; i++) {
17624 0 0 if (StringsEqual(arg, "-v")) options.verbose = 1;
17625 0 0 else if (StringsEqual(arg, "-c")) output_to_stdout = 1;
17626 0 0 else if (StringsEqual(arg, "--deflate")) {
17629 0 0 else if (StringsEqual(arg, "--zlib")) output_type = ZOPFLI_FORMAT_ZLIB;
17630 0 0 else if (StringsEqual(arg, "--gzip")) output_type = ZOPFLI_FORMAT_GZIP;
17631 0 0 else if (StringsEqual(arg, "--splitlast")) /* Ignore */;
17632 0 0 else if (arg[0] == '-' && arg[1] == '-' && arg[2] == 'i'
0 0 else if (arg[0] == '-' && arg[1] == '-' && arg[2] == 'i'
0 0 else if (arg[0] == '-' && arg[1] == '-' && arg[2] == 'i'
17633 0 0 && arg[3] >= '0' && arg[3] <= '9') {
0 0 && arg[3] >= '0' && arg[3] <= '9') {
17636 0 0 else if (StringsEqual(arg, "-h")) {
17655 0 0 if (options.numiterations < 1) {
17660 0 0 for (i = 1; i < argc; i++) {
17661 0 0 if (argv[i][0] != '-') {
17664 0 0 if (output_to_stdout) {
17666 0 0 } else if (output_type == ZOPFLI_FORMAT_GZIP) {
17668 0 0 } else if (output_type == ZOPFLI_FORMAT_ZLIB) {
17674 0 0 if (options.verbose && outfilename) {
0 0 if (options.verbose && outfilename) {
17682 0 0 if (!filename) {
18991 3 0 if (output_type == ZOPFLI_FORMAT_GZIP) {
18993 0 0 } else if (output_type == ZOPFLI_FORMAT_ZLIB) {
18995 0 0 } else if (output_type == ZOPFLI_FORMAT_DEFLATE) {