| 364 | unsigned long order |
| 365 | > |
| 366 | void entropy_encoder_model_kernel_5<alphabet_size,entropy_encoder,total_nodes,order>:: |
| 367 | encode ( |
| 368 | unsigned long sym |
| 369 | ) |
| 370 | { |
| 371 | unsigned short symbol = static_cast<unsigned short>(sym); |
| 372 | node* temp = cur; |
| 373 | cur = 0; |
| 374 | unsigned short low_count, high_count, total_count; |
| 375 | node* new_node = 0; |
| 376 | |
| 377 | // local_order will track the level of temp in the tree |
| 378 | unsigned long local_order = cur_order; |
| 379 | |
| 380 | |
| 381 | unsigned short c; // c == t(a|sk) |
| 382 | unsigned short t; // t == T(sk) |
| 383 | |
| 384 | |
| 385 | if (something_is_excluded()) |
| 386 | clear_exclusions(); |
| 387 | |
| 388 | while (true) |
| 389 | { |
| 390 | low_count = 0; |
| 391 | high_count = 0; |
| 392 | if (space_left()) |
| 393 | { |
| 394 | total_count = temp->total; |
| 395 | |
| 396 | if (total_count > 0) |
| 397 | { |
| 398 | // check if we need to scale the counts |
| 399 | if (total_count > 10000) |
| 400 | { |
| 401 | scale_counts(temp); |
| 402 | total_count = temp->total; |
| 403 | } |
| 404 | |
| 405 | |
| 406 | // find the symbol we are looking for and put a pointer to it |
| 407 | // into found_symbol. If it isn't found then found_symbol == 0. |
| 408 | // also, low_count and high_count will be correctly set. |
| 409 | node* n = temp->child_context; |
| 410 | node* found_symbol = 0; |
| 411 | node* last = 0; |
| 412 | if (something_is_excluded()) |
| 413 | { |
| 414 | node* templast = 0; |
| 415 | while (true) |
| 416 | { |
| 417 | if (is_excluded(n->symbol) == false) |
| 418 | { |
| 419 | exclude(n->symbol); |
| 420 | if (found_symbol == 0) |
| 421 | { |
| 422 | high_count += n->count; |
| 423 | if (n->symbol == symbol) |