80 #include "jpc_mqcod.h" 102 const jpc_mqstate_t **curctx;
105 const jpc_mqstate_t **ctxs;
126 jpc_mqdec_t *jpc_mqdec_create(
unsigned maxctxs, jas_stream_t *in);
129 void jpc_mqdec_destroy(jpc_mqdec_t *dec);
136 void jpc_mqdec_setinput(jpc_mqdec_t *dec, jas_stream_t *in);
139 void jpc_mqdec_init(jpc_mqdec_t *dec);
146 static inline void jpc_mqdec_setcurctx(jpc_mqdec_t *dec,
unsigned ctxno)
148 dec->curctx = &dec->ctxs[ctxno];
152 void jpc_mqdec_setctxs(
const jpc_mqdec_t *dec,
unsigned numctxs,
const jpc_mqctx_t *ctxs);
160 #define jpc_mqdec_getbit(dec) \ 161 jpc_mqdec_getbit_macro(dec) 163 #define jpc_mqdec_getbit(dec) \ 164 jpc_mqdec_getbit_func(dec) 169 #define jpc_mqdec_getbitnoskew(dec) \ 170 jpc_mqdec_getbit_macro(dec) 172 #define jpc_mqdec_getbitnoskew(dec) \ 173 jpc_mqdec_getbit_func(dec) 181 void jpc_mqdec_dump(
const jpc_mqdec_t *dec, FILE *out);
189 bool jpc_mqdec_mpsexchrenormd(jpc_mqdec_t *dec);
190 bool jpc_mqdec_lpsexchrenormd(jpc_mqdec_t *dec);
193 static bool jpc_mqdec_getbit_macro(jpc_mqdec_t *dec)
195 const jpc_mqstate_t *
const state = *dec->curctx;
197 dec->areg -= state->qeval;
199 if (dec->creg >= (uint_least32_t)state->qeval << 16) {
200 dec->creg -= (uint_least32_t)state->qeval << 16;
201 return dec->areg & 0x8000
203 : jpc_mqdec_mpsexchrenormd(dec);
205 return jpc_mqdec_lpsexchrenormd(dec);
210 static bool jpc_mqdec_mpsexchange(uint_least32_t areg, uint_least32_t delta,
const jpc_mqstate_t **curctx)
213 const jpc_mqstate_t *state = *curctx;
215 *curctx = state->nlps;
218 const jpc_mqstate_t *state = *curctx;
220 *curctx = state->nmps;
226 static bool jpc_mqdec_lpsexchange(uint_least32_t *areg_p, uint_least32_t delta,
const jpc_mqstate_t **curctx)
228 if (*areg_p >= delta) {
229 const jpc_mqstate_t *state = *curctx;
231 *curctx = state->nlps;
234 const jpc_mqstate_t *state = *curctx;
236 *curctx = state->nmps;
241 bool jpc_mqdec_getbit_func(jpc_mqdec_t *dec);