Lines Matching refs:hash
1506 static unsigned hash_init(Hash* hash, unsigned windowsize) { in hash_init() argument
1508 hash->head = (int*)lodepng_malloc(sizeof(int) * HASH_NUM_VALUES); in hash_init()
1509 hash->val = (int*)lodepng_malloc(sizeof(int) * windowsize); in hash_init()
1510 hash->chain = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize); in hash_init()
1512 hash->zeros = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize); in hash_init()
1513 hash->headz = (int*)lodepng_malloc(sizeof(int) * (MAX_SUPPORTED_DEFLATE_LENGTH + 1)); in hash_init()
1514 hash->chainz = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize); in hash_init()
1516 if(!hash->head || !hash->chain || !hash->val || !hash->headz|| !hash->chainz || !hash->zeros) { in hash_init()
1521 for(i = 0; i != HASH_NUM_VALUES; ++i) hash->head[i] = -1; in hash_init()
1522 for(i = 0; i != windowsize; ++i) hash->val[i] = -1; in hash_init()
1523 …for(i = 0; i != windowsize; ++i) hash->chain[i] = i; /*same value as index indicates uninitialized… in hash_init()
1525 for(i = 0; i <= MAX_SUPPORTED_DEFLATE_LENGTH; ++i) hash->headz[i] = -1; in hash_init()
1526 …for(i = 0; i != windowsize; ++i) hash->chainz[i] = i; /*same value as index indicates uninitialize… in hash_init()
1531 static void hash_cleanup(Hash* hash) { in hash_cleanup() argument
1532 lodepng_free(hash->head); in hash_cleanup()
1533 lodepng_free(hash->val); in hash_cleanup()
1534 lodepng_free(hash->chain); in hash_cleanup()
1536 lodepng_free(hash->zeros); in hash_cleanup()
1537 lodepng_free(hash->headz); in hash_cleanup()
1538 lodepng_free(hash->chainz); in hash_cleanup()
1573 static void updateHashChain(Hash* hash, size_t wpos, unsigned hashval, unsigned short numzeros) { in updateHashChain() argument
1574 hash->val[wpos] = (int)hashval; in updateHashChain()
1575 if(hash->head[hashval] != -1) hash->chain[wpos] = hash->head[hashval]; in updateHashChain()
1576 hash->head[hashval] = (int)wpos; in updateHashChain()
1578 hash->zeros[wpos] = numzeros; in updateHashChain()
1579 if(hash->headz[numzeros] != -1) hash->chainz[wpos] = hash->headz[numzeros]; in updateHashChain()
1580 hash->headz[numzeros] = (int)wpos; in updateHashChain()
1592 static unsigned encodeLZ77(uivector* out, Hash* hash, in encodeLZ77() argument
1632 updateHashChain(hash, wpos, hashval, numzeros); in encodeLZ77()
1638 hashpos = hash->chain[wpos]; in encodeLZ77()
1657 unsigned skip = hash->zeros[hashpos]; in encodeLZ77()
1678 if(hashpos == hash->chain[hashpos]) break; in encodeLZ77()
1681 hashpos = hash->chainz[hashpos]; in encodeLZ77()
1682 if(hash->zeros[hashpos] != numzeros) break; in encodeLZ77()
1684 hashpos = hash->chain[hashpos]; in encodeLZ77()
1686 if(hash->val[hashpos] != (int)hashval) break; in encodeLZ77()
1706 …hash->head[hashval] = -1; /*the same hashchain update will be done, this ensures no wrong alterati… in encodeLZ77()
1707 hash->headz[numzeros] = -1; /*idem*/ in encodeLZ77()
1733 updateHashChain(hash, wpos, hashval, numzeros); in encodeLZ77()
1806 static unsigned deflateDynamic(LodePNGBitWriter* writer, Hash* hash, in deflateDynamic() argument
1867 error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize, in deflateDynamic()
2028 static unsigned deflateFixed(LodePNGBitWriter* writer, Hash* hash, in deflateFixed() argument
2053 error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize, in deflateFixed()
2077 Hash hash; in lodepng_deflatev() local
2095 error = hash_init(&hash, settings->windowsize); in lodepng_deflatev()
2104 … if(settings->btype == 1) error = deflateFixed(&writer, &hash, in, start, end, settings, final); in lodepng_deflatev()
2105 …else if(settings->btype == 2) error = deflateDynamic(&writer, &hash, in, start, end, settings, fin… in lodepng_deflatev()
2109 hash_cleanup(&hash); in lodepng_deflatev()