Lines Matching refs:state

152 static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
156 for (k = 0; ((unsigned)state->N[Q] << k) < state->A[Q]; k++)
163 ret = get_ur_golomb_jpegls(gb, k, state->limit, state->qbpp);
172 if (!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
175 ret = ff_jpegls_update_state_regular(state, Q, ret);
181 * Get Golomb code, decode it and update state for run termination
183 static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
189 temp = state->A[Q];
191 temp += state->N[Q] >> 1;
193 for (k = 0; ((unsigned)state->N[Q] << k) < temp; k++)
200 ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
201 state->qbpp);
207 if (!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
213 state->B[Q]++;
220 /* update state */
221 state->A[Q] += FFABS(ret) - RItype;
222 ret *= state->twonear;
223 ff_jpegls_downscale_state(state, Q);
231 static inline int ls_decode_line(JLSState *state, MJpegDecodeContext *s,
254 if ((FFABS(D0) <= state->near) &&
255 (FFABS(D1) <= state->near) &&
256 (FFABS(D2) <= state->near)) {
263 r = 1 << ff_log2_run[state->run_index[comp]];
271 if (r != 1 << ff_log2_run[state->run_index[comp]])
273 if (state->run_index[comp] < 31)
274 state->run_index[comp]++;
279 r = ff_log2_run[state->run_index[comp]];
298 RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
299 err = ls_get_code_runterm(&s->gb, state, RItype,
300 ff_log2_run[state->run_index[comp]]);
301 if (state->run_index[comp])
302 state->run_index[comp]--;
304 if (state->near && RItype) {
315 context = ff_jpegls_quantize(state, D0) * 81 +
316 ff_jpegls_quantize(state, D1) * 9 +
317 ff_jpegls_quantize(state, D2);
328 pred = av_clip(pred - state->C[context], 0, state->maxval);
329 err = -ls_get_code_regular(&s->gb, state, context);
331 pred = av_clip(pred + state->C[context], 0, state->maxval);
332 err = ls_get_code_regular(&s->gb, state, context);
338 if (state->near) {
339 if (pred < -state->near)
340 pred += state->range * state->twonear;
341 else if (pred > state->maxval + state->near)
342 pred -= state->range * state->twonear;
343 pred = av_clip(pred, 0, state->maxval);
346 pred &= state->maxval;
359 JLSState *state = s->jls_state;
363 if (!state) {
364 state = av_malloc(sizeof(*state));
365 if (!state)
367 s->jls_state = state;
375 /* initialize JPEG-LS state from JPEG parameters */
376 memset(state, 0, sizeof(*state));
377 state->near = near;
378 state->bpp = (s->bits < 2) ? 2 : s->bits;
379 state->maxval = s->maxval;
380 state->T1 = s->t1;
381 state->T2 = s->t2;
382 state->T3 = s->t3;
383 state->reset = s->reset;
384 ff_jpegls_reset_coding_parameters(state, 0);
385 ff_jpegls_init_state(state);
401 s->width, s->height, state->near, state->maxval,
402 state->T1, state->T2, state->T3,
403 state->reset, state->limit, state->qbpp, state->range);
423 ret = ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
426 ret = ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
449 ret = ls_decode_line(state, s, last + j, cur + j,