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

Method encode

dlib/entropy_encoder_model/entropy_encoder_model_kernel_1.h:127–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 typename cc
126 >
127 void entropy_encoder_model_kernel_1<alphabet_size,entropy_encoder,cc>::
128 encode (
129 unsigned long symbol
130 )
131 {
132 unsigned long low_count = 0, high_count = 0, total_count = 0;
133
134 // if we have seen this symbol in the order-0 context
135 if (order_0.get_range(symbol,low_count,high_count,total_count))
136 {
137 // update the count for this symbol
138 order_0.increment_count(symbol,2);
139 // encode this symbol
140 coder.encode(low_count,high_count,total_count);
141 return;
142 }
143
144 // if we are here then the symbol does not appear in the order-0 context
145
146
147 // since we have never seen the current symbol in this context
148 // escape from order-0 context
149 order_0.get_range(alphabet_size,low_count,high_count,total_count);
150 coder.encode(low_count,high_count,total_count);
151 // increment the count for the escape symbol
152 order_0.increment_count(alphabet_size);
153
154 // update the count for this symbol
155 order_0.increment_count(symbol,2);
156
157 // use order minus one context
158 coder.encode(symbol,symbol+1,alphabet_size);
159
160 }
161
162// ----------------------------------------------------------------------------------------
163

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected