2 * Copyright (c) 2002-2003 Michael David Adams.
6 /* __START_OF_JASPER_LICENSE__
8 * JasPer License Version 2.0
10 * Copyright (c) 1999-2000 Image Power, Inc.
11 * Copyright (c) 1999-2000 The University of British Columbia
12 * Copyright (c) 2001-2003 Michael David Adams
14 * All rights reserved.
16 * Permission is hereby granted, free of charge, to any person (the
17 * "User") obtaining a copy of this software and associated documentation
18 * files (the "Software"), to deal in the Software without restriction,
19 * including without limitation the rights to use, copy, modify, merge,
20 * publish, distribute, and/or sell copies of the Software, and to permit
21 * persons to whom the Software is furnished to do so, subject to the
22 * following conditions:
24 * 1. The above copyright notices and this permission notice (which
25 * includes the disclaimer below) shall be included in all copies or
26 * substantial portions of the Software.
28 * 2. The name of a copyright holder shall not be used to endorse or
29 * promote products derived from the Software without specific prior
32 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
33 * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
34 * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
35 * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
37 * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
38 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
39 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
40 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
41 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
42 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
43 * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
44 * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
45 * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
46 * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
47 * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
48 * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
49 * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
50 * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
51 * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
52 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
53 * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
54 * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
55 * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
56 * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
57 * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
59 * __END_OF_JASPER_LICENSE__
65 * $Id: jas_cm.h,v 1.1 2005/05/22 18:33:01 malaterre Exp $
71 #include <jasper/jas_config.h>
72 #include <jasper/jas_icc.h>
78 typedef int jas_clrspc_t;
80 /* transform operations */
81 #define JAS_CMXFORM_OP_FWD 0
82 #define JAS_CMXFORM_OP_REV 1
83 #define JAS_CMXFORM_OP_PROOF 2
84 #define JAS_CMXFORM_OP_GAMUT 3
86 /* rendering intents */
87 #define JAS_CMXFORM_INTENT_PER 0
88 #define JAS_CMXFORM_INTENT_RELCLR 1
89 #define JAS_CMXFORM_INTENT_ABSCLR 2
90 #define JAS_CMXFORM_INTENT_SAT 3
91 #define JAS_CMXFORM_NUMINTENTS 4
93 #define JAS_CMXFORM_OPTM_SPEED 0
94 #define JAS_CMXFORM_OPTM_SIZE 1
95 #define JAS_CMXFORM_OPTM_ACC 2
98 #define jas_clrspc_create(fam, mbr) (((fam) << 8) | (mbr))
99 #define jas_clrspc_fam(clrspc) ((clrspc) >> 8)
100 #define jas_clrspc_mbr(clrspc) ((clrspc) & 0xff)
101 #define jas_clrspc_isgeneric(clrspc) (!jas_clrspc_mbr(clrspc))
102 #define jas_clrspc_isunknown(clrspc) ((clrspc) & JAS_CLRSPC_UNKNOWNMASK)
104 #define JAS_CLRSPC_UNKNOWNMASK 0x4000
106 /* color space families */
107 #define JAS_CLRSPC_FAM_UNKNOWN 0
108 #define JAS_CLRSPC_FAM_XYZ 1
109 #define JAS_CLRSPC_FAM_LAB 2
110 #define JAS_CLRSPC_FAM_GRAY 3
111 #define JAS_CLRSPC_FAM_RGB 4
112 #define JAS_CLRSPC_FAM_YCBCR 5
114 /* specific color spaces */
115 #define JAS_CLRSPC_UNKNOWN JAS_CLRSPC_UNKNOWNMASK
116 #define JAS_CLRSPC_CIEXYZ jas_clrspc_create(JAS_CLRSPC_FAM_XYZ, 1)
117 #define JAS_CLRSPC_CIELAB jas_clrspc_create(JAS_CLRSPC_FAM_LAB, 1)
118 #define JAS_CLRSPC_SGRAY jas_clrspc_create(JAS_CLRSPC_FAM_GRAY, 1)
119 #define JAS_CLRSPC_SRGB jas_clrspc_create(JAS_CLRSPC_FAM_RGB, 1)
120 #define JAS_CLRSPC_SYCBCR jas_clrspc_create(JAS_CLRSPC_FAM_YCBCR, 1)
122 /* generic color spaces */
123 #define JAS_CLRSPC_GENRGB jas_clrspc_create(JAS_CLRSPC_FAM_RGB, 0)
124 #define JAS_CLRSPC_GENGRAY jas_clrspc_create(JAS_CLRSPC_FAM_GRAY, 0)
125 #define JAS_CLRSPC_GENYCBCR jas_clrspc_create(JAS_CLRSPC_FAM_YCBCR, 0)
127 #define JAS_CLRSPC_CHANIND_YCBCR_Y 0
128 #define JAS_CLRSPC_CHANIND_YCBCR_CB 1
129 #define JAS_CLRSPC_CHANIND_YCBCR_CR 2
131 #define JAS_CLRSPC_CHANIND_RGB_R 0
132 #define JAS_CLRSPC_CHANIND_RGB_G 1
133 #define JAS_CLRSPC_CHANIND_RGB_B 2
135 #define JAS_CLRSPC_CHANIND_GRAY_Y 0
137 typedef double jas_cmreal_t;
139 struct jas_cmpxform_s;
151 jas_cmcmptfmt_t *cmptfmts;
155 void (*destroy)(struct jas_cmpxform_s *pxform);
156 int (*apply)(struct jas_cmpxform_s *pxform, jas_cmreal_t *in, jas_cmreal_t *out, int cnt);
157 void (*dump)(struct jas_cmpxform_s *pxform);
163 } jas_cmshapmatlut_t;
170 jas_cmshapmatlut_t luts[3];
171 jas_cmreal_t mat[3][4];
181 } jas_cmclrspcconv_t;
183 #define jas_align_t double
185 typedef struct jas_cmpxform_s {
187 jas_cmpxformops_t *ops;
192 jas_cmshapmat_t shapmat;
193 jas_cmshaplut_t shaplut;
194 jas_cmclrspcconv_t clrspcconv;
201 jas_cmpxform_t **pxforms;
207 jas_cmpxformseq_t *pxformseq;
210 #define JAS_CMPROF_TYPE_DEV 1
211 #define JAS_CMPROF_TYPE_CLRSPC 2
213 #define JAS_CMPROF_NUMPXFORMSEQS 13
220 jas_iccprof_t *iccprof;
221 jas_cmpxformseq_t *pxformseqs[JAS_CMPROF_NUMPXFORMSEQS];
224 /* Create a profile. */
226 /* Destroy a profile. */
227 void jas_cmprof_destroy(jas_cmprof_t *prof);
230 typedef int_fast32_t jas_cmattrname_t;
231 typedef int_fast32_t jas_cmattrval_t;
232 typedef int_fast32_t jas_cmattrtype_t;
233 /* Load a profile. */
234 int jas_cmprof_load(jas_cmprof_t *prof, jas_stream_t *in, int fmt);
235 /* Save a profile. */
236 int jas_cmprof_save(jas_cmprof_t *prof, jas_stream_t *out, int fmt);
237 /* Set an attribute of a profile. */
238 int jas_cm_prof_setattr(jas_cm_prof_t *prof, jas_cm_attrname_t name, void *val);
239 /* Get an attribute of a profile. */
240 void *jas_cm_prof_getattr(jas_cm_prof_t *prof, jas_cm_attrname_t name);
243 jas_cmxform_t *jas_cmxform_create(jas_cmprof_t *inprof, jas_cmprof_t *outprof,
244 jas_cmprof_t *proofprof, int op, int intent, int optimize);
246 void jas_cmxform_destroy(jas_cmxform_t *xform);
248 /* Apply a transform to data. */
249 int jas_cmxform_apply(jas_cmxform_t *xform, jas_cmpixmap_t *in,
250 jas_cmpixmap_t *out);
252 int jas_cxform_optimize(jas_cmxform_t *xform, int optimize);
254 int jas_clrspc_numchans(int clrspc);
255 jas_cmprof_t *jas_cmprof_createfromiccprof(jas_iccprof_t *iccprof);
256 jas_cmprof_t *jas_cmprof_createfromclrspc(int clrspc);
257 jas_iccprof_t *jas_iccprof_createfromcmprof(jas_cmprof_t *prof);
259 #define jas_cmprof_clrspc(prof) ((prof)->clrspc)
260 jas_cmprof_t *jas_cmprof_copy(jas_cmprof_t *prof);