Home | History | Annotate | Download | only in lodepng

Lines Matching defs:coin

646 A coin, this is the terminology used for the package-merge algorithm and the
647 coin collector's problem. This is used to generate the huffman tree.
648 A coin can be multiple coins (when they're merged)
650 typedef struct Coin
653 float weight; /*the sum of all weights in this coin*/
654 } Coin;
656 static void coin_init(Coin* c)
664 uivector_cleanup(&((Coin*)c)->symbols);
667 static void coin_copy(Coin* c1, const Coin* c2)
673 static void add_coins(Coin* c1, const Coin* c2)
680 static void init_coins(Coin* coins, size_t num)
686 static void cleanup_coins(Coin* coins, size_t num)
693 float wa = ((const Coin*)a)->weight;
694 float wb = ((const Coin*)b)->weight;
698 static unsigned append_symbol_coins(Coin* coins, const unsigned* frequencies, unsigned numcodes, size_t sum)
720 Coin* coins; /*the coins of the currently calculated row*/
721 Coin* prev_row; /*the previous row of coins*/
761 /*Package-Merge algorithm represented by coin collector's problem
765 coins = (Coin*)lodepng_malloc(sizeof(Coin) * coinmem);
766 prev_row = (Coin*)lodepng_malloc(sizeof(Coin) * coinmem);
779 qsort(coins, numcoins, sizeof(Coin), coin_compare);
786 Coin* tempcoins;
799 /*merge prev_row[i] and prev_row[i + 1] into new coin*/
800 Coin* coin = &coins[numcoins++];
801 coin_copy(coin, &prev_row[i]);
802 add_coins(coin, &prev_row[i + 1]);
810 qsort(coins, numcoins, sizeof(Coin), coin_compare);
816 /*calculate the lenghts of each symbol, as the amount of times a coin of each symbol is used*/
819 Coin* coin = &coins[i];
820 for(j = 0; j < coin->symbols.size; j++) lengths[coin->symbols.data[j]]++;