• Home
  • Raw
  • Download

Lines Matching refs:mqenc

180 static void jpc_mqenc_setbits(jpc_mqenc_t *mqenc);
190 jpc_mqenc_t *mqenc; in jpc_mqenc_create() local
193 if (!(mqenc = jas_malloc(sizeof(jpc_mqenc_t)))) { in jpc_mqenc_create()
196 mqenc->out = out; in jpc_mqenc_create()
197 mqenc->maxctxs = maxctxs; in jpc_mqenc_create()
200 if (!(mqenc->ctxs = jas_alloc2(mqenc->maxctxs, sizeof(jpc_mqstate_t *)))) { in jpc_mqenc_create()
205 mqenc->curctx = mqenc->ctxs; in jpc_mqenc_create()
207 jpc_mqenc_init(mqenc); in jpc_mqenc_create()
210 jpc_mqenc_setctxs(mqenc, 0, 0); in jpc_mqenc_create()
212 return mqenc; in jpc_mqenc_create()
215 if (mqenc) { in jpc_mqenc_create()
216 jpc_mqenc_destroy(mqenc); in jpc_mqenc_create()
223 void jpc_mqenc_destroy(jpc_mqenc_t *mqenc) in jpc_mqenc_destroy() argument
225 if (mqenc->ctxs) { in jpc_mqenc_destroy()
226 jas_free(mqenc->ctxs); in jpc_mqenc_destroy()
228 jas_free(mqenc); in jpc_mqenc_destroy()
237 void jpc_mqenc_init(jpc_mqenc_t *mqenc) in jpc_mqenc_init() argument
239 mqenc->areg = 0x8000; in jpc_mqenc_init()
240 mqenc->outbuf = -1; in jpc_mqenc_init()
241 mqenc->creg = 0; in jpc_mqenc_init()
242 mqenc->ctreg = 12; in jpc_mqenc_init()
243 mqenc->lastbyte = -1; in jpc_mqenc_init()
244 mqenc->err = 0; in jpc_mqenc_init()
249 void jpc_mqenc_setctxs(jpc_mqenc_t *mqenc, int numctxs, jpc_mqctx_t *ctxs) in jpc_mqenc_setctxs() argument
254 ctx = mqenc->ctxs; in jpc_mqenc_setctxs()
255 n = JAS_MIN(mqenc->maxctxs, numctxs); in jpc_mqenc_setctxs()
261 n = mqenc->maxctxs - numctxs; in jpc_mqenc_setctxs()
271 void jpc_mqenc_getstate(jpc_mqenc_t *mqenc, jpc_mqencstate_t *state) in jpc_mqenc_getstate() argument
273 state->areg = mqenc->areg; in jpc_mqenc_getstate()
274 state->creg = mqenc->creg; in jpc_mqenc_getstate()
275 state->ctreg = mqenc->ctreg; in jpc_mqenc_getstate()
276 state->lastbyte = mqenc->lastbyte; in jpc_mqenc_getstate()
285 int jpc_mqenc_putbit_func(jpc_mqenc_t *mqenc, int bit) in jpc_mqenc_putbit_func() argument
288 JAS_DBGLOG(100, ("jpc_mqenc_putbit(%p, %d)\n", mqenc, bit)); in jpc_mqenc_putbit_func()
289 JPC_MQENC_CALL(100, jpc_mqenc_dump(mqenc, stderr)); in jpc_mqenc_putbit_func()
291 state = *(mqenc->curctx); in jpc_mqenc_putbit_func()
295 mqenc->areg -= state->qeval; in jpc_mqenc_putbit_func()
296 if (!(mqenc->areg & 0x8000)) { in jpc_mqenc_putbit_func()
297 jpc_mqenc_codemps2(mqenc); in jpc_mqenc_putbit_func()
299 mqenc->creg += state->qeval; in jpc_mqenc_putbit_func()
303 jpc_mqenc_codelps2(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc->curctx, mqenc); in jpc_mqenc_putbit_func()
306 return jpc_mqenc_error(mqenc) ? (-1) : 0; in jpc_mqenc_putbit_func()
309 int jpc_mqenc_codemps2(jpc_mqenc_t *mqenc) in jpc_mqenc_codemps2() argument
315 jpc_mqstate_t *state = *(mqenc->curctx); in jpc_mqenc_codemps2()
316 if (mqenc->areg < state->qeval) { in jpc_mqenc_codemps2()
317 mqenc->areg = state->qeval; in jpc_mqenc_codemps2()
319 mqenc->creg += state->qeval; in jpc_mqenc_codemps2()
321 *mqenc->curctx = state->nmps; in jpc_mqenc_codemps2()
322 jpc_mqenc_renorme(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc); in jpc_mqenc_codemps2()
323 return jpc_mqenc_error(mqenc) ? (-1) : 0; in jpc_mqenc_codemps2()
326 int jpc_mqenc_codelps(jpc_mqenc_t *mqenc) in jpc_mqenc_codelps() argument
328 jpc_mqenc_codelps2(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc->curctx, mqenc); in jpc_mqenc_codelps()
329 return jpc_mqenc_error(mqenc) ? (-1) : 0; in jpc_mqenc_codelps()
338 int jpc_mqenc_flush(jpc_mqenc_t *mqenc, int termmode) in jpc_mqenc_flush() argument
344 k = 11 - mqenc->ctreg + 1; in jpc_mqenc_flush()
346 mqenc->creg <<= mqenc->ctreg; in jpc_mqenc_flush()
347 mqenc->ctreg = 0; in jpc_mqenc_flush()
348 jpc_mqenc_byteout(mqenc->areg, mqenc->creg, mqenc->ctreg, in jpc_mqenc_flush()
349 mqenc); in jpc_mqenc_flush()
350 k -= mqenc->ctreg; in jpc_mqenc_flush()
352 if (mqenc->outbuf != 0xff) { in jpc_mqenc_flush()
353 jpc_mqenc_byteout(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc); in jpc_mqenc_flush()
357 jpc_mqenc_setbits(mqenc); in jpc_mqenc_flush()
358 mqenc->creg <<= mqenc->ctreg; in jpc_mqenc_flush()
359 jpc_mqenc_byteout(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc); in jpc_mqenc_flush()
360 mqenc->creg <<= mqenc->ctreg; in jpc_mqenc_flush()
361 jpc_mqenc_byteout(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc); in jpc_mqenc_flush()
362 if (mqenc->outbuf != 0xff) { in jpc_mqenc_flush()
363 jpc_mqenc_byteout(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc); in jpc_mqenc_flush()
373 static void jpc_mqenc_setbits(jpc_mqenc_t *mqenc) in jpc_mqenc_setbits() argument
375 uint_fast32_t tmp = mqenc->creg + mqenc->areg; in jpc_mqenc_setbits()
376 mqenc->creg |= 0xffff; in jpc_mqenc_setbits()
377 if (mqenc->creg >= tmp) { in jpc_mqenc_setbits()
378 mqenc->creg -= 0x8000; in jpc_mqenc_setbits()
384 int jpc_mqenc_dump(jpc_mqenc_t *mqenc, FILE *out) in jpc_mqenc_dump() argument
387 (unsigned)mqenc->areg, (unsigned)mqenc->creg, (int)mqenc->ctreg); in jpc_mqenc_dump()
389 (int)(*mqenc->curctx - jpc_mqstates), (int)(*mqenc->curctx)->mps, in jpc_mqenc_dump()
390 (int)(*mqenc->curctx)->qeval); in jpc_mqenc_dump()