Path: blob/master/3rdparty/libjasper/jasper/jas_cm.h
16337 views
/*1* Copyright (c) 2002-2003 Michael David Adams.2* All rights reserved.3*/45/* __START_OF_JASPER_LICENSE__6*7* JasPer License Version 2.08*9* Copyright (c) 2001-2006 Michael David Adams10* Copyright (c) 1999-2000 Image Power, Inc.11* Copyright (c) 1999-2000 The University of British Columbia12*13* All rights reserved.14*15* Permission is hereby granted, free of charge, to any person (the16* "User") obtaining a copy of this software and associated documentation17* files (the "Software"), to deal in the Software without restriction,18* including without limitation the rights to use, copy, modify, merge,19* publish, distribute, and/or sell copies of the Software, and to permit20* persons to whom the Software is furnished to do so, subject to the21* following conditions:22*23* 1. The above copyright notices and this permission notice (which24* includes the disclaimer below) shall be included in all copies or25* substantial portions of the Software.26*27* 2. The name of a copyright holder shall not be used to endorse or28* promote products derived from the Software without specific prior29* written permission.30*31* THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS32* LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER33* THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS34* "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING35* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A36* PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO37* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL38* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING39* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,40* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION41* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE42* PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE43* THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.44* EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS45* BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL46* PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS47* GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE48* ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE49* IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL50* SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,51* AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL52* SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH53* THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,54* PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH55* RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY56* EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.57*58* __END_OF_JASPER_LICENSE__59*/6061/*62* Color Management63*64* $Id: jas_cm.h,v 1.2 2008-05-26 09:41:51 vp153 Exp $65*/6667#ifndef JAS_CM_H68#define JAS_CM_H6970#include <jasper/jas_config.h>71#include <jasper/jas_icc.h>7273#ifdef __cplusplus74extern "C" {75#endif7677typedef int jas_clrspc_t;7879/* transform operations */80#define JAS_CMXFORM_OP_FWD 081#define JAS_CMXFORM_OP_REV 182#define JAS_CMXFORM_OP_PROOF 283#define JAS_CMXFORM_OP_GAMUT 38485/* rendering intents */86#define JAS_CMXFORM_INTENT_PER 087#define JAS_CMXFORM_INTENT_RELCLR 188#define JAS_CMXFORM_INTENT_ABSCLR 289#define JAS_CMXFORM_INTENT_SAT 390#define JAS_CMXFORM_NUMINTENTS 49192#define JAS_CMXFORM_OPTM_SPEED 093#define JAS_CMXFORM_OPTM_SIZE 194#define JAS_CMXFORM_OPTM_ACC 2959697#define jas_clrspc_create(fam, mbr) (((fam) << 8) | (mbr))98#define jas_clrspc_fam(clrspc) ((clrspc) >> 8)99#define jas_clrspc_mbr(clrspc) ((clrspc) & 0xff)100#define jas_clrspc_isgeneric(clrspc) (!jas_clrspc_mbr(clrspc))101#define jas_clrspc_isunknown(clrspc) ((clrspc) & JAS_CLRSPC_UNKNOWNMASK)102103#define JAS_CLRSPC_UNKNOWNMASK 0x4000104105/* color space families */106#define JAS_CLRSPC_FAM_UNKNOWN 0107#define JAS_CLRSPC_FAM_XYZ 1108#define JAS_CLRSPC_FAM_LAB 2109#define JAS_CLRSPC_FAM_GRAY 3110#define JAS_CLRSPC_FAM_RGB 4111#define JAS_CLRSPC_FAM_YCBCR 5112113/* specific color spaces */114#define JAS_CLRSPC_UNKNOWN JAS_CLRSPC_UNKNOWNMASK115#define JAS_CLRSPC_CIEXYZ jas_clrspc_create(JAS_CLRSPC_FAM_XYZ, 1)116#define JAS_CLRSPC_CIELAB jas_clrspc_create(JAS_CLRSPC_FAM_LAB, 1)117#define JAS_CLRSPC_SGRAY jas_clrspc_create(JAS_CLRSPC_FAM_GRAY, 1)118#define JAS_CLRSPC_SRGB jas_clrspc_create(JAS_CLRSPC_FAM_RGB, 1)119#define JAS_CLRSPC_SYCBCR jas_clrspc_create(JAS_CLRSPC_FAM_YCBCR, 1)120121/* generic color spaces */122#define JAS_CLRSPC_GENRGB jas_clrspc_create(JAS_CLRSPC_FAM_RGB, 0)123#define JAS_CLRSPC_GENGRAY jas_clrspc_create(JAS_CLRSPC_FAM_GRAY, 0)124#define JAS_CLRSPC_GENYCBCR jas_clrspc_create(JAS_CLRSPC_FAM_YCBCR, 0)125126#define JAS_CLRSPC_CHANIND_YCBCR_Y 0127#define JAS_CLRSPC_CHANIND_YCBCR_CB 1128#define JAS_CLRSPC_CHANIND_YCBCR_CR 2129130#define JAS_CLRSPC_CHANIND_RGB_R 0131#define JAS_CLRSPC_CHANIND_RGB_G 1132#define JAS_CLRSPC_CHANIND_RGB_B 2133134#define JAS_CLRSPC_CHANIND_GRAY_Y 0135136typedef double jas_cmreal_t;137138struct jas_cmpxform_s;139140typedef struct {141long *buf;142int prec;143int sgnd;144int width;145int height;146} jas_cmcmptfmt_t;147148typedef struct {149int numcmpts;150jas_cmcmptfmt_t *cmptfmts;151} jas_cmpixmap_t;152153typedef struct {154void (*destroy)(struct jas_cmpxform_s *pxform);155int (*apply)(struct jas_cmpxform_s *pxform, jas_cmreal_t *in, jas_cmreal_t *out, int cnt);156void (*dump)(struct jas_cmpxform_s *pxform);157} jas_cmpxformops_t;158159typedef struct {160jas_cmreal_t *data;161int size;162} jas_cmshapmatlut_t;163164typedef struct {165int mono;166int order;167int useluts;168int usemat;169jas_cmshapmatlut_t luts[3];170jas_cmreal_t mat[3][4];171} jas_cmshapmat_t;172173typedef struct {174int order;175} jas_cmshaplut_t;176177typedef struct {178int inclrspc;179int outclrspc;180} jas_cmclrspcconv_t;181182#define jas_align_t double183184typedef struct jas_cmpxform_s {185int refcnt;186jas_cmpxformops_t *ops;187int numinchans;188int numoutchans;189union {190jas_align_t dummy;191jas_cmshapmat_t shapmat;192jas_cmshaplut_t shaplut;193jas_cmclrspcconv_t clrspcconv;194} data;195} jas_cmpxform_t;196197typedef struct {198int numpxforms;199int maxpxforms;200jas_cmpxform_t **pxforms;201} jas_cmpxformseq_t;202203typedef struct {204int numinchans;205int numoutchans;206jas_cmpxformseq_t *pxformseq;207} jas_cmxform_t;208209#define JAS_CMPROF_TYPE_DEV 1210#define JAS_CMPROF_TYPE_CLRSPC 2211212#define JAS_CMPROF_NUMPXFORMSEQS 13213214typedef struct {215int clrspc;216int numchans;217int refclrspc;218int numrefchans;219jas_iccprof_t *iccprof;220jas_cmpxformseq_t *pxformseqs[JAS_CMPROF_NUMPXFORMSEQS];221} jas_cmprof_t;222223/* Create a profile. */224225/* Destroy a profile. */226void jas_cmprof_destroy(jas_cmprof_t *prof);227228#if 0229typedef int_fast32_t jas_cmattrname_t;230typedef int_fast32_t jas_cmattrval_t;231typedef int_fast32_t jas_cmattrtype_t;232/* Load a profile. */233int jas_cmprof_load(jas_cmprof_t *prof, jas_stream_t *in, int fmt);234/* Save a profile. */235int jas_cmprof_save(jas_cmprof_t *prof, jas_stream_t *out, int fmt);236/* Set an attribute of a profile. */237int jas_cm_prof_setattr(jas_cm_prof_t *prof, jas_cm_attrname_t name, void *val);238/* Get an attribute of a profile. */239void *jas_cm_prof_getattr(jas_cm_prof_t *prof, jas_cm_attrname_t name);240#endif241242jas_cmxform_t *jas_cmxform_create(jas_cmprof_t *inprof, jas_cmprof_t *outprof,243jas_cmprof_t *proofprof, int op, int intent, int optimize);244245void jas_cmxform_destroy(jas_cmxform_t *xform);246247/* Apply a transform to data. */248int jas_cmxform_apply(jas_cmxform_t *xform, jas_cmpixmap_t *in,249jas_cmpixmap_t *out);250251int jas_cxform_optimize(jas_cmxform_t *xform, int optimize);252253int jas_clrspc_numchans(int clrspc);254jas_cmprof_t *jas_cmprof_createfromiccprof(jas_iccprof_t *iccprof);255jas_cmprof_t *jas_cmprof_createfromclrspc(int clrspc);256jas_iccprof_t *jas_iccprof_createfromcmprof(jas_cmprof_t *prof);257258#define jas_cmprof_clrspc(prof) ((prof)->clrspc)259jas_cmprof_t *jas_cmprof_copy(jas_cmprof_t *prof);260261#ifdef __cplusplus262}263#endif264265#endif266267268