77 #include "jasper/jas_types.h"
78 #include "jasper/jas_stream.h"
80 #include "jpc_mqcod.h"
102 const jpc_mqstate_t **curctx;
105 const jpc_mqstate_t **ctxs;
126 jpc_mqdec_t *jpc_mqdec_create(
int 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 #define jpc_mqdec_setcurctx(dec, ctxno) \
147 ((mqdec)->curctx = &(mqdec)->ctxs[ctxno]);
150 void jpc_mqdec_setctx(jpc_mqdec_t *dec,
int ctxno,
const jpc_mqctx_t *ctx);
153 void jpc_mqdec_setctxs(
const jpc_mqdec_t *dec,
int numctxs,
const jpc_mqctx_t *ctxs);
161 #define jpc_mqdec_getbit(dec) \
162 jpc_mqdec_getbit_macro(dec)
164 #define jpc_mqdec_getbit(dec) \
165 jpc_mqdec_getbit_func(dec)
170 #define jpc_mqdec_getbitnoskew(dec) \
171 jpc_mqdec_getbit_macro(dec)
173 #define jpc_mqdec_getbitnoskew(dec) \
174 jpc_mqdec_getbit_func(dec)
182 void jpc_mqdec_dump(
const jpc_mqdec_t *dec, FILE *out);
190 #define jpc_mqdec_getbit_macro(dec) \
191 ((((dec)->areg -= (*(dec)->curctx)->qeval), \
192 (dec)->creg >> 16 >= (*(dec)->curctx)->qeval) ? \
193 ((((dec)->creg -= (*(dec)->curctx)->qeval << 16), \
194 (dec)->areg & 0x8000) ? (*(dec)->curctx)->mps : \
195 jpc_mqdec_mpsexchrenormd(dec)) : \
196 jpc_mqdec_lpsexchrenormd(dec))
198 #define jpc_mqdec_mpsexchange(areg, delta, curctx, bit) \
200 if ((areg) < (delta)) { \
201 register const jpc_mqstate_t *state = *(curctx); \
203 (bit) = state->mps ^ 1; \
204 *(curctx) = state->nlps; \
206 register const jpc_mqstate_t *state = *(curctx); \
208 (bit) = state->mps; \
209 *(curctx) = state->nmps; \
213 #define jpc_mqdec_lpsexchange(areg, delta, curctx, bit) \
215 if ((areg) >= (delta)) { \
216 register const jpc_mqstate_t *state = *(curctx); \
218 (bit) = state->mps ^ 1; \
219 *(curctx) = state->nlps; \
221 register const jpc_mqstate_t *state = *(curctx); \
223 (bit) = state->mps; \
224 *(curctx) = state->nmps; \
228 #define jpc_mqdec_renormd(areg, creg, ctreg, in, eof, inbuf) \
232 jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf); \
237 } while (!((areg) & 0x8000)); \
240 #define jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf) \
243 unsigned char prevbuf; \
245 if ((c = jas_stream_getc(in)) == EOF) { \
251 if (prevbuf == 0xff) { \
269 int jpc_mqdec_getbit_func(jpc_mqdec_t *dec);
270 int jpc_mqdec_mpsexchrenormd(jpc_mqdec_t *dec);
271 int jpc_mqdec_lpsexchrenormd(jpc_mqdec_t *dec);