MCPcopy Create free account
hub / github.com/davisking/dlib / encode

Method encode

dlib/entropy_encoder_model/entropy_encoder_model_kernel_4.h:292–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290 unsigned long order
291 >
292 void entropy_encoder_model_kernel_4<alphabet_size,entropy_encoder,total_nodes,order>::
293 encode (
294 unsigned long sym
295 )
296 {
297 unsigned short symbol = static_cast<unsigned short>(sym);
298 node* temp = cur;
299 cur = 0;
300 unsigned short low_count, high_count, total_count;
301 node* new_node = 0;
302
303 // local_order will track the level of temp in the tree
304 unsigned long local_order = cur_order;
305
306 while (true)
307 {
308 high_count = 0;
309 if (space_left())
310 {
311 total_count = temp->total;
312
313 if (total_count > 0)
314 {
315 // check if we need to scale the counts
316 if (total_count > 10000)
317 {
318 scale_counts(temp);
319 total_count = temp->total;
320 }
321
322 // find either the symbol we are looking for or the
323 // end of the context set
324 node* n = temp->child_context;
325 node* last = 0;
326 while (true)
327 {
328 high_count += n->count;
329
330 if (n->symbol == symbol || n->next == 0)
331 break;
332 last = n;
333 n = n->next;
334 }
335
336 low_count = high_count - n->count;
337
338 // if we found the symbol
339 if (n->symbol == symbol)
340 {
341 if (new_node != 0)
342 {
343 new_node->parent_context = n;
344 }
345
346 coder.encode(low_count,high_count,total_count);
347 n->count += 8;
348 temp->total += 8;
349

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected