87 #define JP2_SPTOBPC(s, p) \
88 ((((p) - 1) & 0x7f) | (((s) & 1) << 7))
94 #define JP2_BOX_HDRLEN(ext) ((ext) ? 16 : 8)
97 #define JP2_BOX_JP 0x6a502020
98 #define JP2_BOX_FTYP 0x66747970
99 #define JP2_BOX_JP2H 0x6a703268
100 #define JP2_BOX_IHDR 0x69686472
101 #define JP2_BOX_BPCC 0x62706363
102 #define JP2_BOX_COLR 0x636f6c72
103 #define JP2_BOX_PCLR 0x70636c72
104 #define JP2_BOX_CMAP 0x636d6170
105 #define JP2_BOX_CDEF 0x63646566
106 #define JP2_BOX_RES 0x72657320
107 #define JP2_BOX_RESC 0x72657363
108 #define JP2_BOX_RESD 0x72657364
109 #define JP2_BOX_JP2C 0x6a703263
110 #define JP2_BOX_JP2I 0x6a703269
111 #define JP2_BOX_XML 0x786d6c20
112 #define JP2_BOX_UUID 0x75756964
113 #define JP2_BOX_UINF 0x75696e66
114 #define JP2_BOX_ULST 0x75637374
115 #define JP2_BOX_URL 0x75726c20
117 #define JP2_BOX_SUPER 0x01
118 #define JP2_BOX_NODATA 0x02
122 #define JP2_JP_MAGIC 0x0d0a870a
123 #define JP2_JP_LEN 12
131 #define JP2_FTYP_MAXCOMPATCODES 32
132 #define JP2_FTYP_MAJVER 0x6a703220
133 #define JP2_FTYP_MINVER 0
134 #define JP2_FTYP_COMPATCODE JP2_FTYP_MAJVER
137 uint_fast32_t majver;
138 uint_fast32_t minver;
139 uint_fast32_t numcompatcodes;
140 uint_fast32_t compatcodes[JP2_FTYP_MAXCOMPATCODES];
145 #define JP2_IHDR_COMPTYPE 7
146 #define JP2_IHDR_BPCNULL 255
150 uint_fast32_t height;
151 uint_fast16_t numcmpts;
153 uint_fast8_t comptype;
161 uint_fast16_t numcmpts;
167 #define JP2_COLR_ENUM 1
168 #define JP2_COLR_ICC 2
169 #define JP2_COLR_PRI 0
171 #define JP2_COLR_SRGB 16
172 #define JP2_COLR_SGRAY 17
173 #define JP2_COLR_SYCC 18
188 uint_fast16_t numlutents;
189 uint_fast8_t numchans;
190 int_fast32_t *lutdata;
196 #define JP2_CDEF_RGB_R 1
197 #define JP2_CDEF_RGB_G 2
198 #define JP2_CDEF_RGB_B 3
200 #define JP2_CDEF_YCBCR_Y 1
201 #define JP2_CDEF_YCBCR_CB 2
202 #define JP2_CDEF_YCBCR_CR 3
204 #define JP2_CDEF_GRAY_Y 1
206 #define JP2_CDEF_TYPE_COLOR 0
207 #define JP2_CDEF_TYPE_OPACITY 1
208 #define JP2_CDEF_TYPE_UNSPEC 65535
209 #define JP2_CDEF_ASOC_ALL 0
210 #define JP2_CDEF_ASOC_NONE 65535
213 uint_fast16_t channo;
221 uint_fast16_t numchans;
222 jp2_cdefchan_t *ents;
226 uint_fast16_t cmptno;
232 uint_fast16_t numchans;
236 #define JP2_CMAP_DIRECT 0
237 #define JP2_CMAP_PALETTE 1
244 const struct jp2_boxops_s *ops;
245 const struct jp2_boxinfo_s *info;
253 uint_fast32_t datalen;
268 typedef struct jp2_boxops_s {
269 void (*init)(jp2_box_t *box);
270 void (*destroy)(jp2_box_t *box);
271 int (*getdata)(jp2_box_t *box, jas_stream_t *in);
272 int (*putdata)(
const jp2_box_t *box, jas_stream_t *out);
273 void (*dumpdata)(
const jp2_box_t *box, FILE *out);
280 typedef struct jp2_boxinfo_s {
291 jp2_box_t *jp2_box_create(
int type);
292 void jp2_box_destroy(jp2_box_t *box);
293 jp2_box_t *jp2_box_get(jas_stream_t *in);
294 int jp2_box_put(jp2_box_t *box, jas_stream_t *out);
297 static inline uint_least8_t JP2_DTYPETOBPC(uint_least8_t dtype)
299 return (JAS_IMAGE_CDT_GETSGND(dtype) << 7) | (JAS_IMAGE_CDT_GETPREC(dtype) - 1);
303 static inline uint_least8_t JP2_BPCTODTYPE(uint_least8_t bpc)
305 return JAS_IMAGE_CDT_SETSGND(bpc >> 7) | JAS_IMAGE_CDT_SETPREC((bpc & 0x7f) + 1);
308 #define ICC_CS_RGB 0x52474220
309 #define ICC_CS_YCBCR 0x59436272
310 #define ICC_CS_GRAY 0x47524159
312 const jp2_cdefchan_t *jp2_cdef_lookup(jp2_cdef_t *cdef,
int channo);