| 172 | typename ccbig |
| 173 | > |
| 174 | void entropy_decoder_model_kernel_2<alphabet_size,entropy_decoder,cc,ccbig>:: |
| 175 | decode ( |
| 176 | unsigned long& symbol |
| 177 | ) |
| 178 | { |
| 179 | unsigned long current_symbol, low_count, high_count, target; |
| 180 | |
| 181 | // look in the order-1 context |
| 182 | target = coder.get_target(order_1[previous_symbol]->get_total()); |
| 183 | order_1[previous_symbol]->get_symbol(target,current_symbol,low_count,high_count); |
| 184 | |
| 185 | // have the coder decode the next symbol |
| 186 | coder.decode(low_count,high_count); |
| 187 | |
| 188 | // if the current_symbol is not an escape from the order-1 context |
| 189 | if (current_symbol != alphabet_size) |
| 190 | { |
| 191 | symbol = current_symbol; |
| 192 | order_1[previous_symbol]->increment_count(current_symbol,2); |
| 193 | previous_symbol = current_symbol; |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | // since this is an escape to order-0 we should increment |
| 198 | // the escape symbol |
| 199 | order_1[previous_symbol]->increment_count(alphabet_size); |
| 200 | |
| 201 | |
| 202 | |
| 203 | // look in the order-0 context |
| 204 | target = coder.get_target(order_0.get_total()); |
| 205 | order_0.get_symbol(target,current_symbol,low_count,high_count); |
| 206 | |
| 207 | // have coder decode the next symbol |
| 208 | coder.decode(low_count,high_count); |
| 209 | |
| 210 | // if current_symbol is not an escape from the order-0 context |
| 211 | if (current_symbol != alphabet_size) |
| 212 | { |
| 213 | // update the count for this symbol |
| 214 | order_1[previous_symbol]->increment_count(current_symbol,2); |
| 215 | order_0.increment_count(current_symbol,2); |
| 216 | |
| 217 | symbol = current_symbol; |
| 218 | previous_symbol = current_symbol; |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | // update the count for the escape symbol |
| 223 | order_0.increment_count(current_symbol); |
| 224 | |
| 225 | |
| 226 | // go into the order minus one context |
| 227 | target = coder.get_target(alphabet_size); |
| 228 | coder.decode(target,target+1); |
| 229 | |
| 230 | |
| 231 | // update the count for this symbol |