From c0b89ac5bfb90835ef01573267020e42d4fe070c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 23 Aug 2015 12:17:05 +0200 Subject: Imported Upstream version 1.8.0 --- icc/ClayRGB1998.icm | Bin icc/EBU3213_PAL.icm | Bin icc/Jamfile | 0 icc/License.txt | 0 icc/Makefile | 0 icc/Makefile.IBMNT | 0 icc/Makefile.OSX | 0 icc/Makefile.UNIX | 0 icc/Makefile.WNT | 0 icc/ProPhoto.icm | Bin icc/ProPhotoLin.icm | Bin icc/Readme.txt | 0 icc/Rec2020.icm | Bin icc/Rec709.icm | Bin icc/SMPTE431_P3.icm | Bin icc/SMPTE_RP145_NTSC.icm | Bin icc/afiles | 0 icc/icc.c | 217 +++++++++++++++++++++++++++++------------------ icc/icc.h | 20 +++-- icc/iccV42.h | 4 +- icc/iccdump.c | 0 icc/icclu.c | 0 icc/iccrw.c | 0 icc/iccstd.c | 19 +++++ icc/icctest.c | 2 +- icc/lab2lab.icm | Bin icc/log.txt | 0 icc/lutest.c | 0 icc/mcheck.c | 0 icc/mkDispProf.c | 0 icc/sRGB.icm | Bin icc/testDE2K.c | 0 icc/todo.txt | 0 33 files changed, 172 insertions(+), 90 deletions(-) mode change 100644 => 100755 icc/ClayRGB1998.icm mode change 100644 => 100755 icc/EBU3213_PAL.icm mode change 100644 => 100755 icc/Jamfile mode change 100644 => 100755 icc/License.txt mode change 100644 => 100755 icc/Makefile mode change 100644 => 100755 icc/Makefile.IBMNT mode change 100644 => 100755 icc/Makefile.OSX mode change 100644 => 100755 icc/Makefile.UNIX mode change 100644 => 100755 icc/Makefile.WNT mode change 100644 => 100755 icc/ProPhoto.icm mode change 100644 => 100755 icc/ProPhotoLin.icm mode change 100644 => 100755 icc/Readme.txt mode change 100644 => 100755 icc/Rec2020.icm mode change 100644 => 100755 icc/Rec709.icm mode change 100644 => 100755 icc/SMPTE431_P3.icm mode change 100644 => 100755 icc/SMPTE_RP145_NTSC.icm mode change 100644 => 100755 icc/afiles mode change 100644 => 100755 icc/icc.c mode change 100644 => 100755 icc/icc.h mode change 100644 => 100755 icc/iccV42.h mode change 100644 => 100755 icc/iccdump.c mode change 100644 => 100755 icc/icclu.c mode change 100644 => 100755 icc/iccrw.c mode change 100644 => 100755 icc/iccstd.c mode change 100644 => 100755 icc/icctest.c mode change 100644 => 100755 icc/lab2lab.icm mode change 100644 => 100755 icc/log.txt mode change 100644 => 100755 icc/lutest.c mode change 100644 => 100755 icc/mcheck.c mode change 100644 => 100755 icc/mkDispProf.c mode change 100644 => 100755 icc/sRGB.icm mode change 100644 => 100755 icc/testDE2K.c mode change 100644 => 100755 icc/todo.txt (limited to 'icc') diff --git a/icc/ClayRGB1998.icm b/icc/ClayRGB1998.icm old mode 100644 new mode 100755 diff --git a/icc/EBU3213_PAL.icm b/icc/EBU3213_PAL.icm old mode 100644 new mode 100755 diff --git a/icc/Jamfile b/icc/Jamfile old mode 100644 new mode 100755 diff --git a/icc/License.txt b/icc/License.txt old mode 100644 new mode 100755 diff --git a/icc/Makefile b/icc/Makefile old mode 100644 new mode 100755 diff --git a/icc/Makefile.IBMNT b/icc/Makefile.IBMNT old mode 100644 new mode 100755 diff --git a/icc/Makefile.OSX b/icc/Makefile.OSX old mode 100644 new mode 100755 diff --git a/icc/Makefile.UNIX b/icc/Makefile.UNIX old mode 100644 new mode 100755 diff --git a/icc/Makefile.WNT b/icc/Makefile.WNT old mode 100644 new mode 100755 diff --git a/icc/ProPhoto.icm b/icc/ProPhoto.icm old mode 100644 new mode 100755 diff --git a/icc/ProPhotoLin.icm b/icc/ProPhotoLin.icm old mode 100644 new mode 100755 diff --git a/icc/Readme.txt b/icc/Readme.txt old mode 100644 new mode 100755 diff --git a/icc/Rec2020.icm b/icc/Rec2020.icm old mode 100644 new mode 100755 diff --git a/icc/Rec709.icm b/icc/Rec709.icm old mode 100644 new mode 100755 diff --git a/icc/SMPTE431_P3.icm b/icc/SMPTE431_P3.icm old mode 100644 new mode 100755 diff --git a/icc/SMPTE_RP145_NTSC.icm b/icc/SMPTE_RP145_NTSC.icm old mode 100644 new mode 100755 diff --git a/icc/afiles b/icc/afiles old mode 100644 new mode 100755 diff --git a/icc/icc.c b/icc/icc.c old mode 100644 new mode 100755 index 87ce500..92611c3 --- a/icc/icc.c +++ b/icc/icc.c @@ -74,7 +74,7 @@ #endif #include "icc.h" -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(vsnprintf) #define vsnprintf _vsnprintf #define snprintf _snprintf #endif @@ -11801,7 +11801,7 @@ static int icc_check_id( return 1; } - if ((md5 = new_icmMD5(p->al)) == NULL) { + if ((md5 = new_icmMD5_a(p->al)) == NULL) { sprintf(p->err,"icc_check_id: new_icmMD5 failed"); return p->errc = 3; } @@ -11855,84 +11855,11 @@ static int icc_check_id( return 2; /* Didn't match */ } -/* Return the total size needed for the profile */ -/* Return 0 on error. */ -static unsigned int icc_get_size( - icc *p -) { - unsigned int i, size = 0; - -#ifdef ICM_STRICT - /* Check that the right tags etc. are present for a legal ICC profile */ - if (check_icc_legal(p) != 0) { - return 0; - } -#endif /* ICM_STRICT */ - - /* Compute the total size and tag element data offsets */ - if (p->header == NULL) { - sprintf(p->err,"icc_get_size: No header defined"); - p->errc = 1; - return 0; - } - - size = sat_add(size, p->header->get_size(p->header)); - /* Assume header is aligned */ - size = sat_addaddmul(size, 4, p->count, 12); /* Tag table length */ - size = sat_align(ALIGN_SIZE, size); - - if (size == UINT_MAX) { - sprintf(p->err,"icc_get_size: size overflow"); - return p->errc = 1; - } - - /* Reset touched flag for each tag type */ - for (i = 0; i < p->count; i++) { - if (p->data[i].objp == NULL) { - sprintf(p->err,"icc_get_size: Internal error - NULL tag element"); - p->errc = 1; - return 0; - } - p->data[i].objp->touched = 0; - } - /* Get size for each tag type, skipping links */ - for (i = 0; i < p->count; i++) { - if (p->data[i].objp->touched == 0) { /* Not alllowed for previously */ - size = sat_add(size, p->data[i].objp->get_size(p->data[i].objp)); - size = sat_align(ALIGN_SIZE, size); - p->data[i].objp->touched = 1; /* Don't account for this again */ - } - } - - return size; /* Total size needed, or UINT_MAX if overflow */ -} - void quantize3x3S15Fixed16(double targ[3], double mat[3][3], double in[3]); -/* Write the contents of the object. Return 0 on sucess, error code on failure */ -/* NOTE: fp ownership is taken even if the function fails. */ -static int icc_write_x( - icc *p, - icmFile *fp, /* File to write to */ - unsigned int of, /* File offset to write to */ - int take_fp /* NZ if icc is to take ownership of fp */ -) { - char *bp, *buf; /* tag table buffer */ - unsigned int len; - int rv = 0; - unsigned int i, size = 0; - unsigned char pbuf[ALIGN_SIZE]; - - p->fp = fp; /* Open file pointer */ - if (take_fp) - p->del_fp = 1; - p->of = of; /* Offset of ICC profile */ - - /* Compute the total size and tag element data offsets */ - if (p->header == NULL) { - sprintf(p->err,"icc_write: No header defined"); - return p->errc = 1; - } +/* Add any automatically created tags. */ +/* (Hmm. Should we remove them if they shouldn't be there ?) */ +static int icc_add_auto_tags(icc *p) { /* If we're using the ArgyllCMS 'arts' tag to record the chromatic */ /* adapation cone matrix used for the Media Relative WP Transformation, */ @@ -11940,6 +11867,7 @@ static int icc_write_x( /* Don't write it if there is to 'wtpt' tag (i.e. it's a device link) */ if (p->useArts && p->find_tag(p, icSigMediaWhitePointTag) == 0) { + int rv; icmS15Fixed16Array *artsTag; /* Make sure no 'arts' tag currently exists */ @@ -11981,6 +11909,7 @@ static int icc_write_x( /* ICCV4 style, then set the media white point tag to D50 and save */ /* the chromatic adapation matrix to the 'chad' tag. */ { + int rv; icmXYZArray *whitePointTag; icmS15Fixed16Array *chadTag; @@ -12035,6 +11964,94 @@ static int icc_write_x( whitePointTag->data[0] = icmD50; } } + return 0; +} + +/* Return the total size needed for the profile. */ +/* This will add any automatic tags such as 'arts' tag, */ +/* so the current information needs to be final enough */ +/* for the automatic tag creation to be correct. */ +/* Return 0 on error. */ +static unsigned int icc_get_size( + icc *p +) { + unsigned int i, size = 0; + + /* Ignore any errors this time */ + icc_add_auto_tags(p); + +#ifdef ICM_STRICT + /* Check that the right tags etc. are present for a legal ICC profile */ + if (check_icc_legal(p) != 0) { + return 0; + } +#endif /* ICM_STRICT */ + + /* Compute the total size and tag element data offsets */ + if (p->header == NULL) { + sprintf(p->err,"icc_get_size: No header defined"); + p->errc = 1; + return 0; + } + + size = sat_add(size, p->header->get_size(p->header)); + /* Assume header is aligned */ + size = sat_addaddmul(size, 4, p->count, 12); /* Tag table length */ + size = sat_align(ALIGN_SIZE, size); + + if (size == UINT_MAX) { + sprintf(p->err,"icc_get_size: size overflow"); + return p->errc = 1; + } + + /* Reset touched flag for each tag type */ + for (i = 0; i < p->count; i++) { + if (p->data[i].objp == NULL) { + sprintf(p->err,"icc_get_size: Internal error - NULL tag element"); + p->errc = 1; + return 0; + } + p->data[i].objp->touched = 0; + } + /* Get size for each tag type, skipping links */ + for (i = 0; i < p->count; i++) { + if (p->data[i].objp->touched == 0) { /* Not alllowed for previously */ + size = sat_add(size, p->data[i].objp->get_size(p->data[i].objp)); + size = sat_align(ALIGN_SIZE, size); + p->data[i].objp->touched = 1; /* Don't account for this again */ + } + } + + return size; /* Total size needed, or UINT_MAX if overflow */ +} + +/* Write the contents of the object. Return 0 on sucess, error code on failure */ +/* NOTE: fp ownership is taken even if the function fails. */ +static int icc_write_x( + icc *p, + icmFile *fp, /* File to write to */ + unsigned int of, /* File offset to write to */ + int take_fp /* NZ if icc is to take ownership of fp */ +) { + char *bp, *buf; /* tag table buffer */ + unsigned int len; + int rv = 0; + unsigned int i, size = 0; + unsigned char pbuf[ALIGN_SIZE]; + + if ((rv = icc_add_auto_tags(p)) != 0) + return rv; + + p->fp = fp; /* Open file pointer */ + if (take_fp) + p->del_fp = 1; + p->of = of; /* Offset of ICC profile */ + + /* Compute the total size and tag element data offsets */ + if (p->header == NULL) { + sprintf(p->err,"icc_write: No header defined"); + return p->errc = 1; + } /* Check that the right tags etc. are present for a legal ICC profile */ if ((rv = check_icc_legal(p)) != 0) { @@ -12132,7 +12149,7 @@ static int icc_write_x( icmMD5 *md5 = NULL; icmFile *ofp, *dfp = NULL; - if ((md5 = new_icmMD5(p->al)) == NULL) { + if ((md5 = new_icmMD5_a(p->al)) == NULL) { sprintf(p->err,"icc_write: new_icmMD5 failed"); p->al->free(p->al, buf); return p->errc = 2; @@ -13747,7 +13764,7 @@ void icmScale33(double out[3], double in1[3], double in0[3], double rat) { out[2] = in0[2] + (in1[2] - in0[2]) * rat; } -/* Normalise a two point vector to the given length. */ +/* Normalise a vector from 0->1 to the given length. */ /* The new location of in1[] is returned in out[]. */ /* Return nz if not normalisable */ int icmNormalize33(double out[3], double in1[3], double in0[3], double len) { @@ -13963,6 +13980,35 @@ double ve_0[3] /* Second point on line */ return 0; } +/* - - - - - - - - - - - - - - - - - - - - - - - - */ +/* Compute the closest point on a line to a point. */ +/* Return closest point and parameter value if not NULL. */ +/* Return nz if the line length is zero */ +int icmLinePointClosest(double cp[3], double *pa, + double la0[3], double la1[3], double pp[3]) { + double va[3], vp[3]; + double val; /* Vector length */ + double a; /* Parameter value */ + + icmSub3(va, la1, la0); /* Line vector */ + val = icmNorm3(va); /* Vector length */ + + if (val < 1e-12) + return 1; + + icmSub3(vp, pp, la0); /* Point vector to line base */ + + a = icmDot3(vp, va) / val; /* Normalised dist of point projected onto line */ + + if (cp != NULL) + icmBlend3(cp, la0, la1, a); + + if (pa != NULL) + *pa = a; + + return 0; +} + /* - - - - - - - - - - - - - - - - - - - - - - - - */ /* Compute the closest points between two lines a and b. */ /* Return closest points and parameter values if not NULL. */ @@ -15909,12 +15955,19 @@ static void icmMD5_get(icmMD5 *p, ORD8 chsum[16]) { /* Delete the instance */ static void icmMD5_del(icmMD5 *p) { - p->al->free(p->al, p); + icmAlloc *al = p->al; + int del_al = p->del_al; + + /* This object */ + al->free(al, p); + + if (del_al) /* We are responsible for deleting allocator */ + al->del(al); } /* Create a new MD5 checksumming object, with a reset checksum value */ /* Return it or NULL if there is an error */ -icmMD5 *new_icmMD5(icmAlloc *al) { +icmMD5 *new_icmMD5_a(icmAlloc *al) { icmMD5 *p; if ((p = (icmMD5 *)al->calloc(al,1,sizeof(icmMD5))) == NULL) diff --git a/icc/icc.h b/icc/icc.h old mode 100644 new mode 100755 index 8f90d26..4eba0ec --- a/icc/icc.h +++ b/icc/icc.h @@ -119,6 +119,7 @@ #define PNTR UINT_PTR #define vsnprintf _vsnprintf +#define snprintf _snprintf #define PF64PREC "I64" /* printf format precision specifier */ #define CF64PREC "LL" /* Constant precision specifier */ @@ -1466,6 +1467,7 @@ struct _icc { int (*set_version)(struct _icc *p, icmICCVersion ver); /* For creation, use ICC V4 etc. */ unsigned int (*get_size)(struct _icc *p); /* Return total size needed, 0 = err. */ + /* Will add auto tags ('arts' etc.) */ int (*read)(struct _icc *p, icmFile *fp, unsigned int of); /* Returns error code */ int (*read_x)(struct _icc *p, icmFile *fp, unsigned int of, int take_fp); int (*write)(struct _icc *p, icmFile *fp, unsigned int of);/* Returns error code */ @@ -1627,6 +1629,7 @@ struct _icmMD5 { /* Private: */ // icc *icp; /* ICC we're part of */ icmAlloc *al; /* Heap allocator */ + int del_al; /* NZ if heap allocator should be deleted */ int fin; /* Flag, nz if final has been called */ ORD32 sum[4]; /* Current/final checksum */ unsigned int tlen; /* Total length added in bytes */ @@ -1641,9 +1644,11 @@ struct _icmMD5 { }; typedef struct _icmMD5 icmMD5; /* Create a new MD5 checksumming object, with a reset checksum value */ -/* Return it or NULL if there is an error */ -icmMD5 *new_icmMD5(icmAlloc *al); +/* Return it or NULL if there is an error. */ +extern ICCLIB_API icmMD5 *new_icmMD5_a(icmAlloc *al); +/* If SEPARATE_STD not defined: */ +extern ICCLIB_API icmMD5 *new_icmMD5(void); /* Implementation of file access class to compute an MD5 checksum */ struct _icmFileMD5 { @@ -1787,10 +1792,10 @@ double icmNorm33sq(double in1[3], double in0[3]); /* Compute the norm (length) of of a vector defined by two points */ double icmNorm33(double in1[3], double in0[3]); -/* Scale a two point vector by the given ratio. in0[] is the origin. */ +/* Scale a vector from 0->1 by the given ratio. in0[] is the origin. */ void icmScale33(double out[3], double in1[3], double in0[3], double rat); -/* Normalise a two point vector to the given length. */ +/* Normalise a vector from 0->1 to the given length. */ /* The new location of in1[] is returned in out[], in0[] is the origin. */ /* Return nz if not normalisable */ int icmNormalize33(double out[3], double in1[3], double in0[3], double len); @@ -1855,9 +1860,14 @@ void icmVecRotMat(double m[3][4], double s1[3], double s0[3], double t1[3], doub /* return nz if there is no intersection */ int icmVecPlaneIsect(double isect[3], double pl_const, double pl_norm[3], double ve_1[3], double ve_0[3]); +/* Compute the closest point on a line to a point. */ +/* Return closest points and parameter values if not NULL. */ +int icmLinePointClosest(double ca[3], double *pa, + double la0[3], double la1[3], double pp[3]); + /* Compute the closest points between two lines a and b. */ /* Return closest points and parameter values if not NULL. */ -/* Return nz if they are paralel. */ +/* Return nz if they are parallel. */ int icmLineLineClosest(double ca[3], double cb[3], double *pa, double *pb, double la0[3], double la1[3], double lb0[3], double lb1[3]); diff --git a/icc/iccV42.h b/icc/iccV42.h old mode 100644 new mode 100755 index ee3fefb..2f3ec27 --- a/icc/iccV42.h +++ b/icc/iccV42.h @@ -223,7 +223,7 @@ typedef enum { icSigNamedColorTag = 0x6E636f6CL, /* 'ncol' V2.0 */ icSigNamedColor2Tag = 0x6E636C32L, /* 'ncl2' V2.1+ */ icSigOutputResponseTag = 0x72657370L, /* 'resp' V2.2+ */ - icSigPerceptualRenderingIntentGamutTag = 0x72696730L, /* 'rig0' ??? */ + icSigPerceptualRenderingIntentGamutTag = 0x72696730L, /* 'rig0' V4.3+ */ icSigPreview0Tag = 0x70726530L, /* 'pre0' */ icSigPreview1Tag = 0x70726531L, /* 'pre1' */ icSigPreview2Tag = 0x70726532L, /* 'pre2' */ @@ -385,7 +385,7 @@ typedef enum { /* Rendering Intent Gamut Signatures */ typedef enum { - icSigPerceptualReferenceMediumGamut = 0x70726d67L, /* 'prmg' */ + icSigPerceptualReferenceMediumGamut = 0x70726d67L, /* 'prmg' V4.3+ */ icMaxEnumReferenceMediumGamut = icMaxTagVal } icReferenceMediumGamutSignature; diff --git a/icc/iccdump.c b/icc/iccdump.c old mode 100644 new mode 100755 diff --git a/icc/icclu.c b/icc/icclu.c old mode 100644 new mode 100755 diff --git a/icc/iccrw.c b/icc/iccrw.c old mode 100644 new mode 100755 diff --git a/icc/iccstd.c b/icc/iccstd.c old mode 100644 new mode 100755 index 3f7966e..1cb63eb --- a/icc/iccstd.c +++ b/icc/iccstd.c @@ -440,5 +440,24 @@ icc *new_icc(void) { return p; } +/* ------------------------------------------------- */ + +/* Create an icmMD5 with the std allocator */ +icmMD5 *new_icmMD5(void) { + icmMD5 *p; + icmAlloc *al; /* memory allocator */ + + if ((al = new_icmAllocStd()) == NULL) + return NULL; + + if ((p = new_icmMD5_a(al)) == NULL) { + al->del(al); + return NULL; + } + + p->del_al = 1; /* Get md5->del to cleanup allocator */ + return p; +} + #endif /* defined(SEPARATE_STD) || defined(COMBINED_STD) */ diff --git a/icc/icctest.c b/icc/icctest.c old mode 100644 new mode 100755 index f0b1280..d04cc1e --- a/icc/icctest.c +++ b/icc/icctest.c @@ -236,7 +236,7 @@ int md5_test() { if ((icco = new_icc()) == NULL) error ("Creation of ICC object failed"); - m = new_icmMD5(icco->al); + m = new_icmMD5_a(icco->al); for (i = 0; ; i++) { if (tc[i].s == NULL) diff --git a/icc/lab2lab.icm b/icc/lab2lab.icm old mode 100644 new mode 100755 diff --git a/icc/log.txt b/icc/log.txt old mode 100644 new mode 100755 diff --git a/icc/lutest.c b/icc/lutest.c old mode 100644 new mode 100755 diff --git a/icc/mcheck.c b/icc/mcheck.c old mode 100644 new mode 100755 diff --git a/icc/mkDispProf.c b/icc/mkDispProf.c old mode 100644 new mode 100755 diff --git a/icc/sRGB.icm b/icc/sRGB.icm old mode 100644 new mode 100755 diff --git a/icc/testDE2K.c b/icc/testDE2K.c old mode 100644 new mode 100755 diff --git a/icc/todo.txt b/icc/todo.txt old mode 100644 new mode 100755 -- cgit v1.2.3