87 #define JPC_MAXRLVLS 33
90 #define JPC_MAXBANDS (3 * JPC_MAXRLVLS + 1)
93 #define JPC_MAXLYRS 16384
104 #define JPC_CS_INIT 0
106 #define JPC_CS_MHDR 1
108 #define JPC_CS_THDR 2
110 #define JPC_CS_MTLR 3
112 #define JPC_CS_TDATA 4
129 uint_fast16_t numcomps;
140 uint_fast16_t tileno;
150 uint_fast8_t numparts;
189 uint_fast32_t height;
200 uint_fast32_t tilewidth;
203 uint_fast32_t tileheight;
207 uint_fast32_t tilexoff;
211 uint_fast32_t tileyoff;
214 uint_fast16_t numcomps;
217 jpc_sizcomp_t *comps;
230 #define JPC_COX_PRT 0x01
232 #define JPC_COD_SOP 0x02
234 #define JPC_COD_EPH 0x04
242 #define JPC_COD_LRCPPRG 0
245 #define JPC_COD_RLCPPRG 1
247 #define JPC_COD_RPCLPRG 2
249 #define JPC_COD_PCRLPRG 3
251 #define JPC_COD_CPRLPRG 4
257 #define JPC_COX_LAZY 0x01
258 #define JPC_COX_RESET 0x02
259 #define JPC_COX_TERMALL 0x04
260 #define JPC_COX_VSC 0x08
261 #define JPC_COX_PTERM 0x10
262 #define JPC_COX_SEGSYM 0x20
265 #define JPC_COX_INS 0x00
266 #define JPC_COX_RFT 0x01
269 #define JPC_COD_NOMCT 0x00
270 #define JPC_COD_MCT 0x01
274 static inline unsigned JPC_COX_CBLKSIZEEXPN(
unsigned x)
281 static inline unsigned JPC_COX_GETCBLKSIZEEXPN(
unsigned x)
291 uint_fast8_t parwidthval;
294 uint_fast8_t parheightval;
306 uint_fast8_t numdlvls;
309 uint_fast8_t cblkwidthval;
312 uint_fast8_t cblkheightval;
315 uint_fast8_t cblksty;
324 jpc_coxrlvl_t rlvls[JPC_MAXRLVLS];
339 uint_fast16_t numlyrs;
342 uint_fast8_t mctrans;
345 jpc_coxcp_t compparms;
354 uint_fast16_t compno;
357 jpc_coxcp_t compparms;
366 #define JPC_RGN_MAXSHIFT 0x00
371 uint_fast16_t compno;
377 uint_fast8_t roishift;
389 #define JPC_QCX_NOQNT 0
390 #define JPC_QCX_SIQNT 1
391 #define JPC_QCX_SEQNT 2
398 static inline unsigned JPC_QCX_GETEXPN(
unsigned x)
404 static inline unsigned JPC_QCX_GETMANT(
unsigned x)
410 static inline uint_fast16_t JPC_QCX_EXPN(
unsigned x)
412 assert(!(x & (~0x1f)));
414 return (x & 0x1f) << 11;
418 static inline uint_fast16_t JPC_QCX_MANT(
unsigned x)
420 assert(!(x & (~0x7ff)));
436 uint_fast16_t *stepsizes;
439 uint_fast8_t numguard;
448 uint_fast16_t compno;
451 jpc_qcxcp_t compparms;
460 jpc_qcxcp_t compparms;
475 uint_fast8_t rlvlnostart;
479 uint_fast8_t rlvlnoend;
483 uint_fast16_t compnostart;
487 uint_fast16_t compnoend;
491 uint_fast16_t lyrnoend;
496 typedef jpc_pocpchg_t jpc_pchg_t;
506 jpc_pocpchg_t *pchgs;
552 #define JPC_COM_BIN 0x00
553 #define JPC_COM_LATIN 0x01
601 jpc_crgcomp_t *comps;
653 #define JPC_MS_MIN 0xff00
656 #define JPC_MS_MAX 0xffff
659 #define JPC_MS_INMIN 0xff80
661 #define JPC_MS_INMAX 0xffff
664 #define JPC_MS_SOC 0xff4f
665 #define JPC_MS_SOT 0xff90
666 #define JPC_MS_SOD 0xff93
667 #define JPC_MS_EOC 0xffd9
670 #define JPC_MS_SIZ 0xff51
673 #define JPC_MS_COD 0xff52
674 #define JPC_MS_COC 0xff53
675 #define JPC_MS_RGN 0xff5e
676 #define JPC_MS_QCD 0xff5c
677 #define JPC_MS_QCC 0xff5d
678 #define JPC_MS_POC 0xff5f
681 #define JPC_MS_TLM 0xff55
682 #define JPC_MS_PLM 0xff57
683 #define JPC_MS_PLT 0xff58
684 #define JPC_MS_PPM 0xff60
685 #define JPC_MS_PPT 0xff61
688 #define JPC_MS_SOP 0xff91
689 #define JPC_MS_EPH 0xff92
692 #define JPC_MS_CRG 0xff63
693 #define JPC_MS_COM 0xff64
715 const struct jpc_msops_s *ops;
721 typedef struct jpc_msops_s {
724 void (*destroyparms)(jpc_ms_t *ms);
727 int (*getparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in);
730 int (*putparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);
733 int (*dumpparms)(jpc_ms_t *ms, FILE *out);
742 jpc_cstate_t *jpc_cstate_create(
void);
745 void jpc_cstate_destroy(jpc_cstate_t *cstate);
748 jpc_ms_t *jpc_ms_create(
int type);
751 void jpc_ms_destroy(jpc_ms_t *ms);
755 static inline bool JPC_MS_HASPARMS(
unsigned x)
757 return !(x == JPC_MS_SOC || x == JPC_MS_SOD || x == JPC_MS_EOC ||
758 x == JPC_MS_EPH || (x >= 0xff30 && x <= 0xff3f));
763 static inline unsigned jpc_ms_gettype(
const jpc_ms_t *ms)
769 jpc_ms_t *jpc_getms(jas_stream_t *in, jpc_cstate_t *cstate);
772 int jpc_putms(jas_stream_t *out, jpc_cstate_t *cstate, jpc_ms_t *ms);
775 int jpc_getdata(jas_stream_t *in, jas_stream_t *out,
long n);
778 int jpc_putdata(jas_stream_t *out, jas_stream_t *in,
long n);
781 void jpc_ms_dump(jpc_ms_t *ms, FILE *out);
784 int jpc_getuint8(jas_stream_t *in, uint_fast8_t *val);
787 int jpc_getuint16(jas_stream_t *in, uint_fast16_t *val);
790 int jpc_getuint32(jas_stream_t *in, uint_fast32_t *val);
793 int jpc_putuint8(jas_stream_t *out, uint_fast8_t val);
796 int jpc_putuint16(jas_stream_t *out, uint_fast16_t val);
799 int jpc_putuint32(jas_stream_t *out, uint_fast32_t val);