get the literal and length code tree of a deflated block with fixed tree, as per the deflate specification*/
| 861 | |
| 862 | /*get the literal and length code tree of a deflated block with fixed tree, as per the deflate specification*/ |
| 863 | static unsigned generateFixedLitLenTree(HuffmanTree* tree) |
| 864 | { |
| 865 | unsigned i, error = 0; |
| 866 | unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned)); |
| 867 | if(!bitlen) return 83; /*alloc fail*/ |
| 868 | |
| 869 | /*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/ |
| 870 | for(i = 0; i <= 143; i++) bitlen[i] = 8; |
| 871 | for(i = 144; i <= 255; i++) bitlen[i] = 9; |
| 872 | for(i = 256; i <= 279; i++) bitlen[i] = 7; |
| 873 | for(i = 280; i <= 287; i++) bitlen[i] = 8; |
| 874 | |
| 875 | error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15); |
| 876 | |
| 877 | lodepng_free(bitlen); |
| 878 | return error; |
| 879 | } |
| 880 | |
| 881 | /*get the distance code tree of a deflated block with fixed tree, as specified in the deflate specification*/ |
| 882 | static unsigned generateFixedDistanceTree(HuffmanTree* tree) |
no test coverage detected