Changeset 161 for libmpc/branches/r2d/common/huffman.c
- Timestamp:
- 12/18/06 20:52:54 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/common/huffman.c
r157 r161 194 194 * @param num_symbols 195 195 * @param print_type 196 */ 197 void _Huffman_PrintCodes(huff_sym_t * sym, unsigned int num_symbols, int print_type) 196 * @param offset 197 */ 198 void _Huffman_PrintCodes(huff_sym_t * sym, unsigned int num_symbols, int print_type, int offset) 198 199 { 199 200 unsigned int total_cnt = 0, total_size = 0, optim_size = 0; 200 int i ;201 int i, packs[4]; 201 202 202 203 switch( print_type ) { … … 217 218 printf("{\n "); 218 219 for( i = num_symbols - 1; i >= 0; i--) { 219 printf("{0x%.8x, %u, %u}", sym[i].Code << (32 - sym[i].Bits), sym[i].Bits, sym[i].Symbol); 220 printf("{0x%.8x, %u, %i}", sym[i].Code << (32 - sym[i].Bits), sym[i].Bits, sym[i].Symbol - offset); 221 if (i != 0) 222 printf(", "); 223 } 224 printf("\n}\n"); 225 break; 226 case 4: 227 qsort(sym, num_symbols, sizeof(huff_sym_t), 228 (int (*)(const void *, const void *)) _Huffman_CompBits); 229 printf("{\n "); 230 for( i = num_symbols - 1; i >= 0; i--) { 231 int symbol = sym[i].Symbol; 232 packs[3] = symbol / (offset * offset * offset); 233 packs[2] = (symbol - packs[3] * offset * offset * offset) / (offset * offset); 234 packs[1] = (symbol - (packs[3] * offset + packs[2]) * offset * offset) / offset; 235 packs[0] = symbol - ((packs[3] * offset + packs[2]) * offset + packs[1] * offset); 236 packs[0] -= offset >> 1; 237 packs[1] -= offset >> 1; 238 packs[2] -= offset >> 1; 239 packs[3] -= offset >> 1; 240 symbol = ((packs[3] & 15) << 12) | ((packs[2] & 15) << 8) | ((packs[1] & 15) << 4) | (packs[0] & 15); 241 printf("{0x%.8x, %u, %i}", sym[i].Code << (32 - sym[i].Bits), sym[i].Bits, symbol); 220 242 if (i != 0) 221 243 printf(", "); … … 234 256 for( i = 0; i < num_symbols; i++) { 235 257 int k = sym[i].Bits - 1; 236 printf("%-10 u %-10u %-10u ", sym[i].Symbol, sym[i].Count, sym[i].Bits);258 printf("%-10i %-10u %-10u ", sym[i].Symbol - offset, sym[i].Count, sym[i].Bits); 237 259 for (; k >= 0 ; k--) 238 260 printf("%u", (sym[i].Code >> k) & 1 );
Note: See TracChangeset
for help on using the changeset viewer.