vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

jas_cm.h (8102B)


      1 /*
      2  * Copyright (c) 2002-2003 Michael David Adams.
      3  * All rights reserved.
      4  */
      5 
      6 /* __START_OF_JASPER_LICENSE__
      7  * 
      8  * JasPer License Version 2.0
      9  * 
     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
     13  * 
     14  * All rights reserved.
     15  * 
     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:
     23  * 
     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.
     27  * 
     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
     30  * written permission.
     31  * 
     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.
     58  * 
     59  * __END_OF_JASPER_LICENSE__
     60  */
     61 
     62 /*
     63  * Color Management
     64  *
     65  * $Id: jas_cm.h 1918 2005-07-24 14:12:08Z baford $
     66  */
     67 
     68 #ifndef JAS_CM_H
     69 #define JAS_CM_H
     70 
     71 #include <jasper/jas_config.h>
     72 #include <jasper/jas_icc.h>
     73 
     74 #ifdef __cplusplus
     75 extern "C" {
     76 #endif
     77 
     78 typedef int jas_clrspc_t;
     79 
     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
     85 
     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
     92 
     93 #define	JAS_CMXFORM_OPTM_SPEED	0
     94 #define JAS_CMXFORM_OPTM_SIZE	1
     95 #define	JAS_CMXFORM_OPTM_ACC	2
     96 
     97 
     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)
    103 
    104 #define	JAS_CLRSPC_UNKNOWNMASK	0x4000
    105 
    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
    113 
    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)
    121 
    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)
    126 
    127 #define	JAS_CLRSPC_CHANIND_YCBCR_Y	0
    128 #define	JAS_CLRSPC_CHANIND_YCBCR_CB	1
    129 #define	JAS_CLRSPC_CHANIND_YCBCR_CR	2
    130 
    131 #define	JAS_CLRSPC_CHANIND_RGB_R	0
    132 #define	JAS_CLRSPC_CHANIND_RGB_G	1
    133 #define	JAS_CLRSPC_CHANIND_RGB_B	2
    134 
    135 #define	JAS_CLRSPC_CHANIND_GRAY_Y	0
    136 
    137 typedef double jas_cmreal_t;
    138 
    139 struct jas_cmpxform_s;
    140 
    141 typedef struct {
    142 	long *buf;
    143 	int prec;
    144 	int sgnd;
    145 	int width;
    146 	int height;
    147 } jas_cmcmptfmt_t;
    148 
    149 typedef struct {
    150 	int numcmpts;
    151 	jas_cmcmptfmt_t *cmptfmts;
    152 } jas_cmpixmap_t;
    153 
    154 typedef struct {
    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);
    158 } jas_cmpxformops_t;
    159 
    160 typedef struct {
    161 	jas_cmreal_t *data;
    162 	int size;
    163 } jas_cmshapmatlut_t;
    164 
    165 typedef struct {
    166 	int mono;
    167 	int order;
    168 	int useluts;
    169 	int usemat;
    170 	jas_cmshapmatlut_t luts[3];
    171 	jas_cmreal_t mat[3][4];
    172 } jas_cmshapmat_t;
    173 
    174 typedef struct {
    175 	int order;
    176 } jas_cmshaplut_t;
    177 
    178 typedef struct {
    179 	int inclrspc;
    180 	int outclrspc;
    181 } jas_cmclrspcconv_t;
    182 
    183 #define	jas_align_t	double
    184 
    185 typedef struct jas_cmpxform_s {
    186 	int refcnt;
    187 	jas_cmpxformops_t *ops;
    188 	int numinchans;
    189 	int numoutchans;
    190 	union {
    191 		jas_align_t dummy;
    192 		jas_cmshapmat_t shapmat;
    193 		jas_cmshaplut_t shaplut;
    194 		jas_cmclrspcconv_t clrspcconv;
    195 	} data;
    196 } jas_cmpxform_t;
    197 
    198 typedef struct {
    199 	int numpxforms;
    200 	int maxpxforms;
    201 	jas_cmpxform_t **pxforms;
    202 } jas_cmpxformseq_t;
    203 
    204 typedef struct {
    205 	int numinchans;
    206 	int numoutchans;
    207 	jas_cmpxformseq_t *pxformseq;
    208 } jas_cmxform_t;
    209 
    210 #define	JAS_CMPROF_TYPE_DEV	1
    211 #define	JAS_CMPROF_TYPE_CLRSPC	2
    212 
    213 #define	JAS_CMPROF_NUMPXFORMSEQS	13
    214 
    215 typedef struct {
    216 	int clrspc;
    217 	int numchans;
    218 	int refclrspc;
    219 	int numrefchans;
    220 	jas_iccprof_t *iccprof;
    221 	jas_cmpxformseq_t *pxformseqs[JAS_CMPROF_NUMPXFORMSEQS];
    222 } jas_cmprof_t;
    223 
    224 /* Create a profile. */
    225 
    226 /* Destroy a profile. */
    227 void jas_cmprof_destroy(jas_cmprof_t *prof);
    228 
    229 #if 0
    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);
    241 #endif
    242 
    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);
    245 
    246 void jas_cmxform_destroy(jas_cmxform_t *xform);
    247 
    248 /* Apply a transform to data. */
    249 int jas_cmxform_apply(jas_cmxform_t *xform, jas_cmpixmap_t *in,
    250   jas_cmpixmap_t *out);
    251 
    252 int jas_cxform_optimize(jas_cmxform_t *xform, int optimize);
    253 
    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);
    258 
    259 #define	jas_cmprof_clrspc(prof) ((prof)->clrspc)
    260 jas_cmprof_t *jas_cmprof_copy(jas_cmprof_t *prof);
    261 
    262 #ifdef __cplusplus
    263 }
    264 #endif
    265 
    266 #endif