| 218 | typename cc_high |
| 219 | > |
| 220 | void entropy_decoder_model_kernel_3<alphabet_size,entropy_decoder,cc,cc_high>:: |
| 221 | decode ( |
| 222 | unsigned long& symbol |
| 223 | ) |
| 224 | { |
| 225 | unsigned long current_symbol, low_count, high_count, target; |
| 226 | |
| 227 | |
| 228 | // look in the order-2 context |
| 229 | unsigned long temp = previous_symbol + (previous_symbol2 * alphabet_size); |
| 230 | if (order_2[temp] != 0) |
| 231 | { |
| 232 | target = coder.get_target(order_2[temp]->get_total()); |
| 233 | order_2[temp]->get_symbol(target,current_symbol,low_count,high_count); |
| 234 | |
| 235 | // have the coder decode the next symbol |
| 236 | coder.decode(low_count,high_count); |
| 237 | |
| 238 | // if the current_symbol is not an escape from the order-2 context |
| 239 | if (current_symbol != alphabet_size) |
| 240 | { |
| 241 | symbol = current_symbol; |
| 242 | order_2[temp]->increment_count(current_symbol,2); |
| 243 | previous_symbol2 = previous_symbol; |
| 244 | previous_symbol = current_symbol; |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | // since this is an escape to order-1 we should increment |
| 249 | // the escape symbol |
| 250 | order_2[temp]->increment_count(alphabet_size); |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | order_2[temp] = new cc_high(gs_high); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | // look in the order-1 context |
| 263 | target = coder.get_target(order_1[previous_symbol]->get_total()); |
| 264 | order_1[previous_symbol]->get_symbol(target,current_symbol,low_count,high_count); |
| 265 | |
| 266 | // have the coder decode the next symbol |
| 267 | coder.decode(low_count,high_count); |
| 268 | |
| 269 | // if the current_symbol is not an escape from the order-1 context |
| 270 | if (current_symbol != alphabet_size) |
| 271 | { |
| 272 | symbol = current_symbol; |
| 273 | order_2[temp]->increment_count(current_symbol,2); |
| 274 | order_1[previous_symbol]->increment_count(current_symbol,2); |
| 275 | previous_symbol2 = previous_symbol; |
| 276 | previous_symbol = current_symbol; |
| 277 | return; |