2 * Copyright (c) 1999-2000 Image Power, Inc. and the University of
4 * Copyright (c) 2001-2002 Michael David Adams.
8 /* __START_OF_JASPER_LICENSE__
10 * JasPer License Version 2.0
12 * Copyright (c) 1999-2000 Image Power, Inc.
13 * Copyright (c) 1999-2000 The University of British Columbia
14 * Copyright (c) 2001-2003 Michael David Adams
16 * All rights reserved.
18 * Permission is hereby granted, free of charge, to any person (the
19 * "User") obtaining a copy of this software and associated documentation
20 * files (the "Software"), to deal in the Software without restriction,
21 * including without limitation the rights to use, copy, modify, merge,
22 * publish, distribute, and/or sell copies of the Software, and to permit
23 * persons to whom the Software is furnished to do so, subject to the
24 * following conditions:
26 * 1. The above copyright notices and this permission notice (which
27 * includes the disclaimer below) shall be included in all copies or
28 * substantial portions of the Software.
30 * 2. The name of a copyright holder shall not be used to endorse or
31 * promote products derived from the Software without specific prior
34 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
35 * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
36 * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
37 * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39 * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
40 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
41 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
42 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
43 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
44 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
45 * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
46 * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
47 * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
48 * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
49 * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
50 * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
51 * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
52 * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
53 * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
54 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
55 * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
56 * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
57 * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
58 * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
59 * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
61 * __END_OF_JASPER_LICENSE__
67 * $Id: jp2_cod.h,v 1.1 2005/05/22 18:33:03 malaterre Exp $
73 /******************************************************************************\
75 \******************************************************************************/
77 #include "jasper/jas_types.h"
79 /******************************************************************************\
81 \******************************************************************************/
83 #define JP2_SPTOBPC(s, p) \
84 ((((p) - 1) & 0x7f) | (((s) & 1) << 7))
86 /******************************************************************************\
88 \******************************************************************************/
90 #define JP2_BOX_HDRLEN 8
93 #define JP2_BOX_JP 0x6a502020 /* Signature */
94 #define JP2_BOX_FTYP 0x66747970 /* File Type */
95 #define JP2_BOX_JP2H 0x6a703268 /* JP2 Header */
96 #define JP2_BOX_IHDR 0x69686472 /* Image Header */
97 #define JP2_BOX_BPCC 0x62706363 /* Bits Per Component */
98 #define JP2_BOX_COLR 0x636f6c72 /* Color Specification */
99 #define JP2_BOX_PCLR 0x70636c72 /* Palette */
100 #define JP2_BOX_CMAP 0x636d6170 /* Component Mapping */
101 #define JP2_BOX_CDEF 0x63646566 /* Channel Definition */
102 #define JP2_BOX_RES 0x72657320 /* Resolution */
103 #define JP2_BOX_RESC 0x72657363 /* Capture Resolution */
104 #define JP2_BOX_RESD 0x72657364 /* Default Display Resolution */
105 #define JP2_BOX_JP2C 0x6a703263 /* Contiguous Code Stream */
106 #define JP2_BOX_JP2I 0x6a703269 /* Intellectual Property */
107 #define JP2_BOX_XML 0x786d6c20 /* XML */
108 #define JP2_BOX_UUID 0x75756964 /* UUID */
109 #define JP2_BOX_UINF 0x75696e66 /* UUID Info */
110 #define JP2_BOX_ULST 0x75637374 /* UUID List */
111 #define JP2_BOX_URL 0x75726c20 /* URL */
113 #define JP2_BOX_SUPER 0x01
114 #define JP2_BOX_NODATA 0x02
118 #define JP2_JP_MAGIC 0x0d0a870a
119 #define JP2_JP_LEN 12
127 #define JP2_FTYP_MAXCOMPATCODES 32
128 #define JP2_FTYP_MAJVER 0x6a703220
129 #define JP2_FTYP_MINVER 0
130 #define JP2_FTYP_COMPATCODE JP2_FTYP_MAJVER
133 uint_fast32_t majver;
134 uint_fast32_t minver;
135 uint_fast32_t numcompatcodes;
136 uint_fast32_t compatcodes[JP2_FTYP_MAXCOMPATCODES];
141 #define JP2_IHDR_COMPTYPE 7
142 #define JP2_IHDR_BPCNULL 255
146 uint_fast32_t height;
147 uint_fast16_t numcmpts;
149 uint_fast8_t comptype;
157 uint_fast16_t numcmpts;
163 #define JP2_COLR_ENUM 1
164 #define JP2_COLR_ICC 2
165 #define JP2_COLR_PRI 0
167 #define JP2_COLR_SRGB 16
168 #define JP2_COLR_SGRAY 17
169 #define JP2_COLR_SYCC 18
178 /* XXX - Someday we ought to add ICC profile data here. */
184 uint_fast16_t numlutents;
185 uint_fast8_t numchans;
186 int_fast32_t *lutdata;
190 /* CDEF box per-channel data. */
192 #define JP2_CDEF_RGB_R 1
193 #define JP2_CDEF_RGB_G 2
194 #define JP2_CDEF_RGB_B 3
196 #define JP2_CDEF_YCBCR_Y 1
197 #define JP2_CDEF_YCBCR_CB 2
198 #define JP2_CDEF_YCBCR_CR 3
200 #define JP2_CDEF_GRAY_Y 1
202 #define JP2_CDEF_TYPE_COLOR 0
203 #define JP2_CDEF_TYPE_OPACITY 1
204 #define JP2_CDEF_TYPE_UNSPEC 65535
205 #define JP2_CDEF_ASOC_ALL 0
206 #define JP2_CDEF_ASOC_NONE 65535
209 uint_fast16_t channo;
217 uint_fast16_t numchans;
218 jp2_cdefchan_t *ents;
222 uint_fast16_t cmptno;
228 uint_fast16_t numchans;
232 #define JP2_CMAP_DIRECT 0
233 #define JP2_CMAP_PALETTE 1
240 struct jp2_boxops_s *ops;
241 struct jp2_boxinfo_s *info;
259 typedef struct jp2_boxops_s {
260 void (*init)(jp2_box_t *box);
261 void (*destroy)(jp2_box_t *box);
262 int (*getdata)(jp2_box_t *box, jas_stream_t *in);
263 int (*putdata)(jp2_box_t *box, jas_stream_t *out);
264 void (*dumpdata)(jp2_box_t *box, FILE *out);
267 /******************************************************************************\
269 \******************************************************************************/
271 typedef struct jp2_boxinfo_s {
278 /******************************************************************************\
280 \******************************************************************************/
282 jp2_box_t *jp2_box_create(int type);
283 void jp2_box_destroy(jp2_box_t *box);
284 jp2_box_t *jp2_box_get(jas_stream_t *in);
285 int jp2_box_put(jp2_box_t *box, jas_stream_t *out);
287 #define JP2_DTYPETOBPC(dtype) \
288 ((JAS_IMAGE_CDT_GETSGND(dtype) << 7) | (JAS_IMAGE_CDT_GETPREC(dtype) - 1))
289 #define JP2_BPCTODTYPE(bpc) \
290 (JAS_IMAGE_CDT_SETSGND(bpc >> 7) | JAS_IMAGE_CDT_SETPREC((bpc & 0x7f) + 1))
292 #define ICC_CS_RGB 0x52474220
293 #define ICC_CS_YCBCR 0x59436272
294 #define ICC_CS_GRAY 0x47524159
296 jp2_cdefchan_t *jp2_cdef_lookup(jp2_cdef_t *cdef, int channo);