* Get context-dependent Golomb code, decode it and update context */
| 151 | * Get context-dependent Golomb code, decode it and update context |
| 152 | */ |
| 153 | static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q) |
| 154 | { |
| 155 | int k, ret; |
| 156 | |
| 157 | for (k = 0; ((unsigned)state->N[Q] << k) < state->A[Q]; k++) |
| 158 | ; |
| 159 | |
| 160 | #ifdef JLS_BROKEN |
| 161 | if (!show_bits_long(gb, 32)) |
| 162 | return -1; |
| 163 | #endif |
| 164 | ret = get_ur_golomb_jpegls(gb, k, state->limit, state->qbpp); |
| 165 | |
| 166 | /* decode mapped error */ |
| 167 | if (ret & 1) |
| 168 | ret = -(ret + 1 >> 1); |
| 169 | else |
| 170 | ret >>= 1; |
| 171 | |
| 172 | /* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */ |
| 173 | if (!state->near && !k && (2 * state->B[Q] <= -state->N[Q])) |
| 174 | ret = -(ret + 1); |
| 175 | |
| 176 | ret = ff_jpegls_update_state_regular(state, Q, ret); |
| 177 | |
| 178 | return ret; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Get Golomb code, decode it and update state for run termination |
no test coverage detected