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 JAS_DLLEXPORT jp2_box_t *jp2_box_create(
int type);
292 JAS_DLLEXPORT
void jp2_box_destroy(jp2_box_t *box);
293 JAS_DLLEXPORT jp2_box_t *jp2_box_get(jas_stream_t *in);
294 JAS_DLLEXPORT
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 JAS_DLLEXPORT
const jp2_cdefchan_t *jp2_cdef_lookup(jp2_cdef_t *cdef,
int channo);
void jas_image_destroy(jas_image_t *image)
Deallocate any resources associated with an image.
Definition: jas_image.c:303
jas_image_t * jas_image_chclrspc(jas_image_t *image, const jas_cmprof_t *outprof, jas_cmxform_intent_t intent)
Change the color space for an image.
Definition: jas_image.c:1458
#define jas_stream_putc(stream, c)
jas_stream_putc Write a character to a stream.
Definition: jas_stream.h:558
#define jas_image_cmptprec(image, cmptno)
Get the precision of the sample data for a component.
Definition: jas_image.h:427
#define jas_image_brx(image)
Get the x-coordinate of the bottom-right corner of the image bounding box on the reference grid (plus...
Definition: jas_image.h:373
jas_stream_t * jas_stream_fopen(const char *filename, const char *mode)
Open a file as a stream.
Definition: jas_stream.c:301
unsigned jas_stream_read(jas_stream_t *stream, void *buf, unsigned cnt)
Read characters from a stream into a buffer.
Definition: jas_stream.c:670
#define jas_image_numcmpts(image)
Get the number of image components.
Definition: jas_image.h:386
int jas_stream_close(jas_stream_t *stream)
Close a stream.
Definition: jas_stream.c:610
#define jas_image_cmptvstep(image, cmptno)
Get the vertical subsampling factor for a component.
Definition: jas_image.h:439
long jas_stream_tell(jas_stream_t *stream)
Get the current position within the stream.
Definition: jas_stream.c:926
jas_stream_t * jas_stream_fdopen(int fd, const char *mode)
Open a file descriptor as a stream.
Definition: jas_stream.c:540
#define jas_image_cmpttly(image, cmptno)
Get the y-coordinate of the top-left corner of a component.
Definition: jas_image.h:451
#define jas_image_cmpthstep(image, cmptno)
Get the horizontal subsampling factor for a component.
Definition: jas_image.h:433
#define jas_image_cmptheight(image, cmptno)
Get the height of a component.
Definition: jas_image.h:415
#define jas_image_width(image)
Get the width of the image in units of the image reference grid.
Definition: jas_image.h:346
#define jas_image_bry(image)
Get the y-coordinate of the bottom-right corner of the image bounding box on the reference grid (plus...
Definition: jas_image.h:380
int jas_image_readcmptsample(jas_image_t *image, unsigned cmptno, unsigned x, unsigned y)
Read a component sample for an image.
Definition: jas_image.c:1067
int jas_stream_rewind(jas_stream_t *stream)
Seek to the beginning of a stream.
Definition: jas_stream.c:885
JAS_DLLEXPORT int jas_init()
Initialize the JasPer library.
Definition: jas_init.c:77
jas_stream_t * jas_stream_memopen(char *buf, int bufsize)
Open a memory buffer as a stream.
Definition: jas_stream.c:276
#define jas_stream_getc(stream)
jas_stream_getc Read a character from a stream.
Definition: jas_stream.h:547
JasPer Debugging-Related Functionality.
#define jas_image_cmptwidth(image, cmptno)
Get the width of a component.
Definition: jas_image.h:409
#define jas_image_tlx(image)
Get the x-coordinate of the top-left corner of the image bounding box on the reference grid.
Definition: jas_image.h:359
unsigned jas_stream_write(jas_stream_t *stream, const void *buf, unsigned cnt)
Write characters from a buffer to a stream.
Definition: jas_stream.c:735
jas_image_t * jas_image_decode(jas_stream_t *in, int fmt, const char *optstr)
Create an image from a stream in some specified format.
Definition: jas_image.c:416
int jas_stream_copy(jas_stream_t *out, jas_stream_t *in, int n)
Copy data from one stream to another.
Definition: jas_stream.c:1129
#define jas_image_cmpttlx(image, cmptno)
Get the x-coordinate of the top-left corner of a component.
Definition: jas_image.h:445
Image class.
Definition: jas_image.h:202
#define jas_image_height(image)
Get the height of the image in units of the image reference grid.
Definition: jas_image.h:352
int jas_image_getcmptbytype(const jas_image_t *image, jas_image_cmpttype_t ctype)
Get an image component by its type.
Definition: jas_image.c:1112
#define jas_image_tly(image)
Get the y-coordinate of the top-left corner of the image bounding box on the reference grid.
Definition: jas_image.h:366